CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
CachingVertex< N > Class Template Reference

#include <CachingVertex.h>

Public Types

typedef ROOT::Math::SMatrix
< double, N-2, N-2,
ROOT::Math::MatRepStd< double,
N-2, N-2 > > 
AlgebraicMatrixMM
 
typedef ROOT::Math::SMatrix
< double, N, N,
ROOT::Math::MatRepSym< double,
N > > 
AlgebraicSymMatrixNN
 
typedef
ReferenceCountingPointer
< VertexTrack< N > > 
RefCountedVertexTrack
 
typedef std::map
< RefCountedVertexTrack,
AlgebraicMatrixMM
TrackMap
 
typedef std::map
< RefCountedVertexTrack,
TrackMap
TrackToTrackMap
 

Public Member Functions

 CachingVertex (const GlobalPoint &pos, const GlobalError &posErr, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq)
 
 CachingVertex (const GlobalPoint &pos, const GlobalWeight &posWeight, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq)
 
 CachingVertex (const AlgebraicVector3 &weightTimesPosition, const GlobalWeight &posWeight, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq)
 
 CachingVertex (const GlobalPoint &priorPos, const GlobalError &priorErr, const GlobalPoint &pos, const GlobalError &posErr, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq)
 
 CachingVertex (const GlobalPoint &priorPos, const GlobalError &priorErr, const GlobalPoint &pos, const GlobalWeight &posWeight, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq)
 
 CachingVertex (const GlobalPoint &priorPos, const GlobalError &priorErr, const AlgebraicVector3 &weightTimesPosition, const GlobalWeight &posWeight, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq)
 
 CachingVertex (const VertexState &aVertexState, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq)
 
 CachingVertex (const VertexState &priorVertexState, const VertexState &aVertexState, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq)
 
 CachingVertex (const VertexState &aVertexState, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq, const TrackToTrackMap &covMap)
 
 CachingVertex (const VertexState &priorVertexState, const VertexState &aVertexState, const std::vector< RefCountedVertexTrack > &tks, float totalChiSq, const TrackToTrackMap &covMap)
 
 CachingVertex ()
 
float degreesOfFreedom () const
 
GlobalError error () const
 
bool hasPrior () const
 
bool isValid () const
 
 operator TransientVertex () const
 
GlobalPoint position () const
 
GlobalError priorError () const
 
GlobalPoint priorPosition () const
 
VertexState const & priorVertexState () const
 
AlgebraicMatrixMM tkToTkCovariance (const RefCountedVertexTrack t1, const RefCountedVertexTrack t2) const
 
bool tkToTkCovarianceIsAvailable () const
 
float totalChiSquared () const
 
std::vector
< RefCountedVertexTrack >
const & 
tracks () const
 
std::vector
< RefCountedVertexTrack >
const & 
tracksRef () const
 
VertexState const & vertexState () const
 
GlobalWeight weight () const
 
AlgebraicVector3 weightTimesPosition () const
 

Private Member Functions

void computeNDF () const
 

Private Attributes

float theChiSquared
 
TrackToTrackMap theCovMap
 
bool theCovMapAvailable
 
float theNDF
 
bool theNDFAvailable
 
VertexState thePriorVertexState
 
std::vector
< RefCountedVertexTrack
theTracks
 
bool theValid
 
VertexState theVertexState
 
bool withPrior
 

Detailed Description

template<unsigned int N>
class CachingVertex< N >

Class for vertices fitted with Kalman and linear fit algorithms. Provides access to temporary data to speed up the vertex update.

Definition at line 25 of file CachingVertex.h.

Member Typedef Documentation

template<unsigned int N>
typedef ROOT::Math::SMatrix<double,N-2,N-2,ROOT::Math::MatRepStd<double,N-2,N-2> > CachingVertex< N >::AlgebraicMatrixMM

Definition at line 31 of file CachingVertex.h.

template<unsigned int N>
typedef ROOT::Math::SMatrix<double,N,N,ROOT::Math::MatRepSym<double,N> > CachingVertex< N >::AlgebraicSymMatrixNN

Definition at line 30 of file CachingVertex.h.

Definition at line 29 of file CachingVertex.h.

