All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | List of all members
cheat::ParticleInventoryService Class Reference

#include <ParticleInventoryService.h>

Inheritance diagram for cheat::ParticleInventoryService:
cheat::ParticleInventory

Classes

struct  ParticleInventoryServiceConfig
 

Public Types

using provider_type = ParticleInventory
 

Public Member Functions

const provider_typeprovider () const
 
 ParticleInventoryService (const ParticleInventoryServiceConfig &config, art::ActivityRegistry &reg)
 
 ParticleInventoryService (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
const sim::ParticleList & ParticleList () const
 
void Rebuild (const art::Event &evt)
 
void SetEveIdCalculator (sim::EveIdCalculator *ec)
 
const simb::MCParticle * TrackIdToParticle_P (int id) const
 
simb::MCParticle TrackIdToParticle (int const id) const
 
const simb::MCParticle * TrackIdToMotherParticle_P (int id) const
 
simb::MCParticle TrackIdToMotherParticle (int const id) const
 
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P (int id) const
 
simb::MCTruth TrackIdToMCTruth (int const id) const
 
int TrackIdToEveTrackId (int tid) const
 
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P (const simb::MCParticle *p) const
 
simb::MCTruth ParticleToMCTruth (const simb::MCParticle *p) const
 
const std::vector< art::Ptr
< simb::MCTruth > > & 
MCTruthVector_Ps () const
 
std::vector< const
simb::MCParticle * > 
MCTruthToParticles_Ps (art::Ptr< simb::MCTruth > const &mct) const
 
std::set< int > GetSetOfTrackIds () const
 
std::set< int > GetSetOfEveIds () const
 

Private Member Functions

void priv_PrepEvent (const art::Event &evt, art::ScheduleContext)
 
void priv_PrepParticleList (const art::Event &evt)
 
void priv_PrepMCTruthList (const art::Event &evt)
 
void priv_PrepTrackIdToMCTruthIndex (const art::Event &evt)
 
bool priv_CanRun (const art::Event &evt) const
 
bool priv_ParticleListReady ()
 
bool priv_MCTruthListReady ()
 
bool priv_TrackIdToMCTruthReady ()
 
- Private Member Functions inherited from cheat::ParticleInventory
 ParticleInventory (const ParticleInventoryConfig &config)
 
 ParticleInventory (const fhicl::ParameterSet &pSet)
 
 ParticleInventory (ParticleInventory const &)=delete
 
template<typename Evt >
void PrepEvent (const Evt &evt)
 Function to set up the ParticleInventory state for an event. This is a function to tell the ParticleInventory to prepare itself to work with a particular event. More...
 
bool ParticleListReady () const
 A simple check to determine if the ParticleList has already been prepared for this event or not. More...
 
bool MCTruthListReady () const
 A simple check to determine if the MCTruthList has already been prepared and cached or not. More...
 
bool TrackIdToMCTruthReady () const
 A simple check to determine if the TrackIdToMCTruth map has been prepared or not. More...
 
template<typename Evt >
void PrepParticleList (const Evt &evt) const
 A function to load the ParticleList and cache it This function will find the particle list and load it for later use. Ideally this would would be used for a "lazy" loading of the backtracker, but this does not work in the current setup of art. More...
 
template<typename Evt >
void PrepTrackIdToMCTruthIndex (const Evt &evt) const
 A function to prepare and cache a map of TrackIds and MCTruth object indicies from fMCTruthList. More...
 
template<typename Evt >
void PrepMCTruthList (const Evt &evt) const
 A function to load and cache the MCTruthList of the event. More...
 
template<typename Evt >
void PrepMCTruthListAndTrackIdToMCTruthIndex (const Evt &evt) const
 A function to make both PrepTrackIdToMCTruthIndex and PrepMCTruthList run when both are needed. More...
 
template<typename Evt >
bool CanRun (const Evt &evt) const
 A short function to check if use of the backtracker is appropriate or not based on the type of input file. This function simply checks to see if the file loaded is real data, or MC Simulation, as backtracking on real data makes no sense. If one does try to backtrack real data, this will throw and exception. More...
 
const sim::ParticleList & ParticleList () const
 
void SetEveIdCalculator (sim::EveIdCalculator *ec)
 
const std::vector< art::Ptr
< simb::MCTruth > > & 
MCTruthList () const
 
const std::map< int, int > & TrackIdToMCTruthIndex () const
 
void ClearEvent ()
 
const simb::MCParticle * TrackIdToParticle_P (int const &id) const
 
simb::MCParticle TrackIdToParticle (int const &id) const
 
const simb::MCParticle * TrackIdToMotherParticle_P (int const &id) const
 
simb::MCParticle TrackIdToMotherParticle (int const &id) const
 
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P (int const &id) const
 
simb::MCTruth TrackIdToMCTruth (int const &id) const
 
int TrackIdToEveTrackId (const int &tid) const
 
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P (const simb::MCParticle *p) const
 
simb::MCTruth ParticleToMCTruth (const simb::MCParticle *p) const
 
const std::vector< art::Ptr
< simb::MCTruth > > & 
MCTruthVector_Ps () const
 
std::vector< const
simb::MCParticle * > 
MCTruthToParticles_Ps (art::Ptr< simb::MCTruth > const &mct) const
 
std::set< int > GetSetOfTrackIds () const
 
std::set< int > GetSetOfEveIds () const
 

Detailed Description

Definition at line 42 of file ParticleInventoryService.h.

Member Typedef Documentation

Definition at line 53 of file ParticleInventoryService.h.

Constructor & Destructor Documentation

cheat::ParticleInventoryService::ParticleInventoryService ( const ParticleInventoryServiceConfig config,
art::ActivityRegistry &  reg 
)

Definition at line 39 of file ParticleInventoryService.cc.

40  :ParticleInventory(config.ParticleInventoryTable())
41  {
42 // std::cout<<"Config Dump from ParticleInventoryService using fhicl Table\n";
43 // config.ParticleInventoryTable.print_allowed_configuration(std::cout);
44  reg.sPreProcessEvent.watch(this, &ParticleInventoryService::priv_PrepEvent);
45  }
void priv_PrepEvent(const art::Event &evt, art::ScheduleContext)
ParticleInventory(const ParticleInventoryConfig &config)
cheat::ParticleInventoryService::ParticleInventoryService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry &  reg 
)

