ATLAS Offline Software
FillFilterValues.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef XAOD_ANALYSIS
6 
9 #include "EventInfo/EventInfo.h"
10 #include "EventInfo/EventType.h"
11 
12 FillFilterValues::FillFilterValues(const std::string& name, ISvcLocator* svcLoc)
13  : GenBase(name, svcLoc)
14 {
15 }
16 
18 {
22  return StatusCode::SUCCESS;
23 }
24 
26 #ifdef HEPMC3
27  // Check that the collection isn't empty
28  const size_t nEvents = events_const()->size();
29  if (nEvents == 0) {
30  ATH_MSG_WARNING("McEventCollection is empty");
31  return StatusCode::SUCCESS;
32  }
33  // Get the event info/type object to be filled
34  const EventInfo* pInputEvt(nullptr);
35  CHECK(evtStore()->retrieve(pInputEvt));
36  assert(pInputEvt);
37 
38  // write filter values into xAOD::EventInfo
39 
41  if (event_const()->attribute<HepMC3::DoubleAttribute>("filterHT") != NULL){
42  std::shared_ptr<HepMC3::DoubleAttribute> fHT = event_const()->attribute<HepMC3::DoubleAttribute>("filterHT");
43  double fHT_double = fHT->value();
44  dec_filtHT(0) = fHT_double;
45  }
46 
48  if (event_const()->attribute<HepMC3::DoubleAttribute>("filterMET") != NULL){
49  std::shared_ptr<HepMC3::DoubleAttribute> fMET = event_const()->attribute<HepMC3::DoubleAttribute>("filterMET");
50  double fMET_double = fMET->value();
51  dec_filtMET(0) = fMET_double;
52  }
53 
54  // Post-hoc debug printouts
55  ATH_MSG_DEBUG("Copied HepMC filter values to EventInfo");
56 
57 #endif
58  return StatusCode::SUCCESS;
59 }
60 
61 #endif
62 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
GenBase::events_const
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition: GenBase.h:96
EventType.h
This class provides general information about an event. It extends EventInfo with a list of sub-evts ...
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
FillFilterValues::m_mcFilterMETKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_mcFilterMETKey
Definition: FillFilterValues.h:40
FillFilterValues.h
GenBase
Base class for common behaviour of MC truth algorithms.
Definition: GenBase.h:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:99
FillFilterValues::m_mcFilterHTKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_mcFilterHTKey
Definition: FillFilterValues.h:35
WriteDecorHandle.h
Handle class for adding a decoration to an object.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
nEvents
int nEvents
Definition: fbtTestBasics.cxx:77
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
FillFilterValues::initialize
virtual StatusCode initialize() override
Copy the filter values for each event.
Definition: FillFilterValues.cxx:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
FillFilterValues::FillFilterValues
FillFilterValues(const std::string &name, ISvcLocator *svcLoc)
Constructor.
Definition: FillFilterValues.cxx:12
FillFilterValues::execute
virtual StatusCode execute() override
Definition: FillFilterValues.cxx:25
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
GenBase::initialize
virtual StatusCode initialize() override
Definition: GenBase.cxx:17
GenBase::event_const
const HepMC::GenEvent * event_const() const
Access the current signal event (const)
Definition: GenBase.h:83