LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
BackTracker.h
Go to the documentation of this file.
1 //
3 // \file BackTracker.h
4 // \brief Functions needed by the BackTracker service in order to connect truth information with reconstruction.
5 //
6 // \author jason.stock@mines.sdsmt.edu
7 //
8 // Based on the original BackTracker by brebel@fnal.gov
9 //
11 #ifndef CHEAT_BACKTRACKER_H
12 #define CHEAT_BACKTRACKER_H
13 
14 //Includes
15 #include <vector>
16 
17 #include "ParticleInventory.h"
18 
19 
20 #include "fhiclcpp/types/Atom.h"
21 #include "fhiclcpp/types/Table.h"
22 
30 
31 /*namespace recob{
32  class SpacePoint;
33  }*/
34 
35 
36 namespace cheat{
37 
38  class BackTracker{
39  public:
40 
41  //Structure for configuration parameters. (fhicl validation)
42  struct fhiclConfig{
43  fhicl::Atom<art::InputTag> G4ModuleLabel{fhicl::Name("G4ModuleLabel"), fhicl::Comment("The label of the LArG4 module used to produce the art file we will be using."), "largeant"};
44  fhicl::Atom<art::InputTag> DefaultHitModuleLabel{fhicl::Name("DefaultHitModuleLabel"), fhicl::Comment("The label of the module used to produce the hits in the art file we will default to when no hitlist is provided."), "hitfd"};
45  fhicl::Atom<double> MinHitEnergyFraction{fhicl::Name("MinHitEnergyFraction"), fhicl::Comment("The minimum contribution an energy deposit must make to a Hit to be considered part of that hit."),0.010};
46  };
47 
48 
49  BackTracker(const fhiclConfig& config,
50  const cheat::ParticleInventory* partInv,
51  const geo::GeometryCore* geom,
52  const detinfo::DetectorClocks* detClock );
53  BackTracker(const fhicl::ParameterSet& pSet,
54  const cheat::ParticleInventory* partInv,
55  const geo::GeometryCore* geom,
56  const detinfo::DetectorClocks* detClock );
57  //I may need to include this to delete copy of service providers.
58  BackTracker(BackTracker const&) = delete;
59 
60  template<typename Evt>
61  void PrepEvent ( const Evt& evt );
62 
63  template<typename Evt>
64  void PrepSimChannels ( const Evt& evt );
65 
66 // template<typename Evt>
67 // void PrepAllHitList ( const Evt& evt);
68 
69  //-----------------------------------------------------
70  template<typename Evt>
71  bool CanRun(const Evt& evt){ return !(evt.isRealData());}
72 
73  //-----------------------------------------------------
74  template<typename Evt>
75  const std::vector< art::Ptr< recob::Hit > > SpacePointToHits_Ps(art::Ptr< recob::SpacePoint> const& spt, const Evt& evt) const;
76 
77  //-----------------------------------------------------
78  template<typename Evt>
79  const std::vector< double > SpacePointToXYZ( art::Ptr< recob::SpacePoint > const& spt, const Evt& evt) const;
80 
81 
82  //-----------------------------------------------------
83  void ClearEvent();
84 
85 
86  bool SimChannelsReady() const { return !( fSimChannels.empty() ); }
87 // bool AllHitListReady () const { return !( fAllHitList.empty() ); }
88 
89  const std::vector<art::Ptr<sim::SimChannel>>& SimChannels() const { return fSimChannels; }
90  //All Hit List would go here. We explicitly choose not to include it, as the user should not be using backtracker to access Hits. This could change in a concievable future use case where we also allow the user to define what the "AllHitList" should be, though this would have ramifications on other functions.
91 
92  const std::vector<const sim::IDE* > TrackIdToSimIDEs_Ps(int const& id) const;
93  //const std::vector<const sim::IDE> TrackIdToSimIDEs (int const& id) const;
94  const std::vector<const sim::IDE* > TrackIdToSimIDEs_Ps(int const& id, const geo::View_t view) const;
95  //std::vector<const sim::IDE> TrackIdToSimIDEs (int const& id, const geo::View_t view) const;
96 
98 
99  const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const;
100 
101 
102  //Track IDEs cannot be returned as pointers, as they dont exist in the data product, and we will not be storing them.
103  const std::vector< sim::TrackIDE> HitToTrackIDEs(recob::Hit const& hit) const;
104  const std::vector< sim::TrackIDE> HitToTrackIDEs(art::Ptr<recob::Hit> const& hit) const { return this->HitToTrackIDEs(*hit);}
105 
106  const std::vector< int > HitToTrackIds(recob::Hit const& hit) const ;
107  // std::vector< const int> HitToTrackId(art::Ptr<recob::Hit> const& hit) { return this->HitToTrackId(*hit); }
108 
109  const std::vector<sim::TrackIDE> HitToEveTrackIDEs(recob::Hit const& hit) const;
110  const std::vector<sim::TrackIDE> HitToEveTrackIDEs(art::Ptr<recob::Hit> const& hit) const{ return this->HitToEveTrackIDEs(*hit);}
111 
112  //I will not return these by copy, as that could get very large very quickly.
113  std::vector< art::Ptr<recob::Hit> > TrackIdToHits_Ps( const int& tkId, std::vector< art::Ptr< recob::Hit > > const& hitsIn ) const;
114 //I am not allowing this function for now, as caching the allhitlist indiscriminately is a catastrophically bad idea.
115 // std::vector< art::Ptr<recob::Hit> > TrackIdToHits_Ps( const int& tkId ) const
116 // {return this->TrackIdToHits_Ps(tkId, fAllHitList); }
117 
118  std::vector< std::vector< art::Ptr<recob::Hit> > > TrackIdsToHits_Ps( std::vector<int> const& tkIds, std::vector< art::Ptr< recob::Hit > > const& hitsIn ) const;
119 // std::vector< std::vector< art::Ptr<recob::Hit> > > TrackIdsToHits_Ps( std::vector<int> const& tkIds ) const
120 // {return this->TrackIdsToHits_Ps(tkIds, fAllHitList);}
121 
122  const std::vector< sim::IDE > HitToAvgSimIDEs ( recob::Hit const& hit) const;
123  const std::vector< sim::IDE > HitToAvgSimIDEs ( art::Ptr<recob::Hit> hit) const{ return this->HitToAvgSimIDEs(*hit);}
124 
125  const std::vector< const sim::IDE* > HitToSimIDEs_Ps (recob::Hit const& hit) const;
126  const std::vector< const sim::IDE* > HitToSimIDEs_Ps (art::Ptr< recob::Hit > const& hit) const { return this->HitToSimIDEs_Ps (*hit); }
127 
128  //const std::vector< sim::IDE > HitToSimIDEs (recob::Hit const& hit);
129  // std::vector< const sim::IDE > HitToSimIDEs (art::Ptr< recob::Hit > const& hit) { return this->HitToSimIDEsPs (*hit); }
130 
131  const std::vector<double> SimIDEsToXYZ( std::vector< sim::IDE > const& ides) const;
132  const std::vector<double> SimIDEsToXYZ( std::vector< const sim::IDE* > const& ide_Ps) const;
133 
134  const std::vector<double> HitToXYZ(const recob::Hit& hit) const;
135  const std::vector<double> HitToXYZ(art::Ptr<recob::Hit> const& hit) const{ return this->HitToXYZ(*hit);}
136 
137 
138 
139  const double HitCollectionPurity( std::set<int> const& trackIds, std::vector< art::Ptr<recob::Hit> > const& hits) const;
140  const double HitChargeCollectionPurity( std::set<int> const& trackIds, std::vector< art::Ptr<recob::Hit> > const& hits) const;
141 
142  const double HitCollectionEfficiency( std::set<int> const& trackIds, std::vector< art::Ptr<recob::Hit> > const& hits, std::vector< art::Ptr<recob::Hit> > const& allhits, geo::View_t const& view) const;
143 
144 
145  const double HitChargeCollectionEfficiency( std::set<int> trackIds, std::vector< art::Ptr<recob::Hit> > const& hits, std::vector< art::Ptr<recob::Hit> > const& allhits, geo::View_t const& view) const;
146 
147  const std::set<int> GetSetOfTrackIds() const { return fPartInv->GetSetOfTrackIds();}
148  const std::set<int> GetSetOfEveIds() const { return fPartInv->GetSetOfEveIds();}
149 
150  const std::set<int> GetSetOfTrackIds( std::vector< art::Ptr< recob::Hit > > const& hits ) const;
151  const std::set<int> GetSetOfEveIds( std::vector< art::Ptr< recob::Hit > > const& hits ) const;
152 
153  const std::vector< double> SpacePointHitsToWeightedXYZ(std::vector<art::Ptr<recob::Hit>> const& hits) const;
154 
155  private:
156  const cheat::ParticleInventory* fPartInv; //The constructor needs to put something in here
161  const double fMinHitEnergyFraction;
162 
163 
164  mutable std::vector<art::Ptr<sim::SimChannel>> fSimChannels;
165 // mutable std::vector< art::Ptr<recob::Hit> > fAllHitList;
166 
167  };//end class BackTracker
168 
169 }//end namespace cheat
170 
171 #include "BackTracker.tcc"
172 
173 #endif //CHEAT_BACKTRACKER_H
const art::InputTag fHitLabel
Definition: BackTracker.h:160
const std::vector< double > SpacePointHitsToWeightedXYZ(std::vector< art::Ptr< recob::Hit >> const &hits) const
Definition: BackTracker.cc:496
const geo::GeometryCore * fGeom
Definition: BackTracker.h:157
void PrepSimChannels(const Evt &evt)
std::vector< art::Ptr< sim::SimChannel > > fSimChannels
Definition: BackTracker.h:164
fhicl::Atom< double > MinHitEnergyFraction
Definition: BackTracker.h:45
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
const detinfo::DetectorClocks * fDetClocks
Definition: BackTracker.h:158
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(art::Ptr< recob::Hit > const &hit) const
Definition: BackTracker.h:126
Declaration of signal hit object.
const std::set< int > GetSetOfEveIds() const
Definition: BackTracker.h:148
const std::vector< sim::TrackIDE > ChannelToTrackIDEs(raw::ChannelID_t channel, const double hit_start_time, const double hit_end_time) const
Definition: BackTracker.cc:112
const double fMinHitEnergyFraction
Definition: BackTracker.h:161
const std::vector< double > HitToXYZ(art::Ptr< recob::Hit > const &hit) const
Definition: BackTracker.h:135
pure virtual base interface for detector clocks
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:161
const double HitCollectionEfficiency(std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t const &view) const
Definition: BackTracker.cc:406
const std::vector< int > HitToTrackIds(recob::Hit const &hit) const
Definition: BackTracker.cc:171
bool CanRun(const Evt &evt)
Definition: BackTracker.h:71
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Access the description of detector geometry.
const std::vector< const sim::IDE * > TrackIdToSimIDEs_Ps(int const &id) const
Definition: BackTracker.cc:57
void hits()
Definition: readHits.C:15
bool SimChannelsReady() const
Definition: BackTracker.h:86
art::Ptr< sim::SimChannel > FindSimChannel(raw::ChannelID_t channel) const
Definition: BackTracker.cc:99
const std::vector< art::Ptr< recob::Hit > > SpacePointToHits_Ps(art::Ptr< recob::SpacePoint > const &spt, const Evt &evt) const
const std::vector< double > HitToXYZ(const recob::Hit &hit) const
Definition: BackTracker.cc:367
std::vector< std::vector< art::Ptr< recob::Hit > > > TrackIdsToHits_Ps(std::vector< int > const &tkIds, std::vector< art::Ptr< recob::Hit > > const &hitsIn) const
Definition: BackTracker.cc:225
std::set< int > GetSetOfTrackIds() const
const double HitChargeCollectionPurity(std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits) const
Definition: BackTracker.cc:389
const cheat::ParticleInventory * fPartInv
Definition: BackTracker.h:156
const std::vector< const sim::IDE * > HitToSimIDEs_Ps(recob::Hit const &hit) const
Definition: BackTracker.cc:275
const std::vector< sim::TrackIDE > HitToEveTrackIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:181
std::set< int > GetSetOfEveIds() const
Description of geometry of one entire detector.
Detector simulation of raw signals on wires.
Conversion of times between different formats and references.
fhicl::Atom< art::InputTag > G4ModuleLabel
Definition: BackTracker.h:43
const std::vector< art::Ptr< sim::SimChannel > > & SimChannels() const
Definition: BackTracker.h:89
const std::vector< sim::TrackIDE > HitToEveTrackIDEs(art::Ptr< recob::Hit > const &hit) const
Definition: BackTracker.h:110
fhicl::Atom< art::InputTag > DefaultHitModuleLabel
Definition: BackTracker.h:44
code to link reconstructed objects back to the MC truth information
Definition: BackTracker.cc:26
const std::vector< double > SpacePointToXYZ(art::Ptr< recob::SpacePoint > const &spt, const Evt &evt) const
const double HitChargeCollectionEfficiency(std::set< int > trackIds, std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< art::Ptr< recob::Hit > > const &allhits, geo::View_t const &view) const
Definition: BackTracker.cc:438
const std::set< int > GetSetOfTrackIds() const
Definition: BackTracker.h:147
const std::vector< sim::IDE > HitToAvgSimIDEs(art::Ptr< recob::Hit > hit) const
Definition: BackTracker.h:123
object containing MC truth information necessary for making RawDigits and doing back tracking ...
const std::vector< sim::IDE > HitToAvgSimIDEs(recob::Hit const &hit) const
Definition: BackTracker.cc:263
Header for the ParticleInvenotry Service Provider.
const art::InputTag fG4ModuleLabel
Definition: BackTracker.h:159
const std::vector< double > SimIDEsToXYZ(std::vector< sim::IDE > const &ides) const
Definition: BackTracker.cc:338
Data structure containing constant pointers to classes.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:27
std::vector< art::Ptr< recob::Hit > > TrackIdToHits_Ps(const int &tkId, std::vector< art::Ptr< recob::Hit > > const &hitsIn) const
Definition: BackTracker.cc:202
const double HitCollectionPurity(std::set< int > const &trackIds, std::vector< art::Ptr< recob::Hit > > const &hits) const
Definition: BackTracker.cc:373
const std::vector< sim::TrackIDE > HitToTrackIDEs(art::Ptr< recob::Hit > const &hit) const
Definition: BackTracker.h:104
void PrepEvent(const Evt &evt)
BackTracker(const fhiclConfig &config, const cheat::ParticleInventory *partInv, const geo::GeometryCore *geom, const detinfo::DetectorClocks *detClock)
Definition: BackTracker.cc:29