LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ems::DirOfGamma Class Reference

#include "DirOfGamma.h"

Public Member Functions

 DirOfGamma (const std::vector< art::Ptr< recob::Hit > > &src, unsigned int nbins, unsigned int idcl)
 
 ~DirOfGamma ()
 
TVector2 const & GetBaryCenterCm (void) const
 
std::vector< Hit2D * > const & GetHits2D (void) const
 
std::vector< EndPoint > const & GetCandidates (void) const
 
void SetIdCandidate (size_t id)
 
const size_t GetIdCandidate (void)
 
art::Ptr< recob::Hit > const & GetFirstHit (void) const
 
std::vector< art::Ptr< recob::Hit > > const & GetHits (void)
 
TVector2 const & GetFirstPoint (void) const
 
std::vector< art::Ptr< recob::Hit > > const & GetIniHits (void) const
 
size_t const GetIdCl (void) const
 

Private Member Functions

void FindInitialPart (void)
 
void FillBins (void)
 
bool FindCandidates (void)
 
void ComputeBaryCenter (void)
 
void ComputeMaxDist (void)
 
void ComputeMaxCharge (void)
 
void ComputeFinalValues (void)
 

Private Attributes

size_t fNbins
 
size_t fIdCl
 
size_t fCandidateID
 
std::vector< Hit2D * > fPoints2D
 
std::vector< Bin2DfBins
 
std::vector< EndPointfCandidates
 
art::Ptr< recob::HitfStartHit
 
TVector2 fStartPoint
 
std::vector< art::Ptr< recob::Hit > > fIniHits
 
std::vector< art::Ptr< recob::Hit > > fHits
 
TVector2 fBaryCenter
 
float fNormDist
 
float fNormCharge
 
bool fIsCandidateIDset
 

Detailed Description

Definition at line 118 of file DirOfGamma.h.

Constructor & Destructor Documentation

ems::DirOfGamma::DirOfGamma ( const std::vector< art::Ptr< recob::Hit > > &  src,
unsigned int  nbins,
unsigned int  idcl 
)

Definition at line 180 of file DirOfGamma.cxx.

References ComputeBaryCenter(), ComputeMaxCharge(), ComputeMaxDist(), fBaryCenter, fBins, fHits, FillBins(), FindCandidates(), FindInitialPart(), fNbins, and fPoints2D.

180  :
181 fNbins(nbins),
182 fIdCl(idcl),
183 fCandidateID(0),
184 fIsCandidateIDset(false)
185 {
186  fHits = src;
187 
188  for (unsigned int i = 0; i < src.size(); i++)
189  {
190  Hit2D* hit = new Hit2D(src[i]);
191  fPoints2D.push_back(hit);
192  }
193 
195 
196  for (unsigned int i = 0; i < fNbins; i++)
197  fBins.push_back(Bin2D(fBaryCenter));
198 
199  FillBins();
200  ComputeMaxDist();
201  if (FindCandidates())
202  {
204  FindInitialPart();
205  }
206 }
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:155
void FillBins(void)
Definition: DirOfGamma.cxx:223
void ComputeMaxCharge(void)
Definition: DirOfGamma.cxx:301
void FindInitialPart(void)
Definition: DirOfGamma.cxx:313
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:156
TVector2 fBaryCenter
Definition: DirOfGamma.h:174
void ComputeBaryCenter(void)
Definition: DirOfGamma.cxx:208
Detector simulation of raw signals on wires.
bool FindCandidates(void)
Definition: DirOfGamma.cxx:271
size_t fCandidateID
Definition: DirOfGamma.h:153
void ComputeMaxDist(void)
Definition: DirOfGamma.cxx:248
bool fIsCandidateIDset
Definition: DirOfGamma.h:179
std::vector< art::Ptr< recob::Hit > > fHits
Definition: DirOfGamma.h:162
ems::DirOfGamma::~DirOfGamma ( )
inline

Definition at line 122 of file DirOfGamma.h.

122 { for (unsigned int i = 0; i < fPoints2D.size(); ++i) delete fPoints2D[i];}
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:155

Member Function Documentation

void ems::DirOfGamma::ComputeBaryCenter ( void  )
private

Definition at line 208 of file DirOfGamma.cxx.

References fBaryCenter, and fPoints2D.

Referenced by DirOfGamma().

