TPCCluster.cxx
Go to the documentation of this file.
1 //
2 // TPCCluster.cxx
3 //
4 // Created by Brian Rebel on 10/6/16.
5 //
7 
9 #include "TMath.h"
10 
11 namespace gar {
12  namespace rec {
13 
14  //--------------------------------------------------------------------------
16  {
19  return;
20  }
21 
22 
23 
24  bool TPCCluster::operator==(const TPCCluster& rhs) const {
25  return (this->fIDnumero == rhs.fIDnumero);
26  }
27 
28  bool TPCCluster::operator!=(const TPCCluster& rhs) const {
29  return (this->fIDnumero != rhs.fIDnumero);
30  }
31 
33 
34 
35 
36  //--------------------------------------------------------------------------
37  TPCCluster::TPCCluster( const float sig,
38  const float *pos,
39  const float startT,
40  const float endT,
41  const float Time,
42  const float RMS,
43  const float *cov)
44  : fSignal (sig )
45  , fTime (Time )
46  , fStartTime(startT)
47  , fEndTime (endT )
48  , fRMS (RMS )
49  {
52 
53  fPosition[0] = pos[0];
54  fPosition[1] = pos[1];
55  fPosition[2] = pos[2];
56  for (size_t i=0; i<6; ++i)
57  {
58  fCovMat[i] = cov[i];
59  }
60 
61  return;
62  }
63 
64  //--------------------------------------------------------------------------
65  // Users should be careful with this method. It will just add TPCClusters
66  // without checking if the TPCClusters are overlapping in time or close
67  // to each other in time
69  {
70 
71  // add h to this TPCCluster. Set the new position, etc to be the weighted
72  // average of the individual TPCClusters
73  float totSig = fSignal + h.Signal();
74 
75  if(totSig == 0.){
76  MF_LOG_WARNING("TPCCluster")
77  << "attempting to add two TPCClusters and neithr has any signal, bail.";
78  return;
79  }
80 
81  for(size_t i = 0; i < 3; ++i)
82  fPosition[i] = (fPosition[i] * fSignal + h.Position()[i] * h.Signal()) / totSig;
83 
84  // don't do a weighted average but just make a wider TPCCluster
85 
86  //fStartTime = (fStartTime * fSignal + h.StartTime() * h.Signal()) / totSig;
87  //fEndTime = (fEndTime * fSignal + h.EndTime() * h.Signal()) / totSig;
88 
89  fStartTime = TMath::Min(fStartTime,h.StartTime());
90  fEndTime = TMath::Max(fEndTime,h.EndTime());
91 
92  float avgtime = (fTime * fSignal + h.Time() * h.Signal()) / totSig;
93 
94  fRMS = TMath::Sqrt( (fSignal*(TMath::Sq(fTime-avgtime)+TMath::Sq(fRMS))
95  + h.Signal()*(TMath::Sq(h.Time()-avgtime)+TMath::Sq(h.RMS())))/totSig );
96 
97  fTime = avgtime;
98 
99  fSignal += h.Signal();
100 
101  return;
102  }
103 
104 
105  //--------------------------------------------------------------------------
106  std::ostream& operator<< (std::ostream& o, gar::rec::TPCCluster const& h)
107  {
108  const float* cov;
109  cov = h.CovMatPacked();
110  o << "TPCCluster "
111  << "\n\tID number = "
112  << h.getIDNumber()
113  << "\n\tposition = ("
114  << h.Position()[0]
115  << ", "
116  << h.Position()[1]
117  << ", "
118  << h.Position()[2]
119  << ")"
120  << "\n\tcovariance matrix = \n\t"
121  << cov[0] << "\t" << cov[1] << "\t" << cov[2] << "\n"
122  << "\t\t" << cov[3] << "\t" << cov[4] << "\n"
123  << "\t\t\t" << cov[5]
124  << "\n\tsignal = "
125  << h.Signal()
126  << "\n\tdrift direction rms = "
127  << h.RMS()
128  << "\n\tstart time: "
129  << h.StartTime()
130  << "\n\tend time: "
131  << h.EndTime();
132 
133  return o;
134  }
135 
136  } // rec
137 } // gar
rec
Definition: tracks.py:88
float fSignal
size of the signal for this TPCCluster (integral of ADC values)
Definition: TPCCluster.h:27
friend std::ostream & operator<<(std::ostream &o, gar::rec::TPCCluster const &h)
Definition: TPCCluster.cxx:106
float EndTime() const
Definition: TPCCluster.h:71
float fStartTime
start time of the TPCCluster (ticks)
Definition: TPCCluster.h:30
float fRMS
TPCCluster width calculated with RMS (in ticks)
Definition: TPCCluster.h:32
float fCovMat[6]
packed covariance matrix, assuming symmetry. xx, xy, xz, yy, yz, zz
Definition: TPCCluster.h:33
gar::rec::IDNumber getIDNumber() const
Definition: TPCCluster.cxx:32
bool operator!=(const TPCCluster &rhs) const
Definition: TPCCluster.cxx:28
float fEndTime
end time of the TPCCluster (ticks)
Definition: TPCCluster.h:31
static IDNumberGen * create(IDNumber iniValue=std::numeric_limits< IDNumber >::max())
Definition: IDNumberGen.cxx:18
float fTime
time of TPCCluster charge arrival at the readout plane (ticks)
Definition: TPCCluster.h:29
gar::rec::IDNumber fIDnumero
Definition: TPCCluster.h:25
float StartTime() const
Definition: TPCCluster.h:70
float fPosition[3]
position of the TPCCluster
Definition: TPCCluster.h:28
static gar::rec::IDNumber const FirstNumber
Definition: TPCCluster.h:24
float RMS() const
Definition: TPCCluster.h:72
bool operator==(const TPCCluster &rhs) const
Definition: TPCCluster.cxx:24
void operator+=(gar::rec::TPCCluster const &h)
Definition: TPCCluster.cxx:68
General GArSoft Utilities.
float const & Signal() const
Definition: TPCCluster.h:69
const float * CovMatPacked() const
Definition: TPCCluster.h:74
const float * Position() const
Definition: TPCCluster.h:68
#define MF_LOG_WARNING(category)
float Time() const
Definition: TPCCluster.h:73
size_t IDNumber
Definition: IDNumberGen.h:71