ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtPattern.cxx
Go to the documentation of this file.
1 #include "AtPattern.h"
2 
3 #include "AtContainerManip.h"
4 #include "AtHit.h" // for AtHit
5 
6 #include <Math/Point3D.h> // for PositionVector3D
7 #include <TEveLine.h>
8 using namespace AtPatterns;
9 
11 
12 AtPattern::AtPattern(Int_t numPoints) : fNumPoints(numPoints) {}
13 
24 Double_t AtPattern::FitPattern(const std::vector<AtHit> &pointsToFit, Double_t qThreshold)
25 {
26  FitPattern(ContainerManip::GetConstPointerVector(pointsToFit), qThreshold);
27  return fChi2;
28 }
29 
30 Double_t AtPattern::FitPattern(const std::vector<const AtHit *> &pointsToFit, Double_t qThreshold)
31 {
32  std::vector<XYZPoint> points;
33  std::vector<double> charge;
34  for (auto hit : pointsToFit) {
35  if (hit->GetCharge() > qThreshold) {
36  points.push_back(hit->GetPosition());
37  charge.push_back(hit->GetCharge());
38  }
39  }
40 
41  if (qThreshold == -1)
42  FitPattern(points);
43  else
44  FitPattern(points, charge);
45  return fChi2;
46 }
56 Double_t AtPattern::FitPattern(const std::vector<XYZPoint> &pointsToFit)
57 {
58  std::vector<double> charge;
59  FitPattern(pointsToFit, charge);
60  return fChi2;
61 }
62 
63 TEveLine *AtPattern::GetEveLine(double tMin, double tMax, int n) const
64 {
65  // Setup return vector with the correct number of
66  auto retLine = new TEveLine(); // NOLINT these will be owned by TEve classes
67  for (int i = 0; i < n; ++i) {
68  auto t = tMin + i * (tMax - tMin) / n;
69  auto pos = GetPointAt(t) / 10.; // TEve is all in units cm
70  retLine->SetNextPoint(pos.X(), pos.Y(), pos.Z());
71  }
72  return retLine;
73 }
AtPattern.h
ClassImp
ClassImp(AtPattern)
AtPatterns::AtPattern::GetPointAt
virtual XYZPoint GetPointAt(double t) const =0
Point on pattern at t.
ContainerManip::GetConstPointerVector
std::vector< const T * > GetConstPointerVector(const std::vector< T > &vec)
Definition: AtContainerManip.h:85
AtPatterns::AtPattern
Describes a shape in 3D space.
Definition: AtPattern.h:40
AtPatterns::AtPattern::AtPattern
AtPattern(Int_t numPoints=0)
Definition: AtPattern.cxx:12
AtHit.h
AtPatterns::AtPattern::GetEveLine
TEveLine * GetEveLine(double tMin, double tMax, int n) const
Get visual representation of pattern.
Definition: AtPattern.cxx:63
AtPatterns::AtPattern::fChi2
Double_t fChi2
Definition: AtPattern.h:46
AtContainerManip.h
AtPatterns
Definition: AtFissionEvent.h:21
AtPatterns::AtPattern::FitPattern
Double_t FitPattern(const std::vector< AtHit > &pointsToFit, Double_t qThreshold=-1)
Fit the pattern.
Definition: AtPattern.cxx:24