124 using std::ostringstream;
126 using namespace genie;
131 void GetEventRange (Long64_t nev_in_file, Long64_t & nfirst, Long64_t & nlast);
157 tree = dynamic_cast <TTree *> ( file.Get(
"gtree") );
159 LOG(
"grwght1scan",
pNOTICE) <<
"Input tree header: " << *thdr;
162 <<
"Can't find a GHEP tree in input file: "<< file.GetName();
168 tree->SetBranchAddress(
"gmcrec", &mcrec);
170 Long64_t nev_in_file = tree->GetEntries();
177 const float twk_dial_step = (twk_dial_max - twk_dial_min) / (n_points-1);
184 Long64_t nev = (nlast - nfirst + 1);
192 <<
"\n** grwght1scan: Will start processing events promptly." 193 <<
"\nHere is a summary of inputs: " 195 <<
"\n - Processing: " << nev <<
" events in the range [" << nfirst <<
", " << nlast <<
"]" 198 <<
"\n - Neutrino species to reweight : " <<
gOptNu 200 <<
"\n - Specified random number seed : " <<
gOptRanSeed 205 const int n_events = (
const int) nev;
206 float weights [n_events][n_points];
207 float twkdials [n_events][n_points];
267 for(
int ith_dial = 0; ith_dial < n_points; ith_dial++){
270 double twk_dial = twk_dial_min + ith_dial * twk_dial_step;
273 <<
" - Setting tweaking dial to: " << twk_dial;
274 syst.
Set(gOptSyst, twk_dial);
278 for(
int iev = nfirst; iev <= nlast; iev++) {
282 <<
"***** Currently at event number: "<< iev;
288 LOG(
"grwght1scan",
pINFO) <<
"Event: " << iev <<
"\n" <<
event;
291 int idx = iev - nfirst;
292 weights [idx][ith_dial] = -99999.0;
293 twkdials [idx][ith_dial] = twk_dial;
296 int nupdg =
event.Probe()->Pdg();
307 <<
"Overall weight = " << wght;
308 weights[idx][ith_dial] = wght;
326 TTree * wght_tree =
new TTree(
GSyst::AsString(gOptSyst).c_str(),
"GENIE weights tree");
327 int branch_eventnum = 0;
328 TArrayF * branch_weight_array =
new TArrayF(n_points);
329 TArrayF * branch_twkdials_array =
new TArrayF(n_points);
330 wght_tree->Branch(
"eventnum", &branch_eventnum);
331 wght_tree->Branch(
"weights", &branch_weight_array);
332 wght_tree->Branch(
"twkdials", &branch_twkdials_array);
334 for(
int iev = nfirst; iev <= nlast; iev++) {
335 int idx = iev - nfirst;
336 branch_eventnum = iev;
337 for(
int ith_dial = 0; ith_dial < n_points; ith_dial++){
339 <<
"Filling tree with wght = " << weights[idx][ith_dial]
340 <<
", twk dial = "<< twkdials[idx][ith_dial];
341 branch_weight_array -> AddAt (weights [idx][ith_dial], ith_dial);
342 branch_twkdials_array -> AddAt (twkdials[idx][ith_dial], ith_dial);
361 <<
"*** Parsing command line arguments";
363 LOG(
"grwght1scan",
pINFO) <<
"Parsing command line arguments";
374 LOG(
"grwght1scan",
pINFO) <<
"Reading event sample filename";
378 <<
"Unspecified input filename - Exiting";
387 LOG(
"grwght1scan",
pINFO) <<
"Reading number of events to analyze";
389 if (nev.find(
",") != string::npos) {
392 LOG(
"grwght1scan",
pFATAL) <<
"Invalid syntax";
409 <<
"Unspecified number of events to analyze - Use all";
419 <<
"Reading number of tweak dial values";
428 <<
"Specified number of tweak dial is too low, min value is 3 - Exiting";
435 <<
"Unspecified number of tweak dials - Exiting";
444 <<
"Reading input systematic parameter";
448 LOG(
"grwght1scan",
pFATAL) <<
"Unknown systematic: " << systematic;
455 <<
"You need to specify a systematic param using -s";
463 LOG(
"grwght1scan",
pINFO) <<
"Reading requested output filename";
466 LOG(
"grwght1scan",
pINFO) <<
"Setting default output filename";
475 <<
"Reading input list of neutrino codes";
477 if(vecpdg.size()==0) {
479 <<
"Empty list of neutrino codes!?";
485 for( ; it!=vecpdg.end(); ++it) {
490 <<
"Considering all neutrino species";
501 LOG(
"grwght1scan",
pINFO) <<
"Reading random number seed";
504 LOG(
"grwght1scan",
pINFO) <<
"Unspecified random number seed - Using default";
522 void GetEventRange(Long64_t nev_in_file, Long64_t & nfirst, Long64_t & nlast)
532 nlast = TMath::Min(nev_in_file-1,
gOptNEvt2);
535 if(gOptNEvt1<0 && gOptNEvt2>=0) {
540 nlast = TMath::Min(nev_in_file-1,
gOptNEvt2-1);
546 nlast = nev_in_file-1;
549 assert(nfirst < nlast && nfirst >= 0 && nlast <= nev_in_file-1);
557 <<
" -f input_event_file \n" 558 <<
" [-n n1[,n2]] \n" 559 <<
" -s systematic \n" 560 <<
" -t n_twk_diall_values \n" 561 <<
" [--min-tweak minimum_tweak_value] \n" 562 <<
" [--max-tweak maximum_tweak_value] \n" 563 <<
" [-p neutrino_codes] \n" 564 <<
" [-o output_weights_file] \n" 565 <<
" [--seed random_number_seed] \n" 566 <<
" [--message-thresholds xml_file]\n" 567 <<
" [--event-record-print-level level]\n\n\n" 568 <<
" See the GENIE Physics and User manual for more details";
Reweighting GENIE DIS neutrino-nucleus cross sections.
void RandGen(long int seed)
static void SetPrintLevel(int print_level)
tweak Mv CCRES, affects d2sigma(CCRES)/dWdQ2 both in shape and normalization
double ArgAsDouble(char opt)
string gOptOutFilename
name for output file (contains the output weight tree)
string ArgAsString(char opt)
#include "Numerical/GSFunc.h"
MINOS-style ntuple record. Each such ntuple record holds a generated EventRecord object. Ntuples of this type are intended for feeding GENIE events into other applications (for example the GEANT4 based MC generation framework of an experiment) if no direct interface exists.
void ReadFromCommandLine(int argc, char **argv)
Reweighting the GENIE AGKY (free-nucleon) hadronization model.
Reweighting CCQE GENIE neutrino cross sections.
long int gOptRanSeed
random number seed
void GetEventRange(Long64_t nev_in_file, Long64_t &nfirst, Long64_t &nlast)
vector< long > ArgAsLongTokens(char opt, string delimeter)
tweak the Bodek-Yang model parameter B_{ht} - shape only effect to d2sigma(DIS)/dxdy ...
Reweighting NCEL GENIE neutrino cross sections.
Reweight GENIE NC resonance neutrino-production cross section. Basically a clone of the corresponding...
bool ExistsInPDGCodeList(int pdg_code) const
void Reconfigure(void)
reconfigure weight calculators with new params
int main(int argc, char **argv)
GReWeightI * WghtCalc(string name)
access a weight calculator by name
void Set(GSyst_t syst, double current_value)
static const int kModeMaMv
Reweighting vector form factors in GENIE CCQE neutrino cross section calculations.
static GSyst_t FromString(string syst)
static const int kModeABCV12uShape
void Init(GSyst_t syst, double init=0., double min=-1., double max=+1., double step=0.05)
Long64_t gOptNEvt2
range of events to process (2nd input, if any)
Reweighting vector form factors in GENIE CCQE neutrino cross section calculations.
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Reweighting the Fermi Gas nuclear model.
GSyst_t gOptSyst
input systematic param
Reweighting the formation zone model.
An enumeration of systematic parameters.
double gOptMinTwk
Minimum value of tweaked dial.
void AdoptWghtCalc(string name, GReWeightI *wcalc)
add concrete weight calculator, transfers ownership
static const int kModeMaMv
PDGCodeList gOptNu(false)
neutrinos to consider
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
void GetCommandLineArgs(int argc, char **argv)
tweak Mv NCRES, affects d2sigma(NCRES)/dWdQ2 both in shape and normalization
tweak the Bodek-Yang model parameter A_{ht} - shape only effect to d2sigma(DIS)/dxdy ...
static RunOpt * Instance(void)
tweak Ma CCRES, affects d2sigma(CCRES)/dWdQ2 both in shape and normalization
Reweighting the DIS nuclear modification model.
string gOptInpFilename
name for input file (contains input event tree)
tweak Ma CCQE, affects dsigma(CCQE)/dQ2 both in shape and normalization
tweak the Bodek-Yang model parameter CV1u - shape only effect to d2sigma(DIS)/dxdy ...
static string AsString(GSyst_t syst)
Long64_t gOptNEvt1
range of events to process (1st input, if any)
double CalcWeight(const genie::EventRecord &event)
calculate weight for input event
Reweighting resonance decays.
void MesgThresholds(string inpfile)
Reweight GENIE CC resonance neutrino-production.
Command line argument parser.
GSystSet & Systematics(void)
set of enabled systematic params & values
void Clear(Option_t *opt="")
int gOptInpNTwk
of tweaking dial values in the specified range
tweak the Bodek-Yang model parameter CV2u - shape only effect to d2sigma(DIS)/dxdy ...
Set of systematics to be considered by the reweighting package.
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
bool OptionExists(char opt)
was option set?
Interface to the GENIE event reweighting engines.
vector< int > ArgAsIntTokens(char opt, string delimeter)
void push_back(int pdg_code)
Reweighting GENIE coherent neutrino-nucleus cross sections.
Reweighting non-resonance background level.
Reweighting GENIE INTRANUKE/hA hadron transport model.
double gOptMaxTwk
Maximum value of tweaked dial.
tweak Ma NCRES, affects d2sigma(NCRES)/dWdQ2 both in shape and normalization