ATLAS Offline Software
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"
17 #include "eflowRec/eflowRecTrack.h"
19 
20 using namespace PFMatch;
21 
23  const std::string& name,
24  const IInterface* 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 
56 std::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 
66 std::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 }
PFTrackClusterMatchingTool::m_distanceType
std::string m_distanceType
The type of distance measure to be used for matching.
Definition: PFTrackClusterMatchingTool.h:60
PFMatch::MatchDistance
std::pair< ICluster *, double > MatchDistance
Definition: PFMatcher.h:24
PFTrackClusterMatchingTool::m_matcher
std::unique_ptr< PFMatch::TrackClusterMatcher > m_matcher
The track cluster matcher to perform the actual matching.
Definition: PFTrackClusterMatchingTool.h:65
verify_menu_config.results
results
Definition: verify_menu_config.py:67
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
PFTrackClusterMatchingTool::m_trackPositionType
std::string m_trackPositionType
The type of track position to be used for matching.
Definition: PFTrackClusterMatchingTool.h:56
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
eflowRecClusterContainer
Definition: eflowRecCluster.h:275
eflowMatchCluster::e
virtual double e() const
Definition: eflowRecCluster.h:162
PFTrackClusterMatchingTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Online monitoring tool for recording histograms of the alg in action.
Definition: PFTrackClusterMatchingTool.h:68
eflowMatchCluster::phi
virtual double phi() const
Definition: eflowRecCluster.h:164
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
eflowRecMatchTrack
This class, which inherits from the pure virtual ITrack, stores a pointer to an eflowRecTrack and has...
Definition: eflowRecTrack.h:169
eflowRecTrack
This class extends the information about a xAOD::Track.
Definition: eflowRecTrack.h:46
PFMatcher.h
eflowRecTrack.h
Get
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...
Definition: comparitor.cxx:179
PFTrackClusterMatchingTool::m_matchCut
double m_matchCut
The cut value on the distance measure.
Definition: PFTrackClusterMatchingTool.h:62
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PFTrackClusterMatchingTool.h
PFTrackClusterMatchingTool::finalize
StatusCode finalize()
Definition: PFTrackClusterMatchingTool.cxx:51
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PFTrackClusterMatchingTool::doMatches
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.
Definition: PFTrackClusterMatchingTool.cxx:57
eflowRecCluster.h
eflowMatchCluster::getEfRecCluster
eflowRecCluster * getEfRecCluster()
Definition: eflowRecCluster.h:159
PFTrackClusterMatchingTool::m_clusterPositionType
std::string m_clusterPositionType
The type of cluster position to be used for matching.
Definition: PFTrackClusterMatchingTool.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
PFTrackClusterMatchingTool::PFTrackClusterMatchingTool
PFTrackClusterMatchingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PFTrackClusterMatchingTool.cxx:22
PFMatch
Definition: PFMatchDistance.h:17
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
eflowMatchCluster
This class, which inherits from the pure virtual ICluster, stores a pointer to an eflowRecCluster.
Definition: eflowRecCluster.h:140
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PFMatchPositions.h
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
PFTrackClusterMatchingTool::m_invGeV
const float m_invGeV
Definition: PFTrackClusterMatchingTool.h:70
eflowMatchCluster::eta
virtual double eta() const
Definition: eflowRecCluster.h:163
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
AthAlgTool
Definition: AthAlgTool.h:26
PFMatchDistance.h
PFTrackClusterMatchingTool::initialize
StatusCode initialize()
Definition: PFTrackClusterMatchingTool.cxx:38
match
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition: hcg.cxx:356