template<unsigned int N>
typedef std::map<RefCountedVertexTrack, AlgebraicMatrixMM > CachingVertex< N >::TrackMap

Definition at line 32 of file CachingVertex.h.

template<unsigned int N>
typedef std::map<RefCountedVertexTrack, TrackMap > CachingVertex< N >::TrackToTrackMap

Definition at line 33 of file CachingVertex.h.

Constructor & Destructor Documentation

template<unsigned int N>
CachingVertex< N >::CachingVertex ( const GlobalPoint pos,
const GlobalError posErr,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq 
)

Constructors

Definition at line 10 of file CachingVertex.cc.

14  : theVertexState(pos, posErr),
15  theChiSquared(totalChiSq), theNDF(0), theNDFAvailable(false),
16  theTracks(tks), theCovMapAvailable(false), withPrior(false),
17  theValid(true)
18 
19 {}
bool theCovMapAvailable
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const GlobalPoint pos,
const GlobalWeight posWeight,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq 
)

Definition at line 24 of file CachingVertex.cc.

28  : theVertexState(pos, posWeight),
29  theChiSquared(totalChiSq), theNDF(0), theNDFAvailable(false),
30  theTracks(tks), theCovMapAvailable(false), withPrior(false),
31  theValid(true)
32 {}
bool theCovMapAvailable
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const AlgebraicVector3 weightTimesPosition,
const GlobalWeight posWeight,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq 
)

Definition at line 37 of file CachingVertex.cc.

41  : theVertexState(weightTimesPosition, posWeight),
42  theChiSquared(totalChiSq), theNDF(0), theNDFAvailable(false),
43  theTracks(tks), theCovMapAvailable(false), withPrior(false),
44  theValid(true)
45 {}
bool theCovMapAvailable
AlgebraicVector3 weightTimesPosition() const
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const GlobalPoint priorPos,
const GlobalError priorErr,
const GlobalPoint pos,
const GlobalError posErr,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq 
)

Definition at line 84 of file CachingVertex.cc.

90  : theVertexState(pos, posErr),
91  theChiSquared(totalChiSq), theNDF(0), theNDFAvailable(false),
92  theTracks(tks), theCovMapAvailable(false),
93  thePriorVertexState(priorPos, priorErr), withPrior(true), theValid(true)
94 {}
bool theCovMapAvailable
VertexState thePriorVertexState
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const GlobalPoint priorPos,
const GlobalError priorErr,
const GlobalPoint pos,
const GlobalWeight posWeight,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq 
)

Definition at line 99 of file CachingVertex.cc.

105  : theVertexState(pos, posWeight),
106  theChiSquared(totalChiSq), theNDF(0), theNDFAvailable(false),
107  theTracks(tks), theCovMapAvailable(false),
108  thePriorVertexState(priorPos, priorErr), withPrior(true), theValid(true)
109 {}
bool theCovMapAvailable
VertexState thePriorVertexState
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const GlobalPoint priorPos,
const GlobalError priorErr,
const AlgebraicVector3 weightTimesPosition,
const GlobalWeight posWeight,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq 
)

Definition at line 114 of file CachingVertex.cc.

120  : theVertexState(weightTimesPosition, posWeight),
121  theChiSquared(totalChiSq), theNDF(0), theNDFAvailable(false),
122  theTracks(tks), theCovMapAvailable(false),
123  thePriorVertexState(priorPos, priorErr), withPrior(true), theValid(true)
124 {}
bool theCovMapAvailable
VertexState thePriorVertexState
AlgebraicVector3 weightTimesPosition() const
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const VertexState aVertexState,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq 
)

Definition at line 48 of file CachingVertex.cc.

51  : theVertexState(aVertexState),
52  theChiSquared(totalChiSq), theNDF(0), theNDFAvailable(false),
53  theTracks(tks), theCovMapAvailable(false), withPrior(false),
54  theValid(true)
55 {}
bool theCovMapAvailable
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const VertexState priorVertexState,
const VertexState aVertexState,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq 
)

Definition at line 72 of file CachingVertex.cc.

76  : theVertexState(aVertexState), theChiSquared(totalChiSq),
77  theNDF(0), theNDFAvailable(false), theTracks(tks),
78  theCovMapAvailable(false), thePriorVertexState(priorVertexState),
79  withPrior(true), theValid(true)
80 {}
bool theCovMapAvailable
VertexState thePriorVertexState
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const VertexState aVertexState,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq,
const TrackToTrackMap covMap 
)

