CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
BasicMultiTrajectoryState Class Referencefinal

#include <BasicMultiTrajectoryState.h>

Inheritance diagram for BasicMultiTrajectoryState:
BasicTrajectoryState

Public Types

using Components = BasicTrajectoryState::Components
 
- Public Types inherited from BasicTrajectoryState
typedef BasicTrajectoryState BTSOS
 
using Components = std::vector< TrajectoryStateOnSurface >
 
typedef Proxy::pointer pointer
 
typedef ProxyBase11< BTSOSProxy
 
typedef SurfaceSideDefinition::SurfaceSide SurfaceSide
 
typedef Surface SurfaceType
 

Public Member Functions

 BasicMultiTrajectoryState (const std::vector< TSOS > &tsvec)
 
 BasicMultiTrajectoryState ()
 
bool canUpdateLocalParameters () const override
 
pointer clone () const override
 
Components const & components () const override
 
void rescaleError (double factor)
 
bool singleState () const override
 
void update (const LocalTrajectoryParameters &p, const Surface &aSurface, const MagneticField *field, const SurfaceSide side) override
 
void update (double weight, const LocalTrajectoryParameters &p, const LocalTrajectoryError &err, const Surface &aSurface, const MagneticField *field, const SurfaceSide side) override
 
- Public Member Functions inherited from BasicTrajectoryState
 BasicTrajectoryState ()
 
 BasicTrajectoryState (const SurfaceType &aSurface)
 construct invalid trajectory state (without parameters) More...
 
 BasicTrajectoryState (const FreeTrajectoryState &fts, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const FreeTrajectoryState &fts)
 
 BasicTrajectoryState (const LocalTrajectoryParameters &par, const LocalTrajectoryError &err, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const LocalTrajectoryParameters &par, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const GlobalTrajectoryParameters &par, const CartesianTrajectoryError &err, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const GlobalTrajectoryParameters &par, const CurvilinearTrajectoryError &err, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const GlobalTrajectoryParameters &par, const SurfaceType &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
template<typename... Args>
 BasicTrajectoryState (double iweight, Args &&...args)
 
const CartesianTrajectoryError cartesianError () const
 
TrackCharge charge () const
 
const CurvilinearTrajectoryErrorcurvilinearError () const
 
FreeTrajectoryState const * freeTrajectoryState (bool withErrors=true) const
 
GlobalVector globalDirection () const
 
GlobalVector globalMomentum () const
 
const GlobalTrajectoryParametersglobalParameters () const
 
GlobalPoint globalPosition () const
 
bool hasError () const
 
bool isValid () const
 
LocalVector localDirection () const
 
const LocalTrajectoryErrorlocalError () const
 
LocalVector localMomentum () const
 
const LocalTrajectoryParameterslocalParameters () const
 
LocalPoint localPosition () const
 
const MagneticFieldmagneticField () const
 
void rescaleError (double factor)
 
CurvilinearTrajectoryErrorsetCurvilinearError ()
 
double signedInverseMomentum () const
 
const SurfaceTypesurface () const
 
SurfaceSide surfaceSide () const
 Position relative to material, defined relative to momentum vector. More...
 
double transverseCurvature () const
 
virtual void update (const LocalTrajectoryParameters &p, const SurfaceSide side) final
 
virtual void update (const LocalTrajectoryParameters &p, const LocalTrajectoryError &err, const SurfaceSide side) final
 
double weight () const
 
virtual ~BasicTrajectoryState ()
 

Private Types

typedef TrajectoryStateOnSurface TSOS
 

Private Member Functions

void combine ()
 

Private Attributes

Components theStates
 

Additional Inherited Members

- Static Public Member Functions inherited from BasicTrajectoryState
template<typename T , typename... Args>
static std::shared_ptr< BTSOSbuild (Args &&...args)
 
template<typename T , typename... Args>
static std::shared_ptr< BTSOSchurn (Args &&...args)
 

Detailed Description

Class which combines a set of components of a Gaussian mixture into a single component. Given all the components of a mixture, it calculates the mean and covariance matrix of the entire mixture. This combiner class can also be used in the process of transforming a Gaussian mixture into another Gaussian mixture with a smaller number of components. The relevant formulas can be found in R. Fruhwirth, Computer Physics Communications 100 (1997), 1.

Definition at line 17 of file BasicMultiTrajectoryState.h.

Member Typedef Documentation

Definition at line 40 of file BasicMultiTrajectoryState.h.

Definition at line 19 of file BasicMultiTrajectoryState.h.

Constructor & Destructor Documentation

BasicMultiTrajectoryState::BasicMultiTrajectoryState ( const std::vector< TSOS > &  tsvec)
explicit

Definition at line 8 of file BasicMultiTrajectoryState.cc.

References combine(), Exception, mps_fire::i, and unlikely.

8  :
9  BasicTrajectoryState(tsvec.front().surface()), theStates(tsvec) {
10 
11  // only accept planes!!
12  const BoundPlane* bp = dynamic_cast<const BoundPlane*>(&tsvec.begin()->surface());
13  if unlikely( bp==nullptr )
14  throw cms::Exception("LogicError") << "MultiTrajectoryState constructed on cylinder";
15 
16  for (auto i=tsvec.begin(); i!=tsvec.end(); i++) {
17  if unlikely(!i->isValid()) {
18  throw cms::Exception("LogicError") << "MultiTrajectoryState constructed with invalid state";
19  }
20  if unlikely(i->hasError() != tsvec.front().hasError()) {
21  throw cms::Exception("LogicError") << "MultiTrajectoryState mixes states with and without errors";
22  }
23  if unlikely( &i->surface() != &tsvec.front().surface()) {
24  throw cms::Exception("LogicError") << "MultiTrajectoryState mixes states with different surfaces";
25  }
26  if unlikely( i->surfaceSide() != tsvec.front().surfaceSide()) {
27  throw cms::Exception("LogicError")
28  << "MultiTrajectoryState mixes states defined before and after material";
29  }
30  if unlikely( i->localParameters().pzSign()*tsvec.front().localParameters().pzSign()<0. ) {
31  throw cms::Exception("LogicError")
32  << "MultiTrajectoryState mixes states with different signs of local p_z";
33  }
34 
35  }
36  //
37  combine();
38 }
#define unlikely(x)
#define end
Definition: vmac.h:37
#define begin
Definition: vmac.h:30
BasicMultiTrajectoryState::BasicMultiTrajectoryState ( )
inline

Definition at line 25 of file BasicMultiTrajectoryState.h.

References rescaleError().

25 {}

Member Function Documentation

bool BasicMultiTrajectoryState::canUpdateLocalParameters ( ) const
inlineoverridevirtual

Reimplemented from BasicTrajectoryState.

Definition at line 47 of file BasicMultiTrajectoryState.h.

References AlCaHLTBitMon_ParallelJobs::p, and update().

47 { return false; }
pointer BasicMultiTrajectoryState::clone ( void  ) const
inlineoverridevirtual

Implements BasicTrajectoryState.

Definition at line 36 of file BasicMultiTrajectoryState.h.

36  {
37  return build<BasicMultiTrajectoryState>(*this);
38  }
void BasicMultiTrajectoryState::combine ( )
private

Definition at line 54 of file BasicMultiTrajectoryState.cc.

References diffTreeTool::diff, SiStripPI::mean, theStates, unlikely, update(), BasicTrajectoryState::update(), and BasicTrajectoryState::weight().

Referenced by BasicMultiTrajectoryState(), and rescaleError().

54  {
55  const std::vector<TrajectoryStateOnSurface>& tsos = theStates;
56 
57  if unlikely(tsos.empty()) {
58  edm::LogError("MultiTrajectoryStateCombiner")
59  << "Trying to collapse empty set of trajectory states!";
60  return;
61  }
62 
63  double pzSign = tsos.front().localParameters().pzSign();
64  for (std::vector<TrajectoryStateOnSurface>::const_iterator it = tsos.begin();
65  it != tsos.end(); it++) {
66  if unlikely(it->localParameters().pzSign() != pzSign) {
67  edm::LogError("MultiTrajectoryStateCombiner")
68  << "Trying to collapse trajectory states with different signs on p_z!";
69  return;
70  }
71  }
72 
73  if unlikely(tsos.size() == 1) {
74  BasicTrajectoryState::update(tsos.front().weight(),
75  tsos.front().localParameters(),
76  tsos.front().localError(),
77  tsos.front().surface(),
78  tsos.front().magneticField(),
79  tsos.front().surfaceSide()
80  );
81  return;
82  }
83 
84  double sumw = 0.;
85  //int dim = tsos.front().localParameters().vector().num_row();
87  AlgebraicSymMatrix55 covarPart1, covarPart2, covtmp;
88  for (auto it1 = tsos.begin(); it1 != tsos.end(); it1++) {
89  auto weight = it1->weight();
90  auto const & param = it1->localParameters().vector();
91  sumw += weight;
92  mean += weight * param;
93  covarPart1 += weight * it1->localError().matrix();
94  for (auto it2 = it1 + 1; it2 != tsos.end(); it2++) {
95  AlgebraicVector5 diff = param - it2->localParameters().vector();
96  ROOT::Math::AssignSym::Evaluate(covtmp,ROOT::Math::TensorProd(diff,diff));
97  covarPart2 += (weight * it2->weight()) * covtmp;
98  }
99  }
100  double sumwI = 1.0/sumw;
101  mean *= sumwI;
102  covarPart1 *= sumwI; covarPart2 *= (sumwI*sumwI);
103  AlgebraicSymMatrix55 covar = covarPart1 + covarPart2;
104 
106  LocalTrajectoryParameters(mean, pzSign),
107  LocalTrajectoryError(covar),
108  tsos.front().surface(),
109  tsos.front().magneticField(),
110  tsos.front().surfaceSide()
111  );
112 }
virtual void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side)
Definition: weight.py:1
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
#define unlikely(x)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
Components const& BasicMultiTrajectoryState::components ( ) const
inlineoverridevirtual

