EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Bremsstrahlung.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Bremsstrahlung.cxx
1 
11 
12 #include <cassert>
13 #include <cmath>
14 
16 
17 namespace Smear {
18 
20  double traversed,
21  double radLength)
22 : mParticle(nullptr)
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(nullptr), 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 || std::isnan(upper) || std::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 
90  prt.SetP(sqrt(prt.GetE() * prt.GetE() - prt.GetM() * prt.GetM()) );
91  if (prt.GetP() < 0. || std::isnan(prt.GetP())) prt.SetP(0.);
92  prt.SetPt( prt.GetP() * sin(prt.GetTheta() ));
93  prt.SetPz( prt.GetP() * cos(prt.GetTheta() ));
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.SetE ( mParticle->GetE() );
110  FixParticleKinematics(prtOut);
111  prtOut.HandleBogusValues(kE);
112  mParticle.reset(NULL);
113 }
114 
115 } // namespace Smear