ATLAS Offline Software
AsgEventScaleFactorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 //
9 // includes
10 //
11 
13 
14 //
15 // method implementations
16 //
17 
18 namespace CP
19 {
21  AsgEventScaleFactorAlg (const std::string& name,
22  ISvcLocator* pSvcLocator)
23  : AnaAlgorithm (name, pSvcLocator)
24  {}
25 
26 
27 
29  initialize ()
30  {
32  {
33  ANA_MSG_ERROR ("no scale factor decoration name set");
34  return StatusCode::FAILURE;
35  }
36 
43 
44  return StatusCode::SUCCESS;
45  }
46 
47 
48 
50  execute ()
51  {
52  for (const auto& sys : m_systematicsList.systematicsVector())
53  {
54  const xAOD::EventInfo *eventInfo = nullptr;
55  ANA_CHECK (m_eventInfoHandle.retrieve (eventInfo, sys));
56 
57  const xAOD::IParticleContainer *particles = nullptr;
59 
60  float scaleFactor = 1;
61  for (const xAOD::IParticle *particle : *particles)
62  {
64  {
65  scaleFactor *= m_scaleFactorInputDecoration.get (*particle, sys);
66  }
67  }
68 
69  m_scaleFactorOutputDecoration.set (*eventInfo, scaleFactor, sys);
70  }
71 
72  return StatusCode::SUCCESS;
73  }
74 }
CP::SysWriteDecorHandle::set
void set(const SG::AuxElement &object, const T &value, const CP::SystematicSet &sys) const
set the object decoration for the given systematic
CP::AsgEventScaleFactorAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: AsgEventScaleFactorAlg.h:41
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
CP::AsgEventScaleFactorAlg::m_eventInfoHandle
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info we run on (empty by default)
Definition: AsgEventScaleFactorAlg.h:45
CP::AsgEventScaleFactorAlg::execute
StatusCode execute() override
Definition: AsgEventScaleFactorAlg.cxx:50
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysListHandle::systematicsVector
const std::vector< CP::SystematicSet > & systematicsVector() const
the list of systematics to loop over
Definition: SysListHandle.cxx:96
CP::AsgEventScaleFactorAlg::m_particleHandle
SysReadHandle< xAOD::IParticleContainer > m_particleHandle
the jet collection we run on
Definition: AsgEventScaleFactorAlg.h:50
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
CP::SysReadDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
CP::SysListHandle::initialize
::StatusCode initialize()
intialize this property
Definition: SysListHandle.cxx:69
CP::SysReadSelectionHandle::getBool
bool getBool(const SG::AuxElement &element, const CP::SystematicSet &sys) const
get the selection as a bool
CP::SysReadDecorHandle::get
const T & get(const SG::AuxElement &object, const CP::SystematicSet &sys) const
retrieve the object decoration for the given systematic
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::SysWriteDecorHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize this handle
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CP::AsgEventScaleFactorAlg::m_scaleFactorOutputDecoration
SysWriteDecorHandle< float > m_scaleFactorOutputDecoration
the decoration for writing the scale factor
Definition: AsgEventScaleFactorAlg.h:65
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CP::AsgEventScaleFactorAlg::m_scaleFactorInputDecoration
SysReadDecorHandle< float > m_scaleFactorInputDecoration
the decoration for reading the scale factor
Definition: AsgEventScaleFactorAlg.h:60
CP::SysWriteDecorHandle::empty
virtual bool empty() const noexcept override
whether we have a name configured
CP::SysReadDecorHandle::empty
virtual bool empty() const noexcept override
whether we have a name configured
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
CP::AsgEventScaleFactorAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition: AsgEventScaleFactorAlg.h:55
AsgEventScaleFactorAlg.h
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CP::AsgEventScaleFactorAlg::AsgEventScaleFactorAlg
AsgEventScaleFactorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: AsgEventScaleFactorAlg.cxx:21
CP::AsgEventScaleFactorAlg::initialize
StatusCode initialize() override
Definition: AsgEventScaleFactorAlg.cxx:29