209 {
210  double nomx = 0.0; double nomy = 0.0;
211  double denom = 0.0;
212  for (unsigned int i = 0; i < fPoints2D.size(); i++)
213  {
214  nomx += fPoints2D[i]->GetPointCm().X() * fPoints2D[i]->GetCharge();
215  nomy += fPoints2D[i]->GetPointCm().Y() * fPoints2D[i]->GetCharge();
216  denom += fPoints2D[i]->GetCharge();
217  }
218 
219  double bx = nomx / denom; double by = nomy / denom;
220  fBaryCenter.Set(bx, by);
221 }
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:155
TVector2 fBaryCenter
Definition: DirOfGamma.h:174
void ems::DirOfGamma::ComputeFinalValues ( void  )
private
void ems::DirOfGamma::ComputeMaxCharge ( void  )
private

Definition at line 301 of file DirOfGamma.cxx.

References fCandidates, and fNormCharge.

Referenced by DirOfGamma().

302 {
303  fNormCharge = 0.0;
304  for (unsigned int i = 0; i < fCandidates.size(); i++)
305  {
306  if (fCandidates[i].GetMaxCharge() > fNormCharge)
307  {
308  fNormCharge = fCandidates[i].GetMaxCharge();
309  }
310  }
311 }
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:157
void ems::DirOfGamma::ComputeMaxDist ( void  )
private

Definition at line 248 of file DirOfGamma.cxx.

References pma::Dist2(), fBaryCenter, fBins, fNormDist, and ems::Hit2D::GetPointCm().

Referenced by DirOfGamma().

