ATLAS Offline Software
TrigJetEJsHypoAlg.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 "TrigJetEJsHypoAlg.h"
7 #include "TrigJetEJsHypoTool.h"
10 
11 using namespace TrigCompositeUtils;
12 
13 using xAOD::JetContainer;
16 
17 
19  ISvcLocator* pSvcLocator ) :
20  ::HypoBase( name, pSvcLocator ) { }
21 
22 
24 
25  CHECK( m_hypoTools.retrieve() );
27  CHECK( m_PV.initialize() );
28 
29  return StatusCode::SUCCESS;
30 }
31 
32 
33 StatusCode TrigJetEJsHypoAlg::execute( const EventContext& context ) const {
34 
35  ATH_MSG_DEBUG ( "Executing " << name() << "..." );
36 
37  // get the HLT decision container for the previous decisions (one per jet in the original collection)
38 
39  ATH_MSG_DEBUG("Retrieving HLT decision \"" << decisionInput().key() << "\"");
40  auto previousDecisionsHandle = SG::makeHandle(decisionInput(), context );
41  ATH_CHECK(previousDecisionsHandle.isValid());
42  const DecisionContainer* prevDecisions = previousDecisionsHandle.get();
43 
44  // read in tracks container
45  ATH_MSG_DEBUG("Retrieving tracks from the track container \"" << m_tracksKey << "\"");
46  auto TracksHandle = SG::makeHandle(m_tracksKey, context );
47  ATH_CHECK(TracksHandle.isValid());
48  const TrackParticleContainer* tracks = TracksHandle.get();
49 
50  // read in primary vertex container
51  ATH_MSG_DEBUG("Retrieving PV from the vertex container \"" << m_PV << "\"");
52  auto PVHandle = SG::makeHandle(m_PV, context );
53  ATH_CHECK(PVHandle.isValid());
54  const VertexContainer* vertices = PVHandle.get();
55  const xAOD::Vertex_v1 *PV = vertices->at(0);
56 
57 
58  std::vector<TrigJetEJsHypoTool::JetInfo> hypoToolInput;
60  DecisionContainer* outputDecisions = outputHandle.ptr();
61 
62  for (const Decision* previousDecision : *prevDecisions) {
63  LinkInfo< xAOD::JetContainer > myFeature = findLink< xAOD::JetContainer >(previousDecision, featureString());
64  TrigCompositeUtils::DecisionIDContainer previousDecisionIDs;
65  TrigCompositeUtils::decisionIDs(previousDecision, previousDecisionIDs);
66  Decision* newDecision = newDecisionIn(outputDecisions, previousDecision, hypoAlgNodeName(), context);
67  newDecision->setObjectLink<xAOD::JetContainer>(featureString(), myFeature.link);
68  hypoToolInput.emplace_back(TrigJetEJsHypoTool::JetInfo{newDecision, *(myFeature.link), tracks, PV, previousDecisionIDs});
69  }//end loop on previous decisions
70 
71 
72  for (const auto& tool: m_hypoTools) {
73  ATH_MSG_DEBUG("Now computing decision for " << tool->name());
74  CHECK(tool->decide(hypoToolInput));
75  }//end loop on hypoTools
76 
77 
78  DecisionContainer::iterator it = outputDecisions->begin();
79  while(it != outputDecisions->end()) {
80  if (allFailed( *it )) {
81  it = outputDecisions->erase(it);
82  } else {
83  ++it;
84  }
85  }//end loop on output decisios
86 
87  return StatusCode::SUCCESS;
88 
89 }//end execute
TrigCompositeUtils::LinkInfo::link
ElementLink< T > link
Link to the feature.
Definition: LinkInfo.h:61
AthCUDAExamples::TrackParticleContainer
vecmem::edm::container< TrackParticleInterface, vecmem::edm::type::vector< float >, vecmem::edm::type::vector< float >, vecmem::edm::type::vector< float > > TrackParticleContainer
SoA, GPU friendly TrackParticleContainer.
Definition: Control/AthenaExamples/AthExCUDA/src/TrackParticleContainer.h:46
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
skel.it
it
Definition: skel.GENtoEVGEN.py:396
xAOD::TrackParticleContainer
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticleContainer.h:14
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
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
TrigJetEJsHypoAlg::TrigJetEJsHypoAlg
TrigJetEJsHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigJetEJsHypoAlg.cxx:18
xAOD::VertexContainer
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Definition: VertexContainer.h:14
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:270
TrigCompositeUtils.h
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
xAOD::TrigComposite_v1::setObjectLink
bool setObjectLink(const std::string &name, const ElementLink< CONTAINER > &link)
Set the link to an object.
TrigJetEJsHypoAlg::m_hypoTools
ToolHandleArray< TrigJetEJsHypoTool > m_hypoTools
Definition: TrigJetEJsHypoAlg.h:42
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
TrigJetEJsHypoAlg::m_PV
SG::ReadHandleKey< xAOD::VertexContainer > m_PV
Definition: TrigJetEJsHypoAlg.h:48
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
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:794
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:884
TrigJetEJsHypoAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
TrigJetEJsHypoAlg::m_tracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracksKey
Definition: TrigJetEJsHypoAlg.h:46
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
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
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
HLTIdentifier.h
TrigCompositeUtils::allFailed
bool allFailed(const Decision *d)
return true if there is no positive decision stored
Definition: TrigCompositeUtilsRoot.cxx:103
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
TrigJetEJsHypoTool::JetInfo
Definition: TrigJetEJsHypoTool.h:70
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigJetEJsHypoTool.h
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition: JetContainer.h:17
DataVector::erase
iterator erase(iterator position)
Remove element at a given position.
TrigJetEJsHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigJetEJsHypoAlg.cxx:33
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
TrigJetEJsHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigJetEJsHypoAlg.cxx:23
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37