ATLAS Offline Software
electronRescaler.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #include "electronRescaler.h"
6 
7 #include "StoreGate/ReadHandle.h"
9 
10 #include "xAODEgamma/Electron.h"
13 
15  ISvcLocator* pSvcLocator)
16  : AthReentrantAlgorithm(name, pSvcLocator)
17 {}
18 
21 {
22  // the data handle keys
25  return StatusCode::SUCCESS;
26 }
27 
30 {
31  return StatusCode::SUCCESS;
32 }
33 
35 electronRescaler::execute(const EventContext& ctx) const {
38  ATH_CHECK(outputContainer.record(std::make_unique<xAOD::ElectronContainer>(),
39  std::make_unique<xAOD::ElectronAuxContainer>()));
40 
41  xAOD::ElectronContainer* electrons = outputContainer.ptr();
42  electrons->reserve(inputContainer->size());
43  for (const xAOD::Electron* old_el : *inputContainer) {
44  xAOD::Electron* electron = electrons->push_back(std::make_unique<xAOD::Electron>());
45  *electron=*old_el;
46  electron->setPt(old_el->pt()*m_scaleValue);
47  }
48 
49  return StatusCode::SUCCESS;
50 }
electronRescaler::finalize
StatusCode finalize() override final
Definition: electronRescaler.cxx:29
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
WriteHandle.h
Handle class for recording to StoreGate.
ElectronContainer.h
ElectronAuxContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
electronRescaler.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
electronRescaler::m_scaleValue
Gaudi::Property< float > m_scaleValue
Definition: electronRescaler.h:45
electronRescaler::electronRescaler
electronRescaler(const std::string &name, ISvcLocator *pSvcLocator)
Definition: electronRescaler.cxx:14
electronRescaler::initialize
StatusCode initialize() override final
Definition: electronRescaler.cxx:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::Electron_v1
Definition: Electron_v1.h:34
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
electronRescaler::m_electronInputKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronInputKey
Name of the photon output collection.
Definition: electronRescaler.h:41
Electron.h
electronRescaler::execute
StatusCode execute(const EventContext &ctx) const override final
Definition: electronRescaler.cxx:35
ReadHandle.h
Handle class for reading from StoreGate.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
electronRescaler::m_electronOutputKey
SG::WriteHandleKey< xAOD::ElectronContainer > m_electronOutputKey
Name of the electron output collection.
Definition: electronRescaler.h:36