ATLAS Offline Software
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Simulation::CrabKissingVertexPositioner Class Reference

#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. More...
 
virtual ~CrabKissingVertexPositioner ()=default
 Destructor. More...
 
StatusCode initialize () override final
 Athena algtool's Hooks. More...
 
StatusCode finalize () override final
 Athena algtool's Hooks. More...
 
CLHEP::HepLorentzVector * generate (const EventContext &ctx) const override final
 computes the vertex displacement More...
 

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. More...
 
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. More...
 
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 -------------------------— More...
 
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

Enumerator
GAUSS 
FLAT 
NSHAPES 

Definition at line 73 of file CrabKissingVertexPositioner.h.

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  }

◆ ~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  }

◆ BunchShapeHandler()

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

Definition at line 33 of file CrabKissingVertexPositioner.cxx.

34  {
35  if(m_bunchShapeProp.value() == "GAUSS") m_bunchShape = BunchShape::GAUSS;
36  else if(m_bunchShapeProp.value() == "FLAT") m_bunchShape = BunchShape::FLAT;
37  else m_bunchShape=BunchShape::NSHAPES;
38  }

◆ 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  }

◆ 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));
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
119  if ( m_bunchShape == BunchShape::GAUSS) {
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
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  }

◆ 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  }

◆ 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());
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  }

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.

◆ m_alphaPar

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

Definition at line 79 of file CrabKissingVertexPositioner.h.

◆ m_alphaX

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

Definition at line 80 of file CrabKissingVertexPositioner.h.

◆ 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.

◆ 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.

◆ 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.

◆ m_bunchShape

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

Definition at line 74 of file CrabKissingVertexPositioner.h.

◆ 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.

◆ 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.

◆ 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.

◆ m_rndGenSvc

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

Definition at line 68 of file CrabKissingVertexPositioner.h.

◆ m_thetaX

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

Definition at line 81 of file CrabKissingVertexPositioner.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Simulation::CrabKissingVertexPositioner::m_bunchLength
Gaudi::Property< double > m_bunchLength
Parameter in the Z distribution of the beamspot.
Definition: CrabKissingVertexPositioner.h:75
Simulation::CrabKissingVertexPositioner::beamspotFunction
double beamspotFunction(double displacement, double angle1, double angle2) const
Definition: CrabKissingVertexPositioner.cxx:78
Simulation::CrabKissingVertexPositioner::FLAT
@ FLAT
Definition: CrabKissingVertexPositioner.h:73
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
Simulation::CrabKissingVertexPositioner::getDisplacement
double getDisplacement(double bunchSize, double angle1, double angle2, CLHEP::HepRandomEngine *rng) const
Definition: CrabKissingVertexPositioner.cxx:87
Simulation::CrabKissingVertexPositioner::m_alphaX
Gaudi::Property< double > m_alphaX
Definition: CrabKissingVertexPositioner.h:80
Simulation::CrabKissingVertexPositioner::heaviside
double heaviside(double val) const
Definition: CrabKissingVertexPositioner.h:62
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Simulation::CrabKissingVertexPositioner::m_rndGenSvc
ServiceHandle< IAthRNGSvc > m_rndGenSvc
Definition: CrabKissingVertexPositioner.h:68
Simulation::CrabKissingVertexPositioner::m_betaStar
Gaudi::Property< double > m_betaStar
parameters according to S.Fartoukh Phys.Rev.ST Accel.Beams 17 (2014) no.11, 111001 ------------------...
Definition: CrabKissingVertexPositioner.h:77
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
Simulation::CrabKissingVertexPositioner::m_thetaX
Gaudi::Property< double > m_thetaX
Definition: CrabKissingVertexPositioner.h:81
Simulation::CrabKissingVertexPositioner::m_bunchShapeProp
Gaudi::Property< std::string > m_bunchShapeProp
Definition: CrabKissingVertexPositioner.h:71
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
hist_file_dump.f
f
Definition: hist_file_dump.py:135
Simulation::CrabKissingVertexPositioner::NSHAPES
@ NSHAPES
Definition: CrabKissingVertexPositioner.h:73
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Simulation::CrabKissingVertexPositioner::m_epsilon
Gaudi::Property< double > m_epsilon
Definition: CrabKissingVertexPositioner.h:78
Simulation::CrabKissingVertexPositioner::m_randomEngineName
Gaudi::Property< std::string > m_randomEngineName
Definition: CrabKissingVertexPositioner.h:70
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Simulation::CrabKissingVertexPositioner::BunchShapeHandler
void BunchShapeHandler(Gaudi::Details::PropertyBase &)
Definition: CrabKissingVertexPositioner.cxx:33
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
plotting.yearwise_efficiency_vs_mu.yval
float yval
Definition: yearwise_efficiency_vs_mu.py:36
Simulation::CrabKissingVertexPositioner::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: CrabKissingVertexPositioner.h:67
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
Simulation::CrabKissingVertexPositioner::m_alphaPar
Gaudi::Property< double > m_alphaPar
Definition: CrabKissingVertexPositioner.h:79
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
Simulation::CrabKissingVertexPositioner::GAUSS
@ GAUSS
Definition: CrabKissingVertexPositioner.h:73
python.compressB64.c
def c
Definition: compressB64.py:93
TileDCSDataPlotter.tx
tx
Definition: TileDCSDataPlotter.py:878
Simulation::CrabKissingVertexPositioner::m_bunchShape
BunchShape m_bunchShape
Definition: CrabKissingVertexPositioner.h:74