ATLAS Offline Software
Loading...
Searching...
No Matches
NObjectPtSelectorAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9namespace CP {
10
11 NObjectPtSelectorAlg::NObjectPtSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
12 : EL::AnaAlgorithm(name, pSvcLocator)
13 {}
14
28
30 // accessors
31 static const SG::ConstAccessor<float> acc_pt_dressed("pt_dressed");
32
33 for (const auto &sys : m_systematicsList.systematicsVector()) {
34 // retrieve the EventInfo
35 const xAOD::EventInfo *evtInfo = nullptr;
36 ANA_CHECK(m_eventInfoHandle.retrieve(evtInfo, sys));
37
38 // default-decorate EventInfo
39 m_decoration.setBool(*evtInfo, 0, sys);
40
41 // check the preselection
42 if (m_preselection && !m_preselection.getBool(*evtInfo, sys))
43 continue;
44
45 // retrieve the object container
46 const xAOD::IParticleContainer *objects = nullptr;
47 ANA_CHECK(m_objectsHandle.retrieve(objects, sys));
48
49 // apply and calculate the decision
50 int count = 0;
51 for (const xAOD::IParticle *obj : *objects){
52 if (!m_objectSelection || m_objectSelection.getBool(*obj, sys)){
54 if (acc_pt_dressed(*obj) >= m_ptmin) count++;
55 } else {
56 if (obj->pt() >= m_ptmin) count++;
57 }
58 }
59 }
60
61 bool decision = SignEnum::checkValue(m_count.value(), m_signEnum, count);
62 m_decoration.setBool(*evtInfo, decision, sys);
63 }
64 return StatusCode::SUCCESS;
65 }
66} // namespace CP
#define ANA_CHECK(EXP)
check whether the given expression was successful
Gaudi::Property< bool > m_useDressedProperties
use dressed kinematics
CP::SysReadSelectionHandle m_objectSelection
the object selection handle
CP::SysReadHandle< xAOD::IParticleContainer > m_objectsHandle
the object input handle
Gaudi::Property< std::string > m_sign
the sign against which to compare pT (GT, LT, etc)
virtual StatusCode initialize() override
virtual StatusCode execute() override
CP::SysReadSelectionHandle m_preselection
the preselection
Gaudi::Property< float > m_ptmin
the pT threshold on which to select
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
NObjectPtSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Gaudi::Property< int > m_count
the count of events desired
CP::SysListHandle m_systematicsList
the systematics list
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
Helper class to provide constant type-safe access to aux data.
Class providing the definition of the 4-vector interface.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
bool checkValue(T reference, ComparisonOperator sign, T test)
the comparison test given the specified sign and two test values
Definition SignEnums.h:37
static const std::map< std::string, ComparisonOperator > stringToOperator
the map between user inputs and comparison operators
Definition SignEnums.h:27
EventInfo_v1 EventInfo
Definition of the latest event info version.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.