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

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

#include <CrabKissingVertexPositioner.h>

Inheritance diagram for Simulation::CrabKissingVertexPositioner:
Collaboration diagram for Simulation::CrabKissingVertexPositioner:

Public Member Functions

 CrabKissingVertexPositioner (const std::string &t, const std::string &n, const IInterface *p)
 Constructor with parameters.
virtual ~CrabKissingVertexPositioner ()=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 Types

enum  BunchShape { GAUSS , FLAT , NSHAPES }

Private Member Functions

double heaviside (double val) const
double getDisplacement (double bunchSize, double angle1, double angle2, CLHEP::HepRandomEngine *rng) const
double beamspotFunction (double displacement, double angle1, double angle2) const
void BunchShapeHandler (Gaudi::Details::PropertyBase &)

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< std::string > m_bunchShapeProp {this, "BunchShape", "GAUSS", "GAUSS or FLAT"}
BunchShape m_bunchShape {BunchShape::GAUSS}
Gaudi::Property< double > m_bunchLength {this, "BunchLength", 75., "75.0 mm"}
 Parameter in the Z distribution of the beamspot.
Gaudi::Property< double > m_betaStar {this, "BetaStar", 150., "beta* in the parallel (kissing) plane, we assume betax=betay, units: mm"}
 parameters according to S.Fartoukh Phys.Rev.ST Accel.Beams 17 (2014) no.11, 111001 -------------------------—
Gaudi::Property< double > m_epsilon {this, "Epsilon", 2.5e-3, "Normalized emittance, unit: mm"}
Gaudi::Property< double > m_alphaPar {this, "AlfasParallel", 0., "Kissing angle (Radians)"}
Gaudi::Property< double > m_alphaX {this, "AlfaX", 295e-6}
Gaudi::Property< double > m_thetaX {this, "ThetaX", 295e-6}

Detailed Description

This AthenaTool computes geometrical shifts for the initial GenEvent vertices.

based on function from S.Fartoukh Phys.Rev.ST Accel.Beams 17 (2014) no.11, 111001

Author
John.Chapman -at- cern.ch, Elmar.Ritsch -at- cern.ch, Daniele.Ruini -at- poltechnique.edu

Definition at line 43 of file CrabKissingVertexPositioner.h.

Member Enumeration Documentation

◆ BunchShape

Constructor & Destructor Documentation

◆ CrabKissingVertexPositioner()

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

Constructor with parameters.

Constructor.

Definition at line 25 of file CrabKissingVertexPositioner.cxx.

28 : base_class(t,n,p)
29 {
31 }
void BunchShapeHandler(Gaudi::Details::PropertyBase &)

◆ ~CrabKissingVertexPositioner()

virtual Simulation::CrabKissingVertexPositioner::~CrabKissingVertexPositioner ( )
virtualdefault

Destructor.

Member Function Documentation

◆ beamspotFunction()

double Simulation::CrabKissingVertexPositioner::beamspotFunction ( double displacement,
double angle1,
double angle2 ) const
private

Definition at line 78 of file CrabKissingVertexPositioner.cxx.

79 {
80 if ( angle1<1e-10 ) angle1 = 1e-10; // to avoid divide_by_zero errors
81 double temp(1.0-std::fabs(displacement)/m_bunchLength);
82 return 1.0/M_2_SQRTPI * std::erf(angle1*temp)/angle1 *
83 std::exp( -pow(angle2*displacement/m_bunchLength, 2) ) *
84 heaviside(temp);
85 }
constexpr int pow(int base, int exp) noexcept
Gaudi::Property< double > m_bunchLength
Parameter in the Z distribution of the beamspot.

◆ BunchShapeHandler()

void Simulation::CrabKissingVertexPositioner::BunchShapeHandler ( Gaudi::Details::PropertyBase & )
private

◆ finalize()

StatusCode Simulation::CrabKissingVertexPositioner::finalize ( )
finaloverride

Athena algtool's Hooks.

Definition at line 69 of file CrabKissingVertexPositioner.cxx.

70 {
71 ATH_MSG_VERBOSE("Finalizing ...");
72 return StatusCode::SUCCESS;
73 }
#define ATH_MSG_VERBOSE(x)

◆ generate()

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

computes the vertex displacement

Definition at line 103 of file CrabKissingVertexPositioner.cxx.

