LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DirOfGamma.h
Go to the documentation of this file.
1 // Class:
3 // Module Type:
4 // File: DirOfGamma.h
5 // Authors: dorota.stefan@cern.ch robert.sulej@cern.ch
7 
8 #ifndef DirOfGamma_h
9 #define DirOfGamma_h
10 
12 namespace detinfo {
13  class DetectorPropertiesData;
14 }
15 
17 
18 #include "TVector2.h"
19 
20 #include <vector>
21 
22 namespace ems {
23  class Hit2D;
24  class Bin2D;
25  class EndPoint;
26  class DirOfGamma;
27  class bDistCentMore2D;
28  class bDistCentLess2D;
29 }
30 
31 class ems::Hit2D {
32 public:
34 
35  TVector2 const& GetPointCm() const { return fPoint; }
36  double GetCharge() const { return fCharge; }
37 
38  art::Ptr<recob::Hit> const& GetHitPtr() const { return fHit; }
39 
40 private:
41  double fCharge;
42 
43  TVector2 fPoint;
44 
46 };
47 
48 class ems::Bin2D {
49 public:
50  Bin2D(const TVector2& center);
51 
52  void Add(Hit2D* hit);
53 
54  void Sort();
55 
56  void SortLess();
57 
58  double GetTotCharge() const { return fTotCharge; }
59 
60  unsigned int Size() const { return fSize; }
61 
62  std::vector<Hit2D*> const& GetHits2D() const { return fHits2D; }
63 
64  const TVector2& GetCenter() const { return fCenter2D; }
65 
66  std::vector<art::Ptr<recob::Hit>> GetIniHits(const double radius = 10.0,
67  const unsigned int nhits = 10) const;
68 
69 private:
70  const TVector2& fCenter2D;
71  std::vector<Hit2D*> fHits2D;
72  double fTotCharge;
73  unsigned int fSize;
74 };
75 
77 public:
78  EndPoint(const Hit2D& center, const std::vector<Hit2D*>& hits, unsigned int nbins);
79 
80  TVector2 const& GetPosition() const { return fCenter2D.GetPointCm(); }
81 
82  double GetAsymmetry() const;
83 
84  double GetMaxCharge() const { return fMaxCharge; }
85 
86  Bin2D const& MaxChargeBin() const { return fBins[fMaxChargeIdBin]; }
87 
88  std::vector<Bin2D> const& GetBins2D() const { return fBins; }
89 
90  art::Ptr<recob::Hit> const& GetHit() const { return fCenter2D.GetHitPtr(); }
91 
92  const std::vector<art::Ptr<recob::Hit>> GetIniHits() const { return MaxChargeBin().GetIniHits(); }
93 
94  size_t const& GetPlane() const { return fPlane; }
95  size_t const& GetTPC() const { return fTpc; }
96  size_t const& GetCryo() const { return fCryo; }
97 
98 private:
100  std::vector<Hit2D*> fPoints2D;
101  size_t fNbins;
102 
103  double fMaxCharge;
104  double fMeanCharge;
105 
106  std::vector<Bin2D> fBins;
107 
109 
110  void FillBins();
111  void ComputeMaxCharge();
112  void ComputeMeanCharge();
113 
114  size_t fPlane;
115  size_t fTpc;
116  size_t fCryo;
117 };
118 
120 public:
122  const std::vector<art::Ptr<recob::Hit>>& src,
123  unsigned int nbins,
124  unsigned int idcl);
126  {
127  for (unsigned int i = 0; i < fPoints2D.size(); ++i)
128  delete fPoints2D[i];
129  }
130 
131  TVector2 const& GetBaryCenterCm() const { return fBaryCenter; }
132 
133  std::vector<Hit2D*> const& GetHits2D() const { return fPoints2D; }
134 
135  std::vector<EndPoint> const& GetCandidates() const { return fCandidates; }
136 
137  void SetIdCandidate(size_t id)
138  {
139 
140  fIsCandidateIDset = true;
141  fCandidateID = id;
142  fStartHit = fCandidates[id].GetHit();
143  fStartPoint = fCandidates[id].GetPosition();
144  fIniHits = fCandidates[id].MaxChargeBin().GetIniHits();
145  }
146 
147  size_t GetIdCandidate() { return fCandidateID; }
148 
149  art::Ptr<recob::Hit> const& GetFirstHit() const { return fStartHit; }
150 
151  std::vector<art::Ptr<recob::Hit>> const& GetHits() { return fHits; }
152 
153  TVector2 const& GetFirstPoint() const { return fStartPoint; }
154 
155  std::vector<art::Ptr<recob::Hit>> const& GetIniHits() const { return fIniHits; }
156 
157  size_t GetIdCl() const { return fIdCl; }
158 
159 private:
160  size_t fNbins;
161  size_t fIdCl;
162  size_t fCandidateID;
163 
164  std::vector<Hit2D*> fPoints2D;
165  std::vector<Bin2D> fBins;
166  std::vector<EndPoint> fCandidates;
167 
169  TVector2 fStartPoint;
170  std::vector<art::Ptr<recob::Hit>> fIniHits;
171  std::vector<art::Ptr<recob::Hit>> fHits;
172 
173  void FindInitialPart();
174 
175  void FillBins();
176 
177  bool FindCandidates();
178  void ComputeBaryCenter();
179  void ComputeMaxDist();
180  void ComputeMaxCharge();
181  void ComputeFinalValues();
182 
183  TVector2 fBaryCenter;
184 
185  float fNormDist;
186  float fNormCharge;
187 
189 };
190 
192 public:
193  bDistCentMore2D(const TVector2& c) : center(c) {}
194 
195  bool operator()(Hit2D* p1, Hit2D* p2) const
196  {
197  double dx = p1->GetPointCm().X() - center.X();
198  double dy = p1->GetPointCm().Y() - center.Y();
199  double b1 = dx * dx + dy * dy;
200  dx = p2->GetPointCm().X() - center.X();
201  dy = p2->GetPointCm().Y() - center.Y();
202  double b2 = dx * dx + dy * dy;
203 
204  return b1 > b2;
205  }
206 
207 private:
208  TVector2 center;
209 };
210 
212 public:
213  bDistCentLess2D(const TVector2& c) : center(c) {}
214 
215  bool operator()(Hit2D* p1, Hit2D* p2) const
216  {
217  double dx = p1->GetPointCm().X() - center.X();
218  double dy = p1->GetPointCm().Y() - center.Y();
219  double b1 = dx * dx + dy * dy;
220  dx = p2->GetPointCm().X() - center.X();
221  dy = p2->GetPointCm().Y() - center.Y();
222  double b2 = dx * dx + dy * dy;
223 
224  return b1 < b2;
225  }
226 
227 private:
228  TVector2 center;
229 };
230 
231 #endif
TVector2 const & GetPosition() const
Definition: DirOfGamma.h:80
TVector2 fPoint
Definition: DirOfGamma.h:43
Declaration of signal hit object.
art::Ptr< recob::Hit > const & GetFirstHit() const
Definition: DirOfGamma.h:149
std::vector< art::Ptr< recob::Hit > > fHits
Definition: DirOfGamma.h:171
std::vector< art::Ptr< recob::Hit > > const & GetHits()
Definition: DirOfGamma.h:151
std::vector< EndPoint > const & GetCandidates() const
Definition: DirOfGamma.h:135
std::vector< Bin2D > const & GetBins2D() const
Definition: DirOfGamma.h:88
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:100
bool operator()(Hit2D *p1, Hit2D *p2) const
Definition: DirOfGamma.h:215
bDistCentMore2D(const TVector2 &c)
Definition: DirOfGamma.h:193
std::vector< Hit2D * > fHits2D
Definition: DirOfGamma.h:71
size_t const & GetPlane() const
Definition: DirOfGamma.h:94
art::Ptr< recob::Hit > const & GetHit() const
Definition: DirOfGamma.h:90
size_t GetIdCandidate()
Definition: DirOfGamma.h:147
unsigned int Size() const
Definition: DirOfGamma.h:60
art::Ptr< recob::Hit > const & GetHitPtr() const
Definition: DirOfGamma.h:38
TVector2 fBaryCenter
Definition: DirOfGamma.h:183
size_t fNbins
Definition: DirOfGamma.h:101
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:165
void SetIdCandidate(size_t id)
Definition: DirOfGamma.h:137
bDistCentLess2D(const TVector2 &c)
Definition: DirOfGamma.h:213
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
std::vector< Hit2D * > const & GetHits2D() const
Definition: DirOfGamma.h:133
Hit2D fCenter2D
Definition: DirOfGamma.h:99
unsigned int fSize
Definition: DirOfGamma.h:73
void hits()
Definition: readHits.C:15
Float_t radius
Definition: plot.C:23
const TVector2 & fCenter2D
Definition: DirOfGamma.h:70
std::vector< art::Ptr< recob::Hit > > const & GetIniHits() const
Definition: DirOfGamma.h:155
double fTotCharge
Definition: DirOfGamma.h:72
TVector2 const & GetBaryCenterCm() const
Definition: DirOfGamma.h:131
bool operator()(Hit2D *p1, Hit2D *p2) const
Definition: DirOfGamma.h:195
double GetCharge() const
Definition: DirOfGamma.h:36
size_t GetIdCl() const
Definition: DirOfGamma.h:157
size_t fPlane
Definition: DirOfGamma.h:114
General LArSoft Utilities.
double GetTotCharge() const
Definition: DirOfGamma.h:58
Definition: DirOfGamma.h:22
Detector simulation of raw signals on wires.
size_t fMaxChargeIdBin
Definition: DirOfGamma.h:108
double fCharge
Definition: DirOfGamma.h:41
size_t const & GetTPC() const
Definition: DirOfGamma.h:95
size_t fCandidateID
Definition: DirOfGamma.h:162
double GetMaxCharge() const
Definition: DirOfGamma.h:84
art::Ptr< recob::Hit > fHit
Definition: DirOfGamma.h:45
bool fIsCandidateIDset
Definition: DirOfGamma.h:188
const std::vector< art::Ptr< recob::Hit > > GetIniHits() const
Definition: DirOfGamma.h:92
TVector2 fStartPoint
Definition: DirOfGamma.h:169
size_t const & GetCryo() const
Definition: DirOfGamma.h:96
const TVector2 & GetCenter() const
Definition: DirOfGamma.h:64
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:166
TVector2 const & GetPointCm() const
Definition: DirOfGamma.h:35
double fMeanCharge
Definition: DirOfGamma.h:104
Bin2D const & MaxChargeBin() const
Definition: DirOfGamma.h:86
TVector2 const & GetFirstPoint() const
Definition: DirOfGamma.h:153
double fMaxCharge
Definition: DirOfGamma.h:103
std::vector< Hit2D * > const & GetHits2D() const
Definition: DirOfGamma.h:62
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:106
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:168
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:170
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:164
size_t fCryo
Definition: DirOfGamma.h:116