ParticleInventoryService.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \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)
7 ////////////////////////////////////////////////////////////////////////
8 #ifndef CHEAT_PARTICLEINVENTORYSERVICESERVICE_H
9 #define CHEAT_PARTICLEINVENTORYSERVICESERVICE_H
10 
11 #include <vector>
12 
14 
15 
17 #include "fhiclcpp/ParameterSet.h"
18 #include "fhiclcpp/types/Table.h"
23 
24 
26 #include "nug4/ParticleNavigation/ParticleList.h"
27 #include "nug4/ParticleNavigation/EveIdCalculator.h"
29 
30 
31 
32 namespace cheat{
34  {
35  public:
36 
39  fhicl::Name("ParticleInventory"),
40  fhicl::Comment("This is the fhicl configuration for the ParticleInventory Service Provider") };
41  };
42 
43  //attempting to be compliant with ServiceUtil.h. Should ask LArSoft expert to review.
45  const provider_type* provider() const
46  { return static_cast<const provider_type*>(this); }
47 
48 
51 
52  //Move this function into the ParticleInventory.cpp file, and give it an appropriate CheckReady and Prep before the return.
53  const sim::ParticleList& ParticleList() const;
54 
55  void Rebuild( const art::Event& evt );
56 
57  void SetEveIdCalculator(sim::EveIdCalculator *ec) { ParticleInventory::SetEveIdCalculator(ec); }
58 
59  //Does this make sense? A track Id to a single particle? This is not a one to one relationship.
60  const simb::MCParticle* TrackIdToParticle_P(int id) const;
61  simb::MCParticle TrackIdToParticle(int const id) const
62  { return *(this->TrackIdToParticle_P(id)); }//Users are encouraged to use TrackIdToParticleP
63 
64  const simb::MCParticle* TrackIdToMotherParticle_P(int id) const;
65  simb::MCParticle TrackIdToMotherParticle(int const id) const //Users are encouraged to use TrackIdToMotherParticleP
66  { return *(this->TrackIdToMotherParticle_P(id)); }
67 
68  const art::Ptr<simb::MCTruth>& TrackIdToMCTruth_P(int id) const;
69  simb::MCTruth TrackIdToMCTruth (int const id) const //Users are encouraged to use TrackIdToMCTruthP
70  { return *(this->TrackIdToMCTruth_P(id)); }
71 
72  int TrackIdToEveTrackId(int tid) const;
73 
74  const art::Ptr<simb::MCTruth>& ParticleToMCTruth_P(const simb::MCParticle* p) const; //Users are encouraged to use ParticleToMCTruthP
76  { return *(this->ParticleToMCTruth_P(p)); }
77 
78  const std::vector< art::Ptr<simb::MCTruth> >& MCTruthVector_Ps() const; //I don't want this to be able to return a vector of copies. Too much chance of significant memory usage.
79 
80  std::vector<const simb::MCParticle*> MCTruthToParticles_Ps(art::Ptr<simb::MCTruth> const& mct) const; //I don't want this to be able to return a vector of copies. Too much chance of significant memory usage.
81 
82  std::set<int> GetSetOfTrackIds() const;
83  std::set<int> GetSetOfEveIds() const;
84 
85 
86 
87  private:
88 
90  void priv_PrepParticleList ( const art::Event& evt);
91  void priv_PrepMCTruthList ( const art::Event& evt);
92  void priv_PrepTrackIdToMCTruthIndex ( const art::Event& evt);
93  bool priv_CanRun(const art::Event& evt) const;
94 
98  };//class ParticleInventoryService
99 
100 }//namespace
101 
103 
104 
105 #endif //CHEAT_PARTICLEINVENTORYSERVICESERVICE_H
simb::MCTruth TrackIdToMCTruth(int const id) const
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector_Ps() const
bool MCTruthListReady() const
A simple check to determine if the MCTruthList has already been prepared and cached or not...
const simb::MCParticle * TrackIdToParticle_P(int id) const
void SetEveIdCalculator(sim::EveIdCalculator *ec)
bool TrackIdToMCTruthReady() const
A simple check to determine if the TrackIdToMCTruth map has been prepared or not. ...
ChannelGroupService::Name Name
std::vector< const simb::MCParticle * > MCTruthToParticles_Ps(art::Ptr< simb::MCTruth > const &mct) const
Particle class.
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p) const
void SetEveIdCalculator(sim::EveIdCalculator *ec)
simb::MCParticle TrackIdToParticle(int const id) const
void priv_PrepEvent(const art::Event &evt, art::ScheduleContext)
#define DECLARE_ART_SERVICE(svc, scope)
static Config * config
Definition: config.cpp:1054
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
p
Definition: test.py:223
const sim::ParticleList & ParticleList() const
simb::MCParticle TrackIdToMotherParticle(int const id) const
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:22
#define Comment
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:7
Event generator information.
Definition: MCTruth.h:32
const simb::MCParticle * TrackIdToMotherParticle_P(int id) const
void priv_PrepTrackIdToMCTruthIndex(const art::Event &evt)
simb::MCTruth ParticleToMCTruth(const simb::MCParticle *p) const
bool priv_CanRun(const art::Event &evt) const
const provider_type * provider() const