TCTrack.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 /// \brief A TCHit contains pchits and information related to performing a timing calibration
3 /// \author edniner@indiana.edu
4 /// \date Feb. 2013
5 ///////////////////////////////////////////////////////////////////////////
6 #ifndef TCTrack_H
7 #define TCTrack_H
8 
10 #include "NovaDAQConventions/DAQConventions.h"
11 
13 
14 #include "TVector3.h"
15 
16 /// Calibration data products
17 namespace caldp
18 {
19  class PCHit;
20  /// "Timing Calibration Track". Collection of PCHits
21  /// useful in performing a timing calibration."
22  class TCTrack
23  {
24  public:
25  TCTrack();
26 
27  virtual ~TCTrack();
28 
29  /// add a pchit to the track
30  virtual void Add(const art::Ptr<caldp::PCHit>& pchit);
31  /// add a collection of pchits to the track
32  virtual void Add(const std::vector<art::Ptr<caldp::PCHit> >& pchits);
33 
34  /// return the number of hits in a view
35  unsigned int NPCHit(geo::View_t view) const;
36  /// return number of hits in x view
37  unsigned int NXPCHit() const {return fXPCHits.size();}
38  /// return number of hits in y view
39  unsigned int NYPCHit() const {return fYPCHits.size();}
40  /// return total number of hits
41  unsigned int NPCHit() const {return fXPCHits.size() + fYPCHits.size();}
42 
43  /// get the ith pchit from a specified view
44  art::Ptr<caldp::PCHit> PCHit(geo::View_t view, unsigned int viewIdx) const;
45  /// get the ith x view pchit
46  art::Ptr<caldp::PCHit> XPCHit(unsigned int xIdx) const;
47  /// get the ith y view pchit
48  art::Ptr<caldp::PCHit> YPCHit(unsigned int yIdx) const;
49  /// get the ith pchit from either view
50  art::Ptr<caldp::PCHit> PCHit(unsigned int globalIdx) const;
51  /// return the collection of all x view pchits
52  const std::vector<art::Ptr<caldp::PCHit> >& XPCHits() const {return fXPCHits;}
53  /// return the collection of all y view pchits
54  const std::vector<art::Ptr<caldp::PCHit> >& YPCHits() const {return fYPCHits;}
55  /// return the collection of all pchits
56  std::vector<art::Ptr<caldp::PCHit> > AllPCHits() const;
57  /// return the collection of pchits dropped by fiber fit
58  std::vector<art::Ptr<caldp::PCHit> > AllDropPCHits() const {return fDropPCHits;}
59 
60  /// remove a pchit from the current cluster
61  void RemovePCHit(const art::Ptr<caldp::PCHit> pch);
62  /// remove the ith pchit from the cluster
63  void RemovePCHit(unsigned int globalIdx);
64 
65  /// return max plane number in the specified view
66  int MaxPlane(geo::View_t view) const;
67  /// return min plane number in the specified view
68  int MinPlane(geo::View_t view) const;
69  /// return min cell number in the specified view
70  int MinCell(geo::View_t view) const;
71  /// return max cell number in the specified view
72  int MaxCell(geo::View_t view) const;
73 
74  /// return min pchit time for a specified view
75  double MinTNS(geo::View_t view=geo::kXorY) const;
76  /// return max pchit time for a specified view
77  double MaxTNS(geo::View_t view=geo::kXorY) const;
78  /// return shortest path from start of track to a hit in a view
79  double MinPath(geo::View_t view=geo::kXorY) const;
80  /// return longest path from start of track to a hit in a view
81  double MaxPath(geo::View_t view=geo::kXorY) const;
82 
83  /// return the start coordinate for the track
84  TVector3 Start() const {return fStart;}
85  /// return the stop coordinate for the track
86  TVector3 Stop() const {return fStop;}
87 
88  /// return total path lenght for track
89  double TotalLength() const {return fTotalLength;}
90 
91  /// set track start point
92  virtual void SetStart(TVector3 start) {fStart = start;}
93  /// set track stop point
94  virtual void SetStop(TVector3 stop) {fStop = stop;}
95  /// set track total length
96  virtual void SetTotalLength(double length) {fTotalLength = length;}
97 
98  /// return the velocity of the optical fiber, measured for this track
99  double FiberVelocity() const {return fFiberVelocity;}
100 
101  /// Calculate the uncertainty in the time based on pulse height
102  double TNSUncertainty(float pe, bool goodTime, novadaq::cnv::DetId detectorID) const;
103 
104  /// Correct for timewalk effect as a function of distance to readout
105  double ReadoutDistCorrection(float x, novadaq::cnv::DetId detectorID) const;
106 
107  /// Calculate fiber speed as a function of distance from readout
108  double CalcFiberVelocity(float d, novadaq::cnv::DetId detectorID) const;
109 
110  /// Recalculate fiber velocity for current track.
111  /// A linear fit is performed plotting TNS - TOV vs ReadoutDist.
112  /// Where TNS is the hit time and TOF is the time of flight from
113  /// the start of the track to the hit, assuming a speed of c.
114  /// The ReadoutDist is the distance from the hit location to the APD,
115  /// including the pigtail length.
116  /// The maximum residual allowed in the fit is a required parameter
117  /// There is the option to remove hits from the track that fall outside
118  /// this residual. If hits are removed, muon speed will then be recalculated,
119  /// and the currently stored fFiberVelocity overwritten
120  double CalculateFiberVelocity(double timeResid,
121  std::vector<double> *resids,
122  double *icept,
123  double *chisqr,
124  novadaq::cnv::DetId detectorID,
125  bool removeHits = false,
126  bool overwrite = false);
127 
128  /// Calculate muon velocity for the current track
129  /// A linear fit is performed of TNS - readoutCorrection vs pathlenght.
130  /// Where TNS is the time for an individual hit, readoutCorrection is
131  /// the time for photons from that hit to travel to the APD. If no fiberspeed
132  /// is specified then the speed currently stored in the track is used. The
133  /// pathlength is the length from the start of track to the hit.
134  /// The resulting fit for 1/v is multiplied by c so the value returned
135  /// has the form 1/Beta.
136  double CalculateMuonVelocity(std::vector<double> *resids,
137  double *icept,
138  double *chisqr,
139  novadaq::cnv::DetId detectorID,
140  double fiberVel = 9999.0) const;
141 
142  /// Set the fiber speed for the track.
143  virtual void SetFiberVelocity(double vel) {fFiberVelocity = vel;}
144 
145 
146 
147  protected:
148  /// contain collections of pchits
149  std::vector<art::Ptr<caldp::PCHit> > fXPCHits;
150  std::vector<art::Ptr<caldp::PCHit> > fYPCHits;
151 
152  /// contains collection of pchits dropped by fiber fit
153  std::vector<art::Ptr<caldp::PCHit> > fDropPCHits;
154 
155  /// start and endpoint for track
156  TVector3 fStart;
157  TVector3 fStop;
158 
159  /// Total pathlength of track
160  double fTotalLength;
161 
162  /// optical fiber velocity for track
164 
165  };
166 
167 } // end namespace
168 
169 #endif // TCTrack_H
double MinTNS(geo::View_t view=geo::kXorY) const
return min pchit time for a specified view
Definition: TCTrack.cxx:160
int MaxCell(geo::View_t view) const
return max cell number in the specified view
Definition: TCTrack.cxx:150
double CalculateFiberVelocity(double timeResid, std::vector< double > *resids, double *icept, double *chisqr, novadaq::cnv::DetId detectorID, bool removeHits=false, bool overwrite=false)
Definition: TCTrack.cxx:292
unsigned int NPCHit() const
return total number of hits
Definition: TCTrack.h:41
virtual void SetStop(TVector3 stop)
set track stop point
Definition: TCTrack.h:94
X or Y views.
Definition: PlaneGeo.h:30
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
art::Ptr< caldp::PCHit > YPCHit(unsigned int yIdx) const
get the ith y view pchit
Definition: TCTrack.cxx:72
TVector3 Stop() const
return the stop coordinate for the track
Definition: TCTrack.h:86
virtual void SetStart(TVector3 start)
set track start point
Definition: TCTrack.h:92
double TotalLength() const
return total path lenght for track
Definition: TCTrack.h:89
double MaxTNS(geo::View_t view=geo::kXorY) const
return max pchit time for a specified view
Definition: TCTrack.cxx:170
double FiberVelocity() const
return the velocity of the optical fiber, measured for this track
Definition: TCTrack.h:99
int MaxPlane(geo::View_t view) const
return max plane number in the specified view
Definition: TCTrack.cxx:140
TVector3 Start() const
return the start coordinate for the track
Definition: TCTrack.h:84
virtual void SetFiberVelocity(double vel)
Set the fiber speed for the track.
Definition: TCTrack.h:143
TVector3 fStop
Definition: TCTrack.h:157
length
Definition: demo0.py:21
virtual void Add(const art::Ptr< caldp::PCHit > &pchit)
add a pchit to the track
Definition: TCTrack.cxx:25
std::vector< art::Ptr< caldp::PCHit > > fDropPCHits
contains collection of pchits dropped by fiber fit
Definition: TCTrack.h:153
const std::vector< art::Ptr< caldp::PCHit > > & XPCHits() const
return the collection of all x view pchits
Definition: TCTrack.h:52
virtual void SetTotalLength(double length)
set track total length
Definition: TCTrack.h:96
void RemovePCHit(const art::Ptr< caldp::PCHit > pch)
remove a pchit from the current cluster
Definition: TCTrack.cxx:95
virtual ~TCTrack()
Definition: TCTrack.cxx:22
double MinPath(geo::View_t view=geo::kXorY) const
return shortest path from start of track to a hit in a view
Definition: TCTrack.cxx:180
int MinCell(geo::View_t view) const
return min cell number in the specified view
Definition: TCTrack.cxx:130
Float_t d
Definition: plot.C:236
double MaxPath(geo::View_t view=geo::kXorY) const
return longest path from start of track to a hit in a view
Definition: TCTrack.cxx:190
double fTotalLength
Total pathlength of track.
Definition: TCTrack.h:160
unsigned int NXPCHit() const
return number of hits in x view
Definition: TCTrack.h:37
std::vector< art::Ptr< caldp::PCHit > > AllDropPCHits() const
return the collection of pchits dropped by fiber fit
Definition: TCTrack.h:58
Histograms used by attenuation calibration.
art::Ptr< caldp::PCHit > PCHit(geo::View_t view, unsigned int viewIdx) const
get the ith pchit from a specified view
Definition: TCTrack.cxx:54
art::Ptr< caldp::PCHit > XPCHit(unsigned int xIdx) const
get the ith x view pchit
Definition: TCTrack.cxx:65
const std::vector< art::Ptr< caldp::PCHit > > & YPCHits() const
return the collection of all y view pchits
Definition: TCTrack.h:54
double CalcFiberVelocity(float d, novadaq::cnv::DetId detectorID) const
Calculate fiber speed as a function of distance from readout.
Definition: TCTrack.cxx:272
double ReadoutDistCorrection(float x, novadaq::cnv::DetId detectorID) const
Correct for timewalk effect as a function of distance to readout.
Definition: TCTrack.cxx:233
std::vector< art::Ptr< caldp::PCHit > > fYPCHits
Definition: TCTrack.h:150
double fFiberVelocity
optical fiber velocity for track
Definition: TCTrack.h:163
double CalculateMuonVelocity(std::vector< double > *resids, double *icept, double *chisqr, novadaq::cnv::DetId detectorID, double fiberVel=9999.0) const
Definition: TCTrack.cxx:371
std::vector< art::Ptr< caldp::PCHit > > AllPCHits() const
return the collection of all pchits
Definition: TCTrack.cxx:86
TVector3 fStart
start and endpoint for track
Definition: TCTrack.h:156
Definition: fwd.h:28
int MinPlane(geo::View_t view) const
return min plane number in the specified view
Definition: TCTrack.cxx:120
unsigned int NYPCHit() const
return number of hits in y view
Definition: TCTrack.h:39
std::vector< art::Ptr< caldp::PCHit > > fXPCHits
contain collections of pchits
Definition: TCTrack.h:149
double TNSUncertainty(float pe, bool goodTime, novadaq::cnv::DetId detectorID) const
Calculate the uncertainty in the time based on pulse height.
Definition: TCTrack.cxx:200