CMS 3D CMS Logo

Functions
multiTrajectoryStateMode Namespace Reference

Functions

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

Function Documentation

◆ chargeFromMode()

int multiTrajectoryStateMode::chargeFromMode ( TrajectoryStateOnSurface const &  tsos)

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

Definition at line 331 of file MultiTrajectoryStateMode.cc.

331  {
332  //
333  // clear result vector and check validity of the TSOS
334  //
335  if (!tsos.isValid()) {
336  edm::LogInfo("multiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
337  return 0;
338  }
339  //
340  // mode computation for local co-ordinates q/p
341  // extraction of multi-state using helper class
343  GaussianSumUtilities1D utils(state1D);
344  // mode (in case of failure: mean)
345  double result = utils.mode().mean();
346  if (!utils.modeIsValid())
347  result = utils.mean();
348 
349  return result > 0. ? 1 : -1;
350  }

References TrajectoryStateOnSurface::isValid(), MultiGaussianStateTransform::multiState1D(), and mps_fire::result.

◆ momentumFromModeCartesian()

bool multiTrajectoryStateMode::momentumFromModeCartesian ( TrajectoryStateOnSurface const &  tsos,
GlobalVector momentum 
)

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

Definition at line 16 of file MultiTrajectoryStateMode.cc.

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

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

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

◆ momentumFromModeLocal()

bool multiTrajectoryStateMode::momentumFromModeLocal ( TrajectoryStateOnSurface const &  tsos,
GlobalVector momentum 
)

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

Definition at line 111 of file MultiTrajectoryStateMode.cc.

111  {
112  //
113  // clear result vector and check validity of the TSOS
114  //
115  momentum = GlobalVector(0., 0., 0.);
116  if (!tsos.isValid()) {
117  edm::LogInfo("multiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
118  return false;
119  }
120  //
121  // mode computation for local co-ordinates q/p, dx/dz, dy/dz
122  //
123  double qpMode(0);
124  double dxdzMode(0);
125  double dydzMode(0);
126  //
127  // first 3 elements of local parameters = q/p, dx/dz, dy/dz
128  //
129  for (unsigned int iv = 0; iv < 3; ++iv) {
130  // extraction of multi-state using helper class
132  GaussianSumUtilities1D utils(state1D);
133  // mode (in case of failure: mean)
134  double result = utils.mode().mean();
135  if (!utils.modeIsValid())
136  result = utils.mean();
137  if (iv == 0)
138  qpMode = result;
139  else if (iv == 1)
140  dxdzMode = result;
141  else
142  dydzMode = result;
143  }
144  // local momentum vector from dx/dz, dy/dz and q/p + sign of local pz
145  LocalVector localP(dxdzMode, dydzMode, 1.);
146  localP *= tsos.localParameters().pzSign() / fabs(qpMode) / sqrt(dxdzMode * dxdzMode + dydzMode * dydzMode + 1.);
147  // conversion to global coordinates
148  momentum = tsos.surface().toGlobal(localP);
149  return true;
150  }

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

◆ momentumFromModeP()

bool multiTrajectoryStateMode::momentumFromModeP ( TrajectoryStateOnSurface const &  tsos,
double &  momentum 
)

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

Definition at line 180 of file MultiTrajectoryStateMode.cc.

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())
210  momentum = utils.mean();
211 
212  return true;
213  }

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

◆ momentumFromModePPhiEta()

bool multiTrajectoryStateMode::momentumFromModePPhiEta ( TrajectoryStateOnSurface const &  tsos,
GlobalVector momentum 
)

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

Definition at line 252 of file MultiTrajectoryStateMode.cc.

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

References makeMuonMisalignmentScenario::components, funct::cos(), PVValHelper::eta, JetChargeProducer_cfi::exp, TrajectoryStateOnSurface::isValid(), SingleGaussianState1D::mean(), GaussianSumUtilities1D::mean(), GaussianSumUtilities1D::mode(), GaussianSumUtilities1D::modeIsValid(), AlCaHLTBitMon_ParallelJobs::p, DiDispStaMuonMonitor_cfi::pt, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, and funct::sin().

◆ momentumFromModeQP()

bool multiTrajectoryStateMode::momentumFromModeQP ( TrajectoryStateOnSurface const &  tsos,
double &  momentum 
)

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

Definition at line 152 of file MultiTrajectoryStateMode.cc.

