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
13  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
18  UNLIKELY(!i->isValid()) {
19  throw cms::Exception("LogicError") << "MultiTrajectoryState constructed with invalid state";
20  }
21  if
22  UNLIKELY(i->hasError() != tsvec.front().hasError()) {
23  throw cms::Exception("LogicError") << "MultiTrajectoryState mixes states with and without errors";
24  }
25  if
26  UNLIKELY(&i->surface() != &tsvec.front().surface()) {
27  throw cms::Exception("LogicError") << "MultiTrajectoryState mixes states with different surfaces";
28  }
29  if
30  UNLIKELY(i->surfaceSide() != tsvec.front().surfaceSide()) {
31  throw cms::Exception("LogicError") << "MultiTrajectoryState mixes states defined before and after material";
32  }
33  if
34  UNLIKELY(i->localParameters().pzSign() * tsvec.front().localParameters().pzSign() < 0.) {
35  throw cms::Exception("LogicError") << "MultiTrajectoryState mixes states with different signs of local p_z";
36  }
37  }
38  //
39  combine();
40 }

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 54 of file BasicMultiTrajectoryState.cc.

54  {
55  const std::vector<TrajectoryStateOnSurface>& tsos = theStates;
56 
57  if
58  UNLIKELY(tsos.empty()) {
59  edm::LogError("MultiTrajectoryStateCombiner") << "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(); it != tsos.end(); it++) {
65  if
66  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
74  UNLIKELY(tsos.size() == 1) {
75  BasicTrajectoryState::update(tsos.front().weight(),
76  tsos.front().localParameters(),
77  tsos.front().localError(),
78  tsos.front().surface(),
79  tsos.front().magneticField(),
80  tsos.front().surfaceSide());
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;
103  covarPart2 *= (sumwI * sumwI);
104  AlgebraicSymMatrix55 covar = covarPart1 + covarPart2;
105 
108  LocalTrajectoryError(covar),
109  tsos.front().surface(),
110  tsos.front().magneticField(),
111  tsos.front().surfaceSide());
112 }

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 42 of file BasicMultiTrajectoryState.cc.

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

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 114 of file BasicMultiTrajectoryState.cc.

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

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 123 of file BasicMultiTrajectoryState.cc.

128  {
129  throw cms::Exception("LogicError",
130  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, LocalTrajectoryError, ...) called "
131  "even if canUpdateLocalParameters() is false");
132 }

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:355
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
BasicTrajectoryState::weight
double weight() const
Definition: BasicTrajectoryState.h:252
BasicMultiTrajectoryState::combine
void combine()
Definition: BasicMultiTrajectoryState.cc:54
edm::errors::LogicError
Definition: EDMException.h:37
FrontierCondition_GT_autoExpress_cfi.auto
auto
Definition: FrontierCondition_GT_autoExpress_cfi.py:15
end
#define end
Definition: vmac.h:39
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
BasicTrajectoryState::BasicTrajectoryState
BasicTrajectoryState()
Definition: BasicTrajectoryState.h:76
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
LocalTrajectoryError
Definition: LocalTrajectoryError.h:20
edm::LogError
Definition: MessageLogger.h:183
Exception
BasicTrajectoryState::update
virtual void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side)
Definition: BasicTrajectoryState.cc:175
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:27
Exception
Definition: hltDiff.cc:246
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
begin
#define begin
Definition: vmac.h:32
weight
Definition: weight.py:1
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21