]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx
Update TPCCEda to write output file in parts (to avoid too big files produced in...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisEffSE.cxx
CommitLineData
4fbb2459 1//
2// Class AliRsnAnalysisEffSE
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"
a378358c 13#include "AliAODEvent.h"
4fbb2459 14#include "AliMCEvent.h"
15
16#include "AliCFContainer.h"
2dab9030 17#include "AliRsnCutManager.h"
18#include "AliRsnValue.h"
4fbb2459 19#include "AliRsnAnalysisEffSE.h"
20#include "AliRsnPairDef.h"
21#include "AliRsnCutSet.h"
22
23ClassImp(AliRsnAnalysisEffSE)
24
25//_____________________________________________________________________________
26AliRsnAnalysisEffSE::AliRsnAnalysisEffSE(const char *name) :
27 AliRsnVAnalysisTaskSE(name),
fecaa02e 28 fUseITSSA(kTRUE),
29 fUseGlobal(kTRUE),
4fbb2459 30 fStepListMC(0),
31 fStepListESD(0),
c18b1218 32 fAxisList("AliRsnValue", 0),
4fbb2459 33 fPairDefList(0),
34 fContainerList(0x0),
fecaa02e 35 fOutList(0x0),
4fbb2459 36 fVar(0),
c18b1218 37 fPair(),
38 fEventCuts("eventCuts", AliRsnCut::kEvent)
4fbb2459 39{
40//
41// Default constructor.
42//
43
44 AliDebug(AliLog::kDebug+2,"<-");
45
46 DefineOutput(2, TList::Class());
47
48 AliDebug(AliLog::kDebug+2,"->");
49}
50
51//_____________________________________________________________________________
52AliRsnAnalysisEffSE::AliRsnAnalysisEffSE(const AliRsnAnalysisEffSE& copy) :
53 AliRsnVAnalysisTaskSE(copy),
fecaa02e 54 fUseITSSA(copy.fUseITSSA),
55 fUseGlobal(copy.fUseGlobal),
9c67a289 56 fStepListMC(copy.fStepListMC),
57 fStepListESD(copy.fStepListESD),
58 fAxisList(copy.fAxisList),
59 fPairDefList(copy.fPairDefList),
60 fContainerList(copy.fContainerList),
fecaa02e 61 fOutList(0x0),
9c67a289 62 fVar(0),
c18b1218 63 fPair(),
64 fEventCuts(copy.fEventCuts)
4fbb2459 65{
66//
67// Copy constrtuctor
68//
69}
70
c18b1218 71//_____________________________________________________________________________
72void AliRsnAnalysisEffSE::AddStepMC(AliRsnCutManager *mgr)
73{
74//
75// Add a step on montecarlo
76//
77
78 fStepListMC.AddLast(mgr);
79}
80
81//_____________________________________________________________________________
82void AliRsnAnalysisEffSE::AddStepESD(AliRsnCutManager *mgr)
83{
84//
85// Add a step on ESD
86//
87
88 fStepListESD.AddLast(mgr);
89}
90
91//_____________________________________________________________________________
92void AliRsnAnalysisEffSE::AddAxis(AliRsnValue *axis)
93{
94//
95// Add a new axis
96//
97
98 Int_t n = fAxisList.GetEntries();
99 new (fAxisList[n]) AliRsnValue(*axis);
100}
101
4fbb2459 102//_____________________________________________________________________________
103void AliRsnAnalysisEffSE::RsnUserCreateOutputObjects()
104{
105//
106// Creation of output objects.
107// These are created through the utility methods in the analysis manager,
108// which produces a list of histograms for each specified set of pairs.
109// Each of these lists is added to the main list of this task.
110//
111
112 AliDebug(AliLog::kDebug+2,"<-");
113
114 // get number of steps and axes
96e9d35d 115 Int_t iaxis = 0;
4fbb2459 116 Int_t nAxes = fAxisList.GetEntries();
117 Int_t nSteps = (Int_t)fStepListMC.GetEntries() + (Int_t)fStepListESD.GetEntries();
118
119 if (!nSteps) {
120 AliError("No steps defined");
121 return;
122 }
123 if (!nAxes) {
124 AliError("No axes defined");
125 return;
126 }
127
128 // initialize variable list
129 fVar.Set(nAxes);
130
131 // retrieve number of bins for each axis
96e9d35d 132 Int_t *nBins = new Int_t[nAxes];
b2b08ca2 133 for (iaxis = 0; iaxis < nAxes; iaxis++)
134 {
2dab9030 135 AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis);
96e9d35d 136 nBins[iaxis] = fcnAxis->GetArray().GetSize() - 1;
4fbb2459 137 }
138
139 // create ouput list of containers
140 fContainerList = new TList;
141 fContainerList->SetOwner();
142 fContainerList->SetName(Form("%s_containers", GetName()));
143
144 // initialize output list
145 OpenFile(2);
fecaa02e 146 fOutList = new TList();
147 fOutList->SetOwner();
4fbb2459 148
149 // create the containers
96e9d35d 150 Int_t i = 0, nDef = (Int_t)fPairDefList.GetEntries();
fecaa02e 151 for (i = 0; i < nDef; i++)
152 {
4fbb2459 153 AliRsnPairDef *def = (AliRsnPairDef*)fPairDefList[i];
fecaa02e 154 AliCFContainer *cont = new AliCFContainer(Form("%s", def->GetPairName()), "", nSteps, nAxes, nBins);
4fbb2459 155 // set the bin limits for each axis
96e9d35d 156 for (iaxis = 0; iaxis < nAxes; iaxis++)
157 {
158 AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis);
159 cont->SetBinLimits(iaxis, fcnAxis->GetArray().GetArray());
160 }
4fbb2459 161 // add the container to output list
162 fContainerList->Add(cont);
163 }
164
fecaa02e 165 fOutList->Add(fContainerList);
c18b1218 166 fOutList->Print();
4fbb2459 167
fecaa02e 168 PostData(2, fOutList);
96e9d35d 169
170 // clear heap
171 delete [] nBins;
2dab9030 172
4fbb2459 173 AliDebug(AliLog::kDebug+2,"->");
174}
175
176//_____________________________________________________________________________
177void AliRsnAnalysisEffSE::RsnUserExec(Option_t*)
178{
179//
180// Execution of the analysis task.
181// Recovers the input event and processes it with all included pair objects.
182// In this case, we NEED to have ESD and MC, otherwise we cannod do anything.
183//ULTIMO UNDO
184/*
185 AliRsnDaughter trk;
186 for (Int_t i = 0; i <= AliPID::kSPECIES; i++)
187 {
188 cout << AliPID::ParticleName((AliPID::EParticleType)i) << ": " << endl;
189 for (Int_t m = 0; m < AliRsnDaughter::kMethods; m++)
190 {
191 cout << "-- method: " << AliRsnDaughter::MethodName((AliRsnDaughter::EPIDMethod)m) << endl;
192 Char_t sign[2] = {'+', '-'};
193 for (Int_t s = 0; s < 2; s++)
194 {
195 TArrayI *a = fRsnPIDIndex.GetTracksArray((AliRsnDaughter::EPIDMethod)m, sign[s], (AliPID::EParticleType)i);
196 Int_t n = a->GetSize();
197 for (Int_t j = 0; j < n; j++)
198 {
199 Int_t k = a->At(j);
200 cout << "-- -- track " << Form("%4d ", k) << ": ";
201 fRsnEvent.SetDaughter(trk, k);
202 cout << "charge = " << (trk.IsPos() ? "+ " : (trk.IsNeg() ? "- " : "0 "));
203 cout << "truePID = " << Form("%10s ", AliPID::ParticleName(trk.PerfectPID()));
204 cout << "realPID = " << Form("%10s ", AliPID::ParticleName(trk.RealisticPID()));
205 cout << endl;
206 cout << "-- -- -- weights (computed): ";
207 for (Int_t q = 0; q < AliPID::kSPECIES; q++)
208 cout << Form("%15.12f", trk.ComputedWeights()[q]) << ' ';
209 cout << endl;
210 cout << "-- -- -- weights (original): ";
211 for (Int_t q = 0; q < AliPID::kSPECIES; q++)
212 cout << Form("%15.12f", trk.GetRef()->PID()[q]) << ' ';
213 cout << endl;
214 }
215 }
216 }
217 } return;
218 */
219
220 AliDebug(AliLog::kDebug+2,"<-");
a378358c 221 if (fMCOnly && fMCEvent)
222 {
223 fRsnEvent.SetRef (fMCEvent);
224 fRsnEvent.SetRefMC(fMCEvent);
225 }
226 else if (fESDEvent)
227 {
228 fRsnEvent.SetRef (fESDEvent);
229 fRsnEvent.SetRefMC(fMCEvent);
230 }
231 else if (fAODEventOut)
232 {
233 fRsnEvent.SetRef (fAODEventOut);
234 fRsnEvent.SetRefMC(fAODEventOut);
235 }
236 else if (fAODEventIn)
237 {
238 fRsnEvent.SetRef (fAODEventIn);
239 fRsnEvent.SetRefMC(fAODEventIn);
240 }
241 else {
242 AliError("NO ESD or AOD object!!! Skipping ...");
4fbb2459 243 return;
244 }
4fbb2459 245
246 // if general event cuts are added to the task (recommended)
247 // they are checked here on the RSN event interface and,
248 // if the event does not pass them, it is skipped and ProcessInfo
249 // is updated accordingly
a378358c 250 if (!fEventCuts.IsSelected(&fRsnEvent))
251 {
c18b1218 252 fTaskInfo.SetEventUsed(kFALSE);
253 return;
4fbb2459 254 }
c18b1218 255
4fbb2459 256 // if cuts are passed or not cuts were defined,
257 // update the task info before processing the event
258 fTaskInfo.SetEventUsed(kTRUE);
259
260 // process first MC steps and then ESD steps
261 AliRsnPairDef *pairDef = 0;
262 TObjArrayIter iter(&fPairDefList);
263 while ( (pairDef = (AliRsnPairDef*)iter.Next()) )
264 {
a378358c 265 if (fRsnEvent.IsESD()) ProcessEventESD(pairDef);
266 if (fRsnEvent.IsAOD()) ProcessEventAOD(pairDef);
4fbb2459 267 }
268
269 // Post the data
fecaa02e 270 PostData(2, fOutList);
4fbb2459 271
272 AliDebug(AliLog::kDebug+2,"->");
273}
274
275//_____________________________________________________________________________
a378358c 276void AliRsnAnalysisEffSE::ProcessEventESD(AliRsnPairDef *pairDef)
fecaa02e 277{
278//
279// Process current event with the definitions of the specified step in MC list
280// and store results in the container slot defined in second argument.
281// It is associated with the AliCFContainer with the name of the pair.
282//
283
a378358c 284 AliStack *stack = fRsnEvent.GetRefMCESD()->Stack();
fecaa02e 285 AliESDEvent *esd = fRsnEvent.GetRefESD();
a378358c 286 AliMCEvent *mc = fRsnEvent.GetRefMCESD();
fecaa02e 287 AliMCParticle *mother;
288
289 if (!pairDef) return;
290 AliCFContainer *cont = (AliCFContainer*)fContainerList->FindObject(pairDef->GetPairName());
291 if (!cont) return;
292
293 // get informations from pairDef
a378358c 294 Int_t pdgM = 0;
295 Int_t pdgD[2] = {0, 0};
fecaa02e 296 Short_t chargeD[2] = {0, 0};
a378358c 297 pdgM = pairDef->GetMotherPDG();
298 pdgD [0] = AliPID::ParticleCode(pairDef->GetPID(0));
299 pdgD [1] = AliPID::ParticleCode(pairDef->GetPID(1));
fecaa02e 300 chargeD[0] = pairDef->GetChargeShort(0);
301 chargeD[1] = pairDef->GetChargeShort(1);
302
303 // other utility variables
d0282f3d 304 Int_t first, j, ipart;
305 Int_t label[2] = {-1, -1};
306 Short_t charge[2] = {0, 0};
307 Short_t pairDefMatch[2] = {-1, -1};
308 Int_t esdIndex[2] = {-1, -1};
fecaa02e 309 TParticle *part[2] = {0, 0};
310
311 // in this case, we first take the resonance from MC
312 // and then we find its daughters and compute cuts on them
313 for (ipart = 0; ipart < stack->GetNprimary(); ipart++)
314 {
315 // take a track from the MC event
316 mother = (AliMCParticle*) fMCEvent->GetTrack(ipart);
317
318 // check that it is a binary decay and the PDG code matches
319 if (mother->Particle()->GetNDaughters() != 2) continue;
320 if (mother->Particle()->GetPdgCode() != pdgM) continue;
321
322 // store the labels of the two daughters
323 label[0] = mother->Particle()->GetFirstDaughter();
324 label[1] = mother->Particle()->GetLastDaughter();
325
326 // retrieve the particles and other stuff
327 // check if they match the order in the pairDef
328 for (j = 0; j < 2; j++)
329 {
330 if (label[j] < 0) continue;
331 part[j] = stack->Particle(label[j]);
c18b1218 332 pdgD[j] = TMath::Abs(part[j]->GetPdgCode());
fecaa02e 333 charge[j] = (Short_t)(part[j]->GetPDG()->Charge() / 3);
c18b1218 334 if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(0)) && charge[j] == pairDef->GetChargeShort(0))
fecaa02e 335 pairDefMatch[j] = 0;
c18b1218 336 else if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(1)) && charge[j] == pairDef->GetChargeShort(1))
fecaa02e 337 pairDefMatch[j] = 1;
338 else
339 pairDefMatch[j] = -1;
340
341 // find corresponding ESD particle: first try rejecting fakes,
342 // and in case of failure, try accepting fakes
343 esdIndex[j] = FindESDtrack(label[j], esd, kTRUE);
c18b1218 344 //TArrayI idx = FindESDtracks(label[j], esd);
345 //for (Int_t kk = 0; kk < idx.GetSize(); kk++) cout << "DAUGHTER " << j << " --> FOUND INDEX: " << idx[kk] << endl;
fecaa02e 346 if (esdIndex[j] < 0) esdIndex[j] = FindESDtrack(label[j], esd, kFALSE);
c18b1218 347 //cout << "DAUGHTER " << j << " SINGLE FOUND INDEX = " << esdIndex[j] << endl;
fecaa02e 348 }
349
350 // since each candidate good resonance is taken once, we must check
351 // that it matches the pair definition in any order, and reject in case
352 // in none of them the pair is OK
353 // anyway, we must associate the correct daughter to the correct data member
354 if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1)
355 {
356 // 1st track --> 1st member of PairDef
357 fDaughter[0].SetRef(mc->GetTrack(label[0]));
358 fDaughter[0].SetRefMC((AliMCParticle*)mc->GetTrack(label[0]));
359 fDaughter[0].SetGood();
360 // 2nd track --> 2nd member of PairDef
361 fDaughter[1].SetRef(mc->GetTrack(label[1]));
362 fDaughter[1].SetRefMC((AliMCParticle*)mc->GetTrack(label[1]));
363 fDaughter[1].SetGood();
364 }
365 else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0))
366 {
367 // 1st track --> 2nd member of PairDef
368 fDaughter[0].SetRef(mc->GetTrack(label[1]));
369 fDaughter[0].SetRefMC((AliMCParticle*)mc->GetTrack(label[1]));
370 fDaughter[0].SetGood();
371 // 2nd track --> 1st member of PairDef
372 fDaughter[1].SetRef(mc->GetTrack(label[0]));
373 fDaughter[1].SetRefMC((AliMCParticle*)mc->GetTrack(label[0]));
c18b1218 374 fDaughter[1].SetGood();
fecaa02e 375 }
376 else
377 {
378 fDaughter[0].SetBad();
379 fDaughter[1].SetBad();
380 }
381
382 // reject the pair if the matching was unsuccessful
383 if (!fDaughter[0].IsOK() || !fDaughter[1].IsOK()) continue;
384
385 // first, we set the internal AliRsnMother object to
386 // the MC particles and then operate the selections on MC
387 fPair.SetDaughters(&fDaughter[0], pairDef->GetMass(0), &fDaughter[1], pairDef->GetMass(1));
388 FillContainer(cont, &fStepListMC, pairDef, 0);
389
390 // then, if both particles found a good match in the ESD
391 // reassociate the ESD tracks to the pair and fill ESD containers
392 if (esdIndex[0] < 0 || esdIndex[1] < 0) continue;
393 if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1)
394 {
395 // 1st track --> 1st member of PairDef
396 fDaughter[0].SetRef(esd->GetTrack(esdIndex[0]));
397 // 2nd track --> 2nd member of PairDef
c18b1218 398 fDaughter[1].SetRef(esd->GetTrack(esdIndex[1]));
399 //cout << "****** MATCHING SCHEME 1" << endl;
fecaa02e 400 }
401 else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0))
402 {
403 // 1st track --> 2nd member of PairDef
404 fDaughter[0].SetRef(esd->GetTrack(esdIndex[1]));
405 // 2nd track --> 1st member of PairDef
406 fDaughter[1].SetRef(esd->GetTrack(esdIndex[0]));
c18b1218 407 //cout << "****** MATCHING SCHEME 2" << endl;
fecaa02e 408 }
c18b1218 409 //cout << "****** IDs = " << fDaughter[0].GetID() << ' ' << fDaughter[1].GetID() << endl;
fecaa02e 410 // here we must remember how many steps were already filled
411 first = (Int_t)fStepListMC.GetEntries();
412 FillContainer(cont, &fStepListESD, pairDef, first);
413 }
414}
415
416//_____________________________________________________________________________
a378358c 417void AliRsnAnalysisEffSE::ProcessEventAOD(AliRsnPairDef *pairDef)
4fbb2459 418{
419//
420// Process current event with the definitions of the specified step in MC list
a378358c 421// and store results in the container slot defined in second argument.
422// It is associated with the AliCFContainer with the name of the pair.
4fbb2459 423//
424
a378358c 425 AliAODEvent *aod = fRsnEvent.GetRefAOD();
426 AliAODMCParticle *mother;
427 TClonesArray *mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
428 if (!mcArray) return;
4fbb2459 429
430 if (!pairDef) return;
a378358c 431 AliCFContainer *cont = (AliCFContainer*)fContainerList->FindObject(pairDef->GetPairName());
4fbb2459 432 if (!cont) return;
a378358c 433
434 // get informations from pairDef
435 Int_t pdgM = 0;
436 Int_t pdgD[2] = {0, 0};
437 Short_t chargeD[2] = {0, 0};
438 pdgM = pairDef->GetMotherPDG();
439 pdgD [0] = AliPID::ParticleCode(pairDef->GetPID(0));
440 pdgD [1] = AliPID::ParticleCode(pairDef->GetPID(1));
441 chargeD[0] = pairDef->GetChargeShort(0);
442 chargeD[1] = pairDef->GetChargeShort(1);
4fbb2459 443
444 // other utility variables
a378358c 445 Int_t first, j;
446 Int_t label [2] = {-1, -1};
447 Short_t charge[2] = {0, 0};
448 Short_t pairDefMatch[2] = {-1, -1};
449 Int_t aodIndex[2] = {-1, -1};
450 AliAODMCParticle *part[2] = {0, 0};
451
452 // loop on MC particles
453 TObjArrayIter next(mcArray);
454 while ( (mother = (AliAODMCParticle*)next()) )
455 {
456 // check that it is a binary decay and the PDG code matches
457 if (mother->GetNDaughters() != 2) continue;
458 if (mother->GetPdgCode() != pdgM) continue;
4fbb2459 459
a378358c 460 // store the labels of the two daughters
461 label[0] = mother->GetDaughter(0);
462 label[1] = mother->GetDaughter(1);
463
464 // retrieve the particles and other stuff
465 // check if they match the order in the pairDef
466 for (j = 0; j < 2; j++)
fecaa02e 467 {
a378358c 468 if (label[j] < 0) continue;
469 part[j] = (AliAODMCParticle*)mcArray->At(label[j]);
470 pdgD[j] = TMath::Abs(part[j]->GetPdgCode());
471 charge[j] = (Short_t)(part[j]->Charge());
472 if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(0)) && charge[j] == pairDef->GetChargeShort(0))
473 pairDefMatch[j] = 0;
474 else if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(1)) && charge[j] == pairDef->GetChargeShort(1))
475 pairDefMatch[j] = 1;
476 else
477 pairDefMatch[j] = -1;
478
479 // find corresponding ESD particle: first try rejecting fakes,
480 // and in case of failure, try accepting fakes
481 aodIndex[j] = FindAODtrack(label[j], aod, kTRUE);
482 if (aodIndex[j] < 0) aodIndex[j] = FindAODtrack(label[j], aod, kFALSE);
4fbb2459 483 }
a378358c 484
485 // since each candidate good resonance is taken once, we must check
486 // that it matches the pair definition in any order, and reject in case
487 // in none of them the pair is OK
488 // anyway, we must associate the correct daughter to the correct data member
489 if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1)
490 {
491 // 1st track --> 1st member of PairDef
492 fDaughter[0].SetRef((AliAODMCParticle*)mcArray->At(label[0]));
493 fDaughter[0].SetRefMC((AliAODMCParticle*)mcArray->At(label[0]));
494 fDaughter[0].SetGood();
495 // 2nd track --> 2nd member of PairDef
496 fDaughter[1].SetRef((AliAODMCParticle*)mcArray->At(label[1]));
497 fDaughter[1].SetRefMC((AliAODMCParticle*)mcArray->At(label[1]));
498 fDaughter[1].SetGood();
499 }
500 else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0))
501 {
502 // 1st track --> 2nd member of PairDef
503 fDaughter[0].SetRef((AliAODMCParticle*)mcArray->At(label[1]));
504 fDaughter[0].SetRefMC((AliAODMCParticle*)mcArray->At(label[1]));
505 fDaughter[0].SetGood();
506 // 2nd track --> 1st member of PairDef
507 fDaughter[1].SetRef((AliAODMCParticle*)mcArray->At(label[0]));
508 fDaughter[1].SetRefMC((AliAODMCParticle*)mcArray->At(label[0]));
509 fDaughter[1].SetGood();
510 }
511 else
512 {
513 fDaughter[0].SetBad();
514 fDaughter[1].SetBad();
515 }
516
517 // reject the pair if the matching was unsuccessful
518 if (!fDaughter[0].IsOK() || !fDaughter[1].IsOK()) continue;
519
520 // first, we set the internal AliRsnMother object to
521 // the MC particles and then operate the selections on MC
522 fPair.SetDaughters(&fDaughter[0], pairDef->GetMass(0), &fDaughter[1], pairDef->GetMass(1));
4fbb2459 523 FillContainer(cont, &fStepListMC, pairDef, 0);
a378358c 524
525 // then, if both particles found a good match in the AOD
526 // reassociate the AOD tracks to the pair and fill AOD containers
527 if (aodIndex[0] < 0 || aodIndex[1] < 0) continue;
528 if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1)
529 {
530 // 1st track --> 1st member of PairDef
531 fDaughter[0].SetRef(aod->GetTrack(aodIndex[0]));
532 // 2nd track --> 2nd member of PairDef
533 fDaughter[1].SetRef(aod->GetTrack(aodIndex[1]));
534 //cout << "****** MATCHING SCHEME 1" << endl;
535 }
536 else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0))
537 {
538 // 1st track --> 2nd member of PairDef
539 fDaughter[0].SetRef(aod->GetTrack(aodIndex[1]));
540 // 2nd track --> 1st member of PairDef
541 fDaughter[1].SetRef(aod->GetTrack(aodIndex[0]));
542 //cout << "****** MATCHING SCHEME 2" << endl;
4fbb2459 543 }
a378358c 544 //cout << "****** IDs = " << fDaughter[0].GetID() << ' ' << fDaughter[1].GetID() << endl;
545 // here we must remember how many steps were already filled
546 first = (Int_t)fStepListMC.GetEntries();
547 FillContainer(cont, &fStepListESD, pairDef, first);
4fbb2459 548 }
549}
550
551//_____________________________________________________________________________
552void AliRsnAnalysisEffSE::FillContainer(AliCFContainer *cont, const TObjArray *stepList, AliRsnPairDef *pd, Int_t firstOutStep)
553{
554//
555// Fill the containers
556//
557
32992791 558 Int_t iaxis, nAxes = fAxisList.GetEntries();
559 Int_t istep, nSteps = stepList->GetEntries();
560 Bool_t computeOK;
c18b1218 561
562 // set daughters to pair
563 fPair.SetDaughters(&fDaughter[0], pd->GetMass(0), &fDaughter[1], pd->GetMass(1));
4fbb2459 564
565 // compute values for all axes
fecaa02e 566 for (iaxis = 0; iaxis < nAxes; iaxis++)
567 {
2dab9030 568 AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis);
fecaa02e 569 fVar[iaxis] = -1E10;
32992791 570 switch (fcnAxis->GetTargetType())
571 {
572 case AliRsnTarget::kMother:
573 fcnAxis->SetSupportObject(pd);
574 computeOK = fcnAxis->Eval(&fPair);
575 break;
576 case AliRsnTarget::kEvent:
577 computeOK = fcnAxis->Eval(&fRsnEvent);
578 break;
579 default:
580 AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", fcnAxis->GetName(), fcnAxis->GetTargetTypeName()));
581 computeOK = kFALSE;
582 }
583 if (computeOK) fVar[iaxis] = ((Float_t)fcnAxis->GetComputedValue());
4fbb2459 584 }
585
586 // fill all steps
fecaa02e 587 for (istep = 0; istep < nSteps; istep++)
588 {
2dab9030 589 AliRsnCutManager *cutMgr = (AliRsnCutManager*)stepList->At(istep);
c18b1218 590 cutMgr->SetEvent(&fRsnEvent);
591 if (!cutMgr->PassCommonDaughterCuts(&fDaughter[0])) break;
592 if (!cutMgr->PassCommonDaughterCuts(&fDaughter[1])) break;
593 if (!cutMgr->PassDaughter1Cuts(&fDaughter[0])) break;
594 if (!cutMgr->PassDaughter2Cuts(&fDaughter[1])) break;
fecaa02e 595 if (!cutMgr->PassMotherCuts(&fPair)) break;
c18b1218 596 //cout << "**************************************** FILLING STEP " << istep << endl;
4fbb2459 597 cont->Fill(fVar.GetArray(), istep + firstOutStep);
598 }
599}
600
601//_____________________________________________________________________________
602void AliRsnAnalysisEffSE::RsnTerminate(Option_t*)
603{
604//
605// Termination.
606// Could be added some monitor histograms here.
607//
608
609 AliDebug(AliLog::kDebug+2,"<-");
610 AliDebug(AliLog::kDebug+2,"->");
611}
612
613//_____________________________________________________________________________
614void AliRsnAnalysisEffSE::AddPairDef(AliRsnPairDef* pairDef)
615{
616//
617// Adds pair definition
618//
619 fPairDefList.AddLast(pairDef);
620}
2dab9030 621
fecaa02e 622//_____________________________________________________________________________
623Int_t AliRsnAnalysisEffSE::FindESDtrack(Int_t label, AliESDEvent *esd, Bool_t rejectFakes)
624{
625//
626// Finds in the ESD a track whose label corresponds to that in argument.
627// When global tracks are enabled, tries first to find a global track
628// satisfying that requirement.
629// If no global tracks are found, if ITS-SA are enable, tries to search among them
630// otherwise return a negative number.
631// If global tracks are disabled, search only among ITS SA
632//
633
c18b1218 634 Int_t i = 0;
635 Int_t ntracks = esd->GetNumberOfTracks();
636 ULong_t status;
637 Bool_t isTPC;
638 Bool_t isITSSA;
fecaa02e 639
640 // loop for global tracks
641 if (fUseGlobal)
642 {
643 for (i = 0; i < ntracks; i++)
644 {
645 AliESDtrack *track = esd->GetTrack(i);
c18b1218 646 status = (ULong_t)track->GetStatus();
647 isTPC = ((status & AliESDtrack::kTPCin) != 0);
648 if (!isTPC) continue;
fecaa02e 649
650 // check that label match
651 if (TMath::Abs(track->GetLabel()) != label) continue;
652
fecaa02e 653 // if required, reject fakes
654 if (rejectFakes && track->GetLabel() < 0) continue;
655
656 // if all checks are passed and we are searching among global
657 // this means that thie track is a global one with the right label
658 // then, the return value is set to this, and returned
659 return i;
660 }
661 }
662
663 // loop for ITS-SA tracks (this happens only if no global tracks were found
664 // or searching among globals is disabled)
665 if (fUseITSSA)
666 {
667 for (i = 0; i < ntracks; i++)
668 {
669 AliESDtrack *track = esd->GetTrack(i);
c18b1218 670 status = (ULong_t)track->GetStatus();
671 isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
672 if (!isITSSA) continue;
fecaa02e 673
674 // check that label match
675 if (TMath::Abs(track->GetLabel()) != label) continue;
c18b1218 676
fecaa02e 677 // if required, reject fakes
678 if (rejectFakes && track->GetLabel() < 0) continue;
679
680 // if all checks are passed and we are searching among global
681 // this means that thie track is a global one with the right label
682 // then, the return value is set to this, and returned
683 return i;
684 }
685 }
686
687 // if we reach this point, no match were found
688 return -1;
689}
c18b1218 690
691//_____________________________________________________________________________
692TArrayI AliRsnAnalysisEffSE::FindESDtracks(Int_t label, AliESDEvent *esd)
693{
694//
695// Finds in the ESD a track whose label corresponds to that in argument.
696// When global tracks are enabled, tries first to find a global track
697// satisfying that requirement.
698// If no global tracks are found, if ITS-SA are enable, tries to search among them
699// otherwise return a negative number.
700// If global tracks are disabled, search only among ITS SA
701//
702
703 Int_t i = 0;
704 Int_t ntracks = esd->GetNumberOfTracks();
705 ULong_t status;
706 Bool_t isTPC;
707 Bool_t isITSSA;
708 TArrayI array(100);
709 Int_t nfound = 0;
710
711 // loop for global tracks
712 if (fUseGlobal)
713 {
714 for (i = 0; i < ntracks; i++)
715 {
716 AliESDtrack *track = esd->GetTrack(i);
717 status = (ULong_t)track->GetStatus();
718 isTPC = ((status & AliESDtrack::kTPCin) != 0);
719 if (!isTPC) continue;
720
721 // check that label match
722 if (TMath::Abs(track->GetLabel()) != label) continue;
723
724 array[nfound++] = i;
725 }
726 }
727
728 // loop for ITS-SA tracks (this happens only if no global tracks were found
729 // or searching among globals is disabled)
730 if (fUseITSSA)
731 {
732 for (i = 0; i < ntracks; i++)
733 {
734 AliESDtrack *track = esd->GetTrack(i);
735 status = (ULong_t)track->GetStatus();
736 isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
737 if (!isITSSA) continue;
738
739 // check that label match
740 if (TMath::Abs(track->GetLabel()) != label) continue;
741
742 array[nfound++] = i;
743 }
744 }
745
746 array.Set(nfound);
747 return array;
748}
a378358c 749
750//_____________________________________________________________________________
751Int_t AliRsnAnalysisEffSE::FindAODtrack(Int_t label, AliAODEvent *aod, Bool_t rejectFakes)
752{
753//
754// Finds in the ESD a track whose label corresponds to that in argument.
755// When global tracks are enabled, tries first to find a global track
756// satisfying that requirement.
757// If no global tracks are found, if ITS-SA are enable, tries to search among them
758// otherwise return a negative number.
759// If global tracks are disabled, search only among ITS SA
760//
761
762 Int_t i = 0;
763 Int_t ntracks = aod->GetNumberOfTracks();
764 ULong_t status;
765 Bool_t isTPC;
766 Bool_t isITSSA;
767
768 // loop for global tracks
769 if (fUseGlobal)
770 {
771 for (i = 0; i < ntracks; i++)
772 {
773 AliAODTrack *track = aod->GetTrack(i);
774 status = (ULong_t)track->GetStatus();
775 isTPC = ((status & AliESDtrack::kTPCin) != 0);
776 if (!isTPC) continue;
777
778 // check that label match
779 if (TMath::Abs(track->GetLabel()) != label) continue;
780
781 // if required, reject fakes
782 if (rejectFakes && track->GetLabel() < 0) continue;
783
784 // if all checks are passed and we are searching among global
785 // this means that thie track is a global one with the right label
786 // then, the return value is set to this, and returned
787 return i;
788 }
789 }
790
791 // loop for ITS-SA tracks (this happens only if no global tracks were found
792 // or searching among globals is disabled)
793 if (fUseITSSA)
794 {
795 for (i = 0; i < ntracks; i++)
796 {
797 AliAODTrack *track = aod->GetTrack(i);
798 status = (ULong_t)track->GetStatus();
799 isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
800 if (!isITSSA) continue;
801
802 // check that label match
803 if (TMath::Abs(track->GetLabel()) != label) continue;
804
805 // if required, reject fakes
806 if (rejectFakes && track->GetLabel() < 0) continue;
807
808 // if all checks are passed and we are searching among global
809 // this means that thie track is a global one with the right label
810 // then, the return value is set to this, and returned
811 return i;
812 }
813 }
814
815 // if we reach this point, no match were found
816 return -1;
817}
818
819//_____________________________________________________________________________
820TArrayI AliRsnAnalysisEffSE::FindAODtracks(Int_t label, AliAODEvent *aod)
821{
822//
823// Finds in the ESD a track whose label corresponds to that in argument.
824// When global tracks are enabled, tries first to find a global track
825// satisfying that requirement.
826// If no global tracks are found, if ITS-SA are enable, tries to search among them
827// otherwise return a negative number.
828// If global tracks are disabled, search only among ITS SA
829//
830
831 Int_t i = 0;
832 Int_t ntracks = aod->GetNumberOfTracks();
833 ULong_t status;
834 Bool_t isTPC;
835 Bool_t isITSSA;
836 TArrayI array(100);
837 Int_t nfound = 0;
838
839 // loop for global tracks
840 if (fUseGlobal)
841 {
842 for (i = 0; i < ntracks; i++)
843 {
844 AliAODTrack *track = aod->GetTrack(i);
845 status = (ULong_t)track->GetStatus();
846 isTPC = ((status & AliESDtrack::kTPCin) != 0);
847 if (!isTPC) continue;
848
849 // check that label match
850 if (TMath::Abs(track->GetLabel()) != label) continue;
851
852 array[nfound++] = i;
853 }
854 }
855
856 // loop for ITS-SA tracks (this happens only if no global tracks were found
857 // or searching among globals is disabled)
858 if (fUseITSSA)
859 {
860 for (i = 0; i < ntracks; i++)
861 {
862 AliAODTrack *track = aod->GetTrack(i);
863 status = (ULong_t)track->GetStatus();
864 isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
865 if (!isITSSA) continue;
866
867 // check that label match
868 if (TMath::Abs(track->GetLabel()) != label) continue;
869
870 array[nfound++] = i;
871 }
872 }
873
874 array.Set(nfound);
875 return array;
876}
877