CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions
MultiTrajectoryStateMode Class Reference

#include <MultiTrajectoryStateMode.h>

Public Member Functions

int chargeFromMode (const TrajectoryStateOnSurface tsos) const
 
bool momentumFromModeCartesian (const TrajectoryStateOnSurface tsos, GlobalVector &momentum) const
 
bool momentumFromModeLocal (const TrajectoryStateOnSurface tsos, GlobalVector &momentum) const
 
bool momentumFromModeP (const TrajectoryStateOnSurface tsos, double &momentum) const
 
bool momentumFromModePPhiEta (const TrajectoryStateOnSurface tsos, GlobalVector &momentum) const
 
bool momentumFromModeQP (const TrajectoryStateOnSurface tsos, double &momentum) const
 
bool positionFromModeCartesian (const TrajectoryStateOnSurface tsos, GlobalPoint &position) const
 
bool positionFromModeLocal (const TrajectoryStateOnSurface tsos, GlobalPoint &position) const
 

Detailed Description

Definition at line 11 of file MultiTrajectoryStateMode.h.

Member Function Documentation

int MultiTrajectoryStateMode::chargeFromMode ( const TrajectoryStateOnSurface  tsos) const

Charge from 1D mode calculation in q/p. Q=0 in case of failure.

Definition at line 331 of file MultiTrajectoryStateMode.cc.

