9 #include "GaudiKernel/PhysicalConstants.h"
12 #include "CLHEP/Vector/LorentzVector.h"
13 #include "CLHEP/Geometry/Point3D.h"
14 #include "CLHEP/Geometry/Transform3D.h"
19 #include "CLHEP/Random/RandGaussZiggurat.h"
20 #include "CLHEP/Random/RandFlat.h"
42 if (!m_randomEngine) {
43 ATH_MSG_ERROR(
"Could not get random number engine from RandomNumberService. Abort.");
44 return StatusCode::FAILURE;
48 return StatusCode::SUCCESS;
56 return StatusCode::SUCCESS;
62 double temp(1.0-std::abs(
z)/
m_L);
69 double yval(CLHEP::RandFlat::shoot(randomEngine, 0.0, 1.0));
70 double zval(CLHEP::RandFlat::shoot(randomEngine, -150.0, 150.0));
72 if(ntries>1000000)
return 0.0;
73 yval = CLHEP::RandFlat::shoot(randomEngine, 0.0, 1.0);
74 zval = CLHEP::RandFlat::shoot(randomEngine, -150.0, 150.0);
84 m_randomEngine->setSeed(
name(), ctx );
85 CLHEP::HepRandomEngine* randomEngine(m_randomEngine->getEngine(ctx));
90 float vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(0);
91 float vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(1);
92 float vertexZ =
getZpos(randomEngine);
94 CLHEP::HepLorentzVector *vertexSmearing =
95 new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. );
98 const double tx =
tan( beamSpotHandle->beamTilt(1) );
99 const double ty =
tan( beamSpotHandle->beamTilt(0) );
101 const double sqrt_abc = sqrt(1. +
tx*
tx + ty*ty);
102 const double sqrt_fgh = sqrt(1. + ty*ty);
104 const double a = ty/sqrt_abc;
105 const double b =
tx/sqrt_abc;
106 const double c = 1./sqrt_abc;
108 HepGeom::Point3D<double> from1(0,0,1);
109 HepGeom::Point3D<double> to1(
a,
b,
c);
111 const double f = 1./sqrt_fgh;
113 const double h = -(ty)/sqrt_fgh;
115 HepGeom::Point3D<double> from2(1,0,0);
116 HepGeom::Point3D<double> to2(
f,
g,
h);
120 HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(),
121 CLHEP::Hep3Vector( beamSpotHandle->beamPos().x(),
122 beamSpotHandle->beamPos().y(),
123 beamSpotHandle->beamPos().z() )
127 ATH_MSG_VERBOSE(
"BeamSpotSvc reported beam position as " << beamSpotHandle->beamPos() << std::endl
128 <<
"\tWidth is (" << beamSpotHandle->beamSigma(0)
129 <<
", " << beamSpotHandle->beamSigma(1) <<
", "
130 <<
m_L <<
")" << std::endl
131 <<
"\tTilts are " << beamSpotHandle->beamTilt(0) <<
" and " << beamSpotHandle->beamTilt(1) << std::endl
132 <<
"\tVertex Position before transform: " << *vertexSmearing);
135 *vertexSmearing =
transform * HepGeom::Point3D<double>(*vertexSmearing);
143 double bunch_length_z = (std::sqrt(2)*vertexZ)/0.9;
153 double time_offset = CLHEP::RandGaussZiggurat::shoot(
161 return vertexSmearing;