ATLAS Offline Software
RecVertexPositions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  RecVertexPositions.cxx - Description
7  -------------------
8  begin : Autumn 2006
9  authors : Giacinto Piacquadio (Freiburg University)
10  email : Giacinto.Piacquadio@physik.uni-freiburg.de
11  comments:
12  changes :
13 
14  ***************************************************************************/
15 
17 //#include "TrkEventPrimitives/CovarianceMatrix.h" //!< include for the track class
18 //#include "CLHEP/Vector/ThreeVector.h" //!< include for CLHEP::Hep3Vector
19 //#include "VxJetVertex/VxVertexOnJetAxis.h"
20 
21 
22 namespace Trk {
23 
25  VertexPositions(),
26  m_positionError(Amg::MatrixX())
27  { m_positionError.setZero();}
28 
29 
30  RecVertexPositions::RecVertexPositions(const VertexPositions& pos) :
31  VertexPositions(pos),
32  m_positionError(Amg::MatrixX())
33  { m_positionError.setZero();}
34 
35 
36  RecVertexPositions::RecVertexPositions(const Amg::VectorX &pos, const Amg::MatrixX &cov,
37  const double ndf, const double chi2,
38  bool isWeightTimesPosition) :
39  VertexPositions(pos), m_positionError(cov), m_fitQuality(Trk::FitQuality(chi2,ndf)) {
40  m_useWeightTimesPosition=isWeightTimesPosition;
41  }
42 
43 
44  RecVertexPositions::RecVertexPositions(const Amg::VectorX &pos, const double ndf, const double chi2) :
46  m_positionError(Amg::MatrixX()),
47  m_fitQuality(Trk::FitQuality(chi2,ndf)) { m_positionError.setZero();}
48 
49  RecVertexPositions::RecVertexPositions(const RecVertexPositions& rhs) = default;
50 
51 
52  const Amg::VectorX& RecVertexPositions::weightTimesPosition() {
53  if (!m_useWeightTimesPosition && m_positionError.determinant()!=0.0) {
54  m_position=m_positionError.inverse()*m_position;
55  m_useWeightTimesPosition=true;
56  } else {
57  std::cout << "Warning in RecVertexPositions: requested finalization but was already finalized..." << std::endl;
58  }
59  return m_position;
60  }
61 
62  // Use storing weight matrix * position instead of position
63  // saves you from inverting the weight matrix at every fit iteration
64  // Then transparently, asking the position for the first time,
65  // the m_position will be restored to the correct value of position
66  // (using the invertion of the weight matrix only once...)
67  void RecVertexPositions::setWeightTimesPosition(const Amg::VectorX & weightTimesPosition) {
68  m_useWeightTimesPosition=true;
69  m_position=weightTimesPosition;
70  }
71 
72  //the finalizePosition() method is used to ask the RecVertexPositions class
73  //to invert the weight matrix and fill the m_position vector with the real
74  //position, in order to finalize the position (and make it available)
75  void RecVertexPositions::finalizePosition() {
76  if (m_useWeightTimesPosition) {
77  m_useWeightTimesPosition=false;
78  m_position=m_positionError*m_position;
79  }
80  }
81 
82 
83 
84  RecVertexPositions &RecVertexPositions::operator= (const RecVertexPositions& rhs)
85  {
86  if (this!=&rhs)
87  {
88  // you need to call the base class assignment operator
89  VertexPositions::operator=(rhs);
90  m_positionError = rhs.m_positionError;
91  m_fitQuality = rhs.m_fitQuality;
92  }
93  return *this;
94  }
95 
96  MsgStream& RecVertexPositions::dump(MsgStream& sl) const {
97  sl << "Trk::RecVertexPositions: " << std::endl;
98  //VertexOnJetAxis::dump(sl);
99 
100  if (m_useWeightTimesPosition) {
101  sl << "Trk::VertexPositions weight times position: (" ;
102  } else {
103  sl << "Trk::VertexPositions position: (" ;
104  }
105  sl << "xv " << m_position(jet_xv) << "+/-" << sqrt(m_positionError(jet_xv,jet_xv)) << " , "
106  << "yv " << m_position(jet_yv) << "+/-" << sqrt(m_positionError(jet_yv,jet_yv)) <<", "
107  << "zv " << m_position(jet_zv) << "+/-" << sqrt(m_positionError(jet_zv,jet_zv)) <<", "
108  << "phi " << m_position(jet_phi) << "+/-" << sqrt(m_positionError(jet_phi,jet_phi)) <<", "
109  << "theta " << m_position(jet_theta) << "+/-" << sqrt(m_positionError(jet_theta,jet_theta)) << endmsg;
110  if (!m_useWeightTimesPosition) {
111  for (int i=5;i<m_position.rows();i++) {
112  sl << "dist" << i << " " << m_position(i) << "+/-" << sqrt(m_positionError(i,i))<<" , ";
113  }
114  } else {
115  for (int i=5;i<m_position.rows();i++) {
116  sl << "dist corrected" << i << " " << (m_positionError*m_position).eval()(i) << "+/-" << sqrt(m_positionError(i,i))<<" , ";
117  }
118  }
119  sl << endmsg;
120 
121  sl << m_positionError << std::endl;
122  sl << " ndf: " << m_fitQuality.doubleNumberDoF() << "\t chi2: " << m_fitQuality.chiSquared() << endmsg;
123  return sl;
124  }
125 
126  std::ostream& RecVertexPositions::dump(std::ostream& sl) const {
127  // sl << "Trk::RecVertexPositions: " << std::endl;
128  if (m_useWeightTimesPosition) {
129  sl << "Trk::VertexPositions weight times position: (" ;
130  } else {
131  sl << "Trk::VertexPositions position: (" ;
132  }
133  sl << "xv " << m_position(jet_xv) << "+/-" <<sqrt(this->covariancePosition()(jet_xv,jet_xv)) << " , "
134  << "yv " << m_position(jet_yv) << "+/-" <<sqrt(this->covariancePosition()(jet_yv,jet_yv)) <<", "
135  << "zv " << m_position(jet_zv) << "+/-" <<sqrt(this->covariancePosition()(jet_zv,jet_zv)) <<", "
136  << "phi " << m_position(jet_phi) << "+/-"<<sqrt(this->covariancePosition()(jet_phi,jet_phi)) <<", "
137  << "theta " << m_position(jet_theta)<<"+/-"<<sqrt(this->covariancePosition()(jet_theta,jet_theta))
138  << std::endl;
139  if (!m_useWeightTimesPosition) {
140  for (int i=5;i<m_position.rows();i++) {
141  sl << "dist" << i << " " << m_position(i) << "+/-" << sqrt(this->covariancePosition()(i,i))<<" , ";
142  }
143  } else {
144  for (int i=5;i<m_position.rows();i++) {
145  sl << "dist corrected" << i << " " << (m_positionError*m_position).eval()(i) << "+/-" << sqrt(m_positionError(i,i))<<" , ";
146  }
147  }
148  sl << std::endl;
149 
151  sl << m_positionError << std::endl;
152  sl << " ndf: " << m_fitQuality.doubleNumberDoF() << "\t chi2: " << m_fitQuality.chiSquared() << std::endl;
153  return sl;
154  }
155 
156  RecVertexPositions::~RecVertexPositions() = default;
157 
159  {return m_fitQuality;}
160 
161 
162  const Amg::MatrixX& RecVertexPositions::covariancePosition() const
163  {return m_positionError; }
164 
165 
166  void RecVertexPositions::setCovariancePosition(const Amg::MatrixX & newerror) {
167  m_positionError=newerror;
168  }
169 
170  void RecVertexPositions::setFitQuality(const Trk::FitQuality & newFitQuality) {
171  m_fitQuality=newFitQuality;
172  }
173 
174 
175 
176 } // end of namespace
covarianceTool.ndf
ndf
Definition: covarianceTool.py:678
Trk::RecVertexPositions::RecVertexPositions
RecVertexPositions()
default constructor, if called initializes a RecVertexPositions with all data members set to 0.
Definition: RecVertexPositions.cxx:33
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:32
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
Trk::jet_theta
@ jet_theta
Definition: JetVtxParamDefs.h:28
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
Trk::jet_xv
@ jet_xv
Definition: JetVtxParamDefs.h:27
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Trk::jet_yv
@ jet_yv
Definition: JetVtxParamDefs.h:27
Trk::RecVertexPositions::m_fitQuality
Trk::FitQuality m_fitQuality
Definition: RecVertexPositions.h:90
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
python.ChapPy.dump
def dump(buf, stdout=sys.stdout)
Definition: ChapPy.py:25
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Trk::RecVertexPositions::m_positionError
Amg::MatrixX m_positionError
cov matrix on vertex position (primary vtx+jet dir+distance)
Definition: RecVertexPositions.h:89
Trk::jet_zv
@ jet_zv
position x,y,z of primary vertex
Definition: JetVtxParamDefs.h:27
Trk::RecVertexPositions
Definition: RecVertexPositions.h:34
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::GsfMeasurementUpdator::fitQuality
FitQualityOnSurface fitQuality(const MultiComponentState &, const MeasurementBase &)
Method for determining the chi2 of the multi-component state and the number of degrees of freedom.
Definition: GsfMeasurementUpdator.cxx:845
Trk::jet_phi
@ jet_phi
Definition: JetVtxParamDefs.h:28
Trk::VertexPositions
VertexPositions class to represent and store a vertex.
Definition: VertexPositions.h:36
RecVertexPositions.h