ATLAS Offline Software
RunNumberSelectorAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
8 
9 namespace CP {
10 
16 
17  m_signEnum = SignEnum::stringToOperator.at( m_sign );
18 
19  return StatusCode::SUCCESS;
20  }
21 
23 
24  static const SG::AuxElement::Accessor<unsigned int> acc_random("RandomRunNumber");
25 
26  for (const auto &sys : m_systematicsList.systematicsVector()) {
27  // retrieve the EventInfo
28  const xAOD::EventInfo *evtInfo = nullptr;
29  ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
30 
31  // default-decorate EventInfo
32  m_decoration.setBool(*evtInfo, 0, sys);
33 
34  // check the preselection
35  if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
36  continue;
37 
38  // retrieve the runNumber
39  unsigned int runNumber = 0;
40  if (m_useRandomRunNumber) runNumber = acc_random(*evtInfo);
41  else runNumber = evtInfo->runNumber();
42 
43  // calculate decision
44  bool decision = SignEnum::checkValue(m_runNumberRef.value(), m_signEnum, runNumber);
45  m_decoration.setBool(*evtInfo, decision, sys);
46  }
47  return StatusCode::SUCCESS;
48  }
49 } // namespace CP
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
CP::RunNumberSelectorAlg::m_eventInfoHandle
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Definition: RunNumberSelectorAlg.h:54
CP::RunNumberSelectorAlg::execute
virtual StatusCode execute() override
Definition: RunNumberSelectorAlg.cxx:22
CP::RunNumberSelectorAlg::m_useRandomRunNumber
Gaudi::Property< bool > m_useRandomRunNumber
whether to use a random run number
Definition: RunNumberSelectorAlg.h:42
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
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:49
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
CP::SysWriteSelectionHandle::setBool
void setBool(const SG::AuxElement &element, bool selection, const CP::SystematicSet &sys) const
set the selection decoration
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
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::RunNumberSelectorAlg::m_signEnum
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
Definition: RunNumberSelectorAlg.h:48
CP::RunNumberSelectorAlg::m_preselection
CP::SysReadSelectionHandle m_preselection
the preselection
Definition: RunNumberSelectorAlg.h:59
CP::RunNumberSelectorAlg::m_runNumberRef
Gaudi::Property< unsigned int > m_runNumberRef
the run number against which to compare
Definition: RunNumberSelectorAlg.h:39
SignEnum::checkValue
bool checkValue(T reference, ComparisonOperator sign, T test)
the comparison test given the specified sign and two test values
Definition: SignEnums.h:35
RunNumberSelectorAlg.h
CP::RunNumberSelectorAlg::initialize
virtual StatusCode initialize() override
Definition: RunNumberSelectorAlg.cxx:11
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
CP::SysReadSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysReadSelectionHandle.cxx:34
CP::RunNumberSelectorAlg::m_systematicsList
CP::SysListHandle m_systematicsList
the systematics
Definition: RunNumberSelectorAlg.h:51
CP::RunNumberSelectorAlg::m_decoration
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
Definition: RunNumberSelectorAlg.h:64
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CP::SysWriteSelectionHandle::initialize
StatusCode initialize(SysListHandle &sysListHandle, const ISysHandleBase &objectHandle)
initialize the accessor
Definition: SysWriteSelectionHandle.cxx:34
CP::RunNumberSelectorAlg::m_sign
Gaudi::Property< std::string > m_sign
the comparison (GT, LT, etc)
Definition: RunNumberSelectorAlg.h:45