Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
garana::FlatG4Tree Class Reference

#include <FlatG4Tree.h>

Inheritance diagram for garana::FlatG4Tree:
garana::G4Tree garana::TreeReader garana::MillG4Tree

Public Member Functions

 FlatG4Tree ()
 
 FlatG4Tree (TTree *tree)
 
 FlatG4Tree (TTree *tree, char opt)
 
const UInt_t NSim () const override
 number of particles More...
 
const UInt_t NPoints (const UInt_t &iparticle) const override
 number of G4 steps (i.e. trajectory points) More...
 
const UInt_t NRegions (const UInt_t &iparticle) const override
 number of regions traversed by particle More...
 
const Int_t Region (const UInt_t &iparticle, const UInt_t &iregion) const override
 region number More...
 
const vector< const TLorentzVector * > * SimMomEnter (const UInt_t &iparticle) const override
 particle 4-momentum at entry point, all regions More...
 
const vector< const TLorentzVector * > * SimMomExit (const UInt_t &iparticle) const override
 particle 4-momentum at exit point, all regions More...
 
const vector< const TLorentzVector * > * SimPosEnter (const UInt_t &iparticle) const override
 particle 4-position at entry point, all regions More...
 
const vector< const TLorentzVector * > * SimPosExit (const UInt_t &iparticle) const override
 particle 4-position at exit point, all regions More...
 
const TLorentzVector * SimMomEnter (const UInt_t &iparticle, const UInt_t &iregion) const override
 particle 4-momentum at entry point in region More...
 
const TLorentzVector * SimMomExit (const UInt_t &iparticle, const UInt_t &iregion) const override
 particle 4-momentum at exit point in region More...
 
const TLorentzVector * SimPosEnter (const UInt_t &iparticle, const UInt_t &iregion) const override
 particle 4-position at entry point in region More...
 
const TLorentzVector * SimPosExit (const UInt_t &iparticle, const UInt_t &iregion) const override
 particle 4-position at exit point in region More...
 
const bool IsPrimary (const UInt_t &iparticle) const override
 did particle come from generator? More...
 
const Int_t PDG (const UInt_t &iparticle) const override
 particle PDG code More...
 
const int ParentPDG (const UInt_t &iparticle) const override
 parent particle's PDG code More...
 
const int ProgenitorPDG (const UInt_t &iparticle) const override
 PDG of primary that led this one. More...
 
const int TrackID (const UInt_t &iparticle) const override
 G4 track ID (can be <0 if it fell below trking threshold) More...
 
const int ParentTrackID (const UInt_t &iparticle) const override
 G4 track ID of parent particle. More...
 
const int ProgenitorTrackID (const UInt_t &iparticle) const override
 G4 track ID of primary that led this one. More...
 
const Int_t ProcessI (const UInt_t &iparticle) const override
 code for process that created this one More...
 
const Int_t ProcessF (const UInt_t &iparticle) const override
 code for process that killed this one More...
 
void GetEntry (const UInt_t &ientry) override
 
const UInt_t NSubEntries () const
 
- Public Member Functions inherited from garana::G4Tree
virtual ~G4Tree ()
 
UInt_t const GetTruthIndex (UInt_t iparticle) const
 index in gen tree subentry to truth match to this More...
 
const UInt_t NPrimary () const
 
bool HasPassedTPC (const UInt_t &iparticle) const
 did the G4Particle pass through any TPC drift volume(s)? More...
 
bool HasPassedCalo (const UInt_t &iparticle) const
 did the G4Particle pass through any active ECal volume(s)? More...
 
bool IsStoppedTPC (const UInt_t &iparticle) const
 did the G4Particle stop/decay in any TPC drift volume(s)? More...
 
bool IsStoppedCalo (const UInt_t &iparticle) const
 did the G4Particle stop/decay in any active ECal volume(s)? More...
 
bool IsContainedTPC (const UInt_t &iparticle) const
 if the G4Particle was produced in any TPC drift volume, does it remain in either drift volume? More...
 
bool IsContainedCalo (const UInt_t &iparticle) const
 if the G4Particle was produced in any active ECal volume, does it remain there? More...
 
bool IsCathodeCrosser (const UInt_t &iparticle) const
 did the G4Particle cross the TPC central cathode? More...
 
bool IsContainedTPCEvent () const
 do all particles produced in any TPC drift volume in this event remain in either volume? More...
 
bool IsContainedTPCPrimaries () const
 do all primaries produced in any TPC drift volume in this event remain in either volume? More...
 
bool IsContainedCaloEvent () const
 do all particles produced in any active ECal volume in this event remain there? More...
 
bool IsContainedCaloPrimaries () const
 do all primaries produced in any active ECal volume in this event remain there? More...
 
const TLorentzVector * SimMomBegin (const UInt_t &iparticle) const
 
const TLorentzVector * SimMomEnd (const UInt_t &iparticle) const
 
const TLorentzVector * SimPosBegin (const UInt_t &iparticle) const
 
const TLorentzVector * SimPosEnd (const UInt_t &iparticle) const
 
- Public Member Functions inherited from garana::TreeReader
virtual ~TreeReader ()
 
void SetupRead (TTree *tree)
 
TTree * GetInputTree ()
 
size_t NEntries () const
 
Int_t Event () const
 
const TObjArray * GetBranchList () const
 
void Fill ()
 
void Write ()
 
void CheckOpt (char opt)
 
bool BlockWrite () const
 

Protected Member Functions

bool SetBranchAddresses () override
 
void SetVecs ()
 
void ClearVecs ()
 
void SetLimits ()
 
void FillIndexMap ()
 
const UInt_t LocalToGlobalIndex (const UInt_t &iparticle) const
 

