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