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 <costas.andreopoulos \at stfc.ac.uk>
10  University of Liverpool & STFC Rutherford Appleton Lab
11 
12 \created October 1, 2004
13 
14 \cpright Copyright (c) 2003-2019, The GENIE Collaboration
15  For the full text of the license visit http://copyright.genie-mc.org
16  or see $GENIE/LICENSE
17 */
18 //____________________________________________________________________________
19 
20 #ifndef _NTP_WRITER_H_
21 #define _NTP_WRITER_H_
22 
23 #include <string>
24 
26 
27 class TFile;
28 class TTree;
29 class TBranch;
30 class TClonesArray;
31 
32 using std::string;
33 
34 namespace genie {
35 
36 class EventRecord;
37 class NtpMCEventRecord;
38 class NtpMCTreeHeader;
39 
40 class NtpWriter {
41 
42 public :
43  NtpWriter(NtpMCFormat_t fmt = kNFGHEP, Long_t runnu = 0);
44  ~NtpWriter();
45 
46  ///< initialize the ntuple writer
47  void Initialize (void);
48 
49  ///< add event
50  void AddEventRecord (int ievent, const EventRecord * ev_rec);
51 
52  ///< save the event tree
53  void Save (void);
54 
55  ///< get the even tree
56  TTree * EventTree (void) { return fOutTree; }
57 
58  ///< use before Initialize() only if you wish to override the default
59  ///< filename, or the default filename prefix
60  void CustomizeFilename (string filename);
61  void CustomizeFilenamePrefix (string prefix);
62 
63 private:
64 
65  void SetDefaultFilename (string filename_prefix="gntp");
66  void OpenFile (string filename);
67  void CreateTree (void);
68  void CreateTreeHeader (void);
69  void CreateEventBranch (void);
70  void CreateGHEPEventBranch (void);
71 
72  NtpMCFormat_t fNtpFormat; ///< enumeration of event formats
73  Long_t fRunNu; ///< run nu
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:139
void CreateTree(void)
Definition: NtpWriter.cxx:151
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
void CustomizeFilename(string filename)
Definition: NtpWriter.cxx:118
void SetDefaultFilename(string filename_prefix="gntp")
Definition: NtpWriter.cxx:128
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:180
string filename
Definition: shutoffs.py:106
NtpMCFormat_t fNtpFormat
enumeration of event formats
Definition: NtpWriter.h:72
string fOutFilename
output filename
Definition: NtpWriter.h:74
TFile * fOutFile
output file
Definition: NtpWriter.h:75
NtpMCTreeHeader * fNtpMCTreeHeader
Definition: NtpWriter.h:79
TBranch * fEventBranch
the generated event branch
Definition: NtpWriter.h:77
~NtpWriter()
initialize the ntuple writer
Definition: NtpWriter.cxx:64
TTree * EventTree(void)
Definition: NtpWriter.h:56
void CreateEventBranch(void)
Definition: NtpWriter.cxx:165
MINOS-style Ntuple Class to hold an output MC Tree Header.
void Save(void)
get the even tree
Definition: NtpWriter.cxx:214
void AddEventRecord(int ievent, const EventRecord *ev_rec)
save the event tree
Definition: NtpWriter.cxx:69
const XML_Char * prefix
Definition: expat.h:380
void CreateTreeHeader(void)
Definition: NtpWriter.cxx:200
Generated Event Record. It is a GHepRecord object that can accept / be visited by EventRecordVisitorI...
Definition: EventRecord.h:38
void CustomizeFilenamePrefix(string prefix)
Definition: NtpWriter.cxx:123
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
void Initialize(void)
add event
Definition: NtpWriter.cxx:95
A utility class to facilitate creating the GENIE MC Ntuple from the output GENIE GHEP event records...
Definition: NtpWriter.h:40
TTree * fOutTree
output tree
Definition: NtpWriter.h:76
enum genie::ENtpMCFormat NtpMCFormat_t
NtpWriter(NtpMCFormat_t fmt=kNFGHEP, Long_t runnu=0)
Definition: NtpWriter.cxx:48
Long_t fRunNu
run nu
Definition: NtpWriter.h:73
NtpMCEventRecord * fNtpMCEventRecord
Definition: NtpWriter.h:78