Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaVDC.h
Go to the documentation of this file.
1#ifndef Podd_HALLA_VDC_h_
2#define Podd_HALLA_VDC_h_
3
5// //
6// THaVDC //
7// //
9
10#include "THaTrackingDetector.h"
12#include <cassert>
13#include <utility>
14#include <string>
15#include <vector>
16
17class THaVDCChamber;
18class THaTrack;
19class TClonesArray;
20class THaVDCPoint;
21namespace Podd {
22 class TimeCorrectionModule;
23}
24
26
27friend class THaVDCPlane;
28
29public:
30 explicit THaVDC( const char* name, const char* description = "",
31 THaApparatus* a = nullptr );
32
33 virtual ~THaVDC();
34
35 virtual void Clear( Option_t* opt="" );
36 virtual Int_t Decode( const THaEvData& );
37 virtual Int_t CoarseTrack( TClonesArray& tracks );
38 virtual Int_t FineTrack( TClonesArray& tracks );
39 virtual Int_t FindVertices( TClonesArray& tracks );
40 virtual EStatus Init( const TDatime& date );
41 virtual void SetDebug( Int_t level );
42
43 // Get and Set Functions
44 THaVDCChamber* GetUpper() const { return fUpper; }
45 THaVDCChamber* GetLower() const { return fLower; }
46
47 Double_t GetVDCAngle() const { return fVDCAngle; }
48 Double_t GetSpacing() const { return fSpacing; }
49
50 std::pair<Double_t,bool> GetTimeCorrection() const;
52
53 void Print(const Option_t* opt="") const;
54
55 // Bits & and bit masks for THaTrack
56 enum {
57 kStageMask = BIT(14) | BIT(15), // Track processing stage bits
58 kInvalid = 0x0000, // Not processed
59 kCoarse = BIT(14), // Coarse track
60 kFine = BIT(15), // Fine track
61 kReassigned = BIT(16), // Track is a new track in Fine stage
62 kMultiTrack = BIT(17), // Track was generated in the multitrack analysis
63 kBadTrack = BIT(18) // Track prematurely exits the spectrometer or similar
64 };
65
66 // Bits and bit masks for this object
67 enum {
68 kOnlyFastest = BIT(14), // Only use fastest hit for each wire (highest TDC)
69 kTDCbits = BIT(15) | BIT(16), // Mask for TDC mode bits
70 kHardTDCcut = BIT(15), // Use hard TDC cuts (fMinTime, fMaxTime)
71 kSoftTDCcut = BIT(16), // Use soft TDC cut (reasonable estimated drifts)
72 kIgnoreNegDrift = BIT(17), // Completely ignore negative drift times
73#ifdef MCDATA
74 kMCdata = BIT(21), // Assume input is Monte Carlo data
75#endif
76 kDecodeOnly = BIT(22), // Only decode data, disable tracking
77 kCoarseOnly = BIT(23) // Do only coarse tracking
78 };
79
80 enum { kPORDER = 7 };
81
82 // Class for storing matrix element data
84 public:
85 THaMatrixElement() : iszero(true), order(0), v(0)
86 { pw.reserve(5); poly.reserve(kPORDER); }
87 bool match( const THaMatrixElement& rhs ) const
88 { assert(pw.size() == rhs.pw.size()); return ( pw == rhs.pw ); }
89 void clear()
90 { iszero = true; pw.clear(); order = 0; v = 0.0; poly.clear(); }
91
92 bool iszero; // whether the element is zero
93 std::vector<int> pw; // exponents of matrix element
94 // e.g. D100 = { 1, 0, 0 }
95 int order;
96 double v; // its computed value
97 std::vector<double> poly;// the associated polynomial
98 };
99
100protected:
101
104
105 // Subdetectors
106 THaVDCChamber* fLower; // Lower chamber
107 THaVDCChamber* fUpper; // Upper chamber
108
109 // Event data
110 TClonesArray* fLUpairs; // Candidate pairs of lower/upper points
111 Int_t fNtracks; // Number of tracks found in ConstructTracks
112 UInt_t fEvNum; // Event number from decoder (for diagnostics)
113
114 // Geometry
115 Double_t fVDCAngle; // Angle from the VDC cs to TRANSPORT cs (rad)
116 Double_t fSin_vdc; // Sine of VDC angle
117 Double_t fCos_vdc; // Cosine of VDC angle
118 Double_t fTan_vdc; // Tangent of VDC angle
119 Double_t fSpacing; // Spacing between lower and upper chambers (m)
120
121 Double_t fCentralDist; // the path length of the central ray from
122 // the origin of the transport coordinates to
123 // the s1 plane
124
125 // Configuration
126 Int_t fNumIter; // Number of iterations for FineTrack()
127 Double_t fErrorCutoff; // Cut on track matching error
128 ECoordType fCoordType; // Coordinates to use as input for matrix calcs
129
130 // Optics matrix elements (FIXME: move to HRS)
131 std::vector<THaMatrixElement> fTMatrixElems;
132 std::vector<THaMatrixElement> fDMatrixElems;
133 std::vector<THaMatrixElement> fPMatrixElems;
134 std::vector<THaMatrixElement> fPTAMatrixElems; // involves abs(theta_fp)
135 std::vector<THaMatrixElement> fYMatrixElems;
136 std::vector<THaMatrixElement> fYTAMatrixElems; // involves abs(theta_fp)
137 std::vector<THaMatrixElement> fFPMatrixElems; // matrix elements used in
138 // focal plane transformations
139 // { T, Y, P }
140
141 std::vector<THaMatrixElement> fLMatrixElems; // Path-length corrections (meters)
142
144
145 void CalcFocalPlaneCoords( THaTrack* track );
146 void CalcTargetCoords( THaTrack* the_track );
147 static void CalcMatrix( double x, std::vector<THaMatrixElement>& matrix );
148// Double_t DoPoly(const int n, const std::vector<double> &a, const double x);
149// Double_t PolyInv(const double x1, const double x2, const double xacc,
150// const double y, const int norder,
151// const std::vector<double> &a);
152 static Double_t CalcTargetVar( const std::vector<THaMatrixElement>& matrix,
153 const double powers[][5] );
154 static Double_t CalcTarget2FPLen( const std::vector<THaMatrixElement>& matrix,
155 const Double_t powers[][5] );
156 static void PrintME( const std::string& header,
157 const std::vector<THaMatrixElement>& matrix );
158
159 virtual Int_t ConstructTracks( TClonesArray* tracks = nullptr, Int_t flag = 0 );
160
161 void CorrectTimeOfFlight(TClonesArray& tracks);
162 void FindBadTracks(TClonesArray &tracks);
163
164 virtual Int_t ReadDatabase( const TDatime& date );
165 virtual Int_t ReadGeometry( FILE* file, const TDatime& date,
166 Bool_t required = false );
167 virtual Int_t DefineVariables( EMode mode = kDefine );
168
169 ClassDef(THaVDC,0) // VDC class
170};
171
173
174#endif
#define kDefine
Definition BdataLoc.cxx:38
int Int_t
unsigned int UInt_t
bool Bool_t
double Double_t
const char Option_t
#define ClassDef(name, id)
#define BIT(n)
std::vector< int > pw
Definition THaVDC.h:93
bool match(const THaMatrixElement &rhs) const
Definition THaVDC.h:87
std::vector< double > poly
Definition THaVDC.h:97
Double_t fSpacing
Definition THaVDC.h:119
std::vector< THaMatrixElement > fTMatrixElems
Definition THaVDC.h:131
Double_t fErrorCutoff
Definition THaVDC.h:127
static Double_t CalcTarget2FPLen(const std::vector< THaMatrixElement > &matrix, const Double_t powers[][5])
Definition THaVDC.cxx:1023
std::vector< THaMatrixElement > fFPMatrixElems
Definition THaVDC.h:137
@ kPORDER
Definition THaVDC.h:80
UInt_t fEvNum
Definition THaVDC.h:112
THaVDCChamber * GetUpper() const
Definition THaVDC.h:44
virtual Int_t ConstructTracks(TClonesArray *tracks=nullptr, Int_t flag=0)
Definition THaVDC.cxx:472
virtual void SetDebug(Int_t level)
Definition THaVDC.cxx:1213
Double_t GetSpacing() const
Definition THaVDC.h:48
void CalcTargetCoords(THaTrack *the_track)
Definition THaVDC.cxx:917
ECoordType
Definition THaVDC.h:102
@ kTransport
Definition THaVDC.h:102
@ kRotatingTransport
Definition THaVDC.h:102
virtual Int_t FineTrack(TClonesArray &tracks)
Definition THaVDC.cxx:807
virtual EStatus Init(const TDatime &date)
Definition THaVDC.cxx:93
std::vector< THaMatrixElement > fPTAMatrixElems
Definition THaVDC.h:134
Double_t GetTimeCorrectionUnchecked() const
Definition THaVDC.cxx:1236
virtual Int_t DefineVariables(EMode mode=kDefine)
Definition THaVDC.cxx:454
Double_t fVDCAngle
Definition THaVDC.h:115
std::vector< THaMatrixElement > fLMatrixElems
Definition THaVDC.h:141
virtual ~THaVDC()
Definition THaVDC.cxx:82
virtual Int_t ReadDatabase(const TDatime &date)
Definition THaVDC.cxx:231
std::vector< THaMatrixElement > fDMatrixElems
Definition THaVDC.h:132
virtual Int_t Decode(const THaEvData &)
Definition THaVDC.cxx:770
virtual Int_t ReadGeometry(FILE *file, const TDatime &date, Bool_t required=false)
Definition THaVDC.cxx:1165
void CorrectTimeOfFlight(TClonesArray &tracks)
Definition THaVDC.cxx:1041
std::pair< Double_t, bool > GetTimeCorrection() const
Definition THaVDC.cxx:1224
TClonesArray * fLUpairs
Definition THaVDC.h:110
std::vector< THaMatrixElement > fYMatrixElems
Definition THaVDC.h:135
static void CalcMatrix(double x, std::vector< THaMatrixElement > &matrix)
Definition THaVDC.cxx:984
ECoordType fCoordType
Definition THaVDC.h:128
THaVDCChamber * fLower
Definition THaVDC.h:106
Double_t fCentralDist
Definition THaVDC.h:121
std::vector< THaMatrixElement > fPMatrixElems
Definition THaVDC.h:133
static void PrintME(const std::string &header, const std::vector< THaMatrixElement > &matrix)
Definition THaVDC.cxx:1127
Double_t fTan_vdc
Definition THaVDC.h:118
static Double_t CalcTargetVar(const std::vector< THaMatrixElement > &matrix, const double powers[][5])
Definition THaVDC.cxx:1001
@ kOnlyFastest
Definition THaVDC.h:68
@ kDecodeOnly
Definition THaVDC.h:76
@ kSoftTDCcut
Definition THaVDC.h:71
@ kCoarseOnly
Definition THaVDC.h:77
@ kIgnoreNegDrift
Definition THaVDC.h:72
@ kTDCbits
Definition THaVDC.h:69
@ kHardTDCcut
Definition THaVDC.h:70
Double_t GetVDCAngle() const
Definition THaVDC.h:47
virtual void Clear(Option_t *opt="")
Definition THaVDC.cxx:760
Int_t fNumIter
Definition THaVDC.h:126
@ kInvalid
Definition THaVDC.h:58
@ kFine
Definition THaVDC.h:60
@ kCoarse
Definition THaVDC.h:59
@ kMultiTrack
Definition THaVDC.h:62
@ kReassigned
Definition THaVDC.h:61
@ kBadTrack
Definition THaVDC.h:63
@ kStageMask
Definition THaVDC.h:57
std::vector< THaMatrixElement > fYTAMatrixElems
Definition THaVDC.h:136
void Print(const Option_t *opt="") const
Definition THaVDC.cxx:1145
THaVDCChamber * fUpper
Definition THaVDC.h:107
Podd::TimeCorrectionModule * fTimeCorrectionModule
Definition THaVDC.h:143
void FindBadTracks(TClonesArray &tracks)
Definition THaVDC.cxx:1090
Double_t fSin_vdc
Definition THaVDC.h:116
Int_t fNtracks
Definition THaVDC.h:111
void CalcFocalPlaneCoords(THaTrack *track)
Definition THaVDC.cxx:882
EFPMatrixElemTag
Definition THaVDC.h:103
@ P000
Definition THaVDC.h:103
@ T000
Definition THaVDC.h:103
@ Y000
Definition THaVDC.h:103
virtual Int_t CoarseTrack(TClonesArray &tracks)
Definition THaVDC.cxx:790
THaVDCChamber * GetLower() const
Definition THaVDC.h:45
virtual Int_t FindVertices(TClonesArray &tracks)
Definition THaVDC.cxx:833
Double_t fCos_vdc
Definition THaVDC.h:117