ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
BeamEffects
src
GenEventVertexPositioner.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// class header include
6
#include "
GenEventVertexPositioner.h
"
7
8
// HepMC includes
9
#include "
AtlasHepMC/GenEvent.h
"
10
#include "
AtlasHepMC/GenVertex.h
"
11
12
// Framework includes
13
#include "
HepMC_Interfaces/ILorentzVectorGenerator.h
"
14
15
// CLHEP includes
16
#include "CLHEP/Vector/LorentzVector.h"
17
18
namespace
Simulation
19
{
21
GenEventVertexPositioner::GenEventVertexPositioner
(
const
std::string& t,
22
const
std::string& n,
23
const
IInterface* p )
24
: base_class(t,n,p)
25
{
26
}
27
29
StatusCode
GenEventVertexPositioner::initialize
()
30
{
31
ATH_MSG_VERBOSE
(
"Initializing ..."
);
32
33
// retrieve Vertex Shifters
34
if
( !
m_vertexShifters
.empty() ) {
35
ATH_CHECK
(
m_vertexShifters
.retrieve());
36
}
37
38
return
StatusCode::SUCCESS;
39
}
40
42
StatusCode
GenEventVertexPositioner::finalize
()
43
{
44
ATH_MSG_VERBOSE
(
"Finalizing ..."
);
45
return
StatusCode::SUCCESS;
46
}
47
49
StatusCode
GenEventVertexPositioner::manipulate
(
HepMC::GenEvent
& ge,
const
EventContext& ctx)
const
50
{
51
// Grab signal_process_vertex pointer
52
auto
signalProcVtx=
HepMC::signal_process_vertex
(&ge);
53
if
(!signalProcVtx) {
54
ATH_MSG_ERROR
(
"Expected GenEvent::signal_process_vertex() to already have been set at this point!"
);
55
return
StatusCode::FAILURE;
56
}
57
58
// loop over all given ILorentzVectorGenerator AlgTools
59
for
(
const
auto
& vertexShifter :
m_vertexShifters
) {
60
61
// call VertexShifter and let it compute the current shift
62
CLHEP::HepLorentzVector *curShift = vertexShifter->generate(ctx);
63
if
(!curShift) {
64
ATH_MSG_ERROR
(
"Vertex Shifter AthenaTool returned zero-pointer! Ignore."
);
65
continue
;
66
}
67
68
ATH_MSG_VERBOSE
(
"Retrieved Vertex shift of: "
<< *curShift <<
" from "
<< vertexShifter->name());
69
70
// As signal process vertex is a pointer, there is some risk
71
// that the pointer points to a vertex somewhere else in the
72
// event, rather than a unique / new vertex, in which case we
73
// will modify its position in the loop below and will not need
74
// to treat it separately.
75
bool
modifySigVtx(
true
);
76
77
// loop over the vertices in the event, they are in respect with another
78
// (code from Simulation/Fatras/FatrasAlgs/McEventPreProcessing.cxx)
79
for
(
auto
& curVtx: ge.vertices()) {
80
// NB Doing this check to explicitly avoid the fallback mechanism in
81
// HepMC3::GenVertex::position() to return the position of
82
// another GenVertex in the event if the position isn't set (or is set to zero)!
83
const
HepMC::FourVector
&curPos = (curVtx->has_set_position()) ? curVtx->position() : HepMC::FourVector::ZERO_VECTOR();
84
85
// get a copy of the current vertex position
86
CLHEP::HepLorentzVector newPos( curPos.x(), curPos.y(), curPos.z(), curPos.t() );
87
// and update it with the given smearing
88
newPos += (*curShift);
89
90
ATH_MSG_VERBOSE
(
"Original vtx position = "
<< curPos.x() <<
", "
<< curPos.y() <<
", "
<< curPos.z() );
91
ATH_MSG_VERBOSE
(
"Updated vtx position = "
<< newPos );
92
93
// store the updated position in the vertex
94
curVtx->set_position(
HepMC::FourVector
(newPos.x(),newPos.y(),newPos.z(),newPos.t()));
95
if
(modifySigVtx && signalProcVtx==curVtx) {
96
modifySigVtx=
false
;
97
}
98
}
99
100
// Do the same for the signal process vertex if still required.
101
if
(modifySigVtx) {
102
const
HepMC::FourVector
&curPos =
HepMC::signal_process_vertex
(&ge)->position();
103
CLHEP::HepLorentzVector newPos( curPos.x(), curPos.y(), curPos.z(), curPos.t() );
104
newPos += (*curShift);
105
(
HepMC::signal_process_vertex
(&ge))->set_position(
HepMC::FourVector
(newPos.x(),newPos.y(),newPos.z(),newPos.t()) );
106
}
107
108
// memory cleanup
109
delete
curShift;
110
}
111
112
return
StatusCode::SUCCESS;
113
}
114
115
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
GenEventVertexPositioner.h
GenEvent.h
GenVertex.h
ILorentzVectorGenerator.h
Simulation::GenEventVertexPositioner::finalize
StatusCode finalize() override final
Athena algtool's Hooks.
Definition
GenEventVertexPositioner.cxx:42
Simulation::GenEventVertexPositioner::GenEventVertexPositioner
GenEventVertexPositioner(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition
GenEventVertexPositioner.cxx:21
Simulation::GenEventVertexPositioner::initialize
StatusCode initialize() override final
Athena algtool's Hooks.
Definition
GenEventVertexPositioner.cxx:29
Simulation::GenEventVertexPositioner::m_vertexShifters
ToolHandleArray< ILorentzVectorGenerator > m_vertexShifters
Vertex Shifters applied in the given order.
Definition
GenEventVertexPositioner.h:44
Simulation::GenEventVertexPositioner::manipulate
StatusCode manipulate(HepMC::GenEvent &ge, const EventContext &ctx) const override final
modifies (displaces) the given GenEvent
Definition
GenEventVertexPositioner.cxx:49
HepMC::FourVector
HepMC3::FourVector FourVector
Definition
SimpleVector.h:11
HepMC::signal_process_vertex
ConstGenVertexPtr signal_process_vertex(const GenEvent *e)
Definition
GenEvent.h:597
HepMC::GenEvent
HepMC3::GenEvent GenEvent
Definition
GenEvent.h:39
Simulation
Definition
BeamEffectsAlg.cxx:21
Generated on
for ATLAS Offline Software by
1.17.0