LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
old.PhotonBackTracker.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 
17 
18 #include <vector>
19 
20 #include "fhiclcpp/ParameterSet.h"
25 
36 
38 
39 /*namespace recob{
40  class SpacePoint;
41 }*/
42 
44 namespace cheat{
45 
47  {
48 
49  public:
50 
54 
55  void reconfigure(fhicl::ParameterSet const& pset);
56 
57  // The Rebuild function rebuilds the various maps we need to answer backtracking queries.
58  // It is called automatically before each event is processed. For jobs involving
59  // Monte Carlo generation, this is too soon. So, we'll call rebuild after those data
60  // products are put into the event in LArG4. This is the least bad way of ensuring the
61  // PhotonBackTracker works in jobs that combine MC production and reconstruction analysis based
62  // on MC truth. Don't copy this design pattern without talking to brebel@fnal.gov first
63  void Rebuild(const art::Event& evt);
64 
65  // Get a reference to the ParticleList
66  const sim::ParticleList& ParticleList() const { return fParticleList; }
67 
68  // Set the EveIdCalculator for the owned ParticleList
70 
71  // Return a pointer to the simb::MCParticle object corresponding to
72  // the given TrackID
73  const simb::MCParticle* TrackIDToParticle(int const& id) const;
74  const simb::MCParticle* TrackIDToMotherParticle(int const& id) const;
75 
76  std::vector<sim::SDP> TrackIDToSimSDP(int const& id) const;
77 
78  // Get art::Ptr<> to simb::MCTruth and related information
79  const art::Ptr<simb::MCTruth>& TrackIDToMCTruth(int const& id) const;
81  std::vector<const simb::MCParticle*> MCTruthToParticles(art::Ptr<simb::MCTruth> const& mct) const;
82  const std::vector< art::Ptr<simb::MCTruth> >& MCTruthVector() const { return fMCTruthList; }
83 
84  // this method will return the Geant4 track IDs of
85  // the particles contributing ionization electrons to the identified hit
86  DEPRECATED std::vector<sim::TrackSDP> OpHitToTrackID(art::Ptr<recob::OpHit> const& hit)
87  {return OpHitToTrackSDPs(hit);}
88  std::vector<sim::TrackSDP> OpHitToTrackSDPs(art::Ptr<recob::OpHit> const& hit);
89 
90  // method to return a subset of allhits that are matched to a list of TrackIDs
91  const std::vector<std::vector<art::Ptr<recob::OpHit>>> TrackIDsToOpHits(std::vector<art::Ptr<recob::OpHit>> const& allhits,
92  std::vector<int> const& tkIDs);
93 
94  // method to return the EveIDs of particles contributing ionization
95  // electrons to the identified hit
96  std::vector<sim::TrackSDP> OpHitToEveSDPs(art::Ptr<recob::OpHit> const& hit);
97  std::vector<sim::TrackSDP> OpHitToEveID(art::Ptr<recob::OpHit> const& hit);
98 
100  // method to return sim::SDP objects associated with a given hit
101  void OpHitToSDPs(recob::OpHit const& hit,
102  std::vector<sim::SDP>& sdps) const;
104  std::vector<sim::SDP>& sdps) const
105  { OpHitToSDPs( hit, sdps); }
107  std::vector<sim::SDP>& sdps) const
108  { OpHitToSDPs(*hit, sdps); }
110  std::vector<sim::SDP>& sdps) const
111  { OpHitToSDPs(*hit, sdps); }
113 
114  // method to return the XYZ position of the weighted average energy deposition for a given hit
115  std::vector<double> SimSDPsToXYZ(std::vector<sim::SDP> const& sdps);
116 
117  // method to return the XYZ position of the weighted average energy deposition for a given hit
118  std::vector<double> OpHitToXYZ(art::Ptr<recob::OpHit> const& hit);
119 
120  // method to return the XYZ position of a space point (unweighted average XYZ of component hits).
121 /* std::vector<double> SpacePointToXYZ(art::Ptr<recob::SpacePoint> const& spt,
122  art::Event const& evt,
123  std::string const& label);*/
124 
125  // method to return the XYZ position of a space point (unweighted average XYZ of component hits).
126 /* std::vector<double> SpacePointHitsToXYZ(art::PtrVector<recob::Hit> const& hits);*/
127 
128  // method to return the fraction of hits in a collection that come from the specified Geant4 track ids
129  double OpHitCollectionPurity(std::set<int> trackIDs,
131 
132  // method to return the fraction of all hits in an event from a specific set of Geant4 track IDs that are
133  // represented in a collection of hits
134  double OpHitCollectionEfficiency(std::set<int> trackIDs,
136  std::vector< art::Ptr<recob::OpHit> > const& allhits);
137  double OpHitCollectionEfficiency(std::set<int> trackIDs,
139  std::vector< art::Ptr<recob::OpHit> > const& allhits,
140  geo::View_t const& view);
141 
142  // method to return the fraction of charge in a collection that come from the specified Geant4 track ids
143  double OpHitChargeCollectionPurity(std::set<int> trackIDs,
145 
146  // method to return the fraction of all charge in an event from a specific set of Geant4 track IDs that are
147  // represented in a collection of hits
148  double OpHitChargeCollectionEfficiency(std::set<int> trackIDs,
150  std::vector< art::Ptr<recob::OpHit> > const& allhits);
151  double OpHitChargeCollectionEfficiency(std::set<int> trackIDs,
153  std::vector< art::Ptr<recob::OpHit> > const& allhits,
154  geo::View_t const& view);
155 
156  // method to return all EveIDs corresponding to the current sim::ParticleList
157  std::set<int> GetSetOfEveIDs();
158 
159  // method to return all TrackIDs corresponding to the current sim::ParticleList
160  std::set<int> GetSetOfTrackIDs();
161 
162  // method to return all EveIDs corresponding to the given list of hits
163  std::set<int> GetSetOfEveIDs(std::vector< art::Ptr<recob::OpHit> > const& hits);
164 
165  // method to return all TrackIDs corresponding to the given list of hits
166  std::set<int> GetSetOfTrackIDs(std::vector< art::Ptr<recob::OpHit> > const& hits);
167 
168  const std::vector< art::Ptr< sim::OpDetBacktrackerRecord >>& OpDetBacktrackerRecords() const { return cOpDetBacktrackerRecords; }
169 
170  void ChannelToTrackSDPs(std::vector<sim::TrackSDP>& trackSDPs,
171  int channel,
172  const double hit_start_time,
173  const double hit_end_time);
174 
175  private:
176 
177  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
178 
180 
181  const void shouldThisFail() const;
182 
184 
187  std::vector< art::Ptr<simb::MCTruth> > fMCTruthList;
190  std::vector< art::Ptr< sim::OpDetBacktrackerRecord >> cOpDetBacktrackerRecords;
191  std::map<int, int> fTrackIDToMCTruthIndex;
192  std::string fG4ModuleLabel;
194  double fDelay; //Shift in time
198  };
199 } // namespace
200 
202 #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
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)
#define DECLARE_ART_SERVICE(svc, scope)
Definition: ServiceMacros.h:91
double OpHitCollectionPurity(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)
double OpHitChargeCollectionEfficiency(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit > > const &hits, std::vector< art::Ptr< recob::OpHit > > const &allhits)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
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)
void ChannelToTrackSDPs(std::vector< sim::TrackSDP > &trackSDPs, int channel, const double hit_start_time, const double hit_end_time)
double OpHitCollectionEfficiency(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit > > const &hits, std::vector< art::Ptr< recob::OpHit > > const &allhits)
const simb::MCParticle * TrackIDToMotherParticle(int const &id) const
Description of geometry of one entire detector.
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:26
const art::Ptr< sim::OpDetBacktrackerRecord > FindOpDetBacktrackerRecord(int channel) const
geo::GeometryCore const * geom
double fMinOpHitEnergyFraction
minimum fraction of energy a track id has to
#define DEPRECATED
const std::vector< art::Ptr< simb::MCTruth > > & MCTruthVector() const
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 OpHitChargeCollectionPurity(std::set< int > trackIDs, std::vector< art::Ptr< recob::OpHit > > const &hits)
const std::vector< art::Ptr< sim::OpDetBacktrackerRecord > > & OpDetBacktrackerRecords() const
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