]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/FLOW/macros/AddTaskPhiFlow.C
reduce memory usage
[u/mrichter/AliRoot.git] / PWGCF / FLOW / macros / AddTaskPhiFlow.C
CommitLineData
19d77c98 1/////////////////////////////////////////////////////////////////////////////////////////////
2//
3// AddTaskPhiFlow macro
4// Author: Redmer A. Bertens, Utrecht University, 2012
b4f29a18 5// Many thanks to Carlos Perez Lara
6// Commented where necessary
19d77c98 7/////////////////////////////////////////////////////////////////////////////////////////////
b4f29a18 8
9class AliAnalysisDataContainer;
10class AliFlowTrackCuts;
11class AliFlowTrackSimpleCuts;
12class AliFlowEventCuts;
13class AliFlowEventSimpleCuts;
14class AliAnalysisDataContainer;
15
48077518 16AliAnalysisTaskPhiFlow* AddTaskPhiFlow(Bool_t SP = kTRUE,
b4f29a18 17 Bool_t SPSUB = kTRUE,
48077518 18 Bool_t QC = kTRUE,
19 Bool_t EP = kTRUE,
b4f29a18 20 Float_t centrMin = 20.,
21 Float_t centrMax = 30.,
22 Double_t PIDconfig[7],
3ea398e1 23 TString suffixName = "",
24 Bool_t bCentralTrigger = kFALSE,
b4f29a18 25 Float_t EtaGap = 0.,
48077518 26 Float_t POIEtaMin = -0.8,
27 Float_t POIEtaMax = 0.8,
28 Float_t POIPtMin = 0.15,
29 Float_t POIPtMax = 10.,
b4f29a18 30 Float_t deltaDip = 0.,
31 Float_t deltaDipMaxPt = 0.,
32 Float_t DCA = 0.3,
33 Int_t harm = 2,
3ea398e1 34 Bool_t TPCStandAloneTracks = kFALSE,
b4f29a18 35 Bool_t useGlobalRPCuts = kTRUE,
36 Float_t vertexZ = 10.,
37 Bool_t shrinkSP = kTRUE,
38 Bool_t debug = kTRUE)
19d77c98 39{
b4f29a18 40 // main function, create and add tasks
41 if(debug) cout << " === Adding Task PhiFlow === " << endl;
3ea398e1 42 // set up main output container's name
19d77c98 43 TString fileName = AliAnalysisManager::GetCommonFileName();
44 fileName += ":PhiV2FlowEvents";
b4f29a18 45 if(debug) cout << " --> Reconstruction data container: " << fileName << endl;
46 // check validity of arguments
47 if((!SPSUB)&&(EtaGap > 0.)) {
48 if(debug) cout << " --> Fatal error: Eta gap is introduced but method SPSUB is not enabled !!! <-- " << endl;
49 return 0x0;
50 }
51 else if ((QC||SP||EP)&&(EtaGap > 0.)) {
52 if(debug) cout << " --> Fatal error: one or more of the flow analyses is not compatible with the Eta Gap !!! <--" << endl;
53 return 0x0;
54 }
55 // get the manager and input event handler
19d77c98 56 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
b4f29a18 57 if (!mgr) {
58 if(debug) cout << " Fatal error: no analysis manager found! " << endl;
59 return 0x0;
19d77c98 60 }
b4f29a18 61 if (!mgr->GetInputEventHandler()) {
62 if(debug) cout << " Fatal error: no imput event handler found!" << endl;
63 return 0x0;
19d77c98 64 }
19d77c98 65 // create the main task
66 AliAnalysisTaskPhiFlow *task = new AliAnalysisTaskPhiFlow("TaskPhiFlow");
b4f29a18 67 if(debug) cout << " === AliAnalysisTaskPhiFlow === " << task << endl;
68 if(!task) {
69 if(debug) cout << " --> Unexpected error occurred: NO TASK WAS CREATED! (could be a library problem!) " << endl;
70 return 0x0;
71 }
72 // set triggers
73 if (bCentralTrigger) task->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
74 else task->SelectCollisionCandidates(AliVEvent::kMB);
75 if(debug) cout << " --> Set trigger selection to ";
76 if(debug&&bCentralTrigger) cout << " kMB, kCentral, kSemiCentral " << endl;
77 if(debug&&(!bCentralTrigger)) cout << " kMB " << endl;
78 //set RP cuts for flow package analysis
79 cutsRP = new AliFlowTrackCuts("RFPcuts");
80 if(!cutsRP) {
81 if(debug) cout << " Fatal error: no RP cuts found, could be a library problem! " << endl;
82 return 0x0;
83 }
84 if(useGlobalRPCuts) {
85 AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
86 cutsRP->SetParamType(rptype);
87 cutsRP->SetPtRange(0.2, 5.0);
88 cutsRP->SetEtaRange(-0.8, 0.8);
89 cutsRP->SetMinNClustersTPC(70);
90 cutsRP->SetMinChi2PerClusterTPC(0.1);
91 cutsRP->SetMaxChi2PerClusterTPC(4.0);
92 cutsRP->SetRequireTPCRefit(kTRUE);
93 cutsRP->SetMaxDCAToVertexXY(0.3);
94 cutsRP->SetMaxDCAToVertexZ(0.3);
95 cutsRP->SetAcceptKinkDaughters(kFALSE);
96 cutsRP->SetMinimalTPCdedx(10.);
97 if(debug) cout << " --> kGlobal RP's " << cutsRP << endl;
98 }
99 if(!useGlobalRPCuts) {
100 AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kTPCstandalone;
101 cutsRP->SetParamType(rptype);
102 cutsRP->SetPtRange(0.2,5.);
103 cutsRP->SetEtaRange(-0.8,0.8);
104 cutsRP->SetMinNClustersTPC(70);
105 cutsRP->SetMinChi2PerClusterTPC(0.2);
106 cutsRP->SetMaxChi2PerClusterTPC(4.0);
107 cutsRP->SetMaxDCAToVertexXY(3.0);
108 cutsRP->SetMaxDCAToVertexZ(3.0);
109 cutsRP->SetDCAToVertex2D(kTRUE);
110 cutsRP->SetAcceptKinkDaughters(kFALSE);
111 cutsRP->SetMinimalTPCdedx(10.);
112 if(debug) cout << " --> kTPCStandAlone RP's " << cutsRP << endl;
113 }
114 task->SetRPCuts(cutsRP);
3ea398e1 115 // set POI cuts for kaon selection
19d77c98 116 AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
b4f29a18 117 if(!cutsPOI) {
118 if(debug) cout << " Fatal error: no POI cuts (could be a library problem)!" << endl;
119 return 0x0;
120 }
3ea398e1 121 AliFlowTrackCuts* cutsPOI = cutsPOI->GetStandardGlobalTrackCuts2010();
b4f29a18 122 cutsPOI->SetPtRange(0.2, 5); //?
123 cutsPOI->SetMaxDCAToVertexXY(DCA);
124 cutsPOI->SetMaxDCAToVertexZ(DCA);
125 if(debug) cout << " --> cutsPOI " << cutsPOI << endl;
19d77c98 126 task->SetPOICuts(cutsPOI);
b4f29a18 127 // POI filter cuts, will filter invm mass bands and subevents
128 AliFlowTrackSimpleCuts* POIfilterQC[30];
129 AliFlowTrackSimpleCuts* POIfilterSP[30][2];
19d77c98 130 Double_t flowBands[2][30];
b4f29a18 131 for (Int_t mb = 0; mb < 30; mb++) {
132 flowBands[0][mb] = 0.99 + mb * 0.0034;
133 flowBands[1][mb] = 0.99 + (mb + 1) * 0.0034;
134 POIfilterSP[mb][0] = new AliFlowTrackSimpleCuts(Form("FilterPOISP_MB%d_ETANEG", mb));
135 if(!POIfilterSP[mb][0]) {
136 if(debug) cout << " FAILED to initialize POI filters, could be a library problem!" << endl;
137 return 0x0;
138 }
139 POIfilterSP[mb][0]->SetEtaMin(-0.8);
140 POIfilterSP[mb][0]->SetEtaMax(0.);
141 POIfilterSP[mb][0]->SetMassMin(flowBands[0][mb]);
142 POIfilterSP[mb][0]->SetMassMax(flowBands[1][mb]);
143 POIfilterSP[mb][1] = new AliFlowTrackSimpleCuts(Form("FilterPOISP_MB%d_ETAPOS", mb));
144 POIfilterSP[mb][1]->SetEtaMin(0.);
145 POIfilterSP[mb][1]->SetEtaMax(+0.8);
146 POIfilterSP[mb][1]->SetMassMin(flowBands[0][mb]);
147 POIfilterSP[mb][1]->SetMassMax(flowBands[1][mb]);
148 POIfilterQC[mb] = new AliFlowTrackSimpleCuts(Form("FilterPOIQC_MB%d", mb));
149 POIfilterQC[mb]->SetEtaMin(-0.8);
150 POIfilterQC[mb]->SetEtaMax(+0.8);
151 POIfilterQC[mb]->SetMassMin(flowBands[0][mb]);
152 POIfilterQC[mb]->SetMassMax(flowBands[1][mb]);
19d77c98 153 }
b4f29a18 154 if(debug) cout << " --> Created poi filters " << endl;
155 task->SetCommonConstants(30, flowBands[0][0], flowBands[1][29]);
156 if(debug) cout << " --> Set common constants " << endl;
157 // set pair and event cuts
158 if((deltaDip>0.005)&&(deltaDipMaxPt>0.005)) task->SetMaxDeltaDipAngleAndPt(deltaDip, deltaDipMaxPt);
159 else cout << " --> Disabled Delta-Dip exclusion. <-- " << endl;
160 task->SetCandidateEtaAndPt(POIEtaMin, POIEtaMax, POIPtMin, POIPtMax);
161 task->SetCentralityParameters(centrMin, centrMax, "V0M");
162 task->SetVertexZ(vertexZ);
163 if(debug) cout << " --> Set pair cuts and event cuts" << endl;
164 // set the kaon cuts, and specify the PID procedure which will be used
165 task->SetPIDConfiguration(PIDconfig);
166 if(debug) {
167 cout << " ************ Configured PID routine ************ " << endl;
168 cout << " 0 < " << PIDconfig[1] << " p_t, ITS || TPC with s < " << PIDconfig[0] << endl;
169 if(PIDconfig[2] < 0.) cout << " --> TPC control disabled " << endl;
170 if(PIDconfig[2] > 0.) cout << " --> TPC control enabled " << endl;
171 cout << " " << PIDconfig[1] << " < " << PIDconfig[4] << " p_t, TPC || ITS with s < " << PIDconfig[3] << endl;
172 if(PIDconfig[5] < 0.) cout << " --> ITS control disabled " << endl;
173 if(PIDconfig[5] > 0.) cout << " --> ITS control enabled " << endl;
174 cout << " " << PIDconfig[4] << " < 7 p_t, TPC / TOF Bayesian with p < " << PIDconfig[6] << endl;
175 cout << " ************************************************ " << endl;
19d77c98 176 }
b4f29a18 177 if (TPCStandAloneTracks)
178 { // switch to tpc standalone tracks for POI selection
179 if(debug) cout << " --> Switching to TPC standalone analsis " << endl;
180 task->SetRequireStrictKaonCuts();
181 task->SetRequireTPCStandAloneKaons();
3ea398e1 182 }
b4f29a18 183 // create and configure IO containers
184 AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
185 AliAnalysisDataContainer *coutHist = mgr->CreateContainer(Form("PhiV2_%s", OutputName(centrMin, centrMax,PIDconfig, suffixName, bCentralTrigger, EtaGap, POIEtaMin, POIEtaMax, POIPtMin, POIPtMax, deltaDip, deltaDipMaxPt, DCA, harm, TPCStandAloneTracks, vertexZ, debug, useGlobalRPCuts).Data()), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
186 if(debug) cout << " --> Created IO containers " << cinput << ", " << coutHist << endl;
187 mgr->AddTask(task);
188 if(debug) cout << " === ADDING MAIN TASK == " << endl;
189 mgr->ConnectInput(task, 0, cinput);
190 mgr->ConnectOutput(task, 1, coutHist);
191 if(debug) cout << " --> Connected IO containers " << endl;
192 if (SP || EP || QC || SPSUB) // if flow analysis should be done after reconstruction
19d77c98 193 {
b4f29a18 194 if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl;
195 AliAnalysisDataContainer *flowEvent = mgr->CreateContainer("FlowContainer", AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer);
196 mgr->ConnectOutput(task, 2, flowEvent);
197 if(debug) cout << " --> Created IO containers " << flowEvent << endl;
198 // set a suffixname as a unique identifier for each wagon
199 if (suffixName == "")
48077518 200 {
b4f29a18 201 suffixName += Form("%.0f", centrMin);
202 suffixName += Form("%.0f", centrMax);
48077518 203 }
b4f29a18 204 if(debug) cout << " --> suffixName " << suffixName << endl;
205 for (int mb = 0; mb != 30; ++mb) {
206 if (QC) { // add qc tasks
207 AddQCmethod(Form("QCTPCMB_%d_%s", mb, suffixName.Data()), harm, flowEvent, POIfilterQC[mb], debug);
208 if(debug) cout << " --> Hanging QC task ... " << mb << " succes! "<< endl;
209 }
210 if (SPSUB) { // add sp subevent tasks
211 AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -.5*EtaGap, .5*EtaGap, +0.8, "Qa", harm, flowEvent, POIfilterSP[mb][1], NULL, false, shrinkSP, debug, true);
212 if(debug) cout << " --> Hanging SP Qa task " << mb << " succes!" << endl;
213 AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -.5*EtaGap, .5*EtaGap, +0.8, "Qb", harm, flowEvent, POIfilterSP[mb][0], NULL, false, shrinkSP, debug, true);
214 if(debug) cout << " --> Hanging SP Qb task ..." << mb << " succes!"<< endl;
215 }
216 if (SP) { // add sp tasks
217 AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -0.0, +0.0, +0.8, "QaQb", harm, flowEvent, POIfilterQC[mb], NULL, false, shrinkSP, debug);
218 if(debug) cout << " --> Hanging SP task ... " << mb << " succes!" << endl;
219 }
220 if (EP) { // add ep tasks
221 AddSPmethod(Form("EPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -0.0, +0.0, +0.8, "QaQb", harm, flowEvent, POIfilterQC[mb], NULL, true, shrinkSP, debug);
222 if(debug) cout << " --> Hanging EP task ... " << mb << " succes!" << endl;
223 }
48077518 224 }
225 }
b4f29a18 226 // print summary to screen
227 cout << endl << endl << " ========= AddTaskPhiFlow launched succesfully - SUMMARY: ========== " << endl;
228 cout << " ************ Configured PID routine ************ " << endl;
229 cout << " 0 < " << PIDconfig[1] << " p_t, ITS || TPC with s < " << PIDconfig[0] << endl;
230 if(PIDconfig[2] < 0.) cout << " --> TPC control disabled " << endl;
231 if(PIDconfig[2] > 0.) cout << " --> TPC control enabled " << endl;
232 cout << " " << PIDconfig[1] << " < " << PIDconfig[4] << " p_t, TPC || ITS with s < " << PIDconfig[3] << endl;
233 if(PIDconfig[5] < 0.) cout << " --> ITS control disabled " << endl;
234 if(PIDconfig[5] > 0.) cout << " --> ITS control enabled " << endl;
235 cout << " " << PIDconfig[4] << " < 7 p_t, TPC / TOF Bayesian with p < " << PIDconfig[6] << endl;
236 cout << " ************************************************ " << endl << endl;
237 cout << " ************* Task statistics ****************** " << endl;
238 if(SP) cout << " --> Launched 30 QaQb SP filters and corresponding 30 SP tasks " << endl;
239 if(EP) cout << " --> Launched 30 QaQb QC filters and corresponding 30 EP tasks " << endl;
240 if(SPSUB) cout << " --> Launched 30+30 Qa&&Qb SP filters and corresponding 30+30 SP tasks " << endl;
241 if(QC) cout << " --> Launched 30 QaQb QC filters and corresponding 30 QC tasks " << endl;
242 cout << " ************************************************** " << endl;
243 cout << " --> Now go for a coffee! <-- " << endl;
19d77c98 244 return task;
b4f29a18 245}
246//_____________________________________________________________________________
247void AddSPmethod(char *name, double minEtaA, double maxEtaA, double minEtaB, double maxEtaB, char *Qvector, int harmonic, AliAnalysisDataContainer *flowEvent, AliFlowTrackSimpleCuts *cutsPOI = NULL, AliFlowTrackSimpleCuts *cutsRFP = NULL, bool bEP, bool shrink = false, bool debug, bool etagap = false)
248{
249 // add sp task and invm filter tasks
250 if(debug) (bEP) ? cout << " ****** Reveived request for EP task ****** " << endl : cout << " ******* Switching to SP task ******* " << endl;
251 TString fileName = AliAnalysisManager::GetCommonFileName();
252 (bEP) ? fileName+=":EP" : fileName+=":SP";
253 if(etagap) {
254 fileName+="_SUBEVENTS";
255 if(debug) cout << " --> Setting up subevent analysis <-- " << endl;
256 }
257 if(debug) cout << " --> fileName " << fileName << endl;
258 TString myFolder = fileName;
259 if(debug) cout << " --> myFolder " << myFolder << endl;
260 TString myNameSP;
261 (bEP) ? myNameSP = Form("%sEPv%d%s", name, harmonic, Qvector): myNameSP = Form("%sSPv%d%s", name, harmonic, Qvector);
262 if(debug) cout << " myNameSP " << myNameSP << endl;
263 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
264 AliAnalysisDataContainer *flowEvent2 = mgr->CreateContainer(Form("Filter_%s", myNameSP.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer);
265 AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myNameSP.Data()), cutsRFP, cutsPOI);
266 tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB);
267 mgr->AddTask(tskFilter);
268 mgr->ConnectInput(tskFilter, 0, flowEvent);
269 mgr->ConnectOutput(tskFilter, 1, flowEvent2);
270 AliAnalysisDataContainer *outSP = mgr->CreateContainer(myNameSP.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
271 AliAnalysisTaskScalarProduct *tskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s", myNameSP.Data()), kFALSE);
272 tskSP->SetApplyCorrectionForNUA(kTRUE);
273 tskSP->SetHarmonic(harmonic);
274 tskSP->SetTotalQvector(Qvector);
275 if (bEP) tskSP->SetBehaveAsEP();
276 if (shrink) tskSP->SetBookOnlyBasicCCH(kTRUE);
277 mgr->AddTask(tskSP);
278 mgr->ConnectInput(tskSP, 0, flowEvent2);
279 mgr->ConnectOutput(tskSP, 1, outSP);
280}
281//_____________________________________________________________________________
282void AddQCmethod(char *name, int harmonic, AliAnalysisDataContainer *flowEvent, AliFlowTrackSimpleCuts *cutsPOI = NULL, Bool_t debug, AliFlowTrackSimpleCuts *cutsRFP = NULL)
283{
284 // add qc task and invm filter tasks
285 if(debug) cout << " ****** Received request for QC v" << harmonic << " task " << name << ", POI " << cutsPOI << ", IO ****** " << flowEvent << endl;
286 TString fileName = AliAnalysisManager::GetCommonFileName();
287 fileName+=":QC";
288 if(debug) cout << " --> Common filename: " << fileName << endl;
289 TString myFolder = Form("v%d", harmonic);
290 if(debug) cout << " --> myFolder: " << myFolder << endl;
291 TString myName = Form("%s", name);
292 if(debug) cout << " --> myName: " << myName << endl;
293 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
294 AliAnalysisDataContainer *flowEvent2 = mgr->CreateContainer(Form("Filter_%s", myName.Data()), AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
295 AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myName.Data()), cutsRFP, cutsPOI);
296 mgr->AddTask(tskFilter);
297 mgr->ConnectInput(tskFilter, 0, flowEvent);
298 mgr->ConnectOutput(tskFilter, 1, flowEvent2);
299 AliAnalysisDataContainer *outQC = mgr->CreateContainer(myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
300 AliAnalysisTaskQCumulants *tskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s", myName.Data()), kFALSE);
301 tskQC->SetApplyCorrectionForNUA(kTRUE);
302 tskQC->SetHarmonic(harmonic);
303 tskQC->SetBookOnlyBasicCCH(kTRUE);
304 mgr->AddTask(tskQC);
305 mgr->ConnectInput(tskQC, 0, flowEvent2);
306 mgr->ConnectOutput(tskQC, 1, outQC);
307}
308//_____________________________________________________________________________
309TString OutputName( Float_t centrMin,
310 Float_t centrMax,
311 Double_t PIDconfig[7],
312 TString suffixName,
313 Bool_t bCentralTrigger,
314 Float_t EtaGap,
315 Float_t POIEtaMin,
316 Float_t POIEtaMax,
317 Float_t POIPtMin,
318 Float_t POIPtMax,
319 Float_t deltaDip,
320 Float_t deltaDipMaxPt,
321 Float_t DCA,
322 Int_t harm,
323 Bool_t TPCStandAloneTracks,
324 Float_t vertexZ,
325 Bool_t debug,
326 Bool_t useGlobalRPCuts)
327{
328 // generate output name
329 TString centralityName = ("");
330 centralityName += Form("%.0f", centrMin);
331 centralityName += Form("%.0f", centrMax);
332 centralityName += "_";
333 centralityName += Form("vZ%.f", vertexZ);
334 centralityName += "_";
335 for(Int_t i = 0; i < 7; i++) centralityName += Form("%.1f_", PIDconfig[i]);
336 centralityName += "_POIEta";
337 centralityName += Form("%.1f", POIEtaMin);
338 centralityName += Form("%.1f", POIEtaMax);
339 centralityName += "_gap";
340 centralityName += Form("%.1f", -0.5*EtaGap);
341 centralityName += Form("%.1f", 0.5*EtaGap);
342 centralityName += "_";
343 centralityName += Form("dDip%.2f", deltaDip);
344 centralityName += "-";
345 centralityName += Form("dDipPt%.2f", deltaDipMaxPt);
346 if (TPCStandAloneTracks) {
347 centralityName += "-";
348 centralityName += "TPCStandAloneTracks";
349 }
350 if (bCentralTrigger) {
351 centralityName += "-";
352 centralityName += "kMBkCkSC";
353 }
354 if (!useGlobalRPCuts) {
355 centralityName += "-";
356 centralityName += "TPCRP";
357 }
358 if(debug) cout << " --> centralityName " << centralityName << endl;
359 return centralityName;
360}
361//_____________________________________________________________________________
19d77c98 362