test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DualBzeroTrajectoryFactory.cc
Go to the documentation of this file.
8 
9 #include <algorithm>
10 
12 
14 
16 
17 
19 {
20 public:
23 
27  const reco::BeamSpot &beamSpot) const override;
28 
30  const ConstTrajTrackPairCollection &tracks,
31  const ExternalPredictionCollection &external,
32  const reco::BeamSpot &beamSpot) const override;
33 
34  virtual DualBzeroTrajectoryFactory* clone() const override { return new DualBzeroTrajectoryFactory(*this); }
35 
36 protected:
38  {
42  };
43 
45 
47  const Surface &surface,
48  const MagneticField *magField) const;
49 
50  double theMass;
52 
53 };
54 
58 
60  TrajectoryFactoryBase( config )
61 {
62  theMass = config.getParameter< double >( "ParticleMass" );
63  theMomentumEstimate = config.getParameter< double >( "MomentumEstimate" );
64 }
65 
66 
68 
69 
73  const reco::BeamSpot &beamSpot) const
74 {
76 
78  setup.get< IdealMagneticFieldRecord >().get( magneticField );
79 
80  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
81 
82  while ( itTracks != tracks.end() )
83  {
84  const DualBzeroTrajectoryInput input = this->referenceStateAndRecHits( *itTracks );
85  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
86  if ( input.refTsos.isValid() )
87  {
90  config.useBeamSpot = useBeamSpot_;
91  config.includeAPEs = includeAPEs_;
93  input.fwdRecHits,
94  input.bwdRecHits,
95  magneticField.product(),
96  beamSpot,
97  config));
98  trajectories.push_back( ptr );
99  }
100 
101  ++itTracks;
102  }
103 
104  return trajectories;
105 }
106 
110  const ExternalPredictionCollection &external,
111  const reco::BeamSpot &beamSpot) const
112 {
114 
115  if ( tracks.size() != external.size() )
116  {
117  edm::LogInfo("ReferenceTrajectories") << "@SUB=DualBzeroTrajectoryFactory::trajectories"
118  << "Inconsistent input:\n"
119  << "\tnumber of tracks = " << tracks.size()
120  << "\tnumber of external predictions = " << external.size();
121  return trajectories;
122  }
123 
125  setup.get< IdealMagneticFieldRecord >().get( magneticField );
126 
127  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
128  ExternalPredictionCollection::const_iterator itExternal = external.begin();
129 
130  while ( itTracks != tracks.end() )
131  {
133  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
134  if ( input.refTsos.isValid() )
135  {
136  if ( (*itExternal).isValid() )
137  {
138  TrajectoryStateOnSurface propExternal =
139  propagateExternal( *itExternal, input.refTsos.surface(), magneticField.product() );
140 
141  if ( !propExternal.isValid() ) continue;
142 
145  config.useBeamSpot = useBeamSpot_;
146  config.includeAPEs = includeAPEs_;
148  input.fwdRecHits,
149  input.bwdRecHits,
150  magneticField.product(),
151  beamSpot,
152  config));
153 
154  AlgebraicSymMatrix externalParamErrors( asHepMatrix<5>( propExternal.localError().matrix() ) );
155  ptr->setParameterErrors( externalParamErrors.sub( 2, 5 ) );
156  trajectories.push_back( ptr );
157  }
158  else
159  {
162  config.useBeamSpot = useBeamSpot_;
163  config.includeAPEs = includeAPEs_;
165  input.fwdRecHits,
166  input.bwdRecHits,
167  magneticField.product(),
168  beamSpot,
169  config));
170 
171  trajectories.push_back( ptr );
172  }
173  }
174 
175  ++itTracks;
176  ++itExternal;
177  }
178 
179  return trajectories;
180 }
181 
182 
185 {
187 
188  // get the trajectory measurements in the correct order, i.e. reverse if needed
189  Trajectory::DataContainer allTrajMeas = this->orderedTrajectoryMeasurements( *track.first );
190  Trajectory::DataContainer usedTrajMeas;
191  Trajectory::DataContainer::iterator itM;
192  // get all relevant trajectory measurements
193  for ( itM = allTrajMeas.begin(); itM != allTrajMeas.end(); itM++ )
194  {
195  if ( useRecHit( ( *itM ).recHit() ) ) usedTrajMeas.push_back( *itM );
196  }
197 
198  unsigned int iMeas = 0;
199  unsigned int nMeas = usedTrajMeas.size();
200  unsigned int nRefStateMeas = nMeas/2;
201  // get the valid RecHits
202  for ( itM = usedTrajMeas.begin(); itM != usedTrajMeas.end(); itM++, iMeas++ )
203  {
204  TransientTrackingRecHit::ConstRecHitPointer aRecHit = ( *itM ).recHit();
205 
206  if ( iMeas < nRefStateMeas ) {
207  input.bwdRecHits.push_back( aRecHit );
208  } else if ( iMeas > nRefStateMeas ) {
209  input.fwdRecHits.push_back( aRecHit );
210  } else { // iMeas == nRefStateMeas
211  if ( ( *itM ).updatedState().isValid() )
212  {
213  input.refTsos = ( *itM ).updatedState();
214  input.bwdRecHits.push_back( aRecHit );
215  input.fwdRecHits.push_back( aRecHit );
216  } else {
217  // if the tsos of the middle hit is not valid, try the next one ...
218  nRefStateMeas++;
219  input.bwdRecHits.push_back( aRecHit );
220  }
221  }
222  }
223 
224  // bring input.fwdRecHits into correct order
225  std::reverse( input.bwdRecHits.begin(), input.bwdRecHits.end() );
226 
227  return input;
228 }
229 
232  const Surface& surface,
233  const MagneticField* magField ) const
234 {
236  const std::pair< TrajectoryStateOnSurface, double > tsosWithPath =
237  propagator.propagateWithPath( external, surface );
238  return tsosWithPath.first;
239 }
240 
241 
T getParameter(std::string const &) const
const TrajectoryStateOnSurface propagateExternal(const TrajectoryStateOnSurface &external, const Surface &surface, const MagneticField *magField) const
TransientTrackingRecHit::ConstRecHitContainer bwdRecHits
MaterialEffects materialEffects(void) const
const DualBzeroTrajectoryInput referenceStateAndRecHits(const ConstTrajTrackPair &track) const
virtual const Trajectory::DataContainer orderedTrajectoryMeasurements(const Trajectory &trajectory) const
virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the reference trajectories.
AlignmentAlgorithmBase::ConstTrajTrackPair ConstTrajTrackPair
bool useRecHit(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &fts, const Plane &plane) const override
propagation to plane with path length
static std::string const input
Definition: EdmProvDump.cc:44
const SurfaceType & surface() const
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:44
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
std::vector< ConstRecHitPointer > ConstRecHitContainer
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
PropagationDirection propagationDirection(void) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
virtual DualBzeroTrajectoryFactory * clone() const override
A factory that produces instances of class ReferenceTrajectory from a given TrajTrackPairCollection.
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
TransientTrackingRecHit::ConstRecHitContainer fwdRecHits
DualBzeroTrajectoryFactory(const edm::ParameterSet &config)