GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EvtLibRecordList.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \author Chris Backhouse -- c.backhouse@ucl.ac.uk
3 ////////////////////////////////////////////////////////////////////////
4 
5 #ifndef _EVTLIBRECORDLIST_H
6 #define _EVTLIBRECORDLIST_H
7 
8 #include <vector>
9 #include <string>
10 
11 class TFile;
12 class TTree;
13 
14 namespace genie{
15 namespace evtlib{
16 
17  //---------------------------------------------------------------------------
19  {
20  int pdg;
21  float E, px, py, pz;
22  };
23 
24  //---------------------------------------------------------------------------
25  struct EvtLibRecord
26  {
27  EvtLibRecord();
28  EvtLibRecord(float _E, int _prod_id,
29  const std::vector<EvtLibParticle>& _ps);
30 
31  /// Order by energy - this allows OnDemandRecordList to work efficiently
32  bool operator<(const EvtLibRecord& rhs) const;
33 
34  float E;
35  int prod_id;
36  std::vector<EvtLibParticle> parts;
37  };
38 
39  //---------------------------------------------------------------------------
41  {
42  public:
43  virtual ~IEvtLibRecordList(){}
44  virtual const EvtLibRecord* GetRecord(float E) const = 0;
45  };
46 
47  /// Maximum number of particles supported in a single library event record
48  const int kEvtLibMaxParts = 1024;
49 
50  //---------------------------------------------------------------------------
51  /// Helper for \ref SimpleRecordList and \ref OnDemandRecordList
53  {
54  public:
55  RecordLoader(TTree* tree);
56  ~RecordLoader();
57 
58  long NRecords() const;
59  EvtLibRecord GetRecord(int i) const;
60  protected:
61  TTree* fTree;
62 
63  float Enu;
64  int prod_id;
65  int nparts;
69  };
70 
71  //---------------------------------------------------------------------------
73  {
74  public:
75  SimpleRecordList(TTree* tree, const std::string& prettyName);
76  virtual ~SimpleRecordList(){}
77 
78  const EvtLibRecord* GetRecord(float E) const override;
79  protected:
80  std::vector<EvtLibRecord> fRecs;
81  };
82 
83  //---------------------------------------------------------------------------
85  {
86  public:
87  OnDemandRecordList(TTree* tree, const std::string& prettyName);
88  virtual ~OnDemandRecordList(){delete fLoader;}
89 
90  const EvtLibRecord* GetRecord(float E) const override;
91  protected:
92  void LoadIndex() const;
93 
94  TTree* fTree;
95  std::string fPrettyName;
97 
98  mutable std::vector<std::pair<float, int>> fEnergies;
99 
101  };
102 
103 }} // namespaces
104 
105 #endif
const int kEvtLibMaxParts
Maximum number of particles supported in a single library event record.
EvtLibRecord GetRecord(int i) const
std::vector< EvtLibParticle > parts
float px[kEvtLibMaxParts]
float Es[kEvtLibMaxParts]
const EvtLibRecord * GetRecord(float E) const override
virtual const EvtLibRecord * GetRecord(float E) const =0
OnDemandRecordList(TTree *tree, const std::string &prettyName)
float py[kEvtLibMaxParts]
std::vector< EvtLibRecord > fRecs
bool operator<(const EvtLibRecord &rhs) const
Order by energy - this allows OnDemandRecordList to work efficiently.
const EvtLibRecord * GetRecord(float E) const override
float pz[kEvtLibMaxParts]
SimpleRecordList(TTree *tree, const std::string &prettyName)
int pdgs[kEvtLibMaxParts]
std::vector< std::pair< float, int > > fEnergies