CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SiTrackerMultiRecHitUpdator Class Reference

#include <SiTrackerMultiRecHitUpdator.h>

Public Types

typedef std::pair< LocalPoint, LocalErrorLocalParameters
 

Public Member Functions

const std::vector< double > & annealingProgram () const
 
virtual TransientTrackingRecHit::RecHitPointer buildMultiRecHit (const std::vector< const TrackingRecHit *> &rhv, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, float annealing=1.) const
 
double ComputeWeight (const TrajectoryStateOnSurface &tsos, const TransientTrackingRecHit &aRecHit, bool CutWeight, double annealing=1.) const
 
template<unsigned int N>
double ComputeWeight (const TrajectoryStateOnSurface &tsos, const TransientTrackingRecHit &aRecHit, bool CutWeight, double annealing=1.) const
 
const std::vector< double > & getAnnealingProgram () const
 
const TransientTrackingRecHitBuildergetBuilder () const
 
 SiTrackerMultiRecHitUpdator (const TransientTrackingRecHitBuilder *builder, const TrackingRecHitPropagator *hitpropagator, const float Chi2Cut1D, const float Chi2Cut2D, const std::vector< double > &anAnnealingProgram, bool debug)
 
virtual TransientTrackingRecHit::RecHitPointer update (TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
 
TransientTrackingRecHit::RecHitPointer update (TransientTrackingRecHit::ConstRecHitContainer &tcomponents, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
 
virtual ~SiTrackerMultiRecHitUpdator ()
 

Private Member Functions

LocalParameters calcParameters (const TrajectoryStateOnSurface &tsos, std::vector< std::pair< const TrackingRecHit *, float > > &aHitMap) const
 
template<unsigned int N>
LocalParameters calcParameters (const TrajectoryStateOnSurface &tsos, std::vector< std::pair< const TrackingRecHit *, float > > &aHitMap) const
 
bool TIDorTEChit (const TrackingRecHit *const &hit) const
 

Private Attributes

bool debug_
 
const std::vector< double > theAnnealingProgram
 
const TransientTrackingRecHitBuildertheBuilder
 
double theChi2Cut1D
 
double theChi2Cut2D
 
TkClonerImpl theHitCloner
 
const TrackingRecHitPropagatortheHitPropagator
 

Detailed Description

Builds a SiTrackerMultiRecHit out of a vector of TrackingRecHit or updates an existing SiTrackerMultiRecHit given a tsos.

Author
tropiano, genta in May 2014 by brondolin

Definition at line 27 of file SiTrackerMultiRecHitUpdator.h.

Member Typedef Documentation

◆ LocalParameters

Definition at line 29 of file SiTrackerMultiRecHitUpdator.h.

Constructor & Destructor Documentation

◆ SiTrackerMultiRecHitUpdator()

SiTrackerMultiRecHitUpdator::SiTrackerMultiRecHitUpdator ( const TransientTrackingRecHitBuilder builder,
const TrackingRecHitPropagator hitpropagator,
const float  Chi2Cut1D,
const float  Chi2Cut2D,
const std::vector< double > &  anAnnealingProgram,
bool  debug 
)

Definition at line 17 of file SiTrackerMultiRecHitUpdator.cc.

References runTheMatrix::const, and theHitCloner.

23  : theBuilder(builder),
24  theHitPropagator(hitpropagator),
25  theChi2Cut1D(Chi2Cut1D),
26  theChi2Cut2D(Chi2Cut2D),
27  theAnnealingProgram(anAnnealingProgram),
28  debug_(debug) {
29  theHitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(builder)->cloner();
30 }
const std::vector< double > theAnnealingProgram
const TrackingRecHitPropagator * theHitPropagator
const TransientTrackingRecHitBuilder * theBuilder
#define debug
Definition: HDRShower.cc:19

◆ ~SiTrackerMultiRecHitUpdator()

virtual SiTrackerMultiRecHitUpdator::~SiTrackerMultiRecHitUpdator ( )
inlinevirtual

Definition at line 36 of file SiTrackerMultiRecHitUpdator.h.

36 {};

Member Function Documentation

◆ annealingProgram()

const std::vector<double>& SiTrackerMultiRecHitUpdator::annealingProgram ( ) const
inline

Definition at line 68 of file SiTrackerMultiRecHitUpdator.h.

References theAnnealingProgram.

68 { return theAnnealingProgram; }
const std::vector< double > theAnnealingProgram

◆ buildMultiRecHit()

TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::buildMultiRecHit ( const std::vector< const TrackingRecHit *> &  rhv,
const TrajectoryStateOnSurface tsos,
MeasurementDetWithData measDet,
float  annealing = 1. 
) const
virtual

Definition at line 32 of file SiTrackerMultiRecHitUpdator.cc.

References TransientTrackingRecHitBuilder::build(), LogTrace, theBuilder, and update().

36  {
37  LogTrace("SiTrackerMultiRecHitUpdator")
38  << "Calling SiTrackerMultiRecHitUpdator::buildMultiRecHit with AnnealingFactor: " << annealing;
39 
41  for (std::vector<const TrackingRecHit*>::const_iterator iter = rhv.begin(); iter != rhv.end(); iter++) {
43  if (transient->isValid())
44  tcomponents.push_back(transient);
45  }
46  return update(tcomponents, tsos, measDet, annealing);
47 }
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
#define LogTrace(id)
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
const TransientTrackingRecHitBuilder * theBuilder
std::shared_ptr< TrackingRecHit const > RecHitPointer
std::vector< ConstRecHitPointer > ConstRecHitContainer

◆ calcParameters() [1/2]

SiTrackerMultiRecHitUpdator::LocalParameters SiTrackerMultiRecHitUpdator::calcParameters ( const TrajectoryStateOnSurface tsos,
std::vector< std::pair< const TrackingRecHit *, float > > &  aHitMap 
) const
private

Definition at line 298 of file SiTrackerMultiRecHitUpdator.cc.

References Exception, dqmdumpme::first, LogTrace, and Skims_PA_cff::name.

Referenced by update().

299  {
300  //supposing all the hits inside of a MRH have the same dimension
301  LogTrace("SiTrackerMultiRecHitUpdator")
302  << "SiTrackerMultiRecHitUpdator::LocalParameters: dim first recHit: " << aHitMap[0].first->dimension()
303  << std::endl;
304  switch (aHitMap[0].first->dimension()) {
305  case 1:
306  return calcParameters<1>(tsos, aHitMap);
307  case 2:
308  return calcParameters<2>(tsos, aHitMap);
309  }
310  throw cms::Exception("Rec hit of invalid dimension for computing MRH (not 1,2)")
311  << "The value was " << aHitMap[0].first->dimension() << ", type is " << typeid(aHitMap[0].first).name() << "\n";
312 }
#define LogTrace(id)

◆ calcParameters() [2/2]

template<unsigned int N>
SiTrackerMultiRecHitUpdator::LocalParameters SiTrackerMultiRecHitUpdator::calcParameters ( const TrajectoryStateOnSurface tsos,
std::vector< std::pair< const TrackingRecHit *, float > > &  aHitMap 
) const
private

Definition at line 316 of file SiTrackerMultiRecHitUpdator.cc.

References correctionTermsCaloMet_cff::C, relativeConstraints::error, f, invertPosDefMatrix(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LogTrace, LocalTrajectoryError::matrix(), SiStripPI::max, N, packedPFCandidateRefMixer_cfi::pf, position, alignCSCRings::r, alignCSCRings::s, TIDorTEChit(), cms::cuda::V, trackerHitRTTI::vector, LocalTrajectoryParameters::vector(), and x.

317  {
318  typedef typename AlgebraicROOTObject<N, N>::SymMatrix SMatNN;
319  typedef typename AlgebraicROOTObject<N>::Vector VecN;
320 
321  VecN m_sum;
322  SMatNN W_sum;
325 
326  //for TID and TEC the correlation is really high -> need to be scorrelated and then correlated again
327  float s = 0.1;
328 
329  for (std::vector<std::pair<const TrackingRecHit*, float> >::const_iterator ihit = aHitMap.begin();
330  ihit != aHitMap.end();
331  ihit++) {
332  // define variables that will be used to setup the KfComponentsHolder
334  typename AlgebraicROOTObject<N>::Vector r, rMeas;
335  typename AlgebraicROOTObject<N, N>::SymMatrix V, VMeas, Wtemp;
337  const AlgebraicSymMatrix55& C = (tsos.localError().matrix());
338 
339  // setup the holder with the correct dimensions and get the values
340  KfComponentsHolder holder;
341  holder.template setup<N>(&r, &V, &pf, &rMeas, &VMeas, x, C);
342  (ihit->first)->getKfComponents(holder);
343 
344  LogTrace("SiTrackerMultiRecHitUpdator") << "\t position: " << r;
345  LogTrace("SiTrackerMultiRecHitUpdator") << "\t error: " << V;
346 
347  //scorrelation in TID and TEC
348  if (N == 2 && TIDorTEChit(ihit->first)) {
349  V(0, 1) = V(1, 0) = V(0, 1) * s;
350  // V(1,0) = V(1,0)*s;
351  LogTrace("SiTrackerMultiRecHitUpdator") << "\t error scorr: " << V;
352  }
353 
354  bool ierr = invertPosDefMatrix(V);
355  if (!ierr) {
356  edm::LogError("SiTrackerMultiRecHitUpdator") << "SiTrackerMultiRecHitUpdator::calcParameters: V not valid!";
357  }
358  LogTrace("SiTrackerMultiRecHitUpdator") << "\t inverse error: " << V;
359 
360  //compute m_sum and W_sum
361  m_sum += (ihit->second * V * r);
362  W_sum += (ihit->second * V);
363  }
364 
365  bool ierr_sum = invertPosDefMatrix(W_sum);
366  if (!ierr_sum) {
367  edm::LogError("SiTrackerMultiRecHitUpdator") << "SiTrackerMultiRecHitUpdator::calcParameters: W_sum not valid!";
368  }
369 
370  LogTrace("SiTrackerMultiRecHitUpdator") << "\t inverse total error: " << W_sum;
371  typename AlgebraicROOTObject<N>::Vector parameters = W_sum * m_sum;
372  if (N == 1) {
373  position = LocalPoint(parameters(0), 0.f);
374  error = LocalError(W_sum(0, 0), 0.f, std::numeric_limits<float>::max());
375  } else if (N == 2) {
377  //ri-correlation in TID and TEC
378  if (TIDorTEChit(aHitMap.at(0).first))
379  error = LocalError(W_sum(0, 0), W_sum(0, 1) / s, W_sum(1, 1));
380  else
381  error = LocalError(W_sum(0, 0), W_sum(0, 1), W_sum(1, 1));
382  }
383 
384  return std::make_pair(position, error);
385 }
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
const LocalTrajectoryError & localError() const
ROOT::Math::SMatrix< double, D1, D1, ROOT::Math::MatRepSym< double, D1 > > SymMatrix
const LocalTrajectoryParameters & localParameters() const
Log< level::Error, false > LogError
#define LogTrace(id)
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t V
AlgebraicVector5 vector() const
bool TIDorTEChit(const TrackingRecHit *const &hit) const
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
double f[11][100]
#define N
Definition: blowfish.cc:9
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
ROOT::Math::SVector< double, D1 > Vector
static int position[264][3]
Definition: ReadPGInfo.cc:289
const AlgebraicSymMatrix55 & matrix() const

◆ ComputeWeight() [1/2]

double SiTrackerMultiRecHitUpdator::ComputeWeight ( const TrajectoryStateOnSurface tsos,
const TransientTrackingRecHit aRecHit,
bool  CutWeight,
double  annealing = 1. 
) const

Definition at line 193 of file SiTrackerMultiRecHitUpdator.cc.

References TrackingRecHit::dimension(), Exception, and Skims_PA_cff::name.

Referenced by update().

196  {
197  switch (aRecHit.dimension()) {
198  case 1:
199  return ComputeWeight<1>(tsos, aRecHit, CutWeight, annealing);
200  case 2:
201  return ComputeWeight<2>(tsos, aRecHit, CutWeight, annealing);
202  case 3:
203  return ComputeWeight<3>(tsos, aRecHit, CutWeight, annealing);
204  case 4:
205  return ComputeWeight<4>(tsos, aRecHit, CutWeight, annealing);
206  case 5:
207  return ComputeWeight<5>(tsos, aRecHit, CutWeight, annealing);
208  }
209  throw cms::Exception("Rec hit of invalid dimension (not 1,2,3,4,5)")
210  << "The value was " << aRecHit.dimension() << ", type is " << typeid(aRecHit).name() << "\n";
211 }
virtual int dimension() const =0

◆ ComputeWeight() [2/2]

template<unsigned int N>
double SiTrackerMultiRecHitUpdator::ComputeWeight ( const TrajectoryStateOnSurface tsos,
const TransientTrackingRecHit aRecHit,
bool  CutWeight,
double  annealing = 1. 
) const

Definition at line 215 of file SiTrackerMultiRecHitUpdator.cc.

References correctionTermsCaloMet_cff::C, RecoSummaryTask_cfi::Chi2, change_name::diff, JetChargeProducer_cfi::exp, TrackingRecHit::getKfComponents(), invertPosDefMatrix(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LogTrace, LocalTrajectoryError::matrix(), N, packedPFCandidateRefMixer_cfi::pf, dttmaxenums::R, alignCSCRings::r, theChi2Cut1D, theChi2Cut2D, LocalTrajectoryParameters::vector(), and x.

218  {
219  // typedef typename AlgebraicROOTObject<N,5>::Matrix MatN5;
220  // typedef typename AlgebraicROOTObject<5,N>::Matrix Mat5N;
221  // typedef typename AlgebraicROOTObject<N,N>::SymMatrix SMatNN;
222  // typedef typename AlgebraicROOTObject<N>::Vector VecN;
223 
224  // define variables that will be used to setup the KfComponentsHolder
226  typename AlgebraicROOTObject<N>::Vector r, rMeas;
227  typename AlgebraicROOTObject<N, N>::SymMatrix R, RMeas, W;
229  const AlgebraicSymMatrix55& C = (tsos.localError().matrix());
230 
231  // setup the holder with the correct dimensions and get the values
232  KfComponentsHolder holder;
233  holder.template setup<N>(&r, &R, &pf, &rMeas, &RMeas, x, C);
234  aRecHit.getKfComponents(holder);
235 
236  typename AlgebraicROOTObject<N>::Vector diff = r - rMeas;
237 
238  if (!CutWeight) {
239  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t r:" << r;
240  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t tsospos:" << rMeas;
241  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t diff:" << diff;
242  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t R:" << R;
243  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t RMeas:" << RMeas;
244  }
245 
246  R += RMeas; //assume that TSOS is predicted || comb one
247  if (!CutWeight)
248  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t R+RMeas:" << R;
249 
250  //computing chi2 with the smoothTsos
251  // SMatNN R_smooth = R - RMeas;
252  // if(!CutWeight) LogTrace("SiTrackerMultiRecHitUpdator")<< "\t\t R-=Rmeas:" << R_smooth ;
253  // bool ierr2_bis = invertPosDefMatrix(R_smooth);
254  // double Chi2_smooth = ROOT::Math::Similarity(diff, R_smooth);
255 
256  //computing chi2 with the smoothTsos
257  //SMatNN R_pred = R + RMeas;
258  //if(!CutWeight) LogTrace("SiTrackerMultiRecHitUpdator")<< "\t\t R+=Rmeas:" << R_pred ;
259  //bool ierr2_bis = invertPosDefMatrix(R_pred );
260  //double Chi2_pred = ROOT::Math::Similarity(diff, R_pred );
261 
262  //Det2 method will preserve the content of the Matrix
263  //and return true when the calculation is successfull
264  double det;
265  bool ierr = R.Det2(det);
266 
267  bool ierr2 = invertPosDefMatrix(R); //ierr will be set to true when inversion is successfull
268  double Chi2 = ROOT::Math::Similarity(diff, R);
269 
270  if (!ierr || !ierr2) {
271  LogTrace("SiTrackerMultiRecHitUpdator") << "SiTrackerMultiRecHitUpdator::ComputeWeight: W not valid!" << std::endl;
272  LogTrace("SiTrackerMultiRecHitUpdator") << "V: " << R << " AnnealingFactor: " << annealing << std::endl;
273  }
274 
275  if (!CutWeight) {
276  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t det:" << det;
277  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t Chi2:" << Chi2;
278  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t Chi2/ann:" << Chi2 / annealing;
279  }
280 
281  double temp_weight = 0.0;
282  if (CutWeight && N == 1) {
283  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t Chi2Cut1D:" << theChi2Cut1D;
284  temp_weight = exp(-0.5 * theChi2Cut1D / annealing);
285  } else if (CutWeight && N == 2) {
286  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t Chi2Cut2D:" << theChi2Cut2D;
287  temp_weight = exp(-0.5 * theChi2Cut2D / annealing);
288  }
289 
290  if (!CutWeight) {
291  temp_weight = exp(-0.5 * Chi2 / annealing);
292  }
293 
294  return temp_weight;
295 }
const LocalTrajectoryError & localError() const
ROOT::Math::SMatrix< double, D1, D1, ROOT::Math::MatRepSym< double, D1 > > SymMatrix
const LocalTrajectoryParameters & localParameters() const
#define LogTrace(id)
AlgebraicVector5 vector() const
bool invertPosDefMatrix(ROOT::Math::SMatrix< T, N, N, ROOT::Math::MatRepSym< T, N > > &m)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
#define N
Definition: blowfish.cc:9
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
ROOT::Math::SVector< double, D1 > Vector
const AlgebraicSymMatrix55 & matrix() const
Definition: Chi2.h:15
virtual void getKfComponents(KfComponentsHolder &holder) const

◆ getAnnealingProgram()

const std::vector<double>& SiTrackerMultiRecHitUpdator::getAnnealingProgram ( ) const
inline

Definition at line 69 of file SiTrackerMultiRecHitUpdator.h.

References theAnnealingProgram.

69 { return theAnnealingProgram; }
const std::vector< double > theAnnealingProgram

◆ getBuilder()

const TransientTrackingRecHitBuilder* SiTrackerMultiRecHitUpdator::getBuilder ( ) const
inline

Definition at line 71 of file SiTrackerMultiRecHitUpdator.h.

References theBuilder.

Referenced by SimpleDAFHitCollector::SimpleDAFHitCollector().

71 { return theBuilder; }
const TransientTrackingRecHitBuilder * theBuilder

◆ TIDorTEChit()

bool SiTrackerMultiRecHitUpdator::TIDorTEChit ( const TrackingRecHit *const &  hit) const
private

Definition at line 387 of file SiTrackerMultiRecHitUpdator.cc.

References DetId::det(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TID, and DetId::Tracker.

Referenced by calcParameters().

387  {
388  DetId hitId = hit->geographicalId();
389 
390  if (hitId.det() == DetId::Tracker &&
391  (hitId.subdetId() == StripSubdetector::TEC || hitId.subdetId() == StripSubdetector::TID)) {
392  return true;
393  }
394 
395  return false;
396 }
static constexpr auto TEC
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
static constexpr auto TID

◆ update() [1/2]

TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::update ( TransientTrackingRecHit::ConstRecHitPointer  original,
const TrajectoryStateOnSurface tsos,
MeasurementDetWithData measDet,
double  annealing = 1. 
) const
virtual

Definition at line 49 of file SiTrackerMultiRecHitUpdator.cc.

References Exception, TrajectoryStateOnSurface::isValid(), LogTrace, TkClonerImpl::makeShared(), definitions::original, and theHitCloner.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), buildMultiRecHit(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

53  {
54  LogTrace("SiTrackerMultiRecHitUpdator")
55  << "Calling SiTrackerMultiRecHitUpdator::update with AnnealingFactor: " << annealing;
56 
57  if (!tsos.isValid()) {
58  //return original->clone();
59  throw cms::Exception("SiTrackerMultiRecHitUpdator") << "!!! MultiRecHitUpdator::update(..): tsos NOT valid!!! ";
60  }
61 
62  //check if to clone is the right thing
63  if (original->isValid()) {
64  if (original->transientHits().empty()) {
65  return theHitCloner.makeShared(original, tsos);
66  }
67  } else {
68  return theHitCloner.makeShared(original, tsos);
69  }
70 
71  TransientTrackingRecHit::ConstRecHitContainer tcomponents = original->transientHits();
72  return update(tcomponents, tsos, measDet, annealing);
73 }
virtual TransientTrackingRecHit::RecHitPointer update(TransientTrackingRecHit::ConstRecHitPointer original, const TrajectoryStateOnSurface &tsos, MeasurementDetWithData &measDet, double annealing=1.) const
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:64
#define LogTrace(id)
std::vector< ConstRecHitPointer > ConstRecHitContainer

◆ update() [2/2]

TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::update ( TransientTrackingRecHit::ConstRecHitContainer tcomponents,
const TrajectoryStateOnSurface tsos,
MeasurementDetWithData measDet,
double  annealing = 1. 
) const

Definition at line 76 of file SiTrackerMultiRecHitUpdator.cc.

References calcParameters(), cropTnPTrees::cloned, ComputeWeight(), counter, MillePedeFileConverter_cfg::e, Exception, dqmdumpme::first, MeasurementDet::geomDet(), invalid, TrajectoryStateOnSurface::isValid(), LogTrace, TkClonerImpl::makeShared(), MeasurementDetWithData::mdet(), TrackingRecHit::missing, Skims_PA_cff::name, AlCaHLTBitMon_ParallelJobs::p, GloballyPositioned< T >::position(), TrackingRecHitPropagator::project(), edm::second(), TrajectoryStateOnSurface::surface(), theBuilder, theHitCloner, theHitPropagator, and createJobs::tmp.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

80  {
81  if (tcomponents.empty()) {
82  LogTrace("SiTrackerMultiRecHitUpdator") << "Empty components vector passed to SiTrackerMultiRecHitUpdator::update, "
83  "returning an InvalidTransientRecHit ";
84  return std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing);
85  }
86 
87  if (!tsos.isValid()) {
88  LogTrace("SiTrackerMultiRecHitUpdator")
89  << "SiTrackerMultiRecHitUpdator::update: tsos NOT valid!!!, returning an InvalidTransientRecHit";
90  return std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing);
91  }
92 
93  std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents;
94  const GeomDet* geomdet = nullptr;
95 
96  //running on all over the MRH components
97  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator iter = tcomponents.begin();
98  iter != tcomponents.end();
99  iter++) {
100  //the first rechit must belong to the same surface of TSOS
101  if (iter == tcomponents.begin()) {
102  if (&((*iter)->det()->surface()) != &(tsos.surface())) {
103  throw cms::Exception("SiTrackerMultiRecHitUpdator")
104  << "the Trajectory state and the first rechit "
105  "passed to the SiTrackerMultiRecHitUpdator lay on different surfaces!: state lays on surface "
106  << tsos.surface().position() << " hit with detid " << (*iter)->det()->geographicalId().rawId()
107  << " lays on surface " << (*iter)->det()->surface().position();
108  }
109 
110  geomdet = (*iter)->det();
111  }
112 
113  //if the rechit does not belong to the surface of the tsos
114  //GenericProjectedRecHit2D is used to prepagate
115  if (&((*iter)->det()->surface()) != &(tsos.surface())) {
118  //if it is used a sensor by sensor grouping this should not appear
119  if (cloned->isValid())
120  updatedcomponents.push_back(cloned);
121 
122  } else {
124  if (cloned->isValid()) {
125  updatedcomponents.push_back(cloned);
126  }
127  }
128  }
129 
130  std::vector<std::pair<const TrackingRecHit*, float> > mymap;
131  std::vector<std::pair<const TrackingRecHit*, float> > normmap;
132 
133  double a_sum = 0, c_sum = 0;
134 
135  for (std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin();
136  ihit != updatedcomponents.end();
137  ihit++) {
138  double a_i = ComputeWeight(tsos, *(*ihit), false, annealing); //exp(-0.5*Chi2)
139  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t a_i:" << a_i;
140  //double c_i = ComputeWeight(tsos, *(*ihit), true, annealing); //exp(-0.5*theChi2Cut/annealing)/(2.*M_PI*sqrt(det));
141  //LogTrace("SiTrackerMultiRecHitUpdator")<< "\t\t c_i:" << c_i ;
142  mymap.push_back(std::pair<const TrackingRecHit*, float>((*ihit)->hit(), a_i));
143 
144  a_sum += a_i;
145  //with the new definition, the cut weight is computed only once
146  if (ihit == updatedcomponents.begin())
147  c_sum = ComputeWeight(tsos, *(*ihit), true, annealing); //exp(-0.5*theChi2Cut/annealing)
148  }
149  double total_sum = a_sum + c_sum;
150  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t c_sum:" << c_sum;
151  LogTrace("SiTrackerMultiRecHitUpdator") << "\t\t total sum:" << total_sum;
152 
153  unsigned int counter = 0;
154  bool invalid = true;
155  for (std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin();
156  ihit != updatedcomponents.end();
157  ihit++) {
158  double p = ((mymap[counter].second) / total_sum > 1.e-12 ? (mymap[counter].second) / total_sum : 1.e-12);
159  //ORCA: float p = ((mymap[counter].second)/total_sum > 0.01 ? (mymap[counter].second)/total_sum : 1.e-6);
160 
161 #ifdef EDM_ML_DEBUG
162  auto const& tmp = *mymap[counter].first;
163  LogTrace("SiTrackerMultiRecHitUpdator")
164  << " Component hit type " << typeid(tmp).name() << " and dim:" << tmp.dimension() << " position (PRECISE!!!)"
165  << tmp.localPosition() << " error " << tmp.localPositionError() << " with weight " << p;
166 #endif
167 
168  if (p > 10e-6) {
169  invalid = false;
170  normmap.push_back(std::pair<const TrackingRecHit*, float>(mymap[counter].first, p));
171  }
172 
173  counter++;
174  }
175 
176  if (!invalid) {
178  SiTrackerMultiRecHit updated(param.first, param.second, *normmap.front().first->det(), normmap, annealing);
179  LogTrace("SiTrackerMultiRecHitUpdator") << " Updated Hit position " << updated.localPosition() << " updated error "
180  << updated.localPositionError() << std::endl;
181 
182  return std::make_shared<SiTrackerMultiRecHit>(
183  param.first, param.second, *normmap.front().first->det(), normmap, annealing);
184 
185  } else {
186  LogTrace("SiTrackerMultiRecHitUpdator")
187  << " No hits with weight (> 10e-6) have been found for this MRH." << std::endl;
188  return std::make_shared<InvalidTrackingRecHit>(measDet.mdet().geomDet(), TrackingRecHit::missing);
189  }
190 }
virtual const GeomDet & geomDet() const
TrackingRecHit::ConstRecHitPointer makeShared(SiPixelRecHit const &hit, TrajectoryStateOnSurface const &tsos) const override
Definition: TkClonerImpl.cc:64
const SurfaceType & surface() const
const TrackingRecHitPropagator * theHitPropagator
#define LogTrace(id)
TrackingRecHit::RecHitPointer project(const TrackingRecHit::ConstRecHitPointer hit, const GeomDet &det, const TrajectoryStateOnSurface ts, const TransientTrackingRecHitBuilder *builder) const
U second(std::pair< T, U > const &p)
const TransientTrackingRecHitBuilder * theBuilder
std::shared_ptr< TrackingRecHit const > RecHitPointer
std::pair< LocalPoint, LocalError > LocalParameters
const PositionType & position() const
double ComputeWeight(const TrajectoryStateOnSurface &tsos, const TransientTrackingRecHit &aRecHit, bool CutWeight, double annealing=1.) const
const MeasurementDet & mdet() const
static std::atomic< unsigned int > counter
LocalParameters calcParameters(const TrajectoryStateOnSurface &tsos, std::vector< std::pair< const TrackingRecHit *, float > > &aHitMap) const
tmp
align.sh
Definition: createJobs.py:716

Member Data Documentation

◆ debug_

bool SiTrackerMultiRecHitUpdator::debug_
private

Definition at line 88 of file SiTrackerMultiRecHitUpdator.h.

◆ theAnnealingProgram

const std::vector<double> SiTrackerMultiRecHitUpdator::theAnnealingProgram
private

Definition at line 86 of file SiTrackerMultiRecHitUpdator.h.

Referenced by annealingProgram(), and getAnnealingProgram().

◆ theBuilder

const TransientTrackingRecHitBuilder* SiTrackerMultiRecHitUpdator::theBuilder
private

Definition at line 82 of file SiTrackerMultiRecHitUpdator.h.

Referenced by buildMultiRecHit(), getBuilder(), and update().

◆ theChi2Cut1D

double SiTrackerMultiRecHitUpdator::theChi2Cut1D
private

Definition at line 84 of file SiTrackerMultiRecHitUpdator.h.

Referenced by ComputeWeight().

◆ theChi2Cut2D

double SiTrackerMultiRecHitUpdator::theChi2Cut2D
private

Definition at line 85 of file SiTrackerMultiRecHitUpdator.h.

Referenced by ComputeWeight().

◆ theHitCloner

TkClonerImpl SiTrackerMultiRecHitUpdator::theHitCloner
private

Definition at line 87 of file SiTrackerMultiRecHitUpdator.h.

Referenced by SiTrackerMultiRecHitUpdator(), and update().

◆ theHitPropagator

const TrackingRecHitPropagator* SiTrackerMultiRecHitUpdator::theHitPropagator
private

Definition at line 83 of file SiTrackerMultiRecHitUpdator.h.

Referenced by update().