2 #include "dk2nu/tree/dkmeta.h" 3 #include "dk2nu/tree/dk2nu.h" 20 const char*
nuhel[
Nnuhel] = {
"numu",
"numubar",
"nue",
"nuebar"};
33 void doReweight_dk2nu(
const char* inputFile,
const char* outputFile,
const char* optionsFile){
35 const char* thisDir =
getenv(
"PPFX_DIR");
36 const char* OutputDir=thisDir;
38 std::cout<<
"Instance of MakeReweight()" <<std::endl;
42 std::cout<<
"Making an output file to store histograms"<<std::endl;
43 TFile* fOut =
new TFile(outputFile,
"recreate");
44 std::cout<<
"File name: "<<fOut->GetName()<<std::endl;
47 for(
int ii=0;ii<
Nnuhel;ii++){
48 fOut->mkdir(Form(
"%s_thintarget",
nuhel[ii]));
49 fOut->mkdir(Form(
"%s_mippnumi",
nuhel[ii]));
50 fOut->mkdir(Form(
"%s_attenuation",
nuhel[ii]));
51 fOut->mkdir(Form(
"%s_others",
nuhel[ii]));
52 fOut->mkdir(Form(
"%s_total",
nuhel[ii]));
54 std::cout<<
"Done making the output file"<<std::endl;
60 TH1D* hthin[
Nnuhel][Nuniverses];
61 TH1D* hmipp[
Nnuhel][Nuniverses];
62 TH1D* hatt[
Nnuhel][Nuniverses];
63 TH1D* hothers[
Nnuhel][Nuniverses];
64 TH1D* htotal[
Nnuhel][Nuniverses];
66 for(
int ii=0;ii<
Nnuhel;ii++){
69 for(
int jj=0;jj< Nuniverses; jj++){
79 TChain* chain_evts =
new TChain(
"dk2nuTree");
80 TChain* chain_meta =
new TChain(
"dkmetaTree");
81 bsim::Dk2Nu* dk2nu =
new bsim::Dk2Nu;
82 bsim::DkMeta* dkmeta =
new bsim::DkMeta;
84 std::cout<<
" Adding ntuple at: "<<inputFile<<std::endl;
86 chain_evts->Add(inputFile);
87 chain_evts->SetBranchAddress(
"dk2nu",&dk2nu);
88 int nentries = chain_evts->GetEntries();
90 chain_meta->Add(inputFile);
91 chain_meta->SetBranchAddress(
"dkmeta",&dkmeta);
92 chain_meta->GetEntry(0);
94 std::vector<double> vwgt_mipp_pi;
95 std::vector<double> vwgt_mipp_K;
96 std::vector<double> vwgt_abs;
97 std::vector<double> vwgt_att;
98 std::vector<double> vwgt_ttpCpi;
99 std::vector<double> vwgt_ttpCk;
100 std::vector<double> vwgt_ttnCpi;
101 std::vector<double> vwgt_ttpCnu;
102 std::vector<double> vwgt_ttnua;
103 std::vector<double> vwgt_ttmesinc;
104 std::vector<double> vwgt_oth;
106 std::cout<<
"N of entries: "<<nentries<<std::endl;
108 for(
int ii=0;ii<nentries;ii++){
109 if(ii%1000==0)
std::cout<<ii/1000<<
" k evts"<<std::endl;
110 vwgt_mipp_pi.clear();
118 vwgt_ttmesinc.clear();
122 chain_evts->GetEntry(ii);
125 double fluxWGT = ( (dk2nu->nuray)[1].wgt )*(dk2nu->decay.nimpwt)/3.1416;
126 int nuidx =
idx_hel(dk2nu->decay.ntype);
127 double nuenergy = (dk2nu->nuray)[1].
E;
130 std::cout<<
"=> Wrong neutrino file"<<std::endl;
132 hnom[nuidx]->Fill(nuenergy,fluxWGT);
133 hcv[nuidx]->Fill(nuenergy,fluxWGT*makerew->
GetCVWeight());
135 vwgt_mipp_pi = makerew->
GetWeights(
"MIPPNumiPionYields");
136 vwgt_mipp_K = makerew->
GetWeights(
"MIPPNumiKaonYields");
137 vwgt_abs = makerew->
GetWeights(
"TotalAbsorption");
138 vwgt_att = makerew->
GetWeights(
"TargetAttenuation");
139 vwgt_ttpCpi = makerew->
GetWeights(
"ThinTargetpCPion");
140 vwgt_ttpCk = makerew->
GetWeights(
"ThinTargetpCKaon");
141 vwgt_ttnCpi = makerew->
GetWeights(
"ThinTargetnCPion");
142 vwgt_ttpCnu = makerew->
GetWeights(
"ThinTargetpCNucleon");
143 vwgt_ttmesinc= makerew->
GetWeights(
"ThinTargetMesonIncident");
144 vwgt_ttnua = makerew->
GetWeights(
"ThinTargetnucleonA");
148 for(
int jj=0;jj<Nuniverses;jj++){
149 double wgt_thin = vwgt_ttpCpi[jj]*vwgt_ttpCk[jj]*vwgt_ttnCpi[jj]*vwgt_ttpCnu[jj]*vwgt_ttmesinc[jj]*vwgt_ttnua[jj];
150 double wgt_mipp = vwgt_mipp_pi[jj]*vwgt_mipp_K[jj];
151 double wgt_att = vwgt_att[jj]*vwgt_abs[jj];
152 hthin[nuidx][jj]->Fill(nuenergy,fluxWGT*wgt_thin);
153 hmipp[nuidx][jj]->Fill(nuenergy,fluxWGT*wgt_mipp);
154 hatt[nuidx][jj]->Fill(nuenergy,fluxWGT*wgt_att);
155 hothers[nuidx][jj]->Fill(nuenergy,fluxWGT*vwgt_oth[jj]);
156 htotal[nuidx][jj]->Fill(nuenergy,fluxWGT*wgt_thin*wgt_mipp*wgt_att*vwgt_oth[jj]);
161 std::cout<<
"storing general histos"<<std::endl;
163 for(
int ii=0;ii<
Nnuhel;ii++){
167 for(
int jj=0;jj< Nuniverses; jj++){
168 fOut->cd(Form(
"%s_thintarget",
nuhel[ii])); hthin[ii][jj]->Write();
169 fOut->cd(Form(
"%s_mippnumi",
nuhel[ii])); hmipp[ii][jj]->Write();
170 fOut->cd(Form(
"%s_attenuation",
nuhel[ii])); hatt[ii][jj]->Write();
171 fOut->cd(Form(
"%s_others",
nuhel[ii])); hothers[ii][jj]->Write();
172 fOut->cd(Form(
"%s_total",
nuhel[ii])); htotal[ii][jj]->Write();
185 if(pdgcode == 14)idx = 0;
186 if(pdgcode == -14)idx = 1;
187 if(pdgcode == 12)idx = 2;
188 if(pdgcode == -12)idx = 3;
195 int main(
int argc,
const char* argv[]){
const char * nuhel[Nnuhel]
int idx_hel(int pdgdcode)
std::vector< double > GetWeights(std::string nameReweighter)
get the vector of the weights for a given reweighter
A class to make the reweight event by event.
double GetCVWeight()
get the cv weights
static MakeReweight * getInstance()
void doReweight_dk2nu(const char *inputFile, const char *outputFile, const char *optionsFile)
the ParameterSet object passed in for the configuration of a destination should be the only source that can affect the behavior of that destination This is to eliminate the dependencies of configuring a destination from multiple mostly from the defaults It suppresses possible glitches about changing the configuration file somewhere outside of a destination segament might still affect the behavior of that destination In the previous configuration for a specific the value of a certain e may come from following and have been suppressed It the configuring ParameterSet object for each destination will be required to carry a parameter list as complete as possible If a parameter still cannot be found in the ParameterSet the configuration code will go look for a hardwired default directly The model is a great simplicity comparing with the previous especially when looking for default values Another great advantage is most of the parameters now have very limited places that allows to appear Usually they can only appear at one certain level in a configuration file For in the old configuring model or in a default ParameterSet object inside of a or in a category or in a severity object This layout of multiple sources for a single parameter brings great confusion in both writing a configuration and in processing the configuration file Under the new the only allowed place for the parameter limit to appear is inside of a category which is inside of a destination object Other improvements simplify the meaning of a destination name In the old a destination name has multiple folds of meanings the e cout and cerr have the special meaning of logging messages to standard output or standard error the name also serves as the output filename if the destination is a file these names are also references to look up for detailed configurations in configuring the MessageFacility The multi purpose of the destination name might cause some unwanted behavior in either writing or parsing the configuration file To amend in the new model the destination name is now merely a name for a which might represent the literal purpose of this or just an id All other meanings of the destinations names now go into the destination ParameterSet as individual such as the type parameter and filename parameter Following is the deatiled rule for the new configuring Everything that is related with MessageFacility configuration must be wrapped in a single ParameterSet object with the name MessageFacility The MessageFacility ParameterSet object contains a series of top level parameters These parameters can be chosen a vector of string listing the name of debug enabled models Or use *to enable debug messages in all modules a vector of string a vector of string a vector of string a ParameterSet object containing the list of all destinations The destinations ParameterSet object is a combination of ParameterSet objects for individual destinations There are two types of destinations that you can insert in the destinations ParameterSet ordinary including cout
int main(int argc, const char *argv[])
std::string getenv(std::string const &name)
int GetNumberOfUniversesUsed()
number of universes used in this run
static void resetInstance()
void calculateWeights(nu_g4numi *nu, const char *tgtcfg, const char *horncfg)
void SetOptions(std::string fileIn)