ATLAS Offline Software
InDetNNScoringTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Markus Elsing
8 
9 #ifndef INDETNNSCORINGTOOL_H
10 #define INDETNNSCORINGTOOL_H
11 
13 #include "GaudiKernel/ToolHandle.h"
14 #include "GaudiKernel/ServiceHandle.h"
19 #include "lwtnn/lightweight_network_config.hh"
20 #include "lwtnn/LightweightNeuralNetwork.hh"
21 #include "lwtnn/LightweightGraph.hh"
22 #include "lwtnn/parse_json.hh"
25 #include "AthenaKernel/CLASS_DEF.h"
27 // MagField cache
30 #include <fstream>
31 #include <vector>
32 #include <string>
34 
35 namespace Trk {
36  class IExtrapolator;
37  class Track;
38  class TrackSummary;
39 
40 }
41 class EventContext;
42 
43 namespace InDet {
44 class ITrtDriftCircleCutTool;
45 
48  public AthAlgTool
49 {
50 
51  public:
52  InDetNNScoringTool(const std::string&,const std::string&,const IInterface*);
53  virtual ~InDetNNScoringTool () = default;
54  virtual StatusCode initialize() override;
56  virtual bool passBasicSelections( const Trk::Track& track ) const override;
57 
59  virtual Trk::TrackScore score( const Trk::Track& track, bool checkBasicSel ) const override;
60 
62  virtual Trk::TrackScore simpleScore( const Trk::Track& track, const Trk::TrackSummary& trackSum ) const override;
63  Trk::TrackScore ambigScore( const Trk::Track& track, const Trk::TrackSummary& trackSum ) const;
64  Trk::TrackScore calcNnScore( const Trk::Track &track, const Trk::TrackSummary& trackSum , const Trk::Perigee *extrapolatedPerigee) const;
65 
66 
67  private:
68  void setupScoreModifiers();
69 
70  // DNN tools
71  std::unique_ptr<lwt::LightweightGraph> m_graph;
72  std::map<std::string, double> m_DNN_inputValues;
73 
75  bool isEmCaloCompatible(const Trk::Track& track, const EventContext& ctx) const;
76 
77 
78  //these are used for ScoreModifiers
85  std::vector<double> m_boundsSigmaChi2,
87 
89  ToolHandle<ITrtDriftCircleCutTool> m_selectortool
90  {this, "DriftCircleCutTool", "InDet::InDetTrtDriftCircleCutTool"};
91 
93  std::vector<Trk::TrackScore> m_summaryTypeScore;
94 
95  SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };
96 
97  ToolHandle<Trk::IExtrapolator> m_extrapolator
98  {this, "Extrapolator", "Trk::Extrapolator"};
99 
100  // Read handle for conditions object to get the field cache
101  SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"};
102 
103 
105  BooleanProperty m_useAmbigFcn{this, "useAmbigFcn", true};
106  BooleanProperty m_useTRT_AmbigFcn{this, "useTRT_AmbigFcn", false};
107  BooleanProperty m_useSigmaChi2{this, "useSigmaChi2", false};
108 
109  StringProperty m_nnCutConfig{this, "nnCutConfig", ""};
110  DoubleProperty m_nnCutThreshold{this, "nnCutThreshold", -0.1};
111 
112  BooleanProperty m_usePixel{this, "usePixel", true};
113  BooleanProperty m_useSCT{this, "useSCT", true};
114 
116  DoubleProperty m_minPt{this, "minPt", 500., "minimal Pt cut"};
117  DoubleProperty m_maxEta{this, "maxEta", 2.7, "maximal Eta cut"};
118  DoubleProperty m_maxRPhiImp
119  {this, "maxRPhiImp", 10., "maximal RPhi impact parameter cut"};
120  DoubleProperty m_maxZImp
121  {this, "maxZImp", 250., "maximal z impact parameter cut"};
122 
123  IntegerProperty m_minSiClusters
124  {this, "minSiClusters", 7, "minimal number of Si clusters"};
125  IntegerProperty m_maxDoubleHoles
126  {this, "maxDoubleHoles", 2, "maximum number of SCT double holes"};
127  IntegerProperty m_maxSiHoles
128  {this, "maxSiHoles", 5, "max number of Silicon (Pixel+SCT) holes"};
129  IntegerProperty m_maxPixelHoles
130  {this, "maxPixelHoles", 5, "max number of Pixel holes"};
131  IntegerProperty m_maxSctHoles
132  {this, "maxSCTHoles", 5, "max number of SCT holes"};
133  IntegerProperty m_minTRTonTrk
134  {this, "minTRTonTrk", 9, "minimum number of TRT hits"};
135  DoubleProperty m_minTRTprecision
136  {this, "minTRTPrecisionFraction", 0.5, "minimum fraction of TRT precision hits"};
137  IntegerProperty m_minPixel
138  {this, "minPixel", 0, "minimum number of pixel clusters"};
139 
140  DoubleProperty m_maxRPhiImpEM
141  {this, "maxRPhiImpEM", 50., "maximal RPhi impact parameter cut track that match EM clusters"};
142  BooleanProperty m_useEmClusSeed{this, "doEmCaloSeed", true};
143  FloatProperty m_phiWidthEm{this, "phiWidthEM", 0.075};
144  FloatProperty m_etaWidthEm{this, "etaWidthEM", 0.05};
145 
147  {this, "EMROIPhiRZContainer", "", "Name of the calo cluster ROIs in Phi,R,Z parameterization"};
148 };
149 
150 
151 } // namespace InDet
152 
153 
154 #endif
InDet::InDetNNScoringTool::m_maxPixelHits
int m_maxPixelHits
Definition: InDetNNScoringTool.h:81
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
InDet::InDetNNScoringTool::m_maxPixLay
int m_maxPixLay
Definition: InDetNNScoringTool.h:82
InDet::InDetNNScoringTool::m_minPt
DoubleProperty m_minPt
cuts for selecting good tracks
Definition: InDetNNScoringTool.h:116
InDet::InDetNNScoringTool::calcNnScore
Trk::TrackScore calcNnScore(const Trk::Track &track, const Trk::TrackSummary &trackSum, const Trk::Perigee *extrapolatedPerigee) const
Definition: InDetNNScoringTool.cxx:815
InDet::InDetNNScoringTool::m_minTRTprecision
DoubleProperty m_minTRTprecision
Definition: InDetNNScoringTool.h:136
InDet::InDetNNScoringTool::passBasicSelections
virtual bool passBasicSelections(const Trk::Track &track) const override
check track selections independent from TrackSummary
Definition: InDetNNScoringTool.cxx:109
InDet::InDetNNScoringTool::m_boundsTrtFittedRatio
std::vector< double > m_boundsTrtFittedRatio
Definition: InDetNNScoringTool.h:86
InDet::InDetNNScoringTool::m_etaWidthEm
FloatProperty m_etaWidthEm
Definition: InDetNNScoringTool.h:144
InDet::InDetNNScoringTool::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: InDetNNScoringTool.h:95
TrackParameters.h
InDet::InDetNNScoringTool::m_maxHits
int m_maxHits
Definition: InDetNNScoringTool.h:80
InDet::InDetNNScoringTool::simpleScore
virtual Trk::TrackScore simpleScore(const Trk::Track &track, const Trk::TrackSummary &trackSum) const override
create a score based on how good the passed TrackSummary is
Definition: InDetNNScoringTool.cxx:193
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
InDet::InDetNNScoringTool::m_maxB_LayerHits
int m_maxB_LayerHits
Definition: InDetNNScoringTool.h:81
InDet::InDetNNScoringTool::m_DNN_inputValues
std::map< std::string, double > m_DNN_inputValues
Definition: InDetNNScoringTool.h:72
AtlasFieldCacheCondObj.h
InDet::InDetNNScoringTool::m_summaryTypeScore
std::vector< Trk::TrackScore > m_summaryTypeScore
holds the scores assigned to each Trk::SummaryType from the track's Trk::TrackSummary
Definition: InDetNNScoringTool.h:93
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
Trk::ITrackScoringTool
Interface for tool to return a score from a given track.
Definition: ITrackScoringTool.h:23
InDet::InDetNNScoringTool::m_maxDoubleHoles
IntegerProperty m_maxDoubleHoles
Definition: InDetNNScoringTool.h:126
InDet::InDetNNScoringTool::m_nnCutConfig
StringProperty m_nnCutConfig
Definition: InDetNNScoringTool.h:109
InDet::InDetNNScoringTool::isEmCaloCompatible
bool isEmCaloCompatible(const Trk::Track &track, const EventContext &ctx) const
Check if the cluster is compatible with a EM cluster.
Definition: InDetNNScoringTool.cxx:787
InDet::InDetNNScoringTool::m_maxSctHoles
IntegerProperty m_maxSctHoles
Definition: InDetNNScoringTool.h:132
InDet::InDetNNScoringTool::m_selectortool
ToolHandle< ITrtDriftCircleCutTool > m_selectortool
Returns minimum number of expected TRT drift circles depending on eta.
Definition: InDetNNScoringTool.h:90
InDet::InDetNNScoringTool::m_maxRPhiImp
DoubleProperty m_maxRPhiImp
Definition: InDetNNScoringTool.h:119
InDet::InDetNNScoringTool::m_useAmbigFcn
BooleanProperty m_useAmbigFcn
use the scoring tuned to Ambiguity processing or not
Definition: InDetNNScoringTool.h:105
ITrackScoringTool.h
SG::ReadHandleKey< ROIPhiRZContainer >
InDet::InDetNNScoringTool::m_usePixel
BooleanProperty m_usePixel
Definition: InDetNNScoringTool.h:112
InDet::InDetNNScoringTool::m_boundsSigmaChi2
std::vector< double > m_boundsSigmaChi2
Definition: InDetNNScoringTool.h:85
InDet::InDetNNScoringTool::m_factorSigmaChi2
std::vector< double > m_factorSigmaChi2
Definition: InDetNNScoringTool.h:84
InDet::InDetNNScoringTool::m_useEmClusSeed
BooleanProperty m_useEmClusSeed
Definition: InDetNNScoringTool.h:142
InDet::InDetNNScoringTool::m_maxGangedFakes
int m_maxGangedFakes
Definition: InDetNNScoringTool.h:82
InDet::InDetNNScoringTool::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: InDetNNScoringTool.h:98
InDet::InDetNNScoringTool::m_phiWidthEm
FloatProperty m_phiWidthEm
Definition: InDetNNScoringTool.h:143
InDet::InDetNNScoringTool::m_boundsTrtRatio
std::vector< double > m_boundsTrtRatio
Definition: InDetNNScoringTool.h:86
InDet::InDetNNScoringTool::m_factorB_LayerHits
std::vector< double > m_factorB_LayerHits
Definition: InDetNNScoringTool.h:84
InDet::InDetNNScoringTool::m_factorPixHoles
std::vector< double > m_factorPixHoles
Definition: InDetNNScoringTool.h:83
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDet::InDetNNScoringTool
Concrete implementation of the ITrackScoringTool pABC.
Definition: InDetNNScoringTool.h:49
AthAlgTool.h
AtlasFieldCache.h
Trk::TrackScore
float TrackScore
Definition: TrackScore.h:10
InDet::InDetNNScoringTool::m_maxSiHoles
IntegerProperty m_maxSiHoles
Definition: InDetNNScoringTool.h:128
InDet::InDetNNScoringTool::m_graph
std::unique_ptr< lwt::LightweightGraph > m_graph
Definition: InDetNNScoringTool.h:71
InDet::InDetNNScoringTool::m_factorSCT_Holes
std::vector< double > m_factorSCT_Holes
Definition: InDetNNScoringTool.h:83
InDet::InDetNNScoringTool::m_factorPixLay
std::vector< double > m_factorPixLay
Definition: InDetNNScoringTool.h:84
InDet::InDetNNScoringTool::m_factorGangedFakes
std::vector< double > m_factorGangedFakes
Definition: InDetNNScoringTool.h:84
ROIPhiRZContainer.h
InDet::InDetNNScoringTool::m_maxTrtRatio
int m_maxTrtRatio
Definition: InDetNNScoringTool.h:80
InDet::InDetNNScoringTool::m_factorTrtRatio
std::vector< double > m_factorTrtRatio
Definition: InDetNNScoringTool.h:86
InDet::InDetNNScoringTool::m_useSigmaChi2
BooleanProperty m_useSigmaChi2
Definition: InDetNNScoringTool.h:107
InDet::InDetNNScoringTool::ambigScore
Trk::TrackScore ambigScore(const Trk::Track &track, const Trk::TrackSummary &trackSum) const
Definition: InDetNNScoringTool.cxx:342
InDet::InDetNNScoringTool::m_maxPixelHoles
IntegerProperty m_maxPixelHoles
Definition: InDetNNScoringTool.h:130
InDet::InDetNNScoringTool::m_maxRPhiImpEM
DoubleProperty m_maxRPhiImpEM
Definition: InDetNNScoringTool.h:141
InDet::InDetNNScoringTool::m_maxDblHoles
int m_maxDblHoles
Definition: InDetNNScoringTool.h:79
InDet::InDetNNScoringTool::m_factorPixelHits
std::vector< double > m_factorPixelHits
Definition: InDetNNScoringTool.h:84
InDet::InDetNNScoringTool::m_factorDblHoles
std::vector< double > m_factorDblHoles
Definition: InDetNNScoringTool.h:83
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
InDet::InDetNNScoringTool::m_maxPixHoles
int m_maxPixHoles
Definition: InDetNNScoringTool.h:79
PathResolver.h
Trk::TrackSummary
A summary of the information contained by a track.
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:287
TrackScore.h
InDet::InDetNNScoringTool::m_caloClusterROIKey
SG::ReadHandleKey< ROIPhiRZContainer > m_caloClusterROIKey
Definition: InDetNNScoringTool.h:147
InDet::InDetNNScoringTool::m_factorHits
std::vector< double > m_factorHits
Definition: InDetNNScoringTool.h:83
InDet::InDetNNScoringTool::m_maxTrtFittedRatio
int m_maxTrtFittedRatio
Definition: InDetNNScoringTool.h:81
InDet::InDetNNScoringTool::~InDetNNScoringTool
virtual ~InDetNNScoringTool()=default
InDet::InDetNNScoringTool::m_useTRT_AmbigFcn
BooleanProperty m_useTRT_AmbigFcn
Definition: InDetNNScoringTool.h:106
InDet::InDetNNScoringTool::m_maxSigmaChi2
int m_maxSigmaChi2
Definition: InDetNNScoringTool.h:80
InDet::InDetNNScoringTool::m_maxSCT_Holes
int m_maxSCT_Holes
Definition: InDetNNScoringTool.h:79
SG::ReadCondHandleKey< InDet::BeamSpotData >
InDet::InDetNNScoringTool::m_maxZImp
DoubleProperty m_maxZImp
Definition: InDetNNScoringTool.h:121
InDet::InDetNNScoringTool::score
virtual Trk::TrackScore score(const Trk::Track &track, bool checkBasicSel) const override
create a score based on how good the passed track is
Definition: InDetNNScoringTool.cxx:176
InDet::InDetNNScoringTool::initialize
virtual StatusCode initialize() override
Definition: InDetNNScoringTool.cxx:58
InDet::InDetNNScoringTool::m_factorTrtFittedRatio
std::vector< double > m_factorTrtFittedRatio
Definition: InDetNNScoringTool.h:86
InDet::InDetNNScoringTool::InDetNNScoringTool
InDetNNScoringTool(const std::string &, const std::string &, const IInterface *)
Definition: InDetNNScoringTool.cxx:24
InDet::InDetNNScoringTool::m_maxEta
DoubleProperty m_maxEta
Definition: InDetNNScoringTool.h:117
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
IOVSvcDefs.h
defines and typedefs for IOVSvc
BeamSpotData.h
InDet::InDetNNScoringTool::m_useSCT
BooleanProperty m_useSCT
Definition: InDetNNScoringTool.h:113
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
InDet::InDetNNScoringTool::setupScoreModifiers
void setupScoreModifiers()
Definition: InDetNNScoringTool.cxx:561
AthAlgTool
Definition: AthAlgTool.h:26
InDet::InDetNNScoringTool::m_minPixel
IntegerProperty m_minPixel
Definition: InDetNNScoringTool.h:138
CLASS_DEF.h
macros to associate a CLID to a type
InDet::InDetNNScoringTool::m_minTRTonTrk
IntegerProperty m_minTRTonTrk
Definition: InDetNNScoringTool.h:134
InDet::InDetNNScoringTool::m_fieldCacheCondObjInputKey
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCacheCondObjInputKey
Definition: InDetNNScoringTool.h:101
InDet::InDetNNScoringTool::m_nnCutThreshold
DoubleProperty m_nnCutThreshold
Definition: InDetNNScoringTool.h:110
xAOD::TrackSummary
TrackSummary_v1 TrackSummary
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackSummary.h:10
InDet::InDetNNScoringTool::m_minSiClusters
IntegerProperty m_minSiClusters
Definition: InDetNNScoringTool.h:124