CMS 3D CMS Logo

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

#include <TwoBodyDecayTrajectory.h>

Inheritance diagram for TwoBodyDecayTrajectory:
ReferenceTrajectoryBase ReferenceCounted

Public Types

typedef std::pair
< ConstRecHitContainer,
ConstRecHitContainer
ConstRecHitCollection
 
typedef
TransientTrackingRecHit::ConstRecHitContainer 
ConstRecHitContainer
 
- Public Types inherited from ReferenceTrajectoryBase
enum  MaterialEffects {
  none, multipleScattering, energyLoss, combined,
  breakPoints, brokenLinesCoarse, brokenLinesFine
}
 
typedef
ReferenceCountingPointer
< ReferenceTrajectoryBase
ReferenceTrajectoryPtr
 

Public Member Functions

virtual TwoBodyDecayTrajectoryclone (void) const
 
const std::pair< int, int > numberOfRecHits (void)
 
 TwoBodyDecayTrajectory (const TwoBodyDecayTrajectoryState &trajectoryState, const ConstRecHitCollection &recHits, const MagneticField *magField, MaterialEffects materialEffects, PropagationDirection propDir, bool hitsAreReverse, const reco::BeamSpot &beamSpot, bool useRefittedState, bool constructTsosWithErrors)
 
 TwoBodyDecayTrajectory (void)
 
 ~TwoBodyDecayTrajectory (void)
 
- Public Member Functions inherited from ReferenceTrajectoryBase
const AlgebraicMatrixderivatives () const
 
bool isValid ()
 
const AlgebraicMatrixlocalToTrajectory () const
 
const AlgebraicSymMatrixmeasurementErrors () const
 
const AlgebraicVectormeasurements () const
 
unsigned int numberOfHitMeas () const
 
unsigned int numberOfHits () const
 
unsigned int numberOfMsMeas () const
 
unsigned int numberOfMsPar () const
 
unsigned int numberOfPar () const
 
const AlgebraicSymMatrixparameterErrors () const
 
bool parameterErrorsAvailable () const
 
const AlgebraicVectorparameters () const
 
const
TransientTrackingRecHit::ConstRecHitContainer
recHits () const
 
void setParameterErrors (const AlgebraicSymMatrix &error)
 
const AlgebraicSymMatrixtrajectoryPositionErrors () const
 
const AlgebraicVectortrajectoryPositions () const
 
const std::vector
< TrajectoryStateOnSurface > & 
trajectoryStates () const
 
const AlgebraicMatrixtrajectoryToCurv () const
 
virtual ~ReferenceTrajectoryBase ()
 

Private Member Functions

bool construct (const TwoBodyDecayTrajectoryState &state, const ConstRecHitCollection &recHits, const MagneticField *field, MaterialEffects materialEffects, PropagationDirection propDir, const reco::BeamSpot &beamSpot, bool useRefittedState, bool constructTsosWithErrors)
 
void constructSingleTsosWithErrors (const TrajectoryStateOnSurface &tsos, int iTsos, const MagneticField *field)
 
void constructTsosVecWithErrors (const ReferenceTrajectory &traj1, const ReferenceTrajectory &traj2, const MagneticField *field)
 

Private Attributes

std::pair< int, int > theNumberOfRecHits
 

Additional Inherited Members

- Protected Member Functions inherited from ReferenceTrajectoryBase
unsigned int numberOfUsedRecHits (const TransientTrackingRecHit::ConstRecHitContainer &recHits) const
 
 ReferenceTrajectoryBase (unsigned int nPar, unsigned int nHits, unsigned int nMsPar, unsigned int nMsMeas)
 
