CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Public Attributes | 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, edm::ConsumesCollector &iC)
 
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, const edm::ConsumesCollector &iC)
 
 TrajectoryFactoryBase (const edm::ParameterSet &config, unsigned int tracksPerTrajectory, const edm::ConsumesCollector &iC)
 
virtual ~TrajectoryFactoryBase (void)
 

Public Attributes

const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordm_MagFieldToken
 

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::DualTrajectoryFactory ( const edm::ParameterSet config,
edm::ConsumesCollector iC 
)

Definition at line 55 of file DualTrajectoryFactory.cc.

References theMass.

Referenced by clone().

58  theMass(config.getParameter<double>("ParticleMass")) {
59  edm::LogInfo("Alignment") << "@SUB=DualTrajectoryFactory"
60  << "mass: " << theMass;
61 }
Definition: config.py:1
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagFieldToken
Log< level::Info, false > LogInfo
TrajectoryFactoryBase(const edm::ParameterSet &config, const edm::ConsumesCollector &iC)

◆ ~DualTrajectoryFactory()

DualTrajectoryFactory::~DualTrajectoryFactory ( void  )
override

Definition at line 63 of file DualTrajectoryFactory.cc.

63 {}

Member Function Documentation

◆ clone()

DualTrajectoryFactory* DualTrajectoryFactory::clone ( void  ) const
inlineoverridevirtual

Implements TrajectoryFactoryBase.

Definition at line 33 of file DualTrajectoryFactory.cc.

References DualTrajectoryFactory().

33 { return new DualTrajectoryFactory(*this); }
DualTrajectoryFactory(const edm::ParameterSet &config, edm::ConsumesCollector &iC)

◆ propagateExternal()

const TrajectoryStateOnSurface DualTrajectoryFactory::propagateExternal ( const TrajectoryStateOnSurface external,
const Surface surface,
const MagneticField magField 
) const
protected

Definition at line 207 of file DualTrajectoryFactory.cc.

References anyDirection, and TrackCandidateProducer_cfi::propagator.

Referenced by trajectories().

209  {
211  const std::pair<TrajectoryStateOnSurface, double> tsosWithPath = propagator.propagateWithPath(external, surface);
212  return tsosWithPath.first;
213 }

◆ referenceStateAndRecHits()

const DualTrajectoryFactory::DualTrajectoryInput DualTrajectoryFactory::referenceStateAndRecHits ( const ConstTrajTrackPair track) const
protected

Definition at line 163 of file DualTrajectoryFactory.cc.

References input, TrajectoryFactoryBase::orderedTrajectoryMeasurements(), groupFilesInBlocks::reverse, and TrajectoryFactoryBase::useRecHit().

Referenced by trajectories().

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

◆ trajectories() [1/2]

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

References TrajectoryFactoryBase::allowZeroMaterial_, pwdgSkimBPark_cfi::beamSpot, DiMuonV_cfg::config, TrajectoryFactoryBase::includeAPEs_, input, m_MagFieldToken, HLT_2024v13_cff::magneticField, TrajectoryFactoryBase::materialEffects(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), singleTopDQM_cfi::setup, theMass, DiMuonV_cfg::tracks, and TrajectoryFactoryBase::useBeamSpot_.

Referenced by trajectories().

66  {
68 
70 
71  if (magneticField->inTesla(GlobalPoint(0., 0., 0.)).mag2() < 1.e-6) {
72  edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
73  << "B-field in z is " << magneticField->inTesla(GlobalPoint(0., 0., 0.)).z()
74  << ": You should probably use the DualBzeroTrajectoryFactory\n"
75  << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
76  }
77 
78  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
79 
80  while (itTracks != tracks.end()) {
81  const DualTrajectoryInput input = this->referenceStateAndRecHits(*itTracks);
82  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
83  if (input.refTsos.isValid()) {
85  config.useBeamSpot = useBeamSpot_;
86  config.includeAPEs = includeAPEs_;
87  config.allowZeroMaterial = allowZeroMaterial_;
89  input.refTsos, input.fwdRecHits, input.bwdRecHits, magneticField, beamSpot, config));
90  trajectories.push_back(ptr);
91  }
92 
93  ++itTracks;
94  }
95 
96  return trajectories;
97 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Definition: config.py:1
const DualTrajectoryInput referenceStateAndRecHits(const ConstTrajTrackPair &track) const
MaterialEffects materialEffects(void) const
static std::string const input
Definition: EdmProvDump.cc:50
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagFieldToken
const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the reference trajectories.
dictionary config
Read in AllInOne config in JSON format.
Definition: DiMuonV_cfg.py:30
PropagationDirection propagationDirection(void) const
Log< level::Warning, false > LogWarning
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection

