test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonBremsstrahlungSimulator.cc
Go to the documentation of this file.
1 //MuonBremsstrahlungSimulator
3 // Description: Implementation of Muon bremsstrahlung using the Petrukhin model
4 //Authors :Sandro Fonseca de Souza and Andre Sznajder (UERJ/Brazil)
5 // Date: 23-Nov-2010
11 
12 #include <cmath>
13 #include <string>
14 #include <iostream>
15 
16 #include "TF1.h"
17 
18 
19 
20 
22 MuonBremsstrahlungSimulator::MuonBremsstrahlungSimulator(double A,double Z, double density,double radLen,
23  double photonEnergyCut,double photonFractECut) :
24  MaterialEffectsSimulator(A,Z,density,radLen)
25 {
26  // Set the minimal photon energy for a Brem from mu+/-
27  photonEnergy = photonEnergyCut;
28  photonFractE = photonFractECut;
29  d = 0.; //distance
30  LogDebug("MuonBremsstrahlungSimulator")<< "Starting the MuonBremsstrahlungSimulator"<< std::endl;
31 }
32 
33 
34 
36 void
38 {
39 
40  double NA = 6.022e+23; //Avogadro's number
41 
42  if ( radLengths > 4. ) {
43  Particle.SetXYZT(0.,0.,0.,0.);
44  deltaPMuon.SetXYZT(0.,0.,0.,0.);
45  brem_photon.SetXYZT(0.,0.,0.,0.);
46  }
47 
48 // Hard brem probability with a photon Energy above photonEnergy.
49 
50  double EMuon = Particle.e();//Muon Energy
51  if (EMuon<photonEnergy) return;
52  xmin = std::max(photonEnergy/EMuon,photonFractE);//fraction of muon's energy transferred to the photon
53 
54  // xmax = photonEnergy/Particle.e();
55  if ( xmin >=1. || xmin <=0. ) return;
56 
57  xmax = 1.;
58  npar = 3 ;//Number of parameters
59 
60  // create TF1 using a free C function
61  f1 = new TF1("f1",PetrukhinFunc,xmin,xmax,npar);
62  //Setting parameters
63  f1->SetParameters(EMuon,A,Z);
65  //d = distance for several materials
66  //X0 = radLen
67  //d = radLengths * X0(for tracker,yoke,ECAL and HCAL)
68  d = radLengths * radLen ;
69  //Integration
70  bremProba = density * d *(NA/A)* (f1->Integral(0.,1.));
71 
72 
73  // Number of photons to be radiated.
74  unsigned int nPhotons = random->poissonShoot(bremProba);
75  _theUpdatedState.reserve(nPhotons);
76 
77 
78  if ( !nPhotons ) return;
79 
80  //Rotate to the lab frame
81  double chi = Particle.theta();
82  double psi = Particle.phi();
83  RawParticle::RotationZ rotZ(psi);
84  RawParticle::RotationY rotY(chi);
85 
86 
87 
88  // Energy of these photons
89  for ( unsigned int i=0; i<nPhotons; ++i ) {
90 
91  // Check that there is enough energy left.
92  if ( Particle.e() < photonEnergy ) break;
93  LogDebug("MuonBremsstrahlungSimulator")<< "MuonBremsstrahlungSimulator parameters:"<< std::endl;
94  LogDebug("MuonBremsstrahlungSimulator")<< "xmin-> " << xmin << std::endl;
95  LogDebug("MuonBremsstrahlungSimulator")<< "Atomic Weight-> " << A << std::endl;
96  LogDebug("MuonBremsstrahlungSimulator")<< "Density-> " << density << std::endl;
97  LogDebug("MuonBremsstrahlungSimulator")<< "Distance-> " << d << std::endl;
98  LogDebug("MuonBremsstrahlungSimulator")<< "bremProba->" << bremProba << std::endl;
99  LogDebug("MuonBremsstrahlungSimulator")<< "nPhotons->" << nPhotons << std::endl;
100  LogDebug("MuonBremsstrahlungSimulator")<< " Muon_Energy-> " << EMuon << std::endl;
101  LogDebug("MuonBremsstrahlungSimulator")<< "X0-> "<< radLen << std::endl;
102  LogDebug("MuonBremsstrahlungSimulator")<< " radLengths-> " << radLengths << std::endl;
103 
104  // Add a photon
105  RawParticle thePhoton(22,brem(Particle, random));
106  if (thePhoton.E()>0.){
107 
108  thePhoton.rotate(rotY);
109  thePhoton.rotate(rotZ);
110 
111  _theUpdatedState.push_back(thePhoton);
112 
113  // Update the original mu +/-
114  deltaPMuon = Particle -= thePhoton.momentum();
115  // Information of brem photon
116  brem_photon.SetXYZT(thePhoton.Px(),thePhoton.Py(),thePhoton.Pz(),thePhoton.E());
117 
118  LogDebug("MuonBremsstrahlungSimulator")<< " Muon Bremsstrahlung: photon_energy-> " << thePhoton.E() << std::endl;
119  LogDebug("MuonBremsstrahlungSimulator")<< "photon_px->" << thePhoton.Px() << std::endl;
120  LogDebug("MuonBremsstrahlungSimulator")<< "photon_py->" << thePhoton.Py() << std::endl;
121  LogDebug("MuonBremsstrahlungSimulator")<< "photon_pz->" << thePhoton.Pz() << std::endl;
122 
123  }
124 
125  }
126 
127 }
131 
132  // This is a simple version of a Muon Brem using Petrukhin model .
133  //Ref: http://pdg.lbl.gov/2008/AtomicNuclearProperties/adndt.pdf
134  double mumass = 0.105658367;//mu mass (GeV/c^2)
135 
136  // RANDOM_NUMBER_ERROR
137  // Random number should be generated by the engines from the
138  // RandomNumberGeneratorService. This appears to use the global
139  // engine in ROOT. This is not thread safe unless the module using
140  // it is a one module and declares a shared resource and all
141  // other modules using it also declare the same shared resource.
142  // This also breaks replay.
143  // It might be that this is never used because of the std::cout
144  // statement 2 lines below. I've never seen or heard complaints
145  // about that vebosity ....
146  double xp = f1->GetRandom();
147  LogDebug("MuonBremsstrahlungSimulator")<< "MuonBremsstrahlungSimulator: xp->" << xp << std::endl;
148  std::cout << "MuonBremsstrahlungSimulator: xp->" << xp << std::endl;
149 
150  // Have photon energy. Now generate angles with respect to the z axis
151  // defined by the incoming particle's momentum.
152 
153  // Isotropic in phi
154  const double phi = random->flatShoot()*2*M_PI;
155  // theta from universal distribution
156  const double theta = gbteth(pp.e(),mumass,xp,random)*mumass/pp.e();
157 
158  // Make momentum components
159  double stheta = std::sin(theta);
160  double ctheta = std::cos(theta);
161  double sphi = std::sin(phi);
162  double cphi = std::cos(phi);
163 
164  return xp * pp.e() * XYZTLorentzVector(stheta*cphi,stheta*sphi,ctheta,1.);
165 
166 }
168 double
170  const double partm,
171  const double efrac,
172  RandomEngineAndDistribution const* random) const {
173  const double alfa = 0.625;
174 
175  const double d = 0.13*(0.8+1.3/theZ())*(100.0+(1.0/ener))*(1.0+efrac);
176  const double w1 = 9.0/(9.0+d);
177  const double umax = ener*M_PI/partm;
178  double u;
179 
180  do {
181  double beta = (random->flatShoot()<=w1) ? alfa : 3.0*alfa;
182  u = -std::log(random->flatShoot()*random->flatShoot())/beta;
183  } while (u>=umax);
184 
185  return u;
186 }
187 
188 
#define LogDebug(id)
const double Z[kNumberCalorimeter]
const double beta
int i
Definition: DBlmapReader.cc:9
double flatShoot(double xmin=0.0, double xmax=1.0) const
tuple pp
Definition: createTree.py:15
void compute(ParticlePropagator &Particle, RandomEngineAndDistribution const *)
Generate Bremsstrahlung photons.
double gbteth(const double ener, const double partm, const double efrac, RandomEngineAndDistribution const *) const
A universal angular distribution - still from GEANT.
double PetrukhinFunc(double *x, double *p)
double xmin
The fractional photon energy cut (determined from the above two)
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
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
void rotate(double rphi, const XYZVector &raxis)
Definition: RawParticle.cc:155
#define M_PI
MuonBremsstrahlungSimulator(double A, double Z, double density, double radLen, double photonEnergyCut, double photonFractECut)
Constructor.
double photonFractE
The minimum photon fractional energy (wrt that of the electron)
std::vector< RawParticle > _theUpdatedState
unsigned int poissonShoot(double mean) const
XYZTLorentzVector brem(ParticlePropagator &p, RandomEngineAndDistribution const *) const
Compute Brem photon energy and angles, if any.
tuple cout
Definition: gather_cfg.py:145
double photonEnergy
The minimum photon energy to be radiated, in GeV.
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15