@@ -133,6 +133,15 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
133133 auto currentMCParticle = track;
134134 // loop over the generations specified for this prong
135135 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+ }
136145 // check the PDG code
137146 if (!fProngs [i].TestPDG (j, currentMCParticle.pdgCode ())) {
138147 return false ;
@@ -147,23 +156,46 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
147156 }
148157 }
149158 }
150- // make sure that a mother exists in the stack before moving one generation further in history
151- if (!currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
152- return false ;
153- }
154- if (currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
155- /* for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
156- LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
157- }*/
158- currentMCParticle = currentMCParticle.template mothers_first_as <U>();
159- // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
160- // currentMCParticle = currentMCParticle.template mother0_as<U>();
159+
160+ // if checking back in time: look for mother
161+ // else (checking in time): look for daughter
162+ 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+ }
175+ } 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+ }
161184 }
162185 }
163186
164187 if (checkSources) {
165188 currentMCParticle = track;
166189 for (int j = 0 ; j < fProngs [i].fNGenerations ; j++) {
190+ // 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+ }
167199 if (!fProngs [i].fSourceBits [j]) {
168200 // no sources required for this generation
169201 continue ;
@@ -202,23 +234,38 @@ bool MCSignal::CheckProng(int i, bool checkSources, const U& mcStack, const T& t
202234 if (fProngs [i].fUseANDonSourceBitMap [j] && (sourcesDecision != fProngs [i].fSourceBits [j])) {
203235 return false ;
204236 }
205- // move one generation back in history
206- // make sure that a mother exists in the stack before moving one generation further in history
207- if (!currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
208- return false ;
209- }
210- if (currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
211- /* for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
212- LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
237+
238+ // if checking back in time: look for mother
239+ // else (checking in time): look for daughter
240+ if (!fProngs [i].fCheckGenerationsInTime ) {
241+ // move one generation back in history
242+ // make sure that a mother exists in the stack before moving one generation further in history
243+ if (!currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
244+ return false ;
245+ }
246+ if (currentMCParticle.has_mothers () && j < fProngs [i].fNGenerations - 1 ) {
247+ /* for (auto& m : mcParticle.mothers_as<aod::McParticles_001>()) {
248+ LOGF(debug, "M2 %d %d", mcParticle.globalIndex(), m.globalIndex());
249+ }*/
250+ currentMCParticle = currentMCParticle.template mothers_first_as <U>();
251+ // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
252+ // currentMCParticle = currentMCParticle.template mother0_as<U>();
253+ }
254+ /* if (j < fProngs[i].fNGenerations - 1) {
255+ currentMCParticle = mcStack.iteratorAt(currentMCParticle.mother0Id());
256+ //currentMCParticle = currentMCParticle.template mother0_as<U>();
213257 }*/
214- currentMCParticle = currentMCParticle.template mothers_first_as <U>();
215- // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
216- // currentMCParticle = currentMCParticle.template mother0_as<U>();
258+ } else {
259+ // move one generation further in history
260+ // make sure that a daughter exists in the stack before moving one generation younger
261+ if (!currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
262+ return false ;
263+ }
264+ if (currentMCParticle.has_daughters () && j < fProngs [i].fNGenerations - 1 ) {
265+ currentMCParticle = currentMCParticle.template mothers_first_as <U>();
266+ // currentMCParticle = mcStack.iteratorAt(currentMCParticle.mothersIds()[0]);
267+ }
217268 }
218- /* if (j < fProngs[i].fNGenerations - 1) {
219- currentMCParticle = mcStack.iteratorAt(currentMCParticle.mother0Id());
220- //currentMCParticle = currentMCParticle.template mother0_as<U>();
221- }*/
222269 }
223270 }
224271
0 commit comments