All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 183 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:272
process_name hit
Definition: cheaterreco.fcl:51
bool FindCandidates()
Definition: DirOfGamma.cxx:268
TVector2 fBaryCenter
Definition: DirOfGamma.h:284
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:266
void ComputeMaxDist()
Definition: DirOfGamma.cxx:249
size_t fCandidateID
Definition: DirOfGamma.h:263
bool fIsCandidateIDset
Definition: DirOfGamma.h:289
void ComputeBaryCenter()
Definition: DirOfGamma.cxx:204
void ComputeMaxCharge()
Definition: DirOfGamma.cxx:298
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:265
ems::DirOfGamma::~DirOfGamma ( )
inline

Definition at line 189 of file DirOfGamma.h.

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

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:284
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:265
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:267
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)
TVector2 fBaryCenter
Definition: DirOfGamma.h:284
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:266
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 }
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
TVector2 fBaryCenter
Definition: DirOfGamma.h:284
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:266
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:265
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 }
double Dist2(const TVector2 &v1, const TVector2 &v2)
TVector2 fBaryCenter
Definition: DirOfGamma.h:284
std::vector< Bin2D > fBins
Definition: DirOfGamma.h:266
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:267
std::vector< Hit2D * > fPoints2D
Definition: DirOfGamma.h:265
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)
TVector2 fBaryCenter
Definition: DirOfGamma.h:284
size_t fCandidateID
Definition: DirOfGamma.h:263
TVector2 fStartPoint
Definition: DirOfGamma.h:270
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:267
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:269
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:271
TVector2 const& ems::DirOfGamma::GetBaryCenterCm ( ) const
inline

Definition at line 196 of file DirOfGamma.h.

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

Definition at line 208 of file DirOfGamma.h.

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

Definition at line 231 of file DirOfGamma.h.

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

Definition at line 243 of file DirOfGamma.h.

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

Definition at line 237 of file DirOfGamma.h.

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

Definition at line 202 of file DirOfGamma.h.

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

Definition at line 225 of file DirOfGamma.h.

226  {
227  return fCandidateID;
228  }
size_t fCandidateID
Definition: DirOfGamma.h:263
size_t const ems::DirOfGamma::GetIdCl ( ) const
inline

Definition at line 255 of file DirOfGamma.h.

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

Definition at line 249 of file DirOfGamma.h.

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

Definition at line 214 of file DirOfGamma.h.

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  }
size_t fCandidateID
Definition: DirOfGamma.h:263
bool fIsCandidateIDset
Definition: DirOfGamma.h:289
TVector2 fStartPoint
Definition: DirOfGamma.h:270
std::vector< EndPoint > fCandidates
Definition: DirOfGamma.h:267
art::Ptr< recob::Hit > fStartHit
Definition: DirOfGamma.h:269
std::vector< art::Ptr< recob::Hit > > fIniHits
Definition: DirOfGamma.h:271

Member Data Documentation

TVector2 ems::DirOfGamma::fBaryCenter
private

Definition at line 284 of file DirOfGamma.h.

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

Definition at line 266 of file DirOfGamma.h.

size_t ems::DirOfGamma::fCandidateID
private

Definition at line 263 of file DirOfGamma.h.

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

Definition at line 267 of file DirOfGamma.h.

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

Definition at line 272 of file DirOfGamma.h.

size_t ems::DirOfGamma::fIdCl
private

Definition at line 262 of file DirOfGamma.h.

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

Definition at line 271 of file DirOfGamma.h.

bool ems::DirOfGamma::fIsCandidateIDset
private

Definition at line 289 of file DirOfGamma.h.

size_t ems::DirOfGamma::fNbins
private

Definition at line 261 of file DirOfGamma.h.

float ems::DirOfGamma::fNormCharge
private

Definition at line 287 of file DirOfGamma.h.

float ems::DirOfGamma::fNormDist
private

Definition at line 286 of file DirOfGamma.h.

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

Definition at line 265 of file DirOfGamma.h.

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

Definition at line 269 of file DirOfGamma.h.

TVector2 ems::DirOfGamma::fStartPoint
private

Definition at line 270 of file DirOfGamma.h.


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