16 #include <TClonesArray.h>
30 using std::ostringstream;
32 using namespace genie;
45 LOG(
"Ntp",
pNOTICE) <<
"Run number: " << runnu;
59 LOG(
"Ntp",
pINFO) <<
"Adding event " << ievent <<
" to output tree";
62 LOG(
"Ntp",
pERROR) <<
"NULL input EventRecord!";
66 LOG(
"Ntp",
pERROR) <<
"No open output TTree to add the input EventRecord!";
85 LOG(
"Ntp",
pINFO) <<
"Initializing GENIE output MC tree";
97 string tunename(
"unknown");
98 string tuneDir(
"unknown");
99 string customDirs(
"");
103 <<
"No TuneId is available from RunOpt";
105 tunename = tuneId->
Name();
121 configuration.
Load()->Write();
141 fnstr << filename_prefix <<
"."
154 <<
"Opening the output ROOT file: " << filename;
158 fOutFile = TFile::Open(filename.c_str(),
"RECREATE");
165 LOG(
"Ntp",
pINFO) <<
"Creating the output GENIE/ROOT tree";
168 title <<
"GENIE MC Truth TTree"
171 fOutTree =
new TTree(
"gtree",title.str().c_str());
183 <<
"Unknown TTree format. Can not create TBranches";
192 LOG(
"Ntp",
pINFO) <<
"Creating a NtpMCEventRecord TBranch";
195 TTree::SetBranchStyle(1);
197 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,0,0)
212 LOG(
"Ntp",
pINFO) <<
"Creating the NtpMCTreeHeader";
227 LOG(
"Ntp",
pINFO) <<
"Saving the output tree";
237 LOG(
"Ntp",
pERROR) <<
"No open ROOT file was found";
Stores the GENIE configuration in ROOT TFolders along with the output event tree. ...
TuneId * Tune(void) const
void OpenFile(string filename)
Stores a snapshot of your environment in ROOT TFolder along with the output event tree...
void CustomizeFilename(string filename)
void SetDefaultFilename(string filename_prefix="gntp")
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 Fill(unsigned int ievent, const EventRecord *ev_rec)
void CreateGHEPEventBranch(void)
bool IsCustom(void) const
NtpMCFormat_t fNtpFormat
enumeration of event formats
string fOutFilename
output filename
TFile * fOutFile
output file
NtpMCTreeHeader * fNtpMCTreeHeader
TBranch * fEventBranch
the generated event branch
~NtpWriter()
initialize the ntuple writer
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
string TuneDirectory(void) const
void CreateEventBranch(void)
string CustomSource(void) const
void Save(void)
get the even tree
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
void CreateTreeHeader(void)
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
void CustomizeFilenamePrefix(string prefix)
NtpWriter(NtpMCFormat_t fmt=kNFGHEP, Long_t runnu=0, Long_t runseed=-1)
void Initialize(void)
add event
static RunOpt * Instance(void)
TTree * fOutTree
output tree
enum genie::ENtpMCFormat NtpMCFormat_t
NtpMCEventRecord * fNtpMCEventRecord
TFolder * TakeSnapshot(void)