Definition at line 48 of file ParticleInventoryService.cc.

49  :ParticleInventory(pSet.get<fhicl::ParameterSet>("ParticleInventory"))
50  {
51 // std::cout<<"\n\n\n\nConfigDump from ParticleInventoryService using ParameterSet.\n"<<pSet.to_string()<<"\n\n\n\n";
52  reg.sPreProcessEvent.watch(this, &ParticleInventoryService::priv_PrepEvent);
53  }
void priv_PrepEvent(const art::Event &evt, art::ScheduleContext)
ParticleInventory(const ParticleInventoryConfig &config)

Member Function Documentation

std::set< int > cheat::ParticleInventoryService::GetSetOfEveIds ( ) const

Definition at line 173 of file ParticleInventoryService.cc.

173  {
174 // if(!this->priv_ParticleListReady()){this->priv_PrepParticleList();}
175 // Not used for non-lazy mode
177  }
std::set< int > GetSetOfEveIds() const
std::set< int > cheat::ParticleInventoryService::GetSetOfTrackIds ( ) const

Definition at line 167 of file ParticleInventoryService.cc.

167  {
168 // if(!this->priv_ParticleListReady()){this->priv_PrepParticleList();}
169 // Not used for non-lazy mode
171  }
std::set< int > GetSetOfTrackIds() const
std::vector< const simb::MCParticle * > cheat::ParticleInventoryService::MCTruthToParticles_Ps ( art::Ptr< simb::MCTruth > const &  mct) const

Definition at line 159 of file ParticleInventoryService.cc.

160  {
161 // if(!this->priv_ParticleListReady()){this->priv_PrepParticleList();}
162 // if(!this->priv_MCTruthListReady()){this->priv_PrepMCTruthList();}
163 // Not used for non-lazy mode
165  }
std::vector< const simb::MCParticle * > MCTruthToParticles_Ps(art::Ptr< simb::MCTruth > const &mct) const
const std::vector< art::Ptr< simb::MCTruth > > & cheat::ParticleInventoryService::MCTruthVector_Ps ( ) const

Definition at line 118 of file ParticleInventoryService.cc.

118  {
119  //if(!this->priv_MCTruthListReady()){priv_PrepMCTruthList();}
120  // Not used for non-lazy mode
122  }
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector_Ps() const
const sim::ParticleList & cheat::ParticleInventoryService::ParticleList ( ) const

Definition at line 112 of file ParticleInventoryService.cc.

