Public Member Functions | Public Attributes | Private Attributes | List of all members
NeutrinoFluxReweight::ThinTargetpCPionReweighter Class Reference

Reweighter of thin target pion production. More...

#include <ThinTargetpCPionReweighter.h>

Inheritance diagram for NeutrinoFluxReweight::ThinTargetpCPionReweighter:
NeutrinoFluxReweight::IInteractionReweighting

Public Member Functions

 ThinTargetpCPionReweighter (int iuniv, const ParameterTable &cv_pars, const ParameterTable &univ_pars)
 
virtual ~ThinTargetpCPionReweighter ()
 
virtual bool canReweight (const InteractionData &aa)
 can the particular instance of this class reweight this interaction? More...
 
virtual double calculateWeight (const InteractionData &inter_data)
 calculate a weight for this interaction given the central value parameters and the parameters for this universe. The weight is something like: f(cv)/f(MC) * f(univ)/f(cv) where cv in this case corresponds to the best value of the parameter, given the data. If univ_pars=cv_pars then we are calculating a central value weight More...
 
double calculateDataScale (int inc_pdg, double inc_mom, int prod_pdg, double xf, double pt)
 
- Public Member Functions inherited from NeutrinoFluxReweight::IInteractionReweighting
virtual ~IInteractionReweighting ()
 

Public Attributes

double data_prod_xs
 
std::vector< float > vbin_data_pip
 
std::vector< float > vbin_data_pim
 
std::vector< float > bart_vbin_data_pip
 
std::vector< float > bart_vbin_data_pim
 

Private Attributes

int iUniv
 
const ParameterTablecvPars
 
const ParameterTableunivPars
 
float aux_par
 

Detailed Description

Reweighter of thin target pion production.

Definition at line 18 of file ThinTargetpCPionReweighter.h.

Constructor & Destructor Documentation

NeutrinoFluxReweight::ThinTargetpCPionReweighter::ThinTargetpCPionReweighter ( int  iuniv,
const ParameterTable cv_pars,
const ParameterTable univ_pars 
)

Definition at line 11 of file ThinTargetpCPionReweighter.cpp.

11  :iUniv(iuniv),cvPars(cv_pars),univPars(univ_pars){
12 
13  ThinTargetBins* Thinbins = ThinTargetBins::getInstance();
14  vbin_data_pip.reserve(Thinbins->GetNbins_pC_piX_NA49());
15  vbin_data_pim.reserve(Thinbins->GetNbins_pC_piX_NA49());
16  bart_vbin_data_pip.reserve(Thinbins->GetNbins_pC_piX_Barton());
17  bart_vbin_data_pim.reserve(Thinbins->GetNbins_pC_piX_Barton());
18 
19  // const boost::interprocess::flat_map<std::string, double>& cv_table = cvPars.getMap();
20  // const boost::interprocess::flat_map<std::string, double>& univ_table = univPars.getMap();
21 
22  data_prod_xs = univPars.getParameterValue("prod_prtC_xsec");
23 
24  //the number of bins needs to be written from the xmls files
25  char namepar[100];
26  for(int ii=0;ii<Thinbins->GetNbins_pC_piX_NA49();ii++){
27 
28  sprintf(namepar,"ThinTarget_pC_%s_sys_%d","pip",ii);
29  double data_cv = cvPars.getParameterValue(std::string(namepar));
30  double data_sys = univPars.getParameterValue(std::string(namepar));
31  sprintf(namepar,"ThinTarget_pC_%s_stats_%d","pip",ii);
32  double data_sta = univPars.getParameterValue(std::string(namepar));
33  vbin_data_pip.push_back(data_sta + data_sys - data_cv);
34 
35  sprintf(namepar,"ThinTarget_pC_%s_sys_%d","pim",ii);
36  data_cv = cvPars.getParameterValue(std::string(namepar));
37  data_sys = univPars.getParameterValue(std::string(namepar));
38  sprintf(namepar,"ThinTarget_pC_%s_stats_%d","pim",ii);
39  data_sta = univPars.getParameterValue(std::string(namepar));
40  vbin_data_pim.push_back(data_sta + data_sys - data_cv);
41 
42  }
43  for(int ii=0;ii<Thinbins->GetNbins_pC_piX_Barton();ii++){
44 
45  sprintf(namepar,"ThinTargetBarton_pC_%s_%d","pip",ii);
46  double data_err = univPars.getParameterValue(std::string(namepar));
47  bart_vbin_data_pip.push_back(data_err);
48 
49  sprintf(namepar,"ThinTargetBarton_pC_%s_%d","pim",ii);
50  data_err = univPars.getParameterValue(std::string(namepar));
51  bart_vbin_data_pim.push_back(data_err);
52 
53  }
54 
55  aux_par = univPars.getParameterValue("aux_parameter");
56  if(aux_par<1.e-15)aux_par = 1.0;
57 
58  }
std::string string
Definition: nybbler.cc:12
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 ...
const double e
static ThinTargetBins * getInstance()
NeutrinoFluxReweight::ThinTargetpCPionReweighter::~ThinTargetpCPionReweighter ( )
virtual

