46#include "Base/XSecAlgorithmI.h"
48#include "EVGCore/EventRecord.h"
53#include "ReWeight/GReWeightI.h"
54#include "ReWeight/GSystSet.h"
55#include "ReWeight/GReWeight.h"
56#include "ReWeight/GReWeightNuXSecCCQE.h"
57#include "ReWeight/GReWeightNuXSecCCQEvec.h"
58#include "ReWeight/GReWeightNuXSecCCRES.h"
59#include "ReWeight/GReWeightNuXSecNCRES.h"
60#include "ReWeight/GReWeightNuXSecDIS.h"
61#include "ReWeight/GReWeightNuXSecCOH.h"
62#include "ReWeight/GReWeightNonResonanceBkg.h"
63#include "ReWeight/GReWeightFGM.h"
64#include "ReWeight/GReWeightDISNuclMod.h"
65#include "ReWeight/GReWeightResonanceDecay.h"
66#include "ReWeight/GReWeightFZone.h"
67#include "ReWeight/GReWeightINuke.h"
68#include "ReWeight/GReWeightAGKY.h"
69#include "ReWeight/GSystUncertainty.h"
77using namespace genie::rew;
79using std::ostringstream;
82void GetEventRange (Long64_t nev_in_file, Long64_t & nfirst, Long64_t & nlast);
95int main(
int argc,
char ** argv)
103 tree =
dynamic_cast <TTree *
> ( file.Get(
"gtree") );
105 LOG(
"rwghtzexpaxff",
pNOTICE) <<
"Input tree header: " << *thdr;
108 <<
"Can't find a GHEP tree in input file: "<< file.GetName();
114 tree->SetBranchAddress(
"gmcrec", &mcrec);
116 Long64_t nev_in_file = tree->GetEntries();
120 int nev = int(nlast - nfirst + 1);
122 LOG(
"rwghtzexpaxff",
pNOTICE) <<
"Will process " << nev <<
" events";
133 rw.AdoptWghtCalc(
"xsec_ccqe",
new GReWeightNuXSecCCQE );
147 GSystSet & syst = rw.Systematics();
150 GReWeightNuXSecCCQE * rwccqe =
151 dynamic_cast<GReWeightNuXSecCCQE *
> (rw.WghtCalc(
"xsec_ccqe"));
152 rwccqe->SetMode(GReWeightNuXSecCCQE::kModeZExp);
154 GSystUncertainty * unc = GSystUncertainty::Instance();
158 AlgId id(
"genie::LwlynSmithQELCCPXSec",
"ZExp");
174 const int n_events = (
const int) nev;
175 const int n_params = (
const int)
MAX_COEF;
177 float weights [n_events];
180 for (
int iev = 0; iev < nev; iev++) { weights[iev] = 1.; }
189 /unc->OneSigmaErr(kXSecTwkDial_ZNormCCQE,TMath::Sign(1,(
int)(
gOptNormValue-1.))));
193 ostringstream zval_name;
194 for (
int ipr = 0; ipr < n_params; ipr++)
198 zval_name <<
"QEL-Z_A" << ipr+1;
201 unc->SetUncertainty(gsyst,1.,1.);
210 for(
int iev = nfirst; iev <= nlast; iev++) {
214 LOG(
"rwghtzexpaxff",
pNOTICE) <<
"Event number = " << iev;
217 double wght = rw.CalcWeight(event);
219 LOG(
"rwghtzexpaxff",
pNOTICE) <<
"Overall weight = " << wght;
222 weights[iev - nfirst] = wght;
236 TTree * wght_tree =
new TTree(
"ZExpCCQE",
"GENIE weights tree");
238 int branch_eventnum = 0;
239 float branch_weight = 1.;
241 float branch_zparam_val[
MAX_COEF] = {0.};
243 wght_tree->Branch(
"eventnum", &branch_eventnum);
244 wght_tree->Branch(
"weights", &branch_weight);
245 wght_tree->Branch(
"norm", &branch_norm_val);
248 ostringstream zparam_brnch_name;
249 for (
int ipr = 0; ipr < n_params; ipr++) {
250 zparam_brnch_name.str(
"");
251 zparam_brnch_name <<
"param_" << ipr+1;
252 LOG(
"rwghtzexpaxff",
pINFO) <<
"Branch name = " << zparam_brnch_name.str();
255 wght_tree->Branch(zparam_brnch_name.str().c_str(), &branch_zparam_val[ipr]);
258 ostringstream str_wght;
259 for(
int iev = nfirst; iev <= nlast; iev++) {
260 branch_eventnum = iev;
264 <<
"Filling tree with wght = " << weights[iev - nfirst];
265 branch_weight = weights[iev - nfirst];
284 LOG(
"rwghtzexpaxff",
pINFO) <<
"*** Parsing command line arguments";
290 LOG(
"rwghtzexpaxff",
pINFO) <<
"Reading event sample filename";
294 <<
"Unspecified input filename - Exiting";
301 LOG(
"rwghtzexpaxff",
pINFO) <<
"Reading requested output filename";
304 LOG(
"rwghtzexpaxff",
pINFO) <<
"Setting default output filename";
310 LOG(
"grwghtzexpaxff",
pINFO) <<
"Reading number of events to analyze";
312 if (nev.find(
",") != string::npos) {
315 LOG(
"grwghtzexpaxff",
pFATAL) <<
"Invalid syntax";
332 <<
"Unspecified number of events to analyze - Use all";
341 LOG(
"rwghtzexpaxff",
pINFO) <<
"Reading requested parameter values";
346 assert(zvals.size() == (
unsigned int)
MAX_COEF);
353 LOG(
"rwghtzexpaxff",
pINFO)<<
"Parameter value "<<ik+1<<
": "<<
360 LOG(
"rwghtzexpaxff",
pINFO) <<
"Reading requested normalization";
369void GetEventRange(Long64_t nev_in_file, Long64_t & nfirst, Long64_t & nlast)
379 nlast = TMath::Min(nev_in_file-1,
gOptNEvt2);
387 nlast = TMath::Min(nev_in_file-1,
gOptNEvt2-1);
393 nlast = nev_in_file-1;
396 assert(nfirst <= nlast && nfirst >= 0 && nlast <= nev_in_file-1);
402 case 1:
return kXSecTwkDial_ZExpA1CCQE;
break;
403 case 2:
return kXSecTwkDial_ZExpA2CCQE;
break;
404 case 3:
return kXSecTwkDial_ZExpA3CCQE;
break;
405 case 4:
return kXSecTwkDial_ZExpA4CCQE;
break;
408 <<
"Cannot find systematic corresponding to parameter " << ip;
418 <<
"grwghtzexpaxff \n"
419 <<
" -f input_event_file \n"
420 <<
" -v val1,val2,val3,val4 \n"
422 <<
" [-o output_weights_file]";
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE,...
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
static AlgConfigPool * Instance()
Registry * GlobalParameterList(void) const
The GENIE Algorithm Factory.
static AlgFactory * Instance()
Algorithm * AdoptAlgorithm(const AlgId &algid) const
Algorithm ID (algorithm name + configuration set name)
Algorithm abstract base class.
void AdoptSubstructure(void)
virtual const Registry & GetConfig(void) const
Command line argument parser.
string ArgAsString(char opt)
bool OptionExists(char opt)
was option set?
vector< long > ArgAsLongTokens(char opt, string delimeter)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
MINOS-style ntuple record. Each such ntuple record holds a generated EventRecord object....
void Clear(Option_t *opt="")
A registry. Provides the container for algorithm configuration parameters.
RgDbl GetDouble(RgKey key) const
RgDbl GetDoubleDef(RgKey key, RgDbl def_opt, bool set_def=true)
Cross Section Calculation Interface.
void GetEventRange(Long64_t nev_in_file, Long64_t &nfirst, Long64_t &nlast)
double gOptParameterValue[MAX_COEF]
void GetCommandLineArgs(int argc, char **argv)
GSyst_t GetZExpSystematic(int ip)
vector< string > Split(string input, string delim)
THE MAIN GENIE PROJECT NAMESPACE