CMS 3D CMS Logo

BasicMultiTrajectoryState.cc
Go to the documentation of this file.
2 
5 
6 using namespace SurfaceSideDefinition;
7 
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 }
41 
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 }
53 
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 }
113 
115  const Surface& aSurface,
116  const MagneticField* field,
117  const SurfaceSide side) {
118  throw cms::Exception("LogicError",
119  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, Surface, ...) called even if "
120  "canUpdateLocalParameters() is false");
121 }
122 
125  const LocalTrajectoryError& err,
126  const Surface& aSurface,
127  const MagneticField* field,
128  const SurfaceSide side) {
129  throw cms::Exception("LogicError",
130  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, LocalTrajectoryError, ...) called "
131  "even if canUpdateLocalParameters() is false");
132 }
change_name.diff
diff
Definition: change_name.py:13
BasicMultiTrajectoryState::BasicMultiTrajectoryState
BasicMultiTrajectoryState()
Definition: BasicMultiTrajectoryState.h:23
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
BasicTrajectoryState::weight
double weight() const
Definition: BasicTrajectoryState.h:252
BasicMultiTrajectoryState::combine
void combine()
Definition: BasicMultiTrajectoryState.cc:54
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
BasicMultiTrajectoryState::rescaleError
void rescaleError(double factor)
Definition: BasicMultiTrajectoryState.cc:42
Surface
Definition: Surface.h:36
SurfaceSideDefinition::SurfaceSide
SurfaceSide
Definition: SurfaceSideDefinition.h:8
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
BasicMultiTrajectoryState::update
void update(const LocalTrajectoryParameters &p, const Surface &aSurface, const MagneticField *field, const SurfaceSide side) override
Definition: BasicMultiTrajectoryState.cc:114
DQMScaleToClient_cfi.factor
factor
Definition: DQMScaleToClient_cfi.py:8
LocalTrajectoryError
Definition: LocalTrajectoryError.h:20
SurfaceSideDefinition
Definition: SurfaceSideDefinition.h:7
BasicTrajectoryState::update
virtual void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side)
Definition: BasicTrajectoryState.cc:175
BasicTrajectoryState
Definition: BasicTrajectoryState.h:66
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
AlgebraicVector5
ROOT::Math::SVector< double, 5 > AlgebraicVector5
Definition: AlgebraicROOTObjects.h:14
Exception
Definition: hltDiff.cc:246
BoundPlane
BoundPlane.h
BasicMultiTrajectoryState::theStates
Components theStates
Definition: BasicMultiTrajectoryState.h:53
BasicMultiTrajectoryState.h
MagneticField
Definition: MagneticField.h:19
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
weight
Definition: weight.py:1