Definition at line 60 of file ThinTargetpCPionReweighter.cpp.

60  {
61 
62  }

Member Function Documentation

double NeutrinoFluxReweight::ThinTargetpCPionReweighter::calculateDataScale ( int  inc_pdg,
double  inc_mom,
int  prod_pdg,
double  xf,
double  pt 
)

Definition at line 133 of file ThinTargetpCPionReweighter.cpp.

133  {
134  double scaling_violation = 1.0;
135  ThinTargetMC* dtH = ThinTargetMC::getInstance();
136  //temporary:
137  const int Nscl = 11;
138  const int moms[Nscl] = {12,20,31,40,50,60,70,80,100,120,158};
139 
140  int idx_part = -1;
141  if(prod_pdg == 211)idx_part = 0;
142  if(prod_pdg ==-211)idx_part = 1;
143  if(idx_part<0){
144  std::cout<<"Error in the prod particle"<<std::endl;
145  return 1.0;
146  }
147 
148  int binid = dtH->hTTScl[idx_part][Nscl-1]->FindBin(xf,pt);
149  double scl_ref158 = dtH->hTTScl[idx_part][Nscl-1]->GetBinContent(binid);
150 
151  int idx_lowp = -1;
152  int idx_hip = -1;
153  for(int i=0;i<Nscl-1;i++){
154  if(inc_mom>=double(moms[i]) && inc_mom<double(moms[i+1])){
155  idx_lowp=i;
156  idx_hip =i+1;
157  }
158  }
159  if(idx_lowp<0 || idx_hip<0){
160  std::cout<<"Error calculating the scaling"<<std::endl;
161  return 1.0;
162  }
163  double scl_low = dtH->hTTScl[idx_part][idx_lowp]->GetBinContent(binid);
164  double scl_hi = dtH->hTTScl[idx_part][idx_hip]->GetBinContent(binid);
165  double scl_m = scl_low + (inc_mom-double(moms[idx_lowp]))*(scl_hi-scl_low)/(double(moms[idx_hip])-double(moms[idx_lowp]));
166  if(scl_ref158<1.e-10){
167  // std::cout<<"ref158 zero!!! "<<scl_ref158<<std::endl;
168  return 1.0;
169  }
170  scaling_violation = scl_m/scl_ref158;
171  return scaling_violation;
172  }
const double e
QTextStream & endl(QTextStream &s)
static ThinTargetMC * getInstance()
double NeutrinoFluxReweight::ThinTargetpCPionReweighter::calculateWeight ( const InteractionData inter_data)
virtual

calculate a weight for this interaction given the central value parameters and the parameters for this universe. The weight is something like: f(cv)/f(MC) * f(univ)/f(cv) where cv in this case corresponds to the best value of the parameter, given the data. If univ_pars=cv_pars then we are calculating a central value weight

Implements NeutrinoFluxReweight::IInteractionReweighting.

Definition at line 86 of file ThinTargetpCPionReweighter.cpp.

86  {
87 
88  double wgt = 1.0;
89  double low_value = 1.e-18;
90  ThinTargetBins* Thinbins = ThinTargetBins::getInstance();
91  int bin = Thinbins->BinID_pC_pi(aa.xF,aa.Pt,aa.Prod_pdg);
92  int bart_bin = Thinbins->barton_BinID_pC_pi(aa.xF,aa.Pt,aa.Prod_pdg);
93  if(bin<0 && bart_bin<0)return aux_par;
94 
95  //Calculating the scale:
96  double data_scale = calculateDataScale(aa.Inc_pdg,aa.Inc_P,aa.Prod_pdg,aa.xF,aa.Pt);
97  double dataval = -1;
98  if(aa.Prod_pdg == 211 && bin>=0) dataval = vbin_data_pip[bin];
99  else if(aa.Prod_pdg == 211 && bart_bin>=0) dataval = bart_vbin_data_pip[bart_bin];
100  else if(aa.Prod_pdg == -211 && bin>=0) dataval = vbin_data_pim[bin];
101  else if(aa.Prod_pdg == -211 && bart_bin>=0)dataval = bart_vbin_data_pim[bart_bin];
102  else{
103  // std::cout<<"Something is wrong, pdg_prod: "<< aa.Prod_pdg <<std::endl;
104  return aux_par;
105  }
106 
107  //checking if this is the first interaction:
108  if(aa.gen==0)dataval /= data_prod_xs;
109  else if(aa.gen>0)dataval /= 1.0;
110  else{
111  std::cout<<"Something is wrong with gen "<<std::endl;
112  return aux_par;
113  }
114 
115  dataval *= data_scale;
116 
117  ThinTargetMC* mc = ThinTargetMC::getInstance();
118  double mc_cv = mc->getMCval_pC_X(aa.Inc_P,aa.xF,aa.Pt,aa.Prod_pdg);
119  double mc_prod = mc->getMCxs_pC_piK(aa.gen,aa.Inc_P);
120  mc_cv /= mc_prod;
121  // std::cout<<aa.Prod_pdg<<" "<<aa.Pt<<" "<<mc_cv<<" "<<dataval/mc_cv<<std::endl;
122  if(mc_cv<1.e-12)return wgt;
123  wgt = dataval/mc_cv;
124  if(wgt<low_value){
125 
126  //std::cout<<"TTPCPI check wgt(<0) "<<iUniv<<" "<<aa.Inc_P<<" "<<aa.xF<<" "<<aa.Pt<<" "<<aa.Prod_pdg<<std::endl;
127  return aux_par;
128  }
129 
130  return wgt;
131  }
double calculateDataScale(int inc_pdg, double inc_mom, int prod_pdg, double xf, double pt)
const double e
static ThinTargetBins * getInstance()
QTextStream & bin(QTextStream &s)
QTextStream & endl(QTextStream &s)
static ThinTargetMC * getInstance()
bool NeutrinoFluxReweight::ThinTargetpCPionReweighter::canReweight ( const InteractionData aa)
virtual

