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

This tool takes a HepMC::GenEvent and applies rotations See https://twiki.cern.ch/twiki/bin/viewauth/Atlas/AtlasG4EventFilters for more details. More...

#include <GenEventRotator.h>

Inheritance diagram for Simulation::GenEventRotator:
Collaboration diagram for Simulation::GenEventRotator:

Public Member Functions

 GenEventRotator (const std::string &t, const std::string &n, const IInterface *p)
 Constructor with parameters.
StatusCode initialize () override final
 Athena algtool's Hooks.
StatusCode finalize () override final
 Athena algtool's Hooks.
StatusCode initializeAthenaEvent ()
StatusCode manipulate (HepMC::GenEvent &ge, const EventContext &ctx) const override final
 modifies the given GenEvent

Private Member Functions

StatusCode initializeGenEvent (CLHEP::HepLorentzRotation &transform, const EventContext &ctx) const
 calculate the transformations that we want to apply to the particles in the current GenEvent
void rotateParticle (HepMC::GenParticlePtr &p, const CLHEP::HepLorentzRotation &transform) const
 apply rotations to individual GenParticles

Private Attributes

Gaudi::Property< double > m_xangle {this, "xAngle", 0.0, "rotation about x-axis"}
Gaudi::Property< double > m_yangle {this, "yAngle", 0.0, "rotation about y-axis"}
Gaudi::Property< double > m_zangle {this, "zAngle", 0.0, "rotation about z-axis"}

Detailed Description

This tool takes a HepMC::GenEvent and applies rotations See https://twiki.cern.ch/twiki/bin/viewauth/Atlas/AtlasG4EventFilters for more details.

Definition at line 28 of file GenEventRotator.h.

Constructor & Destructor Documentation

◆ GenEventRotator()

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

Constructor with parameters.

Constructor.

Definition at line 22 of file GenEventRotator.cxx.

25 : base_class(t,n,p)
26 {
27 }

Member Function Documentation

◆ finalize()

StatusCode Simulation::GenEventRotator::finalize ( )
finaloverride

Athena algtool's Hooks.

Definition at line 37 of file GenEventRotator.cxx.

38 {
39 ATH_MSG_VERBOSE("Finalizing ...");
40 return StatusCode::SUCCESS;
41 }
#define ATH_MSG_VERBOSE(x)

◆ initialize()

StatusCode Simulation::GenEventRotator::initialize ( )
finaloverride

Athena algtool's Hooks.

Definition at line 30 of file GenEventRotator.cxx.

31 {
32 ATH_MSG_VERBOSE("Initializing ...");
33 return StatusCode::SUCCESS;
34 }

◆ initializeAthenaEvent()

StatusCode Simulation::GenEventRotator::initializeAthenaEvent ( )

Definition at line 43 of file GenEventRotator.cxx.

44 {
45 return StatusCode::SUCCESS;
46 }

◆ initializeGenEvent()

StatusCode Simulation::GenEventRotator::initializeGenEvent ( CLHEP::HepLorentzRotation & transform,
const EventContext & ctx ) const
private

calculate the transformations that we want to apply to the particles in the current GenEvent

Definition at line 48 of file GenEventRotator.cxx.

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 }
Gaudi::Property< double > m_zangle
Gaudi::Property< double > m_xangle
Gaudi::Property< double > m_yangle
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.

◆ manipulate()

StatusCode Simulation::GenEventRotator::manipulate ( HepMC::GenEvent & ge,
const EventContext & ctx ) const
finaloverride

modifies the given GenEvent

modifies (displaces) the given GenEvent

Definition at line 70 of file GenEventRotator.cxx.

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 }
#define ATH_CHECK
Evaluate an expression and check for errors.
void rotateParticle(HepMC::GenParticlePtr &p, const CLHEP::HepLorentzRotation &transform) const
apply rotations to individual GenParticles
StatusCode initializeGenEvent(CLHEP::HepLorentzRotation &transform, const EventContext &ctx) const
calculate the transformations that we want to apply to the particles in the current GenEvent

◆ rotateParticle()

void Simulation::GenEventRotator::rotateParticle ( HepMC::GenParticlePtr & p,
const CLHEP::HepLorentzRotation & transform ) const
private

apply rotations to individual GenParticles

Definition at line 82 of file GenEventRotator.cxx.

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 }

Member Data Documentation

◆ m_xangle

Gaudi::Property<double> Simulation::GenEventRotator::m_xangle {this, "xAngle", 0.0, "rotation about x-axis"}
private

Definition at line 49 of file GenEventRotator.h.

49{this, "xAngle", 0.0, "rotation about x-axis"};

◆ m_yangle

Gaudi::Property<double> Simulation::GenEventRotator::m_yangle {this, "yAngle", 0.0, "rotation about y-axis"}
private

Definition at line 50 of file GenEventRotator.h.

50{this, "yAngle", 0.0, "rotation about y-axis"};

◆ m_zangle

Gaudi::Property<double> Simulation::GenEventRotator::m_zangle {this, "zAngle", 0.0, "rotation about z-axis"}
private

Definition at line 51 of file GenEventRotator.h.

51{this, "zAngle", 0.0, "rotation about z-axis"};

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