CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PairProductionSimulator.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 
7 {
8  // Set the minimal photon energy for possible conversion
9  photonEnergy = std::max(0.100,photonEnergyCut);
10 }
11 
12 void
14 {
15 
16  double eGamma = Particle.e();
17 
18  // The photon has enough energy to create a pair
19  if ( eGamma>=photonEnergy ) {
20 
21  // This is a simple version (a la PDG) of a photon conversion generator.
22  // It replaces the buggy GEANT3 -> C++ former version.
23  // Author : Patrick Janot - 7-Jan-2004
24 
25  // Probability to convert is 7/9*(dx/X0)
26  if ( -std::log(random->flatShoot()) <= (7./9.)*radLengths ) {
27 
28  double xe=0;
29  double xm=eMass()/eGamma;
30  double weight = 0.;
31 
32  // Generate electron energy between emass and eGamma-emass
33  do {
34  xe = random->flatShoot()*(1.-2.*xm) + xm;
35  weight = 1. - 4./3.*xe*(1.-xe);
36  } while ( weight < random->flatShoot() );
37 
38  double eElectron = xe * eGamma;
39  double tElectron = eElectron-eMass();
40  double pElectron = std::sqrt(std::max((eElectron+eMass())*tElectron,0.));
41 
42  double ePositron = eGamma-eElectron;
43  double tPositron = ePositron-eMass();
44  double pPositron = std::sqrt((ePositron+eMass())*tPositron);
45 
46  // Generate angles
47  double phi = random->flatShoot()*2.*M_PI;
48  double sphi = std::sin(phi);
49  double cphi = std::cos(phi);
50 
51  double stheta1, stheta2, ctheta1, ctheta2;
52 
53  if ( eElectron > ePositron ) {
54  double theta1 = gbteth(eElectron,eMass(),xe,random)*eMass()/eElectron;
55  stheta1 = std::sin(theta1);
56  ctheta1 = std::cos(theta1);
57  stheta2 = stheta1*pElectron/pPositron;
58  ctheta2 = std::sqrt(std::max(0.,1.0-(stheta2*stheta2)));
59  } else {
60  double theta2 = gbteth(ePositron,eMass(),xe,random)*eMass()/ePositron;
61  stheta2 = std::sin(theta2);
62  ctheta2 = std::cos(theta2);
63  stheta1 = stheta2*pPositron/pElectron;
64  ctheta1 = std::sqrt(std::max(0.,1.0-(stheta1*stheta1)));
65  }
66 
67 
68  double chi = Particle.theta();
69  double psi = Particle.phi();
70  RawParticle::RotationZ rotZ(psi);
71  RawParticle::RotationY rotY(chi);
72 
73  _theUpdatedState.resize(2,RawParticle());
74 
75  // The eletron
76  _theUpdatedState[0].SetXYZT(pElectron*stheta1*cphi,
77  pElectron*stheta1*sphi,
78  pElectron*ctheta1,
79  eElectron);
80  _theUpdatedState[0].setID(+11);
81  _theUpdatedState[0].rotate(rotY);
82  _theUpdatedState[0].rotate(rotZ);
83 
84  // The positron
85  _theUpdatedState[1].SetXYZT(-pPositron*stheta2*cphi,
86  -pPositron*stheta2*sphi,
87  pPositron*ctheta2,
88  ePositron);
89  _theUpdatedState[1].setID(-11);
90  _theUpdatedState[1].rotate(rotY);
91  _theUpdatedState[1].rotate(rotZ);
92 
93  }
94  }
95 }
96 
97 double
98 PairProductionSimulator::gbteth(double ener,double partm,double efrac, RandomEngineAndDistribution const* random)
99 {
100  const double alfa = 0.625;
101 
102  double d = 0.13*(0.8+1.3/theZ())*(100.0+(1.0/ener))*(1.0+efrac);
103  double w1 = 9.0/(9.0+d);
104  double umax = ener*M_PI/partm;
105  double u;
106 
107  do {
108  double beta;
109  if (random->flatShoot()<=w1) beta = alfa;
110  else beta = 3.0*alfa;
111  u = -(std::log(random->flatShoot()*random->flatShoot()))/beta;
112  } while (u>=umax);
113 
114  return u;
115 }
const double beta
PairProductionSimulator(double photonEnergyCut)
Constructor.
double photonEnergy
The minimal photon energy for possible conversion.
double flatShoot(double xmin=0.0, double xmax=1.0) const
double gbteth(double ener, double partm, double efrac, RandomEngineAndDistribution const *)
A universal angular distribution - still from GEANT.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
TRandom random
Definition: MVATrainer.cc:138
ROOT::Math::RotationZ RotationZ
Definition: RawParticle.h:39
std::map< std::string, int, std::less< std::string > > psi
tuple d
Definition: ztail.py:151
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:38
double eMass() const
Electron mass in GeV/c2.
#define M_PI
void compute(ParticlePropagator &Particle, RandomEngineAndDistribution const *)
Generate an e+e- pair according to the probability that it happens.
std::vector< RawParticle > _theUpdatedState
tuple log
Definition: cmsBatch.py:341