]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx
Add some specific tasks for specific resonances and additional macros
[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.
5faf5a07 183//
4fbb2459 184
185 // process first MC steps and then ESD steps
186 AliRsnPairDef *pairDef = 0;
187 TObjArrayIter iter(&fPairDefList);
188 while ( (pairDef = (AliRsnPairDef*)iter.Next()) )
189 {
a378358c 190 if (fRsnEvent.IsESD()) ProcessEventESD(pairDef);
191 if (fRsnEvent.IsAOD()) ProcessEventAOD(pairDef);
4fbb2459 192 }
193
194 // Post the data
fecaa02e 195 PostData(2, fOutList);
4fbb2459 196}
197
198//_____________________________________________________________________________
a378358c 199void AliRsnAnalysisEffSE::ProcessEventESD(AliRsnPairDef *pairDef)
fecaa02e 200{
201//
202// Process current event with the definitions of the specified step in MC list
203// and store results in the container slot defined in second argument.
204// It is associated with the AliCFContainer with the name of the pair.
205//
206
a378358c 207 AliStack *stack = fRsnEvent.GetRefMCESD()->Stack();
fecaa02e 208 AliESDEvent *esd = fRsnEvent.GetRefESD();
a378358c 209 AliMCEvent *mc = fRsnEvent.GetRefMCESD();
fecaa02e 210 AliMCParticle *mother;
211
212 if (!pairDef) return;
213 AliCFContainer *cont = (AliCFContainer*)fContainerList->FindObject(pairDef->GetPairName());
214 if (!cont) return;
215
216 // get informations from pairDef
a378358c 217 Int_t pdgM = 0;
218 Int_t pdgD[2] = {0, 0};
fecaa02e 219 Short_t chargeD[2] = {0, 0};
a378358c 220 pdgM = pairDef->GetMotherPDG();
221 pdgD [0] = AliPID::ParticleCode(pairDef->GetPID(0));
222 pdgD [1] = AliPID::ParticleCode(pairDef->GetPID(1));
fecaa02e 223 chargeD[0] = pairDef->GetChargeShort(0);
224 chargeD[1] = pairDef->GetChargeShort(1);
225
226 // other utility variables
d0282f3d 227 Int_t first, j, ipart;
228 Int_t label[2] = {-1, -1};
229 Short_t charge[2] = {0, 0};
230 Short_t pairDefMatch[2] = {-1, -1};
231 Int_t esdIndex[2] = {-1, -1};
fecaa02e 232 TParticle *part[2] = {0, 0};
233
234 // in this case, we first take the resonance from MC
235 // and then we find its daughters and compute cuts on them
236 for (ipart = 0; ipart < stack->GetNprimary(); ipart++)
237 {
238 // take a track from the MC event
239 mother = (AliMCParticle*) fMCEvent->GetTrack(ipart);
240
241 // check that it is a binary decay and the PDG code matches
242 if (mother->Particle()->GetNDaughters() != 2) continue;
243 if (mother->Particle()->GetPdgCode() != pdgM) continue;
244
245 // store the labels of the two daughters
246 label[0] = mother->Particle()->GetFirstDaughter();
247 label[1] = mother->Particle()->GetLastDaughter();
248
249 // retrieve the particles and other stuff
250 // check if they match the order in the pairDef
251 for (j = 0; j < 2; j++)
252 {
253 if (label[j] < 0) continue;
254 part[j] = stack->Particle(label[j]);
c18b1218 255 pdgD[j] = TMath::Abs(part[j]->GetPdgCode());
fecaa02e 256 charge[j] = (Short_t)(part[j]->GetPDG()->Charge() / 3);
c18b1218 257 if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(0)) && charge[j] == pairDef->GetChargeShort(0))
fecaa02e 258 pairDefMatch[j] = 0;
c18b1218 259 else if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(1)) && charge[j] == pairDef->GetChargeShort(1))
fecaa02e 260 pairDefMatch[j] = 1;
261 else
262 pairDefMatch[j] = -1;
263
264 // find corresponding ESD particle: first try rejecting fakes,
265 // and in case of failure, try accepting fakes
266 esdIndex[j] = FindESDtrack(label[j], esd, kTRUE);
c18b1218 267 //TArrayI idx = FindESDtracks(label[j], esd);
268 //for (Int_t kk = 0; kk < idx.GetSize(); kk++) cout << "DAUGHTER " << j << " --> FOUND INDEX: " << idx[kk] << endl;
fecaa02e 269 if (esdIndex[j] < 0) esdIndex[j] = FindESDtrack(label[j], esd, kFALSE);
c18b1218 270 //cout << "DAUGHTER " << j << " SINGLE FOUND INDEX = " << esdIndex[j] << endl;
fecaa02e 271 }
272
273 // since each candidate good resonance is taken once, we must check
274 // that it matches the pair definition in any order, and reject in case
275 // in none of them the pair is OK
276 // anyway, we must associate the correct daughter to the correct data member
277 if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1)
278 {
279 // 1st track --> 1st member of PairDef
280 fDaughter[0].SetRef(mc->GetTrack(label[0]));
281 fDaughter[0].SetRefMC((AliMCParticle*)mc->GetTrack(label[0]));
282 fDaughter[0].SetGood();
283 // 2nd track --> 2nd member of PairDef
284 fDaughter[1].SetRef(mc->GetTrack(label[1]));
285 fDaughter[1].SetRefMC((AliMCParticle*)mc->GetTrack(label[1]));
286 fDaughter[1].SetGood();
287 }
288 else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0))
289 {
290 // 1st track --> 2nd member of PairDef
291 fDaughter[0].SetRef(mc->GetTrack(label[1]));
292 fDaughter[0].SetRefMC((AliMCParticle*)mc->GetTrack(label[1]));
293 fDaughter[0].SetGood();
294 // 2nd track --> 1st member of PairDef
295 fDaughter[1].SetRef(mc->GetTrack(label[0]));
296 fDaughter[1].SetRefMC((AliMCParticle*)mc->GetTrack(label[0]));
c18b1218 297 fDaughter[1].SetGood();
fecaa02e 298 }
299 else
300 {
301 fDaughter[0].SetBad();
302 fDaughter[1].SetBad();
303 }
304
305 // reject the pair if the matching was unsuccessful
306 if (!fDaughter[0].IsOK() || !fDaughter[1].IsOK()) continue;
307
308 // first, we set the internal AliRsnMother object to
309 // the MC particles and then operate the selections on MC
310 fPair.SetDaughters(&fDaughter[0], pairDef->GetMass(0), &fDaughter[1], pairDef->GetMass(1));
311 FillContainer(cont, &fStepListMC, pairDef, 0);
312
313 // then, if both particles found a good match in the ESD
314 // reassociate the ESD tracks to the pair and fill ESD containers
315 if (esdIndex[0] < 0 || esdIndex[1] < 0) continue;
316 if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1)
317 {
318 // 1st track --> 1st member of PairDef
319 fDaughter[0].SetRef(esd->GetTrack(esdIndex[0]));
320 // 2nd track --> 2nd member of PairDef
c18b1218 321 fDaughter[1].SetRef(esd->GetTrack(esdIndex[1]));
322 //cout << "****** MATCHING SCHEME 1" << endl;
fecaa02e 323 }
324 else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0))
325 {
326 // 1st track --> 2nd member of PairDef
327 fDaughter[0].SetRef(esd->GetTrack(esdIndex[1]));
328 // 2nd track --> 1st member of PairDef
329 fDaughter[1].SetRef(esd->GetTrack(esdIndex[0]));
c18b1218 330 //cout << "****** MATCHING SCHEME 2" << endl;
fecaa02e 331 }
c18b1218 332 //cout << "****** IDs = " << fDaughter[0].GetID() << ' ' << fDaughter[1].GetID() << endl;
fecaa02e 333 // here we must remember how many steps were already filled
334 first = (Int_t)fStepListMC.GetEntries();
335 FillContainer(cont, &fStepListESD, pairDef, first);
336 }
337}
338
339//_____________________________________________________________________________
a378358c 340void AliRsnAnalysisEffSE::ProcessEventAOD(AliRsnPairDef *pairDef)
4fbb2459 341{
342//
343// Process current event with the definitions of the specified step in MC list
a378358c 344// and store results in the container slot defined in second argument.
345// It is associated with the AliCFContainer with the name of the pair.
4fbb2459 346//
347
a378358c 348 AliAODEvent *aod = fRsnEvent.GetRefAOD();
349 AliAODMCParticle *mother;
350 TClonesArray *mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
351 if (!mcArray) return;
4fbb2459 352
353 if (!pairDef) return;
a378358c 354 AliCFContainer *cont = (AliCFContainer*)fContainerList->FindObject(pairDef->GetPairName());
4fbb2459 355 if (!cont) return;
a378358c 356
357 // get informations from pairDef
358 Int_t pdgM = 0;
359 Int_t pdgD[2] = {0, 0};
360 Short_t chargeD[2] = {0, 0};
361 pdgM = pairDef->GetMotherPDG();
362 pdgD [0] = AliPID::ParticleCode(pairDef->GetPID(0));
363 pdgD [1] = AliPID::ParticleCode(pairDef->GetPID(1));
364 chargeD[0] = pairDef->GetChargeShort(0);
365 chargeD[1] = pairDef->GetChargeShort(1);
4fbb2459 366
367 // other utility variables
a378358c 368 Int_t first, j;
369 Int_t label [2] = {-1, -1};
370 Short_t charge[2] = {0, 0};
371 Short_t pairDefMatch[2] = {-1, -1};
372 Int_t aodIndex[2] = {-1, -1};
373 AliAODMCParticle *part[2] = {0, 0};
374
375 // loop on MC particles
376 TObjArrayIter next(mcArray);
377 while ( (mother = (AliAODMCParticle*)next()) )
378 {
379 // check that it is a binary decay and the PDG code matches
380 if (mother->GetNDaughters() != 2) continue;
381 if (mother->GetPdgCode() != pdgM) continue;
4fbb2459 382
a378358c 383 // store the labels of the two daughters
384 label[0] = mother->GetDaughter(0);
385 label[1] = mother->GetDaughter(1);
386
387 // retrieve the particles and other stuff
388 // check if they match the order in the pairDef
389 for (j = 0; j < 2; j++)
fecaa02e 390 {
a378358c 391 if (label[j] < 0) continue;
392 part[j] = (AliAODMCParticle*)mcArray->At(label[j]);
393 pdgD[j] = TMath::Abs(part[j]->GetPdgCode());
394 charge[j] = (Short_t)(part[j]->Charge());
395 if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(0)) && charge[j] == pairDef->GetChargeShort(0))
396 pairDefMatch[j] = 0;
397 else if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(1)) && charge[j] == pairDef->GetChargeShort(1))
398 pairDefMatch[j] = 1;
399 else
400 pairDefMatch[j] = -1;
401
402 // find corresponding ESD particle: first try rejecting fakes,
403 // and in case of failure, try accepting fakes
404 aodIndex[j] = FindAODtrack(label[j], aod, kTRUE);
405 if (aodIndex[j] < 0) aodIndex[j] = FindAODtrack(label[j], aod, kFALSE);
4fbb2459 406 }
a378358c 407
408 // since each candidate good resonance is taken once, we must check
409 // that it matches the pair definition in any order, and reject in case
410 // in none of them the pair is OK
411 // anyway, we must associate the correct daughter to the correct data member
412 if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1)
413 {
414 // 1st track --> 1st member of PairDef
415 fDaughter[0].SetRef((AliAODMCParticle*)mcArray->At(label[0]));
416 fDaughter[0].SetRefMC((AliAODMCParticle*)mcArray->At(label[0]));
417 fDaughter[0].SetGood();
418 // 2nd track --> 2nd member of PairDef
419 fDaughter[1].SetRef((AliAODMCParticle*)mcArray->At(label[1]));
420 fDaughter[1].SetRefMC((AliAODMCParticle*)mcArray->At(label[1]));
421 fDaughter[1].SetGood();
422 }
423 else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0))
424 {
425 // 1st track --> 2nd member of PairDef
426 fDaughter[0].SetRef((AliAODMCParticle*)mcArray->At(label[1]));
427 fDaughter[0].SetRefMC((AliAODMCParticle*)mcArray->At(label[1]));
428 fDaughter[0].SetGood();
429 // 2nd track --> 1st member of PairDef
430 fDaughter[1].SetRef((AliAODMCParticle*)mcArray->At(label[0]));
431 fDaughter[1].SetRefMC((AliAODMCParticle*)mcArray->At(label[0]));
432 fDaughter[1].SetGood();
433 }
434 else
435 {
436 fDaughter[0].SetBad();
437 fDaughter[1].SetBad();
438 }
439
440 // reject the pair if the matching was unsuccessful
441 if (!fDaughter[0].IsOK() || !fDaughter[1].IsOK()) continue;
442
443 // first, we set the internal AliRsnMother object to
444 // the MC particles and then operate the selections on MC
445 fPair.SetDaughters(&fDaughter[0], pairDef->GetMass(0), &fDaughter[1], pairDef->GetMass(1));
4fbb2459 446 FillContainer(cont, &fStepListMC, pairDef, 0);
a378358c 447
448 // then, if both particles found a good match in the AOD
449 // reassociate the AOD tracks to the pair and fill AOD containers
450 if (aodIndex[0] < 0 || aodIndex[1] < 0) continue;
451 if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1)
452 {
453 // 1st track --> 1st member of PairDef
454 fDaughter[0].SetRef(aod->GetTrack(aodIndex[0]));
455 // 2nd track --> 2nd member of PairDef
456 fDaughter[1].SetRef(aod->GetTrack(aodIndex[1]));
457 //cout << "****** MATCHING SCHEME 1" << endl;
458 }
459 else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0))
460 {
461 // 1st track --> 2nd member of PairDef
462 fDaughter[0].SetRef(aod->GetTrack(aodIndex[1]));
463 // 2nd track --> 1st member of PairDef
464 fDaughter[1].SetRef(aod->GetTrack(aodIndex[0]));
465 //cout << "****** MATCHING SCHEME 2" << endl;
4fbb2459 466 }
a378358c 467 //cout << "****** IDs = " << fDaughter[0].GetID() << ' ' << fDaughter[1].GetID() << endl;
468 // here we must remember how many steps were already filled
469 first = (Int_t)fStepListMC.GetEntries();
470 FillContainer(cont, &fStepListESD, pairDef, first);
4fbb2459 471 }
472}
473
474//_____________________________________________________________________________
475void AliRsnAnalysisEffSE::FillContainer(AliCFContainer *cont, const TObjArray *stepList, AliRsnPairDef *pd, Int_t firstOutStep)
476{
477//
478// Fill the containers
479//
480
32992791 481 Int_t iaxis, nAxes = fAxisList.GetEntries();
482 Int_t istep, nSteps = stepList->GetEntries();
483 Bool_t computeOK;
c18b1218 484
485 // set daughters to pair
486 fPair.SetDaughters(&fDaughter[0], pd->GetMass(0), &fDaughter[1], pd->GetMass(1));
4fbb2459 487
488 // compute values for all axes
fecaa02e 489 for (iaxis = 0; iaxis < nAxes; iaxis++)
490 {
2dab9030 491 AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis);
fecaa02e 492 fVar[iaxis] = -1E10;
32992791 493 switch (fcnAxis->GetTargetType())
494 {
495 case AliRsnTarget::kMother:
496 fcnAxis->SetSupportObject(pd);
497 computeOK = fcnAxis->Eval(&fPair);
498 break;
499 case AliRsnTarget::kEvent:
500 computeOK = fcnAxis->Eval(&fRsnEvent);
501 break;
502 default:
503 AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", fcnAxis->GetName(), fcnAxis->GetTargetTypeName()));
504 computeOK = kFALSE;
505 }
506 if (computeOK) fVar[iaxis] = ((Float_t)fcnAxis->GetComputedValue());
4fbb2459 507 }
508
509 // fill all steps
fecaa02e 510 for (istep = 0; istep < nSteps; istep++)
511 {
2dab9030 512 AliRsnCutManager *cutMgr = (AliRsnCutManager*)stepList->At(istep);
5faf5a07 513 AliRsnTarget::SwitchToFirst();
c18b1218 514 if (!cutMgr->PassCommonDaughterCuts(&fDaughter[0])) break;
515 if (!cutMgr->PassCommonDaughterCuts(&fDaughter[1])) break;
516 if (!cutMgr->PassDaughter1Cuts(&fDaughter[0])) break;
517 if (!cutMgr->PassDaughter2Cuts(&fDaughter[1])) break;
fecaa02e 518 if (!cutMgr->PassMotherCuts(&fPair)) break;
c18b1218 519 //cout << "**************************************** FILLING STEP " << istep << endl;
4fbb2459 520 cont->Fill(fVar.GetArray(), istep + firstOutStep);
521 }
522}
523
524//_____________________________________________________________________________
525void AliRsnAnalysisEffSE::RsnTerminate(Option_t*)
526{
527//
528// Termination.
529// Could be added some monitor histograms here.
530//
531
532 AliDebug(AliLog::kDebug+2,"<-");
533 AliDebug(AliLog::kDebug+2,"->");
534}
535
536//_____________________________________________________________________________
537void AliRsnAnalysisEffSE::AddPairDef(AliRsnPairDef* pairDef)
538{
539//
540// Adds pair definition
541//
542 fPairDefList.AddLast(pairDef);
543}
2dab9030 544
fecaa02e 545//_____________________________________________________________________________
546Int_t AliRsnAnalysisEffSE::FindESDtrack(Int_t label, AliESDEvent *esd, Bool_t rejectFakes)
547{
548//
549// Finds in the ESD a track whose label corresponds to that in argument.
550// When global tracks are enabled, tries first to find a global track
551// satisfying that requirement.
552// If no global tracks are found, if ITS-SA are enable, tries to search among them
553// otherwise return a negative number.
554// If global tracks are disabled, search only among ITS SA
555//
556
c18b1218 557 Int_t i = 0;
558 Int_t ntracks = esd->GetNumberOfTracks();
559 ULong_t status;
560 Bool_t isTPC;
561 Bool_t isITSSA;
fecaa02e 562
563 // loop for global tracks
564 if (fUseGlobal)
565 {
566 for (i = 0; i < ntracks; i++)
567 {
568 AliESDtrack *track = esd->GetTrack(i);
c18b1218 569 status = (ULong_t)track->GetStatus();
570 isTPC = ((status & AliESDtrack::kTPCin) != 0);
571 if (!isTPC) continue;
fecaa02e 572
573 // check that label match
574 if (TMath::Abs(track->GetLabel()) != label) continue;
575
fecaa02e 576 // if required, reject fakes
577 if (rejectFakes && track->GetLabel() < 0) continue;
578
579 // if all checks are passed and we are searching among global
580 // this means that thie track is a global one with the right label
581 // then, the return value is set to this, and returned
582 return i;
583 }
584 }
585
586 // loop for ITS-SA tracks (this happens only if no global tracks were found
587 // or searching among globals is disabled)
588 if (fUseITSSA)
589 {
590 for (i = 0; i < ntracks; i++)
591 {
592 AliESDtrack *track = esd->GetTrack(i);
c18b1218 593 status = (ULong_t)track->GetStatus();
594 isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
595 if (!isITSSA) continue;
fecaa02e 596
597 // check that label match
598 if (TMath::Abs(track->GetLabel()) != label) continue;
c18b1218 599
fecaa02e 600 // if required, reject fakes
601 if (rejectFakes && track->GetLabel() < 0) continue;
602
603 // if all checks are passed and we are searching among global
604 // this means that thie track is a global one with the right label
605 // then, the return value is set to this, and returned
606 return i;
607 }
608 }
609
610 // if we reach this point, no match were found
611 return -1;
612}
c18b1218 613
614//_____________________________________________________________________________
615TArrayI AliRsnAnalysisEffSE::FindESDtracks(Int_t label, AliESDEvent *esd)
616{
617//
618// Finds in the ESD a track whose label corresponds to that in argument.
619// When global tracks are enabled, tries first to find a global track
620// satisfying that requirement.
621// If no global tracks are found, if ITS-SA are enable, tries to search among them
622// otherwise return a negative number.
623// If global tracks are disabled, search only among ITS SA
624//
625
626 Int_t i = 0;
627 Int_t ntracks = esd->GetNumberOfTracks();
628 ULong_t status;
629 Bool_t isTPC;
630 Bool_t isITSSA;
631 TArrayI array(100);
632 Int_t nfound = 0;
633
634 // loop for global tracks
635 if (fUseGlobal)
636 {
637 for (i = 0; i < ntracks; i++)
638 {
639 AliESDtrack *track = esd->GetTrack(i);
640 status = (ULong_t)track->GetStatus();
641 isTPC = ((status & AliESDtrack::kTPCin) != 0);
642 if (!isTPC) continue;
643
644 // check that label match
645 if (TMath::Abs(track->GetLabel()) != label) continue;
646
647 array[nfound++] = i;
648 }
649 }
650
651 // loop for ITS-SA tracks (this happens only if no global tracks were found
652 // or searching among globals is disabled)
653 if (fUseITSSA)
654 {
655 for (i = 0; i < ntracks; i++)
656 {
657 AliESDtrack *track = esd->GetTrack(i);
658 status = (ULong_t)track->GetStatus();
659 isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
660 if (!isITSSA) continue;
661
662 // check that label match
663 if (TMath::Abs(track->GetLabel()) != label) continue;
664
665 array[nfound++] = i;
666 }
667 }
668
669 array.Set(nfound);
670 return array;
671}
a378358c 672
673//_____________________________________________________________________________
674Int_t AliRsnAnalysisEffSE::FindAODtrack(Int_t label, AliAODEvent *aod, Bool_t rejectFakes)
675{
676//
677// Finds in the ESD a track whose label corresponds to that in argument.
678// When global tracks are enabled, tries first to find a global track
679// satisfying that requirement.
680// If no global tracks are found, if ITS-SA are enable, tries to search among them
681// otherwise return a negative number.
682// If global tracks are disabled, search only among ITS SA
683//
684
685 Int_t i = 0;
686 Int_t ntracks = aod->GetNumberOfTracks();
687 ULong_t status;
688 Bool_t isTPC;
689 Bool_t isITSSA;
690
691 // loop for global tracks
692 if (fUseGlobal)
693 {
694 for (i = 0; i < ntracks; i++)
695 {
696 AliAODTrack *track = aod->GetTrack(i);
697 status = (ULong_t)track->GetStatus();
698 isTPC = ((status & AliESDtrack::kTPCin) != 0);
699 if (!isTPC) continue;
700
701 // check that label match
702 if (TMath::Abs(track->GetLabel()) != label) continue;
703
704 // if required, reject fakes
705 if (rejectFakes && track->GetLabel() < 0) continue;
706
707 // if all checks are passed and we are searching among global
708 // this means that thie track is a global one with the right label
709 // then, the return value is set to this, and returned
710 return i;
711 }
712 }
713
714 // loop for ITS-SA tracks (this happens only if no global tracks were found
715 // or searching among globals is disabled)
716 if (fUseITSSA)
717 {
718 for (i = 0; i < ntracks; i++)
719 {
720 AliAODTrack *track = aod->GetTrack(i);
721 status = (ULong_t)track->GetStatus();
722 isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
723 if (!isITSSA) continue;
724
725 // check that label match
726 if (TMath::Abs(track->GetLabel()) != label) continue;
727
728 // if required, reject fakes
729 if (rejectFakes && track->GetLabel() < 0) continue;
730
731 // if all checks are passed and we are searching among global
732 // this means that thie track is a global one with the right label
733 // then, the return value is set to this, and returned
734 return i;
735 }
736 }
737
738 // if we reach this point, no match were found
739 return -1;
740}
741
742//_____________________________________________________________________________
743TArrayI AliRsnAnalysisEffSE::FindAODtracks(Int_t label, AliAODEvent *aod)
744{
745//
746// Finds in the ESD a track whose label corresponds to that in argument.
747// When global tracks are enabled, tries first to find a global track
748// satisfying that requirement.
749// If no global tracks are found, if ITS-SA are enable, tries to search among them
750// otherwise return a negative number.
751// If global tracks are disabled, search only among ITS SA
752//
753
754 Int_t i = 0;
755 Int_t ntracks = aod->GetNumberOfTracks();
756 ULong_t status;
757 Bool_t isTPC;
758 Bool_t isITSSA;
759 TArrayI array(100);
760 Int_t nfound = 0;
761
762 // loop for global tracks
763 if (fUseGlobal)
764 {
765 for (i = 0; i < ntracks; i++)
766 {
767 AliAODTrack *track = aod->GetTrack(i);
768 status = (ULong_t)track->GetStatus();
769 isTPC = ((status & AliESDtrack::kTPCin) != 0);
770 if (!isTPC) continue;
771
772 // check that label match
773 if (TMath::Abs(track->GetLabel()) != label) continue;
774
775 array[nfound++] = i;
776 }
777 }
778
779 // loop for ITS-SA tracks (this happens only if no global tracks were found
780 // or searching among globals is disabled)
781 if (fUseITSSA)
782 {
783 for (i = 0; i < ntracks; i++)
784 {
785 AliAODTrack *track = aod->GetTrack(i);
786 status = (ULong_t)track->GetStatus();
787 isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0);
788 if (!isITSSA) continue;
789
790 // check that label match
791 if (TMath::Abs(track->GetLabel()) != label) continue;
792
793 array[nfound++] = i;
794 }
795 }
796
797 array.Set(nfound);
798 return array;
799}
800
5faf5a07 801//______________________________________________________________________________
802Bool_t AliRsnAnalysisEffSE::EventProcess()
803{
804//
805// Customized event pre-processing.
806// First checks if the current event passes all cuts,
807// and if it does, updates the informations and then
808// call the operations which are already defined in the
809// omonyme function in mother class
810//
811
812 // initially, an event is expected to be bad
813 fTaskInfo.SetEventUsed(kFALSE);
814
815 // check the event cuts and update the info data accordingly
816 // events not passing the cuts must be rejected
817 if (!fEventCuts.IsSelected(&fRsnEvent))
818 {
819 fTaskInfo.SetEventUsed(kFALSE);
820 return kFALSE;
821 }
822
823 // if we reach this point, cuts were passed;
824 // then additional operations can be done
825
826 // find leading particle (without any PID/momentum restriction)
827 fRsnEvent.SelectLeadingParticle(0);
828
829 // final return value is positive
830 // but call the mother class method which updates info object
831 fTaskInfo.SetEventUsed(kTRUE);
832 return AliRsnVAnalysisTaskSE::EventProcess();
833}