ATLAS Offline Software
FastTrackFinderLRTHypoAlg.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include "AthViews/ViewHelper.h"
9 
22 
23 FastTrackFinderLRTHypoAlg::FastTrackFinderLRTHypoAlg(const std::string& name, ISvcLocator* pSvcLocator) :
24 ::HypoBase(name, pSvcLocator)
25 {
26 }
27 
29 {
31  ATH_CHECK(m_trackCountKey.initialize());
33  ATH_CHECK(m_min_pt.size()==m_min_d0.size());
34 
35  if (m_tracksKey.key() == "Undefined" || m_trackCountKey.key() == "Undefined") {
36  ATH_MSG_ERROR("either track Key name or track count key name is undefined " );
37  return StatusCode::FAILURE;
38  }
39 
40  ATH_CHECK(m_hypoTools.retrieve());
41  if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
42 
43  return StatusCode::SUCCESS;
44 }
45 
46 StatusCode FastTrackFinderLRTHypoAlg::execute(const EventContext& context) const
47 {
48  ATH_MSG_DEBUG ( "Executing " << name() << "..." );
49  auto previousDecisionsHandle = SG::makeHandle( decisionInput(), context );
50 
51  if( not previousDecisionsHandle.isValid() ) {//implicit
52  ATH_MSG_DEBUG( "No implicit RH for previous decisions "<< decisionInput().key()<<": is this expected?" );
53  return StatusCode::SUCCESS;
54  }
55 
56  if (previousDecisionsHandle->size() == 0) {
57  ATH_MSG_DEBUG( "No previous decision, nothing to do.");
58  return StatusCode::SUCCESS;
59  } else if (previousDecisionsHandle->size() > 1) {
60  ATH_MSG_ERROR("Found " << previousDecisionsHandle->size() <<" previous decisions.");
61  return StatusCode::FAILURE;
62  }
63 
64  ATH_MSG_DEBUG( "Running with "<< previousDecisionsHandle->size() <<" implicit ReadHandles for previous decisions. Looking for :"<<viewString());
65 
66  std::vector<int> counts(m_min_pt.size());
67 
68 
69  //taken from isohightpt
70 
71  ATH_MSG_DEBUG( "Getting Track Handle "<<m_tracksKey);
72  // get tracks from the key :
73  auto trackHandle = SG::makeHandle(m_tracksKey, context );
74 
75  ATH_CHECK( trackHandle.isValid() );
76  ATH_MSG_DEBUG ( "track handle size: " << trackHandle->size() << "..." );
77 
78  int ntrks = trackHandle->size();
79 
80  const xAOD::TrackParticleContainer * AllTracks = trackHandle.get(); //Later this could be updated to run with tracks above a certain threshold
81 
82  // Loop over all tracks and get a track decision associated with it and create the input
83  for ( const xAOD::TrackParticle_v1* track : *AllTracks) {
84  const double pT = track->pt();
85  const float d0 = track->d0();
86  const double xi2 = 0.0; //fq.chiSquared();
87  const float abs_d0 = std::fabs(d0);
88  for (long unsigned int i=0;i<m_min_pt.size();i++){
89  if(pT >= m_min_pt[i] && abs_d0 < m_max_d0[i] && abs_d0 >= m_min_d0[i] && std::fabs(xi2) < m_max_xi2[i]) counts[i]++;
90  }
91  }
92 
93  //end taken section
94 
95  // Recording Data
96  auto trackCountContainer = std::make_unique< xAOD::TrigCompositeContainer>();
97  auto trackCountContainerAux = std::make_unique< xAOD::TrigCompositeAuxContainer>();
98  trackCountContainer->setStore(trackCountContainerAux.get());
99 
100  xAOD::TrigComposite * trackCount = new xAOD::TrigComposite();
101  trackCountContainer->push_back(trackCount);
102  trackCount->setDetail("ntrks", ntrks);
103  trackCount->setDetail("pTcuts", static_cast<std::vector<float>>(m_min_pt));
104  trackCount->setDetail("d0mincuts", static_cast<std::vector<float>>(m_min_d0));
105  trackCount->setDetail("d0maxcuts", static_cast<std::vector<float>>(m_max_d0));
106  trackCount->setDetail("xi2cuts", static_cast<std::vector<float>>(m_max_xi2));
107  trackCount->setDetail("counts", counts);
108 
109  // TODO revisit
110 
111  auto mon_ntrks = Monitored::Scalar<int>("ntrks",ntrks);
112  Monitored::Group(m_monTool,mon_ntrks);
113  for(long unsigned int i=0;i<counts.size();i++){
114  auto mon_counts = Monitored::Scalar<int>("counts"+std::to_string(i),counts[i]);
115  Monitored::Group(m_monTool,mon_counts);
116  }
117 
119  auto decisions = outputHandle.ptr();
120 
121  TrigCompositeUtils::Decision* d = newDecisionIn(decisions, previousDecisionsHandle->at(0), hypoAlgNodeName(), context);
122 
124  TrigCompositeUtils::decisionIDs( previousDecisionsHandle->at(0), prev );
125 
126  FastTrackFinderLRTHypoTool::TrkCountsInfo trkinfo{d, trackCount, prev};
127 
128  for(auto &tool:m_hypoTools)
129  {
130  ATH_CHECK(tool->decide(trkinfo));
131  }
132 
134  ATH_CHECK(trackCountHandle.record( std::move( trackCountContainer ), std::move( trackCountContainerAux ) ) );
136  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
137  return StatusCode::SUCCESS;
138 }
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
FastTrackFinderLRTHypoAlg::m_min_pt
Gaudi::Property< std::vector< float > > m_min_pt
Definition: FastTrackFinderLRTHypoAlg.h:33
xAOD::TrigComposite_v1::setDetail
bool setDetail(const std::string &name, const TYPE &value)
Set an TYPE detail on the object.
FastTrackFinderLRTHypoAlg::m_max_d0
Gaudi::Property< std::vector< float > > m_max_d0
Definition: FastTrackFinderLRTHypoAlg.h:35
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
xAOD::TrigComposite
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:16
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
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
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
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
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
FastTrackFinderLRTHypoAlg::m_trackCountKey
SG::WriteHandleKey< xAOD::TrigCompositeContainer > m_trackCountKey
Definition: FastTrackFinderLRTHypoAlg.h:32
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
FastTrackFinderLRTHypoAlg::initialize
virtual StatusCode initialize() override
Definition: FastTrackFinderLRTHypoAlg.cxx:28
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrackParticleAuxContainer.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
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:794
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
TrigCompositeUtils::DecisionAuxContainer
xAOD::TrigCompositeAuxContainer DecisionAuxContainer
Definition: TrigCompositeAuxContainer.h:20
FastTrackFinderLRTHypoAlg.h
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:884
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
HypoBase
Hypothesis algorithms take the output of reco algorithms and the decision from the preceeding InputMa...
Definition: HypoBase.h:13
FastTrackFinderLRTHypoAlg::m_min_d0
Gaudi::Property< std::vector< float > > m_min_d0
Definition: FastTrackFinderLRTHypoAlg.h:34
FastTrackFinderLRTHypoAlg::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: FastTrackFinderLRTHypoAlg.h:37
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
FastTrackFinderLRTHypoAlg::m_tracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracksKey
Definition: FastTrackFinderLRTHypoAlg.h:31
FastTrackFinderLRTHypoAlg::m_hypoTools
ToolHandleArray< FastTrackFinderLRTHypoTool > m_hypoTools
Definition: FastTrackFinderLRTHypoAlg.h:30
FastTrackFinderLRTHypoAlg::m_max_xi2
Gaudi::Property< std::vector< float > > m_max_xi2
Definition: FastTrackFinderLRTHypoAlg.h:36
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
FastTrackFinderLRTHypoAlg::FastTrackFinderLRTHypoAlg
FastTrackFinderLRTHypoAlg()
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
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...
FastTrackFinderLRTHypoTool::TrkCountsInfo
Definition: FastTrackFinderLRTHypoTool.h:23
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
FastTrackFinderLRTHypoTool.h
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
FastTrackFinderLRTHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: FastTrackFinderLRTHypoAlg.cxx:46
TrigCompositeUtils::viewString
const std::string & viewString()
Definition: TrigCompositeUtilsRoot.cxx:880
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37