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::MCParticleTrackIdToParticle_P (int id) const
 
simb::MCParticle TrackIdToParticle (int const id) const
 
const simb::MCParticleTrackIdToMotherParticle_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::MCParticleTrackIdToParticle_P (int const &id) const
 
simb::MCParticle TrackIdToParticle (int const &id) const
 
const simb::MCParticleTrackIdToMotherParticle_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 33 of file ParticleInventoryService.h.

Member Typedef Documentation

Definition at line 44 of file ParticleInventoryService.h.

Constructor & Destructor Documentation

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

Definition at line 41 of file ParticleInventoryService_service.cc.

42  :ParticleInventory(config.ParticleInventoryTable())
43  {
44 // std::cout<<"Config Dump from ParticleInventoryService using fhicl Table\n";
45 // config.ParticleInventoryTable.print_allowed_configuration(std::cout);
47  }
void priv_PrepEvent(const art::Event &evt, art::ScheduleContext)
static Config * config
Definition: config.cpp:1054
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &, ScheduleContext)> sPreProcessEvent
ParticleInventory(const ParticleInventoryConfig &config)
cheat::ParticleInventoryService::ParticleInventoryService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Member Function Documentation

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

Definition at line 175 of file ParticleInventoryService_service.cc.

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

Definition at line 169 of file ParticleInventoryService_service.cc.

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

Definition at line 161 of file ParticleInventoryService_service.cc.

162  {
163 // if(!this->priv_ParticleListReady()){this->priv_PrepParticleList();}
164 // if(!this->priv_MCTruthListReady()){this->priv_PrepMCTruthList();}
165 // Not used for non-lazy mode
167  }
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 120 of file ParticleInventoryService_service.cc.

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

Definition at line 114 of file ParticleInventoryService_service.cc.

114  {
115 // if(!this->priv_ParticleListReady()){this->priv_PrepParticleList();}
116 // Not used for non lazy functions
118  } //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 75 of file ParticleInventoryService.h.

76  { return *(this->ParticleToMCTruth_P(p)); }
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 154 of file ParticleInventoryService_service.cc.

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

Definition at line 74 of file ParticleInventoryService_service.cc.

74  {
75  return ParticleInventory::CanRun(evt);
76  }
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 ...
bool cheat::ParticleInventoryService::priv_MCTruthListReady ( )
inlineprivate

Definition at line 96 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 95 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 63 of file ParticleInventoryService_service.cc.

63  {
64  //fEvt=&evt;
66  if( ! this->priv_CanRun(evt) ) { return; }
67  this->priv_PrepParticleList(evt);
68  this->priv_PrepMCTruthList(evt);
70  //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.
71  }
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 98 of file ParticleInventoryService_service.cc.

98  {
99 // if(!this->priv_CanRun(*fEvt)){throw;}
100  if(!this->priv_CanRun(evt)){throw;}
101  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.
103  //try{ ParticleInventory::PrepMCTruthList(*fEvt); }
104  catch(...){ mf::LogWarning("ParticleInventory") << "Rebuild failed to get the MCParticles. This is expected when running on a generation or simulation step.";}
105  //ToDo. Find out exactly which exception is thrown and catch only that.
106 
107  }//End PrepMCTruthList
void PrepMCTruthList(const Evt &evt) const
A function to load and cache the MCTruthList of the event.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
bool priv_CanRun(const art::Event &evt) const
void cheat::ParticleInventoryService::priv_PrepParticleList ( const art::Event evt)
private

Definition at line 79 of file ParticleInventoryService_service.cc.

79  {
80  if(!this->priv_CanRun(evt)) {throw;}
81  //if(!this->priv_CanRun(*fEvt)) {throw;}
82  if(this->priv_ParticleListReady()){ return; }
83  //try{ParticleInventory::PrepParticleList(*fEvt);}
85  catch(...){ mf::LogWarning("ParticleInventory") << "Rebuild failed to get the MCParticles. This is expected when running on a generation or simulation step.";}
86  }
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...
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
bool priv_CanRun(const art::Event &evt) const
void cheat::ParticleInventoryService::priv_PrepTrackIdToMCTruthIndex ( const art::Event evt)
private

Definition at line 89 of file ParticleInventoryService_service.cc.

89  {
90  if(!this->priv_CanRun(evt)){throw;}
91  //if(!this->priv_CanRun(*fEvt)){throw;}
92  if( this->priv_TrackIdToMCTruthReady()){ return; }
93  //try{ParticleInventory::PrepTrackIdToMCTruthIndex(*fEvt);}
95  catch(...){ mf::LogWarning("ParticleInventory") << "Rebuild failed to get the MCParticles. This is expected when running on a generation or simulation step.";}
96  }//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...
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
bool priv_CanRun(const art::Event &evt) const
bool cheat::ParticleInventoryService::priv_TrackIdToMCTruthReady ( )
inlineprivate

Definition at line 97 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 45 of file ParticleInventoryService.h.

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

Definition at line 58 of file ParticleInventoryService_service.cc.

58  {
60  }
void priv_PrepEvent(const art::Event &evt, art::ScheduleContext)
static ScheduleContext invalid()
void cheat::ParticleInventoryService::SetEveIdCalculator ( sim::EveIdCalculator *  ec)
inline

Definition at line 57 of file ParticleInventoryService.h.

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

Definition at line 149 of file ParticleInventoryService_service.cc.

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

Definition at line 69 of file ParticleInventoryService.h.

70  { 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 142 of file ParticleInventoryService_service.cc.

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

Definition at line 65 of file ParticleInventoryService.h.

66  { 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 135 of file ParticleInventoryService_service.cc.

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

Definition at line 61 of file ParticleInventoryService.h.

62  { 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 128 of file ParticleInventoryService_service.cc.

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

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