1#include "HoughTransAlg/HoughTrack.h"
2#include "TrkBase/TrkExchangePar.h"
3#include "TrkFitter/TrkCircleMaker.h"
4#include "TrkFitter/TrkHelixMaker.h"
5#include "TrkBase/TrkHitList.h"
6#include "MdcData/MdcRecoHitOnTrack.h"
8#include "HoughTransAlg/Hough.h"
9TGraph* HoughTrack::m_cut1_cgem =NULL;
10TGraph* HoughTrack::m_cut2_cgem =NULL;
11TGraph* HoughTrack::m_cut1_ODC1 =NULL;
12TGraph* HoughTrack::m_cut2_ODC1 =NULL;
13TGraph* HoughTrack::m_cut1_ODC2 =NULL;
14TGraph* HoughTrack::m_cut2_ODC2 =NULL;
24 m_charge = (charge>0)?1:-1;
36 m_phi0 = (rho>0)? angle:angle+
M_PI;
37 m_phi0 = (m_charge<0)? m_phi0:m_phi0+
M_PI;
39 if(m_phi0<0) m_phi0+=2*
M_PI;
40 m_kappa = fabs(
m_alpha*rho)*m_charge;
58 m_vecHitResidual.clear();
70 m_cgemHitVector.clear();
86 if(m_angle<0)m_angle=+2*
M_PI;
104 m_vecHitResidual.clear();
105 m_vecHitChi2.clear();
113 m_cgemHitVector.clear();
125 m_charge = (
kappa()>0)? 1:-1;;
130 if(m_angle<0)m_angle=+2*
M_PI;
147 m_vecHitResidual.clear();
148 m_vecHitChi2.clear();
156 m_cgemHitVector.clear();
209 m_vecHitResidual.clear();
210 m_vecHitChi2.clear();
218 m_cgemHitVector.clear();
224 m_trkID(other.m_trkID),
225 m_charge(other.m_charge),
226 m_angle(other.m_angle),
228 m_flag(other.m_flag),
230 m_dAngle(other.m_dAngle),
231 m_dRho(other.m_dRho),
232 m_dTanl(other.m_dTanl),
233 m_dDz(other.m_dTanl),
237 m_kappa(other.m_kappa),
242 m_trkRecoTrk(other.m_trkRecoTrk),
244 m_circleFitStat(other.m_circleFitStat),
245 m_vecHitPnt(other.m_vecHitPnt),
246 m_vecHitResidual(other.m_vecHitResidual),
247 m_vecHitChi2(other.m_vecHitChi2),
248 m_vecStereoHitPnt(other.m_vecStereoHitPnt),
249 m_vecStereoHitRes(other.m_vecStereoHitRes),
250 m_mcTrack(other.m_mcTrack),
251 m_cgemHitVector(other.m_cgemHitVector)
256 if (
this == & other)
return *
this;
259 m_trkID = other.m_trkID;
260 m_charge = other.m_charge;
261 m_angle = other.m_angle;
263 m_flag = other.m_flag;
265 m_dAngle = other.m_dAngle;
266 m_dRho = other.m_dRho;
267 m_dTanl = other.m_dTanl;
268 m_dDz = other.m_dTanl;
271 m_phi0 = other.m_phi0;
272 m_kappa = other.m_kappa;
274 m_tanl = other.m_tanl;
276 m_chi2 = other.m_chi2;
277 m_trkRecoTrk = other.m_trkRecoTrk;
279 m_circleFitStat=other.m_circleFitStat;
280 m_vecHitPnt = other.m_vecHitPnt;
281 m_vecHitResidual = other.m_vecHitResidual;
282 m_vecHitChi2 = other.m_vecHitChi2;
284 m_vecStereoHitPnt = other.m_vecStereoHitPnt;
285 m_vecStereoHitRes = other.m_vecStereoHitRes;
286 m_mcTrack = other.m_mcTrack;
287 m_cgemHitVector = other.m_cgemHitVector;
473 m_nGap=XGapSize(m_setLayer,m_maxGap);
482 bool printFlag(
false);
484 for(vector<HoughHit*>::iterator hitIt = hitList.begin(); hitIt != hitList.end(); hitIt++){
487 if((*hitIt)->getFlag() != 0)
continue;
491 if(printFlag)(*hitIt)->print();
495 int iLayer = (*hitIt)->getLayer();
496 int used = (*hitIt)->getUse();
497 XhitCutWindow(m_rho, iLayer, charge,
cut[0],
cut[1]);
499 HepPoint3D positionOntrack(999,999,999), positionOnDetector(999,999,999);
500 double res2 = (*hitIt)->residual(
this, positionOntrack, positionOnDetector);
503 if(printFlag)cout<<
"res:"<<setw(12)<<res;
505 if(printFlag)cout<<
" win: "<<setw(5)<<
cut[0]<<
" ~ "<<setw(5)<<
cut[1];
507 map<int,double>::iterator it_map;
508 it_map=m_map_lay_d.find(iLayer);
509 if(it_map==m_map_lay_d.end()||fabs(res)<fabs(it_map->second))
511 m_map_lay_d[iLayer]=res;
512 m_map_lay_hit[iLayer]=(*hitIt);
514 if(res>
cut[0]&&res<
cut[1])
516 if(printFlag)cout<<
" selected!";
518 m_vecHitPnt.push_back((*hitIt));
519 m_vecHitResidual.push_back(res);
522 m_setLayer.insert(iLayer);
523 if(used==0) m_untried++;
524 if(used==0||used==-1) m_unused++;
527 if(used<=0) m_nHitUnused_FirstHalf++;
531 if(used<=0) m_nHitUnused_SecondHalf++;
535 if(printFlag)cout<<endl;
585 m_nGap=XGapSize(m_setLayer,m_maxGap);
598 double xCenter =
center().x();
599 double yCenter =
center().y();
600 if(xHit*yCenter > xCenter*yHit)
return m_charge;
601 else if(xHit*yCenter < xCenter*yHit)
return -m_charge;
611 double xCenter =
center().x();
612 double yCenter =
center().y();
613 double leftOrRight = xHit*yCenter - xCenter*yHit;
614 if(leftOrRight>0)
return 1;
624 double xCenter =
center().x();
625 double yCenter =
center().y();
626 double leftOrRight = xHit*yCenter - xCenter*yHit;
627 if(leftOrRight>0)
return 1;
634 double residual(9999.);
640 double distance = (circleCenter-hitPoint).perp();
646 double Rc = fabs(
radius());
651 residual = driftDist-fabs(distance - Rc);
656 double rCgem = hitPoint.perp();
662 double phiCrossPoint = crossPoint.phi();
663 double phiMeasure = hitPoint.phi();
664 residual = phiMeasure - phiCrossPoint;
665 while(residual<-
M_PI)residual += 2*
M_PI;
666 while(residual>
M_PI)residual -= 2*
M_PI;
667 residual = rCgem*residual;
771 if(hit->
getFlag()==0)
return nTangency;
779 if(hit->
getFlag()!=2)
return nTangency;
781 for(vector<HoughHit*>::iterator hotIt = m_vecHitPnt.begin(); hotIt != m_vecHitPnt.end(); hotIt++){
782 if((*hotIt)->getFlag()!=0)
continue;
791 pair<double,double> sz(
s,z);
803 double xEast = eastPoint.x()/10.0;
804 double xWest = westPoint.x()/10.0;
805 double yEast = eastPoint.y()/10.0;
806 double yWest = westPoint.y()/10.0;
807 double zEast = eastPoint.z()/10.0;
808 double zWest = westPoint.z()/10.0;
812 double west2east = sqrt((xEast-xWest)*(xEast-xWest)+(yEast-yWest)*(yEast-yWest));
814 double slope = (yEast-yWest)/(xEast-xWest);
815 double intercept = (yWest-slope*xWest+yEast-slope*xEast)/2;
816 double a = 1+slope*slope;
817 double b = -2*(xc+slope*yc-slope*intercept);
818 double c1 = xc*xc+(yc-intercept)*(yc-intercept)-(rTrack+drift)*(rTrack+drift);
819 double c2 = xc*xc+(yc-intercept)*(yc-intercept)-(rTrack-drift)*(rTrack-drift);
822 double delta1 = (b*b-4*
a*
c1);
823 double delta2 = (b*b-4*
a*c2);
827 double x1 = (-b+sqrt(delta1))/(2*
a);
828 double x2 = (-b-sqrt(delta1))/(2*
a);
829 double y1 = slope*x1+intercept;
830 double y2 = slope*x2+intercept;
831 if((x1-xWest)*(x1-xEast)<0){
835 double l = sqrt((x1-xWest)*(x1-xWest)+(y1-yWest)*(y1-yWest));
836 z = zWest + l/west2east*fabs((zEast-zWest));
837 pair<double,double> sz(
s,z);
844 if((x2-xWest)*(x2-xEast)<0){
848 double l = sqrt((x2-xWest)*(x2-xWest)+(y2-yWest)*(y2-yWest));
849 z = zWest + l/west2east*fabs((zEast-zWest));
850 pair<double,double> sz(
s,z);
860 double x1 = (-b+sqrt(delta2))/(2*
a);
861 double x2 = (-b-sqrt(delta2))/(2*
a);
862 double y1 = slope*x1+intercept;
863 double y2 = slope*x2+intercept;
864 if((x1-xWest)*(x1-xEast)<0){
868 double l = sqrt((x1-xWest)*(x1-xWest)+(y1-yWest)*(y1-yWest));
869 z = zWest + l/west2east*fabs((zEast-zWest));
870 pair<double,double> sz(
s,z);
877 if((x2-xWest)*(x2-xEast)<0){
883 double l = sqrt((x2-xWest)*(x2-xWest)+(y2-yWest)*(y2-yWest));
884 z = zWest + l/west2east*fabs((zEast-zWest));
885 pair<double,double> sz(
s,z);
914 std::sort(hotList.begin(),hotList.end(),
sortByLayer);
920 HepVector hepVector(5,0);
922 hepVector(2) = m_phi0;
923 hepVector(3) = m_kappa;
925 hepVector(5) = m_tanl;
933 m_phi0 = (rho>0)? angle:angle+
M_PI;
934 m_phi0 = (m_charge<0)? m_phi0:m_phi0+
M_PI;
936 if(m_phi0<0) m_phi0+=2*
M_PI;
937 m_kappa = fabs(
m_alpha*rho)*m_charge;
940 HepSymMatrix
Ea(5,0);
959 <<setw(12)<<
"trkID:" <<setw(15)<<m_trkID
960 <<setw(12)<<
"flag:" <<setw(15)<<m_flag
962 <<setw(12)<<
"pt:" <<setw(15)<<
pt()
963 <<setw(12)<<
"angle:" <<setw(15)<<m_angle
964 <<setw(12)<<
"rho:" <<setw(15)<<m_rho
966 <<setw(12)<<
"dr:" <<setw(15)<<
dr()
967 <<setw(12)<<
"phi0:" <<setw(15)<<
phi0()
968 <<setw(12)<<
"kappa:" <<setw(15)<<
kappa()
969 <<setw(12)<<
"dz:" <<setw(15)<<
dz()
970 <<setw(12)<<
"tanl:" <<setw(15)<<
tanl()
992 vector<HoughHit*> hotList;
995 for(vector<HoughHit*>::iterator hotIt = axialHot.begin(); hotIt != axialHot.end(); hotIt++){
999 for(vector<HoughHit*>::iterator hotIt = stereoHot.begin(); hotIt != stereoHot.end(); hotIt++){
1004 <<setw(12)<<
"nHot:" <<setw(15)<<nHot
1005 <<setw(12)<<
"nAxialHot0:" <<setw(15)<<nAxialHot
1006 <<setw(12)<<
"nStereoHot0:" <<setw(15)<<nStereoHot
1007 <<setw(12)<<
"nXCluster0:" <<setw(15)<<nXCluster
1008 <<setw(12)<<
"nXVCluster0:" <<setw(15)<<nXVCluster
1017 for(vector<HoughHit*>::iterator hotIt = hitList.begin(); hotIt != hitList.end();hotIt++){
1112void HoughTrack::XhitCutWindow(
double rho,
int ilayer,
double charge,
double& cut1,
double &cut2)
1114 static bool initialized =
false;
1118 double rho[nPt] = {0.07, 0.056,0.045,0.038,0.0335,0.03,0.0198,0.0148,0.0074,0.00376,0.00303,0.00157};
1119 double cut1_Cgem_99[12]={-2.14,-1.36, -0.6 , -0.46, -0.35, -0.59, -0.32, -0.26, -0.22, -0.21, -0.21, -0.211};
1120 double cut2_Cgem_99[12]={ 0.5 , 1.77, 1.99, 1.94, 1.99, 1.9 , 0.31, 0.27, 0.24, 0.23, 0.23, 0.222};
1121 double cut1_ODC1_99[12]={-1.28,-0.71, -0.58, -0.62, -0.64, -0.68, -0.18, -0.14, -0.11, -0.1 , -0.1 , -0.11 };
1122 double cut2_ODC1_99[12]={ 0.9 , 0.74, 0.42, 0.37, 0.32, 0.37, 0.28, 0.25, 0.24, 0.24, 0.24, 0.23};
1123 double cut1_ODC2_99[12]={ -2.14, -1.25, -1.28, -0.86, -0.47, -0.78, -0.36, -0.44, -0.61, -0.67, -0.64, -0.82 };
1124 double cut2_ODC2_99[12]={ -1.35, 0.55 , 0.53 , 0.83 , 0.85 , 0.83 , 0.38 , 0.55 , 0.49 , 0.46 , 0.49 , 0.4};
1125 m_cut1_cgem =
new TGraph(nPt, rho, cut1_Cgem_99);
1126 m_cut2_cgem =
new TGraph(nPt, rho, cut2_Cgem_99);
1127 m_cut1_ODC1 =
new TGraph(nPt, rho, cut1_ODC1_99);
1128 m_cut2_ODC1 =
new TGraph(nPt, rho, cut2_ODC1_99);
1129 m_cut1_ODC2 =
new TGraph(nPt, rho, cut1_ODC2_99);
1130 m_cut2_ODC2 =
new TGraph(nPt, rho, cut2_ODC2_99);
1135 if(rho>0.07) rho=0.07;
1136 TGraph* g_cut1, *g_cut2;
1141 else if(ilayer<=19) {
1145 else if(ilayer<=42) {
1150 cut1=g_cut1->Eval(rho);
1151 cut2=g_cut2->Eval(rho);
1158 double cut=max(fabs(cut1),fabs(cut2));
1176 m_vecHitPnt.clear();
1177 m_vecHitResidual.clear();
1178 m_vecHitChi2.clear();
1179 m_map_lay_d.clear();
1180 m_map_lay_hit.clear();
1186 m_nHitUnused_FirstHalf=0;
1187 m_nHitUnused_SecondHalf=0;
1193int HoughTrack::XGapSize(std::set<int> aLaySet,
int& gapMax)
1199 vector<int> vec_nGap;
1200 vector<int> vec_layerAfterGap;
1202 int nLayer=aLaySet.size();
1203 if(nLayer<2)
return 0;
1204 std::set<int>::iterator it = aLaySet.begin();
1205 int lastLayer = *it;
1208 for(;it!=aLaySet.end(); it++)
1212 if(iLayer>=8&&iLayer<=19) iLayer=iLayer-5;
1213 if(iLayer>=36&&iLayer<=42) iLayer=iLayer-21;
1226 if(it!=aLaySet.begin()) {
1227 if(iLayer-1-lastLayer>0) {
1229 int aGap = iLayer-1-lastLayer;
1232 vec_nGap.push_back(aGap);
1233 vec_layerAfterGap.push_back(*it);
1234 if(aGap>2) nBigGap++;
1237 iGapmax=vec_nGap.size()-1;
1245 if(nBigGap==1&&nGap/(nGap+nLayer)>0.3) {
1246 vector<double>::iterator it0_res = m_vecHitResidual.begin();
1247 vector<HoughHit*>::iterator iter0 = m_vecHitPnt.begin();
1248 vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
1249 for(;
iter!=m_vecHitPnt.end();
iter++)
1251 int iLayer = (*iter)->getLayer();
1252 if(iLayer>=vec_layerAfterGap[iGapmax])
1377 //double rhit=sqrt(hit_x*hit_x+hit_y*hit_y);
1378 //double phi_hit = atan2(hit_y, hit_x);
1379 //double Rho = rad+trkpar(1);
1380 //double l = fabs(rad+trkpar(1));
1381 //double r_hitCent=sqrt((hit_x-xc)*(hit_x-xc)+(hit_y-yc)*(hit_y-yc));
1382 //double d_trk = fabs(rad)-r_hitCent;
1384 //if(d_trk!=0.0) sign=d_trk/fabs(d_trk);
1385 //double d_measured = (*iter)->getDriftDist();
1386 //dm = sign*d_measured-d_trk;
1389 //err2=(*iter)->getMdcCalibFunSvc()->getSigma(iLayer,2,d_measured*10);// in mm
1390 //err2=err2*err2/100.;// in cm
1392 //if(loc_debug) cout<<" d_measured, d_trk, dm = "<<sign*d_measured<<", "<<d_trk<<", "<<dm;
1394 //HepPoint3D aPivot = pivot();
1395 //Helix aHelix(aPivot, vec_a);
1396 //aHelix.pivot((*iter)->getHitPosition());
1397 //double phi0_new = aHelix.phi0();
1399 //double Phi = phi0_new-phi0;
1400 //while(Phi>M_PI) Phi-=2.0*M_PI;
1401 //while(Phi<-M_PI) Phi+=2.0*M_PI;
1402 //double cosPhi=cos(Phi);
1403 //double sinPhi=sin(Phi);
1404 //if(loc_debug) cout<<" tuning phi = "<<Phi;
1406 //double dc=sqrt(rhit*rhit+Rho*Rho-2.*rhit*Rho*cos(phi_hit-phi0));
1408 //double dDddr = -(Rho-rhit*cos(phi_hit-phi0))/dc;
1409 //double dddphi0 = rhit*Rho*sin(phi_hit-phi0)/dc;
1410 //double dddkappa= -rad/kappa;
1411 //if(rad<0) dddkappa=rad/kappa;
1412 //dddkappa+=rad*(Rho-rhit*cos(phi_hit-phi0))/(kappa*dc);
1419 // --- chi2 for initial trk parameters
1420 double chi2_hit = dm*dm/err2;
1421 if(loc_debug) cout<<", err = "<<sqrt(err2);
1422 if(loc_debug) cout<<", chi2 = "<<chi2_hit<<endl;
1423 chi2_ini+=dm*dm/err2;
1424 // --- for U and ATWdM accumulating
1425 for(int i=1; i<4; i++) {
1426 ATWdM(i)=ATWdM(i)+dm/err2*J(i);
1427 for(int j=1; j<4; j++) {
1428 U(i,j) = U(i,j)+J(i)*J(j)/err2;
1431 // cout<<"finish a hit at layer "<<iLayer<<endl;
1434 HepSymMatrix Uinv = U.inverse(ifail);
1438 cout<<"chi2_ini = "<<chi2_ini<<",chi2/ndof = "<<chi2_ini/(nHits-3)<<endl;
1439 cout<<"dr, phi0, kappa = "<<dr<<", "<<phi0<<", "<<kappa<<endl;
1440 cout<<"a_new = "<<a_new(1)<<", "<<a_new(2)<<", "<<a_new(3)<<endl;
1441 cout<<" CalculateCirclePar end ~~~ "<<endl;
1449 vector<HoughHit*>::iterator
iter = hitPntList.begin();
1450 for(;
iter!=hitPntList.end();
iter++)
1452 int useOld = (*iter)->getUse();
1453 if(use==-1&&useOld>0)
continue;
1454 (*iter)->setUse(use);
1466 vector<double>::iterator it0_res = m_vecHitResidual.begin();
1467 vector<HoughHit*>::iterator iter0 = m_vecHitPnt.begin();
1468 vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
1469 for(;
iter!=m_vecHitPnt.end();
iter++)
1471 int useOld = (*iter)->getUse();
1472 if(use==-1&&useOld>0)
continue;
1473 (*iter)->setUse(use);
1478 vector<double>::iterator it_res = it0_res+(
iter-iter0);
1480 (*iter)->addResid(*it_res);
1489 int NtotLayer = m_setLayer.size();
1491 std::set<int>::iterator it = m_setLayer.begin();
1492 int lastLayer = *it;
1494 int nCgemLayer(0), N_ODC1_nearStereo(0), N_ODC2_nearStereo(0);
1495 for(; it!=m_setLayer.end(); it++)
1497 if((*it)<3) nCgemLayer++;
1498 else if((*it)>=16&&(*it)<=19) N_ODC1_nearStereo++;
1499 else if((*it)>=36&&(*it)<=39) N_ODC2_nearStereo++;
1503 enoughVHits = nCgemLayer>=2
1504 || (nCgemLayer>0 && (N_ODC1_nearStereo>=2 || N_ODC2_nearStereo>=2))
1505 || (N_ODC1_nearStereo>=2 && N_ODC2_nearStereo>=2 && NtotLayer>=8) ;
1509 double r_gap = 1.0*m_nGap/(m_nGap+NtotLayer);
1510 bool smallGap = r_gap<0.3;
1515 good=good && m_unused>=3;
1516 good=good && m_untried>=3;
1517 good=good && (nCgemLayer==3||NtotLayer>3);
1518 good=good && enoughVHits;
1519 good=good && smallGap;
1827 vector<HoughHit*>::iterator it = m_vecHitPnt.begin();
1828 for(; it!=m_vecHitPnt.end(); it++)
1830 (*it)->dropTrkID(m_trkID);
1836 vector<HoughHit*>::iterator it0 = m_vecHitPnt.begin();
1837 vector<HoughHit*>::iterator result = find(m_vecHitPnt.begin(), m_vecHitPnt.end(), aHitPnt);
1838 if(result!=m_vecHitPnt.end()) {
1840 m_vecHitPnt.erase(result);
1841 vector<double>::iterator itRes = m_vecHitResidual.begin()+(result-it0);
1842 if(itRes!=m_vecHitResidual.end()) {
1844 m_vecHitResidual.erase(itRes);
1851 vector<HoughHit*>::iterator it0 = m_vecStereoHitPnt.begin();
1852 vector<HoughHit*>::iterator result = find(m_vecStereoHitPnt.begin(), m_vecStereoHitPnt.end(), aHitPnt);
1853 if(result!=m_vecStereoHitPnt.end()) {
1855 m_vecStereoHitPnt.erase(result);
1862 vector<HoughHit*> hitPnt_cgem[3];
1863 HoughHit* hitPnt_cgem_keep[3]={NULL, NULL, NULL};
1864 double res_cgem_keep[3]={999., 999., 999.};
1865 HoughHit* hitPnt_cgem_resMin[3]={NULL, NULL, NULL};
1866 double res_cgem_min[3]={999., 999., 999.};
1867 vector<HoughHit*>::iterator iter0 = m_vecHitPnt.begin();
1868 vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
1869 vector<double>::iterator itRes = m_vecHitResidual.begin();
1870 for(;
iter!=m_vecHitPnt.end();
iter++)
1872 int iLayer = (*iter)->getLayer();
1874 hitPnt_cgem[iLayer].push_back(*
iter);
1875 int idx =
iter-iter0;
1876 double res = m_vecHitResidual[idx];
1877 vector<double> vecRes = (*iter)->getVecResid();
1878 int nTrk = vecRes.size();
1879 if(nTrk==1&&fabs(res)<fabs(res_cgem_keep[iLayer])) {
1880 res_cgem_keep[iLayer] = res;
1881 hitPnt_cgem_keep[iLayer] = *
iter;
1883 if(fabs(res)<fabs(res_cgem_min[iLayer])) {
1884 res_cgem_min[iLayer] = res;
1885 hitPnt_cgem_resMin[iLayer] = *
iter;
1889 for(
int iLayer=0; iLayer<3; iLayer++)
1891 int nHits = hitPnt_cgem[iLayer].size();
1895 if(hitPnt_cgem_keep[iLayer]!=NULL) hitToKeep = hitPnt_cgem_keep[iLayer];
1896 else hitToKeep = hitPnt_cgem_resMin[iLayer];
1902 for(
int iHit=0; iHit<nHits; iHit++)
1904 HoughHit* aHoughHit = hitPnt_cgem[iLayer][iHit];
1905 if(aHoughHit==hitToKeep)
continue;
1921 vector<HoughHit*> hitPnt_cgem[3];
1922 HoughHit* hitPnt_cgem_resMin[3]={NULL, NULL, NULL};
1923 double res_cgem_min[3]={999., 999., 999.};
1924 vector<HoughHit*>::iterator
iter = m_vecStereoHitPnt.begin();
1925 for(;
iter!=m_vecStereoHitPnt.end();
iter++)
1927 int iLayer = (*iter)->getLayer();
1929 hitPnt_cgem[iLayer].push_back(*
iter);
1930 HepPoint3D positionOntrack(999,999,999), positionOnDetector(999,999,999);
1931 double res = (*iter)->residual(
this, positionOntrack, positionOnDetector);
1932 if(fabs(res)<fabs(res_cgem_min[iLayer])) {
1933 res_cgem_min[iLayer] = res;
1934 hitPnt_cgem_resMin[iLayer] = *
iter;
1938 for(
int iLayer=0; iLayer<3; iLayer++)
1940 int nHits = hitPnt_cgem[iLayer].size();
1943 HoughHit* hitToKeep = hitPnt_cgem_resMin[iLayer];
1944 for(
int iHit=0; iHit<nHits; iHit++)
1946 HoughHit* aHoughHit = hitPnt_cgem[iLayer][iHit];
1947 if(aHoughHit==hitToKeep)
continue;
1959 vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
1960 for(;
iter!=m_vecHitPnt.end();
iter++)
1962 vector<double> vecRes = (*iter)->getVecResid();
1963 int nTrk = vecRes.size();
1964 if(nTrk>1) nShared++;
1971 bool printFlag(
false);
1973 m_vecStereoHitPnt.clear();
1974 for(vector<HoughHit*>::iterator hitIt = hitList.begin(); hitIt != hitList.end(); hitIt++){
2018 int layer = (*hitIt)->getLayer();
2019 int wire = (*hitIt)->getWire();
2020 if((*hitIt)->getFlag() == 0)
continue;
2028 double Pt = fabs(
pt());
2029 double cut[2] = {0};
2031 if(
m_cut[0][layer+3]!=NULL)
cut[0]=
m_cut[0][layer+3]->Eval(Pt);
2032 if(
m_cut[1][layer+3]!=NULL)
cut[1]=
m_cut[1][layer+3]->Eval(Pt);
2037 HepPoint3D positionOntrack(999,999,999), positionOnDetector(999,999,999);
2038 double res = (*hitIt)->residual(
this, positionOntrack, positionOnDetector);
2039 if(
judgeCharge(positionOntrack.x(),positionOntrack.y())*charge<0)
continue;
2040 bool isNewHot(
true);
2041 for(vector<HoughHit*>::iterator hotIt = m_vecStereoHitPnt.begin(); hotIt != m_vecStereoHitPnt.end(); hotIt++){
2042 if((*hitIt)->getHitID() == (*hotIt)->getHitID()){
2052 if(printFlag)(*hitIt)->print();
2053 if(printFlag)cout<<
"res:"<<setw(12)<<res;
2054 if(printFlag)cout<<
" win: "<<setw(5)<<
cut[0]<<
" ~ "<<setw(5)<<
cut[1];
2056 if(ext*
cut[0]<res&&res<ext*
cut[1]){
2057 if((*hitIt)->getLayer()>=maxLayer)
continue;
2058 m_vecStereoHitPnt.push_back(*hitIt);
2059 if(printFlag)cout<<
" selected!";
2085 if(printFlag)cout<<endl;
2098 vector<HoughHit*> hotList;
2102 for(vector<HoughHit*>::iterator hotIt = axialHot.begin(); hotIt != axialHot.end(); hotIt++){
2103 if(type==1)
continue;
2105 hotList.push_back(*hotIt);
2107 for(vector<HoughHit*>::iterator hotIt = stereoHot.begin(); hotIt != stereoHot.end(); hotIt++){
2108 if(type>0)hotList.push_back(*hotIt);
2153 double omega = m_kappa/fabs(
alpha());
2168 TrkRecoTrk* trkRecoTrk = circlefactory.
makeTrack(circleTrk, chisum, *trkContextEv, bunchT0);
2169 bool permitFlips =
true;
2170 bool lPickHits =
true;
2171 circlefactory.
setFlipAndDrop(*trkRecoTrk, permitFlips, lPickHits);
2175 vector<MdcHit*> mdcHitVector;
2176 mdcHitVector.clear();
2177 vector<CgemHitOnTrack*> cgemHitVector;
2178 cgemHitVector.clear();
2180 for(vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
iter != m_vecHitPnt.end();
iter++){
2182 if(hitIt->
getFlag()!=0)
continue;
2187 mdcHitVector.push_back(mdcHit);
2202 cgemHitVector.push_back(cgemHitOnTrack);
2228 while(m_phi0>2.*
M_PI) m_phi0-=2.*
M_PI;
2229 while(m_phi0<0.) m_phi0+=2.*
M_PI;
2242 m_chi2 = fitResult->
chisq();
2252 for(vector<MdcHit*>::iterator
iter = mdcHitVector.begin();
iter != mdcHitVector.end();
iter++){
2255 for(vector<CgemHitOnTrack*>::iterator
iter = cgemHitVector.begin();
iter != cgemHitVector.end();
iter++){
2267 double omega = m_kappa/fabs(
alpha());
2269 double tanl = m_tanl;
2276 m_trkRecoTrk = helixfactory.
makeTrack(helixTrk, chisum, *trkContextEv, bunchT0);
2277 bool permitFlips =
true;
2278 bool lPickHits =
true;
2279 helixfactory.
setFlipAndDrop(*m_trkRecoTrk, permitFlips, lPickHits);
2284 for(vector<HoughHit*>::iterator hitIt = hot.begin(); hitIt != hot.end();hitIt++){
2288 bool sameHit(
false);
2295 if((*hitIt)->getLayer()==layerId && (*hitIt)->getWire()==wireId)sameHit =
true;
2298 if(sameHit)
continue;
2303 vector<MdcHit*>::iterator imdcHit = mdcHitCol.
begin();
2304 for(;imdcHit != mdcHitCol.end();imdcHit++){
2305 if((*imdcHit)->mdcId() == (*hitIt)->getDigi()->identify()){
2311 mdcHit->
setCalibSvc((*hitIt)->getMdcCalibFunSvc());
2316 HepPoint3D midPoint = (*hitIt)->getHitPosition();
2325 bool sameHit(
false);
2332 if((*hitIt)->getCgemCluster()->getclusterid()==clusterid)sameHit =
true;
2335 if(sameHit)
continue;
2338 m_cgemHitVector.push_back(cgemHitOnTrack);
2339 if((*hitIt)->getFlag()==0)
continue;
2382 while(m_phi0>2*
M_PI)m_phi0-=2*
M_PI;
2383 while(m_phi0<0)m_phi0+=2*
M_PI;
2388 m_chi2 = fitResult->
chisq();
2408 double omega = m_kappa/fabs(
alpha());
2410 double tanl = m_tanl;
2419 bool permitFlips =
true;
2420 bool lPickHits =
true;
2421 helixfactory.
setFlipAndDrop(*trkRecoTrk, permitFlips, lPickHits);
2426 vector<MdcHit*> mdcHitVector;
2427 mdcHitVector.clear();
2428 vector<CgemHitOnTrack*> cgemHitVector;
2429 cgemHitVector.clear();
2431 for(vector<HoughHit*>::iterator hitIt = hot.begin(); hitIt != hot.end();hitIt++){
2435 if((*hitIt)->getFlag()!=0&&(*hitIt)->getLayer()>maxLayer)
continue;
2436 bool sameHit(
false);
2443 if((*hitIt)->getLayer()==layerId && (*hitIt)->getWire()==wireId)sameHit =
true;
2446 if(sameHit)
continue;
2448 const MdcDigi* mdcDigi = (*hitIt)->getDigi();
2450 mdcHitVector.push_back(mdcHit);
2452 mdcHit->
setCalibSvc((*hitIt)->getMdcCalibFunSvc());
2457 HepPoint3D midPoint = (*hitIt)->getHitPosition();
2466 bool sameHit(
false);
2473 if((*hitIt)->getCgemCluster()->getclusterid()==clusterid)sameHit =
true;
2476 if(sameHit)
continue;
2479 cgemHitVector.push_back(cgemHitOnTrack);
2480 if((*hitIt)->getFlag()==0)
continue;
2521 while(m_phi0>2*
M_PI)m_phi0-=2*
M_PI;
2522 while(m_phi0<0)m_phi0+=2*
M_PI;
2525 m_chi2 = fitResult->
chisq();
2527 for(vector<MdcHit*>::iterator
iter = mdcHitVector.begin();
iter != mdcHitVector.end();
iter++){
2530 for(vector<CgemHitOnTrack*>::iterator
iter = cgemHitVector.begin();
iter != cgemHitVector.end();
iter++){
2540 for(vector<CgemHitOnTrack*>::iterator
iter = m_cgemHitVector.begin();
iter != m_cgemHitVector.end();
iter++){
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
HepGeom::Point3D< double > HepPoint3D
bool sortByLayer(HoughHit *hit1, HoughHit *hit2)
bool innerLayer(HoughHit hit1, HoughHit hit2)
NTuple::Array< double > m_dz
NTuple::Item< double > m_phi0
NTuple::Item< double > m_chi2
NTuple::Item< double > m_tanl
*********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
void setCgemCalibFunSvc(const CgemCalibFunSvc *svc)
const RecCgemCluster * baseHit() const
void setCgemGeomSvc(const CgemGeomSvc *svc)
double flightLength(HepPoint3D &hit) const
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
void set(const HepPoint3D &pivot, const HepVector &a, const HepSymMatrix &Ea)
sets helix pivot position, parameters, and error matrix.
Helix & operator=(const Helix &)
Copy operator.
double IntersectCylinder(double r) const
const HepSymMatrix & Ea(void) const
returns error matrix.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
double bFieldZ(void) const
double flightArc(HepPoint3D &hit) const
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.
MdcGeomSvc * getMdcGeomSvc() const
const MdcDigi * getDigi() const
const RecCgemCluster * getCgemCluster() const
double getDriftDist() const
MdcCalibFunSvc * getMdcCalibFunSvc() const
HepPoint3D getHitPosition() const
HitType getHitType() const
CgemGeomSvc * getCgemGeomSvc() const
CgemCalibFunSvc * getCgemCalibFunSvc() const
void setResidual(double residual)
void updateCirclePar(double dr, double phi0, double kappa)
int findXHot(vector< HoughHit * > &hitList, int charge)
static int m_useCgemInGlobalFit
double driftDistRes(HoughHit *hit)
void sortHot(vector< HoughHit * > &hotList)
void markUsedHot(vector< HoughHit * > &hitPntList, int use=1)
void dropHitPnt(HoughHit *aHitPnt)
TrkErrCode fitCircle(const MdcDetector *mdcDetector, TrkContextEv *trkContextEv, double bunchT0)
int findVHot(vector< HoughHit * > &hitList, int charge, int maxLayer)
TrkErrCode fitHelix(const MdcDetector *mdcDetector, const BField *bField, double bunchT0, vector< HoughHit * > &hot, int Layer)
int judgeHalf(HoughHit *hit)
void dropRedundentCgemXHits()
vector< HoughHit * > getVecHitPnt()
void update(double angle, double rho)
HoughTrack & operator=(const HoughTrack &other)
vector< HoughHit * > getVecStereoHitPnt()
int judgeCharge(HoughHit *hit)
vector< HoughHit * > getHotList(int type=2)
void dropVHitPnt(HoughHit *aHitPnt)
static TGraph * m_cut[2][43]
int calculateZ_S(HoughHit *hit)
void dropRedundentCgemVHits()
HepPoint3D Forward(void) const
HepPoint3D Backward(void) const
const MdcGeoWire *const Wire(unsigned id)
void setCalibSvc(const MdcCalibFunSvc *calibSvc)
unsigned layernumber() const
unsigned wirenumber() const
void setCountPropTime(const bool count)
const MdcHit * mdcHit() const
int getclusterid(void) const
int getclusterflagb(void) const
virtual double chisq() const =0
virtual TrkExchangePar helix(double fltL) const =0
TrkFundHit::hot_iterator begin() const
hot_iterator begin() const
TrkHitOnTrk * appendHot(const TrkHitOnTrk *theHot)
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