eic-smear  1.0.3
A collection of ROOT classes for Monte Carlo events and a fast-smearing code simulating detector effects for the Electron-Ion Collider task force
PlanarTracker.cxx
Go to the documentation of this file.
1 
11 
12 #include <algorithm>
13 #include <cmath>
14 #include <limits>
15 #include <list>
16 
17 #include <TMath.h>
18 
19 namespace Smear {
20 
22 : Tracker(2., 0.03, 0.001)
23 , mNPlanes(25.)
24 , mInnerRadius(0.1)
25 , mOuterRadius(1.)
26 , mZMin(-1.5)
27 , mZMax(1.5) {
28 }
29 
30 PlanarTracker::PlanarTracker(double inner, double outer,
31  double zmin, double zmax,
32  double Bb, double nrl,
33  double sigmaRPhi, double N)
34 : Tracker(Bb, nrl, sigmaRPhi)
35 , mNPlanes(N)
36 , mInnerRadius(inner)
37 , mOuterRadius(outer)
38 // Require zmin < zmax
39 , mZMin(std::min(zmin, zmax))
40 , mZMax(std::max(zmin, zmax)) {
41 }
42 
44 }
45 
46 void PlanarTracker::Print(Option_t* /* option */) const {
47  std::cout << ClassName() << " with:" << std::endl <<
48  "\tinner radius " << mInnerRadius << " m\n" <<
49  "\touter radius " << mOuterRadius << " m\n" <<
50  "\tlength " << mZMin << " to " << mZMax <<
51  " (= " << mZMax - mZMin << ") m\n" <<
52  "\tmagnetic field " << mMagField << " Tesla\n" <<
53  "\t" << mNRadLengths << " radiation lengths\n" <<
54  "\tpoint resolution " << mSigmaRPhi * 1.e6 << " microns\n" <<
55  "\t" << mNPlanes << " planes" << std::endl;
56 }
57 
59  if (mZMax > 0.) {
60  return atan2(mInnerRadius, mZMax);
61  } else {
62  return atan2(mOuterRadius, mZMax);
63  } // if
64 }
65 
67  if (mZMin > 0.) {
68  return atan2(mOuterRadius, mZMin);
69  } else {
70  return atan2(mInnerRadius, mZMin);
71  } // if
72 }
73 
75  const erhic::VirtualParticle& p, double radius) const {
76  // Compute the longitudinal position at which the intersection occurs.
77  // Adjust for any z offset in the vertex of the particle.
78  const double z = radius / tan(p.GetTheta()) + p.GetVertex().z();
79  TVector3 intersection(0., 0., std::numeric_limits<double>::quiet_NaN());
80  if (z > mZMin && z < mZMax) {
81  // Don't care about phi angle, so set x and y arbitrarily.
82  intersection.SetXYZ(radius, 0., z);
83  } // if
84  return intersection;
85 }
86 
87 TVector3 PlanarTracker::ComputeIntersectionWithPlane(
88  const erhic::VirtualParticle& p, double z) const {
89  // Compute the radius of intersection, adusting for any z ooffset
90  // in the particle vertex.
91  const double r = (z - p.GetVertex().z()) * tan(p.GetTheta());
92  TVector3 intersection(0., 0., std::numeric_limits<double>::quiet_NaN());
93  if (r > mInnerRadius && r < mOuterRadius) {
94  // Don't care about phi angle, so set x and y arbitrarily.
95  intersection.SetXYZ(r, 0., z);
96  } // if
97  return intersection;
98 }
99 
100 double PlanarTracker::L(const erhic::VirtualParticle& p) const {
101  float r1 = 0., r2 = 0., pi = 3.1415926535;
102  double zPlane1 = 0., zPlane2 = 0., Length = 0.;
103  // Find radial/z points of first and last plane intersection.
104  // (While there are certainly eaiser ways to carry out this
105  // calculation, I used a manual check at each z-plane since
106  // it is easier to generalize to arbitrarily spaced planes.)
107  for (int i = 0; i < mNPlanes; i++) {
108  zPlane1 = mZMin + i * (mZMax - mZMin) / (mNPlanes - 1);
109  r1 = fabs(tan(p.GetTheta()) * zPlane1);
110  if ((r1 > mInnerRadius) && (r1 < mOuterRadius)) {
111  if (((p.GetTheta() < pi / 2.) && (zPlane1 > 0.)) ||
112  ((p.GetTheta() > pi / 2.) && (zPlane1 < 0.))) {
113  zPlane2 = zPlane1 + (NPoints(p) - 1) * (mZMax - mZMin) / (mNPlanes - 1);
114  r2 = fabs(tan(p.GetTheta()) * zPlane2);
115  break;
116  } // if
117  } // if
118  } // for
119  Length = sqrt((zPlane2 - zPlane1) * (zPlane2 - zPlane1) +
120  (r2 - r1) * (r2 - r1));
121  return Length;
122 }
123 
125  float r1 = 0., r2 = 0., pi = 3.1415926535;
126  double zPlane1 = 0., zPlane2 = 0.;
127  // Find radial points of first/ and last plane intersection.
128  for (int i = 0; i < mNPlanes; i++) {
129  zPlane1 = mZMin + i * (mZMax - mZMin) / (mNPlanes-1);
130  r1 = fabs(tan(p.GetTheta()) * zPlane1);
131  if ((r1 > mInnerRadius) && (r1 < mOuterRadius)) {
132  if (((p.GetTheta() < pi / 2.) && (zPlane1 > 0.)) ||
133  ((p.GetTheta() > pi / 2.) && (zPlane1 < 0.))) {
134  zPlane2 = zPlane1 + (NPoints(p) - 1) * (mZMax - mZMin) / (mNPlanes - 1);
135  r2 = fabs(tan(p.GetTheta()) * zPlane2);
136  break;
137  } // if
138  } // if
139  } // for
140  return fabs(r2 - r1);
141 }
142 
144  double zPlane = 0., pi = 3.1415926535;
145  float r = 0.;
146  int i, n = 0;
147  for (i = 0; i < mNPlanes; i++) {
148  zPlane = mZMin + i * (mZMax - mZMin) / (mNPlanes - 1);
149  // radial intersect of particle at plane position zPlane
150  r = fabs(tan(p.GetTheta()) * zPlane);
151  // At each plane, check if particle passes through
152  if ((r > mInnerRadius) && (r < mOuterRadius)) {
153  if ((p.GetTheta() < pi / 2.) && (zPlane > 0)) n++;
154  if ((p.GetTheta() > pi / 2.) && (zPlane < 0)) n++;
155  } // if
156  } // for
157  return n;
158 }
159 
161  if (NPoints(p) >= 3) {
162  return true;
163  } else {
164  return false;
165  } // if
166 }
167 
168 } // namespace Smear
double mInnerRadius
Inner radius (m)
TVector3 ComputeIntersectionWithRadius(const erhic::VirtualParticle &, double radius) const
virtual void Print(Option_t *="") const
virtual double GetThetaMin() const
double mOuterRadius
Outer radius (m)
double mSigmaRPhi
Point resolution.
Definition: Tracker.h:120
double mNRadLengths
Number of radiation lengths (dimensionless)
Definition: Tracker.h:119
double LPrime(const erhic::VirtualParticle &) const
virtual bool Accepts(const erhic::VirtualParticle &) const
double mMagField
Magnetic field strength in Tesla.
Definition: Tracker.h:118
virtual TVector3 GetVertex() const =0
double mZMin
Lower (most negative) z face.
virtual double GetThetaMax() const
double mNPlanes
Number of planes.
virtual Double_t GetTheta() const =0
virtual int NPoints(const erhic::VirtualParticle &) const
double mZMax
Upper (most positive) z face.
Abstract base class for a general particle.
double L(const erhic::VirtualParticle &) const