ATLAS Offline Software
SPCountHypoTool.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 #include "SPCountHypoTool.h"
6 
9 
10 using namespace TrigCompositeUtils;
11 SPCountHypoTool::SPCountHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
12  : AthCheckedComponent<AthAlgTool>(type, name, parent), m_decisionId(HLT::Identifier::fromToolName(name)) {}
13 
15  return StatusCode::SUCCESS;
16 }
17 
18 template<typename DetailType>
19 bool SPCountHypoTool::applyCut(const Gaudi::Property<DetailType> &threshold, const xAOD::TrigComposite *composit, const std::string_view name) const {
20  if (threshold == -1) {
21  return m_logicAnd; // If the logic is And, it should return true and otherwise it should return false.
22  }
23  const std::string detailName = (name != "" ? std::string(name) : threshold.name());
24 
25  ATH_MSG_DEBUG("count for = " << threshold.name() << "=" << (composit->getDetail<DetailType>(detailName) > threshold));
26  return (composit->getDetail<DetailType>(detailName) > threshold);
27 }
28 
29 template<typename DetailType>
30 bool SPCountHypoTool::applyInverseCut(const Gaudi::Property<DetailType> &threshold, const xAOD::TrigComposite *composit, const std::string_view name) const {
31  if (threshold == -1) {
32  return m_logicAnd; // If the logic is And, it should return true and otherwise it should return false.
33  }
34  const std::string detailName = (name != "" ? std::string(name) : threshold.name());
35 
36  ATH_MSG_DEBUG("count for = " << threshold.name() << "=" << (composit->getDetail<DetailType>(detailName) < threshold));
37  return (composit->getDetail<DetailType>(detailName) < threshold); // here is the difference
38 }
39 
41  if (spinfo.previousDecisionIDs.count(m_decisionId.numeric()) == 0) {
42  ATH_MSG_DEBUG("Already rejected");
43  return StatusCode::SUCCESS;
44  }
45 
46  // clang-format off
47  std::vector<bool> decisionCuts({
48  applyCut(m_pixCL, spinfo.counts),
49  applyInverseCut(m_pixCLMax, spinfo.counts, "pixCL"),
50  applyCut(m_pixCLnoToT, spinfo.counts),
51  applyCut(m_pixCL_1, spinfo.counts),
52  applyCut(m_pixCL_2, spinfo.counts),
53  applyCut(m_pixCLmin3, spinfo.counts),
54  applyCut(m_pixCLBarrel, spinfo.counts),
57  applyCut(m_sctSP, spinfo.counts),
58  applyInverseCut(m_sctSPMax, spinfo.counts, "sctSP"),
59  applyCut(m_sctSPBarrel, spinfo.counts),
62  applyCut(m_pixQ2mod, spinfo.counts)}
63  );
64  // clang-format on
65 
66  if (m_logicAnd && !std::all_of(decisionCuts.begin(), decisionCuts.end(), [](bool k) { return k; })) {
67  ATH_MSG_DEBUG("REGTEST " << name() << " rejected");
68  return StatusCode::SUCCESS;
69  } else if (m_logicAnd == false && !std::any_of(decisionCuts.begin(), decisionCuts.end(), [](bool k) { return k; })) {
70  ATH_MSG_DEBUG("REGTEST " << name() << " rejected");
71  return StatusCode::SUCCESS;
72  } else {
74  ATH_MSG_DEBUG("REGTEST " << name() << " accepted");
75  }
76 
77  return StatusCode::SUCCESS;
78 }
SPCountHypoTool::m_sctSPEndcapC
Gaudi::Property< int > m_sctSPEndcapC
Definition: SPCountHypoTool.h:48
SPCountHypoTool::m_pixCLEndcapA
Gaudi::Property< int > m_pixCLEndcapA
Definition: SPCountHypoTool.h:42
SPCountHypoTool::m_pixCLnoToT
Gaudi::Property< int > m_pixCLnoToT
Definition: SPCountHypoTool.h:37
SPCountHypoTool::m_pixCLMax
Gaudi::Property< int > m_pixCLMax
Definition: SPCountHypoTool.h:36
SPCountHypoTool::SPCountsInfo::decision
TrigCompositeUtils::Decision * decision
Definition: SPCountHypoTool.h:20
SPCountHypoTool::m_pixCL_1
Gaudi::Property< int > m_pixCL_1
Definition: SPCountHypoTool.h:38
SPCountHypoTool::m_pixQ2mod
Gaudi::Property< float > m_pixQ2mod
Definition: SPCountHypoTool.h:50
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
SPCountHypoTool::SPCountsInfo::previousDecisionIDs
const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs
Definition: SPCountHypoTool.h:22
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
SPCountHypoTool::SPCountsInfo
Definition: SPCountHypoTool.h:19
SPCountHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: SPCountHypoTool.h:33
SPCountHypoTool::m_pixCLmin3
Gaudi::Property< int > m_pixCLmin3
Definition: SPCountHypoTool.h:40
SPCountHypoTool::m_logicAnd
Gaudi::Property< bool > m_logicAnd
Definition: SPCountHypoTool.h:49
SPCountHypoTool::m_pixCLEndcapC
Gaudi::Property< int > m_pixCLEndcapC
Definition: SPCountHypoTool.h:43
SPCountHypoTool.h
SPCountHypoTool::SPCountsInfo::counts
const xAOD::TrigComposite * counts
Definition: SPCountHypoTool.h:21
SPCountHypoTool::m_sctSPMax
Gaudi::Property< int > m_sctSPMax
Definition: SPCountHypoTool.h:45
SPCountHypoTool::m_sctSP
Gaudi::Property< int > m_sctSP
Definition: SPCountHypoTool.h:44
SPCountHypoTool::m_sctSPBarrel
Gaudi::Property< int > m_sctSPBarrel
Definition: SPCountHypoTool.h:46
AthCheckedComponent
Mixin class to perform additional checks on a component.
Definition: AthCheckedComponent.h:25
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
SPCountHypoTool::SPCountHypoTool
SPCountHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SPCountHypoTool.cxx:11
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SPCountHypoTool::m_sctSPEndcapA
Gaudi::Property< int > m_sctSPEndcapA
Definition: SPCountHypoTool.h:47
SPCountHypoTool::m_pixCL
Gaudi::Property< int > m_pixCL
Definition: SPCountHypoTool.h:35
threshold
Definition: chainparser.cxx:74
SPCountHypoTool::applyInverseCut
bool applyInverseCut(const Gaudi::Property< DetailType > &threshold, const xAOD::TrigComposite *composit, const std::string_view name="") const
Definition: SPCountHypoTool.cxx:30
SPCountHypoTool::initialize
virtual StatusCode initialize() override
Definition: SPCountHypoTool.cxx:14
SPCountHypoTool::m_pixCL_2
Gaudi::Property< int > m_pixCL_2
Definition: SPCountHypoTool.h:39
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SPCountHypoTool::decide
StatusCode decide(SPCountsInfo &decisions) const
Definition: SPCountHypoTool.cxx:40
HLTIdentifier.h
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
SPCountHypoTool::applyCut
bool applyCut(const Gaudi::Property< DetailType > &threshold, const xAOD::TrigComposite *composit, const std::string_view name="") const
Definition: SPCountHypoTool.cxx:19
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::TrigComposite_v1::getDetail
bool getDetail(const std::string &name, TYPE &value) const
Get an TYPE detail from the object.
SPCountHypoTool::m_pixCLBarrel
Gaudi::Property< int > m_pixCLBarrel
Definition: SPCountHypoTool.h:41
fitman.k
k
Definition: fitman.py:528
Identifier
Definition: IdentifierFieldParser.cxx:14