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)
 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 (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...
 
virtual void save ()
 Used by NuclearInteractionSimulator to save last sampled event. 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, RandomEngineAndDistribution const *)
 Compute the material effect (calls the sub class) More...
 
virtual ~MaterialEffectsSimulator ()
 

Private Member Functions

XYZTLorentzVector brem (ParticlePropagator &p, RandomEngineAndDistribution const *) const
 Compute Brem photon energy and angles, if any. More...
 
void compute (ParticlePropagator &Particle, RandomEngineAndDistribution const *)
 Generate Bremsstrahlung photons. More...
 
double gbteth (const double ener, const double partm, const double efrac, RandomEngineAndDistribution const *) const
 A universal angular distribution - still from GEANT. More...
 
unsigned int poisson (double ymu, RandomEngineAndDistribution const *)
 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
 
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 
)

Constructor.

Definition at line 7 of file BremsstrahlungSimulator.cc.

References photonEnergy, and photonFractE.

9 {
10  // Set the minimal photon energy for a Brem from e+/-
11  photonEnergy = photonEnergyCut;
12  photonFractE = photonFractECut;
13 }
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 35 of file BremsstrahlungSimulator.h.

35 {}

Member Function Documentation

XYZTLorentzVector BremsstrahlungSimulator::brem ( ParticlePropagator p,
RandomEngineAndDistribution const *  random 
) const
private

Compute Brem photon energy and angles, if any.

Definition at line 68 of file BremsstrahlungSimulator.cc.

References funct::cos(), create_public_lumi_plots::exp, RandomEngineAndDistribution::flatShoot(), gbteth(), cmsBatch::log, M_PI, phi, random, funct::sin(), theta(), puppiForMET_cff::weight, and xmin.

Referenced by compute().

68  {
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 }
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
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#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)
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15
tuple log
Definition: cmsBatch.py:341
void BremsstrahlungSimulator::compute ( ParticlePropagator Particle,
RandomEngineAndDistribution const *  random 
)
privatevirtual

Generate Bremsstrahlung photons.

Implements MaterialEffectsSimulator.

Definition at line 17 of file BremsstrahlungSimulator.cc.

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

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 }
int i
Definition: DBlmapReader.cc:9
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
ROOT::Math::RotationY RotationY
Definition: RawParticle.h:38
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.
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)
tuple log
Definition: cmsBatch.py:341
double BremsstrahlungSimulator::gbteth ( const double  ener,
const double  partm,
const double  efrac,
RandomEngineAndDistribution const *  random 
) const
private

A universal angular distribution - still from GEANT.

Definition at line 102 of file BremsstrahlungSimulator.cc.

References beta, ztail::d, RandomEngineAndDistribution::flatShoot(), cmsBatch::log, M_PI, and MaterialEffectsSimulator::theZ().

Referenced by brem().

105  {
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 }
const double beta
TRandom random
Definition: MVATrainer.cc:138
tuple d
Definition: ztail.py:151
#define M_PI
tuple log
Definition: cmsBatch.py:341
unsigned int BremsstrahlungSimulator::poisson ( double  ymu,
RandomEngineAndDistribution const *  random 
)
private

Generate numbers according to a Poisson distribution of mean ymu.

Definition at line 123 of file BremsstrahlungSimulator.cc.

References create_public_lumi_plots::exp, RandomEngineAndDistribution::flatShoot(), gen::n, and x.

Referenced by compute().

123  {
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 }
TRandom random
Definition: MVATrainer.cc:138

Member Data Documentation

double BremsstrahlungSimulator::photonEnergy
private

The minimum photon energy to be radiated, in GeV.

Definition at line 40 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 43 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 46 of file BremsstrahlungSimulator.h.

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