ATLAS Offline Software
TrigBphysStreamerHypo.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "xAODMuon/Muon.h"
10 
14 
18 
19 
20 TrigBphysStreamerHypo::TrigBphysStreamerHypo(const std::string& name, ISvcLocator* pSvcLocator)
21  : ::HypoBase(name, pSvcLocator) {}
22 
23 
25  ATH_MSG_DEBUG( "TrigBphysStreamerHypo::initialize()" );
26 
27  if (m_triggerLevel != "L2" && m_triggerLevel != "EF") {
28  ATH_MSG_ERROR( "triggerLevel should be L2 or EF, but " << m_triggerLevel << " provided" );
29  return StatusCode::FAILURE;
30  }
31 
32  // convert chain names into hashes
33  if (!m_triggerList.empty()) {
34  ATH_MSG_DEBUG( "The ID will be copied from the previous decision if it matches with some trigger from the list below:" );
35  for (size_t i = 0; i < m_triggerList.size(); ++i) {
36  const auto id = HLT::Identifier(m_triggerList[i]);
37  m_triggerIDs.insert(id.numeric());
38  ATH_MSG_DEBUG( i << " " << m_triggerList[i] );
39  }
40  }
41  else {
42  ATH_MSG_DEBUG( "The triggerList is empty, all decision IDs will be copied from the previous decisions" );
43  }
44 
45  ATH_CHECK( m_hypoTools.retrieve() );
46  return StatusCode::SUCCESS;
47 }
48 
49 
50 StatusCode TrigBphysStreamerHypo::execute( const EventContext& context ) const {
51 
52  ATH_MSG_DEBUG( "TrigBphysStreamerHypo::execute() starts" );
53 
54  ATH_MSG_DEBUG( "decision input key: " << decisionInput().key() );
55  auto previousDecisionsHandle = SG::makeHandle(decisionInput(), context);
56  CHECK( previousDecisionsHandle.isValid() );
57  ATH_MSG_DEBUG( "Running with " << previousDecisionsHandle->size() << " previous decisions" );
58 
59  // create the mutable output DecisionContainer and register it to StoreGate
61  DecisionContainer* decisions = outputHandle.ptr();
62 
63  for (const Decision* previousDecision : *previousDecisionsHandle) {
65 
66  if (!m_triggerList.empty()) {
67  TrigCompositeUtils::DecisionIDContainer previousDecisionIDs;
68  TrigCompositeUtils::decisionIDs(previousDecision, previousDecisionIDs);
69  for (const auto& previousDecisionID : previousDecisionIDs) {
70  // we should use the HLT identifier which corresponds to a whole chain
72  if (m_triggerIDs.find(id.numeric()) != m_triggerIDs.end()) {
73  TrigCompositeUtils::addDecisionID(previousDecisionID, decision);
74  }
75  }
76  }
77  else {
78  TrigCompositeUtils::insertDecisionIDs(previousDecision, decision);
79  }
80 
81  if (m_triggerLevel == "L2") {
82  auto muonLinkInfo = TrigCompositeUtils::findLink<xAOD::L2StandAloneMuonContainer>(previousDecision, TrigCompositeUtils::featureString(), true);
83  ATH_CHECK( muonLinkInfo.isValid() );
84  decision->setObjectLink<xAOD::L2StandAloneMuonContainer>(TrigCompositeUtils::featureString(), muonLinkInfo.link);
85 
86  //set roi link (to use same roi in EF CB muon step)
87  auto roiLink = TrigCompositeUtils::findLink<TrigRoiDescriptorCollection>(decision, "roi");
88  decision->setObjectLink(m_roiLinkName.value(), roiLink.link);
89  }
90  else if (m_triggerLevel == "EF") {
91  auto muonLinkInfo = TrigCompositeUtils::findLink<xAOD::MuonContainer>(previousDecision, TrigCompositeUtils::featureString(), true);
92  ATH_CHECK( muonLinkInfo.isValid() );
93  decision->setObjectLink<xAOD::MuonContainer>(TrigCompositeUtils::featureString(), muonLinkInfo.link);
94 
95  if (msgLvl(MSG::DEBUG)) {
96  const xAOD::Muon* muon = *(muonLinkInfo.link);
97  if (muon->trackParticle(xAOD::Muon::TrackParticleType::CombinedTrackParticle)) {
98  const ElementLink<xAOD::TrackParticleContainer> trackEL = muon->inDetTrackParticleLink();
99  ATH_CHECK( trackEL.isValid() );
100  const xAOD::TrackParticle* track = *trackEL;
101  ATH_MSG_DEBUG( " -- muon pt/eta/phi/q: " << track->pt() << " / " << track->eta() << " / " << track->phi() << " / " << track->charge() );
102  ATH_MSG_DEBUG( " Allowed decisions:" );
104  TrigCompositeUtils::decisionIDs(decision, IDs);
105  for (const TrigCompositeUtils::DecisionID& id : IDs) {
106  ATH_MSG_DEBUG( " +++ " << HLT::Identifier(id) );
107  }
108  }
109  }
110  }
111 
112  }
113 
114  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
115 
116  return StatusCode::SUCCESS;
117 }
TrigBphysStreamerHypo::m_roiLinkName
Gaudi::Property< std::string > m_roiLinkName
Definition: TrigBphysStreamerHypo.h:32
TrigBphysStreamerHypo::m_hypoTools
ToolHandleArray< TrigBphysStreamerHypoTool > m_hypoTools
Definition: TrigBphysStreamerHypo.h:27
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
Muon.h
TrigCompositeUtils::newDecisionIn
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
Definition: TrigCompositeUtilsRoot.cxx:46
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:904
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
TrigBphysStreamerHypo::m_triggerLevel
Gaudi::Property< std::string > m_triggerLevel
Definition: TrigBphysStreamerHypo.h:28
TrigCompositeUtils::insertDecisionIDs
void insertDecisionIDs(const Decision *src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
Definition: TrigCompositeUtilsRoot.cxx:80
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
HypoBase::decisionInput
const SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > & decisionInput() const
methods for derived classes to access handles of the base class input other read/write handles may be...
Definition: HypoBase.cxx:16
L2StandAloneMuonContainer.h
TrigCompositeUtils::createAndStore
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
Definition: TrigCompositeUtilsRoot.cxx:30
HypoBase::decisionOutput
const SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > & decisionOutput() const
methods for derived classes to access handles of the base class output other read/write handles may b...
Definition: HypoBase.cxx:20
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
TrigBphysStreamerHypo::m_triggerIDs
TrigCompositeUtils::DecisionIDContainer m_triggerIDs
Definition: TrigBphysStreamerHypo.h:31
TrigBphysStreamerHypo.h
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigCompositeUtils.h
TrigBphysStreamerHypo::execute
virtual StatusCode execute(const EventContext &) const override
Definition: TrigBphysStreamerHypo.cxx:50
TrigBphysStreamerHypo::initialize
virtual StatusCode initialize() override
Definition: TrigBphysStreamerHypo.cxx:24
TrigBphysStreamerHypo::TrigBphysStreamerHypo
TrigBphysStreamerHypo()=delete
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
HypoBase::hypoBaseOutputProcessing
StatusCode hypoBaseOutputProcessing(SG::WriteHandle< TrigCompositeUtils::DecisionContainer > &outputHandle, MSG::Level lvl=MSG::DEBUG) const
Base class function to be called once slice specific code has finished. Handles debug printing and va...
Definition: HypoBase.cxx:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
TrigBphysStreamerHypo::m_triggerList
Gaudi::Property< std::vector< std::string > > m_triggerList
Definition: TrigBphysStreamerHypo.h:30
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:884
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
HypoBase
Hypothesis algorithms take the output of reco algorithms and the decision from the preceeding InputMa...
Definition: HypoBase.h:13
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
MuonContainer.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
DEBUG
#define DEBUG
Definition: page_access.h:11
HLTIdentifier.h
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
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
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
TrigRoiDescriptorCollection.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37