ATLAS Offline Software
Loading...
Searching...
No Matches
Simulation::VertexBeamCondPositioner Class Reference

This AthenaTool computes geometrical shifts for the initial GenEvent vertices. More...

#include <VertexBeamCondPositioner.h>

Inheritance diagram for Simulation::VertexBeamCondPositioner:
Collaboration diagram for Simulation::VertexBeamCondPositioner:

Public Member Functions

 VertexBeamCondPositioner (const std::string &t, const std::string &n, const IInterface *p)
 Constructor with parameters.
 ~VertexBeamCondPositioner ()=default
 Destructor.
StatusCode initialize () override final
 Athena algtool's Hooks.
StatusCode finalize () override final
 Athena algtool's Hooks.
CLHEP::HepLorentzVector * generate (const EventContext &ctx) const override final
 computes the vertex displacement

Private Attributes

SG::ReadCondHandleKey< InDet::BeamSpotDatam_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }
ServiceHandle< IAthRNGSvcm_rndGenSvc {this, "RandomSvc", "AthRNGSvc"}
ATHRNG::RNGWrapper *m_randomEngine ATLAS_THREAD_SAFE {}
 Slot-local RNG.
Gaudi::Property< std::string > m_randomEngineName {this, "RandomStream", "VERTEX"}
 Name of the random number stream.
Gaudi::Property< bool > m_timeSmearing {this, "SimpleTimeSmearing", false}
 Do time smearing.
Gaudi::Property< float > m_timeWidth {this, "TimeWidth", 0.}
 Width of time for smearing.

Detailed Description

This AthenaTool computes geometrical shifts for the initial GenEvent vertices.

based on: https://svnweb.cern.ch/trac/atlasoff/browser/Simulation/G4Atlas/G4AtlasUtilities/trunk/src/VertexPositioner.cxx

Author
Andreas.Salzburger -at- cern.ch , Elmar.Ritsch -at- cern.ch

Definition at line 33 of file VertexBeamCondPositioner.h.

Constructor & Destructor Documentation

◆ VertexBeamCondPositioner()

Simulation::VertexBeamCondPositioner::VertexBeamCondPositioner ( const std::string & t,
const std::string & n,
const IInterface * p )

Constructor with parameters.

Constructor.

Definition at line 25 of file VertexBeamCondPositioner.cxx.

28 : base_class(t,n,p)
29 {
30 }

◆ ~VertexBeamCondPositioner()

Simulation::VertexBeamCondPositioner::~VertexBeamCondPositioner ( )
default

Destructor.

Member Function Documentation

◆ finalize()

StatusCode Simulation::VertexBeamCondPositioner::finalize ( )
finaloverride

Athena algtool's Hooks.

Definition at line 50 of file VertexBeamCondPositioner.cxx.

51 {
52 ATH_MSG_VERBOSE("Finalizing ...");
53 return StatusCode::SUCCESS;
54 }
#define ATH_MSG_VERBOSE(x)

◆ generate()

CLHEP::HepLorentzVector * Simulation::VertexBeamCondPositioner::generate ( const EventContext & ctx) const
finaloverride

computes the vertex displacement

Definition at line 57 of file VertexBeamCondPositioner.cxx.

