CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PFGsfHelper Class Reference

#include <PFGsfHelper.h>

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 30 of file PFGsfHelper.h.

Constructor & Destructor Documentation

PFGsfHelper::PFGsfHelper ( const TrajectoryMeasurement tm)

Definition at line 33 of file PFGsfHelper.cc.

References TrajectoryMeasurement::backwardPredictedState(), makeMuonMisalignmentScenario::components, reco::dp, CollinearFitAtTM::fit(), fitChi2(), TrajectoryMeasurement::forwardPredictedState(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mode(), TrajectoryMeasurement::recHit(), mathSSE::sqrt(), and TrajectoryMeasurement::updatedState().

33  {
34 
35  /* LogInfo("PFGsfHelper")<<" PFGsfHelper built"; */
36 
37 
38  // TrajectoryStateOnSurface theUpdateState = tm.forwardPredictedState();
42 
43 
44  Valid = true;
45  if ( !theUpdateState.isValid() ||
47  !theBackwardState.isValid() ) Valid = false;
48 
49  if (Valid){
50 
51  mode_Px = 0.;
52  mode_Py = 0.;
53  mode_Pz = 0.;
55  auto const & components = comps();
56  auto numb=components.size();
57  std::vector<SingleGaussianState1D> pxStates; pxStates.reserve(numb);
58  std::vector<SingleGaussianState1D> pyStates; pyStates.reserve(numb);
59  std::vector<SingleGaussianState1D> pzStates; pzStates.reserve(numb);
60  for (auto ic=components.begin();
61  ic!=components.end(); ++ic ) {
62  GlobalVector momentum(ic->globalMomentum());
63  AlgebraicSymMatrix66 cov(ic->cartesianError().matrix());
64  pxStates.push_back(SingleGaussianState1D(momentum.x(),cov(3,3),ic->weight()));
65  pyStates.push_back(SingleGaussianState1D(momentum.y(),cov(4,4),ic->weight()));
66  pzStates.push_back(SingleGaussianState1D(momentum.z(),cov(5,5),ic->weight()));
67  // cout<<"COMP "<<momentum<<endl;
68  }
69  MultiGaussianState1D pxState(pxStates);
70  MultiGaussianState1D pyState(pyStates);
71  MultiGaussianState1D pzState(pzStates);
72  GaussianSumUtilities1D pxUtils(pxState);
73  GaussianSumUtilities1D pyUtils(pyState);
74  GaussianSumUtilities1D pzUtils(pzState);
75  mode_Px = pxUtils.mode().mean();
76  mode_Py = pyUtils.mode().mean();
77  mode_Pz = pzUtils.mode().mean();
78 
79 
80  dp = 0.;
81  sigmaDp = 0.;
82 
83  //
84  // prepare input parameter vectors and covariance matrices
85  //
86 
89  computeQpMode(theForwardState,fwdPars,fwdCov);
92  computeQpMode(theBackwardState,bwdPars,bwdCov);
93  LocalPoint hitPos(0.,0.,0.);
94  LocalError hitErr(-1.,-1.,-1.);
95  if ( tm.recHit()->isValid() ) {
96  hitPos = tm.recHit()->localPosition();
97  hitErr = tm.recHit()->localPositionError();
98  }
99 
100  CollinearFitAtTM collinearFit;
101  CollinearFitAtTM::ResultVector fitParameters;
102  CollinearFitAtTM::ResultMatrix fitCovariance;
103  double fitChi2;
104  bool CollFit = true;
105  if ( !collinearFit.fit(fwdPars,fwdCov,bwdPars,bwdCov,
106  hitPos,hitErr,
107  fitParameters,fitCovariance,fitChi2) ) CollFit = false;
108 
109  if (CollFit){
110  double qpIn = fitParameters(0);
111  double sig2In = fitCovariance(0,0);
112  double qpOut = fitParameters(1);
113  double sig2Out = fitCovariance(1,1);
114  double corrInOut = fitCovariance(0,1);
115  double pIn = 1./fabs(qpIn);
116  double pOut = 1./fabs(qpOut);
117  double sig2DeltaP = pIn/qpIn*pIn/qpIn*sig2In - 2*pIn/qpIn*pOut/qpOut*corrInOut +
118  pOut/qpOut*pOut/qpOut*sig2Out;
119  // std::cout << "fitted delta p = " << pOut-pIn << " sigma = "
120  // << sqrt(sig2DeltaP) << std::endl;
121  dp = pOut - pIn;
122  sigmaDp = sqrt(sig2DeltaP);
123 
124  }
125 
126 
127  }
128 }
double dp
Definition: PFGsfHelper.h:51
void computeQpMode(const TrajectoryStateOnSurface tsos, AlgebraicVector5 &parameters, AlgebraicSymMatrix55 &covariance) const
Definition: PFGsfHelper.cc:151
ConstRecHitPointer const & recHit() const
const LocalTrajectoryParameters & localParameters() const
TrajectoryStateOnSurface theBackwardState
Definition: PFGsfHelper.h:55
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > ResultMatrix
bool fit(const TrajectoryMeasurement &tm, ResultVector &parameters, ResultMatrix &covariance, double &chi2)
Fit for one TM. Return value "true" for success.
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
ROOT::Math::SVector< double, 6 > ResultVector
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
static double fitChi2(const CachingVertex< 5 > &vtx)
AlgebraicVector5 vector() const
double sigmaDp
Definition: PFGsfHelper.h:52
T sqrt(T t)
Definition: SSEVec.h:18
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
TrajectoryStateOnSurface const & updatedState() const
float mode_Pz
Definition: PFGsfHelper.h:49
TrajectoryStateOnSurface theUpdateState
Definition: PFGsfHelper.h:53
TrajectoryStateOnSurface theForwardState
Definition: PFGsfHelper.h:54
float mode_Py
Definition: PFGsfHelper.h:48
float mode_Px
Definition: PFGsfHelper.h:47
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
PFGsfHelper::~PFGsfHelper ( )

Definition at line 130 of file PFGsfHelper.cc.

130  {
131 }

Member Function Documentation

GlobalVector PFGsfHelper::computeP ( bool  ComputeMode) const

Definition at line 132 of file PFGsfHelper.cc.

Referenced by PFTrackTransformer::addPointsAndBrems().

132  {
133  GlobalVector gsfp;
134  if (ComputeMode) gsfp = GlobalVector(mode_Px,mode_Py,mode_Pz);
135  else gsfp = theUpdateState.globalMomentum();
136  return gsfp;
137 }
GlobalVector globalMomentum() const
float mode_Pz
Definition: PFGsfHelper.h:49
TrajectoryStateOnSurface theUpdateState
Definition: PFGsfHelper.h:53
float mode_Py
Definition: PFGsfHelper.h:48
float mode_Px
Definition: PFGsfHelper.h:47
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void PFGsfHelper::computeQpMode ( const TrajectoryStateOnSurface  tsos,
AlgebraicVector5 parameters,
AlgebraicSymMatrix55 covariance 
) const
private

Definition at line 151 of file PFGsfHelper.cc.

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

153 {
154  //
155  // parameters and errors from combined state
156  //
157  parameters = tsos.localParameters().vector();
158  covariance = tsos.localError().matrix();
159  //
160  // mode for parameter 0 (q/p)
161  //
163  GaussianSumUtilities1D qpGS(qpState);
164  if ( !qpGS.modeIsValid() ) return;
165  double qp = qpGS.mode().mean();
166  double varQp = qpGS.mode().variance();
167  //
168  // replace q/p value and variance, rescale correlation terms
169  // (heuristic procedure - alternative would be mode in 5D ...)
170  //
171  double VarQpRatio = sqrt(varQp/covariance(0,0));
172  parameters(0) = qp;
173  covariance(0,0) = varQp;
174  for ( int i=1; i<5; ++i ) covariance(i,0) *= VarQpRatio;
175 // std::cout << "covariance " << VarQpRatio << " "
176 // << covariance(1,0) << " " << covariance(0,1) << std::endl;
177 }
const LocalTrajectoryParameters & localParameters() const
AlgebraicVector5 vector() const
MultiGaussianState1D multiState1D(const std::vector< MultiGaussianState< N >::Vector > &, const std::vector< MultiGaussianState< N >::Matrix > &, const std::vector< double > &, unsigned int)
T sqrt(T t)
Definition: SSEVec.h:18
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
double PFGsfHelper::fittedDP ( ) const

Definition at line 138 of file PFGsfHelper.cc.

References reco::dp.

Referenced by PFTrackTransformer::addPointsAndBrems().

139 {
140  return dp;
141 }
double dp
Definition: PFGsfHelper.h:51
bool PFGsfHelper::isValid ( void  ) const

Definition at line 146 of file PFGsfHelper.cc.

Referenced by ntupleDataFormat._Object::_checkIsValid(), and core.AutoHandle.AutoHandle::ReallyLoad().

147 {
148  return Valid;
149 }
double PFGsfHelper::sigmafittedDP ( ) const

Definition at line 142 of file PFGsfHelper.cc.

Referenced by PFTrackTransformer::addPointsAndBrems().

143 {
144  return sigmaDp;
145 }
double sigmaDp
Definition: PFGsfHelper.h:52

Member Data Documentation

double PFGsfHelper::dp
private

Definition at line 51 of file PFGsfHelper.h.

float PFGsfHelper::mode_Px
private

Definition at line 47 of file PFGsfHelper.h.

float PFGsfHelper::mode_Py
private

Definition at line 48 of file PFGsfHelper.h.

float PFGsfHelper::mode_Pz
private

Definition at line 49 of file PFGsfHelper.h.

double PFGsfHelper::sigmaDp
private

Definition at line 52 of file PFGsfHelper.h.

TrajectoryStateOnSurface PFGsfHelper::theBackwardState
private

Definition at line 55 of file PFGsfHelper.h.

TrajectoryStateOnSurface PFGsfHelper::theForwardState
private

Definition at line 54 of file PFGsfHelper.h.

TrajectoryStateOnSurface PFGsfHelper::theUpdateState
private

Definition at line 53 of file PFGsfHelper.h.

bool PFGsfHelper::Valid
private

Definition at line 50 of file PFGsfHelper.h.