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
SiTrackerMultiRecHitUpdatorMTF Class Reference

#include <SiTrackerMultiRecHitUpdatorMTF.h>

Public Types

typedef std::pair< LocalPoint,
LocalError
LocalParameters
 

Public Member Functions

virtual
TransientTrackingRecHit::RecHitPointer 
buildMultiRecHit (TrajectoryStateOnSurface &tsos, TransientTrackingRecHit::ConstRecHitContainer &hits, MultiTrajectoryMeasurement *mtm, float annealing=1.) const
 
virtual double calculatecut (TransientTrackingRecHit::ConstRecHitContainer &trechit, TrajectoryStateOnSurface &vtsos, std::vector< TransientTrackingRecHit::RecHitPointer > &updatedcomponents, float annealing) const
 
const std::vector< double > & getAnnealingProgram () const
 
virtual std::vector< std::pair
< TransientTrackingRecHit::RecHitPointer,
double > > 
mapmaker (TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, float annealing) const
 
 SiTrackerMultiRecHitUpdatorMTF (const TransientTrackingRecHitBuilder *builder, const TrackingRecHitPropagator *hitpropagator, const float Chi2Cut, const std::vector< double > &anAnnealingProgram)
 
virtual double update (TransientTrackingRecHit::ConstRecHitPointer original, TrajectoryStateOnSurface tsos, float annealing=1.) const
 
virtual
TransientTrackingRecHit::RecHitPointer 
update (double rowsum, MultiTrajectoryMeasurement *mtm, double c, std::vector< std::pair< TransientTrackingRecHit::RecHitPointer, double > > &mymap, std::vector< TransientTrackingRecHit::RecHitPointer > &updatedcomponents, float annealing=1.) const
 
virtual double updatecolumn (TransientTrackingRecHit::ConstRecHitPointer trechit, MultiTrajectoryMeasurement *multi, float annealing) const
 
virtual std::vector
< TransientTrackingRecHit::RecHitPointer
updatecomponents (TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, float annealing) const
 
virtual double updaterow (TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, std::vector< TransientTrackingRecHit::RecHitPointer > &updatedcomponents, float annealing) const
 
virtual ~SiTrackerMultiRecHitUpdatorMTF ()
 

Private Member Functions

LocalPoint calcParameters (TransientTrackingRecHit::ConstRecHitContainer &map, const LocalError &er) const
 
LocalParameters calcParameters (TransientTrackingRecHit::ConstRecHitContainer &map) const
 
LocalError calcParametersError (TransientTrackingRecHit::ConstRecHitContainer &map) const
 

Private Attributes

const std::vector< double > theAnnealingProgram
 
const
TransientTrackingRecHitBuilder
theBuilder
 
const float theChi2Cut
 
const TrackingRecHitPropagatortheHitPropagator
 

Detailed Description

Definition at line 24 of file SiTrackerMultiRecHitUpdatorMTF.h.

Member Typedef Documentation

Definition at line 26 of file SiTrackerMultiRecHitUpdatorMTF.h.

Constructor & Destructor Documentation

SiTrackerMultiRecHitUpdatorMTF::SiTrackerMultiRecHitUpdatorMTF ( const TransientTrackingRecHitBuilder builder,
const TrackingRecHitPropagator hitpropagator,
const float  Chi2Cut,
const std::vector< double > &  anAnnealingProgram 
)

Definition at line 13 of file SiTrackerMultiRecHitUpdatorMTF.cc.

16  :
17  theBuilder(builder),
18  theHitPropagator(hitpropagator),
19  theChi2Cut(Chi2Cut),
20  theAnnealingProgram(anAnnealingProgram){}
const TrackingRecHitPropagator * theHitPropagator
const TransientTrackingRecHitBuilder * theBuilder
const std::vector< double > theAnnealingProgram
virtual SiTrackerMultiRecHitUpdatorMTF::~SiTrackerMultiRecHitUpdatorMTF ( )
inlinevirtual

Definition at line 32 of file SiTrackerMultiRecHitUpdatorMTF.h.

32 {};

Member Function Documentation

TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdatorMTF::buildMultiRecHit ( TrajectoryStateOnSurface tsos,
TransientTrackingRecHit::ConstRecHitContainer hits,
MultiTrajectoryMeasurement mtm,
float  annealing = 1. 
) const
virtual

Definition at line 27 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References trackerHits::c, calculatecut(), mapmaker(), update(), updatecomponents(), and updaterow().

Referenced by MTFTrackProducerAlgorithm::updateHits().

