13 #include "nutools/NuBeamWeights/skzpReweight.h" 21 fFPar.push_back(1.56);
22 fFPar.push_back(-6.42);
23 fFPar.push_back(1.11);
24 fFPar.push_back(0.13);
25 fFPar.push_back(1.00);
26 fFPar.push_back(1.25);
27 fFPar.push_back(3.50);
28 fFPar.push_back(4.83);
29 fFPar.push_back(1.51);
30 fFPar.push_back(0.29);
31 fFPar.push_back(0.97);
32 fFPar.push_back(2.16);
33 fFPar.push_back(1.04);
34 fFPar.push_back(-0.89);
35 fFPar.push_back(0.88);
36 fFPar.push_back(0.05);
38 fBPar.push_back(-3.85);
39 fBPar.push_back(1.39);
56 delete fPTPZ[*itPlist];
82 if (xF>1.||xF<0.)
return weight;
83 if (pT>1.||pT<0.)
return weight;
93 A=-0.00761*
pow((1.-xF),4.045)*(1.+9620.*xF)*
pow(xF,-2.975);
94 B=0.05465*
pow((1.-xF),2.675)*(1.+69590.*xF)*
pow(xF,-3.144);
97 C=-7.058/
pow(xF,-0.1419)+9.188;
99 C = (3.008/exp((xF-0.1984)*3.577)) + 2.616*xF+0.1225;
106 weight=(Ap+Bp*pT)/(A+B*pT)*exp(-(Cp-C)*
pow(pT,3./2.));
118 A=-0.005187*
pow((1.-xF),4.119)*(1.+2170.*xF)*
pow(xF,-2.767);
119 B=0.4918*
pow((1.-xF),2.672)*(1.+1373.*xF)*
pow(xF,-2.927);
122 C=-16.10/
pow(xF,-0.04582)+17.92;
124 C = (6.905/exp((xF+0.163)*6.718)) - 0.4257*xF + 2.486;
131 weight=(Ap+Bp*pT)/(A+B*pT)*exp(-(Cp-C)*
pow(pT,3./2.));
141 if (weight>10.) weight=10.;
153 TFile* hFile=
new TFile(
fFpath.c_str());
163 TH2F*
hist=dynamic_cast <TH2F*> (hFile->Get(Form(
"hF05ptxf%s",
PartEnumToString(*itPlist).c_str()))->Clone());
164 hist->SetDirectory(0);
165 TH2F* hist2=dynamic_cast <TH2F*> (hist->Clone(Form(
"hWeightedPTXF%s",
PartEnumToString(*itPlist).c_str())));
166 hist2->SetDirectory(0);
167 hist2->SetTitle(Form(
"%s weighted pt-pz",
PartEnumToString(*itPlist).c_str()));
173 std::pair<Conventions::ParticleType_t, TH2F* >
p(*itPlist, hist);
174 std::pair<Conventions::ParticleType_t, TH2F* > p2(*itPlist, hist2);
178 fPTPZ[*itPlist]->SetDirectory(0);
181 fMeanPT[*itPlist]=
fPTPZ[*itPlist]->ProjectionY()->GetMean()*1000.;
184 double N=
fPTPZ[*itPlist]->ProjectionY()->GetSumOfWeights();
185 double wN=
fWeightedPTPZ[*itPlist]->ProjectionY()->GetSumOfWeights();
199 for (
int i=0;i<
fPTPZ[*itPlist]->GetNbinsX()+1;i++)
201 for (
int j=0;j<
fPTPZ[*itPlist]->GetNbinsY()+1;j++)
203 pz=
fPTPZ[*itPlist]->GetXaxis()->GetBinCenter(i);
204 pt=
fPTPZ[*itPlist]->GetYaxis()->GetBinCenter(j);
225 if (ntype == 14) ntype = 56;
226 else if (ntype == -14) ntype = 55;
227 else if (ntype == 12) ntype = 53;
228 else if (ntype == -12) ntype = 52;
235 for(
int sys = 1; sys <= 2; ++sys){
242 if(EnDex->first > Enu){
258 bool FoundHist =
false;
259 TDirectory *
save = gDirectory;
266 int ntype[] ={ 56, 55 , 53 , 52};
267 for (
int inu = 0; inu < 4; ++inu) {
283 TH1F* hist2=
dynamic_cast<TH1F*
> (
fBeamSysFile->Get(hname.c_str()));
297 std::cout<<
"No histograms found in " <<
fBpath <<
" with name formatted as expected by flag: " <<
fBflag <<
std::endl;
311 std::string nus[]={
"NuMu",
"NuMuBar",
"NuE",
"NuEBar"};
337 for (
int i=1; i<=hist->GetNbinsX();i++)
339 EnDex+=hist->GetBinWidth(i);
340 wmap.insert(WeightMap_t::value_type(EnDex,hist->GetBinContent(i)));
342 fBeamSysMap.insert(std::map<mapkey, WeightMap_t, LessThan >::value_type(dex, wmap));
345 std::cout <<
"Already loaded this histogram!" <<
std::endl;
365 for (
int i=1; i<hist->GetNbinsX()+1;i++)
367 EnDex+=hist->GetBinWidth(i);
368 wmap.insert(WeightMap_t::value_type(EnDex,hist->GetBinContent(i)));
370 fBeamSysMap.insert(std::map<mapkey, WeightMap_t, LessThan >::value_type(dex, wmap));
373 std::cout <<
"Already loaded this histogram!" <<
std::endl;
408 default :
return "Unknown";
break;
422 default :
return "Unknown";
break;
444 default :
return "Unknown";
break;
461 default :
return "Unknown";
break;
477 default :
return "Unknown";
break;
492 default :
return "Unknown";
break;
std::map< Conventions::ParticleType_t, int > fNBinsY
std::vector< double > fFPar
std::map< Conventions::ParticleType_t, double > fN
std::map< Conventions::ParticleType_t, int > fNBinsX
enum nbw::Conventions::EDetType DetType_t
std::vector< Conventions::ParticleType_t > fPlist
std::map< Conventions::ParticleType_t, double > fNWeighted
enum nbw::Conventions::EParticleType ParticleType_t
std::string GetHname(int inu, int eff, int beam, int det)
std::string BeamTypeToString(Conventions::BeamType_t btype)
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
double GetBeamWeight(int ntype, double Enu, int det=1, int beam=2)
std::map< mapkey, WeightMap_t, LessThan > fBeamSysMap
enum nbw::Conventions::EBeamType BeamType_t
std::map< Conventions::ParticleType_t, TH2F * > fWeightedPTPZ
std::map< Conventions::ParticleType_t, TH2F * > fPTPZ
std::map< Conventions::ParticleType_t, TH2F * > fWeightHist
skzpReweight(std::string fpath="/nova/data/flux/SKZPdata/fluka05ptxf.root", std::string bpath="/nova/data/flux/SKZPdata/IPNDhists.root", int flag=2)
void FillVector(TH1D *hist, int ntype, int eff, int beam, int det)
enum nbw::Conventions::EBeamSys BeamSys_t
std::map< Conventions::ParticleType_t, double > fWeightedMeanPT
std::map< double, double > WeightMap_t
std::string PartEnumToString(Conventions::ParticleType_t ptype)
double GetFlukWeight(const simb::MCFlux *mcf)
std::string BeamSysToString(Conventions::BeamSys_t bstype)
reweighting utility for NuMI beam
std::map< Conventions::ParticleType_t, double > fMeanPT
std::string DetTypeToString(Conventions::DetType_t dtype)
std::vector< double > fBPar
Conventions::ParticleType_t GeantToEnum(int ptype)
QTextStream & endl(QTextStream &s)