ATLAS Offline Software
TrigJetCRHypoAlg.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 <algorithm>
6 #include "TrigJetCRHypoAlg.h"
7 #include "TrigJetCRHypoTool.h"
10 
11 using namespace TrigCompositeUtils;
12 
13 
15  ISvcLocator* pSvcLocator ) :
16  ::HypoBase( name, pSvcLocator ) { }
17 
18 
20 
21  ATH_CHECK(m_hypoTools.retrieve() );
24 
25  return StatusCode::SUCCESS;
26 }
27 
28 
29 StatusCode TrigJetCRHypoAlg::execute( const EventContext& context ) const {
30 
31  ATH_MSG_DEBUG( "Executing " << name() << "..." );
32 
33  ATH_MSG_DEBUG("Retrieving HLT decision \"" << decisionInput().key() << "\"");
34  auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
35  ATH_CHECK( previousDecisionsHandle.isValid() );
36  const DecisionContainer* prevDecisions = previousDecisionsHandle.get();
37 
38  // Creates the mutable output DecisionContainer and registers it to StoreGate.
40  DecisionContainer* decisions = outputHandle.ptr();
41 
42 
43  ATH_MSG_DEBUG( "Creating new output decision handle");
44 
45  // prepare imput for tools
46  std::vector<TrigJetCRHypoTool::JetInfo> hypoToolInput;
47 
48  // get tracks from the key :
49  ATH_MSG_DEBUG( "Getting Track Handle "<<m_trackParticleKey);
50  auto trackHandle = SG::makeHandle(m_trackParticleKey, context );
51 
52  ATH_CHECK( trackHandle.isValid() );
53  const xAOD::TrackParticleContainer* allTracks = trackHandle.get();
54  ATH_MSG_DEBUG ( allTracks->size() << " tracks found" );
55 
56  // get cells from the key :
57  ATH_MSG_DEBUG( "Getting Cells Handle "<<m_cellKey);
58  auto cellHandle = SG::makeHandle(m_cellKey, context );
59 
60  ATH_CHECK( cellHandle.isValid() );
61  const CaloConstCellContainer* cells = cellHandle.get();
62  ATH_MSG_DEBUG ( cells->size() << " cells found" );
63 
64  for (const Decision* previousDecision : *prevDecisions) {
65  // Create a new output Decision object, d, backed by the 'decisions' container.
66  // Links previousDecision as the parent of d.
67 
68  Decision* d = newDecisionIn( decisions, previousDecision, hypoAlgNodeName(), context );
69 
70 
71  const std::vector<LinkInfo< xAOD::JetContainer > >jetELs =
72  findLinks< xAOD::JetContainer >( previousDecision, featureString().c_str(), TrigDefs::lastFeatureOfType);
73  d->setObjectLink<xAOD::JetContainer>( featureString(), jetELs.at(0).link );
74  DecisionIDContainer previousDecisionIDs;
75  decisionIDs(previousDecision, previousDecisionIDs);
76 
77  for (const LinkInfo< xAOD::JetContainer> & jetLinkInfo: jetELs){
78  // Collect all the required information for the tool together in a handy struct
79  hypoToolInput.emplace_back( TrigJetCRHypoTool::JetInfo{previousDecisionIDs, *(jetLinkInfo.link), allTracks, cells, d} );
80  }
81  // Obtain the set of chains which are active in previousDecision
82  }
83 
84 
85  //Loop over all hypoToolinputs and get their decisions
86  for ( auto & tool: m_hypoTools ) {
87  ATH_CHECK( tool->decide( hypoToolInput ) );
88  }
89 
90  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
91 
92  return StatusCode::SUCCESS;
93 
94 }
95 
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
TrigCompositeUtils.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
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:906
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
TrigJetCRHypoTool.h
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
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
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
TrigJetCRHypoTool::JetInfo
Definition: TrigJetCRHypoTool.h:59
TrigJetCRHypoAlg::m_hypoTools
ToolHandleArray< TrigJetCRHypoTool > m_hypoTools
Definition: TrigJetCRHypoAlg.h:37
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
TrigJetCRHypoAlg.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
TrigJetCRHypoAlg::m_cellKey
SG::ReadHandleKey< CaloConstCellContainer > m_cellKey
Definition: TrigJetCRHypoAlg.h:45
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
CaloConstCellContainer
CaloCellContainer that can accept const cell pointers.
Definition: CaloConstCellContainer.h:45
TrigJetCRHypoAlg::m_trackParticleKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleKey
Definition: TrigJetCRHypoAlg.h:42
HLTIdentifier.h
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigJetCRHypoAlg::TrigJetCRHypoAlg
TrigJetCRHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigJetCRHypoAlg.cxx:14
TrigJetCRHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigJetCRHypoAlg.cxx:29
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrigJetCRHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigJetCRHypoAlg.cxx:19
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37