6 #include "TLorentzVector.h" 8 #include "EVGCore/EventRecord.h" 9 #include "nusystematics/artless/response_helper.hh" 26 tree->SetBranchAddress(
"ievt", &ievt );
27 tree->SetBranchAddress(
"ifileNo", &ifileNo );
28 int current_file = -1;
29 TFile * ghep_file = NULL;
34 nusyst::response_helper rh( fhicl_filename );
36 std::vector<unsigned int> parIds = rh.GetParameters();
37 for(
unsigned int i = 0; i < parIds.size(); ++i ) {
38 systtools::SystParamHeader head = rh.GetHeader(parIds[i]);
39 printf(
"Adding reweight branch %u for %s with %lu shifts\n", parIds[i], head.prettyName.c_str(), head.paramVariations.size() );
40 bool is_wgt = head.isWeightSystematicVariation;
42 caf.
addRWbranch( parIds[i], head.prettyName, wgt_var, head.paramVariations );
43 caf.
iswgt[parIds[i]] = is_wgt;
48 int N = tree->GetEntries();
49 if( par.
n > 0 && par.
n < N ) N = par.
n + par.
first;
50 for(
int ii = par.
first; ii < N; ++ii ) {
53 if( ii % 100 == 0 ) printf(
"Event %d of %d...\n", ii, N );
57 for(
int j = 0; j < 100; ++j ) {
60 for(
unsigned int k = 0;
k < 100; ++
k ) {
61 caf.
wgt[j][
k] = ( caf.
iswgt[j] ? 1. : 0. );
66 if( ifileNo != current_file ) {
68 if( ghep_file ) ghep_file->Close();
70 if( par.
grid ) ghep_file =
new TFile( Form(
"genie.%d.root", ifileNo) );
71 else ghep_file =
new TFile( Form(
"%s/GAr.%s.%d.ghep.root", ghepdir.c_str(), mode.c_str(), ifileNo) );
73 gtree = (TTree*) ghep_file->Get(
"gtree" );
76 gtree->SetBranchAddress(
"gmcrec", &caf.
mcrec );
77 current_file = ifileNo;
84 gtree->GetEntry( ievt );
99 systtools::event_unit_response_w_cv_t resp = rh.GetEventVariationAndCVResponse(*
event);
101 caf.
nwgt[(*it).pid] = (*it).responses.size();
102 caf.
cvwgt[(*it).pid] = (*it).CV_response;
103 for(
unsigned int i = 0; i < (*it).responses.size(); ++i ) {
104 caf.
wgt[(*it).pid][i] = (*it).responses[i];
122 std::cout <<
"Help yourself by looking at the source code to see what the options are." <<
std::endl;
147 edepfile = argv[i+1];
156 fhicl_filename = argv[i+1];
159 par.
seed = atoi(argv[i+1]);
163 par.
n = atoi(argv[i+1]);
166 par.
nfiles = atoi(argv[i+1]);
169 par.
first = atoi(argv[i+1]);
183 printf(
"Making CAF from edep-sim tree dump: %s\n", edepfile.c_str() );
184 printf(
"Searching for GENIE ghep files here: %s\n", ghepdir.c_str() );
185 if( par.
fhc ) printf(
"Running neutrino mode (FHC)\n" );
186 else printf(
"Running antineutrino mode (RHC)\n" );
187 if( par.
grid ) printf(
"Running grid mode\n" );
188 else printf(
"Running test mode\n" );
189 printf(
"Output CAF file: %s\n", outfile.c_str() );
195 TFile *
tf =
new TFile( edepfile.c_str() );
196 TTree *
tree = (TTree*) tf->Get(
"tree" );
198 loop( caf, par, tree, ghepdir, fhicl_filename );
201 printf(
"Run %d POT %g\n", caf.
meta_run, caf.
pot );
void addRWbranch(int parId, std::string name, std::string wgt_var, std::vector< double > &vars)
genie::NtpMCEventRecord * mcrec
Summary information for an interaction.
TFile * cafFile
The output TFile pointer */.
int main(int argc, char const *argv[])
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
const InitialState & InitState(void) const
void loop(CAF &caf, params &par, TTree *tree, std::string ghepdir, std::string fhicl_filename)
QTextStream & endl(QTextStream &s)
TLorentzVector * GetProbeP4(RefFrame_t rf=kRfHitNucRest) const
Event finding and building.