ATLAS Offline Software
Loading...
Searching...
No Matches
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
20TrigBphysStreamerHypo::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
50StatusCode 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) {
64 Decision* decision = TrigCompositeUtils::newDecisionIn(decisions, previousDecision, TrigCompositeUtils::hypoAlgNodeName(), context);
65
66 if (!m_triggerList.empty()) {
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") {
83 ATH_CHECK( muonLinkInfo.isValid() );
85
86 //set roi link (to use same roi in EF CB muon step)
88 decision->setObjectLink(m_roiLinkName.value(), roiLink.link);
89 }
90 else if (m_triggerLevel == "EF") {
92 ATH_CHECK( muonLinkInfo.isValid() );
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
bool msgLvl(const MSG::Level lvl) const
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:18
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:22
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:35
HypoBase(const std::string &name, ISvcLocator *pSvcLocator)
constructor, to be called by sub-class constructors
Definition HypoBase.cxx:12
pointer_type ptr()
Dereference the pointer.
Gaudi::Property< std::string > m_triggerLevel
TrigBphysStreamerHypo()=delete
Gaudi::Property< std::string > m_roiLinkName
virtual StatusCode initialize() override
TrigCompositeUtils::DecisionIDContainer m_triggerIDs
ToolHandleArray< TrigBphysStreamerHypoTool > m_hypoTools
virtual StatusCode execute(const EventContext &) const override
Gaudi::Property< std::vector< std::string > > m_triggerList
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
unsigned int DecisionID
void insertDecisionIDs(const Decision *src, Decision *dest)
Appends the decision IDs of src to the dest decision object.
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.
const std::string & featureString()
HLT::Identifier getIDFromLeg(const HLT::Identifier &legIdentifier)
Generate the HLT::Identifier which corresponds to the chain name from the leg name.
std::set< DecisionID > DecisionIDContainer
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
const std::string & hypoAlgNodeName()
LinkInfo< T > findLink(const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
L2StandAloneMuonContainer_v2 L2StandAloneMuonContainer
Define the latest version of the muon SA container.
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".