112  {
113 // if(!this->priv_ParticleListReady()){this->priv_PrepParticleList();}
114 // Not used for non lazy functions
116  } //This should be replaced with a public struct so we can get away from the nutools dependency.
const sim::ParticleList & ParticleList() const
simb::MCTruth cheat::ParticleInventoryService::ParticleToMCTruth ( const simb::MCParticle *  p) const
inline

Definition at line 84 of file ParticleInventoryService.h.

85  { return *(this->ParticleToMCTruth_P(p)); }
pdgs p
Definition: selectors.fcl:22
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p) const
const art::Ptr< simb::MCTruth > & cheat::ParticleInventoryService::ParticleToMCTruth_P ( const simb::MCParticle *  p) const

Definition at line 152 of file ParticleInventoryService.cc.

153  {
154 // if(!this->priv_TrackIdToMCTruthReady()){this->priv_PrepTrackIdToMCTruthIndex();}
155 // Not used for non-lazy mode
156  return this->TrackIdToMCTruth_P(p->TrackId());
157  }
pdgs p
Definition: selectors.fcl:22
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
bool cheat::ParticleInventoryService::priv_CanRun ( const art::Event &  evt) const
private

Definition at line 72 of file ParticleInventoryService.cc.

72  {
74  }
bool CanRun(const Evt &evt) const
A short function to check if use of the backtracker is appropriate or not based on the type of input ...
TCEvent evt
Definition: DataStructs.cxx:8
bool cheat::ParticleInventoryService::priv_MCTruthListReady ( )
inlineprivate

Definition at line 105 of file ParticleInventoryService.h.

bool MCTruthListReady() const
A simple check to determine if the MCTruthList has already been prepared and cached or not...
bool cheat::ParticleInventoryService::priv_ParticleListReady ( )
inlineprivate

Definition at line 104 of file ParticleInventoryService.h.

bool ParticleListReady() const
A simple check to determine if the ParticleList has already been prepared for this event or not...
void cheat::ParticleInventoryService::priv_PrepEvent ( const art::Event &  evt,
art::ScheduleContext   
)
private

Definition at line 61 of file ParticleInventoryService.cc.

61  {
62  //fEvt=&evt;
64  if( ! this->priv_CanRun(evt) ) { return; }
68  //fEvt=nullptr; //dont keep the cached pointer since it will expire right after this, and I want to make sure bad calls to prep functions fail.
69  }
void priv_PrepParticleList(const art::Event &evt)
void priv_PrepMCTruthList(const art::Event &evt)
TCEvent evt
Definition: DataStructs.cxx:8
void priv_PrepTrackIdToMCTruthIndex(const art::Event &evt)
bool priv_CanRun(const art::Event &evt) const
void cheat::ParticleInventoryService::priv_PrepMCTruthList ( const art::Event &  evt)
private

Definition at line 96 of file ParticleInventoryService.cc.

96  {
97 // if(!this->priv_CanRun(*fEvt)){throw;}
98  if(!this->priv_CanRun(evt)){throw;}
99  if(this->priv_MCTruthListReady( ) ){ return;} //If the event is data or if the truth list is already built there is nothing for us to do.
101  //try{ ParticleInventory::PrepMCTruthList(*fEvt); }
102  catch(...){ mf::LogWarning("ParticleInventory") << "Rebuild failed to get the MCParticles. This is expected when running on a generation or simulation step.";}
103  //ToDo. Find out exactly which exception is thrown and catch only that.
104 
105  }//End PrepMCTruthList
void PrepMCTruthList(const Evt &evt) const
A function to load and cache the MCTruthList of the event.
TCEvent evt
Definition: DataStructs.cxx:8
bool priv_CanRun(const art::Event &evt) const
void cheat::ParticleInventoryService::priv_PrepParticleList ( const art::Event &  evt)
private

Definition at line 77 of file ParticleInventoryService.cc.

77  {
78  if(!this->priv_CanRun(evt)) {throw;}
79  //if(!this->priv_CanRun(*fEvt)) {throw;}
80  if(this->priv_ParticleListReady()){ return; }
81  //try{ParticleInventory::PrepParticleList(*fEvt);}
83  catch(...){ mf::LogWarning("ParticleInventory") << "Rebuild failed to get the MCParticles. This is expected when running on a generation or simulation step.";}
84  }
void PrepParticleList(const Evt &evt) const
A function to load the ParticleList and cache it This function will find the particle list and load i...
TCEvent evt
Definition: DataStructs.cxx:8
bool priv_CanRun(const art::Event &evt) const
void cheat::ParticleInventoryService::priv_PrepTrackIdToMCTruthIndex ( const art::Event &  evt)
private

