LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 
12 
13 namespace sim {
14  class EveIdCalculator;
15  class ParticleList;
16 }
17 
20 
23 
24 namespace art {
25  class ActivityRegistry;
26  class Event;
27 }
28 
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  public:
46  fhicl::Name("ParticleInventory"),
48  "This is the fhicl configuration for the ParticleInventory Service Provider")};
49  };
50 
51  //attempting to be compliant with ServiceUtil.h. Should ask LArSoft expert to review.
53  const provider_type* provider() const { return static_cast<const provider_type*>(this); }
54 
58 
59  //Move this function into the ParticleInventory.cpp file, and give it an appropriate CheckReady and Prep before the return.
60  const sim::ParticleList& ParticleList() const;
61 
62  void Rebuild(const art::Event& evt);
63 
64  void SetEveIdCalculator(sim::EveIdCalculator* ec) { ParticleInventory::SetEveIdCalculator(ec); }
65 
66  //Does this make sense? A track Id to a single particle? This is not a one to one relationship.
67  const simb::MCParticle* TrackIdToParticle_P(int id) const;
68  simb::MCParticle TrackIdToParticle(int const id) const
69  {
70  return *(this->TrackIdToParticle_P(id));
71  } //Users are encouraged to use TrackIdToParticleP
72 
73  const simb::MCParticle* TrackIdToMotherParticle_P(int id) const;
75  int const id) const //Users are encouraged to use TrackIdToMotherParticleP
76  {
77  return *(this->TrackIdToMotherParticle_P(id));
78  }
79 
80  const art::Ptr<simb::MCTruth>& TrackIdToMCTruth_P(int id) const;
82  int const id) const //Users are encouraged to use TrackIdToMCTruthP
83  {
84  return *(this->TrackIdToMCTruth_P(id));
85  }
86 
87  int TrackIdToEveTrackId(int tid) const;
88 
89  const art::Ptr<simb::MCTruth>& ParticleToMCTruth_P(
90  const simb::MCParticle* p) const; //Users are encouraged to use ParticleToMCTruthP
92  {
93  return *(this->ParticleToMCTruth_P(p));
94  }
95 
96  const std::vector<art::Ptr<simb::MCTruth>>& MCTruthVector_Ps()
97  const; //I don't want this to be able to return a vector of copies. Too much chance of significant memory usage.
98 
99  std::vector<const simb::MCParticle*> MCTruthToParticles_Ps(art::Ptr<simb::MCTruth> const& mct)
100  const; //I don't want this to be able to return a vector of copies. Too much chance of significant memory usage.
101 
102  std::set<int> GetSetOfTrackIds() const;
103  std::set<int> GetSetOfEveIds() const;
104 
105  private:
106  void priv_PrepEvent(const art::Event& evt, art::ScheduleContext);
107  void priv_PrepParticleList(const art::Event& evt);
108  void priv_PrepMCTruthList(const art::Event& evt);
109  void priv_PrepTrackIdToMCTruthIndex(const art::Event& evt);
110  bool priv_CanRun(const art::Event& evt) const;
111 
112  bool priv_ParticleListReady() { return ParticleInventory::ParticleListReady(); }
113  bool priv_MCTruthListReady() { return ParticleInventory::MCTruthListReady(); }
114  bool priv_TrackIdToMCTruthReady() { return ParticleInventory::TrackIdToMCTruthReady(); }
115  }; //class ParticleInventoryService
116 
117 } //namespace
118 
120 
121 #endif //CHEAT_PARTICLEINVENTORYSERVICESERVICE_H
simb::MCTruth TrackIdToMCTruth(int const id) const
void SetEveIdCalculator(sim::EveIdCalculator *ec)
Particle class.
simb::MCParticle TrackIdToParticle(int const id) const
#define DECLARE_ART_SERVICE(svc, scope)
parameter set interface
Monte Carlo Simulation.
simb::MCParticle TrackIdToMotherParticle(int const id) const
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:22
Header for the ParticleInvenotry Service Provider.
Definition: MVAAlg.h:12
TCEvent evt
Definition: DataStructs.cxx:8
Event generator information.
Definition: MCTruth.h:32
simb::MCTruth ParticleToMCTruth(const simb::MCParticle *p) const
const provider_type * provider() const