CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
BremsstrahlungSimulator Class Reference

#include <BremsstrahlungSimulator.h>

Inheritance diagram for BremsstrahlungSimulator:
MaterialEffectsSimulator

Public Member Functions

 BremsstrahlungSimulator (double photonEnergyCut, double photonFractECut, const RandomEngine *engine)
 Constructor. More...
 
 ~BremsstrahlungSimulator ()
 Default destructor. More...
 
- Public Member Functions inherited from MaterialEffectsSimulator
RHEP_const_iter beginDaughters () const
 Returns const iterator to the beginning of the daughters list. More...
 
int closestDaughterId ()
 The id of the closest charged daughter (filled for nuclear interactions only) More...
 
double eMass () const
 Electron mass in GeV/c2. More...
 
RHEP_const_iter endDaughters () const
 Returns const iterator to the end of the daughters list. More...
 
double excitE () const
 Mean excitation energy (in GeV) More...
 
 MaterialEffectsSimulator (const RandomEngine *engine, double A=28.0855, double Z=14.0000, double density=2.329, double radLen=9.360)
 
unsigned nDaughters () const
 Returns the number of daughters. More...
 
XYZVector orthogonal (const XYZVector &) const
 A vector orthogonal to another one (because it's not in XYZTLorentzVector) More...
 
double radLenIncm () const
 One radiation length in cm. More...
 
double rho () const
 Density in g/cm3. More...
 
void setNormalVector (const GlobalVector &normal)
 Sets the vector normal to the surface traversed. More...
 
double theA () const
 A. More...
 
double theZ () const
 Z. More...
 
void updateState (ParticlePropagator &myTrack, double radlen)
 Compute the material effect (calls the sub class) More...
 
virtual ~MaterialEffectsSimulator ()
 

Private Member Functions

XYZTLorentzVector brem (ParticlePropagator &p) const
 Compute Brem photon energy and angles, if any. More...
 
void compute (ParticlePropagator &Particle)
 Generate Bremsstrahlung photons. More...
 
double gbteth (const double ener, const double partm, const double efrac) const
 A universal angular distribution - still from GEANT. More...
 
unsigned int poisson (double ymu)
 Generate numbers according to a Poisson distribution of mean ymu. More...
 

Private Attributes

double photonEnergy
 The minimum photon energy to be radiated, in GeV. More...
 
double photonFractE
 The minimum photon fractional energy (wrt that of the electron) More...
 
double xmin
 The fractional photon energy cut (determined from the above two) More...
 

Additional Inherited Members

- Public Types inherited from MaterialEffectsSimulator
typedef std::vector
< RawParticle >
::const_iterator 
RHEP_const_iter
 
- Protected Attributes inherited from MaterialEffectsSimulator
std::vector< RawParticle_theUpdatedState
 
double A
 
double density
 
double radLen
 
double radLengths
 
const RandomEnginerandom
 
int theClosestChargedDaughterId
 
GlobalVector theNormalVector
 
double Z
 

Detailed Description

Definition at line 26 of file BremsstrahlungSimulator.h.

Constructor & Destructor Documentation

BremsstrahlungSimulator::BremsstrahlungSimulator ( double  photonEnergyCut,
double  photonFractECut,
const RandomEngine engine 
)

Constructor.

Definition at line 7 of file BremsstrahlungSimulator.cc.

References photonEnergy, and photonFractE.

9  :
11 {
12 
13  // Set the minimal photon energy for a Brem from e+/-
14  photonEnergy = photonEnergyCut;
15  photonFractE = photonFractECut;
16 
17 }
MaterialEffectsSimulator(const RandomEngine *engine, double A=28.0855, double Z=14.0000, double density=2.329, double radLen=9.360)
double photonEnergy
The minimum photon energy to be radiated, in GeV.
double photonFractE
The minimum photon fractional energy (wrt that of the electron)
BremsstrahlungSimulator::~BremsstrahlungSimulator ( )
inline

Default destructor.

Definition at line 36 of file BremsstrahlungSimulator.h.

36 {}

Member Function Documentation

XYZTLorentzVector BremsstrahlungSimulator::brem ( ParticlePropagator p) const
private

Compute Brem photon energy and angles, if any.

Definition at line 72 of file BremsstrahlungSimulator.cc.

References funct::cos(), create_public_lumi_plots::exp, RandomEngine::flatShoot(), gbteth(), create_public_lumi_plots::log, M_PI, phi, MaterialEffectsSimulator::random, funct::sin(), theta(), histoStyle::weight, and xmin.

Referenced by compute().

72  {
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 }
tuple pp
Definition: createTree.py:15
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
Definition: BFit3D.cc:3
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)
int weight
Definition: histoStyle.py:50
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15
Definition: DDAxes.h:10
void BremsstrahlungSimulator::compute ( ParticlePropagator Particle)
privatevirtual

Generate Bremsstrahlung photons.

Implements MaterialEffectsSimulator.

Definition at line 21 of file BremsstrahlungSimulator.cc.

References MaterialEffectsSimulator::_theUpdatedState, brem(), i, create_public_lumi_plots::log, max(), RawParticle::momentum(), photonEnergy, photonFractE, poisson(), MaterialEffectsSimulator::radLengths, RawParticle::rotate(), and xmin.

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 }
int i
Definition: DBlmapReader.cc:9
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.
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:37
XYZTLorentzVector brem(ParticlePropagator &p) const
Compute Brem photon energy and angles, if any.
double xmin
The fractional photon energy cut (determined from the above two)
std::vector< RawParticle > _theUpdatedState
double photonEnergy
The minimum photon energy to be radiated, in GeV.
double photonFractE
The minimum photon fractional energy (wrt that of the electron)
double BremsstrahlungSimulator::gbteth ( const double  ener,
const double  partm,
const double  efrac 
) const
private

A universal angular distribution - still from GEANT.

Definition at line 106 of file BremsstrahlungSimulator.cc.

References beta, RandomEngine::flatShoot(), create_public_lumi_plots::log, M_PI, MaterialEffectsSimulator::random, and MaterialEffectsSimulator::theZ().

Referenced by brem().

108  {
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 }
const double beta
#define M_PI
Definition: BFit3D.cc:3
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
unsigned int BremsstrahlungSimulator::poisson ( double  ymu)
private

Generate numbers according to a Poisson distribution of mean ymu.

Definition at line 126 of file BremsstrahlungSimulator.cc.

References create_public_lumi_plots::exp, RandomEngine::flatShoot(), n, mix_2012_Summer_inTimeOnly_cff::prob, MaterialEffectsSimulator::random, and x.

Referenced by compute().

126  {
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 }
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
Definition: DDAxes.h:10

Member Data Documentation

double BremsstrahlungSimulator::photonEnergy
private

The minimum photon energy to be radiated, in GeV.

Definition at line 41 of file BremsstrahlungSimulator.h.

Referenced by BremsstrahlungSimulator(), and compute().

double BremsstrahlungSimulator::photonFractE
private

The minimum photon fractional energy (wrt that of the electron)

Definition at line 44 of file BremsstrahlungSimulator.h.

Referenced by BremsstrahlungSimulator(), and compute().

double BremsstrahlungSimulator::xmin
private

The fractional photon energy cut (determined from the above two)

Definition at line 47 of file BremsstrahlungSimulator.h.

Referenced by svgfig.XAxis::__repr__(), svgfig.Axes::__repr__(), svgfig.HGrid::__repr__(), svgfig.Grid::__repr__(), brem(), compute(), and svgfig.Axes::SVG().