CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 29 of file PFGsfHelper.h.

Constructor & Destructor Documentation

PFGsfHelper::PFGsfHelper ( const TrajectoryMeasurement tm)

Definition at line 32 of file PFGsfHelper.cc.

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

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

Definition at line 121 of file PFGsfHelper.cc.

121 {}

Member Function Documentation

GlobalVector PFGsfHelper::computeP ( bool  ComputeMode) const

Definition at line 122 of file PFGsfHelper.cc.

Referenced by PFTrackTransformer::addPointsAndBrems().

122  {
123  GlobalVector gsfp;
124  if (ComputeMode)
126  else
128  return gsfp;
129 }
GlobalVector globalMomentum() const
float mode_Pz
Definition: PFGsfHelper.h:46
TrajectoryStateOnSurface theUpdateState
Definition: PFGsfHelper.h:50
float mode_Py
Definition: PFGsfHelper.h:45
float mode_Px
Definition: PFGsfHelper.h:44
Global3DVector GlobalVector
Definition: GlobalVector.h:10
void PFGsfHelper::computeQpMode ( const TrajectoryStateOnSurface  tsos,
AlgebraicVector5 parameters,
AlgebraicSymMatrix55 covariance 
) const
private

Definition at line 134 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().

136  {
137  //
138  // parameters and errors from combined state
139  //
140  parameters = tsos.localParameters().vector();
141  covariance = tsos.localError().matrix();
142  //
143  // mode for parameter 0 (q/p)
144  //
146  GaussianSumUtilities1D qpGS(qpState);
147  if (!qpGS.modeIsValid())
148  return;
149  double qp = qpGS.mode().mean();
150  double varQp = qpGS.mode().variance();
151  //
152  // replace q/p value and variance, rescale correlation terms
153  // (heuristic procedure - alternative would be mode in 5D ...)
154  //
155  double VarQpRatio = sqrt(varQp / covariance(0, 0));
156  parameters(0) = qp;
157  covariance(0, 0) = varQp;
158  for (int i = 1; i < 5; ++i)
159  covariance(i, 0) *= VarQpRatio;
160  // std::cout << "covariance " << VarQpRatio << " "
161  // << covariance(1,0) << " " << covariance(0,1) << std::endl;
162 }
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:19
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
double PFGsfHelper::fittedDP ( ) const

Definition at line 130 of file PFGsfHelper.cc.

Referenced by PFTrackTransformer::addPointsAndBrems().

130 { return dp; }
double dp
Definition: PFGsfHelper.h:48
bool PFGsfHelper::isValid ( void  ) const

Definition at line 132 of file PFGsfHelper.cc.

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

132 { return Valid; }
double PFGsfHelper::sigmafittedDP ( ) const

Definition at line 131 of file PFGsfHelper.cc.

Referenced by PFTrackTransformer::addPointsAndBrems().

131 { return sigmaDp; }
double sigmaDp
Definition: PFGsfHelper.h:49

Member Data Documentation

double PFGsfHelper::dp
private

Definition at line 48 of file PFGsfHelper.h.

float PFGsfHelper::mode_Px
private

Definition at line 44 of file PFGsfHelper.h.

float PFGsfHelper::mode_Py
private

Definition at line 45 of file PFGsfHelper.h.

float PFGsfHelper::mode_Pz
private

Definition at line 46 of file PFGsfHelper.h.

double PFGsfHelper::sigmaDp
private

Definition at line 49 of file PFGsfHelper.h.

TrajectoryStateOnSurface PFGsfHelper::theBackwardState
private

Definition at line 52 of file PFGsfHelper.h.

TrajectoryStateOnSurface PFGsfHelper::theForwardState
private

Definition at line 51 of file PFGsfHelper.h.

TrajectoryStateOnSurface PFGsfHelper::theUpdateState
private

Definition at line 50 of file PFGsfHelper.h.

bool PFGsfHelper::Valid
private

Definition at line 47 of file PFGsfHelper.h.