]>
Commit | Line | Data |
---|---|---|
c865cb1d | 1 | // |
2 | // Class AliRsnLoopEffDaughter | |
3 | // | |
4 | // Inherits from basic AliRsnLoopEff for efficiency, | |
5 | // and computed efficiencies for single-tracks | |
b63357a0 | 6 | // using cut set definitions. |
c865cb1d | 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 | //_____________________________________________________________________________ | |
547e2d97 | 32 | AliRsnLoopEffDaughter::AliRsnLoopEffDaughter(const AliRsnLoopEffDaughter ©) : |
c865cb1d | 33 | AliRsnLoopEff(copy), |
34 | fDef(copy.fDef) | |
35 | { | |
36 | // | |
37 | // Copy constrtuctor. | |
38 | // | |
39 | } | |
40 | ||
41 | //_____________________________________________________________________________ | |
547e2d97 | 42 | AliRsnLoopEffDaughter &AliRsnLoopEffDaughter::operator=(const AliRsnLoopEffDaughter ©) |
c865cb1d | 43 | { |
44 | // | |
45 | // Assignment operator. | |
46 | // Owned data members are meaningless for this operator. | |
47 | // | |
48 | ||
49 | AliRsnLoopEff::operator=(copy); | |
e6f3a909 | 50 | if (this == ©) |
547e2d97 | 51 | return *this; |
c865cb1d | 52 | fDef = copy.fDef; |
547e2d97 | 53 | |
c865cb1d | 54 | return (*this); |
55 | } | |
56 | ||
57 | //_____________________________________________________________________________ | |
58 | Bool_t AliRsnLoopEffDaughter::OkStepMC(TObject *target, Int_t istep) | |
59 | { | |
60 | // | |
61 | // Check step with MC | |
62 | // | |
63 | ||
547e2d97 | 64 | AliRsnCutSet *cuts = (AliRsnCutSet *)fStepsMC[istep]; |
c865cb1d | 65 | return cuts->IsSelected(target); |
66 | } | |
67 | ||
68 | //_____________________________________________________________________________ | |
69 | Bool_t AliRsnLoopEffDaughter::OkStepRec(TObject *target, Int_t istep) | |
70 | { | |
71 | // | |
72 | // Check step with MC | |
73 | // | |
74 | ||
547e2d97 | 75 | AliRsnCutSet *cuts = (AliRsnCutSet *)fStepsRec[istep]; |
c865cb1d | 76 | return cuts->IsSelected(target); |
77 | } | |
78 | ||
79 | //_____________________________________________________________________________ | |
80 | Int_t AliRsnLoopEffDaughter::ProcessEventESD(AliRsnEvent *rsn) | |
81 | { | |
82 | // | |
83 | // Process current event with the definitions of the specified step in MC list | |
84 | // and store results in the container slot defined in second argument. | |
85 | // It is associated with the AliCFContainer with the name of the pair. | |
86 | // | |
87 | ||
88 | AliESDEvent *esd = rsn->GetRefESD(); | |
89 | AliMCEvent *mc = rsn->GetRefMCESD(); | |
90 | TArrayI indexes; | |
91 | Int_t imax, istep, icheck, itrack, ipart; | |
92 | Int_t nsteps = NSteps(); | |
93 | ||
94 | static AliRsnDaughter daughter; | |
95 | daughter.SetOwnerEvent(rsn); | |
96 | ||
97 | // loop on the MC list of particles | |
98 | for (ipart = 0; ipart < stack->GetNprimary(); ipart++) { | |
99 | ||
100 | // MC particle | |
547e2d97 | 101 | daughter.SetRefMC((AliMCParticle *)mc->GetTrack(ipart)); |
c865cb1d | 102 | |
103 | // search for reconstructed track | |
104 | // if no tracks are found with that label, rec ref is set to zero | |
105 | // if more than one tracks are found we use the one which passes | |
106 | // most cut steps | |
107 | indexes = FindTracks(ipart, esd); | |
108 | if (indexes.GetSize() < 1) | |
109 | daughter.SetRef(0x0); | |
110 | else if (indexes.GetSize() == 1) | |
111 | daughter.SetRef(esd->GetTrack(indexes[0])); | |
112 | else { | |
113 | imax = istep = itrack = 0; | |
114 | for (icheck = 0; icheck < indexes.GetSize(); icheck++) { | |
115 | daughter.SetRef(esd->GetTrack(indexes[icheck])); | |
116 | daughter.SetMass(def->GetMass()); | |
117 | istep = NGoodSteps(&daughter); | |
118 | if (istep > imax) itrack = icheck; | |
119 | } | |
120 | daughter.SetRef(esd->GetTrack(indexes[itrack])); | |
121 | } | |
122 | ||
123 | // compute 4-momenta | |
124 | daughter.SetMass(def->GetMass()); | |
125 | ||
126 | // fill MC container | |
127 | for (istep = 0; istep < nsteps; istep++) { | |
128 | if (!OkStep(&daughter, istep)) break; | |
129 | GetOutput()->Fill(&daughter, istep); | |
130 | } | |
131 | } | |
132 | } | |
133 | ||
134 | //_____________________________________________________________________________ | |
135 | Int_t AliRsnLoopEffDaughter::ProcessEventAOD(AliRsnEvent *rsn) | |
136 | { | |
137 | // | |
138 | // Process current event with the definitions of the specified step in MC list | |
139 | // and store results in the container slot defined in second argument. | |
140 | // It is associated with the AliCFContainer with the name of the pair. | |
141 | // | |
142 | ||
143 | AliAODEvent *aod = fRsnEvent[0].GetRefAOD(); | |
547e2d97 | 144 | TClonesArray *mcArray = (TClonesArray *)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()); |
c865cb1d | 145 | if (!mcArray) return; |
146 | TArrayI indexes; | |
147 | Int_t imax, istep, icheck, itrack, ipart; | |
148 | ||
149 | static AliRsnDaughter daughter; | |
150 | daughter->SetOwnerEvent(rsn); | |
151 | ||
152 | // loop on the MC list of particles | |
153 | TObjArrayIter next(mcArray); | |
154 | AliAODMCParticle *particle; | |
547e2d97 | 155 | while ((particle = (AliAODMCParticle *)next())) { |
c865cb1d | 156 | |
157 | // MC particle | |
158 | daughter.SetRefMC(particle); | |
159 | ||
160 | // search for reconstructed track | |
161 | // if no tracks are found with that label, rec ref is set to zero | |
162 | // if more than one tracks are found we use the one which passes | |
163 | // most cut steps | |
164 | ipart = particle->GetLabel(); | |
165 | indexes = FindTracks(ipart, aod); | |
166 | if (indexes.GetSize() < 1) | |
167 | daughter.SetRef(0x0); | |
168 | else if (indexes.GetSize() == 1) | |
169 | daughter.SetRef(aod->GetTrack(indexes[0])); | |
170 | else { | |
171 | imax = istep = itrack = 0; | |
172 | for (icheck = 0; icheck < indexes.GetSize(); icheck++) { | |
173 | daughter.SetRef(aod->GetTrack(indexes[icheck])); | |
174 | daughter.SetMass(def->GetMass()); | |
175 | istep = NGoodSteps(); | |
176 | if (istep > imax) { | |
177 | itrack = icheck; | |
178 | imax = istep; | |
179 | } | |
180 | } | |
181 | daughter.SetRef(aod->GetTrack(indexes[itrack])); | |
182 | } | |
183 | ||
184 | // compute 4-momenta | |
185 | daughter.SetMass(def->GetMass()); | |
186 | ||
187 | // fill MC container | |
188 | for (istep = 0; istep < nsteps; istep++) { | |
189 | if (!OkStep(&daughter, istep)) break; | |
190 | GetOutput()->Fill(&daughter, istep); | |
191 | } | |
192 | } | |
193 | } |