ATLAS Offline Software
Generators
BoostAfterburner
src
BoostEvent.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
BoostAfterburner/BoostEvent.h
"
6
7
#include "CLHEP/Vector/LorentzVector.h"
8
#include "
GeneratorObjects/McEventCollection.h
"
9
#include <iomanip>
10
11
BoostEvent::BoostEvent
(
const
std::string&
name
, ISvcLocator* pSvcLocator) :
AthAlgorithm
(
name
, pSvcLocator)
12
{
13
declareProperty
(
"McInputKey"
,
m_inkey
=
"GEN_EVENT"
);
14
declareProperty
(
"McOutputKey"
,
m_outkey
=
"BOOSTED_EVENT"
);
15
declareProperty
(
"BetaX"
,
m_beta_x
=0);
16
declareProperty
(
"BetaY"
,
m_beta_y
=0);
17
declareProperty
(
"BetaZ"
,
m_beta_z
=0);
18
}
19
20
StatusCode
BoostEvent::initialize
()
21
{
22
msg
(
MSG::DEBUG
) <<
"Properties:\n"
23
<< std::setw(60) <<
"McInputKey "
<<
m_inkey
<<
"\n"
24
<< std::setw(60) <<
"McOutputKey "
<<
m_outkey
<<
"\n"
25
<< std::setw(60) <<
"BetaX "
<<
m_beta_x
<<
"\n"
26
<< std::setw(60) <<
"BetaY "
<<
m_beta_y
<<
"\n"
27
<< std::setw(60) <<
"BetaZ "
<<
m_beta_z
<<
"\n"
28
<<
endmsg
;
29
return
StatusCode::SUCCESS;
30
}
31
32
StatusCode
BoostEvent::execute
()
33
{
34
const
McEventCollection
* input_collection =
nullptr
;
35
if
(
evtStore
()->
retrieve
(input_collection,
m_inkey
).isFailure() )
36
{
37
msg
(MSG::ERROR) <<
"Could not retrieve truth McEventCollection "
<<
m_inkey
<<
endmsg
;
38
return
StatusCode::FAILURE;
39
}
40
41
// Loop over all events in original McEventCollection and
42
// Copy to a new (modifiable) collection
43
McEventCollection
* output_collection =
new
McEventCollection
();
44
for
(
McEventCollection::const_iterator
citr = input_collection->
begin
(); citr!=input_collection->
end
(); ++citr)
45
{
46
output_collection->
push_back
(
new
HepMC::GenEvent(*(*citr)));
47
}
48
49
//now loop on particles
50
msg
(
MSG::VERBOSE
) <<
"Boosting event with beta=("
<<
m_beta_x
<<
","
<<
m_beta_y
<<
","
<<
m_beta_z
<<
")"
<<
endmsg
;
51
msg
(
MSG::VERBOSE
) << std::setw(10) <<
"pt"
52
<< std::setw(10) <<
"E"
53
<< std::setw(10) <<
"eta"
54
<< std::setw(10) <<
"phi"
55
<< std::setw(10) <<
"pt'"
56
<< std::setw(10) <<
"E'"
57
<< std::setw(10) <<
"eta'"
58
<< std::setw(10) <<
"phi'"
59
<<
endmsg
;
60
61
for
(
McEventCollection::iterator
itr = output_collection->
begin
(); itr!=output_collection->
end
(); ++itr)
62
{
63
for
(
auto
particle
: **itr){
64
CLHEP::HepLorentzVector
momentum
(
particle
->momentum().px(),
65
particle
->momentum().py(),
66
particle
->momentum().pz(),
67
particle
->momentum().e());
68
69
momentum
.boost(
m_beta_x
,
m_beta_y
,
m_beta_z
);
70
msg
(
MSG::VERBOSE
) << std::setw(10) <<
particle
->momentum().perp()
71
<< std::setw(10) <<
particle
->momentum().e()
72
<< std::setw(10) <<
particle
->momentum().eta()
73
<< std::setw(10) <<
particle
->momentum().phi()
74
<< std::setw(10) <<
momentum
.perp()
75
<< std::setw(10) <<
momentum
.e()
76
<< std::setw(10) <<
momentum
.eta()
77
<< std::setw(10) <<
momentum
.phi()
78
<<
endmsg
;
79
80
particle
->set_momentum( HepMC::FourVector(
momentum
.px(),
momentum
.py(),
momentum
.pz(),
momentum
.e()) );
81
}
82
}
83
84
if
(
evtStore
()->record(output_collection,
m_outkey
).isFailure())
85
{
86
msg
(MSG::ERROR) <<
"Could not record boosted McEventCollection "
<<
m_outkey
<<
endmsg
;
87
return
StatusCode::FAILURE;
88
}
89
90
return
StatusCode::SUCCESS;
91
}
92
93
StatusCode
BoostEvent::finalize
()
94
{
95
return
StatusCode::SUCCESS;
96
}
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition:
PyKernel.py:110
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition:
DVLIterator.h:82
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition:
ParticleHypothesis.h:76
BoostEvent::finalize
StatusCode finalize()
Definition:
BoostEvent.cxx:93
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition:
AthCommonDataStore.h:145
McEventCollection
McEventCollection
Definition:
GeneratorObjectsTPCnv.cxx:60
BoostEvent.h
BoostEvent::execute
StatusCode execute()
Definition:
BoostEvent.cxx:32
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition:
AthCommonDataStore.h:85
BoostEvent::m_beta_x
double m_beta_x
Definition:
BoostEvent.h:21
BoostEvent::m_beta_y
double m_beta_y
Definition:
BoostEvent.h:22
ParticleGun_EoverP_Config.momentum
momentum
Definition:
ParticleGun_EoverP_Config.py:63
McEventCollection.h
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition:
DVLIterator.h:184
BoostEvent::m_outkey
std::string m_outkey
Definition:
BoostEvent.h:20
endmsg
#define endmsg
Definition:
AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition:
McEventCollection.h:33
BoostEvent::m_beta_z
double m_beta_z
Definition:
BoostEvent.h:23
AthAlgorithm
Definition:
AthAlgorithm.h:47
BoostEvent::m_inkey
std::string m_inkey
Definition:
BoostEvent.h:19
BoostEvent::initialize
StatusCode initialize()
Definition:
BoostEvent.cxx:20
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:221
BoostEvent::BoostEvent
BoostEvent(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
BoostEvent.cxx:11
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
DEBUG
#define DEBUG
Definition:
page_access.h:11
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition:
AthCommonMsg.h:24
python.Constants.VERBOSE
int VERBOSE
Definition:
Control/AthenaCommon/python/Constants.py:14
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Generated on Thu Nov 7 2024 21:10:51 for ATLAS Offline Software by
1.8.18