Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions sbncode/SBNEventWeight/Calculators/BNBFlux/FluxCalcPrep.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,16 @@ namespace sbn {
// std::cout<<"SBNEventWeight : getweight for the "<<inu<<" th particles of an event"<< std::endl;
//MCFlux & MCTruth
art::Handle< std::vector<simb::MCFlux> > mcFluxHandle;
e.getByLabel(fGeneratorModuleLabel,mcFluxHandle);
e.getByLabel(fGeneratorModuleLabel, mcFluxHandle);
std::vector<simb::MCFlux> const& fluxlist = *mcFluxHandle;

art::Handle< std::vector<bsim::Dk2Nu> > dk2nuHandle;
std::vector<bsim::Dk2Nu> const* dk2nu_v = nullptr;
e.getByLabel(fGeneratorModuleLabel, dk2nuHandle);
if (dk2nuHandle.isValid()) {
dk2nu_v = dk2nuHandle.product();
}

//or do the above 3 lines in one line
// auto const& mclist = *e.getValidHandle<std::vector<simb::MCTruth>>(fGeneratorModuleLabel);

Expand Down Expand Up @@ -287,7 +295,32 @@ namespace sbn {

// First let's check that the parent of the neutrino we are looking for is
// the particle we intended it to be, if not set all weights to 1
if (std::find(fprimaryHad.begin(), fprimaryHad.end(),(fluxlist[inu].ftptype)) == fprimaryHad.end() ){//if it does not contain any particles we need get 1

simb::MCFlux flux;
flux.ftptype = fluxlist[inu].ftptype;
flux.ftpx = fluxlist[inu].ftpx;
flux.ftpy = fluxlist[inu].ftpy;
flux.ftpz = fluxlist[inu].ftpz;

// int tptype = fluxlist[inu].ftptype;

// If Dk2Nu flux, use ancestors to evaluate tptype
if (fluxlist[inu].fFluxType == simb::kDk2Nu) {

// Find the first inelastic interaction
int firstInelastic = 0;
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++;

// Get the parent/ancestor (this should be the secondary in the p+Be interaction)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're aiming exclusively for the pBe secondary, you might also be able to find the first ancestor whose creation process includes "BooNEHadronInelastic:BooNEpBeInteraction", rather than just looking for the first inelastic interaction. I don't know myself exactly how much this affects things, how many first inelastic aren't the pBe interaction that's constrained in the above interaction type. It would leave the possibility that some neutrinos may never have that interaction type, but that would be a rare case.

flux.ftptype = dk2nu_v->at(inu).ancestor[firstInelastic].pdg;
flux.ftpx = dk2nu_v->at(inu).ancestor[firstInelastic].startpx;
flux.ftpy = dk2nu_v->at(inu).ancestor[firstInelastic].startpy;
flux.ftpz = dk2nu_v->at(inu).ancestor[firstInelastic].startpz;

}


if (std::find(fprimaryHad.begin(), fprimaryHad.end(),(flux.ftptype)) == fprimaryHad.end() ){//if it does not contain any particles we need get 1
weights.resize( NUni);
std::fill(weights.begin(), weights.end(), 1);
return weights;//done, all 1
Expand All @@ -301,19 +334,18 @@ namespace sbn {
std::vector< float > Vrandom = (fParameterSet.fParameterMap.begin())->second;//vector of random #
std::vector< float > subVrandom;//sub-vector of random numbers;
if( CalcType == "PrimaryHadronNormalization"){//Normalization
test_weight = PHNWeightCalc(fluxlist[inu], Vrandom[i]);
test_weight = PHNWeightCalc(flux, Vrandom[i]);

} else {
subVrandom = {Vrandom.begin()+i*FitCov->GetNcols(), Vrandom.begin()+(i+1)*FitCov->GetNcols()};
if( CalcType == "PrimaryHadronFeynmanScaling"){//FeynmanScaling
test_weight = PHFSWeightCalc(fluxlist[inu], subVrandom);
test_weight = PHFSWeightCalc(flux, subVrandom);

} else if( CalcType == "PrimaryHadronSanfordWang"){//SanfordWang
test_weight = PHSWWeightCalc(fluxlist[inu], subVrandom);
test_weight = PHSWWeightCalc(flux, subVrandom);

} else if( CalcType == "PrimaryHadronSWCentralSplineVariation"){//SWCentaralSplineVariation
test_weight = PHSWCSVWeightCalc(fluxlist[inu], subVrandom);

test_weight = PHSWCSVWeightCalc(flux, subVrandom);
} else throw cet::exception(__PRETTY_FUNCTION__) << GetName() << ": this shouldnt happen.."<<std::endl;
}

Expand Down
4 changes: 4 additions & 0 deletions sbncode/SBNEventWeight/Calculators/BNBFlux/FluxCalcPrep.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "nusimdata/SimulationBase/MCFlux.h"
#include "nusimdata/SimulationBase/MCTruth.h"

#include "dk2nu/tree/NuChoice.h"
#include "dk2nu/tree/dk2nu.h"
#include "dk2nu/tree/dkmeta.h"

#include "sbncode/SBNEventWeight/Base/WeightCalc.h"
#include "art/Framework/Principal/Event.h"
#include "sbncode/SBNEventWeight/Base/WeightCalcCreator.h"
Expand Down