Protected Attributes

std::map< UInt_t, std::pair< UInt_t, UInt_t > > fLimits
 for each array for a given particle More...
 
std::map< UInt_t, UInt_t > fLocalToGlobalIndex
 
UInt_t fNSim = UINT_MAX
 number of G4 particles per event More...
 
vector< UInt_t > * fNPts = nullptr
 number of 4-vector "snapshots" (G4 steps) More...
 
vector< UInt_t > * fNRegions = nullptr
 number of regions of interest cross by the particle More...
 
vector< Int_t > * fRegions = nullptr
 region IDs More...
 
vector< Int_t > * fTrkID = nullptr
 particle's G4 trackID More...
 
vector< Int_t > * fPDG = nullptr
 particle's PDG code More...
 
vector< Int_t > * fParentPdg = nullptr
 particle parent's PDG code More...
 
vector< Int_t > * fProgenitorPdg = nullptr
 FS particle from gen stage that led to this one. More...
 
vector< Int_t > * fParentTrackId = nullptr
 particle's parent's trackID More...
 
vector< Int_t > * fProgenitorTrackId = nullptr
 FS particle from gen stage that led to this one. More...
 
vector< Int_t > * fProcessI = nullptr
 process that produced the particle More...
 
vector< Int_t > * fProcessF = nullptr
 process that killed the particle More...
 
vector< Float_t > * fX = nullptr
 particle's x-position in lab frame [cm] More...
 
vector< Float_t > * fY = nullptr
 particle's y-position in lab frame [cm] More...
 
vector< Float_t > * fZ = nullptr
 particle's z-position in lab frame [cm] More...
 
vector< Float_t > * fT = nullptr
 particle's time in lab frame [ns] More...
 
vector< Float_t > * fPx = nullptr
 particle's x-momentum in lab frame [GeV/c] More...
 
vector< Float_t > * fPy = nullptr
 particle's y-momentum in lab frame [GeV/c] More...
 
vector< Float_t > * fPz = nullptr
 particle's z-momentum in lab frame [GeV/c] More...
 
vector< Float_t > * fE = nullptr
 particle's total energy in lab frame [GeV] More...
 
TBranch * b_NSim = nullptr
 
TBranch * b_NPts = nullptr
 
TBranch * b_NRegions = nullptr
 
TBranch * b_Regions = nullptr
 
TBranch * b_TrkID = nullptr
 
TBranch * b_PDG = nullptr
 
TBranch * b_ParentPdg = nullptr
 
TBranch * b_ProgenitorPdg = nullptr
 
TBranch * b_ParentTrackId = nullptr
 
TBranch * b_ProgenitorTrackId = nullptr
 
TBranch * b_ProcessI = nullptr
 
TBranch * b_ProcessF = nullptr
 
TBranch * b_X = nullptr
 
TBranch * b_Y = nullptr
 
TBranch * b_Z = nullptr
 
TBranch * b_T = nullptr
 
TBranch * b_Px = nullptr
 
TBranch * b_Py = nullptr
 
TBranch * b_Pz = nullptr
 
TBranch * b_E = nullptr
 
- Protected Attributes inherited from garana::G4Tree
vector< UInt_t > * fG4TruthIndex = nullptr
 
vector< UInt_t > * fG4FSIndex = nullptr
 
TBranch * b_G4TruthIndex = nullptr
 
TBranch * b_G4FSIndex = nullptr
 
- Protected Attributes inherited from garana::TreeReader
const std::string treename
 
char fOpt = 'r'
 
TTree * fTreeIn = nullptr
 pointer to the analyzed TTree or TChain More...
 
UInt_t fCurrentEntry = UINT_MAX
 
TBranch * b_Event = nullptr
 
Int_t fEvent = -1
 event number for tree entry More...
 

Detailed Description

Definition at line 19 of file FlatG4Tree.h.

Constructor & Destructor Documentation

garana::FlatG4Tree::FlatG4Tree ( )
inline

Definition at line 23 of file FlatG4Tree.h.

23 {}
FlatG4Tree::FlatG4Tree ( TTree *  tree)

Definition at line 14 of file FlatG4Tree.cxx.

15 {
16  SetupRead(tree);
17 
18 }
void SetupRead(TTree *tree)
Definition: TreeReader.cxx:6
FlatG4Tree::FlatG4Tree ( TTree *  tree,
char  opt 
)

Definition at line 20 of file FlatG4Tree.cxx.

21 {
22  CheckOpt(opt);//sets TreeReader::fOpt
23 
24  if(fOpt=='r'){
25  std::cout << "constructed FlatG4Tree object in read-only mode" << std::endl;
26  SetupRead(tree);
27  }
28  else {
29  std::cout << "constructed FlatG4Tree object in write mode" << std::endl;
30  fTreeIn = tree;
32  SetVecs();
33  }
34 
35 }
opt
Definition: train.py:196
TTree * fTreeIn
pointer to the analyzed TTree or TChain
Definition: TreeReader.h:51
void CheckOpt(char opt)
Definition: TreeReader.cxx:67
void SetupRead(TTree *tree)
Definition: TreeReader.cxx:6
QTextStream & endl(QTextStream &s)
bool SetBranchAddresses() override
Definition: FlatG4Tree.cxx:47

Member Function Documentation

void FlatG4Tree::ClearVecs ( )
protected

Definition at line 130 of file FlatG4Tree.cxx.

