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