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

Definition at line 31 of file SiTrackerMultiRecHitUpdator.h.

Constructor & Destructor Documentation

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 theHitCloner.

22  :
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
virtual SiTrackerMultiRecHitUpdator::~SiTrackerMultiRecHitUpdator ( )
inlinevirtual

Definition at line 37 of file SiTrackerMultiRecHitUpdator.h.

References buildMultiRecHit(), ComputeWeight(), definitions::original, and update().

37 {};

Member Function Documentation

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

Definition at line 65 of file SiTrackerMultiRecHitUpdator.h.

References theAnnealingProgram.

65 {return theAnnealingProgram;}
const std::vector< double > theAnnealingProgram
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::buildMultiRecHit ( const std::vector< const TrackingRecHit * > &  rhv,
const TrajectoryStateOnSurface tsos,
MeasurementDetWithData measDet,
float  annealing = 1. 
) const
virtual

Definition at line 33 of file SiTrackerMultiRecHitUpdator.cc.

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

Referenced by ~SiTrackerMultiRecHitUpdator().

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

Definition at line 292 of file SiTrackerMultiRecHitUpdator.cc.

References Exception, plotBeamSpotDB::first, LogTrace, and dataset::name.

Referenced by getBuilder(), and update().

292  {
293 
294  //supposing all the hits inside of a MRH have the same dimension
295  LogTrace("SiTrackerMultiRecHitUpdator")<<"SiTrackerMultiRecHitUpdator::LocalParameters: dim first recHit: " << aHitMap[0].first->dimension() <<std::endl;
296  switch (aHitMap[0].first->dimension()) {
297  case 1: return calcParameters<1>(tsos,aHitMap);
298  case 2: return calcParameters<2>(tsos,aHitMap);
299  }
300  throw cms::Exception("Rec hit of invalid dimension for computing MRH (not 1,2)") <<
301  "The value was " << aHitMap[0].first->dimension() <<
302  ", type is " << typeid(aHitMap[0].first).name() << "\n";
303 
304 }
#define LogTrace(id)
template<unsigned int N>
SiTrackerMultiRecHitUpdator::LocalParameters SiTrackerMultiRecHitUpdator::calcParameters ( const TrajectoryStateOnSurface tsos,
std::vector< std::pair< const TrackingRecHit *, float > > &  aHitMap 
) const
private

Definition at line 308 of file SiTrackerMultiRecHitUpdator.cc.

References patCaloMETCorrections_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(), LocalTrajectoryParameters::vector(), and x.

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

Definition at line 192 of file SiTrackerMultiRecHitUpdator.cc.

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

Referenced by update(), and ~SiTrackerMultiRecHitUpdator().

193  {
194  switch (aRecHit.dimension()) {
195  case 1: return ComputeWeight<1>(tsos,aRecHit,CutWeight,annealing);
196  case 2: return ComputeWeight<2>(tsos,aRecHit,CutWeight,annealing);
197  case 3: return ComputeWeight<3>(tsos,aRecHit,CutWeight,annealing);
198  case 4: return ComputeWeight<4>(tsos,aRecHit,CutWeight,annealing);
199  case 5: return ComputeWeight<5>(tsos,aRecHit,CutWeight,annealing);
200  }
201  throw cms::Exception("Rec hit of invalid dimension (not 1,2,3,4,5)") <<
202  "The value was " << aRecHit.dimension() <<
203  ", type is " << typeid(aRecHit).name() << "\n";
204 }
virtual int dimension() const =0
template<unsigned int N>
double SiTrackerMultiRecHitUpdator::ComputeWeight ( const TrajectoryStateOnSurface tsos,
const TransientTrackingRecHit aRecHit,
bool  CutWeight,
double  annealing = 1. 
) const

Definition at line 208 of file SiTrackerMultiRecHitUpdator.cc.

References patCaloMETCorrections_cff::C, pfMuonSelector_cfi::Chi2, diffTreeTool::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.

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

Definition at line 66 of file SiTrackerMultiRecHitUpdator.h.

References theAnnealingProgram.

Referenced by DAFTrackProducerAlgorithm::runWithCandidate().

66 {return theAnnealingProgram;}
const std::vector< double > theAnnealingProgram
const TransientTrackingRecHitBuilder* SiTrackerMultiRecHitUpdator::getBuilder ( ) const
inline

Definition at line 68 of file SiTrackerMultiRecHitUpdator.h.

References calcParameters(), theBuilder, and TIDorTEChit().

Referenced by SimpleDAFHitCollector::SimpleDAFHitCollector().

68 {return theBuilder;}
const TransientTrackingRecHitBuilder * theBuilder
bool SiTrackerMultiRecHitUpdator::TIDorTEChit ( const TrackingRecHit *const &  hit) const
private

Definition at line 381 of file SiTrackerMultiRecHitUpdator.cc.

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

Referenced by calcParameters(), and getBuilder().

381  {
382 
383  DetId hitId = hit->geographicalId();
384 
385  if( hitId.det() == DetId::Tracker &&
386  ( hitId.subdetId() == StripSubdetector::TEC || hitId.subdetId() == StripSubdetector::TID) ) {
387  return true;
388  }
389 
390  return false;
391 }
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
Definition: DetId.h:18
DetId geographicalId() const
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdator::update ( TransientTrackingRecHit::ConstRecHitPointer  original,
const TrajectoryStateOnSurface tsos,
MeasurementDetWithData measDet,
double  annealing = 1. 
) const
virtual

Definition at line 50 of file SiTrackerMultiRecHitUpdator.cc.

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

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), buildMultiRecHit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), Vispa.Gui.PortConnection.PointToPointConnection::updateConnection(), DAFTrackProducerAlgorithm::updateHits(), and ~SiTrackerMultiRecHitUpdator().

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

Definition at line 75 of file SiTrackerMultiRecHitUpdator.cc.

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

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

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

Member Data Documentation

bool SiTrackerMultiRecHitUpdator::debug_
private

Definition at line 84 of file SiTrackerMultiRecHitUpdator.h.

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

Definition at line 82 of file SiTrackerMultiRecHitUpdator.h.

Referenced by annealingProgram(), and getAnnealingProgram().

const TransientTrackingRecHitBuilder* SiTrackerMultiRecHitUpdator::theBuilder
private

Definition at line 78 of file SiTrackerMultiRecHitUpdator.h.

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

double SiTrackerMultiRecHitUpdator::theChi2Cut1D
private

Definition at line 80 of file SiTrackerMultiRecHitUpdator.h.

Referenced by ComputeWeight().

double SiTrackerMultiRecHitUpdator::theChi2Cut2D
private

Definition at line 81 of file SiTrackerMultiRecHitUpdator.h.

Referenced by ComputeWeight().

TkClonerImpl SiTrackerMultiRecHitUpdator::theHitCloner
private

Definition at line 83 of file SiTrackerMultiRecHitUpdator.h.

Referenced by SiTrackerMultiRecHitUpdator(), and update().

const TrackingRecHitPropagator* SiTrackerMultiRecHitUpdator::theHitPropagator
private

Definition at line 79 of file SiTrackerMultiRecHitUpdator.h.

Referenced by update().