130  {
131 
132  fNPts->clear();
133  fTrkID->clear();
134  fPDG->clear();
135  fParentPdg->clear();
136  fProgenitorPdg->clear();
137  fParentTrackId->clear();
138  fProgenitorTrackId->clear();
139  fProcessI->clear();
140  fProcessF->clear();
141  fX->clear();
142  fY->clear();
143  fZ->clear();
144  fT->clear();
145  fPx->clear();
146  fPy->clear();
147  fPz->clear();
148  fE->clear();
149 
150  }
vector< Int_t > * fTrkID
particle&#39;s G4 trackID
Definition: FlatG4Tree.h:76
vector< Int_t > * fParentPdg
particle parent&#39;s PDG code
Definition: FlatG4Tree.h:78
vector< Float_t > * fPy
particle&#39;s y-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:89
vector< Int_t > * fProcessI
process that produced the particle
Definition: FlatG4Tree.h:82
vector< UInt_t > * fNPts
number of 4-vector "snapshots" (G4 steps)
Definition: FlatG4Tree.h:73
vector< Float_t > * fE
particle&#39;s total energy in lab frame [GeV]
Definition: FlatG4Tree.h:91
vector< Float_t > * fT
particle&#39;s time in lab frame [ns]
Definition: FlatG4Tree.h:87
vector< Int_t > * fProgenitorPdg
FS particle from gen stage that led to this one.
Definition: FlatG4Tree.h:79
vector< Int_t > * fParentTrackId
particle&#39;s parent&#39;s trackID
Definition: FlatG4Tree.h:80
vector< Float_t > * fY
particle&#39;s y-position in lab frame [cm]
Definition: FlatG4Tree.h:85
vector< Float_t > * fZ
particle&#39;s z-position in lab frame [cm]
Definition: FlatG4Tree.h:86
vector< Float_t > * fPz
particle&#39;s z-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:90
vector< Int_t > * fProcessF
process that killed the particle
Definition: FlatG4Tree.h:83
vector< Int_t > * fProgenitorTrackId
FS particle from gen stage that led to this one.
Definition: FlatG4Tree.h:81
vector< Int_t > * fPDG
particle&#39;s PDG code
Definition: FlatG4Tree.h:77
vector< Float_t > * fPx
particle&#39;s x-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:88
vector< Float_t > * fX
particle&#39;s x-position in lab frame [cm]
Definition: FlatG4Tree.h:84
void FlatG4Tree::FillIndexMap ( )
protected

Definition at line 300 of file FlatG4Tree.cxx.

300  {
301  fLocalToGlobalIndex.clear();
302  UInt_t iparticle=0;
303  int trkid = -1; fTrkID->at(0);
304  for(UInt_t i=0; i<NSubEntries(); i++){
305  if(trkid!=fTrkID->at(i)){
306  fLocalToGlobalIndex[iparticle] = i;
307  trkid = fTrkID->at(i);
308  iparticle++;
309  }
310  }
311 }
vector< Int_t > * fTrkID
particle&#39;s G4 trackID
Definition: FlatG4Tree.h:76
const UInt_t NSubEntries() const
Definition: FlatG4Tree.cxx:296
std::map< UInt_t, UInt_t > fLocalToGlobalIndex
Definition: FlatG4Tree.h:66
void FlatG4Tree::GetEntry ( const UInt_t &  ientry)
overridevirtual

Reimplemented from garana::TreeReader.

Definition at line 38 of file FlatG4Tree.cxx.

38  {
39 
40  FillIndexMap();
41  if(ientry != fCurrentEntry) {
42  fCurrentEntry = ientry;
43  fTreeIn->GetEntry(ientry);
44  }
45 }
UInt_t fCurrentEntry
Definition: TreeReader.h:52
TTree * fTreeIn
pointer to the analyzed TTree or TChain
Definition: TreeReader.h:51
const bool FlatG4Tree::IsPrimary ( const UInt_t &  iparticle) const
overridevirtual

did particle come from generator?

Implements garana::G4Tree.

Definition at line 160 of file FlatG4Tree.cxx.

160  {
161  if(fParentPdg->at(iparticle)==INT_MAX) return true;
162  else return false;
163  }
vector< Int_t > * fParentPdg
particle parent&#39;s PDG code
Definition: FlatG4Tree.h:78
const UInt_t FlatG4Tree::LocalToGlobalIndex ( const UInt_t &  iparticle) const
protected

Definition at line 313 of file FlatG4Tree.cxx.

313  {
314 
315  return fLocalToGlobalIndex.at(iparticle);
316 }
std::map< UInt_t, UInt_t > fLocalToGlobalIndex
Definition: FlatG4Tree.h:66
const UInt_t FlatG4Tree::NPoints ( const UInt_t &  iparticle) const
overridevirtual

number of G4 steps (i.e. trajectory points)

Implements garana::G4Tree.

Definition at line 156 of file FlatG4Tree.cxx.

156  {
157  return fNPts->at(iparticle);
158  }//
vector< UInt_t > * fNPts
number of 4-vector "snapshots" (G4 steps)
Definition: FlatG4Tree.h:73
const UInt_t FlatG4Tree::NRegions ( const UInt_t &  iparticle) const
overridevirtual

number of regions traversed by particle

Implements garana::G4Tree.

Definition at line 169 of file FlatG4Tree.cxx.

169  {
170  return fNRegions->at(iparticle);
171 }
vector< UInt_t > * fNRegions
number of regions of interest cross by the particle
Definition: FlatG4Tree.h:74
const UInt_t FlatG4Tree::NSim ( ) const
overridevirtual

number of particles

Implements garana::G4Tree.

Definition at line 152 of file FlatG4Tree.cxx.

152  {
153  return fNSim;
154  }//
UInt_t fNSim
number of G4 particles per event
Definition: FlatG4Tree.h:72
const UInt_t FlatG4Tree::NSubEntries ( ) const

Definition at line 296 of file FlatG4Tree.cxx.