bool useRecHit (const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
 
- Protected Attributes inherited from ReferenceTrajectoryBase
AlgebraicMatrix theDerivatives
 
AlgebraicMatrix theInnerLocalToTrajectory
 
AlgebraicMatrix theInnerTrajectoryToCurvilinear
 
AlgebraicVector theMeasurements
 
AlgebraicSymMatrix theMeasurementsCov
 
unsigned int theNumberOfHits
 
unsigned int theNumberOfMsMeas
 
unsigned int theNumberOfMsPars
 
unsigned int theNumberOfPars
 
bool theParamCovFlag
 
AlgebraicSymMatrix theParameterCov
 
AlgebraicVector theParameters
 
TransientTrackingRecHit::ConstRecHitContainer theRecHits
 
AlgebraicSymMatrix theTrajectoryPositionCov
 
AlgebraicVector theTrajectoryPositions
 
std::vector
< TrajectoryStateOnSurface
theTsosVec
 
bool theValidityFlag
 
- Static Protected Attributes inherited from ReferenceTrajectoryBase
static const unsigned int nMeasPerHit = 2
 

Detailed Description

Definition at line 14 of file TwoBodyDecayTrajectory.h.

Member Typedef Documentation

Definition at line 20 of file TwoBodyDecayTrajectory.h.

Definition at line 19 of file TwoBodyDecayTrajectory.h.

Constructor & Destructor Documentation

TwoBodyDecayTrajectory::TwoBodyDecayTrajectory ( const TwoBodyDecayTrajectoryState trajectoryState,
const ConstRecHitCollection recHits,
const MagneticField magField,
MaterialEffects  materialEffects,
PropagationDirection  propDir,
bool  hitsAreReverse,
const reco::BeamSpot beamSpot,
bool  useRefittedState,
bool  constructTsosWithErrors 
)

Definition at line 13 of file TwoBodyDecayTrajectory.cc.

References construct(), and ReferenceTrajectoryBase::theValidityFlag.

24  TwoBodyDecayParameters::dimension, recHits.first.size() + recHits.second.size(),
25  (materialEffects >= breakPoints) ? 2*(recHits.first.size() + recHits.second.size())-4 : 0,
26  (materialEffects >= breakPoints) ? 2*(recHits.first.size() + recHits.second.size())-4 : 0 )
27 {
28  if ( hitsAreReverse )
29  {
30  TransientTrackingRecHit::ConstRecHitContainer::const_reverse_iterator itRecHits;
31  ConstRecHitCollection fwdRecHits;
32 
33  fwdRecHits.first.reserve( recHits.first.size() );
34  for ( itRecHits = recHits.first.rbegin(); itRecHits != recHits.first.rend(); ++itRecHits )
35  {
36  fwdRecHits.first.push_back( *itRecHits );
37  }
38 
39  fwdRecHits.second.reserve( recHits.second.size() );
40  for ( itRecHits = recHits.second.rbegin(); itRecHits != recHits.second.rend(); ++itRecHits )
41  {
42  fwdRecHits.second.push_back( *itRecHits );
43  }
44 
45  theValidityFlag = this->construct( trajectoryState, fwdRecHits, magField, materialEffects, propDir,
46  beamSpot, useRefittedState, constructTsosWithErrors );
47  }
48  else
49  {
50  theValidityFlag = this->construct( trajectoryState, recHits, magField, materialEffects, propDir,
51  beamSpot, useRefittedState, constructTsosWithErrors );
52  }
53 }
ReferenceTrajectoryBase(unsigned int nPar, unsigned int nHits, unsigned int nMsPar, unsigned int nMsMeas)
const TransientTrackingRecHit::ConstRecHitContainer & recHits() const
std::pair< ConstRecHitContainer, ConstRecHitContainer > ConstRecHitCollection
bool construct(const TwoBodyDecayTrajectoryState &state, const ConstRecHitCollection &recHits, const MagneticField *field, MaterialEffects materialEffects, PropagationDirection propDir, const reco::BeamSpot &beamSpot, bool useRefittedState, bool constructTsosWithErrors)
TwoBodyDecayTrajectory::TwoBodyDecayTrajectory ( void  )

Definition at line 56 of file TwoBodyDecayTrajectory.cc.

Referenced by clone().

57  : ReferenceTrajectoryBase( 0, 0, 0, 0)
58 {}
ReferenceTrajectoryBase(unsigned int nPar, unsigned int nHits, unsigned int nMsPar, unsigned int nMsMeas)
TwoBodyDecayTrajectory::~TwoBodyDecayTrajectory ( void  )
inline

Definition at line 34 of file TwoBodyDecayTrajectory.h.

34 {}

Member Function Documentation

virtual TwoBodyDecayTrajectory* TwoBodyDecayTrajectory::clone ( void  ) const
inlinevirtual

Implements ReferenceTrajectoryBase.

Definition at line 36 of file TwoBodyDecayTrajectory.h.

References TwoBodyDecayTrajectory().

37  { return new TwoBodyDecayTrajectory( *this ); }
bool TwoBodyDecayTrajectory::construct ( const TwoBodyDecayTrajectoryState state,
const ConstRecHitCollection recHits,
const MagneticField field,
MaterialEffects  materialEffects,
PropagationDirection  propDir,
const reco::BeamSpot beamSpot,
bool  useRefittedState,
bool  constructTsosWithErrors 
)
private

Definition at line 61 of file TwoBodyDecayTrajectory.cc.

References constructTsosVecWithErrors(), TwoBodyDecayParameters::covariance(), TwoBodyDecayTrajectoryState::decayParameters(), TwoBodyDecayTrajectoryState::derivatives(), ReferenceTrajectoryBase::derivatives(), ReferenceTrajectoryBase::isValid(), ReferenceTrajectoryBase::localToTrajectory(), ReferenceTrajectoryBase::measurementErrors(), ReferenceTrajectoryBase::measurements(), ReferenceTrajectoryBase::numberOfHitMeas(), ReferenceTrajectoryBase::numberOfHits(), ReferenceTrajectoryBase::numberOfMsMeas(), ReferenceTrajectoryBase::numberOfMsPar(), ReferenceTrajectoryBase::numberOfPar(), TwoBodyDecayParameters::parameters(), TwoBodyDecayTrajectoryState::particleMass(), ReferenceTrajectoryBase::theDerivatives, ReferenceTrajectoryBase::theMeasurements, ReferenceTrajectoryBase::theMeasurementsCov, ReferenceTrajectoryBase::theNumberOfHits, ReferenceTrajectoryBase::theNumberOfMsMeas, ReferenceTrajectoryBase::theNumberOfMsPars, ReferenceTrajectoryBase::theNumberOfPars, theNumberOfRecHits, ReferenceTrajectoryBase::theParameters, ReferenceTrajectoryBase::theRecHits, ReferenceTrajectoryBase::theTrajectoryPositionCov, ReferenceTrajectoryBase::theTrajectoryPositions, ReferenceTrajectoryBase::theTsosVec, ReferenceTrajectoryBase::trajectoryPositions(), TwoBodyDecayTrajectoryState::trajectoryStates(), and ReferenceTrajectoryBase::trajectoryStates().

Referenced by TwoBodyDecayTrajectory().

69 {
70  const TwoBodyDecayTrajectoryState::TsosContainer& tsos = state.trajectoryStates( useRefittedState );
72  double mass = state.particleMass();
73 
74  //
75  // first track
76  //
77 
78  // construct a trajectory (hits should be already in correct order)
79  ReferenceTrajectory trajectory1( tsos.first, recHits.first, false, field, materialEffects,
80  propDir, mass, false, beamSpot);
81 
82  // check if construction of trajectory was successful
83  if ( !trajectory1.isValid() ) return false;
84 
85  int nLocal = deriv.first.num_row();
86  int nTbd = deriv.first.num_col();
87  unsigned int nHitMeas1 = trajectory1.numberOfHitMeas();
88  unsigned int nMsMeas1 = trajectory1.numberOfMsMeas();
89  unsigned int nPar1 = trajectory1.numberOfPar();
90  unsigned int nMsPar1 = trajectory1.numberOfMsPar();
91 
92  // derivatives of the trajectory w.r.t. to the decay parameters
93  AlgebraicMatrix fullDeriv1 = trajectory1.derivatives().sub(1,nHitMeas1+nMsMeas1,1,nLocal) * trajectory1.localToTrajectory() * deriv.first;
94 
95  //
96  // second track
97  //
98 
99  ReferenceTrajectory trajectory2( tsos.second, recHits.second, false, field, materialEffects,
100  propDir, mass, false, beamSpot );
101 
102  if ( !trajectory2.isValid() ) return false;
103 
104  unsigned int nHitMeas2 = trajectory2.numberOfHitMeas();
105  unsigned int nMsMeas2 = trajectory2.numberOfMsMeas();
106  unsigned int nPar2 = trajectory2.numberOfPar();
107  unsigned int nMsPar2 = trajectory2.numberOfMsPar();
108 
109  AlgebraicMatrix fullDeriv2 = trajectory2.derivatives().sub(1,nHitMeas2+nMsMeas2,1,nLocal) * trajectory2.localToTrajectory() * deriv.second;
110 
111  //
112  // combine both tracks
113  //
114 
115  theNumberOfRecHits.first = recHits.first.size();
116  theNumberOfRecHits.second = recHits.second.size();
117 
118  theNumberOfHits = trajectory1.numberOfHits() + trajectory2.numberOfHits();
119  theNumberOfPars = nPar1 + nPar2;
120  theNumberOfMsPars = nMsPar1 + nMsPar2;
121  theNumberOfMsMeas = nMsMeas1 + nMsMeas2;
122 
123  // hit measurements from trajectory 1
124  int rowOffset = 1;
125  int colOffset = 1;
126  theDerivatives.sub( rowOffset, colOffset, fullDeriv1.sub( 1, nHitMeas1, 1, nTbd ) );
127  colOffset += nTbd;
128  theDerivatives.sub( rowOffset, colOffset, trajectory1.derivatives().sub( 1, nHitMeas1, nLocal + 1, nPar1 + nMsPar1 ) );
129  // hit measurements from trajectory 2
130  rowOffset += nHitMeas1;
131  colOffset = 1;
132  theDerivatives.sub( rowOffset, colOffset, fullDeriv2.sub( 1, nHitMeas2, 1, nTbd ) );
133  colOffset += (nPar1 + nMsPar1 + nTbd - nLocal);
134  theDerivatives.sub( rowOffset, colOffset, trajectory2.derivatives().sub( 1, nHitMeas2, nLocal + 1, nPar2 + nMsPar2 ) );
135  // MS measurements from trajectory 1
136  rowOffset += nHitMeas2;
137  colOffset = 1;
138  theDerivatives.sub( rowOffset, colOffset, fullDeriv1.sub(nHitMeas1 + 1, nHitMeas1 + nMsMeas1, 1, nTbd ) );
139  colOffset += nTbd;
140  theDerivatives.sub( rowOffset, colOffset, trajectory1.derivatives().sub(nHitMeas1 + 1, nHitMeas1 + nMsMeas1, nLocal + 1, nPar1 + nMsPar1 ) );
141  // MS measurements from trajectory 2
142  rowOffset += nMsMeas1;
143  colOffset = 1;
144  theDerivatives.sub( rowOffset, colOffset, fullDeriv2.sub(nHitMeas2 + 1, nHitMeas2 + nMsMeas2, 1, nTbd ) );
145  colOffset += (nPar1 + nMsPar1 + nTbd - nLocal);
146  theDerivatives.sub( rowOffset, colOffset, trajectory2.derivatives().sub(nHitMeas2 + 1, nHitMeas2 + nMsMeas2, nLocal + 1, nPar2 + nMsPar2 ) );
147 
148  theMeasurements.sub( 1, trajectory1.measurements().sub( 1, nHitMeas1 ) );
149  theMeasurements.sub( nHitMeas1 + 1, trajectory2.measurements().sub( 1, nHitMeas2 ) );
150  theMeasurements.sub( nHitMeas1 + nHitMeas2 + 1, trajectory1.measurements().sub(nHitMeas1 + 1, nHitMeas1 + nMsMeas1 ) );
151  theMeasurements.sub( nHitMeas1 + nHitMeas2 + nMsMeas1 + 1, trajectory2.measurements().sub(nHitMeas2 + 1, nHitMeas2 + nMsMeas2 ) );
152 
153  theMeasurementsCov.sub( 1, trajectory1.measurementErrors().sub( 1, nHitMeas1 ) );
154  theMeasurementsCov.sub( nHitMeas1 + 1, trajectory2.measurementErrors().sub( 1, nHitMeas2 ) );
155  theMeasurementsCov.sub( nHitMeas1 + nHitMeas2 + 1, trajectory1.measurementErrors().sub(nHitMeas1 + 1, nHitMeas1 + nMsMeas1 ) );
156  theMeasurementsCov.sub( nHitMeas1 + nHitMeas2 + nMsMeas1 + 1, trajectory2.measurementErrors().sub(nHitMeas2 + 1, nHitMeas2 + nMsMeas2 ) );
157 
158  theTrajectoryPositions.sub( 1, trajectory1.trajectoryPositions() );
159  theTrajectoryPositions.sub( nHitMeas1 + 1, trajectory2.trajectoryPositions() );
160 
161  theTrajectoryPositionCov = state.decayParameters().covariance().similarity( theDerivatives.sub(1, nHitMeas1 + nHitMeas2, 1, 9) );
162 
164 
165  theRecHits.insert( theRecHits.end(), recHits.first.begin(), recHits.first.end() );
166  theRecHits.insert( theRecHits.end(), recHits.second.begin(), recHits.second.end() );
167 
168  if ( constructTsosWithErrors )
169  {
170  constructTsosVecWithErrors( trajectory1, trajectory2, field );
171  }
172  else
173  {
174  theTsosVec.insert( theTsosVec.end(),
175  trajectory1.trajectoryStates().begin(),
176  trajectory1.trajectoryStates().end() );
177 
178  theTsosVec.insert( theTsosVec.end(),
179  trajectory2.trajectoryStates().begin(),
180  trajectory2.trajectoryStates().end() );
181  }
182 
183  return true;
184 }
const AlgebraicVector & parameters(void) const
Get decay parameters.
const TransientTrackingRecHit::ConstRecHitContainer & recHits() const
const TsosContainer & trajectoryStates(bool useRefittedState=true) const
AlgebraicSymMatrix theTrajectoryPositionCov
const Derivatives & derivatives(void) const
CLHEP::HepMatrix AlgebraicMatrix
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > TsosContainer
std::pair< int, int > theNumberOfRecHits
TransientTrackingRecHit::ConstRecHitContainer theRecHits
AlgebraicSymMatrix theMeasurementsCov
const TwoBodyDecayParameters & decayParameters(void) const
std::pair< AlgebraicMatrix, AlgebraicMatrix > Derivatives
void constructTsosVecWithErrors(const ReferenceTrajectory &traj1, const ReferenceTrajectory &traj2, const MagneticField *field)
const AlgebraicSymMatrix & covariance(void) const
Get error matrix.
std::vector< TrajectoryStateOnSurface > theTsosVec
void TwoBodyDecayTrajectory::constructSingleTsosWithErrors ( const TrajectoryStateOnSurface tsos,
int  iTsos,
const MagneticField field 
)
private

