1#include "MdcHoughFinder/Hough2D.h"
2#include "CgemData/CgemHitOnTrack.h"
31 _circleR=other._circleR;
32 _circleX=other._circleX;
33 _circleY=other._circleY;
37 _charge=other._charge;
40 _chi2_aver2D=other._chi2_aver2D;
41 _bunchT0=other._bunchT0;
44 _recHitVec=other._recHitVec;
89 int hitCandiSize=_recHitVec.size();
91 for(
int i=0;i<hitCandiSize;i++){
95 x_sum=x_sum+( _recHitVec[i].getMidX() );
96 y_sum=y_sum+( _recHitVec[i].getMidY() );
97 x2_sum=x2_sum+( _recHitVec[i].getMidX() )*( _recHitVec[i].getMidX() );
98 y2_sum=y2_sum+( _recHitVec[i].getMidY() )*( _recHitVec[i].getMidY() );
99 x3_sum=x3_sum+( _recHitVec[i].getMidX() )*( _recHitVec[i].getMidX() )*( _recHitVec[i].getMidX() );
100 y3_sum=y3_sum+( _recHitVec[i].getMidY() )*( _recHitVec[i].getMidY() )*( _recHitVec[i].getMidY() );
101 x2y_sum=x2y_sum+( _recHitVec[i].getMidX() )*( _recHitVec[i].getMidX() )*( _recHitVec[i].getMidY() );
102 xy2_sum=xy2_sum+( _recHitVec[i].getMidX() )*( _recHitVec[i].getMidY() )*( _recHitVec[i].getMidY() );
103 xy_sum=xy_sum+( _recHitVec[i].getMidX() )*( _recHitVec[i].getMidY() );
106 a1=x2_sum-x_sum*x_sum/hitCandiSize;
107 a2=xy_sum-x_sum*y_sum/hitCandiSize;
109 b2=y2_sum-y_sum*y_sum/hitCandiSize;
110 c1=(x3_sum+xy2_sum-x_sum*(x2_sum+y2_sum)/hitCandiSize)/2.;
111 c2=(y3_sum+x2y_sum-y_sum*(x2_sum+y2_sum)/hitCandiSize)/2.;
117 _circleX =(b1*c2-b2*
c1)/(b1*b1-a1*b2);
118 _circleY =(b1*
c1-a1*c2)/(b1*b1-a1*b2);
119 _circleR=sqrt( (x2_sum+y2_sum-2*_circleX*x_sum-2*_circleY*y_sum)/hitCandiSize+_circleX*_circleX+_circleY*_circleY );
123 _d0=sqrt(_circleX*_circleX+_circleY*_circleY)-_circleR;
124 _phi0=atan2(_circleY,_circleX)+
M_PI/2.;
126 double pt_temp=_circleR/333.567;
127 if(
m_debug>0) cout<<
" pt: "<<pt_temp<<endl;
128 if(
m_debug>0) cout<<
"par: ("<<_d0<<
","<<_phi0<<
","<<_omega<<
")"<<endl;
131 _circleX_least =(b1*c2-b2*
c1)/(b1*b1-a1*b2);
132 _circleY_least =(b1*
c1-a1*c2)/(b1*b1-a1*b2);
133 _circleR_least=sqrt( (x2_sum+y2_sum-2*_circleX*x_sum-2*_circleY*y_sum)/hitCandiSize+_circleX*_circleX+_circleY*_circleY );
152 if (
m_debug>0) cout<<
"q d0 phi0 omega: "<<_charge<<
" "<<_d0<<
" "<<_phi0<<
" "<<_omega<<endl;
157 bool permitFlips =
true;
158 bool lPickHits =
true;
163 vector<MdcHit*> t_hitCol;
164 std::vector<HoughRecHit>::iterator
iter = _recHitVec.begin();
165 for (;
iter != _recHitVec.end();
iter++, digiId++) {
166 if( (*iter).getflag()!=0)
continue;
167 if((*iter).getDetectorType()==
MDC) {
170 const MdcDigi* aDigi = (*iter).digi();
176 t_hitCol.push_back(hit);
189 newhot->
setFltLen( (*iter).getRet().second);
190 double distoTrack= (*iter).getDisToTrack();
195 if(hit->
driftTime(_bunchT0,0)>1000) use_in2d=0;
196 if(hit->
driftDist(_bunchT0,0)>ddCut) use_in2d=0;
199 if(use_in2d==0)
continue;
201 }
else if((*iter).getDetectorType()==
CGEM &&(*iter).getCluster()->getflag()==0){
202 if(
m_debug>0) std::cout<<__FILE__<<
" "<<__LINE__<<
" add CGEM hit to fit "<<std::endl;
222 cout <<
" global 2d fit failed ";
223 if(newFit) cout <<
" nAct "<<newFit->
nActive();
224 cout<<
"ERR1 failure ="<<err.
failure()<<endl;
231 chi2=newFit->
chisq();
232 if(
m_debug>0) cout<<
"chi2 "<<chi2<<endl;
239 bool badQuality =
false;
260 std::cout<<__FILE__<<
" "<<__LINE__<<
" drop track by nhit"<<nActiveHit <<
" <= "<<
m_dropTrkNhitCut<<std::endl;
264 if( badQuality) fit_stat=0;
268 cout <<
" global 2d fit success"<<endl;
269 cout<<__FILE__<<__LINE__<<
"AFTER fit 2d "<<endl;
270 newTrack->
print(std::cout);
274 double phi0=par.
phi0();
275 double omega=par.
omega();
276 double r_temp=-1./par.
omega();
277 double x_cirtemp =
sin(par.
phi0()) *(par.
d0()+1/par.
omega()) * -1.;
278 double y_cirtemp = -1.*
cos(par.
phi0()) *(par.
d0()+1/par.
omega()) * -1;
280 cout<<
" circle after globle 2d: "<<
"("<<x_cirtemp<<
","<<y_cirtemp<<
","<<r_temp<<
")"<<endl;
281 cout<<
"pt_rec: "<<1./omega/333.567<<endl;
283 _pt=1./omega/333.567;
286 _circleR=_charge/omega;
292 if(
m_debug>1) cout<<
" hot list:"<<endl;
294 int lay=((
MdcHit*)(hotIter->hit()))->layernumber();
295 int wir=((
MdcHit*)(hotIter->hit()))->wirenumber();
296 int hittemp=lay*1000+wir;
298 if(
m_debug>1){ cout <<
"(" <<((
MdcHit*)(hotIter->hit()))->layernumber()
299 <<
","<<((
MdcHit*)(hotIter->hit()))->wirenumber()
300 <<
":"<<hotIter->isActive()<<
") ";
302 if (hotIter->isActive()==1) nfit2d++;
307 _chi2_aver2D=chi2/_nfit;
309 for(
int i=0;i<t_hitCol.size();i++){
314 if(
m_debug>0) cout<<
" in 2D fit number of Active hits : "<<_nfit<<endl;
320 _circleX =
sin(_phi0) *(_d0+1/_omega) * -1.;
321 _circleY = -1.*
cos(_phi0) *(_d0+1/_omega) * -1;
322 _circleR = _charge/_omega;
323 _pt = 1./_omega/333.567;
365 cout<<
" print hough2d "<<endl;
366 cout<<
"par: "<<_d0<<
" "<<_phi0<<
" "<<_omega<<endl;
double abs(const EvtComplex &c)
double sin(const BesAngle a)
double cos(const BesAngle a)
std::vector< HoughRecHit > recHitCol
void setCgemCalibFunSvc(const CgemCalibFunSvc *svc)
void setCgemGeomSvc(const CgemGeomSvc *svc)
static double m_dropTrkChi2NdfCut
static double m_dropTrkDzCut
static const MdcCalibFunSvc * _mdcCalibFunSvc
static TrkContextEv * _context
static const CgemCalibFunSvc * _cgemCalibFunSvc
static const CgemGeomSvc * _cgemGeomSvc
static int m_qualityFactor
static double m_dropTrkChi2Cut
static double m_dropTrkNhitCut
static double m_dropTrkDrCut
double getT0(int layid, int cellid) const
double getTimeWalk(int layid, double Q) const
void setCalibSvc(const MdcCalibFunSvc *calibSvc)
double driftTime(double tof, double z) const
void setCountPropTime(const bool count)
double driftDist(double, int, double, double, double) const
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
virtual Identifier identify() const
unsigned int getChargeChannel() const
virtual double chisq() const =0
virtual int nActive() const =0
virtual TrkExchangePar helix(double fltL) const =0
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)
const TrkHotList & hotList() const
hot_iterator begin() const
virtual int nActive(TrkEnums::TrkViewInfo view=TrkEnums::bothView) const =0
virtual void print(std::ostream &) const
const TrkFit * fitResult() const
bool setFlipAndDrop(TrkRecoTrk &, bool allowFlips, bool allowDrops) const
TrkRecoTrk * makeTrack(const TrkExchangePar &helix, const double chi2, const TrkContext &, double trackT0) const