CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
BasicMultiTrajectoryState Class Reference

#include <BasicMultiTrajectoryState.h>

Inheritance diagram for BasicMultiTrajectoryState:
BasicTrajectoryState ReferenceCountedPoolAllocated BlockWipedPoolAllocated

Public Member Functions

 BasicMultiTrajectoryState (const std::vector< TSOS > &tsvec)
 
 BasicMultiTrajectoryState ()
 
virtual bool canUpdateLocalParameters () const
 
virtual BasicMultiTrajectoryStateclone () const
 
virtual std::vector
< TrajectoryStateOnSurface
components () const
 
void rescaleError (double factor)
 
virtual void update (const LocalTrajectoryParameters &p, const Surface &aSurface, const MagneticField *field, const SurfaceSide side)
 
virtual void update (const LocalTrajectoryParameters &p, const LocalTrajectoryError &err, const Surface &aSurface, const MagneticField *field, const SurfaceSide side, double weight)
 
- Public Member Functions inherited from BasicTrajectoryState
 BasicTrajectoryState ()
 
 BasicTrajectoryState (const Surface &aSurface)
 construct invalid trajectory state (without parameters) More...
 
 BasicTrajectoryState (const FreeTrajectoryState &fts, const Surface &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const GlobalTrajectoryParameters &par, const Surface &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const GlobalTrajectoryParameters &par, const CartesianTrajectoryError &err, const Surface &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const GlobalTrajectoryParameters &par, const CurvilinearTrajectoryError &err, const Surface &aSurface, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface, double weight=1.)
 
 BasicTrajectoryState (const GlobalTrajectoryParameters &par, const CurvilinearTrajectoryError &err, const Surface &aSurface, double weight)
 
 BasicTrajectoryState (const LocalTrajectoryParameters &par, const Surface &aSurface, const MagneticField *field, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface)
 
 BasicTrajectoryState (const LocalTrajectoryParameters &par, const LocalTrajectoryError &err, const Surface &aSurface, const MagneticField *field, const SurfaceSide side=SurfaceSideDefinition::atCenterOfSurface, double weight=1.)
 
 BasicTrajectoryState (const LocalTrajectoryParameters &par, const LocalTrajectoryError &err, const Surface &aSurface, const MagneticField *field, double weight)
 
const CartesianTrajectoryError cartesianError () const
 
TrackCharge charge () const
 
const CurvilinearTrajectoryErrorcurvilinearError () const
 
FreeTrajectoryStatefreeTrajectoryState (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)
 
double signedInverseMomentum () const
 
const Surfacesurface () const
 
SurfaceSide surfaceSide () const
 Position relative to material, defined relative to momentum vector. More...
 
double transverseCurvature () const
 
virtual double weight () const
 
virtual ~BasicTrajectoryState ()
 
- Public Member Functions inherited from ReferenceCountedPoolAllocated
void addReference () const
 
const
ReferenceCountedPoolAllocated
operator= (const ReferenceCountedPoolAllocated &)
 
 ReferenceCountedPoolAllocated ()
 
 ReferenceCountedPoolAllocated (const ReferenceCountedPoolAllocated &iRHS)
 
unsigned int references () const
 
void removeReference () const
 
virtual ~ReferenceCountedPoolAllocated ()
 
- Public Member Functions inherited from BlockWipedPoolAllocated
virtual ~BlockWipedPoolAllocated ()
 

Private Types

typedef TrajectoryStateOnSurface TSOS
 

Private Member Functions

void combine ()
 

Private Attributes

std::vector< TSOStheStates
 

Additional Inherited Members

- Public Types inherited from BasicTrajectoryState
typedef BasicTrajectoryState BTSOS
 
typedef ProxyBase< BTSOS,
CopyUsingClone< BTSOS > > 
Proxy
 
typedef
ReferenceCountingPointer
< BasicTrajectoryState
RCPtr
 
typedef
SurfaceSideDefinition::SurfaceSide 
SurfaceSide
 
- Static Public Member Functions inherited from BlockWipedPoolAllocated
static BlockWipedAllocatorallocator (size_t s)
 
static void operator delete (void *p, size_t s)
 
static void * operator new (size_t s, void *p)
 
static void * operator new (size_t s)
 
static BlockWipedAllocator::Stat stat (size_t s)
 
static void usePool ()
 
- Static Public Attributes inherited from ReferenceCountedPoolAllocated
static int s_alive =0
 
static int s_referenced =0
 
- Static Public Attributes inherited from BlockWipedPoolAllocated
static int s_alive =0
 
static bool s_usePool =false
 

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 19 of file BasicMultiTrajectoryState.h.

Constructor & Destructor Documentation

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

Definition at line 8 of file BasicMultiTrajectoryState.cc.

References combine(), edm::hlt::Exception, i, theStates, and unlikely.

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

Definition at line 25 of file BasicMultiTrajectoryState.h.

Referenced by clone().

25 {}

Member Function Documentation

virtual bool BasicMultiTrajectoryState::canUpdateLocalParameters ( ) const
inlinevirtual

Reimplemented from BasicTrajectoryState.

Definition at line 45 of file BasicMultiTrajectoryState.h.

45 { return false; }
virtual BasicMultiTrajectoryState* BasicMultiTrajectoryState::clone ( void  ) const
inlinevirtual

Implements BasicTrajectoryState.

Definition at line 36 of file BasicMultiTrajectoryState.h.

References BasicMultiTrajectoryState().

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

Definition at line 57 of file BasicMultiTrajectoryState.cc.

