All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DirOfGamma.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class:
3 // Module Type:
4 // File: DirOfGamma.h
5 // Authors: dorota.stefan@cern.ch robert.sulej@cern.ch
6 ////////////////////////////////////////////////////////////////////////
7 
8 #ifndef DirOfGamma_h
9 #define DirOfGamma_h
10 
12 namespace detinfo {
13  class DetectorPropertiesData;
14 }
15 
16 #include "canvas/Persistency/Common/Ptr.h"
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:
33  Hit2D(detinfo::DetectorPropertiesData const& detProp, art::Ptr<recob::Hit> src);
34 
35  TVector2 const&
36  GetPointCm() const
37  {
38  return fPoint;
39  }
40  double
41  GetCharge() const
42  {
43  return fCharge;
44  }
45 
46  art::Ptr<recob::Hit> const&
47  GetHitPtr() const
48  {
49  return fHit;
50  }
51 
52 private:
53  double fCharge;
54 
55  TVector2 fPoint;
56 
57  art::Ptr<recob::Hit> fHit;
58 };
59 
60 class ems::Bin2D {
61 public:
62  Bin2D(const TVector2& center);
63 
64  void Add(Hit2D* hit);
65 
66  void Sort();
67 
68  void SortLess();
69 
70  double
71  GetTotCharge() const
72  {
73  return fTotCharge;
74  }
75 
76  unsigned int
77  Size() const
78  {
79  return fSize;
80  }
81 
82  std::vector<Hit2D*> const&
83  GetHits2D() const
84  {
85  return fHits2D;
86  }
87 
88  const TVector2&
89  GetCenter() const
90  {
91  return fCenter2D;
92  }
93 
94  std::vector<art::Ptr<recob::Hit>> GetIniHits(const double radius = 10.0,
95  const unsigned int nhits = 10) const;
96 
97 private:
98  const TVector2& fCenter2D;
99  std::vector<Hit2D*> fHits2D;
100  double fTotCharge;
101  unsigned int fSize;
102 };
103 
105 public:
106  EndPoint(const Hit2D& center, const std::vector<Hit2D*>& hits, unsigned int nbins);
107 
108  TVector2 const&
109  GetPosition() const
110  {
111  return fCenter2D.GetPointCm();
112  }
113 
114  double GetAsymmetry() const;
115 
116  double
117  GetMaxCharge() const
118  {
119  return fMaxCharge;
120  }
121 
122  Bin2D const&
123  MaxChargeBin() const
124  {
125  return fBins[fMaxChargeIdBin];
126  }
127 
128  std::vector<Bin2D> const&
129  GetBins2D() const
130  {
131  return fBins;
132  }
133 
134  art::Ptr<recob::Hit> const&
135  GetHit() const
136  {
137  return fCenter2D.GetHitPtr();
138  }
139 
140  const std::vector<art::Ptr<recob::Hit>>
141  GetIniHits() const
142  {
143  return MaxChargeBin().GetIniHits();
144  }
145 
146  size_t const&
147  GetPlane() const
148  {
149  return fPlane;
150  }
151  size_t const&
152  GetTPC() const
153  {
154  return fTpc;
155  }
156  size_t const&
157  GetCryo() const
158  {
159  return fCryo;
160  }
161 
162 private:
164  std::vector<Hit2D*> fPoints2D;
165  size_t fNbins;
166 
167  double fMaxCharge;
168  double fMeanCharge;
169 
170  std::vector<Bin2D> fBins;
171 
173 
174  void FillBins();
175  void ComputeMaxCharge();
176  void ComputeMeanCharge();
177 
178  size_t fPlane;
179  size_t fTpc;
180  size_t fCryo;
181 };
182 
184 public:
186  const std::vector<art::Ptr<recob::Hit>>& src,
187  unsigned int nbins,
188  unsigned int idcl);
190  {
191  for (unsigned int i = 0; i < fPoints2D.size(); ++i)
192  delete fPoints2D[i];
193  }
194 
195  TVector2 const&
197  {
198  return fBaryCenter;
199  }
200 
201  std::vector<Hit2D*> const&
202  GetHits2D() const
203  {
204  return fPoints2D;
205  }
206 
207  std::vector<EndPoint> const&
209  {
210  return fCandidates;
211  }
212 
213  void
214  SetIdCandidate(size_t id)
215  {
216 
217  fIsCandidateIDset = true;
218  fCandidateID = id;
219  fStartHit = fCandidates[id].GetHit();
220  fStartPoint = fCandidates[id].GetPosition();
221  fIniHits = fCandidates[id].MaxChargeBin().GetIniHits();
222  }
223 
224  const size_t
226  {
227  return fCandidateID;
228  }
229 
230  art::Ptr<recob::Hit> const&
231  GetFirstHit() const
232  {
233  return fStartHit;
234  }
235 
236  std::vector<art::Ptr<recob::Hit>> const&
238  {
239  return fHits;
240  }
241 
242  TVector2 const&
244  {
245  return fStartPoint;
246  }
247 
248  std::vector<art::Ptr<recob::Hit>> const&
249  GetIniHits() const
250  {
251  return fIniHits;
252  }
253 
254  size_t const
255  GetIdCl() const
256  {
257  return fIdCl;
258  }
259 
260 private:
261  size_t fNbins;
262  size_t fIdCl;
263  size_t fCandidateID;
264 
265  std::vector<Hit2D*> fPoints2D;
266  std::vector<Bin2D> fBins;
267  std::vector<EndPoint> fCandidates;
268 
269  art::Ptr<recob::Hit> fStartHit;
270  TVector2 fStartPoint;
271  std::vector<art::Ptr<recob::Hit>> fIniHits;
272  std::vector<art::Ptr<recob::Hit>> fHits;
273 
274  void FindInitialPart();
275 
276  void FillBins();
277 
278  bool FindCandidates();
279  void ComputeBaryCenter();
280  void ComputeMaxDist();
281  void ComputeMaxCharge();
282  void ComputeFinalValues();
283 
284  TVector2 fBaryCenter;
285 
286  float fNormDist;
287  float fNormCharge;
288 
290 };
291 
292 class ems::bDistCentMore2D : public std::binary_function<Hit2D*, Hit2D*, bool> {
293 public:
294  bDistCentMore2D(const TVector2& c) : center(c) {}
295 
296  bool
298  {
299  double dx = p1->GetPointCm().X() - center.X();
300  double dy = p1->GetPointCm().Y() - center.Y();
301  double b1 = dx * dx + dy * dy;
302  dx = p2->GetPointCm().X() - center.X();
303  dy = p2->GetPointCm().Y() - center.Y();
304  double b2 = dx * dx + dy * dy;
305 
306  return b1 > b2;
307  }
308 
309 private:
310  TVector2 center;
311 };
312 
313 class ems::bDistCentLess2D : public std::binary_function<Hit2D*, Hit2D*, bool> {
314 public:
315  bDistCentLess2D(const TVector2& c) : center(c) {}
316 
317  bool
319  {
320  double dx = p1->GetPointCm().X() - center.X();
321  double dy = p1->GetPointCm().Y() - center.Y();
322  double b1 = dx * dx + dy * dy;
323  dx = p2->GetPointCm().X() - center.X();
324  dy = p2->GetPointCm().Y() - center.Y();
325  double b2 = dx * dx + dy * dy;
326 
327  return b1 < b2;
328  }
329 
330 private:
331  TVector2 center;
332 };
333 
334 #endif
TVector2 const & GetPosition() const
Definition: DirOfGamma.h:109
void SortLess()
Definition: DirOfGamma.cxx:57
void FindInitialPart()
Definition: DirOfGamma.cxx:309
TVector2 fPoint
Definition: DirOfGamma.h:55
DirOfGamma(const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &src, unsigned int nbins, unsigned int idcl)
Definition: DirOfGamma.cxx:177
void FillBins()
Definition: DirOfGamma.cxx:95
void ComputeFinalValues()
void Add(Hit2D *hit)
Definition: DirOfGamma.cxx:42
Declaration of signal hit object.
art::Ptr< recob::Hit > const & GetFirstHit() const
Definition: DirOfGamma.h:231
std::vector< art::Ptr< recob::Hit > > fHits
Definition: DirOfGamma.h:272
std::vector< art::Ptr< recob::Hit > > const & GetHits()
Definition: DirOfGamma.h:237
std::vector< EndPoint > const & GetCandidates() const
Definition: DirOfGamma.h:208
std::vector< Bin2D > const & GetBins2D() const
Definition: DirOfGamma.h:129
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:164
bDistCentMore2D(const TVector2 &c)
Definition: DirOfGamma.h:294
process_name hit
Definition: cheaterreco.fcl:51
std::vector< Hit2D * > fHits2D
Definition: DirOfGamma.h:99
size_t const & GetPlane() const
Definition: DirOfGamma.h:147
size_t const GetIdCl() const
Definition: DirOfGamma.h:255
art::Ptr< recob::Hit > const & GetHit() const
Definition: DirOfGamma.h:135
void ComputeMaxCharge()
Definition: DirOfGamma.cxx:134
unsigned int Size() const
Definition: DirOfGamma.h:77
bool FindCandidates()
Definition: DirOfGamma.cxx:268
art::Ptr< recob::Hit > const & GetHitPtr() const
Definition: DirOfGamma.h:47
TVector2 fBaryCenter
Definition: DirOfGamma.h:284
size_t fNbins
Definition: DirOfGamma.h:165
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:266
void SetIdCandidate(size_t id)
Definition: DirOfGamma.h:214
bDistCentLess2D(const TVector2 &c)
Definition: DirOfGamma.h:315
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::vector< Hit2D * > const & GetHits2D() const
Definition: DirOfGamma.h:202
Hit2D fCenter2D
Definition: DirOfGamma.h:163
unsigned int fSize
Definition: DirOfGamma.h:101
void ComputeMaxDist()
Definition: DirOfGamma.cxx:249
const TVector2 & fCenter2D
Definition: DirOfGamma.h:98
std::vector< art::Ptr< recob::Hit > > const & GetIniHits() const
Definition: DirOfGamma.h:249
double fTotCharge
Definition: DirOfGamma.h:100
TVector2 const & GetBaryCenterCm() const
Definition: DirOfGamma.h:196
Hit2D(detinfo::DetectorPropertiesData const &detProp, art::Ptr< recob::Hit > src)
Definition: DirOfGamma.cxx:14
EndPoint(const Hit2D &center, const std::vector< Hit2D * > &hits, unsigned int nbins)
Definition: DirOfGamma.cxx:77
double GetCharge() const
Definition: DirOfGamma.h:41
size_t fPlane
Definition: DirOfGamma.h:178
std::vector< art::Ptr< recob::Hit > > GetIniHits(const double radius=10.0, const unsigned int nhits=10) const
Definition: DirOfGamma.cxx:63
double GetTotCharge() const
Definition: DirOfGamma.h:71
size_t fMaxChargeIdBin
Definition: DirOfGamma.h:172
double fCharge
Definition: DirOfGamma.h:53
size_t const & GetTPC() const
Definition: DirOfGamma.h:152
size_t fCandidateID
Definition: DirOfGamma.h:263
double GetMaxCharge() const
Definition: DirOfGamma.h:117
const size_t GetIdCandidate()
Definition: DirOfGamma.h:225
art::Ptr< recob::Hit > fHit
Definition: DirOfGamma.h:57
bool fIsCandidateIDset
Definition: DirOfGamma.h:289
const std::vector< art::Ptr< recob::Hit > > GetIniHits() const
Definition: DirOfGamma.h:141
void ComputeBaryCenter()
Definition: DirOfGamma.cxx:204
void ComputeMaxCharge()
Definition: DirOfGamma.cxx:298
TVector2 fStartPoint
Definition: DirOfGamma.h:270
size_t const & GetCryo() const
Definition: DirOfGamma.h:157
void Sort()
Definition: DirOfGamma.cxx:51
const TVector2 & GetCenter() const
Definition: DirOfGamma.h:89
bool operator()(Hit2D *p1, Hit2D *p2)
Definition: DirOfGamma.h:318
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:267
TVector2 const & GetPointCm() const
Definition: DirOfGamma.h:36
double fMeanCharge
Definition: DirOfGamma.h:168
void ComputeMeanCharge()
Definition: DirOfGamma.cxx:148
Bin2D const & MaxChargeBin() const
Definition: DirOfGamma.h:123
TVector2 const & GetFirstPoint() const
Definition: DirOfGamma.h:243
double fMaxCharge
Definition: DirOfGamma.h:167
double GetAsymmetry() const
Definition: DirOfGamma.cxx:171
std::vector< Hit2D * > const & GetHits2D() const
Definition: DirOfGamma.h:83
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:170
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:269
physics associatedGroupsWithLeft p1
auto const detProp
bool operator()(Hit2D *p1, Hit2D *p2)
Definition: DirOfGamma.h:297
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:271
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:265
size_t fCryo
Definition: DirOfGamma.h:180
Bin2D(const TVector2 &center)
Definition: DirOfGamma.cxx:39