10TGraph* HoughTrack::m_cut1_cgem =NULL;
11TGraph* HoughTrack::m_cut2_cgem =NULL;
12TGraph* HoughTrack::m_cut1_ODC1 =NULL;
13TGraph* HoughTrack::m_cut2_ODC1 =NULL;
14TGraph* HoughTrack::m_cut1_ODC2 =NULL;
15TGraph* HoughTrack::m_cut2_ODC2 =NULL;
25 m_charge = (charge>0)?1:-1;
37 m_phi0 = (rho>0)? angle:angle+
M_PI;
38 m_phi0 = (m_charge<0)? m_phi0:m_phi0+
M_PI;
40 if(m_phi0<0) m_phi0+=2*
M_PI;
41 m_kappa = fabs(
m_alpha*rho)*m_charge;
59 m_vecHitResidual.clear();
71 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),
252 m_vecRecMdcHit(other.m_vecRecMdcHit)
257 if (
this == & other)
return *
this;
260 m_trkID = other.m_trkID;
261 m_charge = other.m_charge;
262 m_angle = other.m_angle;
264 m_flag = other.m_flag;
266 m_dAngle = other.m_dAngle;
267 m_dRho = other.m_dRho;
268 m_dTanl = other.m_dTanl;
272 m_phi0 = other.m_phi0;
273 m_kappa = other.m_kappa;
275 m_tanl = other.m_tanl;
277 m_chi2 = other.m_chi2;
278 m_trkRecoTrk = other.m_trkRecoTrk;
280 m_circleFitStat=other.m_circleFitStat;
281 m_vecHitPnt = other.m_vecHitPnt;
282 m_vecHitResidual = other.m_vecHitResidual;
283 m_vecHitChi2 = other.m_vecHitChi2;
285 m_vecStereoHitPnt = other.m_vecStereoHitPnt;
286 m_vecStereoHitRes = other.m_vecStereoHitRes;
287 m_mcTrack = other.m_mcTrack;
288 m_cgemHitVector = other.m_cgemHitVector;
289 m_vecRecMdcHit = other.m_vecRecMdcHit;
475m_nGap=XGapSize(m_setLayer,m_maxGap);
484 bool printFlag(
false);
486 for(vector<HoughHit*>::iterator hitIt = hitList.begin(); hitIt != hitList.end(); hitIt++){
489 if((*hitIt)->getFlag() != 0)
continue;
493 if(printFlag)(*hitIt)->print();
497 int iLayer = (*hitIt)->getLayer();
498 int used = (*hitIt)->getUse();
499 XhitCutWindow(m_rho, iLayer, charge,
cut[0],
cut[1]);
501 HepPoint3D positionOntrack(999,999,999), positionOnDetector(999,999,999);
502 double res2 = (*hitIt)->residual(
this, positionOntrack, positionOnDetector);
505 if(printFlag)cout<<
"res:"<<setw(12)<<res;
507 if(printFlag)cout<<
" win: "<<setw(5)<<
cut[0]<<
" ~ "<<setw(5)<<
cut[1];
509 map<int,double>::iterator it_map;
510 it_map=m_map_lay_d.find(iLayer);
511 if(it_map==m_map_lay_d.end()||fabs(res)<fabs(it_map->second))
513 m_map_lay_d[iLayer]=res;
514 m_map_lay_hit[iLayer]=(*hitIt);
516 if(res>
cut[0]&&res<
cut[1])
518 if(printFlag)cout<<
" selected!";
520 m_vecHitPnt.push_back((*hitIt));
521 m_vecHitResidual.push_back(res);
524 m_setLayer.insert(iLayer);
525 if(used==0) m_untried++;
526 if(used==0||used==-1) m_unused++;
530 if(used<=0) m_nHitUnused_FirstHalf++;
535 if(used<=0) m_nHitUnused_SecondHalf++;
539 if(printFlag)cout<<endl;
589 m_nGap=XGapSize(m_setLayer,m_maxGap);
602 double xCenter =
center().x();
603 double yCenter =
center().y();
604 if(xHit*yCenter > xCenter*yHit)
return m_charge;
605 else if(xHit*yCenter < xCenter*yHit)
return -m_charge;
615 double xCenter =
center().x();
616 double yCenter =
center().y();
617 double leftOrRight = xHit*yCenter - xCenter*yHit;
618 if(leftOrRight>0)
return 1;
628 double xCenter =
center().x();
629 double yCenter =
center().y();
630 double leftOrRight = xHit*yCenter - xCenter*yHit;
631 if(leftOrRight>0)
return 1;
638 double residual(9999.);
644 double distance = (circleCenter-hitPoint).perp();
650 double Rc = fabs(
radius());
655 residual = driftDist-fabs(distance - Rc);
660 double rCgem = hitPoint.perp();
666 double phiCrossPoint = crossPoint.phi();
667 double phiMeasure = hitPoint.phi();
668 residual = phiMeasure - phiCrossPoint;
669 while(residual<-
M_PI)residual += 2*
M_PI;
670 while(residual>
M_PI)residual -= 2*
M_PI;
671 residual = rCgem*residual;
777 if(hit->
getFlag()==0)
return nTangency;
785 if(hit->
getFlag()!=2)
return nTangency;
787 for(vector<HoughHit*>::iterator hotIt = m_vecHitPnt.begin(); hotIt != m_vecHitPnt.end(); hotIt++){
788 if((*hotIt)->getFlag()!=0)
continue;
797 pair<double,double> sz(
s,z);
809 double xEast = eastPoint.x()/10.0;
810 double xWest = westPoint.x()/10.0;
811 double yEast = eastPoint.y()/10.0;
812 double yWest = westPoint.y()/10.0;
813 double zEast = eastPoint.z()/10.0;
814 double zWest = westPoint.z()/10.0;
818 double west2east = sqrt((xEast-xWest)*(xEast-xWest)+(yEast-yWest)*(yEast-yWest));
820 double slope = (yEast-yWest)/(xEast-xWest);
821 double intercept = (yWest-slope*xWest+yEast-slope*xEast)/2;
822 double a = 1+slope*slope;
823 double b = -2*(xc+slope*yc-slope*intercept);
824 double c1 = xc*xc+(yc-intercept)*(yc-intercept)-(rTrack+drift)*(rTrack+drift);
825 double c2 = xc*xc+(yc-intercept)*(yc-intercept)-(rTrack-drift)*(rTrack-drift);
828 double delta1 = (b*b-4*
a*
c1);
829 double delta2 = (b*b-4*
a*c2);
833 double x1 = (-b+sqrt(delta1))/(2*
a);
834 double x2 = (-b-sqrt(delta1))/(2*
a);
835 double y1 = slope*x1+intercept;
836 double y2 = slope*x2+intercept;
837 if((x1-xWest)*(x1-xEast)<0){
841 double l = sqrt((x1-xWest)*(x1-xWest)+(y1-yWest)*(y1-yWest));
842 z = zWest + l/west2east*fabs((zEast-zWest));
843 pair<double,double> sz(
s,z);
850 if((x2-xWest)*(x2-xEast)<0){
854 double l = sqrt((x2-xWest)*(x2-xWest)+(y2-yWest)*(y2-yWest));
855 z = zWest + l/west2east*fabs((zEast-zWest));
856 pair<double,double> sz(
s,z);
866 double x1 = (-b+sqrt(delta2))/(2*
a);
867 double x2 = (-b-sqrt(delta2))/(2*
a);
868 double y1 = slope*x1+intercept;
869 double y2 = slope*x2+intercept;
870 if((x1-xWest)*(x1-xEast)<0){
874 double l = sqrt((x1-xWest)*(x1-xWest)+(y1-yWest)*(y1-yWest));
875 z = zWest + l/west2east*fabs((zEast-zWest));
876 pair<double,double> sz(
s,z);
883 if((x2-xWest)*(x2-xEast)<0){
889 double l = sqrt((x2-xWest)*(x2-xWest)+(y2-yWest)*(y2-yWest));
890 z = zWest + l/west2east*fabs((zEast-zWest));
891 pair<double,double> sz(
s,z);
920 std::sort(hotList.begin(),hotList.end(),
sortByLayer);
926 HepVector hepVector(5,0);
928 hepVector(2) = m_phi0;
929 hepVector(3) = m_kappa;
931 hepVector(5) = m_tanl;
939 m_phi0 = (rho>0)? angle:angle+
M_PI;
940 m_phi0 = (m_charge<0)? m_phi0:m_phi0+
M_PI;
942 if(m_phi0<0) m_phi0+=2*
M_PI;
943 m_kappa = fabs(
m_alpha*rho)*m_charge;
946 HepSymMatrix
Ea(5,0);
965 <<setw(12)<<
"trkID:" <<setw(15)<<m_trkID
966 <<setw(12)<<
"flag:" <<setw(15)<<m_flag
968 <<setw(12)<<
"pt:" <<setw(15)<<
pt()
969 <<setw(12)<<
"angle:" <<setw(15)<<m_angle
970 <<setw(12)<<
"rho:" <<setw(15)<<m_rho
972 <<setw(12)<<
"dr:" <<setw(15)<<
dr()
973 <<setw(12)<<
"phi0:" <<setw(15)<<
phi0()
974 <<setw(12)<<
"kappa:" <<setw(15)<<
kappa()
975 <<setw(12)<<
"dz:" <<setw(15)<<
dz()
976 <<setw(12)<<
"tanl:" <<setw(15)<<
tanl()
977 <<setw(12)<<
"chi2:" <<setw(15)<<
getChi2()
999 vector<HoughHit*> hotList;
1002 for(vector<HoughHit*>::iterator hotIt = axialHot.begin(); hotIt != axialHot.end(); hotIt++){
1006 for(vector<HoughHit*>::iterator hotIt = stereoHot.begin(); hotIt != stereoHot.end(); hotIt++){
1011 <<setw(12)<<
"nHot:" <<setw(15)<<nHot
1012 <<setw(12)<<
"nAxialHot0:" <<setw(15)<<nAxialHot
1013 <<setw(12)<<
"nStereoHot0:" <<setw(15)<<nStereoHot
1014 <<setw(12)<<
"nXCluster0:" <<setw(15)<<nXCluster
1015 <<setw(12)<<
"nXVCluster0:" <<setw(15)<<nXVCluster
1024 for(vector<HoughHit*>::iterator hotIt = hitList.begin(); hotIt != hitList.end();hotIt++){
1121 cout<<
"HoughTrack::printRecMdcHitVec(): "<<endl;
1122 vector<RecMdcHit>::iterator iter_recMdcHit = m_vecRecMdcHit.begin();
1123 for(; iter_recMdcHit!=m_vecRecMdcHit.end(); iter_recMdcHit++)
1125 Identifier mdcid = iter_recMdcHit->getMdcId();
1128 cout<<
" hit at layer "<<layer<<
" wire "<<wire<<endl;
1132void HoughTrack::XhitCutWindow(
double rho,
int ilayer,
double charge,
double& cut1,
double &cut2)
1134 static bool initialized =
false;
1138 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};
1139 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};
1140 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};
1141 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 };
1142 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};
1143 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 };
1144 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};
1145 m_cut1_cgem =
new TGraph(nPt, rho, cut1_Cgem_99);
1146 m_cut2_cgem =
new TGraph(nPt, rho, cut2_Cgem_99);
1147 m_cut1_ODC1 =
new TGraph(nPt, rho, cut1_ODC1_99);
1148 m_cut2_ODC1 =
new TGraph(nPt, rho, cut2_ODC1_99);
1149 m_cut1_ODC2 =
new TGraph(nPt, rho, cut1_ODC2_99);
1150 m_cut2_ODC2 =
new TGraph(nPt, rho, cut2_ODC2_99);
1155 if(rho>0.07) rho=0.07;
1156 TGraph* g_cut1, *g_cut2;
1161 else if(ilayer<=19) {
1165 else if(ilayer<=42) {
1170 cut1=g_cut1->Eval(rho);
1171 cut2=g_cut2->Eval(rho);
1178 double cut=max(fabs(cut1),fabs(cut2));
1196 m_vecHitPnt.clear();
1197 m_vecHitResidual.clear();
1198 m_vecHitChi2.clear();
1199 m_map_lay_d.clear();
1200 m_map_lay_hit.clear();
1206 m_nHitUnused_FirstHalf=0;
1207 m_nHitUnused_SecondHalf=0;
1213int HoughTrack::XGapSize(std::set<int> aLaySet,
int& gapMax)
1219 vector<int> vec_nGap;
1220 vector<int> vec_layerAfterGap;
1222 int nLayer=aLaySet.size();
1223 if(nLayer<2)
return 0;
1224 std::set<int>::iterator it = aLaySet.begin();
1225 int lastLayer = *it;
1228 for(;it!=aLaySet.end(); it++)
1232 if(iLayer>=8&&iLayer<=19) iLayer=iLayer-5;
1233 if(iLayer>=36&&iLayer<=42) iLayer=iLayer-21;
1246 if(it!=aLaySet.begin()) {
1247 if(iLayer-1-lastLayer>0) {
1249 int aGap = iLayer-1-lastLayer;
1252 vec_nGap.push_back(aGap);
1253 vec_layerAfterGap.push_back(*it);
1254 if(aGap>2) nBigGap++;
1257 iGapmax=vec_nGap.size()-1;
1265 if(nBigGap==1&&nGap/(nGap+nLayer)>0.3) {
1266 vector<double>::iterator it0_res = m_vecHitResidual.begin();
1267 vector<HoughHit*>::iterator iter0 = m_vecHitPnt.begin();
1268 vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
1269 for(;
iter!=m_vecHitPnt.end();
iter++)
1271 int iLayer = (*iter)->getLayer();
1272 if(iLayer>=vec_layerAfterGap[iGapmax])
1397//double rhit=sqrt(hit_x*hit_x+hit_y*hit_y);
1398//double phi_hit = atan2(hit_y, hit_x);
1399//double Rho = rad+trkpar(1);
1400//double l = fabs(rad+trkpar(1));
1401//double r_hitCent=sqrt((hit_x-xc)*(hit_x-xc)+(hit_y-yc)*(hit_y-yc));
1402//double d_trk = fabs(rad)-r_hitCent;
1404//if(d_trk!=0.0) sign=d_trk/fabs(d_trk);
1405//double d_measured = (*iter)->getDriftDist();
1406//dm = sign*d_measured-d_trk;
1409//err2=(*iter)->getMdcCalibFunSvc()->getSigma(iLayer,2,d_measured*10);// in mm
1410//err2=err2*err2/100.;// in cm
1412//if(loc_debug) cout<<" d_measured, d_trk, dm = "<<sign*d_measured<<", "<<d_trk<<", "<<dm;
1414//HepPoint3D aPivot = pivot();
1415//Helix aHelix(aPivot, vec_a);
1416//aHelix.pivot((*iter)->getHitPosition());
1417//double phi0_new = aHelix.phi0();
1419//double Phi = phi0_new-phi0;
1420//while(Phi>M_PI) Phi-=2.0*M_PI;
1421//while(Phi<-M_PI) Phi+=2.0*M_PI;
1422//double cosPhi=cos(Phi);
1423//double sinPhi=sin(Phi);
1424//if(loc_debug) cout<<" tuning phi = "<<Phi;
1426//double dc=sqrt(rhit*rhit+Rho*Rho-2.*rhit*Rho*cos(phi_hit-phi0));
1428//double dDddr = -(Rho-rhit*cos(phi_hit-phi0))/dc;
1429//double dddphi0 = rhit*Rho*sin(phi_hit-phi0)/dc;
1430//double dddkappa= -rad/kappa;
1431//if(rad<0) dddkappa=rad/kappa;
1432//dddkappa+=rad*(Rho-rhit*cos(phi_hit-phi0))/(kappa*dc);
1439// --- chi2 for initial trk parameters
1440double chi2_hit = dm*dm/err2;
1441if(loc_debug) cout<<", err = "<<sqrt(err2);
1442if(loc_debug) cout<<", chi2 = "<<chi2_hit<<endl;
1443chi2_ini+=dm*dm/err2;
1444// --- for U and ATWdM accumulating
1445for(int i=1; i<4; i++) {
1446 ATWdM(i)=ATWdM(i)+dm/err2*J(i);
1447 for(int j=1; j<4; j++) {
1448 U(i,j) = U(i,j)+J(i)*J(j)/err2;
1451// cout<<"finish a hit at layer "<<iLayer<<endl;
1454HepSymMatrix Uinv = U.inverse(ifail);
1458 cout<<"chi2_ini = "<<chi2_ini<<",chi2/ndof = "<<chi2_ini/(nHits-3)<<endl;
1459 cout<<"dr, phi0, kappa = "<<dr<<", "<<phi0<<", "<<kappa<<endl;
1460 cout<<"a_new = "<<a_new(1)<<", "<<a_new(2)<<", "<<a_new(3)<<endl;
1461 cout<<" CalculateCirclePar end ~~~ "<<endl;
1469 vector<HoughHit*>::iterator
iter = hitPntList.begin();
1470 for(;
iter!=hitPntList.end();
iter++)
1472 int useOld = (*iter)->getUse();
1473 if(use==-1&&useOld>0)
continue;
1474 (*iter)->setUse(use);
1486 vector<double>::iterator it0_res = m_vecHitResidual.begin();
1487 vector<HoughHit*>::iterator iter0 = m_vecHitPnt.begin();
1488 vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
1489 for(;
iter!=m_vecHitPnt.end();
iter++)
1491 int useOld = (*iter)->getUse();
1492 if(use==-1&&useOld>0)
continue;
1493 (*iter)->setUse(use);
1498 vector<double>::iterator it_res = it0_res+(
iter-iter0);
1500 (*iter)->addResid(*it_res);
1510 int NtotLayer = m_setLayer.size();
1512 std::set<int>::iterator it = m_setLayer.begin();
1513 int lastLayer = *it;
1515 int nCgemLayer(0), N_ODC1_nearStereo(0), N_ODC2_nearStereo(0);
1516 for(; it!=m_setLayer.end(); it++)
1518 if((*it)<3) nCgemLayer++;
1519 else if((*it)>=16&&(*it)<=19) N_ODC1_nearStereo++;
1520 else if((*it)>=36&&(*it)<=39) N_ODC2_nearStereo++;
1524 enoughVHits = nCgemLayer>=2
1525 || (nCgemLayer>0 && (N_ODC1_nearStereo>=2 || N_ODC2_nearStereo>=2))
1527 || ( (N_ODC1_nearStereo>=2 || N_ODC2_nearStereo>=2) && NtotLayer>=8) ;
1530 double r_gap = 1.0*m_nGap/(m_nGap+NtotLayer);
1531 bool smallGap = r_gap<0.5;
1534 if(!enoughVHits) cout<<
"not enough V hits, ";
1535 if(!smallGap) cout<<
"gap too large 50%, "<<endl;
1536 if(m_unused<3) cout<<
"N_unused = "<<m_unused<<
"<3"<<endl;
1537 if(m_untried<3) cout<<
"N_untried = "<<m_untried<<
"<3"<<endl;
1542 good=good && m_unused>=2;
1543 good=good && m_untried>=2;
1544 good=good && (nCgemLayer==3||NtotLayer>3);
1545 good=good && enoughVHits;
1546 good=good && smallGap;
1854 vector<HoughHit*>::iterator it = m_vecHitPnt.begin();
1855 for(; it!=m_vecHitPnt.end(); it++)
1857 (*it)->dropTrkID(m_trkID);
1863 vector<HoughHit*>::iterator it0 = m_vecHitPnt.begin();
1864 vector<HoughHit*>::iterator result = find(m_vecHitPnt.begin(), m_vecHitPnt.end(), aHitPnt);
1865 if(result!=m_vecHitPnt.end()) {
1867 m_vecHitPnt.erase(result);
1868 vector<double>::iterator itRes = m_vecHitResidual.begin()+(result-it0);
1869 if(itRes!=m_vecHitResidual.end()) {
1871 m_vecHitResidual.erase(itRes);
1878 vector<HoughHit*>::iterator it0 = m_vecStereoHitPnt.begin();
1879 vector<HoughHit*>::iterator result = find(m_vecStereoHitPnt.begin(), m_vecStereoHitPnt.end(), aHitPnt);
1880 if(result!=m_vecStereoHitPnt.end()) {
1882 m_vecStereoHitPnt.erase(result);
1889 vector<HoughHit*> hitPnt_cgem[3];
1890 HoughHit* hitPnt_cgem_keep[3]={NULL, NULL, NULL};
1891 double res_cgem_keep[3]={999., 999., 999.};
1892 HoughHit* hitPnt_cgem_resMin[3]={NULL, NULL, NULL};
1893 double res_cgem_min[3]={999., 999., 999.};
1894 vector<HoughHit*>::iterator iter0 = m_vecHitPnt.begin();
1895 vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
1896 vector<double>::iterator itRes = m_vecHitResidual.begin();
1897 for(;
iter!=m_vecHitPnt.end();
iter++)
1899 int iLayer = (*iter)->getLayer();
1901 hitPnt_cgem[iLayer].push_back(*
iter);
1902 int idx =
iter-iter0;
1903 double res = m_vecHitResidual[idx];
1904 vector<double> vecRes = (*iter)->getVecResid();
1905 int nTrk = vecRes.size();
1906 if(nTrk==1&&fabs(res)<fabs(res_cgem_keep[iLayer])) {
1907 res_cgem_keep[iLayer] = res;
1908 hitPnt_cgem_keep[iLayer] = *
iter;
1910 if(fabs(res)<fabs(res_cgem_min[iLayer])) {
1911 res_cgem_min[iLayer] = res;
1912 hitPnt_cgem_resMin[iLayer] = *
iter;
1916 for(
int iLayer=0; iLayer<3; iLayer++)
1918 int nHits = hitPnt_cgem[iLayer].size();
1922 if(hitPnt_cgem_keep[iLayer]!=NULL) hitToKeep = hitPnt_cgem_keep[iLayer];
1923 else hitToKeep = hitPnt_cgem_resMin[iLayer];
1929 for(
int iHit=0; iHit<nHits; iHit++)
1931 HoughHit* aHoughHit = hitPnt_cgem[iLayer][iHit];
1932 if(aHoughHit==hitToKeep)
continue;
1948 vector<HoughHit*> hitPnt_cgem[3];
1949 HoughHit* hitPnt_cgem_resMin[3]={NULL, NULL, NULL};
1950 double res_cgem_min[3]={999., 999., 999.};
1951 vector<HoughHit*>::iterator
iter = m_vecStereoHitPnt.begin();
1952 for(;
iter!=m_vecStereoHitPnt.end();
iter++)
1954 int iLayer = (*iter)->getLayer();
1956 hitPnt_cgem[iLayer].push_back(*
iter);
1957 HepPoint3D positionOntrack(999,999,999), positionOnDetector(999,999,999);
1958 double res = (*iter)->residual(
this, positionOntrack, positionOnDetector);
1959 if(fabs(res)<fabs(res_cgem_min[iLayer])) {
1960 res_cgem_min[iLayer] = res;
1961 hitPnt_cgem_resMin[iLayer] = *
iter;
1965 for(
int iLayer=0; iLayer<3; iLayer++)
1967 int nHits = hitPnt_cgem[iLayer].size();
1970 HoughHit* hitToKeep = hitPnt_cgem_resMin[iLayer];
1971 for(
int iHit=0; iHit<nHits; iHit++)
1973 HoughHit* aHoughHit = hitPnt_cgem[iLayer][iHit];
1974 if(aHoughHit==hitToKeep)
continue;
1986 vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
1987 for(;
iter!=m_vecHitPnt.end();
iter++)
1989 vector<double> vecRes = (*iter)->getVecResid();
1990 int nTrk = vecRes.size();
1991 if(nTrk>1) nShared++;
1998 bool printFlag(
false);
2000 m_vecStereoHitPnt.clear();
2001 for(vector<HoughHit*>::iterator hitIt = hitList.begin(); hitIt != hitList.end(); hitIt++){
2045 int layer = (*hitIt)->getLayer();
2046 int wire = (*hitIt)->getWire();
2047 if((*hitIt)->getFlag() == 0)
continue;
2055 double Pt = fabs(
pt());
2056 double cut[2] = {0};
2058 if(
m_cut[0][layer+3]!=NULL)
cut[0]=
m_cut[0][layer+3]->Eval(Pt);
2059 if(
m_cut[1][layer+3]!=NULL)
cut[1]=
m_cut[1][layer+3]->Eval(Pt);
2064 HepPoint3D positionOntrack(999,999,999), positionOnDetector(999,999,999);
2065 double res = (*hitIt)->residual(
this, positionOntrack, positionOnDetector);
2066 if(
judgeCharge(positionOntrack.x(),positionOntrack.y())*charge<0)
continue;
2067 bool isNewHot(
true);
2068 for(vector<HoughHit*>::iterator hotIt = m_vecStereoHitPnt.begin(); hotIt != m_vecStereoHitPnt.end(); hotIt++){
2069 if((*hitIt)->getHitID() == (*hotIt)->getHitID()){
2079 if(printFlag)(*hitIt)->print();
2080 if(printFlag)cout<<
"res:"<<setw(12)<<res;
2081 if(printFlag)cout<<
" win: "<<setw(5)<<
cut[0]<<
" ~ "<<setw(5)<<
cut[1];
2082 double ext=cutFactor;
2083 if(ext*
cut[0]<res&&res<ext*
cut[1]){
2084 if((*hitIt)->getLayer()>=maxLayer)
2089 m_vecStereoHitPnt.push_back(*hitIt);
2090 if(printFlag)cout<<
" selected!";
2116 if(printFlag)cout<<endl;
2129 vector<HoughHit*> hotList;
2133 for(vector<HoughHit*>::iterator hotIt = axialHot.begin(); hotIt != axialHot.end(); hotIt++){
2134 if(type==1)
continue;
2136 hotList.push_back(*hotIt);
2138 for(vector<HoughHit*>::iterator hotIt = stereoHot.begin(); hotIt != stereoHot.end(); hotIt++){
2139 if(type>0)hotList.push_back(*hotIt);
2187 double omega = m_kappa/fabs(
alpha());
2202 TrkRecoTrk* trkRecoTrk = circlefactory.
makeTrack(circleTrk, chisum, *trkContextEv, bunchT0);
2203 bool permitFlips =
true;
2204 bool lPickHits =
true;
2205 circlefactory.
setFlipAndDrop(*trkRecoTrk, permitFlips, lPickHits);
2209 vector<MdcHit*> mdcHitVector;
2210 mdcHitVector.clear();
2211 vector<CgemHitOnTrack*> cgemHitVector;
2212 cgemHitVector.clear();
2214 for(vector<HoughHit*>::iterator
iter = m_vecHitPnt.begin();
iter != m_vecHitPnt.end();
iter++){
2216 if(hitIt->
getFlag()!=0)
continue;
2221 mdcHitVector.push_back(mdcHit);
2236 cgemHitVector.push_back(cgemHitOnTrack);
2262 while(m_phi0>2.*
M_PI) m_phi0-=2.*
M_PI;
2263 while(m_phi0<0.) m_phi0+=2.*
M_PI;
2276 m_chi2 = fitResult->
chisq();
2277 if(debug) cout<<
"chi2 obtained "<<m_chi2<<endl;
2296 if(!(recoHot->
isActive()))
continue;
2307 if(stat==0)
continue;
2312 if(debug) cout<<nHotKept<<
" hits kept after TrkFitter"<<endl;
2314 for(vector<MdcHit*>::iterator
iter = mdcHitVector.begin();
iter != mdcHitVector.end();
iter++){
2317 for(vector<CgemHitOnTrack*>::iterator
iter = cgemHitVector.begin();
iter != cgemHitVector.end();
iter++){
2329 m_vecMdcDigiPnt.clear();
2330 m_vecCgemClusterPnt.clear();
2331 for(vector<HoughHit*>::iterator hotIt = m_vecHitPnt.begin(); hotIt != m_vecHitPnt.end(); hotIt++)
2333 if((*hotIt)->getFlag()!=0)
continue;
2336 const MdcDigi* aMdcDigi = (*hotIt)->getDigi();
2337 m_vecMdcDigiPnt.push_back(aMdcDigi);
2341 const RecCgemCluster* aRecCgemCluster = (*hotIt)->getCgemCluster();
2342 m_vecCgemClusterPnt.push_back(aRecCgemCluster);
2350 HepSymMatrix
Ea(5,0);
2353 double phi0_Hough = (m_rho>0)? m_angle:m_angle+
M_PI;
2354 phi0_Hough = (m_charge<0)? phi0_Hough:phi0_Hough+
M_PI;
2355 if(phi0_Hough>2*
M_PI)phi0_Hough-=2*
M_PI;
2356 if(phi0_Hough<0) phi0_Hough+=2*
M_PI;
2357 double kappa_Hough = fabs(
m_alpha*m_rho)*m_charge;
2368 if(debug) cout<<
"circle ini_helix: "<<ini_helix.
a()<<endl;
2370 fitter->
setDChits(m_vecMdcDigiPnt, bunchT0);
2372 if(debug) cout<<
"finish DotsHelixFitter setting"<<endl;
2383 HepVector a_new = fitter->
getHelix();
2384 if(debug) cout<<
"circle helix from DotsHelixFitter: "<<a_new<<
", chi2="<<fitter->
getChi2()<<
" "<<fitter->
getNActiveHits()<<
" hits kept"<<endl;
2388 if(debug) cout<<
"too large chi2, drop one worst DC hit!"<<endl;
2394 if(debug) cout<<
"DotsHelixFitter failed, fitFlag = "<<fitFlag<<endl;
2407 double omega = m_kappa/fabs(
alpha());
2409 double tanl = m_tanl;
2416 m_trkRecoTrk = helixfactory.
makeTrack(helixTrk, chisum, *trkContextEv, bunchT0);
2417 bool permitFlips =
true;
2418 bool lPickHits =
true;
2419 helixfactory.
setFlipAndDrop(*m_trkRecoTrk, permitFlips, lPickHits);
2424 for(vector<HoughHit*>::iterator hitIt = hot.begin(); hitIt != hot.end();hitIt++){
2428 bool sameHit(
false);
2435 if((*hitIt)->getLayer()==layerId && (*hitIt)->getWire()==wireId)sameHit =
true;
2438 if(sameHit)
continue;
2443 vector<MdcHit*>::iterator imdcHit = mdcHitCol.
begin();
2444 for(;imdcHit != mdcHitCol.end();imdcHit++){
2445 if((*imdcHit)->mdcId() == (*hitIt)->getDigi()->identify()){
2451 mdcHit->
setCalibSvc((*hitIt)->getMdcCalibFunSvc());
2456 HepPoint3D midPoint = (*hitIt)->getHitPosition();
2465 bool sameHit(
false);
2472 if((*hitIt)->getCgemCluster()->getclusterid()==clusterid)sameHit =
true;
2475 if(sameHit)
continue;
2478 m_cgemHitVector.push_back(cgemHitOnTrack);
2479 if((*hitIt)->getFlag()==0)
continue;
2522 while(m_phi0>2*
M_PI)m_phi0-=2*
M_PI;
2523 while(m_phi0<0)m_phi0+=2*
M_PI;
2528 m_chi2 = fitResult->
chisq();
2549 double omega = m_kappa/fabs(
alpha());
2551 double tanl = m_tanl;
2560 bool permitFlips =
true;
2561 bool lPickHits =
true;
2562 helixfactory.
setFlipAndDrop(*trkRecoTrk, permitFlips, lPickHits);
2567 vector<MdcHit*> mdcHitVector;
2568 mdcHitVector.clear();
2569 vector<CgemHitOnTrack*> cgemHitVector;
2570 cgemHitVector.clear();
2572 for(vector<HoughHit*>::iterator hitIt = hot.begin(); hitIt != hot.end();hitIt++){
2576 if((*hitIt)->getFlag()!=0&&(*hitIt)->getLayer()>maxLayer)
continue;
2577 bool sameHit(
false);
2584 if((*hitIt)->getLayer()==layerId && (*hitIt)->getWire()==wireId)sameHit =
true;
2587 if(sameHit)
continue;
2589 const MdcDigi* mdcDigi = (*hitIt)->getDigi();
2591 mdcHitVector.push_back(mdcHit);
2593 mdcHit->
setCalibSvc((*hitIt)->getMdcCalibFunSvc());
2598 HepPoint3D midPoint = (*hitIt)->getHitPosition();
2607 bool sameHit(
false);
2614 if((*hitIt)->getCgemCluster()->getclusterid()==clusterid)sameHit =
true;
2617 if(sameHit)
continue;
2620 cgemHitVector.push_back(cgemHitOnTrack);
2621 if((*hitIt)->getFlag()==0)
continue;
2663 while(m_phi0>2*
M_PI)m_phi0-=2*
M_PI;
2664 while(m_phi0<0)m_phi0+=2*
M_PI;
2666 m_chi2 = fitResult->
chisq();
2675 if(!(recoHot->
isActive()))
continue;
2686 if(stat==0)
continue;
2692 cout<<
"chi2= "<<m_chi2
2693 <<
", "<<nHotKept<<
" hits kept after TrkFitter"
2694 <<
", helix from TrkFitter = "<<
a()
2697 for(vector<MdcHit*>::iterator
iter = mdcHitVector.begin();
iter != mdcHitVector.end();
iter++){
2700 for(vector<CgemHitOnTrack*>::iterator
iter = cgemHitVector.begin();
iter != cgemHitVector.end();
iter++){
2713 m_vecMdcDigiPnt.clear();
2714 m_vecCgemClusterPnt.clear();
2715 for(vector<HoughHit*>::iterator hotIt = m_vecHitPnt.begin(); hotIt != m_vecHitPnt.end(); hotIt++)
2720 const MdcDigi* aMdcDigi = (*hotIt)->getDigi();
2721 m_vecMdcDigiPnt.push_back(aMdcDigi);
2725 const RecCgemCluster* aRecCgemCluster = (*hotIt)->getCgemCluster();
2726 m_vecCgemClusterPnt.push_back(aRecCgemCluster);
2729 for(vector<HoughHit*>::iterator hotIt = m_vecStereoHitPnt.begin(); hotIt != m_vecStereoHitPnt.end(); hotIt++)
2733 const MdcDigi* aMdcDigi = (*hotIt)->getDigi();
2734 m_vecMdcDigiPnt.push_back(aMdcDigi);
2738 const RecCgemCluster* aRecCgemCluster = (*hotIt)->getCgemCluster();
2739 if(aRecCgemCluster->
getflag()==2)
2742 RecCgemClusterCol::iterator cgemClusterIter = recCgemClusterColBegin+clusterId;
2744 if(clusterId==(*cgemClusterIter)->getclusterid())
2745 m_vecCgemClusterPnt.push_back(*cgemClusterIter);
2755 HepSymMatrix aEa(5,0);
2762 if(debug) cout<<
"fitHelix ini_helix: "<<ini_helix.
a()<<endl;
2764 fitter->
setDChits(m_vecMdcDigiPnt, bunchT0);
2766 int nMdcDigi = m_vecMdcDigiPnt.size();
2776 HepVector a_new = fitter->
getHelix();
2778 cout<<
"helix from DotsHelixFitter: "<<a_new<<
", chi2="<<fitter->
getChi2()<<
" "<<fitter->
getNActiveHits()<<
" hits kept"<<endl;
2779 cout<<
"nMdcDigi = "<<nMdcDigi<<endl;
2785 if(debug) cout<<
"too large chi2, drop the outmost DC hit!"<<endl;
2790 if(debug) cout<<
"stop droping hit! "<<endl;
2796 if(debug) cout<<
"DotsHelixFitter failed, fitFlag = "<<fitFlag<<endl;
2816 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)
*********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
NTuple::Array< double > m_dz
NTuple::Item< double > m_phi0
NTuple::Item< double > m_chi2
NTuple::Item< double > m_tanl
void setCgemCalibFunSvc(const CgemCalibFunSvc *svc)
const RecCgemCluster * baseHit() const
void setCgemGeomSvc(const CgemGeomSvc *svc)
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)
const HepSymMatrix & getEa()
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)
int findVHot(vector< HoughHit * > &hitList, int charge, int maxLayer, double cutFactor=1.0)
void markUsedHot(vector< HoughHit * > &hitPntList, int use=1)
void dropHitPnt(HoughHit *aHitPnt)
TrkErrCode fitCircle(const MdcDetector *mdcDetector, TrkContextEv *trkContextEv, double bunchT0)
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()
int fitHelix(DotsHelixFitter *fitter, double bunchT0, RecCgemClusterCol::iterator recCgemClusterColBegin, double averageChi2cut=25)
const HepVector & a(void) const
returns helix parameters.
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)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
const MdcHit * mdcHit() const
int getclusterid(void) const
int getclusterflagb(void) const
int getclusterflage(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