NtpWriter.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::NtpWriter
5 
6 \brief A utility class to facilitate creating the GENIE MC Ntuple from the
7  output GENIE GHEP event records.
8 
9 \author Costas Andreopoulos <constantinos.andreopoulos \at cern.ch>
10  University of Liverpool & STFC Rutherford Appleton Laboratory
11 
12 \created October 1, 2004
13 
14 \cpright Copyright (c) 2003-2020, The GENIE Collaboration
15  For the full text of the license visit http://copyright.genie-mc.org
16 */
17 //____________________________________________________________________________
18 
19 #ifndef _NTP_WRITER_H_
20 #define _NTP_WRITER_H_
21 
22 #include <string>
23 
25 
26 class TFile;
27 class TTree;
28 class TBranch;
29 class TClonesArray;
30 
31 using std::string;
32 
33 namespace genie {
34 
35 class EventRecord;
36 class NtpMCEventRecord;
37 class NtpMCTreeHeader;
38 
39 class NtpWriter {
40 
41 public :
42  NtpWriter(NtpMCFormat_t fmt = kNFGHEP, Long_t runnu = 0, Long_t runseed = -1);
43  ~NtpWriter();
44 
45  ///< initialize the ntuple writer
46  void Initialize (void);
47 
48  ///< add event
49  void AddEventRecord (int ievent, const EventRecord * ev_rec);
50 
51  ///< save the event tree
52  void Save (void);
53 
54  ///< get the even tree
55  TTree * EventTree (void) { return fOutTree; }
56 
57  ///< use before Initialize() only if you wish to override the default
58  ///< filename, or the default filename prefix
59  void CustomizeFilename (string filename);
60  void CustomizeFilenamePrefix (string prefix);
61 
62 private:
63 
64  void SetDefaultFilename (string filename_prefix="gntp");
65  void OpenFile (string filename);
66  void CreateTree (void);
67  void CreateTreeHeader (void);
68  void CreateEventBranch (void);
69  void CreateGHEPEventBranch (void);
70 
71  NtpMCFormat_t fNtpFormat; ///< enumeration of event formats
72  Long_t fRunNu; ///< run nu
73  Long_t fRunSeed; ///< run seed
74  string fOutFilename; ///< output filename
75  TFile * fOutFile; ///< output file
76  TTree * fOutTree; ///< output tree
77  TBranch * fEventBranch; ///< the generated event branch
80 };
81 
82 } // genie namespace
83 #endif // _NTP_WRITER_H_
void OpenFile(string filename)
Definition: NtpWriter.cxx:149
void CreateTree(void)
Definition: NtpWriter.cxx:161
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
void CustomizeFilename(string filename)
Definition: NtpWriter.cxx:128
void SetDefaultFilename(string filename_prefix="gntp")
Definition: NtpWriter.cxx:138
std::string string
Definition: nybbler.cc:12
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 CreateGHEPEventBranch(void)
Definition: NtpWriter.cxx:190
NtpMCFormat_t fNtpFormat
enumeration of event formats
Definition: NtpWriter.h:71
string fOutFilename
output filename
Definition: NtpWriter.h:74
TFile * fOutFile
output file
Definition: NtpWriter.h:75
string filename
Definition: train.py:213
NtpMCTreeHeader * fNtpMCTreeHeader
Definition: NtpWriter.h:79
TBranch * fEventBranch
the generated event branch
Definition: NtpWriter.h:77
Long_t fRunSeed
run seed
Definition: NtpWriter.h:73
~NtpWriter()
initialize the ntuple writer
Definition: NtpWriter.cxx:52
TTree * EventTree(void)
Definition: NtpWriter.h:55
void CreateEventBranch(void)
Definition: NtpWriter.cxx:175
MINOS-style Ntuple Class to hold an output MC Tree Header.
void Save(void)
get the even tree
Definition: NtpWriter.cxx:225
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
Definition: NtpWriter.cxx:57
void CreateTreeHeader(void)
Definition: NtpWriter.cxx:210
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:37
void CustomizeFilenamePrefix(string prefix)
Definition: NtpWriter.cxx:133
NtpWriter(NtpMCFormat_t fmt=kNFGHEP, Long_t runnu=0, Long_t runseed=-1)
Definition: NtpWriter.cxx:35
void Initialize(void)
add event
Definition: NtpWriter.cxx:83
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
Definition: NtpWriter.h:39
TTree * fOutTree
output tree
Definition: NtpWriter.h:76
enum genie::ENtpMCFormat NtpMCFormat_t
Long_t fRunNu
run nu
Definition: NtpWriter.h:72
NtpMCEventRecord * fNtpMCEventRecord
Definition: NtpWriter.h:78