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

DualTrajectoryFactoryclone () const override
 
 DualTrajectoryFactory (const edm::ParameterSet &config)
 
const ReferenceTrajectoryCollection trajectories (const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
 Produce the reference trajectories. More...
 
const ReferenceTrajectoryCollection trajectories (const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const ExternalPredictionCollection &external, const reco::BeamSpot &beamSpot) const override
 
 ~DualTrajectoryFactory () override
 
- 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 17 of file DualTrajectoryFactory.cc.

Constructor & Destructor Documentation

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

Definition at line 54 of file DualTrajectoryFactory.cc.

References theMass.

Referenced by clone().

55  : TrajectoryFactoryBase(config), theMass(config.getParameter<double>("ParticleMass")) {
56  edm::LogInfo("Alignment") << "@SUB=DualTrajectoryFactory"
57  << "mass: " << theMass;
58 }
T getParameter(std::string const &) const
TrajectoryFactoryBase(const edm::ParameterSet &config)
DualTrajectoryFactory::~DualTrajectoryFactory ( void  )
override

Definition at line 60 of file DualTrajectoryFactory.cc.

60 {}

Member Function Documentation

DualTrajectoryFactory* DualTrajectoryFactory::clone ( void  ) const
inlineoverridevirtual

Implements TrajectoryFactoryBase.

Definition at line 32 of file DualTrajectoryFactory.cc.

References DualTrajectoryFactory().

32 { 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 206 of file DualTrajectoryFactory.cc.

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

Referenced by trajectories().

208  {
210  const std::pair<TrajectoryStateOnSurface, double> tsosWithPath = propagator.propagateWithPath(external, surface);
211  return tsosWithPath.first;
212 }
const DualTrajectoryFactory::DualTrajectoryInput DualTrajectoryFactory::referenceStateAndRecHits ( const ConstTrajTrackPair track) const
protected

Definition at line 162 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().

163  {
164  DualTrajectoryInput input;
165 
166  // get the trajectory measurements in the correct order, i.e. reverse if needed
168  Trajectory::DataContainer usedTrajMeas;
169  Trajectory::DataContainer::iterator itM;
170  // get all relevant trajectory measurements
171  for (itM = allTrajMeas.begin(); itM != allTrajMeas.end(); itM++) {
172  if (useRecHit((*itM).recHit()))
173  usedTrajMeas.push_back(*itM);
174  }
175 
176  unsigned int iMeas = 0;
177  unsigned int nMeas = usedTrajMeas.size();
178  unsigned int nRefStateMeas = nMeas / 2;
179  // get the valid RecHits
180  for (itM = usedTrajMeas.begin(); itM != usedTrajMeas.end(); itM++, iMeas++) {
181  TransientTrackingRecHit::ConstRecHitPointer aRecHit = (*itM).recHit();
182 
183  if (iMeas < nRefStateMeas) {
184  input.bwdRecHits.push_back(aRecHit);
185  } else if (iMeas > nRefStateMeas) {
186  input.fwdRecHits.push_back(aRecHit);
187  } else { // iMeas == nRefStateMeas
188  if ((*itM).updatedState().isValid()) {
189  input.refTsos = (*itM).updatedState();
190  input.bwdRecHits.push_back(aRecHit);
191  input.fwdRecHits.push_back(aRecHit);
192  } else {
193  // if the tsos of the middle hit is not valid, try the next one ...
194  nRefStateMeas++;
195  input.bwdRecHits.push_back(aRecHit);
196  }
197  }
198  }
199 
200  // bring input.fwdRecHits into correct order
201  std::reverse(input.bwdRecHits.begin(), input.bwdRecHits.end());
202 
203  return input;
204 }
virtual const Trajectory::DataContainer orderedTrajectoryMeasurements(const Trajectory &trajectory) const
bool useRecHit(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
static std::string const input
Definition: EdmProvDump.cc:48
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 62 of file DualTrajectoryFactory.cc.

References ReferenceTrajectoryBase::Config::allowZeroMaterial, TrajectoryFactoryBase::allowZeroMaterial_, ecalDrivenElectronSeedsParameters_cff::beamSpot, DualTrajectoryFactory::DualTrajectoryInput::bwdRecHits, looper::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().

63  {
65 
67  setup.get<IdealMagneticFieldRecord>().get(magneticField);
68  if (magneticField->inTesla(GlobalPoint(0., 0., 0.)).mag2() < 1.e-6) {
69  edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
70  << "B-field in z is " << magneticField->inTesla(GlobalPoint(0., 0., 0.)).z()
71  << ": You should probably use the DualBzeroTrajectoryFactory\n"
72  << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
73  }
74 
75  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
76 
77  while (itTracks != tracks.end()) {
78  const DualTrajectoryInput input = this->referenceStateAndRecHits(*itTracks);
79  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
80  if (input.refTsos.isValid()) {
82  config.useBeamSpot = useBeamSpot_;
83  config.includeAPEs = includeAPEs_;
84  config.allowZeroMaterial = allowZeroMaterial_;
86  input.refTsos, input.fwdRecHits, input.bwdRecHits, magneticField.product(), beamSpot, config));
87  trajectories.push_back(ptr);
88  }
89 
90  ++itTracks;
91  }
92 
93  return trajectories;
94 }
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:48
config
Definition: looper.py:291
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.
T get() const
Definition: EventSetup.h:71
PropagationDirection propagationDirection(void) const
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
T const * product() const
Definition: ESHandle.h:86
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
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 96 of file DualTrajectoryFactory.cc.

References ReferenceTrajectoryBase::Config::allowZeroMaterial, TrajectoryFactoryBase::allowZeroMaterial_, ecalDrivenElectronSeedsParameters_cff::beamSpot, DualTrajectoryFactory::DualTrajectoryInput::bwdRecHits, looper::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().

100  {
102 
103  if (tracks.size() != external.size()) {
104  edm::LogInfo("ReferenceTrajectories")
105  << "@SUB=DualTrajectoryFactory::trajectories"
106  << "Inconsistent input:\n"
107  << "\tnumber of tracks = " << tracks.size() << "\tnumber of external predictions = " << external.size();
108  return trajectories;
109  }
110 
112  setup.get<IdealMagneticFieldRecord>().get(magneticField);
113  if (magneticField->inTesla(GlobalPoint(0., 0., 0.)).mag2() < 1.e-6) {
114  edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
115  << "B-field in z is " << magneticField->inTesla(GlobalPoint(0., 0., 0.)).z()
116  << ": You should probably use the DualBzeroTrajectoryFactory\n"
117  << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
118  }
119 
120  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
121  ExternalPredictionCollection::const_iterator itExternal = external.begin();
122 
123  while (itTracks != tracks.end()) {
124  const DualTrajectoryInput input = referenceStateAndRecHits(*itTracks);
125  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
126  if (input.refTsos.isValid()) {
127  if ((*itExternal).isValid()) {
128  TrajectoryStateOnSurface propExternal =
129  propagateExternal(*itExternal, input.refTsos.surface(), magneticField.product());
130 
131  if (!propExternal.isValid())
132  continue;
133 
135  config.useBeamSpot = useBeamSpot_;
136  config.includeAPEs = includeAPEs_;
137  config.allowZeroMaterial = allowZeroMaterial_;
139  propExternal, input.fwdRecHits, input.bwdRecHits, magneticField.product(), beamSpot, config));
140 
141  AlgebraicSymMatrix externalParamErrors(asHepMatrix<5>(propExternal.localError().matrix()));
142  ptr->setParameterErrors(externalParamErrors);
143  trajectories.push_back(ptr);
144  } else {
146  config.useBeamSpot = useBeamSpot_;
147  config.includeAPEs = includeAPEs_;
148  config.allowZeroMaterial = allowZeroMaterial_;
150  input.refTsos, input.fwdRecHits, input.bwdRecHits, magneticField.product(), beamSpot, config));
151  trajectories.push_back(ptr);
152  }
153  }
154 
155  ++itTracks;
156  ++itExternal;
157  }
158 
159  return trajectories;
160 }
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:48
config
Definition: looper.py:291
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.
T get() const
Definition: EventSetup.h:71
PropagationDirection propagationDirection(void) const
CLHEP::HepSymMatrix AlgebraicSymMatrix
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
T const * product() const
Definition: ESHandle.h:86
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection

Member Data Documentation

double DualTrajectoryFactory::theMass
protected