]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnLoopEffDaughter.cxx
Implementation of all needed changes in the package in order to speed-up the executio...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnLoopEffDaughter.cxx
1 //
2 // Class AliRsnLoopEffDaughter
3 //
4 // Inherits from basic AliRsnLoopEff for efficiency,
5 // and computed efficiencies for single-tracks
6 //
7 // author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
8 //
9
10 #include "AliStack.h"
11
12 #include "AliRsnDaughterDef.h"
13 #include "AliRsnCutSet.h"
14
15 #include "AliRsnLoopEffDaughter.h"
16
17 ClassImp(AliRsnLoopEffDaughter)
18
19 //_____________________________________________________________________________
20 AliRsnLoopEffDaughter::AliRsnLoopEffDaughter(const char *name, AliRsnDaughterDef *def) :
21    AliRsnLoopEff(name),
22    fDef(def)
23 {
24 //
25 // Default constructor.
26 // Do not repeat 'DefineOutput' since it is done in base class and we don't add new ones.
27 //
28 }
29
30 //_____________________________________________________________________________
31 AliRsnLoopEffDaughter::AliRsnLoopEffDaughter(const AliRsnLoopEffDaughter& copy) :
32    AliRsnLoopEff(copy),
33    fDef(copy.fDef)
34 {
35 //
36 // Copy constrtuctor.
37 //
38 }
39
40 //_____________________________________________________________________________
41 AliRsnLoopEffDaughter& AliRsnLoopEffDaughter::operator=(const AliRsnLoopEffDaughter& copy)
42 {
43 //
44 // Assignment operator.
45 // Owned data members are meaningless for this operator.
46 //
47
48    AliRsnLoopEff::operator=(copy);
49    fDef = copy.fDef;
50
51    return (*this);
52 }
53
54 //_____________________________________________________________________________
55 Bool_t AliRsnLoopEffDaughter::OkStepMC(TObject *target, Int_t istep)
56 {
57 //
58 // Check step with MC
59 //
60
61    AliRsnCutSet *cuts = (AliRsnCutSet*)fStepsMC[istep];
62    return cuts->IsSelected(target);
63 }
64
65 //_____________________________________________________________________________
66 Bool_t AliRsnLoopEffDaughter::OkStepRec(TObject *target, Int_t istep)
67 {
68 //
69 // Check step with MC
70 //
71
72    AliRsnCutSet *cuts = (AliRsnCutSet*)fStepsRec[istep];
73    return cuts->IsSelected(target);
74 }
75
76 //_____________________________________________________________________________
77 Int_t AliRsnLoopEffDaughter::ProcessEventESD(AliRsnEvent *rsn)
78 {
79 //
80 // Process current event with the definitions of the specified step in MC list
81 // and store results in the container slot defined in second argument.
82 // It is associated with the AliCFContainer with the name of the pair.
83 //
84
85    AliESDEvent *esd   = rsn->GetRefESD();
86    AliMCEvent  *mc    = rsn->GetRefMCESD();
87    TArrayI      indexes;
88    Int_t        imax, istep, icheck, itrack, ipart;
89    Int_t        nsteps = NSteps();
90
91    static AliRsnDaughter daughter;
92    daughter.SetOwnerEvent(rsn);
93
94    // loop on the MC list of particles
95    for (ipart = 0; ipart < stack->GetNprimary(); ipart++) {
96
97       // MC particle
98       daughter.SetRefMC((AliMCParticle*)mc->GetTrack(ipart));
99
100       // search for reconstructed track
101       // if no tracks are found with that label, rec ref is set to zero
102       // if more than one tracks are found we use the one which passes
103       // most cut steps
104       indexes = FindTracks(ipart, esd);
105       if (indexes.GetSize() < 1)
106          daughter.SetRef(0x0);
107       else if (indexes.GetSize() == 1)
108          daughter.SetRef(esd->GetTrack(indexes[0]));
109       else {
110          imax = istep = itrack = 0;
111          for (icheck = 0; icheck < indexes.GetSize(); icheck++) {
112             daughter.SetRef(esd->GetTrack(indexes[icheck]));
113             daughter.SetMass(def->GetMass());
114             istep = NGoodSteps(&daughter);
115             if (istep > imax) itrack = icheck;
116          }
117          daughter.SetRef(esd->GetTrack(indexes[itrack]));
118       }
119
120       // compute 4-momenta
121       daughter.SetMass(def->GetMass());
122
123       // fill MC container
124       for (istep = 0; istep < nsteps; istep++) {
125          if (!OkStep(&daughter, istep)) break;
126          GetOutput()->Fill(&daughter, istep);
127       }
128    }
129 }
130
131 //_____________________________________________________________________________
132 Int_t AliRsnLoopEffDaughter::ProcessEventAOD(AliRsnEvent *rsn)
133 {
134 //
135 // Process current event with the definitions of the specified step in MC list
136 // and store results in the container slot defined in second argument.
137 // It is associated with the AliCFContainer with the name of the pair.
138 //
139
140    AliAODEvent  *aod     = fRsnEvent[0].GetRefAOD();
141    TClonesArray *mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
142    if (!mcArray) return;
143    TArrayI       indexes;
144    Int_t         imax, istep, icheck, itrack, ipart;
145
146    static AliRsnDaughter daughter;
147    daughter->SetOwnerEvent(rsn);
148
149    // loop on the MC list of particles
150    TObjArrayIter next(mcArray);
151    AliAODMCParticle *particle;
152    while ((particle = (AliAODMCParticle*)next())) {
153
154       // MC particle
155       daughter.SetRefMC(particle);
156
157       // search for reconstructed track
158       // if no tracks are found with that label, rec ref is set to zero
159       // if more than one tracks are found we use the one which passes
160       // most cut steps
161       ipart = particle->GetLabel();
162       indexes = FindTracks(ipart, aod);
163       if (indexes.GetSize() < 1)
164          daughter.SetRef(0x0);
165       else if (indexes.GetSize() == 1)
166          daughter.SetRef(aod->GetTrack(indexes[0]));
167       else {
168          imax = istep = itrack = 0;
169          for (icheck = 0; icheck < indexes.GetSize(); icheck++) {
170             daughter.SetRef(aod->GetTrack(indexes[icheck]));
171             daughter.SetMass(def->GetMass());
172             istep = NGoodSteps();
173             if (istep > imax) {
174                itrack = icheck;
175                imax = istep;
176             }
177          }
178          daughter.SetRef(aod->GetTrack(indexes[itrack]));
179       }
180
181       // compute 4-momenta
182       daughter.SetMass(def->GetMass());
183
184       // fill MC container
185       for (istep = 0; istep < nsteps; istep++) {
186          if (!OkStep(&daughter, istep)) break;
187          GetOutput()->Fill(&daughter, istep);
188       }
189    }
190 }