Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaVDCCluster.h
Go to the documentation of this file.
1#ifndef Podd_THaVDCCluster_h_
2#define Podd_THaVDCCluster_h_
3
5// //
6// THaVDCCluster //
7// //
9
10#include "TObject.h"
11#include "DataType.h"
12#include <utility>
13#include <vector>
14
15class THaVDCHit;
16class THaVDCPlane;
17class THaVDCPointPair;
18class THaTrack;
19
20namespace VDC {
21 class FitCoord_t {
22 public:
23 FitCoord_t( Double_t _x, Double_t _y, Double_t _w = 1.0, Int_t _s = 1 )
24 : x(_x), y(_y), w(_w), s(_s) {}
27 };
28 typedef std::pair<Double_t,Int_t> chi2_t;
30 typedef std::vector<THaVDCHit*> Vhit_t;
31 typedef std::vector<FitCoord_t> Vcoord_t;
32
33 inline chi2_t operator+( chi2_t a, const chi2_t& b ) {
34 a.first += b.first;
35 a.second += b.second;
36 return a;
37 }
38}
39
40class THaVDCCluster : public TObject {
41
42public:
43
44 explicit THaVDCCluster( THaVDCPlane* owner = nullptr );
45 virtual ~THaVDCCluster() = default;
46
48
49 virtual void AddHit( THaVDCHit* hit );
50 virtual void EstTrackParameters();
51 virtual void ConvertTimeToDist();
52 virtual void FitTrack( EMode mode = kSimple );
53 virtual void ClearFit();
54 virtual void CalcChisquare(Double_t& chi2, Int_t& nhits) const;
55 VDC::chi2_t CalcDist(); // calculate global track to wire distances
56
57 // TObject functions redefined
58 virtual void Clear( Option_t* opt="" );
59 virtual Int_t Compare( const TObject* obj ) const;
60 virtual Bool_t IsSortable() const { return true; }
61 virtual void Print( Option_t* opt="" ) const;
62
63 //Get and Set Functions
64 THaVDCHit* GetHit(Int_t i) const { return fHits[i]; }
65 THaVDCPlane* GetPlane() const { return fPlane; }
66 Int_t GetSize () const { return static_cast<Int_t>(fHits.size()); }
67 Double_t GetSlope() const { return fSlope; }
70 Double_t GetIntercept() const { return fInt; }
72 THaVDCHit* GetPivot() const { return fPivot; }
73 Int_t GetPivotWireNum() const;
75 Double_t GetT0() const { return fT0; }
77 THaTrack* GetTrack() const { return fTrack; }
78 Int_t GetTrackIndex() const;
79 Int_t GetTrkNum() const { return fTrkNum; }
80 Double_t GetSigmaT0() const { return fSigmaT0; }
81 Double_t GetChi2() const { return fChi2; }
82 Double_t GetNDoF() const { return fNDoF; }
83 Bool_t IsFitOK() const { return fFitOK; }
84 Bool_t IsUsed() const { return (fTrack != nullptr); }
85
86 void SetPlane( THaVDCPlane* plane ) { fPlane = plane; }
87 void SetIntercept( Double_t intercept ) { fInt = intercept; }
88 void SetSlope( Double_t slope) { fSlope = slope;}
89 void SetPivot( THaVDCHit* piv) { fPivot = piv; }
91 void SetPointPair( VDC::VDCpp_t* pp ) { fPointPair = pp; }
92 void SetTrack( THaTrack* track );
93
94protected:
95 VDC::Vhit_t fHits; // Hits associated w/this cluster
96 THaVDCPlane* fPlane; // Plane the cluster belongs to
97 VDC::VDCpp_t* fPointPair; // Lower/upper combo we're assigned to
98 THaTrack* fTrack; // Track the cluster belongs to
99 Int_t fTrkNum; // Number of the track using this cluster
100
101 //Track Parameters
102 Double_t fSlope; // Current best estimate of actual slope
103 Double_t fLocalSlope; // Fitted slope, from FitTrack()
104 Double_t fSigmaSlope; // Error estimate of fLocalSlope from fit
105 Double_t fInt, fSigmaInt; // Intercept and error estimate
106 Double_t fT0, fSigmaT0; // Fitted common timing offset and error
107 THaVDCHit* fPivot; // Pivot - hit with smallest drift time
108 //FIXME: in the code, this is used as a distance correction!!
109 Double_t fTimeCorrection; // correction to be applied when fitting
110 // drift times
111 Bool_t fFitOK; // Flag indicating that fit results valid
112 Double_t fChi2; // chi2 for the cluster (using fSlope)
113 Double_t fNDoF; // NDoF in local chi2 calculation
114 Int_t fClsBeg; // Starting wire number
115 Int_t fClsEnd; // Ending wire number
116
117 // Workspace for fitting routines
118 VDC::Vcoord_t fCoord; // coordinates to be fit
119
120 void CalcLocalDist(); // calculate the local track to wire distances
121
122 void FitSimpleTrack( Bool_t weighted = false );
123 //void FitNLTrack(); // Non-linear 3-parameter fit
124
125 VDC::chi2_t CalcChisquare( Double_t slope, Double_t icpt, Double_t d0 ) const;
126 void DoCalcChisquare( Double_t& chi2, Int_t& nhits,
127 Double_t slope, bool do_print = false ) const;
128 void Linear3DFit( Double_t& slope, Double_t& icpt, Double_t& d0 ) const;
130
131 ClassDef(THaVDCCluster,0) // A group of VDC hits
132};
133
135
136#endif
int Int_t
bool Bool_t
double Double_t
const char Option_t
#define ClassDef(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Int_t GetTrackIndex() const
void SetPointPair(VDC::VDCpp_t *pp)
virtual void Clear(Option_t *opt="")
THaVDCPlane * fPlane
Double_t fTimeCorrection
void SetSlope(Double_t slope)
THaVDCHit * fPivot
THaVDCHit * GetPivot() const
virtual void EstTrackParameters()
virtual Bool_t IsSortable() const
Double_t GetIntercept() const
Double_t GetSigmaSlope() const
VDC::VDCpp_t * fPointPair
Double_t fLocalSlope
THaTrack * fTrack
virtual void Print(Option_t *opt="") const
VDC::VDCpp_t * GetPointPair() const
void SetPivot(THaVDCHit *piv)
THaTrack * GetTrack() const
void SetPlane(THaVDCPlane *plane)
Double_t GetLocalSlope() const
Double_t fSigmaSlope
void SetTimeCorrection(Double_t dt)
virtual void ClearFit()
void SetIntercept(Double_t intercept)
void SetTrack(THaTrack *track)
Double_t GetChi2() const
Double_t GetSlope() const
Int_t GetTrkNum() const
Double_t GetTimeCorrection() const
Double_t GetSigmaT0() const
void FitSimpleTrack(Bool_t weighted=false)
VDC::Vhit_t fHits
virtual void ConvertTimeToDist()
VDC::Vcoord_t fCoord
THaVDCPlane * GetPlane() const
Int_t GetSize() const
Double_t GetNDoF() const
virtual void AddHit(THaVDCHit *hit)
Bool_t IsFitOK() const
virtual Int_t Compare(const TObject *obj) const
Double_t GetT0() const
virtual void FitTrack(EMode mode=kSimple)
Double_t fSigmaT0
virtual ~THaVDCCluster()=default
VDC::chi2_t CalcDist()
virtual void CalcChisquare(Double_t &chi2, Int_t &nhits) const
Double_t fSigmaInt
void Linear3DFit(Double_t &slope, Double_t &icpt, Double_t &d0) const
Int_t GetPivotWireNum() const
Int_t LinearClusterFitWithT0()
Bool_t IsUsed() const
THaVDCHit * GetHit(Int_t i) const
void DoCalcChisquare(Double_t &chi2, Int_t &nhits, Double_t slope, bool do_print=false) const
Double_t GetSigmaIntercept() const
FitCoord_t(Double_t _x, Double_t _y, Double_t _w=1.0, Int_t _s=1)
std::vector< FitCoord_t > Vcoord_t
THaVDCPointPair VDCpp_t
chi2_t operator+(chi2_t a, const chi2_t &b)
std::pair< Double_t, Int_t > chi2_t
std::vector< THaVDCHit * > Vhit_t
TArc a