22 #include "StMiniMcHelper.h"
32 static Double_t sectorX[] = {
34 0.866025403784439, -0.5,
35 0.5, -0.866025403784439,
37 -0.5, -0.866025403784439,
38 -0.866025403784439, -0.5,
40 -0.866025403784439, 0.5,
41 -0.5, 0.866025403784438,
43 0.5, 0.866025403784439,
44 0.866025403784438, 0.5,
46 0.866025403784439, 0.5,
47 0.5, 0.866025403784438,
49 -0.5, 0.866025403784439,
50 -0.866025403784439, 0.5,
52 -0.866025403784439, -0.5,
53 -0.5, -0.866025403784439,
55 0.5, -0.866025403784439,
56 0.866025403784438, -0.5,
62 static Double_t sectorY[] = {
64 0.5, 0.866025403784439,
65 0.866025403784439, 0.5,
67 0.866025403784439, -0.5,
68 0.5, -0.866025403784439,
70 -0.5, -0.866025403784439,
71 -0.866025403784439, -0.5,
73 -0.866025403784439, 0.5,
74 -0.5, 0.866025403784438,
76 -0.5, 0.866025403784439,
77 -0.866025403784439, 0.5,
79 -0.866025403784439, -0.5,
80 -0.5, -0.866025403784439,
82 0.5, -0.866025403784439,
83 0.866025403784438, -0.5,
85 0.866025403784438, 0.5,
86 0.5, 0.866025403784439,
95 double distance(
double a1,
double b1,
double a2,
double b2){
96 return ::sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) );
105 return (point1-point2).mag();
118 if(fabs(helix.curvature())<=static_cast<double>(0)){
119 return lineDca2D(helix,point,*origin);
122 return helixDca2D(helix,point);
134 double z0 = helix.
origin().z();
135 double phi = atan2(point.y()-helix.
ycenter(),
138 double dphi = h*(phi-helix.
phase());
141 dphi = (fabs(dphi) < M_PI ) ? dphi :
142 ((dphi<0) ? 2*M_PI + dphi : 2*M_PI - dphi);
144 double arclength= (1./helix.curvature()) * dphi;
146 double dcaZ = (point.z() - (z0 + arclength*tan(helix.dipAngle())));
189 if(fabs(helix.curvature())<=static_cast<double>(0)){
190 return lineCrossingAngle(helix,hit);
193 return helixCrossingAngle(helix,hit,bField);
200 if(fabs(helix.curvature())<=static_cast<double>(0)){
201 return linePadrowDca(helix,hit);
204 return helixPadrowDca(helix,hit);
236 double R = 1./helix.curvature();
237 double dX = hit->position().x() - helix.
xcenter();
238 double dY = hit->position().y() - helix.
ycenter();
246 double d = TMath::Sqrt(dX*dX + dY*dY);
247 double dPerp = dX*sectorY[2*hit->sector()] +
248 dY*sectorY[2*hit->sector() + 1];
256 x = - dX*sectorY[2*hit->sector() + 1] +
257 dY*sectorY[2*hit->sector()];
260 double cosTheta = (dX*sectorX[2*hit->sector()] +
261 dY*sectorX[2*hit->sector() + 1])/d;
263 x = -d*cosTheta + (cosTheta<0 ? -1. : 1.) *
264 TMath::Sqrt(R*R - d*d*(1 - cosTheta*cosTheta));
269 dX = hit->position().x() + x*sectorX[2*hit->sector()];
270 dY = hit->position().y() + x*sectorX[2*hit->sector() + 1];
299 double s = propagateToPadrow(helix, hit);
300 double dX = hit->position().x() - helix.
x(s);
301 double dY = hit->position().y() - helix.y(s);
302 double dca = TMath::Sqrt(dX*dX + dY*dY);
305 if (helixDca2D(helix, hit->position()) < 0) dca *= -1.;
316 double helixCrossingAngle(
float pt,
float phi,
int sector)
318 double px=pt*cos(phi);
319 double py=pt*sin(phi);
320 double cosTheta = (px*sectorY[2*sector] +
321 py*sectorY[2*sector + 1])/pt;
328 double theta = TMath::ACos(cosTheta);
329 if (px*sectorY[2*sector + 1] -
330 py*sectorY[2*sector] > 0) theta *= -1.;
344 double s = propagateToPadrow(helix, hit);
353 double cosTheta = (p.x()*sectorY[2*hit->sector()] +
354 p.y()*sectorY[2*hit->sector() + 1])/p.perp();
375 double theta = TMath::ACos(cosTheta);
376 if (p.x()*sectorY[2*hit->sector() + 1] -
377 p.y()*sectorY[2*hit->sector()] > 0) theta *= -1.;
386 return (distance(helix.
xcenter(),point.x(),helix.
ycenter(),point.y())
387 -(1./helix.curvature()));
406 double cosPhase = cos(helix.
phase());
407 double sinPhase = sin(helix.
phase());
409 double px = point.x();
410 double py = point.y();
411 double dx = px-origin.x();
412 double dy = py-origin.y();
414 double s = cosPhase*dy-sinPhase*dx;
417 double xDca = origin.x() - s*sinPhase;
418 double yDca = origin.y() + s*cosPhase;
445 (perp.x()*sectorX[2*hit->sector()] +
446 perp.y()*sectorX[2*hit->sector()+1])/perp.perp();
448 double padrowDca = perp.perp()/fabs(cosTheta);
452 double sign = lineDca2D(helix,hit->position(),origin);
454 return (sign>=0) ? padrowDca : -padrowDca;
462 double psi = helix.
phase() + TMath::Pi()/2.;
463 double psiX = cos(psi);
464 double psiY = sin(psi);
467 psiX*sectorY[2*hit->sector()] + psiY*sectorY[2*hit->sector()+1];
471 cout <<
"%%% line crossing angle negative? "
477 double sign = psiX*sectorY[2*hit->sector()+1]-psiY*sectorY[2*hit->sector()];
479 return (sign>0) ? acos(cosTheta) : -acos(cosTheta);
487 double psi = helix.
phase() + TMath::Pi()/2.;
488 double psiX = cos(psi);
489 double psiY = sin(psi);
492 psiX*sectorY[2*sector] + psiY*sectorY[2*sector+1];
496 cout <<
"%%% line crossing angle negative? "
502 double sign = psiX*sectorY[2*sector+1]-psiY*sectorY[2*sector];
504 return (sign>0) ? acos(cosTheta) : -acos(cosTheta);
528 double cross = origin2atHit.x()*origin2hit.y()
529 - origin2atHit.y()*origin2hit.x();
531 return (cross>=0) ? dca.perp() : - dca.perp();
int h() const
y-center of circle in xy-plane
double x(double s) const
coordinates of helix at point s
double distance(const StThreeVector< double > &p, bool scanPeriods=true) const
minimal distance between point and helix
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
double ycenter() const
x-center of circle in xy-plane
const StThreeVector< double > & origin() const
-sign(q*B);
double xcenter() const
aziumth in xy-plane measured from ring center
double phase() const
1/R in xy-plane