]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/RESONANCES/macros/train/AnalysisSetup.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / macros / train / AnalysisSetup.C
CommitLineData
00163883 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 Int_t nmix,
21 const char *options,
22 const char *outputFileName,
23 const char *configPath
24)
25{
26 //
27 // === EXAMINE OPTIONS ==========================================================================
28 //
29
30 // this is done using the utility 'RsnOptions.C'
31 // which provides a unique way to interpret them
32
33 TString opt(options);
34 opt.ToUpper();
35 opt.ReplaceAll(" ", "");
36
37 Bool_t isMix = (nmix > 0);
38 Bool_t isESD = opt.Contains("ESD");
39 Bool_t isAOD = opt.Contains("AOD");
af472fff 40 Bool_t useTender = opt.Contains("Tender");
00163883 41 Bool_t usePhysSel = opt.Contains("PHYS");
42 Bool_t noV0 = opt.Contains("NOV0");
43 Bool_t useCent = opt.Contains("CENT");
44
45 //
46 // === LOAD LIBRARIES ===========================================================================
47 //
48
4070f709 49 gSystem->Load("libVMC");
50 gSystem->Load("libTree");
51 gSystem->Load("libPhysics");
52 gSystem->Load("libMatrix");
53 gSystem->Load("libMinuit");
54 gSystem->Load("libXMLParser");
55 gSystem->Load("libGui");
56 gSystem->Load("libSTEERBase");
57 gSystem->Load("libESD");
58 gSystem->Load("libAOD");
59 gSystem->Load("libANALYSIS");
60 gSystem->Load("libANALYSISalice");
61 gSystem->Load("libEventMixing");
62 gSystem->Load("libCORRFW");
00163883 63
64 if (useTender) {
65 ::Info("AnalysisSetup", "Loading tender libraries");
4070f709 66 gSystem->Load("libTender");
67 gSystem->Load("libTenderSupplies");
00163883 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 ::Info("AnalysisSetup", "Using Multi Handler");
86 // create multi input event handler
87 AliMultiInputEventHandler *multiHandler = new AliMultiInputEventHandler();
88
89 // since there is an exit point above if the job
90 // isn't either ESD or AOD, here we don't recheck that
91 if (isESD) {
92 ::Info("AnalysisSetup", "Creating ESD handler");
93 AliESDInputHandler *esdHandler = new AliESDInputHandler();
94 multiHandler->AddInputEventHandler(esdHandler);
95
96 // if possible, create also MC handler
97 if (isMC) {
98 ::Info("AnalysisSetup", "Creating MC handler");
99 AliMCEventHandler *mcHandler = new AliMCEventHandler();
100 multiHandler->AddInputEventHandler(mcHandler);
101 }
102 } else {
103 ::Info("AnalysisSetup", "Creating AOD handler");
104 AliAODInputHandler *aodHandler = new AliAODInputHandler();
105 multiHandler->AddInputEventHandler(aodHandler);
106 }
107
108 // add RSN input handler
109 ::Info("AnalysisSetup", "Adding RSN input handler");
110 gROOT->LoadMacro(Form("%s/AddRsnInputHandler.C", configPath));
111 AddRsnInputHandler(isMC, multiHandler);
112
113 // set the input event handler for manager
114 mgr->SetInputEventHandler(multiHandler);
115
116 // set event mixing properties, if required
117 if (isMix) {
118 ::Info("AnalysisSetup", "Setting mixing to n = %d", nmix);
119 // define mixing handler
120 AliMixInputEventHandler *mixHandler = new AliMixInputEventHandler(1, nmix);
121 mixHandler->SetInputHandlerForMixing(multiHandler);
122
123 // define binnings
124 AliMixEventPool *evPool = new AliMixEventPool();
125 AliMixEventCutObj *multip = new AliMixEventCutObj(AliMixEventCutObj::kMultiplicity, 1., 10000., 1000.);
126 AliMixEventCutObj *zvertex = new AliMixEventCutObj(AliMixEventCutObj::kZVertex, -10., 10., 4.);
127 AliMixEventCutObj *cent = new AliMixEventCutObj(AliMixEventCutObj::kCentrality, 0.0, 100.0, 10.0, "V0M");
128
129 // add cuts to handler and handler to manager
130 evPool->AddCut(zvertex);
131 if (useCent) evPool->AddCut(cent); else evPool->AddCut(multip);
132 mixHandler->SetEventPool(evPool);
133 multiHandler->AddInputEventHandler(mixHandler);
134 }
135
136 //
af472fff 137 // === CONFIGURE AND INSERT PHYSICS SELECTION & Tender SUPPLY ===================================
00163883 138 //
139
140 // add event selection for data if running ESD
141 if (isESD) {
142 // add tender supply for TOF
143 if (useTender) {
144 ::Info("AnalysisSetup", "options '%s' require to add tender", options);
145 gROOT->LoadMacro(Form("%s/AddTenderSupplies.C", configPath));
146 AddTenderSupplies(100.0, kTRUE, kFALSE);
147 }
148
149 // add event selection for data
150 // and swtich off VZERO if tender is not used
151 if (usePhysSel) {
152 ::Info("AnalysisSetup", "options '%s' require to add physics selection", options);
63b6cbd0 153 gROOT->LoadMacro("$(ALICE_ROOT)/OADB/macros/AddTaskPhysicsSelection.C");
00163883 154 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(isMC);
155 if (noV0) {
156 ::Info("AnalysisSetup", "options '%s' require to skip V0 info", options);
157 physSelTask->GetPhysicsSelection()->SetSkipV0(kTRUE);
158 }
159 if (multiHandler) {
160 AliESDInputHandler *esdHandler = dynamic_cast<AliESDInputHandler*>(multiHandler->GetFirstInputEventHandler());
161 esdHandler->SetEventSelection(multiHandler->GetEventSelection());
162 }
163 }
164 }
165
166 // add PID response task
167 //gROOT->LoadMacro("$(ALICE_ROOT)/ANALYSIS/macros/AddTaskPIDResponse.C");
168 //AddTaskPIDResponse(isMC);
169
170 ::Info("AnalysisSetup", "Setup successful");
171 return kTRUE;
172}