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