30  {
31 
32  //LogDebug("SiTrackerMultiRechitUpdatorMTF") << "Vector pushed back " << td::endl;
33 
34 
35  //get the other variables needed to do the update
36  std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents = updatecomponents(rhv, state, annealing);
37 
38 
39  // LogDebug("SiTrackerMultiRechitUpdatorMTF") << "built a vector (updated) of size: "<<updatedcomponents.size()
40  // << std::endl;
41 
42  double rowsum = updaterow(rhv, state, updatedcomponents, annealing);
43  //if (rowsum==-1)return an invalid hit?
44  //float columnsum = updatecolumn(hit, mtm, annealing);
45  double c = calculatecut(rhv, state, updatedcomponents, annealing);
46  //LogDebug("SiTrackerMultiRechitUpdatorMTF") <<" rowsum = " << rowsum <<std::endl
47  // <<" columnsum = "<<columnsum<<std::endl
48  // <<" c = "<<c<<std::endl;
49 
50  std::vector<std::pair<TransientTrackingRecHit::RecHitPointer, double> > themap = mapmaker(rhv, state, annealing);
51  //LogDebug("SiTrackerMultiRechitUpdatorMTF") << " made a map of "<<themap.size()<<"components"
52  // << std::endl;
53 
54  //LogDebug("SiTrackerMultiRechitUpdatorMTF") << " local position "<<themap.front().first->localPosition()
55  // << std::endl;
56 
57  //returns a vector updated given 6 variables
58  return update(rowsum,mtm,c,themap,updatedcomponents,annealing);
59 
60 }
virtual std::vector< std::pair< TransientTrackingRecHit::RecHitPointer, double > > mapmaker(TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, float annealing) const
virtual double updaterow(TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, std::vector< TransientTrackingRecHit::RecHitPointer > &updatedcomponents, float annealing) const
virtual double calculatecut(TransientTrackingRecHit::ConstRecHitContainer &trechit, TrajectoryStateOnSurface &vtsos, std::vector< TransientTrackingRecHit::RecHitPointer > &updatedcomponents, float annealing) const
virtual std::vector< TransientTrackingRecHit::RecHitPointer > updatecomponents(TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, float annealing) const
char state
Definition: procUtils.cc:75
virtual double update(TransientTrackingRecHit::ConstRecHitPointer original, TrajectoryStateOnSurface tsos, float annealing=1.) const
LocalPoint SiTrackerMultiRecHitUpdatorMTF::calcParameters ( TransientTrackingRecHit::ConstRecHitContainer map,
const LocalError er 
) const
private

Definition at line 545 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References gather_cfg::cout, m, Parameters::parameters, LocalError::xx(), LocalError::xy(), and LocalError::yy().

Referenced by update().

545  {
546  AlgebraicVector2 m_sum;
547  int ierr;
548  for( TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = map.begin(); ihit != map.end(); ihit ++) {
549  AlgebraicVector2 m(asSVector<2>((*ihit)->parameters()));
550  AlgebraicSymMatrix22 V(asSMatrix<2>((*ihit)->parametersError()));
551  AlgebraicSymMatrix22 W(V.Inverse(ierr));
552 
553  if(ierr != 0) {
554  std::cout<<"MultiRecHit::checkParameters: W not valid!"<<std::endl;
555  }
556 
557  //m_sum += ihit->weight()*(W*m);
558  else m_sum += ((*ihit)->weight()*(W*m));
559  }
560  AlgebraicSymMatrix22 V_sum;
561 
562  V_sum(0,0) = er.xx();
563  V_sum(0,1) = er.xy();
564  V_sum(1,1) = er.yy();
565  //AlgebraicSymMatrix V_sum(parametersError());
566  AlgebraicVector2 parameters = V_sum*m_sum;
567  return LocalPoint(parameters(0), parameters(1));
568 }
float xx() const
Definition: LocalError.h:19
dictionary parameters
Definition: Parameters.py:2
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
float xy() const
Definition: LocalError.h:20
float yy() const
Definition: LocalError.h:21
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
tuple cout
Definition: gather_cfg.py:41
ROOT::Math::SVector< double, 2 > AlgebraicVector2
SiTrackerMultiRecHitUpdatorMTF::LocalParameters SiTrackerMultiRecHitUpdatorMTF::calcParameters ( TransientTrackingRecHit::ConstRecHitContainer map) const
private

Definition at line 502 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References error, m, Parameters::parameters, and position.

502  {
503  AlgebraicSymMatrix22 W_sum;
504  AlgebraicVector2 m_sum;
505  int ierr;
506  for(TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = map.begin(); ihit != map.end(); ihit ++) {
507  AlgebraicVector2 m(asSVector<2>((*ihit)->parameters()));
508  AlgebraicSymMatrix22 V(asSMatrix<2>((*ihit)->parametersError()));
509  AlgebraicSymMatrix22 W(V.Inverse(ierr));
510 
511  if(ierr != 0) {
512  edm::LogError("SiTrackerMultiRecHitUpdator")<<"MultiRecHit::checkParameters: W not valid!"<<std::endl;
513  }
514 
515  else {
516  W_sum += ((*ihit)->weight()*W);
517  m_sum += ((*ihit)->weight()*(W*m));
518  }
519  }
520  AlgebraicSymMatrix22 V_sum= W_sum.Inverse(ierr);
521  AlgebraicVector2 parameters = V_sum*m_sum;
522  LocalError error=LocalError(V_sum(0,0), V_sum(0,1), V_sum(1,1));
524  return std::make_pair(position,error);
525 }
dictionary parameters
Definition: Parameters.py:2
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
ROOT::Math::SVector< double, 2 > AlgebraicVector2
LocalError SiTrackerMultiRecHitUpdatorMTF::calcParametersError ( TransientTrackingRecHit::ConstRecHitContainer map) const
private

