LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ParticleInventoryService.h
Go to the documentation of this file.
1 // \file ParticleInventoryService.h
3 // \brief A service for managing the ParticleInventory when run in art.
4 //
5 // \author jason.stock@mines.sdsmt.edu
6 // Based on the original BackTracker by Brian Rebel (brebel@fnal.gov)
8 #ifndef CHEAT_PARTICLEINVENTORYSERVICESERVICE_H
9 #define CHEAT_PARTICLEINVENTORYSERVICESERVICE_H
10 
11 #include <vector>
12 
14 
15 
17 #include "fhiclcpp/ParameterSet.h"
21 #include "art/Framework/Services/Registry/ServiceMacros.h" //Needed for Legacy support
22 
23 
28 
29 
30 
31 namespace cheat{
33  {
34  public:
35 
38  fhicl::Name("ParticleInventory"),
39  fhicl::Comment("This is the fhicl configuration for the ParticleInventory Service Provider") };
40  };
41 
42  //attempting to be compliant with ServiceUtil.h. Should ask LArSoft expert to review.
44  const provider_type* provider() const
45  { return static_cast<const provider_type*>(this); }
46 
47 
50 
51  //Move this function into the ParticleInventory.cpp file, and give it an appropriate CheckReady and Prep before the return.
53 
54  void Rebuild( const art::Event& evt );
55 
57 
58  //Does this make sense? A track Id to a single particle? This is not a one to one relationship.
59  const simb::MCParticle* TrackIdToParticle_P(int const& id);
61  { return *(this->TrackIdToParticle_P(id)); }//Users are encouraged to use TrackIdToParticleP
62 
63  const simb::MCParticle* TrackIdToMotherParticle_P(int const& id);
64  simb::MCParticle TrackIdToMotherParticle(int const& id)//Users are encouraged to use TrackIdToMotherParticleP
65  { return *(this->TrackIdToMotherParticle_P(id)); }
66 
67  const art::Ptr<simb::MCTruth>& TrackIdToMCTruth_P(int const& id);
68  simb::MCTruth TrackIdToMCTruth (int const& id)//Users are encouraged to use TrackIdToMCTruthP
69  { return *(this->TrackIdToMCTruth_P(id)); }
70 
71  int TrackIdToEveTrackId(const int& tid) const;
72 
73  const art::Ptr<simb::MCTruth>& ParticleToMCTruth_P(const simb::MCParticle* p); //Users are encouraged to use ParticleToMCTruthP
75  { return *(this->ParticleToMCTruth_P(p)); }
76 
77  const std::vector< art::Ptr<simb::MCTruth> >& MCTruthVector_Ps() ; //I don't want this to be able to return a vector of copies. Too much chance of significant memory usage.
78 
79  const std::vector<const simb::MCParticle*> MCTruthToParticles_Ps(art::Ptr<simb::MCTruth> const& mct) ; //I don't want this to be able to return a vector of copies. Too much chance of significant memory usage.
80 
81  std::set<int> GetSetOfTrackIds();
82  std::set<int> GetSetOfEveIds();
83 
84 
85 
86  private:
87 
88 
89  // for c2: remove unused data member
90  //const art::Event* fEvt=nullptr;
91 
92  void priv_PrepEvent ( const art::Event& evt );
93  void priv_PrepParticleList ( const art::Event& evt);
94  void priv_PrepMCTruthList ( const art::Event& evt);
95  void priv_PrepTrackIdToMCTruthIndex ( const art::Event& evt);
96  bool priv_CanRun(const art::Event& evt) const;
97 
101  };//class ParticleInventoryService
102 
103 }//namespace
104 
106 
107 
108 #endif //CHEAT_PARTICLEINVENTORYSERVICESERVICE_H
109 
const simb::MCParticle * TrackIdToParticle_P(int const &id)
bool MCTruthListReady() const
A simple check to determine if the MCTruthList has already been prepared and cached or not...
simb::MCParticle TrackIdToParticle(int const &id)
void SetEveIdCalculator(sim::EveIdCalculator *ec)
simb::MCTruth ParticleToMCTruth(const simb::MCParticle *p)
bool TrackIdToMCTruthReady() const
A simple check to determine if the TrackIdToMCTruth map has been prepared or not. ...
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p)
#define DECLARE_ART_SERVICE(svc, scope)
Definition: ServiceMacros.h:91
Particle class.
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector_Ps()
simb::MCTruth TrackIdToMCTruth(int const &id)
void SetEveIdCalculator(sim::EveIdCalculator *ec)
simb::MCParticle TrackIdToMotherParticle(int const &id)
Interface for calculating the "ultimate mother" of a particle in a simulated event.
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:26
bool ParticleListReady() const
A simple check to determine if the ParticleList has already been prepared for this event or not...
fhicl::Table< ParticleInventory::ParticleInventoryConfig > ParticleInventoryTable
ParticleInventoryService(const ParticleInventoryServiceConfig &config, art::ActivityRegistry &reg)
Header for the ParticleInvenotry Service Provider.
ParticleInventory(const ParticleInventoryConfig &config)
TCEvent evt
Definition: DataStructs.cxx:5
Event generator information.
Definition: MCTruth.h:30
void priv_PrepTrackIdToMCTruthIndex(const art::Event &evt)
const simb::MCParticle * TrackIdToMotherParticle_P(int const &id)
Particle list in DetSim contains Monte Carlo particle information.
bool priv_CanRun(const art::Event &evt) const
const provider_type * provider() const
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int const &id)
const std::vector< const simb::MCParticle * > MCTruthToParticles_Ps(art::Ptr< simb::MCTruth > const &mct)