10 #include "TStopwatch.h"
12 #include "THashList.h"
14 #include "AliAnalysisTask.h"
15 #include "AliAnalysisManager.h"
16 #include "AliTracker.h"
17 #include "AliESDEvent.h"
18 #include "AliESDInputHandler.h"
19 #include "AliESDpid.h"
21 #include "AliMCEvent.h"
22 #include "AliMCEventHandler.h"
23 #include "AliESDtrackCuts.h"
24 #include "AliKineTrackCuts.h"
25 #include "AliMCParticle.h"
26 #include "AliESDVZERO.h"
27 #include "AliAnalysisTaskNetParticle.h"
28 #include "AliGenEventHeader.h"
29 #include "AliCentrality.h"
30 #include "AliAODEvent.h"
31 #include "AliAODInputHandler.h"
36 * Class for NetParticle Distributions
38 * Authors: Jochen Thaeder <jochen@thaeder.de>
39 * Michael Weber <m.weber@cern.ch>
42 ClassImp(AliAnalysisTaskNetParticle)
45 * ---------------------------------------------------------------------------------
46 * Constructor / Destructor
47 * ---------------------------------------------------------------------------------
50 //________________________________________________________________________
51 AliAnalysisTaskNetParticle::AliAnalysisTaskNetParticle(const char *name) :
52 AliAnalysisTaskSE(name),
68 fESDTrackCutsBase(NULL),
70 fESDTrackCutsBkg(NULL),
71 fESDTrackCutsEff(NULL),
92 fAODtrackCutBit(1024) {
95 AliLog::SetClassDebugLevel("AliAnalysisTaskNetParticle",10);
100 fPtRangeEff[1] = 1.6;
103 // -------------------------------------------------
104 DefineOutput(1, TList::Class());
105 DefineOutput(2, TList::Class());
106 DefineOutput(3, TList::Class());
107 DefineOutput(4, TList::Class());
108 DefineOutput(5, TList::Class());
111 //________________________________________________________________________
112 AliAnalysisTaskNetParticle::~AliAnalysisTaskNetParticle() {
115 if (fESDTrackCutsBase) delete fESDTrackCutsBase;
116 if (fESDTrackCuts) delete fESDTrackCuts;
117 if (fESDTrackCutsBkg) delete fESDTrackCutsBkg;
118 if (fESDTrackCutsEff) delete fESDTrackCutsEff;
120 if (fEffCont) delete fEffCont;
121 if (fDCA) delete fDCA;
122 if (fDist) delete fDist;
124 if (fHelper) delete fHelper;
128 * ---------------------------------------------------------------------------------
130 * ---------------------------------------------------------------------------------
133 //________________________________________________________________________
134 void AliAnalysisTaskNetParticle::UserCreateOutputObjects() {
137 // ------------------------------------------------------------------
138 // -- Create Output Lists
139 // ------------------------------------------------------------------
140 Bool_t oldStatus = TH1::AddDirectoryStatus();
141 TH1::AddDirectory(kFALSE);
143 fOutList = new TList;
144 fOutList->SetName(GetName()) ;
145 fOutList->SetOwner(kTRUE);
147 fOutListEff = new TList;
148 fOutListEff->SetName(Form("%s_eff",GetName()));
149 fOutListEff->SetOwner(kTRUE) ;
151 fOutListCont = new TList;
152 fOutListCont->SetName(Form("%s_cont",GetName()));
153 fOutListCont->SetOwner(kTRUE) ;
155 fOutListDCA = new TList;
156 fOutListDCA->SetName(Form("%s_dca",GetName()));
157 fOutListDCA->SetOwner(kTRUE) ;
159 fOutListQA = new TList;
160 fOutListQA->SetName(Form("%s_qa",GetName()));
161 fOutListQA->SetOwner(kTRUE) ;
163 // ------------------------------------------------------------------
164 // -- Initialize all classes
165 // ------------------------------------------------------------------
168 // ------------------------------------------------------------------
169 // -- Get event / trigger statistics histograms
170 // ------------------------------------------------------------------
171 fOutList->Add(fHelper->GetHEventStat0());
172 fOutList->Add(fHelper->GetHEventStat1());
173 fOutList->Add(fHelper->GetHTriggerStat());
174 fOutList->Add(fHelper->GetHCentralityStat());
176 // ------------------------------------------------------------------
177 // -- Add histograms from efficiency/contamination class
178 // ------------------------------------------------------------------
179 if ((fIsAOD||fIsMC) && fModeEffCreation == 1) {
180 fOutListEff->Add(fEffCont->GetHnEff());
181 fOutListCont->Add(fEffCont->GetHnCont());
184 // ------------------------------------------------------------------
185 // -- Add histograms from DCA class
186 // ------------------------------------------------------------------
187 if (fModeDCACreation == 1)
188 fOutListDCA->Add(fDCA->GetHnDCA());
190 // ------------------------------------------------------------------
191 // -- Add histograms from QA class
192 // ------------------------------------------------------------------
193 if (fModeQACreation == 1)
194 fOutListQA->Add(fQA->GetHnQA());
196 // ------------------------------------------------------------------
198 TH1::AddDirectory(oldStatus);
200 PostData(1,fOutList);
201 PostData(2,fOutListEff);
202 PostData(3,fOutListCont);
203 PostData(4,fOutListDCA);
204 PostData(5,fOutListQA);
209 //________________________________________________________________________
210 void AliAnalysisTaskNetParticle::UserExec(Option_t *) {
211 // Called for each event
213 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
215 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
216 if (SetupEvent() < 0) {
217 PostData(1,fOutList);
218 PostData(2,fOutListEff);
219 PostData(3,fOutListCont);
220 PostData(4,fOutListDCA);
221 PostData(5,fOutListQA);
225 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
226 // -- Process Efficiency / Contamination Determination
227 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
228 if ((fIsMC||fIsAOD) && fModeEffCreation == 1)
231 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
232 // -- Process DCA Determination
233 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
234 if (fModeDCACreation == 1)
237 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
238 // -- Process Distributions
239 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
240 if (fModeDistCreation == 1)
243 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
244 // -- Fill QA histograms
245 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
246 if (fModeQACreation == 1)
249 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
250 // -- Post output data
251 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
253 PostData(1,fOutList);
254 PostData(2,fOutListEff);
255 PostData(3,fOutListCont);
256 PostData(4,fOutListDCA);
257 PostData(5,fOutListQA);
262 //________________________________________________________________________
263 void AliAnalysisTaskNetParticle::Terminate(Option_t *){
268 * ---------------------------------------------------------------------------------
270 * ---------------------------------------------------------------------------------
273 //________________________________________________________________________
274 Int_t AliAnalysisTaskNetParticle::Initialize() {
277 // ------------------------------------------------------------------
279 // ------------------------------------------------------------------
280 TString sModeName("");
282 // -- Create ESD track cuts
283 // --------------------------
284 fESDTrackCutsBase = new AliESDtrackCuts;
286 if (fESDTrackCutMode == 0) {
287 fESDTrackCutsBase->SetMinNCrossedRowsTPC(70); // TPC
288 fESDTrackCutsBase->SetMinRatioCrossedRowsOverFindableClustersTPC(0.8); // TPC
290 else if (fESDTrackCutMode == 1) {
291 fESDTrackCutsBase->SetMinNClustersTPC(70); // TPC 2010
294 fESDTrackCutsBase->SetMaxChi2PerClusterTPC(4); // TPC 2010
295 fESDTrackCutsBase->SetAcceptKinkDaughters(kFALSE); // TPC 2010
296 fESDTrackCutsBase->SetRequireTPCRefit(kTRUE); // TPC 2010
298 if (fESDTrackCutMode == 0) {
299 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kOff); // ITS
300 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSDD,AliESDtrackCuts::kOff); // ITS
301 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSSD,AliESDtrackCuts::kOff); // ITS
303 else if (fESDTrackCutMode == 1) {
304 fESDTrackCutsBase->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny); // ITS 2010
305 // fESDTrackCutsBase->SetMinNClustersITS(4);
308 fESDTrackCutsBase->SetRequireITSRefit(kTRUE); // ITS 2010
309 fESDTrackCutsBase->SetMaxChi2PerClusterITS(36); // ITS 2010
311 fESDTrackCutsBase->SetDCAToVertex2D(kFALSE); // VertexConstrained 2010
312 fESDTrackCutsBase->SetRequireSigmaToVertex(kFALSE); // VertexConstrained 2010
313 fESDTrackCutsBase->SetMaxDCAToVertexZ(2); // VertexConstrained 2010
315 fESDTrackCutsBase->SetEtaRange(-1.*fEtaMax, fEtaMax); // Acceptance
316 fESDTrackCutsBase->SetPtRange(fPtRange[0],fPtRange[1]); // Acceptance
318 // -- Mode : standard cuts
319 if (fESDTrackCutMode == 0)
321 // -- Mode : for comparison to LF
322 else if (fESDTrackCutMode == 1)
328 fESDTrackCutsBase->SetName(Form("NetParticleCuts2010_%s",sModeName.Data()));
330 // -- Create ESD track cuts -> Base + DCA
331 // ------------------------------
332 fESDTrackCuts = static_cast<AliESDtrackCuts*>(fESDTrackCutsBase->Clone());
333 fESDTrackCuts->SetName(Form("NetParticleCuts2010_%s",sModeName.Data()));
334 if (fESDTrackCutMode == 0)
335 fESDTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); // 2010 VertexConstrained -> 7*(0.0026+0.0050/pt^1.01)
336 // fESDTrackCuts->SetMaxDCAToVertexXY(0.3);
337 else if (fESDTrackCutMode == 1)
338 fESDTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01"); // 2010 VertexConstrained -> 7*(0.0026+0.0050/pt^1.01)
340 // fESDTrackCuts->SetMaxChi2TPCConstrainedGlobal(36); // golden cut off
342 // -- Create ESD BKG track cuts -> Base + Acceptance(Eff)
343 // ------------------------------
344 fESDTrackCutsBkg = static_cast<AliESDtrackCuts*>(fESDTrackCutsBase->Clone());
345 fESDTrackCutsBkg->SetName(Form("NetParticleCuts2010_%s_Bkg",sModeName.Data()));
346 fESDTrackCutsBkg->SetPtRange(fPtRangeEff[0],fPtRangeEff[1]); // Acceptance
347 fESDTrackCutsBkg->SetEtaRange(-1.*fEtaMaxEff, fEtaMaxEff); // Acceptance
349 // -- Create ESD Eff track cuts -> Base + DCA + Acceptance(Eff)
350 // ------------------------------
351 fESDTrackCutsEff = static_cast<AliESDtrackCuts*>(fESDTrackCuts->Clone());
352 fESDTrackCutsEff->SetName(Form("NetParticleCuts2010_%s_Eff",sModeName.Data()));
353 fESDTrackCutsEff->SetPtRange(fPtRangeEff[0],fPtRangeEff[1]); // Acceptance
354 fESDTrackCutsEff->SetEtaRange(-1.*fEtaMaxEff, fEtaMaxEff); // Acceptance
356 // ------------------------------------------------------------------
357 // -- Initialize Helper
358 // ------------------------------------------------------------------
359 if (fHelper->Initialize(fESDTrackCutsEff, fIsMC, fAODtrackCutBit, fModeDistCreation))
362 // ------------------------------------------------------------------
363 // -- Create / Initialize Efficiency/Contamination
364 // ------------------------------------------------------------------
365 if ((fIsMC||fIsAOD) && fModeEffCreation == 1) {
366 fEffCont = new AliAnalysisNetParticleEffCont;
367 fEffCont->Initialize(fHelper);
370 // ------------------------------------------------------------------
371 // -- Create / Initialize DCA Determination
372 // ------------------------------------------------------------------
373 if (fModeDCACreation == 1) {
374 fDCA = new AliAnalysisNetParticleDCA;
375 fDCA->SetESDTrackCutsBkg(fESDTrackCutsBkg);
376 fDCA->Initialize(fHelper);
379 // ------------------------------------------------------------------
380 // -- Create / Initialize Distribution Determination
381 // ------------------------------------------------------------------
382 if (fModeDistCreation == 1) {
383 fDist = new AliAnalysisNetParticleDistribution;
384 fDist->SetOutList(fOutList);
385 fDist->Initialize(fHelper, fESDTrackCuts);
388 // ------------------------------------------------------------------
389 // -- Create / Initialize QA Determination
390 // ------------------------------------------------------------------
391 if (fModeQACreation == 1) {
392 fQA = new AliAnalysisNetParticleQA();
393 fQA->Initialize(fHelper);
396 // ------------------------------------------------------------------
398 // ------------------------------------------------------------------
405 * ---------------------------------------------------------------------------------
406 * Setup/Reset Methods - private
407 * ---------------------------------------------------------------------------------
410 //________________________________________________________________________
411 Int_t AliAnalysisTaskNetParticle::SetupEvent() {
412 // Setup Reading of event
413 // > return 0 for success / accepted event
414 // > return -1 for failed setup
415 // > return -2 for rejected event
420 // ------------------------------------------------------------------
421 if (!fIsAOD && SetupESDEvent() < 0) {
422 AliError("Setup ESD Event failed");
427 // ------------------------------------------------------------------
428 if (fIsAOD && SetupAODEvent() < 0) {
429 AliError("Setup AOD Event failed");
434 // ------------------------------------------------------------------
435 if (fIsMC && SetupMCEvent() < 0) {
436 AliError("Setup MC Event failed");
440 // -- Setup Event for Helper / EffCont / DCA / Dist / QA classes
441 // ------------------------------------------------------------------
442 fHelper->SetupEvent(fESDHandler, fAODHandler, fMCEvent);
444 if (fModeEffCreation && (fIsMC || fIsAOD) )
445 fEffCont->SetupEvent();
447 if (fModeDCACreation == 1)
450 if (fModeDistCreation == 1)
453 if (fModeQACreation == 1)
456 // -- Evaluate Event cuts
457 // ------------------------------------------------------------------
458 return fHelper->IsEventRejected() ? -2 : 0;
461 //________________________________________________________________________
462 Int_t AliAnalysisTaskNetParticle::SetupESDEvent() {
463 // -- Setup ESD Event
464 // > return 0 for success
465 // > return -1 for failed setup
467 fESDHandler= dynamic_cast<AliESDInputHandler*>
468 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
470 AliError("Could not get ESD input handler");
474 fESD = fESDHandler->GetEvent();
476 AliError("Could not get ESD event");
480 // -- Check PID response
481 // ------------------------------------------------------------------
482 if (!fESDHandler->GetPIDResponse()) {
483 AliError("Could not get PID response");
488 // ------------------------------------------------------------------
489 if (!fESD->GetPrimaryVertexTracks()) {
490 AliError("Could not get vertex from tracks");
494 // -- Check Centrality
495 // ------------------------------------------------------------------
496 if (!fESD->GetCentrality()) {
497 AliError("Could not get centrality");
504 //________________________________________________________________________
505 Int_t AliAnalysisTaskNetParticle::SetupAODEvent() {
506 // -- Setup AOD Event
507 // > return 0 for success
508 // > return -1 for failed setup
510 fAODHandler= dynamic_cast<AliAODInputHandler*>
511 (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
513 AliError("Could not get AOD input handler");
517 fAOD = fAODHandler->GetEvent();
519 AliError("Could not get AOD event");
523 // -- Check PID response
524 // ------------------------------------------------------------------
525 if (!fAODHandler->GetPIDResponse()) {
526 AliError("Could not get PID response");
531 // ------------------------------------------------------------------
532 if (!fAOD->GetPrimaryVertex()) {
533 AliError("Could not get primary vertex");
537 // -- Check Centrality
538 // ------------------------------------------------------------------
539 if (!((AliVAODHeader*)fAOD->GetHeader())->GetCentralityP()) {
540 AliError("Could not get centrality");
547 //________________________________________________________________________
548 Int_t AliAnalysisTaskNetParticle::SetupMCEvent() {
550 // > return 0 for success
551 // > return -1 for failed setup
553 AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>
554 (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
557 AliError("MC event handler not available");
561 fMCEvent = mcH->MCEvent();
563 AliError("MC event not available");
568 // ------------------------------------------------------------------
569 AliHeader* header = fMCEvent->Header();
571 AliError("MC header not available");
576 // ------------------------------------------------------------------
577 fMCStack = fMCEvent->Stack();
579 AliError("MC stack not available");
583 // -- Check GenHeader
584 // ------------------------------------------------------------------
585 if (!header->GenEventHeader()) {
586 AliError("Could not retrieve genHeader from header");
590 // -- Check primary vertex
591 // ------------------------------------------------------------------
592 if (!fMCEvent->GetPrimaryVertex()){
593 AliError("Could not get MC vertex");
600 //________________________________________________________________________
601 void AliAnalysisTaskNetParticle::ResetEvent() {
604 // -- Reset ESD Event
607 // -- Reset AOD Event
614 // -- Reset Dist Creation
615 if (fModeDistCreation == 1)