ATLAS Offline Software
Loading...
Searching...
No Matches
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"
18
19namespace 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
31 {
32 ATH_MSG_VERBOSE("Initializing ...");
33 return StatusCode::SUCCESS;
34 }
35
38 {
39 ATH_MSG_VERBOSE("Finalizing ...");
40 return StatusCode::SUCCESS;
41 }
42
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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Gaudi::Property< double > m_zangle
Gaudi::Property< double > m_xangle
StatusCode manipulate(HepMC::GenEvent &ge, const EventContext &ctx) const override final
modifies the given GenEvent
StatusCode finalize() override final
Athena algtool's Hooks.
void rotateParticle(HepMC::GenParticlePtr &p, const CLHEP::HepLorentzRotation &transform) const
apply rotations to individual GenParticles
GenEventRotator(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Gaudi::Property< double > m_yangle
StatusCode initialize() override final
Athena algtool's Hooks.
StatusCode initializeGenEvent(CLHEP::HepLorentzRotation &transform, const EventContext &ctx) const
calculate the transformations that we want to apply to the particles in the current GenEvent
GenParticle * GenParticlePtr
Definition GenParticle.h:37