CMS 3D CMS Logo

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

A factory that produces instances of class ReferenceTrajectory from a given TrajTrackPairCollection. More...

Inheritance diagram for DualTrajectoryFactory:
TrajectoryFactoryBase

Classes

struct  DualTrajectoryInput
 

Public Member Functions

virtual DualTrajectoryFactoryclone () const override
 
 DualTrajectoryFactory (const edm::ParameterSet &config)
 
virtual const
ReferenceTrajectoryCollection 
trajectories (const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
 Produce the reference trajectories. More...
 
virtual const
ReferenceTrajectoryCollection 
trajectories (const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const ExternalPredictionCollection &external, const reco::BeamSpot &beamSpot) const override
 
virtual ~DualTrajectoryFactory ()
 
- Public Member Functions inherited from TrajectoryFactoryBase
const edm::ParameterSetconfiguration () const
 
MaterialEffects materialEffects (void) const
 
PropagationDirection propagationDirection (void) const
 
 TrajectoryFactoryBase (const edm::ParameterSet &config)
 
virtual ~TrajectoryFactoryBase (void)
 

Protected Member Functions

const TrajectoryStateOnSurface propagateExternal (const TrajectoryStateOnSurface &external, const Surface &surface, const MagneticField *magField) const
 
const DualTrajectoryInput referenceStateAndRecHits (const ConstTrajTrackPair &track) const
 
- Protected Member Functions inherited from TrajectoryFactoryBase
virtual const TrajectoryInput innermostStateAndRecHits (const ConstTrajTrackPair &track) const
 
virtual const
Trajectory::DataContainer 
orderedTrajectoryMeasurements (const Trajectory &trajectory) const
 
bool sameSurface (const Surface &s1, const Surface &s2) const
 
bool useRecHit (const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
 

Protected Attributes

double theMass
 
- Protected Attributes inherited from TrajectoryFactoryBase
bool theUseBeamSpot
 

Additional Inherited Members

- Public Types inherited from TrajectoryFactoryBase
typedef
AlignmentAlgorithmBase::ConstTrajTrackPair 
ConstTrajTrackPair
 
typedef
AlignmentAlgorithmBase::ConstTrajTrackPairCollection 
ConstTrajTrackPairCollection
 
typedef std::vector
< TrajectoryStateOnSurface
ExternalPredictionCollection
 
typedef
ReferenceTrajectoryBase::MaterialEffects 
MaterialEffects
 
typedef std::vector
< ReferenceTrajectoryPtr
ReferenceTrajectoryCollection
 
typedef
ReferenceTrajectoryBase::ReferenceTrajectoryPtr 
ReferenceTrajectoryPtr
 
typedef std::pair
< TrajectoryStateOnSurface,
TransientTrackingRecHit::ConstRecHitContainer
TrajectoryInput
 

Detailed Description

A factory that produces instances of class ReferenceTrajectory from a given TrajTrackPairCollection.

Definition at line 18 of file DualTrajectoryFactory.cc.

Constructor & Destructor Documentation

DualTrajectoryFactory::DualTrajectoryFactory ( const edm::ParameterSet config)

Definition at line 57 of file DualTrajectoryFactory.cc.

References theMass.

Referenced by clone().

57  :
58  TrajectoryFactoryBase( config ),
59  theMass(config.getParameter<double>("ParticleMass"))
60 {
61  edm::LogInfo("Alignment") << "@SUB=DualTrajectoryFactory"
62  << "mass: " << theMass;
63 }
T getParameter(std::string const &) const
TrajectoryFactoryBase(const edm::ParameterSet &config)
DualTrajectoryFactory::~DualTrajectoryFactory ( void  )
virtual

Definition at line 66 of file DualTrajectoryFactory.cc.

66 {}

Member Function Documentation

virtual DualTrajectoryFactory* DualTrajectoryFactory::clone ( void  ) const
inlineoverridevirtual

Implements TrajectoryFactoryBase.

Definition at line 34 of file DualTrajectoryFactory.cc.

References DualTrajectoryFactory().

34 { return new DualTrajectoryFactory(*this); }
DualTrajectoryFactory(const edm::ParameterSet &config)
const TrajectoryStateOnSurface DualTrajectoryFactory::propagateExternal ( const TrajectoryStateOnSurface external,
const Surface surface,
const MagneticField magField 
) const
protected

Definition at line 236 of file DualTrajectoryFactory.cc.

References AnalyticalPropagator_cfi::AnalyticalPropagator, and anyDirection.

Referenced by trajectories().

239 {
240  AnalyticalPropagator propagator( magField, anyDirection );
241  const std::pair< TrajectoryStateOnSurface, double > tsosWithPath =
242  propagator.propagateWithPath( external, surface );
243  return tsosWithPath.first;
244 }
const DualTrajectoryFactory::DualTrajectoryInput DualTrajectoryFactory::referenceStateAndRecHits ( const ConstTrajTrackPair track) const
protected

Definition at line 189 of file DualTrajectoryFactory.cc.

References DualTrajectoryFactory::DualTrajectoryInput::bwdRecHits, DualTrajectoryFactory::DualTrajectoryInput::fwdRecHits, input, TrajectoryFactoryBase::orderedTrajectoryMeasurements(), DualTrajectoryFactory::DualTrajectoryInput::refTsos, and TrajectoryFactoryBase::useRecHit().

Referenced by trajectories().

190 {
191  DualTrajectoryInput input;
192 
193  // get the trajectory measurements in the correct order, i.e. reverse if needed
194  Trajectory::DataContainer allTrajMeas = this->orderedTrajectoryMeasurements( *track.first );
195  Trajectory::DataContainer usedTrajMeas;
196  Trajectory::DataContainer::iterator itM;
197  // get all relevant trajectory measurements
198  for ( itM = allTrajMeas.begin(); itM != allTrajMeas.end(); itM++ )
199  {
200  if ( useRecHit( ( *itM ).recHit() ) ) usedTrajMeas.push_back( *itM );
201  }
202 
203  unsigned int iMeas = 0;
204  unsigned int nMeas = usedTrajMeas.size();
205  unsigned int nRefStateMeas = nMeas/2;
206  // get the valid RecHits
207  for ( itM = usedTrajMeas.begin(); itM != usedTrajMeas.end(); itM++, iMeas++ )
208  {
209  TransientTrackingRecHit::ConstRecHitPointer aRecHit = ( *itM ).recHit();
210 
211  if ( iMeas < nRefStateMeas ) {
212  input.bwdRecHits.push_back( aRecHit );
213  } else if ( iMeas > nRefStateMeas ) {
214  input.fwdRecHits.push_back( aRecHit );
215  } else { // iMeas == nRefStateMeas
216  if ( ( *itM ).updatedState().isValid() )
217  {
218  input.refTsos = ( *itM ).updatedState();
219  input.bwdRecHits.push_back( aRecHit );
220  input.fwdRecHits.push_back( aRecHit );
221  } else {
222  // if the tsos of the middle hit is not valid, try the next one ...
223  nRefStateMeas++;
224  input.bwdRecHits.push_back( aRecHit );
225  }
226  }
227  }
228 
229  // bring input.fwdRecHits into correct order
230  std::reverse( input.bwdRecHits.begin(), input.bwdRecHits.end() );
231 
232  return input;
233 }
virtual const Trajectory::DataContainer orderedTrajectoryMeasurements(const Trajectory &trajectory) const
bool useRecHit(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
static std::string const input
Definition: EdmProvDump.cc:44
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:42
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
const DualTrajectoryFactory::ReferenceTrajectoryCollection DualTrajectoryFactory::trajectories ( const edm::EventSetup setup,
const ConstTrajTrackPairCollection tracks,
const reco::BeamSpot beamSpot 
) const
overridevirtual

Produce the reference trajectories.

Implements TrajectoryFactoryBase.

Definition at line 70 of file DualTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, DualTrajectoryFactory::DualTrajectoryInput::bwdRecHits, DualTrajectoryFactory::DualTrajectoryInput::fwdRecHits, edm::EventSetup::get(), input, TrajectoryStateOnSurface::isValid(), TrajectoryFactoryBase::materialEffects(), edm::ESHandle< class >::product(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), DualTrajectoryFactory::DualTrajectoryInput::refTsos, theMass, and TrajectoryFactoryBase::theUseBeamSpot.

Referenced by trajectories().

73 {
75 
76  edm::ESHandle< MagneticField > magneticField;
77  setup.get< IdealMagneticFieldRecord >().get( magneticField );
78  if (magneticField->inTesla(GlobalPoint(0.,0.,0.)).mag2() < 1.e-6) {
79  edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
80  << "B-field in z is " << magneticField->inTesla(GlobalPoint(0.,0.,0.)).z()
81  << ": You should probably use the DualBzeroTrajectoryFactory\n"
82  << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
83  }
84 
85  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
86 
87  while ( itTracks != tracks.end() )
88  {
89  const DualTrajectoryInput input = this->referenceStateAndRecHits( *itTracks );
90  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
91  if ( input.refTsos.isValid() )
92  {
93  ReferenceTrajectoryPtr ptr( new DualReferenceTrajectory( input.refTsos,
94  input.fwdRecHits,
95  input.bwdRecHits,
96  magneticField.product(),
99  theMass,
101  trajectories.push_back( ptr );
102  }
103 
104  ++itTracks;
105  }
106 
107  return trajectories;
108 }
const DualTrajectoryInput referenceStateAndRecHits(const ConstTrajTrackPair &track) const
MaterialEffects materialEffects(void) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static std::string const input
Definition: EdmProvDump.cc:44
virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the reference trajectories.
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
PropagationDirection propagationDirection(void) const
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
const DualTrajectoryFactory::ReferenceTrajectoryCollection DualTrajectoryFactory::trajectories ( const edm::EventSetup setup,
const ConstTrajTrackPairCollection tracks,
const ExternalPredictionCollection external,
const reco::BeamSpot beamSpot 
) const
overridevirtual

Implements TrajectoryFactoryBase.

Definition at line 111 of file DualTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, DualTrajectoryFactory::DualTrajectoryInput::bwdRecHits, DualTrajectoryFactory::DualTrajectoryInput::fwdRecHits, edm::EventSetup::get(), input, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), TrajectoryFactoryBase::materialEffects(), LocalTrajectoryError::matrix(), edm::ESHandle< class >::product(), propagateExternal(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), DualTrajectoryFactory::DualTrajectoryInput::refTsos, TrajectoryStateOnSurface::surface(), theMass, TrajectoryFactoryBase::theUseBeamSpot, and trajectories().

115 {
117 
118  if ( tracks.size() != external.size() )
119  {
120  edm::LogInfo("ReferenceTrajectories") << "@SUB=DualTrajectoryFactory::trajectories"
121  << "Inconsistent input:\n"
122  << "\tnumber of tracks = " << tracks.size()
123  << "\tnumber of external predictions = " << external.size();
124  return trajectories;
125  }
126 
127  edm::ESHandle< MagneticField > magneticField;
128  setup.get< IdealMagneticFieldRecord >().get( magneticField );
129  if (magneticField->inTesla(GlobalPoint(0.,0.,0.)).mag2() < 1.e-6) {
130  edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
131  << "B-field in z is " << magneticField->inTesla(GlobalPoint(0.,0.,0.)).z()
132  << ": You should probably use the DualBzeroTrajectoryFactory\n"
133  << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
134  }
135 
136  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
137  ExternalPredictionCollection::const_iterator itExternal = external.begin();
138 
139  while ( itTracks != tracks.end() )
140  {
141  const DualTrajectoryInput input = referenceStateAndRecHits( *itTracks );
142  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
143  if ( input.refTsos.isValid() )
144  {
145  if ( (*itExternal).isValid() )
146  {
147  TrajectoryStateOnSurface propExternal =
148  propagateExternal( *itExternal, input.refTsos.surface(), magneticField.product() );
149 
150  if ( !propExternal.isValid() ) continue;
151 
152  // set the flag for reversing the RecHits to false, since they are already in the correct order.
153  ReferenceTrajectoryPtr ptr( new DualReferenceTrajectory( propExternal,
154  input.fwdRecHits,
155  input.bwdRecHits,
156  magneticField.product(),
157  materialEffects(),
159  theMass,
161 
162  AlgebraicSymMatrix externalParamErrors( asHepMatrix<5>( propExternal.localError().matrix() ) );
163  ptr->setParameterErrors( externalParamErrors );
164  trajectories.push_back( ptr );
165  }
166  else
167  {
168  ReferenceTrajectoryPtr ptr( new DualReferenceTrajectory( input.refTsos,
169  input.fwdRecHits,
170  input.bwdRecHits,
171  magneticField.product(),
172  materialEffects(),
174  theMass,
176  trajectories.push_back( ptr );
177  }
178  }
179 
180  ++itTracks;
181  ++itExternal;
182  }
183 
184  return trajectories;
185 }
const TrajectoryStateOnSurface propagateExternal(const TrajectoryStateOnSurface &external, const Surface &surface, const MagneticField *magField) const
const DualTrajectoryInput referenceStateAndRecHits(const ConstTrajTrackPair &track) const
MaterialEffects materialEffects(void) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
static std::string const input
Definition: EdmProvDump.cc:44
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the reference trajectories.
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
PropagationDirection propagationDirection(void) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr

Member Data Documentation

double DualTrajectoryFactory::theMass
protected