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 numberOfPar () const
 
unsigned int numberOfVirtualMeas () const
 
unsigned int numberOfVirtualPar () 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 nVirtualPar, unsigned int nVirtualMeas)
 
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 theNumberOfPars
 
unsigned int theNumberOfVirtualMeas
 
unsigned int theNumberOfVirtualPars
 
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 15 of file TwoBodyDecayTrajectory.cc.

References construct(), and ReferenceTrajectoryBase::theValidityFlag.

26  TwoBodyDecayParameters::dimension, recHits.first.size() + recHits.second.size(),
27  (materialEffects >= breakPoints) ? 2*(recHits.first.size() + recHits.second.size())-4 : 0,
28  (materialEffects >= breakPoints) ? 2*(recHits.first.size() + recHits.second.size())-3 : 1 )
29 {
30  if ( hitsAreReverse )
31  {
32  TransientTrackingRecHit::ConstRecHitContainer::const_reverse_iterator itRecHits;
33  ConstRecHitCollection fwdRecHits;
34 
35  fwdRecHits.first.reserve( recHits.first.size() );
36  for ( itRecHits = recHits.first.rbegin(); itRecHits != recHits.first.rend(); ++itRecHits )
37  {
38  fwdRecHits.first.push_back( *itRecHits );
39  }
40 
41  fwdRecHits.second.reserve( recHits.second.size() );
42  for ( itRecHits = recHits.second.rbegin(); itRecHits != recHits.second.rend(); ++itRecHits )
43  {
44  fwdRecHits.second.push_back( *itRecHits );
45  }
46 
47  theValidityFlag = this->construct( trajectoryState, fwdRecHits, magField, materialEffects, propDir,
48  beamSpot, useRefittedState, constructTsosWithErrors );
49  }
50  else
51  {
52  theValidityFlag = this->construct( trajectoryState, recHits, magField, materialEffects, propDir,
53  beamSpot, useRefittedState, constructTsosWithErrors );
54  }
55 }
ReferenceTrajectoryBase(unsigned int nPar, unsigned int nHits, unsigned int nVirtualPar, unsigned int nVirtualMeas)
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 58 of file TwoBodyDecayTrajectory.cc.

Referenced by clone().

59  : ReferenceTrajectoryBase( 0, 0, 0, 0)
60 {}
ReferenceTrajectoryBase(unsigned int nPar, unsigned int nHits, unsigned int nVirtualPar, unsigned int nVirtualMeas)
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 63 of file TwoBodyDecayTrajectory.cc.

References constructTsosVecWithErrors(), TwoBodyDecayParameters::covariance(), TwoBodyDecayTrajectoryState::decayParameters(), TwoBodyDecayTrajectoryState::derivatives(), ReferenceTrajectoryBase::derivatives(), ReferenceTrajectoryBase::isValid(), ReferenceTrajectoryBase::localToTrajectory(), TwoBodyDecayParameters::mass, ReferenceTrajectoryBase::measurementErrors(), ReferenceTrajectoryBase::measurements(), ReferenceTrajectoryBase::numberOfHitMeas(), ReferenceTrajectoryBase::numberOfHits(), ReferenceTrajectoryBase::numberOfPar(), ReferenceTrajectoryBase::numberOfVirtualMeas(), ReferenceTrajectoryBase::numberOfVirtualPar(), TwoBodyDecayParameters::parameters(), TwoBodyDecayTrajectoryState::particleMass(), TwoBodyDecayTrajectoryState::primaryMass(), TwoBodyDecayTrajectoryState::primaryWidth(), ReferenceTrajectoryBase::theDerivatives, ReferenceTrajectoryBase::theMeasurements, ReferenceTrajectoryBase::theMeasurementsCov, ReferenceTrajectoryBase::theNumberOfHits, ReferenceTrajectoryBase::theNumberOfPars, theNumberOfRecHits, ReferenceTrajectoryBase::theNumberOfVirtualMeas, ReferenceTrajectoryBase::theNumberOfVirtualPars, ReferenceTrajectoryBase::theParameters, ReferenceTrajectoryBase::theRecHits, ReferenceTrajectoryBase::theTrajectoryPositionCov, ReferenceTrajectoryBase::theTrajectoryPositions, ReferenceTrajectoryBase::theTsosVec, ReferenceTrajectoryBase::trajectoryPositions(), TwoBodyDecayTrajectoryState::trajectoryStates(), and ReferenceTrajectoryBase::trajectoryStates().

Referenced by TwoBodyDecayTrajectory().

