4 // Simple task to test the collision normalization. Can be called for
5 // both MC and data and shows how to fill the collision normalization
8 // Author: Michele Floris
12 #include "AliCollisionNormalizationTask.h"
19 #include <AliESDEvent.h>
20 #include <AliHeader.h>
22 #include "AliCollisionNormalization.h"
23 #include "AliAnalysisManager.h"
24 #include "AliInputEventHandler.h"
26 //#include "AliBackgroundSelection.h"
27 #include "AliMultiplicity.h"
28 #include "AliMCEvent.h"
30 ClassImp(AliCollisionNormalizationTask)
32 AliCollisionNormalizationTask::AliCollisionNormalizationTask() :
33 AliAnalysisTaskSE("AliCollisionNormalizationTask"),
36 fCollisionNormalization(0)
39 // Default event handler
42 // Define input and output slots here
43 DefineOutput(1, TList::Class());
47 AliCollisionNormalizationTask::AliCollisionNormalizationTask(const char* name) :
48 AliAnalysisTaskSE(name),
51 fCollisionNormalization(new AliCollisionNormalization())
54 // Constructor. Initialization of pointers
57 // Define input and output slots here
58 DefineOutput(1, TList::Class());
60 // AliLog::SetClassDebugLevel("AliCollisionNormalizationTask", AliLog::kWarning);
63 AliCollisionNormalizationTask::~AliCollisionNormalizationTask()
69 // histograms are in the output list and deleted when the output
70 // list is deleted by the TSelector dtor
72 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
78 void AliCollisionNormalizationTask::UserCreateOutputObjects()
80 // create result objects and add to output list
82 Printf("AliCollisionNormalizationTask::CreateOutputObjects");
87 if (!fCollisionNormalization)
88 fCollisionNormalization = new AliCollisionNormalization;
90 fOutput->Add(fCollisionNormalization);
91 // fOutput->Add(fCollisionNormalization->GetVzCorrZeroBin ());
92 // fOutput->Add(fCollisionNormalization->GetVzMCGen ());
93 // fOutput->Add(fCollisionNormalization->GetVzMCRec ());
94 // fOutput->Add(fCollisionNormalization->GetVzMCTrg ());
95 // fOutput->Add(fCollisionNormalization->GetVzData ());
96 // fOutput->Add(fCollisionNormalization->GetNEvents ());
97 // fOutput->Add(fCollisionNormalization->GetStatBin0 ());
101 void AliCollisionNormalizationTask::UserExec(Option_t*)
106 PostData(1, fOutput);
109 AliESDEvent * aESD = dynamic_cast<AliESDEvent*>(fInputEvent);
111 AliFatal("Cannot get ESD");
113 if (strcmp(aESD->ClassName(),"AliESDEvent")) {
114 AliFatal("Not processing ESDs");
116 // Get MC event, if needed
117 AliMCEvent* mcEvent = fIsMC ? MCEvent() : 0;
118 if (!mcEvent && fIsMC){
119 AliFatal("Running on MC but no MC handler available");
122 // Physics selection. At least in the case of MC we cannot use
123 // yourTask->SelectCollisionCandidates();, because we also need to
124 // fill the "generated" histogram
125 // NB never call IsEventSelected more than once per event
126 // (statistics histogram would be altered)
128 // FIXME: using only MB events, foresee more events?
129 Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
131 // Get the Multiplicity cut
132 const AliMultiplicity* mult = aESD->GetMultiplicity();
134 AliError("Can't get mult object");
138 // Check if the event is "reconstructed" according to some quality
139 // cuts. Tipically, we mean "it has a good-eonugh vertex"
141 Int_t ntracklet = mult->GetNumberOfTracklets();
142 const AliESDVertex * vtxESD = aESD->GetPrimaryVertexSPD();
143 if (IsEventInBinZero()) {
148 if (ntracklet > 0 && !vtxESD) {
149 AliError("No vertex but reconstructed tracklets?");
152 // assign vz. For MC we use generated vz
154 if (!fIsMC) vz = vtxESD ? vtxESD->GetZ() : 0; // FIXME : is zv used anywhere in Gen?
155 else vz = mcEvent->GetPrimaryVertex()->GetZ();
158 // Monte Carlo: we fill 3 histos
159 if (!isSelected || !vtxESD) ntracklet = 0; //If the event does not pass the physics selection or is not rec, it goes in the bin0
160 fCollisionNormalization->FillVzMCGen(vz, ntracklet, mcEvent);
161 // If triggered == passing the physics selection
163 fCollisionNormalization->FillVzMCTrg(vz, ntracklet, mcEvent);
164 // If reconstructer == good enough vertex
165 if (vtxESD) fCollisionNormalization->FillVzMCRec(vz, ntracklet, mcEvent);
169 // Passing the trigger
170 fCollisionNormalization->FillVzData(vz,ntracklet);
176 void AliCollisionNormalizationTask::Terminate(Option_t *)
178 // The Terminate() function is the last function to be called during
179 // a query. It always runs on the client, it can be used to present
180 // the results graphically or save the results to file.
182 fOutput = dynamic_cast<TList*> (GetOutputData(1));
184 Printf("ERROR: fOutput not available");
189 Bool_t AliCollisionNormalizationTask::IsEventInBinZero() {
191 // Returns true if an event is to be assigned to the zero bin
193 // You should have your own version of this method in the class: in
194 // general, the definition of "reconstructed" event is subjective.
196 Bool_t isZeroBin = kTRUE;
197 const AliESDEvent* esd= dynamic_cast<AliESDEvent*>(fInputEvent);
199 Printf("AliCollisionNormalizationTask::IsEventInBinZero: Can't get ESD");
202 const AliMultiplicity* mult = esd->GetMultiplicity();
204 Printf("AliCollisionNormalizationTask::IsEventInBinZero: Can't get mult object");
207 Int_t ntracklet = mult->GetNumberOfTracklets();
208 const AliESDVertex * vtxESD = esd->GetPrimaryVertexSPD();
210 // If there is a vertex from vertexer z with delta phi > 0.02 we
211 // don't consider it rec (we keep the event in bin0). If quality
212 // is good eneough we check the number of tracklets
213 // if the vertex is more than 15 cm away, this is autamatically bin0
214 if( TMath::Abs(vtxESD->GetZ()) <= 15 ) {
215 if (vtxESD->IsFromVertexerZ()) {
216 if (vtxESD->GetDispersion()<=0.02 ) {
217 if(ntracklet>0) isZeroBin = kFALSE;
219 } else if(ntracklet>0) isZeroBin = kFALSE; // if the event is not from Vz we chek the n of tracklets