References diffTreeTool::diff, timingPdfMaker::mean, alignCSCRings::s, theStates, unlikely, BasicTrajectoryState::update(), and BasicTrajectoryState::weight().

Referenced by BasicMultiTrajectoryState(), and rescaleError().

57  {
58  const std::vector<TrajectoryStateOnSurface>& tsos = theStates;
59 
60  if unlikely(tsos.empty()) {
61  edm::LogError("MultiTrajectoryStateCombiner")
62  << "Trying to collapse empty set of trajectory states!";
63  return;
64  }
65 
66  double pzSign = tsos.front().localParameters().pzSign();
67  for (std::vector<TrajectoryStateOnSurface>::const_iterator it = tsos.begin();
68  it != tsos.end(); it++) {
69  if unlikely(it->localParameters().pzSign() != pzSign) {
70  edm::LogError("MultiTrajectoryStateCombiner")
71  << "Trying to collapse trajectory states with different signs on p_z!";
72  return;
73  }
74  }
75 
76  if unlikely(tsos.size() == 1) {
77  BasicTrajectoryState::update(tsos.front().localParameters(),
78  tsos.front().localError(),
79  tsos.front().surface(),
80  tsos.front().magneticField(),
81  tsos.front().surfaceSide(),
82  tsos.front().weight()
83  );
84  return;
85  }
86 
87  double sumw = 0.;
88  //int dim = tsos.front().localParameters().vector().num_row();
90  AlgebraicSymMatrix55 covarPart1, covarPart2;
91  for (std::vector<TrajectoryStateOnSurface>::const_iterator it1 = tsos.begin();
92  it1 != tsos.end(); it1++) {
93  double weight = it1->weight();
94  AlgebraicVector5 param = it1->localParameters().vector();
95  sumw += weight;
96  mean += weight * param;
97  covarPart1 += weight * it1->localError().matrix();
98  for (std::vector<TrajectoryStateOnSurface>::const_iterator it2 = it1 + 1;
99  it2 != tsos.end(); it2++) {
100  AlgebraicVector5 diff = param - it2->localParameters().vector();
101  AlgebraicSymMatrix11 s = AlgebraicMatrixID(); //stupid trick to make CLHEP work decently
102  covarPart2 += (weight * it2->weight()) *
103  ROOT::Math::Similarity(AlgebraicMatrix51(diff.Array(), 5), s);
104  //FIXME: we can surely write this thing in a better way
105  }
106  }
107  double sumwI = 1.0/sumw;
108  mean *= sumwI;
109  covarPart1 *= sumwI; covarPart2 *= (sumwI*sumwI);
110  AlgebraicSymMatrix55 covar = covarPart1 + covarPart2;
111 
113  LocalTrajectoryError(covar),
114  tsos.front().surface(),
115  tsos.front().magneticField(),
116  tsos.front().surfaceSide(),
117  sumw);
118 }
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
ROOT::Math::SMatrix< double, 5, 1, ROOT::Math::MatRepStd< double, 5, 1 > > AlgebraicMatrix51
virtual void update(const LocalTrajectoryParameters &p, const Surface &aSurface, const MagneticField *field, const SurfaceSide side)
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
#define unlikely(x)
Definition: Likely.h:21
ROOT::Math::SVector< double, 5 > AlgebraicVector5
virtual double weight() const
ROOT::Math::SMatrix< double, 1, 1, ROOT::Math::MatRepSym< double, 1 > > AlgebraicSymMatrix11
virtual std::vector<TrajectoryStateOnSurface> BasicMultiTrajectoryState::components ( ) const
inlinevirtual

Reimplemented from BasicTrajectoryState.

Definition at line 40 of file BasicMultiTrajectoryState.h.

References theStates.

40  {
41  return theStates;
42  }
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 43 of file BasicMultiTrajectoryState.cc.

References combine(), theStates, and unlikely.

43  {
44 
45  if unlikely(theStates.empty()) {
46  edm::LogError("BasicMultiTrajectoryState") << "Trying to rescale errors of empty MultiTrajectoryState!";
47  return;
48  }
49 
50  for (std::vector<TSOS>::iterator it = theStates.begin(); it != theStates.end(); it++) {
51  it->rescaleError(factor);
52  }
53  combine();
54 }
#define unlikely(x)
Definition: Likely.h:21
void BasicMultiTrajectoryState::update ( const LocalTrajectoryParameters p,
const Surface aSurface,
const MagneticField field,
const SurfaceSide  side 
)
virtual

Reimplemented from BasicTrajectoryState.

Definition at line 122 of file BasicMultiTrajectoryState.cc.

References edm::hlt::Exception.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.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(), relval_steps.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().

126 {
127  throw cms::Exception("LogicError",
128  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, Surface, ...) called even if canUpdateLocalParameters() is false");
129 }
void BasicMultiTrajectoryState::update ( const LocalTrajectoryParameters p,
const LocalTrajectoryError err,
const Surface aSurface,
const MagneticField field,
const SurfaceSide  side,
double  weight 
)
virtual

Reimplemented from BasicTrajectoryState.

Definition at line 133 of file BasicMultiTrajectoryState.cc.

References edm::hlt::Exception.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.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(), relval_steps.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().

139 {
140  throw cms::Exception("LogicError",
141  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, LocalTrajectoryError, ...) called even if canUpdateLocalParameters() is false");
142 }

Member Data Documentation

std::vector<TSOS> BasicMultiTrajectoryState::theStates
private