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
Tracker.cxx
Go to the documentation of this file.
1 
10 #include "eicsmear/smear/Tracker.h"
11 
12 #include <algorithm>
13 #include <cmath>
14 #include <limits>
15 #include <list>
16 
17 #include <TMath.h>
18 
19 namespace {
20 
21 // Functor for testing non-existent intersection points,
22 struct NoIntersection {
23  bool operator()(const TVector3& v) const {
24  return TMath::IsNaN(v.z());
25  }
26 };
27 
28 } // anonymous namespace
29 
30 namespace Smear {
31 
32 Tracker::Tracker(double magneticField, double nRadiationLengths,
33  double resolution)
34 : mFactor(720) // Assume no vertex constraint.
35 , mMagField(magneticField)
36 , mNRadLengths(nRadiationLengths)
37 , mSigmaRPhi(resolution) {
38 }
39 
41 }
42 
44  const erhic::VirtualParticle& p) const {
45  // Technically should be a factor of particle charge in the numerator
46  // but this is effectively always one.
47  double val = 0.016 / 0.3 * p.GetP() * sqrt(mNRadLengths) / LPrime(p) /
48  p.Get4Vector().Beta() / mMagField;
49  if (TMath::IsNaN(val)) {
50  std::cerr << "MS nan!" << std::endl;
51  } // if
52  return val;
53 }
54 
56  const erhic::VirtualParticle& p) const {
57  // The factor
58  // sqrt(720 * N^3 / ((N-1)(N+1)(N+2)(N+3)))
59  // is a more exact version of the factor
60  // sqrt(720 / (N+5))
61  // The constant factor in the sqrt depends on whether there is
62  // a vertex constraint assumed.
63  double val = sqrt(mFactor * pow(NPoints(p), 3.)) / 0.3 * pow(p.GetP(), 2.)
64  * mSigmaRPhi / mMagField / pow(LPrime(p), 2.)
65  / sqrt((NPoints(p)-1)*(NPoints(p)+1)*(NPoints(p)+2)*(NPoints(p)+3));
66  if (TMath::IsNaN(val)) {
67  std::cerr << "Intrinsic nan!" << std::endl;
68  } // if
69  return val;
70 }
71 
73  // Don't compute resolution for very small path length
74  // as L in the denominator causes it to blow up.
75  if (!Accepts(p)) {
76  return 0.;
77  } // if
78  return sqrt(pow(MultipleScatteringContribution(p), 2.) +
79  pow(IntrinsicContribution(p), 2.));
80 }
81 
83  ParticleMCS& pOut) {
84  if (Accepts(pIn) && Accept.Is(pIn)) {
85  double y = GetVariable(pIn, kP);
86  // Randomly generate a smeared value from the resolution
87  // and set it in the smeared particle.
89  // Ensure E, p are positive definite
90  HandleBogusValues(pOut, kP);
91  if (pOut.GetP() < 0.) {
92  std::cerr << "p " << pOut.GetP() << std::endl;
93  } // if
94  if (TMath::IsNaN(pOut.GetP())) {
95  std::cerr << "p nan" << std::endl;
96  } // if
97  } // if
98 }
99 
100 void Tracker::SetVertexConstraint(bool constrain) {
101  if (constrain) {
102  mFactor = 320;
103  } else {
104  mFactor = 720;
105  } // if
106 }
107 
108 } // namespace Smear
Smear
Definition: Acceptance.cxx:16
Smear::Acceptance::Is
bool Is(const erhic::VirtualParticle &prt) const
This function determines if the particle provided lies within the acceptance of the detector.
Definition: Acceptance.cxx:46
Smear::HandleBogusValues
void HandleBogusValues(ParticleMCS &prt, KinType kin)
This dictates how the namespace deals with positive definite variables which have been smeared to neg...
Definition: Smear.h:155
Tracker.h
Smear::Tracker::Resolution
virtual double Resolution(const erhic::VirtualParticle &) const
Returns the resolution at the kinematics of this particle.
Definition: Tracker.cxx:72
Smear::ParticleMCS::GetP
virtual Double_t GetP() const
Returns the total momentum (GeV).
Definition: ParticleMCS.h:213
Smear::Tracker::Accepts
virtual bool Accepts(const erhic::VirtualParticle &) const =0
Returns true if the particle falls within the angular acceptance of the detector.
Smear::Tracker::mMagField
double mMagField
Magnetic field strength in Tesla.
Definition: Tracker.h:118
erhic::VirtualParticle::GetP
virtual Double_t GetP() const =0
Returns the magnitude of 3-momentum (GeV).
Smear::Tracker::NPoints
virtual int NPoints(const erhic::VirtualParticle &) const =0
Returns the number of measurement points for the particle.
Smear::Smearer::Accept
Acceptance Accept
Definition: Smearer.h:50
Smear::Tracker::SetVertexConstraint
void SetVertexConstraint(bool constrain)
Set whether a vertex constraint should be used when calculating the intrinsic resolution.
Definition: Tracker.cxx:100
Smear::SetVariable
void SetVariable(ParticleMCS &prt, double z, KinType kin)
Stores z in the ParticleS.K where K is the kinematic variable associated with kin.
Definition: Smear.h:132
Smear::Tracker::mSigmaRPhi
double mSigmaRPhi
Point resolution.
Definition: Tracker.h:120
Smear::Tracker::mNRadLengths
double mNRadLengths
Number of radiation lengths (dimensionless)
Definition: Tracker.h:119
Smear::Tracker::Tracker
Tracker(double magneticField=2., double nRadiationLengths=0.01, double resolution=0.001)
Constructor.
Definition: Tracker.cxx:32
erhic::VirtualParticle
Abstract base class for a general particle.
Definition: VirtualParticle.h:23
Smear::ParticleMCS
A smeared Monte Carlo particle.
Definition: ParticleMCS.h:27
Smear::kP
@ kP
Definition: Smear.h:44
Smear::Tracker::~Tracker
virtual ~Tracker()
Destructor.
Definition: Tracker.cxx:40
Smear::Tracker::Distribution
Distributor Distribution
Random distribution.
Definition: Tracker.h:121
Smear::Tracker::LPrime
virtual double LPrime(const erhic::VirtualParticle &) const =0
Returns the transverse path length of the particle through the tracker in metres.
erhic::VirtualParticle::Get4Vector
virtual TLorentzVector Get4Vector() const =0
Returns the momentum-energy four-vector (px, py, pz, E).
Smear::Tracker::IntrinsicContribution
virtual double IntrinsicContribution(const erhic::VirtualParticle &) const
The intrinsic resolution of the detector, depending on momentum, magnetic field, the detector dimensi...
Definition: Tracker.cxx:55
Smear::Tracker::mFactor
Int_t mFactor
Factor in intrinsic resolution calculation dependent on vertex constraint.
Definition: Tracker.h:116
Smear::GetVariable
double GetVariable(const erhic::VirtualParticle &prt, KinType kin)
Returns the kinematic variable associated with kin from the input particle.
Definition: Smear.h:108
Smear::Tracker::Smear
void Smear(const erhic::VirtualParticle &, ParticleMCS &)
Smear the properties of the input particle and store the smeared values in the ParticleMCS.
Definition: Tracker.cxx:82
Smear::Distributor::Generate
virtual double Generate(double midpoint, double width)
Generate a random value based on a given midpoint and width.
Definition: Distributor.cxx:45
Smear::Tracker::MultipleScatteringContribution
virtual double MultipleScatteringContribution(const erhic::VirtualParticle &) const
Multiple scattering contribution, given by delta(p)/p = 0.0136 * z * sqrt(NRL) / (0....
Definition: Tracker.cxx:43