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