All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
12 
13 namespace sim {
14  class EveIdCalculator;
15  class ParticleList;
16 }
17 
18 #include "nusimdata/SimulationBase/MCParticle.h"
19 #include "nusimdata/SimulationBase/MCTruth.h"
20 
21 #include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"
22 #include "art/Persistency/Provenance/ScheduleContext.h"
23 
24 namespace art {
25  class ActivityRegistry;
26  class Event;
27 }
28 
29 #include "canvas/Persistency/Common/Ptr.h"
30 #include "fhiclcpp/types/Comment.h"
31 #include "fhiclcpp/types/Name.h"
32 #include "fhiclcpp/types/Table.h"
33 
34 namespace fhicl {
35  class ParameterSet;
36 }
37 
38 #include <set>
39 #include <vector>
40 
41 namespace cheat{
43  {
44  public:
45 
47  fhicl::Table<ParticleInventory::ParticleInventoryConfig> ParticleInventoryTable{
48  fhicl::Name("ParticleInventory"),
49  fhicl::Comment("This is the fhicl configuration for the ParticleInventory Service Provider") };
50  };
51 
52  //attempting to be compliant with ServiceUtil.h. Should ask LArSoft expert to review.
54  const provider_type* provider() const
55  { return static_cast<const provider_type*>(this); }
56 
57 
58  ParticleInventoryService(const ParticleInventoryServiceConfig& config, art::ActivityRegistry& reg);
59  ParticleInventoryService(fhicl::ParameterSet const& pset, art::ActivityRegistry& reg);
60 
61  //Move this function into the ParticleInventory.cpp file, and give it an appropriate CheckReady and Prep before the return.
62  const sim::ParticleList& ParticleList() const;
63 
64  void Rebuild( const art::Event& evt );
65 
66  void SetEveIdCalculator(sim::EveIdCalculator *ec) { ParticleInventory::SetEveIdCalculator(ec); }
67 
68  //Does this make sense? A track Id to a single particle? This is not a one to one relationship.
69  const simb::MCParticle* TrackIdToParticle_P(int id) const;
70  simb::MCParticle TrackIdToParticle(int const id) const
71  { return *(this->TrackIdToParticle_P(id)); }//Users are encouraged to use TrackIdToParticleP
72 
73  const simb::MCParticle* TrackIdToMotherParticle_P(int id) const;
74  simb::MCParticle TrackIdToMotherParticle(int const id) const //Users are encouraged to use TrackIdToMotherParticleP
75  { return *(this->TrackIdToMotherParticle_P(id)); }
76 
77  const art::Ptr<simb::MCTruth>& TrackIdToMCTruth_P(int id) const;
78  simb::MCTruth TrackIdToMCTruth (int const id) const //Users are encouraged to use TrackIdToMCTruthP
79  { return *(this->TrackIdToMCTruth_P(id)); }
80 
81  int TrackIdToEveTrackId(int tid) const;
82 
83  const art::Ptr<simb::MCTruth>& ParticleToMCTruth_P(const simb::MCParticle* p) const; //Users are encouraged to use ParticleToMCTruthP
84  simb::MCTruth ParticleToMCTruth (const simb::MCParticle* p) const
85  { return *(this->ParticleToMCTruth_P(p)); }
86 
87  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.
88 
89  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.
90 
91  std::set<int> GetSetOfTrackIds() const;
92  std::set<int> GetSetOfEveIds() const;
93 
94 
95 
96  private:
97 
98  void priv_PrepEvent ( const art::Event& evt, art::ScheduleContext);
99  void priv_PrepParticleList ( const art::Event& evt);
100  void priv_PrepMCTruthList ( const art::Event& evt);
101  void priv_PrepTrackIdToMCTruthIndex ( const art::Event& evt);
102  bool priv_CanRun(const art::Event& evt) const;
103 
107  };//class ParticleInventoryService
108 
109 }//namespace
110 
111 DECLARE_ART_SERVICE(cheat::ParticleInventoryService, LEGACY)
112 
113 
114 #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
pdgs p
Definition: selectors.fcl:22
void SetEveIdCalculator(sim::EveIdCalculator *ec)
bool TrackIdToMCTruthReady() const
A simple check to determine if the TrackIdToMCTruth map has been prepared or not. ...
std::vector< const simb::MCParticle * > MCTruthToParticles_Ps(art::Ptr< simb::MCTruth > const &mct) const
void priv_PrepParticleList(const art::Event &evt)
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)
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
BEGIN_PROLOG vertical distance to the surface Name
const sim::ParticleList & ParticleList() const
simb::MCParticle TrackIdToMotherParticle(int const id) const
void priv_PrepMCTruthList(const art::Event &evt)
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.
void Rebuild(const art::Event &evt)
ParticleInventory(const ParticleInventoryConfig &config)
TCEvent evt
Definition: DataStructs.cxx:8
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