16#include <CLHEP/Vector/ThreeVector.h>
17#include <CLHEP/Geometry/Point3D.h>
19#include "MucRecEvent/RecMucTrack.h"
20#include "MucRecEvent/MucTrackParameter.h"
21#include "MucRecEvent/MucRec2DRoad.h"
22#include "MucRecEvent/MucRec3DRoad.h"
23#include "MucGeomSvc/MucConstant.h"
29 m_MdcPos(0.0, 0.0, 0.0),
30 m_MdcMomentum(0.0, 0.0, 0.0),
31 m_MucPos(0.0, 0.0, 0.0),
32 m_MucPosSigma(0.0, 0.0, 0.0),
33 m_MucMomentum(0.0, 0.0, 0.0),
34 m_CurrentPos(0.0, 0.0, 0.0),
35 m_CurrentDir(0.0, 0.0, 0.0),
36 m_CurrentInsct(0.0, 0.0, 0.0),
44 for(
int igap = 0; igap < 9; igap++){
45 m_IntersectionInner[igap].set(-9999,-9999,-9999);
46 m_IntersectionOuter[igap].set(-9999,-9999,-9999);
87 if (
this != &orig ) {
89 m_ExtTrackID = orig.m_ExtTrackID;
90 m_MdcPos = orig.m_MdcPos;
91 m_MdcMomentum = orig.m_MdcMomentum;
92 m_MucPos = orig.m_MucPos;
93 m_MucPosSigma = orig.m_MucPosSigma;
94 m_MucMomentum = orig.m_MucMomentum;
95 m_CurrentPos = orig.m_CurrentPos;
96 m_CurrentDir = orig.m_CurrentDir;
97 m_CurrentInsct = orig.m_CurrentInsct;
113 m_pHits = orig.m_pHits;
114 m_pExpectedHits = orig.m_pExpectedHits;
115 m_Intersections = orig.m_Intersections;
116 m_Directions = orig.m_Directions;
120 m_changeUnit = orig.m_changeUnit;
121 m_recmode = orig.m_recmode;
136 m_ExtTrackID (source.m_ExtTrackID),
137 m_MdcPos (source.m_MdcPos),
138 m_MdcMomentum (source.m_MdcMomentum),
139 m_MucPos (source.m_MucPos),
140 m_MucPosSigma (source.m_MucPosSigma),
141 m_MucMomentum (source.m_MucMomentum),
142 m_CurrentPos (source.m_CurrentPos),
143 m_CurrentDir (source.m_CurrentDir),
144 m_CurrentInsct (source.m_CurrentInsct),
145 m_pHits (source.m_pHits),
146 m_pExpectedHits(source.m_pExpectedHits),
147 m_Intersections(source.m_Intersections),
148 m_Directions (source.m_Directions)
168 m_changeUnit = source.m_changeUnit;
169 m_recmode = source.m_recmode;
189 DstMucTrack::operator=(dstTrack);
195 m_brFirstLayer = -99;
196 m_ecFirstLayer = -99;
203for(
int i = 0 ; i < m_pExpectedHits.size(); i++)
204 delete m_pExpectedHits[i];
223 m_MdcPos.set(
x*10, y*10, z*10);
231 m_MdcMomentum.set(
px*1000,
py*1000,
pz*1000);
239 m_MucPos.set(
x*10, y*10, z*10);
250 m_MucPosSigma.set(
x*10, y*10, z*10);
261 m_MucMomentum.set(
px*1000,
py*1000,
pz*1000);
272 m_ExtMucPos.set(
x*10, y*10, z*10);
280 m_ExtMucMomentum.set(
px*1000,
py*1000,
pz*1000);
288 m_CurrentPos.set(
x*10, y*10, z*10);
296 m_CurrentDir.set(
x*1000, y*1000, z*1000);
304 m_CurrentInsct.set(
x, y, z);
316 m_ExtTrack = extTrack;
317 if (m_ExtTrack) m_ExtTrackID = extTrack->
GetTrackId();
325 for(
int i = 0 ; i < pHits.size(); i++)
326 m_vecHits.push_back((pHits[i]->GetID()).get_value());
332 for(
int i = 0 ; i < pHits.size(); i++)
333 m_expHits.push_back((pHits[i]->GetID()).get_value());
338 Hep3Vector &mucStartPos, Hep3Vector &mucStartMomentum)
343 mdcStartMomentum*=1000;
347 Hep3Vector pt = mdcStartMomentum;
350 double radius = (pt.mag() * 1e6 /
kvC * 1e3) / (fabs(charge *
kMagnetField)) ;
356 mucStartPos = mdcStartPos;
357 mucStartMomentum = mdcStartMomentum;
361 phi = mucStartMomentum.getPhi() +
deltaPhi;
362 mucStartPos.setX(mucStartPos.x() + radius *
kDeltaPhi *
cos(phi));
363 mucStartPos.setY(mucStartPos.y() + radius *
kDeltaPhi *
sin(phi));
364 mucStartPos.setZ(mucStartPos.z() + deltaZ);
366 mucStartMomentum.setPhi(mucStartMomentum.phi() +
deltaPhi);
374 mucStartMomentum/=1000;
397 cout <<
"RecMucTrack::AttachHit-E1 null hit pointer!" << endl;
401 int part = hit->
Part();
402 int gap = hit->
Gap();
405 cout <<
"Muc2DRoad::AttachHit(MucRecHit*), bad gap number = " << gap
411 m_pHits.push_back(hit);
423 float& x,
float& y,
float& z,
427 x = 0.0; y = 0.0; z = 0.0;
430 cout <<
"Muc2DRoad::Project(), invalid gap = " << gap << endl;
435 Hep3Vector dir = m_CurrentDir;
438 if( insctCon.size() == 0 ) {
456 phi = acos(
x/sqrt(
x*
x+y*y));
457 if(y < 0) phi = 2.0*
kPi - phi;
458 phi = fmod((phi +
kPi/8.0), 2.0*
kPi);
459 seg = int(phi/(
kPi/4.0));
486 cout <<
"RecMucTrack:GetHitDistance-E1 null hit pointer!" << endl;
490 int part = hit->
Part();
491 int gap = hit->
Gap();
493 cout <<
"RecMucTrack::GetHitDistance() bad gap number = " << gap << endl;
503 if(orient == 1)
distance = fabs(posInsctLocal.x() - posHitLocal.x());
504 if(orient == 0)
distance = fabs(posInsctLocal.y() - posHitLocal.y());
514 cout <<
"RecMucTrack:GetHitDistance-E1 null hit pointer!" << endl;
518 int part = hit->
Part();
519 int gap = hit->
Gap();
521 cout <<
"RecMucTrack::GetHitDistance() bad gap number = " << gap << endl;
531 if(orient == 1)
distance = (posInsctLocal.x() - posHitLocal.x());
532 if(orient == 0)
distance = (posInsctLocal.y() - posHitLocal.y());
547 for(
int i = 0; i < (int)m_pHits.size(); i++) {
549 if(aHit->
Part() == part &&
550 aHit->
Seg() == seg &&
551 aHit->
Gap() == gap) {
555 int nHitInGap = hitSeq.size();
563 for(
int i = 0; i < nHitInGap; i++)
x.push_back(0);
564 float xInsct = 0, xNewInsct = 0;
567 int orient = gapPtr->
Orient();
568 if(orient == 1) xInsct = insctLocal.x();
569 if(orient == 0) xInsct = insctLocal.y();
571 for(
int i = 0; i < nHitInGap; i++) {
572 float xStrip, yStrip, zStrip;
573 (m_pHits[hitSeq[i]])->GetStrip()->GetCenterPos(xStrip, yStrip, zStrip);
574 if(orient == 1)
x[i] = xStrip;
575 if(orient == 0)
x[i] = yStrip;
584 for(
int i = 0; i < nHitInGap; i++) {
591 newInsctLocal.setX(xNewInsct);
592 newInsctLocal.setY(insctLocal.y());
595 newInsctLocal.setX(insctLocal.x());
596 newInsctLocal.setY(xNewInsct);
604 return m_CurrentInsct;
610 m_Intersections.push_back(insct);
616 m_Directions.push_back(dir);
623 m_CurrentDir = m_CurrentInsct - m_CurrentPos;
624 m_CurrentDir.setMag(1.0);
631 m_CurrentPos = m_CurrentInsct;
637 int lastGap1, lastGap2;
638 int firstGap1, firstGap2;
639 lastGap1 = lastGap2 = -1;
640 firstGap1 = firstGap2 = 99;
641 vector<MucRecHit*>::const_iterator iHit;
642 iHit = m_pHits.begin();
643 for( ;iHit != m_pHits.end(); iHit++)
647 int part = (*iHit)->Part();
648 int gap = (*iHit)->Gap();
651 if(gap > lastGap1) lastGap1 = gap;
652 if(gap < firstGap1) firstGap1 = gap;
655 if(gap > lastGap2) { m_ecPart = part;
m_endPart = part; lastGap2 = gap; }
656 if(gap < firstGap2) firstGap2 = gap;
662 if(firstGap1 == 99) m_brFirstLayer = -1;
663 else if(firstGap1>=0&&firstGap1<9) m_brFirstLayer = firstGap1;
666 if(firstGap2 == 99) m_ecFirstLayer = -1;
667 else if(firstGap2>=0&&firstGap2<8) m_ecFirstLayer = firstGap2;
676 m_depth = m_depth_3 = -99;
return 0;
679 m_depth = m_depth_3 = 0;
return 0;
684 float brThickness = 0.0;
float ecThickness = 0.0;
float deltaPhi = 0.0;
687 float phi = m_MucMomentum.phi();
688 float theta = m_MucMomentum.theta();
690 vector<MucRecHit*>::const_iterator iHit;
694 int Seg[9];
int part, seg, gap, strip;
695 for(
int gap = 0; gap < ngap; gap++){Seg[gap] = -1;}
696 for(iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
698 part = (*iHit)->Part();
699 seg = (*iHit)->Seg();
700 gap = (*iHit)->Gap();
701 strip = (*iHit)->Strip();
702 if(part==1) Seg[gap] = seg;
708 if(Seg[gap] != -1) segTrackBr = Seg[gap];
712 float thickness = 0.0;
716 if(
sin(m_MucMomentum.theta()) != 0 ) thickness /=
sin(m_MucMomentum.theta());
719 if(Seg[gap] == -1 && betweenSeg == 1) {
729 if(m_MucMomentum.mag()>1000 ||
brFirstLayer()<2) brThickness += thickness;
732 else cout<<
"in RecMucTrack: Wrong Gap Info"<<endl;
741 for (
int gap = 0; gap!=-1&&gap <=
ecLastLayer(); gap++) {
745 if (
cos(theta) != 0.0) ecThickness /=
cos(theta);
747 ecThickness = fabs(ecThickness);
753 if((m_Good3DLine == 1) &&(m_Good3DPart == 1)){
754 if(m_IntersectionInner[0].
x()!=-9999){
757 if(m_IntersectionInner[gap].
x() != -9999 && m_IntersectionInner[gap-1].x() != -9999)
758 m_depth_3 += (m_IntersectionInner[gap] - m_IntersectionOuter[gap-1]).mag();
761 m_depth_3 += ecThickness;
763 else m_depth_3 = brThickness + ecThickness;
765 if((m_Good3DLine == 1) &&(m_Good3DPart != 1)){
768 if(m_IntersectionInner[gap].
x() != -9999 && m_IntersectionInner[gap-1].x() != -9999)
769 m_depth_3 += (m_IntersectionInner[gap] - m_IntersectionOuter[gap-1]).mag();
772 m_depth_3 += brThickness;
773 if (
cos(theta) != 0.0) m_depth_3 += 40/
cos(theta);
775 if(m_Good3DLine == 0) m_depth_3 = brThickness + ecThickness;
776 if(m_depth_3>2000) m_depth_3 = brThickness + ecThickness;
780 m_depth_3 = brThickness + ecThickness;
784 double offset = 50.0;
800 float brThickness = 0.0;
806 float brThickness_2 = 0.0;
813 float brThickness_3 = 0.0;
814 vector<MucRecHit*>::const_iterator iHit;
816 int Seg[9];
int part, seg, gap, strip;
817 for(
int gap = 0; gap < ngap; gap++){Seg[gap] = -1;}
818 for(iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
820 part = (*iHit)->Part();
821 seg = (*iHit)->Seg();
822 gap = (*iHit)->Gap();
823 strip = (*iHit)->Strip();
824 if(part==1) Seg[gap] = seg;
828 float deltaPhi_3 = 0.0;
833 if(Seg[gap] != -1) segTrackBr = Seg[gap];
837 float thickness = 0.0;
840 if(
sin(m_MucMomentum.theta()) != 0 ) thickness /=
sin(m_MucMomentum.theta());
841 else cout<<
"RecMucTrack::ComputeDepth, In Barrel,theta=0?"<<endl;
843 deltaPhi_3 = m_MucMomentum.phi() - segTrackBr*
kPi/4;
844 if(Seg[gap] == -1 && betweenSeg == 1) {
845 cout<<
"between segment"<<endl;
849 if(
cos(deltaPhi_3) != 0 ) thickness /=
cos(deltaPhi_3);
850 else cout<<
"RecMucTrack::ComputeDepth, In Barrel,Cos(phi)=0?"<<endl;
852 if(deltaPhi_3 == 0 && Seg[
brLastLayer()-1]==2 ) thickness = 0;
854 brThickness_3 += thickness;
860 float phi = m_MucMomentum.phi();
863 float theta = m_MucMomentum.theta();
867 if (
sin(theta) != 0.0) brThickness /=
sin(theta);
868 else cout <<
"RecMucTrack::ComputeDepth, In Barrel, Track theta = 0.0 ? " << endl;
871 brThickness = fabs(brThickness);
875 float ecThickness = 0.0;
882 if (
cos(theta) != 0.0) ecThickness /=
cos(theta);
884 ecThickness = fabs(ecThickness);
887 m_depth = brThickness + ecThickness;
888 m_depth_3 = brThickness_3 + ecThickness;
889 cout <<
"Depth " <<
m_depth <<
" Depth3 = "<<m_depth_3<<endl;
891 double offset = 50.0;
899 bool firstHitFound =
false;
901 vector<MucRecHit*>::const_iterator iHit;
902 vector<MucRecHit*> hitsGap0;
903 float stripLocal[3]={0.0, 0.0, 0.0};
904 float stripGlobal[3]={0.0, 0.0, 0.0};
907 int part, seg, gap, strip;
908 int barrel_gap0_exist = 0;
910 for(iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
912 part = (*iHit)->
Part();
913 seg = (*iHit)->Seg();
914 gap = (*iHit)->Gap();
915 strip = (*iHit)->Strip();
916 if(!firstHitFound && gap == 0) {
918 firstHitFound =
true;
920 if(firstGap && part == firstGap->
Part() && seg == firstGap->
Seg() && gap == firstGap->
Gap()) {
923 HepPoint3D posHitLocal = (*iHit)->GetGap()->TransformToGap(posHit);
924 if(part==1&&gap==0) barrel_gap0_exist = 1;
926 stripLocal[0] += posHitLocal.x();
927 stripLocal[1] += posHitLocal.y();
928 stripLocal[2] += posHitLocal.z();
930 stripGlobal[0] += posHit.x();
931 stripGlobal[1] += posHit.y();
932 stripGlobal[2] += posHit.z();
941 int apart = -1, aseg = -1;
944 if(apart == -1 && aseg== -1)
945 {m_Dist_muc_ext.set(0,0,0);}
950 float dist_x = fextLocal.x() - fmucLocal.x();
951 float dist_y = fextLocal.y() - fmucLocal.y();
952 float dist_z = fextLocal.z() - fmucLocal.z();
953 m_Dist_muc_ext.set(dist_x,dist_y,dist_z);
955 if (fakefirstGap->
Orient() == 0) {
965 if (nStrip == 0 || !firstGap) {
970 for (
int k = 0; k < 3; k++) stripLocal[k] /= nStrip;
971 for (
int k = 0; k < 3; k++) stripGlobal[k] /= nStrip;
973 m_StripPhi.set(stripGlobal[0],stripGlobal[1],stripGlobal[2]);
982 if (firstGap->
Orient() == 0) {
983 distance = extLocal.y() - stripLocal[1];
987 distance = extLocal.x() - stripLocal[0];
1002 float x = m_ExtMucPos.x(), y = m_ExtMucPos.y(), z = m_ExtMucPos.z();
1005 float myMucR = 1720.0;
1006 float myMucZ = 2110.0;
1008 while ( ( (fabs(
x)<=myMucR) && (fabs(y)<=myMucR) && ((fabs(
x-y)/sqrt(2.))<=myMucR) && ((fabs(
x+y)/sqrt(2.))<=myMucR) && (fabs(z)<=myMucZ) )&&count_<1000 ) {
1009 x += step * m_MucMomentum.x();
1010 y += step * m_MucMomentum.y();
1011 z += step * m_MucMomentum.z();
1017 while( !( (fabs(
x)<=myMucR) && (fabs(y)<=myMucR) && ((fabs(
x-y)/sqrt(2.))<=myMucR) && ((fabs(
x+y)/sqrt(2.))<=myMucR) && (fabs(z)<=myMucZ) )&&
count<1000 ) {
1018 x -= step * m_MucMomentum.x();
1019 y -= step * m_MucMomentum.y();
1020 z -= step * m_MucMomentum.z();
1025 if(
count<1000&&count_<1000){
1026 if(fabs(
x)<2600&&fabs(y)<2600&&fabs(z)<2800){
1027 m_ExtMucPos.set(
x, y, z);
1028 m_MucPos.set(
x,y,z);
1042 int part = -1, seg = -1;
1046 if (part < 0 || seg < 0) {
1052 float startPos[3] = {0.0, 0.0, 0.0};
1054 vector<MucRecHit*>::const_iterator iHit;
1055 for (
int orient = 0; orient <= 1; orient++) {
1056 road2D[orient] =
MucRec2DRoad(part, seg, orient, startPos[0], startPos[1], startPos[2],fittingMethod );
1057 for(iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1059 int hitPart = (*iHit)->Part();
1060 int hitSeg = (*iHit)->Seg();
1061 int hitOrient = (*iHit)->GetGap()->Orient();
1062 if (hitPart == part && hitSeg == seg && hitOrient == orient) {
1075 float vx, vy, x0, y0;
1078 road2D[1].GetIntercept(), road2D[0].GetIntercept(),
1098 m_Good3DPart = road3D.
GetPart();
1102 float startx = 0.0, starty = 0.0, startz = 0.0;
1103 float startxSigma = 0.0, startySigma = 0.0, startzSigma = 0.0;
1104 float x1 = 0.0, y1 = 0.0, z1 = 0.0, x2 = 0.0, y2 = 0.0, z2 = 0.0;
1107 if(fittingMethod==2){
1108 for(
int igap=0; igap<9;igap++){
1109 road3D.
Project(igap, x1, y1, z1, x2, y2, z2);
1110 m_IntersectionInner[igap].set(x1,y1,z1);
1111 m_IntersectionOuter[igap].set(x2,y2,z2);
1118 road3D.
ProjectWithSigma(gap, startx, starty, startz, startxSigma, startySigma, startzSigma);
1121 while ( (startx*startx + starty*starty + startz*startz) <
kMinor &&
1124 if(fabs(startx)<2600&&fabs(starty)<2600&&fabs(startz)<2800){
1125 Hep3Vector MucPos_self;
1126 MucPos_self.set(startx, starty, startz);
1127 float dist = (MucPos_self - m_MucPos).mag();
1130 m_MucPos.set(startx, starty, startz);
1136 m_MucPosSigma.set(startxSigma, startySigma, startzSigma);
1142 float momentum = m_MucMomentum.mag();
1144 if (m_MucMomentum.z() != 0.0) zDir = m_MucMomentum.z() / fabs(m_MucMomentum.z());
1149 float segPhi = 0.25*
kPi*seg;
1151 if (part == 1 &&
px*
cos(segPhi)+
py*
sin(segPhi) < 0.0) {
1158 m_MucMomentum.set(
px,
py,
pz);
1162 Hep3Vector phi_mdc, phi_muc;
1163 phi_mdc.set(m_MdcMomentum.x(),m_MdcMomentum.y(),0);
1164 phi_muc.set(
px,
py,0);
1165 double deltaPhi = phi_mdc.angle(phi_muc);
1170 if(m_chi2<0||m_chi2>1000)
m_chi2 = 0;
1177 float xInsct = 0.0, yInsct = 0.0, zInsct = 0.0, sigmax = 0.0, sigmay = 0.0, sigmaz = 0.0;
1178 float quad_x1 = 0.0, quad_y1 = 0.0, quad_z1 = 0.0, quad_x2 = 0.0, quad_y2 = 0.0, quad_z2 = 0.0;
1179 for(
int ihit = 0; ihit < m_pHits.size(); ihit++){
1180 int igap = (m_pHits[ihit])->Gap();
1182 quad_x1, quad_y1, quad_z1, quad_x2, quad_y2, quad_z2);
1187 m_distHits.push_back(dist_hit_track);
1191 if(fittingMethod==2)
1194 Hep3Vector center = m_pHits[ihit]->GetCenterPos();
1195 int iPart = m_pHits[ihit]->Part();
1196 int iSeg = m_pHits[ihit]->Seg();
1197 int iGap = m_pHits[ihit]->Gap();
1198 float xHit, yHit, zHit = 0.;
1200 if ( iGap %2 == 1) {
1202 yHit = sqrt(center.x()*center.x()
1203 + center.y()*center.y());
1204 if(iSeg==2) yHit = center.y();
1212 if ( iGap %2 == 0) {
1222 float distance1 = fabs(xHit - quad_x1)/(xHit - quad_x1) * sqrt((xHit - quad_x1)*(xHit - quad_x1) + (yHit - quad_y1)*(yHit - quad_y1));
1223 float distance2 = fabs(xHit - quad_x2)/(xHit - quad_x2) * sqrt((xHit - quad_x2)*(xHit - quad_x2) + (yHit - quad_y2)*(yHit - quad_y2));
1225 float dist_quad = distance1;
1226 if(fabs(distance1) > fabs(distance2)) dist_quad = distance2;
1232 if(quad_x1 == -9999) m_distHits_quad.push_back(-99);
1233 else m_distHits_quad.push_back(dist_quad);
1239 for(
int ihit = 0; ihit < m_pHits.size(); ihit++){
1240 m_distHits.push_back(-99);
1241 m_distHits_quad.push_back(-99);
1252 for(
int igap = 0; igap < 9 ; igap++){
1254 vector<float> intersect_x;
1255 vector<float> intersect_y;
1256 vector<float> intersect_z;
1259 float zx, zy, x0, y0;
1261 Hep3Vector mom_refit;
1264 if (m_MucMomentum.z() != 0.0) zDir = m_MucMomentum.z() / fabs(m_MucMomentum.z());
1265 float px_refit = zx * zDir;
1266 float py_refit = zy * zDir;
1267 float pz_refit = zDir;
1268 float segPhi = 0.25*
kPi*seg;
1270 if (part == 1 && px_refit*
cos(segPhi)+py_refit*
sin(segPhi) < 0.0) {
1276 mom_refit.setX(px_refit);
1277 mom_refit.setY(py_refit);
1278 mom_refit.setZ(pz_refit);
1281 else mom_refit = m_MucMomentum;
1285 float initPosx_refit, initPosy_refit, initPosz_refit;
1286 float sigmax_refit, sigmay_refit, sigmaz_refit;
1287 road3D.
Project(0, zx, x0, zy, y0, initPosx_refit, initPosy_refit, initPosz_refit);
1288 initPos_refit.setX(initPosx_refit-mom_refit.x()/
momentum);
1289 initPos_refit.setY(initPosy_refit-mom_refit.y()/
momentum);
1290 initPos_refit.setZ(initPosz_refit-mom_refit.z()/
momentum);
1292 else initPos_refit = initPos;
1300 vector<Identifier> MuId = road3D.
ProjectToStrip(1,igap,initPos_refit,mom_refit,padID,intersect_x,intersect_y,intersect_z);
1304 vector<Identifier>::const_iterator mucid;
1306 for(mucid = MuId.begin(); mucid != MuId.end(); mucid++,i++)
1314 m_pExpectedHits.push_back(pHit);
1321 for(
int igap = 0; igap < 8; igap++){
1323 vector<float> intersect_x;
1324 vector<float> intersect_y;
1325 vector<float> intersect_z;
1328 float zx, zy, x0, y0;
1331 Hep3Vector mom_refit;
1334 if (m_MucMomentum.z() != 0.0) zDir = m_MucMomentum.z() / fabs(m_MucMomentum.z());
1335 float px_refit = zx * zDir;
1336 float py_refit = zy * zDir;
1337 float pz_refit = zDir;
1338 float segPhi = 0.25*
kPi*seg;
1340 if (part == 1 && px_refit*
cos(segPhi)+py_refit*
sin(segPhi) < 0.0) {
1346 mom_refit.setX(px_refit);
1347 mom_refit.setY(py_refit);
1348 mom_refit.setZ(pz_refit);
1351 else mom_refit = m_MucMomentum;
1355 float initPosx_refit, initPosy_refit, initPosz_refit;
1356 float sigmax_refit, sigmay_refit, sigmaz_refit;
1357 road3D.
Project(0, zx, x0, zy, y0, initPosx_refit, initPosy_refit, initPosz_refit);
1358 initPos_refit.setX(initPosx_refit-mom_refit.x()/
momentum);
1359 initPos_refit.setY(initPosy_refit-mom_refit.y()/
momentum);
1360 initPos_refit.setZ(initPosz_refit-mom_refit.z()/
momentum);
1362 else initPos_refit = initPos;
1367 vector<Identifier> MuId = road3D.
ProjectToStrip(
m_endPart,igap,initPos_refit,mom_refit,padID,intersect_x,intersect_y,intersect_z);
1369 vector<Identifier>::const_iterator mucid;
1371 for(mucid = MuId.begin(); mucid != MuId.end(); mucid++,i++)
1379 m_pExpectedHits.push_back(pHit);
1385 for(
int i=0; i< m_pExpectedHits.size(); i++)
1392 for(
int i=0; i< m_pHits.size(); i++)
1403 for(
int ihit = 0; ihit < m_pHits.size(); ihit++){
1404 m_distHits.push_back(-99);
1405 m_distHits_quad.push_back(-99);
1416 vector<int> firedGap;
1417 for(gap = 0; gap < ngap; gap++) firedGap.push_back(0);
1419 vector<MucRecHit*>::const_iterator iHit;
1420 for (iHit=m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1422 gap = (*iHit)->Gap();
1427 for ( gap = 0; gap < ngap; gap++) {
1428 count += firedGap[gap];
1439 return m_pHits.size();
1445 if ( part < 0 || part > 2 ) {
1446 cout <<
"RecMucTrack::GetHitInGap(), invalid part " << part << endl;
1450 cout <<
"RecMucTrack::GetHitInGap(), invalid gap " << gap << endl;
1454 vector<MucRecHit*>::const_iterator iHit;
1457 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1460 cout <<
"RecMucTrack::GetHitInGap() null hit pointer !" << endl;
1464 if( part == (*iHit)->Part() && gap == (*iHit)->Gap() ) hitsInGap++;
1481 if ( part < 0 || part > 2 ) {
1482 cout <<
"RecMucTrack::GetHitInSeg(), invalid part " << part << endl;
1486 cout <<
"RecMucTrack::GetHitInSeg(), invalid seg = " << seg << endl;
1490 vector<MucRecHit*>::const_iterator iHit;
1493 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1496 cout <<
"RecMucTrack::GetHitInSeg(), null hit pointer !" << endl;
1500 if( part == (*iHit)->Part() && seg == (*iHit)->Seg() &&
1501 orient == (*iHit)->GetGap()->Orient() ) hitsInSeg++;
1516 if (hits > maxHits) {
1535 if(hits > maxHits) maxHits = hits;
1546 vector<MucRecHit*>::const_iterator iHit;
1548 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1550 if ( (*iHit)->Part() == part &&
1551 (*iHit)->Seg() == seg &&
1552 (*iHit)->Gap() == gap &&
1553 (*iHit)->Strip() == strip ) {
1566 cout <<
"RecMucTrack::HasHitInGap-E2 invalid gap = " << gap << endl;
1571 vector<MucRecHit*>::const_iterator iHit;
1573 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1575 if ( (*iHit)->Part() == part &&
1576 (*iHit)->Gap() == gap ) {
1593 vector<MucRecHit*>::const_iterator iHit1;
1594 vector<MucRecHit*>::const_iterator iHit2;
1597 for( iHit1 = m_pHits.begin(); iHit1 != m_pHits.end(); iHit1++){
1598 for( iHit2 = track2->m_pHits.begin();
1599 iHit2 != track2->m_pHits.end(); iHit2++){
1603 if ( (hit1 != 0) && (hit2 != 0) ) {
1618 cout <<
"RecMucTrack::Hit-E1 invalid gap = " << gap << endl;
1622 vector<MucRecHit*>::const_iterator iHit;
1624 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1626 if ( (*iHit)->Part() == part &&
1627 (*iHit)->Gap() == gap) {
1645 return m_pExpectedHits;
1653 vector<MucRecHit*>::const_iterator iHit;
1654 for ( iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1656 long index = (*iHit)->GetID();
1686 vector<MucRecHit*>::const_iterator iHit;
1687 for ( iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1690 (*iHit)->GetStrip()->GetCenterPos(xl, yl, zl);
1692 HepPoint3D vg = (*iHit)->GetGap()->TransformToGlobal(vl);
1694 cout <<
" part " << (*iHit)->Part()
1695 <<
" seg " << (*iHit)->Seg()
1696 <<
" gap " << (*iHit)->Gap()
1697 <<
" strip " << (*iHit)->Strip()
1698 <<
" pos (" << vg.x() <<
", " << vg.y() <<
", " << vg.z() <<
")"
1708 if(m_changeUnit ==
false){
1726 m_changeUnit =
true;
**********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
DOUBLE_PRECISION count[2]
double sin(const BesAngle a)
double cos(const BesAngle a)
const double kSuperConductorR
const double kSuperConductorZ
const double kMagnetField
const double kInsctWeight
int intersection(const HepPoint3D &c1, double r1, const HepPoint3D &c2, double r2, double eps, HepPoint3D &x1, HepPoint3D &x2)
Circle utilities.
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
const int GetTrackId() const
HepPoint3D TransformToGlobal(const HepPoint3D pPoint) const
Transform a point from gap coordinate to global coordinate.
int Seg() const
Get seg identifier (0-7).
int Gap() const
Get gap identifier (0-8).
int Part() const
Get part identifier (0,2 for cap, 1 for barrel).
float GetIronThickness() const
HepPoint3D TransformToGap(const HepPoint3D gPoint) const
Transform a point from global coordinate to gap coordinate.
vector< HepPoint3D > FindIntersections(const int part, const int gap, const HepPoint3D gPoint, const Hep3Vector gDirection)
MucGeoGap * GetGap(const int part, const int seg, const int gap) const
Get a pointer to the gap identified by (part,seg,gap).
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
static int part(const Identifier &id)
static value_type getGapMax()
static value_type getPartNum()
static int gap(const Identifier &id)
static int seg(const Identifier &id)
static value_type getSegNum(int part)
static int strip(const Identifier &id)
static value_type getGapNum(int part)
float GetIntercept() const
Intercept of trajectory.
void AttachHit(MucRecHit *hit)
Attach the given hit to this road.
float GetSlope() const
Slope of trajectory.
int RefitNoCurrentGap(const int &gap, float &slopeZX, float &interceptZX, float &slopeZY, float &interceptZY)
refit the 3D road without the assigned gap
float GetSlopeZX() const
Get Z-X dimension slope.
float GetSlopeZY() const
Get Z-Y dimension slope.
void TransformPhiRToXY(const float &vk, const float &vr, const float &k0, const float &r0, float &vx, float &vy, float &x0, float &y0) const
Where does the trajectory of this road intersect the reference plane?
void ProjectNoCurrentGap(const int &gap, float &x, float &y, float &z, float &sigmaX, float &sigmaY, float &sigmaZ, float &quad_x1, float &quad_y1, float &quad_z1, float &quad_x2, float &quad_y2, float &quad_z2)
Where does the trajectory of this road intersect a specific gap when refit without current gap!...
int GetPart() const
In which part was this road found?
vector< Identifier > ProjectToStrip(const int &part, const int &gap, const HepPoint3D &gPoint, const Hep3Vector &gDirection)
void SetSimpleFitParams(const float &m_SlopeZX, const float &m_InterceptZX, const float &m_SlopeZY, const float &m_InterceptZY)
set the fit parameters : slope and intercept for XZ and YZ.
int GetDegreesOfFreedom() const
How many degrees of freedom in the trajectory fit?
void Project(const int &gap, float &x1, float &y1, float &z1, float &x2, float &y2, float &z2)
Where does the trajectory of this road intersect two surfaces of a specific gap?
void ProjectWithSigma(const int &gap, float &x, float &y, float &z, float &sigmaX, float &sigmaY, float &sigmaZ)
Where does the trajectory of this road intersect a specific gap?
float GetReducedChiSquare() const
Chi-square parameter (per degree of freedom) of the trajectory fit.
void SetIntersectZ(float z)
MucGeoGap * GetGap() const
Get geometry data for the gap containing this hit.
Hep3Vector GetCenterPos() const
Get Center position of the strip (global coords).
int Part() const
Get Part.
void SetIntersectY(float y)
void SetIntersectX(float x)
Identifier GetID() const
Get soft identifier of this hit.
int GetTotalHits() const
How many hits in all does this track contain?
void LineFit(int fittingMethod)
Line fit with hits on a seg with max hits.
void CorrectPos()
Correct current position of this trajectory.
void PrintHitsInfo() const
Print Hits Infomation.
void CorrectDir()
Correct direction of this trajectory.
void ComputeTrackInfo(int fittingmethod)
Get corresponding monte carlo track pointer.
int GetNGapsWithHits() const
How many gaps provide hits attached to this track?
void SetMdcMomentum(const float px, const float py, const float pz)
set start moment of the track in Mdc.
void setExpHits(vector< MucRecHit * > &pHits)
void SetMucPosSigma(const float sigmax, const float sigmay, const float sigmaz)
MucRecHit * GetHit(const int part, const int gap) const
Get a pointer to the first hit attached in a particular gap.
bool IsInsideSuperConductor(Hep3Vector pos)
int GetHitInSeg(const int part, const int seg) const
How many hits does a segment contains.
~RecMucTrack()
Destructor.
void AttachInsct(Hep3Vector insct)
Attach the intersection to this trajectory.
int brFirstLayer() const
Which gap on Barrel is the first one with hits attached to this track?
void SetExtMucPos(const float x, const float y, const float z)
set start position of ext track in Muc. (compute from MdcPos MdcMomentum or get from ExtTrack)
int GetNSharedHits(const RecMucTrack *track) const
How many hits do two tracks share?
void ComputeNGapsWithHits()
ComputeNGapsWithHits;.
void SetMdcPos(const float x, const float y, const float z)
set start position of the track in Mdc.
void SetCurrentDir(const float x, const float y, const float z)
set current direction of the trajectory.
void ComputeDepth()
chi2 of line fit
float GetHitDistance(const MucRecHit *hit)
Calculate the distance of the hit to the intersection in read direction.
void SetExtTrack(RecExtTrack *extTrack)
set Ext track point.
void setTrackId(const int trackId)
set the index for this track.
bool HasHit(const int part, const int seg, const int gap, const int strip) const
How many hits were attached in the gap with the most attached hits?
void GetMdcExtTrack(Hep3Vector mdcStartPos, Hep3Vector mdcStartMomentum, int charge, Hep3Vector &mucStartPos, Hep3Vector &mucStartMomentum)
compute ext track myself from mdc.
void ComputeMaxHitsInGap()
ComputeMaxHitsInGap;.
int GetHitInGap(const int part, const int gap) const
How many hits per gap does this track contain?
int FindSegWithMaxHits(int &part, int &seg)
Find the segment which contains most hits, return max hits number.
Hep3Vector CalculateInsct(const int part, const int seg, const int gap)
Calculate intersection from all hits attached on this gap.
void Project(const int &part, const int &gap, float &x, float &y, float &z, int &seg)
Where does the trajectory of this track intersect a specific gap?
void SetMucMomentum(const float px, const float py, const float pz)
set start moment of the track in Muc.
void setVecHits(vector< MucRecHit * > &pHits)
reload setVecHits
vector< long > GetHitIndices() const
Get indices of all hits in the track.
int GetHitInSegOrient(const int part, const int seg, const int orient) const
How many hits does a segment contains in one orient.
void SetExtMucMomentum(const float px, const float py, const float pz)
set start moment of ext track in Muc.
RecMucTrack & operator=(const RecMucTrack &orig)
Assignment constructor.
vector< MucRecHit * > GetHits() const
Get all hits on this track.
void AttachHit(MucRecHit *hit)
set corresponding monte carlo track pointer.
void SetCurrentInsct(const float x, const float y, const float z)
set current intersection of the trajectory with strip plane.
void ComputeDistanceMatch()
Compute distance match //2006.11.08.
void OutputUnitChange()
change unit
void SetCurrentPos(const float x, const float y, const float z)
set current position of the trajectory.
vector< MucRecHit * > GetExpectedHits() const
void SetMucPos(const float x, const float y, const float z)
set start position of the track in Muc. (after line fit and correction)
float GetHitDistance2(const MucRecHit *hit)
no abs value
void Extend()
Extend mucpos and extmucpos to first layer of muc.
bool HasHitInGap(const int part, const int gap) const
Does this track contain any hits in the given gap?
void ComputeLastGap()
Comute last gap in barrel and endcap.
RecMucTrack()
Constructor.
void AttachDirection(Hep3Vector dir)
Attach the direction to this trajectory.