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