LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ems::DirOfGamma Class Reference

#include "DirOfGamma.h"

Public Member Functions

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

Private Member Functions

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

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 119 of file DirOfGamma.h.

Constructor & Destructor Documentation

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

Definition at line 160 of file DirOfGamma.cxx.

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

164  : fNbins(nbins), fIdCl(idcl), fCandidateID(0), fIsCandidateIDset(false)
165 {
166  fHits = src;
167 
168  for (unsigned int i = 0; i < src.size(); i++) {
169  Hit2D* hit = new Hit2D(detProp, src[i]);
170  fPoints2D.push_back(hit);
171  }
172 
174 
175  for (unsigned int i = 0; i < fNbins; i++)
176  fBins.push_back(Bin2D(fBaryCenter));
177 
178  FillBins();
179  ComputeMaxDist();
180  if (FindCandidates()) {
182  FindInitialPart();
183  }
184 }
void FindInitialPart()
Definition: DirOfGamma.cxx:286
std::vector< art::Ptr< recob::Hit > > fHits
Definition: DirOfGamma.h:171
bool FindCandidates()
Definition: DirOfGamma.cxx:247
TVector2 fBaryCenter
Definition: DirOfGamma.h:183
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:165
void ComputeMaxDist()
Definition: DirOfGamma.cxx:229
Detector simulation of raw signals on wires.
size_t fCandidateID
Definition: DirOfGamma.h:162
bool fIsCandidateIDset
Definition: DirOfGamma.h:188
void ComputeBaryCenter()
Definition: DirOfGamma.cxx:186
void ComputeMaxCharge()
Definition: DirOfGamma.cxx:276
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:164
ems::DirOfGamma::~DirOfGamma ( )
inline

Definition at line 125 of file DirOfGamma.h.

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

Member Function Documentation

void ems::DirOfGamma::ComputeBaryCenter ( )
private

Definition at line 186 of file DirOfGamma.cxx.

References fBaryCenter, and fPoints2D.

Referenced by DirOfGamma().

187 {
188  double nomx = 0.0;
189  double nomy = 0.0;
190  double denom = 0.0;
191  for (unsigned int i = 0; i < fPoints2D.size(); i++) {
192  nomx += fPoints2D[i]->GetPointCm().X() * fPoints2D[i]->GetCharge();
193  nomy += fPoints2D[i]->GetPointCm().Y() * fPoints2D[i]->GetCharge();
194  denom += fPoints2D[i]->GetCharge();
195  }
196 
197  double bx = nomx / denom;
198  double by = nomy / denom;
199  fBaryCenter.Set(bx, by);
200 }
TVector2 fBaryCenter
Definition: DirOfGamma.h:183
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:164
void ems::DirOfGamma::ComputeFinalValues ( )
private
void ems::DirOfGamma::ComputeMaxCharge ( )
private

Definition at line 276 of file DirOfGamma.cxx.

References fCandidates, and fNormCharge.

Referenced by DirOfGamma().

277 {
278  fNormCharge = 0.0;
279  for (unsigned int i = 0; i < fCandidates.size(); i++) {
280  if (fCandidates[i].GetMaxCharge() > fNormCharge) {
281  fNormCharge = fCandidates[i].GetMaxCharge();
282  }
283  }
284 }
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:166
void ems::DirOfGamma::ComputeMaxDist ( )
private

Definition at line 229 of file DirOfGamma.cxx.

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

Referenced by DirOfGamma().

