14#include <CLHEP/Vector/ThreeVector.h>
15#include <CLHEP/Geometry/Point3D.h>
17#include "Identifier/MucID.h"
18#include "MucGeomSvc/MucGeomSvc.h"
19#include "MucGeomSvc/MucConstant.h"
20#include "MucRecEvent/MucRecHit.h"
21#include "MucRecEvent/MucRec2DRoad.h"
22#include "MucRecEvent/MucRec3DRoad.h"
23#include "MucRecEvent/MucRecLineFit.h"
27 : m_Road0(road0), m_Road1(road1),
29 m_Part(road0->GetPart()),
30 m_Seg(road0->GetSeg()),
41 if ( (road1->
GetPart() != m_Part) || (road1->
GetSeg() != m_Seg) ) {
42 cout <<
"MucRec3DRoad(ctor)-E1 mismatched 2D roads:"
43 <<
" x part = " << road0->
GetPart() <<
" seg = " << road0->
GetSeg() << endl
44 <<
" y part = " << road1->
GetPart() <<
" seg = " << road1->
GetSeg() << endl;
70 hit = m_Road0->
GetHit(gap);
76 m_Chi2 += dist * dist;
80 hit = m_Road1->
GetHit(gap);
82 if ( hit->
Part() == 1 ) {
91 m_Chi2 += dist * dist;
100 : m_VertexPos(source.m_VertexPos),
101 m_VertexSigma(source.m_VertexSigma),
102 m_Road0(source.m_Road0), m_Road1(source.m_Road1),
103 m_Index(source.m_Index),
104 m_Part(source.m_Part), m_Seg(source.m_Seg),
105 m_LastGap(source.m_LastGap),
106 m_Chi2(source.m_Chi2), m_DOF(source.m_DOF),
107 m_Group(source.m_Group)
121 if (index >= 0) m_Index = index;
128 if (Group >= 0) m_Group = Group;
134 const float& interceptZX,
135 const float& slopeZY,
136 const float& interceptZY)
139 m_InterceptZX = interceptZX;
141 m_InterceptZY = interceptZY;
205 cout <<
"MucRec3DRoad::HitsPerGap-E1 invalid gap = " << gap << endl;
218 if( nHit0 > nHit1 ) {
231 cout <<
"MucRec3DRoad::HasHitInGap-E2 invalid gap = " << gap << endl;
286 return (m_Chi2/m_DOF);
302 return m_InterceptZX;
316 return m_InterceptZY;
324 cout <<
"MucRec3DRoad::GetHit-E1 invalid gap = " << gap << endl;
328 if ( m_Road0->
GetHit(gap) ) {
329 return m_Road0->
GetHit(gap);
332 if ( m_Road1->
GetHit(gap) ) {
333 return m_Road1->
GetHit(gap);
346 float vx, vy, vk, vr;
347 float x0, y0, k0, r0;
348 float svx, svy, svk, svr;
349 float sx0, sy0, sk0, sr0;
355 int status1, status2;
370 svx -= vx; svy -= vy; sx0 -= x0; sy0 -= y0;
379 if(status1 == -1 || status2 == -1)
return -1;
380 slopeZX = vx; interceptZX = x0;
381 slopeZY = vy; interceptZY = y0;
391 cout <<
"MucRec3DRoad::Project-E1 invalid part = " << part << endl;
395 cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
402MucRec3DRoad::ProjectToStrip(
const int& part,
const int& gap,
const HepPoint3D& gPoint,
const Hep3Vector&gDirection, vector<int>&padID, vector<float>&intersect_x, vector<float>&intersect_y, vector<float>&intersect_z)
405 cout <<
"MucRec3DRoad::Project-E1 invalid part = " << part << endl;
409 cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
419 x = 0.0; sigmaX = 0.0;
420 y = 0.0; sigmaY = 0.0;
421 z = 0.0; sigmaZ = 0.0;
424 cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
428 float vx, vy, vk, vr;
429 float x0, y0, k0, r0;
430 float svx, svy, svk, svr;
431 float sx0, sy0, sk0, sr0;
446 svx -= vx; svy -= vy; sx0 -= x0; sy0 -= y0;
464 vx, vy, 1.0, x0, y0, 0.0,
465 svx, svy, 0.0, sx0, sy0, 0.0,
467 sigmaX, sigmaY, sigmaZ);
482 float sa, sb, sc;
int whichhalf;
496 float& quad_x1,
float& quad_y1,
float& quad_z1,
float& quad_x2,
float& quad_y2,
float& quad_z2)
499 x = 0.0; sigmaX = 0.0;
500 y = 0.0; sigmaY = 0.0;
501 z = 0.0; sigmaZ = 0.0;
504 cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
508 float vx, vy, vk, vr;
509 float x0, y0, k0, r0;
510 float svx, svy, svk, svr;
511 float sx0, sy0, sk0, sr0;
530 svx -= vx; svy -= vy; sx0 -= x0; sy0 -= y0;
547 vx, vy, 1.0, x0, y0, 0.0,
548 svx, svy, 0.0, sx0, sy0, 0.0,
550 sigmaX, sigmaY, sigmaZ);
553 vx, vy, 1.0, x0, y0, r0,
554 svx, svy, 0.0, sx0, sy0, 0.0,
556 sigmaX, sigmaY, sigmaZ);
563 float sa, sb, sc;
int whichhalf;
567 if(m_Part == 1 && gap%2 == 0) orient = 1;
568 if(m_Part != 1 && gap%2 == 1) orient = 1;
570 if(orient == 0) m_Road0->
GetSimpleFitParams(a, b, c, whichhalf, sa, sb, sc, chi2x, ydof);
574 quad_x1 = -9999; quad_y1 = -9999; quad_z1 = -9999; quad_x2 = -9999; quad_y2 = -9999; quad_z2 = -9999;
578 a, b, c, whichhalf, quad_x1, quad_y1, quad_z1, quad_x2, quad_y2, quad_z2, sigmaX, sigmaY, sigmaZ);
584MucRec3DRoad::Project(
const int &gap,
const float vx,
const float x0,
const float vy,
const float y0 ,
float &x,
float &y,
float &z)
586 float svx=0, svy=0, sx0=0, sy0=0;
587 float sigmaX,sigmaY,sigmaZ;
589 vx, vy, 1.0, x0, y0, 0.0,
590 svx, svy, 0.0, sx0, sy0, 0.0,
592 sigmaX, sigmaY, sigmaZ);
600 float sigmaX1, sigmaY1, sigmaZ1;
601 float sigmaX2, sigmaY2, sigmaZ2;
603 x1 = 0.0; sigmaX1 = 0.0;
604 y1 = 0.0; sigmaY1 = 0.0;
605 z1 = 0.0; sigmaZ1 = 0.0;
606 x2 = 0.0; sigmaX2 = 0.0;
607 y2 = 0.0; sigmaY2 = 0.0;
608 z2 = 0.0; sigmaZ2 = 0.0;
611 cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
615 float vx, vy, vk, vr;
616 float x0, y0, k0, r0;
617 float svx, svy, svk, svr;
618 float sx0, sy0, sk0, sr0;
646 vx, vy, 1.0, x0, y0, 0.0,
647 svx, svy, 0.0, sx0, sy0, 0.0,
648 x1, y1, z1, x2, y2, z2,
649 sigmaX1, sigmaY1, sigmaZ1,
650 sigmaX2, sigmaY2, sigmaZ2);
653 float sa, sb, sc;
int whichhalf;
657 int projectwithquad = 0;
658 if( m_Part == 1 && projectwithquad) {
667 svx, svy, 0.0, sx0, sy0, 0.0,
668 x1, y1, z1, x2, y2, z2,
669 sigmaX1, sigmaY1, sigmaZ1);
694 vector<Identifier> idCon;
695 vector<Identifier>::iterator hit;
696 vector<Identifier> hitRoad0 = m_Road0->
GetHitsID();
697 vector<Identifier> hitRoad1 = m_Road1->
GetHitsID();
702 for ( hit = hitRoad0.begin(); hit != hitRoad0.end(); hit++) {
704 idCon.push_back(*hit);
709 for ( hit = hitRoad1.begin(); hit != hitRoad1.end();hit++) {
711 idCon.push_back(*hit);
721 const float& k0,
const float& r0,
722 float& vx,
float& vy,
723 float& x0,
float& y0)
const
731 float phi = 0.25*
kPi*m_Seg;
738 if (
cos(phi) + vk*
sin(phi) == 0.0 ) {
739 cout <<
" track parallel to gap, some error occurs! " << endl;
755 float atan_vk = atan(vk);
756 if(atan_vk<0) atan_vk +=
kPi;
761 float deltaPhi = atan_vk - (m_Seg%4)*(0.25*
kPi);
766 vx = (vr/fabs(
cos(deltaPhi)))*
GetVxSign(vk)/sqrt(1.0+vk*vk);
768 x0 = (r0 - k0*
sin(phi)) / (vk*
sin(phi) +
cos(phi));
774 if(vr>0) safe_vr = 10000;
775 else safe_vr = -10000;
776 vx = (safe_vr/fabs(
cos(deltaPhi)))*
GetVxSign(vk)/sqrt(1.0+vk*vk);
788 float segmentPhiMin = 0.25*
kPi*(m_Seg-2);
789 float segmentPhiMax = 0.25*
kPi*(m_Seg+2);
791 segmentPhiMin -= 2.0*
kPi;
792 segmentPhiMax -= 2.0*
kPi;
796 float theta = atan(vk);
797 if (theta >= segmentPhiMin && theta <= segmentPhiMax)
return 1.0;
808 cout <<
"Intersection with each gap : " << endl;
809 for (
int iGap = 0; iGap <= m_LastGap; iGap++) {
810 float x, y, z, sigmaX, sigmaY, sigmaZ;
812 cout <<
" gap " << iGap
double abs(const EvtComplex &c)
double sin(const BesAngle a)
double cos(const BesAngle a)
void FindIntersectionQuadLocal(const int part, const int seg, const int gap, const float a, const float b, const float c, const int whichhalf, float &x1, float &y1, float &z1, float &x2, float &y2, float &z2, float &sigmaX, float &sigmaY, float &sigmaZ)
vector< Identifier > FindIntersectStrips(const int part, const int gap, const HepPoint3D gPoint, const Hep3Vector gDirection)
void FindIntersectionSurface(const int part, const int seg, const int gap, const float vx, const float vy, const float vz, const float x0, const float y0, const float z0, const float sigmaVx, const float sigmaVy, const float sigmaVz, const float sigmaX0, const float sigmaY0, const float sigmaZ0, float &x1, float &y1, float &z1, float &x2, float &y2, float &z2, float &sigmaX1, float &sigmaY1, float &sigmaZ1, float &sigmaX2, float &sigmaY2, float &sigmaZ2)
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
void FindIntersection(const int part, const int seg, const int gap, const float vx, const float vy, const float vz, const float x0, const float y0, const float z0, const float sigmaVx, const float sigmaVy, const float sigmaVz, const float sigmaX0, const float sigmaY0, const float sigmaZ0, float &x, float &y, float &z, float &sigmaX, float &sigmaY, float &sigmaZ)
static value_type getGapMax()
static value_type getPartNum()
vector< Identifier > GetHitsID() const
Get indices of all hits in the road.
bool HasHitInGap(const int &gap) const
Does this road contain any hits in the given gap?
void PrintHitsInfo() const
Print Hits Infomation.
int GetTotalHits() const
How many hits in all does this road contain?
int GetHitsPerGap(const int &gap) const
How many hits per gap does this road contain?
void GetVertexPos(float &x, float &y, float &z) const
Position of the vertex point.
void GetPosSigma(float &possigma) const
int GetMaxHitsPerGap() const
How many hits were attached in the gap with the most attached hits?
int GetLastGap() const
Which gap is the last one with hits attached to this road?
int GetNSharedHits(const MucRec2DRoad *road) const
How many hits do two roads share?
int GetPart() const
In which part was this road found?
float GetHitDistance(const MucRecHit *hit)
Distance to a hit.
int GetDegreesOfFreedom() const
How many degrees of freedom in the trajectory fit?
void GetSimpleFitParams(float &slope, float &intercept, float &sigmaSlope, float &sigmaIntercept, float &chisq, int &ndof) const
Get the parameters from the simple fit.
int GetSeg() const
In which segment was this road found?
MucRecHit * GetHit(const int &gap) const
Get a pointer to the first found hit attached in a particular gap.
int SimpleFitNoCurrentGap(int currentgap, float &slope, float &intercept, float &sigmaSlope, float &sigmaIntercept, float &chisq, int &ndof)
Calculate the best-fit straight line with "simple" weights. not use current gap!!!
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?
bool HasHitInGap(const int &gap) const
Does this road contain any hits in the given segment?
int GetLastGapDelta() const
Difference between the last gap in the two 1-D roads.
void SetIndex(const int &index)
set the index for this road
int GetHitsPerGap(const int &gap) const
How many hits per gap does this road contain?
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!...
float GetVxSign(const float vk) const
Get sign of vx in TransformPhiRToXY.
MucRecHit * GetHit(const int &gap) const
Get a pointer to the first hit attached in a particular 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)
int GetLastGap() const
Which gap is the last one with hits attached to this road?
int GetTotalHitsDelta() const
Difference between the number of hits in the two 1-D roads.
void PrintHitsInfo()
Print Hits Infomation.
void SetGroup(const int &Group)
set the group index for this road
int GetTotalHits() const
How many hits in all does this road contain?
float GetInterceptZY() const
Get Z-Y dimension intercept.
MucRec3DRoad(MucRec2DRoad *road0, MucRec2DRoad *road1)
Constructor.
int GetGroup() const
unique index of group this road belongs to
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 GetNSharedHits(const MucRec3DRoad *road) const
How many hits do two roads share?
int GetSeg() const
In which segment was this road found?
int GetDegreesOfFreedom() const
How many degrees of freedom in the trajectory fit?
~MucRec3DRoad()
Destructor.
MucRec2DRoad * Get2DRoad(const int &orient=0) const
Is the intersection of a pair of H and V clusters inside a panel?
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?
vector< Identifier > GetHitsID() const
Get indices of all hits in the road.
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 GetInterceptZX() const
Get Z-X dimension intercept.
int GetNGapsWithHits() const
How many gaps provide hits attached to this road?
int GetIndex() const
A unique identifier for this road in the current event.
float GetReducedChiSquare() const
Chi-square parameter (per degree of freedom) of the trajectory fit.
int GetMaxHitsPerGap() const
How many hits were attached in the gap with the most attached hits?
Hep3Vector GetCenterSigma() const
Get Center position uncertainty of the strip (global coords).
int Part() const
Get Part.