ATLAS Offline Software
Loading...
Searching...
No Matches
DisplacedJetDispHypoAlg.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
9
22
23DisplacedJetDispHypoAlg::DisplacedJetDispHypoAlg(const std::string& name, ISvcLocator* pSvcLocator) :
24::HypoBase(name, pSvcLocator)
25{
26}
27
29{
30 ATH_CHECK(m_lrtTracksKey.initialize());
32 ATH_CHECK(m_vtxKey.initialize());
33 ATH_CHECK(m_beamSpotKey.initialize());
34
35 ATH_CHECK(m_hypoTools.retrieve());
36 return StatusCode::SUCCESS;
37}
38
39StatusCode 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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
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.
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()
const std::string & featureString()
const std::string & viewString()
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...
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)
virtual StatusCode execute(const EventContext &context) const override
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vtxKey
ToolHandleArray< DisplacedJetDispHypoTool > m_hypoTools
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_lrtTracksKey
virtual StatusCode initialize() override
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
const_pointer_type retrieve()
pointer_type ptr()
Dereference the pointer.
Class describing a Vertex.
Definition Vertex_v1.h:42
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
const std::string & viewString()
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()
xAOD::TrigCompositeAuxContainer DecisionAuxContainer
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.
void findLinks(const Decision *start, const std::string &linkName, std::vector< LinkInfo< T > > &links, unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const xAOD::TrigComposite * > *fullyExploredFrom=nullptr)
search back the TC links for the object of type T linked to the one of TC (recursively) Populates pro...
const std::string & hypoAlgNodeName()
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
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 decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
static const unsigned int lastFeatureOfType
Run 3 "enum". Only return the final feature along each route through the navigation.
auto makeHandle(const SG::View *view, const KEY &key, const EventContext &ctx)
Create a view handle from a handle key.
Definition ViewHelper.h:273
@ PriVtx
Primary vertex.
Jet_v1 Jet
Definition of the current "jet version".
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition LinkInfo.h:22
ElementLink< T > link
Link to the feature.
Definition LinkInfo.h:55