References TrajectoryStateOnSurface::isValid(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mean(), GaussianSumUtilities1D::mode(), GaussianSumUtilities1D::modeIsValid(), MultiGaussianStateTransform::multiState1D(), and mps_fire::result.

332 {
333  //
334  // clear result vector and check validity of the TSOS
335  //
336  if ( !tsos.isValid() ) {
337  edm::LogInfo("MultiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
338  return 0;
339  }
340  //
341  // mode computation for local co-ordinates q/p
342  // extraction of multi-state using helper class
344  GaussianSumUtilities1D utils(state1D);
345  // mode (in case of failure: mean)
346  double result = utils.mode().mean();
347  if ( !utils.modeIsValid() ) result = utils.mean();
348 
349  return result>0. ? 1 : -1;
350 }
tuple result
Definition: mps_fire.py:84
MultiGaussianState1D multiState1D(const std::vector< MultiGaussianState< N >::Vector > &, const std::vector< MultiGaussianState< N >::Matrix > &, const std::vector< double > &, unsigned int)
bool MultiTrajectoryStateMode::momentumFromModeCartesian ( const TrajectoryStateOnSurface  tsos,
GlobalVector momentum 
) const

Cartesian momentum from 1D mode calculation in cartesian co-ordinates. Return value true for success.

Definition at line 13 of file MultiTrajectoryStateMode.cc.

References makeMuonMisalignmentScenario::components, TrajectoryStateOnSurface::components(), TrajectoryStateOnSurface::isValid(), SingleGaussianState1D::mean(), and GaussianSumUtilities1D::mode().

Referenced by PFTrackTransformer::addPointsAndBrems(), GsfElectronAlgo::ElectronData::calculateMode(), MultiTrajectoryStateTransform::innerMomentumFromMode(), MultiTrajectoryStateTransform::outerMomentumFromMode(), EgammaHLTPixelMatchElectronAlgo::process(), and PFElecTkProducer::resolveGsfTracks().

15 {
16  //
17  // clear result vector and check validity of the TSOS
18  //
19  momentum = GlobalVector(0.,0.,0.);
20  if ( !tsos.isValid() ) {
21  edm::LogInfo("MultiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
22  return false;
23  }
24  //
25  // 1D mode computation for px, py and pz
26  //
27  std::vector<TrajectoryStateOnSurface> components(tsos.components());
28  unsigned int numb = components.size();
29  // vectors of components in x, y and z
30  std::vector<SingleGaussianState1D> pxStates; pxStates.reserve(numb);
31  std::vector<SingleGaussianState1D> pyStates; pyStates.reserve(numb);
32  std::vector<SingleGaussianState1D> pzStates; pzStates.reserve(numb);
33  // iteration over components
34  for ( std::vector<TrajectoryStateOnSurface>::const_iterator ic=components.begin();
35  ic!=components.end(); ++ic ) {
36  // extraction of parameters and variances
37  GlobalVector mom(ic->globalMomentum());
38  AlgebraicSymMatrix66 cov(ic->cartesianError().matrix());
39  pxStates.push_back(SingleGaussianState1D(mom.x(),cov(3,3),ic->weight()));
40  pyStates.push_back(SingleGaussianState1D(mom.y(),cov(4,4),ic->weight()));
41  pzStates.push_back(SingleGaussianState1D(mom.z(),cov(5,5),ic->weight()));
42  }
43  //
44  // transformation in 1D multi-states and creation of utility classes
45  //
46  MultiGaussianState1D pxState(pxStates);
47  MultiGaussianState1D pyState(pyStates);
48  MultiGaussianState1D pzState(pzStates);
49  GaussianSumUtilities1D pxUtils(pxState);
50  GaussianSumUtilities1D pyUtils(pyState);
51  GaussianSumUtilities1D pzUtils(pzState);
52  //
53  // cartesian momentum vector from modes
54  //
55  momentum = GlobalVector(pxUtils.mode().mean(),pyUtils.mode().mean(),pzUtils.mode().mean());
56  return true;
57 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
std::vector< TrajectoryStateOnSurface > components() const
Global3DVector GlobalVector
Definition: GlobalVector.h:10
bool MultiTrajectoryStateMode::momentumFromModeLocal ( const TrajectoryStateOnSurface  tsos,
GlobalVector momentum 
) const

Cartesian momentum from 1D mode calculation in local co-ordinates (q/p, dx/dz, dy/dz). Return value true for success.

Definition at line 107 of file MultiTrajectoryStateMode.cc.

References TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localParameters(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mean(), GaussianSumUtilities1D::mode(), GaussianSumUtilities1D::modeIsValid(), MultiGaussianStateTransform::multiState1D(), LocalTrajectoryParameters::pzSign(), mps_fire::result, mathSSE::sqrt(), TrajectoryStateOnSurface::surface(), and Surface::toGlobal().

109 {
110  //
111  // clear result vector and check validity of the TSOS
112  //
113  momentum = GlobalVector(0.,0.,0.);
114  if ( !tsos.isValid() ) {
115  edm::LogInfo("MultiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
116  return false;
117  }
118  //
119  // mode computation for local co-ordinates q/p, dx/dz, dy/dz
120  //
121  double qpMode(0);
122  double dxdzMode(0);
123  double dydzMode(0);
124  //
125  // first 3 elements of local parameters = q/p, dx/dz, dy/dz
126  //
127  for ( unsigned int iv=0; iv<3; ++iv ) {
128  // extraction of multi-state using helper class
130  GaussianSumUtilities1D utils(state1D);
131  // mode (in case of failure: mean)
132  double result = utils.mode().mean();
133  if ( !utils.modeIsValid() ) result = utils.mean();
134  if ( iv==0 ) qpMode = result;
135  else if ( iv==1 ) dxdzMode = result;
136  else dydzMode = result;
137  }
138  // local momentum vector from dx/dz, dy/dz and q/p + sign of local pz
139  LocalVector localP(dxdzMode,dydzMode,1.);
140  localP *= tsos.localParameters().pzSign()/fabs(qpMode)
141  /sqrt(dxdzMode*dxdzMode+dydzMode*dydzMode+1.);
142  // conversion to global coordinates
143  momentum = tsos.surface().toGlobal(localP);
144  return true;
145 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
const LocalTrajectoryParameters & localParameters() const
tuple result
Definition: mps_fire.py:84
const SurfaceType & surface() 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
float pzSign() const
Sign of the z-component of the momentum in the local frame.
Global3DVector GlobalVector
Definition: GlobalVector.h:10
bool MultiTrajectoryStateMode::momentumFromModeP ( const TrajectoryStateOnSurface  tsos,
double &  momentum 
) const

Momentum from 1D mode calculation in p. Return value true for sucess.

Definition at line 178 of file MultiTrajectoryStateMode.cc.

References MultiGaussianState1D::components(), i, TrajectoryStateOnSurface::isValid(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mean(), GaussianSumUtilities1D::mode(), GaussianSumUtilities1D::modeIsValid(), MultiGaussianStateTransform::multiState1D(), AlCaHLTBitMon_ParallelJobs::p, SingleGaussianState1D::variance(), and SingleGaussianState1D::weight().

180 {
181  //
182  // clear result vector and check validity of the TSOS
183  //
184  momentum = 0.;
185  if ( !tsos.isValid() ) {
186  edm::LogInfo("MultiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
187  return false;
188  }
189  //
190  // first element of local parameters = q/p
191  //
192  // extraction of multi-state using helper class
194  std::vector<SingleGaussianState1D> states(qpMultiState.components());
195  // transform from q/p to p
196  for ( unsigned int i=0; i<states.size(); ++i ) {
197  SingleGaussianState1D& qpState = states[i];
198  double wgt = qpState.weight();
199  double qp = qpState.mean();
200  double varQp = qpState.variance();
201  double p = 1./fabs(qp);
202  double varP = p*p*p*p*varQp;
203  states[i] = SingleGaussianState1D(p,varP,wgt);
204  }
205  MultiGaussianState1D pMultiState(states);
206  GaussianSumUtilities1D utils(pMultiState);
207  // mode (in case of failure: mean)
208  momentum = utils.mode().mean();
209  if ( !utils.modeIsValid() ) momentum = utils.mean();
210 
211  return true;
212 }
int i
Definition: DBlmapReader.cc:9
MultiGaussianState1D multiState1D(const std::vector< MultiGaussianState< N >::Vector > &, const std::vector< MultiGaussianState< N >::Matrix > &, const std::vector< double > &, unsigned int)
double mean() const
parameter vector
double variance() const
variance
double weight() const
weight
const SingleState1dContainer & components() const
access to components
bool MultiTrajectoryStateMode::momentumFromModePPhiEta ( const TrajectoryStateOnSurface  tsos,
GlobalVector momentum 
) const

Cartesian momentum from 1D mode calculation in p, phi, eta. Return value true for success.

Definition at line 252 of file MultiTrajectoryStateMode.cc.

References makeMuonMisalignmentScenario::components, TrajectoryStateOnSurface::components(), funct::cos(), eta, create_public_lumi_plots::exp, TrajectoryStateOnSurface::isValid(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mean(), GaussianSumUtilities1D::mode(), GaussianSumUtilities1D::modeIsValid(), AlCaHLTBitMon_ParallelJobs::p, phi, EnergyCorrector::pt, funct::sin(), and PV3DBase< T, PVType, FrameType >::x().

254 {
255  //
256  // clear result vector and check validity of the TSOS
257  //
258  momentum = GlobalVector(0.,0.,0.);
259  if ( !tsos.isValid() ) {
260  edm::LogInfo("MultiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
261  return false;
262  }
263  //
264  // 1D mode computation for p, phi, eta
265  //
266  std::vector<TrajectoryStateOnSurface> components(tsos.components());
267  unsigned int numb = components.size();
268  // vectors of components in p, phi and eta
269  std::vector<SingleGaussianState1D> pStates; pStates.reserve(numb);
270  std::vector<SingleGaussianState1D> phiStates; phiStates.reserve(numb);
271  std::vector<SingleGaussianState1D> etaStates; etaStates.reserve(numb);
272  // covariances in cartesian and p-phi-eta and jacobian
273  AlgebraicMatrix33 jacobian;
274  AlgebraicSymMatrix33 covCart;
275  AlgebraicSymMatrix33 covPPhiEta;
276  // iteration over components
277  for ( std::vector<TrajectoryStateOnSurface>::const_iterator ic=components.begin();
278  ic!=components.end(); ++ic ) {
279  // parameters
280  GlobalVector mom(ic->globalMomentum());
281  double px = mom.x();
282  double py = mom.y();
283  double pz = mom.z();
284  double p = mom.mag();
285  double pt2 = mom.perp2();
286  double phi = mom.phi();
287  double eta = mom.eta();
288  // jacobian
289  jacobian(0,0) = px/p;
290  jacobian(0,1) = py/p;
291  jacobian(0,2) = pz/p;
292  jacobian(1,0) = py/pt2;
293  jacobian(1,1) = -px/pt2;
294  jacobian(1,2) = 0;
295  jacobian(2,0) = px*pz/(pt2*p);
296  jacobian(2,1) = py*pz/(pt2*p);
297  jacobian(2,2) = -1./p;
298  // extraction of the momentum part from the 6x6 cartesian error matrix
299  // and conversion to p-phi-eta
300  covCart = ic->cartesianError().matrix().Sub<AlgebraicSymMatrix33>(3,3);
301  covPPhiEta = ROOT::Math::Similarity(jacobian,covCart);
302  pStates.push_back(SingleGaussianState1D(p,covPPhiEta(0,0),ic->weight()));
303  phiStates.push_back(SingleGaussianState1D(phi,covPPhiEta(1,1),ic->weight()));
304  etaStates.push_back(SingleGaussianState1D(eta,covPPhiEta(2,2),ic->weight()));
305  }
306  //
307  // transformation in 1D multi-states and creation of utility classes
308  //
309  MultiGaussianState1D pState(pStates);
310  MultiGaussianState1D phiState(phiStates);
311  MultiGaussianState1D etaState(etaStates);
312  GaussianSumUtilities1D pUtils(pState);
313  GaussianSumUtilities1D phiUtils(phiState);
314  GaussianSumUtilities1D etaUtils(etaState);
315  //
316  // parameters from mode (in case of failure: mean)
317  //
318  double p = pUtils.modeIsValid() ? pUtils.mode().mean() : pUtils.mean();
319  double phi = phiUtils.modeIsValid() ? phiUtils.mode().mean() : phiUtils.mean();
320  double eta = etaUtils.modeIsValid() ? etaUtils.mode().mean() : etaUtils.mean();
321 // double theta = 2*atan(exp(-eta));
322  double tanth2 = exp(-eta);
323  double pt = p*2*tanth2/(1+tanth2*tanth2); // p*sin(theta)
324  double pz = p*(1-tanth2*tanth2)/(1+tanth2*tanth2); // p*cos(theta)
325  // conversion to a cartesian momentum vector
326  momentum = GlobalVector(pt*cos(phi),pt*sin(phi),pz);
327  return true;
328 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< TrajectoryStateOnSurface > components() const
T x() const
Definition: PV3DBase.h:62
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
Global3DVector GlobalVector
Definition: GlobalVector.h:10
bool MultiTrajectoryStateMode::momentumFromModeQP ( const TrajectoryStateOnSurface  tsos,
double &  momentum 
) const

Momentum from 1D mode calculation in q/p. Return value true for sucess.

Definition at line 148 of file MultiTrajectoryStateMode.cc.

References TrajectoryStateOnSurface::isValid(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mean(), GaussianSumUtilities1D::mode(), GaussianSumUtilities1D::modeIsValid(), and MultiGaussianStateTransform::multiState1D().

150 {
151  //
152  // clear result vector and check validity of the TSOS
153  //
154  momentum = 0.;
155  if ( !tsos.isValid() ) {
156  edm::LogInfo("MultiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
157  return false;
158  }
159  //
160  // mode computation for local co-ordinates q/p, dx/dz, dy/dz
161  //
162  double qpMode(0);
163  //
164  // first element of local parameters = q/p
165  //
166  // extraction of multi-state using helper class
168  GaussianSumUtilities1D utils(state1D);
169  // mode (in case of failure: mean)
170  qpMode = utils.mode().mean();
171  if ( !utils.modeIsValid() ) qpMode = utils.mean();
172 
173  momentum = 1./fabs(qpMode);
174  return true;
175 }
MultiGaussianState1D multiState1D(const std::vector< MultiGaussianState< N >::Vector > &, const std::vector< MultiGaussianState< N >::Matrix > &, const std::vector< double > &, unsigned int)
bool MultiTrajectoryStateMode::positionFromModeCartesian ( const TrajectoryStateOnSurface  tsos,
GlobalPoint position 
) const

Cartesian position from 1D mode calculation in cartesian co-ordinates. Return value true for success.

Definition at line 60 of file MultiTrajectoryStateMode.cc.

References makeMuonMisalignmentScenario::components, TrajectoryStateOnSurface::components(), TrajectoryStateOnSurface::isValid(), SingleGaussianState1D::mean(), and GaussianSumUtilities1D::mode().

Referenced by PFTrackTransformer::addPointsAndBrems(), and GsfElectronAlgo::ElectronData::calculateMode().

62 {
63  //
64  // clear result vector and check validity of the TSOS
65  //
66  position = GlobalPoint(0.,0.,0.);
67  if ( !tsos.isValid() ) {
68  edm::LogInfo("MultiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
69  return false;
70  }
71  //
72  // 1D mode computation for x, y and z
73  //
74  std::vector<TrajectoryStateOnSurface> components(tsos.components());
75  unsigned int numb = components.size();
76  // vectors of components in x, y and z
77  std::vector<SingleGaussianState1D> xStates; xStates.reserve(numb);
78  std::vector<SingleGaussianState1D> yStates; yStates.reserve(numb);
79  std::vector<SingleGaussianState1D> zStates; zStates.reserve(numb);
80  // iteration over components
81  for ( std::vector<TrajectoryStateOnSurface>::const_iterator ic=components.begin();
82  ic!=components.end(); ++ic ) {
83  // extraction of parameters and variances
84  GlobalPoint pos(ic->globalPosition());
85  AlgebraicSymMatrix66 cov(ic->cartesianError().matrix());
86  xStates.push_back(SingleGaussianState1D(pos.x(),cov(0,0),ic->weight()));
87  yStates.push_back(SingleGaussianState1D(pos.y(),cov(1,1),ic->weight()));
88  zStates.push_back(SingleGaussianState1D(pos.z(),cov(2,2),ic->weight()));
89  }
90  //
91  // transformation in 1D multi-states and creation of utility classes
92  //
93  MultiGaussianState1D xState(xStates);
94  MultiGaussianState1D yState(yStates);
95  MultiGaussianState1D zState(zStates);
96  GaussianSumUtilities1D xUtils(xState);
97  GaussianSumUtilities1D yUtils(yState);
98  GaussianSumUtilities1D zUtils(zState);
99  //
100  // cartesian position vector from modes
101  //
102  position = GlobalPoint(xUtils.mode().mean(),yUtils.mode().mean(),zUtils.mode().mean());
103  return true;
104 }
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< TrajectoryStateOnSurface > components() const
bool MultiTrajectoryStateMode::positionFromModeLocal ( const TrajectoryStateOnSurface  tsos,
GlobalPoint position 
) const

Cartesian position from 1D mode calculation in local co-ordinates (x, y). Return value true for success.

Definition at line 215 of file MultiTrajectoryStateMode.cc.

References TrajectoryStateOnSurface::isValid(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mean(), GaussianSumUtilities1D::mode(), GaussianSumUtilities1D::modeIsValid(), MultiGaussianStateTransform::multiState1D(), mps_fire::result, TrajectoryStateOnSurface::surface(), and Surface::toGlobal().

217 {
218  //
219  // clear result vector and check validity of the TSOS
220  //
221  position = GlobalPoint(0.,0.,0.);
222  if ( !tsos.isValid() ) {
223  edm::LogInfo("MultiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
224  return false;
225  }
226  //
227  // mode computation for local co-ordinates x, y
228  //
229  double xMode(0);
230  double yMode(0);
231  //
232  // last 2 elements of local parameters = x, y
233  //
234  for ( unsigned int iv=3; iv<5; ++iv ) {
235  // extraction of multi-state using helper class
237  GaussianSumUtilities1D utils(state1D);
238  // mode (in case of failure: mean)
239  double result = utils.mode().mean();
240  if ( !utils.modeIsValid() ) result = utils.mean();
241  if ( iv==3 ) xMode = result;
242  else yMode = result;
243  }
244  // local position vector from x, y
245  LocalPoint localP(xMode,yMode,0.);
246  // conversion to global coordinates
247  position = tsos.surface().toGlobal(localP);
248  return true;
249 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
tuple result
Definition: mps_fire.py:84
const SurfaceType & surface() const
MultiGaussianState1D multiState1D(const std::vector< MultiGaussianState< N >::Vector > &, const std::vector< MultiGaussianState< N >::Matrix > &, const std::vector< double > &, unsigned int)