Definition at line 87 of file ParticleInventoryService.cc.

87  {
88  if(!this->priv_CanRun(evt)){throw;}
89  //if(!this->priv_CanRun(*fEvt)){throw;}
90  if( this->priv_TrackIdToMCTruthReady()){ return; }
91  //try{ParticleInventory::PrepTrackIdToMCTruthIndex(*fEvt);}
93  catch(...){ mf::LogWarning("ParticleInventory") << "Rebuild failed to get the MCParticles. This is expected when running on a generation or simulation step.";}
94  }//End priv_PrepTrackIdToMCTruthIndexList
void PrepTrackIdToMCTruthIndex(const Evt &evt) const
A function to prepare and cache a map of TrackIds and MCTruth object indicies from fMCTruthList...
TCEvent evt
Definition: DataStructs.cxx:8
bool priv_CanRun(const art::Event &evt) const
bool cheat::ParticleInventoryService::priv_TrackIdToMCTruthReady ( )
inlineprivate

Definition at line 106 of file ParticleInventoryService.h.

bool TrackIdToMCTruthReady() const
A simple check to determine if the TrackIdToMCTruth map has been prepared or not. ...
const provider_type* cheat::ParticleInventoryService::provider ( ) const
inline

Definition at line 54 of file ParticleInventoryService.h.

55  { return static_cast<const provider_type*>(this); }
void cheat::ParticleInventoryService::Rebuild ( const art::Event &  evt)

Definition at line 56 of file ParticleInventoryService.cc.

56  {
57  this->priv_PrepEvent(evt, art::ScheduleContext::invalid());
58  }
void priv_PrepEvent(const art::Event &evt, art::ScheduleContext)
TCEvent evt
Definition: DataStructs.cxx:8
void cheat::ParticleInventoryService::SetEveIdCalculator ( sim::EveIdCalculator *  ec)
inline

Definition at line 66 of file ParticleInventoryService.h.

void SetEveIdCalculator(sim::EveIdCalculator *ec)
int cheat::ParticleInventoryService::TrackIdToEveTrackId ( int  tid) const

Definition at line 147 of file ParticleInventoryService.cc.

148  {
150  }
int TrackIdToEveTrackId(const int &tid) const
simb::MCTruth cheat::ParticleInventoryService::TrackIdToMCTruth ( int const  id) const
inline

Definition at line 78 of file ParticleInventoryService.h.

79  { return *(this->TrackIdToMCTruth_P(id)); }
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
const art::Ptr< simb::MCTruth > & cheat::ParticleInventoryService::TrackIdToMCTruth_P ( int  id) const

Definition at line 140 of file ParticleInventoryService.cc.

141  {
142 // if(!this->priv_TrackIdToMCTruthReady()){this->priv_PrepTrackIdToMCTruthIndex();}
143 // Not used for non-lazy mode
145  }
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int const &id) const
simb::MCParticle cheat::ParticleInventoryService::TrackIdToMotherParticle ( int const  id) const
inline

Definition at line 74 of file ParticleInventoryService.h.

75  { return *(this->TrackIdToMotherParticle_P(id)); }
const simb::MCParticle * TrackIdToMotherParticle_P(int id) const
const simb::MCParticle * cheat::ParticleInventoryService::TrackIdToMotherParticle_P ( int  id) const

Definition at line 133 of file ParticleInventoryService.cc.

134  {
135 // if(!this->priv_ParticleListReady()){this->priv_PrepParticleList();}
136 // Not used for non-lazy mode
138  }
const simb::MCParticle * TrackIdToMotherParticle_P(int const &id) const
simb::MCParticle cheat::ParticleInventoryService::TrackIdToParticle ( int const  id) const
inline

Definition at line 70 of file ParticleInventoryService.h.

71  { return *(this->TrackIdToParticle_P(id)); }//Users are encouraged to use TrackIdToParticleP
const simb::MCParticle * TrackIdToParticle_P(int id) const
const simb::MCParticle * cheat::ParticleInventoryService::TrackIdToParticle_P ( int  id) const

Definition at line 126 of file ParticleInventoryService.cc.

126  {
127 // if(!this->priv_ParticleListReady()){this->priv_PrepParticleList();}
128 // Not used for non-lazy mode
130  }//End TrackIdToParticle
const simb::MCParticle * TrackIdToParticle_P(int const &id) const

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