Implements BasicTrajectoryState.

Definition at line 41 of file BasicMultiTrajectoryState.h.

References theStates.

41  {
42  return theStates;
43  }
void BasicMultiTrajectoryState::rescaleError ( double  factor)

Rescaling the error of the mixture with a given factor. Please note that this rescaling is imposed on each of the components of the mixture and does therefore not exactly correspond to rescaling theCombinedState with the same factor.

Definition at line 42 of file BasicMultiTrajectoryState.cc.

References combine(), theStates, and unlikely.

Referenced by BasicMultiTrajectoryState().

42  {
43 
44  if unlikely(theStates.empty()) {
45  edm::LogError("BasicMultiTrajectoryState") << "Trying to rescale errors of empty MultiTrajectoryState!";
46  return;
47  }
48 
49  for (auto & is : theStates) is.rescaleError(factor);
50  combine();
51 }
#define unlikely(x)
bool BasicMultiTrajectoryState::singleState ( ) const
inlineoverridevirtual

Implements BasicTrajectoryState.

Definition at line 44 of file BasicMultiTrajectoryState.h.

44 { return false;}
void BasicMultiTrajectoryState::update ( const LocalTrajectoryParameters p,
const Surface aSurface,
const MagneticField field,
const SurfaceSide  side 
)
overridevirtual

Reimplemented from BasicTrajectoryState.

Definition at line 116 of file BasicMultiTrajectoryState.cc.

References Exception.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), canUpdateLocalParameters(), combine(), 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().

120 {
121  throw cms::Exception("LogicError",
122  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, Surface, ...) called even if canUpdateLocalParameters() is false");
123 }
void BasicMultiTrajectoryState::update ( double  weight,
const LocalTrajectoryParameters p,
const LocalTrajectoryError err,
const Surface aSurface,
const MagneticField field,
const SurfaceSide  side 
)
overridevirtual

Reimplemented from BasicTrajectoryState.

Definition at line 127 of file BasicMultiTrajectoryState.cc.

References Exception.

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().

133 {
134  throw cms::Exception("LogicError",
135  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, LocalTrajectoryError, ...) called even if canUpdateLocalParameters() is false");
136 }

Member Data Documentation

Components BasicMultiTrajectoryState::theStates
private

Definition at line 61 of file BasicMultiTrajectoryState.h.

Referenced by combine(), components(), and rescaleError().