14 const std::string& name, ISvcLocator* pSvcLocator)
35 ATH_MSG_ERROR(
"Use either track finder or track reader, not both.");
36 return StatusCode::FAILURE;
53 ATH_MSG_INFO(
"Applying the following cuts during GNN-based track reconstruction: ");
62 ATH_MSG_INFO(
"Applying the following eta dependant track cuts after GNN-based track reconstruction: ");
63 std::vector <double> etaBins, minPT, maxz0, maxd0;
64 std::vector <int> minClusters, minPixelHits, maxHoles;
81 return StatusCode::SUCCESS;
90 uint32_t runNumber = ctx.eventID().run_number();
91 uint32_t eventNumber = ctx.eventID().event_number();
97 std::vector<const Trk::PrepRawData*> allClusters =
getClustersInEvent(ctx, eventNumber);
100 std::vector<std::vector<uint32_t> > TT;
101 std::vector<std::vector<uint32_t> > clusterTracks;
110 ATH_MSG_ERROR(
"Both GNNTrackFinder and GNNTrackReader are not set");
111 return StatusCode::FAILURE;
114 ATH_MSG_DEBUG(
"Event " << eventNumber <<
" obtained " << TT.size() <<
" Tracks");
118 int trackCounter = -1;
119 std::vector<int> status_codes;
121 for (
auto& trackIndices : TT) {
126 std::vector<const Trk::SpacePoint*> trackCandidate =
getSpacePoints(trackIndices, spacePoints);
131 getClusters (clusterTracks, allClusters, trackCounter)
141 auto [fitSuccess, passTrackCut, track] =
doFitAndCut(ctx, trackCandidate, clusters, trackCounter);
143 if (not fitSuccess) {
147 if (passTrackCut <= 0) {
148 outputTracks->push_back(track.release());
151 status_codes.push_back(passTrackCut);
156 ATH_MSG_INFO(
"Event " << eventNumber <<
" has " << status_codes.size() <<
" tracks found, "
157 << std::count(status_codes.begin(), status_codes.end(), 0)
158 <<
" tracks remains after applying track cuts");
160 ATH_MSG_INFO(
"Event " << eventNumber <<
" has " << status_codes.size() <<
" tracks found, all tracks are kept");
163 return StatusCode::SUCCESS;
174 const Trk::Perigee* origPerigee = track.perigeeParameters();
175 double pt = origPerigee->
pT();
177 double eta = std::abs(origPerigee->
eta());
179 double d0 = std::abs(origPerigee->parameters()[
Trk::d0]);
181 double z0 = std::abs(origPerigee->parameters()[
Trk::z0]);
188 int nClusters = nPixels + nStrips;
190 ATH_MSG_DEBUG(
"track params: " << pt <<
" " <<
eta <<
" " << d0 <<
" " << z0
191 <<
" " << nClusters << nStrips
195 if (nClusters < m_etaDependentCutsSvc->getMinSiHitsAtEta(
eta))
199 if (nPixels < m_etaDependentCutsSvc->getMinPixelHitsAtEta(
eta))
203 if (pt < m_etaDependentCutsSvc->getMinPtAtEta(
eta))
222 const EventContext& ctx,
225 std::vector<const Trk::SpacePoint*> spacePoints;
227 int npixsp(0), nstrip(0), n_overlap(0);
229 spacePoints.push_back(
sp);
233 spacePoints.push_back(
sp);
237 spacePoints.push_back(
sp);
241 <<
" pixel space points, " << nstrip
242 <<
" strips space points" << n_overlap
243 <<
" overlapping spacepoints" << spacePoints.size()
250 const EventContext& ctx,
253 std::vector<const Trk::SpacePoint*> spacePoints;
254 if (not containerKey.
empty()){
262 for(; spc != spce; ++spc){
264 auto sp = spCollection->
begin();
265 auto spe = spCollection->
end();
266 for(;
sp != spe; ++
sp) {
268 spacePoints.push_back(spacePoint);
278 const EventContext& ctx,
282 std::vector<const Trk::SpacePoint*> spacePoints;
284 if (not containerKey.
empty()){
290 spacePoints.push_back(
sp);
299 const EventContext& ctx,
302 std::vector<const Trk::PrepRawData*> allClusters;
314 if (!strip_container.
isValid()) {
319 auto pixcollection = pixcontainer->begin();
320 auto pixcollectionEnd = pixcontainer->end();
321 for (; pixcollection != pixcollectionEnd; ++pixcollection) {
322 if ((*pixcollection)->empty()) {
326 auto const* clusterCollection = (*pixcollection);
327 auto thisCluster = clusterCollection->begin();
328 auto clusterEnd = clusterCollection->end();
329 for (; thisCluster != clusterEnd; ++thisCluster) {
331 allClusters.push_back(cl);
335 auto strip_collection = strip_container->begin();
336 auto strip_collectionEnd = strip_container->end();
337 for (; strip_collection != strip_collectionEnd; ++strip_collection) {
338 if ((*strip_collection)->empty()) {
342 auto const* clusterCollection = (*strip_collection);
343 auto thisCluster = clusterCollection->begin();
344 auto clusterEnd = clusterCollection->end();
345 for (; thisCluster != clusterEnd; ++thisCluster) {
347 allClusters.push_back(cl);
351 ATH_MSG_DEBUG(
"Event " << eventNumber <<
" has " << allClusters.size()
359 const std::vector<uint32_t>& trackIndices,
360 const std::vector<const Trk::SpacePoint*>& allSpacePoints
363 std::vector<const Trk::SpacePoint*> trackCandidate;
364 trackCandidate.reserve(trackIndices.size());
366 std::vector<std::pair<double, const Trk::SpacePoint*> > distanceSortedSPs;
370 for (
auto&
id : trackIndices) {
372 if (
id > allSpacePoints.size()) {
374 <<
id <<
" out of range: " << allSpacePoints.size());
382 distanceSortedSPs.push_back(
384 pow(
sp->globalPosition().x(), 2) +
pow(
sp->globalPosition().y(), 2),
392 std::sort(distanceSortedSPs.begin(), distanceSortedSPs.end());
395 for (
size_t i = 0; i < distanceSortedSPs.size(); i++) {
396 trackCandidate.push_back(distanceSortedSPs[i].second);
399 return trackCandidate;
402std::vector<const Trk::PrepRawData*> InDet::SiSPGNNTrackMaker :: spacePointsToClusters (
403 const std::vector<const Trk::SpacePoint*>& spacePoints
405 std::vector<const Trk::PrepRawData*> clusters;
407 clusters.push_back(
sp->clusterList().first);
408 if (
sp->clusterList().second !=
nullptr) {
409 clusters.push_back(
sp->clusterList().second);
415std::vector<const Trk::PrepRawData*> InDet::SiSPGNNTrackMaker :: getClusters (
416 const std::vector<std::vector<uint32_t>>& clusterTracks,
417 const std::vector<const Trk::PrepRawData*>& allClusters,
420 std::vector<uint32_t> clusterIndices = clusterTracks[trackNumber];
421 std::vector<const Trk::PrepRawData*> clusters;
422 clusters.reserve(clusterIndices.size());
423 for (uint32_t
id : clusterIndices) {
424 if (
id > allClusters.size()) {
428 clusters.push_back(allClusters[
id]);
467 const EventContext& ctx,
468 std::vector<const Trk::SpacePoint*>& spacePoints,
469 std::vector<const Trk::PrepRawData*>& clusters,
474 int nPIX(0), nStrip(0);
481 ATH_MSG_DEBUG(
"Track " << trackCounter <<
" has " << spacePoints.size()
482 <<
" space points, " << clusters.size()
483 <<
" clusters, " << nPIX <<
" pixel clusters, "
484 << nStrip <<
" strip clusters");
487 if (not
prefitCheck(nPIX, nStrip, clusters.size(), spacePoints.size())) {
488 ATH_MSG_DEBUG(
"Track " << trackCounter <<
" does not pass prefit cuts, skipping");
489 return std::make_tuple(
false, 999,
nullptr);
494 if (trkParameters ==
nullptr) {
496 return std::make_tuple(
false, 999,
nullptr);
499 std::unique_ptr<Trk::Track> track =
fitTrack(ctx, clusters, *trkParameters, trackCounter);
501 if (track ==
nullptr || track->perigeeParameters() ==
nullptr) {
503 <<
" fails the chi2 fit, skipping");
504 return std::make_tuple(
false, 999,
nullptr);
508 if (track->perigeeParameters()->pT() <
m_pTmin) {
510 <<
"with pt = " << track->perigeeParameters()->pT()
511 <<
" has pT too low, skipping track!");
512 return std::make_tuple(
false, 999,
nullptr);
516 if (std::abs(track->perigeeParameters()->eta()) >
m_etamax) {
518 << std::abs(track->perigeeParameters()->eta())
519 <<
" has eta too high, skipping track!");
520 return std::make_tuple(
false, 999,
nullptr);
529 return std::make_tuple(
true, passTrackCut, std::move(track));
534 const EventContext& ctx,
535 std::vector<const Trk::PrepRawData*> clusters,
543 bool keepOnTrying =
true;
544 std::unique_ptr<Trk::Track> track;
545 while (keepOnTrying) {
546 track =
m_trackFitter->fit(ctx, clusters, initial_params,
false, matEffects);
548 if (track ==
nullptr || track->perigeeParameters() ==
nullptr) {
551 keepOnTrying =
false;
554 keepOnTrying =
false;
558 if (track ==
nullptr || track->perigeeParameters() ==
nullptr) {
560 <<
" fails the first chi2 fit, skipping");
565 if (track->perigeeParameters()->pT() <
m_pTmin) {
567 <<
" fails the first chi2 fit, skipping");
574 while (keepOnTrying) {
575 track =
m_trackFitter->fit(ctx, clusters, origPerigee,
true, matEffects);
578 if (track ==
nullptr || track->trackSummary() ==
nullptr || track->outliersOnTrack()->size()>=3) {
592 <<
" fails the second chi2 fit, skipping");
602MsgStream& InDet::operator <<
611std::ostream& InDet::operator <<
634 out<<
"| Location of output tracks | "
636 out<<
"|----------------------------------------------------------------"
637 <<
"----------------------------------------------------|"
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
constexpr int pow(int base, int exp) noexcept
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
InDet::SiSPGNNTrackMaker is an algorithm that uses the GNN-based track finding tool to reconstruct tr...
ToolHandle< ISeedFitter > m_seedFitter
MsgStream & dump(MsgStream &out) const
std::unique_ptr< Trk::Track > fitTrack(const EventContext &ctx, std::vector< const Trk::PrepRawData * > clusters, const Trk::TrackParameters &initial_params, int trackCounter) const
UnsignedIntegerProperty m_minStripClusters
ToolHandle< IGNNTrackReaderTool > m_gnnTrackReader
SG::ReadHandleKey< InDet::PixelClusterContainer > m_ClusterPixelKey
BooleanProperty m_doRecoverFailedFits
std::vector< const Trk::SpacePoint * > getSpacePoints(const std::vector< uint32_t > &trackIndices, const std::vector< const Trk::SpacePoint * > &allSpacePoints) const
SG::ReadHandleKey< InDet::SCT_ClusterContainer > m_ClusterStripKey
UnsignedIntegerProperty m_minPixelClusters
BooleanProperty m_doRecoTrackCuts
BooleanProperty m_areInputClusters
int passEtaDepCuts(const Trk::Track &track) const
SiSPGNNTrackMaker(const std::string &name, ISvcLocator *pSvcLocator)
ServiceHandle< IInDetEtaDependentCutsSvc > m_etaDependentCutsSvc
std::vector< const Trk::PrepRawData * > getClustersInEvent(const EventContext &ctx, int eventNumber) const
SG::WriteHandleKey< TrackCollection > m_outputTracksKey
std::vector< const Trk::PrepRawData * > spacePointsToClusters(const std::vector< const Trk::SpacePoint * > &spacePoints) const
ToolHandle< Trk::ITrackFitter > m_trackFitter
Track Fitter.
SG::ReadHandleKey< SpacePointContainer > m_SpacePointsSCTKey
MsgStream & dumpevent(MsgStream &out) const
virtual StatusCode initialize() override
ToolHandle< IGNNTrackFinder > m_gnnTrackFinder
GNN-based track finding tool that produces track candidates.
bool prefitCheck(unsigned int nPix, unsigned int nStrip, unsigned int nClusters, unsigned int nSpacePoints) const
std::vector< const Trk::SpacePoint * > getSpacePointsInEvent(const EventContext &ctx, int eventNumber) const
UnsignedIntegerProperty m_minClusters
virtual StatusCode execute(const EventContext &ctx) const override
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trackSummaryTool
std::vector< const Trk::PrepRawData * > getClusters(const std::vector< std::vector< uint32_t > > &clusterTracks, const std::vector< const Trk::PrepRawData * > &allClusters, int trackNumber) const
SG::ReadHandleKey< SpacePointOverlapCollection > m_SpacePointsOverlapKey
SG::ReadHandleKey< SpacePointContainer > m_SpacePointsPixelKey
std::tuple< bool, int, std::unique_ptr< Trk::Track > > doFitAndCut(const EventContext &ctx, std::vector< const Trk::SpacePoint * > &spacePoints, std::vector< const Trk::PrepRawData * > &clusters, int &trackCounter) const
Fits a track and applies quality cuts to determine if it should be kept.
MsgStream & dumptools(MsgStream &out) const
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
bool empty() const
Test if the key is blank.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
double eta() const
Access method for pseudorapidity - from momentum.
double pT() const
Access method for transverse momentum.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters
@ numberOfSCTHits
number of SCT holes
@ numberOfPixelHits
number of pixel layers on track with absence of hits
@ numberOfSCTHoles
number of Holes in both sides of a SCT module
@ numberOfPixelHoles
number of pixels which have a ganged ambiguity.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.