9 #include "GaudiKernel/PhysicalConstants.h"
12 #include "CLHEP/Vector/LorentzVector.h"
13 #include "CLHEP/Geometry/Point3D.h"
14 #include "CLHEP/Geometry/Transform3D.h"
18 #include "CLHEP/Random/RandGaussZiggurat.h"
19 #include "CLHEP/Random/RandFlat.h"
50 if (!m_randomEngine) {
51 ATH_MSG_ERROR(
"Could not get random number engine from RandomNumberService. Abort.");
52 return StatusCode::FAILURE;
64 return StatusCode::SUCCESS;
72 return StatusCode::SUCCESS;
80 if ( angle1<1
e-10 ) angle1 = 1
e-10;
82 return 1.0/M_2_SQRTPI * std::erf(angle1*temp)/angle1 *
88 CLHEP::HepRandomEngine* randomEngine)
const
91 double yval(CLHEP::RandFlat::shoot(randomEngine, 0.0, 1.0));
92 double displ(CLHEP::RandFlat::shoot(randomEngine, -bunchSize, bunchSize));
94 if(ntries>1000000)
return 0.0;
95 yval = CLHEP::RandFlat::shoot(randomEngine, 0.0, 1.0);
96 displ = CLHEP::RandFlat::shoot(randomEngine, -bunchSize, bunchSize);
106 m_randomEngine->setSeed(
name(), ctx );
107 CLHEP::HepRandomEngine* randomEngine(m_randomEngine->getEngine(ctx));
112 double vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(0);
113 double vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(1);
122 vertexZ = CLHEP::RandGaussZiggurat::shoot(randomEngine, 0., zWidth);
123 vertexT = CLHEP::RandGaussZiggurat::shoot(randomEngine, 0., timeWidth);
131 return new CLHEP::HepLorentzVector(0.,0.,0.,0.);
134 ", Zvertex = " << vertexZ <<
", Tvertex = " << vertexT);
137 CLHEP::HepLorentzVector *vertexSmearing =
138 new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. );
141 const double tx =
tan( beamSpotHandle->beamTilt(1) );
142 const double ty =
tan( beamSpotHandle->beamTilt(0) );
144 const double sqrt_abc = std::sqrt(1. +
tx*
tx + ty*ty);
145 const double sqrt_fgh = std::sqrt(1. + ty*ty);
147 const double a = ty/sqrt_abc;
148 const double b =
tx/sqrt_abc;
149 const double c = 1./sqrt_abc;
151 HepGeom::Point3D<double> from1(0,0,1);
152 HepGeom::Point3D<double> to1(
a,
b,
c);
154 const double f = 1./sqrt_fgh;
156 const double h = -(ty)/sqrt_fgh;
158 HepGeom::Point3D<double> from2(1,0,0);
159 HepGeom::Point3D<double> to2(
f,
g,
h);
163 HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(),
164 CLHEP::Hep3Vector( beamSpotHandle->beamPos().x(),
165 beamSpotHandle->beamPos().y(),
166 beamSpotHandle->beamPos().z() )
169 ATH_MSG_VERBOSE(
"BeamSpotSvc reported beam position as " << beamSpotHandle->beamPos());
170 ATH_MSG_VERBOSE(
"Width is (" << beamSpotHandle->beamSigma(0) <<
", " <<
171 beamSpotHandle->beamSigma(1) <<
", " <<
m_bunchLength <<
")");
172 ATH_MSG_VERBOSE(
"Tilts are " << beamSpotHandle->beamTilt(0) <<
" and " <<
173 beamSpotHandle->beamTilt(1));
174 ATH_MSG_VERBOSE(
"Vertex Position before transform: " << *vertexSmearing);
177 *vertexSmearing =
transform * HepGeom::Point3D<double>(*vertexSmearing);
178 vertexSmearing->setT(vertexT);
181 return vertexSmearing;