104 {
105 // Prepare the random engine
106 m_randomEngine->setSeed( name(), ctx );
107 CLHEP::HepRandomEngine* randomEngine(m_randomEngine->getEngine(ctx));
108 SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey, ctx };
109 // See jira issue ATLASSIM-497 for an explanation of why calling
110 // shoot outside the CLHEP::HepLorentzVector constructor is
111 // necessary/preferable.
112 double vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(0);
113 double vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(1);
114 double piwinski_phi = std::fabs(m_thetaX - m_alphaX) * m_bunchLength/std::sqrt(m_epsilon * m_betaStar);
115 double piwinski_psi = m_alphaPar * m_bunchLength / std::sqrt( m_epsilon * m_betaStar);
116 double vertexZ = 0;
117 double vertexT = 0;
118 // Time should be set in units of distance, the following methods generate c*t
120 double zWidth = m_bunchLength / std::sqrt(2*(1+pow(piwinski_phi,2)));
121 double timeWidth = m_bunchLength / std::sqrt(2*(1+pow(piwinski_psi,2)));
122 vertexZ = CLHEP::RandGaussZiggurat::shoot(randomEngine, 0., zWidth);
123 vertexT = CLHEP::RandGaussZiggurat::shoot(randomEngine, 0., timeWidth);
124 }
125 else if ( m_bunchShape == BunchShape::FLAT ) {
126 vertexZ = getDisplacement(m_bunchLength, piwinski_psi, piwinski_phi, randomEngine);
127 vertexT = getDisplacement(m_bunchLength, piwinski_phi, piwinski_psi, randomEngine);
128 }
129 else {
130 ATH_MSG_WARNING("Invalid BunchShape ("<<m_bunchShapeProp.value()<<"). Vertex smearing disabled");
131 return new CLHEP::HepLorentzVector(0.,0.,0.,0.);
132 }
133 ATH_MSG_VERBOSE("m_bunchLength = " << m_bunchLength <<
134 ", Zvertex = " << vertexZ << ", Tvertex = " << vertexT);
135
136 // calculate the vertexSmearing
137 CLHEP::HepLorentzVector *vertexSmearing =
138 new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. );
139
140 // (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx
141 const double tx = tan( beamSpotHandle->beamTilt(1) );
142 const double ty = tan( beamSpotHandle->beamTilt(0) );
143
144 const double sqrt_abc = std::sqrt(1. + tx*tx + ty*ty);
145 const double sqrt_fgh = std::sqrt(1. + ty*ty);
146
147 const double a = ty/sqrt_abc;
148 const double b = tx/sqrt_abc;
149 const double c = 1./sqrt_abc;
150
151 HepGeom::Point3D<double> from1(0,0,1);
152 HepGeom::Point3D<double> to1(a,b,c);
153
154 const double f = 1./sqrt_fgh;
155 const double g = 0.;
156 const double h = -(ty)/sqrt_fgh;
157
158 HepGeom::Point3D<double> from2(1,0,0);
159 HepGeom::Point3D<double> to2(f,g,h);
160
161 // first rotation, then translation
162 HepGeom::Transform3D transform(
163 HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(),
164 CLHEP::Hep3Vector( beamSpotHandle->beamPos().x(),
165 beamSpotHandle->beamPos().y(),
166 beamSpotHandle->beamPos().z() )
167 );
168
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);
175
176 // update with the tilt
177 *vertexSmearing = transform * HepGeom::Point3D<double>(*vertexSmearing);
178 vertexSmearing->setT(vertexT);
179
180 // and return it
181 return vertexSmearing;
182 }
#define ATH_MSG_WARNING(x)
static Double_t a
Gaudi::Property< double > m_betaStar
parameters according to S.Fartoukh Phys.Rev.ST Accel.Beams 17 (2014) no.11, 111001 ------------------...
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
double getDisplacement(double bunchSize, double angle1, double angle2, CLHEP::HepRandomEngine *rng) const
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.

◆ getDisplacement()

double Simulation::CrabKissingVertexPositioner::getDisplacement ( double bunchSize,
double angle1,
double angle2,
CLHEP::HepRandomEngine * rng ) const
private

Definition at line 87 of file CrabKissingVertexPositioner.cxx.

89 {
90 size_t ntries(0);
91 double yval(CLHEP::RandFlat::shoot(randomEngine, 0.0, 1.0));
92 double displ(CLHEP::RandFlat::shoot(randomEngine, -bunchSize, bunchSize));
93 while (this->beamspotFunction(displ, angle1, angle2)<yval) {
94 if(ntries>1000000) return 0.0; //just so we don't sit in this loop forever
95 yval = CLHEP::RandFlat::shoot(randomEngine, 0.0, 1.0);
96 displ = CLHEP::RandFlat::shoot(randomEngine, -bunchSize, bunchSize);
97 ++ntries;
98 }
99 return displ;
100 }
double beamspotFunction(double displacement, double angle1, double angle2) const

◆ heaviside()

double Simulation::CrabKissingVertexPositioner::heaviside ( double val) const
inlineprivate

Definition at line 62 of file CrabKissingVertexPositioner.h.

62{return (val >= 0.0) ? 1.0 : 0.0;};

◆ initialize()

StatusCode Simulation::CrabKissingVertexPositioner::initialize ( )
finaloverride

Athena algtool's Hooks.

