ATLAS Offline Software
InDetSecVtxTrackCut.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 //Author: Lianyou Shan <lianyou.shan@cern.ch>
5 // -*- c++ -*-
6 // InDetSecVtxTrackCuts.cxx
7 // implementations and definitions of cut objects
8 
9 #include "InDetSecVtxTrackCut.h"
11 
12 #include <algorithm>
13 
14 
15 // ---------------- SecVtxTrackCut ----------------
17  : asg::AsgMessaging(tool)
18  , m_trackAccessors(nullptr)
19  , m_selectionTool(tool)
20 {
21 }
22 
24 
25 // this function is a friend of the tool
27 {
28  if (!m_selectionTool) {
29  ATH_MSG_ERROR( "Invalid pointer to InDetSecVtxTrackSelectionTool." );
30  return StatusCode::FAILURE;
31  }
32  // let the cut have a handle on the tool's accessors
34  return StatusCode::SUCCESS;
35 }
36 
37 // ---------------- D0minCut ----------------
40  , m_minValue(min)
41  , m_paramAccessor(nullptr)
42 {
43 }
44 
46 {
49  return StatusCode::SUCCESS;
50 }
51 
53 {
54  if (!m_paramAccessor) {
55  ATH_MSG_WARNING( "Track parameter accessor not valid. Track will not pass this cut." );
56  return false;
57  }
58  ATH_MSG_DEBUG( " trk D0 " << m_paramAccessor->getValue() << " vs D0minCut " << m_minValue ) ;
59  return std::fabs( m_paramAccessor->getValue() ) >= m_minValue;
60 }
61 
62 // ---------------- FuncSummaryValueCut ----------------
63 template <size_t N>
65  const std::array<xAOD::SummaryType,N>&& sumTypes) : InDet::SecVtxTrackCut(tool)
66  , m_summaryTypes(sumTypes)
67 {
68 }
69 
70 template <size_t N>
72 {
73  // first run the base class version to get access to the tool's accessors
75 
76  for (size_t i=0; i<N; ++i) {
77  std::string summaryName = "summaryType";
78  summaryName += std::to_string(m_summaryTypes[i]);
79  std::shared_ptr<SummaryAccessor> accessor;
80  ATH_CHECK( getAccessor(summaryName, accessor) );
81  accessor->setSummaryType( m_summaryTypes[i] );
82  m_summaryAccessors[i] = std::move(accessor);
83  }
84 
85  return StatusCode::SUCCESS;
86 }
87 
88 template <size_t N>
90 {
91  std::array<uint8_t,N> results{}; // member variable to store the results
92 
93  for (size_t i=0; i<N; ++i) {
94  if (!m_summaryAccessors[i]) {
95  ATH_MSG_WARNING( "Track summary accessor not valid. Track will not pass this cut." );
96  return false;
97  }
98  results[i] = m_summaryAccessors[i]->getValue();
99  }
100  return m_func(results);
101 }
102 
103 template class InDet::FuncSummaryValueCut<3>;
104 template class InDet::FuncSummaryValueCut<4>;
InDet::FuncSummaryValueCut::initialize
virtual StatusCode initialize()
Definition: InDetSecVtxTrackCut.cxx:71
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
asg
Definition: DataHandleTestTool.h:28
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
InDet::D0minCut::D0minCut
D0minCut(InDetSecVtxTrackSelectionTool *, Double_t min=-99.)
Definition: InDetSecVtxTrackCut.cxx:38
InDet::FuncSummaryValueCut::FuncSummaryValueCut
FuncSummaryValueCut(InDetSecVtxTrackSelectionTool *, const std::array< xAOD::SummaryType, N > &&)
Definition: InDetSecVtxTrackCut.cxx:64
InDet::SecVtxTrackCut::initialize
virtual StatusCode initialize()
Definition: InDetSecVtxTrackCut.cxx:26
InDetSecVtxTrackSelectionTool.h
InDet::SecVtxTrackCut::m_selectionTool
InDetSecVtxTrackSelectionTool * m_selectionTool
Definition: InDetSecVtxTrackCut.h:42
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDet::D0minCut::result
virtual bool result() const
Definition: InDetSecVtxTrackCut.cxx:52
InDet::D0minCut::m_paramAccessor
std::shared_ptr< svParamAccessor< 0 > > m_paramAccessor
Definition: InDetSecVtxTrackCut.h:53
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::SecVtxTrackCut::SecVtxTrackCut
SecVtxTrackCut(InDetSecVtxTrackSelectionTool *)
Definition: InDetSecVtxTrackCut.cxx:16
InDet::D0minCut::m_minValue
Double_t m_minValue
Definition: InDetSecVtxTrackCut.h:52
InDet::SecVtxTrackCut
Definition: InDetSecVtxTrackCut.h:25
InDet::FuncSummaryValueCut::result
virtual bool result() const
Definition: InDetSecVtxTrackCut.cxx:89
min
#define min(a, b)
Definition: cfImp.cxx:40
InDet::SecVtxTrackCut::m_trackAccessors
std::unordered_map< std::string, std::shared_ptr< SecVtxTrackAccessor > > * m_trackAccessors
Definition: InDetSecVtxTrackCut.h:40
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
python.ami.results
def results
Definition: ami.py:386
InDet::InDetSecVtxTrackSelectionTool
Implementation of the track selector tool.
Definition: InDetSecVtxTrackSelectionTool.h:36
InDet::SecVtxTrackCut::getAccessor
StatusCode getAccessor(const std::string &name, std::shared_ptr< AccessorType > &accessor)
Definition: InDetSecVtxTrackCut.h:72
xAOD::JetAttributeAccessor::accessor
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.
Definition: JetAccessorMap.h:26
InDet::InDetSecVtxTrackSelectionTool::m_trackAccessors
std::unordered_map< std::string, std::shared_ptr< SecVtxTrackAccessor > > m_trackAccessors
list of the accessors that need to be run for each track
Definition: InDetSecVtxTrackSelectionTool.h:94
InDetSecVtxTrackCut.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
InDet::SecVtxTrackCut::~SecVtxTrackCut
virtual ~SecVtxTrackCut()=0
InDet::FuncSummaryValueCut
Definition: InDetSecVtxTrackCut.h:57
InDet::D0minCut::initialize
virtual StatusCode initialize()
Definition: InDetSecVtxTrackCut.cxx:45