test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BasicMultiTrajectoryState.cc
Go to the documentation of this file.
2 
5 
6 using namespace SurfaceSideDefinition;
7 
8 BasicMultiTrajectoryState::BasicMultiTrajectoryState( const std::vector<TSOS>& tsvec) :
9  BasicTrajectoryState(tsvec.front().surface()), theStates(tsvec) {
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  for (auto i=tsvec.begin(); i!=tsvec.end(); i++) {
17  if unlikely(!i->isValid()) {
18  throw cms::Exception("LogicError") << "MultiTrajectoryState constructed with invalid state";
19  }
20  if unlikely(i->hasError() != tsvec.front().hasError()) {
21  throw cms::Exception("LogicError") << "MultiTrajectoryState mixes states with and without errors";
22  }
23  if unlikely( &i->surface() != &tsvec.front().surface()) {
24  throw cms::Exception("LogicError") << "MultiTrajectoryState mixes states with different surfaces";
25  }
26  if unlikely( i->surfaceSide() != tsvec.front().surfaceSide()) {
27  throw cms::Exception("LogicError")
28  << "MultiTrajectoryState mixes states defined before and after material";
29  }
30  if unlikely( i->localParameters().pzSign()*tsvec.front().localParameters().pzSign()<0. ) {
31  throw cms::Exception("LogicError")
32  << "MultiTrajectoryState mixes states with different signs of local p_z";
33  }
34 
35  }
36  //
37  combine();
38 }
39 
40 
41 
43 
44  if unlikely(theStates.empty()) {
45  edm::LogError("BasicMultiTrajectoryState") << "Trying to rescale errors of empty MultiTrajectoryState!";
46  return;
47  }
48 
49  for (std::vector<TSOS>::iterator it = theStates.begin(); it != theStates.end(); it++) {
50  it->rescaleError(factor);
51  }
52  combine();
53 }
54 
55 void
57  const std::vector<TrajectoryStateOnSurface>& tsos = theStates;
58 
59  if unlikely(tsos.empty()) {
60  edm::LogError("MultiTrajectoryStateCombiner")
61  << "Trying to collapse empty set of trajectory states!";
62  return;
63  }
64 
65  double pzSign = tsos.front().localParameters().pzSign();
66  for (std::vector<TrajectoryStateOnSurface>::const_iterator it = tsos.begin();
67  it != tsos.end(); it++) {
68  if unlikely(it->localParameters().pzSign() != pzSign) {
69  edm::LogError("MultiTrajectoryStateCombiner")
70  << "Trying to collapse trajectory states with different signs on p_z!";
71  return;
72  }
73  }
74 
75  if unlikely(tsos.size() == 1) {
76  BasicTrajectoryState::update(tsos.front().weight(),
77  tsos.front().localParameters(),
78  tsos.front().localError(),
79  tsos.front().surface(),
80  tsos.front().magneticField(),
81  tsos.front().surfaceSide()
82  );
83  return;
84  }
85 
86  double sumw = 0.;
87  //int dim = tsos.front().localParameters().vector().num_row();
89  AlgebraicSymMatrix55 covarPart1, covarPart2, covtmp;
90  for (auto it1 = tsos.begin(); it1 != tsos.end(); it1++) {
91  double weight = it1->weight();
92  AlgebraicVector5 param = it1->localParameters().vector();
93  sumw += weight;
94  mean += weight * param;
95  covarPart1 += weight * it1->localError().matrix();
96  for (auto it2 = it1 + 1; it2 != tsos.end(); it2++) {
97  AlgebraicVector5 diff = param - it2->localParameters().vector();
98  ROOT::Math::AssignSym::Evaluate(covtmp,ROOT::Math::TensorProd(diff,diff));
99  covarPart2 += (weight * it2->weight()) * covtmp;
100  }
101  }
102  double sumwI = 1.0/sumw;
103  mean *= sumwI;
104  covarPart1 *= sumwI; covarPart2 *= (sumwI*sumwI);
105  AlgebraicSymMatrix55 covar = covarPart1 + covarPart2;
106 
108  LocalTrajectoryParameters(mean, pzSign),
109  LocalTrajectoryError(covar),
110  tsos.front().surface(),
111  tsos.front().magneticField(),
112  tsos.front().surfaceSide()
113  );
114 }
115 
116 void
119  const Surface& aSurface,
120  const MagneticField* field,
121  const SurfaceSide side)
122 {
123  throw cms::Exception("LogicError",
124  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, Surface, ...) called even if canUpdateLocalParameters() is false");
125 }
126 
127 void
129 update( double weight,
131  const LocalTrajectoryError& err,
132  const Surface& aSurface,
133  const MagneticField* field,
134  const SurfaceSide side)
135 {
136  throw cms::Exception("LogicError",
137  "BasicMultiTrajectoryState::update(LocalTrajectoryParameters, LocalTrajectoryError, ...) called even if canUpdateLocalParameters() is false");
138 }
139 
int i
Definition: DBlmapReader.cc:9
virtual void update(const LocalTrajectoryParameters &p, const SurfaceType &aSurface, const MagneticField *field, const SurfaceSide side)
virtual void update(const LocalTrajectoryParameters &p, const Surface &aSurface, const MagneticField *field, const SurfaceSide side) override
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
list diff
Definition: mps_update.py:85
#define unlikely(x)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
int weight
Definition: histoStyle.py:50