CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 35 of file BasicMultiTrajectoryState.h.

Definition at line 18 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.

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

Definition at line 23 of file BasicMultiTrajectoryState.h.

23 {}

Member Function Documentation

bool BasicMultiTrajectoryState::canUpdateLocalParameters ( ) const
inlineoverridevirtual

Reimplemented from BasicTrajectoryState.

Definition at line 39 of file BasicMultiTrajectoryState.h.

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

Implements BasicTrajectoryState.

Definition at line 33 of file BasicMultiTrajectoryState.h.

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

Definition at line 47 of file BasicMultiTrajectoryState.cc.

References change_name::diff, SiStripPI::mean, theStates, UNLIKELY, BasicTrajectoryState::update(), and BasicTrajectoryState::weight().

Referenced by BasicMultiTrajectoryState(), and rescaleError().

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

Implements BasicTrajectoryState.

Definition at line 36 of file BasicMultiTrajectoryState.h.

References theStates.

36 { return theStates; }
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 36 of file BasicMultiTrajectoryState.cc.

References combine(), theStates, and UNLIKELY.

36  {
37  if UNLIKELY (theStates.empty()) {
38  edm::LogError("BasicMultiTrajectoryState") << "Trying to rescale errors of empty MultiTrajectoryState!";
39  return;
40  }
41 
42  for (auto& is : theStates)
43  is.rescaleError(factor);
44  combine();
45 }
Log< level::Error, false > LogError
#define UNLIKELY(x)
Definition: Likely.h:21
bool BasicMultiTrajectoryState::singleState ( ) const
inlineoverridevirtual

Implements BasicTrajectoryState.

Definition at line 37 of file BasicMultiTrajectoryState.h.

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

Reimplemented from BasicTrajectoryState.

Definition at line 104 of file BasicMultiTrajectoryState.cc.

References Exception.

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

107  {
108  throw cms::Exception("LogicError",
109  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, Surface, ...) called even if "
110  "canUpdateLocalParameters() is false");
111 }
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 113 of file BasicMultiTrajectoryState.cc.

References Exception.

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

118  {
119  throw cms::Exception("LogicError",
120  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, LocalTrajectoryError, ...) called "
121  "even if canUpdateLocalParameters() is false");
122 }

Member Data Documentation

Components BasicMultiTrajectoryState::theStates
private

Definition at line 53 of file BasicMultiTrajectoryState.h.

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