Public Member Functions | Private Member Functions | Private Attributes | List of all members
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)
 
const 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 const 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 181 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 177 of file DirOfGamma.cxx.

181  : fNbins(nbins), fIdCl(idcl), fCandidateID(0), fIsCandidateIDset(false)
182 {
183  fHits = src;
184 
185  for (unsigned int i = 0; i < src.size(); i++) {
186  Hit2D* hit = new Hit2D(detProp, src[i]);
187  fPoints2D.push_back(hit);
188  }
189 
191 
192  for (unsigned int i = 0; i < fNbins; i++)
193  fBins.push_back(Bin2D(fBaryCenter));
194 
195  FillBins();
196  ComputeMaxDist();
197  if (FindCandidates()) {
199  FindInitialPart();
200  }
201 }
void FindInitialPart()
Definition: DirOfGamma.cxx:309
std::vector< art::Ptr< recob::Hit > > fHits
Definition: DirOfGamma.h:270
bool FindCandidates()
Definition: DirOfGamma.cxx:268
TVector2 fBaryCenter
Definition: DirOfGamma.h:282
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:264
void ComputeMaxDist()
Definition: DirOfGamma.cxx:249
Detector simulation of raw signals on wires.
size_t fCandidateID
Definition: DirOfGamma.h:261
bool fIsCandidateIDset
Definition: DirOfGamma.h:287
void ComputeBaryCenter()
Definition: DirOfGamma.cxx:204
void ComputeMaxCharge()
Definition: DirOfGamma.cxx:298
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:263
ems::DirOfGamma::~DirOfGamma ( )
inline

Definition at line 187 of file DirOfGamma.h.

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

Member Function Documentation

void ems::DirOfGamma::ComputeBaryCenter ( )
private

Definition at line 204 of file DirOfGamma.cxx.

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

Definition at line 298 of file DirOfGamma.cxx.

299 {
300  fNormCharge = 0.0;
301  for (unsigned int i = 0; i < fCandidates.size(); i++) {
302  if (fCandidates[i].GetMaxCharge() > fNormCharge) {
303  fNormCharge = fCandidates[i].GetMaxCharge();
304  }
305  }
306 }
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:265
void ems::DirOfGamma::ComputeMaxDist ( )
private

Definition at line 249 of file DirOfGamma.cxx.

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

Definition at line 221 of file DirOfGamma.cxx.

222 {
223  TVector2 vstart(0, 1);
224 
225  for (unsigned int i = 0; i < fPoints2D.size(); i++) {
226  TVector2 pos(fPoints2D[i]->GetPointCm().X(), fPoints2D[i]->GetPointCm().Y());
227  TVector2 vecp = pos - fBaryCenter;
228  float sinsign = (vstart.X() * vecp.Y()) - (vstart.Y() * vecp.X());
229  float cosine = (vstart * vecp) / (vstart.Mod() * vecp.Mod());
230  float theta = 180.0F * (std::acos(cosine)) / TMath::Pi();
231 
232  unsigned int id = 0;
233  double bin = double(360.0) / double(fNbins);
234 
235  if (sinsign >= 0)
236  id = int(theta / bin);
237  else if (sinsign < 0)
238  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++)
245  fBins[id].Sort();
246 }
TVector2 fBaryCenter
Definition: DirOfGamma.h:282
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:264
QTextStream & bin(QTextStream &s)
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:263
bool ems::DirOfGamma::FindCandidates ( )
private

Definition at line 268 of file DirOfGamma.cxx.

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

Definition at line 309 of file DirOfGamma.cxx.

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

Definition at line 194 of file DirOfGamma.h.

195  {
196  return fBaryCenter;
197  }
TVector2 fBaryCenter
Definition: DirOfGamma.h:282
std::vector<EndPoint> const& ems::DirOfGamma::GetCandidates ( ) const
inline

Definition at line 206 of file DirOfGamma.h.

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

Definition at line 229 of file DirOfGamma.h.

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

Definition at line 241 of file DirOfGamma.h.

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

Definition at line 235 of file DirOfGamma.h.

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

Definition at line 200 of file DirOfGamma.h.

201  {
202  return fPoints2D;
203  }
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:263
const size_t ems::DirOfGamma::GetIdCandidate ( )
inline

Definition at line 223 of file DirOfGamma.h.

224  {
225  return fCandidateID;
226  }
size_t fCandidateID
Definition: DirOfGamma.h:261
size_t const ems::DirOfGamma::GetIdCl ( ) const
inline

Definition at line 253 of file DirOfGamma.h.

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

Definition at line 247 of file DirOfGamma.h.

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

Definition at line 212 of file DirOfGamma.h.

213  {
214 
215  fIsCandidateIDset = true;
216  fCandidateID = id;
217  fStartHit = fCandidates[id].GetHit();
218  fStartPoint = fCandidates[id].GetPosition();
219  fIniHits = fCandidates[id].MaxChargeBin().GetIniHits();
220  }
size_t fCandidateID
Definition: DirOfGamma.h:261
bool fIsCandidateIDset
Definition: DirOfGamma.h:287
TVector2 fStartPoint
Definition: DirOfGamma.h:268
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:265
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:267
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:269

Member Data Documentation

TVector2 ems::DirOfGamma::fBaryCenter
private

Definition at line 282 of file DirOfGamma.h.

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

Definition at line 264 of file DirOfGamma.h.

size_t ems::DirOfGamma::fCandidateID
private

Definition at line 261 of file DirOfGamma.h.

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

Definition at line 265 of file DirOfGamma.h.

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

Definition at line 270 of file DirOfGamma.h.

size_t ems::DirOfGamma::fIdCl
private

Definition at line 260 of file DirOfGamma.h.

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

Definition at line 269 of file DirOfGamma.h.

bool ems::DirOfGamma::fIsCandidateIDset
private

Definition at line 287 of file DirOfGamma.h.

size_t ems::DirOfGamma::fNbins
private

Definition at line 259 of file DirOfGamma.h.

float ems::DirOfGamma::fNormCharge
private

Definition at line 285 of file DirOfGamma.h.

float ems::DirOfGamma::fNormDist
private

Definition at line 284 of file DirOfGamma.h.

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

Definition at line 263 of file DirOfGamma.h.

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

Definition at line 267 of file DirOfGamma.h.

TVector2 ems::DirOfGamma::fStartPoint
private

Definition at line 268 of file DirOfGamma.h.


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