296  {
297  return fTrkID->size();
298 }
vector< Int_t > * fTrkID
particle&#39;s G4 trackID
Definition: FlatG4Tree.h:76
const int FlatG4Tree::ParentPDG ( const UInt_t &  iparticle) const
overridevirtual

parent particle's PDG code

Implements garana::G4Tree.

Definition at line 268 of file FlatG4Tree.cxx.

268  {
269  return fParentPdg->at(LocalToGlobalIndex(iparticle));
270 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Int_t > * fParentPdg
particle parent&#39;s PDG code
Definition: FlatG4Tree.h:78
const int FlatG4Tree::ParentTrackID ( const UInt_t &  iparticle) const
overridevirtual

G4 track ID of parent particle.

Implements garana::G4Tree.

Definition at line 280 of file FlatG4Tree.cxx.

280  {
281  return fParentTrackId->at(LocalToGlobalIndex(iparticle));
282 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Int_t > * fParentTrackId
particle&#39;s parent&#39;s trackID
Definition: FlatG4Tree.h:80
const Int_t FlatG4Tree::PDG ( const UInt_t &  iparticle) const
overridevirtual

particle PDG code

Implements garana::G4Tree.

Definition at line 165 of file FlatG4Tree.cxx.

165  {
166  return fPDG->at(iparticle);
167  }
vector< Int_t > * fPDG
particle&#39;s PDG code
Definition: FlatG4Tree.h:77
const Int_t FlatG4Tree::ProcessF ( const UInt_t &  iparticle) const
overridevirtual

code for process that killed this one

Implements garana::G4Tree.

Definition at line 292 of file FlatG4Tree.cxx.

292  {
293  return fProcessF->at(LocalToGlobalIndex(iparticle));
294 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Int_t > * fProcessF
process that killed the particle
Definition: FlatG4Tree.h:83
const Int_t FlatG4Tree::ProcessI ( const UInt_t &  iparticle) const
overridevirtual

code for process that created this one

Implements garana::G4Tree.

Definition at line 288 of file FlatG4Tree.cxx.

288  {
289  return fProcessI->at(LocalToGlobalIndex(iparticle));
290 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Int_t > * fProcessI
process that produced the particle
Definition: FlatG4Tree.h:82
const int FlatG4Tree::ProgenitorPDG ( const UInt_t &  iparticle) const
overridevirtual

PDG of primary that led this one.

Implements garana::G4Tree.

Definition at line 272 of file FlatG4Tree.cxx.

272  {
273  return fProgenitorPdg->at(LocalToGlobalIndex(iparticle));
274 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Int_t > * fProgenitorPdg
FS particle from gen stage that led to this one.
Definition: FlatG4Tree.h:79
const int FlatG4Tree::ProgenitorTrackID ( const UInt_t &  iparticle) const
overridevirtual

G4 track ID of primary that led this one.

Implements garana::G4Tree.

Definition at line 284 of file FlatG4Tree.cxx.

284  {
285  return fProgenitorTrackId->at(LocalToGlobalIndex(iparticle));
286 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Int_t > * fProgenitorTrackId
FS particle from gen stage that led to this one.
Definition: FlatG4Tree.h:81
const Int_t FlatG4Tree::Region ( const UInt_t &  iparticle,
const UInt_t &  iregion 
) const
overridevirtual

region number

Implements garana::G4Tree.

Definition at line 173 of file FlatG4Tree.cxx.

173  {
174  return fRegions->at(LocalToGlobalIndex(iparticle)+iregion);
175 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Int_t > * fRegions
region IDs
Definition: FlatG4Tree.h:75
bool FlatG4Tree::SetBranchAddresses ( )
overrideprotectedvirtual

Implements garana::TreeReader.

Definition at line 47 of file FlatG4Tree.cxx.

47  {
48 
49 std::cout << "FlatG4Tree SetBranchAddresses()" << std::endl;
50 
51  if(fOpt=='r'){
52  fTreeIn->SetBranchAddress("Event", &fEvent, &b_Event );
53  fTreeIn->SetBranchAddress("TruthIndex", &fG4TruthIndex, &b_G4TruthIndex );
54  //fTreeIn->SetBranchAddress("FSIndex", &fG4FSIndex, &b_G4FSIndex);
55  fTreeIn->SetBranchAddress("NSim", &fNSim, &b_NSim );
56  fTreeIn->SetBranchAddress("NPts", &fNPts, &b_NPts );
57  fTreeIn->SetBranchAddress("NRegions", &fNRegions, &b_NRegions );
58  fTreeIn->SetBranchAddress("Region", &fRegions, &b_Regions );
59  fTreeIn->SetBranchAddress("TrkID", &fTrkID, &b_TrkID );
60  fTreeIn->SetBranchAddress("Pdg", &fPDG, &b_PDG );
61  fTreeIn->SetBranchAddress("ParentPdg", &fParentPdg, &b_ParentPdg );
62  fTreeIn->SetBranchAddress("ProgenitorPdg", &fProgenitorPdg, &b_ProgenitorPdg );
63  fTreeIn->SetBranchAddress("ParentTrackId", &fParentTrackId, &b_ParentTrackId );
64  fTreeIn->SetBranchAddress("ProgenitorTrackId", &fProgenitorTrackId, &b_ProgenitorTrackId);
65  fTreeIn->SetBranchAddress("ProcessI", &fProcessI, &b_ProcessI );
66  fTreeIn->SetBranchAddress("ProcessF", &fProcessF, &b_ProcessF );
67  fTreeIn->SetBranchAddress("X", &fX, &b_X );
68  fTreeIn->SetBranchAddress("Y", &fY, &b_Y );
69  fTreeIn->SetBranchAddress("Z", &fZ, &b_Z );
70  fTreeIn->SetBranchAddress("T", &fT, &b_T );
71  fTreeIn->SetBranchAddress("Px", &fPx, &b_Px );
72  fTreeIn->SetBranchAddress("Py", &fPy, &b_Py );
73  fTreeIn->SetBranchAddress("Pz", &fPz, &b_Pz );
74  fTreeIn->SetBranchAddress("E", &fE, &b_E );
75 
76  }
77 
78 
79  if(fOpt=='w'){
80 
81  fTreeIn->Branch("Event", &fEvent, "Event/I");
82  fTreeIn->Branch("NSim", &fNSim, "NSim/I" );
83  fTreeIn->Branch("NPts", &fNPts );
84  fTreeIn->Branch("NRegions", &fNRegions );
85  fTreeIn->Branch("Region", &fRegions );
86  fTreeIn->Branch("TrkID", &fTrkID );
87  fTreeIn->Branch("Pdg", &fPDG );
88  fTreeIn->Branch("ParentPdg", &fParentPdg );
89  fTreeIn->Branch("ProgenitorPdg", &fProgenitorPdg );
90  fTreeIn->Branch("ParentTrackId", &fParentTrackId );
91  fTreeIn->Branch("ProgenitorTrackId", &fProgenitorTrackId );
92  fTreeIn->Branch("ProcessI", &fProcessI );
93  fTreeIn->Branch("ProcessF", &fProcessF );
94  fTreeIn->Branch("X", &fX );
95  fTreeIn->Branch("Y", &fY );
96  fTreeIn->Branch("Z", &fZ );
97  fTreeIn->Branch("T", &fT );
98  fTreeIn->Branch("Px", &fPx );
99  fTreeIn->Branch("Py", &fPy );
100  fTreeIn->Branch("Pz", &fPz );
101  fTreeIn->Branch("E", &fE );
102  }
103 
104  return true;
105 }
vector< Int_t > * fTrkID
particle&#39;s G4 trackID
Definition: FlatG4Tree.h:76
TBranch * b_ProgenitorTrackId
Definition: FlatG4Tree.h:103
vector< Int_t > * fParentPdg
particle parent&#39;s PDG code
Definition: FlatG4Tree.h:78
vector< Float_t > * fPy
particle&#39;s y-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:89
vector< Int_t > * fProcessI
process that produced the particle
Definition: FlatG4Tree.h:82
vector< Int_t > * fRegions
region IDs
Definition: FlatG4Tree.h:75
TBranch * b_ParentTrackId
Definition: FlatG4Tree.h:102
vector< UInt_t > * fNRegions
number of regions of interest cross by the particle
Definition: FlatG4Tree.h:74
TBranch * b_TrkID
Definition: FlatG4Tree.h:98
TTree * fTreeIn
pointer to the analyzed TTree or TChain
Definition: TreeReader.h:51
TBranch * b_Regions
Definition: FlatG4Tree.h:97
vector< UInt_t > * fNPts
number of 4-vector "snapshots" (G4 steps)
Definition: FlatG4Tree.h:73
TBranch * b_ProgenitorPdg
Definition: FlatG4Tree.h:101
TBranch * b_NRegions
Definition: FlatG4Tree.h:96
vector< UInt_t > * fG4TruthIndex
Definition: G4Tree.h:71
vector< Float_t > * fE
particle&#39;s total energy in lab frame [GeV]
Definition: FlatG4Tree.h:91
vector< Float_t > * fT
particle&#39;s time in lab frame [ns]
Definition: FlatG4Tree.h:87
TBranch * b_ProcessF
Definition: FlatG4Tree.h:105
TBranch * b_PDG
Definition: FlatG4Tree.h:99
vector< Int_t > * fProgenitorPdg
FS particle from gen stage that led to this one.
Definition: FlatG4Tree.h:79
vector< Int_t > * fParentTrackId
particle&#39;s parent&#39;s trackID
Definition: FlatG4Tree.h:80
TBranch * b_G4TruthIndex
Definition: G4Tree.h:73
UInt_t fNSim
number of G4 particles per event
Definition: FlatG4Tree.h:72
TBranch * b_Event
Definition: TreeReader.h:54
TBranch * b_ParentPdg
Definition: FlatG4Tree.h:100
vector< Float_t > * fY
particle&#39;s y-position in lab frame [cm]
Definition: FlatG4Tree.h:85
vector< Float_t > * fZ
particle&#39;s z-position in lab frame [cm]
Definition: FlatG4Tree.h:86
vector< Float_t > * fPz
particle&#39;s z-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:90
vector< Int_t > * fProcessF
process that killed the particle
Definition: FlatG4Tree.h:83
TBranch * b_NPts
Definition: FlatG4Tree.h:95
vector< Int_t > * fProgenitorTrackId
FS particle from gen stage that led to this one.
Definition: FlatG4Tree.h:81
vector< Int_t > * fPDG
particle&#39;s PDG code
Definition: FlatG4Tree.h:77
TBranch * b_ProcessI
Definition: FlatG4Tree.h:104
Int_t fEvent
event number for tree entry
Definition: TreeReader.h:55
TBranch * b_NSim
Definition: FlatG4Tree.h:94
vector< Float_t > * fPx
particle&#39;s x-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:88
QTextStream & endl(QTextStream &s)
vector< Float_t > * fX
particle&#39;s x-position in lab frame [cm]
Definition: FlatG4Tree.h:84
void garana::FlatG4Tree::SetLimits ( )
protected
void FlatG4Tree::SetVecs ( )
protected

Definition at line 108 of file FlatG4Tree.cxx.

108  {
109 
110  fNPts = new vector<UInt_t>();
111  fTrkID = new vector<Int_t>();
112  fPDG = new vector<Int_t>();
113  fParentPdg = new vector<Int_t>();
114  fProgenitorPdg = new vector<Int_t>();
115  fParentTrackId = new vector<Int_t>();
116  fProgenitorTrackId = new vector<Int_t>();
117  fProcessI = new vector<Int_t>();
118  fProcessF = new vector<Int_t>();
119  fX = new vector<Float_t>();
120  fY = new vector<Float_t>();
121  fZ = new vector<Float_t>();
122  fT = new vector<Float_t>();
123  fPx = new vector<Float_t>();
124  fPy = new vector<Float_t>();
125  fPz = new vector<Float_t>();
126  fE = new vector<Float_t>();
127 
128  }
vector< Int_t > * fTrkID
particle&#39;s G4 trackID
Definition: FlatG4Tree.h:76
vector< Int_t > * fParentPdg
particle parent&#39;s PDG code
Definition: FlatG4Tree.h:78
vector< Float_t > * fPy
particle&#39;s y-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:89
vector< Int_t > * fProcessI
process that produced the particle
Definition: FlatG4Tree.h:82
vector< UInt_t > * fNPts
number of 4-vector "snapshots" (G4 steps)
Definition: FlatG4Tree.h:73
vector< Float_t > * fE
particle&#39;s total energy in lab frame [GeV]
Definition: FlatG4Tree.h:91
vector< Float_t > * fT
particle&#39;s time in lab frame [ns]
Definition: FlatG4Tree.h:87
vector< Int_t > * fProgenitorPdg
FS particle from gen stage that led to this one.
Definition: FlatG4Tree.h:79
vector< Int_t > * fParentTrackId
particle&#39;s parent&#39;s trackID
Definition: FlatG4Tree.h:80
vector< Float_t > * fY
particle&#39;s y-position in lab frame [cm]
Definition: FlatG4Tree.h:85
vector< Float_t > * fZ
particle&#39;s z-position in lab frame [cm]
Definition: FlatG4Tree.h:86
vector< Float_t > * fPz
particle&#39;s z-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:90
vector< Int_t > * fProcessF
process that killed the particle
Definition: FlatG4Tree.h:83
vector< Int_t > * fProgenitorTrackId
FS particle from gen stage that led to this one.
Definition: FlatG4Tree.h:81
vector< Int_t > * fPDG
particle&#39;s PDG code
Definition: FlatG4Tree.h:77
vector< Float_t > * fPx
particle&#39;s x-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:88
vector< Float_t > * fX
particle&#39;s x-position in lab frame [cm]
Definition: FlatG4Tree.h:84
const vector< const TLorentzVector * > * FlatG4Tree::SimMomEnter ( const UInt_t &  iparticle) const
overridevirtual

particle 4-momentum at entry point, all regions

Implements garana::G4Tree.

Definition at line 177 of file FlatG4Tree.cxx.

177  {
178 
179  //output vector
180  auto v = new vector<const TLorentzVector*>();
181 
182  //get index range
183  size_t ireg = LocalToGlobalIndex(iparticle);
184  size_t ireg_max = ireg+2*fNRegions->at(iparticle);
185 
186  //fill for all regions
187  //entry points are every other value and precede exit points
188  for(; ireg<ireg_max; ireg+=2){
189  v->push_back(new TLorentzVector(fPx->at(ireg), fPy->at(ireg),
190  fPz->at(ireg), fE->at(ireg)));
191  }
192  return v;
193 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Float_t > * fPy
particle&#39;s y-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:89
vector< UInt_t > * fNRegions
number of regions of interest cross by the particle
Definition: FlatG4Tree.h:74
vector< Float_t > * fE
particle&#39;s total energy in lab frame [GeV]
Definition: FlatG4Tree.h:91
vector< Float_t > * fPz
particle&#39;s z-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:90
vector< Float_t > * fPx
particle&#39;s x-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:88
const TLorentzVector * FlatG4Tree::SimMomEnter ( const UInt_t &  iparticle,
const UInt_t &  iregion 
) const
overridevirtual

particle 4-momentum at entry point in region

Implements garana::G4Tree.

Definition at line 249 of file FlatG4Tree.cxx.

249  {
250  UInt_t index = LocalToGlobalIndex(iparticle) + iregion;
251  return new TLorentzVector(fPx->at(index), fPy->at(index), fPz->at(index), fE->at(index));
252 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Float_t > * fPy
particle&#39;s y-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:89
vector< Float_t > * fE
particle&#39;s total energy in lab frame [GeV]
Definition: FlatG4Tree.h:91
vector< Float_t > * fPz
particle&#39;s z-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:90
vector< Float_t > * fPx
particle&#39;s x-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:88
const vector< const TLorentzVector * > * FlatG4Tree::SimMomExit ( const UInt_t &  iparticle) const
overridevirtual

particle 4-momentum at exit point, all regions

Implements garana::G4Tree.

Definition at line 195 of file FlatG4Tree.cxx.

195  {
196 
197  //output vector
198  auto v = new vector<const TLorentzVector*>();
199 
200  //get index range
201  size_t ireg = LocalToGlobalIndex(iparticle)+1;
202  const size_t ireg_max = ireg-1 + 2*fNRegions->at(iparticle);
203 
204  //fill for all regions
205  //exit points are every other value and follow entry points
206  for(; ireg<ireg_max; ireg+=2){
207  v->push_back(new TLorentzVector(fPx->at(ireg), fPy->at(ireg),
208  fPz->at(ireg), fE->at(ireg)));
209  }
210  return v;
211 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Float_t > * fPy
particle&#39;s y-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:89
vector< UInt_t > * fNRegions
number of regions of interest cross by the particle
Definition: FlatG4Tree.h:74
vector< Float_t > * fE
particle&#39;s total energy in lab frame [GeV]
Definition: FlatG4Tree.h:91
vector< Float_t > * fPz
particle&#39;s z-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:90
vector< Float_t > * fPx
particle&#39;s x-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:88
const TLorentzVector * FlatG4Tree::SimMomExit ( const UInt_t &  iparticle,
const UInt_t &  iregion 
) const
overridevirtual

particle 4-momentum at exit point in region

Implements garana::G4Tree.

Definition at line 254 of file FlatG4Tree.cxx.

254  {
255  UInt_t index = LocalToGlobalIndex(iparticle) + 1 + iregion;
256  return new TLorentzVector(fPx->at(index), fPy->at(index), fPz->at(index), fE->at(index));
257 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Float_t > * fPy
particle&#39;s y-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:89
vector< Float_t > * fE
particle&#39;s total energy in lab frame [GeV]
Definition: FlatG4Tree.h:91
vector< Float_t > * fPz
particle&#39;s z-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:90
vector< Float_t > * fPx
particle&#39;s x-momentum in lab frame [GeV/c]
Definition: FlatG4Tree.h:88
const vector< const TLorentzVector * > * FlatG4Tree::SimPosEnter ( const UInt_t &  iparticle) const
overridevirtual

particle 4-position at entry point, all regions

Implements garana::G4Tree.

Definition at line 213 of file FlatG4Tree.cxx.

213  {
214 
215  //output vector
216  auto v = new vector<const TLorentzVector*>();
217 
218  //get index range
219  size_t ireg = LocalToGlobalIndex(iparticle);
220  size_t ireg_max = ireg+2*fNRegions->at(iparticle);
221 
222  //fill for all regions
223  //exit points are every other value and follow entry points
224  for(; ireg<ireg_max; ireg+=2){
225  v->push_back(new TLorentzVector(fX->at(ireg), fY->at(ireg),
226  fZ->at(ireg), fT->at(ireg)));
227  }
228  return v;
229 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< UInt_t > * fNRegions
number of regions of interest cross by the particle
Definition: FlatG4Tree.h:74
vector< Float_t > * fT
particle&#39;s time in lab frame [ns]
Definition: FlatG4Tree.h:87
vector< Float_t > * fY
particle&#39;s y-position in lab frame [cm]
Definition: FlatG4Tree.h:85
vector< Float_t > * fZ
particle&#39;s z-position in lab frame [cm]
Definition: FlatG4Tree.h:86
vector< Float_t > * fX
particle&#39;s x-position in lab frame [cm]
Definition: FlatG4Tree.h:84
const TLorentzVector * FlatG4Tree::SimPosEnter ( const UInt_t &  iparticle,
const UInt_t &  iregion 
) const
overridevirtual

particle 4-position at entry point in region

Implements garana::G4Tree.

Definition at line 259 of file FlatG4Tree.cxx.

259  {
260  UInt_t index = LocalToGlobalIndex(iparticle) + iregion;
261  return new TLorentzVector(fX->at(index), fY->at(index), fZ->at(index), fT->at(index));
262 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Float_t > * fT
particle&#39;s time in lab frame [ns]
Definition: FlatG4Tree.h:87
vector< Float_t > * fY
particle&#39;s y-position in lab frame [cm]
Definition: FlatG4Tree.h:85
vector< Float_t > * fZ
particle&#39;s z-position in lab frame [cm]
Definition: FlatG4Tree.h:86
vector< Float_t > * fX
particle&#39;s x-position in lab frame [cm]
Definition: FlatG4Tree.h:84
const vector< const TLorentzVector * > * FlatG4Tree::SimPosExit ( const UInt_t &  iparticle) const
overridevirtual

particle 4-position at exit point, all regions

Implements garana::G4Tree.

Definition at line 231 of file FlatG4Tree.cxx.

231  {
232 
233  //output vector
234  auto v = new vector<const TLorentzVector*>();
235 
236  //get index range
237  size_t ireg = LocalToGlobalIndex(iparticle)+1;
238  size_t ireg_max = ireg-1 + 2*fNRegions->at(iparticle);
239 
240  //fill for all regions
241  //exit points are every other value and follow entry points
242  for(; ireg<ireg_max; ireg+=2){
243  v->push_back(new TLorentzVector(fX->at(ireg), fY->at(ireg),
244  fZ->at(ireg), fT->at(ireg)));
245  }
246  return v;
247 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< UInt_t > * fNRegions
number of regions of interest cross by the particle
Definition: FlatG4Tree.h:74
vector< Float_t > * fT
particle&#39;s time in lab frame [ns]
Definition: FlatG4Tree.h:87
vector< Float_t > * fY
particle&#39;s y-position in lab frame [cm]
Definition: FlatG4Tree.h:85
vector< Float_t > * fZ
particle&#39;s z-position in lab frame [cm]
Definition: FlatG4Tree.h:86
vector< Float_t > * fX
particle&#39;s x-position in lab frame [cm]
Definition: FlatG4Tree.h:84
const TLorentzVector * FlatG4Tree::SimPosExit ( const UInt_t &  iparticle,
const UInt_t &  iregion 
) const
overridevirtual

particle 4-position at exit point in region

Implements garana::G4Tree.

Definition at line 263 of file FlatG4Tree.cxx.

263  {
264  UInt_t index = LocalToGlobalIndex(iparticle) + 1 + iregion;
265  return new TLorentzVector(fX->at(index), fY->at(index), fZ->at(index), fT->at(index));
266 }
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313
vector< Float_t > * fT
particle&#39;s time in lab frame [ns]
Definition: FlatG4Tree.h:87
vector< Float_t > * fY
particle&#39;s y-position in lab frame [cm]
Definition: FlatG4Tree.h:85
vector< Float_t > * fZ
particle&#39;s z-position in lab frame [cm]
Definition: FlatG4Tree.h:86
vector< Float_t > * fX
particle&#39;s x-position in lab frame [cm]
Definition: FlatG4Tree.h:84
const int FlatG4Tree::TrackID ( const UInt_t &  iparticle) const
overridevirtual

G4 track ID (can be <0 if it fell below trking threshold)

Implements garana::G4Tree.

Definition at line 276 of file FlatG4Tree.cxx.

276  {
277  return fTrkID->at(LocalToGlobalIndex(iparticle));
278 }
vector< Int_t > * fTrkID
particle&#39;s G4 trackID
Definition: FlatG4Tree.h:76
const UInt_t LocalToGlobalIndex(const UInt_t &iparticle) const
Definition: FlatG4Tree.cxx:313

Member Data Documentation

TBranch* garana::FlatG4Tree::b_E = nullptr
protected

Definition at line 113 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_NPts = nullptr
protected

Definition at line 95 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_NRegions = nullptr
protected

Definition at line 96 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_NSim = nullptr
protected

Definition at line 94 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_ParentPdg = nullptr
protected

Definition at line 100 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_ParentTrackId = nullptr
protected

Definition at line 102 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_PDG = nullptr
protected

Definition at line 99 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_ProcessF = nullptr
protected

Definition at line 105 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_ProcessI = nullptr
protected

Definition at line 104 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_ProgenitorPdg = nullptr
protected

Definition at line 101 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_ProgenitorTrackId = nullptr
protected

Definition at line 103 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_Px = nullptr
protected

Definition at line 110 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_Py = nullptr
protected

Definition at line 111 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_Pz = nullptr
protected

Definition at line 112 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_Regions = nullptr
protected

Definition at line 97 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_T = nullptr
protected

Definition at line 109 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_TrkID = nullptr
protected

Definition at line 98 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_X = nullptr
protected

Definition at line 106 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_Y = nullptr
protected

Definition at line 107 of file FlatG4Tree.h.

TBranch* garana::FlatG4Tree::b_Z = nullptr
protected

Definition at line 108 of file FlatG4Tree.h.

vector<Float_t>* garana::FlatG4Tree::fE = nullptr
protected

particle's total energy in lab frame [GeV]

Definition at line 91 of file FlatG4Tree.h.

std::map<UInt_t, std::pair<UInt_t,UInt_t> > garana::FlatG4Tree::fLimits
protected

for each array for a given particle

tree is completely flat so need first and last index

Definition at line 64 of file FlatG4Tree.h.

std::map<UInt_t,UInt_t> garana::FlatG4Tree::fLocalToGlobalIndex
protected

Definition at line 66 of file FlatG4Tree.h.

vector<UInt_t>* garana::FlatG4Tree::fNPts = nullptr
protected

number of 4-vector "snapshots" (G4 steps)

Definition at line 73 of file FlatG4Tree.h.

vector<UInt_t>* garana::FlatG4Tree::fNRegions = nullptr
protected

number of regions of interest cross by the particle

Definition at line 74 of file FlatG4Tree.h.

UInt_t garana::FlatG4Tree::fNSim = UINT_MAX
protected

number of G4 particles per event

Definition at line 72 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fParentPdg = nullptr
protected

particle parent's PDG code

Definition at line 78 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fParentTrackId = nullptr
protected

particle's parent's trackID

Definition at line 80 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fPDG = nullptr
protected

particle's PDG code

Definition at line 77 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fProcessF = nullptr
protected

process that killed the particle

Definition at line 83 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fProcessI = nullptr
protected

process that produced the particle

Definition at line 82 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fProgenitorPdg = nullptr
protected

FS particle from gen stage that led to this one.

Definition at line 79 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fProgenitorTrackId = nullptr
protected

FS particle from gen stage that led to this one.

Definition at line 81 of file FlatG4Tree.h.

vector<Float_t>* garana::FlatG4Tree::fPx = nullptr
protected

particle's x-momentum in lab frame [GeV/c]

Definition at line 88 of file FlatG4Tree.h.

vector<Float_t>* garana::FlatG4Tree::fPy = nullptr
protected

particle's y-momentum in lab frame [GeV/c]

Definition at line 89 of file FlatG4Tree.h.

vector<Float_t>* garana::FlatG4Tree::fPz = nullptr
protected

particle's z-momentum in lab frame [GeV/c]

Definition at line 90 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fRegions = nullptr
protected

region IDs

Definition at line 75 of file FlatG4Tree.h.

vector<Float_t>* garana::FlatG4Tree::fT = nullptr
protected

particle's time in lab frame [ns]

Definition at line 87 of file FlatG4Tree.h.

vector<Int_t>* garana::FlatG4Tree::fTrkID = nullptr
protected

particle's G4 trackID

Definition at line 76 of file FlatG4Tree.h.

vector<Float_t>* garana::FlatG4Tree::fX = nullptr
protected

particle's x-position in lab frame [cm]

Definition at line 84 of file FlatG4Tree.h.

vector<Float_t>* garana::FlatG4Tree::fY = nullptr
protected

particle's y-position in lab frame [cm]

Definition at line 85 of file FlatG4Tree.h.

vector<Float_t>* garana::FlatG4Tree::fZ = nullptr
protected

particle's z-position in lab frame [cm]

Definition at line 86 of file FlatG4Tree.h.


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