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 "PFMatcher.h"
15#include "PFMatchDistance.h"
16#include "PFMatchPositions.h"
17#include "eflowRecTrack.h"
18#include "eflowRecCluster.h"
19
20using namespace PFMatch;
21
23 const std::string& name,
24 const IInterface* parent) :
25 AthAlgTool(type, name, parent),
26 m_matcher(nullptr) {
27 declareInterface<PFTrackClusterMatchingTool>(this);
28}
29
31
33
34 ATH_MSG_VERBOSE("In initialize:");
35 ATH_MSG_VERBOSE("Track position type is \"" << m_trackPositionType << "\"");
36 ATH_MSG_VERBOSE("Cluster position type is \"" << m_clusterPositionType << "\"");
37 ATH_MSG_VERBOSE("Distance type is \"" << m_distanceType << "\"");
38 ATH_MSG_VERBOSE("Match cut is " << m_matchCut);
39
40 return StatusCode::SUCCESS;
41}
42
44
45 return StatusCode::SUCCESS;
46}
47
48std::vector<std::pair<eflowRecCluster*, float>>
51 int nMatches) const
52{
53 std::vector<eflowRecCluster*> vec_clusters(clusters->begin(),
54 clusters->end());
55 return doMatches(track, vec_clusters, nMatches);
56}
57
58std::vector<std::pair<eflowRecCluster*, float>>
60 const eflowRecTrack* track,
61 std::vector<eflowRecCluster*>& clusters,
62 int nMatches) const
63{
64 auto matched_tracks_pt = Monitored::Scalar<float>("matched_tracks_pt");
65 auto matched_clusters_e = Monitored::Scalar<float>("matched_clusters_e");
66 auto matched_clusters_eta = Monitored::Scalar<float>("matched_clusters_eta");
67 auto matched_clusters_phi = Monitored::Scalar<float>("matched_clusters_phi");
68 auto group = Monitored::Group(m_monTool, matched_tracks_pt, matched_clusters_e,
69 matched_clusters_eta, matched_clusters_phi);
70
71 /* Transform the vector of eflowRecCluster into a vector of eflowMatchClusters
72 */
73 std::vector<eflowMatchCluster*> matchClusters;
74 matchClusters.reserve(clusters.size());
75
76 for (auto& cluster : clusters) {
77 matchClusters.push_back(cluster->getMatchCluster());
78 }
79
80 /* Use the TrackClusterMatcher to retrieve the matches */
81 eflowRecMatchTrack matchTrack(track);
82 std::vector<MatchDistance> allMatches = m_matcher->bestMatches(
83 &matchTrack, matchClusters, nMatches, 0.1 * track->getTrack()->e());
84
85 /* Transform the vector of MatchDistance objects into a vector of
86 * eflowRecClusters and return it */
87 std::vector<std::pair<eflowRecCluster*, float>> results;
88 for (MatchDistance& match : allMatches) {
89 // The matching cannot change the cluster type, this started as
90 // eflowMatchCluster and remains of that type -- no need to test cast from
91 // ICluster*
92 eflowMatchCluster* thisMatch = static_cast<eflowMatchCluster*>(match.first);
93 results.emplace_back(thisMatch->getEfRecCluster(), match.second);
94 matched_clusters_e = thisMatch->e() * m_invGeV;
95 matched_clusters_eta = thisMatch->eta();
96 matched_clusters_phi = thisMatch->phi();
97 }
98 matched_tracks_pt = track->getTrack()->pt() / 1000; //Conversion to GeV
99 return results;
100}
#define ATH_MSG_VERBOSE(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
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)
Gaudi::Property< double > m_matchCut
The cut value on the distance measure.
ToolHandle< GenericMonitoringTool > m_monTool
Online monitoring tool for recording histograms of the alg in action.
Gaudi::Property< std::string > m_clusterPositionType
The type of cluster position to be used for matching.
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.
Gaudi::Property< std::string > m_trackPositionType
The type of track position to be used for matching.
std::unique_ptr< PFMatch::TrackClusterMatcher > m_matcher
The track cluster matcher to perform the actual matching.
Gaudi::Property< std::string > m_distanceType
The type of distance measure to be used for matching.
PFTrackClusterMatchingTool(const std::string &type, const std::string &name, const IInterface *parent)
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:359
std::pair< ICluster *, double > MatchDistance
Definition PFMatcher.h:24