ATLAS Offline Software
MuonChainFilterAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "MuonChainFilterAlg.h"
9 
10 
11 MuonChainFilterAlg::MuonChainFilterAlg(const std::string& name, ISvcLocator* pSvcLocator)
12  : ::AthReentrantAlgorithm(name, pSvcLocator) {}
13 
14 
16 
17  ATH_CHECK( m_inputDecisionKeys.initialize() );
18  ATH_CHECK( m_muCombKey.initialize(m_writeL2muComb) );
19  ATH_CHECK( m_muFastKey.initialize(m_writeL2muFast) );
20 
21  // convert chain names into hashes
22  if (!m_filterChains.empty()) {
23  for (size_t i = 0; i < m_filterChains.size(); ++i) {
24  const auto id = HLT::Identifier(m_filterChains[i]);
25  m_filterChainIDs.insert(id.numeric());
26  ATH_MSG_DEBUG( i << " filter chain >> " << m_filterChains[i] );
27  }
28  }
29  return StatusCode::SUCCESS;
30 }
31 
32 
33 StatusCode MuonChainFilterAlg::execute(const EventContext& ctx) const {
34 
35  // check if there is anything in the filter list
36  if (m_filterChains.empty()) {
37  ATH_MSG_DEBUG( "Nothing to filter, pass = " << (m_notGate ? "false" : "true") );
38 
39  if (m_notGate) {
41  }
43  return StatusCode::SUCCESS;
44  }
45 
46  // get input decisions (from output of input maker)
47  for (auto inputKey : m_inputDecisionKeys) {
48  auto inputDecisions = SG::makeHandle(inputKey, ctx);
49  ATH_CHECK( inputDecisions.isValid() );
50  ATH_MSG_DEBUG( "Checking inputHandle " << inputDecisions.key() << " with size: " << inputDecisions->size() );
51  for (const TrigCompositeUtils::Decision* dec : *inputDecisions) {
54  for (const auto& legID : decIDs) {
55  // in case of asymmetric trigger we should use HLT identifier which corresponds to a whole chain,
56  // i.e. use HLT_mu6_mu4_bJpsimumu_L1MU6_2MU4 instead of leg001_HLT_mu6_mu4_bJpsimumu_L1MU6_2MU4;
57  // TrigCompositeUtils::getIDFromLeg() will return unchanged id for the symmetric trigger
59  std::string chainName = HLT::Identifier(id).name();
60  const auto itr = m_filterChainIDs.find(id.numeric());
61  if (!m_notGate) { // pass if id does NOT match to any trigger from the filter list
62  if (itr != m_filterChainIDs.end()) {
63  ATH_MSG_DEBUG( "chain " << chainName << " is on the filter list, keep looking" );
64  }
65  else {
66  ATH_MSG_DEBUG( "chain " << chainName << " is not on the filter list, passing" );
67  setFilterPassed(true, ctx);
68  return StatusCode::SUCCESS;
69  }
70  }
71  else { // pass if id is found in the filter list
72  if (itr != m_filterChainIDs.end()) {
73  ATH_MSG_DEBUG( "chain " << chainName << " is on the not-filter list, passing" );
74  setFilterPassed(true, ctx);
75  return StatusCode::SUCCESS;
76  }
77  else {
78  ATH_MSG_DEBUG( "chain " << chainName << " is not on the not-filter list, keep looking" );
79  }
80  }
81  }
82  }
83  }
84 
85  // if we've reached this point, the only active chains were on the filter list, so the filter will fail
86  ATH_MSG_DEBUG( "No trigger chains found, pass = false" );
88  setFilterPassed(false, ctx);
89 
90  return StatusCode::SUCCESS;
91 }
92 
93 
95 
96  // write out empty muComb/muFast container since EDM creator expects the container to always be present in the view
97  if (m_writeL2muComb) {
98  SG::WriteHandle handle(m_muCombKey, ctx);
99  ATH_CHECK( handle.record(std::make_unique<xAOD::L2CombinedMuonContainer>(), std::make_unique<xAOD::L2CombinedMuonAuxContainer>()) );
100  }
101  if (m_writeL2muFast) {
102  SG::WriteHandle handle(m_muFastKey, ctx);
103  ATH_CHECK( handle.record(std::make_unique<xAOD::L2StandAloneMuonContainer>(), std::make_unique<xAOD::L2StandAloneMuonAuxContainer>()) );
104  }
105  return StatusCode::SUCCESS;
106 }
L2CombinedMuonAuxContainer.h
MuonChainFilterAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: MuonChainFilterAlg.cxx:33
MuonChainFilterAlg.h
TrigCompositeUtils.h
MuonChainFilterAlg::m_muFastKey
SG::WriteHandleKey< xAOD::L2StandAloneMuonContainer > m_muFastKey
Definition: MuonChainFilterAlg.h:36
TileDigitizationConfig.inputKey
inputKey
Definition: TileDigitizationConfig.py:103
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
MuonChainFilterAlg::m_muCombKey
SG::WriteHandleKey< xAOD::L2CombinedMuonContainer > m_muCombKey
Definition: MuonChainFilterAlg.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
MuonChainFilterAlg::m_filterChains
Gaudi::Property< std::vector< std::string > > m_filterChains
Definition: MuonChainFilterAlg.h:29
MuonChainFilterAlg::m_notGate
Gaudi::Property< bool > m_notGate
Definition: MuonChainFilterAlg.h:38
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MuonChainFilterAlg::MuonChainFilterAlg
MuonChainFilterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MuonChainFilterAlg.cxx:11
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
MuonChainFilterAlg::m_writeL2muFast
Gaudi::Property< bool > m_writeL2muFast
Definition: MuonChainFilterAlg.h:35
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:353
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
HLT::Identifier::name
std::string name() const
reports human redable name if it is enabled or, empty string
Definition: HLTIdentifier.cxx:14
MuonChainFilterAlg::m_filterChainIDs
TrigCompositeUtils::DecisionIDContainer m_filterChainIDs
Definition: MuonChainFilterAlg.h:40
MuonChainFilterAlg::m_writeL2muComb
Gaudi::Property< bool > m_writeL2muComb
Definition: MuonChainFilterAlg.h:32
TrigCompositeUtils::getIDFromLeg
HLT::Identifier getIDFromLeg(const HLT::Identifier &legIdentifier)
Generate the HLT::Identifier which corresponds to the chain name from the leg name.
Definition: TrigCompositeUtilsRoot.cxx:180
MuonChainFilterAlg::m_inputDecisionKeys
SG::ReadHandleKeyArray< TrigCompositeUtils::DecisionContainer > m_inputDecisionKeys
Definition: MuonChainFilterAlg.h:30
MuonChainFilterAlg::initialize
virtual StatusCode initialize() override
Definition: MuonChainFilterAlg.cxx:15
MuonChainFilterAlg::createDummyMuonContainers
StatusCode createDummyMuonContainers(const EventContext &ctx) const
Definition: MuonChainFilterAlg.cxx:94
L2StandAloneMuonAuxContainer.h
AthReentrantAlgorithm::setFilterPassed
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Definition: AthReentrantAlgorithm.h:139