]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/EBYE/PIDFluctuation/task/AliEbyEPidRatioTask.cxx
Added computation of mothers in acceptance (Massimo) + macros for D0 analysis updated
[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),
84 fIsAOD(kFALSE),
85 fESDTrackCutMode(0),
86 fModeEffCreation(0),
87 fModeDCACreation(0),
88 fModeDistCreation(0),
89 fModeQACreation(0),
90
91 fMCEvent(NULL),
92 fMCStack(NULL),
93
94 fEtaMax(0.8),
95 fEtaMaxEff(0.9),
96 fPtRange(),
97 fPtRangeEff(),
98
99 fAODtrackCutBit(1024) {
100 // Constructor
101
102 AliLog::SetClassDebugLevel("AliEbyEPidRatioTask",10);
103
104 fPtRange[0] = 0.4;
105 fPtRange[1] = 0.8;
106 fPtRangeEff[0] = 0.2;
107 fPtRangeEff[1] = 1.6;
108
109 // -- Output slots
110 // -------------------------------------------------
111 DefineOutput(1, TList::Class());
112 DefineOutput(2, TList::Class());
113 DefineOutput(3, TList::Class());
114 DefineOutput(4, TList::Class());
115 DefineOutput(5, TList::Class());
116}
117
118//________________________________________________________________________
119AliEbyEPidRatioTask::~AliEbyEPidRatioTask() {
120 // Destructor
121
122 if (fESDTrackCutsBase) delete fESDTrackCutsBase;
123 if (fESDTrackCuts) delete fESDTrackCuts;
124 if (fESDTrackCutsBkg) delete fESDTrackCutsBkg;
125 if (fESDTrackCutsEff) delete fESDTrackCutsEff;
126
127 if (fEffCont) delete fEffCont;
128 if (fDCA) delete fDCA;
129 if (fDist) delete fDist;
130 if (fQA) delete fQA;
131 if (fHelper) delete fHelper;
132}
133
134/*
135 * ---------------------------------------------------------------------------------
136 * Public Methods
137 * ---------------------------------------------------------------------------------
138 */
139
140//________________________________________________________________________
141void AliEbyEPidRatioTask::UserCreateOutputObjects() {
142 // Create histograms
143
144 // ------------------------------------------------------------------
145 // -- Create Output Lists
146 // ------------------------------------------------------------------
147 Bool_t oldStatus = TH1::AddDirectoryStatus();
148 TH1::AddDirectory(kFALSE);
149
150 fOutList = new TList;
151 fOutList->SetName(GetName()) ;
152 fOutList->SetOwner(kTRUE);
153
154 fOutListEff = new TList;
155 fOutListEff->SetName(Form("%s_eff",GetName()));
156 fOutListEff->SetOwner(kTRUE) ;
157
158 fOutListCont = new TList;
159 fOutListCont->SetName(Form("%s_cont",GetName()));
160 fOutListCont->SetOwner(kTRUE) ;
161
162 fOutListDCA = new TList;
163 fOutListDCA->SetName(Form("%s_dca",GetName()));
164 fOutListDCA->SetOwner(kTRUE) ;
165
166 fOutListQA = new TList;
167 fOutListQA->SetName(Form("%s_qa",GetName()));
168 fOutListQA->SetOwner(kTRUE) ;
169
170 Initialize();
171
172 fOutList->Add(new TList);
173 TList *list = static_cast<TList*>(fOutList->Last());
174 list->SetName(Form("fStat"));
175 list->SetOwner(kTRUE);
176
177 list->Add(fHelper->GetHEventStat0());
178 list->Add(fHelper->GetHEventStat1());
179 list->Add(fHelper->GetHTriggerStat());
180 list->Add(fHelper->GetHCentralityStat());
181
182 if ((fIsAOD||fIsMC) && fModeEffCreation == 1) {
f7ea34d2 183 fOutListEff->Add(fEffCont->GetHnEffMc());
184 fOutListEff->Add(fEffCont->GetHnEffRec());
185
186 fOutListCont->Add(fEffCont->GetHnContMc());
187 fOutListCont->Add(fEffCont->GetHnContRec());
0a28d543 188 }
189
190 if (fModeDCACreation == 1)
191 fOutListDCA->Add(fDCA->GetHnDCA());
192
f7ea34d2 193 if (fModeQACreation == 1) {
194 fOutListQA->Add(fQA->GetHnQAPid());
195 fOutListQA->Add(fQA->GetHnQADca());
196 }
0a28d543 197
198 TH1::AddDirectory(oldStatus);
199
200 PostData(1,fOutList);
201 PostData(2,fOutListEff);
202 PostData(3,fOutListCont);
203 PostData(4,fOutListDCA);
204 PostData(5,fOutListQA);
205
206 return;
207}
208
209//________________________________________________________________________
210void AliEbyEPidRatioTask::UserExec(Option_t *) {
211
212 if (SetupEvent() < 0) {
213 PostData(1,fOutList);
214 PostData(2,fOutListEff);
215 PostData(3,fOutListCont);
216 PostData(4,fOutListDCA);
217 PostData(5,fOutListQA);
218 return;
219 }
220
221
222 if ((fIsMC||fIsAOD) && fModeEffCreation == 1)
223 fEffCont->Process();
224
225 if (fModeDCACreation == 1)
226 fDCA->Process();
227
228 if (fModeDistCreation == 1)
229 fDist->Process();
230
231 if (fModeQACreation == 1)
232 fQA->Process();
233
234 PostData(1,fOutList);
235 PostData(2,fOutListEff);
236 PostData(3,fOutListCont);
237 PostData(4,fOutListDCA);
238 PostData(5,fOutListQA);
239
240 return;
241}
242
243//________________________________________________________________________
244void AliEbyEPidRatioTask::Terminate(Option_t *){
245 // Terminate
246}
247
248Int_t AliEbyEPidRatioTask::Initialize() {
249 // Initialize event
250
251 // ------------------------------------------------------------------
252 // -- ESD TrackCuts
253 // ------------------------------------------------------------------
254 TString sModeName("");
255
256 // -- Create ESD track cuts
257 // --------------------------
258 fESDTrackCutsBase = new AliESDtrackCuts;
259
260 if (fESDTrackCutMode == 0) {
261 fESDTrackCutsBase->SetMinNCrossedRowsTPC(70); // TPC
262 fESDTrackCutsBase->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8); // TPC
263 }
264 else if (fESDTrackCutMode == 1) {
265 fESDTrackCutsBase->SetMinNClustersTPC(70); // TPC 2010
266 }
267
268 fESDTrackCutsBase->SetMaxChi2PerClusterTPC(4); // TPC 2010
269 fESDTrackCutsBase->SetAcceptKinkDaughters(kFALSE); // TPC 2010
270 fESDTrackCutsBase->SetRequireTPCRefit(kTRUE); // TPC 2010
271
272 if (fESDTrackCutMode == 0) {
273 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff); // ITS
274 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSDD,AliESDtrackCuts::kOff); // ITS
275 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSSD,AliESDtrackCuts::kOff); // ITS
276 }
277 else if (fESDTrackCutMode == 1) {
278 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny); // ITS 2010
279 // fESDTrackCutsBase->SetMinNClustersITS(4);
280 }
281
282 fESDTrackCutsBase->SetRequireITSRefit(kTRUE); // ITS 2010
283 fESDTrackCutsBase->SetMaxChi2PerClusterITS(36); // ITS 2010
284
285 fESDTrackCutsBase->SetDCAToVertex2D(kFALSE); // VertexConstrained 2010
286 fESDTrackCutsBase->SetRequireSigmaToVertex(kFALSE); // VertexConstrained 2010
287 fESDTrackCutsBase->SetMaxDCAToVertexZ(2); // VertexConstrained 2010
288
289 fESDTrackCutsBase->SetEtaRange(-1.*fEtaMax, fEtaMax); // Acceptance
290 fESDTrackCutsBase->SetPtRange(fPtRange[0],fPtRange[1]); // Acceptance
291
292 // -- Mode : standard cuts
293 if (fESDTrackCutMode == 0)
294 sModeName = "Std";
295 // -- Mode : for comparison to LF
296 else if (fESDTrackCutMode == 1)
297 sModeName = "LF";
298 // -- Mode : Default
299 else
300 sModeName = "Base";
301
302 fESDTrackCutsBase->SetName(Form("NetParticleCuts2010_%s",sModeName.Data()));
303
304 // -- Create ESD track cuts -> Base + DCA
305 // ------------------------------
306 fESDTrackCuts = static_cast<AliESDtrackCuts*>(fESDTrackCutsBase->Clone());
307 fESDTrackCuts->SetName(Form("NetParticleCuts2010_%s",sModeName.Data()));
308 if (fESDTrackCutMode == 0)
309 fESDTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); // 2010 VertexConstrained -> 7*(0.0026+0.0050/pt^1.01)
310 // fESDTrackCuts->SetMaxDCAToVertexXY(0.3);
311 else if (fESDTrackCutMode == 1)
312 fESDTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); // 2010 VertexConstrained -> 7*(0.0026+0.0050/pt^1.01)
313
314 // fESDTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); // golden cut off
315
316 // -- Create ESD BKG track cuts -> Base + Acceptance(Eff)
317 // ------------------------------
318 fESDTrackCutsBkg = static_cast<AliESDtrackCuts*>(fESDTrackCutsBase->Clone());
319 fESDTrackCutsBkg->SetName(Form("NetParticleCuts2010_%s_Bkg",sModeName.Data()));
320 fESDTrackCutsBkg->SetPtRange(fPtRangeEff[0],fPtRangeEff[1]); // Acceptance
321 fESDTrackCutsBkg->SetEtaRange(-1.*fEtaMaxEff, fEtaMaxEff); // Acceptance
322
323 // -- Create ESD Eff track cuts -> Base + DCA + Acceptance(Eff)
324 // ------------------------------
325 fESDTrackCutsEff = static_cast<AliESDtrackCuts*>(fESDTrackCuts->Clone());
326 fESDTrackCutsEff->SetName(Form("NetParticleCuts2010_%s_Eff",sModeName.Data()));
327 fESDTrackCutsEff->SetPtRange(fPtRangeEff[0],fPtRangeEff[1]); // Acceptance
328 fESDTrackCutsEff->SetEtaRange(-1.*fEtaMaxEff, fEtaMaxEff); // Acceptance
329
330 // ------------------------------------------------------------------
331 // -- Initialize Helper
332 // ------------------------------------------------------------------
f7ea34d2 333 if (fHelper->Initialize(fESDTrackCutsEff, fIsMC, fIsRatio, fAODtrackCutBit, fModeDistCreation))
0a28d543 334 return -1;
335
336 // ------------------------------------------------------------------
337 // -- Create / Initialize Efficiency/Contamination
338 // ------------------------------------------------------------------
339 if ((fIsMC||fIsAOD) && fModeEffCreation == 1) {
340 fEffCont = new AliEbyEPidRatioEffCont;
341 fEffCont->Initialize(fHelper);
342 }
343
344 // ------------------------------------------------------------------
345 // -- Create / Initialize DCA Determination
346 // ------------------------------------------------------------------
347 if (fModeDCACreation == 1) {
348 fDCA = new AliEbyEPidRatioDCA;
349 fDCA->SetESDTrackCutsBkg(fESDTrackCutsBkg);
350 fDCA->Initialize(fHelper);
351 }
352
353 // ------------------------------------------------------------------
354 // -- Create / Initialize Phy Determination
355 // ------------------------------------------------------------------
356 if (fModeDistCreation == 1) {
357 fDist = new AliEbyEPidRatioPhy;
358 fDist->SetOutList(fOutList);
359 fDist->Initialize(fHelper, fESDTrackCuts);
360 }
361
362 // ------------------------------------------------------------------
363 // -- Create / Initialize QA Determination
364 // ------------------------------------------------------------------
365 if (fModeQACreation == 1) {
366 fQA = new AliEbyEPidRatioQA();
367 fQA->Initialize(fHelper);
368 }
369
370 // ------------------------------------------------------------------
371 // -- Reset Event
372 // ------------------------------------------------------------------
373 ResetEvent();
374
375 return 0;
376}
377
0a28d543 378//________________________________________________________________________
379Int_t AliEbyEPidRatioTask::SetupEvent() {
0a28d543 380
381 ResetEvent();
382
383 // -- ESD Event
384 // ------------------------------------------------------------------
385 if (!fIsAOD && SetupESDEvent() < 0) {
386 AliError("Setup ESD Event failed");
387 return -1;
388 }
389
390 // -- AOD Event
391 // ------------------------------------------------------------------
392 if (fIsAOD && SetupAODEvent() < 0) {
393 AliError("Setup AOD Event failed");
394 return -1;
395 }
396
397 // -- Setup MC Event
398 // ------------------------------------------------------------------
399 if (fIsMC && SetupMCEvent() < 0) {
400 AliError("Setup MC Event failed");
401 return -1;
402 }
403
404 // -- Setup Event for Helper / EffCont / DCA / Dist / QA classes
405 // ------------------------------------------------------------------
406 fHelper->SetupEvent(fESDHandler, fAODHandler, fMCEvent);
407
408
409 if (fModeEffCreation && (fIsMC || fIsAOD) )
410 fEffCont->SetupEvent();
411
412 if (fModeDCACreation == 1)
413 fDCA->SetupEvent();
414
415 if (fModeDistCreation == 1)
416 fDist->SetupEvent();
417
418 if (fModeQACreation == 1)
419 fQA->SetupEvent();
420
421
422 // -- Evaluate Event cuts
423 // ------------------------------------------------------------------
424 return fHelper->IsEventRejected() ? -2 : 0;
425}
426
427//________________________________________________________________________
428Int_t AliEbyEPidRatioTask::SetupESDEvent() {
429 // -- Setup ESD Event
430 // > return 0 for success
431 // > return -1 for failed setup
432
433
434
435
436 fESDHandler= dynamic_cast<AliESDInputHandler*>
437 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
438 if (!fESDHandler) {
439 AliError("Could not get ESD input handler");
440 return -1;
441 }
442
443 fESD = fESDHandler->GetEvent();
444 if (!fESD) {
445 AliError("Could not get ESD event");
446 return -1;
447 }
448
449 // -- Check PID response
450 // ------------------------------------------------------------------
451 if (!fESDHandler->GetPIDResponse()) {
452 AliError("Could not get PID response");
453 return -1;
454 }
455
456 // -- Check Vertex
457 // ------------------------------------------------------------------
458 if (!fESD->GetPrimaryVertexTracks()) {
459 AliError("Could not get vertex from tracks");
460 return -1;
461 }
462
463 // -- Check Centrality
464 // ------------------------------------------------------------------
465 if (!fESD->GetCentrality()) {
466 AliError("Could not get centrality");
467 return -1;
468 }
469
470 return 0;
471}
472
473//________________________________________________________________________
474Int_t AliEbyEPidRatioTask::SetupAODEvent() {
475 // -- Setup AOD Event
476 // > return 0 for success
477 // > return -1 for failed setup
478
479 fAODHandler= dynamic_cast<AliAODInputHandler*>
480 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
481 if (!fAODHandler) {
482 AliError("Could not get AOD input handler");
483 return -1;
484 }
485
486 fAOD = fAODHandler->GetEvent();
487 if (!fAOD) {
488 AliError("Could not get AOD event");
489 return -1;
490 }
491
492 // -- Check PID response
493 // ------------------------------------------------------------------
494 if (!fAODHandler->GetPIDResponse()) {
495 AliError("Could not get PID response");
496 return -1;
497 }
498
499 // -- Check Vertex
500 // ------------------------------------------------------------------
501 if (!fAOD->GetPrimaryVertex()) {
502 AliError("Could not get primary vertex");
503 return -1;
504 }
505
506 // -- Check Centrality
507 // ------------------------------------------------------------------
508 if (!fAOD->GetHeader()->GetCentralityP()) {
509 AliError("Could not get centrality");
510 return -1;
511 }
512
513 return 0;
514}
515
516//________________________________________________________________________
517Int_t AliEbyEPidRatioTask::SetupMCEvent() {
518 AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>
519 (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
520
521 if (!mcH) {
522 AliError("MC event handler not available");
523 return -1;
524 }
525
526 fMCEvent = mcH->MCEvent();
527 if (!fMCEvent) {
528 AliError("MC event not available");
529 return -1;
530 }
531
532 // -- Get MC header
533 // ------------------------------------------------------------------
534 AliHeader* header = fMCEvent->Header();
535 if (!header) {
536 AliError("MC header not available");
537 return -1;
538 }
539
540 // -- Check Stack
541 // ------------------------------------------------------------------
542 fMCStack = fMCEvent->Stack();
543 if (!fMCStack) {
544 AliError("MC stack not available");
545 return -1;
546 }
547
548 // -- Check GenHeader
549 // ------------------------------------------------------------------
550 if (!header->GenEventHeader()) {
551 AliError("Could not retrieve genHeader from header");
552 return -1;
553 }
554
555 // -- Check primary vertex
556 // ------------------------------------------------------------------
557 if (!fMCEvent->GetPrimaryVertex()){
558 AliError("Could not get MC vertex");
559 return -1;
560 }
561
562 return 0;
563}
564
565//________________________________________________________________________
566void AliEbyEPidRatioTask::ResetEvent() {
567 // -- Reset event
568
569 // -- Reset ESD Event
570 fESD = NULL;
571
572 // -- Reset AOD Event
573 fAOD = NULL;
574
575 // -- Reset MC Event
576 if (fIsMC)
577 fMCEvent = NULL;
578
579 // -- Reset Dist Creation
580 if (fModeDistCreation == 1)
581 fDist->ResetEvent();
582
583 return;
584}
585
586