]>
Commit | Line | Data |
---|---|---|
1 | class AliAnalysisGrid; | |
2 | class AliAnalysisAlien; | |
3 | ||
4 | void RunAnalysisAODVertexingHF() | |
5 | { | |
6 | // | |
7 | // Test macro for AliAnalysisTaskSE's for heavy-flavour candidates | |
8 | // It has the structure of a Analysis Train: | |
9 | // - in this macro, change things related to running mode | |
10 | // and input preparation | |
11 | // - add your task using a AddTaskXXX macro | |
12 | // | |
13 | // A.Dainese, andrea.dainese@lnl.infn.it | |
14 | // "grid" mode added by R.Bala, bala@to.infn.it | |
15 | // | |
16 | ||
17 | ||
18 | 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/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/OADB -I$ALICE_ROOT/PWGHF -I$ALICE_ROOT/PWGHF/base -I$ALICE_ROOT/PWGHF/vertexingHF -I$ALICE_ROOT/PWG/FLOW/Base -I$ALICE_ROOT/PWG/FLOW/Tasks -g"); | |
19 | // | |
20 | TString trainName = "D2H"; | |
21 | TString analysisMode = "grid"; // "local", "grid", or "proof" | |
22 | TString inputMode = "list"; // "list", "xml", or "dataset" | |
23 | Long64_t nentries=123567890,firstentry=0; | |
24 | Bool_t useParFiles=kFALSE; | |
25 | Bool_t useAlienPlugin=kTRUE; | |
26 | TString pluginmode="full"; | |
27 | TString testfileslistWithPlugin=""; | |
28 | Bool_t saveProofToAlien=kFALSE; | |
29 | TString proofOutdir = ""; | |
30 | TString loadMacroPath="$ALICE_ROOT/PWGHF/vertexingHF/macros/"; | |
31 | //TString loadMacroPath="./"; // this is normally needed for CAF | |
32 | // | |
33 | ||
34 | if(analysisMode=="grid") { | |
35 | // Connect to AliEn | |
36 | TGrid::Connect("alien://"); | |
37 | } else if(analysisMode=="proof") { | |
38 | // Connect to the PROOF cluster | |
39 | if(inputMode!="dataset") {printf("Input mode must be dataset, for proof analysis\n"); return;} | |
40 | gEnv->SetValue("XSec.GSI.DelegProxy","2"); | |
41 | TProof::Open("alicecaf"); | |
42 | //TProof::Reset("alicecaf"); | |
43 | if(saveProofToAlien) { | |
44 | TGrid::Connect("alien://"); | |
45 | if(gGrid) { | |
46 | TString homedir = gGrid->GetHomeDirectory(); | |
47 | TString workdir = homedir + trainName; | |
48 | if(!gGrid->Cd(workdir)) { | |
49 | gGrid->Cd(homedir); | |
50 | if(gGrid->Mkdir(workdir)) { | |
51 | gGrid->Cd(trainName); | |
52 | ::Info("VertexingTrain::Connect()", "Directory %s created", gGrid->Pwd()); | |
53 | } | |
54 | } | |
55 | gGrid->Mkdir("proof_output"); | |
56 | gGrid->Cd("proof_output"); | |
57 | proofOutdir = Form("alien://%s", gGrid->Pwd()); | |
58 | } | |
59 | } | |
60 | } | |
61 | ||
62 | ||
63 | // AliRoot libraries | |
64 | if(analysisMode=="local" || analysisMode=="grid") { | |
65 | TString loadLibraries="LoadLibraries.C"; loadLibraries.Prepend(loadMacroPath.Data()); | |
66 | gROOT->LoadMacro(loadLibraries.Data()); | |
67 | LoadLibraries(useParFiles); | |
68 | } else if (analysisMode=="proof") { | |
69 | gSystem->Load("libTree.so"); | |
70 | gSystem->Load("libGeom.so"); | |
71 | gSystem->Load("libPhysics.so"); | |
72 | gSystem->Load("libVMC.so"); | |
73 | gSystem->Load("libMinuit.so"); | |
74 | // Enable the needed packages | |
75 | //gProof->ClearPackages(); | |
76 | TString parDir="/afs/cern.ch/user/d/dainesea/code/"; | |
77 | TString parFile; | |
78 | if(!useParFiles) { | |
79 | gProof->UploadPackage("AF-v4-17"); | |
80 | gProof->EnablePackage("AF-v4-17"); | |
81 | // --- Enable the PWGHFvertexingHF Package | |
82 | parFile="PWGHFvertexingHF.par"; parFile.Prepend(parDir.Data()); | |
83 | gProof->UploadPackage(parFile.Data()); | |
84 | gProof->EnablePackage("PWGHFvertexingHF"); | |
85 | } else { | |
86 | // --- Enable the STEERBase Package | |
87 | parFile="STEERBase.par"; parFile.Prepend(parDir.Data()); | |
88 | gProof->UploadPackage(parFile.Data()); | |
89 | gProof->EnablePackage("STEERBase"); | |
90 | // --- Enable the ESD Package | |
91 | parFile="ESD.par"; parFile.Prepend(parDir.Data()); | |
92 | gProof->UploadPackage(parFile.Data()); | |
93 | gProof->EnablePackage("ESD"); | |
94 | // --- Enable the AOD Package | |
95 | parFile="AOD.par"; parFile.Prepend(parDir.Data()); | |
96 | gProof->UploadPackage(parFile.Data()); | |
97 | gProof->EnablePackage("AOD"); | |
98 | // --- Enable the ANALYSIS Package | |
99 | parFile="ANALYSIS.par"; parFile.Prepend(parDir.Data()); | |
100 | gProof->UploadPackage(parFile.Data()); | |
101 | gProof->EnablePackage("ANALYSIS"); | |
102 | // --- Enable the ANALYSISalice Package | |
103 | parFile="ANALYSISalice.par"; parFile.Prepend(parDir.Data()); | |
104 | gProof->UploadPackage(parFile.Data()); | |
105 | gProof->EnablePackage("ANALYSISalice"); | |
106 | // --- Enable the CORRFW Package | |
107 | parFile="CORRFW.par"; parFile.Prepend(parDir.Data()); | |
108 | gProof->UploadPackage(parFile.Data()); | |
109 | gProof->EnablePackage("CORRFW"); | |
110 | // --- Enable the PWGHFbase Package | |
111 | parFile="PWGHFbase.par"; parFile.Prepend(parDir.Data()); | |
112 | gProof->UploadPackage(parFile.Data()); | |
113 | gProof->EnablePackage("PWGHFbase"); | |
114 | // --- Enable the PWGHFvertexingHF Package | |
115 | parFile="PWGHFvertexingHF.par"; parFile.Prepend(parDir.Data()); | |
116 | gProof->UploadPackage(parFile.Data()); | |
117 | gProof->EnablePackage("PWGHFvertexingHF"); | |
118 | } | |
119 | gProof->ShowEnabledPackages(); // show a list of enabled packages | |
120 | } | |
121 | ||
122 | ||
123 | // Create Alien plugin, if requested | |
124 | if(useAlienPlugin) { | |
125 | // if(analysisMode!="grid") {printf("Analysis mode must be grid, to use alien plugin\n"); return;} | |
126 | AliAnalysisGrid *alienHandler = CreateAlienHandler(pluginmode,useParFiles,testfileslistWithPlugin); | |
127 | if(!alienHandler) return; | |
128 | } | |
129 | ||
130 | ||
131 | //------------------------------------------------------------------- | |
132 | // Prepare input | |
133 | TChain *chainAOD = 0; | |
134 | TString dataset; // for proof | |
135 | ||
136 | if(!useAlienPlugin) { | |
137 | TString makeAODInputChain="../MakeAODInputChain.C"; makeAODInputChain.Prepend(loadMacroPath.Data()); | |
138 | if(inputMode=="list") { | |
139 | // Local files | |
140 | gROOT->LoadMacro(makeAODInputChain.Data()); | |
141 | chainAOD = MakeAODInputChain();// with this it reads ./AliAOD.root and ./AliAOD.VertexingHF.root | |
142 | //chainAOD = MakeAODInputChain("alien:///alice/cern.ch/user/r/rbala/newtrain/out_lhc08x/180100/",1,1); | |
143 | printf("ENTRIES %d\n",chainAOD->GetEntries()); | |
144 | } else if(inputMode=="xml") { | |
145 | // xml | |
146 | gROOT->LoadMacro(makeAODInputChain.Data()); | |
147 | chainAOD = MakeAODInputChain("collection_aod.xml","collection_aodHF.xml"); | |
148 | } else if(inputMode=="dataset") { | |
149 | // CAF dataset | |
150 | //gProof->ShowDataSets(); | |
151 | dataset="/ITS/dainesea/AODVertexingHF_LHC08x_180100"; | |
152 | } | |
153 | } | |
154 | ||
155 | // Create the analysis manager | |
156 | AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager"); | |
157 | mgr->SetDebugLevel(10); | |
158 | // Connect plug-in to the analysis manager | |
159 | if(useAlienPlugin) mgr->SetGridHandler(alienHandler); | |
160 | ||
161 | // Input | |
162 | AliAODInputHandler *inputHandler = new AliAODInputHandler("handler","handler for D2H"); | |
163 | if(analysisMode=="proof" ) { | |
164 | inputHandler->AddFriend("./AliAOD.VertexingHF.root"); | |
165 | //inputHandler->AddFriend("deltas/AliAOD.VertexingHF.root"); | |
166 | if(saveProofToAlien) mgr->SetSpecialOutputLocation(proofOutdir); | |
167 | } | |
168 | mgr->SetInputEventHandler(inputHandler); | |
169 | //------------------------------------------------------------------- | |
170 | ||
171 | ||
172 | //------------------------------------------------------------------- | |
173 | // Analysis tasks (wagons of the train) | |
174 | // | |
175 | // First add the task for the PID response setting | |
176 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); | |
177 | AliAnalysisTaskSE *setupTask = AddTaskPIDResponse(kFALSE,kTRUE); | |
178 | ||
179 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDqa..C"); | |
180 | AliAnalysisTaskPIDqa *pidQA = AddTaskPIDqa(); | |
181 | ||
182 | ||
183 | TString taskName; | |
184 | ||
185 | ////// ADD THE FULL D2H TRAIN | |
186 | /*taskName="../AddD2HTrain.C"; taskName.Prepend(loadMacroPath.Data()); | |
187 | gROOT->LoadMacro(taskName.Data()); | |
188 | Bool_t readMC=kFALSE; | |
189 | AddD2HTrain(readMC);//,1,0,0,0,0,0,0,0,0,0,0);*/ | |
190 | ||
191 | ////// OR ADD INDIVIDUAL TASKS | |
192 | ||
193 | ||
194 | /* taskName="AddTaskCompareHF.C"; taskName.Prepend(loadMacroPath.Data()); | |
195 | gROOT->LoadMacro(taskName.Data()); | |
196 | AliAnalysisTaskSECompareHF *cmpTask = AddTaskCompareHF(); | |
197 | */ | |
198 | taskName="AddTaskD0Mass.C"; taskName.Prepend(loadMacroPath.Data()); | |
199 | gROOT->LoadMacro(taskName.Data()); | |
200 | AliAnalysisTaskSED0Mass *d0massTask = AddTaskD0Mass(); | |
201 | AliAnalysisTaskSED0Mass *d0massLikeSignTask = AddTaskD0Mass(1); | |
202 | /* | |
203 | taskName="AddTaskDplus.C"; taskName.Prepend(loadMacroPath.Data()); | |
204 | gROOT->LoadMacro(taskName.Data()); | |
205 | AliAnalysisTaskSEDplus *dplusTask = AddTaskDplus(); | |
206 | ||
207 | taskName="AddTaskDs.C"; taskName.Prepend(loadMacroPath.Data()); | |
208 | gROOT->LoadMacro(taskName.Data()); | |
209 | AliAnalysisTaskSEDs *dsTask = AddTaskDs(); | |
210 | ||
211 | //taskName="AddTaskSelectHF.C"; taskName.Prepend(loadMacroPath.Data()); | |
212 | //gROOT->LoadMacro(taskName.Data()); | |
213 | //AliAnalysisTaskSESelectHF *seleTask = AddTaskSelectHF(); | |
214 | ||
215 | taskName="AddTaskBkgLikeSignD0.C"; taskName.Prepend(loadMacroPath.Data()); | |
216 | gROOT->LoadMacro(taskName.Data()); | |
217 | AliAnalysisTaskSEBkgLikeSignD0 *lsD0Task = AddTaskBkgLikeSignD0(); | |
218 | ||
219 | taskName="AddTaskCFMultiVarMultiStep.C"; taskName.Prepend(loadMacroPath.Data()); | |
220 | gROOT->LoadMacro(taskName.Data()); | |
221 | AliCFHeavyFlavourTaskMultiVarMultiStep *cfmvmsTask = AddTaskCFMultiVarMultiStep(); | |
222 | ||
223 | ||
224 | taskName="AddTaskSECharmFraction.C"; | |
225 | taskName.Prepend(loadMacroPath.Data()); | |
226 | gROOT->LoadMacro(taskName.Data()); | |
227 | Int_t switchMC[5]={0,0,0,0,0}; | |
228 | Int_t ppPbPb=1;// 0 for pp, 1 for PbPb, used to siwtch on/off the removal of daughters from the primary vertex | |
229 | AliAnalysisTaskSECharmFraction *cFractTask = AddTaskSECharmFraction("standard",switchMC,readMC,kTRUE,kFALSE,"D0toKpiCharmFractCuts.root","c",ppPbPb); | |
230 | // arguments: filename,switchMC,readmc,usepid,likesign,cutfilename,containerprefix | |
231 | ||
232 | ||
233 | // attach a private task (not committed) | |
234 | // (the files MyTask.h MyTask.cxx AddMyTask.C have to be declared in plugin | |
235 | // configuration, see below) | |
236 | ||
237 | if(analysisMode.Data()=="proof") { | |
238 | gProof->LoadMacro("MyTask.cxx++g"); | |
239 | } else { | |
240 | gROOT->LoadMacro("MyTask.cxx++g"); | |
241 | } | |
242 | gROOT->LoadMacro("AddMyTask.C"); | |
243 | MyTask *myTask = AddMyTask(); | |
244 | ||
245 | ||
246 | if(analysisMode.Data()=="proof") { | |
247 | gProof->LoadMacro("AliDStarJets.cxx++g"); | |
248 | } else { | |
249 | gROOT->LoadMacro("AliDStarJets.cxx++g"); | |
250 | } | |
251 | gROOT->LoadMacro("AddTaskDStarJets.C"); | |
252 | AliDStarJets *myTask = AddTaskDStarJets(); | |
253 | */ | |
254 | //------------------------------------------------------------------- | |
255 | ||
256 | // | |
257 | // Run the analysis | |
258 | // | |
259 | if(chainAOD) printf("CHAIN HAS %d ENTRIES\n",(Int_t)chainAOD->GetEntries()); | |
260 | ||
261 | if(!mgr->InitAnalysis()) return; | |
262 | mgr->PrintStatus(); | |
263 | if(analysisMode=="grid" && !useAlienPlugin) analysisMode="local"; | |
264 | if(analysisMode!="proof") { | |
265 | mgr->StartAnalysis(analysisMode.Data(),chainAOD,nentries,firstentry); | |
266 | } else { | |
267 | // proof | |
268 | mgr->StartAnalysis(analysisMode.Data(),dataset.Data(),nentries,firstentry); | |
269 | } | |
270 | ||
271 | return; | |
272 | } | |
273 | //_____________________________________________________________________________ | |
274 | // | |
275 | AliAnalysisGrid* CreateAlienHandler(TString pluginmode="test",Bool_t useParFiles=kFALSE, TString testfileslistWithPlugin="") | |
276 | { | |
277 | // Check if user has a valid token, otherwise make one. This has limitations. | |
278 | // One can always follow the standard procedure of calling alien-token-init then | |
279 | // source /tmp/gclient_env_$UID in the current shell. | |
280 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); | |
281 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") | |
282 | plugin->SetRunMode(pluginmode.Data()); | |
283 | plugin->SetUser(); | |
284 | // Set versions of used packages | |
285 | plugin->SetAPIVersion("V1.1x"); | |
286 | plugin->SetROOTVersion(); | |
287 | plugin->SetAliROOTVersion(); | |
288 | plugin->SetNtestFiles(1); | |
289 | gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/AddGoodRuns.C"); | |
290 | ||
291 | // Declare input data to be processed. | |
292 | //************************************************ | |
293 | // Set data file list to test on local mode | |
294 | //************************************************ | |
295 | plugin->SetFileForTestMode(testfileslistWithPlugin.Data()); | |
296 | ||
297 | //************************************************ | |
298 | // Set data search pattern for DATA | |
299 | //************************************************ | |
300 | //Method 1: To create automatically xml through plugin | |
301 | plugin->SetGridDataDir("/alice/data/2010/LHC10d"); // specify LHC period | |
302 | plugin->SetDataPattern("pass2/AOD018/*AliAOD.root"); // specify reco pass and AOD set | |
303 | plugin->SetFriendChainName("./AliAOD.VertexingHF.root"); | |
304 | // OR plugin->SetFriendChainName("deltas/AliAOD.VertexingHF.root"); | |
305 | // Adds only the good runs from the Monalisa Run Condition Table | |
306 | // More than one period can be added but the period name has to be removed from GridDataDir (to be tested) | |
307 | Int_t totruns=0; | |
308 | //totruns += AddGoodRuns(plugin,"LHC10b"); // specify LHC period | |
309 | //totruns += AddGoodRuns(plugin,"LHC10c"); // specify LHC period | |
310 | totruns += AddGoodRuns(plugin,"LHC10d"); // specify LHC period | |
311 | plugin->SetNrunsPerMaster(totruns); | |
312 | ||
313 | // Method 2: Declare existing data files (e.g xml collections) | |
314 | ||
315 | //plugin->AddDataFile("/alice/cern.ch/user/r/rbala/000168068_000170593.xml"); | |
316 | // plugin->SetDataPattern("*AliAOD.root"); | |
317 | // plugin->SetFriendChainName("./AliAOD.VertexingHF.root"); | |
318 | ||
319 | //************************************************ | |
320 | // Set data search pattern for MONTECARLO | |
321 | //************************************************ | |
322 | /* | |
323 | plugin->SetGridDataDir("/alice/sim/LHC10d3"); // specify MC sample | |
324 | plugin->SetDataPattern("AOD005/*AliAOD.root"); // specify AOD set | |
325 | plugin->SetFriendChainName("./AliAOD.VertexingHF.root"); | |
326 | // OR plugin->SetFriendChainName("deltas/AliAOD.VertexingHF.root"); | |
327 | // Adds only the good runs from the Monalisa Run Condition Table | |
328 | // More than one period can be added! | |
329 | Int_t totruns=0; | |
330 | totruns += AddGoodRuns(plugin,"LHC10b","LHC10d3"); // specify LHC period for anchor runs; and the name of the MC production | |
331 | //totruns += AddGoodRuns(plugin,"LHC10c","LHC10f7"); // specify LHC period for anchor runs; and the name of the MC production | |
332 | //totruns += AddGoodRuns(plugin,"LHC10d","LHC10f7"); // specify LHC period for anchor runs; and the name of the MC production | |
333 | plugin->SetNrunsPerMaster(totruns); | |
334 | */ | |
335 | // | |
336 | // Define alien work directory where all files will be copied. Relative to alien $HOME. | |
337 | plugin->SetGridWorkingDir("myHFanalysis"); | |
338 | // Name of executable | |
339 | plugin->SetExecutable("myHFanalysis.sh"); | |
340 | // Declare alien output directory. Relative to working directory. | |
341 | plugin->SetGridOutputDir("output"); // In this case will be $HOME/work/output | |
342 | // Declare the analysis source files names separated by blancs. To be compiled runtime | |
343 | // using ACLiC on the worker nodes. | |
344 | //plugin->SetAnalysisSource("AliDStarJets.cxx"); | |
345 | // Declare all libraries (other than the default ones for the framework. These will be | |
346 | // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. | |
347 | plugin->SetAdditionalLibs("libPWGflowBase.so libPWGflowTasks.so libPWGHFbase.so libPWGHFvertexingHF.so"); | |
348 | // use par files | |
349 | if(useParFiles) { | |
350 | plugin->EnablePackage("STEERBase.par"); | |
351 | plugin->EnablePackage("ESD.par"); | |
352 | plugin->EnablePackage("AOD.par"); | |
353 | plugin->EnablePackage("ANALYSIS.par"); | |
354 | plugin->EnablePackage("OADB.par"); | |
355 | plugin->EnablePackage("ANALYSISalice.par"); | |
356 | plugin->EnablePackage("CORRFW.par"); | |
357 | plugin->EnablePackage("PWGHFbase.par"); | |
358 | plugin->EnablePackage("PWGHFvertexingHF.par"); | |
359 | } | |
360 | 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/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_ROOT/TRD -I$ALICE_ROOT/macros -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/OADB -I$ALICE_ROOT/PWGHF -I$ALICE_ROOT/PWGHF/base -I$ALICE_ROOT/PWGHF/vertexingHF -I$ALICE_ROOT/PWG/FLOW/Base -I$ALICE_ROOT/PWG/FLOW/Tasks -g"); | |
361 | ||
362 | plugin->SetDefaultOutputs(kTRUE); | |
363 | // merging via jdl | |
364 | plugin->SetMergeViaJDL(kTRUE); | |
365 | plugin->SetOneStageMerging(kFALSE); | |
366 | plugin->SetMaxMergeStages(2); | |
367 | ||
368 | // Optionally set a name for the generated analysis macro (default MyAnalysis.C) | |
369 | plugin->SetAnalysisMacro("AnalysisHF.C"); | |
370 | // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) | |
371 | // Optionally modify the name of the generated JDL (default analysis.jdl) | |
372 | plugin->SetJDLName("TaskHF.jdl"); | |
373 | ||
374 | return plugin; | |
375 | } |