CMS 3D CMS Logo

PFGsfHelper Class Reference

#include <RecoParticleFlow/PFTracking/interface/PFGsfHelper.h>

List of all members.

Public Member Functions

GlobalVector computeP (bool ComputeMode) const
double fittedDP () const
bool isValid () const
 PFGsfHelper (const TrajectoryMeasurement &)
double sigmafittedDP () const
 ~PFGsfHelper ()

Private Member Functions

void computeQpMode (const TrajectoryStateOnSurface tsos, AlgebraicVector5 &parameters, AlgebraicSymMatrix55 &covariance) const

Private Attributes

double dp
float mode_Px
float mode_Py
float mode_Pz
double sigmaDp
TrajectoryStateOnSurface theBackwardState
TrajectoryStateOnSurface theForwardState
TrajectoryStateOnSurface theUpdateState
bool Valid


Detailed Description

Definition at line 31 of file PFGsfHelper.h.


Constructor & Destructor Documentation

PFGsfHelper::PFGsfHelper ( const TrajectoryMeasurement tm  ) 

Definition at line 31 of file PFGsfHelper.cc.

References TrajectoryMeasurement::backwardPredictedState(), TrajectoryStateOnSurface::components(), computeQpMode(), dp, CollinearFitAtTM::fit(), TrajectoryMeasurement::forwardPredictedState(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LocalTrajectoryError::matrix(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mode(), mode_Px, mode_Py, mode_Pz, TrajectoryMeasurement::recHit(), sigmaDp, funct::sqrt(), theBackwardState, theForwardState, theUpdateState, TrajectoryMeasurement::updatedState(), Valid, and LocalTrajectoryParameters::vector().

00031                                                        {
00032   
00033   /* LogInfo("PFGsfHelper")<<" PFGsfHelper  built"; */
00034 
00035   
00036   // TrajectoryStateOnSurface theUpdateState = tm.forwardPredictedState();
00037   theUpdateState = tm.updatedState();
00038   theForwardState = tm.forwardPredictedState();
00039   theBackwardState = tm.backwardPredictedState();
00040   
00041 
00042   Valid = true;
00043   if ( !theUpdateState.isValid() ||
00044        !theForwardState.isValid() ||
00045         !theBackwardState.isValid() )  Valid = false;
00046 
00047   if (Valid){
00048       
00049     mode_Px = 0.;
00050     mode_Py = 0.;
00051     mode_Pz = 0.;
00052     std::vector<TrajectoryStateOnSurface> components(theForwardState.components());
00053     unsigned int numb = components.size();
00054 
00055     std::vector<SingleGaussianState1D> pxStates; pxStates.reserve(numb);
00056     std::vector<SingleGaussianState1D> pyStates; pyStates.reserve(numb);
00057     std::vector<SingleGaussianState1D> pzStates; pzStates.reserve(numb);
00058     for ( std::vector<TrajectoryStateOnSurface>::const_iterator ic=components.begin();
00059           ic!=components.end(); ++ic ) {
00060       GlobalVector momentum(ic->globalMomentum());
00061       AlgebraicSymMatrix66 cov(ic->cartesianError().matrix());
00062         pxStates.push_back(SingleGaussianState1D(momentum.x(),cov(3,3),ic->weight()));
00063         pyStates.push_back(SingleGaussianState1D(momentum.y(),cov(4,4),ic->weight()));
00064         pzStates.push_back(SingleGaussianState1D(momentum.z(),cov(5,5),ic->weight()));
00065         //      cout<<"COMP "<<momentum<<endl;
00066     }
00067     MultiGaussianState1D pxState(pxStates);
00068     MultiGaussianState1D pyState(pyStates);
00069     MultiGaussianState1D pzState(pzStates);
00070     GaussianSumUtilities1D pxUtils(pxState);
00071     GaussianSumUtilities1D pyUtils(pyState);
00072     GaussianSumUtilities1D pzUtils(pzState);
00073     mode_Px = pxUtils.mode().mean();
00074     mode_Py = pyUtils.mode().mean();
00075     mode_Pz = pzUtils.mode().mean();
00076 
00077   
00078     dp = 0.;
00079     sigmaDp = 0.;
00080     
00081     //
00082     // prepare input parameter vectors and covariance matrices
00083     //
00084  
00085     AlgebraicVector5 fwdPars = theForwardState.localParameters().vector();
00086     AlgebraicSymMatrix55 fwdCov = theForwardState.localError().matrix();
00087     computeQpMode(theForwardState,fwdPars,fwdCov);
00088     AlgebraicVector5 bwdPars = theBackwardState.localParameters().vector();
00089     AlgebraicSymMatrix55 bwdCov = theBackwardState.localError().matrix();
00090     computeQpMode(theBackwardState,bwdPars,bwdCov);
00091     LocalPoint hitPos(0.,0.,0.);
00092     LocalError hitErr(-1.,-1.,-1.);
00093     if ( tm.recHit()->isValid() ) {
00094       hitPos = tm.recHit()->localPosition();
00095       hitErr = tm.recHit()->localPositionError();
00096     }
00097     
00098     CollinearFitAtTM collinearFit;
00099     CollinearFitAtTM::ResultVector fitParameters;
00100     CollinearFitAtTM::ResultMatrix fitCovariance;
00101     double fitChi2;
00102     bool CollFit = true;
00103     if ( !collinearFit.fit(fwdPars,fwdCov,bwdPars,bwdCov,
00104                            hitPos,hitErr,
00105                            fitParameters,fitCovariance,fitChi2) )  CollFit = false;
00106 
00107     if (CollFit){
00108       double qpIn = fitParameters(0);
00109       double sig2In = fitCovariance(0,0);
00110       double qpOut = fitParameters(1);
00111       double sig2Out = fitCovariance(1,1);
00112       double corrInOut = fitCovariance(0,1);
00113       double pIn = 1./fabs(qpIn);
00114       double pOut = 1./fabs(qpOut);
00115       double sig2DeltaP = pIn/qpIn*pIn/qpIn*sig2In - 2*pIn/qpIn*pOut/qpOut*corrInOut + 
00116         pOut/qpOut*pOut/qpOut*sig2Out;
00117       //   std::cout << "fitted delta p = " << pOut-pIn << " sigma = " 
00118       //            << sqrt(sig2DeltaP) << std::endl;
00119       dp = pOut - pIn;      
00120       sigmaDp = sqrt(sig2DeltaP);
00121   
00122     }
00123     
00124     
00125   }
00126 }

PFGsfHelper::~PFGsfHelper (  ) 

Definition at line 128 of file PFGsfHelper.cc.

00128                          {
00129 }


Member Function Documentation

GlobalVector PFGsfHelper::computeP ( bool  ComputeMode  )  const

Definition at line 130 of file PFGsfHelper.cc.

References TrajectoryStateOnSurface::globalMomentum(), mode_Px, mode_Py, mode_Pz, and theUpdateState.

Referenced by PFTrackTransformer::addPointsAndBrems().

00130                                                          {
00131   GlobalVector gsfp;
00132   if (ComputeMode) gsfp = GlobalVector(mode_Px,mode_Py,mode_Pz);
00133   else gsfp = theUpdateState.globalMomentum();
00134   return gsfp;
00135 }

void PFGsfHelper::computeQpMode ( const TrajectoryStateOnSurface  tsos,
AlgebraicVector5 parameters,
AlgebraicSymMatrix55 covariance 
) const [private]

Definition at line 149 of file PFGsfHelper.cc.

References i, TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LocalTrajectoryError::matrix(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mode(), GaussianSumUtilities1D::modeIsValid(), MultiGaussianStateTransform::multiState1D(), python::trackProbabilityAnalysis_cff::parameters, funct::sqrt(), SingleGaussianState1D::variance(), and LocalTrajectoryParameters::vector().

Referenced by PFGsfHelper().

00151 {
00152   //
00153   // parameters and errors from combined state
00154   //
00155   parameters = tsos.localParameters().vector();
00156   covariance = tsos.localError().matrix();
00157   //
00158   // mode for parameter 0 (q/p)
00159   //
00160   MultiGaussianState1D qpState(MultiGaussianStateTransform::multiState1D(tsos,0));
00161   GaussianSumUtilities1D qpGS(qpState);
00162   if ( !qpGS.modeIsValid() )  return;
00163   double qp = qpGS.mode().mean();
00164   double varQp = qpGS.mode().variance();
00165   //
00166   // replace q/p value and variance, rescale correlation terms
00167   //   (heuristic procedure - alternative would be mode in 5D ...)
00168   //
00169   double VarQpRatio = sqrt(varQp/covariance(0,0));
00170   parameters(0) = qp;
00171   covariance(0,0) = varQp;
00172   for ( int i=1; i<5; ++i )  covariance(i,0) *= VarQpRatio;
00173 //   std::cout << "covariance " << VarQpRatio << " "
00174 //          << covariance(1,0) << " " << covariance(0,1) << std::endl;
00175 }

double PFGsfHelper::fittedDP (  )  const

Definition at line 136 of file PFGsfHelper.cc.

References dp.

Referenced by PFTrackTransformer::addPointsAndBrems().

00137 {  
00138   return dp;
00139 }

bool PFGsfHelper::isValid ( void   )  const

Definition at line 144 of file PFGsfHelper.cc.

References Valid.

00145 {
00146   return Valid;
00147 } 

double PFGsfHelper::sigmafittedDP (  )  const

Definition at line 140 of file PFGsfHelper.cc.

References sigmaDp.

Referenced by PFTrackTransformer::addPointsAndBrems().

00141 {
00142   return sigmaDp;
00143 }


Member Data Documentation

double PFGsfHelper::dp [private]

Definition at line 52 of file PFGsfHelper.h.

Referenced by fittedDP(), and PFGsfHelper().

float PFGsfHelper::mode_Px [private]

Definition at line 48 of file PFGsfHelper.h.

Referenced by computeP(), and PFGsfHelper().

float PFGsfHelper::mode_Py [private]

Definition at line 49 of file PFGsfHelper.h.

Referenced by computeP(), and PFGsfHelper().

float PFGsfHelper::mode_Pz [private]

Definition at line 50 of file PFGsfHelper.h.

Referenced by computeP(), and PFGsfHelper().

double PFGsfHelper::sigmaDp [private]

Definition at line 53 of file PFGsfHelper.h.

Referenced by PFGsfHelper(), and sigmafittedDP().

TrajectoryStateOnSurface PFGsfHelper::theBackwardState [private]

Definition at line 56 of file PFGsfHelper.h.

Referenced by PFGsfHelper().

TrajectoryStateOnSurface PFGsfHelper::theForwardState [private]

Definition at line 55 of file PFGsfHelper.h.

Referenced by PFGsfHelper().

TrajectoryStateOnSurface PFGsfHelper::theUpdateState [private]

Definition at line 54 of file PFGsfHelper.h.

Referenced by computeP(), and PFGsfHelper().

bool PFGsfHelper::Valid [private]

Definition at line 51 of file PFGsfHelper.h.

Referenced by isValid(), and PFGsfHelper().


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