]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/EBYE/macros/runBalanceFunctionPsi.C
.so cleanup: removed from gSystem->Load()
[u/mrichter/AliRoot.git] / PWGCF / EBYE / macros / runBalanceFunctionPsi.C
1 // run.C
2 //
3 // Template run macro for AliBasicTask.cxx/.h with example layout of
4 // physics selections and options, in macro and task.
5 //
6 // Author: Arvinder Palaha
7 //
8 class AliAnalysisGrid;
9 class AliAnalysisTaskBF;
10 class AliBalance;
11
12 //Centrality stuff
13 Int_t binfirst = 0;  //where do we start numbering bins
14 Int_t binlast = 8;  //where do we stop numbering bins
15 const Int_t numberOfCentralityBins = 9;
16 Double_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
17
18 //Systematic studies
19 const Int_t numberOfSyst = 13;
20 Float_t vZ[numberOfSyst]     = {10.,12.,6.,8.,10.,10.,10.,10.,10.,10.,10.,10.,10.};     // global Vertex Z cut
21 Float_t DCAxy[numberOfSyst]  = {-1.,2.4,2.4,2.4,2.2,2.0,1.8,2.4,2.4,2.4,2.4,2.4,2.4};   // DCA xy cut (afterburner, -1 = w/o additional cut)
22 Float_t DCAz[numberOfSyst]   = {-1.,3.2,3.2,3.2,3.0,2.8,2.6,3.2,3.2,3.2,3.2,3.2,3.2};   // DCA z cut (afterburner, -1 = w/o additional cut)
23 Float_t ptMin[numberOfSyst]  = {0.3,0.3,0.3,0.3,0.3,0.3,0.3,1.5,5.0,0.3,0.3,0.3,0.3};   // pt cuts
24 Float_t ptMax[numberOfSyst]  = {5.,1.5,1.5,1.5,1.5,1.5,1.5,5.0,10.0,10.0,1.5,1.5,1.5}; // pt cuts
25 Float_t etaMin[numberOfSyst] = {-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-1.0,-0.6,-0.4}; // eta cuts
26 Float_t etaMax[numberOfSyst] = {0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,1.0,0.6,0.4};   // eta cuts
27
28 Bool_t kUsePID = kFALSE;
29 Bool_t bUseHBTCut = kTRUE;
30 Bool_t bUseConversionCut = kTRUE;
31 Bool_t bResonancesCut = kTRUE;
32 Bool_t bMomentumDifferenceCut = kTRUE;
33 Int_t kNSigmaElectronRejection = 3;
34
35 //______________________________________________________________________________
36 void runBalanceFunctionPsi(
37          const char* runtype = "local", // local, proof or grid
38          const char *gridmode = "test", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof
39          const Int_t bunchN = 0,
40          const bool bAOD = 1, // 1 = AOD ANALYSIS, 0 = ESD ANALYSIS
41          const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data)
42          const bool bMCphyssel = 1, // 1 = looking at MC truth or reconstructed, 0 = looking at real data
43          const Long64_t nentries = 50000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events.
44          const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode
45          TString proofdataset = "bunchPROOF", // path to dataset on proof cluster, for proof analysis
46          const char *proofcluster = "miweber@alice-caf.cern.ch", // which proof cluster to use in proof mode
47          const char *taskname = "BF_Syst_Test" // sets name of grid generated macros
48          )
49 {
50     // check run type
51     if(runtype != "local" && runtype != "proof" && runtype != "grid") {
52         Printf("\n\tIncorrect run option, check first argument of run macro");
53         Printf("\tint runtype = local, proof or grid\n");
54         return;
55     }
56     Printf("%s analysis chosen",runtype);
57   
58     // load libraries
59     gSystem->Load("libCore");
60     gSystem->Load("libGeom");
61     gSystem->Load("libVMC");
62     gSystem->Load("libPhysics");
63     gSystem->Load("libTree");
64     gSystem->Load("libSTEERBase");
65     gSystem->Load("libESD");
66     gSystem->Load("libAOD");
67     gSystem->Load("libANALYSIS");
68     gSystem->Load("libANALYSISalice");
69     gSystem->Load("libEventMixing");
70     gSystem->Load("libCORRFW");
71     gSystem->Load("libPWGTools");
72     gSystem->Load("libPWGCFebye");
73
74     // additional
75
76     // compile standalone stuff
77     //gROOT->LoadMacro("AliBalance.cxx++g");
78     //gROOT->LoadMacro("AliAnalysisTaskBF.cxx++g");
79
80     // add aliroot indlude path
81     //gROOT->ProcessLine(".include $PWD/.");
82     //gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT")));
83
84     gROOT->SetStyle("Plain");
85
86     // analysis manager
87     AliAnalysisManager* mgr = new AliAnalysisManager(Form("%s%i",taskname,bunchN));
88     
89     // create the alien handler and attach it to the manager
90     if(runtype == "grid") {
91       AliAnalysisGrid *plugin = CreateAlienHandler(bAOD,bunchN,Form("%s%i",taskname,bunchN), gridmode, proofcluster, Form("%s_%d.txt",proofdataset.Data(),bunchN)); 
92       mgr->SetGridHandler(plugin);
93     }
94     else if(runtype == "local") {
95       TString filename;
96       TChain* chain = 0x0;
97       if((!bAOD)&&(!bMCtruth)) {
98         chain = new TChain("esdTree");
99         for(Int_t i = 0; i < 4; i++) {
100           filename = "/data/alice2/pchrist/HeavyIons/Data/2011/Set";
101           filename += i; filename += "/AliESDs.root";
102           chain->Add(filename.Data());
103         }
104       }
105       else if((bAOD)&&(!bMCtruth)) {
106         chain = new TChain("aodTree");
107         for(Int_t i = 1; i < 20; i++) {
108           filename = "/glusterfs/alice1/alice2/pchrist/pp/LHC10c/7TeV/Data/Set";
109           filename += i; filename += "/AliAOD.root";
110           chain->Add(filename.Data());
111         }
112       }
113       else if((!bAOD)&&(bMCtruth)) {
114         chain = new TChain("TE");
115         for(Int_t i = 10; i < 99; i++) {
116           filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/";
117           filename += i;
118           filename += "/galice.root";
119           chain->Add(filename.Data());
120         }
121       }
122       else if((bAOD)&&(bMCtruth)) { //used for MCAOD
123         chain = new TChain("aodTree");   
124         for(Int_t i = 10; i < 99; i++) { 
125           filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/";
126           filename += i; 
127           filename += "/AliAOD.root";
128           chain->Add(filename.Data());
129         } 
130       }
131       
132
133     }//local mode
134
135     // input handler (ESD or AOD)
136     AliVEventHandler* inputH = NULL;
137     if(!bAOD){
138       inputH = new AliESDInputHandler();
139     }
140     else{
141       inputH = new AliAODInputHandler();
142     }
143     mgr->SetInputEventHandler(inputH);
144     
145     // mc event handler
146     if(bMCtruth) {
147       AliMCEventHandler* mchandler = new AliMCEventHandler();
148       // Not reading track references
149       mchandler->SetReadTR(kFALSE);
150       mgr->SetMCtruthEventHandler(mchandler);
151     }   
152     
153     // AOD output handler
154     //AliAODHandler* aodoutHandler = new AliAODHandler();
155     //aodoutHandler->SetOutputFileName("aod.root");
156     //mgr->SetOutputEventHandler(aodoutHandler); 
157     
158     // === Physics Selection Task ===
159     //
160     // In SelectCollisionCandidate(), default is kMB, so the task UserExec() 
161     // function is only called for these events.
162     // Options are:
163     //    kMB             Minimum Bias trigger
164     //    kMBNoTRD        Minimum bias trigger where the TRD is not read out
165     //    kMUON           Muon trigger
166     //    kHighMult       High-Multiplicity Trigger
167     //    kUserDefined    For manually defined trigger selection
168     //
169     // Multiple options possible with the standard AND/OR operators && and ||
170     // These all have the usual offline SPD or V0 selections performed.
171     //
172     // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(),
173     // one can manually set the selected and background classes using:
174     //    AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL")
175     //    AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL");
176     //
177     // One can also specify multiple classes at once, or require a class to NOT
178     // trigger, for e.g.
179     //    AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL");
180     //
181     // NOTE that manually setting the physics selection overrides the standard
182     // selection, so it must be done in completeness.
183     //
184     // ALTERNATIVELY, one can make the physics selection inside the task
185     // UserExec().
186     // For this case, comment out the task->SelectCol.... line, 
187     // and see AliBasicTask.cxx UserExec() function for details on this.
188
189     //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
190     //AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel);
191     //if(!physSelTask) { Printf("no physSelTask"); return; }
192     //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection();
193     //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769");
194                 
195     // create task
196     //Add the centrality determination task and the physics selection 
197     // (only on ESD level, in AODs centrality is already in header and events are selected)
198     if((!bAOD)&&(!bMCtruth)){
199       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
200       AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
201
202       // Add physics selection task (NOT needed for AODs)
203       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
204       AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(bMCphyssel);
205     }
206
207     //Add the PID response
208     if((kUsePID)||(kNSigmaElectronRejection)) {
209       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
210       AddTaskPIDResponse(bMCphyssel); 
211     }
212
213     //Add the VZERO event plane task
214     gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C"); 
215     AliVZEROEPSelectionTask* epSelTask = AddTaskVZEROEPSelection();
216
217     //Add the BF task (all centralities)
218     gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C"); 
219
220     AliAnalysisTaskBFPsi *taskBF = AddTaskBalancePsiCentralityTrain(0, 500, kFALSE, kTRUE, kFALSE, "V0M", 10, -1, -1, 0.2, 20.0, -0.8, 0.8, -1, -1, kUsePID, kFALSE, kTRUE, 0.02, kFALSE, 0.04, kTRUE, 0.1, 128, 1, "AnalysisResults","TE","Multiplicity","AOD",kTRUE, kNSigmaElectronRejection);
221     //taskBF->SetDebugLevel();
222
223     // enable debug printouts
224     //mgr->SetDebugLevel(2);
225     //mgr->SetUseProgressBar(1,100);
226     if (!mgr->InitAnalysis()) return;
227     mgr->PrintStatus();
228   
229     // start analysis
230     Printf("Starting Analysis....");
231     if(runtype == "local") 
232       mgr->StartAnalysis("local",chain);
233     else
234       mgr->StartAnalysis(runtype,nentries,firstentry);
235 }
236
237 //______________________________________________________________________________
238 AliAnalysisGrid* CreateAlienHandler(Bool_t bAOD, Int_t bunchN, const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset)
239 {
240     AliAnalysisAlien *plugin = new AliAnalysisAlien();
241     // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
242     plugin->SetRunMode(gridmode);
243
244     // Set versions of used packages
245     plugin->SetAPIVersion("V1.1x");
246     plugin->SetROOTVersion("v5-28-00d");
247     plugin->SetAliROOTVersion("v5-02-05-AN");
248
249     // Declare input data to be processed.
250
251     // Method 1: Create automatically XML collections using alien 'find' command.
252     // Define production directory LFN
253     plugin->SetGridDataDir("/alice/data/2010/LHC10h/");
254     // On real reconstructed data:
255     // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
256
257     // Set data search pattern
258     //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES
259     // Data pattern for reconstructed data
260     if(!bAOD){
261       plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
262     } 
263     else{
264       plugin->SetDataPattern("*ESDs/pass2/AOD049/*/AliAOD.root");
265     }
266
267     plugin->SetRunPrefix("000");   // real data
268     // ...then add run numbers to be considered
269     //plugin->SetRunRange(114917,115322);
270
271     if(bunchN==0){
272       plugin->AddRunNumber(137366);
273     }
274     
275     //bunch1
276     else if(bunchN == 1){
277       plugin->AddRunNumber(139510);
278       plugin->AddRunNumber(139507);
279       plugin->AddRunNumber(139505);
280       plugin->AddRunNumber(139503); 
281       plugin->AddRunNumber(139465); 
282       plugin->AddRunNumber(139438);
283       plugin->AddRunNumber(139437);
284       plugin->AddRunNumber(139360); 
285       plugin->AddRunNumber(139329);
286       plugin->AddRunNumber(139328); 
287     }
288
289     //bunch2
290     else if(bunchN == 2){
291       plugin->AddRunNumber(139314); 
292       plugin->AddRunNumber(139310);
293       plugin->AddRunNumber(139309); 
294       plugin->AddRunNumber(139173); 
295       plugin->AddRunNumber(139107); 
296       plugin->AddRunNumber(139105); 
297       plugin->AddRunNumber(139038); 
298       plugin->AddRunNumber(139037); 
299       plugin->AddRunNumber(139036); 
300       plugin->AddRunNumber(139029); 
301       plugin->AddRunNumber(139028); 
302       plugin->AddRunNumber(138872); 
303       plugin->AddRunNumber(138871); 
304       plugin->AddRunNumber(138870); 
305       plugin->AddRunNumber(138837); 
306       plugin->AddRunNumber(138732); 
307       plugin->AddRunNumber(138730);
308       plugin->AddRunNumber(138666);
309       plugin->AddRunNumber(138662); 
310       plugin->AddRunNumber(138653); 
311     }
312
313     else if(bunchN == 3){
314       plugin->AddRunNumber(138652);
315       plugin->AddRunNumber(138638);
316       plugin->AddRunNumber(138624); 
317       plugin->AddRunNumber(138621); 
318       plugin->AddRunNumber(138583); 
319       plugin->AddRunNumber(138582); 
320       plugin->AddRunNumber(138579); 
321       plugin->AddRunNumber(138578);
322       plugin->AddRunNumber(138534);
323       plugin->AddRunNumber(138469); 
324     }
325
326     else if(bunchN == 4){
327       
328       plugin->AddRunNumber(138442);
329       plugin->AddRunNumber(138439);
330       plugin->AddRunNumber(138438);
331       plugin->AddRunNumber(138396); 
332       plugin->AddRunNumber(138364); 
333       plugin->AddRunNumber(138275); 
334       plugin->AddRunNumber(138225); 
335       plugin->AddRunNumber(138201);
336       plugin->AddRunNumber(138197); 
337       plugin->AddRunNumber(138192); 
338     }
339
340     else if(bunchN == 5){
341
342       plugin->AddRunNumber(138190);
343       plugin->AddRunNumber(137848); 
344       plugin->AddRunNumber(137844); 
345       plugin->AddRunNumber(137752); 
346       plugin->AddRunNumber(137751); 
347       plugin->AddRunNumber(137724); 
348       plugin->AddRunNumber(137722); 
349       plugin->AddRunNumber(137718); 
350       plugin->AddRunNumber(137704); 
351       plugin->AddRunNumber(137693);
352     }
353
354     else if(bunchN == 6){
355
356       plugin->AddRunNumber(137692); 
357       plugin->AddRunNumber(137691); 
358       plugin->AddRunNumber(137686); 
359       plugin->AddRunNumber(137685); 
360       plugin->AddRunNumber(137639); 
361       plugin->AddRunNumber(137638);
362       plugin->AddRunNumber(137608); 
363       plugin->AddRunNumber(137595);
364       plugin->AddRunNumber(137549);
365       plugin->AddRunNumber(137546); 
366
367     }
368
369     else if(bunchN == 7){
370
371       plugin->AddRunNumber(137544); 
372       plugin->AddRunNumber(137541); 
373       plugin->AddRunNumber(137539); 
374       plugin->AddRunNumber(137531); 
375       plugin->AddRunNumber(137530); 
376       plugin->AddRunNumber(137443); 
377       plugin->AddRunNumber(137441); 
378       plugin->AddRunNumber(137440); 
379       plugin->AddRunNumber(137439); 
380       plugin->AddRunNumber(137434); 
381
382     }
383
384     else if(bunchN == 8){
385
386       plugin->AddRunNumber(137432); 
387       plugin->AddRunNumber(137431); 
388       plugin->AddRunNumber(137430); 
389       plugin->AddRunNumber(137366); 
390       plugin->AddRunNumber(137243); 
391       plugin->AddRunNumber(137236);
392       plugin->AddRunNumber(137235);
393       plugin->AddRunNumber(137232); 
394       plugin->AddRunNumber(137231); 
395       plugin->AddRunNumber(137162); 
396       plugin->AddRunNumber(137161);
397     }
398
399     else{
400
401       stderr<<"BUNCH NOT THERE"<<endl;
402       return NULL;
403
404     }
405
406
407     //plugin->AddRunList("139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137430, 137366, 137243, 137236, 137235, 137232, 137231, 137162, 137161");
408
409
410
411
412
413     plugin->SetNrunsPerMaster(1);
414     plugin->SetOutputToRunNo();
415     // comment out the next line when using the "terminate" option, unless
416     // you want separate merged files for each run
417     plugin->SetMergeViaJDL();
418
419     // Method 2: Declare existing data files (raw collections, xml collections, root file)
420     // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
421     // XML collections added via this method can be combined with the first method if
422     // the content is compatible (using or not tags)
423     //   plugin->AddDataFile("tag.xml");
424     //   plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
425
426     // Define alien work directory where all files will be copied. Relative to alien $HOME.
427     plugin->SetGridWorkingDir(taskname);
428
429     // Declare alien output directory. Relative to working directory.
430     plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
431
432    // Declare the analysis source files names separated by blancs. To be compiled runtime
433     // using ACLiC on the worker nodes.
434     plugin->SetAnalysisSource("AliBalance.cxx AliAnalysisTaskBF.cxx");
435
436     // Declare all libraries (other than the default ones for the framework. These will be
437     // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
438     //plugin->AddIncludePath("-I.");
439     //plugin->SetAdditionalLibs("libPWGCFebye.so");
440     plugin->SetAdditionalLibs("AliBalance.cxx AliBalance.h AliAnalysisTaskBF.cxx AliAnalysisTaskBF.h");
441
442      // Declare the output file names separated by blancs.
443     // (can be like: file.root or file.root@ALICE::Niham::File)
444     // To only save certain files, use SetDefaultOutputs(kFALSE), and then
445     // SetOutputFiles("list.root other.filename") to choose which files to save
446     plugin->SetDefaultOutputs();
447     //plugin->SetOutputFiles("list.root");
448
449     // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
450     plugin->SetAnalysisMacro(Form("%s.C",taskname));
451
452     // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
453     plugin->SetSplitMaxInputFileNumber(100);
454
455     // Optionally modify the executable name (default analysis.sh)
456     plugin->SetExecutable(Form("%s.sh",taskname));
457
458     // set number of test files to use in "test" mode
459     plugin->SetNtestFiles(1);
460
461     // Optionally resubmit threshold.
462     plugin->SetMasterResubmitThreshold(90);
463
464     // Optionally set time to live (default 30000 sec)
465     plugin->SetTTL(90000);
466
467     // Optionally set input format (default xml-single)
468     plugin->SetInputFormat("xml-single");
469
470     // Optionally modify the name of the generated JDL (default analysis.jdl)
471     plugin->SetJDLName(Form("%s.jdl",taskname));
472
473     // Optionally modify job price (default 1)
474     plugin->SetPrice(1);      
475
476     // Optionally modify split mode (default 'se')    
477     plugin->SetSplitMode("se");
478
479     //plugin->SetUseSubmitPolicy();
480     //plugin->SetKeepLogs();
481     
482     //----------------------------------------------------------
483     //---      PROOF MODE SPECIFIC SETTINGS         ------------
484     //---------------------------------------------------------- 
485     // Proof cluster
486     plugin->SetProofCluster(proofcluster);
487     // Dataset to be used   
488     plugin->SetProofDataSet(proofdataset);
489     // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
490     plugin->SetProofReset(0);
491     // May limit number of workers
492     plugin->SetNproofWorkers(0);
493     // May limit the number of workers per slave
494     plugin->SetNproofWorkersPerSlave(1);   
495     // May use a specific version of root installed in proof
496     plugin->SetRootVersionForProof("current");
497     // May set the aliroot mode. Check http://aaf.cern.ch/node/83 
498     plugin->SetAliRootMode("default"); // Loads AF libs by default
499     // May request ClearPackages (individual ClearPackage not supported)
500     plugin->SetClearPackages(kFALSE);
501     // Plugin test mode works only providing a file containing test file locations, used in "local" mode also
502     plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc
503     // Request connection to alien upon connection to grid
504     plugin->SetProofConnectGrid(kFALSE);
505
506     plugin->Print();
507
508     return plugin;
509 }
510