Skip to content

Commit 2a55bc4

Browse files
committed
Use BooNEpBeInteraction to identify pBe interaction, also better loop
Co-authored-by: John Plows kom.plows@gmail.com
1 parent 56bd4b1 commit 2a55bc4

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

sbncode/SBNEventWeight/Calculators/BNBFlux/FluxCalcPrep.cxx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,20 @@ namespace sbn {
302302
flux.ftpy = fluxlist[inu].ftpy;
303303
flux.ftpz = fluxlist[inu].ftpz;
304304

305-
// int tptype = fluxlist[inu].ftptype;
306-
307305
// If Dk2Nu flux, use ancestors to evaluate tptype
308306
if (fluxlist[inu].fFluxType == simb::kDk2Nu) {
309307

310-
// Find the first inelastic interaction
311-
int firstInelastic = 0;
312-
while (dk2nu_v->at(inu).ancestor[firstInelastic].proc.find("HadronInelastic")==std::string::npos||dk2nu_v->at(inu).ancestor[firstInelastic].proc.find("QEBooNE")!=std::string::npos) firstInelastic++;
313-
314-
// Get the parent/ancestor (this should be the secondary in the p+Be interaction)
315-
flux.ftptype = dk2nu_v->at(inu).ancestor[firstInelastic].pdg;
316-
flux.ftpx = dk2nu_v->at(inu).ancestor[firstInelastic].startpx;
317-
flux.ftpy = dk2nu_v->at(inu).ancestor[firstInelastic].startpy;
318-
flux.ftpz = dk2nu_v->at(inu).ancestor[firstInelastic].startpz;
319-
308+
for( const bsim::Ancestor & ancestor : dk2nu_v->at(inu).ancestor ) {
309+
std::string aproc = ancestor.proc;
310+
if( (aproc.find("BooNEHadronInelastic:BooNEpBeInteraction") != std::string::npos) && (aproc.find("QEBooNE") == std::string::npos) ) {
311+
flux.ftptype = ancestor.pdg;
312+
flux.ftpx = ancestor.startpx;
313+
flux.ftpy = ancestor.startpy;
314+
flux.ftpz = ancestor.startpz;
315+
} // found it
316+
} // find first inelastic
320317
}
321318

322-
323319
if (std::find(fprimaryHad.begin(), fprimaryHad.end(),(flux.ftptype)) == fprimaryHad.end() ){//if it does not contain any particles we need get 1
324320
weights.resize( NUni);
325321
std::fill(weights.begin(), weights.end(), 1);

0 commit comments

Comments
 (0)