Definition at line 528 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References gather_cfg::cout.

528  {
529  AlgebraicSymMatrix22 W_sum;
530  int ierr;
531  for(TransientTrackingRecHit::ConstRecHitContainer::const_iterator ihit = map.begin(); ihit != map.end(); ihit ++) {
532  AlgebraicSymMatrix22 V(asSMatrix<2>((*ihit)->parametersError()));
533  AlgebraicSymMatrix22 W(V.Inverse(ierr));
534 
535  if(ierr != 0) {
536  std::cout<<"MultiRecHit::checkParametersError: W not valid!"<<std::endl;
537  }
538 
539  else W_sum += ((*ihit)->weight()*W);
540  }
541  AlgebraicSymMatrix22 parametersError = W_sum.Inverse(ierr);
542  return LocalError(parametersError(0,0), parametersError(0,1), parametersError(1,1));
543 }
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
tuple cout
Definition: gather_cfg.py:41
double SiTrackerMultiRecHitUpdatorMTF::calculatecut ( TransientTrackingRecHit::ConstRecHitContainer trechit,
TrajectoryStateOnSurface vtsos,
std::vector< TransientTrackingRecHit::RecHitPointer > &  updatedcomponents,
float  annealing 
) const
virtual

Definition at line 230 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References funct::exp(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localPosition(), LogTrace, M_PI, mathSSE::sqrt(), theChi2Cut, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by buildMultiRecHit().

233  {
234 
235  if (tcomponents.empty()){
236  LogTrace("SiTrackerMultiRecHitUpdator")
237  << "Empty components rechit vector passed to SiTrackerMultiRecHitUpdator::calculatecut";
238  return -1;
239  }
240 
241  if(!tsos.isValid()) {
242  LogTrace("SiTrackerMultiRecHitUpdator")<<"SiTrackerMultiRecHitUpdator::calculatecut: tsos NOT valid!!!";
243  return -2;
244  }
245 
246  //a loop to propagate all the hits on the same surface...
247  //std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents = updatecomponents(tcomponents,tsos,annealing);
248 
249  double c_sum=0;
250  int ierr;
251  AlgebraicVector2 tsospos;
252  tsospos[0]=tsos.localPosition().x();
253  tsospos[1]=tsos.localPosition().y();
254  //LogTrace("SiTrackerMultiRecHitUpdator")<< "Hit position " << tcomponents->localPosition();
255 
256  for(std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin(); ihit != updatedcomponents.end(); ihit++) {
257  // AlgebraicVector2 r(asSVector<2>((*ihit)->parameters()) - tsospos);
258  AlgebraicSymMatrix22 V(asSMatrix<2>((*ihit)->parametersError()));
259  V *= annealing;//assume that TSOS is smoothed one
260  //V += me.measuredError(*ihit);// result = b*V + H*C*H.T()
261  AlgebraicSymMatrix22 W(V.Inverse(ierr));
262  double det=0;
263  bool ierr2=!(V.Det2(det));
264 
265  if(ierr != 0||ierr2) {
266  LogTrace("SiTrackerMultiRecHitUpdator")<<"MultiRecHitUpdator::calculatecut: W not valid!"<<std::endl;
267  LogTrace("SiTrackerMultiRecHitUpdator")<<"V: "<<V<<" AnnealingFactor: "<<annealing<<std::endl;
268  }
269  else{
270  //float Chi2 = W.similarity(r);// Chi2 = r.T()*W*r
271  //this is a normalization factor, to define a cut c, for dropping the probability to 0
272  LogTrace("SiTrackerMultiRecHitUpdator")<<"SiTrackerMultiRecHitUpdator::calculatecut: det= "<<det<<std::endl;
273  double c_i = exp(-0.5*theChi2Cut/annealing)/(2.*M_PI*sqrt(det));
274  c_sum += c_i;
275  }
276  }
277  LogTrace("SiTrackerMultiRecHitUpdator")<<"SiTrackerMultiRecHitUpdator::calculatecut: csum= "<<c_sum<<std::endl;
278  return c_sum;
279 
280 
281 }
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
T sqrt(T t)
Definition: SSEVec.h:28
#define LogTrace(id)
#define M_PI
Definition: BFit3D.cc:3
ROOT::Math::SVector< double, 2 > AlgebraicVector2
const std::vector<double>& SiTrackerMultiRecHitUpdatorMTF::getAnnealingProgram ( ) const
inline
std::vector< std::pair< TransientTrackingRecHit::RecHitPointer, double > > SiTrackerMultiRecHitUpdatorMTF::mapmaker ( TransientTrackingRecHit::ConstRecHitContainer tcomponents,
TrajectoryStateOnSurface tsos,
float  annealing 
) const
virtual

Definition at line 284 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References funct::exp(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localPosition(), LogDebug, LogTrace, M_PI, csvReporter::r, mathSSE::sqrt(), updatecomponents(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by buildMultiRecHit().

286  {
287  if (tcomponents.empty()){
288  LogTrace("SiTrackerMultiRecHitUpdator")
289  << "Empty components vector passed to SiTrackerMultiRecHitUpdator::update, returning an InvalidTransientRecHit ";
290  // return InvalidTransientRecHit::build(0);
291  }
292 
293  if(!tsos.isValid()) {
294  LogTrace("SiTrackerMultiRecHitUpdator")<<"SiTrackerMultiRecHitUpdator::update: tsos NOT valid!!!, returning an InvalidTransientRecHit";
295  //return InvalidTransientRecHit::build(0);
296  }
297 
298  std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents = updatecomponents(tcomponents, tsos,annealing);
299 
300  int ierr;
301  std::vector<std::pair<TransientTrackingRecHit::RecHitPointer, double> > mymap;
302 
303 
304  AlgebraicVector2 tsospos;
305  tsospos[0]=tsos.localPosition().x();
306  tsospos[1]=tsos.localPosition().y();
307  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<< "TSOS position " << tsos.localPosition();
308  for(std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin(); ihit != updatedcomponents.end(); ihit++) {
309  AlgebraicVector2 r(asSVector<2>((*ihit)->parameters()) - tsospos);
310  AlgebraicSymMatrix22 V(asSMatrix<2>((*ihit)->parametersError()));
311  V *= annealing;//assume that TSOS is smoothed one
312  //V += me.measuredError(*ihit);// result = b*V + H*C*H.T()
313  AlgebraicSymMatrix22 W(V.Inverse(ierr));
314  double det=0;
315  bool ierr2=!(V.Det2(det));
316  double a_i=0;
317  if(ierr != 0||ierr2) {
318  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"MultiRecHitUpdator::update: W not valid!"<<std::endl;
319  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"V: "<<V<<" AnnealingFactor: "<<annealing<<std::endl;
320 
321  }
322  else{
323  double Chi2 =ROOT::Math::Similarity(r,W);// Chi2 = r.T()*W*r
324  //this is the probability of the hit respect to the track
325  a_i=exp(-0.5*Chi2)/(2.*M_PI*sqrt(det));
326  }
327  mymap.push_back(std::pair<TransientTrackingRecHit::RecHitPointer, float>((*ihit), a_i));
328  //this is a normalization factor, to define a cut c, for dropping the probability to 0
329  //a_sum += a_i;
330  }
331 
332  LogDebug("SiTrackerMultiRecHitUpdatorMTF") << "Map mymap size: " << mymap.size() << std::endl
333  << "Position 1st element: " << mymap.front().first->localPosition()<<std::endl;
334 
335 
336  return mymap;
337 }
#define LogDebug(id)
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
T y() const
Definition: PV3DBase.h:57
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
T sqrt(T t)
Definition: SSEVec.h:28
#define LogTrace(id)
#define M_PI
Definition: BFit3D.cc:3
virtual std::vector< TransientTrackingRecHit::RecHitPointer > updatecomponents(TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, float annealing) const
Definition: Chi2.h:17
T x() const
Definition: PV3DBase.h:56
ROOT::Math::SVector< double, 2 > AlgebraicVector2
double SiTrackerMultiRecHitUpdatorMTF::update ( TransientTrackingRecHit::ConstRecHitPointer  original,
TrajectoryStateOnSurface  tsos,
float  annealing = 1. 
) const
virtual

Definition at line 64 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References edm::hlt::Exception, TrajectoryStateOnSurface::isValid(), LogTrace, updatecomponents(), and updaterow().

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), buildMultiRecHit(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

66  {
67 
68  // LogTrace("SiTrackerMultiRecHitUpdator") << "Calling SiTrackerMultiRecHitUpdator::update with AnnealingFactor: " << annealing;
69  if (original->isValid())
70  LogTrace("SiTrackerMultiRecHitUpdator") << "Original Hit position " << original->localPosition() << " original error "
71  << original->parametersError();
72  else LogTrace("SiTrackerMultiRecHitUpdator") << "Invalid hit";
73 
74  if(!tsos.isValid()) {
75  //return original->clone();
76  throw cms::Exception("SiTrackerMultiRecHitUpdator") << "!!! MultiRecHitUpdator::update(..): tsos NOT valid!!! ";
77  }
78 
79  //check if to clone is the right thing
80  if (original->transientHits().empty()) return 0;
81  //return original->clone(tsos);
82  //
83  TransientTrackingRecHit::ConstRecHitContainer tcomponents = original->transientHits();
84 
85  std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents = updatecomponents(tcomponents, tsos, annealing);
86 
87  return updaterow(tcomponents, tsos, updatedcomponents, annealing);
88 }
virtual double updaterow(TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, std::vector< TransientTrackingRecHit::RecHitPointer > &updatedcomponents, float annealing) const
#define LogTrace(id)
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual std::vector< TransientTrackingRecHit::RecHitPointer > updatecomponents(TransientTrackingRecHit::ConstRecHitContainer &tcomponents, TrajectoryStateOnSurface &tsos, float annealing) const
TransientTrackingRecHit::RecHitPointer SiTrackerMultiRecHitUpdatorMTF::update ( double  rowsum,
MultiTrajectoryMeasurement mtm,
double  c,
std::vector< std::pair< TransientTrackingRecHit::RecHitPointer, double > > &  mymap,
std::vector< TransientTrackingRecHit::RecHitPointer > &  updatedcomponents,
float  annealing = 1. 
) const
virtual

Definition at line 400 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References TSiTrackerMultiRecHit::build(), calcParameters(), cmsDriverOptions::counter, first, LogDebug, LogTrace, L1TEmulatorMonitor_cff::p, edm::second(), and updatecolumn().

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

405  {
406 
407  //LogDebug("SiTrackerMultiRecHitUpdatorMTF") << "check if the map is good" << std::endl
408  // << "size: " << mymap.size()<< std::endl;
409 
410 
411  unsigned int counter = 0;
413  //create a map normalized
414  std::vector<std::pair<TransientTrackingRecHit::RecHitPointer, double> > normmap;
415  const GeomDet* geomdet = updatedcomponents.front()->det();
416  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"Multirechit size"<<updatedcomponents.size()<<std::endl;
417  for(std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin(); ihit != updatedcomponents.end(); ihit++) {
418 
419  // LogDebug("SiTrackerMultiRechitUpdatorMTF") <<" the value of phi is "<< mymap[counter].second << std::endl
420  // <<" the value of totalsum is "<< total_sum << std::endl
421  // <<" the value of the cut is "<< c << std::endl
422  // <<" the size of the map is " << mymap.size() << std::endl
423  // <<" printing the first element of the map" << mymap[counter].first << std::endl;
424  // <<" the local position of the hit is: "
425 
426  double colsum = updatecolumn(*ihit, mtm, annealing);
427  double total_sum = rowsum + colsum;
428  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"rowsum= "<<rowsum<<", colsum= "<<colsum<<std::endl;
429  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"phi_i_j= "<<mymap[counter].second<<", c="<<c<<std::endl;
430  //float p = ( (mymap[counter].second)/(total_sum - mymap[counter].second ) > 1.e-6 ? (mymap[counter].second)/(total_sum- mymap[counter].second) : 1.e-6);
431  double p = ( (mymap[counter].second)/(total_sum - mymap[counter].second + c) > 1.e-6 ? (mymap[counter].second)/(total_sum- mymap[counter].second +c) : 1.e-6);
432 
433  // LogDebug("SiTrackerMultiRechitUpdatorMTF") << " the probability of this hit is "
434  // << p << std::endl;
435 
436  //float p = ((mymap[counter].second)/total_sum > 0.01 ? (mymap[counter].second)/total_sum : 1.e-6);
437  normmap.push_back(std::pair<TransientTrackingRecHit::RecHitPointer, double>(mymap[counter].first, p) );
438  //LogDebug("SiTrackerMultiRechitUpdatorMTF") <<"stored the pair <hit,p> in the map "
439  // <<std::endl;
440 
441 
442 
443  //let's store the weight in the component TransientTrackingRecHit too
444  (*ihit)->setWeight(p);
445  // LogDebug("SiTrackerMultiRechitUpdatorMTF")<<"Weight set"<<std::endl;
446 
447  (*ihit)->setAnnealingFactor(annealing);
448  // LogDebug("SiTrackerMultiRechitUpdatorMTF")<<"Annealing factor set"<<std::endl;
449 
450  finalcomponents.push_back(*ihit);
451  //LogDebug("SiTrackerMultiRechitUpdatorMTF")<<"Component pushed back"<<std::endl;
452 
453  //LogDebug("SiTrackerMultiRecHitUpdatorMTF")<<"FinalComponents size: "<<finalcomponents.size()<<std::endl;
454 
455  LogDebug("SiTrackerMultiRecHitUpdatorMTF")<<"Component hit type "<< typeid(*(normmap[counter].first)).name() <<std::endl
456 
457  << "position " << mymap[counter].first->localPosition()<<std::endl
458  << "error " << mymap[counter].first->localPositionError()<<std::endl
459  << "with weight " <<p<<std::endl;
460 
461  counter++;
462 
463  }
464 
465 
466 
467  mymap = normmap;
469 
470  // LocalError er = calcParametersError(finalcomponents);
471 
472  //LocalPoint pos = calcParameters(finalcomponents, er);
473 
474  std::vector<std::pair<const TrackingRecHit*,float> > newmap;
475 
476 
477  for(std::vector<std::pair<TransientTrackingRecHit::RecHitPointer,double> >::iterator imap=mymap.begin(); imap!=mymap.end(); imap++)
478  {
479 
480  newmap.push_back(std::pair<const TrackingRecHit*, float>(imap->first->hit(),imap->second));
481 
482  }
483 
484 
485 
486 
487 
488  SiTrackerMultiRecHit updatedmrh(param.first,param.second, newmap.front().first->geographicalId(), newmap);
489 
490  LogDebug("SiTrackerMultiRecHitUpdatorMTF") << "SiTrackerMultiRecHit built " << std::endl;
491 
492  LogDebug("SiTrackerMultiRecHitUpdatorMTF") << "Updated Hit position "
493  << updatedmrh.localPosition() << " updated error "
494  << updatedmrh.parametersError() << std::endl;
495 
496  //return new SiTrackerMultiRecHit(normmap);
497 
498  return TSiTrackerMultiRecHit::build(geomdet, &updatedmrh, finalcomponents, annealing);
499 
500 }
#define LogDebug(id)
std::pair< LocalPoint, LocalError > LocalParameters
U second(std::pair< T, U > const &p)
static RecHitPointer build(const GeomDet *geom, const SiTrackerMultiRecHit *rh, const ConstRecHitContainer &components, float annealing=1.)
bool first
Definition: L1TdeRCT.cc:79
#define LogTrace(id)
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual double updatecolumn(TransientTrackingRecHit::ConstRecHitPointer trechit, MultiTrajectoryMeasurement *multi, float annealing) const
LocalPoint calcParameters(TransientTrackingRecHit::ConstRecHitContainer &map, const LocalError &er) const
double SiTrackerMultiRecHitUpdatorMTF::updatecolumn ( TransientTrackingRecHit::ConstRecHitPointer  trechit,
MultiTrajectoryMeasurement multi,
float  annealing 
) const
virtual

Definition at line 152 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References funct::exp(), MultiTrajectoryMeasurement::filteredStates(), LogTrace, M_PI, csvReporter::r, and mathSSE::sqrt().

Referenced by update().

154  {
155 
156 
157  if(!trechit->isValid()) {
158  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"SiTrackerMultiRecHitUpdatorMTF::updatecolumn: rechit NOT valid!!!, returning an InvalidTransientRecHit";
159  //return InvalidTransientRecHit::build(0);
160  }
161 
162  int ierr;
163 
164  //const GeomDet* geomdet = 0;
165 
166  double a_sum=0;
167 
168 
169  AlgebraicVector2 hitpos(asSVector<2>(trechit->parameters()));
170  //hitpos[0]=trechit->localPosition().x();
171  //hitpos[1]=trechit->localPosition().y();
172  // LogDebug("SiTrackerMultiRecHitUpdatorMTF")<< "Hit position " << trechit->localPosition();
173 
174  //calculate parameters outside for cycle
175  AlgebraicSymMatrix22 V( asSMatrix<2>(trechit->parametersError()));
176  V *= annealing;//assume that TSOS is smoothed one
177  double det=0;
178  bool ierr2=!(V.Det2(det));
179  double denom= (2.*M_PI*sqrt(det));
180  AlgebraicSymMatrix22 W(V.Inverse(ierr));
181 
182  if(ierr != 0 ||ierr2) {
183  edm::LogWarning("SiTrackerMultiRecHitUpdatorMTF")<<"MultiRecHitUpdator::update: W not valid!"<<std::endl;
184  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"V: "<<V<<" AnnealingFactor: "<<annealing<<std::endl;
185  }
186  else{
187  AlgebraicVector2 tsospos;
188  //substitute the loop over the hits with a loop over the tsos
189  for(std::map<int,TSOS>::const_iterator imtm=mtm->filteredStates().begin(); imtm!=mtm->filteredStates().end(); imtm++) {
190 
191 
192  //LogDebug("SiTrackerMultiRecHitUpdatorMTF") << "entered in the for cicle";
193  //std::cout << "debug message for cicle";
194  //every step a different tsos
195  //here I call a constructor
196  //TSOS tsos( (*(imtm->second.freeState())), imtm->second.surface(), imtm->second.surfaceSide() );
197 
198  //then I fill the vector with the positions
199 
200  tsospos[0]= imtm->second.localPosition().x();
201  tsospos[1]= imtm->second.localPosition().y();
202 
203  //LogDebug("SiTrackerMultiRecHitUpdatorMTF")<< "TSOS position " << imtm->second.localPosition() ;
204 
205  AlgebraicVector2 r( hitpos - tsospos);
206 
207 
208 
209  //V += me.measuredError(*ihit);// result = b*V + H*C*H.T()
210 
211 
212  double Chi2 = ROOT::Math::Similarity(r,W);// Chi2 = r.T()*W*r
213  //LogDebug("SiTrackerMultiRecHitUpdatorMTF")<<"Chi2 (updatecolumn method)= "<<Chi2<<std::endl;
214 
215  //this is the probability of the hit respect to the track
216  //float a_i = exp(-0.5*Chi2)/(2.*M_PI*sqrt(V.determinant()));
217  double a_i = exp(-0.5*Chi2)/denom;
218  a_sum += a_i;
219 
220  // LogDebug("SiTrackerMultiRecHitUpdatorMTF")<< "Value of a " << a_i ;
221  }
222  }
223 
224  return a_sum;
225 
226 }
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
T sqrt(T t)
Definition: SSEVec.h:28
#define LogTrace(id)
#define M_PI
Definition: BFit3D.cc:3
Definition: Chi2.h:17
ROOT::Math::SVector< double, 2 > AlgebraicVector2
std::vector< TransientTrackingRecHit::RecHitPointer > SiTrackerMultiRecHitUpdatorMTF::updatecomponents ( TransientTrackingRecHit::ConstRecHitContainer tcomponents,
TrajectoryStateOnSurface tsos,
float  annealing 
) const
virtual

Definition at line 340 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References cropTnPTrees::cloned, edm::hlt::Exception, TrajectoryStateOnSurface::isValid(), LogTrace, GloballyPositioned< T >::position(), TrackingRecHitPropagator::project(), TrajectoryStateOnSurface::surface(), and theHitPropagator.

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

342  {
343 
344  if (tcomponents.empty()){
345  LogTrace("SiTrackerMultiRecHitUpdator")
346  << "Empty components vector passed to SiTrackerMultiRecHitUpdatorMTF::updatecomponents, returning an InvalidTransientRecHit ";
347  //return InvalidTransientRecHit::build(0);
348  }
349 
350  if(!tsos.isValid())
351  {
352  LogTrace("SiTrackerMultiRecHitUpdatorMTF")
353  <<"SiTrackerMultiRecHitUpdatorMTF::updatecomponents: tsos NOT valid!!!, returning an InvalidTransientRecHit";
354  //return InvalidTransientRecHit::build(0);
355  }
356 
357  std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents;
358  const GeomDet* geomdet = 0;
359  for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator iter = tcomponents.begin(); iter != tcomponents.end(); iter++){
360  if (iter == tcomponents.begin()) {
361  //to be fixed, to take into account hits coming from different modules
362  if (&((*iter)->det()->surface())!=&(tsos.surface())){
363  throw cms::Exception("SiTrackerMultiRecHitUpdatorMTF")
364  << "the Trajectory state and the first rechit passed to the SiTrackerMultiRecHitUpdatorMTF lay on different surfaces!: state lays on surface "
365  << tsos.surface().position()
366  << "hit with detid "
367  << (*iter)->det()->geographicalId().rawId()
368  << "lays on surface "
369  << (*iter)->det()->surface().position();
370  }
371  geomdet = (*iter)->det();
372  // LogTrace("SiTrackerMultiRecHitUpdatorMTF") << "Current reference surface located at " << geomdet->surface().position();
373  }
374  if (&((*iter)->det()->surface())!=&(tsos.surface())){
376  LogTrace("SiTrackerMultiRecHitUpdatorMTF") << "Projecting a hit from surface " << (*iter)->det()->surface().position()
377  << " to surface " << tsos.surface().position() << " original global position "
378  << (*iter)->globalPosition() << " projected position " << cloned->globalPosition();
379  if (cloned->isValid()) updatedcomponents.push_back(cloned);
380  } else {
381 
382 
383  //changed to limit the use of clone method
384  //if ( (*iter)->isValid() ) updatedcomponents.push_back(*iter);
385  LogTrace("SiTrackerMultiRecHitUpdatorMTF") << "about to clone the tracking rechit with the method clone " << std::endl;
386  TransientTrackingRecHit::RecHitPointer cloned = (*iter)->clone(tsos);
387  LogTrace("SiTrackerMultiRecHitUpdatorMTF") << "cloned";
388  LogTrace("SiTrackerMultiRecHitUpdatorMTF") <<"Original position: "<<(*iter)->localPosition()<<std::endl;
389  LogTrace("SiTrackerMultiRecHitUpdatorMTF") <<"New position: "<<cloned->localPosition()<<std::endl;
390 
391  if (cloned->isValid()) updatedcomponents.push_back(cloned);
392  }
393  }
394 
395  return updatedcomponents;
396 }
const TrackingRecHitPropagator * theHitPropagator
#define LogTrace(id)
const Surface & surface() const
const PositionType & position() const
TransientTrackingRecHit::RecHitPointer project(const TransientTrackingRecHit::ConstRecHitPointer hit, const GeomDet &det, const TrajectoryStateOnSurface ts) const
double SiTrackerMultiRecHitUpdatorMTF::updaterow ( TransientTrackingRecHit::ConstRecHitContainer tcomponents,
TrajectoryStateOnSurface tsos,
std::vector< TransientTrackingRecHit::RecHitPointer > &  updatedcomponents,
float  annealing 
) const
virtual

Definition at line 95 of file SiTrackerMultiRecHitUpdatorMTF.cc.

References funct::exp(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localPosition(), LogTrace, M_PI, csvReporter::r, mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by buildMultiRecHit(), and update().

98  {
99 
100  if (tcomponents.empty()){
101  LogTrace("SiTrackerMultiRecHitUpdator") << "Empty components vector passed to SiTrackerMultiRecHitUpdator::updateraw";
102  return -1;
103  }
104 
105  if(!tsos.isValid()) {
106  LogTrace("SiTrackerMultiRecHitUpdator")<<"SiTrackerMultiRecHitUpdator::updateraw: tsos NOT valid!!!";
107  return -2;
108  }
109 
110 
111 
112  //a loop to propagate all the hits on the same surface...
113  //std::vector<TransientTrackingRecHit::RecHitPointer> updatedcomponents = updatecomponents(tcomponents,tsos,annealing);
114 
115  int ierr;
116 
117  double a_sum=0;
118 
119  AlgebraicVector2 tsospos;
120  tsospos[0]=tsos.localPosition().x();
121  tsospos[1]=tsos.localPosition().y();
122  // LogDebug("SiTrackerMultiRecHitUpdatorMTF")<< "TSOS position " << tsos.localPosition();
123 
124  for(std::vector<TransientTrackingRecHit::RecHitPointer>::iterator ihit = updatedcomponents.begin(); ihit != updatedcomponents.end(); ihit++) {
125 
126  // LogDebug("SiTrackerMultiRecHitUpdatorMTF")<< "hit position " << (*ihit)->localPosition();
127  AlgebraicVector2 r(asSVector<2>((*ihit)->parameters()) - tsospos);
128  AlgebraicSymMatrix22 V(asSMatrix<2>((*ihit)->parametersError()));
129  V *= annealing;//assume that TSOS is smoothed one
130  //V += me.measuredError(*ihit);// result = b*V + H*C*H.T()
131  AlgebraicSymMatrix22 W(V.Inverse(ierr));
132  double det;
133  bool ierr2=!(V.Det2(det));
134 
135  if(ierr != 0|| ierr2) {
136  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"MultiRecHitUpdator::update: W not valid!"<<std::endl;
137  LogTrace("SiTrackerMultiRecHitUpdatorMTF")<<"V: "<<V<<" AnnealingFactor: "<<annealing<<std::endl;
138  }
139  else{
140  double Chi2 = ROOT::Math::Similarity(r,W);// Chi2 = r.T()*W*r
141  //LogDebug("SiTrackerMultiRecHitUpdatorMTF")<<"Chi2 (updaterow method)= "<<Chi2<<std::endl;
142  //this is the probability of the hit respect to the track
143  double a_i = exp(-0.5*Chi2)/(2.*M_PI*sqrt(det));
144  a_sum += a_i;
145  }
146  }
147 
148  return a_sum;
149 }
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > AlgebraicSymMatrix22
T y() const
Definition: PV3DBase.h:57
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
T sqrt(T t)
Definition: SSEVec.h:28
#define LogTrace(id)
#define M_PI
Definition: BFit3D.cc:3
Definition: Chi2.h:17
T x() const
Definition: PV3DBase.h:56
ROOT::Math::SVector< double, 2 > AlgebraicVector2

Member Data Documentation

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

Definition at line 96 of file SiTrackerMultiRecHitUpdatorMTF.h.

Referenced by getAnnealingProgram().

const TransientTrackingRecHitBuilder* SiTrackerMultiRecHitUpdatorMTF::theBuilder
private

Definition at line 93 of file SiTrackerMultiRecHitUpdatorMTF.h.

const float SiTrackerMultiRecHitUpdatorMTF::theChi2Cut
private

Definition at line 95 of file SiTrackerMultiRecHitUpdatorMTF.h.

Referenced by calculatecut().

const TrackingRecHitPropagator* SiTrackerMultiRecHitUpdatorMTF::theHitPropagator
private

Definition at line 94 of file SiTrackerMultiRecHitUpdatorMTF.h.

Referenced by updatecomponents().