8 #include "TDatabasePDG.h" 9 #include "TParticlePDG.h" 18 bsim::Dk2Nu*
dk2nu =
new bsim::Dk2Nu;
19 bsim::DkMeta* dkmeta =
new bsim::DkMeta;
20 tdk2nu->SetBranchAddress(
"dk2nu",&dk2nu);
21 Long64_t
nentries = tdk2nu->GetEntries();
22 Long64_t ntrees = tdk2nu->GetNtrees();
23 tdkmeta->SetBranchAddress(
"dkmeta",&dkmeta);
38 const char* ppfxDir =
getenv(
"PPFX_DIR");
40 makerew->
SetOptions(Form(
"%s/scripts/inputs_imap.xml",ppfxDir));
52 std::cout<<
"FillIMapHists looping over "<<ntrees<<
" trees with a total of "<<nentries<<
" entries."<<
std::endl;
53 double total_weight=0.0;
54 for(Long64_t ientry=0;ientry<
nentries;ientry++){
55 if(ientry%100000==0)std::cout<<
"ientry "<<ientry/1000<<
" k evts"<<
std::endl;
56 tdk2nu->GetEntry(ientry);
57 tdkmeta->GetEntry(ientry);
59 total_weight+=
FillOneEntry(dk2nu,dkmeta,hists,opts,&reweighters);
72 TDatabasePDG*
pdg = TDatabasePDG::Instance();
75 const int nu_type=dk2nu->decay.ntype;
76 const int nuray_idx=1;
77 const double enu=dk2nu->nuray[nuray_idx].E;
80 std::cout<<
"FillOneEntry() for nu_type= "<<nu_type
84 if( (opts->
nuid!=0 && nu_type!= opts->
nuid)
85 || (enu<opts->elow || enu>opts->
ehigh) ){
87 std::cout<<
"Fails cut on nu_type or energy"<<
std::endl;
91 const double nwtnear=dk2nu->nuray[nuray_idx].wgt;
92 const double nimpwt=dk2nu->decay.nimpwt;
93 weight=nwtnear*nimpwt;
109 std::cout<<
"Passes energy cut and has a weight of "<<weight
110 <<
" with "<<ninter<<
" entries in ancestry chain"<<
std::endl;
116 for(
int iinter=0; iinter<ninter; iinter++){
121 std::cout<<
"Processing interaction "<<iinter<<
endl;
122 interdata.
print(std::cout);
125 if(interdata.
Proc==
"Decay"){
127 std::cout<<
" This is a decay, skip it"<<
std::endl;
136 if(opts->
cut_mipp && numi_pion_nodes[iinter])
continue;
137 if(opts->
cut_mipp && numi_kaon_nodes[iinter])
continue;
139 bool covered_by_thintarget =
false;
141 covered_by_thintarget =
true;
150 covered_by_thintarget =
true;
160 covered_by_thintarget =
true;
164 covered_by_thintarget =
true;
168 covered_by_thintarget =
true;
172 covered_by_thintarget =
true;
176 covered_by_thintarget =
false;
185 if(opts->
cut_mipp && covered_by_thintarget)
continue;
196 if(mode==
"REF"||mode==
"OPT"){
202 std::cout<<
"Skipping unknown volume "<< interdata.
Vol 203 <<
" for interaction "<<iinter<<
std::endl;
207 const string proj_name=pdg->GetParticle(interdata.
Inc_pdg)->GetName();
208 const string prod_name=pdg->GetParticle(interdata.
Prod_pdg)->GetName();
218 std::cout<<
" Projectile: "<<proj_name<<
" with popidx "<<proj_pop_idx<<
std::endl;
219 std::cout<<
" Produced : "<<prod_name<<
" with popidx "<<prod_pop_idx<<
std::endl;
224 if(prod_pop_idx!=-1){
228 hists->
_hkepop_tot[prod_pop_idx]->Fill(produced_KE,weight);
230 hists->
_hxfpt_tot[prod_pop_idx]->Fill(interdata.
xF,interdata.
Pt,weight);
234 hists->
_hmatbkw[prod_pop_idx]->Fill(material_name.c_str(),proj_name.c_str(),
weight);
237 if(proj_pop_idx!=-1){
240 hists->
_hkepop[prod_pop_idx][proj_pop_idx]->Fill(produced_KE,weight);
241 hists->
_htmpop[prod_pop_idx][proj_pop_idx]->Fill(interdata.
Prod_P,weight);
242 hists->
_hxfpt[prod_pop_idx][proj_pop_idx]->Fill(interdata.
xF,interdata.
Pt,weight);
247 if(proj_pop_idx!=-1){
249 const double projectile_KE=interdata.
Inc_P4[3]-interdata.
Inc_Mass;
250 hists->
_henergytotal[proj_pop_idx]->Fill(projectile_KE,weight);
252 hists->
_hmat[proj_pop_idx]->Fill(material_name.c_str(),prod_name.c_str(),
weight);
253 hists->
_hvol[proj_pop_idx]->Fill(volume_name.c_str(),prod_name.c_str(),
weight);
256 if(mv_idx!=-1) hists->
_henergyvolume[mv_idx][proj_pop_idx]->Fill(projectile_KE,weight);
257 if(projectile_KE>118 and proj_pop_idx==1){
275 if((mode==
"REF"||mode==
"OPT")){
TH2D * _h_hpwgt_xfpt_pc_kp
NeutrinoFluxReweight::MIPPNumiKaonYieldsReweighter * NumiKaons
virtual double calculateWeight(const InteractionData &aa)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
static const std::string materials[nvol]
A class to make the reweight event by event.
NeutrinoFluxReweight::ThinTargetMesonIncidentReweighter * ThinTargetMesonIncident
vector< TH1F * > _hkepop_tot
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
TH1D * _h_aveint_vs_enu_thin_nucleona
Information about the chain of interactions leading to a neutrino.
int FindIndexFromVolume(const std::string &wanted)
int Prod_pdg
pdg code of the produced particle
static MakeReweight * getInstance()
vector< vector< TH1F * > > _hkepop
double Pt
Transversal momentum (GeV/c) of the produced particle.
static const std::string volume[nvol]
TH1D * _h_aveint_vs_enu_tot
The information about a hadronic interaction needed to calculate weights.
std::vector< InteractionData > interaction_chain
vector of neutrino ancestors
std::ostream & print(std::ostream &os) const
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
static const int nvoldune
double Inc_P4[4]
Momentum 4 vector of the incident particle, E=p[3].
double Prod_P
Momentum magnitude of the produced particle.
TH1D * _h_aveint_vs_enu_thin_pCpion
vector< vector< TH2D * > > _hxfpt
vector< vector< TH1F * > > _henergyvolume
double xF
Feynmann-x of the produced particle: .
vector< TH2D * > _hxfpt_tot
TH1D * _h_aveint_vs_enu_thin_nCpion
vector< TH1F * > _htmpop_tot
virtual double calculateWeight(const InteractionData &inter_data)
calculate a weight for this interaction given the central value parameters and the parameters for thi...
NeutrinoFluxReweight::ThinTargetpCPionReweighter * ThinTargetpCPion
double Prod_P4[4]
Momentum 4 vector of the produced particle, E=p[3].
std::string getenv(std::string const &name)
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
double FillIMapHists(TChain *tdk2nu, TChain *tdkmeta, HistList *hists, const FillIMapHistsOpts *opts)
std::string Proc
Interaction process.
TH2D * _h_occ_xfpt_pc_pip
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
NeutrinoFluxReweight::MIPPNumiPionYieldsReweighter * NumiPions
std::string Vol
Interaction volume.
double Inc_Mass
Mass of the incident particle.
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
vector< vector< TH1F * > > _htmpop
NeutrinoFluxReweight::ThinTargetnucleonAReweighter * ThinTargetnucleonA
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
int Inc_pdg
pdg code of the incident particle
TH1D * _h_aveint_vs_enu_others
vector< TH2D * > _hmatbkw
vector< TH1F * > _henergytotal
static void resetInstance()
NeutrinoFluxReweight::ThinTargetpCKaonReweighter * ThinTargetpCKaon
int FindIndexFromParticleName(const std::string &wanted)
TH1D * _h_aveint_vs_enu_thin_mesoninc
static const std::string materialsdune[nvoldune]
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?
NeutrinoFluxReweight::ThinTargetnCPionReweighter * ThinTargetnCPion
static const std::string popparticle[npop]
ReweightDriver * cv_rw
Reweighter Drivers for the central value.
TH2D * _h_nint_vs_enu_cuts
TH1D * _h_aveint_vs_enu_thin_pCnucleon
static const std::string volumedune[nvoldune]
TH1D * _h_aveint_vs_enu_thin_pCkaon
TH2D * _h_hpwgt_xfpt_pc_pip
NeutrinoFluxReweight::ThinTargetpCNucleonReweighter * ThinTargetpCNucleon
QTextStream & endl(QTextStream &s)
double Prod_Mass
Mass of the produced particle.
void SetOptions(std::string fileIn)
double FillOneEntry(bsim::Dk2Nu *dk2nu, bsim::DkMeta *dkmeta, HistList *hists, const FillIMapHistsOpts *opts, FillIMapHistsReweighters *reweighters)
virtual bool canReweight(const InteractionData &aa)
can the particular instance of this class reweight this interaction?