152  {
153  //
154  // clear result vector and check validity of the TSOS
155  //
156  momentum = 0.;
157  if (!tsos.isValid()) {
158  edm::LogInfo("multiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
159  return false;
160  }
161  //
162  // mode computation for local co-ordinates q/p, dx/dz, dy/dz
163  //
164  double qpMode(0);
165  //
166  // first element of local parameters = q/p
167  //
168  // extraction of multi-state using helper class
170  GaussianSumUtilities1D utils(state1D);
171  // mode (in case of failure: mean)
172  qpMode = utils.mode().mean();
173  if (!utils.modeIsValid())
174  qpMode = utils.mean();
175 
176  momentum = 1. / fabs(qpMode);
177  return true;
178  }

References TrajectoryStateOnSurface::isValid(), and MultiGaussianStateTransform::multiState1D().

◆ positionFromModeCartesian()

bool multiTrajectoryStateMode::positionFromModeCartesian ( TrajectoryStateOnSurface const &  tsos,
GlobalPoint position 
)

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

Definition at line 63 of file MultiTrajectoryStateMode.cc.

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

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

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

◆ positionFromModeLocal()

bool multiTrajectoryStateMode::positionFromModeLocal ( TrajectoryStateOnSurface const &  tsos,
GlobalPoint position 
)

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.

215  {
216  //
217  // clear result vector and check validity of the TSOS
218  //
219  position = GlobalPoint(0., 0., 0.);
220  if (!tsos.isValid()) {
221  edm::LogInfo("multiTrajectoryStateMode") << "Cannot calculate mode from invalid TSOS";
222  return false;
223  }
224  //
225  // mode computation for local co-ordinates x, y
226  //
227  double xMode(0);
228  double yMode(0);
229  //
230  // last 2 elements of local parameters = x, y
231  //
232  for (unsigned int iv = 3; iv < 5; ++iv) {
233  // extraction of multi-state using helper class
235  GaussianSumUtilities1D utils(state1D);
236  // mode (in case of failure: mean)
237  double result = utils.mode().mean();
238  if (!utils.modeIsValid())
239  result = utils.mean();
240  if (iv == 3)
241  xMode = result;
242  else
243  yMode = result;
244  }
245  // local position vector from x, y
246  LocalPoint localP(xMode, yMode, 0.);
247  // conversion to global coordinates
248  position = tsos.surface().toGlobal(localP);
249  return true;
250  }

References TrajectoryStateOnSurface::isValid(), MultiGaussianStateTransform::multiState1D(), position, mps_fire::result, TrajectoryStateOnSurface::surface(), and Surface::toGlobal().

Vector3DBase
Definition: Vector3DBase.h:8
AlgebraicSymMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
Definition: AlgebraicROOTObjects.h:21
mps_fire.i
i
Definition: mps_fire.py:355
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
pos
Definition: PixelAliasList.h:18
edm::LogInfo
Definition: MessageLogger.h:254
AlgebraicMatrix33
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
Definition: AlgebraicROOTObjects.h:41
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
SingleGaussianState1D::mean
double mean() const
parameter vector
Definition: SingleGaussianState1D.h:25
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
GetComponents
Definition: GetComponents.h:4
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
SingleGaussianState1D::variance
double variance() const
variance
Definition: SingleGaussianState1D.h:27
PVValHelper::eta
Definition: PVValidationHelpers.h:69
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
AlgebraicSymMatrix66
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Definition: AlgebraicROOTObjects.h:24
MultiGaussianState1D
Definition: MultiGaussianState1D.h:12
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
SingleGaussianState1D::weight
double weight() const
weight
Definition: SingleGaussianState1D.h:23
PVValHelper::phi
Definition: PVValidationHelpers.h:68
SingleGaussianState1D
Definition: SingleGaussianState1D.h:10
MultiGaussianState1D::components
const SingleState1dContainer & components() const
access to components
Definition: MultiGaussianState1D.h:30
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
makeMuonMisalignmentScenario.components
string components
Definition: makeMuonMisalignmentScenario.py:58
utils
Definition: utils.py:1
GaussianSumUtilities1D
Definition: GaussianSumUtilities1D.h:16
mps_fire.result
result
Definition: mps_fire.py:303
MultiGaussianStateTransform::multiState1D
MultiGaussianState1D multiState1D(const std::vector< MultiGaussianState< N >::Vector > &, const std::vector< MultiGaussianState< N >::Matrix > &, const std::vector< double > &, unsigned int)
Definition: MultiGaussianStateTransform.cc:54
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6