ATLAS Offline Software
TrigThresholdDecisionTool.h
Go to the documentation of this file.
1 // This file is really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef TRIGT1MUCTPIPHASE1_TRIGTHRESHOLDECISIONTOOL_H
8 #define TRIGT1MUCTPIPHASE1_TRIGTHRESHOLDECISIONTOOL_H
9 
10 /*
11  Tool to help perform decision about trigger threshold given ROI data
12 */
13 
16 #include "TrigConfData/L1Menu.h"
18 
21 
23 #include "xAODTrigger/MuonRoI.h"
25 
26 #include <map>
27 #include <vector>
28 #include <string>
29 #include <memory>
30 #include <utility>
31 
32 namespace LVL1 {
33 
34  namespace MURoIThresholdsToolParams {
35  extern const char ContainerName[];
36  extern const char ThresholdType[];
38  }
39 
40  class TrigThresholdDecisionTool : public extends<MURoIThresholdsToolParams::BaseClass, ITrigThresholdDecisionTool>
41  {
42  public:
43 
44  TrigThresholdDecisionTool(const std::string& type,
45  const std::string& name,
46  const IInterface* parent);
47 
48  virtual StatusCode initialize() override;
49  virtual StatusCode start() override;
50 
51  virtual uint64_t getPattern(const EventContext& ctx,
52  const xAOD::MuonRoI& roi,
53  const ThrVec& menuThresholds,
54  const TrigConf::L1ThrExtraInfoBase& menuExtraInfo) const override;
55 
56  virtual uint64_t getPattern(uint32_t dataWord,
57  const ThrVec& menuThresholds,
58  const TrigConf::L1ThrExtraInfoBase& menuExtraInfo) const;
59 
60  virtual
61  std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool> >
63  const EventContext& eventContext) const override;
64  virtual
65  std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool> >
67  const ThrVec& menuThresholds,
68  const TrigConf::L1ThrExtraInfoBase& menuExtraInfo) const override;
69 
70  virtual
71  std::pair<std::string, double> getMinThresholdNameAndValue(const std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>, bool> >& decisions,
72  const double& eta = 0) const override;
73 
74  protected:
75  //Function that performs the actual initialization of the tool.
77 
79  {
80  TGCFlagDecision(const bool& F, const bool& C, const bool& H) {word = F + 2*C + 4*H;pass=false;}
81 
82  //implement < operator so we can store this type in a set
83  bool operator<(const TGCFlagDecision& rhs) const {return word < rhs.word;}
84 
85  unsigned word;
86  bool pass;
87  };
89  {
90  RPCFlagDecision(const bool& M) {word = M;pass=false;}
91 
92  //implement < operator so we can store this type in a set
93  bool operator<(const RPCFlagDecision& rhs) const {return word < rhs.word;}
94 
95  unsigned word;
96  bool pass;
97  };
98 
99  bool isExcludedRPCROI(const TrigConf::L1ThrExtraInfo_MU& menuExtraInfo,
100  const std::string& rpcExclROIList,
101  unsigned roi,
102  unsigned sectorID,
103  bool isSideC) const;
104 
105  bool getTGCDecision(const std::string& tgcFlags, bool F, bool C, bool H) const;
106  void makeTGCDecision(const std::string& tgcFlags, bool F, bool C, bool H) const;
107 
108  bool getRPCDecision(const std::string& rpcFlags, bool M) const;
109  void makeRPCDecision(const std::string& rpcFlags, bool M) const;
110 
111  void parseFlags(const std::string& flags) const;
112  std::vector<std::string> parseString(const std::string& str, const std::string& sep) const;
113  std::string getShapedFlags(const std::string& flags) const;
114 
115  ToolHandle<LVL1::ITrigT1MuonRecRoiTool> m_rpcTool{this, "RPCRecRoiTool", "LVL1::TrigT1RPCRecRoiTool/LVL1__TrigT1RPCRecRoiTool", "Tool to get the eta/phi coordinates in the RPC"};
116  ToolHandle<LVL1::ITrigT1MuonRecRoiTool> m_tgcTool{this, "TGCRecRoiTool", "LVL1::TrigT1TGCRecRoiTool/LVL1__TrigT1TGCRecRoiTool", "Tool to get the eta/phi coordinates in the TGC"};
117 
118  //buffered parsed TGC/RPC flags
119  mutable std::map<std::string, std::vector<std::vector<std::string> > > m_parsed_flags ATLAS_THREAD_SAFE{};
120 
121  //buffered set of decisions for words that have been checked for each TGC/RPC flag
122  mutable std::map<std::string, std::set<TGCFlagDecision> > m_tgcFlag_decisions ATLAS_THREAD_SAFE{};
123  mutable std::map<std::string, std::set<RPCFlagDecision> > m_rpcFlag_decisions ATLAS_THREAD_SAFE{};
124 
125  //configuration that toddle the L1menu loading sfrom xAOD as metadata or from det store
126  ServiceHandle<TrigConf::ITrigConfigSvc> m_configSvc{this, "TrigConfigSvc", "TrigConf::xAODConfigSvc"};
127  Gaudi::Property<bool> m_MenuFromxAOD {this, "MenuFromxAOD", false, "Flag to enable loading the L1 menu from xAOD as metadata instead of the detector store"};
128  mutable std::atomic<bool> m_isInitialized ATLAS_THREAD_SAFE{false};
129  mutable std::mutex m_mutex ATLAS_THREAD_SAFE{};
130  };
131 
132 }
133 
134 
135 #endif
LVL1::TrigThresholdDecisionTool::makeTGCDecision
void makeTGCDecision(const std::string &tgcFlags, bool F, bool C, bool H) const
Definition: TrigThresholdDecisionTool.cxx:330
LVL1::TrigThresholdDecisionTool::makeRPCDecision
void makeRPCDecision(const std::string &rpcFlags, bool M) const
Definition: TrigThresholdDecisionTool.cxx:377
LVL1::TrigThresholdDecisionTool::RPCFlagDecision::RPCFlagDecision
RPCFlagDecision(const bool &M)
Definition: TrigThresholdDecisionTool.h:90
TrigConf::L1ThrExtraInfo_MU
Definition: L1ThrExtraInfo.h:657
LVL1::TrigThresholdDecisionTool::getThresholdDecisions
virtual std::vector< std::pair< std::shared_ptr< TrigConf::L1Threshold >, bool > > getThresholdDecisions(uint32_t dataWord, const EventContext &eventContext) const override
Definition: TrigThresholdDecisionTool.cxx:208
LVL1::TrigThresholdDecisionTool::RPCFlagDecision
Definition: TrigThresholdDecisionTool.h:89
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
MuonRoIContainer.h
ITrigConfigSvc.h
LVL1::MURoIThresholdsToolParams::ThresholdType
const char ThresholdType[]
Definition: TrigThresholdDecisionTool.cxx:12
LVL1::MURoIThresholdsToolParams::ContainerName
const char ContainerName[]
Definition: TrigThresholdDecisionTool.cxx:11
LVL1::TrigThresholdDecisionTool::getMinThresholdNameAndValue
virtual std::pair< std::string, double > getMinThresholdNameAndValue(const std::vector< std::pair< std::shared_ptr< TrigConf::L1Threshold >, bool > > &decisions, const double &eta=0) const override
Definition: TrigThresholdDecisionTool.cxx:254
LVL1::TrigThresholdDecisionTool::initialize
virtual StatusCode initialize() override
Definition: TrigThresholdDecisionTool.cxx:20
ITrigThresholdDecisionTool.h
LVL1::TrigThresholdDecisionTool::parseString
std::vector< std::string > parseString(const std::string &str, const std::string &sep) const
Definition: TrigThresholdDecisionTool.cxx:426
LVL1::TrigThresholdDecisionTool::parseFlags
void parseFlags(const std::string &flags) const
Definition: TrigThresholdDecisionTool.cxx:410
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
TrigConf::L1ThrExtraInfoBase
L1 extra information for certain threshold types.
Definition: L1ThresholdBase.h:72
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
L1Threshold.h
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
LVL1::TrigThresholdDecisionTool::TGCFlagDecision::operator<
bool operator<(const TGCFlagDecision &rhs) const
Definition: TrigThresholdDecisionTool.h:83
H
#define H(x, y, z)
Definition: MD5.cxx:114
LVL1::TrigThresholdDecisionTool::RPCFlagDecision::pass
bool pass
Definition: TrigThresholdDecisionTool.h:96
LVL1::TrigThresholdDecisionTool::m_rpcTool
ToolHandle< LVL1::ITrigT1MuonRecRoiTool > m_rpcTool
Definition: TrigThresholdDecisionTool.h:115
LVL1::TrigThresholdDecisionTool::TGCFlagDecision::TGCFlagDecision
TGCFlagDecision(const bool &F, const bool &C, const bool &H)
Definition: TrigThresholdDecisionTool.h:80
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::MuonRoI_v1
Class describing a LVL1 muon region of interest.
Definition: MuonRoI_v1.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
LVL1::TrigThresholdDecisionTool::getRPCDecision
bool getRPCDecision(const std::string &rpcFlags, bool M) const
Definition: TrigThresholdDecisionTool.cxx:365
ITrigT1MuonRecRoiTool.h
LVL1::TrigThresholdDecisionTool::TGCFlagDecision
Definition: TrigThresholdDecisionTool.h:79
LVL1::TrigThresholdDecisionTool::getShapedFlags
std::string getShapedFlags(const std::string &flags) const
Definition: TrigThresholdDecisionTool.cxx:452
LVL1::TrigThresholdDecisionTool::start
virtual StatusCode start() override
Definition: TrigThresholdDecisionTool.cxx:36
LVL1::TrigThresholdDecisionTool
Definition: TrigThresholdDecisionTool.h:41
LVL1::TrigThresholdDecisionTool::isExcludedRPCROI
bool isExcludedRPCROI(const TrigConf::L1ThrExtraInfo_MU &menuExtraInfo, const std::string &rpcExclROIList, unsigned roi, unsigned sectorID, bool isSideC) const
Definition: TrigThresholdDecisionTool.cxx:285
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
LVL1::TrigThresholdDecisionTool::m_tgcTool
ToolHandle< LVL1::ITrigT1MuonRecRoiTool > m_tgcTool
Definition: TrigThresholdDecisionTool.h:116
TrigConf::name
Definition: HLTChainList.h:35
LVL1::TrigThresholdDecisionTool::m_MenuFromxAOD
Gaudi::Property< bool > m_MenuFromxAOD
Definition: TrigThresholdDecisionTool.h:127
grepfile.sep
sep
Definition: grepfile.py:38
RoIThresholdsTool
Definition: IRoIThresholdsTool.h:22
IRoIThresholdsTool.h
LVL1::TrigThresholdDecisionTool::getPattern
virtual uint64_t getPattern(const EventContext &ctx, const xAOD::MuonRoI &roi, const ThrVec &menuThresholds, const TrigConf::L1ThrExtraInfoBase &menuExtraInfo) const override
Definition: TrigThresholdDecisionTool.cxx:96
LVL1::TrigThresholdDecisionTool::RPCFlagDecision::word
unsigned word
Definition: TrigThresholdDecisionTool.h:95
LVL1::TrigThresholdDecisionTool::TGCFlagDecision::word
unsigned word
Definition: TrigThresholdDecisionTool.h:85
LVL1::TrigThresholdDecisionTool::getTGCDecision
bool getTGCDecision(const std::string &tgcFlags, bool F, bool C, bool H) const
Definition: TrigThresholdDecisionTool.cxx:318
LVL1::TrigThresholdDecisionTool::RPCFlagDecision::operator<
bool operator<(const RPCFlagDecision &rhs) const
Definition: TrigThresholdDecisionTool.h:93
MuonRoI.h
F
#define F(x, y, z)
Definition: MD5.cxx:112
str
Definition: BTagTrackIpAccessor.cxx:11
LVL1::TrigThresholdDecisionTool::TGCFlagDecision::pass
bool pass
Definition: TrigThresholdDecisionTool.h:86
LVL1::TrigThresholdDecisionTool::TrigThresholdDecisionTool
TrigThresholdDecisionTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrigThresholdDecisionTool.cxx:15
L1Menu.h
LVL1::TrigThresholdDecisionTool::m_configSvc
ServiceHandle< TrigConf::ITrigConfigSvc > m_configSvc
Definition: TrigThresholdDecisionTool.h:126
LVL1::TrigThresholdDecisionTool::configureToolFromMenu
StatusCode configureToolFromMenu(const TrigConf::L1Menu &l1Menu) const
Definition: TrigThresholdDecisionTool.cxx:52
LVL1::TrigThresholdDecisionTool::ATLAS_THREAD_SAFE
std::map< std::string, std::vector< std::vector< std::string > > > m_parsed_flags ATLAS_THREAD_SAFE
Definition: TrigThresholdDecisionTool.h:119
L1ThrExtraInfo.h
ServiceHandle< TrigConf::ITrigConfigSvc >