ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include "CLHEP/Vector/LorentzVector.h"
9#include <iomanip>
10
11BoostEvent::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
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
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
94{
95 return StatusCode::SUCCESS;
96}
#define endmsg
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
MsgStream & msg() const
StatusCode initialize()
double m_beta_y
Definition BoostEvent.h:22
double m_beta_x
Definition BoostEvent.h:21
StatusCode finalize()
BoostEvent(const std::string &name, ISvcLocator *pSvcLocator)
double m_beta_z
Definition BoostEvent.h:23
std::string m_inkey
Definition BoostEvent.h:19
StatusCode execute()
std::string m_outkey
Definition BoostEvent.h:20
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::iterator< DataVector > iterator
Definition DataVector.h:842
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...