From 2fd536526035121aee829b8378526055e297f3f6 Mon Sep 17 00:00:00 2001 From: Andy Haas <ahaas@cern.ch> Date: Fri, 30 Jun 2017 05:21:53 -0400 Subject: [PATCH] Actually checks for matching tracks Former-commit-id: a880dfe61957b99c6f4b0087694133d89523924e --- .../FTK_DuplicateTrackRemovalTool.h | 1 + .../src/FTK_DuplicateTrackRemovalTool.cxx | 44 +++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_DuplicateTrackRemovalTool.h b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_DuplicateTrackRemovalTool.h index 2ee164d169c..f290548a1f0 100644 --- a/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_DuplicateTrackRemovalTool.h +++ b/Trigger/TrigFTK/FTK_RecTools/FTK_RecTools/FTK_DuplicateTrackRemovalTool.h @@ -32,6 +32,7 @@ class FTK_DuplicateTrackRemovalTool : public AthAlgTool, virtual public IFTK_Dup FTK_RawTrackContainer* m_trks_nodups; ToolHandle<IFTK_UncertaintyTool> m_uncertaintyTool; bool match(const FTK_RawTrack* track, const FTK_RawTrack* oldtrack) const; + int m_HW_ndiff; }; #endif diff --git a/Trigger/TrigFTK/FTK_RecTools/src/FTK_DuplicateTrackRemovalTool.cxx b/Trigger/TrigFTK/FTK_RecTools/src/FTK_DuplicateTrackRemovalTool.cxx index 1756f748ccd..6e758de716b 100644 --- a/Trigger/TrigFTK/FTK_RecTools/src/FTK_DuplicateTrackRemovalTool.cxx +++ b/Trigger/TrigFTK/FTK_RecTools/src/FTK_DuplicateTrackRemovalTool.cxx @@ -12,10 +12,12 @@ FTK_DuplicateTrackRemovalTool::FTK_DuplicateTrackRemovalTool(const std::string& const IInterface* p ): AthAlgTool(t,n,p), m_trks_nodups(NULL), - m_uncertaintyTool("FTK_UncertaintyTool",this) + m_uncertaintyTool("FTK_UncertaintyTool",this), + m_HW_ndiff(6) { declareInterface< IFTK_DuplicateTrackRemovalTool >( this ); declareProperty( "UncertaintyTool", m_uncertaintyTool); + declareProperty("HW_ndiff",m_HW_ndiff); } StatusCode FTK_DuplicateTrackRemovalTool::initialize() { @@ -37,7 +39,40 @@ StatusCode FTK_DuplicateTrackRemovalTool::finalize() { } bool FTK_DuplicateTrackRemovalTool::match(const FTK_RawTrack* track, const FTK_RawTrack* oldtrack) const { - return true; // TODO + const std::vector<FTK_RawPixelCluster>& pixclus = track->getPixelClusters(); + const std::vector<FTK_RawSCT_Cluster>& sctclus = track->getSCTClusters(); + const std::vector<FTK_RawPixelCluster>& oldpixclus = oldtrack->getPixelClusters(); + const std::vector<FTK_RawSCT_Cluster>& oldsctclus = oldtrack->getSCTClusters(); + + int nmatchingpixclus=0; + for (auto clus : pixclus){ + //is this pixel clus matched by any on the old track? + long int barcode = clus.getBarcode(); + for (auto oldclus : oldpixclus){ + if (oldclus.getBarcode()==barcode){ + nmatchingpixclus++; + } + } + } + + int nmatchingsctclus=0; + for (auto clus : sctclus){ + //is this sct clus matched by any on the old track? + long int barcode = clus.getBarcode(); + for (auto oldclus : oldsctclus){ + if (oldclus.getBarcode()==barcode){ + nmatchingsctclus++; + } + } + } + + int nclus = pixclus.size() + sctclus.size(); + int nmatchingclus = nmatchingpixclus+nmatchingsctclus; + //it matches if the number of unmatched clusters is <= 6 (or HW_diff) + if ( (nclus-nmatchingclus) <= m_HW_ndiff){//corresponding criteria in simulation + return true; + } + else return false; } FTK_RawTrackContainer* FTK_DuplicateTrackRemovalTool::removeDuplicates(const FTK_RawTrackContainer* trks){ @@ -48,13 +83,14 @@ FTK_RawTrackContainer* FTK_DuplicateTrackRemovalTool::removeDuplicates(const FTK const FTK_RawTrack *track = trks->at(i); //now we should see whether this track overlaps with one (or more?) tracks already in the nodups container - std::vector<int> matching_oldtracks; + std::vector<const FTK_RawTrack *> matching_oldtracks; for (unsigned int e = 0; e!=m_trks_nodups->size(); e++) { const FTK_RawTrack *oldtrack = m_trks_nodups->at(e); if (match(track,oldtrack)) { - matching_oldtracks.push_back(e); + matching_oldtracks.push_back(oldtrack); } } + ATH_MSG_INFO("Found "<<matching_oldtracks.size()<<" old tracks matching track "<<i); //if it does, either replace the (worst?) matching track with this new track, or ignore this new track, depending on which track we like better -- GitLab