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
 
unsigned int tracksPerTrajectory () const
 
 TrajectoryFactoryBase (const edm::ParameterSet &config)
 
 TrajectoryFactoryBase (const edm::ParameterSet &config, unsigned int tracksPerTrajectory)
 
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
const bool includeAPEs_
 
const bool useBeamSpot_
 

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 238 of file DualTrajectoryFactory.cc.

References anyDirection, AnalyticalPropagator::propagateWithPath(), and HLT_25ns10e33_v2_cff::propagator.

Referenced by trajectories().

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

Definition at line 191 of file DualTrajectoryFactory.cc.

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

Referenced by trajectories().

192 {
193  DualTrajectoryInput input;
194 
195  // get the trajectory measurements in the correct order, i.e. reverse if needed
196  Trajectory::DataContainer allTrajMeas = this->orderedTrajectoryMeasurements( *track.first );
197  Trajectory::DataContainer usedTrajMeas;
198  Trajectory::DataContainer::iterator itM;
199  // get all relevant trajectory measurements
200  for ( itM = allTrajMeas.begin(); itM != allTrajMeas.end(); itM++ )
201  {
202  if ( useRecHit( ( *itM ).recHit() ) ) usedTrajMeas.push_back( *itM );
203  }
204 
205  unsigned int iMeas = 0;
206  unsigned int nMeas = usedTrajMeas.size();
207  unsigned int nRefStateMeas = nMeas/2;
208  // get the valid RecHits
209  for ( itM = usedTrajMeas.begin(); itM != usedTrajMeas.end(); itM++, iMeas++ )
210  {
211  TransientTrackingRecHit::ConstRecHitPointer aRecHit = ( *itM ).recHit();
212 
213  if ( iMeas < nRefStateMeas ) {
214  input.bwdRecHits.push_back( aRecHit );
215  } else if ( iMeas > nRefStateMeas ) {
216  input.fwdRecHits.push_back( aRecHit );
217  } else { // iMeas == nRefStateMeas
218  if ( ( *itM ).updatedState().isValid() )
219  {
220  input.refTsos = ( *itM ).updatedState();
221  input.bwdRecHits.push_back( aRecHit );
222  input.fwdRecHits.push_back( aRecHit );
223  } else {
224  // if the tsos of the middle hit is not valid, try the next one ...
225  nRefStateMeas++;
226  input.bwdRecHits.push_back( aRecHit );
227  }
228  }
229  }
230 
231  // bring input.fwdRecHits into correct order
232  std::reverse( input.bwdRecHits.begin(), input.bwdRecHits.end() );
233 
234  return input;
235 }
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:44
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, mps_alisetup::config, DualTrajectoryFactory::DualTrajectoryInput::fwdRecHits, edm::EventSetup::get(), ReferenceTrajectoryBase::Config::includeAPEs, TrajectoryFactoryBase::includeAPEs_, input, TrajectoryStateOnSurface::isValid(), HLT_25ns10e33_v2_cff::magneticField, TrajectoryFactoryBase::materialEffects(), edm::ESHandle< class >::product(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), DualTrajectoryFactory::DualTrajectoryInput::refTsos, theMass, ReferenceTrajectoryBase::Config::useBeamSpot, and TrajectoryFactoryBase::useBeamSpot_.

Referenced by trajectories().

73 {
75 
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  {
94  config.useBeamSpot = useBeamSpot_;
95  config.includeAPEs = includeAPEs_;
96  ReferenceTrajectoryPtr ptr(new DualReferenceTrajectory(input.refTsos,
97  input.fwdRecHits,
98  input.bwdRecHits,
99  magneticField.product(),
100  beamSpot,
101  config));
102  trajectories.push_back( ptr );
103  }
104 
105  ++itTracks;
106  }
107 
108  return trajectories;
109 }
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:56
T const * product() const
Definition: ESHandle.h:86
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 112 of file DualTrajectoryFactory.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, DualTrajectoryFactory::DualTrajectoryInput::bwdRecHits, mps_alisetup::config, DualTrajectoryFactory::DualTrajectoryInput::fwdRecHits, edm::EventSetup::get(), ReferenceTrajectoryBase::Config::includeAPEs, TrajectoryFactoryBase::includeAPEs_, input, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), HLT_25ns10e33_v2_cff::magneticField, TrajectoryFactoryBase::materialEffects(), LocalTrajectoryError::matrix(), edm::ESHandle< class >::product(), propagateExternal(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), DualTrajectoryFactory::DualTrajectoryInput::refTsos, TrajectoryStateOnSurface::surface(), theMass, trajectories(), ReferenceTrajectoryBase::Config::useBeamSpot, and TrajectoryFactoryBase::useBeamSpot_.

116 {
118 
119  if ( tracks.size() != external.size() )
120  {
121  edm::LogInfo("ReferenceTrajectories") << "@SUB=DualTrajectoryFactory::trajectories"
122  << "Inconsistent input:\n"
123  << "\tnumber of tracks = " << tracks.size()
124  << "\tnumber of external predictions = " << external.size();
125  return trajectories;
126  }
127 
129  setup.get< IdealMagneticFieldRecord >().get( magneticField );
130  if (magneticField->inTesla(GlobalPoint(0.,0.,0.)).mag2() < 1.e-6) {
131  edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
132  << "B-field in z is " << magneticField->inTesla(GlobalPoint(0.,0.,0.)).z()
133  << ": You should probably use the DualBzeroTrajectoryFactory\n"
134  << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
135  }
136 
137  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
138  ExternalPredictionCollection::const_iterator itExternal = external.begin();
139 
140  while ( itTracks != tracks.end() )
141  {
142  const DualTrajectoryInput input = referenceStateAndRecHits( *itTracks );
143  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
144  if ( input.refTsos.isValid() )
145  {
146  if ( (*itExternal).isValid() )
147  {
148  TrajectoryStateOnSurface propExternal =
149  propagateExternal( *itExternal, input.refTsos.surface(), magneticField.product() );
150 
151  if ( !propExternal.isValid() ) continue;
152 
154  config.useBeamSpot = useBeamSpot_;
155  config.includeAPEs = includeAPEs_;
156  ReferenceTrajectoryPtr ptr(new DualReferenceTrajectory(propExternal,
157  input.fwdRecHits,
158  input.bwdRecHits,
159  magneticField.product(),
160  beamSpot,
161  config));
162 
163  AlgebraicSymMatrix externalParamErrors( asHepMatrix<5>( propExternal.localError().matrix() ) );
164  ptr->setParameterErrors( externalParamErrors );
165  trajectories.push_back( ptr );
166  }
167  else
168  {
170  config.useBeamSpot = useBeamSpot_;
171  config.includeAPEs = includeAPEs_;
172  ReferenceTrajectoryPtr ptr(new DualReferenceTrajectory(input.refTsos,
173  input.fwdRecHits,
174  input.bwdRecHits,
175  magneticField.product(),
176  beamSpot,
177  config));
178  trajectories.push_back( ptr );
179  }
180  }
181 
182  ++itTracks;
183  ++itExternal;
184  }
185 
186  return trajectories;
187 }
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:56
T const * product() const
Definition: ESHandle.h:86
PropagationDirection propagationDirection(void) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr

Member Data Documentation

double DualTrajectoryFactory::theMass
protected