◆ trajectories() [2/2]

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

References TrajectoryFactoryBase::allowZeroMaterial_, pwdgSkimBPark_cfi::beamSpot, DiMuonV_cfg::config, TrajectoryFactoryBase::includeAPEs_, input, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), m_MagFieldToken, HLT_2024v13_cff::magneticField, TrajectoryFactoryBase::materialEffects(), LocalTrajectoryError::matrix(), propagateExternal(), TrajectoryFactoryBase::propagationDirection(), referenceStateAndRecHits(), singleTopDQM_cfi::setup, theMass, DiMuonV_cfg::tracks, trajectories(), and TrajectoryFactoryBase::useBeamSpot_.

103  {
105 
106  if (tracks.size() != external.size()) {
107  edm::LogInfo("ReferenceTrajectories")
108  << "@SUB=DualTrajectoryFactory::trajectories"
109  << "Inconsistent input:\n"
110  << "\tnumber of tracks = " << tracks.size() << "\tnumber of external predictions = " << external.size();
111  return trajectories;
112  }
114 
115  if (magneticField->inTesla(GlobalPoint(0., 0., 0.)).mag2() < 1.e-6) {
116  edm::LogWarning("Alignment") << "@SUB=DualTrajectoryFactory::trajectories"
117  << "B-field in z is " << magneticField->inTesla(GlobalPoint(0., 0., 0.)).z()
118  << ": You should probably use the DualBzeroTrajectoryFactory\n"
119  << "or fix this code to switch automatically as the ReferenceTrajectoryFactory does.";
120  }
121 
122  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
123  ExternalPredictionCollection::const_iterator itExternal = external.begin();
124 
125  while (itTracks != tracks.end()) {
126  const DualTrajectoryInput input = referenceStateAndRecHits(*itTracks);
127  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
128  if (input.refTsos.isValid()) {
129  if ((*itExternal).isValid()) {
130  TrajectoryStateOnSurface propExternal = propagateExternal(*itExternal, input.refTsos.surface(), magneticField);
131 
132  if (!propExternal.isValid())
133  continue;
134 
136  config.useBeamSpot = useBeamSpot_;
137  config.includeAPEs = includeAPEs_;
138  config.allowZeroMaterial = allowZeroMaterial_;
140  propExternal, input.fwdRecHits, input.bwdRecHits, magneticField, beamSpot, config));
141 
142  AlgebraicSymMatrix externalParamErrors(asHepMatrix<5>(propExternal.localError().matrix()));
143  ptr->setParameterErrors(externalParamErrors);
144  trajectories.push_back(ptr);
145  } else {
147  config.useBeamSpot = useBeamSpot_;
148  config.includeAPEs = includeAPEs_;
149  config.allowZeroMaterial = allowZeroMaterial_;
151  input.refTsos, input.fwdRecHits, input.bwdRecHits, magneticField, beamSpot, config));
152  trajectories.push_back(ptr);
153  }
154  }
155 
156  ++itTracks;
157  ++itExternal;
158  }
159 
160  return trajectories;
161 }
const TrajectoryStateOnSurface propagateExternal(const TrajectoryStateOnSurface &external, const Surface &surface, const MagneticField *magField) const
const LocalTrajectoryError & localError() const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Definition: config.py:1
const DualTrajectoryInput referenceStateAndRecHits(const ConstTrajTrackPair &track) const
MaterialEffects materialEffects(void) const
static std::string const input
Definition: EdmProvDump.cc:50
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_MagFieldToken
Log< level::Info, false > LogInfo
const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the reference trajectories.
const AlgebraicSymMatrix55 & matrix() const
CLHEP::HepSymMatrix AlgebraicSymMatrix
dictionary config
Read in AllInOne config in JSON format.
Definition: DiMuonV_cfg.py:30
PropagationDirection propagationDirection(void) const
Log< level::Warning, false > LogWarning
ReferenceTrajectoryBase::ReferenceTrajectoryPtr ReferenceTrajectoryPtr
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection

Member Data Documentation

◆ m_MagFieldToken

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> DualTrajectoryFactory::m_MagFieldToken

Definition at line 21 of file DualTrajectoryFactory.cc.

Referenced by trajectories().

◆ theMass

double DualTrajectoryFactory::theMass
protected

Definition at line 48 of file DualTrajectoryFactory.cc.

Referenced by DualTrajectoryFactory(), and trajectories().