CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MRHChi2MeasurementEstimator.cc
Go to the documentation of this file.
11 
13  const TrackingRecHit& aRecHit) const {
14 
15  switch (aRecHit.dimension()) {
16  case 2: return estimate<2>(tsos,aRecHit);
17  //avoid the not-2D hit due to the final sum
18  case ( 1 || 3 || 4 || 5 ):{
19  LogDebug("MRHChi2MeasurementEstimator") << "WARNING:The hit is not 2D: does not count in the MRH Chi2 estimation." ;
20  double est = 0.0;
21  return HitReturnType(false, est);
22  }
23  }
24  throw cms::Exception("Rec hit of invalid dimension (not 1,2,3,4,5)") <<
25  "The value was " << aRecHit.dimension() <<
26  ", type is " << typeid(aRecHit).name() << "\n";
27 }
28 
29 //---------------------------------------------------------------------------------------------------------------
30 template <unsigned int N>
31 std::pair<bool, double> MRHChi2MeasurementEstimator::estimate(const TrajectoryStateOnSurface& tsos,
32  const TrackingRecHit& aRecHit) const {
33 
34  SiTrackerMultiRecHit const & mHit = dynamic_cast<SiTrackerMultiRecHit const &>(aRecHit);
35  double est=0;
36 
37  double annealing = mHit.getAnnealingFactor();
38  LogDebug("MRHChi2MeasurementEstimator") << "Current annealing factor is " << annealing;
39 
40  std::vector<const TrackingRecHit*> components = mHit.recHits();
41  LogDebug("MRHChi2MeasurementEstimator") << "this hit has " << components.size() << " components";
42 
43  int iComp = 0;
44  for(std::vector<const TrackingRecHit*>::const_iterator iter = components.begin(); iter != components.end(); iter++, iComp++){
45 
46  // define variables that will be used to setup the KfComponentsHolder
48  typename AlgebraicROOTObject<N>::Vector r, rMeas;
49  typename AlgebraicROOTObject<N,N>::SymMatrix V, VMeas;
51  const AlgebraicSymMatrix55 &C = (tsos.localError().matrix());
52 
53  // setup the holder with the correct dimensions and get the values
54  KfComponentsHolder holder;
55  holder.template setup<N>(&r, &V, &pf, &rMeas, &VMeas, x, C);
56  (**iter).getKfComponents(holder);
57 
58  r -= rMeas;
59  V = V*annealing + VMeas;
60  bool ierr = invertPosDefMatrix(V);
61  if( !ierr ) {
62  edm::LogError("SiTrackerMultiRecHitUpdator")<<"SiTrackerMultiRecHitUpdator::ComputeParameters2dim: W not valid!"<<std::endl;
63  }
64 
65  LogDebug("MRHChi2MeasurementEstimator") << "Hit with weight " << mHit.weight(iComp);
66  est += ROOT::Math::Similarity(r, V)*mHit.weight(iComp);
67 
68  }
69 
70  return returnIt(est);
71 
72 }
73 
#define LogDebug(id)
virtual int dimension() const =0
ROOT::Math::SMatrix< double, D1, D1, ROOT::Math::MatRepSym< double, D1 > > SymMatrix
std::pair< bool, double > returnIt(double est) const
const LocalTrajectoryParameters & localParameters() const
virtual double getAnnealingFactor() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
float weight(unsigned int i) const
AlgebraicVector5 vector() const
virtual std::vector< const TrackingRecHit * > recHits() const
Access to component RecHits (if any)
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
std::pair< bool, double > HitReturnType
ROOT::Math::SVector< double, D1 > Vector
ROOT::Math::SVector< double, 5 > AlgebraicVector5
std::pair< bool, double > estimate(const TrajectoryStateOnSurface &tsos, const TrackingRecHit &aRecHit) const
Definition: DDAxes.h:10