58 {
59 // Prepare the random engine
60 m_randomEngine->setSeed( name(), ctx );
61 CLHEP::HepRandomEngine* randomEngine(m_randomEngine->getEngine(ctx));
62 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey, ctx };
63 // See jira issue ATLASSIM-497 for an explanation of why calling
64 // shoot outside the CLHEP::HepLorentzVector constructor is
65 // necessary/preferable.
66 float vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(0);
67 float vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(1);
68 float vertexZ = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(2);
69 // calculate the vertexSmearing
70 CLHEP::HepLorentzVector *vertexSmearing =
71 new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. );
72
73 // (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx
74 const double tx = tan( beamSpotHandle->beamTilt(1) );
75 const double ty = tan( beamSpotHandle->beamTilt(0) );
76
77 const double sqrt_abc = sqrt(1. + tx*tx + ty*ty);
78 const double sqrt_fgh = sqrt(1. + ty*ty);
79
80 const double a = ty/sqrt_abc;
81 const double b = tx/sqrt_abc;
82 const double c = 1./sqrt_abc;
83
84 HepGeom::Point3D<double> from1(0,0,1);
85 HepGeom::Point3D<double> to1(a,b,c);
86
87 const double f = 1./sqrt_fgh;
88 const double g = 0.;
89 const double h = -(ty)/sqrt_fgh;
90
91 HepGeom::Point3D<double> from2(1,0,0);
92 HepGeom::Point3D<double> to2(f,g,h);
93
94 // first rotation, then translation
95 HepGeom::Transform3D transform(
96 HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(),
97 CLHEP::Hep3Vector( beamSpotHandle->beamPos().x(),
98 beamSpotHandle->beamPos().y(),
99 beamSpotHandle->beamPos().z() )
100 );
101
102 // FIXME: don't use endl in MsgStream printouts
103 ATH_MSG_VERBOSE("BeamSpotSvc reported beam position as " << beamSpotHandle->beamPos() << std::endl
104 << "\tWidth is (" << beamSpotHandle->beamSigma(0)
105 << ", " << beamSpotHandle->beamSigma(1) << ", "
106 << beamSpotHandle->beamSigma(2) << ")" << std::endl
107 << "\tTime smearing is " << (m_timeSmearing ? "on" : "off") << " with width " << m_timeWidth << std::endl
108 << "\tTilts are " << beamSpotHandle->beamTilt(0) << " and " << beamSpotHandle->beamTilt(1) << std::endl
109 << "\tVertex Position before transform: " << *vertexSmearing);
110
111 // update with the tilt
112 *vertexSmearing = transform * HepGeom::Point3D<double>(*vertexSmearing);
113
114 float vertexT = m_timeSmearing ? CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_timeWidth*Gaudi::Units::c_light : 0.;
115 vertexSmearing->setT(vertexT);
116
117 // and return it
118 return vertexSmearing;
119 }
static Double_t a
Gaudi::Property< bool > m_timeSmearing
Do time smearing.
Gaudi::Property< float > m_timeWidth
Width of time for smearing.
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.

◆ initialize()

StatusCode Simulation::VertexBeamCondPositioner::initialize ( )
finaloverride

Athena algtool's Hooks.

Definition at line 33 of file VertexBeamCondPositioner.cxx.

34 {
35 ATH_MSG_VERBOSE("Initializing ...");
36
37 // retrieve the random number service
38 ATH_CHECK(m_rndGenSvc.retrieve());
39 m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName);
40 if (!m_randomEngine) {
41 ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort.");
42 return StatusCode::FAILURE;
43 }
44 ATH_CHECK(m_beamSpotKey.initialize());
45 // everything set up properly
46 return StatusCode::SUCCESS;
47 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Gaudi::Property< std::string > m_randomEngineName
Name of the random number stream.

Member Data Documentation

◆ ATLAS_THREAD_SAFE

ATHRNG::RNGWrapper* m_randomEngine Simulation::VertexBeamCondPositioner::ATLAS_THREAD_SAFE {}
private

Slot-local RNG.

Definition at line 54 of file VertexBeamCondPositioner.h.

54{};

◆ m_beamSpotKey

SG::ReadCondHandleKey<InDet::BeamSpotData> Simulation::VertexBeamCondPositioner::m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }
private

Definition at line 52 of file VertexBeamCondPositioner.h.

52{ this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };

◆ m_randomEngineName

Gaudi::Property<std::string> Simulation::VertexBeamCondPositioner::m_randomEngineName {this, "RandomStream", "VERTEX"}
private

Name of the random number stream.

Definition at line 56 of file VertexBeamCondPositioner.h.

56{this, "RandomStream", "VERTEX"};

◆ m_rndGenSvc

ServiceHandle<IAthRNGSvc> Simulation::VertexBeamCondPositioner::m_rndGenSvc {this, "RandomSvc", "AthRNGSvc"}
private

Definition at line 53 of file VertexBeamCondPositioner.h.

53{this, "RandomSvc", "AthRNGSvc"};

◆ m_timeSmearing

Gaudi::Property<bool> Simulation::VertexBeamCondPositioner::m_timeSmearing {this, "SimpleTimeSmearing", false}
private

Do time smearing.

Definition at line 57 of file VertexBeamCondPositioner.h.

57{this, "SimpleTimeSmearing", false};

◆ m_timeWidth

Gaudi::Property<float> Simulation::VertexBeamCondPositioner::m_timeWidth {this, "TimeWidth", 0.}
private

Width of time for smearing.

Definition at line 58 of file VertexBeamCondPositioner.h.

58{this, "TimeWidth", 0.};

The documentation for this class was generated from the following files: