4#include "GaudiKernel/Bootstrap.h"
13 myHelix(NULL),myIsInitialized(
false),myMdcGeomSvc(NULL),myCgemGeomSvc(NULL),myMdcCalibFunSvc(NULL),myMdcUtilitySvc(NULL)
15 myHelix_Ea=HepSymMatrix(5,0);
17 myMinXhitsInCircleFit=3;
18 myMinVhitsInHelixFit=2;
19 myMinHitsInHelixFit=5;
23 myChi2Diverge=1000000.0;
24 myFitCircleOnly=
false;
25 myUseAxialHitsOnly=
false;
31 if(myHelix)
delete myHelix;
36 if(myIsInitialized)
return;
39 ISvcLocator* svcLocator = Gaudi::svcLocator();
41 StatusCode Cgem_sc=svcLocator->service(
"CgemGeomSvc", ISvc);
42 if(Cgem_sc.isSuccess()) myCgemGeomSvc=
dynamic_cast<CgemGeomSvc *
>(ISvc);
43 else cout<<
"DotsHelixFitter::initialize(): can not get CgemGeomSvc"<<endl;
46 cout<<
"DotsHelixFitter::initialize(): nLayerCgem!=3 !!!"<<endl;
49 for(
int i=0; i<nLayerCgem; i++)
54 myR2midDGapCgem[i]=pow(myRmidDGapCgem[i],2);
62 cout<<
"CGEM layer "<<i<<
": "
63 <<
" Rmid="<<myRmidDGapCgem[i]<<
" cm "
64 <<
" RV ="<<myRVCgem[i]<<
" cm "
65 <<
" RX ="<<myRXCgem[i]<<
" cm "
66 <<
" , stereo angle = "<<myAngStereoCgem[i]<<
" radian "
67 <<myNSheets[i]<<
" sheets"
75 StatusCode mdc_sc=svcLocator->service(
"MdcGeomSvc", ISvc2);
76 if(mdc_sc.isSuccess()) myMdcGeomSvc=
dynamic_cast<MdcGeomSvc *
>(ISvc2);
77 else cout<<
"DotsHelixFitter::initialize(): can not get MdcGeomSvc"<<endl;
79 if(nLayer!=43) cout<<
"DotsHelixFitter::initialize(): MDC nLayer = "<<nLayer<<
" !=43 !!!"<<endl;
80 for(
int i=0; i<nLayer; i++)
83 myRWires[i]=0.1*(aLayer->
Radius());
84 cout<<
"MDC layer "<<i<<
" R = "<<myRWires[i]<<endl;
86 if(nomShift>0) myWireFlag[i]=1;
87 else if(nomShift<0) myWireFlag[i]=-1;
89 int nWires=aLayer->
NCell();
91 for(
int j=0; j<nWires; j++)
95 double* aPointArray =
new double[3]{aPointEast.x(),aPointEast.y(),aPointEast.z()};
96 myWestPosWires[i].push_back(aPointArray);
98 aPointArray =
new double[3]{aPointWest.x(),aPointWest.y(),aPointWest.z()};
99 myEastPosWires[i].push_back(aPointArray);
100 HepPoint3D aPointMiddle = 0.5*(aPointEast+aPointWest);
101 aPointArray =
new double[3]{aPointMiddle.x(),aPointMiddle.y(),aPointMiddle.z()};
102 myPosWires[i].push_back(aPointArray);
104 myPhiWires[i].push_back(aPointMiddle.phi());
105 myTensionWires[i].push_back(aWire->
Tension());;
111 StatusCode sc = svcLocator->service(
"MdcCalibFunSvc", imdcCalibSvc);
112 if ( sc.isSuccess() ){
116 cout<<
"DotsHelixFitter::initialize(): can not get MdcCalibFunSvc"<<endl;
120 sc = svcLocator->service(
"CgemCalibFunSvc", myCgemCalibSvc);
121 if ( !(sc.isSuccess()) )
123 cout<<
"DotsHelixFitter::initialize(): can not get CgemCalibFunSvc"<<endl;
126 myIsInitialized=
true;
129 sc = svcLocator->service(
"MdcUtilitySvc", myMdcUtilitySvc);
130 if ( !(sc.isSuccess()) )
132 cout<<
"DotsHelixFitter::initialize(): can not get MdcUtilitySvc"<<endl;
141 myVecMdcDigi=aVecMdcDigi;
143 int nDigi = myVecMdcDigi.size();
144 myChiVecMdcDigi.resize(nDigi);
145 myAmbiguityMdcDigi.resize(nDigi);
146 myMdcDigiIsActive.resize(nDigi);
149 for(
int i=0; i<43; i++) myNumMdcDigiPerLayer[i]=0;
151 for(
int i=0; i<nDigi; i++)
153 myChiVecMdcDigi[i]=9999;
154 myAmbiguityMdcDigi[i]=0;
155 myMdcDigiIsActive[i]=1;
161 myVecCgemCluster=aVecCgemCluster;
162 int nCluster1D = myVecCgemCluster.size();
163 myChiVecCgemCluster.resize(nCluster1D);
164 myCgemClusterIsActive.resize(nCluster1D);
166 myVecCgemClusterX.clear();
167 myVecCgemClusterV.clear();
168 vector<const RecCgemCluster*>::iterator iter_cluster = myVecCgemCluster.begin();
169 for(
int i=0; iter_cluster!=myVecCgemCluster.end(); iter_cluster++, i++)
171 int flag = (*iter_cluster)->getflag();
172 myChiVecCgemCluster[i]=9999;
173 myCgemClusterIsActive[i]=1;
183 double tension = 9999.;
186 if(myFitCircleOnly) nPar=3;
190 for(
int i=0; i<43; i++) myNumMdcDigiPerLayer[i]=0;
192 int nXHits[3]={0,0,0}, nVHits[3]={0,0,0};
193 int nDigi=myVecMdcDigi.size();
194 double* vec_zini =
new double[nDigi];
197 vector<const MdcDigi*>::iterator iter_mdcDigi = myVecMdcDigi.begin();
198 for(; iter_mdcDigi!=myVecMdcDigi.end(); iter_mdcDigi++, i_digi++)
207 if(myMdcDigiIsActive[i_digi])
211 int hitFlag = myWireFlag[layer];
223 if(maxLayer<layer) maxLayer=layer;
224 int nHits = myNumMdcDigiPerLayer[layer];
226 myIdxMdcDigiNeighbour[layer][nHits]=i_digi;
227 myWireIdMdcDigiNeighbour[layer][nHits]=wire;
229 myNumMdcDigiPerLayer[layer]++;
233 double maxRTrk = farPoint.perp();
234 for(
int i=0; i<43; i++)
236 if(maxRTrk<myRWires[i]+2)
break;
237 if(myNumMdcDigiPerLayer[i]==2)
239 int wire_1 = myWireIdMdcDigiNeighbour[i][0];
240 int wire_2 = myWireIdMdcDigiNeighbour[i][1];
241 int delta_n =
abs(wire_1-wire_2);
246 ambi_1 = wire_1>wire_2? 1:-1;
247 ambi_2 = wire_1>wire_2? -1:1;
249 else if(delta_n==myNWire[i]-1)
251 ambi_1 = wire_1<=1? 1:-1;
252 ambi_2 = wire_2<=1? 1:-1;
255 cout<<
"layer, wire1, wire2, ambi1, ambi2 = "
268 vector<const RecCgemCluster*>::iterator iter_cluster = myVecCgemCluster.begin();
269 for(; iter_cluster!=myVecCgemCluster.end(); iter_cluster++, i_digi++)
271 int flag = (*iter_cluster)->getflag();
286 if(nXHits[0]<myMinXhitsInCircleFit)
return 1;
290 if((nXHits[0]+nVHits[0])<myMinHitsInHelixFit)
return 2;
291 if(nVHits[0]<myMinVhitsInHelixFit)
return 3;
298 double lastTotChi2 = 999999;
300 int n_chi2_increase = 0;
304 myMapFlylenIdx.clear();
306 HepSymMatrix U(nPar, 0);
310 HepMatrix
P(nPar,1,0);
311 HepMatrix J(nPar,1,0), JT(1,nPar,0);
312 HepMatrix J_dmdx(1,3,0), J_dxda(3,nPar,0);
317 vector<const MdcDigi*>::iterator iter_mdcDigi = myVecMdcDigi.begin();
318 for(; iter_mdcDigi!=myVecMdcDigi.end(); iter_mdcDigi++, i_digi++)
324 double charge = (*iter_mdcDigi)->getChargeChannel();
328 double wpos[7]={myEastPosWires[layer][wire][0], myEastPosWires[layer][wire][1], myEastPosWires[layer][wire][2]
329 , myWestPosWires[layer][wire][0], myWestPosWires[layer][wire][1], myWestPosWires[layer][wire][2], tension};
335 cout<<
"* layer "<<layer<<
", wire "<<wire<<
", is active "<<myMdcDigiIsActive[i_digi] <<endl;
339 getDoca(myHelix_a, wpos, doca_trk, whitPos, vec_zini[i_digi]);
342 cout<<
"doca = "<<doca_trk<<endl;
347 leftRight=int(doca_trk/fabs(doca_trk));
355 signDoca=leftRight/fabs(leftRight);
358 if(leftRight==1) leftRight=0;
362 vec_zini[i_digi] = whitPos[2];
366 double tprop = myMdcCalibFunSvc->
getTprop(layer, vec_zini[i_digi]);
367 double T0Walk = myMdcCalibFunSvc->
getT0(layer,wire) + myMdcCalibFunSvc->
getTimeWalk(layer, charge);
370 HepPoint3D aNewPivot(whitPos[0],whitPos[1],whitPos[2]);
371 aHelix.
pivot(aNewPivot);
372 double newPhi0 = aHelix.
phi0();
373 double dphi = newPhi0-myHelix->
phi0();
376 double flightLength = fabs(dphi*myHelix->
radius())*sqrt(1+myHelix->
tanl()*myHelix->
tanl());
377 myMapFlylenIdx[flightLength]=i_digi;
378 HepLorentzVector p4_pi = myHelix->
momentum(dphi, 0.13957);
379 double speed = p4_pi.beta()*
CC;
380 double TOF = flightLength/speed*1.e9;
382 double driftT = rawTime - myEventT0 - TOF - T0Walk - tprop;
385 double phiWire = atan2(whitPos[1],whitPos[0]);
386 double phiP = p4_pi.phi();
387 double entranceAngle = phiP-phiWire;
388 while(entranceAngle<-
M_PI) entranceAngle+=2*
M_PI;
389 while(entranceAngle>
M_PI) entranceAngle-=2*
M_PI;
391 double doca_hit = 0.1 * myMdcCalibFunSvc->
driftTimeToDist(driftT,layer,wire,leftRight, entranceAngle);
393 double docaErr_hit = 0.1 * myMdcCalibFunSvc->
getSigma(layer, leftRight, doca_hit, entranceAngle, myHelix_a[4], vec_zini[i_digi], charge);
399 double delD = doca_hit-doca_trk;
400 double chi = delD/docaErr_hit;
402 cout<<
"delta_m, err_m, chi = "<<delD<<
", "<<docaErr_hit<<
", "<<chi<<endl;
403 myChiVecMdcDigi[i_digi]=chi;
405 if(!myMdcDigiIsActive[i_digi])
continue;
406 if(myUseAxialHitsOnly && myWireFlag[layer]!=0)
continue;
409 for(
int ipar=0; ipar<nPar; ipar++)
413 getDeriLoc(ipar,myHelix_a, deri, wpos, vec_zini[i_digi]);
419 P(ipar+1,1) += J(ipar+1,1)*(doca_hit-doca_trk)/(docaErr_hit*docaErr_hit*scale);
420 for(
int ipar2=0; ipar2<=ipar; ipar2++)
423 U(ipar+1,ipar2+1)+=J(ipar+1,1)*J(ipar2+1,1)/(docaErr_hit*docaErr_hit*scale);
427 if(debug) cout<<
"end of MDC hits loop"<<endl;
432 vector<const RecCgemCluster*>::iterator iter_cluster = myVecCgemCluster.begin();
433 for(; iter_cluster!=myVecCgemCluster.end(); iter_cluster++, i_digi++)
436 int layer = (*iter_cluster)->getlayerid();
437 int flag = (*iter_cluster)->getflag();
438 if(myUseAxialHitsOnly && flag!=0)
continue;
439 int sheet = (*iter_cluster)->getsheetid();
443 cout<<endl<<
"layer, sheet, flag = "<<setw(5)<<layer<<setw(5)<<sheet<<setw(5)<<flag<<endl;
450 double phi_trk = pos.phi();
451 double z_trk = pos.z();
453 Hep3Vector p3_trk = myHelix->
momentum(dphi);
454 double phi_p3trk = p3_trk.phi();
455 double incidentPhi = phi_p3trk-phi_trk;
456 while(incidentPhi>CLHEP::pi) incidentPhi-=CLHEP::twopi;
457 while(incidentPhi<-CLHEP::pi) incidentPhi+=CLHEP::twopi;
461 double X_CC(0.), V_CC(0.);
462 double delta_m, err_m;
466 Q=(*iter_cluster)->getenergydeposit();
468 phi_CC = (*iter_cluster)->getrecphi();
470 double del_phi = phi_CC-phi_trk;
471 while(del_phi<-
M_PI) del_phi+=2*
M_PI;
472 while(del_phi>
M_PI) del_phi-=2*
M_PI;
473 X_CC=phi_CC*myRmidDGapCgem[layer];
474 if(debug) cout<<
"phi_trk, phi_rec = "<<phi_trk<<
", "<<phi_CC<<endl;
478 err_m=myCgemCalibSvc->
getSigma(layer,flag,mode,incidentPhi,Q,T)/10.;
479 err_m/=myRmidDGapCgem[layer];
480 J_dmdx(1,1)=-1*pos.y()/myR2midDGapCgem[layer];
481 J_dmdx(1,2)=pos.x()/myR2midDGapCgem[layer];
485 double V_trk = readoutPlane->
getVFromPhiZ(phi_trk,z_trk*10,
false)/10.0;
486 V_CC=(*iter_cluster)->getrecv()/10.;
488 if(debug) cout<<
"V_trk, V_rec = "<<V_trk<<
", "<<V_CC<<endl;
490 if(fabs(delta_m)>5) {
499 double delta_m_2=V_CC-V_trk_nearPhiMin;
500 if(fabs(delta_m_2)<fabs(delta_m)) delta_m=delta_m_2;
501 if(debug) cout<<
"V_trk_nearPhiMin= "<<V_trk_nearPhiMin<<endl;
503 err_m=myCgemCalibSvc->
getSigma(layer,flag,mode,incidentPhi,Q,T)/10.;
504 J_dmdx(1,1)=-myRVCgem[layer]*
cos(myAngStereoCgem[layer])*pos.y()/myR2midDGapCgem[layer];
505 J_dmdx(1,2)= myRVCgem[layer]*
cos(myAngStereoCgem[layer])*pos.x()/myR2midDGapCgem[layer];
506 J_dmdx(1,3)= -
sin(myAngStereoCgem[layer]);
509 cout<<
"flag ="<<flag<<
", DotsHelixFitter::calculateNewHelix() is not ready for it!"<<endl;
514 double chi = delta_m/err_m;
515 myChiVecCgemCluster[i_digi]=chi;
517 cout<<
"delta_m, err_m, chi = "<<delta_m<<
", "<<err_m<<
", "<<chi<<endl;
519 for(
int ipar=0; ipar<nPar; ipar++)
523 P(ipar+1,1) += J(ipar+1,1)*chi/err_m;
524 for(
int ipar2=0; ipar2<=ipar; ipar2++)
526 U(ipar+1,ipar2+1)+=J(ipar+1,1)*J(ipar2+1,1)/(err_m*err_m);
531 cout<<
"end of CGEM cluster loop"<<endl;
550 for(
int ipar=0; ipar<nPar; ipar++)
552 myHelix_a[ipar]+=da[ipar];
553 myHelix_aVec[ipar]=myHelix_a[ipar];
555 myHelix->
a(myHelix_aVec);
558 cout<<
"aNew = "<<myHelix_aVec
559 <<
" chi2 = "<<totChi2
567 if(fabs(lastTotChi2-totChi2)<myDchi2Converge) {
569 cout<<
"DotsHelixFitter::calculateNewHelix(): converge after "<<nIterations<<
" iterations"
570 <<
" with lastTotChi2="<<lastTotChi2<<
", totChi2="<<totChi2
579 else if(totChi2-lastTotChi2>myDchi2Diverge) {
581 if(n_chi2_increase>myMaxNChi2Increase||totChi2>myChi2Diverge)
584 if(nIterations>myMaxIteration) {
585 if(debug) cout<<
"DotsHelixFitter::calculateNewHelix(): "<<nIterations
586 <<
" iterations, break with lastTotChi2, totChi2 = "<<lastTotChi2<<
", "<<totChi2<<endl;
595 if(nIterations>myMaxIteration)
return 4;
602 map<double, int> map_abschi_idx;
608 vector<const MdcDigi*>::iterator iter_mdcDigi = myVecMdcDigi.begin();
609 for(; iter_mdcDigi!=myVecMdcDigi.end(); iter_mdcDigi++, i_digi++)
611 if(myMdcDigiIsActive[i_digi])
613 double abs_chi=fabs(myChiVecMdcDigi[i_digi]);
615 if( abs_chi>chi_cut )
620 map_abschi_idx[abs_chi]=i_digi;
625 if(nMax>0&&map_abschi_idx.size()>0)
627 map<double, int>::reverse_iterator it_map;
628 for(it_map=map_abschi_idx.rbegin(); it_map!=map_abschi_idx.rend(); it_map++)
630 myMdcDigiIsActive[it_map->second]=0;
633 if(nDeactive>=nMax)
break;
654 vector<const MdcDigi*>::iterator iter_mdcDigi = myVecMdcDigi.begin();
655 for(; iter_mdcDigi!=myVecMdcDigi.end(); iter_mdcDigi++, i_digi++)
657 if(!myMdcDigiIsActive[i_digi])
659 double abs_chi=fabs(myChiVecMdcDigi[i_digi]);
661 if( abs_chi<chi_cut )
663 myMdcDigiIsActive[i_digi] = 1;
677 vector<const MdcDigi*>::iterator iter_mdcDigi_begin = myVecMdcDigi.begin();
678 map<double, int>::iterator it_map;
680 for(it_map=myMapFlylenIdx.begin(); it_map!=myMapFlylenIdx.end(); it_map++)
683 vector<const MdcDigi*>::iterator iter_mdcDigi = iter_mdcDigi_begin+(it_map->second);
684 if(myMdcDigiIsActive[it_map->second])
686 if(nActive>=nHit_max) myMdcDigiIsActive[it_map->second]=0;
689 if(layer>=layer_max) myMdcDigiIsActive[it_map->second]=0;
690 if(myMdcDigiIsActive[it_map->second]) nActive++;
705 myHelix_aVec = aHelix.
a();
706 if(myHelix!=NULL)
delete myHelix;
709 for(
int i=0; i<5; i++) myHelix_a[i]=myHelix_aVec[i];
722 double tension = 9999.;
724 myWirePos[0]=myEastPosWires[myLayer][myWire][0];
725 myWirePos[1]=myEastPosWires[myLayer][myWire][1];
726 myWirePos[2]=myEastPosWires[myLayer][myWire][2];
727 myWirePos[3]=myWestPosWires[myLayer][myWire][0];
728 myWirePos[4]=myWestPosWires[myLayer][myWire][1];
729 myWirePos[5]=myWestPosWires[myLayer][myWire][2];
730 myWirePos[6]=tension;
741 getDoca(myHelix_a, myWirePos, myDocaFromTrk, myPosOnWire, myPosOnWire[2]);
744 cout<<
"DotsHelixFitter::UpdateDcDigiInfo(): "<<endl;
745 cout<<
"doca = "<<myDocaFromTrk<<endl;
746 cout<<
"point on wire: "<<myPosOnWire[0]<<
", "<<myPosOnWire[1]<<
", "<<myPosOnWire[2]<<endl;
751 HepPoint3D aNewPivot(myPosOnWire[0],myPosOnWire[1],myPosOnWire[2]);
752 aHelix.
pivot(aNewPivot);
753 double newPhi0 = aHelix.
phi0();
754 double dphi = newPhi0-myHelix->
phi0();
757 myFlightLength = fabs(dphi*myHelix->
radius())*sqrt(1+myHelix->
tanl()*myHelix->
tanl());
767 getDoca(myHelix_a, myWirePos, myDocaFromTrk, myPosOnWire, myPosOnWire[2]);
768 double phiWire = atan2(myPosOnWire[1],myPosOnWire[0]);
771 cout<<
"DotsHelixFitter::UpdateDcDigiInfo(): "<<endl;
772 cout<<
"doca = "<<myDocaFromTrk<<endl;
773 cout<<
"point on wire: "<<myPosOnWire[0]<<
", "<<myPosOnWire[1]<<
", "<<myPosOnWire[2]<<endl;
778 HepPoint3D aNewPivot(myPosOnWire[0],myPosOnWire[1],myPosOnWire[2]);
779 aHelix.
pivot(aNewPivot);
780 double newPhi0 = aHelix.
phi0();
781 double dphi = newPhi0-myHelix->
phi0();
784 myFlightLength = fabs(dphi*myHelix->
radius())*sqrt(1+myHelix->
tanl()*myHelix->
tanl());
788 myPosOnTrk[0]=posOnTrk.x();
789 myPosOnTrk[1]=posOnTrk.y();
790 myPosOnTrk[2]=posOnTrk.z();
791 double phiPosOnTrk=atan2(myPosOnTrk[1],myPosOnTrk[0]);
798 myLeftRight=int(myDocaFromTrk/fabs(myDocaFromTrk));
799 signDoca=myLeftRight;
803 if(myLeftRight==1) myLeftRight=0;
805 double dphiLR=phiWire-phiPosOnTrk;
812 if(debug) cout<<
"myLeftRight = "<<myLeftRight<<endl;
815 HepLorentzVector p4_pi = myHelix->
momentum(dphi, 0.13957);
816 double speed = p4_pi.beta()*
CC;
817 double TOF = myFlightLength/speed*1.e9;
821 double tprop = myMdcCalibFunSvc->
getTprop(myLayer, myPosOnWire[2]);
822 double T0Walk = myMdcCalibFunSvc->
getT0(myLayer,myWire) + myMdcCalibFunSvc->
getTimeWalk(myLayer, myCharge);
825 myDriftTime = rawTime - myEventT0 - TOF - T0Walk - tprop;
826 if(debug) cout<<
"driftT = "<<myDriftTime<<endl;
828 double phiP = p4_pi.phi();
829 double entranceAngle = phiP-phiWire;
830 while(entranceAngle<-
M_PI) entranceAngle+=2*
M_PI;
831 while(entranceAngle>
M_PI) entranceAngle-=2*
M_PI;
832 myEntranceAngle = entranceAngle;
834 myDocaFromDigi = 0.1 * myMdcCalibFunSvc->
driftTimeToDist(myDriftTime,myLayer,myWire,myLeftRight,entranceAngle);
835 myDriftDist[myLeftRight]=myDocaFromDigi;
836 myDriftDist[1-myLeftRight]=0.1 * myMdcCalibFunSvc->
driftTimeToDist(myDriftTime,myLayer,myWire,1-myLeftRight,entranceAngle);
838 double docaErr_hit = 0.1 * myMdcCalibFunSvc->
getSigma(myLayer, myLeftRight, myDocaFromDigi, myEntranceAngle, myHelix_a[4], myPosOnWire[2], myCharge);
840 myDriftDistErr[myLeftRight]=docaErr_hit;
841 myDriftDistErr[1-myLeftRight] = 0.1 * myMdcCalibFunSvc->
getSigma(myLayer, 1-myLeftRight, myDocaFromDigi, myEntranceAngle, myHelix_a[4], myPosOnWire[2], myCharge);
844 myDocaFromDigi*=signDoca;
845 if(debug) cout<<
"doca_hit = "<<myDocaFromDigi<<endl;
846 double delD = myDocaFromDigi-myDocaFromTrk;
847 myDcChi = delD/docaErr_hit;
869 double doca=fabs(myDocaFromTrk);
870 if(myLeftRight==0) doca*=-1;
872 aRecMdcHit.
setEntra(myEntranceAngle);
873 aRecMdcHit.
setZhit(myPosOnWire[2]);
887 vector<RecMdcHit> aRecMdcHitVec;
889 vector<const MdcDigi*>::iterator iter_mdcDigi = myVecMdcDigi.begin();
890 for(; iter_mdcDigi!=myVecMdcDigi.end(); iter_mdcDigi++, i_digi++)
892 if(sel==1&&!myMdcDigiIsActive[i_digi])
continue;
895 return aRecMdcHitVec;
901 double m_rad = myHelix->
radius();
902 double l = myHelix->
center().perp();
904 double cosPhi = (m_rad * m_rad + l * l - r * r) / (2 * m_rad * l);
906 if(cosPhi < -1 || cosPhi > 1)
return 0;
908 double dPhi = myHelix->
center().phi() - acos(cosPhi) - myHelix->
phi0();
917 HepMatrix dXDA(3,5,0);
921 double phi0 = a.
phi0();
922 double kappa = a.
kappa();
924 double tanl = a.
tanl();
932 double cosPhi=
cos(phi);
933 double sinPhi=
sin(phi);
935 double dPhiDdr = -(kappa/
alpha-cosPhi/(dr+
alpha/kappa))/sinPhi;
939 double dPhiDkappa = -kappa*(dr*dr-r2)*(2*
alpha+dr*kappa)/(2*
alpha*(
alpha+dr*kappa)*(
alpha+dr*kappa)*sinPhi);
941 double dxDdr =
cos(phi0)+
alpha/kappa*
sin(phi0+phi)*dPhiDdr;
942 double dyDdr =
sin(phi0)-
alpha/kappa*
cos(phi0+phi)*dPhiDdr;
943 double dxDphi0 = -dr*
sin(phi0)+
alpha/kappa*(-
sin(phi0)+
sin(phi0+phi));
944 double dyDphi0 = dr*
cos(phi0)+
alpha/kappa*(
cos(phi0)-
cos(phi0+phi));
945 double dxDkappa = -
alpha/(kappa*kappa)*(
cos(phi0)-
cos(phi0+phi))+
alpha/kappa*
sin(phi0+phi)*dPhiDkappa;
946 double dyDkappa = -
alpha/(kappa*kappa)*(
sin(phi0)-
sin(phi0+phi))-
alpha/kappa*
cos(phi0+phi)*dPhiDkappa;
947 double dzDdr = -
alpha/kappa*tanl*dPhiDdr;
948 double dzDkappa =
alpha/(kappa*kappa)*tanl*phi-
alpha/kappa*tanl*dPhiDkappa;
949 double dzDtanl = -
alpha/kappa*phi;
953 dXDA(1,3) = dxDkappa;
956 dXDA(2,3) = dyDkappa;
958 dXDA(3,3) = dzDkappa;
double sin(const BesAngle a)
double cos(const BesAngle a)
double P(RecMdcKalTrack *trk)
double abs(const EvtComplex &c)
double getMiddleROfGapD() const
double getInnerROfAnodeCu1() const
int getNumberOfSheet() const
double getAngleOfStereo() const
double getInnerROfAnodeCu2() const
double getVFromPhiZ(double phi, double z, bool checkRange=true) const
double getVFromPhiZ_nearPhiMin(double phi, double z, bool checkRange=true) const
CgemGeoLayer * getCgemLayer(int i) const
int getNumberOfCgemLayer() const
CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const
void setInitialHelix(KalmanFit::Helix aHelix)
int deactiveHits(double chi_cut=10, int nMax=1)
void setDChits(vector< const MdcDigi * > aVecMdcDigi, double T0)
void setCgemClusters(vector< const RecCgemCluster * > aVecCgemCluster)
HepMatrix dxda_cgem(KalmanFit::Helix a, double phi)
void calculateDocaFromTrk(const MdcDigi *aDcDigi)
void loadOneDcDigi(const MdcDigi *aDcDigi)
vector< RecMdcHit > makeRecMdcHitVec(int sel=1)
RecMdcHit makeRecMdcHit(const MdcDigi *aDcDigi)
double IntersectCylinder(double r)
void updateDcDigiInfo(const MdcDigi *aDcDigi)
int activeHits(double chi_cut=10)
virtual double getSigma(int layer, int xvFlag, int readoutMode, double angle, double Q, double T) const =0
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
Hep3Vector momentum(double dPhi=0.) const
returns momentum vector after rotating angle dPhi in phi direction.
const HepSymMatrix & Ea(void) const
returns error matrix.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
double radius(void) const
returns radious of helix.
double dr(void) const
returns an element of parameters.
const HepVector & a(void) const
returns helix parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
double getSigma(int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getT0(int layid, int cellid) const
double driftTimeToDist(double drifttime, int layid, int cellid, int lr, double entrance=0.0) const
double getTprop(int lay, double z) const
double getTimeWalk(int layid, double Q) const
double Radius(void) const
double nomShift(void) const
HepPoint3D Forward(void) const
HepPoint3D Backward(void) const
double Tension(void) const
const MdcGeoWire *const Wire(unsigned id)
const MdcGeoLayer *const Layer(unsigned id)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
static double MdcTime(int timeChannel)
virtual Identifier identify() const
unsigned int getChargeChannel() const
unsigned int getTimeChannel() const
void setMdcId(Identifier mdcid)
void setErrDriftDistRight(double erddr)
void setFltLen(double fltLen)
void setErrDriftDistLeft(double erddl)
void setDriftDistLeft(double ddl)
void setDoca(double doca)
void setChisqAdd(double pChisq)
void setZhit(double zhit)
void setDriftT(double driftT)
void setDriftDistRight(double ddr)
void setEntra(double entra)
bool getDeriLoc(int ipar, double helix[], double &deri, double wpos[], double zini)
bool getDoca(double trkpar[], double wpos[], double &doca, double whitPos[], double zini)