BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MucRec3DRoad.cxx
Go to the documentation of this file.
1//$id$
2//
3//$log$
4
5/*
6 * 2003/12/25 Zhengyun You Peking University
7 *
8 * 2005/02/27 Zhengyun You Peking University
9 * transplanted to Gaudi framework
10 */
11
12#include <CLHEP/Geometry/Point3D.h>
13#include <CLHEP/Vector/ThreeVector.h>
14#include <iostream>
15#include <vector>
16
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"
24
25// Constructor.
27 : m_Road0( road0 )
28 , m_Road1( road1 )
29 , m_Index( -1 )
30 , m_Part( road0->GetPart() )
31 , m_Seg( road0->GetSeg() )
32 , m_LastGap( 0 )
33 , m_Group( -1 ) {
34 float x, y, z;
35 road0->GetVertexPos( x, y, z );
36 m_VertexPos.setX( x );
37 m_VertexPos.setY( y );
38 m_VertexPos.setZ( z );
39
40 // If the part numbers don't match, something is seriously wrong!
41 if ( ( road1->GetPart() != m_Part ) || ( road1->GetSeg() != m_Seg ) )
42 {
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;
46 m_Part = -1;
47 m_Seg = -1;
48 }
49
50 // Compute the last-gap parameter; take the deeper of the 1D roads.
51 if ( road1->GetLastGap() > road0->GetLastGap() ) { m_LastGap = road1->GetLastGap(); }
52 else { m_LastGap = road0->GetLastGap(); }
53
54 // Check that the two 1D roads have clusters in the same panels.
55 // FIXME: logic needs more thought!
56
57 // Calculate the chi-square and number of degrees of freedom of the
58 // 2-D trajectory (use the "simple" fits).
59 // FIXME: Can we calc. chi-square without brute force?
60
61 m_DOF = m_Road0->GetDegreesOfFreedom() + m_Road1->GetDegreesOfFreedom();
62 m_Chi2 = 0.0;
63
64 for ( int gap = 0; gap < (int)MucID::getGapMax(); gap++ )
65 {
66 MucRecHit* hit;
67 float dist, sigma;
68 hit = m_Road0->GetHit( gap );
69 if ( hit )
70 {
71 if ( hit->Part() == 1 ) sigma = hit->GetCenterSigma().y(); // ???
72 else sigma = hit->GetCenterSigma().y();
73
74 dist = m_Road0->GetHitDistance( hit ) / sigma;
75 m_Chi2 += dist * dist;
76 // cout<<"in MucRec3DRoad dist1="<<dist<<" hitdis "<<dist*sigma<<" sigma="<<sigma<<"
77 // chi2="<<m_Chi2<<endl;
78 }
79
80 hit = m_Road1->GetHit( gap );
81 if ( hit )
82 {
83 if ( hit->Part() == 1 )
84 {
85 // sigma = fabs(sqrt( (hit->GetCenterSigma().x())*(hit->GetCenterSigma().x())
86 // + (hit->GetCenterSigma().y())*(hit->GetCenterSigma().y()) ));
87 sigma = hit->GetCenterSigma().x();
88 }
89 else { sigma = hit->GetCenterSigma().x(); }
90 dist = m_Road1->GetHitDistance( hit ) / sigma;
91 m_Chi2 += dist * dist;
92 // cout<<"in MucRec3DRoad dist2="<<dist<<" hitdis "<<dist*sigma<<" sigma="<<sigma<<"
93 // chi2="<<m_Chi2<<endl;
94 }
95 }
96}
97
98// Copy constructor.
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 ) {}
111
112// Destructor.
114 // The 3D road objects do not "own" 2D objects, so don't delete them
115 // here!
116}
117
118// Set the index for this road.
119void MucRec3DRoad::SetIndex( const int& index ) {
120 if ( index >= 0 ) m_Index = index;
121}
122
123// Set the group index for this road.
124void MucRec3DRoad::SetGroup( const int& Group ) {
125 if ( Group >= 0 ) m_Group = Group;
126}
127
128// Set the fit parameters : slope and intercept for XZ and YZ.
129void MucRec3DRoad::SetSimpleFitParams( const float& slopeZX, const float& interceptZX,
130 const float& slopeZY, const float& interceptZY ) {
131 m_SlopeZX = slopeZX;
132 m_InterceptZX = interceptZX;
133 m_SlopeZY = slopeZY;
134 m_InterceptZY = interceptZY;
135}
136
137// the index for this road in the current event.
138int MucRec3DRoad::GetIndex() const { return m_Index; }
139
140// the group index for this road in the current event.
141int MucRec3DRoad::GetGroup() const { return m_Group; }
142
143// In which part was this road found?
144int MucRec3DRoad::GetPart() const { return m_Part; }
145
146// In which seg was this road found?
147int MucRec3DRoad::GetSeg() const { return m_Seg; }
148
149// Which gap is the last one with hits attached to this road?
150int MucRec3DRoad::GetLastGap() const { return m_LastGap; }
151
152// How many gaps provide hits attached to this road?
154 int count = 0;
155 for ( int gap = 0; gap < (int)MucID::getGapMax(); gap++ )
156 {
157 if ( ( m_Road0->GetHitsPerGap( gap ) > 0 ) || ( m_Road1->GetHitsPerGap( gap ) > 0 ) )
158 { count++; }
159 }
160 return count;
161}
162
163// How many hits in all does this road contain?
165 return ( m_Road0->GetTotalHits() + m_Road1->GetTotalHits() );
166}
167
168// How many hits per gap does this road contain?
169int MucRec3DRoad::GetHitsPerGap( const int& gap ) const {
170 if ( ( gap < 0 ) || ( gap >= (int)MucID::getGapMax() ) )
171 {
172 cout << "MucRec3DRoad::HitsPerGap-E1 invalid gap = " << gap << endl;
173 return 0;
174 }
175
176 return ( m_Road0->GetHitsPerGap( gap ) + m_Road1->GetHitsPerGap( gap ) );
177}
178
179// How many hits were attached in the gap with the most attached hits?
181 int nHit0 = m_Road0->GetMaxHitsPerGap();
182 int nHit1 = m_Road1->GetMaxHitsPerGap();
183 if ( nHit0 > nHit1 ) { return nHit0; }
184 else { return nHit1; }
185}
186
187// Does this road contain any hits in the given gap?
188bool MucRec3DRoad::HasHitInGap( const int& gap ) const {
189 if ( ( gap < 0 ) || ( gap >= (int)MucID::getGapMax() ) )
190 {
191 cout << "MucRec3DRoad::HasHitInGap-E2 invalid gap = " << gap << endl;
192 return false;
193 }
194
195 return ( m_Road0->HasHitInGap( gap ) || m_Road1->HasHitInGap( gap ) );
196}
197
198// How many hits do two roads share?
200 if ( !road ) { return 0; }
201
202 int count = 0;
203 count += m_Road0->GetNSharedHits( road->Get2DRoad( int( 0 ) ) );
204 count += m_Road1->GetNSharedHits( road->Get2DRoad( int( 1 ) ) );
205
206 return count;
207}
208
209// Difference between the last gap in the two 2-D roads.
211 return abs( m_Road0->GetLastGap() - m_Road1->GetLastGap() );
212}
213
214// Difference between the number of hits in the two 2-D roads.
216 return abs( m_Road0->GetTotalHits() - m_Road1->GetTotalHits() );
217}
218
219// How many degrees of freedom in the trajectory fit?
220int MucRec3DRoad::GetDegreesOfFreedom() const { return m_DOF; }
221
222// Chi-square parameter (per degree of freedom) of the trajectory fit.
224 if ( m_DOF < 0 ) { return -1.0; }
225 else
226 {
227 if ( m_DOF == 0 ) { return 0.0; }
228 else { return ( m_Chi2 / m_DOF ); }
229 }
230}
231
232// Get Z-X dimension slope.
233float MucRec3DRoad::GetSlopeZX() const { return m_SlopeZX; }
234
235// Get Z-X dimension intercept.
236float MucRec3DRoad::GetInterceptZX() const { return m_InterceptZX; }
237
238// Get Z-Y dimension slope.
239float MucRec3DRoad::GetSlopeZY() const { return m_SlopeZY; }
240
241// Get Z-Y dimension intercept.
242float MucRec3DRoad::GetInterceptZY() const { return m_InterceptZY; }
243
244// Get a pointer to the hit attached in a particular gap.
245MucRecHit* MucRec3DRoad::GetHit( const int& gap ) const {
246 if ( ( gap < 0 ) || ( gap >= (int)MucID::getGapMax() ) )
247 {
248 cout << "MucRec3DRoad::GetHit-E1 invalid gap = " << gap << endl;
249 return 0;
250 }
251
252 if ( m_Road0->GetHit( gap ) ) { return m_Road0->GetHit( gap ); }
253 else
254 {
255 if ( m_Road1->GetHit( gap ) ) { return m_Road1->GetHit( gap ); }
256 }
257 return 0;
258}
259
260int MucRec3DRoad::RefitNoCurrentGap( const int& gap, float& slopeZX, float& interceptZX,
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;
266 int xdof, ydof;
267 float chi2x, chi2y;
268 float spos0, spos1;
269
270 // Determine the projection point of the "simple" fit to the desired gap.
271 int status1, status2;
272
273 // now these 2 2D road have been refit without current gap!
274 if ( m_Part == 1 )
275 {
276 status1 = m_Road0->SimpleFitNoCurrentGap( gap, vr, r0, svr, sr0, chi2x, xdof );
277 status2 = m_Road1->SimpleFitNoCurrentGap( gap, vk, k0, svk, sk0, chi2y, ydof );
278
279 m_Road0->GetPosSigma( spos0 );
280 m_Road1->GetPosSigma( spos1 );
281
282 TransformPhiRToXY( vk, vr, k0, r0, vx, vy, x0, y0 );
283
284 // TransformPhiRToXY(svk, svr, sk0, sr0, svx, svy, sx0, sy0);
285 TransformPhiRToXY( vk + svk, vr + svr, k0 + sk0, r0 + sr0, svx, svy, sx0, sy0 );
286 svx -= vx;
287 svy -= vy;
288 sx0 -= x0;
289 sy0 -= y0;
290 }
291 else
292 {
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 );
297 }
298
299 if ( status1 == -1 || status2 == -1 ) return -1;
300 slopeZX = vx;
301 interceptZX = x0;
302 slopeZY = vy;
303 interceptZY = y0;
304
305 return 0;
306}
307
308// Where does the trajectory of this road intersect a specific strip? ---for calib
309vector<Identifier> MucRec3DRoad::ProjectToStrip( const int& part, const int& gap,
310 const HepPoint3D& gPoint,
311 const Hep3Vector& gDirection ) {
312 if ( ( part < 0 ) || ( part >= (int)MucID::getPartNum() ) )
313 { cout << "MucRec3DRoad::Project-E1 invalid part = " << part << endl; }
314
315 if ( ( gap < 0 ) || ( gap >= (int)MucID::getGapMax() ) )
316 { cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl; }
317
318 return MucGeoGeneral::Instance()->FindIntersectStrips( part, gap, gPoint, gDirection );
319}
320
321vector<Identifier>
322MucRec3DRoad::ProjectToStrip( const int& part, const int& gap, const HepPoint3D& gPoint,
323 const Hep3Vector& gDirection, vector<int>& padID,
324 vector<float>& intersect_x, vector<float>& intersect_y,
325 vector<float>& intersect_z ) {
326 if ( ( part < 0 ) || ( part >= (int)MucID::getPartNum() ) )
327 { cout << "MucRec3DRoad::Project-E1 invalid part = " << part << endl; }
328
329 if ( ( gap < 0 ) || ( gap >= (int)MucID::getGapMax() ) )
330 { cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl; }
331
333 part, gap, gPoint, gDirection, padID, intersect_x, intersect_y, intersect_z );
334}
335
336// Where does the trajectory of this road intersect a specific gap?
337void MucRec3DRoad::ProjectWithSigma( const int& gap, float& x, float& y, float& z,
338 float& sigmaX, float& sigmaY, float& sigmaZ ) {
339 x = 0.0;
340 sigmaX = 0.0;
341 y = 0.0;
342 sigmaY = 0.0;
343 z = 0.0;
344 sigmaZ = 0.0;
345
346 if ( ( gap < 0 ) || ( gap >= (int)MucID::getGapMax() ) )
347 {
348 cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
349 return;
350 }
351
352 float vx, vy, vk, vr;
353 float x0, y0, k0, r0;
354 float svx, svy, svk, svr;
355 float sx0, sy0, sk0, sr0;
356 int xdof, ydof;
357 float chi2x, chi2y;
358 float spos0, spos1;
359
360 // Determine the projection point of the "simple" fit to the desired gap.
361 if ( m_Part == 1 )
362 {
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 );
367
368 TransformPhiRToXY( vk, vr, k0, r0, vx, vy, x0, y0 );
369 // TransformPhiRToXY(svk, svr, sk0, sr0, svx, svy, sx0, sy0);
370 TransformPhiRToXY( vk + svk, vr + svr, k0 + sk0, r0 + sr0, svx, svy, sx0, sy0 );
371 svx -= vx;
372 svy -= vy;
373 sx0 -= x0;
374 sy0 -= y0;
375 }
376 else
377 {
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 );
382 }
383
384 /*
385 cout << " vr " << vr << " vk " << vk << endl;
386 cout << " r0 " << r0 << " k0 " << k0 << endl;
387 cout << " vx " << vx << " vy " << vy << endl;
388 cout << " x0 " << x0 << " y0 " << y0 << endl;
389 */
390
391 MucGeoGeneral::Instance()->FindIntersection( m_Part, m_Seg, gap, vx, vy, 1.0, x0, y0, 0.0,
392 svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX,
393 sigmaY, sigmaZ );
394 /*
395 if(fabs(vr)>10000) ///////////////////if fabs(vr) too big, r0 will be intersection in x
396 coordinate!!! MucGeoGeneral::Instance()->FindIntersection(m_Part, m_Seg, gap, vx, vy, 1.0,
397 x0, y0, r0, svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX, sigmaY, sigmaZ);
398 */
399
400 sigmaX = spos1;
401 sigmaY = spos0;
402 sigmaZ = 0.0;
403
404 float a, b, c;
405 float sa, sb, sc;
406 int whichhalf;
407 // cout<<"in MucRec3DRoad xyz form linefit "<<x<<" "<<y<<" "<<z<<endl;
408
409 if ( m_Part == 1 )
410 {
411 m_Road1->GetSimpleFitParams( a, b, c, whichhalf, sa, sb, sc, chi2x, ydof );
412 // cout<<"in MucRec3DRoad "<<vy<<" "<<y0<<" "<<a<<" "<<b<<" "<<c<<endl;
413 }
414
415 return;
416}
417
418// Where does the trajectory of this road intersect a specific gap?
419void MucRec3DRoad::ProjectNoCurrentGap( const int& gap, float& x, float& y, float& z,
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 ) {
423
424 x = 0.0;
425 sigmaX = 0.0;
426 y = 0.0;
427 sigmaY = 0.0;
428 z = 0.0;
429 sigmaZ = 0.0;
430
431 if ( ( gap < 0 ) || ( gap >= (int)MucID::getGapMax() ) )
432 {
433 cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
434 return;
435 }
436
437 float vx, vy, vk, vr;
438 float x0, y0, k0, r0;
439 float svx, svy, svk, svr;
440 float sx0, sy0, sk0, sr0;
441 int xdof, ydof;
442 float chi2x, chi2y;
443 float spos0, spos1;
444
445 // Determine the projection point of the "simple" fit to the desired gap.
446
447 // now these 2 2D road have been refit without current gap!
448 if ( m_Part == 1 )
449 {
450 m_Road0->SimpleFitNoCurrentGap( gap, vr, r0, svr, sr0, chi2x, xdof );
451 m_Road1->SimpleFitNoCurrentGap( gap, vk, k0, svk, sk0, chi2y, ydof );
452
453 m_Road0->GetPosSigma( spos0 );
454 m_Road1->GetPosSigma( spos1 );
455
456 TransformPhiRToXY( vk, vr, k0, r0, vx, vy, x0, y0 );
457
458 // TransformPhiRToXY(svk, svr, sk0, sr0, svx, svy, sx0, sy0);
459 TransformPhiRToXY( vk + svk, vr + svr, k0 + sk0, r0 + sr0, svx, svy, sx0, sy0 );
460 svx -= vx;
461 svy -= vy;
462 sx0 -= x0;
463 sy0 -= y0;
464 }
465 else
466 {
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 );
471 }
472 /*
473 cout << " vr " << vr << " vk " << vk << endl;
474 cout << " r0 " << r0 << " k0 " << k0 << endl;
475 cout << " vx " << vx << " vy " << vy << endl;
476 cout << " x0 " << x0 << " y0 " << y0 << endl;
477 */
478
479 MucGeoGeneral::Instance()->FindIntersection( m_Part, m_Seg, gap, vx, vy, 1.0, x0, y0, 0.0,
480 svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX,
481 sigmaY, sigmaZ );
482 if ( fabs( vr ) > 10000 ) ///////////////////if fabs(vr) too big, r0 will be intersection in
483 /// x coordinate!!!
484 MucGeoGeneral::Instance()->FindIntersection( m_Part, m_Seg, gap, vx, vy, 1.0, x0, y0, r0,
485 svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX,
486 sigmaY, sigmaZ );
487
488 sigmaX = spos1;
489 sigmaY = spos0;
490 sigmaZ = 0.0;
491
492 float a, b, c;
493 float sa, sb, sc;
494 int whichhalf;
495
496 // calc orient now
497 int orient = 0;
498 if ( m_Part == 1 && gap % 2 == 0 ) orient = 1;
499 if ( m_Part != 1 && gap % 2 == 1 ) orient = 1;
500
501 if ( orient == 0 )
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 );
504
505 // cout<<"orient = "<<orient<<" abc: "<<a<<" "<<b<<" "<<c<<endl;
506 quad_x1 = -9999;
507 quad_y1 = -9999;
508 quad_z1 = -9999;
509 quad_x2 = -9999;
510 quad_y2 = -9999;
511 quad_z2 = -9999;
512
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 );
517
518 return;
519}
520
521void MucRec3DRoad::Project( const int& gap, const float vx, const float x0, const float vy,
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;
525 MucGeoGeneral::Instance()->FindIntersection( m_Part, m_Seg, gap, vx, vy, 1.0, x0, y0, 0.0,
526 svx, svy, 0.0, sx0, sy0, 0.0, x, y, z, sigmaX,
527 sigmaY, sigmaZ );
528}
529
530// Where does the trajectory of this road intersect two surface of a specific gap?
531// a line or a parabola!
532void MucRec3DRoad::Project( const int& gap, float& x1, float& y1, float& z1, float& x2,
533 float& y2, float& z2 ) // x1: inner; x2: outer
534{
535 float sigmaX1, sigmaY1, sigmaZ1;
536 float sigmaX2, sigmaY2, sigmaZ2;
537
538 x1 = 0.0;
539 sigmaX1 = 0.0;
540 y1 = 0.0;
541 sigmaY1 = 0.0;
542 z1 = 0.0;
543 sigmaZ1 = 0.0;
544 x2 = 0.0;
545 sigmaX2 = 0.0;
546 y2 = 0.0;
547 sigmaY2 = 0.0;
548 z2 = 0.0;
549 sigmaZ2 = 0.0;
550
551 if ( ( gap < 0 ) || ( gap >= (int)MucID::getGapMax() ) )
552 {
553 cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
554 return;
555 }
556
557 float vx, vy, vk, vr;
558 float x0, y0, k0, r0;
559 float svx, svy, svk, svr;
560 float sx0, sy0, sk0, sr0;
561 int xdof, ydof;
562 float chi2x, chi2y;
563
564 // Determine the projection point of the "simple" fit to the desired gap.
565
566 if ( m_Part == 1 )
567 {
568 m_Road0->GetSimpleFitParams( vr, r0, svr, sr0, chi2x, xdof );
569 m_Road1->GetSimpleFitParams( vk, k0, svk, sk0, chi2y, ydof );
570 TransformPhiRToXY( vk, vr, k0, r0, vx, vy, x0, y0 );
571
572 // cout<<"in MucRec3DRoad after vx,vy"<<endl;
573 TransformPhiRToXY( svk, svr, sk0, sr0, svx, svy, sx0, sy0 );
574 }
575 else
576 {
577 m_Road0->GetSimpleFitParams( vy, y0, svy, sy0, chi2y, ydof );
578 m_Road1->GetSimpleFitParams( vx, x0, svx, sx0, chi2x, xdof );
579 }
580 /*
581 cout << " vr " << vr << " vk " << vk << endl;
582 cout << " r0 " << r0 << " k0 " << k0 << endl;
583 cout << " vx " << vx << " vy " << vy << endl;
584 cout << " x0 " << x0 << " y0 " << y0 << endl;
585 */
586
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 );
590
591 float a, b, c;
592 float sa, sb, sc;
593 int whichhalf;
594 // cout<<"in MucRec3DRoad xyz form linefit "<<x1<<" "<<y1<<" "<<z1<<" "<<x2<<" "<<y2<<"
595 // "<<z2<<endl;
596
597 // if this trajectory is parabola!
598 int projectwithquad = 0;
599 if ( m_Part == 1 && projectwithquad )
600 {
601 m_Road1->GetSimpleFitParams( a, b, c, whichhalf, sa, sb, sc, chi2x, ydof );
602
603 // cout<<"in MucRec3DRoad "<<vy<<" "<<y0<<" "<<a<<" "<<b<<" "<<c<<endl;
604 if ( m_Road1->GetQuadFitOk() )
605 {
607 m_Part, m_Seg, gap, vy, x0, y0, 0.0, a, b, c, // y = a*x*x + b*x +c
608 whichhalf, svx, svy, 0.0, sx0, sy0, 0.0, x1, y1, z1, x2, y2, z2, sigmaX1, sigmaY1,
609 sigmaZ1 );
610 }
611 }
612
613 return;
614}
615
616// get a pointer to the 2D road in the 3D road
617MucRec2DRoad* MucRec3DRoad::Get2DRoad( const int& orient ) const {
618 if ( orient == 0 ) { return m_Road0; }
619 else { return m_Road1; }
620}
621
622// Get indices of all hits in the road.
623vector<Identifier> MucRec3DRoad::GetHitsID() const
624
625{
626 vector<Identifier> idCon;
627 vector<Identifier>::iterator hit;
628 vector<Identifier> hitRoad0 = m_Road0->GetHitsID();
629 vector<Identifier> hitRoad1 = m_Road1->GetHitsID();
630
631 // List will be ordered by orientation.
632
633 // Road0 first ...
634 for ( hit = hitRoad0.begin(); hit != hitRoad0.end(); hit++ )
635 {
636 int index = *hit;
637 idCon.push_back( *hit );
638 // cout << " MucRec3DRoad::HitIndices Road0 = " << index << endl;
639 }
640
641 // ... then Road1.
642 for ( hit = hitRoad1.begin(); hit != hitRoad1.end(); hit++ )
643 {
644 int index = *hit;
645 idCon.push_back( *hit );
646 // cout << " MucRec3DRoad::HitIndices Road1 = " << index << endl;
647 }
648
649 return idCon;
650}
651
652// Transform the Phi, ZR cord. to ZX, ZY cord.
653void MucRec3DRoad::TransformPhiRToXY( const float& vk, const float& vr, const float& k0,
654 const float& r0, float& vx, float& vy, float& x0,
655 float& y0 ) const {
656 vx = 0.0;
657 vy = 0.0;
658 x0 = 0.0;
659 y0 = 0.0;
660
661 // cout << vk << " " << vr << " " << endl;
662
663 // float pi = 3.1415926536;
664 float phi = 0.25 * kPi * m_Seg;
665
666 // From y0 = vk * x0 + k0;
667 // y0 - r0*sin(phi)
668 // ------------------ = tan(phi + 0.5*kPi);
669 // x0 - r0*cos(phi)
670
671 if ( cos( phi ) + vk * sin( phi ) == 0.0 )
672 {
673 cout << " track parallel to gap, some error occurs! " << endl;
674 // m_Seg = 1, and vk = -1;
675 // 2, 0;
676 // 3, 1;
677 // 5, -1;
678 // 6, 0;
679 // 7, 1;
680 }
681 else
682 {
683 /*
684 vx = vr / ( cos(phi) + vk*sin(phi) );
685 vy = vk * vx;
686 x0 = (r0 - k0) / ( cos(phi) + vk );
687 y0 = vk * x0 + k0;
688 */
689
690 float atan_vk = atan( vk );
691 if ( atan_vk < 0 ) atan_vk += kPi;
692
693 // float deltaPhi = fabs(atan(vk)) - int( fabs(atan(vk))/(0.25*kPi) )*0.25*kPi;
694 // if (deltaPhi > 0.125*kPi) deltaPhi = 0.25*kPi - delta
695
696 float deltaPhi = atan_vk - ( m_Seg % 4 ) * ( 0.25 * kPi );
697
698 // vx = vr*cos(deltaPhi)*GetVxSign(vk)/sqrt(1.0+vk*vk); //change to vr/cos()... liangyt
699 // 2007.4.10 I think it should be vr/cos...
700
701 vx = ( vr / fabs( cos( deltaPhi ) ) ) * GetVxSign( vk ) / sqrt( 1.0 + vk * vk );
702 vy = vk * vx;
703 x0 = ( r0 - k0 * sin( phi ) ) / ( vk * sin( phi ) + cos( phi ) );
704 y0 = vk * x0 + k0;
705
706 float safe_vr = vr;
707
708 if ( fabs( vr ) > 10000 )
709 {
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 );
713 vy = vk * vx;
714 y0 = -vy * r0;
715 x0 = ( y0 - k0 ) / vk;
716 }
717 }
718}
719
720float MucRec3DRoad::GetVxSign( const float vk ) const {
721 float segmentPhiMin = 0.25 * kPi * ( m_Seg - 2 );
722 float segmentPhiMax = 0.25 * kPi * ( m_Seg + 2 );
723 if ( m_Seg > 4 )
724 {
725 segmentPhiMin -= 2.0 * kPi;
726 segmentPhiMax -= 2.0 * kPi;
727 }
728
729 // vk = tan(theta); theta = atan(vk); -90<theta<90
730 float theta = atan( vk );
731 if ( theta >= segmentPhiMin && theta <= segmentPhiMax ) return 1.0;
732 else return -1.0;
733}
734
735// Print Hits Infomation.
737 m_Road0->PrintHitsInfo();
738 m_Road1->PrintHitsInfo();
739
740 cout << "Intersection with each gap : " << endl;
741 for ( int iGap = 0; iGap <= m_LastGap; iGap++ )
742 {
743 float x, y, z, sigmaX, sigmaY, sigmaZ;
744 ProjectWithSigma( iGap, x, y, z, sigmaX, sigmaY, sigmaZ );
745 cout << " gap " << iGap << " (" << x << ", " << y << ", " << z << ")" << endl;
746 }
747}
HepGeom::Point3D< double > HepPoint3D
DOUBLE_PRECISION count[3]
************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
Definition KK2f.h:69
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()
Definition MucID.cxx:165
static value_type getPartNum()
Definition MucID.cxx:131
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).
Definition MucRecHit.cxx:99