Public Member Functions | Protected Attributes | List of all members
genie::evtlib::RecordLoader Class Reference

Helper for SimpleRecordList and OnDemandRecordList. More...

#include <EvtLibRecordList.h>

Public Member Functions

 RecordLoader (TTree *tree)
 
 ~RecordLoader ()
 
long NRecords () const
 
EvtLibRecord GetRecord (int i) const
 

Protected Attributes

TTree * fTree
 
float Enu
 
int prod_id
 
int nparts
 
int pdgs [kEvtLibMaxParts]
 
float Es [kEvtLibMaxParts]
 
float px [kEvtLibMaxParts]
 
float py [kEvtLibMaxParts]
 
float pz [kEvtLibMaxParts]
 

Detailed Description

Helper for SimpleRecordList and OnDemandRecordList.

Definition at line 52 of file EvtLibRecordList.h.

Constructor & Destructor Documentation

genie::evtlib::RecordLoader::RecordLoader ( TTree *  tree)

Definition at line 36 of file EvtLibRecordList.cxx.

37  : fTree(tree)
38  {
39  fTree->SetBranchAddress("Enu", &Enu);
40  fTree->SetBranchAddress("prod_id", &prod_id);
41 
42  fTree->SetBranchAddress("nparts", &nparts);
43 
44  fTree->SetBranchAddress("pdg", &pdgs);
45  fTree->SetBranchAddress("E", &Es);
46  fTree->SetBranchAddress("px", &px);
47  fTree->SetBranchAddress("py", &py);
48  fTree->SetBranchAddress("pz", &pz);
49  }
float px[kEvtLibMaxParts]
float Es[kEvtLibMaxParts]
float py[kEvtLibMaxParts]
float pz[kEvtLibMaxParts]
int pdgs[kEvtLibMaxParts]
genie::evtlib::RecordLoader::~RecordLoader ( )

Definition at line 52 of file EvtLibRecordList.cxx.

53  {
54  }

Member Function Documentation

EvtLibRecord genie::evtlib::RecordLoader::GetRecord ( int  i) const

Definition at line 63 of file EvtLibRecordList.cxx.

64  {
65  fTree->GetEntry(i);
66 
67  // The event library ROOT format is as minimalistic as possible. We use
68  // variable-sized arrays for the particle list. Because the address of
69  // `parts` had to be provided to SetBranchAddress up-front we had to pick
70  // a fixed size. If the list was actually longer we're in trouble and
71  // should bail out. This seems extremely unlikely to be a problem in
72  // practice, and we can always increase the constant to something larger.
73  if(nparts > kEvtLibMaxParts){
74  LOG("ELI", pFATAL) << "Too many particles " << nparts << "(limit " << kEvtLibMaxParts << ")";
75  exit(1);
76  }
77 
78  std::vector<EvtLibParticle> parts(nparts);
79  for(int j = 0; j < nparts; ++j){
80  parts[j].pdg = pdgs[j];
81  parts[j].E = Es[j];
82  parts[j].px = px[j];
83  parts[j].py = py[j];
84  parts[j].pz = pz[j];
85  } // end for j
86 
87  return EvtLibRecord(Enu, prod_id, parts);
88  }
const int kEvtLibMaxParts
Maximum number of particles supported in a single library event record.
float px[kEvtLibMaxParts]
#define pFATAL
Definition: Messenger.h:56
float Es[kEvtLibMaxParts]
#define LOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a string (using the FILE...
Definition: Messenger.h:96
float py[kEvtLibMaxParts]
float pz[kEvtLibMaxParts]
int pdgs[kEvtLibMaxParts]
long genie::evtlib::RecordLoader::NRecords ( ) const

Definition at line 57 of file EvtLibRecordList.cxx.

58  {
59  return fTree->GetEntries();
60  }

Member Data Documentation

float genie::evtlib::RecordLoader::Enu
protected

Definition at line 63 of file EvtLibRecordList.h.

float genie::evtlib::RecordLoader::Es[kEvtLibMaxParts]
protected

Definition at line 67 of file EvtLibRecordList.h.

TTree* genie::evtlib::RecordLoader::fTree
protected

Definition at line 61 of file EvtLibRecordList.h.

int genie::evtlib::RecordLoader::nparts
protected

Definition at line 65 of file EvtLibRecordList.h.

int genie::evtlib::RecordLoader::pdgs[kEvtLibMaxParts]
protected

Definition at line 66 of file EvtLibRecordList.h.

int genie::evtlib::RecordLoader::prod_id
protected

Definition at line 64 of file EvtLibRecordList.h.

float genie::evtlib::RecordLoader::px[kEvtLibMaxParts]
protected

Definition at line 68 of file EvtLibRecordList.h.

float genie::evtlib::RecordLoader::py[kEvtLibMaxParts]
protected

Definition at line 68 of file EvtLibRecordList.h.

float genie::evtlib::RecordLoader::pz[kEvtLibMaxParts]
protected

Definition at line 68 of file EvtLibRecordList.h.


The documentation for this class was generated from the following files: