Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:09

0001 #include "RecoVertex/GaussianSumVertexFit/interface/PerigeeMultiLTS.h"
0002 #include "RecoVertex/VertexTools/interface/PerigeeRefittedTrackState.h"
0003 #include "TrackingTools/TrajectoryState/interface/PerigeeConversions.h"
0004 #include "RecoVertex/VertexPrimitives/interface/VertexException.h"
0005 #include "RecoVertex/VertexTools/interface/PerigeeLinearizedTrackState.h"
0006 
0007 using namespace std;
0008 
0009 PerigeeMultiLTS::PerigeeMultiLTS(const GlobalPoint& linP,
0010                                  const reco::TransientTrack& track,
0011                                  const TrajectoryStateOnSurface& tsos)
0012     : theLinPoint(linP), theTrack(track), theTSOS(tsos), theCharge(theTrack.charge()), collapsedStateAvailable(false) {
0013   //Extract the TSOS components:
0014 
0015   vector<TrajectoryStateOnSurface> tsosComp = theTSOS.components();
0016   //cout << "PerigeeMultiLTS components: "<<tsosComp.size()<<endl;
0017   ltComp.reserve(tsosComp.size());
0018   for (vector<TrajectoryStateOnSurface>::iterator it = tsosComp.begin(); it != tsosComp.end(); it++) {
0019     // cout <<(*it).globalPosition()<<endl;
0020     ltComp.push_back(theLTSfactory.linearizedTrackState(theLinPoint, theTrack, *it));
0021   }
0022 }
0023 
0024 void PerigeeMultiLTS::prepareCollapsedState() const {
0025   if (!collapsedStateAvailable) {
0026     collapsedStateLT = theLTSfactory.linearizedTrackState(theLinPoint, theTrack, theTSOS);
0027   }
0028   collapsedStateAvailable = true;
0029 }
0030 
0031 /** Method returning the constant term of the Taylor expansion
0032  *  of the measurement equation
0033  */
0034 const AlgebraicVector5& PerigeeMultiLTS::constantTerm() const {
0035   if (!collapsedStateAvailable)
0036     prepareCollapsedState();
0037   return collapsedStateLT->constantTerm();
0038 }
0039 
0040 /**
0041  * Method returning the Position Jacobian (Matrix A)
0042  */
0043 const AlgebraicMatrix53& PerigeeMultiLTS::positionJacobian() const {
0044   if (!collapsedStateAvailable)
0045     prepareCollapsedState();
0046   return collapsedStateLT->positionJacobian();
0047 }
0048 
0049 /**
0050  * Method returning the Momentum Jacobian (Matrix B)
0051  */
0052 const AlgebraicMatrix53& PerigeeMultiLTS::momentumJacobian() const {
0053   if (!collapsedStateAvailable)
0054     prepareCollapsedState();
0055   return collapsedStateLT->momentumJacobian();
0056 }
0057 
0058 /** Method returning the parameters of the Taylor expansion
0059  */
0060 const AlgebraicVector5& PerigeeMultiLTS::parametersFromExpansion() const {
0061   if (!collapsedStateAvailable)
0062     prepareCollapsedState();
0063   return collapsedStateLT->parametersFromExpansion();
0064 }
0065 
0066 /**
0067  * Method returning the TrajectoryStateClosestToPoint at the point
0068  * of closest approch to the z-axis (a.k.a. transverse impact point)
0069  */
0070 const TrajectoryStateClosestToPoint& PerigeeMultiLTS::predictedState() const {
0071   if (!collapsedStateAvailable)
0072     prepareCollapsedState();
0073   const PerigeeLinearizedTrackState* otherP = dynamic_cast<const PerigeeLinearizedTrackState*>(collapsedStateLT.get());
0074   return otherP->predictedState();
0075 }
0076 
0077 bool PerigeeMultiLTS::hasError() const {
0078   if (!collapsedStateAvailable)
0079     prepareCollapsedState();
0080   return collapsedStateLT->hasError();
0081 }
0082 
0083 AlgebraicVector5 PerigeeMultiLTS::predictedStateParameters() const {
0084   if (!collapsedStateAvailable)
0085     prepareCollapsedState();
0086   return collapsedStateLT->predictedStateParameters();
0087 }
0088 
0089 AlgebraicVector3 PerigeeMultiLTS::predictedStateMomentumParameters() const {
0090   if (!collapsedStateAvailable)
0091     prepareCollapsedState();
0092   return collapsedStateLT->predictedStateMomentumParameters();
0093 }
0094 
0095 AlgebraicSymMatrix55 PerigeeMultiLTS::predictedStateWeight(int& error) const {
0096   if (!collapsedStateAvailable)
0097     prepareCollapsedState();
0098   return collapsedStateLT->predictedStateWeight(error);
0099 }
0100 
0101 AlgebraicSymMatrix55 PerigeeMultiLTS::predictedStateError() const {
0102   if (!collapsedStateAvailable)
0103     prepareCollapsedState();
0104   return collapsedStateLT->predictedStateError();
0105 }
0106 
0107 AlgebraicSymMatrix33 PerigeeMultiLTS::predictedStateMomentumError() const {
0108   if (!collapsedStateAvailable)
0109     prepareCollapsedState();
0110   return collapsedStateLT->predictedStateMomentumError();
0111 }
0112 
0113 bool PerigeeMultiLTS::operator==(LinearizedTrackState<5>& other) const {
0114   const PerigeeMultiLTS* otherP = dynamic_cast<const PerigeeMultiLTS*>(&other);
0115   if (otherP == nullptr) {
0116     throw VertexException("PerigeeMultiLTS: don't know how to compare myself to non-perigee track state");
0117   }
0118   return (otherP->track() == theTrack);
0119 }
0120 
0121 PerigeeMultiLTS::RefCountedLinearizedTrackState PerigeeMultiLTS::stateWithNewLinearizationPoint(
0122     const GlobalPoint& newLP) const {
0123   return RefCountedLinearizedTrackState(new PerigeeMultiLTS(newLP, track(), theTSOS));
0124 }
0125 
0126 PerigeeMultiLTS::RefCountedRefittedTrackState PerigeeMultiLTS::createRefittedTrackState(
0127     const GlobalPoint& vertexPosition,
0128     const AlgebraicVectorM& vectorParameters,
0129     const AlgebraicSymMatrixOO& covarianceMatrix) const {
0130   TrajectoryStateClosestToPoint refittedTSCP = PerigeeConversions::trajectoryStateClosestToPoint(
0131       vectorParameters, vertexPosition, charge(), covarianceMatrix, theTrack.field());
0132   return RefCountedRefittedTrackState(new PerigeeRefittedTrackState(refittedTSCP, vectorParameters));
0133 }
0134 
0135 AlgebraicVector5 PerigeeMultiLTS::refittedParamFromEquation(const RefCountedRefittedTrackState& theRefittedState) const {
0136   AlgebraicVector3 vertexPosition;
0137   vertexPosition(0) = theRefittedState->position().x();
0138   vertexPosition(1) = theRefittedState->position().y();
0139   vertexPosition(2) = theRefittedState->position().z();
0140   AlgebraicVectorN param =
0141       constantTerm() + positionJacobian() * vertexPosition + momentumJacobian() * theRefittedState->momentumVector();
0142   if (param(2) > M_PI)
0143     param(2) -= 2 * M_PI;
0144   if (param(2) < -M_PI)
0145     param(2) += 2 * M_PI;
0146 
0147   return param;
0148 }
0149 
0150 void PerigeeMultiLTS::checkParameters(AlgebraicVector5& parameters) const {
0151   if (parameters(2) > M_PI)
0152     parameters(2) -= 2 * M_PI;
0153   if (parameters(2) < -M_PI)
0154     parameters(2) += 2 * M_PI;
0155 }