CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MultiTrajectoryStateCombiner.cc
Go to the documentation of this file.
2 
4 
6 MultiTrajectoryStateCombiner::combine(const std::vector<TrajectoryStateOnSurface>& tsos) const {
7 
8  if (tsos.empty()) {
9  edm::LogError("MultiTrajectoryStateCombiner")
10  << "Trying to collapse empty set of trajectory states!";
11  return TrajectoryStateOnSurface();
12  }
13 
14  double pzSign = tsos.front().localParameters().pzSign();
15  for (std::vector<TrajectoryStateOnSurface>::const_iterator it = tsos.begin();
16  it != tsos.end(); it++) {
17  if (it->localParameters().pzSign() != pzSign) {
18  edm::LogError("MultiTrajectoryStateCombiner")
19  << "Trying to collapse trajectory states with different signs on p_z!";
20  return TrajectoryStateOnSurface();
21  }
22  }
23 
24  if (tsos.size() == 1) {
25  return TrajectoryStateOnSurface(tsos.front());
26  }
27 
28  double sumw = 0.;
29  //int dim = tsos.front().localParameters().vector().num_row();
31  AlgebraicSymMatrix55 covarPart1, covarPart2;
32  for (std::vector<TrajectoryStateOnSurface>::const_iterator it1 = tsos.begin();
33  it1 != tsos.end(); it1++) {
34  double weight = it1->weight();
35  AlgebraicVector5 param = it1->localParameters().vector();
36  sumw += weight;
37  mean += weight * param;
38  covarPart1 += weight * it1->localError().matrix();
39  for (std::vector<TrajectoryStateOnSurface>::const_iterator it2 = it1 + 1;
40  it2 != tsos.end(); it2++) {
41  AlgebraicVector5 diff = param - it2->localParameters().vector();
42  AlgebraicSymMatrix11 s = AlgebraicMatrixID(); //stupid trick to make CLHEP work decently
43  covarPart2 += weight * it2->weight() *
44  ROOT::Math::Similarity(AlgebraicMatrix51(diff.Array(), 5), s);
45  //FIXME: we can surely write this thing in a better way
46  }
47  }
48  double sumwI = 1.0/sumw;
49  mean *= sumwI;
50  covarPart1 *= sumwI; covarPart2 *= (sumwI*sumwI);
51  AlgebraicSymMatrix55 covar = covarPart1 + covarPart2;
52 
54  LocalTrajectoryError(covar),
55  tsos.front().surface(),
56  &(tsos.front().globalParameters().magneticField()),
57  tsos.front().surfaceSide(),
58  sumw);
59 }
60 
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
TrajectoryStateOnSurface combine(const std::vector< TrajectoryStateOnSurface > &tsos) const
ROOT::Math::SMatrix< double, 5, 1, ROOT::Math::MatRepStd< double, 5, 1 > > AlgebraicMatrix51
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
ROOT::Math::SVector< double, 5 > AlgebraicVector5
string s
Definition: asciidump.py:422
ROOT::Math::SMatrix< double, 1, 1, ROOT::Math::MatRepSym< double, 1 > > AlgebraicSymMatrix11