@@ -130,18 +130,20 @@ 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+
133143 auto currentMCParticle = track;
144+
134145 // loop over the generations specified for this prong
135146 for (int j = 0 ; j < fProngs [i].fNGenerations ; j++) {
136- // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end
137- if (fProngs [i].fCheckGenerationsInTime ) {
138- std::reverse (fProngs [i].fPDGcodes .begin (), fProngs [i].fPDGcodes .end ());
139- std::reverse (fProngs [i].fCheckBothCharges .begin (), fProngs [i].fCheckBothCharges .end ());
140- std::reverse (fProngs [i].fExcludePDG .begin (), fProngs [i].fExcludePDG .end ());
141- std::reverse (fProngs [i].fSourceBits .begin (), fProngs [i].fSourceBits .end ());
142- std::reverse (fProngs [i].fExcludeSource .begin (), fProngs [i].fExcludeSource .end ());
143- std::reverse (fProngs [i].fUseANDonSourceBitMap .begin (), fProngs [i].fUseANDonSourceBitMap .end ());
144- }
145147 // check the PDG code
146148 if (!fProngs [i].TestPDG (j, currentMCParticle.pdgCode ())) {
147149 return false ;
@@ -160,42 +162,69 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
160162 // if checking back in time: look for mother
161163 // else (checking in time): look for daughter
162164 if (!fProngs [i].fCheckGenerationsInTime ) {
163- // make sure that a mother exists in the stack before moving one generation further in history
164- if (!currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
165- return false ;
166- }
167- if (currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
168- /* for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
169- LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
170- }*/
171- currentMCParticle = currentMCParticle.template mothers_first_as <U>();
172- // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
173- // currentMCParticle = currentMCParticle.template mother0_as<U>();
174- }
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>();
186+ }
187+ // }
175188 } else {
176- // make sure that a daughter exists in the stack before moving one generation younger
177- if (!currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
178- return false ;
179- }
180- if (currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
181- currentMCParticle = currentMCParticle.template mothers_first_as <U>();
182- // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
183- }
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());
206+ currentMCParticle = d;
207+ // printf("changed currentPart pdg = %i \n", currentMCParticle.pdgCode());
208+ }
209+ // currentMCParticle = mcStack.iteratorAt(currentMCParticle.daughtersIds()[0]);
210+ }
211+ // printf(" -------------- \n");
212+ // }
184213 }
185214 }
186215
187216 if (checkSources) {
188217 currentMCParticle = track;
189218 for (int j = 0 ; j < fProngs [i].fNGenerations ; j++) {
190219 // if generations are checked in time (grandmother->mother->daughter) reverse order of MCProng variables to start at the end
191- if (fProngs [i].fCheckGenerationsInTime ) {
192- std::reverse (fProngs [i].fPDGcodes .begin (), fProngs [i].fPDGcodes .end ());
193- std::reverse (fProngs [i].fCheckBothCharges .begin (), fProngs [i].fCheckBothCharges .end ());
194- std::reverse (fProngs [i].fExcludePDG .begin (), fProngs [i].fExcludePDG .end ());
195- std::reverse (fProngs [i].fSourceBits .begin (), fProngs [i].fSourceBits .end ());
196- std::reverse (fProngs [i].fExcludeSource .begin (), fProngs [i].fExcludeSource .end ());
197- std::reverse (fProngs [i].fUseANDonSourceBitMap .begin (), fProngs [i].fUseANDonSourceBitMap .end ());
198- }
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+ // }
199228 if (!fProngs [i].fSourceBits [j]) {
200229 // no sources required for this generation
201230 continue ;
@@ -262,7 +291,7 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
262291 return false ;
263292 }
264293 if (currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
265- currentMCParticle = currentMCParticle.template mothers_first_as <U>();
294+ // currentMCParticle = currentMCParticle.template mothers_first_as<U>();
266295 // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
267296 }
268297 }
0 commit comments