249 {
250  double maxdist2 = 0.0;
251 
252  for (unsigned int id = 0; id < fBins.size(); id++)
253  {
254 
255  if (!fBins[id].Size()) continue;
256 
257  Hit2D* candidate = fBins[id].GetHits2D().front();
258  if (candidate)
259  {
260  double dist2 = pma::Dist2(candidate->GetPointCm(), fBaryCenter);
261  if (dist2 > maxdist2)
262  {
263  maxdist2 = dist2;
264  }
265  }
266  }
267 
268  fNormDist = std::sqrt(maxdist2);
269 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:156
TVector2 fBaryCenter
Definition: DirOfGamma.h:174
void ems::DirOfGamma::FillBins ( void  )
private

Definition at line 223 of file DirOfGamma.cxx.

References bin, fBaryCenter, fBins, fNbins, fPoints2D, X, and Y.

Referenced by DirOfGamma().

224 {
225  TVector2 vstart(0, 1);
226 
227  for (unsigned int i = 0; i < fPoints2D.size(); i++)
228  {
229  TVector2 pos(fPoints2D[i]->GetPointCm().X(), fPoints2D[i]->GetPointCm().Y());
230  TVector2 vecp = pos - fBaryCenter;
231  float sinsign = (vstart.X() * vecp.Y()) - (vstart.Y() * vecp.X());
232  float cosine = (vstart * vecp) / (vstart.Mod() * vecp.Mod());
233  float theta = 180.0F * (std::acos(cosine)) / TMath::Pi();
234 
235  unsigned int id = 0; double bin = double(360.0) / double(fNbins);
236 
237  if (sinsign >= 0) id = int (theta / bin);
238  else if (sinsign < 0) id = int (theta / bin) + (fNbins/2);
239  if (id > (fNbins - 1)) id = (fNbins - 1);
240 
241  fBins[id].Add(fPoints2D[i]);
242  }
243 
244  for (unsigned int id = 0; id < fBins.size(); id++) fBins[id].Sort();
245 
246 }
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:155
Float_t Y
Definition: plot.C:39
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:156
TVector2 fBaryCenter
Definition: DirOfGamma.h:174
float bin[41]
Definition: plottest35.C:14
Float_t X
Definition: plot.C:39
bool ems::DirOfGamma::FindCandidates ( void  )
private

Definition at line 271 of file DirOfGamma.cxx.

References pma::Dist2(), fBaryCenter, fBins, fCandidates, fNbins, fNormDist, fPoints2D, and ems::Hit2D::GetPointCm().

Referenced by DirOfGamma().

272 {
273  float rad = 0.5F * fNormDist; unsigned int nbins = fNbins * 4;
274  for (unsigned int id = 0; id < fNbins; id++)
275  {
276 
277  if (!fBins[id].Size()) continue;
278 
279  std::vector< Hit2D* > points;
280  Hit2D* candidate2D = fBins[id].GetHits2D().front();
281 
282  for (unsigned int i = 0; i < fPoints2D.size(); i++)
283  {
284  double distnorm = std::sqrt(pma::Dist2(candidate2D->GetPointCm(), fBaryCenter)) / fNormDist;
285  double dist2 = pma::Dist2(candidate2D->GetPointCm(), fPoints2D[i]->GetPointCm());
286 
287  if ((distnorm > 0.5) && (dist2 < rad*rad)) points.push_back(fPoints2D[i]);
288  }
289 
290 
291  if (fBins[id].Size() > 1)
292  {
293  EndPoint ep(*candidate2D, points, nbins);
294  fCandidates.push_back(ep);
295  }
296  }
297  if (fCandidates.size()) return true;
298  else return false;
299 }
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:155
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:156
TVector2 fBaryCenter
Definition: DirOfGamma.h:174
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:157
void ems::DirOfGamma::FindInitialPart ( void  )
private

Definition at line 313 of file DirOfGamma.cxx.

References pma::Dist2(), fBaryCenter, fCandidateID, fCandidates, fIniHits, fStartHit, and fStartPoint.

Referenced by DirOfGamma().

314 {
315  double max_asymmetry = 0.0;
316  unsigned int saveid = 0; bool found = false;
317 
318  double maxdist2 = 0.0; double maxcharge = 0.0;
319  unsigned int idmaxdist = 0; unsigned int idmaxcharge = 0;
320 
321  for (unsigned int i = 0; i < fCandidates.size(); i++)
322  {
323  double dist2 = pma::Dist2(fCandidates[i].GetPosition(), fBaryCenter);
324  double charge = fCandidates[i].GetMaxCharge();
325  if (dist2 > maxdist2) { maxdist2 = dist2; idmaxdist = i;}
326  if (charge > maxcharge) { maxcharge = charge; idmaxcharge = i;}
327  }
328 
329  maxdist2 = 0.0; unsigned int idmaxdistb = 0;
330  for (size_t i = 0; i < fCandidates.size(); i++)
331  {
332  if ((i == idmaxdist) || (i == idmaxcharge)) continue;
333 
334  double dist2 = pma::Dist2(fCandidates[i].GetPosition(), fCandidates[idmaxdist].GetPosition());
335  if (dist2 > maxdist2) { maxdist2 = dist2; idmaxdistb = i;}
336  }
337 
338  if (fCandidates.size() > 2)
339  {
340  for (unsigned int i = 0; i < fCandidates.size(); i++)
341  {
342  double asymmetry = fCandidates[i].GetAsymmetry();
343 
344  if ((i == idmaxdist) || (i == idmaxcharge) || (i == idmaxdistb))
345  {
346  if (asymmetry > max_asymmetry)
347  {
348  max_asymmetry = asymmetry;
349  saveid = i; found = true;
350  }
351  }
352  }
353  }
354  else
355  {
356  for (unsigned int i = 0; i < fCandidates.size(); i++)
357  {
358  double asymmetry = fCandidates[i].GetAsymmetry();
359 
360  if ((i == idmaxdist) || (i == idmaxdistb))
361  {
362  if (asymmetry > max_asymmetry)
363  {
364  max_asymmetry = asymmetry;
365  saveid = i; found = true;
366  }
367  }
368  }
369  }
370 
371  if (!found) mf::LogError("DirOfGamma") << fCandidates.size() << "DirOfGamma - Find Initial Part problem.";
372 
373  fStartHit = fCandidates[saveid].GetHit();
374  fStartPoint = fCandidates[saveid].GetPosition();
375  fIniHits = fCandidates[saveid].MaxChargeBin().GetIniHits();
376  fCandidateID = saveid;
377 
378 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:19
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TVector2 fBaryCenter
Definition: DirOfGamma.h:174
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:161
size_t fCandidateID
Definition: DirOfGamma.h:153
TVector2 fStartPoint
Definition: DirOfGamma.h:160
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:159
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:157
TVector2 const& ems::DirOfGamma::GetBaryCenterCm ( void  ) const
inline

Definition at line 124 of file DirOfGamma.h.

124 { return fBaryCenter; }
TVector2 fBaryCenter
Definition: DirOfGamma.h:174
std::vector< EndPoint > const& ems::DirOfGamma::GetCandidates ( void  ) const
inline

Definition at line 128 of file DirOfGamma.h.

128 { return fCandidates; }
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:157
art::Ptr< recob::Hit > const& ems::DirOfGamma::GetFirstHit ( void  ) const
inline

Definition at line 140 of file DirOfGamma.h.

140 { return fStartHit; }
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:159
TVector2 const& ems::DirOfGamma::GetFirstPoint ( void  ) const
inline

Definition at line 144 of file DirOfGamma.h.

144 { return fStartPoint; }
TVector2 fStartPoint
Definition: DirOfGamma.h:160
std::vector< art::Ptr< recob::Hit > > const& ems::DirOfGamma::GetHits ( void  )
inline

Definition at line 142 of file DirOfGamma.h.

142 { return fHits; }
std::vector< art::Ptr< recob::Hit > > fHits
Definition: DirOfGamma.h:162
std::vector< Hit2D* > const& ems::DirOfGamma::GetHits2D ( void  ) const
inline

Definition at line 126 of file DirOfGamma.h.

Referenced by ems::EMShower3D::CollectShower2D().

126 { return fPoints2D; }
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:155
const size_t ems::DirOfGamma::GetIdCandidate ( void  )
inline

Definition at line 138 of file DirOfGamma.h.

138 { return fCandidateID; }
size_t fCandidateID
Definition: DirOfGamma.h:153
size_t const ems::DirOfGamma::GetIdCl ( void  ) const
inline

Definition at line 148 of file DirOfGamma.h.

148 {return fIdCl;}
std::vector< art::Ptr< recob::Hit > > const& ems::DirOfGamma::GetIniHits ( void  ) const
inline

Definition at line 146 of file DirOfGamma.h.

146 { return fIniHits;}
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:161
void ems::DirOfGamma::SetIdCandidate ( size_t  id)
inline

Definition at line 130 of file DirOfGamma.h.

130  {
131 
132  fIsCandidateIDset = true; fCandidateID = id;
133  fStartHit = fCandidates[id].GetHit();
134  fStartPoint = fCandidates[id].GetPosition();
135  fIniHits = fCandidates[id].MaxChargeBin().GetIniHits();
136  }
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:161
size_t fCandidateID
Definition: DirOfGamma.h:153
bool fIsCandidateIDset
Definition: DirOfGamma.h:179
TVector2 fStartPoint
Definition: DirOfGamma.h:160
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:159
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:157

Member Data Documentation

TVector2 ems::DirOfGamma::fBaryCenter
private
std::vector< Bin2D > ems::DirOfGamma::fBins
private

Definition at line 156 of file DirOfGamma.h.

Referenced by ComputeMaxDist(), DirOfGamma(), FillBins(), and FindCandidates().

size_t ems::DirOfGamma::fCandidateID
private

Definition at line 153 of file DirOfGamma.h.

Referenced by FindInitialPart().

std::vector< EndPoint > ems::DirOfGamma::fCandidates
private

Definition at line 157 of file DirOfGamma.h.

Referenced by ComputeMaxCharge(), FindCandidates(), and FindInitialPart().

std::vector< art::Ptr< recob::Hit > > ems::DirOfGamma::fHits
private

Definition at line 162 of file DirOfGamma.h.

Referenced by DirOfGamma().

size_t ems::DirOfGamma::fIdCl
private

Definition at line 152 of file DirOfGamma.h.

std::vector< art::Ptr< recob::Hit > > ems::DirOfGamma::fIniHits
private

Definition at line 161 of file DirOfGamma.h.

Referenced by FindInitialPart().

bool ems::DirOfGamma::fIsCandidateIDset
private

Definition at line 179 of file DirOfGamma.h.

size_t ems::DirOfGamma::fNbins
private

Definition at line 151 of file DirOfGamma.h.

Referenced by DirOfGamma(), FillBins(), and FindCandidates().

float ems::DirOfGamma::fNormCharge
private

Definition at line 177 of file DirOfGamma.h.

Referenced by ComputeMaxCharge().

float ems::DirOfGamma::fNormDist
private

Definition at line 176 of file DirOfGamma.h.

Referenced by ComputeMaxDist(), and FindCandidates().

std::vector< Hit2D* > ems::DirOfGamma::fPoints2D
private

Definition at line 155 of file DirOfGamma.h.

Referenced by ComputeBaryCenter(), DirOfGamma(), FillBins(), and FindCandidates().

art::Ptr< recob::Hit > ems::DirOfGamma::fStartHit
private

Definition at line 159 of file DirOfGamma.h.

Referenced by FindInitialPart().

TVector2 ems::DirOfGamma::fStartPoint
private

Definition at line 160 of file DirOfGamma.h.

Referenced by FindInitialPart().


The documentation for this class was generated from the following files: