ATLAS Offline Software
DisplacedJetDispHypoAlg.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "AthViews/ViewHelper.h"
9 
22 
23 DisplacedJetDispHypoAlg::DisplacedJetDispHypoAlg(const std::string& name, ISvcLocator* pSvcLocator) :
24 ::HypoBase(name, pSvcLocator)
25 {
26 }
27 
29 {
32  ATH_CHECK(m_vtxKey.initialize());
34 
35  ATH_CHECK(m_hypoTools.retrieve());
36  return StatusCode::SUCCESS;
37 }
38 
39 StatusCode DisplacedJetDispHypoAlg::execute(const EventContext& context) const
40 {
41  ATH_MSG_DEBUG ( "Executing " << name() << "..." );
42  auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
43 
44  ATH_CHECK( previousDecisionsHandle.isValid() );
45 
47  auto decisions = outputHandle.ptr();
48 
49  ATH_MSG_DEBUG("Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions. Looking for :"<<viewString());
50 
51  auto vtxHandle = SG::makeHandle(m_vtxKey, context);
52  ATH_CHECK( vtxHandle.isValid() );
53  const xAOD::VertexContainer* vtxs = vtxHandle.get();
54 
55  //get the primary vertex
56  const xAOD::Vertex_v1* primary_vertex = nullptr;
57 
58  for(auto v: *vtxs){
59  if(v->vertexType()==xAOD::VxType::PriVtx){
60  primary_vertex = v;
61  }
62  }
63 
64  if(primary_vertex == nullptr){
65  ATH_MSG_DEBUG("missing primary vertex");
66  return StatusCode::SUCCESS;
67  }
68 
69  SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey, context };
70 
71  ATH_CHECK(beamSpotHandle.isValid());
72 
73  DisplacedJetBeamspotInfo beamspot_info(beamSpotHandle.retrieve());
74 
75  for(const TrigCompositeUtils::Decision* previousDecision: *previousDecisionsHandle){
76  const auto viewELInfo = findLink< ViewContainer >( previousDecision, viewString() );
77  ATH_CHECK( viewELInfo.isValid() );
78 
79  TrigCompositeUtils::Decision* d = newDecisionIn(decisions, previousDecision, hypoAlgNodeName(), context);
80 
82  TrigCompositeUtils::decisionIDs( previousDecision, prev );
83 
84 
85  ATH_MSG_DEBUG("Getting LRT Tracks "<<m_lrtTracksKey);
86 
87  //get containers
88  auto lrtHandle = ViewHelper::makeHandle(*viewELInfo.link, m_lrtTracksKey, context);
89 
90  ATH_CHECK( lrtHandle.isValid() );
91 
92  const xAOD::TrackParticleContainer* lrtTracks = lrtHandle.get();
93 
94  //get the linked jet feature
95  std::vector<TrigCompositeUtils::LinkInfo<xAOD::JetContainer>> jet_feature_links = TrigCompositeUtils::findLinks<xAOD::JetContainer>(previousDecision, TrigCompositeUtils::featureString(), TrigDefs::lastFeatureOfType);
96  ATH_CHECK(jet_feature_links.size() == 1); //ensure we only have 1 link
97  const TrigCompositeUtils::LinkInfo<xAOD::JetContainer> jet_feature_link = jet_feature_links.at(0);
98  //verify if the feature link is valid
99  ATH_CHECK(jet_feature_link.isValid());
100  const xAOD::Jet* jet = *(jet_feature_link.link);
101 
102  //reattach jet feature link
103  d->setObjectLink(featureString(), jet_feature_link.link);
104 
105  //get my count object which has been linked to the decision
106  auto count_links = TrigCompositeUtils::findLinks<xAOD::TrigCompositeContainer>(previousDecision, "djtrig_counts");
107  ATH_CHECK(count_links.size() == 1); //ensure we only have 1 link
108  auto count_link = count_links.at(0);
109  ATH_CHECK(count_link.isValid());
110  const xAOD::TrigComposite* count = *(count_link.link);
111 
112 
113  //count the number of tracks in the RoI (at this point it is running in RoI mode)
114  //apply the nprompt, nother, ndisp requirements and generated the per jet decision
115 
116  DisplacedJetDispHypoTool::Info info{d, prev, jet, lrtTracks, primary_vertex, count, beamspot_info};
117 
118  for(auto &tool:m_hypoTools)
119  {
120  ATH_CHECK(tool->decide(info));
121  }
122  }
123 
124 
125  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
126  return StatusCode::SUCCESS;
127 }
grepfile.info
info
Definition: grepfile.py:38
DisplacedJetDispHypoAlg.h
TrigCompositeUtils::LinkInfo::link
ElementLink< T > link
Link to the feature.
Definition: LinkInfo.h:61
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
DisplacedJetDispHypoAlg::DisplacedJetDispHypoAlg
DisplacedJetDispHypoAlg()
TrigCompositeUtils::LinkInfo::isValid
bool isValid() const
Definition: LinkInfo.h:43
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:904
ViewHelper::makeHandle
SG::ReadHandle< T > makeHandle(const SG::View *view, const SG::ReadHandleKey< T > &rhKey, const EventContext &context)
navigate from the TrigComposite to nearest view and fetch object from it
Definition: ViewHelper.h:259
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
Definition: AthCommonDataStore.h:380
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
DisplacedJetDispHypoAlg::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: DisplacedJetDispHypoAlg.h:36
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
DisplacedJetDispHypoAlg::m_vtxKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vtxKey
Definition: DisplacedJetDispHypoAlg.h:34
DisplacedJetDispHypoAlg::initialize
virtual StatusCode initialize() override
Definition: DisplacedJetDispHypoAlg.cxx:28
ViewHelper.h
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
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
DisplacedJetDispHypoAlg::m_lrtTracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_lrtTracksKey
Definition: DisplacedJetDispHypoAlg.h:33
DisplacedJetDispHypoAlg::m_hypoTools
ToolHandleArray< DisplacedJetDispHypoTool > m_hypoTools
Definition: DisplacedJetDispHypoAlg.h:32
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
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
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
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:101
TrigCompositeUtils::DecisionAuxContainer
xAOD::TrigCompositeAuxContainer DecisionAuxContainer
Definition: TrigCompositeAuxContainer.h:20
P4Helpers.h
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:884
DisplacedJetDispHypoTool::Info
Definition: DisplacedJetDispHypoTool.h:29
DisplacedJetBeamspotInfo
Definition: DisplacedJetBeamspotInfo.h:12
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
HypoBase
Hypothesis algorithms take the output of reco algorithms and the decision from the preceeding InputMa...
Definition: HypoBase.h:13
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
python.PyAthena.v
v
Definition: PyAthena.py:154
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrigCompositeUtils::linkToPrevious
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
Definition: TrigCompositeUtilsRoot.cxx:139
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
TrigCompositeUtils::findLink
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...
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
DisplacedJetDispHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: DisplacedJetDispHypoAlg.cxx:39
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:880
DisplacedJetDispHypoTool.h