MIPPNumiPionYieldsReweighter.cpp
Go to the documentation of this file.
1 
4 
5 #include "MIPPNumiYieldsBins.h"
6 #include "MIPPNumiMC.h"
7 
8 #include <iostream>
9 
10 namespace NeutrinoFluxReweight{
11 
12  MIPPNumiPionYieldsReweighter::MIPPNumiPionYieldsReweighter(int iuniv, const ParameterTable& cv_pars, const ParameterTable& univ_pars):cvPars(cv_pars),univPars(univ_pars),iUniv(iuniv){
13 
15  vbin_data_pip.reserve(MIPPbins->GetNbins_pip_MIPPNuMI());
16  vbin_data_pim.reserve(MIPPbins->GetNbins_pim_MIPPNuMI());
17 
18  //const boost::interprocess::flat_map<std::string, double>& cv_table = cvPars.getMap();
19  //const boost::interprocess::flat_map<std::string, double>& univ_table = univPars.getMap();
20  prt_no_inter = univPars.getParameterValue("prt_no_interacting");
21  char namepar[100];
22  for(int ii=0;ii<MIPPbins->GetNbins_pip_MIPPNuMI();ii++){
23  sprintf(namepar,"MIPP_NuMI_%s_sys_%d","pip",ii);
24  double data_cv = cvPars.getParameterValue(std::string(namepar));
25  double data_sys = univPars.getParameterValue(std::string(namepar));
26  sprintf(namepar,"MIPP_NuMI_%s_stats_%d","pip",ii);
27  double data_sta = univPars.getParameterValue(std::string(namepar));
28  data_sys /= (1.0-prt_no_inter);
29  data_sta /= (1.0-prt_no_inter);
30  data_cv /= (1.0-prt_no_inter);
31  vbin_data_pip.push_back(data_sys + data_sta - data_cv);
32  }
33  for(int ii=0;ii<MIPPbins->GetNbins_pim_MIPPNuMI();ii++){
34  sprintf(namepar,"MIPP_NuMI_%s_sys_%d","pim",ii);
35  double data_cv = cvPars.getParameterValue(std::string(namepar));
36  double data_sys = univPars.getParameterValue(std::string(namepar));
37  sprintf(namepar,"MIPP_NuMI_%s_stats_%d","pim",ii);
38  double data_sta = univPars.getParameterValue(std::string(namepar));
39  data_sys /= (1.0-prt_no_inter);
40  data_sta /= (1.0-prt_no_inter);
41  data_cv /= (1.0-prt_no_inter);
42  vbin_data_pim.push_back(data_sys + data_sta - data_cv);
43  }
44 
45 
46 }
48 
49  }
51 
53  std::vector<bool> this_nodes;
54  for(size_t ii=0;ii<(aa.interaction_chain).size();ii++){
55  this_nodes.push_back(false);
56  }
57 
58  //Look for MIPP Numi events
59  //if the code find a MIPP Numi event, it will look
60  //for how many interaction nodes covers
61  //if not, return all nodes false.
62  //bool is_there_mipp = false;
63  TargetData tar = aa.tar_info;
64  //Cheking if the particle is a pion plus and pion minus:
65  if(tar.Tar_pdg != 211 && tar.Tar_pdg != -211)return this_nodes;
66  int binID = MIPPbins->BinID(tar.Pz,tar.Pt,tar.Tar_pdg);
67  if(binID<0) return this_nodes;
68 
69  //Now that we know that we have a MIPP Numi event,
70  //we will see how many nodes are covered.
71  std::vector<InteractionData> this_interactions = aa.interaction_chain;
72 
73  //Now we have the index of the hadron that exit the target in the
74  //ancesty chain:
75  if(tar.Idx_ancestry>=0){
76  for(int ii=0;ii<tar.Idx_ancestry;ii++){
77  this_nodes[ii] = true;
78  }
79  }
80  else{
81  // std::cout<<"==>>SOMETHING WEIRD WITH MIPP NUMI "<<tar.Idx_ancestry<<" "<<tar.Tar_pdg<<std::endl;
82  }
83 
84  return this_nodes;
85  }
87 
88  double wgt = 1.0;
89 
92 
93  TargetData tar = aa.tar_info;
94  int binID = MIPPbins->BinID(tar.Pz,tar.Pt,tar.Tar_pdg);
95 
96  if(binID<0){
97  std::cout<<"BINID ZERO:" <<tar.Pz<<" "<<tar.Pt<<" " <<tar.Tar_pdg<<std::endl;
98  return 1.0;
99  }
100 
101  //Getting MC:
102  double binC = MCval->getMCval(tar.Pz,tar.Pt,tar.Tar_pdg);
103  if(binC<1.e-18){
104  std::cout<<"LOW MC VAL: "<<binC <<std::endl;
105  return 1.0;
106  }
107 
108  if(tar.Tar_pdg == 211)wgt = vbin_data_pip[binID]/binC;
109  if(tar.Tar_pdg ==-211)wgt = vbin_data_pim[binID]/binC;
110 
111  if(wgt<0)std::cout<<"TTMIPPPI check wgt(<0) "<<iUniv<<" "<<tar.Pz<<" "<<tar.Pt<<" "<<tar.Tar_pdg<<std::endl;
112  return wgt;
113 
114  }
115 
116 }
int Idx_ancestry
The index of the hadron leaving the target in the ancestry chain.
Definition: TargetData.h:51
double getMCval(double pz, double pt, int pdgcode)
MC value for this HP production.
Definition: MIPPNumiMC.cpp:222
A list/table of parameter names and values.
MIPPNumiPionYieldsReweighter(int iuniv, const ParameterTable &cv_pars, const ParameterTable &univ_pars)
A class to manage the MC value for MIPP NuMI.
Definition: MIPPNumiMC.h:16
std::string string
Definition: nybbler.cc:12
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
Information about the chain of interactions leading to a neutrino.
double getParameterValue(const std::string &name) const
get the value of a parameter. throw an exception of a well defined type if we don&#39;t have it ...
std::vector< InteractionData > interaction_chain
vector of neutrino ancestors
int Tar_pdg
pdg code of the particle
Definition: TargetData.h:24
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
static MIPPNumiMC * getInstance()
Definition: MIPPNumiMC.cpp:295
const double e
int BinID(double pz, double pt, int pdgcode)
Return the Bin ID for this data.
A class to manage the bin definitions for MIPP Numi Yields.
static MIPPNumiYieldsBins * getInstance()
double Pt
Transversal momentum (GeV/c) of the particle.
Definition: TargetData.h:39
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
The information about the hadron that exits the target.
Definition: TargetData.h:12
double Pz
Longitudinal momentum (GeV/c) of the particle.
Definition: TargetData.h:27
TargetData tar_info
Information about the hadron which exited the target.
QTextStream & endl(QTextStream &s)