ATLAS Offline Software
T2TrackClusterer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //
6 // $Id: T2TrackClusterer.cxx 793164 2017-01-20 03:59:26Z ssnyder $
7 //
8 
9 #include "T2TrackClusterer.h"
10 
14 
15 #include <cmath>
16 #include <stdexcept>
17 
18 using std::abs;
19 using std::sqrt;
20 using std::sin;
21 using std::cos;
22 using std::tan;
23 
24 using namespace PESA;
25 
26 
28 T2TrackClusterer::trackPerigeeFromString(const std::string& perigeeStr)
29 {
30  if (perigeeStr == "original") {
31  return perigee_original;
32  } else if (perigeeStr == "beamspot") {
33  return perigee_beamspot;
34  } else if (perigeeStr == "beamline") {
35  return perigee_beamline;
36  } else {
37  throw std::runtime_error("Invalid value of ClusterPerigee parameter: " + perigeeStr);
38  }
39 }
40 
41 double
43 {
44  const double trackZ0Err = Amg::error(*(track.perigeeParameters()->covariance()),Trk::z0);
45  const double weight = ( m_weightedZ ) ? 1. / ( trackZ0Err*trackZ0Err ) : 1.;
46  return weight;
47 }
48 
51 {
52  m_seedZ0 = 0.;
53  m_totalZ0Err = 0.;
54  m_cluster.clear();
55  m_unusedTracks.clear();
56 
57  if ( tracks.empty() ) {
58  return m_cluster;
59  }
60 
61  const Trk::Track* seedTrack = *tracks.begin();
62 
63  auto& params = seedTrack->perigeeParameters()->parameters();
64  const double seedPT = std::abs(sin(params[Trk::theta])/params[Trk::qOverP]);
65 
66  if ( seedPT < m_minPT ) {
67  m_unusedTracks.assign(tracks.begin(), tracks.end());
68  return m_cluster;
69  }
70 
71  double sumWeight = trackWeight(*seedTrack);
72  m_seedZ0 = trackPerigeeZ0(*seedTrack, beamspot);
73 
74  m_cluster.push_back(seedTrack);
75 
76  for (auto track_itr = tracks.begin() + 1; track_itr != tracks.end(); ++track_itr) {
77  const double trackZ0 = trackPerigeeZ0(**track_itr, beamspot);
78  const double deltaZ = trackZ0 - m_seedZ0;
79  const double weight = trackWeight( **track_itr );
80 
81  if (abs(deltaZ) <= m_deltaZ && m_cluster.size() < m_maxSize) {
82  m_cluster.push_back(*track_itr);
83 
84  m_seedZ0 = ( m_seedZ0 * sumWeight + trackZ0 * weight ) / ( sumWeight + weight );
85  sumWeight += weight;
86  } else {
87  m_unusedTracks.push_back(*track_itr);
88  }
89  }
90 
91  m_totalZ0Err = sqrt( 1. / sumWeight );
92 
93  return m_cluster;
94 }
95 
96 double
98 {
99  auto& params0 = track.perigeeParameters()->parameters();
100  if (m_trackPerigee == perigee_original or beamspot == nullptr) {
101  return params0[Trk::z0];
103  // TODO: beamline is doing the same as beamspot for now, I think it should be OK
104  // with our track resolution, somethig to check in the future (when I retire)
105 
106  // This assumes that track perigee is defined at 0,0, transform is:
107  // z = z_0 + (B_x*cos(phi) + B_y*sin(phi)) / tan(theta)
108 
109  double z_0 = params0[Trk::z0];
110  double phi = params0[Trk::phi];
111  double theta = params0[Trk::theta];
112  auto& beamPos = beamspot->beamPos();
113  double B_x = beamPos[0];
114  double B_y = beamPos[1];
115 
116  double z = z_0 + (B_x*cos(phi) + B_y*sin(phi)) / tan(theta);
117  return z;
118 
119  } else {
120  // fallback to "original"
121  return params0[Trk::z0];
122  }
123 }
PESA::T2TrackClusterer::m_seedZ0
double m_seedZ0
Definition: T2TrackClusterer.h:105
TrackParameters.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
EventPrimitivesHelpers.h
PESA::T2TrackClusterer::m_deltaZ
const double m_deltaZ
Definition: T2TrackClusterer.h:99
PESA::T2TrackClusterer::m_trackPerigee
const TrackPerigee m_trackPerigee
Definition: T2TrackClusterer.h:103
PESA::T2TrackClusterer::m_maxSize
const unsigned m_maxSize
Definition: T2TrackClusterer.h:102
PESA::T2TrackClusterer::trackWeight
double trackWeight(const Trk::Track &track) const
Definition: T2TrackClusterer.cxx:42
PESA::T2TrackClusterer::m_totalZ0Err
double m_totalZ0Err
Definition: T2TrackClusterer.h:106
Trk::z0
@ z0
Definition: ParamDefs.h:64
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
PESA::T2TrackClusterer::m_unusedTracks
TrackVector m_unusedTracks
Definition: T2TrackClusterer.h:109
PESA::T2TrackClusterer::trackPerigeeFromString
static TrackPerigee trackPerigeeFromString(const std::string &perigeeStr)
Definition: T2TrackClusterer.cxx:28
PESA::T2TrackClusterer::TrackPerigee
TrackPerigee
Definition: T2TrackClusterer.h:48
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
PESA::T2TrackClusterer::m_minPT
const double m_minPT
Definition: T2TrackClusterer.h:100
PESA
Local tools.
Definition: T2BeamSpot.cxx:13
PESA::T2TrackClusterer::cluster
const TrackVector & cluster(const TrackVector &tracks, const InDet::BeamSpotData *beamspot=nullptr)
Find one cluster in a set of tracks.
Definition: T2TrackClusterer.cxx:50
PESA::T2TrackClusterer::m_cluster
TrackVector m_cluster
Definition: T2TrackClusterer.h:108
PESA::T2TrackClusterer::perigee_original
@ perigee_original
Definition: T2TrackClusterer.h:49
z
#define z
Trk::theta
@ theta
Definition: ParamDefs.h:66
PESA::T2TrackClusterer::perigee_beamspot
@ perigee_beamspot
Definition: T2TrackClusterer.h:51
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
InDet::BeamSpotData::beamPos
const Amg::Vector3D & beamPos() const noexcept
Definition: BeamSpotData.h:68
PESA::T2TrackClusterer::trackPerigeeZ0
double trackPerigeeZ0(const Trk::Track &track, const InDet::BeamSpotData *beamspot) const
Definition: T2TrackClusterer.cxx:97
PESA::T2TrackClusterer::TrackVector
std::vector< const Trk::Track * > TrackVector
Definition: T2TrackClusterer.h:45
Trk::Track::perigeeParameters
const Perigee * perigeeParameters() const
return Perigee.
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:163
PESA::T2TrackClusterer::perigee_beamline
@ perigee_beamline
Definition: T2TrackClusterer.h:52
Amg::error
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Definition: EventPrimitivesHelpers.h:40
InDet::BeamSpotData
Definition: BeamSpotData.h:21
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
PESA::T2TrackClusterer::m_weightedZ
const bool m_weightedZ
Definition: T2TrackClusterer.h:101
Trk::phi
@ phi
Definition: ParamDefs.h:75
T2TrackClusterer.h
BeamSpotData.h
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
makeComparison.deltaZ
int deltaZ
Definition: makeComparison.py:46