14 #include "art/Framework/IO/Sources/put_product_in_principal.h"
15 #include "art/Framework/Core/EDProducer.h"
16 #include "art/Framework/Principal/SubRun.h"
17 #include "art_root_io/TFileService.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
25 #include "nusimdata/SimulationBase/MCFlux.h"
26 #include "nusimdata/SimulationBase/MCTruth.h"
28 #include "dk2nu/tree/dk2nu.h"
29 #include "dk2nu/tree/NuChoice.h"
36 #include "GENIE/Framework/EventGen/EventRecord.h"
38 #include "nutools/EventGeneratorBase/evgenbase.h"
48 art::ProductRegistryHelper &helper,
49 art::SourceHelper
const &pm)
53 fInputType(ps.
get<
std::string>(
"inputType")),
54 fSelfIncrementRuns(ps.
get<
bool>(
"SelfIncrementRun")),
56 fTLmctruth{helper.reconstitutes<std::vector<simb::MCTruth>, art::InEvent>(
"flux")},
57 fTLmcflux{helper.reconstitutes<std::vector<simb::MCFlux>, art::InEvent>(
"flux")},
67 helper.reconstitutes<art::Assns<simb::MCTruth, bsim::Dk2Nu>, art::InEvent>(
"flux");
68 helper.reconstitutes<art::Assns<simb::MCTruth, bsim::NuChoice>, art::InEvent>(
"flux");
69 helper.reconstitutes<art::Assns<simb::MCTruth, simb::MCFlux>, art::InEvent>(
"flux");
71 fConfigPS=ps.get<fhicl::ParameterSet>(ps.get<std::string>(
"dk2nuConfig"));
74 art::ServiceHandle<art::TFileService>
tfs;
76 art::TFileDirectory tffluxdir = tfs->mkdir(
"Flux" );
77 string nutype[] ={
"nue",
"nuebar",
"numu",
"numubar"};
78 string nultx[] ={
"#nu_{e}",
"#bar{#nu}_{e}",
"#nu_{#mu}",
"#bar{#nu}_{#mu}"};
79 string pltx[] ={
"#mu^{#pm}",
"#pi^{#pm}",
"K^{0}_{L}",
"K^{#pm}"};
80 string secltx[] ={
"pBe->#pi^{#pm}->...->#mu^{#pm}",
81 "pBe->#pi^{#pm}->..(not #mu^{#pm})..",
82 "pBe->K^{0}_{L}->...",
84 "pBe->(p or n)->..."};
87 int nbins=ps.get<
int>(
"nBins",0);
88 int Elow=ps.get<
float>(
"Elow",0);
89 int Ehigh=ps.get<
float>(
"Ehigh",0);
91 for (
int i=0;i<4;i++) {
92 fHFlux[i]=tffluxdir.make<TH1D>(Form(
"h50%i",i+1),
93 Form(
"%s (all);Energy %s (GeV);#phi(%s)/50MeV/POT",nultx[i].c_str(),nultx[i].c_str(),nultx[i].c_str()),
98 for (
int inu=0;inu<4;inu++) {
99 for (
int ipar=0;ipar<4;ipar++) {
100 fHFluxParent[inu][ipar]=tffluxdir.make<TH1D>(Form(
"h5%i%i",ipar+1,inu+1),
101 Form(
"...->%s->%s;Energy %s (GeV);#phi(%s)/50MeV/POT",pltx[ipar].c_str(),nultx[inu].c_str(),nultx[inu].c_str(),nultx[inu].c_str()),
106 for (
int isec=0;isec<5;isec++) {
107 fHFluxSec[inu][isec]=tffluxdir.make<TH1D>(Form(
"h7%i%i",isec+1,inu+1),
108 Form(
"%s->%s;Energy %s (GeV);#phi(%s)/50MeV/POT",secltx[isec].c_str(),nultx[inu].c_str(),nultx[inu].c_str(),nultx[inu].c_str()),
117 fEntry=ps.get<uint32_t>(
"skipEvents", 0);
136 std::cout <<
"readFile " << name << std::endl;
138 fb =
new art::FileBlock(art::FileFormatVersion(1,
"FluxReader"), name);
156 throw cet::exception(__PRETTY_FUNCTION__) <<
"Ntuple format "<<
fInputType<<
" not supported"<<std::endl;
158 std::cout <<
"Reading in file " << name << std::endl;
173 art::SubRunPrincipal*
const &,
174 art::RunPrincipal* &outR,
175 art::SubRunPrincipal* &outSR,
176 art::EventPrincipal* &outE)
184 std::unique_ptr< std::vector<simb::MCFlux> > mcfluxvec(
new std::vector<simb::MCFlux >);
185 std::unique_ptr< std::vector<simb::MCTruth> > mctruthvec(
new std::vector<simb::MCTruth >);
187 std::unique_ptr< std::vector<bsim::Dk2Nu> > dk2nuvec(
new std::vector<bsim::Dk2Nu >);
188 std::unique_ptr< std::vector<bsim::NuChoice> > nuchoicevec(
new std::vector<bsim::NuChoice >);
189 std::unique_ptr< art::Assns<simb::MCTruth, bsim::Dk2Nu> >
190 dk2nuassn(
new art::Assns<simb::MCTruth, bsim::Dk2Nu>);
191 std::unique_ptr< art::Assns<simb::MCTruth, bsim::NuChoice> >
192 nuchoiceassn(
new art::Assns<simb::MCTruth, bsim::NuChoice>);
193 std::unique_ptr< art::Assns<simb::MCTruth, simb::MCFlux> >
194 mcfluxassn(
new art::Assns<simb::MCTruth, simb::MCFlux>);
211 simb::MCTruth mctruth;
212 simb::MCParticle mcpnu(0,flux.fntype,
"Flux");
216 mctruth.SetNeutrino(0,0,0,0,0,0,0,0,0,0);
217 mctruthvec->push_back(mctruth);
226 if (flux.fntype==12) ipdg=0;
227 else if (flux.fntype==-12) ipdg=1;
228 else if (flux.fntype==14) ipdg=2;
229 else if (flux.fntype==-14) ipdg=3;
231 double enu=flux.fnenergyn;
232 double totwgh=flux.fnwtnear*flux.fnimpwt/
fCurrentPOT;
234 else if (totwgh<0 || totwgh>100) {
235 std::cout<<
" Bad weight "<<totwgh<<std::endl;
240 fHFlux[ipdg]->Fill(enu,totwgh);
242 if (flux.fptype==13 || flux.fptype==-13)
244 else if (flux.fptype==211 || flux.fptype==-211)
246 else if (flux.fptype==130)
248 else if (flux.fptype==321 || flux.fptype==-321)
251 if (fabs(flux.ftptype==211) && fabs(flux.fptype)==13)
253 else if (fabs(flux.ftptype)==211)
255 else if (fabs(flux.ftptype)==130)
257 else if (fabs(flux.ftptype)==321)
259 else if (flux.ftptype==2212 || flux.ftptype==2112)
262 mcfluxvec->push_back(flux);
267 if (rn==0) rn=999999;
268 art::Timestamp tstamp(time(0));
270 art::SubRunID newID(rn, 0);
271 if (
fSubRunID.runID() != newID.runID()) {
280 art::put_product_in_principal(std::move(pot),
294 art::put_product_in_principal(std::move(mcfluxvec),
297 art::put_product_in_principal(std::move(mctruthvec),
301 art::put_product_in_principal(std::move(dk2nuvec),
304 art::put_product_in_principal(std::move(nuchoicevec),
313 dk2nuassn->addSingle(aptr,bptr);
314 nuchoiceassn->addSingle(aptr,cptr);
315 mcfluxassn->addSingle(aptr,dptr);
317 art::put_product_in_principal(std::move(dk2nuassn),
320 art::put_product_in_principal(std::move(nuchoiceassn),
323 art::put_product_in_principal(std::move(mcfluxassn),
virtual const TLorentzVector GetNuMomentum()=0
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Utilities related to art service access.
virtual bool FillMCFlux(Long64_t ientry, simb::MCFlux &mclux)=0
virtual const float GetPOT()=0
virtual const TLorentzVector GetNuPosition()=0
virtual const int GetRun()=0
art::SourceHelper const & fSourceHelper
TH1D * fHFluxParent[4][4]
Interface to read flux files in BooNE tuple format.
bool readNext(art::RunPrincipal *const &inR, art::SubRunPrincipal *const &inSR, art::RunPrincipal *&outR, art::SubRunPrincipal *&outSR, art::EventPrincipal *&outE)
void readFile(std::string const &name, art::FileBlock *&fb)
fhicl::ParameterSet fConfigPS
art::TypeLabel fTLnuchoice
virtual const Long64_t GetEntries()=0
virtual const void SetRun(int)=0
art::ServiceHandle< art::TFileService > tfs
art::TypeLabel fTLmctruth
FluxInterface * fFluxDriver
art framework interface to geometry description
BEGIN_PROLOG could also be cout
FluxReader(fhicl::ParameterSet const &pset, art::ProductRegistryHelper &helper, art::SourceHelper const &pm)
art::RunNumber_t fIncrement