CMS 3D CMS Logo

DualBzeroTrajectoryFactory.cc
Go to the documentation of this file.
8 
9 #include <algorithm>
10 
12 
14 
16 
18 public:
20  ~DualBzeroTrajectoryFactory() override;
21 
25  const reco::BeamSpot &beamSpot) const override;
26 
30  const reco::BeamSpot &beamSpot) const override;
31 
32  DualBzeroTrajectoryFactory *clone() const override { return new DualBzeroTrajectoryFactory(*this); }
33 
34 protected:
39  };
40 
42 
44  const Surface &surface,
45  const MagneticField *magField) const;
46 
47  double theMass;
49 };
50 
54 
57  theMass = config.getParameter<double>("ParticleMass");
58  theMomentumEstimate = config.getParameter<double>("MomentumEstimate");
59 }
60 
62 
66 
69 
70  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
71 
72  while (itTracks != tracks.end()) {
74  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
75  if (input.refTsos.isValid()) {
77  config.useBeamSpot = useBeamSpot_;
78  config.includeAPEs = includeAPEs_;
79  config.allowZeroMaterial = allowZeroMaterial_;
81  input.refTsos, input.fwdRecHits, input.bwdRecHits, magneticField.product(), beamSpot, config));
82  trajectories.push_back(ptr);
83  }
84 
85  ++itTracks;
86  }
87 
88  return trajectories;
89 }
90 
92  const edm::EventSetup &setup,
95  const reco::BeamSpot &beamSpot) const {
97 
98  if (tracks.size() != external.size()) {
99  edm::LogInfo("ReferenceTrajectories")
100  << "@SUB=DualBzeroTrajectoryFactory::trajectories"
101  << "Inconsistent input:\n"
102  << "\tnumber of tracks = " << tracks.size() << "\tnumber of external predictions = " << external.size();
103  return trajectories;
104  }
105 
108 
109  ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
110  ExternalPredictionCollection::const_iterator itExternal = external.begin();
111 
112  while (itTracks != tracks.end()) {
114  // Check input: If all hits were rejected, the TSOS is initialized as invalid.
115  if (input.refTsos.isValid()) {
116  if ((*itExternal).isValid()) {
117  TrajectoryStateOnSurface propExternal =
118  propagateExternal(*itExternal, input.refTsos.surface(), magneticField.product());
119 
120  if (!propExternal.isValid())
121  continue;
122 
124  config.useBeamSpot = useBeamSpot_;
125  config.includeAPEs = includeAPEs_;
126  config.allowZeroMaterial = allowZeroMaterial_;
128  propExternal, input.fwdRecHits, input.bwdRecHits, magneticField.product(), beamSpot, config));
129 
130  AlgebraicSymMatrix externalParamErrors(asHepMatrix<5>(propExternal.localError().matrix()));
131  ptr->setParameterErrors(externalParamErrors.sub(2, 5));
132  trajectories.push_back(ptr);
133  } else {
135  config.useBeamSpot = useBeamSpot_;
136  config.includeAPEs = includeAPEs_;
137  config.allowZeroMaterial = allowZeroMaterial_;
139  input.refTsos, input.fwdRecHits, input.bwdRecHits, magneticField.product(), beamSpot, config));
140 
141  trajectories.push_back(ptr);
142  }
143  }
144 
145  ++itTracks;
146  ++itExternal;
147  }
148 
149  return trajectories;
150 }
151 
153  const ConstTrajTrackPair &track) const {
155 
156  // get the trajectory measurements in the correct order, i.e. reverse if needed
157  Trajectory::DataContainer allTrajMeas = this->orderedTrajectoryMeasurements(*track.first);
158  Trajectory::DataContainer usedTrajMeas;
159  Trajectory::DataContainer::iterator itM;
160  // get all relevant trajectory measurements
161  for (itM = allTrajMeas.begin(); itM != allTrajMeas.end(); itM++) {
162  if (useRecHit((*itM).recHit()))
163  usedTrajMeas.push_back(*itM);
164  }
165 
166  unsigned int iMeas = 0;
167  unsigned int nMeas = usedTrajMeas.size();
168  unsigned int nRefStateMeas = nMeas / 2;
169  // get the valid RecHits
170  for (itM = usedTrajMeas.begin(); itM != usedTrajMeas.end(); itM++, iMeas++) {
171  TransientTrackingRecHit::ConstRecHitPointer aRecHit = (*itM).recHit();
172 
173  if (iMeas < nRefStateMeas) {
174  input.bwdRecHits.push_back(aRecHit);
175  } else if (iMeas > nRefStateMeas) {
176  input.fwdRecHits.push_back(aRecHit);
177  } else { // iMeas == nRefStateMeas
178  if ((*itM).updatedState().isValid()) {
179  input.refTsos = (*itM).updatedState();
180  input.bwdRecHits.push_back(aRecHit);
181  input.fwdRecHits.push_back(aRecHit);
182  } else {
183  // if the tsos of the middle hit is not valid, try the next one ...
184  nRefStateMeas++;
185  input.bwdRecHits.push_back(aRecHit);
186  }
187  }
188  }
189 
190  // bring input.fwdRecHits into correct order
191  std::reverse(input.bwdRecHits.begin(), input.bwdRecHits.end());
192 
193  return input;
194 }
195 
197  const Surface &surface,
198  const MagneticField *magField) const {
200  const std::pair<TrajectoryStateOnSurface, double> tsosWithPath = propagator.propagateWithPath(external, surface);
201  return tsosWithPath.first;
202 }
203 
TrajectoryFactoryBase::useRecHit
bool useRecHit(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
Definition: TrajectoryFactoryBase.cc:94
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
anyDirection
Definition: PropagationDirection.h:4
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
ESHandle.h
HLT_2018_cff.magneticField
magneticField
Definition: HLT_2018_cff.py:348
DualBzeroTrajectoryFactory::trajectories
const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup, const ConstTrajTrackPairCollection &tracks, const reco::BeamSpot &beamSpot) const override
Produce the reference trajectories.
Definition: DualBzeroTrajectoryFactory.cc:63
edm::LogInfo
Definition: MessageLogger.h:254
TrajectoryFactoryBase::includeAPEs_
const bool includeAPEs_
Definition: TrajectoryFactoryBase.h:71
Surface
Definition: Surface.h:36
DualBzeroTrajectoryFactory::~DualBzeroTrajectoryFactory
~DualBzeroTrajectoryFactory() override
Definition: DualBzeroTrajectoryFactory.cc:61
DualBzeroTrajectoryFactory::theMomentumEstimate
double theMomentumEstimate
Definition: DualBzeroTrajectoryFactory.cc:48
ReferenceTrajectoryBase::Config
Definition: ReferenceTrajectoryBase.h:121
LocalTrajectoryError::matrix
const AlgebraicSymMatrix55 & matrix() const
Definition: LocalTrajectoryError.h:60
ReferenceCountingPointer
Definition: ReferenceCounted.h:60
DualBzeroTrajectoryFactory::propagateExternal
const TrajectoryStateOnSurface propagateExternal(const TrajectoryStateOnSurface &external, const Surface &surface, const MagneticField *magField) const
Definition: DualBzeroTrajectoryFactory.cc:196
DualBzeroTrajectoryFactory
A factory that produces instances of class ReferenceTrajectory from a given TrajTrackPairCollection.
Definition: DualBzeroTrajectoryFactory.cc:17
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
groupFilesInBlocks.reverse
reverse
Definition: groupFilesInBlocks.py:131
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
config
Definition: config.py:1
external
Definition: HEPTopTaggerV2.h:20
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
DualBzeroTrajectoryFactory::theMass
double theMass
Definition: DualBzeroTrajectoryFactory.cc:47
DualBzeroTrajectoryFactory::clone
DualBzeroTrajectoryFactory * clone() const override
Definition: DualBzeroTrajectoryFactory.cc:32
Trajectory::DataContainer
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:40
TrajectoryFactoryBase::ConstTrajTrackPair
AlignmentAlgorithmBase::ConstTrajTrackPair ConstTrajTrackPair
Definition: TrajectoryFactoryBase.h:24
TrajectoryFactoryBase::useBeamSpot_
const bool useBeamSpot_
Definition: TrajectoryFactoryBase.h:70
DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::fwdRecHits
TransientTrackingRecHit::ConstRecHitContainer fwdRecHits
Definition: DualBzeroTrajectoryFactory.cc:37
reco::BeamSpot
Definition: BeamSpot.h:21
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
TrajectoryFactoryBase::propagationDirection
PropagationDirection propagationDirection(void) const
Definition: TrajectoryFactoryBase.h:46
looper.config
config
Definition: looper.py:291
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DualBzeroReferenceTrajectory.h
TrajectoryFactoryBase::ReferenceTrajectoryCollection
std::vector< ReferenceTrajectoryPtr > ReferenceTrajectoryCollection
Definition: TrajectoryFactoryBase.h:26
edm::ParameterSet
Definition: ParameterSet.h:36
TrackingRecHit::ConstRecHitContainer
std::vector< ConstRecHitPointer > ConstRecHitContainer
Definition: TrackingRecHit.h:32
TrajectoryFactoryBase
Definition: TrajectoryFactoryBase.h:20
TrajectoryFactoryPlugin.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DualBzeroTrajectoryFactory::referenceStateAndRecHits
const DualBzeroTrajectoryInput referenceStateAndRecHits(const ConstTrajTrackPair &track) const
Definition: DualBzeroTrajectoryFactory.cc:152
DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::bwdRecHits
TransientTrackingRecHit::ConstRecHitContainer bwdRecHits
Definition: DualBzeroTrajectoryFactory.cc:38
TrackingRecHit::ConstRecHitPointer
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
Definition: TrackingRecHit.h:25
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
edm::EventSetup
Definition: EventSetup.h:57
AnalyticalPropagator.h
TrajectoryFactoryBase::materialEffects
MaterialEffects materialEffects(void) const
Definition: TrajectoryFactoryBase.h:45
get
#define get
TrajectoryFactoryBase::allowZeroMaterial_
const bool allowZeroMaterial_
Definition: TrajectoryFactoryBase.h:72
DualBzeroTrajectoryFactory::DualBzeroTrajectoryFactory
DualBzeroTrajectoryFactory(const edm::ParameterSet &config)
Definition: DualBzeroTrajectoryFactory.cc:55
AnalyticalPropagator
Definition: AnalyticalPropagator.h:22
TrajectoryFactoryBase::ConstTrajTrackPairCollection
AlignmentAlgorithmBase::ConstTrajTrackPairCollection ConstTrajTrackPairCollection
Definition: TrajectoryFactoryBase.h:25
DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput::refTsos
TrajectoryStateOnSurface refTsos
Definition: DualBzeroTrajectoryFactory.cc:36
DualBzeroReferenceTrajectory
Definition: DualBzeroReferenceTrajectory.h:37
EventSetup.h
DualBzeroTrajectoryFactory::DualBzeroTrajectoryInput
Definition: DualBzeroTrajectoryFactory.cc:35
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
ParameterSet.h
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
MagneticField
Definition: MagneticField.h:19
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
TrajectoryFactoryBase.h
TrajectoryFactoryBase::orderedTrajectoryMeasurements
virtual const Trajectory::DataContainer orderedTrajectoryMeasurements(const Trajectory &trajectory) const
Definition: TrajectoryFactoryBase.cc:65
TrajectoryFactoryBase::ExternalPredictionCollection
std::vector< TrajectoryStateOnSurface > ExternalPredictionCollection
Definition: TrajectoryFactoryBase.h:28