CMS 3D CMS Logo

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 allowZeroMaterial_
 
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< TrajectoryStateOnSurfaceExternalPredictionCollection
 
typedef ReferenceTrajectoryBase::MaterialEffects MaterialEffects
 
typedef std::vector< ReferenceTrajectoryPtrReferenceTrajectoryCollection
 
typedef ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
 
typedef std::pair< TrajectoryStateOnSurface, TransientTrackingRecHit::ConstRecHitContainerTrajectoryInput
 

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

References anyDirection, DEFINE_EDM_PLUGIN, AnalyticalPropagator::propagateWithPath(), and PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::propagator.

Referenced by trajectories().

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

Definition at line 194 of file DualTrajectoryFactory.cc.

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

Referenced by trajectories().

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

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  config.allowZeroMaterial = allowZeroMaterial_;
97  ReferenceTrajectoryPtr ptr(new DualReferenceTrajectory(input.refTsos,
98  input.fwdRecHits,
99  input.bwdRecHits,
100  magneticField.product(),
101  beamSpot,
102  config));
103  trajectories.push_back( ptr );
104  }
105 
106  ++itTracks;
107  }
108 
109  return trajectories;
110 }
T mag2() const
Definition: PV3DBase.h:66
const DualTrajectoryInput referenceStateAndRecHits(const ConstTrajTrackPair &track) const
MaterialEffects materialEffects(void) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Definition: config.py:1
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.
T z() const
Definition: PV3DBase.h:64
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
const T & get() const
Definition: EventSetup.h:56
PropagationDirection propagationDirection(void) const
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
T const * product() const
Definition: ESHandle.h:86
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 113 of file DualTrajectoryFactory.cc.

References ReferenceTrajectoryBase::Config::allowZeroMaterial, TrajectoryFactoryBase::allowZeroMaterial_, ecalDrivenElectronSeedsParameters_cff::beamSpot, DualTrajectoryFactory::DualTrajectoryInput::bwdRecHits, mps_alisetup::config, DualTrajectoryFactory::DualTrajectoryInput::fwdRecHits, edm::EventSetup::get(), ReferenceTrajectoryBase::Config::includeAPEs, TrajectoryFactoryBase::includeAPEs_, input, MagneticField::inTesla(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), PV3DBase< T, PVType, FrameType >::mag2(), seedCreatorFromRegionConsecutiveHitsEDProducer_cff::magneticField, TrajectoryFactoryBase::materialEffects(), LocalTrajectoryError::matrix(), edm::ESHandle< T >::product(), propagateExternal(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), DualTrajectoryFactory::DualTrajectoryInput::refTsos, TrajectoryStateOnSurface::surface(), theMass, trajectories(), ReferenceTrajectoryBase::Config::useBeamSpot, TrajectoryFactoryBase::useBeamSpot_, and PV3DBase< T, PVType, FrameType >::z().

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

Member Data Documentation

double DualTrajectoryFactory::theMass
protected