@@ -130,18 +130,7 @@ class MCSignal : public TNamed
130130template <typename U, typename T>
131131bool MCSignal::CheckProng (int i, bool checkSources, const U& mcStack, const T& track)
132132{
133- // // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end
134- // if (fProngs[i].fCheckGenerationsInTime) {
135- // std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end());
136- // std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end());
137- // std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end());
138- // std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end());
139- // std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end());
140- // std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end());
141- // }
142-
143133 auto currentMCParticle = track;
144-
145134 // loop over the generations specified for this prong
146135 for (int j = 0 ; j < fProngs [i].fNGenerations ; j++) {
147136 // check the PDG code
@@ -162,69 +151,43 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
162151 // if checking back in time: look for mother
163152 // else (checking in time): look for daughter
164153 if (!fProngs [i].fCheckGenerationsInTime ) {
165- // if (currentMCParticle.has_mothers() > 0) {
166- // printf("CheckGenInTime = %i \n", fProngs[i].fCheckGenerationsInTime);
167- // printf("currentPart pdg = %i \n", currentMCParticle.pdgCode());
168- // printf("fProng.NGenerations = %i \n", fProngs[i].fNGenerations);
169- // for (int k = 0; k < fProngs[i].fNGenerations; k++) {
170- // printf("fProng.pdg(kGen=%i) = %i \n", k, fProngs[i].fPDGcodes[k]);
171- // }
172- // printf("currentParticle.hasMothers = %i \n", currentMCParticle.has_mothers());
173-
174- // make sure that a mother exists in the stack before moving one generation further in history
175- if (!currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
176- return false ;
177- }
178- if (currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
179- /* for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
180- LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
181- }*/
182- currentMCParticle = currentMCParticle.template mothers_first_as <U>();
183- // printf("changed to mother particle pdg = %i \n", currentMCParticle.pdgCode());
184- // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
185- // currentMCParticle = currentMCParticle.template mother0_as<U>();
154+ // make sure that a mother exists in the stack before moving one generation further in history
155+ if (!currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
156+ return false ;
157+ }
158+ /* for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
159+ LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
160+ }*/
161+ // currentMCParticle = currentMCParticle.template mothers_first_as<U>();
162+ if (currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
163+ const auto & mothersSlice = currentMCParticle.template mothers_as <U>();
164+ for (auto & mother : mothersSlice) {
165+ currentMCParticle = mother;
186166 }
187- // }
167+ // printf("changed to mother particle pdg = %i \n", currentMCParticle.pdgCode());
168+ // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
169+ // currentMCParticle = currentMCParticle.template mother0_as<U>();
170+ }
188171 } else {
189- // if (currentMCParticle.has_daughters() > 0) {
190- // printf("CheckGenInTime = %i \n", fProngs[i].fCheckGenerationsInTime);
191- // printf("currentPart pdg = %i \n", currentMCParticle.pdgCode());
192- // printf("fProng.NGenerations = %i \n", fProngs[i].fNGenerations);
193- // for (int k = 0; k < fProngs[i].fNGenerations; k++) {
194- // printf("fProng.pdg(kGen=%i) = %i \n", k, fProngs[i].fPDGcodes[k]);
195- // }
196- // printf("currentParticle.hasDaugthers = %i \n", currentMCParticle.has_daughters());
197- // make sure that a daughter exists in the stack before moving one generation younger
198- if (!currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
199- return false ;
200- }
201- if (currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
202- auto daughtersSlice = currentMCParticle.template daughters_as <U>();
203- // printf("DaughtersSlice.size = %i \n", daughtersSlice.size());
204- for (auto d : daughtersSlice) {
205- // printf("daughterPart pdg = %i \n", d.pdgCode());
172+ // make sure that a daughter exists in the stack before moving one generation younger
173+ if (!currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
174+ return false ;
175+ }
176+ if (currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
177+ const auto & daughtersSlice = currentMCParticle.template daughters_as <U>();
178+ for (auto & d : daughtersSlice) {
179+ if (abs (d.pdgCode ()) == fProngs [i].fPDGcodes [j + 1 ]) {
206180 currentMCParticle = d;
207- // printf("changed currentPart pdg = %i \n", currentMCParticle.pdgCode()) ;
181+ break ;
208182 }
209- // currentMCParticle = mcStack.iteratorAt(currentMCParticle.daughtersIds()[0]);
210183 }
211- // printf(" -------------- \n");
212- // }
184+ }
213185 }
214186 }
215187
216188 if (checkSources) {
217189 currentMCParticle = track;
218190 for (int j = 0 ; j < fProngs [i].fNGenerations ; j++) {
219- // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end
220- // if (fProngs[i].fCheckGenerationsInTime) {
221- // std::reverse(fProngs[i].fPDGcodes.begin(), fProngs[i].fPDGcodes.end());
222- // std::reverse(fProngs[i].fCheckBothCharges.begin(), fProngs[i].fCheckBothCharges.end());
223- // std::reverse(fProngs[i].fExcludePDG.begin(), fProngs[i].fExcludePDG.end());
224- // std::reverse(fProngs[i].fSourceBits.begin(), fProngs[i].fSourceBits.end());
225- // std::reverse(fProngs[i].fExcludeSource.begin(), fProngs[i].fExcludeSource.end());
226- // std::reverse(fProngs[i].fUseANDonSourceBitMap.begin(), fProngs[i].fUseANDonSourceBitMap.end());
227- // }
228191 if (!fProngs [i].fSourceBits [j]) {
229192 // no sources required for this generation
230193 continue ;
@@ -294,6 +257,15 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
294257 // currentMCParticle = currentMCParticle.template mothers_first_as<U>();
295258 // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
296259 }
260+ if (currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
261+ const auto & daughtersSlice = currentMCParticle.template daughters_as <U>();
262+ for (auto & d : daughtersSlice) {
263+ if (abs (d.pdgCode ()) == fProngs [i].fPDGcodes [j + 1 ]) {
264+ currentMCParticle = d;
265+ break ;
266+ }
267+ }
268+ }
297269 }
298270 }
299271 }
0 commit comments