LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
SmallClusterFinderAlg.h
Go to the documentation of this file.
1 //
3 // \file SmallClusterFinderAlg.h
4 //
5 // \author corey.adams@yale.edu
6 //
7 // This algorithm is designed to find small clusters that could correspond to gammas
8 // or low energy electrons.
9 //
10 /* There are two parameters that matter from the fcl file:
11  fNHitsInClust is the number of hits that should be in these small clusters
12  ^-- Gamma events seem to rarely have more than 4 hits in the cluster
13  ^-- SN events are unclear. Should this even be used for SN?
14  fRadiusSizePar is the distance (in cm) between the small clusters and any other hits.
15 
16  This algorithm sorts the hits by plane, and then looks at each hit individually. If
17  there is a hit within RadiusSizePar, it gets added to a local list. All other hits
18  are ignored. Then, if the number of hits that got added to the local list is greater
19  then NHitsInClust, the original hit is ignored. If it's less, the original hit is
20  presumed to be part of a very small (or single hit) cluster. So its added to the list
21  of hits in the small cluster.
22 
23  All of the small clusters are then split apart into groups in the way you would expect.
24  Each cluster is assigned an ID number to distinguish it, and the hits that aren't
25  identified as small clusters all end up in the "leftover" cluster. The numbering scheme
26  is ID = 100*iPlane + Cluster on that plane, and the leftover hits are the first (0th)
27  cluster written out.
28 
29  -Corey
30 */
31 //
32 //
34 
35 #ifndef SMALLCLUSTERFINDERALG_H
36 #define SMALLCLUSTERFINDERALG_H
37 
40 #include "fhiclcpp/fwd.h"
41 
44 
45 namespace detinfo {
46  class DetectorClocksData;
47  class DetectorPropertiesData;
48 }
49 
50 namespace util {
51  class GeometryUtilities;
52 }
53 
54 #include <vector>
55 
56 namespace cluster {
57 
59  public:
60  explicit SmallClusterFinderAlg(fhicl::ParameterSet const& pset);
61 
62  void SelectLocalHitlist(util::GeometryUtilities const& gser,
64  std::vector<art::Ptr<recob::Hit>>& hitlistlocal,
65  double wire_start,
66  double time_start,
67  double radlimit) const;
68  void SelectLocalHitlist(util::GeometryUtilities const& gser,
70  std::vector<art::Ptr<recob::Hit>>& hitlistlocal,
71  double wire_start,
72  double time_start,
73  double radlimit,
74  std::vector<int>&) const;
75 
76  // pass in a hit, all the others are filled in the function.
77  int GetPlaneAndTPC(art::Ptr<recob::Hit> a,
78  unsigned int& plane,
79  unsigned int& cryostat,
80  unsigned int& time,
81  unsigned int& wire) const;
82 
83  //passes in a hitlist, returns a list of gammas and puts everything else in hitlistleftover
84  std::vector<art::Ptr<recob::Hit>> CreateHighHitlist(
85  util::GeometryUtilities const& gser,
86  std::vector<art::Ptr<recob::Hit>> const& hitlist,
87  std::vector<art::Ptr<recob::Hit>>& hitlistleftover) const;
88 
89  // this routine actually finds the clusters
90  // It stores them in smallClustList
91  // It puts the leftover hits in hitlistleftover
92  void FindSmallClusters(util::GeometryUtilities const& gser,
93  detinfo::DetectorClocksData const& dataClocks,
94  detinfo::DetectorPropertiesData const& detProp,
96 
97  // This function is solely to sort the leftover hits. It's not done
98  // automatically because it's not a short process if the number of hits is
99  // big. For a few hits its not that bad. not yet functional! by this I
100  // mean, does not yet exist
101  void sortLeftoverHits();
102 
103  std::vector<std::vector<art::Ptr<recob::Hit>>> GetSmallClustersByPlane(unsigned int iPlane);
104  //This function just returns the clusters by plane, and they are split already.
105 
106  std::vector<art::Ptr<recob::Hit>> GetLeftoversByPlane(unsigned int iPlane);
107  //This function returns the leftover hits.
108 
109  private:
110  //Special function to make sure the vectors are all the right size
111  //can't do the hits, but can clear them and do the planes.
112  //Gets called each time FindSmallClusters is called, as well as in the constructor.
113  void ClearandResizeVectors();
114 
115  //**************All of the constants needed to do this process:
116  double fWiretoCm, fTimetoCm, fWireTimetoCmCm;
117  float fTimeTick; // time sample in us
118  float fDriftVelocity; // used to convert time to cm
119  double fWirePitch; // wire pitch in cm
120  std::vector<unsigned int> fNWires; // Number of wires on each plane
121  unsigned int fNPlanes; // number of planes
122  double fNTimes;
123 
124  // The various art grabbed Larsoft stuff to get physical properties.
126 
127  // The vectors that actually get used to hold hits, sets of hits, etc.
128  // All have the plane as the first index
129  std::vector<std::vector<std::vector<art::Ptr<recob::Hit>>>> smallClustList;
130  // This list is meant to contain the small clusters.
131  // It should be indexed by smallClustList[plane][smallcluster][hit]
132  std::vector<std::vector<art::Ptr<recob::Hit>>>
133  hitlistrefined; // list, by plane, of hits that ought to be gammas
134  std::vector<std::vector<art::Ptr<recob::Hit>>> hitlistbyplane; // list of all hits on each plane
135  std::vector<std::vector<art::Ptr<recob::Hit>>>
136  hitlistleftover; // list of all hits on each plane that are NOT gammas
137 
138  // input parameters, grabbed from the parameter set
139  bool verbose; // Make lots of printouts?
140  double fRadiusSizePar; // Determines the max radius of the cluster, must be
141  // separated
142  double fNHitsInClust; // Forces cluster to have a max number of hits
143  // Remember, this is the *small* cluster finder
144  }; // class SmallAngleFinder
145 }
146 #endif // SMALLCLUSTERFINDERALG_H
Namespace for general, non-LArSoft-specific utilities.
Definition: PIDAAlg.h:26
std::vector< std::vector< art::Ptr< recob::Hit > > > hitlistbyplane
std::vector< std::vector< std::vector< art::Ptr< recob::Hit > > > > smallClustList
Declaration of signal hit object.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
Cluster finding and building.
std::vector< std::vector< art::Ptr< recob::Hit > > > hitlistleftover
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
Interface for a class providing readout channel mapping to geometry.
General LArSoft Utilities.
std::vector< std::vector< art::Ptr< recob::Hit > > > hitlistrefined
std::vector< unsigned int > fNWires
Contains all timing reference information for the detector.