Definition at line 209 of file TwoBodyDecayTrajectory.cc.

References ExpressReco_HICollisions_FallBack::e, TrajectoryStateOnSurface::localParameters(), LocalTrajectoryParameters::momentum(), ReferenceTrajectoryBase::nMeasPerHit, L1TEmulatorMonitor_cff::p, LocalTrajectoryParameters::signedInverseMomentum(), TrajectoryStateOnSurface::surface(), TrajectoryStateOnSurface::surfaceSide(), ReferenceTrajectoryBase::theTrajectoryPositionCov, ReferenceTrajectoryBase::theTsosVec, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by constructTsosVecWithErrors().

212 {
213  AlgebraicSymMatrix localErrors( 5, 0 );
214  const double coeff = 1e-2;
215 
216  double invP = tsos.localParameters().signedInverseMomentum();
218 
219  // rough estimate for the errors of q/p, dx/dz and dy/dz, assuming that
220  // sigma(px) = sigma(py) = sigma(pz) = coeff*p.
221  float dpinv = coeff*( fabs(p.x()) + fabs(p.y()) + fabs(p.z()) )*invP*invP;
222  float dxdir = coeff*( fabs(p.x()) + fabs(p.z()) )/p.z()/p.z();
223  float dydir = coeff*( fabs(p.y()) + fabs(p.z()) )/p.z()/p.z();
224  localErrors[0][0] = dpinv*dpinv;
225  localErrors[1][1] = dxdir*dxdir;
226  localErrors[2][2] = dydir*dydir;
227 
228  // exact values for the errors on local x and y
229  localErrors[3][3] = theTrajectoryPositionCov[nMeasPerHit*iTsos][nMeasPerHit*iTsos];
230  localErrors[3][4] = theTrajectoryPositionCov[nMeasPerHit*iTsos][nMeasPerHit*iTsos+1];
231  localErrors[4][4] = theTrajectoryPositionCov[nMeasPerHit*iTsos+1][nMeasPerHit*iTsos+1];
232 
233  // construct tsos with local errors
235  LocalTrajectoryError( localErrors ),
236  tsos.surface(),
237  field,
238  tsos.surfaceSide() );
239 }
const LocalTrajectoryParameters & localParameters() const
static const unsigned int nMeasPerHit
T y() const
Definition: PV3DBase.h:57
AlgebraicSymMatrix theTrajectoryPositionCov
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
T z() const
Definition: PV3DBase.h:58
LocalVector momentum() const
Momentum vector in the local frame.
const Surface & surface() const
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< TrajectoryStateOnSurface > theTsosVec
T x() const
Definition: PV3DBase.h:56
double signedInverseMomentum() const
Signed inverse momentum q/p (zero for neutrals).
void TwoBodyDecayTrajectory::constructTsosVecWithErrors ( const ReferenceTrajectory traj1,
const ReferenceTrajectory traj2,
const MagneticField field 
)
private