Definition at line 41 of file CrabKissingVertexPositioner.cxx.

42 {
43 ATH_MSG_VERBOSE("Initializing ...");
44
45 // prepare the RandonNumber generation
46 ATH_CHECK(m_rndGenSvc.retrieve());
47 ATH_CHECK(m_beamSpotKey.initialize());
48
49 m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName);
50 if (!m_randomEngine) {
51 ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort.");
52 return StatusCode::FAILURE;
53 }
54
55 ATH_MSG_DEBUG("BunchShape = " << m_bunchShapeProp.value());
56 ATH_MSG_DEBUG("BunchLength = " << m_bunchLength);
57 ATH_MSG_DEBUG("Epsilon (normalized emittance) = " << m_epsilon);
58 ATH_MSG_DEBUG("BetaStar = " << m_betaStar);
59 ATH_MSG_DEBUG("AlfaParallel (kissing angle) = " << m_alphaPar);
60 ATH_MSG_DEBUG("AlfaX (crabbing angle) = " << m_alphaX);
61 ATH_MSG_DEBUG("ThetaX (half crossing angle) = " << m_thetaX);
62
63 // everything set up properly
64 return StatusCode::SUCCESS;
65 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)

Member Data Documentation

◆ ATLAS_THREAD_SAFE

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

Slot-local RNG.

Definition at line 69 of file CrabKissingVertexPositioner.h.

69{};

◆ m_alphaPar

Gaudi::Property<double> Simulation::CrabKissingVertexPositioner::m_alphaPar {this, "AlfasParallel", 0., "Kissing angle (Radians)"}
private

Definition at line 79 of file CrabKissingVertexPositioner.h.

79{this, "AlfasParallel", 0., "Kissing angle (Radians)"}; // Kissing angle

◆ m_alphaX

Gaudi::Property<double> Simulation::CrabKissingVertexPositioner::m_alphaX {this, "AlfaX", 295e-6}
private

Definition at line 80 of file CrabKissingVertexPositioner.h.

80{this, "AlfaX", 295e-6};

◆ m_beamSpotKey

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

Definition at line 67 of file CrabKissingVertexPositioner.h.

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

◆ m_betaStar

Gaudi::Property<double> Simulation::CrabKissingVertexPositioner::m_betaStar {this, "BetaStar", 150., "beta* in the parallel (kissing) plane, we assume betax=betay, units: mm"}
private

parameters according to S.Fartoukh Phys.Rev.ST Accel.Beams 17 (2014) no.11, 111001 -------------------------—

Definition at line 77 of file CrabKissingVertexPositioner.h.

77{this, "BetaStar", 150., "beta* in the parallel (kissing) plane, we assume betax=betay, units: mm"};

◆ m_bunchLength

Gaudi::Property<double> Simulation::CrabKissingVertexPositioner::m_bunchLength {this, "BunchLength", 75., "75.0 mm"}
private

Parameter in the Z distribution of the beamspot.

Definition at line 75 of file CrabKissingVertexPositioner.h.

75{this, "BunchLength", 75., "75.0 mm"};

◆ m_bunchShape

BunchShape Simulation::CrabKissingVertexPositioner::m_bunchShape {BunchShape::GAUSS}
private

Definition at line 74 of file CrabKissingVertexPositioner.h.

74{BunchShape::GAUSS}; // GAUSS or FLAT

◆ m_bunchShapeProp

Gaudi::Property<std::string> Simulation::CrabKissingVertexPositioner::m_bunchShapeProp {this, "BunchShape", "GAUSS", "GAUSS or FLAT"}
private

Definition at line 71 of file CrabKissingVertexPositioner.h.

71{this, "BunchShape", "GAUSS", "GAUSS or FLAT"};

◆ m_epsilon

Gaudi::Property<double> Simulation::CrabKissingVertexPositioner::m_epsilon {this, "Epsilon", 2.5e-3, "Normalized emittance, unit: mm"}
private

Definition at line 78 of file CrabKissingVertexPositioner.h.

78{this, "Epsilon", 2.5e-3, "Normalized emittance, unit: mm"};

◆ m_randomEngineName

Gaudi::Property<std::string> Simulation::CrabKissingVertexPositioner::m_randomEngineName {this, "RandomStream", "VERTEX", "Name of the random number stream"}
private

Definition at line 70 of file CrabKissingVertexPositioner.h.

70{this, "RandomStream", "VERTEX", "Name of the random number stream"};

◆ m_rndGenSvc

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

Definition at line 68 of file CrabKissingVertexPositioner.h.

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

◆ m_thetaX

Gaudi::Property<double> Simulation::CrabKissingVertexPositioner::m_thetaX {this, "ThetaX", 295e-6}
private

Definition at line 81 of file CrabKissingVertexPositioner.h.

81{this, "ThetaX", 295e-6};

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