Definition at line 59 of file CachingVertex.cc.

References CachingVertex< N >::theCovMap, and CachingVertex< N >::theCovMapAvailable.

63  : theVertexState(aVertexState),
64  theChiSquared(totalChiSq), theNDF(0), theNDFAvailable(false),
65  theTracks(tks), theCovMap(covMap), theCovMapAvailable(true),
66  withPrior(false), theValid(true)
67 {
68  if (theCovMap.empty()) theCovMapAvailable = false;
69 }
bool theCovMapAvailable
TrackToTrackMap theCovMap
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( const VertexState priorVertexState,
const VertexState aVertexState,
const std::vector< RefCountedVertexTrack > &  tks,
float  totalChiSq,
const TrackToTrackMap covMap 
)

Definition at line 128 of file CachingVertex.cc.

References CachingVertex< N >::theCovMap, and CachingVertex< N >::theCovMapAvailable.

133  : theVertexState(aVertexState), theChiSquared(totalChiSq),
134  theNDF(0), theNDFAvailable(false), theTracks(tks),
135  theCovMap(covMap), theCovMapAvailable(true),
136  thePriorVertexState(priorVertexState), withPrior(true), theValid(true)
137 {
138  if (theCovMap.empty()) theCovMapAvailable = false;
139 }
bool theCovMapAvailable
VertexState thePriorVertexState
TrackToTrackMap theCovMap
std::vector< RefCountedVertexTrack > theTracks
VertexState theVertexState
template<unsigned int N>
CachingVertex< N >::CachingVertex ( )

Constructor for invalid CachingVertex

Definition at line 142 of file CachingVertex.cc.

143  : theChiSquared(-1), theNDF(0), theNDFAvailable(false), theTracks(),
144  theCovMapAvailable(false), withPrior(false),
145  theValid(false)
146 {}
bool theCovMapAvailable
std::vector< RefCountedVertexTrack > theTracks

Member Function Documentation

template<unsigned int N>
void CachingVertex< N >::computeNDF ( ) const
private

Definition at line 185 of file CachingVertex.cc.

186 {
187  theNDF = 0;
188  for (typename std::vector<RefCountedVertexTrack>::const_iterator itk = theTracks.begin();
189  itk != theTracks.end(); ++itk) {
190  theNDF += (**itk).weight(); // adds up weights
191  }
192  theNDF *= 2.; // times 2df for each track
193  if (!withPrior) theNDF -= 3.; // 3 position coordinates fitted
194  theNDFAvailable = true;
195 }
std::vector< RefCountedVertexTrack > theTracks
template<unsigned int N>
float CachingVertex< N >::degreesOfFreedom ( ) const

Definition at line 177 of file CachingVertex.cc.

Referenced by FinalTreeBuilder::buildTree(), fitChi2(), and KinematicVertex::KinematicVertex().

178 {
179  if (!theNDFAvailable) computeNDF();
180  return theNDF;
181 }
void computeNDF() const
template<unsigned int N>
GlobalError CachingVertex< N >::error ( ) const

Definition at line 156 of file CachingVertex.cc.

Referenced by KinematicVertex::KinematicVertex(), trackVertexCompat(), and reco::GhostTrackVertexFinder::vertexCompat().

157 {
158  return theVertexState.error();
159 }
GlobalError error() const
Definition: VertexState.h:55
VertexState theVertexState
template<unsigned int N>
bool CachingVertex< N >::hasPrior ( ) const
inline
template<unsigned int N>
bool CachingVertex< N >::isValid ( void  ) const
inline
template<unsigned int N>
CachingVertex< N >::operator TransientVertex ( ) const

Definition at line 238 of file CachingVertex.cc.

References i, j, TransientVertex::refittedTracks(), reco::t2, TransientVertex::tkToTkCovariance(), and TransientVertex::weightMap().

