5 #include "CLHEP/Random/RandGaussQ.h" 7 #include "MakeReweight.h" 8 #include "cetlib/search_path.h" 9 #include "dk2nu/tree/dk2nu.h" 10 #include "dk2nu/tree/dkmeta.h" 32 NeutrinoFluxReweight::MakeReweight*
fPPFXrw;
40 CLHEP::HepRandomEngine& engine)
50 fMode = pset.
get<std::string>(
"mode");
51 fHorn = pset.
get<std::string>(
"horn_curr");
52 fTarget = pset.
get<std::string>(
"target_config");
53 fSeed = pset.
get<
int>(
"random_seed", -1);
55 gSystem->Setenv(
"MODE", fPPFXMode.c_str());
57 fPPFXrw = NeutrinoFluxReweight::MakeReweight::getInstance();
58 std::cout <<
"PPFX instance " <<
fPPFXrw << std::endl;
60 std::string inputOptions;
61 std::string mode_file =
"inputs_" + fPPFXMode +
".xml";
62 cet::search_path sp(
"FW_SEARCH_PATH");
63 sp.find_file(mode_file, inputOptions);
65 if (fSeed != -1)
fPPFXrw->setBaseSeed(fSeed);
66 std::cout <<
"is PPFX setup : " <<
fPPFXrw->AlreadyInitialized() << std::endl;
67 std::cout <<
"Setting PPFX, inputs: " << inputOptions << std::endl;
68 std::cout <<
"Setting Horn Current Configuration to: " << fHorn << std::endl;
69 std::cout <<
"Setting Target Configuration to: " << fTarget << std::endl;
70 if (!(
fPPFXrw->AlreadyInitialized())) {
fPPFXrw->SetOptions(inputOptions); }
71 std::cout <<
"PPFX just set with mode: " << fPPFXMode << std::endl;
76 std::vector<std::vector<double>>
weight;
80 int nmctruth = 0, nmatched = 0;
83 std::vector<art::Handle<std::vector<bsim::Dk2Nu>>> dk2nus2 =
84 e.
getMany<std::vector<bsim::Dk2Nu>>();
85 for (
size_t dk2 = 0; dk2 < dk2nus2.size(); ++dk2) {
88 while ((flag = mcitr.
Next())) {
89 std::string label = mcitr.
GetLabel();
93 const bsim::Dk2Nu* pdk2nu = mcitr.
GetDk2Nu();
100 std::cout <<
"FluxWeightCalculator [" << std::setw(4) << ievt <<
"] " 101 <<
" label \"" << label <<
"\" MCTruth@ " << pmctruth <<
" Dk2Nu@ " << pdk2nu
104 if (!pdk2nu)
continue;
115 dkmeta_obj.horncfg =
fHorn;
116 (dkmeta_obj.vintnames).push_back(
"Index_Tar_In_Ancestry");
117 (dkmeta_obj.vintnames).push_back(
"Playlist");
118 bsim::DkMeta* tmp_dkmeta = &dkmeta_obj;
127 bsim::Dk2Nu* tmp_dk2nu =
const_cast<bsim::Dk2Nu*
>(pdk2nu);
129 fPPFXrw->calculateWeights(tmp_dk2nu, tmp_dkmeta);
132 std::cerr <<
"Failed to calcualte weight" << std::endl;
136 if (
fMode ==
"reweight") {
137 double ppfx_cv_wgt =
fPPFXrw->GetCVWeight();
138 std::vector<double> wvec = {ppfx_cv_wgt};
139 weight.push_back(wvec);
142 std::vector<double> vttpcnucleon =
fPPFXrw->GetWeights(
"ThinTargetpCNucleon");
144 std::vector<double> tmp_vhptot;
145 for (
unsigned int iuniv = 0; iuniv < vttpcnucleon.size(); iuniv++) {
146 tmp_vhptot.push_back(
float(vttpcnucleon[iuniv]));
148 weight.push_back(tmp_vhptot);
const simb::MCTruth * GetMCTruth() const
std::vector< std::string > fInputLabels
void Configure(fhicl::ParameterSet const &p, CLHEP::HepRandomEngine &engine) override
std::vector< std::vector< double > > GetWeight(art::Event &e) override
#define DECLARE_WEIGHTCALC(wghcalc)
T get(std::string const &key) const
NeutrinoFluxReweight::MakeReweight * fPPFXrw
std::string fGenieModuleLabel
Event generator information.
std::string GetLabel() const
const bsim::Dk2Nu * GetDk2Nu() const
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
#define REGISTER_WEIGHTCALC(wghcalc)