2 // Class AliRsnAnalysisTrackEffSE
7 // authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
8 // Martin Vala (martin.vala@cern.ch)
10 #include <Riostream.h>
12 #include "AliESDEvent.h"
13 #include "AliMCEvent.h"
15 #include "AliCFContainer.h"
16 #include "AliRsnCutSet.h"
17 #include "AliRsnFunctionAxis.h"
18 #include "AliRsnAnalysisTrackEffSE.h"
19 #include "AliRsnCutSet.h"
21 ClassImp(AliRsnAnalysisTrackEffSE)
23 //_____________________________________________________________________________
24 AliRsnAnalysisTrackEffSE::AliRsnAnalysisTrackEffSE(const char *name) :
25 AliRsnVAnalysisTaskSE(name),
34 // Default constructor.
37 AliDebug(AliLog::kDebug+2,"<-");
39 DefineOutput(2, TList::Class());
42 for (i = 0; i <= AliPID::kSPECIES; i++) fContainer[i] = 0x0;
44 AliDebug(AliLog::kDebug+2,"->");
47 //_____________________________________________________________________________
48 AliRsnAnalysisTrackEffSE::AliRsnAnalysisTrackEffSE(const AliRsnAnalysisTrackEffSE& copy) :
49 AliRsnVAnalysisTaskSE(copy),
50 fEventCuts(copy.fEventCuts),
51 fStepListMC(copy.fStepListMC),
52 fStepListESD(copy.fStepListESD),
53 fAxisList(copy.fAxisList),
62 //_____________________________________________________________________________
63 void AliRsnAnalysisTrackEffSE::RsnUserCreateOutputObjects()
66 // Creation of output objects.
67 // These are created through the utility methods in the analysis manager,
68 // which produces a list of histograms for each specified set of pairs.
69 // Each of these lists is added to the main list of this task.
72 AliDebug(AliLog::kDebug+2,"<-");
74 // get number of steps and axes
76 Int_t nAxes = fAxisList.GetEntries();
77 Int_t nSteps = (Int_t)fStepListMC.GetEntries() + (Int_t)fStepListESD.GetEntries();
80 AliError("No steps defined");
84 AliError("No axes defined");
88 // initialize variable list
91 // retrieve number of bins for each axis
92 Int_t *nBins = new Int_t[nAxes];
93 TArrayD *binLimits = new TArrayD[nAxes];
94 for (iaxis = 0; iaxis < nAxes; iaxis++) {
95 AliRsnFunctionAxis *fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(iaxis);
96 binLimits[iaxis] = fcnAxis->GetArray();
97 nBins[iaxis] = binLimits[iaxis].GetSize() - 1;
100 // initialize output list
102 fOutList[1] = new TList();
103 fOutList[1]->SetOwner();
105 // create the containers
107 for (i = 0; i <= AliPID::kSPECIES; i++)
109 if (i < AliPID::kSPECIES) fContainer[i] = new AliCFContainer(Form("%s", AliPID::ParticleName((AliPID::EParticleType)i)), "", nSteps, nAxes, nBins);
110 else fContainer[i] = new AliCFContainer("all", "", nSteps, nAxes, nBins);
111 // set the bin limits for each axis
112 for (iaxis = 0; iaxis < nAxes; iaxis++) fContainer[i]->SetBinLimits(iaxis, binLimits[iaxis].GetArray());
113 // add the container to output list
114 fOutList[1]->Add(fContainer[i]);
117 AliDebug(AliLog::kDebug+2,"->");
120 //_____________________________________________________________________________
121 void AliRsnAnalysisTrackEffSE::RsnUserExec(Option_t*)
124 // Execution of the analysis task.
125 // Recovers the input event and processes it with all included pair objects.
126 // In this case, we NEED to have ESD and MC, otherwise we cannod do anything.
129 AliDebug(AliLog::kDebug+2,"<-");
130 if (!fESDEvent || !fMCEvent) {
131 AliError("This task can process only ESD + MC events");
134 fRsnEvent.SetRef(fESDEvent, fMCEvent);
136 // if general event cuts are added to the task (recommended)
137 // they are checked here on the RSN event interface and,
138 // if the event does not pass them, it is skipped and ProcessInfo
139 // is updated accordingly
141 if (!fEventCuts->IsSelected(AliRsnCut::kEvent, &fRsnEvent)) {
142 fTaskInfo.SetEventUsed(kFALSE);
147 // if cuts are passed or not cuts were defined,
148 // update the task info before processing the event
149 fTaskInfo.SetEventUsed(kTRUE);
151 // process first MC steps and then ESD steps
156 PostData(2, fOutList[1]);
158 AliDebug(AliLog::kDebug+2,"->");
161 //_____________________________________________________________________________
162 void AliRsnAnalysisTrackEffSE::ProcessEventMC()
165 // Process current event with the definitions of the specified step in MC list
166 // and store results in the container slot defined in second argument
169 AliStack *stack = fMCEvent->Stack();
172 // other utility variables
175 // in this case, we first take the resonance from MC
176 // and then we find its daughters and compute cuts on them
177 for (ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++)
179 part = (AliMCParticle*) fMCEvent->GetTrack(ipart);
181 fDaughter.SetRef(part);
182 fDaughter.SetParticle(part->Particle());
183 fDaughter.FindMotherPDG(stack);
185 FillContainer(&fStepListMC, 0);
189 //_____________________________________________________________________________
190 void AliRsnAnalysisTrackEffSE::ProcessEventESD()
193 // Process current event with the definitions of the specified step in ESD list
194 // and store results in the container slot defined in second argument
197 Int_t ic, i, first = (Int_t)fStepListMC.GetEntries();
199 // get arrays of all charged tracks
201 a[0] = fRsnPIDIndex.GetTracksArray(AliRsnDaughter::kNoPID, '+', AliPID::kUnknown);
202 a[1] = fRsnPIDIndex.GetTracksArray(AliRsnDaughter::kNoPID, '-', AliPID::kUnknown);
204 // external loop on tracks
205 for (ic = 0; ic < 2; ic++)
207 for (i = 0; i < a[ic]->GetSize(); i++)
210 fRsnEvent.SetDaughter(fDaughter, a[ic]->At(i));
211 if (!fDaughter.IsOK()) continue;
212 fDaughter.SetRequiredPID(fDaughter.PerfectPID());
214 FillContainer(&fStepListESD, first);
219 //_____________________________________________________________________________
220 void AliRsnAnalysisTrackEffSE::FillContainer
221 (const TObjArray *stepList, Int_t firstOutStep)
224 // Fill the containers
228 Int_t iaxis, nAxes = fAxisList.GetEntries();
229 Int_t istep, nSteps = stepList->GetEntries();
231 // compute values for all axes
232 for (iaxis = 0; iaxis < nAxes; iaxis++) {
233 AliRsnFunctionAxis *fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(iaxis);
234 switch (fcnAxis->GetAxisObject())
236 case AliRsnFunctionAxis::kParticle:
237 fVar[iaxis] = (Double_t)fcnAxis->Eval(&fDaughter);
239 case AliRsnFunctionAxis::kEvent:
240 fVar[iaxis] = (Double_t)fcnAxis->Eval(&fRsnEvent);
248 for (istep = 0; istep < nSteps; istep++) {
249 AliRsnCutSet *cutSet = (AliRsnCutSet*)stepList->At(istep);
250 if (!cutSet->IsSelected(AliRsnCut::kParticle, &fDaughter)) break;
251 if (stepList == &fStepListESD && !PassedAllCutsMC()) break;
253 ipid = (Int_t)fDaughter.PerfectPID();
254 if (ipid == (Int_t)AliPID::kUnknown) ipid = (Int_t)AliPID::kSPECIES;
255 fContainer[ipid]->Fill(fVar.GetArray(), istep + firstOutStep);
256 fContainer[AliPID::kSPECIES]->Fill(fVar.GetArray(), istep + firstOutStep);
260 //_____________________________________________________________________________
261 Bool_t AliRsnAnalysisTrackEffSE::PassedAllCutsMC()
264 // Check if this daughter passes all cuts MC
267 Int_t istep, nSteps = fStepListMC.GetEntries();
269 for (istep = 0; istep < nSteps; istep++) {
270 AliRsnCutSet *cutSet = (AliRsnCutSet*)fStepListMC.At(istep);
271 if (!cutSet->IsSelected(AliRsnCut::kParticle, &fDaughter)) return kFALSE;
277 //_____________________________________________________________________________
278 void AliRsnAnalysisTrackEffSE::RsnTerminate(Option_t*)
282 // Could be added some monitor histograms here.
285 AliDebug(AliLog::kDebug+2,"<-");
286 AliDebug(AliLog::kDebug+2,"->");