239 {
240  //If the vertex is invalid, return an invalid TV !
241  if (!isValid()) return TransientVertex();
242 
243  typedef std::map<reco::TransientTrack, float> TransientTrackToFloatMap;
244 
245 // Construct Track vector
246  std::vector<reco::TransientTrack> ttVect;
247  ttVect.reserve(theTracks.size());
248  std::vector<reco::TransientTrack> refTTVect;
249  TransientTrackToFloatMap theWeightMap;
250  TTtoTTmap ttCovMap;
251  // float theMinWeight = 0.5;
252 
253  for (typename std::vector<RefCountedVertexTrack>::const_iterator i = theTracks.begin();
254  i != theTracks.end(); ++i) {
255  // discard tracks with too low weight
256  // if ((**i).weight() < theMinWeight) continue;
257 
258  reco::TransientTrack t1((**i).linearizedTrack()->track());
259  ttVect.push_back(t1);
260  //Fill in the weight map
261  theWeightMap[t1] = (**i).weight();
262 
263  //Fill in the tk-to-tk covariance map
264  if (theCovMapAvailable) {
265  for (typename std::vector<RefCountedVertexTrack>::const_iterator j = (i+1);
266  j != theTracks.end(); ++j) {
267  reco::TransientTrack t2((**j).linearizedTrack()->track());
268  ttCovMap[t1][t2] = tkToTkCovariance(*i, *j);
269  }
270  }
271  if ((**i).refittedStateAvailable()) {
272  refTTVect.push_back( (**i).refittedState()->transientTrack()) ;
273  }
274  }
275  TransientVertex tv;
276  if (withPrior) {
278  } else {
280  }
281  tv.weightMap(theWeightMap);
282  if (theCovMapAvailable) tv.tkToTkCovariance(ttCovMap);
283  if (!refTTVect.empty()) tv.refittedTracks(refTTVect);
284  return tv;
285 }
int i
Definition: DBlmapReader.cc:9
bool theCovMapAvailable
VertexState const & vertexState() const
Definition: CachingVertex.h:85
std::map< reco::TransientTrack, TTmap > TTtoTTmap
Definition: TTtoTTmap.h:12
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
float totalChiSquared() const
int j
Definition: DBlmapReader.cc:9
float degreesOfFreedom() const
std::vector< RefCountedVertexTrack > theTracks
VertexState const & priorVertexState() const
Definition: CachingVertex.h:86
AlgebraicMatrixMM tkToTkCovariance(const RefCountedVertexTrack t1, const RefCountedVertexTrack t2) const
bool isValid() const
Definition: CachingVertex.h:96
std::vector< reco::TransientTrack > const & refittedTracks() const
AlgebraicMatrix33 tkToTkCovariance(const reco::TransientTrack &t1, const reco::TransientTrack &t2) const
TransientTrackToFloatMap weightMap() const
template<unsigned int N>
GlobalPoint CachingVertex< N >::position ( ) const
template<unsigned int N>
GlobalError CachingVertex< N >::priorError ( ) const
inline

Definition at line 94 of file CachingVertex.h.

Referenced by GsfVertexUpdator::add(), GsfVertexMerger::merge(), and SequentialVertexSmoother< N >::smooth().

94 {return priorVertexState().error();}
VertexState const & priorVertexState() const
Definition: CachingVertex.h:86
GlobalError error() const
Definition: VertexState.h:55
template<unsigned int N>
GlobalPoint CachingVertex< N >::priorPosition ( ) const
inline

Definition at line 93 of file CachingVertex.h.

Referenced by GsfVertexUpdator::add(), GsfVertexMerger::merge(), and SequentialVertexSmoother< N >::smooth().

93 {return priorVertexState().position();}
GlobalPoint position() const
Definition: VertexState.h:50
VertexState const & priorVertexState() const
Definition: CachingVertex.h:86
template<unsigned int N>
VertexState const& CachingVertex< N >::priorVertexState ( ) const
inline
template<unsigned int N>
CachingVertex< N >::AlgebraicMatrixMM CachingVertex< N >::tkToTkCovariance ( const RefCountedVertexTrack  t1,
const RefCountedVertexTrack  t2 
) const

Track to track covariance

Definition at line 200 of file CachingVertex.cc.

References reco::t2.

Referenced by FinalTreeBuilder::momentumPart(), and InvariantMassFromVertex::uncertainty().

