]>
Commit | Line | Data |
---|---|---|
eca224a3 | 1 | // |
2 | // Class AliRsnAnalysisTrackEffSE | |
3 | // | |
4 | // TODO | |
5 | // TODO | |
6 | // | |
7 | // authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) | |
8 | // Martin Vala (martin.vala@cern.ch) | |
9 | // | |
10 | #include <Riostream.h> | |
11 | #include "AliStack.h" | |
12 | #include "AliESDEvent.h" | |
13 | #include "AliMCEvent.h" | |
14 | ||
15 | #include "AliCFContainer.h" | |
16 | #include "AliRsnCutSet.h" | |
17 | #include "AliRsnFunctionAxis.h" | |
18 | #include "AliRsnAnalysisTrackEffSE.h" | |
19 | #include "AliRsnCutSet.h" | |
20 | ||
21 | ClassImp(AliRsnAnalysisTrackEffSE) | |
22 | ||
23 | //_____________________________________________________________________________ | |
24 | AliRsnAnalysisTrackEffSE::AliRsnAnalysisTrackEffSE(const char *name) : | |
25 | AliRsnVAnalysisTaskSE(name), | |
26 | fEventCuts(0x0), | |
27 | fStepListMC(0), | |
28 | fStepListESD(0), | |
29 | fAxisList(0), | |
9c67a289 | 30 | fVar(0), |
31 | fDaughter() | |
eca224a3 | 32 | { |
33 | // | |
34 | // Default constructor. | |
35 | // | |
36 | ||
37 | AliDebug(AliLog::kDebug+2,"<-"); | |
38 | ||
39 | DefineOutput(2, TList::Class()); | |
40 | ||
41 | Int_t i; | |
42 | for (i = 0; i <= AliPID::kSPECIES; i++) fContainer[i] = 0x0; | |
43 | ||
44 | AliDebug(AliLog::kDebug+2,"->"); | |
45 | } | |
46 | ||
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), | |
9c67a289 | 54 | fVar(0), |
55 | fDaughter() | |
eca224a3 | 56 | { |
57 | // | |
58 | // Copy constrtuctor | |
59 | // | |
60 | } | |
61 | ||
62 | //_____________________________________________________________________________ | |
63 | void AliRsnAnalysisTrackEffSE::RsnUserCreateOutputObjects() | |
64 | { | |
65 | // | |
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. | |
70 | // | |
71 | ||
72 | AliDebug(AliLog::kDebug+2,"<-"); | |
73 | ||
74 | // get number of steps and axes | |
75 | Int_t iaxis; | |
76 | Int_t nAxes = fAxisList.GetEntries(); | |
77 | Int_t nSteps = (Int_t)fStepListMC.GetEntries() + (Int_t)fStepListESD.GetEntries(); | |
78 | ||
79 | if (!nSteps) { | |
80 | AliError("No steps defined"); | |
81 | return; | |
82 | } | |
83 | if (!nAxes) { | |
84 | AliError("No axes defined"); | |
85 | return; | |
86 | } | |
87 | ||
88 | // initialize variable list | |
89 | fVar.Set(nAxes); | |
90 | ||
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; | |
98 | } | |
99 | ||
100 | // initialize output list | |
101 | OpenFile(2); | |
102 | fOutList[1] = new TList(); | |
103 | fOutList[1]->SetOwner(); | |
104 | ||
105 | // create the containers | |
106 | Int_t i; | |
107 | for (i = 0; i <= AliPID::kSPECIES; i++) | |
108 | { | |
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]); | |
115 | } | |
116 | ||
117 | AliDebug(AliLog::kDebug+2,"->"); | |
118 | } | |
119 | ||
120 | //_____________________________________________________________________________ | |
121 | void AliRsnAnalysisTrackEffSE::RsnUserExec(Option_t*) | |
122 | { | |
123 | // | |
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. | |
127 | // | |
128 | ||
129 | AliDebug(AliLog::kDebug+2,"<-"); | |
130 | if (!fESDEvent || !fMCEvent) { | |
131 | AliError("This task can process only ESD + MC events"); | |
132 | return; | |
133 | } | |
134 | fRsnEvent.SetRef(fESDEvent, fMCEvent); | |
135 | ||
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 | |
140 | if (fEventCuts) { | |
141 | if (!fEventCuts->IsSelected(AliRsnCut::kEvent, &fRsnEvent)) { | |
142 | fTaskInfo.SetEventUsed(kFALSE); | |
143 | return; | |
144 | } | |
145 | } | |
146 | ||
147 | // if cuts are passed or not cuts were defined, | |
148 | // update the task info before processing the event | |
149 | fTaskInfo.SetEventUsed(kTRUE); | |
150 | ||
151 | // process first MC steps and then ESD steps | |
152 | ProcessEventMC(); | |
153 | ProcessEventESD(); | |
154 | ||
155 | // Post the data | |
156 | PostData(2, fOutList[1]); | |
157 | ||
158 | AliDebug(AliLog::kDebug+2,"->"); | |
159 | } | |
160 | ||
161 | //_____________________________________________________________________________ | |
162 | void AliRsnAnalysisTrackEffSE::ProcessEventMC() | |
163 | { | |
164 | // | |
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 | |
167 | // | |
168 | ||
169 | AliStack *stack = fMCEvent->Stack(); | |
170 | AliMCParticle *part; | |
171 | ||
172 | // other utility variables | |
173 | Int_t ipart; | |
174 | ||
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++) | |
178 | { | |
7aad0c47 | 179 | part = (AliMCParticle*) fMCEvent->GetTrack(ipart); |
eca224a3 | 180 | |
181 | fDaughter.SetRef(part); | |
182 | fDaughter.SetParticle(part->Particle()); | |
183 | fDaughter.FindMotherPDG(stack); | |
184 | ||
185 | FillContainer(&fStepListMC, 0); | |
186 | } | |
187 | } | |
188 | ||
189 | //_____________________________________________________________________________ | |
190 | void AliRsnAnalysisTrackEffSE::ProcessEventESD() | |
191 | { | |
192 | // | |
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 | |
195 | // | |
196 | ||
197 | Int_t ic, i, first = (Int_t)fStepListMC.GetEntries(); | |
198 | ||
199 | // get arrays of all charged tracks | |
200 | TArrayI *a[2]; | |
201 | a[0] = fRsnPIDIndex.GetTracksArray(AliRsnDaughter::kNoPID, '+', AliPID::kUnknown); | |
202 | a[1] = fRsnPIDIndex.GetTracksArray(AliRsnDaughter::kNoPID, '-', AliPID::kUnknown); | |
203 | ||
204 | // external loop on tracks | |
205 | for (ic = 0; ic < 2; ic++) | |
206 | { | |
207 | for (i = 0; i < a[ic]->GetSize(); i++) | |
208 | { | |
209 | // connect interface | |
210 | fRsnEvent.SetDaughter(fDaughter, a[ic]->At(i)); | |
211 | if (!fDaughter.IsOK()) continue; | |
212 | fDaughter.SetRequiredPID(fDaughter.PerfectPID()); | |
213 | ||
214 | FillContainer(&fStepListESD, first); | |
215 | } | |
216 | } | |
217 | } | |
218 | ||
219 | //_____________________________________________________________________________ | |
220 | void AliRsnAnalysisTrackEffSE::FillContainer | |
221 | (const TObjArray *stepList, Int_t firstOutStep) | |
222 | { | |
223 | // | |
224 | // Fill the containers | |
225 | // | |
226 | ||
227 | Int_t ipid; | |
228 | Int_t iaxis, nAxes = fAxisList.GetEntries(); | |
229 | Int_t istep, nSteps = stepList->GetEntries(); | |
230 | ||
231 | // compute values for all axes | |
232 | for (iaxis = 0; iaxis < nAxes; iaxis++) { | |
233 | AliRsnFunctionAxis *fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(iaxis); | |
234 | switch (fcnAxis->GetAxisObject()) | |
235 | { | |
236 | case AliRsnFunctionAxis::kParticle: | |
237 | fVar[iaxis] = (Double_t)fcnAxis->Eval(&fDaughter); | |
238 | break; | |
239 | case AliRsnFunctionAxis::kEvent: | |
240 | fVar[iaxis] = (Double_t)fcnAxis->Eval(&fRsnEvent); | |
241 | break; | |
242 | default: | |
243 | fVar[iaxis] = 0.0; | |
244 | } | |
245 | } | |
246 | ||
247 | // fill all steps | |
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; | |
252 | ||
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); | |
257 | } | |
258 | } | |
259 | ||
260 | //_____________________________________________________________________________ | |
261 | Bool_t AliRsnAnalysisTrackEffSE::PassedAllCutsMC() | |
262 | { | |
263 | // | |
264 | // Check if this daughter passes all cuts MC | |
265 | // | |
266 | ||
267 | Int_t istep, nSteps = fStepListMC.GetEntries(); | |
268 | ||
269 | for (istep = 0; istep < nSteps; istep++) { | |
270 | AliRsnCutSet *cutSet = (AliRsnCutSet*)fStepListMC.At(istep); | |
271 | if (!cutSet->IsSelected(AliRsnCut::kParticle, &fDaughter)) return kFALSE; | |
272 | } | |
273 | ||
274 | return kTRUE; | |
275 | } | |
276 | ||
277 | //_____________________________________________________________________________ | |
278 | void AliRsnAnalysisTrackEffSE::RsnTerminate(Option_t*) | |
279 | { | |
280 | // | |
281 | // Termination. | |
282 | // Could be added some monitor histograms here. | |
283 | // | |
284 | ||
285 | AliDebug(AliLog::kDebug+2,"<-"); | |
286 | AliDebug(AliLog::kDebug+2,"->"); | |
287 | } | |
288 |