ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
BeamEffects
src
GenEventRotator.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// class header include
6
#include "
GenEventRotator.h
"
7
8
// Athena includes
9
#include "CLHEP/Random/RandGaussZiggurat.h"
10
11
// CLHEP includes
12
#include "CLHEP/Vector/LorentzVector.h"
13
#include "CLHEP/Units/PhysicalConstants.h"
14
15
// HepMC includes
16
#include "
AtlasHepMC/GenEvent.h
"
17
#include "
AtlasHepMC/GenParticle.h
"
18
19
namespace
Simulation
20
{
22
GenEventRotator::GenEventRotator
(
const
std::string& t,
23
const
std::string& n,
24
const
IInterface* p )
25
: base_class(t,n,p)
26
{
27
}
28
30
StatusCode
GenEventRotator::initialize
()
31
{
32
ATH_MSG_VERBOSE
(
"Initializing ..."
);
33
return
StatusCode::SUCCESS;
34
}
35
37
StatusCode
GenEventRotator::finalize
()
38
{
39
ATH_MSG_VERBOSE
(
"Finalizing ..."
);
40
return
StatusCode::SUCCESS;
41
}
42
43
StatusCode
GenEventRotator::initializeAthenaEvent
()
44
{
45
return
StatusCode::SUCCESS;
46
}
47
48
StatusCode
GenEventRotator::initializeGenEvent
(CLHEP::HepLorentzRotation& transform,
const
EventContext&)
const
49
{
50
// Reset the transformation
51
transform = CLHEP::HepLorentzRotation();
//TODO drop this
52
53
// Setting up three rotation matrices, via 3x3 rep. rather than even more messy EulerAngles
54
const
double
sinX = sin(
m_xangle
*CLHEP::deg);
55
const
double
cosX = cos(
m_xangle
*CLHEP::deg);
56
const
CLHEP::HepRotation rotx(CLHEP::HepRep3x3(1.0,0.0,0.0, 0.0,cosX,-sinX, 0.0,sinX,cosX));
57
const
double
sinY = sin(
m_yangle
*CLHEP::deg);
58
const
double
cosY = cos(
m_yangle
*CLHEP::deg);
59
const
CLHEP::HepRotation roty(CLHEP::HepRep3x3(cosY,0.0,sinY, 0.0,1.0,0.0, -sinY,0.0,cosY));
60
const
double
sinZ = sin(
m_zangle
*CLHEP::deg);
61
const
double
cosZ = cos(
m_zangle
*CLHEP::deg);
62
const
CLHEP::HepRotation rotz(CLHEP::HepRep3x3(cosZ,-sinZ,0.0, sinZ,cosZ,0.0, 0.0,0.0,1.0));
63
// Combine the three rotations - order of trf execution is unimportant as they are orthogonal.
64
const
CLHEP::HepRotation rot = rotx*roty*rotz;
65
transform.set(rot);
66
return
StatusCode::SUCCESS;
67
}
68
70
StatusCode
GenEventRotator::manipulate
(
HepMC::GenEvent
& ge,
const
EventContext& ctx)
const
71
{
72
// Obtain the transformation
73
CLHEP::HepLorentzRotation transform = CLHEP::HepLorentzRotation();
74
ATH_CHECK
(
initializeGenEvent
(transform, ctx) );
75
76
for
(
auto
particleIter: ge) {
77
rotateParticle
(particleIter, transform);
78
}
79
return
StatusCode::SUCCESS;
80
}
81
82
void
GenEventRotator::rotateParticle
(
HepMC::GenParticlePtr
& p,
83
const
CLHEP::HepLorentzRotation& transform)
const
84
{
85
// Apply the same transformation for EVERY HepMC::GenParticle
86
const
HepMC::FourVector
mom = p->momentum();
87
CLHEP::HepLorentzVector hv(mom.px(), mom.py(), mom.pz(), mom.e());
//TODO check units
88
ATH_MSG_VERBOSE
(
"initial momentum "
<< hv );
89
hv.transform(transform);
90
ATH_MSG_VERBOSE
(
"transformed momentum "
<< hv);
91
p->set_momentum(
HepMC::FourVector
(hv.px(),hv.py(),hv.pz(),hv.e()));
//TODO check units
92
}
93
94
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
GenEventRotator.h
GenEvent.h
GenParticle.h
Simulation::GenEventRotator::m_zangle
Gaudi::Property< double > m_zangle
Definition
GenEventRotator.h:51
Simulation::GenEventRotator::m_xangle
Gaudi::Property< double > m_xangle
Definition
GenEventRotator.h:49
Simulation::GenEventRotator::manipulate
StatusCode manipulate(HepMC::GenEvent &ge, const EventContext &ctx) const override final
modifies the given GenEvent
Definition
GenEventRotator.cxx:70
Simulation::GenEventRotator::initializeAthenaEvent
StatusCode initializeAthenaEvent()
Definition
GenEventRotator.cxx:43
Simulation::GenEventRotator::finalize
StatusCode finalize() override final
Athena algtool's Hooks.
Definition
GenEventRotator.cxx:37
Simulation::GenEventRotator::rotateParticle
void rotateParticle(HepMC::GenParticlePtr &p, const CLHEP::HepLorentzRotation &transform) const
apply rotations to individual GenParticles
Definition
GenEventRotator.cxx:82
Simulation::GenEventRotator::GenEventRotator
GenEventRotator(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition
GenEventRotator.cxx:22
Simulation::GenEventRotator::m_yangle
Gaudi::Property< double > m_yangle
Definition
GenEventRotator.h:50
Simulation::GenEventRotator::initialize
StatusCode initialize() override final
Athena algtool's Hooks.
Definition
GenEventRotator.cxx:30
Simulation::GenEventRotator::initializeGenEvent
StatusCode initializeGenEvent(CLHEP::HepLorentzRotation &transform, const EventContext &ctx) const
calculate the transformations that we want to apply to the particles in the current GenEvent
Definition
GenEventRotator.cxx:48
HepMC::FourVector
HepMC3::FourVector FourVector
Definition
SimpleVector.h:11
HepMC::GenParticlePtr
HepMC3::GenParticlePtr GenParticlePtr
Definition
GenParticle.h:19
HepMC::GenEvent
HepMC3::GenEvent GenEvent
Definition
GenEvent.h:39
Simulation
Definition
BeamEffectsAlg.cxx:21
Generated on
for ATLAS Offline Software by
1.17.0