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),
33 // Default constructor.
36 AliDebug(AliLog::kDebug+2,"<-");
38 DefineOutput(2, TList::Class());
41 for (i = 0; i <= AliPID::kSPECIES; i++) fContainer[i] = 0x0;
43 AliDebug(AliLog::kDebug+2,"->");
46 //_____________________________________________________________________________
47 AliRsnAnalysisTrackEffSE::AliRsnAnalysisTrackEffSE(const AliRsnAnalysisTrackEffSE& copy) :
48 AliRsnVAnalysisTaskSE(copy),
49 fEventCuts(copy.fEventCuts),
50 fStepListMC(copy.fStepListMC),
51 fStepListESD(copy.fStepListESD),
52 fAxisList(copy.fAxisList),
60 //_____________________________________________________________________________
61 void AliRsnAnalysisTrackEffSE::RsnUserCreateOutputObjects()
64 // Creation of output objects.
65 // These are created through the utility methods in the analysis manager,
66 // which produces a list of histograms for each specified set of pairs.
67 // Each of these lists is added to the main list of this task.
70 AliDebug(AliLog::kDebug+2,"<-");
72 // get number of steps and axes
74 Int_t nAxes = fAxisList.GetEntries();
75 Int_t nSteps = (Int_t)fStepListMC.GetEntries() + (Int_t)fStepListESD.GetEntries();
78 AliError("No steps defined");
82 AliError("No axes defined");
86 // initialize variable list
89 // retrieve number of bins for each axis
90 Int_t *nBins = new Int_t[nAxes];
91 TArrayD *binLimits = new TArrayD[nAxes];
92 for (iaxis = 0; iaxis < nAxes; iaxis++) {
93 AliRsnFunctionAxis *fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(iaxis);
94 binLimits[iaxis] = fcnAxis->GetArray();
95 nBins[iaxis] = binLimits[iaxis].GetSize() - 1;
98 // initialize output list
100 fOutList[1] = new TList();
101 fOutList[1]->SetOwner();
103 // create the containers
105 for (i = 0; i <= AliPID::kSPECIES; i++)
107 if (i < AliPID::kSPECIES) fContainer[i] = new AliCFContainer(Form("%s", AliPID::ParticleName((AliPID::EParticleType)i)), "", nSteps, nAxes, nBins);
108 else fContainer[i] = new AliCFContainer("all", "", nSteps, nAxes, nBins);
109 // set the bin limits for each axis
110 for (iaxis = 0; iaxis < nAxes; iaxis++) fContainer[i]->SetBinLimits(iaxis, binLimits[iaxis].GetArray());
111 // add the container to output list
112 fOutList[1]->Add(fContainer[i]);
115 AliDebug(AliLog::kDebug+2,"->");
118 //_____________________________________________________________________________
119 void AliRsnAnalysisTrackEffSE::RsnUserExec(Option_t*)
122 // Execution of the analysis task.
123 // Recovers the input event and processes it with all included pair objects.
124 // In this case, we NEED to have ESD and MC, otherwise we cannod do anything.
127 AliDebug(AliLog::kDebug+2,"<-");
128 if (!fESDEvent || !fMCEvent) {
129 AliError("This task can process only ESD + MC events");
132 fRsnEvent.SetRef(fESDEvent, fMCEvent);
134 // if general event cuts are added to the task (recommended)
135 // they are checked here on the RSN event interface and,
136 // if the event does not pass them, it is skipped and ProcessInfo
137 // is updated accordingly
139 if (!fEventCuts->IsSelected(AliRsnCut::kEvent, &fRsnEvent)) {
140 fTaskInfo.SetEventUsed(kFALSE);
145 // if cuts are passed or not cuts were defined,
146 // update the task info before processing the event
147 fTaskInfo.SetEventUsed(kTRUE);
149 // process first MC steps and then ESD steps
154 PostData(2, fOutList[1]);
156 AliDebug(AliLog::kDebug+2,"->");
159 //_____________________________________________________________________________
160 void AliRsnAnalysisTrackEffSE::ProcessEventMC()
163 // Process current event with the definitions of the specified step in MC list
164 // and store results in the container slot defined in second argument
167 AliStack *stack = fMCEvent->Stack();
170 // other utility variables
173 // in this case, we first take the resonance from MC
174 // and then we find its daughters and compute cuts on them
175 for (ipart = 0; ipart < fMCEvent->GetNumberOfTracks(); ipart++)
177 part = (AliMCParticle*) fMCEvent->GetTrack(ipart);
179 fDaughter.SetRef(part);
180 fDaughter.SetParticle(part->Particle());
181 fDaughter.FindMotherPDG(stack);
183 FillContainer(&fStepListMC, 0);
187 //_____________________________________________________________________________
188 void AliRsnAnalysisTrackEffSE::ProcessEventESD()
191 // Process current event with the definitions of the specified step in ESD list
192 // and store results in the container slot defined in second argument
195 Int_t ic, i, first = (Int_t)fStepListMC.GetEntries();
197 // get arrays of all charged tracks
199 a[0] = fRsnPIDIndex.GetTracksArray(AliRsnDaughter::kNoPID, '+', AliPID::kUnknown);
200 a[1] = fRsnPIDIndex.GetTracksArray(AliRsnDaughter::kNoPID, '-', AliPID::kUnknown);
202 // external loop on tracks
203 for (ic = 0; ic < 2; ic++)
205 for (i = 0; i < a[ic]->GetSize(); i++)
208 fRsnEvent.SetDaughter(fDaughter, a[ic]->At(i));
209 if (!fDaughter.IsOK()) continue;
210 fDaughter.SetRequiredPID(fDaughter.PerfectPID());
212 FillContainer(&fStepListESD, first);
217 //_____________________________________________________________________________
218 void AliRsnAnalysisTrackEffSE::FillContainer
219 (const TObjArray *stepList, Int_t firstOutStep)
222 // Fill the containers
226 Int_t iaxis, nAxes = fAxisList.GetEntries();
227 Int_t istep, nSteps = stepList->GetEntries();
229 // compute values for all axes
230 for (iaxis = 0; iaxis < nAxes; iaxis++) {
231 AliRsnFunctionAxis *fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(iaxis);
232 switch (fcnAxis->GetAxisObject())
234 case AliRsnFunctionAxis::kParticle:
235 fVar[iaxis] = (Double_t)fcnAxis->Eval(&fDaughter);
237 case AliRsnFunctionAxis::kEvent:
238 fVar[iaxis] = (Double_t)fcnAxis->Eval(&fRsnEvent);
246 for (istep = 0; istep < nSteps; istep++) {
247 AliRsnCutSet *cutSet = (AliRsnCutSet*)stepList->At(istep);
248 if (!cutSet->IsSelected(AliRsnCut::kParticle, &fDaughter)) break;
249 if (stepList == &fStepListESD && !PassedAllCutsMC()) break;
251 ipid = (Int_t)fDaughter.PerfectPID();
252 if (ipid == (Int_t)AliPID::kUnknown) ipid = (Int_t)AliPID::kSPECIES;
253 fContainer[ipid]->Fill(fVar.GetArray(), istep + firstOutStep);
254 fContainer[AliPID::kSPECIES]->Fill(fVar.GetArray(), istep + firstOutStep);
258 //_____________________________________________________________________________
259 Bool_t AliRsnAnalysisTrackEffSE::PassedAllCutsMC()
262 // Check if this daughter passes all cuts MC
265 Int_t istep, nSteps = fStepListMC.GetEntries();
267 for (istep = 0; istep < nSteps; istep++) {
268 AliRsnCutSet *cutSet = (AliRsnCutSet*)fStepListMC.At(istep);
269 if (!cutSet->IsSelected(AliRsnCut::kParticle, &fDaughter)) return kFALSE;
275 //_____________________________________________________________________________
276 void AliRsnAnalysisTrackEffSE::RsnTerminate(Option_t*)
280 // Could be added some monitor histograms here.
283 AliDebug(AliLog::kDebug+2,"<-");
284 AliDebug(AliLog::kDebug+2,"->");