7 #include "AliESDtrack.h"
8 #include "AliESDEvent.h"
9 #include "AliESDVertex.h"
10 #include "AliESDtrackCuts.h"
12 #include "AliAnalysisTask.h"
13 #include "AliAnalysisManager.h"
14 #include "AliInputEventHandler.h"
17 #include "AliMCEvent.h"
18 #include "AliMCParticle.h"
19 #include "AliGenEventHeader.h"
21 #include "AliAnalysisTaskEventCount.h"
23 // analysis task creating basic QA plots for resonance particles
24 // Author: Ayben Karasu Uysal
27 ClassImp(AliAnalysisTaskEventCount)
29 //________________________________________________________________________
30 AliAnalysisTaskEventCount::AliAnalysisTaskEventCount(const char *name) :
31 AliAnalysisTaskSE(name),
42 // Define input and output slots here
43 // Input slot #0 works with a TChain
44 DefineInput(0, TChain::Class());
46 // Output slot #0 id reserved by the base class for AOD
47 // Output slot #1 writes into a TH1 container
48 DefineOutput(1, TList::Class());
50 // setup to NULL all remaining histos
52 for (i = 0; i < kTypes; i++) fCheck[i] = 0;
55 //________________________________________________________________________
56 void AliAnalysisTaskEventCount::UserCreateOutputObjects()
59 // Create histograms (called once)
63 fESDpid = new AliESDpid();
64 fTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE);
65 fTrackCuts->SetPtRange(0.1, 1E20);
66 fTrackCuts->SetEtaRange(-0.8, 0.8);
69 fOutputList = new TList();
70 fOutputList->SetOwner();
73 fHEvent = new TH1I("EventStat", "Event statistics", kTypes, 0, kTypes);
74 for (Int_t i = 0; i < kTypes; i++) {
75 fHEvent->GetXaxis()->SetBinLabel(i + 1, Title((EType)i));
78 // add histograms to list
79 fOutputList->Add(fHEvent);
81 PostData(1, fOutputList);
84 //________________________________________________________________________
85 void AliAnalysisTaskEventCount::UserExec(Option_t *)
88 // Execute computations
91 // assign first checks
93 fCheck[kPassPhysicsSel] = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
94 fCheck[kGoodPrimaryVertex] = kFALSE;
95 fCheck[kHas1TrackAny] = kFALSE;
96 fCheck[kHas1TrackQuality] = kFALSE;
98 // try to cast input event to ESD and loop on tracks
99 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(InputEvent());
102 // check primary vertex
103 const AliESDVertex *v0 = esd->GetPrimaryVertexTracks();
105 if (v0->GetNContributors() > 0)
106 fCheck[kGoodPrimaryVertex] = kTRUE;
108 v0 = fESD->GetPrimaryVertexSPD();
110 if (v0->GetNContributors() > 0)
111 fCheck[kGoodPrimaryVertex] = kTRUE;
114 v0 = esd->GetPrimaryVertexTPC();
116 if (v0->GetNContributors() > 0) fCheck[kGoodPrimaryVertex] = kTRUE;
125 if (esd->GetNumberOfTracks() > 0) fCheck[kHas1TrackAny] = kTRUE;
126 if (fTrackCuts->CountAcceptedTracks(esd) > 0) fCheck[kHas1TrackQuality] = kTRUE;
129 for (Int_t i = 0; i < kTypes; i++) {
130 if (fCheck[i]) fHEvent->Fill((Double_t)i + 0.01);
133 PostData(1, fOutputList);
136 //________________________________________________________________________
137 void AliAnalysisTaskEventCount::Terminate(Option_t *)
141 // Quickly check that the output list is there
144 fOutputList = dynamic_cast<TList*>(GetOutputData(1));
146 AliError("Output list not found!!!");