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;
73 for (
const auto currentGenEvent : *h_inputMcEventCollection) {
75 if ( !currentGenEvent ) {
77 ATH_MSG_WARNING(
"No first event found in the McEventCollection input collection, use default weight="<<weight);
85 float z=signalVertex->position().z();
87 float beamz=beamSpotHandle->beamPos().z();
88 float newsigmaz=beamSpotHandle->beamSigma(2);
90 float pullnew=(
z-beamz)/newsigmaz;
94 if(std::abs(pullold)<10 && std::abs(pullnew)<10) {
100 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);
103 ATH_MSG_WARNING(
"No signal vertex found, use default weight="<<weight);
113 return StatusCode::FAILURE;
116 BeamSpotWeight(0) = weight;
121 if (!evt.isValid()) {
123 return(StatusCode::FAILURE);
125 ATH_MSG_DEBUG(
"EventInfo after adding the weight: " << evt->eventNumber()
126 <<
" run: " << evt->runNumber()
127 <<
" hasBeamSpotWeight: "<< evt->hasBeamSpotWeight()
128 <<
" beamSpotWeight: "<< evt->beamSpotWeight() );
131 return StatusCode::SUCCESS;
139 if (!ge.vertices().empty()) {
140 ATH_MSG_DEBUG(
"No signal_process_vertex found - using the first GenVertex in the event.");
141 auto signalVertex = ge.vertices().front();
145 if (!ge.vertices().empty()) {
146 ATH_MSG_ERROR(
"Failed to set signal_process_vertex for GenEvent!!");
158 if( !ge.signal_process_vertex() ) {
159 if (!ge.vertices_empty()) {
160 ATH_MSG_DEBUG(
"No signal_process_vertex found - using the first GenVertex in the event.");
161 HepMC::GenVertex *signalVertex = *(ge.vertices_begin());
164 if( !ge.signal_process_vertex() ) {
165 if (!ge.vertices_empty()) {
166 ATH_MSG_ERROR(
"Failed to set signal_process_vertex for GenEvent!!");
175 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