Go to the documentation of this file.00001 #include "TrackingTools/GsfTools/interface/MultiTrajectoryStateCombiner.h"
00002
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004
00005 TrajectoryStateOnSurface
00006 MultiTrajectoryStateCombiner::combine(const std::vector<TrajectoryStateOnSurface>& tsos) const {
00007
00008 if (tsos.empty()) {
00009 edm::LogError("MultiTrajectoryStateCombiner")
00010 << "Trying to collapse empty set of trajectory states!";
00011 return TrajectoryStateOnSurface();
00012 }
00013
00014 double pzSign = tsos.front().localParameters().pzSign();
00015 for (std::vector<TrajectoryStateOnSurface>::const_iterator it = tsos.begin();
00016 it != tsos.end(); it++) {
00017 if (it->localParameters().pzSign() != pzSign) {
00018 edm::LogError("MultiTrajectoryStateCombiner")
00019 << "Trying to collapse trajectory states with different signs on p_z!";
00020 return TrajectoryStateOnSurface();
00021 }
00022 }
00023
00024 if (tsos.size() == 1) {
00025 return TrajectoryStateOnSurface(tsos.front());
00026 }
00027
00028 double sumw = 0.;
00029
00030 AlgebraicVector5 mean;
00031 AlgebraicSymMatrix55 covarPart1, covarPart2;
00032 for (std::vector<TrajectoryStateOnSurface>::const_iterator it1 = tsos.begin();
00033 it1 != tsos.end(); it1++) {
00034 double weight = it1->weight();
00035 AlgebraicVector5 param = it1->localParameters().vector();
00036 sumw += weight;
00037 mean += weight * param;
00038 covarPart1 += weight * it1->localError().matrix();
00039 for (std::vector<TrajectoryStateOnSurface>::const_iterator it2 = it1 + 1;
00040 it2 != tsos.end(); it2++) {
00041 AlgebraicVector5 diff = param - it2->localParameters().vector();
00042 AlgebraicSymMatrix11 s = AlgebraicMatrixID();
00043 covarPart2 += weight * it2->weight() *
00044 ROOT::Math::Similarity(AlgebraicMatrix51(diff.Array(), 5), s);
00045
00046 }
00047 }
00048 double sumwI = 1.0/sumw;
00049 mean *= sumwI;
00050 covarPart1 *= sumwI; covarPart2 *= (sumwI*sumwI);
00051 AlgebraicSymMatrix55 covar = covarPart1 + covarPart2;
00052
00053 return TrajectoryStateOnSurface(LocalTrajectoryParameters(mean, pzSign),
00054 LocalTrajectoryError(covar),
00055 tsos.front().surface(),
00056 &(tsos.front().globalParameters().magneticField()),
00057 tsos.front().surfaceSide(),
00058 sumw);
00059 }
00060