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