Last bug fixes. The encoder was validated on ppbench test suite.
[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
a273622f 161 taskName="AddTaskD0Mass.C"; taskName.Prepend(loadMacroPath.Data());\r
162 gROOT->LoadMacro(taskName.Data());\r
163 AliAnalysisTaskSED0Mass *d0massTask = AddTaskD0Mass();\r
164\r
165 \r
d486095a 166 taskName="AddTaskDplus.C"; taskName.Prepend(loadMacroPath.Data());\r
167 gROOT->LoadMacro(taskName.Data());\r
168 AliAnalysisTaskSEDplus *dplusTask = AddTaskDplus();\r
81c01455 169 \r
1a6db1e0 170 //taskName="AddTaskSelectHF.C"; taskName.Prepend(loadMacroPath.Data());\r
171 //gROOT->LoadMacro(taskName.Data());\r
172 //AliAnalysisTaskSESelectHF *seleTask = AddTaskSelectHF();\r
a9f684f8 173\r
17e8df02 174 taskName="AddTaskBkgLikeSignD0.C"; taskName.Prepend(loadMacroPath.Data());\r
175 gROOT->LoadMacro(taskName.Data());\r
176 AliAnalysisTaskSEBkgLikeSignD0 *lsD0Task = AddTaskBkgLikeSignD0();\r
177\r
8f6dd855 178 taskName="AddTaskBkgLikeSignJPSI.C"; taskName.Prepend(loadMacroPath.Data());\r
b093f071 179 gROOT->LoadMacro(taskName.Data());\r
17e8df02 180 AliAnalysisTaskSEBkgLikeSignJPSI *lsJPSITask = AddTaskBkgLikeSignJPSI();\r
a9f684f8 181\r
d234e959 182 taskName="AddTaskBtoJPSItoEle.C"; taskName.Prepend(loadMacroPath.Data());\r
183 gROOT->LoadMacro(taskName.Data());\r
184 AliAnalysisTaskSEBtoJPSItoEle *jpsiTask = AddTaskBtoJPSItoEle();\r
a9f684f8 185\r
75ff3310 186 taskName="AddTaskCFMultiVarMultiStep.C"; taskName.Prepend(loadMacroPath.Data());\r
b093f071 187 gROOT->LoadMacro(taskName.Data());\r
09d822de 188 AliCFHeavyFlavourTaskMultiVarMultiStep *cfmvmsTask = AddTaskCFMultiVarMultiStep();\r
a9f684f8 189\r
d234e959 190 taskName="AddTaskCharmFraction.C"; taskName.Prepend(loadMacroPath.Data());\r
191 gROOT->LoadMacro(taskName.Data());\r
192 // The task is added several times with different settings:\r
193 AliAnalysisTaskCharmFraction *cFractTaskSignal = AddTaskCharmFraction("d0D0_Signal.root");\r
194 AliAnalysisTaskCharmFraction *cFractTaskNoMCSel = AddTaskCharmFraction("d0D0NoMCSel.root",kFALSE,kTRUE,kFALSE);\r
195 AliAnalysisTaskCharmFraction *cFractTaskNoMCSel = AddTaskCharmFraction("d0D0NoMCSel_SideBand.root",kTRUE,kTRUE,kFALSE);\r
196 AliAnalysisTaskCharmFraction *cFractTaskPureBack = AddTaskCharmFraction("d0D0_PureBack.root",kFALSE,kTRUE,kTRUE,kTRUE,kFALSE,kTRUE,kTRUE,kTRUE,kTRUE);\r
81c01455 197 \r
32bb35a1 198\r
199 //-------------------------------------------------------------------\r
200\r
201 //\r
202 // Run the analysis\r
203 // \r
1a6db1e0 204 if(chainAOD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainAOD->GetEntries());\r
205\r
206 if(!mgr->InitAnalysis()) return;\r
207 mgr->PrintStatus();\r
208 if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local";\r
209 mgr->StartAnalysis(analysisMode.Data(),chainAOD,nentries,firstentry);\r
32bb35a1 210\r
211 return;\r
212}\r
1a6db1e0 213//_____________________________________________________________________________\r
214//\r
215AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",Bool_t useParFiles=kFALSE)\r
216{\r
217 // Check if user has a valid token, otherwise make one. This has limitations.\r
218 // One can always follow the standard procedure of calling alien-token-init then\r
219 // source /tmp/gclient_env_$UID in the current shell.\r
220 if (!AliAnalysisGrid::CreateToken()) return NULL;\r
221 AliAnalysisAlien *plugin = new AliAnalysisAlien();\r
222 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")\r
223 plugin->SetRunMode(pluginmode.Data());\r
224 plugin->SetUser("dainesea");\r
225 plugin->SetNtestFiles(1);\r
226 // Set versions of used packages\r
227 plugin->SetAPIVersion("V2.4");\r
228 plugin->SetROOTVersion("v5-23-02");\r
229 plugin->SetAliROOTVersion("v4-17-00");\r
230 // Declare input data to be processed.\r
231 // Method 1: Create automatically XML collections using alien 'find' command.\r
232 // Define production directory LFN\r
75ff3310 233 //plugin->SetGridDataDir("/alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/");\r
234 plugin->SetGridDataDir("/alice/cern.ch/user/m/mgheata/analysisESD/output_train_default_28May2009_09h33/");\r
1a6db1e0 235 // Set data search pattern\r
236 plugin->SetDataPattern("AliAOD.root");\r
237 plugin->SetFriendChainName("AliAOD.VertexingHF.root");\r
238 // ...then add run numbers to be considered\r
d234e959 239 plugin->AddRunNumber(529007);\r
240 // or\r
241 //plugin->SetRunRange(529000,529007);\r
1a6db1e0 242 // Method 2: Declare existing data files (raw collections, xml collections, root file)\r
243 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())\r
244 // XML collections added via this method can be combined with the first method if\r
245 // the content is compatible (using or not tags)\r
246 //plugin->AddDataFile("/alice/cern.ch/user/r/rbala/newtrain/collection/collection_aod_lhc08w.xml");\r
247 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");\r
248 // Define alien work directory where all files will be copied. Relative to alien $HOME.\r
249 plugin->SetGridWorkingDir("work");\r
250 // Declare alien output directory. Relative to working directory.\r
251 plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output\r
252 // Declare the analysis source files names separated by blancs. To be compiled runtime\r
253 // using ACLiC on the worker nodes.\r
254 //plugin->SetAnalysisSource("$ALICE_ROOT/PWG3/vertexingHF/AliAnalysisTaskSECompareHF.cxx");\r
255 // Declare all libraries (other than the default ones for the framework. These will be\r
256 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.\r
d234e959 257 plugin->SetAdditionalLibs("libPWG3vertexingHF.so libPWG3base.so libPWG3muon.so libPWG4PartCorrBase.so libPWG4PartCorrDep.so MakeAODInputChain.C");\r
1a6db1e0 258 // use par files\r
259 if(useParFiles) {\r
260 plugin->EnablePackage("STEERBase.par");\r
261 plugin->EnablePackage("ESD.par");\r
262 plugin->EnablePackage("AOD.par");\r
263 plugin->EnablePackage("ANALYSIS.par");\r
264 plugin->EnablePackage("ANALYSISalice.par");\r
265 plugin->EnablePackage("CORRFW.par");\r
75ff3310 266 plugin->EnablePackage("PWG3base.par");\r
1a6db1e0 267 plugin->EnablePackage("PWG3vertexingHF.par");\r
75ff3310 268 plugin->EnablePackage("PWG3muon.par");\r
269 plugin->EnablePackage("PWG4PartCorrBase.par");\r
270 plugin->EnablePackage("PWG4PartCorrDep.par");\r
1a6db1e0 271 }\r
272 // Declare the output file names separated by blancs.\r
273 // (can be like: file.root or file.root@ALICE::Niham::File)\r
274 plugin->SetOutputFiles("CmpHF.root");\r
275 // Optionally define the files to be archived.\r
276 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");\r
277 plugin->SetOutputArchive("log_archive.zip:stdout,stderr");\r
278 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)\r
279 plugin->SetAnalysisMacro("AnalysisHF.C");\r
280 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)\r
281 plugin->SetSplitMaxInputFileNumber(5);\r
282 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.\r
283 //plugin->SetMaxInitFailed(5);\r
284 // Optionally resubmit threshold.\r
285 //plugin->SetMasterResubmitThreshold(90);\r
286 // Optionally set time to live (default 30000 sec)\r
287 //plugin->SetTTL(20000);\r
288 // Optionally set input format (default xml-single)\r
289 plugin->SetInputFormat("xml-single");\r
290 // Optionally modify the name of the generated JDL (default analysis.jdl)\r
291 plugin->SetJDLName("TaskHF.jdl");\r
292 // Optionally modify job price (default 1)\r
293 //plugin->SetPrice(1); \r
294 // Optionally modify split mode (default 'se') \r
295 plugin->SetSplitMode("se");\r
296 // Optionally set the preferred SE \r
297 plugin->SetPreferedSE("ALICE::Legnaro::SE");\r
298 \r
299 return plugin;\r
300}\r