Bug fix (Renu)
[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
d2a0f79f 16 gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/PWG3 -I$ALICE_ROOT/PWG3/vertexingHF -g"); \r
1a6db1e0 17 //\r
75e79c0f 18 TString analysisMode = "grid"; // "local", "grid", or "proof"\r
19 TString inputMode = "list"; // "list", "xml", or "dataset"\r
1a6db1e0 20 Long64_t nentries=1234567890,firstentry=0;\r
aabcfd8f 21 Bool_t useParFiles=kFALSE;\r
75ff3310 22 Bool_t useAlienPlugin=kTRUE;\r
1a02c480 23 TString pluginmode="test";\r
1a6db1e0 24 TString loadMacroPath="$ALICE_ROOT/PWG3/vertexingHF/";\r
a73f46fd 25 //TString loadMacroPath="./"; // this is normally needed for CAF\r
1a6db1e0 26 //\r
32bb35a1 27\r
1a6db1e0 28 if(analysisMode=="grid") {\r
29 // Connect to AliEn\r
30 TGrid::Connect("alien://");\r
31 } else if(analysisMode=="proof") {\r
32 // Connect to the PROOF cluster\r
1a02c480 33 if(inputMode!="dataset") {printf("Input mode must be dataset, for proof analysis\n"); return;}\r
75e79c0f 34 gEnv->SetValue("XSec.GSI.DelegProxy","2");\r
1a6db1e0 35 TProof::Open("alicecaf");\r
36 //TProof::Reset("alicecaf");\r
37 }\r
32bb35a1 38\r
32bb35a1 39\r
1a6db1e0 40 // AliRoot libraries\r
41 if(analysisMode=="local" || analysisMode=="grid") {\r
42 TString loadLibraries="LoadLibraries.C"; loadLibraries.Prepend(loadMacroPath.Data());\r
43 gROOT->LoadMacro(loadLibraries.Data());\r
44 LoadLibraries(useParFiles);\r
45 } else if (analysisMode=="proof") {\r
46 gSystem->Load("libTree.so");\r
47 gSystem->Load("libGeom.so");\r
48 gSystem->Load("libPhysics.so");\r
49 gSystem->Load("libVMC.so"); \r
50 // Enable the needed packages\r
51 //gProof->ClearPackages();\r
a73f46fd 52 TString parDir="/afs/cern.ch/user/d/dainesea/code/";\r
53 TString parFile;\r
1a6db1e0 54 if(!useParFiles) {\r
75e79c0f 55 gProof->UploadPackage("AF-v4-17");\r
56 gProof->EnablePackage("AF-v4-17");\r
a73f46fd 57 // --- Enable the PWG3vertexingHF Package\r
58 parFile="PWG3vertexingHF.par"; parFile.Prepend(parDir.Data());\r
59 gProof->UploadPackage(parFile.Data());\r
60 gProof->EnablePackage("PWG3vertexingHF");\r
1a6db1e0 61 } else {\r
1a6db1e0 62 // --- Enable the STEERBase Package\r
63 parFile="STEERBase.par"; parFile.Prepend(parDir.Data());\r
64 gProof->UploadPackage(parFile.Data());\r
65 gProof->EnablePackage("STEERBase");\r
66 // --- Enable the ESD Package\r
67 parFile="ESD.par"; parFile.Prepend(parDir.Data());\r
68 gProof->UploadPackage(parFile.Data());\r
69 gProof->EnablePackage("ESD");\r
70 // --- Enable the AOD Package\r
71 parFile="AOD.par"; parFile.Prepend(parDir.Data());\r
72 gProof->UploadPackage(parFile.Data());\r
73 gProof->EnablePackage("AOD");\r
74 // --- Enable the ANALYSIS Package\r
75 parFile="ANALYSIS.par"; parFile.Prepend(parDir.Data());\r
76 gProof->UploadPackage(parFile.Data());\r
77 gProof->EnablePackage("ANALYSIS");\r
78 // --- Enable the ANALYSISalice Package\r
79 parFile="ANALYSISalice.par"; parFile.Prepend(parDir.Data());\r
80 gProof->UploadPackage(parFile.Data());\r
81 gProof->EnablePackage("ANALYSISalice");\r
82 // --- Enable the CORRFW Package\r
83 parFile="CORRFW.par"; parFile.Prepend(parDir.Data());\r
84 gProof->UploadPackage(parFile.Data());\r
85 gProof->EnablePackage("CORRFW");\r
b093f071 86 // --- Enable the PWG3base Package\r
87 parFile="PWG3base.par"; parFile.Prepend(parDir.Data());\r
88 gProof->UploadPackage(parFile.Data());\r
89 gProof->EnablePackage("PWG3base");\r
1a6db1e0 90 // --- Enable the PWG3vertexingHF Package\r
91 parFile="PWG3vertexingHF.par"; parFile.Prepend(parDir.Data());\r
92 gProof->UploadPackage(parFile.Data());\r
93 gProof->EnablePackage("PWG3vertexingHF");\r
b093f071 94 // --- Enable the JETAN Package\r
95 parFile="JETAN.par"; parFile.Prepend(parDir.Data());\r
96 gProof->UploadPackage(parFile.Data());\r
97 gProof->EnablePackage("JETAN");\r
98 // --- Enable the PWG3muon Package\r
99 parFile="PWG3muon.par"; parFile.Prepend(parDir.Data());\r
100 gProof->UploadPackage(parFile.Data());\r
101 gProof->EnablePackage("PWG3muon");\r
102 // --- Enable the PWG4PartCorrBase Package\r
103 parFile="PWG4PartCorrBase.par"; parFile.Prepend(parDir.Data());\r
104 gProof->UploadPackage(parFile.Data());\r
105 gProof->EnablePackage("PWG4PartCorrBase");\r
106 // --- Enable the PWG4PartCorrDep Package\r
107 parFile="PWG4PartCorrDep.par"; parFile.Prepend(parDir.Data());\r
108 gProof->UploadPackage(parFile.Data());\r
109 gProof->EnablePackage("PWG4PartCorrDep");\r
1a6db1e0 110 }\r
111 gProof->ShowEnabledPackages(); // show a list of enabled packages\r
112 }\r
32bb35a1 113\r
114\r
1a6db1e0 115 // Create Alien plugin, if requested\r
116 if(useAlienPlugin) { \r
75e79c0f 117 if(analysisMode!="grid") {printf("Analysis mode must be grid, to use alien plugin\n"); return;}\r
1a6db1e0 118 AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode,useParFiles); \r
119 if(!alienHandler) return;\r
120 }\r
32bb35a1 121\r
122\r
123 //-------------------------------------------------------------------\r
75e79c0f 124 // Prepare input\r
32bb35a1 125 TChain *chainAOD = 0;\r
1a6db1e0 126 TString dataset; // for proof\r
127\r
128 if(!useAlienPlugin) {\r
aabcfd8f 129 TString makeAODInputChain="MakeAODInputChain.C"; makeAODInputChain.Prepend(loadMacroPath.Data());\r
1a6db1e0 130 if(inputMode=="list") {\r
131 // Local files\r
75e79c0f 132 gROOT->LoadMacro(makeAODInputChain.Data());\r
1a6db1e0 133 chainAOD = MakeAODInputChain();// with this it reads ./AliAOD.root and ./AliAOD.VertexingHF.root\r
aabcfd8f 134 //chainAOD = MakeAODInputChain("alien:///alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/180100/",1,1);\r
1a6db1e0 135 } else if(inputMode=="xml") {\r
136 // xml\r
75e79c0f 137 gROOT->LoadMacro(makeAODInputChain.Data());\r
1a6db1e0 138 chainAOD = MakeAODInputChain("collection_aod.xml","collection_aodHF.xml");\r
139 } else if(inputMode=="dataset") {\r
140 // CAF dataset\r
75e79c0f 141 //gProof->ShowDataSets();\r
142 dataset="/ITS/dainesea/AODVertexingHF_LHC08x_180100";\r
1a6db1e0 143 }\r
32bb35a1 144 }\r
145\r
146 // Create the analysis manager\r
147 AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager");\r
148 mgr->SetDebugLevel(10);\r
1a6db1e0 149 // Connect plug-in to the analysis manager\r
150 if(useAlienPlugin) mgr->SetGridHandler(alienHandler);\r
151\r
32bb35a1 152\r
153 // Input\r
154 AliAODInputHandler *inputHandler = new AliAODInputHandler();\r
75e79c0f 155 if(analysisMode=="proof") inputHandler->AddFriend("AliAOD.VertexingHF.root");\r
32bb35a1 156 mgr->SetInputEventHandler(inputHandler);\r
157 //-------------------------------------------------------------------\r
158\r
159 \r
160 //-------------------------------------------------------------------\r
1a6db1e0 161 // Analysis tasks (wagons of the train) \r
32bb35a1 162 //\r
1a6db1e0 163 TString taskName;\r
164\r
165 taskName="AddTaskCompareHF.C"; taskName.Prepend(loadMacroPath.Data());\r
166 gROOT->LoadMacro(taskName.Data());\r
32bb35a1 167 AliAnalysisTaskSECompareHF *cmpTask = AddTaskCompareHF();\r
f3be8296 168 \r
a273622f 169 taskName="AddTaskD0Mass.C"; taskName.Prepend(loadMacroPath.Data());\r
170 gROOT->LoadMacro(taskName.Data());\r
171 AliAnalysisTaskSED0Mass *d0massTask = AddTaskD0Mass();\r
172\r
173 \r
d486095a 174 taskName="AddTaskDplus.C"; taskName.Prepend(loadMacroPath.Data());\r
175 gROOT->LoadMacro(taskName.Data());\r
176 AliAnalysisTaskSEDplus *dplusTask = AddTaskDplus();\r
81c01455 177 \r
1a6db1e0 178 //taskName="AddTaskSelectHF.C"; taskName.Prepend(loadMacroPath.Data());\r
179 //gROOT->LoadMacro(taskName.Data());\r
180 //AliAnalysisTaskSESelectHF *seleTask = AddTaskSelectHF();\r
a9f684f8 181\r
17e8df02 182 taskName="AddTaskBkgLikeSignD0.C"; taskName.Prepend(loadMacroPath.Data());\r
183 gROOT->LoadMacro(taskName.Data());\r
184 AliAnalysisTaskSEBkgLikeSignD0 *lsD0Task = AddTaskBkgLikeSignD0();\r
185\r
8f6dd855 186 taskName="AddTaskBkgLikeSignJPSI.C"; taskName.Prepend(loadMacroPath.Data());\r
b093f071 187 gROOT->LoadMacro(taskName.Data());\r
17e8df02 188 AliAnalysisTaskSEBkgLikeSignJPSI *lsJPSITask = AddTaskBkgLikeSignJPSI();\r
a9f684f8 189\r
d234e959 190 taskName="AddTaskBtoJPSItoEle.C"; taskName.Prepend(loadMacroPath.Data());\r
191 gROOT->LoadMacro(taskName.Data());\r
192 AliAnalysisTaskSEBtoJPSItoEle *jpsiTask = AddTaskBtoJPSItoEle();\r
a9f684f8 193\r
75ff3310 194 taskName="AddTaskCFMultiVarMultiStep.C"; taskName.Prepend(loadMacroPath.Data());\r
b093f071 195 gROOT->LoadMacro(taskName.Data());\r
09d822de 196 AliCFHeavyFlavourTaskMultiVarMultiStep *cfmvmsTask = AddTaskCFMultiVarMultiStep();\r
a9f684f8 197\r
d234e959 198 taskName="AddTaskCharmFraction.C"; taskName.Prepend(loadMacroPath.Data());\r
199 gROOT->LoadMacro(taskName.Data());\r
200 // The task is added several times with different settings:\r
201 AliAnalysisTaskCharmFraction *cFractTaskSignal = AddTaskCharmFraction("d0D0_Signal.root");\r
202 AliAnalysisTaskCharmFraction *cFractTaskNoMCSel = AddTaskCharmFraction("d0D0NoMCSel.root",kFALSE,kTRUE,kFALSE);\r
203 AliAnalysisTaskCharmFraction *cFractTaskNoMCSel = AddTaskCharmFraction("d0D0NoMCSel_SideBand.root",kTRUE,kTRUE,kFALSE);\r
e501585f 204 AliAnalysisTaskCharmFraction *cFractTaskPureBack = AddTaskCharmFraction("d0D0_PureBack.root",kFALSE,kTRUE,kTRUE,kTRUE,kFALSE,kTRUE,kTRUE,kFALSE,kTRUE);\r
f3be8296 205 AliAnalysisTaskCharmFraction *cFractTaskFromB = AddTaskCharmFraction("d0D0_FromB.root",kFALSE,kTRUE,kTRUE,kFALSE,kTRUE);\r
32bb35a1 206\r
f6cc2d5d 207 // attach a private task (not committed)\r
208 // (the files MyTask.h MyTask.cxx AddMyTask.C have to be declared in plugin\r
209 // configuration, see below)\r
210 /*\r
75e79c0f 211 if(analysisMode.Data()=="proof") {\r
212 gProof->LoadMacro("MyTask.cxx++g");\r
213 } else {\r
214 gROOT->LoadMacro("MyTask.cxx++g");\r
215 }\r
216 gROOT->LoadMacro("AddMyTask.C");\r
217 MyTask *myTask = AddMyTask();\r
f6cc2d5d 218 */\r
219\r
32bb35a1 220 //-------------------------------------------------------------------\r
221\r
222 //\r
223 // Run the analysis\r
224 // \r
1a6db1e0 225 if(chainAOD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainAOD->GetEntries());\r
226\r
227 if(!mgr->InitAnalysis()) return;\r
228 mgr->PrintStatus();\r
229 if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local";\r
ff395ef6 230 if(analysisMode!="proof") {\r
75e79c0f 231 mgr->StartAnalysis(analysisMode.Data(),chainAOD,nentries,firstentry);\r
232 } else {\r
233 // proof\r
234 mgr->StartAnalysis(analysisMode.Data(),dataset.Data(),nentries,firstentry);\r
235 }\r
32bb35a1 236\r
237 return;\r
238}\r
1a6db1e0 239//_____________________________________________________________________________\r
240//\r
241AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",Bool_t useParFiles=kFALSE)\r
242{\r
243 // Check if user has a valid token, otherwise make one. This has limitations.\r
244 // One can always follow the standard procedure of calling alien-token-init then\r
245 // source /tmp/gclient_env_$UID in the current shell.\r
246 if (!AliAnalysisGrid::CreateToken()) return NULL;\r
247 AliAnalysisAlien *plugin = new AliAnalysisAlien();\r
248 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")\r
249 plugin->SetRunMode(pluginmode.Data());\r
250 plugin->SetUser("dainesea");\r
251 plugin->SetNtestFiles(1);\r
252 // Set versions of used packages\r
253 plugin->SetAPIVersion("V2.4");\r
e501585f 254 plugin->SetROOTVersion("v5-24-00");\r
255 plugin->SetAliROOTVersion("v4-18-01-AN");\r
1a6db1e0 256 // Declare input data to be processed.\r
257 // Method 1: Create automatically XML collections using alien 'find' command.\r
258 // Define production directory LFN\r
75ff3310 259 //plugin->SetGridDataDir("/alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/");\r
e501585f 260 //plugin->SetGridDataDir("/alice/cern.ch/user/m/mgheata/analysisESD/output_train_default_28May2009_09h33/");\r
261 plugin->SetGridDataDir("/alice/sim/PDC_09/LHC09a6/AOD/");\r
1a6db1e0 262 // Set data search pattern\r
263 plugin->SetDataPattern("AliAOD.root");\r
264 plugin->SetFriendChainName("AliAOD.VertexingHF.root");\r
265 // ...then add run numbers to be considered\r
e501585f 266 //plugin->AddRunNumber(529007);\r
d234e959 267 // or\r
268 //plugin->SetRunRange(529000,529007);\r
1a6db1e0 269 // Method 2: Declare existing data files (raw collections, xml collections, root file)\r
270 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())\r
271 // XML collections added via this method can be combined with the first method if\r
272 // the content is compatible (using or not tags)\r
273 //plugin->AddDataFile("/alice/cern.ch/user/r/rbala/newtrain/collection/collection_aod_lhc08w.xml");\r
274 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");\r
275 // Define alien work directory where all files will be copied. Relative to alien $HOME.\r
276 plugin->SetGridWorkingDir("work");\r
277 // Declare alien output directory. Relative to working directory.\r
278 plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output\r
279 // Declare the analysis source files names separated by blancs. To be compiled runtime\r
280 // using ACLiC on the worker nodes.\r
f6cc2d5d 281 //plugin->SetAnalysisSource("MyTask.cxx");\r
1a6db1e0 282 // Declare all libraries (other than the default ones for the framework. These will be\r
283 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.\r
187c0242 284 plugin->SetAdditionalLibs("libPWG3vertexingHF.so libPWG3base.so libPWG3muon.so libPWG4PartCorrBase.so libPWG4PartCorrDep.so MakeAODInputChain.C"/* MyTask.cxx MyTask.h" */);\r
1a6db1e0 285 // use par files\r
286 if(useParFiles) {\r
287 plugin->EnablePackage("STEERBase.par");\r
288 plugin->EnablePackage("ESD.par");\r
289 plugin->EnablePackage("AOD.par");\r
290 plugin->EnablePackage("ANALYSIS.par");\r
291 plugin->EnablePackage("ANALYSISalice.par");\r
292 plugin->EnablePackage("CORRFW.par");\r
75ff3310 293 plugin->EnablePackage("PWG3base.par");\r
1a6db1e0 294 plugin->EnablePackage("PWG3vertexingHF.par");\r
75ff3310 295 plugin->EnablePackage("PWG3muon.par");\r
296 plugin->EnablePackage("PWG4PartCorrBase.par");\r
297 plugin->EnablePackage("PWG4PartCorrDep.par");\r
1a6db1e0 298 }\r
d2a0f79f 299 plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TPC -I$ALICE_ROOT/CONTAINERS -I$ALICE_ROOT/STEER -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/PWG3 -I$ALICE_ROOT/PWG3/vertexingHF -g");\r
1a6db1e0 300 // Declare the output file names separated by blancs.\r
301 // (can be like: file.root or file.root@ALICE::Niham::File)\r
e501585f 302 plugin->SetDefaultOutputs(kTRUE);\r
303 //plugin->SetOutputFiles("output.root CmpHF.root CmpHFnt.root D0InvMass.root InvMassDplus.root InvMassDplus_nt1.root InvMassDplus_nt2.root");\r
1a6db1e0 304 // Optionally define the files to be archived.\r
305 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");\r
306 plugin->SetOutputArchive("log_archive.zip:stdout,stderr");\r
307 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)\r
308 plugin->SetAnalysisMacro("AnalysisHF.C");\r
309 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)\r
310 plugin->SetSplitMaxInputFileNumber(5);\r
311 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.\r
312 //plugin->SetMaxInitFailed(5);\r
313 // Optionally resubmit threshold.\r
314 //plugin->SetMasterResubmitThreshold(90);\r
315 // Optionally set time to live (default 30000 sec)\r
316 //plugin->SetTTL(20000);\r
317 // Optionally set input format (default xml-single)\r
318 plugin->SetInputFormat("xml-single");\r
319 // Optionally modify the name of the generated JDL (default analysis.jdl)\r
320 plugin->SetJDLName("TaskHF.jdl");\r
321 // Optionally modify job price (default 1)\r
322 //plugin->SetPrice(1); \r
323 // Optionally modify split mode (default 'se') \r
324 plugin->SetSplitMode("se");\r
325 // Optionally set the preferred SE \r
e501585f 326 plugin->SetPreferedSE("ALICE::Torino::DPM");\r
1a6db1e0 327 \r
328 return plugin;\r
329}\r