Definition at line 187 of file TwoBodyDecayTrajectory.cc.

References constructSingleTsosWithErrors(), and ReferenceTrajectoryBase::trajectoryStates().

Referenced by construct().

190 {
191  int iTsos = 0;
192 
193  std::vector< TrajectoryStateOnSurface >::const_iterator itTsos;
194 
195  for ( itTsos = traj1.trajectoryStates().begin(); itTsos != traj1.trajectoryStates().end(); itTsos++ )
196  {
197  constructSingleTsosWithErrors( *itTsos, iTsos, field );
198  iTsos++;
199  }
200 
201  for ( itTsos = traj2.trajectoryStates().begin(); itTsos != traj2.trajectoryStates().end(); itTsos++ )
202  {
203  constructSingleTsosWithErrors( *itTsos, iTsos, field );
204  iTsos++;
205  }
206 }
void constructSingleTsosWithErrors(const TrajectoryStateOnSurface &tsos, int iTsos, const MagneticField *field)
const std::vector< TrajectoryStateOnSurface > & trajectoryStates() const
const std::pair< int, int > TwoBodyDecayTrajectory::numberOfRecHits ( void  )
inline

Number of RecHits belonging to the first and second track.

Definition at line 41 of file TwoBodyDecayTrajectory.h.

References theNumberOfRecHits.

41 { return theNumberOfRecHits; }
std::pair< int, int > theNumberOfRecHits

Member Data Documentation

std::pair< int, int > TwoBodyDecayTrajectory::theNumberOfRecHits
private

Definition at line 62 of file TwoBodyDecayTrajectory.h.

Referenced by construct(), and numberOfRecHits().