TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / macros / train_old / AnalysisSetup.C
CommitLineData
4873fa4a 1//
2// This macro sets all the aspects of configuration of an Analysis Train run
3// which are always the same for all kinds of analysis (local, PROOF, AliEn)
4//
5// Inputs:
6//
7// - taskList = a string containin all the 'add-task' macros to be used
8// - options = a set of keywords which drive some configurations
9// - outputFileName = name of file produced by train
10// - configPath = a path where all required config macros are stored
11//
12// Notes:
13//
14// - in case the source is an ESD, and if inputs are a MC production
15// the MC input handler is created by default
16//
17Bool_t AnalysisSetup
18(
19 Bool_t isMC,
20 const char *options,
21 const char *outputFileName,
22 const char *configPath
23)
24{
25 //
26 // === EXAMINE OPTIONS ==========================================================================
27 //
28
29 // this is done using the utility 'RsnOptions.C'
30 // which provides a unique way to interpret them
31
32 TString opt(options);
33 opt.ToUpper();
34 opt.ReplaceAll(" ", "");
35
36 Bool_t isMix = opt.Contains("MIX");
37 Bool_t isESD = opt.Contains("ESD");
38 Bool_t isAOD = opt.Contains("AOD");
39 Bool_t central = opt.Contains("CEN");
40 Bool_t peripheral = opt.Contains("PER");
af472fff 41 Bool_t useTender = opt.Contains("Tender");
4873fa4a 42 Bool_t usePhysSel = opt.Contains("PHYS");
43 Bool_t noV0 = opt.Contains("NOV0");
44
45 //
46 // === LOAD LIBRARIES ===========================================================================
47 //
48
49 gSystem->Load("libVMC.so");
50 gSystem->Load("libTree.so");
51 gSystem->Load("libPhysics.so");
52 gSystem->Load("libMatrix.so");
53 gSystem->Load("libMinuit.so");
54 gSystem->Load("libXMLParser.so");
55 gSystem->Load("libGui.so");
56 gSystem->Load("libSTEERBase.so");
57 gSystem->Load("libESD.so");
58 gSystem->Load("libAOD.so");
59 gSystem->Load("libANALYSIS.so");
60 gSystem->Load("libANALYSISalice.so");
61 gSystem->Load("libEventMixing.so");
62 gSystem->Load("libCORRFW.so");
63
64 if (useTender) {
65 ::Info("AnalysisSetup", "Loading tender libraries");
af472fff 66 gSystem->Load("libTender.so");
67 gSystem->Load("libTenderSupplies.so");
4873fa4a 68 }
69
70 if (!AliAnalysisAlien::SetupPar("PWG2resonances.par")) return kFALSE;
71
72 //
73 // === ANALYSIS MANAGER CONFIGURATION ===========================================================
74 //
75
76 // create analysis manager
77 AliAnalysisManager *mgr = new AliAnalysisManager("RsnAnalysisManager");
78 mgr->SetCommonFileName(outputFileName);
79 ::Info("AnalysisSetup", "Common file name: %s", outputFileName);
80
81 //
82 // === INPUT / OUTPUT HANDLER CONFIGURATION =====================================================
83 //
84
85 // create input handler
86 // since there is an exit point above if the job
87 // isn't either ESD or AOD, here we don't recheck that
88 if (isESD) {
89 ::Info("AnalysisSetup", "Configuring for ESD");
90 AliESDInputHandler *esdHandler = new AliESDInputHandler();
91 mgr->SetInputEventHandler(esdHandler);
92 // if possible, create also MC handler
93 if (isMC) {
94 ::Info("AnalysisSetup", "Creating MC handler");
95 AliMCEventHandler *mcHandler = new AliMCEventHandler();
96 mgr->SetMCtruthEventHandler(mcHandler);
97 }
98 } else if (isAOD) {
99 ::Info("AnalysisSetup", "Configuring for AOD");
100 AliAODInputHandler *aodHandler = new AliAODInputHandler();
101 mgr->SetInputEventHandler(aodHandler);
102 } else {
103 ::Error("AnalysisSetup", "Require ESD or AOD");
104 return kFALSE;
105 }
106
107 //
af472fff 108 // === CONFIGURE AND INSERT PHYSICS SELECTION & Tender SUPPLY ===================================
4873fa4a 109 //
110
111 // add event selection for data if running ESD
112 if (isESD) {
113 // add tender supply for TOF
114 if (useTender) {
115 ::Info("AnalysisSetup", "options '%s' require to add tender", options);
116 gROOT->LoadMacro(Form("%s/AddTenderSupplies.C", configPath));
117 AddTenderSupplies(100.0, kTRUE, kFALSE);
118 }
119
120 // add event selection for data
121 // and swtich off VZERO if tender is not used
122 if (usePhysSel) {
123 ::Info("AnalysisSetup", "options '%s' require to add physics selection", options);
124 gROOT->LoadMacro("$(ALICE_ROOT)/ANALYSIS/macros/AddTaskPhysicsSelection.C");
125 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(isMC);
126 if (noV0) {
127 ::Info("AnalysisSetup", "options '%s' require to skip V0 info", options);
128 physSelTask->GetPhysicsSelection()->SetSkipV0(kTRUE);
129 }
130 }
131 }
132
133 ::Info("AnalysisSetup", "Setup successful");
134 return kTRUE;
135}