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 ()
 
 BasicMultiTrajectoryState (const std::vector< TSOS > &tsvec)
 
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 FreeTrajectoryState &fts)
 
 BasicTrajectoryState (const FreeTrajectoryState &fts, const SurfaceType &aSurface, 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)
 
 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 SurfaceType &aSurface)
 construct invalid trajectory state (without parameters) More...
 
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 LocalTrajectoryError &err, const SurfaceSide side) final
 
virtual void update (const LocalTrajectoryParameters &p, 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

◆ Components

Definition at line 35 of file BasicMultiTrajectoryState.h.

◆ TSOS

Definition at line 18 of file BasicMultiTrajectoryState.h.

Constructor & Destructor Documentation

◆ BasicMultiTrajectoryState() [1/2]

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

Definition at line 8 of file BasicMultiTrajectoryState.cc.

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 }

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

◆ BasicMultiTrajectoryState() [2/2]

BasicMultiTrajectoryState::BasicMultiTrajectoryState ( )
inline

Definition at line 23 of file BasicMultiTrajectoryState.h.

23 {}

Member Function Documentation

◆ canUpdateLocalParameters()

bool BasicMultiTrajectoryState::canUpdateLocalParameters ( ) const
inlineoverridevirtual

Reimplemented from BasicTrajectoryState.

Definition at line 39 of file BasicMultiTrajectoryState.h.

39 { return false; }

◆ clone()

pointer BasicMultiTrajectoryState::clone ( void  ) const
inlineoverridevirtual

Implements BasicTrajectoryState.

Definition at line 33 of file BasicMultiTrajectoryState.h.

33 { return build<BasicMultiTrajectoryState>(*this); }

◆ combine()

void BasicMultiTrajectoryState::combine ( )
private

Definition at line 47 of file BasicMultiTrajectoryState.cc.

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 
98  LocalTrajectoryError(covar),
99  tsos.front().surface(),
100  tsos.front().magneticField(),
101  tsos.front().surfaceSide());
102 }

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

Referenced by BasicMultiTrajectoryState(), and rescaleError().

◆ components()

Components const& BasicMultiTrajectoryState::components ( ) const
inlineoverridevirtual

Implements BasicTrajectoryState.

Definition at line 36 of file BasicMultiTrajectoryState.h.

36 { return theStates; }

References theStates.

◆ rescaleError()

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.

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 }

References combine(), DQMScaleToClient_cfi::factor, theStates, and UNLIKELY.

◆ singleState()

bool BasicMultiTrajectoryState::singleState ( ) const
inlineoverridevirtual

Implements BasicTrajectoryState.

Definition at line 37 of file BasicMultiTrajectoryState.h.

37 { return false; }

◆ update() [1/2]

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.

107  {
108  throw cms::Exception("LogicError",
109  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, Surface, ...) called even if "
110  "canUpdateLocalParameters() is false");
111 }

References Exception.

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

◆ update() [2/2]

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.

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

References Exception.

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

Member Data Documentation

◆ theStates

Components BasicMultiTrajectoryState::theStates
private

Definition at line 53 of file BasicMultiTrajectoryState.h.

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

change_name.diff
diff
Definition: change_name.py:13
mps_fire.i
i
Definition: mps_fire.py:428
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
BasicTrajectoryState::weight
double weight() const
Definition: BasicTrajectoryState.h:248
BasicMultiTrajectoryState::combine
void combine()
Definition: BasicMultiTrajectoryState.cc:47
edm::errors::LogicError
Definition: EDMException.h:37
FrontierCondition_GT_autoExpress_cfi.auto
auto
Definition: FrontierCondition_GT_autoExpress_cfi.py:16
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState()
Definition: BasicTrajectoryState.h:76
mps_fire.end
end
Definition: mps_fire.py:242
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
LocalTrajectoryError
Definition: LocalTrajectoryError.h:20
Exception
BasicTrajectoryState::update
virtual void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side)
Definition: BasicTrajectoryState.cc:173
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlgebraicVector5
ROOT::Math::SVector< double, 5 > AlgebraicVector5
Definition: AlgebraicROOTObjects.h:14
cms::cuda::for
for(int i=first, nt=offsets[nh];i< nt;i+=gridDim.x *blockDim.x)
Definition: HistoContainer.h:15
Exception
Definition: hltDiff.cc:245
BoundPlane
ALCARECOPromptCalibProdSiPixelAli0T_cff.throw
throw
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:9
BasicMultiTrajectoryState::theStates
Components theStates
Definition: BasicMultiTrajectoryState.h:53
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
weight
Definition: weight.py:1
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21