16#include "GaudiKernel/IToolSvc.h"
17#include "CLHEP/Units/SystemOfUnits.h"
30 const std::string& name,
31 const IInterface* parent ) :
32 base_class(
type, name, parent )
69 const double pixelSizeX = 0.05;
70 const double pixelSizeY = 0.25;
93 const float planesZDist = 9.;
95 const float pixelSizeX = 0.05;
97 m_aposterioriCov[1][1] = pixelSizeX * pixelSizeX / (planesZDist*planesZDist*3.);
99 const float pixelSizeY = 0.25;
101 m_aposterioriCov[3][3] = pixelSizeY * pixelSizeY / (planesZDist*planesZDist*3.);
114 return StatusCode::FAILURE;
120 ATH_MSG_ERROR(
"Impossible to make seeds when length of m_layersForSeeds is 0 ");
121 return StatusCode::FAILURE;
126 if(lfs->first == lfs->second)
128 ATH_MSG_WARNING(
"Both layer IDs in m_layersForSeeds are equal to "<<lfs->first<<
", removing this pair of layer IDs");
138 if(lfs->first > lfs->second)
140 ATH_MSG_INFO(
"The first layer ID for seeds ("<<lfs->first<<
") is higher than the second layer ID ("<<lfs->second<<
"), swapping");
142 lfs->first=lfs->second;
159 ATH_MSG_WARNING(
"Found duplicity for {"<<lfs2->first<<
","<<lfs2->second<<
"}, removing the duplicity");
172 ATH_MSG_ERROR(
"Nothing is left in m_layersForSeeds after cleaning, please fix the setup");
173 return StatusCode::FAILURE;
176 std::string stringLayersForSeeds=
"{";
179 stringLayersForSeeds+=
"{"+std::to_string(lfs->first)+
","+std::to_string(lfs->second)+
"},";
181 stringLayersForSeeds.pop_back();
182 ATH_MSG_DEBUG(
"Pairs of layer IDs that will make track seeds = "<<stringLayersForSeeds<<
"}");
191 return StatusCode::SUCCESS;
196 return StatusCode::SUCCESS;
206 my_stationClusters.
clustersInLayer(theCluster->pixelLayerID()).push_back(theCluster);
208 catch (
const std::out_of_range& outOfRange) {
209 ATH_MSG_WARNING(
"Cluster with station or pixel ID outside expected range. Aborting track reconstruction.");
217 const double dx = a->xLocal() - b->xLocal();
218 const double dy = a->yLocal() - b->yLocal();
219 const double maxDistanceSq = allowedDistanceBetweenClustersInSeed * allowedDistanceBetweenClustersInSeed;
221 return dx * dx + dy * dy <= maxDistanceSq;
227 if(!hitsClusterContainer.
isValid())
230 return StatusCode::SUCCESS;
234 using LayersIter_t = std::vector<std::vector<const xAOD::AFPSiHitsCluster *>>
::const_iterator;
237 std::list<AFPSiDBasicKalmanToolTrack> reconstructedTracks;
253 const LayersIter_t layersEnd = my_stationClusters.
layers().end();
254 const LayersIter_t layersBegin = my_stationClusters.
layers().begin();
257 LayersIter_t firstLayer = layersBegin+layersForSeeds->first;
258 LayersIter_t secondLayer = layersBegin+layersForSeeds->second;
275 for (LayersIter_t remainingLayersIT = layersBegin; remainingLayersIT != layersEnd; ++remainingLayersIT)
277 if(remainingLayersIT==firstLayer || remainingLayersIT==secondLayer)
continue;
280 if (closestCluster !=
nullptr)
290 reconstructedTracks.pop_back();
301 saveToXAOD(track, outputContainer, hitsClusterContainer);
316 Monitored::Group(
m_monTool, trkStationID, trkXLocal, trkYLocal, trkZLocal, trkXSlope, trkYSlope, trkNClusters, trkNHoles, trkChi2, trkMask);
318 return StatusCode::SUCCESS;
323 auto *track = containerToFill->push_back(std::make_unique<xAOD::AFPTrack>());
328 track->setStationID(firstCluster->
stationID());
329 track->setXLocal(firstPoint[0]);
330 track->setYLocal(firstPoint[2]);
331 track->setZLocal(firstCluster->
zLocal());
332 track->setXSlope(firstPoint[1]);
333 track->setYSlope(firstPoint[3]);
335 track->setNHoles(recoTrack.
holes());
340 ATH_MSG_DEBUG(
"Track position: (x="<<track->xLocal()<<
", y="<<track->yLocal()<<
", z="<<track->zLocal()<<
") slope: (dx="<<track->xSlope()<<
", dy="<<track->ySlope()<<
") chi2="<<track->chi2()<<
", nHoles="<<track->nHoles()<<
", nClusters="<<track->nClusters());
344 track->addCluster(clusterLink);
346 ATH_MSG_DEBUG(
"cluster position: (x="<<theCluster->xLocal()<<
", y="<<theCluster->yLocal()<<
", z="<<theCluster->zLocal()<<
")");
353 std::list<AFPSiDBasicKalmanToolTrack>::iterator mainIterator = tracksList.begin();
354 while (mainIterator != tracksList.end()) {
356 bool deletedMain =
false;
358 std::list<AFPSiDBasicKalmanToolTrack>::iterator compareIterator = mainIterator;
360 while (compareIterator != tracksList.end())
363 bool removeMain =
false;
364 bool removeCompare =
false;
374 if(mainTrkQuality >= compareTrkQuality)
376 removeCompare =
true;
383 else if(sharedClusters == mainIterator->clustersInTrack().size() && sharedClusters == compareIterator->clustersInTrack().size())
386 removeCompare =
true;
391 tracksList.erase(compareIterator++);
396 tracksList.erase(mainIterator++);
405 if (!deletedMain) ++mainIterator;
412 unsigned int sharedClustersN = 0;
416 if (firstCluster == secondCluster) {
421 return sharedClustersN;
426 const int rowsN = matrix.num_row();
427 const int columnsN = matrix.num_col();
430 if ( ((
int)vec1D.size()) == rowsN*columnsN) {
432 for (
int rowID = 0; rowID < rowsN; rowID++)
433 for (
int columnID = 0; columnID < columnsN; columnID++)
434 matrix[rowID][columnID] = vec1D[rowID*columnsN + columnID];
438 std::stringstream warningMessage;
439 warningMessage<<
"Matrix size ("<<rowsN<<
"x"<<columnsN
440 <<
" = "<<rowsN*columnsN<<
") is not compatible with vector size: "
442 warningMessage<<
"Matrix will not be initialised. The vector contains following numbers: ";
443 for (
const float number : vec1D)
444 warningMessage<<
number<<
" ";
#define ATH_MSG_WARNING(x)
#define CHECK(...)
Evaluate an expression and check for errors.
Helper class representing an AFP station used in track reconstruction.
std::vector< const xAOD::AFPSiHitsCluster * > & clustersInLayer(const unsigned int layerID)
Returns vector of clusters in the layer with given ID.
void setNumberOfLayers(const unsigned int layersN)
Sets vector containing layers to the specified size.
std::vector< std::vector< const xAOD::AFPSiHitsCluster * > > & layers()
Returns vector layers, each layer is a vector of clusters.
ElementLink implementation for ROOT usage.
bool toContainedElement(BaseConstReference data, ElementType element, IProxyDict *sg=0)
Set from element pointer and a reference to the container (storable)
Group of local monitoring quantities and retain correlation when filling histograms
virtual bool isValid() override final
Can the handle be successfully dereferenced?
float zLocal() const
Cluster position along Z axis in station local coordinate system.
int stationID() const
Index of the station with pixels cluster.
static constexpr int basicKalman
basic Kalman algorithm id=0
float xLocal() const
Track position along X axis in station local coordinate system.
int stationID() const
Index of the station where track was reconstructed.
float xSlope() const
Slope of the reconstructed track along X axis in local coordinate system.
float yLocal() const
Track position along Y axis in station local coordinate system.
float chi2() const
value of the track fit to the selected clusters.
int nClusters() const
Number of clusters used to reconstruct the track.
float ySlope() const
Slope of the reconstructed track along Y axis in local coordinate system.
unsigned int nHoles() const
Number of empty layers that the track passes through.
float zLocal() const
Track position along Z axis in station local coordinate system.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
AFPSiHitsCluster_v1 AFPSiHitsCluster
std::string number(const double &d, const std::string &s)