CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DualReferenceTrajectory.cc
Go to the documentation of this file.
1 
3 
5 
8 
10 
12  const ConstRecHitContainer &forwardRecHits,
13  const ConstRecHitContainer &backwardRecHits,
14  const MagneticField *magField,
15  MaterialEffects materialEffects,
16  PropagationDirection propDir,
17  double mass,
18  bool useBeamSpot,
19  const reco::BeamSpot &beamSpot)
20  : ReferenceTrajectoryBase(referenceTsos.localParameters().mixedFormatVector().kSize,
21  numberOfUsedRecHits(forwardRecHits) + numberOfUsedRecHits(backwardRecHits) - 1,
22  0, 0)
23 {
24  theValidityFlag = this->construct( referenceTsos, forwardRecHits, backwardRecHits,
25  mass, materialEffects, propDir, magField, useBeamSpot, beamSpot );
26 }
27 
28 
29 
30 DualReferenceTrajectory::DualReferenceTrajectory(unsigned int nPar, unsigned int nHits)
31  : ReferenceTrajectoryBase(nPar, nHits, 0, 0)
32 {}
33 
34 
36  const ConstRecHitContainer &forwardRecHits,
37  const ConstRecHitContainer &backwardRecHits,
38  double mass, MaterialEffects materialEffects,
39  const PropagationDirection propDir,
40  const MagneticField *magField,
41  bool useBeamSpot,
42  const reco::BeamSpot &beamSpot)
43 {
44  if (materialEffects >= breakPoints) throw cms::Exception("BadConfig")
45  << "[DualReferenceTrajectory::construct] Wrong MaterialEffects: " << materialEffects;
46 
47  ReferenceTrajectoryBase* fwdTraj = construct(refTsos, forwardRecHits,
48  mass, materialEffects,
49  propDir, magField, useBeamSpot, beamSpot);
50 
51  ReferenceTrajectoryBase* bwdTraj = construct(refTsos, backwardRecHits,
52  mass, materialEffects,
53  oppositeDirection(propDir), magField, false, beamSpot);
54 
55  if ( !( fwdTraj->isValid() && bwdTraj->isValid() ) )
56  {
57  delete fwdTraj;
58  delete bwdTraj;
59  return false;
60  }
61 
62  //
63  // Combine both reference trajactories to a dual reference trajectory
64  //
65 
66  const std::vector<TrajectoryStateOnSurface>& fwdTsosVec = fwdTraj->trajectoryStates();
67  const std::vector<TrajectoryStateOnSurface>& bwdTsosVec = bwdTraj->trajectoryStates();
68  theTsosVec.insert( theTsosVec.end(), fwdTsosVec.begin(), fwdTsosVec.end() );
69  theTsosVec.insert( theTsosVec.end(), ++bwdTsosVec.begin(), bwdTsosVec.end() );
70 
71  const ConstRecHitContainer &fwdRecHits = fwdTraj->recHits();
72  const ConstRecHitContainer &bwdRecHits = bwdTraj->recHits();
73  theRecHits.insert( theRecHits.end(), fwdRecHits.begin(), fwdRecHits.end() );
74  theRecHits.insert( theRecHits.end(), ++bwdRecHits.begin(), bwdRecHits.end() );
75 
76  theParameters = extractParameters( refTsos );
77 
78  unsigned int nParam = theNumberOfPars;
79  unsigned int nFwdMeas = fwdTraj->numberOfHitMeas();
80  unsigned int nBwdMeas = bwdTraj->numberOfHitMeas();
81  unsigned int nFwdBP = fwdTraj->numberOfVirtualMeas();
82  unsigned int nBwdBP = bwdTraj->numberOfVirtualMeas();
83  unsigned int nMeas = nFwdMeas+nBwdMeas-nMeasPerHit;
84 
85  theMeasurements.sub( 1, fwdTraj->measurements().sub( 1, nFwdMeas ) );
86  theMeasurements.sub( nFwdMeas+1, bwdTraj->measurements().sub( nMeasPerHit+1, nBwdMeas ) );
87 
88  theMeasurementsCov.sub( 1, fwdTraj->measurementErrors().sub( 1, nFwdMeas ) );
89  theMeasurementsCov.sub( nFwdMeas+1, bwdTraj->measurementErrors().sub( nMeasPerHit+1, nBwdMeas ) );
90 
91  theTrajectoryPositions.sub( 1, fwdTraj->trajectoryPositions() );
92  theTrajectoryPositions.sub( nFwdMeas+1, bwdTraj->trajectoryPositions().sub( nMeasPerHit+1, nBwdMeas ) );
93 
95  theTrajectoryPositionCov.sub( nFwdMeas+1, bwdTraj->trajectoryPositionErrors().sub( nMeasPerHit+1, nBwdMeas ) );
96 
97  theDerivatives.sub( 1, 1, fwdTraj->derivatives().sub( 1, nFwdMeas, 1, nParam ) );
98  theDerivatives.sub( nFwdMeas+1, 1, bwdTraj->derivatives().sub( nMeasPerHit+1, nBwdMeas, 1, nParam ) );
99 
100 // for the break points
101 // DUAL with break points makes no sense: (MS) correlations between the two parts are lost !
102  if (nFwdBP>0 )
103  {
104  theMeasurements.sub( nMeas+1, fwdTraj->measurements().sub( nFwdMeas+1, nFwdMeas+nFwdBP ) );
105  theMeasurementsCov.sub( nMeas+1, fwdTraj->measurementErrors().sub( nFwdMeas+1, nFwdMeas+nFwdBP ) );
106  theDerivatives.sub( 1, nParam+1, fwdTraj->derivatives().sub( 1, nFwdMeas, nParam+1, nParam+nFwdBP ) );
107  theDerivatives.sub( nMeas+1, nParam+1, fwdTraj->derivatives().sub( nFwdMeas+1, nFwdMeas+nFwdBP, nParam+1, nParam+nFwdBP ) );
108  }
109  if (nBwdBP>0 )
110  {
111  theMeasurements.sub( nMeas+nFwdBP+1, bwdTraj->measurements().sub( nBwdMeas+1, nBwdMeas+nBwdBP ) );
112  theMeasurementsCov.sub( nMeas+nFwdBP+1, bwdTraj->measurementErrors().sub( nBwdMeas+1, nBwdMeas+nBwdBP ) );
113  theDerivatives.sub( nFwdMeas+1, nParam+nFwdBP+1, bwdTraj->derivatives().sub( nMeasPerHit+1, nBwdMeas, nParam+1, nParam+nBwdBP ) );
114  theDerivatives.sub( nMeas+nFwdBP+1, nParam+nFwdBP+1, bwdTraj->derivatives().sub( nBwdMeas+1, nBwdMeas+nBwdBP, nParam+1, nParam+nBwdBP ) );
115  }
116 
117  delete fwdTraj;
118  delete bwdTraj;
119 
120  return true;
121 }
122 
123 
126  const ConstRecHitContainer &recHits,
127  double mass, MaterialEffects materialEffects,
128  const PropagationDirection propDir,
129  const MagneticField *magField,
130  bool useBeamSpot,
131  const reco::BeamSpot &beamSpot) const
132 {
133  if (materialEffects >= breakPoints) throw cms::Exception("BadConfig")
134  << "[DualReferenceTrajectory::construct] Wrong MaterialEffects: " << materialEffects;
135 
136  return new ReferenceTrajectory(referenceTsos, recHits, false,
137  magField, materialEffects, propDir, mass,
138  useBeamSpot, beamSpot);
139 }
140 
141 
144 {
145  return asHepVector<5>( referenceTsos.localParameters().mixedFormatVector() );
146 }
const LocalTrajectoryParameters & localParameters() const
static const unsigned int nMeasPerHit
unsigned int numberOfHitMeas() const
const TransientTrackingRecHit::ConstRecHitContainer & recHits() const
const PropagationDirection oppositeDirection(const PropagationDirection propDir) const
PropagationDirection
DualReferenceTrajectory(const TrajectoryStateOnSurface &referenceTsos, const ConstRecHitContainer &forwardRecHits, const ConstRecHitContainer &backwardRecHits, const MagneticField *magField, MaterialEffects materialEffects, PropagationDirection propDir, double mass, bool useBeamSpot, const reco::BeamSpot &beamSpot)
const AlgebraicSymMatrix & measurementErrors() const
const AlgebraicSymMatrix & trajectoryPositionErrors() const
AlgebraicSymMatrix theTrajectoryPositionCov
const AlgebraicMatrix & derivatives() const
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
virtual AlgebraicVector extractParameters(const TrajectoryStateOnSurface &referenceTsos) const
TransientTrackingRecHit::ConstRecHitContainer theRecHits
AlgebraicSymMatrix theMeasurementsCov
CLHEP::HepVector AlgebraicVector
AlgebraicVector5 mixedFormatVector() const
tuple mass
Definition: scaleCards.py:27
unsigned int numberOfVirtualMeas() const
const AlgebraicVector & measurements() const
std::vector< TrajectoryStateOnSurface > theTsosVec
const AlgebraicVector & trajectoryPositions() const
virtual bool construct(const TrajectoryStateOnSurface &referenceTsos, const ConstRecHitContainer &forwardRecHits, const ConstRecHitContainer &backwardRecHits, double mass, MaterialEffects materialEffects, const PropagationDirection propDir, const MagneticField *magField, bool useBeamSpot, const reco::BeamSpot &beamSpot)
const std::vector< TrajectoryStateOnSurface > & trajectoryStates() const