ATLAS Offline Software
MSVertex.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <cmath>
8 
9 #include <sstream>
10 
11 MSVertex::MSVertex() : m_author(0), m_position(), m_tracks(0), m_chi2prob(-1.), m_chi2(-1.), m_nMDT(-1), m_nRPC(-1), m_nTGC(-1) {}
12 
14  m_author(vertex.getAuthor()),
15  m_position(vertex.getPosition()),
16  m_tracks(0),
17  m_chi2prob(vertex.getChi2Probability()),
18  m_chi2(vertex.getChi2()),
19  m_nMDT(vertex.getNMDT()),
20  m_nRPC(vertex.getNRPC()),
21  m_nTGC(vertex.getNTGC()) {
22  for (std::vector<xAOD::TrackParticle*>::const_iterator i = vertex.getTracks()->begin(); i != vertex.getTracks()->end(); ++i) {
23  m_tracks.push_back(new xAOD::TrackParticle(**i));
24  }
25 }
26 
27 MSVertex::MSVertex(int author, const Amg::Vector3D& position, float chi2prob, float chi2, int nMDT, int nRPC, int nTGC) :
28  m_author(author), m_position(position), m_tracks(0), m_chi2prob(chi2prob), m_chi2(chi2), m_nMDT(nMDT), m_nRPC(nRPC), m_nTGC(nTGC) {}
29 
30 MSVertex::MSVertex(int author, const Amg::Vector3D& position, const std::vector<xAOD::TrackParticle*>& tracks, float chi2prob, float chi2,
31  int nMDT, int nRPC, int nTGC) :
32  m_author(author),
33  m_position(position),
34  m_tracks(tracks),
35  m_chi2prob(chi2prob),
36  m_chi2(chi2),
37  m_nMDT(nMDT),
38  m_nRPC(nRPC),
39  m_nTGC(nTGC) {}
40 
42  for (std::vector<xAOD::TrackParticle*>::iterator i = m_tracks.begin(); i != m_tracks.end(); ++i) {
43  if ((*i)) {
44  delete (*i);
45  (*i) = 0;
46  }
47  }
48  m_tracks.clear();
49 }
50 
52  if (this != &msvx) {
53  m_author = msvx.getAuthor();
54  m_position = msvx.getPosition();
56  m_chi2 = msvx.getChi2();
57  m_nMDT = msvx.getNMDT();
58  m_nRPC = msvx.getNRPC();
59  m_nTGC = msvx.getNTGC();
60 
61  for (std::vector<xAOD::TrackParticle*>::const_iterator i = msvx.getTracks()->begin(); i != msvx.getTracks()->end(); ++i) {
62  m_tracks.push_back(new xAOD::TrackParticle(**i));
63  }
64  }
65  return *this;
66 }
67 
69  std::vector<xAOD::TrackParticle*> trk;
70  for (std::vector<xAOD::TrackParticle*>::iterator i = m_tracks.begin(); i != m_tracks.end(); ++i) {
71  trk.push_back(new xAOD::TrackParticle(**i));
72  }
74 }
75 
76 void MSVertex::setPosition(const Amg::Vector3D& position) { m_position = position; }
77 
79 
80 const std::vector<xAOD::TrackParticle*>* MSVertex::getTracks(void) const { return &m_tracks; }
81 
82 void MSVertex::setAuthor(const int author) { m_author = author; }
83 
84 int MSVertex::getAuthor() const { return m_author; }
85 float MSVertex::getChi2Probability() const { return m_chi2prob; }
86 float MSVertex::getChi2() const { return m_chi2; }
87 
88 int MSVertex::getNTracks() const {
89  if (getTracks())
90  return getTracks()->size();
91  else
92  return 0;
93 }
94 
95 void MSVertex::setNMDT(const int nMDT) { m_nMDT = nMDT; }
96 void MSVertex::setNRPC(const int nRPC) { m_nRPC = nRPC; }
97 void MSVertex::setNTGC(const int nTGC) { m_nTGC = nTGC; }
98 
99 int MSVertex::getNMDT() const { return m_nMDT; }
100 int MSVertex::getNRPC() const { return m_nRPC; }
101 int MSVertex::getNTGC() const { return m_nTGC; }
102 
103 std::string str(const MSVertex& a) {
104  std::stringstream ss;
105 
106  ss << "author = " << a.getAuthor() << "; x = " << a.getPosition().x() << "; y = " << a.getPosition().y()
107  << "; z = " << a.getPosition().z() << "; phi = " << a.getPosition().phi() << "; eta = " << a.getPosition().eta()
108  << "; chi2 prob. = " << a.getChi2Probability() << "; # tracks = " << a.getNTracks() << "; # MDT hits = " << a.getNMDT()
109  << "; # RPC hits = " << a.getNRPC() << "; # TGC hits = " << a.getNTGC();
110 
111  return ss.str();
112 }
113 
114 MsgStream& operator<<(MsgStream& m, const MSVertex& a) { return (m << str(a)); }
115 
116 bool operator==(const MSVertex& a, const MSVertex& b) {
117  //* distance used to compare floats *//
118  const double DELTA = 1e-3;
119 
120  if (std::abs(a.getPosition().x() - b.getPosition().x()) > DELTA) return false;
121  if (std::abs(a.getPosition().y() - b.getPosition().y()) > DELTA) return false;
122  if (std::abs(a.getPosition().z() - b.getPosition().z()) > DELTA) return false;
123  if (std::abs(a.getPosition().eta() - b.getPosition().eta()) > DELTA) return false;
124  if (std::abs(a.getPosition().phi() - b.getPosition().phi()) > DELTA) return false;
125  if (std::abs(a.getChi2Probability() - b.getChi2Probability()) > DELTA) return false;
126 
127  if (a.getAuthor() - b.getAuthor() != 0) return false;
128  if (a.getNTracks() - b.getNTracks() != 0) return false;
129  if (a.getNMDT() - b.getNMDT() != 0) return false;
130  if (a.getNRPC() - b.getNRPC() != 0) return false;
131  if (a.getNTGC() - b.getNTGC() != 0) return false;
132 
133  return true;
134 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
MSVertex::m_nMDT
int m_nMDT
Definition: MSVertex.h:56
MSVertex::setPosition
void setPosition(const Amg::Vector3D &)
Definition: MSVertex.cxx:76
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
MSVertex::getNTracks
int getNTracks() const
Definition: MSVertex.cxx:88
MSVertex::m_position
Amg::Vector3D m_position
Definition: MSVertex.h:50
IDTPM::getAuthor
std::vector< unsigned int > getAuthor(const xAOD::TrackParticle &p)
Accessor utility function for getting the track author.
Definition: TrackParametersHelper.h:135
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
MSVertex::m_nTGC
int m_nTGC
Definition: MSVertex.h:56
MSVertex::m_chi2
float m_chi2
Definition: MSVertex.h:54
MSVertex::clone
MSVertex * clone()
Definition: MSVertex.cxx:68
MSVertex::m_tracks
std::vector< xAOD::TrackParticle * > m_tracks
Definition: MSVertex.h:52
MSVertex.h
operator<<
MsgStream & operator<<(MsgStream &m, const MSVertex &a)
Definition: MSVertex.cxx:114
MSVertex
Definition: MSVertex.h:12
MSVertex::getChi2
float getChi2() const
Definition: MSVertex.cxx:86
Pmt::getPosition
Eigen::Vector3d getPosition(const xAOD::TrackParticle &trk)
Definition: PoorMansIpAugmenterAlg.cxx:43
MSVertex::m_chi2prob
float m_chi2prob
Definition: MSVertex.h:54
MSVertex::getNRPC
int getNRPC() const
Definition: MSVertex.cxx:100
str
std::string str(const MSVertex &a)
Definition: MSVertex.cxx:103
MSVertex::~MSVertex
virtual ~MSVertex()
Definition: MSVertex.cxx:41
MSVertex::getNMDT
int getNMDT() const
Definition: MSVertex.cxx:99
MSVertex::setNRPC
void setNRPC(const int)
Definition: MSVertex.cxx:96
lumiFormat.i
int i
Definition: lumiFormat.py:85
MSVertex::getChi2Probability
float getChi2Probability() const
Definition: MSVertex.cxx:85
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
MSVertex::setNTGC
void setNTGC(const int)
Definition: MSVertex.cxx:97
MSVertex::operator=
MSVertex & operator=(const MSVertex &msvx)
Definition: MSVertex.cxx:51
MSVertex::setAuthor
void setAuthor(const int)
Definition: MSVertex.cxx:82
MSVertex::m_author
unsigned int m_author
Definition: MSVertex.h:48
MSVertex::getNTGC
int getNTGC() const
Definition: MSVertex.cxx:101
MSVertex::m_nRPC
int m_nRPC
Definition: MSVertex.h:56
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
MSVertex::setNMDT
void setNMDT(const int)
Definition: MSVertex.cxx:95
a
TList * a
Definition: liststreamerinfos.cxx:10
CaloCondBlobAlgs_fillNoiseFromASCII.author
string author
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:26
MSVertex::MSVertex
MSVertex()
Definition: MSVertex.cxx:11
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
MSVertex::getTracks
const std::vector< xAOD::TrackParticle * > * getTracks() const
Definition: MSVertex.cxx:80
muCombUtil::getChi2
double getChi2(int &ndof, double ipt, double eta1, double seta1, double phi1, double sphi1, double ipt1, double sipt1, double eta2, double seta2, double phi2, double sphi2, double ipt2, double sipt2, bool useAbsPt)
Get OLD style (i.e. muFast time) Chi2.
Definition: muCombUtil.cxx:374
operator==
bool operator==(const MSVertex &a, const MSVertex &b)
Definition: MSVertex.cxx:116
MSVertex::getAuthor
int getAuthor() const
Definition: MSVertex.cxx:84
MSVertex::getPosition
const Amg::Vector3D & getPosition() const
Definition: MSVertex.cxx:78