15 #elif defined __GNUC__ 16 #pragma GCC diagnostic push 17 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 22 :cvPars(cv_pars),univPars(univ_pars),iUniv(iuniv){
38 std::vector<bool> can_rws;
40 int ninter = vec_inter.size();
43 for(
int ii=0;ii<ninter;ii++){
44 if(vec_inter[ii].Inc_P==0.0){
45 can_rws.push_back(
false);
51 bool is_tgt_int = vec_inter[0].Vol ==
"BudalMonitor" || vec_inter[0].Vol ==
"TGT1" || vec_inter[0].Vol ==
"Budal_HFVS" || vec_inter[0].Vol ==
"Budal_VFHS";
52 if((mode==
"REF")||(mode==
"OPT")){
53 is_tgt_int = vec_inter[0].Vol ==
"TargetFinHorizontal" || vec_inter[0].Vol ==
"TargetNoSplitSegment" || vec_inter[0].Vol==
"tCoreLog";
55 if(is_tgt_int)can_rws.push_back(
true);
56 else if(vec_inter[0].Inc_pdg == 2212)can_rws.push_back(
true);
57 else can_rws.push_back(
false);
61 bool starts_tgt = vec_inter[ii-1].Vol ==
"BudalMonitor" || vec_inter[ii-1].Vol ==
"TGT1" || vec_inter[ii-1].Vol ==
"Budal_HFVS" || vec_inter[ii-1].Vol ==
"Budal_VFHS";
62 bool ends_tgt = vec_inter[ii].Vol ==
"BudalMonitor" || vec_inter[ii].Vol ==
"TGT1" || vec_inter[ii-1].Vol ==
"Budal_HFVS" || vec_inter[ii-1].Vol ==
"Budal_VFHS";
63 if((mode==
"REF")||(mode==
"OPT")){
64 starts_tgt = vec_inter[ii-1].Vol ==
"TargetFinHorizontal" || vec_inter[ii-1].Vol ==
"TargetNoSplitSegment"|| vec_inter[0].Vol==
"tCoreLog";
65 ends_tgt = vec_inter[ii-1].Vol ==
"TargetFinHorizontal" || vec_inter[ii-1].Vol ==
"TargetNoSplitSegment"||vec_inter[0].Vol==
"tCoreLog";
67 if(starts_tgt && ends_tgt){
68 can_rws.push_back(
true);
70 else if(starts_tgt && !ends_tgt){
71 can_rws.push_back(
true);
74 can_rws.push_back(
false);
86 bool domipp = (makerew->
cv_rw)->doMIPPNumi;
89 const double graphite_density=1.78;
90 const double avog_x_mb2cm2 = 6.02214e-4;
91 const double graphite_A = 12.01;
99 bool there_is_MIPP =
false;
100 bool it_is_survival =
false;
107 if( !is_le && !is_me ){
108 throw std::runtime_error(
"cannot determine if it's LE or ME beam");
114 there_is_MIPP =
true;
121 int aux_binID = MIPPbins->
BinID(tar.
Pz,tar.
Pt,211);
123 there_is_MIPP =
true;
131 int aux_binID = MIPPbins->
BinID(tar.
Pz,tar.
Pt,-211);
133 there_is_MIPP =
true;
139 int aux_binID = MIPPbins->
BinID(tar.
Pz,tar.
Pt,211);
141 there_is_MIPP =
true;
147 std::cout<<
"=> There is an in MIPPNumiYieldsBins"<<
std::endl;
152 if(!there_is_MIPP && vec_inter[0].Vol!=
"BudalMonitor" && vec_inter[0].Vol!=
"TGT1" && vec_inter[0].Vol!=
"Budal_HFVS" && vec_inter[0].Vol!=
"Budal_VFHS"){
153 it_is_survival =
true;
155 if((mode==
"REF")||(mode==
"OPT")){
156 if(!there_is_MIPP && vec_inter[0].Vol!=
"TargetFinHorizontal" && vec_inter[0].Vol!=
"TargetNoSplitSegment" && vec_inter[0].Vol!=
"tCoreLog"){
158 it_is_survival =
true;
162 double delta_sigma = 0.0;
163 double ratio_sigma = 0.0;
169 double mcval = (dtH->
hXS_prtC)->GetBinContent(binpartC);
171 std::cout<<
"This seems especial cases in which the proton interact before the target (Air?). we need to investigate it."<<
" Inc_P "<<vec_inter[0].Inc_P<<
std::endl;
174 ratio_sigma = delta_sigma / mcval;
175 delta_sigma -= mcval;
180 double endZ = (vec_inter[0].Vtx)[2];
185 if(vec_inter[0].Vol==
"BudalMonitor"){
186 if(endZ<startZ || endZ>(startZ+2.0))std::cout<<
"Potential error of BudalMonitor=> startZ, endZ: "<<startZ<<
" "<<endZ<<
std::endl;
188 if((mode==
"OPT")||(mode==
"REF")){
189 if(vec_inter[0].Vol==
"TargetFinHorizontal"){
190 if(endZ<startZ || endZ>(startZ+2.0))std::cout<<
"Potential error of BudalMonitor=> startZ, endZ: "<<startZ<<
" "<<endZ<<
std::endl;
198 if(vec_inter[0].Vol==
"Budal_HFVS"){
199 if(endZ<startZ || endZ>(startZ+2.4))std::cout<<
"Potential error of Budal_HFVS => startZ, endZ: "<<startZ<<
" "<<endZ<<
std::endl;
204 if(totmatZ<0)totmatZ=0;
206 totmatZ *= avog_x_mb2cm2;
207 totmatZ /= graphite_A;
208 totmatZ *= graphite_density;
212 if(there_is_MIPP && domipp){
213 int nbins = hzpos->GetXaxis()->GetNbins();
214 double integral_mc = 0;
215 double integral_wt = 0;
216 for(
int ib=1;ib<=
nbins;ib++){
217 double cont = hzpos->GetBinContent(ib);
218 double crr = hzpos->GetXaxis()->GetBinCenter(ib);
220 integral_wt += cont*ratio_sigma*exp(-1.0*crr*avog_x_mb2cm2*graphite_density*delta_sigma/graphite_A);
222 if(integral_wt<=0 || integral_mc<=0){
223 throw std::runtime_error(
"yield is zero or negative... check!");
225 norm = integral_mc/integral_wt;
229 double wgt_pri = 1.0;
232 wgt_pri = exp(-1.0*totmatZ*delta_sigma);
235 wgt_pri = norm*ratio_sigma*exp(-1.0*totmatZ*delta_sigma);
239 double wgt_sec = 1.0;
241 for(
size_t ii=1;ii<vec_inter.size();ii++){
242 bool starts_tgt = vec_inter[ii-1].Vol ==
"BudalMonitor" || vec_inter[ii-1].Vol ==
"TGT1" || vec_inter[ii-1].Vol ==
"Budal_HFVS" || vec_inter[ii-1].Vol ==
"Budal_VFHS";
243 if((mode==
"REF")||(mode==
"OPT")){
244 starts_tgt = vec_inter[ii-1].Vol ==
"TargetFinHorizontal" || vec_inter[ii-1].Vol ==
"TargetNoSplitSegment"|| vec_inter[ii-1].Vol ==
"tCoreLog";
246 if(!starts_tgt)
continue;
247 bool ends_tgt = vec_inter[ii].Vol ==
"BudalMonitor" || vec_inter[ii].Vol ==
"TGT1" || vec_inter[ii].Vol ==
"Budal_HFVS" || vec_inter[ii].Vol ==
"Budal_VFHS";
248 if((mode==
"REF")||(mode==
"OPT")){
249 ends_tgt = vec_inter[ii].Vol ==
"TargetFinHorizontal" || vec_inter[ii].Vol ==
"TargetNoSplitSegment" || vec_inter[ii].Vol ==
"tCoreLog";
253 double fact_int = 1.0;
256 if(vec_inter[ii].Inc_pdg==2212){
257 dsigma = delta_sigma;
259 mcval = (dtH->
hXS_prtC)->GetBinContent(binpartC);
260 fact_int = (dsigma+mcval)/mcval;
262 else if(vec_inter[ii].Inc_pdg==211 || vec_inter[ii].Inc_pdg==-211){
265 mcval = (dtH->
hXS_piC)->GetBinContent(binpartC);
266 fact_int = (dsigma+mcval)/mcval;
268 else if(vec_inter[ii].Inc_pdg == 321){
272 mcval = (dtH->
hXS_kapC)->GetBinContent(binpartC);
273 fact_int = (dsigma+mcval)/mcval;
275 else if(vec_inter[ii].Inc_pdg ==-321){
279 mcval = (dtH->
hXS_kamC)->GetBinContent(binpartC);
280 fact_int = (dsigma+mcval)/mcval;
282 else if(totmatZ<1.
e-12){
290 mcval = (dtH->
hXS_kapC)->GetBinContent(binpartC);
291 fact_int = (dsigma+mcval)/mcval;
301 double zi = (vec_inter[ii-1].Vtx)[2];
304 zf = (vec_inter[ii].Vtx)[2];
308 double startpart[3] = {(vec_inter[ii-1].Vtx)[0],(vec_inter[ii-1].Vtx)[1],(vec_inter[ii-1].Vtx)[2]};
309 double momtar[3] = {tar.
Px,tar.
Py,tar.
Pz};
320 totmatZ *= avog_x_mb2cm2;
321 totmatZ /= graphite_A;
322 totmatZ *= graphite_density;
323 wgt_sec *= fact*exp(-1.0*totmatZ*dsigma);
324 if(isinf(wgt_sec))std::cout<<
"BAD "<<zi<<
" "<<zf<<
" "<<totmatZ<<
" "<<startZ<<
330 return wgt = wgt_pri*wgt_sec;
342 if(mode==
"OPT")z0=0.0;
343 if(mode==
"REF")z0=-64.7002;
345 }
else if(
isME(tgtcfg) ){
350 throw std::runtime_error(
"cannot determine if it's LE or ME beam");
354 for (
size_t i=0; i<tgtcfg.length(); ++i) {
355 if(isdigit(tgtcfg[i])) just_nums.push_back(tgtcfg[i]);
356 if(tgtcfg[i]==
'z')
break;
359 double dz=atof(just_nums.c_str());
365 return (tgtcfg.find(
"LE")==0)|| (tgtcfg.find(
"le")==0) || (tgtcfg.find(
"Le")==0);
370 return (tgtcfg.find(
"ME")==0) || (tgtcfg.find(
"me")==0) || (tgtcfg.find(
"Me")==0);
377 double shift_for_playlist = 0;
379 shift_for_playlist = 0.;
381 else if( ipl == 0 || ipl == 1 ){
382 shift_for_playlist = 0.50;
384 else if( ipl == 7 || ipl == 10 || ipl == 6 ){
385 shift_for_playlist = 0.82;
388 shift_for_playlist = -0.40;
391 shift_for_playlist = 0.83;
394 shift_for_playlist = 1.15;
396 else if( ipl == 2 || ipl == 3 ){
397 shift_for_playlist = 0.43;
399 else if( ipl == 11 || ipl == 12 ){
400 shift_for_playlist = 0.83;
403 shift_for_playlist = 0.43;
406 shift_for_playlist = - 0.09;
409 return shift_for_playlist;
428 const double us_edges[nfins]={25.4484, 42.1683, 44.1983, 46.2283, 48.2583,
429 50.2883, 52.3183, 54.3483, 56.3783,
430 58.4083, 60.4383, 62.4683, 64.4983,
431 66.5283, 68.5583, 70.5883, 72.6183,
432 74.6483, 76.6783, 78.7083, 80.7383,
433 82.7683, 84.7983, 86.8283, 88.8583,
434 90.8883, 92.9183, 94.9483, 96.9783,
435 99.0083, 101.0383, 103.0683, 105.0983,
436 107.1283, 109.1583, 111.1883, 113.2183,
437 115.2483, 117.2783, 119.3083, 121.3383,
438 123.3683, 125.3983, 127.4283, 129.4583,
439 131.4883, 133.5183, 135.5483};
440 const int nfins_ref=49;
442 const double us_edges_ref[nfins_ref]={-64.7002,-46.9176,-44.8909, -42.8609, -40.8309, -38.8009, -36.7709,
443 -34.7409, -32.7109, -30.6809, -28.6509, -26.6209, -24.5909,
444 -22.5609, -20.5309, -18.5009, -16.4709, -14.4409, -12.4109, -10.3809, -8.3509, -6.3209,
445 -4.2909, -2.2609, -0.2309, 1.7991, 3.8291, 5.8591, 7.8891, 9.9191, 11.9491, 13.9791, 16.0091,
446 18.0391, 20.0691, 22.0991, 24.1291, 26.1591, 28.1891, 30.2191,
447 32.2491, 34.2791, 36.3091, 38.3391, 40.3691, 42.3991, 44.4291, 46.4591, 48.4891};
449 const int nfins_opt = 119;
450 const double us_edges_opt[nfins_opt] = {-27.3347,-0.0054, 4.0917, 6.0876, 8.1176, 10.1476, 12.1776, 14.2076, 16.2376, 18.2676, 20.2976, 22.3276, 24.3576, 26.3876, 28.4176, 30.4476, 32.4776, 34.5076, 36.5376, 38.5676, 40.5976,
451 42.6276, 44.6576, 46.6876, 48.7176, 50.7476, 52.7776, 54.8076, 56.8376, 58.8676, 60.8976, 62.9276, 64.9576, 66.9876, 69.0176, 71.0476, 73.0776, 75.1076, 77.1376, 79.1676, 81.1976,
452 83.2276, 85.2576, 87.2876, 89.3176, 91.3476, 93.3776, 95.4076, 97.4376, 99.4676, 101.498, 103.528, 105.558, 107.588, 109.618, 111.648, 113.678, 115.708, 117.738, 119.768, 121.798,
453 123.828, 125.858, 127.888, 129.918, 131.948, 133.978, 136.008, 138.038, 140.068, 142.098, 144.128, 146.158, 148.188, 150.218, 152.248, 154.278, 156.308, 158.338, 160.368, 162.398,
454 164.428, 166.458, 168.488, 170.518, 172.548, 174.578, 176.608, 178.638, 180.668, 182.698, 184.728, 186.758, 188.788, 190.818, 192.848, 194.878, 196.908, 198.938, 200.968, 202.998,
455 205.028, 207.058, 209.088, 211.118, 213.148, 215.178, 217.208, 219.238, 221.268, 223.298, 225.328, 227.358, 229.388,
456 231.418, 233.448, 235.478, 237.508};
462 std::vector<double> vus_edges;
463 for(
int i = 0;i<nfins;i++){
464 vus_edges.push_back(us_edges[i]);
468 for(
int i = 0;i<nfins_ref-1;i++){
469 vus_edges.push_back(us_edges_ref[i]);
474 for(
int i = 0;i<nfins_opt;i++){
475 vus_edges.push_back(us_edges_opt[i]);
479 const double budal_us_edge=vus_edges.at(0);
480 double fin_width=2.0;
482 if(mode==
"OPT")fin_width = 1.95;
483 if(mode==
"REF")fin_width = 2.02;
487 const double z_trans=z0_budal - budal_us_edge;
499 double mat_start=0.0;
500 double mat_end = 0.0;
502 for(
unsigned int ifin=0; ifin<vus_edges.size(); ifin++){
503 const double fin_us_edge=vus_edges.at(ifin)+z_trans;
504 const double fin_ds_edge=fin_us_edge+fin_width;
505 if(z_start<=fin_us_edge)
break;
506 else if(z_start<fin_ds_edge){
507 mat_start+=(z_start-fin_us_edge);
511 mat_start+=fin_width;
517 for(
unsigned int ifin=0; ifin<vus_edges.size(); ifin++){
518 const double fin_us_edge=vus_edges.at(ifin)+z_trans;
519 const double fin_ds_edge=fin_us_edge+fin_width;
520 if(z_end<=fin_us_edge)
break;
521 else if(z_end<fin_ds_edge){
522 mat_end+=(z_end-fin_us_edge);
531 double mat_traversed=mat_end-mat_start;
535 return mat_traversed;
554 const double us_edges[nfins]={ 19.285, 22.185, 25.035, 27.485,
555 29.935, 32.385, 34.835, 37.285,
556 39.735, 42.185, 44.635, 47.085,
557 49.535, 51.985, 54.435, 56.885,
558 59.335, 61.785, 64.235, 66.685,
559 69.135, 71.585, 74.035, 76.485,
560 78.935, 81.385, 83.835, 86.285,
561 88.735, 91.185, 93.635, 96.085,
562 98.535, 100.985, 103.435, 105.885,
563 108.335, 110.785, 113.235, 115.685,
564 118.135, 120.585, 123.035, 125.485,
565 127.935, 130.385, 132.835, 135.285,
568 const double ds_edges[nfins]={21.685, 24.585, 27.435, 29.885,
569 32.335, 34.785, 37.235, 39.685,
570 42.135, 44.585, 47.035, 49.485,
571 51.935, 54.385, 56.835, 59.285,
572 61.735, 64.185, 66.635, 69.085,
573 71.535, 73.985, 76.435, 78.885,
574 81.335, 83.785, 86.235, 88.685,
575 91.135, 93.585, 96.035, 98.485,
576 100.935, 103.385, 105.835, 108.285,
577 110.735, 113.185, 115.635, 118.085,
578 120.535, 122.985, 125.435, 127.885,
579 130.335, 132.785, 135.235, 137.685,
584 const double budal_us_edge=us_edges[0];
588 const double z_trans=z0_budal - budal_us_edge;
599 double mat_start=0.0;
600 for(
int ifin=0; ifin<nfins; ifin++){
601 const double fin_us_edge=us_edges[ifin]+z_trans;
602 const double fin_ds_edge=ds_edges[ifin]+z_trans;
603 if(z_start<=fin_us_edge)
break;
604 else if(z_start<fin_ds_edge){
605 mat_start+=(z_start-fin_us_edge);
609 mat_start+=(fin_ds_edge-fin_us_edge);
615 for(
int ifin=0; ifin<nfins; ifin++){
616 const double fin_us_edge=us_edges[ifin]+z_trans;
617 const double fin_ds_edge=ds_edges[ifin]+z_trans;
618 if(z_end<=fin_us_edge)
break;
619 else if(z_end<fin_ds_edge){
620 mat_end+=(z_end-fin_us_edge);
624 mat_end+=(fin_ds_edge-fin_us_edge);
627 double mat_traversed=mat_end-mat_start;
630 return mat_traversed;
664 double mx = mom_start[0]/mom_start[2];
665 if(mx>0)shift = (a-pos_start[0])/mx;
666 else shift = (-1.*a-pos_start[0])/mx;
667 double z_usingx = pos_start[2] + shift;
670 double my = mom_start[1]/mom_start[2];
672 if(leflag)shift = (b-pos_start[1])/my;
673 if(meflag)shift = (a-pos_start[1])/my;
676 shift = (-1.*b-pos_start[1])/my;
678 double z_usingy = pos_start[2] + shift;
682 double zout = z_usingx;
683 if(z_usingy<z_usingx)zout = z_usingy;
690 #if defined __clang__ 691 #elif defined __GNUC__ 692 #pragma GCC diagnostic pop
A list/table of parameter names and values.
std::vector< TH1D * > hzpostgt_kam_le
float delta_sigma_kapC_xsec_lowP
static bool isLE(const std::string &tgtcfg)
does the configuration correspond to the LE beam?
A class to make the reweight event by event.
std::vector< TH1D * > hzpostgt_pip_le
Information about the chain of interactions leading to a neutrino.
static MakeReweight * getInstance()
static double shiftPlaylist(const int ipl)
Get the additional shift for the Minerva playlist if this is defined.
double getParameterValue(const std::string &name) const
get the value of a parameter. throw an exception of a well defined type if we don't have it ...
std::vector< InteractionData > interaction_chain
vector of neutrino ancestors
std::vector< TH1D * > hzpostgt_kam_me
static double getZTgtExit(double pos_start[], double mom_start[], bool leflag, bool meflag)
int FindBin(double value, std::vector< double > binning)
const ParameterTable & univPars
static double getTargetPenetrationLE(double z_start, double z_end, double z0_budal)
virtual ~TargetAttenuationReweighter()
float delta_sigma_piC_xsec
int Tar_pdg
pdg code of the particle
std::vector< TH1D * > hzpostgt_pim_me
float delta_sigma_kapC_xsec_highP
static double targetStartZ(const std::string &tgtcfg)
float delta_sigma_kamC_xsec_lowP
static bool isME(const std::string &tgtcfg)
does the configuration correspond to the ME beam?
std::vector< TH1D * > hzpostgt_pip_me
std::vector< TH1D * > hzpostgt_kap_me
std::string getenv(std::string const &name)
double Px
P_{x} (GeV/c) of the particle.
TargetAttenuationReweighter(int iuniv, const ParameterTable &cv_pars, const ParameterTable &univ_pars)
float delta_sigma_kamC_xsec_highP
std::string target_config
The target configuration. Example: le010z.
int BinID(double pz, double pt, int pdgcode)
Return the Bin ID for this data.
auto norm(Vector const &v)
Return norm of the specified vector.
std::vector< TH1D * > hzpostgt_kap_le
A class to manage the bin definitions for MIPP Numi Yields.
int playlist
The tgt playlist (exact position of the target after survey)
static AttenuationMC * getInstance()
virtual std::vector< bool > canReweight(const InteractionChainData &aa)
Look through the InteractionChainData input and identify those Interactions that can be reweighted as...
std::vector< TH1D * > hzpostgt_pim_le
static MIPPNumiYieldsBins * getInstance()
double Pt
Transversal momentum (GeV/c) of the particle.
virtual double calculateWeight(const InteractionChainData &aa)
calculate a weight for this interaction chain given the central value parameters and the parameters f...
static double getTargetPenetrationME(double z_start, double z_end, double z0_budal)
The information about the hadron that exits the target.
double Pz
Longitudinal momentum (GeV/c) of the particle.
ReweightDriver * cv_rw
Reweighter Drivers for the central value.
double Py
P_{y} (GeV/c) of the particle.
TargetData tar_info
Information about the hadron which exited the target.
QTextStream & endl(QTextStream &s)