71 {
72  const TwoBodyDecayTrajectoryState::TsosContainer& tsos = state.trajectoryStates( useRefittedState );
74  double mass = state.particleMass();
75 
76  //
77  // first track
78  //
79 
80  // construct a trajectory (hits should be already in correct order)
81  ReferenceTrajectory trajectory1( tsos.first, recHits.first, false, field, materialEffects,
82  propDir, mass, false, beamSpot);
83 
84  // check if construction of trajectory was successful
85  if ( !trajectory1.isValid() ) return false;
86 
87  int nLocal = deriv.first.num_row();
88  int nTbd = deriv.first.num_col();
89  unsigned int nHitMeas1 = trajectory1.numberOfHitMeas();
90  unsigned int nVirtualMeas1 = trajectory1.numberOfVirtualMeas();
91  unsigned int nPar1 = trajectory1.numberOfPar();
92  unsigned int nVirtualPar1 = trajectory1.numberOfVirtualPar();
93 
94  // derivatives of the trajectory w.r.t. to the decay parameters
95  AlgebraicMatrix fullDeriv1 = trajectory1.derivatives().sub(1,nHitMeas1+nVirtualMeas1,1,nLocal) * trajectory1.localToTrajectory() * deriv.first;
96 
97  //
98  // second track
99  //
100 
101  ReferenceTrajectory trajectory2( tsos.second, recHits.second, false, field, materialEffects,
102  propDir, mass, false, beamSpot );
103 
104  if ( !trajectory2.isValid() ) return false;
105 
106  unsigned int nHitMeas2 = trajectory2.numberOfHitMeas();
107  unsigned int nVirtualMeas2 = trajectory2.numberOfVirtualMeas();
108  unsigned int nPar2 = trajectory2.numberOfPar();
109  unsigned int nVirtualPar2 = trajectory2.numberOfVirtualPar();
110 
111  AlgebraicMatrix fullDeriv2 = trajectory2.derivatives().sub(1,nHitMeas2+nVirtualMeas2,1,nLocal) * trajectory2.localToTrajectory() * deriv.second;
112 
113  //
114  // combine both tracks
115  //
116 
117  theNumberOfRecHits.first = recHits.first.size();
118  theNumberOfRecHits.second = recHits.second.size();
119 
120  theNumberOfHits = trajectory1.numberOfHits() + trajectory2.numberOfHits();
121  theNumberOfPars = nPar1 + nPar2;
122  theNumberOfVirtualPars = nVirtualPar1 + nVirtualPar2;
123  theNumberOfVirtualMeas = nVirtualMeas1 + nVirtualMeas2 + 1; // add virtual mass measurement
124 
125  // hit measurements from trajectory 1
126  int rowOffset = 1;
127  int colOffset = 1;
128  theDerivatives.sub( rowOffset, colOffset, fullDeriv1.sub( 1, nHitMeas1, 1, nTbd ) );
129  colOffset += nTbd;
130  theDerivatives.sub( rowOffset, colOffset, trajectory1.derivatives().sub( 1, nHitMeas1, nLocal + 1, nPar1 + nVirtualPar1 ) );
131  // hit measurements from trajectory 2
132  rowOffset += nHitMeas1;
133  colOffset = 1;
134  theDerivatives.sub( rowOffset, colOffset, fullDeriv2.sub( 1, nHitMeas2, 1, nTbd ) );
135  colOffset += (nPar1 + nVirtualPar1 + nTbd - nLocal);
136  theDerivatives.sub( rowOffset, colOffset, trajectory2.derivatives().sub( 1, nHitMeas2, nLocal + 1, nPar2 + nVirtualPar2 ) );
137  // MS measurements from trajectory 1
138  rowOffset += nHitMeas2;
139  colOffset = 1;
140  theDerivatives.sub( rowOffset, colOffset, fullDeriv1.sub(nHitMeas1 + 1, nHitMeas1 + nVirtualMeas1, 1, nTbd ) );
141  colOffset += nTbd;
142  theDerivatives.sub( rowOffset, colOffset, trajectory1.derivatives().sub(nHitMeas1 + 1, nHitMeas1 + nVirtualMeas1, nLocal + 1, nPar1 + nVirtualPar1 ) );
143  // MS measurements from trajectory 2
144  rowOffset += nVirtualMeas1;
145  colOffset = 1;
146  theDerivatives.sub( rowOffset, colOffset, fullDeriv2.sub(nHitMeas2 + 1, nHitMeas2 + nVirtualMeas2, 1, nTbd ) );
147  colOffset += (nPar1 + nVirtualPar1 + nTbd - nLocal);
148  theDerivatives.sub( rowOffset, colOffset, trajectory2.derivatives().sub(nHitMeas2 + 1, nHitMeas2 + nVirtualMeas2, nLocal + 1, nPar2 + nVirtualPar2 ) );
149 
150  theMeasurements.sub( 1, trajectory1.measurements().sub( 1, nHitMeas1 ) );
151  theMeasurements.sub( nHitMeas1 + 1, trajectory2.measurements().sub( 1, nHitMeas2 ) );
152  theMeasurements.sub( nHitMeas1 + nHitMeas2 + 1, trajectory1.measurements().sub(nHitMeas1 + 1, nHitMeas1 + nVirtualMeas1 ) );
153  theMeasurements.sub( nHitMeas1 + nHitMeas2 + nVirtualMeas1 + 1, trajectory2.measurements().sub(nHitMeas2 + 1, nHitMeas2 + nVirtualMeas2 ) );
154 
155  theMeasurementsCov.sub( 1, trajectory1.measurementErrors().sub( 1, nHitMeas1 ) );
156  theMeasurementsCov.sub( nHitMeas1 + 1, trajectory2.measurementErrors().sub( 1, nHitMeas2 ) );
157  theMeasurementsCov.sub( nHitMeas1 + nHitMeas2 + 1, trajectory1.measurementErrors().sub(nHitMeas1 + 1, nHitMeas1 + nVirtualMeas1 ) );
158  theMeasurementsCov.sub( nHitMeas1 + nHitMeas2 + nVirtualMeas1 + 1, trajectory2.measurementErrors().sub(nHitMeas2 + 1, nHitMeas2 + nVirtualMeas2 ) );
159 
160  theTrajectoryPositions.sub( 1, trajectory1.trajectoryPositions() );
161  theTrajectoryPositions.sub( nHitMeas1 + 1, trajectory2.trajectoryPositions() );
162 
163  theTrajectoryPositionCov = state.decayParameters().covariance().similarity( theDerivatives.sub(1, nHitMeas1 + nHitMeas2, 1, 9) );
164 
166 
167  theRecHits.insert( theRecHits.end(), recHits.first.begin(), recHits.first.end() );
168  theRecHits.insert( theRecHits.end(), recHits.second.begin(), recHits.second.end() );
169 
170  // add virtual mass measurement
171  rowOffset += nVirtualMeas2;
172  int indMass = rowOffset-1;
174  theMeasurementsCov[indMass][indMass] = state.primaryWidth() * state.primaryWidth();
176 
177  if ( constructTsosWithErrors )
178  {
179  constructTsosVecWithErrors( trajectory1, trajectory2, field );
180  }
181  else
182  {
183  theTsosVec.insert( theTsosVec.end(),
184  trajectory1.trajectoryStates().begin(),
185  trajectory1.trajectoryStates().end() );
186 
187  theTsosVec.insert( theTsosVec.end(),
188  trajectory2.trajectoryStates().begin(),
189  trajectory2.trajectoryStates().end() );
190  }
191 
192  return true;
193 }
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 218 of file TwoBodyDecayTrajectory.cc.

