5 #ifndef SICLUSTERIZATIONTOOL_NnClusterizationFactory_C
6 #define SICLUSTERIZATIONTOOL_NnClusterizationFactory_C
22#include "GaudiKernel/ToolHandle.h"
23#include "GaudiKernel/ServiceHandle.h"
39#include <RtypesCore.h>
53 class LightweightGraph;
57 class NeuralNetworkToHistoTool;
70 operator bool()
const {
97 const std::string& n,
const IInterface* p);
101 virtual StatusCode
finalize()
override {
return StatusCode::SUCCESS; };
113 std::vector<Amg::MatrixX> & errors,
114 int numberSubClusters)
const;
120 std::vector<Amg::MatrixX> & errors,
121 int numberSubClusters)
const;
131 const std::vector<double>& inputData)
const;
142 const std::vector<double>& inputData,
145 int numberSubClusters,
146 std::vector<Amg::MatrixX> & errors)
const;
155 int numberSubClusters,
156 std::vector<Amg::MatrixX> & errors)
const;
160 const Eigen::VectorXd& input)
const;
164 const Eigen::VectorXd& input,
167 int numberSubClusters,
168 std::vector<Amg::MatrixX>& errors)
const;
173 double correctedRMSY(
double posPixels, std::vector<float>& pitches)
const;
178 double & tanl)
const;
183 const double tanl)
const;
199 std::vector<double>& outputY,
200 std::vector<Amg::MatrixX>& errorMatrix,
201 int nParticles)
const;
205 {
this,
"NetworkOrder", {
210 "ImpactPointErrorsX1",
211 "ImpactPointErrorsX2",
212 "ImpactPointErrorsX3",
213 "ImpactPointErrorsY1",
214 "ImpactPointErrorsY2",
215 "ImpactPointErrorsY3"},
216 "The order in which the networks will appear in the TTrainedNetworkCollection"};
223 static constexpr std::array<std::string_view, kNNetworkTypes>
s_nnTypeNames{
229 static const std::array<std::regex, kNNetworkTypes>
m_nnNames;
232 std::vector< std::vector<unsigned int> >
m_NNId{};
250 {
this,
"PixelLorentzAngleTool",
"SiLorentzAngleTool/PixelLorentzAngleTool",
"Tool to retreive Lorentz angle of Pixel"};
253 {
this,
"PixelChargeCalibCondData",
"PixelChargeCalibCondData",
"Output key"};
256 {
this,
"NnCollectionReadKey",
"PixelClusterNN",
"The conditions store key for the pixel cluster NNs"};
259 {
this,
"NnCollectionWithTrackReadKey",
"PixelClusterNNWithTrack",
260 "The conditions store key for the pixel cluster NNs which needs tracks as input"};
263 {
this,
"NnCollectionJSONReadKey",
"PixelClusterNNJSON",
264 "The conditions key for the pixel cluster NNs configured via JSON file and accessed with lwtnn"};
271 {
this,
"OutputNodePos1", 7,
272 "Output node for the 1 position networks (LWTNN)"};
275 {
this,
"OutputNodePos2", { 10, 11 },
276 "List of output nodes for the 2 position network (LWTNN)"};
279 {
this,
"OutputNodePos3", { 13, 14, 15 },
280 "List of output nodes for the 3 position networks (LWTNN)"};
283 {
this,
"MaxSubClusters", 3,
"Maximum number of sub cluster supported by the networks." };
286 {
this,
"correctLorShiftBarrelWithoutTracks",0.,
"Lorentz shift correction factor when evaluating NN without track input."};
289 {
this,
"correctLorShiftBarrelWithTracks",0.,
"Lorentz shift correction factor when evaluating NN with track input."};
292 {
this,
"useToT",
true,
"Use Tot rather than charge." };
295 {
this,
"addIBL",
false,
"Also apply to clusters in IBL." };
298 {
this,
"doRunI",
false,
"Use runI style network (outputs are not normalised; add pitches; use charge if not m_useToT)"};
301 {
this,
"NnCollectionONNXReadKey",
"",
302 "The conditions key for ONNX-based pixel cluster NNs"};
305 {
this,
"useONNX",
false,
"Use ONNX models instead of LWTNN for NN inference."};
308 {
this,
"useTTrainedNetworks",
false,
"Use earlier (release-21-like) neural networks stored in ROOT files and accessed via TTrainedNetowrk."};
311 {
this,
"useRecenteringNNWithoutTracks",
false,
"Recenter x position when evaluating NN without track input."};
314 {
this,
"useRecenteringNNWithTracks",
false,
"Recenter x position when evaluating NN with track input."};
317 {
this,
"sizeX",7,
"Size of pixel matrix along X"};
320 {
this,
"sizeY",7,
"Size of pixel matrix along Y"};
Store pixel constant parameters in PixelModuleData.
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
std::vector< Double_t > ReturnType
std::vector< double > assembleInputRunII(NNinput &input) const
void addTrackInfoToInput(NNinput &input, const Trk::Surface &pixelSurface, const Trk::TrackParameters &trackParsAtSurface, const double tanl) const
Gaudi::Property< unsigned int > m_maxSubClusters
SG::ReadCondHandleKey< PixelChargeCalibCondData > m_chargeDataKey
std::vector< double > estimateNumberOfParticlesLWTNN(NnClusterizationFactory::InputVector &input) const
virtual StatusCode finalize() override
std::vector< Amg::Vector2D > estimatePositionsONNX(const Eigen::VectorXd &input, NNinput &rawInput, const InDet::PixelCluster &pCluster, int numberSubClusters, std::vector< Amg::MatrixX > &errors) const
Gaudi::Property< unsigned int > m_sizeX
~NnClusterizationFactory()=default
double correctedRMSY(double posPixels, std::vector< float > &pitches) const
ReturnType(::TTrainedNetwork::* m_calculateOutput)(const InputType &input) const
NNinput createInput(const InDet::PixelCluster &pCluster, Amg::Vector3D &beamSpotPosition, double &tanl) const
Gaudi::Property< bool > m_useONNX
virtual StatusCode initialize() override
Gaudi::Property< double > m_correctLorShiftBarrelWithoutTracks
static const InterfaceID & interfaceID()
AlgTool interface methods.
Gaudi::Property< std::size_t > m_outputNodesPos1
Gaudi::Property< std::vector< std::size_t > > m_outputNodesPos2
ToolHandle< ISiLorentzAngleTool > m_pixelLorentzAngleTool
Gaudi::Property< bool > m_useToT
Gaudi::Property< std::vector< std::size_t > > m_outputNodesPos3
std::vector< Amg::Vector2D > estimatePositionsLWTNN(NnClusterizationFactory::InputVector &input, NNinput &rawInput, const InDet::PixelCluster &pCluster, int numberSubClusters, std::vector< Amg::MatrixX > &errors) const
SG::ReadCondHandleKey< OnnxNNCollection > m_readKeyONNX
std::vector< double > assembleInputRunI(NNinput &input) const
SG::ReadCondHandleKey< LWTNNCollection > m_readKeyJSON
std::vector< Amg::Vector2D > estimatePositions(const InDet::PixelCluster &pCluster, Amg::Vector3D &beamSpotPosition, std::vector< Amg::MatrixX > &errors, int numberSubClusters) const
Gaudi::Property< std::vector< std::string > > m_nnOrder
Gaudi::Property< double > m_correctLorShiftBarrelWithTracks
Gaudi::Property< bool > m_useTTrainedNetworks
std::vector< double > estimateNumberOfParticlesTTN(const TTrainedNetworkCollection &nn_collection, const std::vector< double > &inputData) const
static constexpr std::array< unsigned int, kNNetworkTypes > m_nParticleGroup
unsigned int m_nParticleNNId
SG::ReadCondHandleKey< TTrainedNetworkCollection > m_readKeyWithoutTrack
std::vector< double >(InDet::NnClusterizationFactory::* m_assembleInput)(NNinput &input) const
std::vector< Eigen::VectorXd > InputVector
NnClusterizationFactory(const std::string &name, const std::string &n, const IInterface *p)
std::vector< Amg::Vector2D > estimatePositionsTTN(const TTrainedNetworkCollection &nn_collection, const std::vector< double > &inputData, const NNinput &input, const InDet::PixelCluster &pCluster, int numberSubClusters, std::vector< Amg::MatrixX > &errors) const
Gaudi::Property< bool > m_doRunI
static const std::array< std::regex, kNNetworkTypes > m_nnNames
Gaudi::Property< bool > m_useRecenteringNNWithouTracks
static constexpr std::array< std::string_view, kNNetworkTypes > s_nnTypeNames
InputVector eigenInput(NNinput &input) const
void getErrorMatrixFromOutput(std::vector< double > &outputX, std::vector< double > &outputY, std::vector< Amg::MatrixX > &errorMatrix, int nParticles) const
std::vector< Double_t > InputType
Gaudi::Property< bool > m_useRecenteringNNWithTracks
std::vector< std::vector< unsigned int > > m_NNId
std::vector< Amg::Vector2D > getPositionsFromOutput(std::vector< double > &output, const NNinput &input, const InDet::PixelCluster &pCluster) const
static double correctedRMSX(double posPixels)
size_t calculateVectorDimension(const bool useTrackInfo) const
Gaudi::Property< unsigned int > m_sizeY
Gaudi::Property< bool > m_addIBL
SG::ReadCondHandleKey< TTrainedNetworkCollection > m_readKeyWithTrack
std::vector< double > estimateNumberOfParticlesONNX(const Eigen::VectorXd &input) const
std::vector< double > estimateNumberOfParticles(const InDet::PixelCluster &pCluster, Amg::Vector3D &beamSpotPosition) const
DVec calculateNormalized(const DVec &input) const
Abstract Base Class for tracking surfaces.
Eigen::Matrix< double, 3, 1 > Vector3D
static const InterfaceID IID_NnClusterizationFactory("InDet::NnClusterizationFactory", 1, 0)
Ensure that the ATLAS eigen extensions are properly loaded.
ParametersBase< TrackParametersDim, Charged > TrackParameters