ATLAS Offline Software
AFPSiDBasicKalmanTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #ifndef AFP_LOCRECO_AFPSIDBASICKALMANTOOL_H
11 #define AFP_LOCRECO_AFPSIDBASICKALMANTOOL_H 1
12 
13 
14 #include <CLHEP/Matrix/Matrix.h>
15 #include <CLHEP/Matrix/Vector.h>
16 
17 // FrameWork includes
19 #include "GaudiKernel/ServiceHandle.h"
20 
21 // Monitoring includes
24 
25 // xAOD includes
31 
32 // AFP_LocReco includes
36 
37 // STL includes
38 #include <string>
39 #include <list>
40 #include <vector>
41 #include <utility> // pair
42 #include <algorithm> // sort
43 
44 
50  : public extends<AthAlgTool, IAFPSiDLocRecoTrackAlgTool>
51 {
52 public:
53  AFPSiDBasicKalmanTool(const std::string& type,
54  const std::string& name,
55  const IInterface* parent);
56 
57  virtual ~AFPSiDBasicKalmanTool() override {}
58 
60  virtual StatusCode initialize() override;
61 
63  virtual StatusCode finalize() override;
64 
73  StatusCode reconstructTracks(std::unique_ptr<xAOD::AFPTrackContainer>& outputContainer, const EventContext& ctx) const override;
74 
76  const std::string& outputContainerName () const override {return m_tracksContainerName;}
77 
86  void filterTrkCollection(std::list<AFPSiDBasicKalmanToolTrack>& reconstructedTracks) const;
87 
89  unsigned int countSharedClusters(const AFPSiDBasicKalmanToolTrack& firstTrack, const AFPSiDBasicKalmanToolTrack& secondTrack) const;
90 
92  void clearAllLayers(AFPLocRecoStationBasicObj& my_stationClusters) const
93  {my_stationClusters.clear();}
94 
95 
96 private:
97 
99  Gaudi::Property<std::string> m_tracksContainerName{this, "tracksContainerName", "AFPTrackContainer", "Name of the container in which tracks are saved"};
100 
102  Gaudi::Property<int> m_stationID{this, "stationID", 0, "ID number of station for which tracks should be reconstructed"};
103 
114  CLHEP::HepMatrix m_observationModel;
115 
119  Gaudi::Property<std::vector<float> > m_observationModelInit{this, "observationModel", {}, "vector used to initialise observation model matrix (2x4), the first four numbers correspond to the first row of the matrix"};
120 
130  CLHEP::HepMatrix m_observationNoise;
131 
135  Gaudi::Property<std::vector<float>> m_observationNoiseInit{this, "observationNoise", {}, "vector used to initialise observation noise matrix (2x2), the first two numbers correspond to the first row of the matrix"};
136 
137 
142  CLHEP::HepMatrix m_processNoiseCov;
143 
147  Gaudi::Property<std::vector<float>> m_processNoiseCovInit{this, "processNoiseCov", {}, "A vector used to initialise process noise covariance matrix (4x4).The first 4 numbers correspond to the first row of the matrix."};
148 
154  CLHEP::HepMatrix m_aposterioriCov;
155 
159  Gaudi::Property<std::vector<float>> m_aposterioriCovInit{this, "aposterioriCov", {}, "A vector used to initialise a posteriori covariance matrix (4x4). The first 4 numbers correspond to the first row of the matrix."};
160 
164  Gaudi::Property<int> m_numberOfLayersInStation{this, "numberOfLayersInStations", 4, "The size of the vector sets number of stations. Each element defines number of pixel layers in the station."};
165 
167  SG::ReadHandleKey<xAOD::AFPSiHitsClusterContainer> m_hitsClusterContainerKey{this, "AFPSiHitsClusterContainerKey", "AFPSiHitsClusterContainer", "Name of the container with clusters of hits from which tracks are to be reconstructed"};
168 
170  Gaudi::Property<double> m_maxAllowedDistance{this, "maxAllowedDistance", 10, "Maximal distance at which cluster can be joined to the track"};
171 
173  Gaudi::Property<unsigned int> m_minClustersNumber{this, "minClustersNumber", 3, "Minimal number of clusters in track. If there are less clusters track is rejected"};
174 
176  Gaudi::Property<unsigned int> m_maxSharedClusters{this, "maxSharedClusters", 2, "Maximal number of hits that two tracks can share. If they share more one is deleted."};
177 
179  Gaudi::Property<float> m_clusterMaxChi2{this, "clusterMaxChi2", 3, "Maximal value of chi2 for which a cluster is added."};
180 
182  Gaudi::Property<float> m_trackMaxChi2{this, "trackMaxChi2", 3, "Maximal value of chi2 for the track."};
183 
185  Gaudi::Property<double> m_allowedDistanceBetweenClustersInSeed{this, "allowedDistanceBetweenClustersInSeed", 0.5, "Maximum allowed distance between clusters in a seed to be considered coming from the same proton; if the difference between clusters is 2 layers (3 layers), this distance is multiplied by 2 (3)"};
186 
188  Gaudi::Property<std::vector<std::pair<int,int>>> m_layersForSeeds{this, "layersForSeeds", {{0,1}}, "Pairs of layers that are used to create seeds."};
189 
191  void fillLayersWithClusters(AFPLocRecoStationBasicObj& my_stationClusters, SG::ReadHandle<xAOD::AFPSiHitsClusterContainer>& hitsClusterContainer) const;
192 
201  void initMatrixFromVector (CLHEP::HepMatrix& matrix, const std::vector<float>& vec1D) const;
202 
204  bool checkMatrixAndVectorSize(const CLHEP::HepMatrix& matrix, const std::vector<float>& vec1D) const
205  {return ((int)vec1D.size()) == matrix.num_row()*matrix.num_col();}
206 
209  bool areNeighbours(const xAOD::AFPSiHitsCluster* a, const xAOD::AFPSiHitsCluster* b, const double dist) const;
210 
212  void saveToXAOD (const AFPSiDBasicKalmanToolTrack& recoTrack, std::unique_ptr<xAOD::AFPTrackContainer>& containerToFill, SG::ReadHandle<xAOD::AFPSiHitsClusterContainer>& hitsClusterContainer) const;
213 
215  ToolHandle<GenericMonitoringTool> m_monTool {this, "MonTool", "", "Monitoring tool"};
216 };
217 
218 
219 #endif // > !AFP_LOCRECO_AFPSIDBASICKALMANTOOL_H
AFPTrackContainer.h
AFPSiHitsCluster.h
AFPSiDBasicKalmanTool::reconstructTracks
StatusCode reconstructTracks(std::unique_ptr< xAOD::AFPTrackContainer > &outputContainer, const EventContext &ctx) const override
Does actual tracks reconstruction.
Definition: AFPSiDBasicKalmanTool.cxx:224
AFPLocRecoStationBasicObj::clear
void clear()
Clear clusters from each layer.
Definition: AFPLocRecoStationBasicObj.h:47
AFPSiDBasicKalmanTool::m_observationNoiseInit
Gaudi::Property< std::vector< float > > m_observationNoiseInit
A vector used to initialise m_observationNoise matrix.
Definition: AFPSiDBasicKalmanTool.h:135
AFPSiDBasicKalmanTool::m_processNoiseCovInit
Gaudi::Property< std::vector< float > > m_processNoiseCovInit
A vector used to initialise m_processNoiseCov matrix.
Definition: AFPSiDBasicKalmanTool.h:147
AFPSiDBasicKalmanTool::m_observationNoise
CLHEP::HepMatrix m_observationNoise
The observation noise matrix.
Definition: AFPSiDBasicKalmanTool.h:130
AFPSiDBasicKalmanTool::m_observationModel
CLHEP::HepMatrix m_observationModel
The observation model which maps the true state space into the observed space ( )
Definition: AFPSiDBasicKalmanTool.h:114
AFPSiDBasicKalmanTool::checkMatrixAndVectorSize
bool checkMatrixAndVectorSize(const CLHEP::HepMatrix &matrix, const std::vector< float > &vec1D) const
Returns true if vector size equals matrix rows times columns.
Definition: AFPSiDBasicKalmanTool.h:204
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AFPSiDBasicKalmanTool::m_allowedDistanceBetweenClustersInSeed
Gaudi::Property< double > m_allowedDistanceBetweenClustersInSeed
Maximum allowed distance between clusters to be considered coming from the same proton.
Definition: AFPSiDBasicKalmanTool.h:185
AFPSiDBasicKalmanTool::outputContainerName
const std::string & outputContainerName() const override
Definition: AFPSiDBasicKalmanTool.h:76
AFPSiDBasicKalmanTool::m_aposterioriCovInit
Gaudi::Property< std::vector< float > > m_aposterioriCovInit
A vector used to initialise m_aposterioriCov matrix.
Definition: AFPSiDBasicKalmanTool.h:159
AFPSiDBasicKalmanTool::m_processNoiseCov
CLHEP::HepMatrix m_processNoiseCov
The covariance matrix of process noise.
Definition: AFPSiDBasicKalmanTool.h:142
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
AFPSiDBasicKalmanTool::~AFPSiDBasicKalmanTool
virtual ~AFPSiDBasicKalmanTool() override
Definition: AFPSiDBasicKalmanTool.h:57
AFPSiDBasicKalmanTool::m_minClustersNumber
Gaudi::Property< unsigned int > m_minClustersNumber
Minimal number of clusters in track. If there are less clusters track is rejected (Default = 3)
Definition: AFPSiDBasicKalmanTool.h:173
AFPSiDBasicKalmanTool::finalize
virtual StatusCode finalize() override
Does nothing.
Definition: AFPSiDBasicKalmanTool.cxx:194
AFPSiDBasicKalmanTool::m_trackMaxChi2
Gaudi::Property< float > m_trackMaxChi2
Maximal value of chi2 for the track.
Definition: AFPSiDBasicKalmanTool.h:182
AFPSiDBasicKalmanTool::clearAllLayers
void clearAllLayers(AFPLocRecoStationBasicObj &my_stationClusters) const
clear all layers from clusters saved in #m_stationsClusters;
Definition: AFPSiDBasicKalmanTool.h:92
AFPTrackRecoAlgID.h
Definitions of identification numbers of track reconstruction algorithms.
AFPSiDBasicKalmanTool::m_aposterioriCov
CLHEP::HepMatrix m_aposterioriCov
A posteriori error covariance matrix (a measure of the estimated accuracy of the state estimate) ( )
Definition: AFPSiDBasicKalmanTool.h:154
AFPSiDBasicKalmanTool::m_layersForSeeds
Gaudi::Property< std::vector< std::pair< int, int > > > m_layersForSeeds
Vector of pairs of layers. These pairs will be used to make seeds.
Definition: AFPSiDBasicKalmanTool.h:188
AFPSiDBasicKalmanTool::saveToXAOD
void saveToXAOD(const AFPSiDBasicKalmanToolTrack &recoTrack, std::unique_ptr< xAOD::AFPTrackContainer > &containerToFill, SG::ReadHandle< xAOD::AFPSiHitsClusterContainer > &hitsClusterContainer) const
Save reconstructed track to the xAOD container.
Definition: AFPSiDBasicKalmanTool.cxx:321
AFPSiDBasicKalmanToolTrack.h
Header file for AFPSiDBasicKalmanToolTrack used in tracks reconstruction with Kalman filter.
GenericMonitoringTool.h
AFPSiDBasicKalmanTool::m_observationModelInit
Gaudi::Property< std::vector< float > > m_observationModelInit
A vector used to initialise m_observationModel matrix.
Definition: AFPSiDBasicKalmanTool.h:119
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AFPSiDBasicKalmanTool::m_maxSharedClusters
Gaudi::Property< unsigned int > m_maxSharedClusters
Maximal number of hits that two tracks can share. If they share more one is deleted.
Definition: AFPSiDBasicKalmanTool.h:176
AFPSiDBasicKalmanTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Monitoring.
Definition: AFPSiDBasicKalmanTool.h:215
AFPSiDBasicKalmanTool::m_tracksContainerName
Gaudi::Property< std::string > m_tracksContainerName
Name of the xAOD container to which tracks will be saved; actual saving is done in AFPSIDLocRecoTool.
Definition: AFPSiDBasicKalmanTool.h:99
AthAlgTool.h
AFPSiDBasicKalmanTool
Class reconstructing tracks using basic Kalman filter.
Definition: AFPSiDBasicKalmanTool.h:51
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AFPLocRecoStationBasicObj
Helper class representing an AFP station used in track reconstruction.
Definition: AFPLocRecoStationBasicObj.h:24
AFPSiHitsClusterContainer.h
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
AFPSiDBasicKalmanToolTrack
Class representing a reconstructed track with Kalman filter.
Definition: AFPSiDBasicKalmanToolTrack.h:24
AFPSiDBasicKalmanTool::m_maxAllowedDistance
Gaudi::Property< double > m_maxAllowedDistance
Maximal distance at which cluster can be joined to the track (Default = 100 - all clusters)
Definition: AFPSiDBasicKalmanTool.h:170
AFPSiDBasicKalmanTool::initialize
virtual StatusCode initialize() override
Read parameters from job options and print tool configuration.
Definition: AFPSiDBasicKalmanTool.cxx:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
AFPSiDBasicKalmanTool::fillLayersWithClusters
void fillLayersWithClusters(AFPLocRecoStationBasicObj &my_stationClusters, SG::ReadHandle< xAOD::AFPSiHitsClusterContainer > &hitsClusterContainer) const
Fills layers with clusters of hits, dividing them into stations and layers.
Definition: AFPSiDBasicKalmanTool.cxx:199
IAFPSiDLocRecoTrackAlgTool.h
Header file for interface IAFPSiDLocRecoTrackAlgTool.
AFPLocRecoStationBasicObj.h
Full implementation of class AFPLocRecoStationBasicObj.
AFPSiDBasicKalmanTool::countSharedClusters
unsigned int countSharedClusters(const AFPSiDBasicKalmanToolTrack &firstTrack, const AFPSiDBasicKalmanToolTrack &secondTrack) const
Returns number of the same clusters used to reconstruct two tracks.
Definition: AFPSiDBasicKalmanTool.cxx:410
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:66
AFPSiDBasicKalmanTool::m_hitsClusterContainerKey
SG::ReadHandleKey< xAOD::AFPSiHitsClusterContainer > m_hitsClusterContainerKey
Name of the xAOD container with clusters to be used in track reconstruction.
Definition: AFPSiDBasicKalmanTool.h:167
a
TList * a
Definition: liststreamerinfos.cxx:10
AFPSiDBasicKalmanTool::initMatrixFromVector
void initMatrixFromVector(CLHEP::HepMatrix &matrix, const std::vector< float > &vec1D) const
Method that initialises 2D matrix using values from the vector.
Definition: AFPSiDBasicKalmanTool.cxx:424
AFPSiDBasicKalmanTool::m_clusterMaxChi2
Gaudi::Property< float > m_clusterMaxChi2
Maximal value of chi2 for which a cluster is added.
Definition: AFPSiDBasicKalmanTool.h:179
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AFPSiDBasicKalmanTool::AFPSiDBasicKalmanTool
AFPSiDBasicKalmanTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: AFPSiDBasicKalmanTool.cxx:29
AFPSiDBasicKalmanTool::areNeighbours
bool areNeighbours(const xAOD::AFPSiHitsCluster *a, const xAOD::AFPSiHitsCluster *b, const double dist) const
Checks if clusters are neighbours Compares distance between them to m_allowedDistanceBetweenClustersI...
Definition: AFPSiDBasicKalmanTool.cxx:215
AFPSiDBasicKalmanTool::filterTrkCollection
void filterTrkCollection(std::list< AFPSiDBasicKalmanToolTrack > &reconstructedTracks) const
Filters duplicate tracks from the list.
Definition: AFPSiDBasicKalmanTool.cxx:350
xAOD::AFPSiHitsCluster_v1
Class representing a cluster of AFP pixel hits.
Definition: AFPSiHitsCluster_v1.h:32
AFPSiDBasicKalmanTool::m_numberOfLayersInStation
Gaudi::Property< int > m_numberOfLayersInStation
Number of layers used for reconstruction in station If not set in job options 4 stations,...
Definition: AFPSiDBasicKalmanTool.h:164
AFPSiDBasicKalmanTool::m_stationID
Gaudi::Property< int > m_stationID
AFP station ID for which tracks will be reconstructed.
Definition: AFPSiDBasicKalmanTool.h:102
AFPTrackAuxContainer.h