ATLAS Offline Software
Loading...
Searching...
No Matches
PFTrackClusterMatchingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6 * PFMatchingTool.cxx
7 *
8 * Created on: 15.04.2014
9 * Author: tlodd
10 */
11
13
14#include "eflowRec/PFMatcher.h"
19
20using namespace PFMatch;
21
23 const std::string& name,
24 const IInterface* parent) :
25 AthAlgTool(type, name, parent),
26 m_trackPositionType("EM2EtaPhi"),
27 m_clusterPositionType("GeomCenterEtaPhi"),
28 m_distanceType("EtaPhiSquareSignificance"),
29 m_matchCut(1.64*1.64),
30 m_matcher(nullptr) {
31 declareInterface<PFTrackClusterMatchingTool>(this);
32 declareProperty("TrackPositionType",m_trackPositionType);
33 declareProperty("ClusterPositionType",m_clusterPositionType);
34 declareProperty("DistanceType",m_distanceType);
35 declareProperty("MatchCut", m_matchCut);
36}
37
39
41
42 ATH_MSG_VERBOSE("In initialize:");
43 ATH_MSG_VERBOSE("Track position type is \"" << m_trackPositionType << "\"");
44 ATH_MSG_VERBOSE("Cluster position type is \"" << m_clusterPositionType << "\"");
45 ATH_MSG_VERBOSE("Distance type is \"" << m_distanceType << "\"");
46 ATH_MSG_VERBOSE("Match cut is " << m_matchCut);
47
48 return StatusCode::SUCCESS;
49}
50
52
53 return StatusCode::SUCCESS;
54}
55
56std::vector<std::pair<eflowRecCluster*, float>>
59 int nMatches) const
60{
61 std::vector<eflowRecCluster*> vec_clusters(clusters->begin(),
62 clusters->end());
63 return doMatches(track, vec_clusters, nMatches);
64}
65
66std::vector<std::pair<eflowRecCluster*, float>>
68 const eflowRecTrack* track,
69 std::vector<eflowRecCluster*>& clusters,
70 int nMatches) const
71{
72 auto matched_tracks_pt = Monitored::Scalar<float>("matched_tracks_pt");
73 auto matched_clusters_e = Monitored::Scalar<float>("matched_clusters_e");
74 auto matched_clusters_eta = Monitored::Scalar<float>("matched_clusters_eta");
75 auto matched_clusters_phi = Monitored::Scalar<float>("matched_clusters_phi");
76 auto group = Monitored::Group(m_monTool, matched_tracks_pt, matched_clusters_e,
77 matched_clusters_eta, matched_clusters_phi);
78
79 /* Transform the vector of eflowRecCluster into a vector of eflowMatchClusters
80 */
81 std::vector<eflowMatchCluster*> matchClusters;
82 matchClusters.reserve(clusters.size());
83
84 for (auto& cluster : clusters) {
85 matchClusters.push_back(cluster->getMatchCluster());
86 }
87
88 /* Use the TrackClusterMatcher to retrieve the matches */
89 eflowRecMatchTrack matchTrack(track);
90 std::vector<MatchDistance> allMatches = m_matcher->bestMatches(
91 &matchTrack, matchClusters, nMatches, 0.1 * track->getTrack()->e());
92
93 /* Transform the vector of MatchDistance objects into a vector of
94 * eflowRecClusters and return it */
95 std::vector<std::pair<eflowRecCluster*, float>> results;
96 for (MatchDistance& match : allMatches) {
97 // The matching cannot change the cluster type, this started as
98 // eflowMatchCluster and remains of that type -- no need to test cast from
99 // ICluster*
100 eflowMatchCluster* thisMatch = static_cast<eflowMatchCluster*>(match.first);
101 results.emplace_back(thisMatch->getEfRecCluster(), match.second);
102 matched_clusters_e = thisMatch->e() * m_invGeV;
103 matched_clusters_eta = thisMatch->eta();
104 matched_clusters_phi = thisMatch->phi();
105 }
106 matched_tracks_pt = track->getTrack()->pt() / 1000; //Conversion to GeV
107 return results;
108}
#define ATH_MSG_VERBOSE(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
static std::unique_ptr< IPositionProvider > Get(const std::string &positionType)
static std::unique_ptr< IDistanceProvider > Get(const std::string &distanceType, std::unique_ptr< IPositionProvider > trackPosition, std::unique_ptr< IPositionProvider > clusterPosition)
static std::unique_ptr< IPositionProvider > Get(const std::string &positionType)
std::string m_distanceType
The type of distance measure to be used for matching.
std::string m_trackPositionType
The type of track position to be used for matching.
ToolHandle< GenericMonitoringTool > m_monTool
Online monitoring tool for recording histograms of the alg in action.
std::vector< std::pair< eflowRecCluster *, float > > doMatches(const eflowRecTrack *track, eflowRecClusterContainer *clusters, int n) const
Get n clusters that matches best to a given track.
std::string m_clusterPositionType
The type of cluster position to be used for matching.
std::unique_ptr< PFMatch::TrackClusterMatcher > m_matcher
The track cluster matcher to perform the actual matching.
PFTrackClusterMatchingTool(const std::string &type, const std::string &name, const IInterface *parent)
double m_matchCut
The cut value on the distance measure.
This class, which inherits from the pure virtual ICluster, stores a pointer to an eflowRecCluster.
virtual double e() const
virtual double eta() const
eflowRecCluster * getEfRecCluster()
virtual double phi() const
This class, which inherits from the pure virtual ITrack, stores a pointer to an eflowRecTrack and has...
This class extends the information about a xAOD::Track.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357
std::pair< ICluster *, double > MatchDistance
Definition PFMatcher.h:24