]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/EBYE/PIDFluctuation/task/AliEbyEPidRatioTask.cxx
Updates on pi0 analysis in p-Pb (Hongsheng)
[u/mrichter/AliRoot.git] / PWGCF / EBYE / PIDFluctuation / task / AliEbyEPidRatioTask.cxx
CommitLineData
0a28d543 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: ALICE Offline. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16//=========================================================================//
17// AliEbyE Analysis for Particle Ratio Fluctuation //
18// Deepika Rathee | Satyajit Jena //
19// drathee@cern.ch | sjena@cern.ch //
20// Date: Wed Jul 9 18:38:30 CEST 2014 //
21// New approch to find particle ratio to reduce memory //
22// (Test Only) //
23//=========================================================================//
24
25#include "TFile.h"
26#include "TChain.h"
27#include "TTree.h"
28#include "TH1F.h"
29#include "TH2F.h"
30#include "TH3F.h"
31#include "TCanvas.h"
32#include "TStopwatch.h"
33#include "TMath.h"
34#include "THashList.h"
35
36#include "AliAnalysisTask.h"
37#include "AliAnalysisManager.h"
38#include "AliTracker.h"
39#include "AliESDEvent.h"
40#include "AliESDInputHandler.h"
41#include "AliESDpid.h"
42#include "AliStack.h"
43#include "AliMCEvent.h"
44#include "AliMCEventHandler.h"
45#include "AliESDtrackCuts.h"
46#include "AliKineTrackCuts.h"
47#include "AliMCParticle.h"
48#include "AliESDVZERO.h"
49#include "AliEbyEPidRatioTask.h"
50#include "AliGenEventHeader.h"
51#include "AliCentrality.h"
52#include "AliAODEvent.h"
53#include "AliAODInputHandler.h"
54
55using namespace std;
56ClassImp(AliEbyEPidRatioTask)
57//________________________________________________________________________
58AliEbyEPidRatioTask::AliEbyEPidRatioTask(const char *name) :
59 AliAnalysisTaskSE(name),
60 fHelper(NULL),
61 fEffCont(NULL),
62 fDCA(NULL),
63 fDist(NULL),
64 fQA(NULL),
65
66 fOutList(NULL),
67 fOutListEff(NULL),
68 fOutListCont(NULL),
69 fOutListDCA(NULL),
70 fOutListQA(NULL),
71
72 fESD(NULL),
73 fESDHandler(NULL),
74
75 fESDTrackCutsBase(NULL),
76 fESDTrackCuts(NULL),
77 fESDTrackCutsBkg(NULL),
78 fESDTrackCutsEff(NULL),
79
80 fAOD(NULL),
81 fAODHandler(NULL),
82
83 fIsMC(kFALSE),
1648d22e 84 fIsRatio(kFALSE),
85 fIsPtBin(kFALSE),
0a28d543 86 fIsAOD(kFALSE),
87 fESDTrackCutMode(0),
88 fModeEffCreation(0),
89 fModeDCACreation(0),
90 fModeDistCreation(0),
91 fModeQACreation(0),
92
93 fMCEvent(NULL),
94 fMCStack(NULL),
95
96 fEtaMax(0.8),
97 fEtaMaxEff(0.9),
98 fPtRange(),
99 fPtRangeEff(),
100
101 fAODtrackCutBit(1024) {
1648d22e 102
0a28d543 103 AliLog::SetClassDebugLevel("AliEbyEPidRatioTask",10);
104
1648d22e 105 fPtRange[0] = 0.4;
106 fPtRange[1] = 0.8;
0a28d543 107 fPtRangeEff[0] = 0.2;
108 fPtRangeEff[1] = 1.6;
109
0a28d543 110 DefineOutput(1, TList::Class());
111 DefineOutput(2, TList::Class());
112 DefineOutput(3, TList::Class());
113 DefineOutput(4, TList::Class());
114 DefineOutput(5, TList::Class());
115}
116
117//________________________________________________________________________
118AliEbyEPidRatioTask::~AliEbyEPidRatioTask() {
119 // Destructor
120
121 if (fESDTrackCutsBase) delete fESDTrackCutsBase;
122 if (fESDTrackCuts) delete fESDTrackCuts;
123 if (fESDTrackCutsBkg) delete fESDTrackCutsBkg;
124 if (fESDTrackCutsEff) delete fESDTrackCutsEff;
125
126 if (fEffCont) delete fEffCont;
127 if (fDCA) delete fDCA;
128 if (fDist) delete fDist;
129 if (fQA) delete fQA;
130 if (fHelper) delete fHelper;
131}
132
1648d22e 133
0a28d543 134
135//________________________________________________________________________
136void AliEbyEPidRatioTask::UserCreateOutputObjects() {
0a28d543 137 Bool_t oldStatus = TH1::AddDirectoryStatus();
138 TH1::AddDirectory(kFALSE);
139
140 fOutList = new TList;
141 fOutList->SetName(GetName()) ;
142 fOutList->SetOwner(kTRUE);
143
144 fOutListEff = new TList;
145 fOutListEff->SetName(Form("%s_eff",GetName()));
146 fOutListEff->SetOwner(kTRUE) ;
147
148 fOutListCont = new TList;
149 fOutListCont->SetName(Form("%s_cont",GetName()));
150 fOutListCont->SetOwner(kTRUE) ;
151
152 fOutListDCA = new TList;
153 fOutListDCA->SetName(Form("%s_dca",GetName()));
154 fOutListDCA->SetOwner(kTRUE) ;
155
156 fOutListQA = new TList;
157 fOutListQA->SetName(Form("%s_qa",GetName()));
158 fOutListQA->SetOwner(kTRUE) ;
159
160 Initialize();
161
162 fOutList->Add(new TList);
163 TList *list = static_cast<TList*>(fOutList->Last());
164 list->SetName(Form("fStat"));
165 list->SetOwner(kTRUE);
166
167 list->Add(fHelper->GetHEventStat0());
168 list->Add(fHelper->GetHEventStat1());
169 list->Add(fHelper->GetHTriggerStat());
170 list->Add(fHelper->GetHCentralityStat());
171
172 if ((fIsAOD||fIsMC) && fModeEffCreation == 1) {
f7ea34d2 173 fOutListEff->Add(fEffCont->GetHnEffMc());
174 fOutListEff->Add(fEffCont->GetHnEffRec());
175
176 fOutListCont->Add(fEffCont->GetHnContMc());
177 fOutListCont->Add(fEffCont->GetHnContRec());
0a28d543 178 }
179
180 if (fModeDCACreation == 1)
181 fOutListDCA->Add(fDCA->GetHnDCA());
182
f7ea34d2 183 if (fModeQACreation == 1) {
184 fOutListQA->Add(fQA->GetHnQAPid());
185 fOutListQA->Add(fQA->GetHnQADca());
186 }
0a28d543 187
188 TH1::AddDirectory(oldStatus);
189
190 PostData(1,fOutList);
191 PostData(2,fOutListEff);
192 PostData(3,fOutListCont);
193 PostData(4,fOutListDCA);
194 PostData(5,fOutListQA);
195
196 return;
197}
198
199//________________________________________________________________________
200void AliEbyEPidRatioTask::UserExec(Option_t *) {
201
202 if (SetupEvent() < 0) {
203 PostData(1,fOutList);
204 PostData(2,fOutListEff);
205 PostData(3,fOutListCont);
206 PostData(4,fOutListDCA);
207 PostData(5,fOutListQA);
208 return;
209 }
210
211
212 if ((fIsMC||fIsAOD) && fModeEffCreation == 1)
213 fEffCont->Process();
214
215 if (fModeDCACreation == 1)
216 fDCA->Process();
217
218 if (fModeDistCreation == 1)
219 fDist->Process();
220
221 if (fModeQACreation == 1)
222 fQA->Process();
223
224 PostData(1,fOutList);
225 PostData(2,fOutListEff);
226 PostData(3,fOutListCont);
227 PostData(4,fOutListDCA);
228 PostData(5,fOutListQA);
229
230 return;
231}
232
233//________________________________________________________________________
234void AliEbyEPidRatioTask::Terminate(Option_t *){
235 // Terminate
236}
237
238Int_t AliEbyEPidRatioTask::Initialize() {
239 // Initialize event
240
241 // ------------------------------------------------------------------
242 // -- ESD TrackCuts
243 // ------------------------------------------------------------------
244 TString sModeName("");
245
246 // -- Create ESD track cuts
247 // --------------------------
248 fESDTrackCutsBase = new AliESDtrackCuts;
249
250 if (fESDTrackCutMode == 0) {
251 fESDTrackCutsBase->SetMinNCrossedRowsTPC(70); // TPC
252 fESDTrackCutsBase->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8); // TPC
253 }
254 else if (fESDTrackCutMode == 1) {
255 fESDTrackCutsBase->SetMinNClustersTPC(70); // TPC 2010
256 }
257
258 fESDTrackCutsBase->SetMaxChi2PerClusterTPC(4); // TPC 2010
259 fESDTrackCutsBase->SetAcceptKinkDaughters(kFALSE); // TPC 2010
260 fESDTrackCutsBase->SetRequireTPCRefit(kTRUE); // TPC 2010
261
262 if (fESDTrackCutMode == 0) {
263 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff); // ITS
264 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSDD,AliESDtrackCuts::kOff); // ITS
265 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSSD,AliESDtrackCuts::kOff); // ITS
266 }
267 else if (fESDTrackCutMode == 1) {
268 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny); // ITS 2010
269 // fESDTrackCutsBase->SetMinNClustersITS(4);
270 }
271
272 fESDTrackCutsBase->SetRequireITSRefit(kTRUE); // ITS 2010
273 fESDTrackCutsBase->SetMaxChi2PerClusterITS(36); // ITS 2010
274
275 fESDTrackCutsBase->SetDCAToVertex2D(kFALSE); // VertexConstrained 2010
276 fESDTrackCutsBase->SetRequireSigmaToVertex(kFALSE); // VertexConstrained 2010
277 fESDTrackCutsBase->SetMaxDCAToVertexZ(2); // VertexConstrained 2010
278
279 fESDTrackCutsBase->SetEtaRange(-1.*fEtaMax, fEtaMax); // Acceptance
280 fESDTrackCutsBase->SetPtRange(fPtRange[0],fPtRange[1]); // Acceptance
281
282 // -- Mode : standard cuts
283 if (fESDTrackCutMode == 0)
284 sModeName = "Std";
285 // -- Mode : for comparison to LF
286 else if (fESDTrackCutMode == 1)
287 sModeName = "LF";
288 // -- Mode : Default
289 else
290 sModeName = "Base";
291
292 fESDTrackCutsBase->SetName(Form("NetParticleCuts2010_%s",sModeName.Data()));
293
294 // -- Create ESD track cuts -> Base + DCA
295 // ------------------------------
296 fESDTrackCuts = static_cast<AliESDtrackCuts*>(fESDTrackCutsBase->Clone());
297 fESDTrackCuts->SetName(Form("NetParticleCuts2010_%s",sModeName.Data()));
298 if (fESDTrackCutMode == 0)
299 fESDTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); // 2010 VertexConstrained -> 7*(0.0026+0.0050/pt^1.01)
300 // fESDTrackCuts->SetMaxDCAToVertexXY(0.3);
301 else if (fESDTrackCutMode == 1)
302 fESDTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); // 2010 VertexConstrained -> 7*(0.0026+0.0050/pt^1.01)
303
304 // fESDTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); // golden cut off
305
306 // -- Create ESD BKG track cuts -> Base + Acceptance(Eff)
307 // ------------------------------
308 fESDTrackCutsBkg = static_cast<AliESDtrackCuts*>(fESDTrackCutsBase->Clone());
309 fESDTrackCutsBkg->SetName(Form("NetParticleCuts2010_%s_Bkg",sModeName.Data()));
310 fESDTrackCutsBkg->SetPtRange(fPtRangeEff[0],fPtRangeEff[1]); // Acceptance
311 fESDTrackCutsBkg->SetEtaRange(-1.*fEtaMaxEff, fEtaMaxEff); // Acceptance
312
313 // -- Create ESD Eff track cuts -> Base + DCA + Acceptance(Eff)
314 // ------------------------------
315 fESDTrackCutsEff = static_cast<AliESDtrackCuts*>(fESDTrackCuts->Clone());
316 fESDTrackCutsEff->SetName(Form("NetParticleCuts2010_%s_Eff",sModeName.Data()));
317 fESDTrackCutsEff->SetPtRange(fPtRangeEff[0],fPtRangeEff[1]); // Acceptance
318 fESDTrackCutsEff->SetEtaRange(-1.*fEtaMaxEff, fEtaMaxEff); // Acceptance
319
320 // ------------------------------------------------------------------
321 // -- Initialize Helper
322 // ------------------------------------------------------------------
1648d22e 323
324
325 if (fHelper->Initialize(fESDTrackCutsEff, fIsMC,fIsRatio,fIsPtBin, fAODtrackCutBit, fModeDistCreation))
0a28d543 326 return -1;
327
1648d22e 328 // fHelper->SetIsRatio(fIsRatio);
329 // fHelper->SetIsPtBin(fIsPtBin);
330
0a28d543 331 // ------------------------------------------------------------------
332 // -- Create / Initialize Efficiency/Contamination
333 // ------------------------------------------------------------------
334 if ((fIsMC||fIsAOD) && fModeEffCreation == 1) {
335 fEffCont = new AliEbyEPidRatioEffCont;
336 fEffCont->Initialize(fHelper);
337 }
338
339 // ------------------------------------------------------------------
340 // -- Create / Initialize DCA Determination
341 // ------------------------------------------------------------------
342 if (fModeDCACreation == 1) {
343 fDCA = new AliEbyEPidRatioDCA;
344 fDCA->SetESDTrackCutsBkg(fESDTrackCutsBkg);
345 fDCA->Initialize(fHelper);
346 }
347
348 // ------------------------------------------------------------------
349 // -- Create / Initialize Phy Determination
350 // ------------------------------------------------------------------
351 if (fModeDistCreation == 1) {
352 fDist = new AliEbyEPidRatioPhy;
353 fDist->SetOutList(fOutList);
354 fDist->Initialize(fHelper, fESDTrackCuts);
355 }
356
357 // ------------------------------------------------------------------
358 // -- Create / Initialize QA Determination
359 // ------------------------------------------------------------------
360 if (fModeQACreation == 1) {
361 fQA = new AliEbyEPidRatioQA();
362 fQA->Initialize(fHelper);
363 }
364
365 // ------------------------------------------------------------------
366 // -- Reset Event
367 // ------------------------------------------------------------------
368 ResetEvent();
369
370 return 0;
371}
372
0a28d543 373//________________________________________________________________________
374Int_t AliEbyEPidRatioTask::SetupEvent() {
0a28d543 375
376 ResetEvent();
377
378 // -- ESD Event
379 // ------------------------------------------------------------------
380 if (!fIsAOD && SetupESDEvent() < 0) {
381 AliError("Setup ESD Event failed");
382 return -1;
383 }
384
385 // -- AOD Event
386 // ------------------------------------------------------------------
387 if (fIsAOD && SetupAODEvent() < 0) {
388 AliError("Setup AOD Event failed");
389 return -1;
390 }
391
392 // -- Setup MC Event
393 // ------------------------------------------------------------------
394 if (fIsMC && SetupMCEvent() < 0) {
395 AliError("Setup MC Event failed");
396 return -1;
397 }
398
399 // -- Setup Event for Helper / EffCont / DCA / Dist / QA classes
400 // ------------------------------------------------------------------
401 fHelper->SetupEvent(fESDHandler, fAODHandler, fMCEvent);
402
403
404 if (fModeEffCreation && (fIsMC || fIsAOD) )
405 fEffCont->SetupEvent();
406
407 if (fModeDCACreation == 1)
408 fDCA->SetupEvent();
409
410 if (fModeDistCreation == 1)
411 fDist->SetupEvent();
412
413 if (fModeQACreation == 1)
414 fQA->SetupEvent();
415
416
417 // -- Evaluate Event cuts
418 // ------------------------------------------------------------------
419 return fHelper->IsEventRejected() ? -2 : 0;
420}
421
422//________________________________________________________________________
423Int_t AliEbyEPidRatioTask::SetupESDEvent() {
424 // -- Setup ESD Event
425 // > return 0 for success
426 // > return -1 for failed setup
427
428
429
430
431 fESDHandler= dynamic_cast<AliESDInputHandler*>
432 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
433 if (!fESDHandler) {
434 AliError("Could not get ESD input handler");
435 return -1;
436 }
437
438 fESD = fESDHandler->GetEvent();
439 if (!fESD) {
440 AliError("Could not get ESD event");
441 return -1;
442 }
443
444 // -- Check PID response
445 // ------------------------------------------------------------------
446 if (!fESDHandler->GetPIDResponse()) {
447 AliError("Could not get PID response");
448 return -1;
449 }
450
451 // -- Check Vertex
452 // ------------------------------------------------------------------
453 if (!fESD->GetPrimaryVertexTracks()) {
454 AliError("Could not get vertex from tracks");
455 return -1;
456 }
457
458 // -- Check Centrality
459 // ------------------------------------------------------------------
460 if (!fESD->GetCentrality()) {
461 AliError("Could not get centrality");
462 return -1;
463 }
464
465 return 0;
466}
467
468//________________________________________________________________________
469Int_t AliEbyEPidRatioTask::SetupAODEvent() {
470 // -- Setup AOD Event
471 // > return 0 for success
472 // > return -1 for failed setup
473
474 fAODHandler= dynamic_cast<AliAODInputHandler*>
475 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
476 if (!fAODHandler) {
477 AliError("Could not get AOD input handler");
478 return -1;
479 }
480
481 fAOD = fAODHandler->GetEvent();
482 if (!fAOD) {
483 AliError("Could not get AOD event");
484 return -1;
485 }
486
487 // -- Check PID response
488 // ------------------------------------------------------------------
489 if (!fAODHandler->GetPIDResponse()) {
490 AliError("Could not get PID response");
491 return -1;
492 }
493
494 // -- Check Vertex
495 // ------------------------------------------------------------------
496 if (!fAOD->GetPrimaryVertex()) {
497 AliError("Could not get primary vertex");
498 return -1;
499 }
500
501 // -- Check Centrality
502 // ------------------------------------------------------------------
503 if (!fAOD->GetHeader()->GetCentralityP()) {
504 AliError("Could not get centrality");
505 return -1;
506 }
507
508 return 0;
509}
510
511//________________________________________________________________________
512Int_t AliEbyEPidRatioTask::SetupMCEvent() {
513 AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>
514 (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
515
516 if (!mcH) {
517 AliError("MC event handler not available");
518 return -1;
519 }
520
521 fMCEvent = mcH->MCEvent();
522 if (!fMCEvent) {
523 AliError("MC event not available");
524 return -1;
525 }
526
527 // -- Get MC header
528 // ------------------------------------------------------------------
529 AliHeader* header = fMCEvent->Header();
530 if (!header) {
531 AliError("MC header not available");
532 return -1;
533 }
534
535 // -- Check Stack
536 // ------------------------------------------------------------------
537 fMCStack = fMCEvent->Stack();
538 if (!fMCStack) {
539 AliError("MC stack not available");
540 return -1;
541 }
542
543 // -- Check GenHeader
544 // ------------------------------------------------------------------
545 if (!header->GenEventHeader()) {
546 AliError("Could not retrieve genHeader from header");
547 return -1;
548 }
549
550 // -- Check primary vertex
551 // ------------------------------------------------------------------
552 if (!fMCEvent->GetPrimaryVertex()){
553 AliError("Could not get MC vertex");
554 return -1;
555 }
556
557 return 0;
558}
559
560//________________________________________________________________________
561void AliEbyEPidRatioTask::ResetEvent() {
562 // -- Reset event
563
564 // -- Reset ESD Event
565 fESD = NULL;
566
567 // -- Reset AOD Event
568 fAOD = NULL;
569
570 // -- Reset MC Event
571 if (fIsMC)
572 fMCEvent = NULL;
573
574 // -- Reset Dist Creation
575 if (fModeDistCreation == 1)
576 fDist->ResetEvent();
577
578 return;
579}
580
581