References alignCSCRings::e, statics::field, TrajectoryStateOnSurface::localParameters(), LocalTrajectoryParameters::momentum(), ReferenceTrajectoryBase::nMeasPerHit, AlCaHLTBitMon_ParallelJobs::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().

221 {
222  AlgebraicSymMatrix55 localErrors;
223  const double coeff = 1e-2;
224 
225  double invP = tsos.localParameters().signedInverseMomentum();
227 
228  // rough estimate for the errors of q/p, dx/dz and dy/dz, assuming that
229  // sigma(px) = sigma(py) = sigma(pz) = coeff*p.
230  float dpinv = coeff*( fabs(p.x()) + fabs(p.y()) + fabs(p.z()) )*invP*invP;
231  float dxdir = coeff*( fabs(p.x()) + fabs(p.z()) )/p.z()/p.z();
232  float dydir = coeff*( fabs(p.y()) + fabs(p.z()) )/p.z()/p.z();
233  localErrors[0][0] = dpinv*dpinv;
234  localErrors[1][1] = dxdir*dxdir;
235  localErrors[2][2] = dydir*dydir;
236 
237  // exact values for the errors on local x and y
238  localErrors[3][3] = theTrajectoryPositionCov[nMeasPerHit*iTsos][nMeasPerHit*iTsos];
239  localErrors[3][4] = theTrajectoryPositionCov[nMeasPerHit*iTsos][nMeasPerHit*iTsos+1];
240  localErrors[4][4] = theTrajectoryPositionCov[nMeasPerHit*iTsos+1][nMeasPerHit*iTsos+1];
241 
242  // construct tsos with local errors
244  LocalTrajectoryError( localErrors ),
245  tsos.surface(),
246  field,
247  tsos.surfaceSide() );
248 }
const LocalTrajectoryParameters & localParameters() const
static const unsigned int nMeasPerHit
T y() const
Definition: PV3DBase.h:63
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
tuple field
Definition: statics.py:62
AlgebraicSymMatrix theTrajectoryPositionCov
const SurfaceType & surface() const
SurfaceSide surfaceSide() const
Position relative to material, defined relative to momentum vector.
T z() const
Definition: PV3DBase.h:64
LocalVector momentum() const
Momentum vector in the local frame.
std::vector< TrajectoryStateOnSurface > theTsosVec
T x() const
Definition: PV3DBase.h:62
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 196 of file TwoBodyDecayTrajectory.cc.

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

Referenced by construct().

199 {
200  int iTsos = 0;
201 
202  std::vector< TrajectoryStateOnSurface >::const_iterator itTsos;
203 
204  for ( itTsos = traj1.trajectoryStates().begin(); itTsos != traj1.trajectoryStates().end(); itTsos++ )
205  {
206  constructSingleTsosWithErrors( *itTsos, iTsos, field );
207  iTsos++;
208  }
209 
210  for ( itTsos = traj2.trajectoryStates().begin(); itTsos != traj2.trajectoryStates().end(); itTsos++ )
211  {
212  constructSingleTsosWithErrors( *itTsos, iTsos, field );
213  iTsos++;
214  }
215 }
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().