1#include "HoughTransAlg/HoughHit.h"
2#include "Identifier/MdcID.h"
3#include "RawEvent/RawDataUtil.h"
4#include "MdcGeom/Constants.h"
5#include "TrkBase/TrkPoca.h"
6#include "TrkBase/HelixTraj.h"
7#include "TrkFitter/TrkCircleTraj.h"
8#include "TrkBase/TrkExchangePar.h"
41 m_bunchTime = bunchTime;
45 m_hitPosition = (
wire->Forward() +
wire->Backward())/10/2;
46 m_westPoint =
wire->Forward();
47 m_eastPoint =
wire->Backward();
48 m_driftDist = driftDistance();
70 m_cgemCluster = cgemCluster;
78 m_flag = cgemCluster->
getflag();
80 m_bunchTime = bunchTime;
85 m_hitPosition.setZ(cgemCluster->
getRecZ()/10.);
107 m_cgemCluster = NULL;
110 m_mdcMcHit = mdcMcHit;
114 m_use = mdcMcHit->getPositionFlag();
115 m_bunchTime = bunchTime;
117 m_depositEnergy = mdcMcHit->getDepositEnergy();
118 m_hitPosition.setX(mdcMcHit->getPositionX()/10.);
119 m_hitPosition.setY(mdcMcHit->getPositionY()/10.);
120 m_hitPosition.setZ(mdcMcHit->getPositionZ()/10.);
123 m_driftDist = mdcMcHit->getDriftDistance()/10.;
130 m_trkID.push_back(mdcMcHit->getTrackIndex());
143 m_cgemCluster = NULL;
145 m_cgemMcHit = cgemMcHit;
147 m_layer = cgemMcHit->GetLayerID();
153 m_bunchTime = bunchTime;
156 m_hitPosition.setX((cgemMcHit->GetPositionXOfPrePoint()+cgemMcHit->GetPositionXOfPostPoint())/2/10.);
157 m_hitPosition.setY((cgemMcHit->GetPositionYOfPrePoint()+cgemMcHit->GetPositionYOfPostPoint())/2/10.);
158 m_hitPosition.setZ((cgemMcHit->GetPositionZOfPrePoint()+cgemMcHit->GetPositionZOfPostPoint())/2/10.);
168 m_trkID.push_back(cgemMcHit->GetTrackID());
178 m_hitID(other.m_hitID),
179 m_hitType(other.m_hitType),
180 m_cgemCluster(other.m_cgemCluster),
181 m_mdcDigi(other.m_mdcDigi),
182 m_cgemMcHit(other.m_cgemMcHit),
183 m_mdcMcHit(other.m_mdcMcHit),
186 m_flag(other.m_flag),
188 m_bunchTime(other.m_bunchTime),
189 m_rawTime(other.m_rawTime),
190 m_depositEnergy(other.m_depositEnergy),
191 m_hitPosition(other.m_hitPosition),
192 m_westPoint(other.m_westPoint),
193 m_eastPoint(other.m_eastPoint),
194 m_driftDist(other.m_driftDist),
195 m_residual(other.m_residual),
201 m_trkID(other.m_trkID),
203 m_pairHit(other.m_pairHit),
204 m_halfCircle(other.m_halfCircle),
205 m_position(other.m_position),
206 m_mdcHit(other.m_mdcHit)
211 m_hitID = other.m_hitID;
212 m_hitType = other.m_hitType;
213 m_cgemCluster = other.m_cgemCluster;
214 m_mdcDigi = other.m_mdcDigi;
215 m_cgemMcHit = other.m_cgemMcHit;
216 m_mdcMcHit = other.m_mdcMcHit;
217 m_layer = other.m_layer;
218 m_wire = other.m_wire;
219 m_flag = other.m_flag;
221 m_bunchTime = other.m_bunchTime;
222 m_rawTime = other.m_rawTime;
223 m_depositEnergy = other.m_depositEnergy;
224 m_hitPosition = other.m_hitPosition;
225 m_westPoint = other.m_westPoint;
226 m_eastPoint = other.m_eastPoint;
227 m_driftDist = other.m_driftDist;
228 m_residual = other.m_residual;
234 m_trkID = other.m_trkID;
236 m_pairHit = other.m_pairHit;
237 m_halfCircle = other.m_halfCircle;
238 m_position = other.m_position;
239 m_mdcHit =other.m_mdcHit;
291 if(nomShift>0)
return 1;
292 else if(nomShift<0)
return -1;
298 double ToF = 1.e9*sqrt(m_hitPosition.x()*m_hitPosition.x()+m_hitPosition.y()*m_hitPosition.y())/
Constants::c;
299 double Tprop = m_mdcCalibFunSvc->
getTprop(m_layer,m_hitPosition.z()*10.);
300 double Twalk = m_mdcCalibFunSvc->
getTimeWalk(m_layer, m_depositEnergy);
301 double T0 = m_mdcCalibFunSvc->
getT0(m_layer,m_wire);
302 double driftTime = m_rawTime - 1.e9*m_bunchTime - ToF - Tprop - Twalk -T0;
310double HoughHit::driftDistance()
314 if(fabs(driftT)>1500.||fabs(m_hitPosition.z()>150.)){
318 double driftDist(-1);
322 double entranceAngle = 0;
323 driftDist = 0.1 * m_mdcCalibFunSvc->
driftTimeToDist(driftT,m_layer,m_wire,lrCalib,entranceAngle);
331 case CGEMHIT : hitType =
"CGEMHIT";
break;
332 case MDCHIT : hitType =
"MDCHIT";
break;
333 case CGEMMCHIT : hitType =
"CGEMMCHIT";
break;
334 case MDCMCHIT : hitType =
"MDCMCHIT";
break;
335 default : hitType =
"";
337 cout<<
"ID:" <<setw(6)<<m_hitID;
338 cout<<
"(" <<setw(2)<<m_layer;
339 cout<<
"," <<setw(3)<<m_wire<<
") ";
340 cout<<
" flag:" <<setw(3)<<m_flag;
344 cout<<
" trkID:"<<setw(3)<<(m_pairHit->
getTrkID())[0];
347 cout<<
" McLR:"<<setw(3)<<m_pairHit->
getMdcMcHit()->getPositionFlag();
348 cout<<
" drift:"<<setw(10)<<m_pairHit->
getMdcMcHit()->getDriftDistance();
356 cout<<
" trkID:"<<setw(3)<<m_trkID[0];
357 cout<<
" McHit:("<<setw(10)<<m_hitPosition.x()<<
", "<<setw(10)<<m_hitPosition.y()<<
", "<<setw(10)<<m_hitPosition.z()<<
") ";
361 cout<<
" McLR:"<<setw(3)<<m_mdcMcHit->getPositionFlag();
362 cout<<
" drift:"<<setw(10)<<m_mdcMcHit->getDriftDistance();
399 vector<int>::iterator it0 = m_trkID.begin();
400 vector<int>::iterator result = find(m_trkID.begin(),m_trkID.end(),trkID);
401 if(result!=m_trkID.end()) {
402 m_trkID.erase(result);
403 vector<double>::iterator itRes = m_vecResid.begin()+(result-it0);
404 if(itRes!=m_vecResid.end()) m_vecResid.erase(itRes);
410 if(
getFlag()==0)
return m_position;
415 double xc = track->
center().x();
416 double yc = track->
center().y();
417 double rTrack = track->
radius();
424 double xEast = eastPoint.x()/10.0;
425 double xWest = westPoint.x()/10.0;
426 double yEast = eastPoint.y()/10.0;
427 double yWest = westPoint.y()/10.0;
428 double zEast = eastPoint.z()/10.0;
429 double zWest = westPoint.z()/10.0;
433 double west2east = sqrt((xEast-xWest)*(xEast-xWest)+(yEast-yWest)*(yEast-yWest));
435 double slope = (yEast-yWest)/(xEast-xWest);
436 double intercept = (yWest-slope*xWest+yEast-slope*xEast)/2;
437 double a = 1+slope*slope;
438 double b = -2*(xc+slope*yc-slope*intercept);
439 double c1 = xc*xc+(yc-intercept)*(yc-intercept)-(rTrack+drift)*(rTrack+drift);
440 double c2 = xc*xc+(yc-intercept)*(yc-intercept)-(rTrack-drift)*(rTrack-drift);
443 double delta1 = (b*b-4*a*
c1);
444 double delta2 = (b*b-4*a*c2);
448 double x1 = (-b+sqrt(delta1))/(2*a);
449 double x2 = (-b-sqrt(delta1))/(2*a);
450 double y1 = slope*x1+intercept;
451 double y2 = slope*x2+intercept;
452 if((x1-xWest)*(x1-xEast)<0){
453 double l = sqrt((x1-xWest)*(x1-xWest)+(y1-yWest)*(y1-yWest));
454 z = zWest + l/west2east*fabs((zEast-zWest));
456 m_position.push_back(position);
458 if((x2-xWest)*(x2-xEast)<0){
459 double l = sqrt((x2-xWest)*(x2-xWest)+(y2-yWest)*(y2-yWest));
460 z = zWest + l/west2east*fabs((zEast-zWest));
462 m_position.push_back(position);
467 double x1 = (-b+sqrt(delta2))/(2*a);
468 double x2 = (-b-sqrt(delta2))/(2*a);
469 double y1 = slope*x1+intercept;
470 double y2 = slope*x2+intercept;
471 if((x1-xWest)*(x1-xEast)<0){
472 double l = sqrt((x1-xWest)*(x1-xWest)+(y1-yWest)*(y1-yWest));
473 z = zWest + l/west2east*fabs((zEast-zWest));
475 m_position.push_back(position);
477 if((x2-xWest)*(x2-xEast)<0){
480 double l = sqrt((x2-xWest)*(x2-xWest)+(y2-yWest)*(y2-yWest));
481 z = zWest + l/west2east*fabs((zEast-zWest));
483 m_position.push_back(position);
499 double distance = (circleCenter-hitPoint).perp();
501 double Rc = fabs(track->
radius());
506 residual = driftDist-fabs(distance - Rc);
511 double rCgem = hitPoint.perp();
514 phiTrkFlt = track->
judgeHalf(
this)*phiTrkFlt;
517 double phiCrossPoint = crossPoint.phi();
518 double phiMeasure = hitPoint.phi();
519 residual = phiMeasure - phiCrossPoint;
529 for(vector<HepPoint3D>::iterator posIt = position.begin();posIt!=position.end();posIt++){
532 double zTrk = track->
dz()+
s*track->
tanl();
533 double res = point.z() - zTrk;
535 if(fabs(res)<minRes){
542 double zTrk = track->
dz()+
s*track->
tanl();
543 residual = m_hitPosition.z() - zTrk;
556 for(vector<HepPoint3D>::iterator posIt = position.begin();posIt!=position.end();posIt++){
559 double zTrk = track->
dz()+
s*track->
tanl();
560 double res = point.z() - zTrk;
561 if(fabs(res)<minRes){
566 m_hitPosition = hitPoint;
567 m_driftDist = driftDistance();
578 MdcHit mdcHit(m_mdcDigi,mdcDetector);
581 double d0 = -track->
dr();
583 double omega = track->
kappa()/fabs(track->
alpha());
584 double z0 = track->
dz();
585 double tanl = track->
tanl();
599 double hitWireLength = m_hitPosition.z()-m_westPoint.z();
601 double trkFlightLength = track->
flightLength(m_hitPosition);
602 const HelixTraj helixTraj(trkExchangePar);
603 TrkPoca trkPoca(helixTraj,trkFlightLength,*
wire,hitWireLength);
604 trkFlightLength = trkPoca.
flt1();
605 hitWireLength = trkPoca.
flt2();
606 double doca = trkPoca.
doca();
614 Hep3Vector wireDirection, trackDirection;
616 wire->getInfo(hitWireLength, positionOnDetector, wireDirection);
617 helixTraj.
getInfo(trkFlightLength, positionOntrack, trackDirection);
618 residual = m_driftDist - fabs(doca);
634 double rCgem = m_hitPosition.perp();
637 phiTrkFlt = track->
judgeHalf(
this)*phiTrkFlt;
639 positionOntrack = track->
x(phiTrkFlt);
640 positionOnDetector = track->
x(phiTrkFlt);
642 double phiCrossPoint = positionOntrack.phi();
643 double phiMeasure = m_hitPosition.phi();
644 double dphi = phiMeasure - phiCrossPoint;
double sin(const BesAngle a)
double cos(const BesAngle a)
NTuple::Array< double > m_wire
NTuple::Array< double > m_layer
HepGeom::Point3D< double > HepPoint3D
double getMiddleROfGapD() const
double getVFromPhiZ(double phi, double z) const
CgemGeoLayer * getCgemLayer(int i) const
CgemGeoReadoutPlane * getReadoutPlane(int iLayer, int iSheet) const
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &dir) const
double flightLength(HepPoint3D &hit) const
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
double IntersectCylinder(double r) const
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
double flightArc(HepPoint3D &hit) const
double radius(void) const
returns radious of helix.
double dr(void) const
returns an element of parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
MdcGeomSvc * getMdcGeomSvc() const
double residual(HoughTrack *track)
void dropTrkID(int trkID)
double getDriftDist() const
vector< int > getTrkID() const
const MdcMcHit * getMdcMcHit() const
HepPoint3D getHitPosition() const
HitType getHitType() const
void updateVHit(HoughTrack *track)
vector< HepPoint3D > & VHitPosition(HoughTrack *track)
const MdcSWire * wire() const
HoughHit & operator=(const HoughHit &other)
int judgeHalf(HoughHit *hit)
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 nomShift(void) const
const MdcGeoWire *const Wire(unsigned id)
const MdcGeoLayer *const Layer(unsigned id)
const Trajectory * hitTraj() const
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
double getenergydeposit(void) const
double getRecZ(void) const
int getlayerid(void) const
double getrecphi(void) const
double getrecv(void) const
int getsheetid(void) const