12#include <CLHEP/Geometry/Point3D.h>
13#include <CLHEP/Vector/ThreeVector.h>
17#include "Identifier/MucID.h"
18#include "MucGeomSvc/MucConstant.h"
19#include "MucGeomSvc/MucGeoGeneral.h"
20#include "MucRecEvent/MucRec2DRoad.h"
21#include "MucRecEvent/MucRec3DRoad.h"
22#include "MucRecEvent/MucRecHit.h"
23#include "MucRecEvent/MucRecLineFit.h"
36 m_VertexPos.setX( x );
37 m_VertexPos.setY( y );
38 m_VertexPos.setZ( z );
41 if ( ( road1->
GetPart() != m_Part ) || ( road1->
GetSeg() != m_Seg ) )
43 cout <<
"MucRec3DRoad(ctor)-E1 mismatched 2D roads:"
44 <<
" x part = " << road0->GetPart() <<
" seg = " << road0->GetSeg() << endl
45 <<
" y part = " << road1->GetPart() <<
" seg = " << road1->GetSeg() << endl;
52 else { m_LastGap = road0->GetLastGap(); }
61 m_DOF = m_Road0->GetDegreesOfFreedom() + m_Road1->GetDegreesOfFreedom();
68 hit = m_Road0->GetHit( gap );
74 dist = m_Road0->GetHitDistance( hit ) / sigma;
75 m_Chi2 += dist * dist;
80 hit = m_Road1->GetHit( gap );
83 if ( hit->
Part() == 1 )
90 dist = m_Road1->GetHitDistance( hit ) / sigma;
91 m_Chi2 += dist * dist;
100 : m_VertexPos( source.m_VertexPos )
101 , m_VertexSigma( source.m_VertexSigma )
102 , m_Road0( source.m_Road0 )
103 , m_Road1( source.m_Road1 )
104 , m_Index( source.m_Index )
105 , m_Part( source.m_Part )
106 , m_Seg( source.m_Seg )
107 , m_LastGap( source.m_LastGap )
108 , m_Chi2( source.m_Chi2 )
109 , m_DOF( source.m_DOF )
110 , m_Group( source.m_Group ) {}
120 if ( index >= 0 ) m_Index = index;
125 if ( Group >= 0 ) m_Group = Group;
130 const float& slopeZY,
const float& interceptZY ) {
132 m_InterceptZX = interceptZX;
134 m_InterceptZY = interceptZY;
157 if ( ( m_Road0->GetHitsPerGap( gap ) > 0 ) || ( m_Road1->GetHitsPerGap( gap ) > 0 ) )
165 return ( m_Road0->GetTotalHits() + m_Road1->GetTotalHits() );
172 cout <<
"MucRec3DRoad::HitsPerGap-E1 invalid gap = " << gap << endl;
176 return ( m_Road0->GetHitsPerGap( gap ) + m_Road1->GetHitsPerGap( gap ) );
181 int nHit0 = m_Road0->GetMaxHitsPerGap();
182 int nHit1 = m_Road1->GetMaxHitsPerGap();
183 if ( nHit0 > nHit1 ) {
return nHit0; }
184 else {
return nHit1; }
191 cout <<
"MucRec3DRoad::HasHitInGap-E2 invalid gap = " << gap << endl;
195 return ( m_Road0->HasHitInGap( gap ) || m_Road1->HasHitInGap( gap ) );
200 if ( !road ) {
return 0; }
211 return abs( m_Road0->GetLastGap() - m_Road1->GetLastGap() );
216 return abs( m_Road0->GetTotalHits() - m_Road1->GetTotalHits() );
224 if ( m_DOF < 0 ) {
return -1.0; }
227 if ( m_DOF == 0 ) {
return 0.0; }
228 else {
return ( m_Chi2 / m_DOF ); }
248 cout <<
"MucRec3DRoad::GetHit-E1 invalid gap = " << gap << endl;
252 if ( m_Road0->GetHit( gap ) ) {
return m_Road0->GetHit( gap ); }
255 if ( m_Road1->GetHit( gap ) ) {
return m_Road1->GetHit( gap ); }
261 float& slopeZY,
float& interceptZY ) {
262 float vx, vy, vk, vr;
263 float x0, y0, k0, r0;
264 float svx, svy, svk, svr;
265 float sx0, sy0, sk0, sr0;
271 int status1, status2;
276 status1 = m_Road0->SimpleFitNoCurrentGap( gap, vr, r0, svr, sr0, chi2x, xdof );
277 status2 = m_Road1->SimpleFitNoCurrentGap( gap, vk, k0, svk, sk0, chi2y, ydof );
279 m_Road0->GetPosSigma( spos0 );
280 m_Road1->GetPosSigma( spos1 );
293 status1 = m_Road0->SimpleFitNoCurrentGap( gap, vy, y0, svy, sy0, chi2y, ydof );
294 status2 = m_Road1->SimpleFitNoCurrentGap( gap, vx, x0, svx, sx0, chi2x, xdof );
295 m_Road0->GetPosSigma( spos0 );
296 m_Road1->GetPosSigma( spos1 );
299 if ( status1 == -1 || status2 == -1 )
return -1;
311 const Hep3Vector& gDirection ) {
313 { cout <<
"MucRec3DRoad::Project-E1 invalid part = " << part << endl; }
316 { cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl; }
323 const Hep3Vector& gDirection, vector<int>& padID,
324 vector<float>& intersect_x, vector<float>& intersect_y,
325 vector<float>& intersect_z ) {
327 { cout <<
"MucRec3DRoad::Project-E1 invalid part = " << part << endl; }
330 { cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl; }
333 part, gap, gPoint, gDirection, padID, intersect_x, intersect_y, intersect_z );
338 float& sigmaX,
float& sigmaY,
float& sigmaZ ) {
348 cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
352 float vx, vy, vk, vr;
353 float x0, y0, k0, r0;
354 float svx, svy, svk, svr;
355 float sx0, sy0, sk0, sr0;
363 m_Road0->GetSimpleFitParams( vr, r0, svr, sr0, chi2x, xdof );
364 m_Road1->GetSimpleFitParams( vk, k0, svk, sk0, chi2y, ydof );
365 m_Road0->GetPosSigma( spos0 );
366 m_Road1->GetPosSigma( spos1 );
378 m_Road0->GetSimpleFitParams( vy, y0, svy, sy0, chi2y, ydof );
379 m_Road1->GetSimpleFitParams( vx, x0, svx, sx0, chi2x, xdof );
380 m_Road0->GetPosSigma( spos0 );
381 m_Road1->GetPosSigma( spos1 );
392 svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX,
411 m_Road1->GetSimpleFitParams( a, b, c, whichhalf, sa, sb, sc, chi2x, ydof );
420 float& sigmaX,
float& sigmaY,
float& sigmaZ,
421 float& quad_x1,
float& quad_y1,
float& quad_z1,
422 float& quad_x2,
float& quad_y2,
float& quad_z2 ) {
433 cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
437 float vx, vy, vk, vr;
438 float x0, y0, k0, r0;
439 float svx, svy, svk, svr;
440 float sx0, sy0, sk0, sr0;
450 m_Road0->SimpleFitNoCurrentGap( gap, vr, r0, svr, sr0, chi2x, xdof );
451 m_Road1->SimpleFitNoCurrentGap( gap, vk, k0, svk, sk0, chi2y, ydof );
453 m_Road0->GetPosSigma( spos0 );
454 m_Road1->GetPosSigma( spos1 );
467 m_Road0->SimpleFitNoCurrentGap( gap, vy, y0, svy, sy0, chi2y, ydof );
468 m_Road1->SimpleFitNoCurrentGap( gap, vx, x0, svx, sx0, chi2x, xdof );
469 m_Road0->GetPosSigma( spos0 );
470 m_Road1->GetPosSigma( spos1 );
480 svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX,
482 if ( fabs( vr ) > 10000 )
485 svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX,
498 if ( m_Part == 1 && gap % 2 == 0 ) orient = 1;
499 if ( m_Part != 1 && gap % 2 == 1 ) orient = 1;
502 m_Road0->GetSimpleFitParams( a, b, c, whichhalf, sa, sb, sc, chi2x, ydof );
503 else m_Road1->GetSimpleFitParams( a, b, c, whichhalf, sa, sb, sc, chi2x, ydof );
513 if ( orient == 0 && m_Road0->GetQuadFitOk() || orient == 1 && m_Road1->GetQuadFitOk() )
515 m_Part, m_Seg, gap, a, b, c, whichhalf, quad_x1, quad_y1, quad_z1, quad_x2, quad_y2,
516 quad_z2, sigmaX, sigmaY, sigmaZ );
522 const float y0,
float& x,
float& y,
float& z ) {
523 float svx = 0, svy = 0, sx0 = 0, sy0 = 0;
524 float sigmaX, sigmaY, sigmaZ;
526 svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX,
533 float& y2,
float& z2 )
535 float sigmaX1, sigmaY1, sigmaZ1;
536 float sigmaX2, sigmaY2, sigmaZ2;
553 cout <<
"MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
557 float vx, vy, vk, vr;
558 float x0, y0, k0, r0;
559 float svx, svy, svk, svr;
560 float sx0, sy0, sk0, sr0;
568 m_Road0->GetSimpleFitParams( vr, r0, svr, sr0, chi2x, xdof );
569 m_Road1->GetSimpleFitParams( vk, k0, svk, sk0, chi2y, ydof );
577 m_Road0->GetSimpleFitParams( vy, y0, svy, sy0, chi2y, ydof );
578 m_Road1->GetSimpleFitParams( vx, x0, svx, sx0, chi2x, xdof );
588 m_Part, m_Seg, gap, vx, vy, 1.0, x0, y0, 0.0, svx, svy, 0.0, sx0, sy0, 0.0, x1, y1, z1,
589 x2, y2, z2, sigmaX1, sigmaY1, sigmaZ1, sigmaX2, sigmaY2, sigmaZ2 );
598 int projectwithquad = 0;
599 if ( m_Part == 1 && projectwithquad )
601 m_Road1->GetSimpleFitParams( a, b, c, whichhalf, sa, sb, sc, chi2x, ydof );
604 if ( m_Road1->GetQuadFitOk() )
607 m_Part, m_Seg, gap, vy, x0, y0, 0.0, a, b, c,
608 whichhalf, svx, svy, 0.0, sx0, sy0, 0.0, x1, y1, z1, x2, y2, z2, sigmaX1, sigmaY1,
618 if ( orient == 0 ) {
return m_Road0; }
619 else {
return m_Road1; }
626 vector<Identifier> idCon;
627 vector<Identifier>::iterator hit;
628 vector<Identifier> hitRoad0 = m_Road0->
GetHitsID();
629 vector<Identifier> hitRoad1 = m_Road1->GetHitsID();
634 for ( hit = hitRoad0.begin(); hit != hitRoad0.end(); hit++ )
637 idCon.push_back( *hit );
642 for ( hit = hitRoad1.begin(); hit != hitRoad1.end(); hit++ )
645 idCon.push_back( *hit );
654 const float& r0,
float& vx,
float& vy,
float& x0,
664 float phi = 0.25 *
kPi * m_Seg;
671 if (
cos( phi ) + vk *
sin( phi ) == 0.0 )
673 cout <<
" track parallel to gap, some error occurs! " << endl;
690 float atan_vk = atan( vk );
691 if ( atan_vk < 0 ) atan_vk +=
kPi;
696 float deltaPhi = atan_vk - ( m_Seg % 4 ) * ( 0.25 *
kPi );
701 vx = ( vr / fabs(
cos( deltaPhi ) ) ) *
GetVxSign( vk ) / sqrt( 1.0 + vk * vk );
703 x0 = ( r0 - k0 *
sin( phi ) ) / ( vk *
sin( phi ) +
cos( phi ) );
708 if ( fabs( vr ) > 10000 )
710 if ( vr > 0 ) safe_vr = 10000;
711 else safe_vr = -10000;
712 vx = ( safe_vr / fabs(
cos( deltaPhi ) ) ) *
GetVxSign( vk ) / sqrt( 1.0 + vk * vk );
715 x0 = ( y0 - k0 ) / vk;
721 float segmentPhiMin = 0.25 *
kPi * ( m_Seg - 2 );
722 float segmentPhiMax = 0.25 *
kPi * ( m_Seg + 2 );
725 segmentPhiMin -= 2.0 *
kPi;
726 segmentPhiMax -= 2.0 *
kPi;
730 float theta = atan( vk );
731 if ( theta >= segmentPhiMin && theta <= segmentPhiMax )
return 1.0;
737 m_Road0->PrintHitsInfo();
738 m_Road1->PrintHitsInfo();
740 cout <<
"Intersection with each gap : " << endl;
741 for (
int iGap = 0; iGap <= m_LastGap; iGap++ )
743 float x, y, z, sigmaX, sigmaY, sigmaZ;
745 cout <<
" gap " << iGap <<
" (" << x <<
", " << y <<
", " << z <<
")" << endl;
HepGeom::Point3D< double > HepPoint3D
DOUBLE_PRECISION count[3]
double sin(const BesAngle a)
double cos(const BesAngle a)
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input READ never touch them !$ !debug facility $ !maximum weight $ !inverse alfaQED $ !minimum real photon IR regulator $ !ficticious photon IR regulator $ !Enhancement factor for Crude photon multiplicity $ !technical cut on E Ebeam for non IR real contributions $ !output cross section available through getter $ !output crossxsection available through getter *EVENT $ !e beam $ !e beam $ !final fermion $ !final anti fermion $ !photon momenta $ !MAIN weight of KK2f $ !crude distr from ISR and FSR $ !complete list of weights $ !complete list of weights $ !crude in nanobarns $ !Crude Born $ for fsr $ !photon for
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.
void GetVertexPos(float &x, float &y, float &z) const
Position of the vertex point.
int GetLastGap() const
Which gap is the last one with hits attached to this road?
int GetPart() const
In which part was this road found?
int GetSeg() const
In which segment was this road found?
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)
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.