LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
old.PhotonBackTrackerService.h
Go to the documentation of this file.
1 // \adapted from BackTracker.h by brebel@fnal.gov
8 #ifndef CHEAT_PHOTONBACKTRACKERER_H
9 #define CHEAT_PHOTONBACKTRACKERER_H
10 #ifdef __GNUC__
11 #define DEPRECATED __attribute__((deprecated))
12 #else
13 #define DEPRECATED
14 #endif
15 
16 #include <vector>
17 
21 #include "fhiclcpp/ParameterSet.h"
22 
33 
35 
36 /*namespace recob{
37  class SpacePoint;
38 }*/
39 
41 namespace cheat {
42 
43  class PhotonBackTracker {
44 
45  public:
48 
49  void reconfigure(fhicl::ParameterSet const& pset);
50 
51  // The Rebuild function rebuilds the various maps we need to answer backtracking queries.
52  // It is called automatically before each event is processed. For jobs involving
53  // Monte Carlo generation, this is too soon. So, we'll call rebuild after those data
54  // products are put into the event in LArG4. This is the least bad way of ensuring the
55  // PhotonBackTracker works in jobs that combine MC production and reconstruction analysis based
56  // on MC truth. Don't copy this design pattern without talking to brebel@fnal.gov first
57  void Rebuild(const art::Event& evt);
58 
59  // Get a reference to the ParticleList
60  const sim::ParticleList& ParticleList() const { return fParticleList; }
61 
62  // Set the EveIdCalculator for the owned ParticleList
64 
65  // Return a pointer to the simb::MCParticle object corresponding to
66  // the given TrackID
67  const simb::MCParticle* TrackIDToParticle(int const& id) const;
68  const simb::MCParticle* TrackIDToMotherParticle(int const& id) const;
69 
70  std::vector<sim::SDP> TrackIDToSimSDP(int const& id) const;
71 
72  // Get art::Ptr<> to simb::MCTruth and related information
73  const art::Ptr<simb::MCTruth>& TrackIDToMCTruth(int const& id) const;
75  std::vector<const simb::MCParticle*> MCTruthToParticles(
76  art::Ptr<simb::MCTruth> const& mct) const;
77  const std::vector<art::Ptr<simb::MCTruth>>& MCTruthVector() const { return fMCTruthList; }
78 
79  // this method will return the Geant4 track IDs of
80  // the particles contributing ionization electrons to the identified hit
81  DEPRECATED std::vector<sim::TrackSDP> OpHitToTrackID(art::Ptr<recob::OpHit> const& hit)
82  {
83  return OpHitToTrackSDPs(hit);
84  }
85  std::vector<sim::TrackSDP> OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& hit);
86 
87  // method to return a subset of allhits that are matched to a list of TrackIDs
88  const std::vector<std::vector<art::Ptr<recob::OpHit>>> TrackIDsToOpHits(
89  std::vector<art::Ptr<recob::OpHit>> const& allhits,
90  std::vector<int> const& tkIDs);
91 
92  // method to return the EveIDs of particles contributing ionization
93  // electrons to the identified hit
94  std::vector<sim::TrackSDP> OpHitToEveSDPs(art::Ptr<recob::OpHit> const& hit);
95  std::vector<sim::TrackSDP> OpHitToEveID(art::Ptr<recob::OpHit> const& hit);
96 
98  // method to return sim::SDP objects associated with a given hit
99  void OpHitToSDPs(recob::OpHit const& hit, std::vector<sim::SDP>& sdps) const;
100  DEPRECATED void OpHitToSimSDPs(recob::OpHit const& hit, std::vector<sim::SDP>& sdps) const
101  {
102  OpHitToSDPs(hit, sdps);
103  }
104  void OpHitToSDPs(art::Ptr<recob::OpHit> const& hit, std::vector<sim::SDP>& sdps) const
105  {
106  OpHitToSDPs(*hit, sdps);
107  }
109  std::vector<sim::SDP>& sdps) const
110  {
111  OpHitToSDPs(*hit, sdps);
112  }
114 
115  // method to return the XYZ position of the weighted average energy deposition for a given hit
116  std::vector<double> SimSDPsToXYZ(std::vector<sim::SDP> const& sdps);
117 
118  // method to return the XYZ position of the weighted average energy deposition for a given hit
119  std::vector<double> OpHitToXYZ(art::Ptr<recob::OpHit> const& hit);
120 
121  // method to return the XYZ position of a space point (unweighted average XYZ of component hits).
122  /* std::vector<double> SpacePointToXYZ(art::Ptr<recob::SpacePoint> const& spt,
123  art::Event const& evt,
124  std::string const& label);*/
125 
126  // method to return the XYZ position of a space point (unweighted average XYZ of component hits).
127  /* std::vector<double> SpacePointHitsToXYZ(art::PtrVector<recob::Hit> const& hits);*/
128 
129  // method to return the fraction of hits in a collection that come from the specified Geant4 track ids
130  double OpHitCollectionPurity(std::set<int> trackIDs,
132 
133  // method to return the fraction of all hits in an event from a specific set of Geant4 track IDs that are
134  // represented in a collection of hits
135  double OpHitCollectionEfficiency(std::set<int> trackIDs,
137  std::vector<art::Ptr<recob::OpHit>> const& allhits);
138  double OpHitCollectionEfficiency(std::set<int> trackIDs,
140  std::vector<art::Ptr<recob::OpHit>> const& allhits,
141  geo::View_t const& view);
142 
143  // method to return the fraction of charge in a collection that come from the specified Geant4 track ids
144  double OpHitChargeCollectionPurity(std::set<int> trackIDs,
146 
147  // method to return the fraction of all charge in an event from a specific set of Geant4 track IDs that are
148  // represented in a collection of hits
149  double OpHitChargeCollectionEfficiency(std::set<int> trackIDs,
151  std::vector<art::Ptr<recob::OpHit>> const& allhits);
152  double OpHitChargeCollectionEfficiency(std::set<int> trackIDs,
154  std::vector<art::Ptr<recob::OpHit>> const& allhits,
155  geo::View_t const& view);
156 
157  // method to return all EveIDs corresponding to the current sim::ParticleList
158  std::set<int> GetSetOfEveIDs();
159 
160  // method to return all TrackIDs corresponding to the current sim::ParticleList
161  std::set<int> GetSetOfTrackIDs();
162 
163  // method to return all EveIDs corresponding to the given list of hits
164  std::set<int> GetSetOfEveIDs(std::vector<art::Ptr<recob::OpHit>> const& hits);
165 
166  // method to return all TrackIDs corresponding to the given list of hits
168 
169  const std::vector<art::Ptr<sim::OpDetBacktrackerRecord>>& OpDetBacktrackerRecords() const
170  {
172  }
173 
174  void ChannelToTrackSDPs(std::vector<sim::TrackSDP>& trackSDPs,
175  int channel,
176  const double hit_start_time,
177  const double hit_end_time);
178 
179  private:
180  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
181 
183 
184  const void shouldThisFail() const;
185 
186  bool have_complained;
187 
190  std::vector<art::Ptr<simb::MCTruth>> fMCTruthList;
193  std::vector<art::Ptr<sim::OpDetBacktrackerRecord>>
195  std::map<int, int> fTrackIDToMCTruthIndex;
196  std::string fG4ModuleLabel;
197  double fMinOpHitEnergyFraction;
198  double fDelay; //Shift in time
202  };
203 } // namespace
204 
206 #endif // CHEAT_PHOTONBACKTRACKER_H
const simb::MCParticle * TrackIDToParticle(int const &id) const
std::vector< const simb::MCParticle * > MCTruthToParticles(art::Ptr< simb::MCTruth > const &mct) const
DEPRECATED void OpHitToSimSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
#define DEPRECATED
void SetEveIdCalculator(sim::EveIdCalculator *ec)
std::map< int, int > fTrackIDToMCTruthIndex
map of track ids to MCTruthList entry
Container of LAr voxel information.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::vector< sim::SDP > TrackIDToSimSDP(int const &id) const
std::vector< double > SimSDPsToXYZ(std::vector< sim::SDP > const &sdps)
double OpHitChargeCollectionPurity(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits)
Particle class.
const art::Ptr< simb::MCTruth > & ParticleToMCTruth(const simb::MCParticle *p) const
std::string fG4ModuleLabel
label for geant4 module
std::vector< double > OpHitToXYZ(art::Ptr< recob::OpHit > const &hit)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
Access the description of detector geometry.
void hits()
Definition: readHits.C:15
void OpHitToSDPs(recob::OpHit const &hit, std::vector< sim::SDP > &sdps) const
void reconfigure(fhicl::ParameterSet const &pset)
DEPRECATED void OpHitToSimSDPs(art::Ptr< recob::OpHit > const &hit, std::vector< sim::SDP > &sdps) const
std::vector< sim::TrackSDP > OpHitToEveSDPs(art::Ptr< recob::OpHit > const &hit)
#define DECLARE_ART_SERVICE(svc, scope)
void ChannelToTrackSDPs(std::vector< sim::TrackSDP > &trackSDPs, int channel, const double hit_start_time, const double hit_end_time)
const simb::MCParticle * TrackIDToMotherParticle(int const &id) const
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
void Rebuild(const art::Event &evt)
Definition of data types for geometry description.
Interface for calculating the "ultimate mother" of a particle in a simulated event.
Detector simulation of raw signals on wires.
void OpHitToSDPs(art::Ptr< recob::OpHit > const &hit, std::vector< sim::SDP > &sdps) const
const sim::ParticleList & ParticleList() const
std::vector< sim::TrackSDP > OpHitToTrackSDPs(art::Ptr< recob::OpHit > const &hit)
std::vector< sim::TrackSDP > OpHitToEveID(art::Ptr< recob::OpHit > const &hit)
PhotonBackTracker(fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:22
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBacktrackerRecord(int channel) const
geo::GeometryCore const * geom
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector() const
double OpHitCollectionEfficiency(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits, std::vector< art::Ptr< recob::OpHit >> const &allhits)
double OpHitCollectionPurity(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits)
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & OpDetBacktrackerRecords() const
TCEvent evt
Definition: DataStructs.cxx:8
std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > cOpDetBacktrackerRecords
all the OpDetBacktrackerRecords for the event
Particle list in DetSim contains Monte Carlo particle information.
std::vector< art::Ptr< simb::MCTruth > > fMCTruthList
all the MCTruths for the event
static void AdoptEveIdCalculator(EveIdCalculator *)
double OpHitChargeCollectionEfficiency(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit >> const &hits, std::vector< art::Ptr< recob::OpHit >> const &allhits)
const std::vector< std::vector< art::Ptr< recob::OpHit > > > TrackIDsToOpHits(std::vector< art::Ptr< recob::OpHit >> const &allhits, std::vector< int > const &tkIDs)
sim::ParticleList fParticleList
ParticleList to map track ID to sim::Particle.
art framework interface to geometry description
DEPRECATED std::vector< sim::TrackSDP > OpHitToTrackID(art::Ptr< recob::OpHit > const &hit)
const art::Ptr< simb::MCTruth > & TrackIDToMCTruth(int const &id) const