18#include "CLHEP/Vector/LorentzVector.h"
40 return StatusCode::SUCCESS;
48 return StatusCode::SUCCESS;
55 return(StatusCode::FAILURE);
57 ATH_MSG_DEBUG(
"EventInfo before adding the weight: " << evt->eventNumber()
58 <<
" run: " << evt->runNumber()
59 <<
" hasBeamSpotWeight: "<< evt->hasBeamSpotWeight()
60 <<
" beamSpotWeight: "<< evt->beamSpotWeight() );
65 if(!h_inputMcEventCollection.
isValid()) {
66 ATH_MSG_FATAL(
"No input McEventCollection called " << h_inputMcEventCollection.
name() <<
" in StoreGate.");
67 return StatusCode::FAILURE;
71 for (
const auto currentGenEvent : *h_inputMcEventCollection) {
73 if ( !currentGenEvent ) {
75 ATH_MSG_WARNING(
"No first event found in the McEventCollection input collection, use default weight="<<weight);
83 float z=signalVertex->position().z();
85 float beamz=beamSpotHandle->beamPos().z();
86 float newsigmaz=beamSpotHandle->beamSigma(2);
88 float pullnew=(
z-beamz)/newsigmaz;
92 if(std::abs(pullold)<10 && std::abs(pullnew)<10) {
98 ATH_MSG_WARNING(
"Large pull of beamspot: Beamspot z="<<beamz<<
", z="<<
z<<
"; old sigma_z="<<
m_input_beam_sigma_z<<
", old pull="<<pullold<<
"; new sigma_z="<<newsigmaz<<
", new pull="<<pullnew<<
" => use default weight="<<weight);
101 ATH_MSG_WARNING(
"No signal vertex found, use default weight="<<weight);
111 return StatusCode::FAILURE;
114 BeamSpotWeight(0) = weight;
119 if (!evt.isValid()) {
121 return(StatusCode::FAILURE);
123 ATH_MSG_DEBUG(
"EventInfo after adding the weight: " << evt->eventNumber()
124 <<
" run: " << evt->runNumber()
125 <<
" hasBeamSpotWeight: "<< evt->hasBeamSpotWeight()
126 <<
" beamSpotWeight: "<< evt->beamSpotWeight() );
129 return StatusCode::SUCCESS;
137 if (!ge.vertices().empty()) {
138 ATH_MSG_DEBUG(
"No signal_process_vertex found - using the first GenVertex in the event.");
139 auto signalVertex = ge.vertices().front();
143 if (!ge.vertices().empty()) {
144 ATH_MSG_ERROR(
"Failed to set signal_process_vertex for GenEvent!!");
156 if( !ge.signal_process_vertex() ) {
157 if (!ge.vertices_empty()) {
158 ATH_MSG_DEBUG(
"No signal_process_vertex found - using the first GenVertex in the event.");
159 HepMC::GenVertex *signalVertex = *(ge.vertices_begin());
162 if( !ge.signal_process_vertex() ) {
163 if (!ge.vertices_empty()) {
164 ATH_MSG_ERROR(
"Failed to set signal_process_vertex for GenEvent!!");
173 return ge.signal_process_vertex();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const std::string & name() const
Return the StoreGate ID for the referenced object.
Handle class for adding a decoration to an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
bool isPresent() const
Is the referenced container present in SG?
SG::ReadHandleKey< McEventCollection > m_inputMcEventCollection
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
virtual StatusCode execute(const EventContext &ctx) const override final
Athena algorithm's interface method execute()
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
virtual StatusCode initialize() override final
Athena algorithm's interface method initialize()
Gaudi::Property< float > m_input_beam_sigma_z
HepMC::ConstGenVertexPtr GetSignalProcessVertex(const HepMC::GenEvent &ge) const
Ensure that the GenEvent::signal_process_vertex has been set.
BeamSpotReweightingAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteDecorHandleKey< xAOD::EventInfo > m_beamSpotWeight
GenVertex * signal_process_vertex(const GenEvent *e)
const HepMC::GenVertex * ConstGenVertexPtr