All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DisambigAlg.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////
2 // \fileDisambigAlg.h
3 // tylerdalion@gmail.com
4 ////////////////////////////////////////////////////////////////////
5 #ifndef DisambigAlg_H
6 #define DisambigAlg_H
7 
8 #include <map>
9 #include <utility> // std::pair<>
10 #include <vector>
11 
12 #include "art/Framework/Principal/Handle.h"
13 #include "art/Framework/Services/Registry/ServiceHandle.h"
14 #include "canvas/Persistency/Common/Ptr.h"
15 
16 namespace fhicl {
17  class ParamterSet;
18 }
19 
21 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
26 namespace detinfo {
27  class DetectorClocksData;
28  class DetectorPropertiesData;
29 }
30 
31 namespace apa {
32 
33  //---------------------------------------------------------------
34  class DisambigAlg {
35  public:
36  explicit DisambigAlg(fhicl::ParameterSet const& pset);
37 
38  void RunDisambig(detinfo::DetectorClocksData const& clockData,
40  art::Handle<std::vector<recob::Hit>> GausHits);
41 
42  void TrivialDisambig(detinfo::DetectorClocksData const& clockData,
43  detinfo::DetectorPropertiesData const& detProp,
44  unsigned int apa); ///< Make the easiest and safest disambiguations in apa
45  void Crawl(unsigned int apa); ///< Extend what we disambiguation we do have in apa
46  unsigned int FindChanTimeEndPts(detinfo::DetectorPropertiesData const& detProp,
47  unsigned int apa); ///< Basic endpoint-hit finder per apa
48  void UseEndPts(detinfo::DetectorPropertiesData const& detProp,
49  unsigned int apa); ///< Try to associate endpoint hits and
50  ///< crawl from there
51  unsigned int CompareViews(
52  detinfo::DetectorPropertiesData const& detProp,
53  unsigned int apa); ///< Compare U and V to see if one says something about the other
55  unsigned int apa); ///< See how much disambiguation has been done in this apa so far
56 
57  std::map<unsigned int, double> fUeffSoFar;
58  std::map<unsigned int, double> fVeffSoFar;
59  std::map<unsigned int, unsigned int> fnUSoFar;
60  std::map<unsigned int, unsigned int> fnVSoFar;
61  std::map<unsigned int, unsigned int> fnDUSoFar;
62  std::map<unsigned int, unsigned int> fnDVSoFar;
63 
64  std::vector<std::pair<art::Ptr<recob::Hit>, geo::WireID>> fDisambigHits;
65  ///< The final list of hits to pass back to be made
66 
67  private:
68  // other classes we will use
70  art::ServiceHandle<geo::Geometry const> geom;
71  // **temporarily** here to look at performance without noise hits
72  art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
73 
74  // Hits organization
75  std::map<raw::ChannelID_t, std::vector<art::Ptr<recob::Hit>>> fChannelToHits;
76  std::map<unsigned int, std::vector<art::Ptr<recob::Hit>>> fAPAToUVHits, fAPAToZHits;
77  std::map<unsigned int, std::vector<art::Ptr<recob::Hit>>> fAPAToHits;
78  ///\ todo: Channel/APA to hits can be done in a unified way
79  std::map<unsigned int, std::vector<art::Ptr<recob::Hit>>> fAPAToEndPHits;
80  std::map<unsigned int, std::vector<std::pair<art::Ptr<recob::Hit>, geo::WireID>>> fAPAToDHits;
81  ///< Hold the disambiguations per APA
82 
83  // data/function to keep track of disambiguation along the way
84  std::map<std::pair<double, double>, geo::WireID> fChanTimeToWid;
85  ///< If a hit is disambiguated, map its chan and peak time to the chosen wireID
86  std::map<unsigned int, std::map<std::pair<double, double>, bool>> fHasBeenDisambiged;
87  ///< Convenient way to keep track of disambiguation so far
88  void MakeDisambigHit(art::Ptr<recob::Hit> const& hit, geo::WireID, unsigned int apa);
89  ///< Makes a disambiguated hit while keeping track of what has already been disambiguated
90 
91  // Functions that support disambiguation methods
92  unsigned int MakeCloseHits(int ext, geo::WireID wid, double Dmin, double Dmax);
93  ///< Having disambiguated a time range on a wireID, extend to neighboring channels
95  recob::Hit const& hitA,
96  recob::Hit const& hitB);
97  bool HitsReasonablyMatch(art::Ptr<recob::Hit> hitA, art::Ptr<recob::Hit> hitB);
98  ///\ todo: Write function that compares hits more detailedly
99 
100  // Configure the disambiguation
101  bool fCrawl;
102  bool fUseEndP;
104  unsigned int fNChanJumps; ///< Number of channels the crawl can jump over
105  double fCloseHitsRadius; ///< Distance (cm) away from a hit to look when
106  ///< checking if it's an endpoint
107  double fMaxEndPDegRange; ///< Within the close hits radius, how spread can
108  ///< the majority of the activity be around a
109  ///< possible endpoint
110 
111  }; // class DisambigAlg
112 
113 } // namespace apa
114 
115 #endif // ifndef DisambigAlg_H
std::map< unsigned int, std::map< std::pair< double, double >, bool > > fHasBeenDisambiged
Convenient way to keep track of disambiguation so far.
Definition: DisambigAlg.h:86
std::map< raw::ChannelID_t, std::vector< art::Ptr< recob::Hit > > > fChannelToHits
Definition: DisambigAlg.h:75
bool HitsReasonablyMatch(art::Ptr< recob::Hit > hitA, art::Ptr< recob::Hit > hitB)
double fCloseHitsRadius
Definition: DisambigAlg.h:105
bool HitsOverlapInTime(detinfo::DetectorPropertiesData const &detProp, recob::Hit const &hitA, recob::Hit const &hitB)
std::map< unsigned int, std::vector< art::Ptr< recob::Hit > > > fAPAToZHits
Definition: DisambigAlg.h:76
std::map< unsigned int, unsigned int > fnDVSoFar
Definition: DisambigAlg.h:62
apa::APAGeometryAlg fAPAGeo
Definition: DisambigAlg.h:69
Declaration of signal hit object.
std::map< unsigned int, unsigned int > fnVSoFar
Definition: DisambigAlg.h:60
void Crawl(unsigned int apa)
Extend what we disambiguation we do have in apa.
void RunDisambig(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, art::Handle< std::vector< recob::Hit >> GausHits)
Definition: DisambigAlg.cxx:54
process_name hit
Definition: cheaterreco.fcl:51
std::map< unsigned int, std::vector< art::Ptr< recob::Hit > > > fAPAToEndPHits
\ todo: Channel/APA to hits can be done in a unified way
Definition: DisambigAlg.h:79
art::ServiceHandle< geo::Geometry const > geom
Definition: DisambigAlg.h:70
void TrivialDisambig(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, unsigned int apa)
Make the easiest and safest disambiguations in apa.
void AssessDisambigSoFar(unsigned int apa)
See how much disambiguation has been done in this apa so far.
std::map< unsigned int, std::vector< art::Ptr< recob::Hit > > > fAPAToUVHits
Definition: DisambigAlg.h:76
std::map< unsigned int, std::vector< art::Ptr< recob::Hit > > > fAPAToHits
Definition: DisambigAlg.h:77
DisambigAlg(fhicl::ParameterSet const &pset)
Definition: DisambigAlg.cxx:40
std::map< unsigned int, double > fVeffSoFar
Definition: DisambigAlg.h:58
void MakeDisambigHit(art::Ptr< recob::Hit > const &hit, geo::WireID, unsigned int apa)
Makes a disambiguated hit while keeping track of what has already been disambiguated.
unsigned int fNChanJumps
Number of channels the crawl can jump over.
Definition: DisambigAlg.h:104
Definition of data types for geometry description.
void UseEndPts(detinfo::DetectorPropertiesData const &detProp, unsigned int apa)
Contains all timing reference information for the detector.
bool fCrawl
\ todo: Write function that compares hits more detailedly
Definition: DisambigAlg.h:101
art::ServiceHandle< cheat::BackTrackerService const > bt_serv
Definition: DisambigAlg.h:72
std::vector< std::pair< art::Ptr< recob::Hit >, geo::WireID > > fDisambigHits
The final list of hits to pass back to be made.
Definition: DisambigAlg.h:64
double fMaxEndPDegRange
Definition: DisambigAlg.h:107
unsigned int CompareViews(detinfo::DetectorPropertiesData const &detProp, unsigned int apa)
Compare U and V to see if one says something about the other.
std::map< unsigned int, double > fUeffSoFar
Definition: DisambigAlg.h:57
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
std::map< unsigned int, unsigned int > fnUSoFar
Definition: DisambigAlg.h:59
unsigned int FindChanTimeEndPts(detinfo::DetectorPropertiesData const &detProp, unsigned int apa)
Basic endpoint-hit finder per apa.
std::map< unsigned int, std::vector< std::pair< art::Ptr< recob::Hit >, geo::WireID > > > fAPAToDHits
Hold the disambiguations per APA.
Definition: DisambigAlg.h:80
unsigned int MakeCloseHits(int ext, geo::WireID wid, double Dmin, double Dmax)
Having disambiguated a time range on a wireID, extend to neighboring channels.
art framework interface to geometry description
auto const detProp
std::map< std::pair< double, double >, geo::WireID > fChanTimeToWid
If a hit is disambiguated, map its chan and peak time to the chosen wireID.
Definition: DisambigAlg.h:84
std::map< unsigned int, unsigned int > fnDUSoFar
Definition: DisambigAlg.h:61