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
Bremsstrahlung.cxx
Go to the documentation of this file.
1 
11 
12 #include <cassert>
13 #include <cmath>
14 
16 
17 namespace Smear {
18 
20  double traversed,
21  double radLength)
22 : mParticle(NULL)
23 , mKMin(0.)
24 , mKMax(0.)
25 , mEpsilon(epsilon)
26 , mTraversed(traversed)
27 , mRadLength(radLength)
28 , mPdf(NULL) {
29  Accept.AddParticle(11);
30  Accept.AddParticle(-11);
31 }
32 
34  : Device(other), mParticle(NULL), mKMin(other.mKMin), mKMax(other.mKMax),
35  mEpsilon(other.mEpsilon), mTraversed(other.mTraversed),
36  mRadLength(other.mRadLength), mPdf(NULL) {
37  // Duplicate cached particle if there is one
38  // SetParticle() duplicates the particle and sets up the PDF
39  //if (other.mParticle.get()) {
40  // SetParticle(*mParticle);
41  //} // if
42 }
43 
44 double Bremsstrahlung::dSigmadK(double *x, double*) {
45  double k = x[0];
46  double ret = 4. / 3.;
47  ret += -4. * k / (3. * mParticle->E);
48  ret += pow(k / mParticle->E, 2.);
49  ret /= k;
50  return ret;
51 }
52 
54  double lower = mEpsilon;
55  double upper = mParticle->E - mEpsilon;
56  if (upper < lower || isnan(upper) || isnan(lower)) {
57  return false;
58  } // if
59  mKMin = lower;
60  mKMax = upper;
61  mPdf->SetRange(mKMin, mKMax);
62  return true;
63 }
64 
66  double ret = 4. * log(mKMax / mKMin) / 3.;
67  ret += -4. * (mKMax - mKMin) / (3. * mParticle->E);
68  ret += 0.5* pow((mKMax - mKMin) / mParticle->E, 2.);
69  ret *= mTraversed / mRadLength;
70  int n = static_cast<int>(ret);
71  if (fabs(ret - n) < fabs(ret - n - 1)) {
72  return n;
73  } else {
74  return n + 1;
75  } // if
76 }
77 
79  mParticle.reset(static_cast<erhic::ParticleMC*>(prt.Clone()));
80  if (!mPdf) {
81  mPdf = new TF1("Smear_Bremsstrahlung_PDF",
82  this,
84  mKMin, mKMax, 0);
85  } // if
86  SetupPDF();
87 }
88 
89 void Bremsstrahlung::FixParticleKinematics(ParticleMCS& prt) {
90  prt.p = sqrt(prt.GetE() * prt.GetE() - prt.GetM() * prt.GetM());
91  if (prt.p < 0. || isnan(prt.p)) prt.p = 0.;
92  prt.pt = prt.p * sin(prt.theta);
93  prt.pz = prt.p * cos(prt.theta);
94 }
95 
96 Bremsstrahlung* Bremsstrahlung::Clone(Option_t* /* not used */) const {
97  return new Bremsstrahlung(*this);
98 }
99 
101  ParticleMCS& prtOut) {
102  SetParticle(prt);
103  const int nGamma = NGamma();
104  for (int i = 0; i < nGamma; i++) {
105  if (!SetupPDF()) break;
106  double loss = mPdf->GetRandom();
107  mParticle->E -= loss;
108  } // for
109  prtOut.E = mParticle->GetE();
110  FixParticleKinematics(prtOut);
111  HandleBogusValues(prtOut);
112  mParticle.reset(NULL);
113 }
114 
115 } // namespace Smear
TF1 * mPdf
dSigma/dK function
Bremsstrahlung(double epsilon=0.01, double traversed=10., double radLength=47.1)
A specialized Device class for modelling radiative losses.
virtual Double_t GetM() const
Definition: ParticleMCS.h:201
Double32_t E
Energy of particle.
Definition: ParticleMCS.h:176
double dSigmadK(double *x, double *)
void SetParticle(const erhic::VirtualParticle &)
virtual Bremsstrahlung * Clone(Option_t *option="not used") const
Double32_t p
Total momentum of particle.
Definition: ParticleMCS.h:178
void AddParticle(int particle)
Definition: Acceptance.cxx:42
Double32_t pt
Transverse momentum of particle.
Definition: ParticleMCS.h:177
virtual Double_t GetE() const
Definition: ParticleMCS.h:197
std::auto_ptr< erhic::ParticleMC > mParticle
Copy of the current particle.
Double32_t pz
z component of particle momentum
Definition: ParticleMCS.h:175
Abstract base class for a general particle.
Double32_t theta
Polar angle.
Definition: ParticleMCS.h:179
virtual void Smear(const erhic::VirtualParticle &, ParticleMCS &)