test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 31 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().

31  {
32 
33  /* LogInfo("PFGsfHelper")<<" PFGsfHelper built"; */
34 
35 
36  // TrajectoryStateOnSurface theUpdateState = tm.forwardPredictedState();
40 
41 
42  Valid = true;
43  if ( !theUpdateState.isValid() ||
45  !theBackwardState.isValid() ) Valid = false;
46 
47  if (Valid){
48 
49  mode_Px = 0.;
50  mode_Py = 0.;
51  mode_Pz = 0.;
52  std::vector<TrajectoryStateOnSurface> components(theUpdateState.components());
53  unsigned int numb = components.size();
54 
55  std::vector<SingleGaussianState1D> pxStates; pxStates.reserve(numb);
56  std::vector<SingleGaussianState1D> pyStates; pyStates.reserve(numb);
57  std::vector<SingleGaussianState1D> pzStates; pzStates.reserve(numb);
58  for ( std::vector<TrajectoryStateOnSurface>::const_iterator ic=components.begin();
59  ic!=components.end(); ++ic ) {
60  GlobalVector momentum(ic->globalMomentum());
61  AlgebraicSymMatrix66 cov(ic->cartesianError().matrix());
62  pxStates.push_back(SingleGaussianState1D(momentum.x(),cov(3,3),ic->weight()));
63  pyStates.push_back(SingleGaussianState1D(momentum.y(),cov(4,4),ic->weight()));
64  pzStates.push_back(SingleGaussianState1D(momentum.z(),cov(5,5),ic->weight()));
65  // cout<<"COMP "<<momentum<<endl;
66  }
67  MultiGaussianState1D pxState(pxStates);
68  MultiGaussianState1D pyState(pyStates);
69  MultiGaussianState1D pzState(pzStates);
70  GaussianSumUtilities1D pxUtils(pxState);
71  GaussianSumUtilities1D pyUtils(pyState);
72  GaussianSumUtilities1D pzUtils(pzState);
73  mode_Px = pxUtils.mode().mean();
74  mode_Py = pyUtils.mode().mean();
75  mode_Pz = pzUtils.mode().mean();
76 
77 
78  dp = 0.;
79  sigmaDp = 0.;
80 
81  //
82  // prepare input parameter vectors and covariance matrices
83  //
84 
87  computeQpMode(theForwardState,fwdPars,fwdCov);
90  computeQpMode(theBackwardState,bwdPars,bwdCov);
91  LocalPoint hitPos(0.,0.,0.);
92  LocalError hitErr(-1.,-1.,-1.);
93  if ( tm.recHit()->isValid() ) {
94  hitPos = tm.recHit()->localPosition();
95  hitErr = tm.recHit()->localPositionError();
96  }
97 
98  CollinearFitAtTM collinearFit;
99  CollinearFitAtTM::ResultVector fitParameters;
100  CollinearFitAtTM::ResultMatrix fitCovariance;
101  double fitChi2;
102  bool CollFit = true;
103  if ( !collinearFit.fit(fwdPars,fwdCov,bwdPars,bwdCov,
104  hitPos,hitErr,
105  fitParameters,fitCovariance,fitChi2) ) CollFit = false;
106 
107  if (CollFit){
108  double qpIn = fitParameters(0);
109  double sig2In = fitCovariance(0,0);
110  double qpOut = fitParameters(1);
111  double sig2Out = fitCovariance(1,1);
112  double corrInOut = fitCovariance(0,1);
113  double pIn = 1./fabs(qpIn);
114  double pOut = 1./fabs(qpOut);
115  double sig2DeltaP = pIn/qpIn*pIn/qpIn*sig2In - 2*pIn/qpIn*pOut/qpOut*corrInOut +
116  pOut/qpOut*pOut/qpOut*sig2Out;
117  // std::cout << "fitted delta p = " << pOut-pIn << " sigma = "
118  // << sqrt(sig2DeltaP) << std::endl;
119  dp = pOut - pIn;
120  sigmaDp = sqrt(sig2DeltaP);
121 
122  }
123 
124 
125  }
126 }
double dp
Definition: PFGsfHelper.h:51
void computeQpMode(const TrajectoryStateOnSurface tsos, AlgebraicVector5 &parameters, AlgebraicSymMatrix55 &covariance) const
Definition: PFGsfHelper.cc:149
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 &quot;true&quot; 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
std::vector< TrajectoryStateOnSurface > components() const
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 128 of file PFGsfHelper.cc.

128  {
129 }

Member Function Documentation

GlobalVector PFGsfHelper::computeP ( bool  ComputeMode) const

Definition at line 130 of file PFGsfHelper.cc.

Referenced by PFTrackTransformer::addPointsAndBrems().

130  {
131  GlobalVector gsfp;
132  if (ComputeMode) gsfp = GlobalVector(mode_Px,mode_Py,mode_Pz);
133  else gsfp = theUpdateState.globalMomentum();
134  return gsfp;
135 }
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 149 of file PFGsfHelper.cc.

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

151 {
152  //
153  // parameters and errors from combined state
154  //
155  parameters = tsos.localParameters().vector();
156  covariance = tsos.localError().matrix();
157  //
158  // mode for parameter 0 (q/p)
159  //
161  GaussianSumUtilities1D qpGS(qpState);
162  if ( !qpGS.modeIsValid() ) return;
163  double qp = qpGS.mode().mean();
164  double varQp = qpGS.mode().variance();
165  //
166  // replace q/p value and variance, rescale correlation terms
167  // (heuristic procedure - alternative would be mode in 5D ...)
168  //
169  double VarQpRatio = sqrt(varQp/covariance(0,0));
170  parameters(0) = qp;
171  covariance(0,0) = varQp;
172  for ( int i=1; i<5; ++i ) covariance(i,0) *= VarQpRatio;
173 // std::cout << "covariance " << VarQpRatio << " "
174 // << covariance(1,0) << " " << covariance(0,1) << std::endl;
175 }
int i
Definition: DBlmapReader.cc:9
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 136 of file PFGsfHelper.cc.

References reco::dp.

Referenced by PFTrackTransformer::addPointsAndBrems().

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

Definition at line 144 of file PFGsfHelper.cc.

Referenced by core.AutoHandle.AutoHandle::ReallyLoad().

145 {
146  return Valid;
147 }
double PFGsfHelper::sigmafittedDP ( ) const

Definition at line 140 of file PFGsfHelper.cc.

Referenced by PFTrackTransformer::addPointsAndBrems().

141 {
142  return sigmaDp;
143 }
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.