Adding task for like-sign bkg for D0->Kpi (Carmelo)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / RunAnalysisAODVertexingHF.C
CommitLineData
1a6db1e0 1class AliAnalysisGrid;\r
2\r
32bb35a1 3void RunAnalysisAODVertexingHF()\r
4{\r
5 //\r
6 // Test macro for AliAnalysisTaskSE's for heavy-flavour candidates\r
7 // It has the structure of a Analysis Train:\r
8 // - in this macro, change things related to running mode\r
9 // and input preparation \r
10 // - add your task using a AddTaskXXX macro \r
11 //\r
12 // A.Dainese, andrea.dainese@lnl.infn.it\r
13 // "grid" mode added by R.Bala, bala@to.infn.it\r
14 //\r
15\r
1a6db1e0 16 //\r
75ff3310 17 TString analysisMode = "grid"; // "local", "grid", or "proof" (not yet)\r
1a6db1e0 18 TString inputMode = "list"; // "list", "xml", or "dataset" (not yet)\r
19 Long64_t nentries=1234567890,firstentry=0;\r
aabcfd8f 20 Bool_t useParFiles=kFALSE;\r
75ff3310 21 Bool_t useAlienPlugin=kTRUE;\r
22 TString pluginmode="test";\r
1a6db1e0 23 TString loadMacroPath="$ALICE_ROOT/PWG3/vertexingHF/";\r
24 //\r
32bb35a1 25\r
1a6db1e0 26 if(analysisMode=="grid") {\r
27 // Connect to AliEn\r
28 TGrid::Connect("alien://");\r
29 } else if(analysisMode=="proof") {\r
30 // Connect to the PROOF cluster\r
31 printf("PROOF mode not yet functional..\n");\r
32 return;\r
33 TProof::Open("alicecaf");\r
34 //TProof::Reset("alicecaf");\r
35 }\r
32bb35a1 36\r
32bb35a1 37\r
1a6db1e0 38 // AliRoot libraries\r
39 if(analysisMode=="local" || analysisMode=="grid") {\r
40 TString loadLibraries="LoadLibraries.C"; loadLibraries.Prepend(loadMacroPath.Data());\r
41 gROOT->LoadMacro(loadLibraries.Data());\r
42 LoadLibraries(useParFiles);\r
43 } else if (analysisMode=="proof") {\r
44 gSystem->Load("libTree.so");\r
45 gSystem->Load("libGeom.so");\r
46 gSystem->Load("libPhysics.so");\r
47 gSystem->Load("libVMC.so"); \r
48 // Enable the needed packages\r
49 //gProof->ClearPackages();\r
50 if(!useParFiles) {\r
51 gProof->UploadPackage("AF-v4-16");\r
52 gProof->EnablePackage("AF-v4-16");\r
53 } else {\r
54 TString parDir="/afs/cern.ch/user/d/dainesea/code/";\r
55 TString parFile;\r
56 // --- Enable the STEERBase Package\r
57 parFile="STEERBase.par"; parFile.Prepend(parDir.Data());\r
58 gProof->UploadPackage(parFile.Data());\r
59 gProof->EnablePackage("STEERBase");\r
60 // --- Enable the ESD Package\r
61 parFile="ESD.par"; parFile.Prepend(parDir.Data());\r
62 gProof->UploadPackage(parFile.Data());\r
63 gProof->EnablePackage("ESD");\r
64 // --- Enable the AOD Package\r
65 parFile="AOD.par"; parFile.Prepend(parDir.Data());\r
66 gProof->UploadPackage(parFile.Data());\r
67 gProof->EnablePackage("AOD");\r
68 // --- Enable the ANALYSIS Package\r
69 parFile="ANALYSIS.par"; parFile.Prepend(parDir.Data());\r
70 gProof->UploadPackage(parFile.Data());\r
71 gProof->EnablePackage("ANALYSIS");\r
72 // --- Enable the ANALYSISalice Package\r
73 parFile="ANALYSISalice.par"; parFile.Prepend(parDir.Data());\r
74 gProof->UploadPackage(parFile.Data());\r
75 gProof->EnablePackage("ANALYSISalice");\r
76 // --- Enable the CORRFW Package\r
77 parFile="CORRFW.par"; parFile.Prepend(parDir.Data());\r
78 gProof->UploadPackage(parFile.Data());\r
79 gProof->EnablePackage("CORRFW");\r
b093f071 80 // --- Enable the PWG3base Package\r
81 parFile="PWG3base.par"; parFile.Prepend(parDir.Data());\r
82 gProof->UploadPackage(parFile.Data());\r
83 gProof->EnablePackage("PWG3base");\r
1a6db1e0 84 // --- Enable the PWG3vertexingHF Package\r
85 parFile="PWG3vertexingHF.par"; parFile.Prepend(parDir.Data());\r
86 gProof->UploadPackage(parFile.Data());\r
87 gProof->EnablePackage("PWG3vertexingHF");\r
b093f071 88 // --- Enable the JETAN Package\r
89 parFile="JETAN.par"; parFile.Prepend(parDir.Data());\r
90 gProof->UploadPackage(parFile.Data());\r
91 gProof->EnablePackage("JETAN");\r
92 // --- Enable the PWG3muon Package\r
93 parFile="PWG3muon.par"; parFile.Prepend(parDir.Data());\r
94 gProof->UploadPackage(parFile.Data());\r
95 gProof->EnablePackage("PWG3muon");\r
96 // --- Enable the PWG4PartCorrBase Package\r
97 parFile="PWG4PartCorrBase.par"; parFile.Prepend(parDir.Data());\r
98 gProof->UploadPackage(parFile.Data());\r
99 gProof->EnablePackage("PWG4PartCorrBase");\r
100 // --- Enable the PWG4PartCorrDep Package\r
101 parFile="PWG4PartCorrDep.par"; parFile.Prepend(parDir.Data());\r
102 gProof->UploadPackage(parFile.Data());\r
103 gProof->EnablePackage("PWG4PartCorrDep");\r
1a6db1e0 104 }\r
105 gProof->ShowEnabledPackages(); // show a list of enabled packages\r
106 }\r
32bb35a1 107\r
108\r
1a6db1e0 109 // Create Alien plugin, if requested\r
110 if(useAlienPlugin) { \r
111 AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode,useParFiles); \r
112 if(!alienHandler) return;\r
113 }\r
32bb35a1 114\r
115\r
116 //-------------------------------------------------------------------\r
117 // Prepare input chain\r
118 TChain *chainAOD = 0;\r
1a6db1e0 119 TString dataset; // for proof\r
120\r
121 if(!useAlienPlugin) {\r
aabcfd8f 122 TString makeAODInputChain="MakeAODInputChain.C"; makeAODInputChain.Prepend(loadMacroPath.Data());\r
1a6db1e0 123 gROOT->LoadMacro(makeAODInputChain.Data());\r
124 if(inputMode=="list") {\r
125 // Local files\r
126 chainAOD = MakeAODInputChain();// with this it reads ./AliAOD.root and ./AliAOD.VertexingHF.root\r
aabcfd8f 127 //chainAOD = MakeAODInputChain("alien:///alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/180100/",1,1);\r
1a6db1e0 128 } else if(inputMode=="xml") {\r
129 // xml\r
130 chainAOD = MakeAODInputChain("collection_aod.xml","collection_aodHF.xml");\r
131 } else if(inputMode=="dataset") {\r
132 // CAF dataset\r
133 //gProof->ShowDataSet();\r
134 dataset="/ITS/dainesea/AODVertexingHF_LHC08x_180100_small";\r
135 chainAOD = MakeAODInputChainCAF(dataset.Data());\r
136 }\r
32bb35a1 137 }\r
138\r
139 // Create the analysis manager\r
140 AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager");\r
141 mgr->SetDebugLevel(10);\r
1a6db1e0 142 // Connect plug-in to the analysis manager\r
143 if(useAlienPlugin) mgr->SetGridHandler(alienHandler);\r
144\r
32bb35a1 145\r
146 // Input\r
147 AliAODInputHandler *inputHandler = new AliAODInputHandler();\r
148 mgr->SetInputEventHandler(inputHandler);\r
149 //-------------------------------------------------------------------\r
150\r
151 \r
152 //-------------------------------------------------------------------\r
1a6db1e0 153 // Analysis tasks (wagons of the train) \r
32bb35a1 154 //\r
1a6db1e0 155 TString taskName;\r
156\r
157 taskName="AddTaskCompareHF.C"; taskName.Prepend(loadMacroPath.Data());\r
158 gROOT->LoadMacro(taskName.Data());\r
32bb35a1 159 AliAnalysisTaskSECompareHF *cmpTask = AddTaskCompareHF();\r
a9f684f8 160\r
d486095a 161 taskName="AddTaskDplus.C"; taskName.Prepend(loadMacroPath.Data());\r
162 gROOT->LoadMacro(taskName.Data());\r
163 AliAnalysisTaskSEDplus *dplusTask = AddTaskDplus();\r
164\r
1a6db1e0 165 //taskName="AddTaskSelectHF.C"; taskName.Prepend(loadMacroPath.Data());\r
166 //gROOT->LoadMacro(taskName.Data());\r
167 //AliAnalysisTaskSESelectHF *seleTask = AddTaskSelectHF();\r
a9f684f8 168\r
17e8df02 169 taskName="AddTaskBkgLikeSignD0.C"; taskName.Prepend(loadMacroPath.Data());\r
170 gROOT->LoadMacro(taskName.Data());\r
171 AliAnalysisTaskSEBkgLikeSignD0 *lsD0Task = AddTaskBkgLikeSignD0();\r
172\r
8f6dd855 173 taskName="AddTaskBkgLikeSignJPSI.C"; taskName.Prepend(loadMacroPath.Data());\r
b093f071 174 gROOT->LoadMacro(taskName.Data());\r
17e8df02 175 AliAnalysisTaskSEBkgLikeSignJPSI *lsJPSITask = AddTaskBkgLikeSignJPSI();\r
a9f684f8 176\r
1a6db1e0 177 //taskName="AddTaskBtoJPSItoEle.C"; taskName.Prepend(loadMacroPath.Data());\r
178 //gROOT->LoadMacro(taskName.Data());\r
32bb35a1 179 //AliAnalysisTaskSEBtoJPSItoEle *jpsiTask = AddTaskBtoJPSItoEle();\r
a9f684f8 180\r
1a6db1e0 181 //taskName="AddTaskCF.C"; taskName.Prepend(loadMacroPath.Data());\r
182 //gROOT->LoadMacro(taskName.Data());\r
a9f684f8 183 //AliCFHeavyFlavourTask *cfTask = AddTaskCF();\r
184\r
1a6db1e0 185 //taskName="AddTaskCFMultiVar.C"; taskName.Prepend(loadMacroPath.Data());\r
186 //gROOT->LoadMacro(taskName.Data());\r
32bb35a1 187 //AliCFHeavyFlavourTaskMultiVar *cfmvTask = AddTaskCFMultiVar();\r
188\r
75ff3310 189 taskName="AddTaskCFMultiVarMultiStep.C"; taskName.Prepend(loadMacroPath.Data());\r
b093f071 190 gROOT->LoadMacro(taskName.Data());\r
56440003 191 //AliCFHeavyFlavourTaskMultiVarMultiStep *cfmvmsTask = AddTaskCFMultiVarMultiStep();\r
a9f684f8 192\r
32bb35a1 193\r
194 //-------------------------------------------------------------------\r
195\r
196 //\r
197 // Run the analysis\r
198 // \r
1a6db1e0 199 if(chainAOD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainAOD->GetEntries());\r
200\r
201 if(!mgr->InitAnalysis()) return;\r
202 mgr->PrintStatus();\r
203 if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local";\r
204 mgr->StartAnalysis(analysisMode.Data(),chainAOD,nentries,firstentry);\r
32bb35a1 205\r
206 return;\r
207}\r
1a6db1e0 208//_____________________________________________________________________________\r
209//\r
210AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",Bool_t useParFiles=kFALSE)\r
211{\r
212 // Check if user has a valid token, otherwise make one. This has limitations.\r
213 // One can always follow the standard procedure of calling alien-token-init then\r
214 // source /tmp/gclient_env_$UID in the current shell.\r
215 if (!AliAnalysisGrid::CreateToken()) return NULL;\r
216 AliAnalysisAlien *plugin = new AliAnalysisAlien();\r
217 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")\r
218 plugin->SetRunMode(pluginmode.Data());\r
219 plugin->SetUser("dainesea");\r
220 plugin->SetNtestFiles(1);\r
221 // Set versions of used packages\r
222 plugin->SetAPIVersion("V2.4");\r
223 plugin->SetROOTVersion("v5-23-02");\r
224 plugin->SetAliROOTVersion("v4-17-00");\r
225 // Declare input data to be processed.\r
226 // Method 1: Create automatically XML collections using alien 'find' command.\r
227 // Define production directory LFN\r
75ff3310 228 //plugin->SetGridDataDir("/alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/");\r
229 plugin->SetGridDataDir("/alice/cern.ch/user/m/mgheata/analysisESD/output_train_default_28May2009_09h33/");\r
1a6db1e0 230 // Set data search pattern\r
231 plugin->SetDataPattern("AliAOD.root");\r
232 plugin->SetFriendChainName("AliAOD.VertexingHF.root");\r
233 // ...then add run numbers to be considered\r
75ff3310 234 plugin->AddRunNumber(529007);\r
17e8df02 235 // or\r
236 //plugin->SetRunRange(529000,529007);\r
1a6db1e0 237 // Method 2: Declare existing data files (raw collections, xml collections, root file)\r
238 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())\r
239 // XML collections added via this method can be combined with the first method if\r
240 // the content is compatible (using or not tags)\r
241 //plugin->AddDataFile("/alice/cern.ch/user/r/rbala/newtrain/collection/collection_aod_lhc08w.xml");\r
242 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");\r
243 // Define alien work directory where all files will be copied. Relative to alien $HOME.\r
244 plugin->SetGridWorkingDir("work");\r
245 // Declare alien output directory. Relative to working directory.\r
246 plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output\r
247 // Declare the analysis source files names separated by blancs. To be compiled runtime\r
248 // using ACLiC on the worker nodes.\r
249 //plugin->SetAnalysisSource("$ALICE_ROOT/PWG3/vertexingHF/AliAnalysisTaskSECompareHF.cxx");\r
250 // Declare all libraries (other than the default ones for the framework. These will be\r
251 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.\r
75ff3310 252 plugin->SetAdditionalLibs("libPWG3vertexingHF.so libPWG3base.so libPWG3muon.so libPWG4PartCorrBase.so libPWG4PartCorrDep.so");\r
1a6db1e0 253 // use par files\r
254 if(useParFiles) {\r
255 plugin->EnablePackage("STEERBase.par");\r
256 plugin->EnablePackage("ESD.par");\r
257 plugin->EnablePackage("AOD.par");\r
258 plugin->EnablePackage("ANALYSIS.par");\r
259 plugin->EnablePackage("ANALYSISalice.par");\r
260 plugin->EnablePackage("CORRFW.par");\r
75ff3310 261 plugin->EnablePackage("PWG3base.par");\r
1a6db1e0 262 plugin->EnablePackage("PWG3vertexingHF.par");\r
75ff3310 263 plugin->EnablePackage("PWG3muon.par");\r
264 plugin->EnablePackage("PWG4PartCorrBase.par");\r
265 plugin->EnablePackage("PWG4PartCorrDep.par");\r
1a6db1e0 266 }\r
267 // Declare the output file names separated by blancs.\r
268 // (can be like: file.root or file.root@ALICE::Niham::File)\r
269 plugin->SetOutputFiles("CmpHF.root");\r
270 // Optionally define the files to be archived.\r
271 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");\r
272 plugin->SetOutputArchive("log_archive.zip:stdout,stderr");\r
273 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)\r
274 plugin->SetAnalysisMacro("AnalysisHF.C");\r
275 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)\r
276 plugin->SetSplitMaxInputFileNumber(5);\r
277 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.\r
278 //plugin->SetMaxInitFailed(5);\r
279 // Optionally resubmit threshold.\r
280 //plugin->SetMasterResubmitThreshold(90);\r
281 // Optionally set time to live (default 30000 sec)\r
282 //plugin->SetTTL(20000);\r
283 // Optionally set input format (default xml-single)\r
284 plugin->SetInputFormat("xml-single");\r
285 // Optionally modify the name of the generated JDL (default analysis.jdl)\r
286 plugin->SetJDLName("TaskHF.jdl");\r
287 // Optionally modify job price (default 1)\r
288 //plugin->SetPrice(1); \r
289 // Optionally modify split mode (default 'se') \r
290 plugin->SetSplitMode("se");\r
291 // Optionally set the preferred SE \r
292 plugin->SetPreferedSE("ALICE::Legnaro::SE");\r
293 \r
294 return plugin;\r
295}\r