CMS 3D CMS Logo

MultiTrajectoryStateCombiner Class Reference

Class which combines a set of components of a Gaussian mixture into a single component. More...

#include <TrackingTools/GsfTools/interface/MultiTrajectoryStateCombiner.h>

List of all members.

Public Member Functions

TrajectoryStateOnSurface combine (const std::vector< TrajectoryStateOnSurface > &tsos) const
 MultiTrajectoryStateCombiner ()
 ~MultiTrajectoryStateCombiner ()


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 15 of file MultiTrajectoryStateCombiner.h.


Constructor & Destructor Documentation

MultiTrajectoryStateCombiner::MultiTrajectoryStateCombiner (  )  [inline]

Definition at line 19 of file MultiTrajectoryStateCombiner.h.

00019 {}

MultiTrajectoryStateCombiner::~MultiTrajectoryStateCombiner (  )  [inline]

Definition at line 20 of file MultiTrajectoryStateCombiner.h.

00020 {}


Member Function Documentation

TrajectoryStateOnSurface MultiTrajectoryStateCombiner::combine ( const std::vector< TrajectoryStateOnSurface > &  tsos  )  const

Definition at line 6 of file MultiTrajectoryStateCombiner.cc.

References diff, it, it1, mean(), s, and weight.

Referenced by BasicMultiTrajectoryState::checkCombinedState().

00006                                                                                            {
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   //int dim = tsos.front().localParameters().vector().num_row();
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(); //stupid trick to make CLHEP work decently
00043       covarPart2 += weight * it2->weight() * 
00044                                 ROOT::Math::Similarity(AlgebraicMatrix51(diff.Array(), 5), s);
00045                         //FIXME: we can surely write this thing in a better way
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 }


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:28:34 2009 for CMSSW by  doxygen 1.5.4