202 {
204  throw VertexException("CachingVertex::TkTkCovariance requested before been calculated");
205  }
206  else {
209  bool transp = false;
210  if(t1 < t2) {
211  tr1 = t1;
212  tr2 = t2;
213  }
214  else {
215  tr1 = t2;
216  tr2 = t1;
217  transp = true;
218  }
219  typename TrackToTrackMap::const_iterator it = theCovMap.find(tr1);
220  if (it != theCovMap.end()) {
221  const TrackMap & tm = it->second;
222  typename TrackMap::const_iterator nit = tm.find(tr2);
223  if (nit != tm.end()) {
224  if (transp) return( ROOT::Math::Transpose(nit->second) );
225  else return( nit->second);
226  }
227  else {
228  throw VertexException("CachingVertex::requested TkTkCovariance does not exist");
229  }
230  }
231  else {
232  throw VertexException("CachingVertex::requested TkTkCovariance does not exist");
233  }
234  }
235 }
Common base class.
TrackToTrackMap theCovMap
ReferenceCountingPointer< VertexTrack< N > > RefCountedVertexTrack
Definition: CachingVertex.h:29
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
std::map< RefCountedVertexTrack, AlgebraicMatrixMM > TrackMap
Definition: CachingVertex.h:32
bool tkToTkCovarianceIsAvailable() const
template<unsigned int N>
bool CachingVertex< N >::tkToTkCovarianceIsAvailable ( ) const
inline
template<unsigned int N>
float CachingVertex< N >::totalChiSquared ( ) const
inline
template<unsigned int N>
std::vector<RefCountedVertexTrack> const& CachingVertex< N >::tracks ( void  ) const
inline
template<unsigned int N>
std::vector<RefCountedVertexTrack> const& CachingVertex< N >::tracksRef ( ) const
inline

Definition at line 92 of file CachingVertex.h.

Referenced by KalmanVertexTrackCompatibilityEstimator< N >::estimate().

92 { return theTracks; }
std::vector< RefCountedVertexTrack > theTracks
template<unsigned int N>
VertexState const& CachingVertex< N >::vertexState ( ) const
inline
template<unsigned int N>
GlobalWeight CachingVertex< N >::weight ( void  ) const
template<unsigned int N>
AlgebraicVector3 CachingVertex< N >::weightTimesPosition ( ) const

Definition at line 170 of file CachingVertex.cc.

171 {
173 }
AlgebraicVector3 weightTimesPosition() const
Definition: VertexState.h:65
VertexState theVertexState

Member Data Documentation

template<unsigned int N>
float CachingVertex< N >::theChiSquared
private

Definition at line 116 of file CachingVertex.h.

Referenced by CachingVertex< 5 >::totalChiSquared().

template<unsigned int N>
TrackToTrackMap CachingVertex< N >::theCovMap
private

Definition at line 120 of file CachingVertex.h.

Referenced by CachingVertex< N >::CachingVertex().

template<unsigned int N>
bool CachingVertex< N >::theCovMapAvailable
private
template<unsigned int N>
float CachingVertex< N >::theNDF
mutableprivate

Definition at line 117 of file CachingVertex.h.

template<unsigned int N>
bool CachingVertex< N >::theNDFAvailable
mutableprivate

Definition at line 118 of file CachingVertex.h.

template<unsigned int N>
VertexState CachingVertex< N >::thePriorVertexState
mutableprivate

Definition at line 122 of file CachingVertex.h.

Referenced by CachingVertex< 5 >::priorVertexState().

template<unsigned int N>
std::vector<RefCountedVertexTrack> CachingVertex< N >::theTracks
private

Definition at line 119 of file CachingVertex.h.

Referenced by CachingVertex< 5 >::tracks(), and CachingVertex< 5 >::tracksRef().

template<unsigned int N>
bool CachingVertex< N >::theValid
private

Definition at line 125 of file CachingVertex.h.

Referenced by CachingVertex< 5 >::isValid().

template<unsigned int N>
VertexState CachingVertex< N >::theVertexState
mutableprivate

Definition at line 115 of file CachingVertex.h.

Referenced by CachingVertex< 5 >::vertexState().

template<unsigned int N>
bool CachingVertex< N >::withPrior
private

Definition at line 123 of file CachingVertex.h.

Referenced by CachingVertex< 5 >::hasPrior().