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

Constructor & Destructor Documentation

◆ PFGsfHelper()

PFGsfHelper::PFGsfHelper ( const TrajectoryMeasurement tm)

Definition at line 32 of file PFGsfHelper.cc.

References TrajectoryMeasurement::backwardPredictedState(), makeMuonMisalignmentScenario::components, Calorimetry_cff::dp, CollinearFitAtTM::fit(), fitChi2(), L1TRate_cfi::fitParameters, 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;
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
const LocalTrajectoryError & localError() const
TrajectoryStateOnSurface theBackwardState
Definition: PFGsfHelper.h:52
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
bool fit(const TrajectoryMeasurement &tm, ResultVector &parameters, ResultMatrix &covariance, double &chi2)
Fit for one TM. Return value "true" for success.
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > ResultMatrix
static double fitChi2(const CachingVertex< 5 > &vtx)
double sigmaDp
Definition: PFGsfHelper.h:49
fitParameters
Offline oracleDB = cms.string("oracle://cms_orcon_adg/CMS_COND_31X_L1T"), # For offline pathCondDB = ...
Definition: L1TRate_cfi.py:69
T sqrt(T t)
Definition: SSEVec.h:23
AlgebraicVector5 vector() const
void computeQpMode(const TrajectoryStateOnSurface tsos, AlgebraicVector5 &parameters, AlgebraicSymMatrix55 &covariance) const
Definition: PFGsfHelper.cc:134
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
ROOT::Math::SVector< double, 6 > ResultVector
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
const AlgebraicSymMatrix55 & matrix() 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
ConstRecHitPointer const & recHit() const
float mode_Px
Definition: PFGsfHelper.h:44

◆ ~PFGsfHelper()

PFGsfHelper::~PFGsfHelper ( )

Definition at line 121 of file PFGsfHelper.cc.

121 {}

Member Function Documentation

◆ computeP()

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

◆ computeQpMode()

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 LocalTrajectoryError & localError() const
const LocalTrajectoryParameters & localParameters() 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:23
AlgebraicVector5 vector() const
const AlgebraicSymMatrix55 & matrix() const

◆ fittedDP()

double PFGsfHelper::fittedDP ( ) const

Definition at line 130 of file PFGsfHelper.cc.

References Calorimetry_cff::dp.

Referenced by PFTrackTransformer::addPointsAndBrems().

130 { return dp; }
double dp
Definition: PFGsfHelper.h:48

◆ isValid()

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; }

◆ sigmafittedDP()

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

◆ dp

double PFGsfHelper::dp
private

Definition at line 48 of file PFGsfHelper.h.

◆ mode_Px

float PFGsfHelper::mode_Px
private

Definition at line 44 of file PFGsfHelper.h.

◆ mode_Py

float PFGsfHelper::mode_Py
private

Definition at line 45 of file PFGsfHelper.h.

◆ mode_Pz

float PFGsfHelper::mode_Pz
private

Definition at line 46 of file PFGsfHelper.h.

◆ sigmaDp

double PFGsfHelper::sigmaDp
private

Definition at line 49 of file PFGsfHelper.h.

◆ theBackwardState

TrajectoryStateOnSurface PFGsfHelper::theBackwardState
private

Definition at line 52 of file PFGsfHelper.h.

◆ theForwardState

TrajectoryStateOnSurface PFGsfHelper::theForwardState
private

Definition at line 51 of file PFGsfHelper.h.

◆ theUpdateState

TrajectoryStateOnSurface PFGsfHelper::theUpdateState
private

Definition at line 50 of file PFGsfHelper.h.

◆ Valid

bool PFGsfHelper::Valid
private

Definition at line 47 of file PFGsfHelper.h.