can the particular instance of this class reweight this interaction?

Implements NeutrinoFluxReweight::IInteractionReweighting.

Definition at line 63 of file ThinTargetpCPionReweighter.cpp.

63  {
64  std::string mode(getenv("MODE"));
65  //checking:
66  //std::cout<<"ThingTargetpcPionReweighter:: "<<aa.Inc_pdg<<" "<<aa.Vol<<" "<<aa.Prod_pdg<<" "<<std::endl;
67  if(aa.Inc_pdg != 2212)return false;
68  if(aa.Inc_P < 12.0)return false;
69  //volume check:
70  bool is_wrong_volume = aa.Vol != "TGT1" && aa.Vol != "BudalMonitor" && aa.Vol != "Budal_HFVS" && aa.Vol != "Budal_VFHS";
71  if( (mode=="REF") || (mode=="OPT") ){
72  is_wrong_volume = aa.Vol != "TargetFinHorizontal" && aa.Vol != "TargetNoSplitSegment" && aa.Vol!="tCoreLog";
73  }
74  if(is_wrong_volume)return false;
75  //
76  if(aa.Prod_pdg != 211 && aa.Prod_pdg != -211)return false;
77 
78  ThinTargetBins* Thinbins = ThinTargetBins::getInstance();
79  int bin = Thinbins->BinID_pC_pi(aa.xF,aa.Pt,aa.Prod_pdg);
80  int bart_bin = Thinbins->barton_BinID_pC_pi(aa.xF,aa.Pt,aa.Prod_pdg);
81 
82  if(bin<0 && bart_bin<0)return false;
83  else return true;
84  }
std::string string
Definition: nybbler.cc:12
std::string getenv(std::string const &name)
Definition: getenv.cc:15
static ThinTargetBins * getInstance()
QTextStream & bin(QTextStream &s)

Member Data Documentation

float NeutrinoFluxReweight::ThinTargetpCPionReweighter::aux_par
private

Definition at line 34 of file ThinTargetpCPionReweighter.h.

std::vector<float> NeutrinoFluxReweight::ThinTargetpCPionReweighter::bart_vbin_data_pim

Definition at line 28 of file ThinTargetpCPionReweighter.h.

std::vector<float> NeutrinoFluxReweight::ThinTargetpCPionReweighter::bart_vbin_data_pip

Definition at line 28 of file ThinTargetpCPionReweighter.h.

const ParameterTable& NeutrinoFluxReweight::ThinTargetpCPionReweighter::cvPars
private

Definition at line 32 of file ThinTargetpCPionReweighter.h.

double NeutrinoFluxReweight::ThinTargetpCPionReweighter::data_prod_xs

Definition at line 26 of file ThinTargetpCPionReweighter.h.

int NeutrinoFluxReweight::ThinTargetpCPionReweighter::iUniv
private

Definition at line 31 of file ThinTargetpCPionReweighter.h.

const ParameterTable& NeutrinoFluxReweight::ThinTargetpCPionReweighter::univPars
private

Definition at line 33 of file ThinTargetpCPionReweighter.h.

std::vector<float> NeutrinoFluxReweight::ThinTargetpCPionReweighter::vbin_data_pim

Definition at line 27 of file ThinTargetpCPionReweighter.h.

std::vector<float> NeutrinoFluxReweight::ThinTargetpCPionReweighter::vbin_data_pip

Definition at line 27 of file ThinTargetpCPionReweighter.h.


The documentation for this class was generated from the following files: