CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
DotsHelixFitter.h
Go to the documentation of this file.
1#ifndef DotsHelixFitter_H
2#define DotsHelixFitter_H
3
9#include "MdcGeomSvc/MdcGeomSvc.h"
13
14//using namespace KalmanFit;
15
17{
18 public:
21 DotsHelixFitter(KalmanFit::Helix iniHelix, vector<const MdcDigi*> vecMdcDigi, vector<const RecCgemCluster*> vecCgemCluster);
22 void initialize();
23 void updateBField();
24 void setMaxIterations(int n=10) {myMaxIteration=n;};
25 void setMinXhitsInCircleFit(int n=3) {myMinXhitsInCircleFit=n;};
26 void setMinVhitsInHelixFit(int n=2) {myMinVhitsInHelixFit=n;};
27 void setMinHitsInHelixFit(int n=5) {myMinHitsInHelixFit=n;};
28 void setDchi2Converge(double cut=5) {myDchi2Converge=cut;};
29 void setDchi2Diverge(double cut=50) {myDchi2Diverge=cut;};
30 void setMaxNChi2Increase(int n=2) {myMaxNChi2Increase=n;};
31 void setChi2Diverge(double cut=1000000) {myChi2Diverge=cut;};
32
34 void setT0(double T0) {myEventT0=T0;};
35 void setCgemClusters(vector<const RecCgemCluster*> aVecCgemCluster);
36 void setDChits(vector<const MdcDigi*> aVecMdcDigi, double T0);
37 bool setDChitsFitFlag(vector<int>& vec);
38 bool setDChitsPhiAmbi(const vector<double>& vec);
39 void clearAllHits();
40
41 void resetChi2FitFlag();
42
43 void fitCircleOnly(bool x=true) {myFitCircleOnly=x;};
44 void fitModeCircle() {myFitCircleOnly=true;}
45 void fitModeCircleOrigin() {myFitCircleOriginOnly=true;}
46 void fitModeHelix() {myFitCircleOnly=false; myUseAxialHitsOnly=false;}
47 void useAxialHitsOnly(bool x=true) {myUseAxialHitsOnly=x;}
48 void useMdcHitsOnly(bool x=true) {myUseMdcHitsOnly=x;};
49 void usePhiAmbi(bool x=true) {myUsePhiAmbi=x;};
50
51 double dPhi(double phi1, double phi2)
52 {
53 double dphi=phi1-phi2;
54 if(dphi<-M_PI||dphi> M_PI) dphi=atan2(sin(dphi),cos(dphi));// into [-pi, pi]
55 return dphi;
56 }
57
58 KalmanFit::Helix getClassHelix() {return *myHelix;} // in cm, radian, GeV/c
59 HepVector getHelix() {return myHelix_aVec;};
60 const HepSymMatrix & getEa() {return myHelix_Ea;};// error matrix
61 double getChi2() {return myChi2;};
62
63 void fit();
64
65 void setExtraPoints(vector< pair<double, double> > extraPoints) {myExtraPoints=extraPoints;};
66 vector<double> CircleFitByTaubin(const vector< pair<double, double> >& pos_hits); // Taubin circle fit using (x,y) inputs
67 vector<double> circleParConversion(const vector<double>& vec_par_Taubin);
68
69 vector<double> calculateCirclePar_Taubin(bool useIniHelix=false, int layerMin=-1, int layerMax=50, bool useExtraPoints=false, int debug=0); // int useHits=3);// useHits, 1: CGEM only; 2: MDC only; 3: all
70
74 int deactiveHits(double chi_cut=10, int nMax=1, int layerMin=0, int layerMax=50);
75 int activeHits(double chi_cut=10, int sel=0);// sel=0: all, sel=1: only uncertain hits
76 int deactiveHits(int layer_max=43, int nHit_max=1000);
77 int getNActiveHits() {return myNActiveHits;};
78 int getNActiveOuterXHits() {return myNActiveOuterXHits;};
79 int getNInnerXHits() {return myNInnerXHits;};
80 int getNOuterXHits() {return myNOuterXHits;};
81 int getNFittedHits() {return myNFittedHits;};
82 //void updateChi2();
83 void printActiveHits();
84
85 void loadOneDcDigi(const MdcDigi* aDcDigi);
86 void calculateRoughDD(const MdcDigi* aMdcDigi);
87 void calculateDocaFromTrk(const MdcDigi* aDcDigi);
88 void updateDcDigiInfo(const MdcDigi* aDcDigi);
89 vector<pair<double, double> > getSZ(const MdcDigi* aDcDigi);
90 double getFlightLength() { return myFlightLength; };
91 double getFlightLength(const MdcDigi* aDcDigi) { calculateDocaFromTrk(aDcDigi); return myFlightLength; };
92 int getLayer(const MdcDigi* aDcDigi) { loadOneDcDigi(aDcDigi); return myLayer; };
93 double getDocaFromTrk() {return myDocaFromTrk;};
94 double getDocaFromTrk(const MdcDigi* aDcDigi) { calculateDocaFromTrk(aDcDigi); return myDocaFromTrk;};
95 double getDigiChi() { return myDcChi;};
96
97 RecMdcHit makeRecMdcHit(const MdcDigi* aDcDigi);
98 RecMdcHit makeRecMdcHit(const MdcDigi* aDcDigi, KalmanFit::Helix aHelix);
99 vector<RecMdcHit> makeRecMdcHitVec(int sel=1);// sel=0: all, 1: only active
100
101 vector<const MdcDigi*> getVecMdcDigi() {return myVecMdcDigi;}
102 vector<double> getVecChiMdcDigi() {return myChiVecMdcDigi;}
103 vector<int> getVecMdcDigiIsAct() {return myMdcDigiIsActive;}
104
105 vector<const RecCgemCluster*> getVecCgemCluster() { return myVecCgemCluster;}
106 vector<int> getVecIsActiveCgemCluster() { return myCgemClusterIsActive;}
107 vector<double> getVecChiCgemCluster() { return myChiVecCgemCluster;}
108
109 double IntersectCylinder(double r);
110 HepMatrix dxda_cgem(KalmanFit::Helix a, double phi);
111
112 double getRmidGapCgem(int i)
113 {
114 if(i>2) i=2;
115 if(i<0) i=0;
116 return myRmidDGapCgem[i];
117 }
118
119 bool getPosAtCgem(int layer, HepPoint3D& pos);
120
122 myWireCrossPointPersistent=mode;
123 }
124
125 private:
126
127 // --- if initialized
128 bool myIsInitialized;
129
130 // --- option
131 bool myFitCircleOnly;
132 bool myFitCircleOriginOnly;
133 bool myUseAxialHitsOnly;
134 bool myUseMdcHitsOnly;
135 bool myWireCrossPointPersistent;
136 bool myUsePhiAmbi;
137
138 // --- criteria
139 int myMaxIteration;
140 int myMinXhitsInCircleFit;
141 int myMinVhitsInHelixFit;
142 int myMinHitsInHelixFit;
143 double myDchi2Converge;
144 double myDchi2Diverge;
145 int myMaxNChi2Increase;
146 double myChi2Diverge;
147
148 // --- some common information at event level
149 double myEventT0;// event start time
150
151 // --- information of a DC digi (or CGEM cluster) under proccessing
152 int myLayer;
153 int myWire;
154 double myWirePos[7];
155 double myCharge;
156 double myPosOnWire[3];
157 double myPosOnTrk[3];
158 int myLeftRight;//left:0, right:1
159 double myDocaFromTrk;
160 double myEntranceAngle;
161 double myFlightLength;
162 double myDocaFromDigi;
163 double myDriftDist[2];//left/right
164 double myDriftDistErr[2];//left/right
165 double myDriftTime;
166 double myDcChi;
167
168
169 // --- track parameters
170 KalmanFit::Helix* myHelix;// in cm, radian, GeV/c
171 double myHelix_a[5];// in cm, radian, GeV/c
172 void prtHelix() { cout<<"my Helix: "<<myHelix_a[0] <<", "<< myHelix_a[1] <<", "<< myHelix_a[2] <<", "<< myHelix_a[3] <<", "<< myHelix_a[4] <<endl; }
173 HepVector myHelix_aVec;
174 HepSymMatrix myHelix_Ea;// error matrix
175 double myChi2;
176 int myNActiveHits;
177 int myNActiveOuterXHits;
178 int myNOuterXHits;
179 int myNInnerXHits;
180 int myNFittedHits;
181 double myAlpha;
182
183
184 // --- digi collection for DC
185 vector<const MdcDigi*> myVecMdcDigi;
186 vector<double> myPhiAmbiVecMdcDigi;
187 vector<double> myDelDVecMdcDigi;
188 vector< vector<double> > myDerivVecMdcDigi;
189 vector<double> myChiVecMdcDigi;
190 vector<int> myAmbiguityMdcDigi;// left: -1, right: 1, not sure: 0
191 vector<int> myMdcDigiIsActive;// active: 1, inactive: -1, uncertain: 0
192 int myNumMdcDigiPerLayer[43];
193 int myIdxMdcDigiNeighbour[43][2];// index
194 int myWireIdMdcDigiNeighbour[43][2];// wire id
195
196 // --- cluster collection for CGEM
197 vector<const RecCgemCluster*> myVecCgemCluster;
198 vector<int> myCgemClusterIsActive;// active: 1, inactive: -1, uncertain: 0
199 vector<double> myChiVecCgemCluster;
200 vector<const RecCgemCluster*> myVecCgemClusterX;
201 vector<const RecCgemCluster*> myVecCgemClusterV;
202
203 // --- index ordered by flight length
204 map<double, int> myMapFlylenIdx;
205 //map<double, double> myMapFlylenChi;
206
207 // --- extra points (x,y) for Taubin circle fit
208 vector< pair<double, double> > myExtraPoints;
209
210 // --- geometry for MDC
211 MdcGeomSvc* myMdcGeomSvc;
212 int myWireFlag[43];// sign for wire orientation
213 int myNWire[43];
214 double myRWires[43];
215 vector<double> myPhiWires[43];
216 vector<double> myTensionWires[43];
217 vector<double*> myEastPosWires[43];// wire backward, aka +z
218 vector<double*> myWestPosWires[43];// wire forward, aka -z
219 vector<double*> myPosWires[43];// position of wires with z=0
220 vector<double*> myDirWires[43];// direction of wires
221
222 // --- geometry for CGEM
223 CgemGeomSvc* myCgemGeomSvc;
224 double myRmidDGapCgem[3];
225 double myR2midDGapCgem[3];
226 double myRVCgem[3];
227 double myRXCgem[3];
228 double myAngStereoCgem[3];
229 int myNSheets[3];
230
231 // --- calibration svc
232 MdcCalibFunSvc* myMdcCalibFunSvc;
233 ICgemCalibFunSvc* myCgemCalibSvc;
234
235 // --- MDC utility
236 IMdcUtilitySvc* myMdcUtilitySvc;
237
238};
239
240#endif
double sin(const BesAngle a)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213
const Int_t n
Double_t phi2
Double_t x[10]
Double_t phi1
*********Class see also m_nmax DOUBLE PRECISION m_MasPhot DOUBLE PRECISION m_phsu DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_r2 DOUBLE PRECISION m_WtMass INTEGER m_nmax INTEGER m_Nevgen INTEGER m_IsFSR INTEGER m_MarTot *COMMON c_KarFin $ !Output file $ !Event serial number $ !alpha QED at Thomson limit $ !minimum energy at CMS for remooval $ !infrared cut
Definition KarFin.h:27
#define M_PI
Definition TConstant.h:4
void setInitialHelix(KalmanFit::Helix aHelix)
void setChi2Diverge(double cut=1000000)
int activeHits(double chi_cut=10, int sel=0)
activate myMdcDigiIsActive's hit based on myChiVecMdcDigi
double getFlightLength()
int getLayer(const MdcDigi *aDcDigi)
void setDChits(vector< const MdcDigi * > aVecMdcDigi, double T0)
double dPhi(double phi1, double phi2)
void calcuMeasDeriv()
vector< const RecCgemCluster * > getVecCgemCluster()
vector< const MdcDigi * > getVecMdcDigi()
void setCgemClusters(vector< const RecCgemCluster * > aVecCgemCluster)
void setMinHitsInHelixFit(int n=5)
void useAxialHitsOnly(bool x=true)
bool getPosAtCgem(int layer, HepPoint3D &pos)
DotsHelixFitter(KalmanFit::Helix iniHelix, vector< const MdcDigi * > vecMdcDigi, vector< const RecCgemCluster * > vecCgemCluster)
int deactiveHits(double chi_cut=10, int nMax=1, int layerMin=0, int layerMax=50)
HepMatrix dxda_cgem(KalmanFit::Helix a, double phi)
void setMaxNChi2Increase(int n=2)
bool setDChitsPhiAmbi(const vector< double > &vec)
void calculateDocaFromTrk(const MdcDigi *aDcDigi)
void setDchi2Diverge(double cut=50)
void setDchi2Converge(double cut=5)
vector< double > circleParConversion(const vector< double > &vec_par_Taubin)
void setMinVhitsInHelixFit(int n=2)
double getRmidGapCgem(int i)
vector< double > getVecChiCgemCluster()
const HepSymMatrix & getEa()
KalmanFit::Helix getClassHelix()
HepVector getHelix()
void setModeWireCrossPointPersistent(bool mode)
vector< pair< double, double > > getSZ(const MdcDigi *aDcDigi)
return S, the track length in XY; and Z of a hit on a stereo wire
void setMaxIterations(int n=10)
bool setDChitsFitFlag(vector< int > &vec)
set myMdcDigiIsActive from vec
void fitCircleOnly(bool x=true)
void setMinXhitsInCircleFit(int n=3)
vector< double > CircleFitByTaubin(const vector< pair< double, double > > &pos_hits)
double getFlightLength(const MdcDigi *aDcDigi)
void loadOneDcDigi(const MdcDigi *aDcDigi)
vector< double > calculateCirclePar_Taubin(bool useIniHelix=false, int layerMin=-1, int layerMax=50, bool useExtraPoints=false, int debug=0)
void setExtraPoints(vector< pair< double, double > > extraPoints)
void usePhiAmbi(bool x=true)
vector< RecMdcHit > makeRecMdcHitVec(int sel=1)
void calculateRoughDD(const MdcDigi *aMdcDigi)
RecMdcHit makeRecMdcHit(const MdcDigi *aDcDigi)
void calculateInitialHelix()
vector< double > getVecChiMdcDigi()
void useMdcHitsOnly(bool x=true)
void setT0(double T0)
vector< int > getVecMdcDigiIsAct()
double IntersectCylinder(double r)
void updateDcDigiInfo(const MdcDigi *aDcDigi)
based on input aDcDigi, modifies myFlightLength, myLeftRight, myPosOnWire, myDocaFromDigi,...
double getDocaFromTrk()
double getDocaFromTrk(const MdcDigi *aDcDigi)
vector< int > getVecIsActiveCgemCluster()
dble_vec_t vec[12]
Definition ranlxd.c:372