230 {
231  double maxdist2 = 0.0;
232 
233  for (unsigned int id = 0; id < fBins.size(); id++) {
234 
235  if (!fBins[id].Size()) continue;
236 
237  Hit2D* candidate = fBins[id].GetHits2D().front();
238  if (candidate) {
239  double dist2 = pma::Dist2(candidate->GetPointCm(), fBaryCenter);
240  if (dist2 > maxdist2) { maxdist2 = dist2; }
241  }
242  }
243 
244  fNormDist = std::sqrt(maxdist2);
245 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
TVector2 fBaryCenter
Definition: DirOfGamma.h:183
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:165
void ems::DirOfGamma::FillBins ( )
private

Definition at line 202 of file DirOfGamma.cxx.

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

Referenced by DirOfGamma().

203 {
204  TVector2 vstart(0, 1);
205 
206  for (unsigned int i = 0; i < fPoints2D.size(); i++) {
207  TVector2 pos(fPoints2D[i]->GetPointCm().X(), fPoints2D[i]->GetPointCm().Y());
208  TVector2 vecp = pos - fBaryCenter;
209  float sinsign = (vstart.X() * vecp.Y()) - (vstart.Y() * vecp.X());
210  float cosine = (vstart * vecp) / (vstart.Mod() * vecp.Mod());
211  float theta = 180.0F * (std::acos(cosine)) / TMath::Pi();
212 
213  unsigned int id = 0;
214  double bin = double(360.0) / double(fNbins);
215 
216  if (sinsign >= 0)
217  id = int(theta / bin);
218  else if (sinsign < 0)
219  id = int(theta / bin) + (fNbins / 2);
220  if (id > (fNbins - 1)) id = (fNbins - 1);
221 
222  fBins[id].Add(fPoints2D[i]);
223  }
224 
225  for (unsigned int id = 0; id < fBins.size(); id++)
226  fBins[id].Sort();
227 }
Float_t Y
Definition: plot.C:37
TVector2 fBaryCenter
Definition: DirOfGamma.h:183
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:165
float bin[41]
Definition: plottest35.C:14
Float_t X
Definition: plot.C:37
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:164
bool ems::DirOfGamma::FindCandidates ( )
private

Definition at line 247 of file DirOfGamma.cxx.

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

Referenced by DirOfGamma().

248 {
249  float rad = 0.5F * fNormDist;
250  unsigned int nbins = fNbins * 4;
251  for (unsigned int id = 0; id < fNbins; id++) {
252 
253  if (!fBins[id].Size()) continue;
254 
255  std::vector<Hit2D*> points;
256  Hit2D* candidate2D = fBins[id].GetHits2D().front();
257 
258  for (unsigned int i = 0; i < fPoints2D.size(); i++) {
259  double distnorm = std::sqrt(pma::Dist2(candidate2D->GetPointCm(), fBaryCenter)) / fNormDist;
260  double dist2 = pma::Dist2(candidate2D->GetPointCm(), fPoints2D[i]->GetPointCm());
261 
262  if ((distnorm > 0.5) && (dist2 < rad * rad)) points.push_back(fPoints2D[i]);
263  }
264 
265  if (fBins[id].Size() > 1) {
266  EndPoint ep(*candidate2D, points, nbins);
267  fCandidates.push_back(ep);
268  }
269  }
270  if (fCandidates.size())
271  return true;
272  else
273  return false;
274 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
TVector2 fBaryCenter
Definition: DirOfGamma.h:183
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:165
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:166
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:164
void ems::DirOfGamma::FindInitialPart ( )
private

Definition at line 286 of file DirOfGamma.cxx.

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

Referenced by DirOfGamma().

287 {
288  double max_asymmetry = 0.0;
289  unsigned int saveid = 0;
290  bool found = false;
291 
292  double maxdist2 = 0.0;
293  double maxcharge = 0.0;
294  unsigned int idmaxdist = 0;
295  unsigned int idmaxcharge = 0;
296 
297  for (unsigned int i = 0; i < fCandidates.size(); i++) {
298  double dist2 = pma::Dist2(fCandidates[i].GetPosition(), fBaryCenter);
299  double charge = fCandidates[i].GetMaxCharge();
300  if (dist2 > maxdist2) {
301  maxdist2 = dist2;
302  idmaxdist = i;
303  }
304  if (charge > maxcharge) {
305  maxcharge = charge;
306  idmaxcharge = i;
307  }
308  }
309 
310  maxdist2 = 0.0;
311  unsigned int idmaxdistb = 0;
312  for (size_t i = 0; i < fCandidates.size(); i++) {
313  if ((i == idmaxdist) || (i == idmaxcharge)) continue;
314 
315  double dist2 = pma::Dist2(fCandidates[i].GetPosition(), fCandidates[idmaxdist].GetPosition());
316  if (dist2 > maxdist2) {
317  maxdist2 = dist2;
318  idmaxdistb = i;
319  }
320  }
321 
322  if (fCandidates.size() > 2) {
323  for (unsigned int i = 0; i < fCandidates.size(); i++) {
324  double asymmetry = fCandidates[i].GetAsymmetry();
325 
326  if ((i == idmaxdist) || (i == idmaxcharge) || (i == idmaxdistb)) {
327  if (asymmetry > max_asymmetry) {
328  max_asymmetry = asymmetry;
329  saveid = i;
330  found = true;
331  }
332  }
333  }
334  }
335  else {
336  for (unsigned int i = 0; i < fCandidates.size(); i++) {
337  double asymmetry = fCandidates[i].GetAsymmetry();
338 
339  if ((i == idmaxdist) || (i == idmaxdistb)) {
340  if (asymmetry > max_asymmetry) {
341  max_asymmetry = asymmetry;
342  saveid = i;
343  found = true;
344  }
345  }
346  }
347  }
348 
349  if (!found)
350  mf::LogError("DirOfGamma") << fCandidates.size() << "DirOfGamma - Find Initial Part problem.";
351 
352  fStartHit = fCandidates[saveid].GetHit();
353  fStartPoint = fCandidates[saveid].GetPosition();
354  fIniHits = fCandidates[saveid].MaxChargeBin().GetIniHits();
355  fCandidateID = saveid;
356 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
Definition: Utilities.cxx:39
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TVector2 fBaryCenter
Definition: DirOfGamma.h:183
size_t fCandidateID
Definition: DirOfGamma.h:162
TVector2 fStartPoint
Definition: DirOfGamma.h:169
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:166
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:168
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:170
TVector2 const& ems::DirOfGamma::GetBaryCenterCm ( ) const
inline

Definition at line 131 of file DirOfGamma.h.

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

Definition at line 135 of file DirOfGamma.h.

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

Definition at line 149 of file DirOfGamma.h.

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

Definition at line 153 of file DirOfGamma.h.

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

Definition at line 151 of file DirOfGamma.h.

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

Definition at line 133 of file DirOfGamma.h.

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

133 { return fPoints2D; }
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:164
size_t ems::DirOfGamma::GetIdCandidate ( )
inline

Definition at line 147 of file DirOfGamma.h.

147 { return fCandidateID; }
size_t fCandidateID
Definition: DirOfGamma.h:162
size_t ems::DirOfGamma::GetIdCl ( ) const
inline

Definition at line 157 of file DirOfGamma.h.

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

Definition at line 155 of file DirOfGamma.h.

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

Definition at line 137 of file DirOfGamma.h.

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  }
size_t fCandidateID
Definition: DirOfGamma.h:162
bool fIsCandidateIDset
Definition: DirOfGamma.h:188
TVector2 fStartPoint
Definition: DirOfGamma.h:169
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:166
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:168
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:170

Member Data Documentation

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

Definition at line 165 of file DirOfGamma.h.

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

size_t ems::DirOfGamma::fCandidateID
private

Definition at line 162 of file DirOfGamma.h.

Referenced by FindInitialPart().

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

Definition at line 166 of file DirOfGamma.h.

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

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

Definition at line 171 of file DirOfGamma.h.

Referenced by DirOfGamma().

size_t ems::DirOfGamma::fIdCl
private

Definition at line 161 of file DirOfGamma.h.

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

Definition at line 170 of file DirOfGamma.h.

Referenced by FindInitialPart().

bool ems::DirOfGamma::fIsCandidateIDset
private

Definition at line 188 of file DirOfGamma.h.

size_t ems::DirOfGamma::fNbins
private

Definition at line 160 of file DirOfGamma.h.

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

float ems::DirOfGamma::fNormCharge
private

Definition at line 186 of file DirOfGamma.h.

Referenced by ComputeMaxCharge().

float ems::DirOfGamma::fNormDist
private

Definition at line 185 of file DirOfGamma.h.

Referenced by ComputeMaxDist(), and FindCandidates().

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

Definition at line 164 of file DirOfGamma.h.

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

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

Definition at line 168 of file DirOfGamma.h.

Referenced by FindInitialPart().

TVector2 ems::DirOfGamma::fStartPoint
private

Definition at line 169 of file DirOfGamma.h.

Referenced by FindInitialPart().


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