20 #include "art_root_io/TFileService.h" 32 #include "dk2nu/tree/NuChoice.h" 33 #include "dk2nu/tree/dk2nu.h" 35 #include "GENIE/Framework/EventGen/EventRecord.h" 44 , fInputType(ps.
get<
std::string>(
"inputType"))
48 helper.reconstitutes<std::vector<bsim::Dk2Nu>,
art::InEvent>(
"flux") :
51 helper.reconstitutes<std::vector<bsim::NuChoice>,
art::InEvent>(
"flux") :
66 art::TFileDirectory tffluxdir = tfs->mkdir(
"Flux");
67 string nutype[] = {
"nue",
"nuebar",
"numu",
"numubar"};
68 string nultx[] = {
"#nu_{e}",
"#bar{#nu}_{e}",
"#nu_{#mu}",
"#bar{#nu}_{#mu}"};
69 string pltx[] = {
"#mu^{#pm}",
"#pi^{#pm}",
"K^{0}_{L}",
"K^{#pm}"};
70 string secltx[] = {
"pBe->#pi^{#pm}->...->#mu^{#pm}",
71 "pBe->#pi^{#pm}->..(not #mu^{#pm})..",
72 "pBe->K^{0}_{L}->...",
74 "pBe->(p or n)->..."};
76 int nbins = ps.
get<
int>(
"nBins", 0);
77 int Elow = ps.get<
float>(
"Elow", 0);
78 int Ehigh = ps.get<
float>(
"Ehigh", 0);
80 for (
int i = 0; i < 4; i++) {
81 fHFlux[i] = tffluxdir.make<TH1D>(Form(
"h50%i", i + 1),
82 Form(
"%s (all);Energy %s (GeV);#phi(%s)/50MeV/POT",
92 for (
int inu = 0; inu < 4; inu++) {
93 for (
int ipar = 0; ipar < 4; ipar++) {
95 tffluxdir.make<TH1D>(Form(
"h5%i%i", ipar + 1, inu + 1),
96 Form(
"...->%s->%s;Energy %s (GeV);#phi(%s)/50MeV/POT",
107 for (
int isec = 0; isec < 5; isec++) {
109 tffluxdir.make<TH1D>(Form(
"h7%i%i", isec + 1, inu + 1),
110 Form(
"%s->%s;Energy %s (GeV);#phi(%s)/50MeV/POT",
111 secltx[isec].c_str(),
123 fEntry = ps.get<uint32_t>(
"skipEvents", 0);
158 <<
"Ntuple format " <<
fInputType <<
" not supported" << std::endl;
176 std::unique_ptr<std::vector<simb::MCFlux>> mcfluxvec(
new std::vector<simb::MCFlux>);
177 std::unique_ptr<std::vector<simb::MCTruth>> mctruthvec(
new std::vector<simb::MCTruth>);
179 std::unique_ptr<std::vector<bsim::Dk2Nu>> dk2nuvec(
new std::vector<bsim::Dk2Nu>);
180 std::unique_ptr<std::vector<bsim::NuChoice>> nuchoicevec(
new std::vector<bsim::NuChoice>);
181 std::unique_ptr<art::Assns<simb::MCTruth, bsim::Dk2Nu>> dk2nuassn(
183 std::unique_ptr<art::Assns<simb::MCTruth, bsim::NuChoice>> nuchoiceassn(
185 std::unique_ptr<art::Assns<simb::MCTruth, simb::MCFlux>> mcfluxassn(
197 mctruthvec->push_back(mctruth);
208 else if (flux.
fntype == -12)
210 else if (flux.
fntype == 14)
212 else if (flux.
fntype == -14)
217 if (totwgh < 0 || totwgh > 100) {
218 std::cout <<
" Bad weight " << totwgh << std::endl;
223 fHFlux[ipdg]->Fill(enu, totwgh);
229 else if (flux.
fptype == 130)
236 else if (fabs(flux.
ftptype) == 211)
238 else if (fabs(flux.
ftptype) == 130)
240 else if (fabs(flux.
ftptype) == 321)
245 mcfluxvec->push_back(flux);
260 <<
") does not match current run number (" << newID.
run()
261 <<
")! Reassigning variable...." << std::endl;
265 <<
") does not match current subrun number (" << newID.
subRun()
266 <<
")! Reassigning variable...." << std::endl;
292 dk2nuassn->addSingle(aptr, bptr);
293 nuchoiceassn->addSingle(aptr, cptr);
294 mcfluxassn->addSingle(aptr, dptr);
fhicl::ParameterSet fConfigPS
Ptr< T > makePtr(TypeLabel const &t, Principal const &p, typename Ptr< T >::key_type key) const
virtual Long64_t GetEntries() const =0
virtual float GetPOT() const =0
virtual TLorentzVector GetNuPosition() const =0
void AddTrajectoryPoint(TLorentzVector const &position, TLorentzVector const &momentum)
virtual bool FillMCFlux(Long64_t ientry, simb::MCFlux &mclux)=0
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary subRunAux) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
TH1D * fHFluxParent[4][4]
EventPrincipal * makeEventPrincipal(EventAuxiliary eventAux) const
void SetNeutrino(int CCNC, int mode, int interactionType, int target, int nucleon, int quark, double w, double x, double y, double qsqr)
virtual int GetRun() const =0
bool readNext(art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
object containing MC flux information
TypeLabel const & reconstitutes(std::string const &modLabel, std::string const &instanceName={})
RunID const & runID() const
FluxInterface * fFluxDriver
T get(std::string const &key) const
PPFXFluxReader(fhicl::ParameterSet const &pset, art::ProductRegistryHelper &helper, art::SourceHelper const &pm)
art::SourceHelper const & fSourceHelper
art::TypeLabel fTLnuchoice
static constexpr SubRunID flushSubRun() noexcept
void Add(simb::MCParticle const &part)
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
RunPrincipal * makeRunPrincipal(RunAuxiliary runAux) const
std::enable_if_t<!detail::range_sets_supported(P::branch_type)> put_product_in_principal(std::unique_ptr< T > &&product, P &principal, std::string const &module_label, std::string const &instance_name={})
virtual TLorentzVector GetNuMomentum() const =0
art::TypeLabel fTLmctruth
SubRunNumber_t subRun() const
Event generator information.
void readFile(std::string const &name, art::FileBlock *&fb)
cet::coded_exception< error, detail::translate > exception
IDNumber_t< Level::Run > RunNumber_t