]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/EBYE/NetParticle/macros/AddTaskNetParticle.C
Fixing bug in NetParticle
[u/mrichter/AliRoot.git] / PWGCF / EBYE / NetParticle / macros / AddTaskNetParticle.C
CommitLineData
cb68eb1d 1/* *********************************************************************************
2 * File : AddTaskNetParticle.C
4918c45f 3 * Authors : Jochen Thaeder <jochen@thaeder.de>
4 * Michael Weber <m.weber@cern.ch>
cb68eb1d 5 * *********************************************************************************
6 * Configuring NetParticle Task:
7 * - ARGUMENTS :
4918c45f 8 * name -> Name of the task, containing particle type :
9 * Currently : Proton, Pion, Kaon, Charge
cb68eb1d 10 * isModeDist -> Fill Distributions
11 * isModeEff -> Fill Efficiency/Contamination ThnSparse
12 * isModeDCA -> Fill DCA ThnSparse
5de3d4d1 13 * isModeQA -> Fill QA ThnSparse
a2ddc3d0 14 * isModeAOD -> Use AOD input
cb68eb1d 15 * isCreateCSC -> Prepare for CrossSectionCorrection
16 * - requires isModeEff to be set
17 * - Proton only
67dfcbcf 18 * isSetExt -> 1 if want to set pt, nSigma from arguments
19 * 0 takes default values
20 *
a2ddc3d0 21 * modeCSC -> Use differnt Pt cut for
22 * 0 : TPC+TOF
23 * 1 : TPC
24 * modeCuts -> Different Cut scenarios
25 * 0 : Standard cuts
26 * 1 : LF cuts
27 * modePID -> PID Strategy
28 * -1 : Default -> 7 (modeCuts=0) and 5 (modeCuts=1)
29 * 0 : TPC(TPClow+TPCHigh)
30 * 1 : ITS
31 * 2 : TOF
32 * 3 : ITS+TPC(TPClow+TPCHigh)
33 * 4 : TPC(TPClow+TPCHigh)+TOF
34 * 5 : TPC(TPClow+TPCHigh)+TOF for pT >= fMinPtForTOFRequired TOF is required, below, only used if there
35 * 6 : TPC(TPClow+TPCHigh)+ITS+TOF with TOF only for those tracks which have TOF information
36 * 7 : TPC(TPClow+TPCHigh)+ITS+TOF for pT >= fMinPtForTOFRequired TOF is required, below, only used if there
37 * 8 : TPC(TPClow+TPCHigh)+ITS+TOF
cb68eb1d 38 *
a2ddc3d0 39 * *********************************************************************************
40 * - PID Strategy
41 *
42* *********************************************************************************
cb68eb1d 43 * - OUTPUT CONTAINER : #N = 5
44 * (1) - Standard Output, Distributions
45 * (2) - Efficiency ThnSparse
46 * (3) - Contamination ThnSparse
47 * (4) - DCA ThnSparse
48 * (5) - QA ThnSparse
49 *
50 ********************************************************************************* */
51
67dfcbcf 52AliAnalysisTask *AddTaskNetParticle(const Char_t *name = "jthaeder_NetProton",
53 Bool_t isModeDist = kTRUE,
54 Bool_t isModeEff = kFALSE,
55 Bool_t isModeDCA = kFALSE,
56 Bool_t isModeQA = kFALSE,
57 Bool_t isCreateCSC = kFALSE,
58 Bool_t isModeAOD = kFALSE,
59 Bool_t isSetExt = kFALSE,
60 Int_t aodFilterBit = 1024, /* 1024 = RAA cuts */
61 Int_t modeCSC = 0,
62 Int_t modeCuts = 0,
63 Int_t modePID =-1,
64 Float_t gMinPt = 0.3,
65 Float_t gMaxPt = 2.5,
66 Float_t gMinPtForTof = 0.21,
67 Float_t gSigmaITS = 4.0,
68 Float_t gSigmaTPC = 4.0,
69 Float_t gSigmaTPClow = 3.0,
70 Float_t gSigmaTOF = 4.0) {
cb68eb1d 71
72 TString sName(name);
73
74 if (isCreateCSC && !isModeEff) {
75 Error("AddTaskNetParticle", "Creating CrossSectionCorrection needs 'isModeEff' to be set.");
76 return NULL;
77 }
78
79 // ----------------------------------------------
80 // -- Get the current analysis manager
81 // ----------------------------------------------
82 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
83 if (!mgr) {
84 Error("AddTaskNetParticle", "No analysis manager found.");
85 return NULL;
86 }
87
88 // ----------------------------------------------
89 // -- Check for MC
90 // ----------------------------------------------
91 Bool_t isMC = (mgr->GetMCtruthEventHandler() != NULL);
92 if (isMC)
93 Info("AddTaskNetParticle", "This task has MC.");
94
95 // ----------------------------------------------
478c95cf 96 // -- Create task
cb68eb1d 97 // ----------------------------------------------
98 AliAnalysisTaskNetParticle *task = new AliAnalysisTaskNetParticle("AliAnalysisTaskNetParticle");
99 if (!task) {
100 Error("AddTaskNetParticle", "Task could not be created.");
101 return NULL;
102 }
103
478c95cf 104 // ----------------------------------------------
105 // -- Configure flags
106 // ----------------------------------------------
cb68eb1d 107 if (isMC)
108 task->SetIsMC();
478c95cf 109 if (isModeEff)
67dfcbcf 110 task->SetModeEffCreation(1); // => 1 = on | 0 = off (default)
478c95cf 111 if (isModeDCA)
67dfcbcf 112 task->SetModeDCACreation(1); // => 1 = on | 0 = off (default)
478c95cf 113 if (isModeDist)
67dfcbcf 114 task->SetModeDistCreation(1); // => 1 = on | 0 = off (default)
478c95cf 115 if (isModeAOD) {
67dfcbcf 116 task->SetIsAOD(1); // => 1 = AOD | 0 = ESD (default)
117 task->SetTrackFilterBit(aodFilterBit);
478c95cf 118 }
119 if (isModeQA)
67dfcbcf 120 task->SetModeQACreation(1); // => 1 = on | 0 = off (default)
121
478c95cf 122 // ----------------------------------------------
123 // -- Create helper class
124 // ----------------------------------------------
125 AliAnalysisNetParticleHelper *helper = new AliAnalysisNetParticleHelper;
126 if (!helper) {
127 Error("AddTaskNetParticle", "Helper could not be created.");
128 delete task;
129 return NULL;
130 }
131
132 task->SetNetParticleHelper(helper);
133
134 // ----------------------------------------------
cb68eb1d 135 // -- Set particle type
136 // ----------------------------------------------
67dfcbcf 137 Float_t minPt, maxPt, minPtEff, maxPtEff, minPtForTOF, etaMax, etaMaxEff, nSigmaITS, nSigmaTPC, nSigmaTPClow, nSigmaTOF, maxPtForTPClow;
a2ddc3d0 138 Int_t pidStrategy;
cb68eb1d 139
67dfcbcf 140
141if (sName.Contains("Proton")) {
478c95cf 142 helper->SetParticleSpecies(AliPID::kProton);
a2ddc3d0 143 minPtForTOF = 0.69; // minPtForTOF = 0.21;
144 maxPtForTPClow = 0.69;
67dfcbcf 145 minPt = 0.5; maxPt = 2.0; // minPt = 0.22; maxPt = 4.5;
146 minPtEff = 0.5; maxPtEff = 2.0; // minPtEff = 0.22; maxPtEff = 4.5;
147 etaMax = 0.8;
148 etaMaxEff = 0.8;
149 nSigmaITS = 4.0; nSigmaTPC = 4.0; nSigmaTPClow = 3.0; nSigmaTOF = 4.0;
a2ddc3d0 150
151 // For TPC only case
152 if (isCreateCSC && modeCSC == 1)
153 minPtForTOF = maxPtEff;
cb68eb1d 154 }
155 else if (sName.Contains("Pion")) {
478c95cf 156 helper->SetParticleSpecies(AliPID::kPion);
67dfcbcf 157 minPt = 0.3; maxPt = 0.6;
158 minPtEff = 0.2; maxPtEff = 1.0;
cb68eb1d 159 minPtForTOF = 0.8;
67dfcbcf 160 etaMax = 8.8;
161 etaMaxEff = 8.8;
162 nSigmaITS = 2.5; nSigmaTPC = 2.5; nSigmaTOF = 2.5;
a2ddc3d0 163 pidStrategy = 1;
cb68eb1d 164 }
165 else if (sName.Contains("Kaon")) {
478c95cf 166 helper->SetParticleSpecies(AliPID::kKaon);
67dfcbcf 167 minPt = 0.5; maxPt = 1.4;
168 minPtEff = 0.1; maxPtEff = 2.5;
e45ea6db 169 minPtForTOF = 0.5;
67dfcbcf 170 etaMax = 0.8;
171 etaMaxEff = 0.8;
172 nSigmaITS = 2.5; nSigmaTPC = 2.5; nSigmaTOF = 2.5;
a2ddc3d0 173 pidStrategy = 1;
478c95cf 174 }
175 else if (sName.Contains("Charge")) {
176 helper->SetUsePID(kFALSE);
67dfcbcf 177 minPt = 0.3; maxPt = 2.5;
178 minPtEff = 0.1; maxPtEff = 3.0;
179 minPtForTOF =-1.0;
180 etaMax = 0.8;
181 etaMaxEff = 0.8;
182 nSigmaITS = -1.; nSigmaTPC = -1.; nSigmaTOF = -1.;
a2ddc3d0 183 pidStrategy = 1;
cb68eb1d 184 }
185 else {
186 Error("AddTaskNetParticle", "Unknown Particle type.");
478c95cf 187 delete task;
cb68eb1d 188 return NULL;
189 }
67dfcbcf 190
191// ----------------------------------------------
192// -- use value arguments --
193// ----------------------------------------------
194
195 if (isSetExt) {
196 minPt = gMinPt;
197 maxPt = gMinPt;
7d303db8 198 minPtForTOF = gMinPtForTof;
67dfcbcf 199
200 nSigmaITS = gSigmaITS;
201 nSigmaTPC = gSigmaTPC;
202 nSigmaTPClow = gSigmaTPClow;
203 nSigmaTOF = gSigmaTOF;
204
205 }
206 // ----------------------------------------------
207 // -- PID Strategy
208 // ----------------------------------------------
209
210 if (modePID == -1) { // default
211 pidStrategy = 7; // 7: ITS + TPC + TOF (using minPtForTOF)
212 if (modeCuts == 1)
213 pidStrategy = 5; // 5: TPC + TOF (using minPtForTOF)
214 }
215 else
216 pidStrategy = modePID;
217
a2ddc3d0 218 // ----------------------------------------------
219 // -- Read Environment Variables
220 // ----------------------------------------------
221 ifstream in;
222 in.open("setRunENV.txt");
223
224 TString current;
225 while(in.good()) {
226 in >> current;
227
228 TObjArray *arr = current.Tokenize('=');
229 if (!arr)
230 continue;
231
232 TObjString* oKey = dynamic_cast<TObjString*>(arr->At(0));
233 TObjString* oValue = dynamic_cast<TObjString*>(arr->At(1));
234 if (!oKey)
235 continue;
236
237 TString key(oKey->GetString());
238 TString value(oValue->GetString());
239
240 if (!key.CompareTo("NETPARTICLE_PID_STRATEGY")) {
241 pidStrategy = value.Atoi();
242 printf(">>>> USE NETPARTICLE_PID_STRATEGY %d\n", pidStrategy);
243 }
244 if (!key.CompareTo("NETPARTICLE_NSIGMAMAX_ITS")) {
245 nSigmaITS = value.Atof();
246 printf(">>>> USE NETPARTICLE_NSIGMAMAX_ITS %.2f\n", nSigmaITS);
247 }
248 if (!key.CompareTo("NETPARTICLE_NSIGMAMAX_TPC")) {
249 nSigmaTPC = value.Atof();
250 printf(">>>> USE NETPARTICLE_NSIGMAMAX_TPC %.2f\n", nSigmaTPC);
251 }
252 if (!key.CompareTo("NETPARTICLE_NSIGMAMAX_TOF")) {
253 nSigmaTOF = value.Atof();
254 printf(">>>> USE NETPARTICLE_NSIGMAMAX_TOF %.2f\n", nSigmaTOF);
255 }
256
257 arr->Clear();
258 delete arr;
259 }
260
261 in.close();
262
cb68eb1d 263 // ----------------------------------------------
cb68eb1d 264 // -- Configure cuts
265 // ----------------------------------------------
266
4918c45f 267 // -- Set cut flags
a2ddc3d0 268 task->SetESDTrackCutMode(modeCuts); // => 0 = normal | 1 = LF
cb68eb1d 269
cb68eb1d 270 // -- Set analysis ranges
4918c45f 271 task->SetEtaMax(etaMax); // eta cut
272 task->SetEtaMaxEff(etaMaxEff); // eta cut for efficiency
cb68eb1d 273 task->SetPtRange(minPt, maxPt); // pt cut range for the analysis
274 task->SetPtRangeEff(minPtEff, maxPtEff); // pt cut range for the correction / efficiency / contamination creation
478c95cf 275
276 // ----------------------------------------------
277 // -- Configure cuts - helper class
278 // ----------------------------------------------
279
280 // -- Set standard event cuts
281 helper->SetVertexZMax(10.);
282 helper->SetCentralityBinMax(7);
283
284 // -- Set track event cuts
285 helper->SetRapidityMax(0.5);
a2ddc3d0 286 // helper->SetRapidityMax(0.2);
478c95cf 287 helper->SetMinTrackLengthMC(70.);
4918c45f 288 helper->SetNSigmaMaxCdd(0.); // 3. || ->> Turn off sigmaDCA cuts for now
289 helper->SetNSigmaMaxCzz(0.); // 3. || ->> Turn off sigmaDCA cuts for now
5de3d4d1 290 helper->SetPhiRange(0., 3.88); // Only used if requested in task - default is TwoPi
478c95cf 291
292 // -- Set pid cuts
a2ddc3d0 293 helper->SetPIDStrategy(pidStrategy);
294 helper->SetNSigmaMaxITS(nSigmaITS);
478c95cf 295 helper->SetNSigmaMaxTPC(nSigmaTPC);
a2ddc3d0 296 helper->SetNSigmaMaxTPClow(nSigmaTPClow);
478c95cf 297 helper->SetNSigmaMaxTOF(nSigmaTOF);
298 helper->SetMinPtForTOFRequired(minPtForTOF);
a2ddc3d0 299 helper->SetMaxPtForTPClow(maxPtForTPClow);
cb68eb1d 300
a2ddc3d0 301 // -- Set N sub samples
302 helper->SetNSubSamples(20);
303
cb68eb1d 304 // ----------------------------------------------
478c95cf 305 // -- Add task to the ANALYSIS manager
cb68eb1d 306 // ----------------------------------------------
478c95cf 307 mgr->AddTask(task);
cb68eb1d 308
309 // ----------------------------------------------
310 // -- data containers - input
311 // ----------------------------------------------
312 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
313
314 // ----------------------------------------------
315 // -- data containers - output
316 // ----------------------------------------------
67dfcbcf 317 TString outputFileName = Form("%s:%s", AliAnalysisManager::GetCommonFileName(), name);
318 TString outputQAFileName = Form("%s:%s", AliAnalysisManager::GetCommonFileName(), name);
319
a2ddc3d0 320 AliAnalysisDataContainer *coutput = mgr->CreateContainer(name, TList::Class(), AliAnalysisManager::kOutputContainer, outputFileName);
321 AliAnalysisDataContainer *coutputEff = mgr->CreateContainer(Form("%s_eff", name), TList::Class(), AliAnalysisManager::kOutputContainer, outputFileName);
5c01a71f 322 AliAnalysisDataContainer *coutputCont = mgr->CreateContainer(Form("%s_cont", name), TList::Class(), AliAnalysisManager::kOutputContainer, outputFileName);
a2ddc3d0 323 AliAnalysisDataContainer *coutputDca = mgr->CreateContainer(Form("%s_dca", name), TList::Class(), AliAnalysisManager::kOutputContainer, outputFileName);
cb68eb1d 324
a2ddc3d0 325 AliAnalysisDataContainer *coutputQA = mgr->CreateContainer(Form("%sQA", name), TList::Class(), AliAnalysisManager::kOutputContainer, outputQAFileName);
cb68eb1d 326
327 mgr->ConnectInput (task, 0, cinput );
328 mgr->ConnectOutput (task, 1, coutput);
329 mgr->ConnectOutput (task, 2, coutputEff);
330 mgr->ConnectOutput (task, 3, coutputCont);
331 mgr->ConnectOutput (task, 4, coutputDca);
332 mgr->ConnectOutput (task, 5, coutputQA);
333
334 return task;
335}