CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BremsstrahlungSimulator.cc
Go to the documentation of this file.
1 //FAMOS Headers
4 
5 #include <cmath>
6 
8  double photonFractECut,
9  const RandomEngine* engine) :
11 {
12 
13  // Set the minimal photon energy for a Brem from e+/-
14  photonEnergy = photonEnergyCut;
15  photonFractE = photonFractECut;
16 
17 }
18 
19 
20 void
22 {
23 
24  // Protection : Just stop the electron if more than 1 radiation lengths.
25  // This case corresponds to an electron entering the layer parallel to
26  // the layer axis - no reliable simulation can be done in that case...
27  // 08/02/06 - pv: increase protection from 1 to 4 X0 for eta>4.8 region
28  // if ( radLengths > 1. ) Particle.SetXYZT(0.,0.,0.,0.);
29  if ( radLengths > 4. ) Particle.SetXYZT(0.,0.,0.,0.);
30 
31  // Hard brem probability with a photon Energy above photonEnergy.
32  if (Particle.e()<photonEnergy) return;
33  xmin = std::max(photonEnergy/Particle.e(),photonFractE);
34  if ( xmin >=1. || xmin <=0. ) return;
35 
36  double bremProba = radLengths * ( 4./3. * std::log(1./xmin)
37  - 4./3. * (1.-xmin)
38  + 1./2. * (1.-xmin*xmin) );
39 
40 
41  // Number of photons to be radiated.
42  unsigned int nPhotons = poisson(bremProba);
43  _theUpdatedState.reserve(nPhotons);
44 
45  if ( !nPhotons ) return;
46 
47  //Rotate to the lab frame
48  double chi = Particle.theta();
49  double psi = Particle.phi();
50  RawParticle::RotationZ rotZ(psi);
51  RawParticle::RotationY rotY(chi);
52 
53  // Energy of these photons
54  for ( unsigned int i=0; i<nPhotons; ++i ) {
55 
56  // Check that there is enough energy left.
57  if ( Particle.e() < photonEnergy ) break;
58 
59  // Add a photon
60  RawParticle thePhoton(22,brem(Particle));
61  thePhoton.rotate(rotY);
62  thePhoton.rotate(rotZ);
63  _theUpdatedState.push_back(thePhoton);
64 
65  // Update the original e+/-
66  Particle -= thePhoton.momentum();
67 
68  }
69 }
70 
73 
74  // This is a simple version (a la PDG) of a Brem generator.
75  // It replaces the buggy GEANT3 -> C++ former version.
76  // Author : Patrick Janot - 25-Dec-2003
77  double emass = 0.0005109990615;
78  double xp=0;
79  double weight = 0.;
80 
81  do {
82  xp = xmin * std::exp ( -std::log(xmin) * random->flatShoot() );
83  weight = 1. - xp + 3./4.*xp*xp;
84  } while ( weight < random->flatShoot() );
85 
86 
87  // Have photon energy. Now generate angles with respect to the z axis
88  // defined by the incoming particle's momentum.
89 
90  // Isotropic in phi
91  const double phi = random->flatShoot()*2*M_PI;
92  // theta from universal distribution
93  const double theta = gbteth(pp.e(),emass,xp)*emass/pp.e();
94 
95  // Make momentum components
96  double stheta = std::sin(theta);
97  double ctheta = std::cos(theta);
98  double sphi = std::sin(phi);
99  double cphi = std::cos(phi);
100 
101  return xp * pp.e() * XYZTLorentzVector(stheta*cphi,stheta*sphi,ctheta,1.);
102 
103 }
104 
105 double
107  const double partm,
108  const double efrac) const {
109  const double alfa = 0.625;
110 
111  const double d = 0.13*(0.8+1.3/theZ())*(100.0+(1.0/ener))*(1.0+efrac);
112  const double w1 = 9.0/(9.0+d);
113  const double umax = ener*M_PI/partm;
114  double u;
115 
116  do {
117  double beta = (random->flatShoot()<=w1) ? alfa : 3.0*alfa;
118  u = -std::log(random->flatShoot()*random->flatShoot())/beta;
119  } while (u>=umax);
120 
121  return u;
122 }
123 
124 
125 unsigned int
127 
128  unsigned int n = 0;
129  double prob = std::exp(-ymu);
130  double proba = prob;
131  double x = random->flatShoot();
132 
133  while ( proba <= x ) {
134  prob *= ymu / double(++n);
135  proba += prob;
136  }
137 
138  return n;
139 
140 }
141 
const double beta
void compute(ParticlePropagator &Particle)
Generate Bremsstrahlung photons.
int i
Definition: DBlmapReader.cc:9
tuple pp
Definition: createTree.py:15
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
ROOT::Math::RotationZ RotationZ
Definition: RawParticle.h:38
std::map< std::string, int, std::less< std::string > > psi
const XYZTLorentzVector & momentum() const
the momentum fourvector
Definition: RawParticle.h:285
const T & max(const T &a, const T &b)
unsigned int poisson(double ymu)
Generate numbers according to a Poisson distribution of mean ymu.
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:37
void rotate(double rphi, const XYZVector &raxis)
Definition: RawParticle.cc:154
#define M_PI
Definition: BFit3D.cc:3
Log< T >::type log(const T &t)
Definition: Log.h:22
XYZTLorentzVector brem(ParticlePropagator &p) const
Compute Brem photon energy and angles, if any.
double gbteth(const double ener, const double partm, const double efrac) const
A universal angular distribution - still from GEANT.
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
double xmin
The fractional photon energy cut (determined from the above two)
std::vector< RawParticle > _theUpdatedState
Definition: DDAxes.h:10
BremsstrahlungSimulator(double photonEnergyCut, double photonFractECut, const RandomEngine *engine)
Constructor.
double photonEnergy
The minimum photon energy to be radiated, in GeV.
double photonFractE
The minimum photon fractional energy (wrt that of the electron)
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15
Definition: DDAxes.h:10