CMS 3D CMS Logo

BaseCkfTrajectoryBuilder.cc
Go to the documentation of this file.
2 
8 
16 
20 
26 
28  std::unique_ptr<TrajectoryFilter> filter,
29  std::unique_ptr<TrajectoryFilter> inOutFilter)
30  : theSeedAs5DHit(conf.getParameter<bool>("seedAs5DHit")),
31  theFilter(std::move(filter)),
32  theInOutFilter(std::move(inOutFilter)),
33  theUpdatorName(conf.getParameter<std::string>("updator")),
34  thePropagatorAlongName(conf.getParameter<std::string>("propagatorAlong")),
35  thePropagatorOppositeName(conf.getParameter<std::string>("propagatorOpposite")),
36  theEstimatorName(conf.getParameter<std::string>("estimator")),
37  theRecHitBuilderName(conf.getParameter<std::string>("TTRHBuilder")) {
38  if (conf.exists("clustersToSkip"))
39  edm::LogError("BaseCkfTrajectoryBuilder")
40  << "ERROR: " << typeid(*this).name() << " has a clustersToSkip parameter set";
41 }
42 
44 
47  return TrajectoryFilterFactory::get()->create(pset.getParameter<std::string>("ComponentType"), pset, iC);
48 }
49 
52  PTrajectoryStateOnDet pState(seed.startingState());
53  const GeomDet* gdet = theMeasurementTracker->geomTracker()->idToDet(pState.detId());
54  TSOS outerState =
56 
57  if (as5D) {
59  TSOS invalidState(gdet->surface());
60  auto hitLayer = theMeasurementTracker->geometricSearchTracker()->detLayer(pState.detId());
61  result.emplace(invalidState, outerState, recHit, 0, hitLayer);
62  return;
63  }
64 
65  for (auto ihit = seed.recHits().begin(); ihit != seed.recHits().end(); ihit++) {
66  TrackingRecHit::RecHitPointer recHit = ihit->cloneSH();
67  const GeomDet* hitGeomDet = recHit->det();
68 
69  const DetLayer* hitLayer = theMeasurementTracker->geometricSearchTracker()->detLayer(ihit->geographicalId());
70 
71  TSOS invalidState(hitGeomDet->surface());
72  if (ihit == seed.recHits().end() - 1) {
73  // the seed trajectory state should correspond to this hit
74  if (&gdet->surface() != &hitGeomDet->surface()) {
75  edm::LogError("CkfPattern")
76  << "CkfTrajectoryBuilder error: the seed state is not on the surface of the detector of the last seed hit";
77  return; // FIXME: should throw exception
78  }
79 
80  //TSOS updatedState = outerstate;
81  result.emplace(invalidState, outerState, recHit, 0, hitLayer);
82  } else {
83  TSOS innerState = backwardPropagator(seed)->propagate(outerState, hitGeomDet->surface());
84 
85  // try to recover if propagation failed
86  if UNLIKELY (!innerState.isValid())
88  pState, &(hitGeomDet->surface()), forwardPropagator(seed)->magneticField());
89 
90  if (innerState.isValid()) {
91  TSOS innerUpdated = theUpdator->update(innerState, *recHit);
92  result.emplace(invalidState, innerUpdated, recHit, 0, hitLayer);
93  }
94  }
95  }
96 
97  // method for debugging
98  // fix somehow
99  // fillSeedHistoDebugger(result.begin(),result.end());
100 }
101 
103  TempTrajectory result(seed.direction(), seed.nHits());
105 
106  LogDebug("CkfPattern") << " initial trajectory from the seed: " << PrintoutHelper::dumpCandidate(result, true);
107 
108  return result;
109 }
110 
112  if UNLIKELY (traj.measurements().size() > 400) {
113  edm::LogError("BaseCkfTrajectoryBuilder_InfiniteLoop");
114  LogTrace("BaseCkfTrajectoryBuilder_InfiniteLoop")
115  << "Cropping Track After 400 Measurements:\n"
116  << " Last predicted state: " << traj.lastMeasurement().predictedState() << "\n"
117  << " Last layer subdetector: " << (traj.lastLayer() ? traj.lastLayer()->subDetector() : -1) << "\n"
118  << " Found hits: " << traj.foundHits() << ", lost hits: " << traj.lostHits() << "\n\n";
119  return false;
120  }
121  // Called after each new hit is added to the trajectory, to see if it is
122  // worth continuing to build this track candidate.
123  if (inOut) {
124  // if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
125  return theInOutFilter->toBeContinued(traj);
126  } else {
127  return theFilter->toBeContinued(traj);
128  }
129 }
130 
131 bool BaseCkfTrajectoryBuilder::qualityFilter(const TempTrajectory& traj, bool inOut) const {
132  // Called after building a trajectory is completed, to see if it is good enough
133  // to keep.
134  if (inOut) {
135  // if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
136  return theInOutFilter->qualityFilter(traj);
137  } else {
138  return theFilter->qualityFilter(traj);
139  }
140 }
141 
142 void BaseCkfTrajectoryBuilder::addToResult(std::shared_ptr<const TrajectorySeed> const& seed,
143  TempTrajectory& tmptraj,
145  bool inOut) const {
146  // quality check
147  if (!qualityFilter(tmptraj, inOut))
148  return;
149  Trajectory traj = tmptraj.toTrajectory();
150  traj.setSharedSeed(seed);
151  // discard latest dummy measurements
152  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid())
153  traj.pop();
154  LogDebug("CkfPattern") << inOut << "=inOut option. pushing a Trajectory with: " << traj.foundHits() << " found hits. "
155  << traj.lostHits()
156  << " lost hits. Popped :" << (tmptraj.measurements().size()) - (traj.measurements().size())
157  << " hits.";
158  result.push_back(std::move(traj));
159 }
160 
163  bool inOut) const {
164  // quality check
165  if (!qualityFilter(tmptraj, inOut))
166  return;
167  // discard latest dummy measurements
168  TempTrajectory traj = tmptraj;
169  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid())
170  traj.pop();
171  LogDebug("CkfPattern") << inOut << "=inOut option. pushing a TempTrajectory with: " << traj.foundHits()
172  << " found hits. " << traj.lostHits()
173  << " lost hits. Popped :" << (tmptraj.measurements().size()) - (traj.measurements().size())
174  << " hits.";
175  result.push_back(std::move(traj));
176 }
177 
179  // quality check
180  if (!qualityFilter(traj, inOut))
181  return;
182  // discard latest dummy measurements
183  while (!traj.empty() && !traj.lastMeasurement().recHitR().isValid())
184  traj.pop();
185  LogDebug("CkfPattern") << inOut << "=inOut option. pushing a TempTrajectory with: " << traj.foundHits()
186  << " found hits. " << traj.lostHits();
187  // <<" lost hits. Popped :"<<(ttraj.measurements().size())-(traj.measurements().size())<<" hits.";
188  result.push_back(std::move(traj));
189 }
190 
192  const TrajectorySeed& seed, const TempTrajectory& traj) const {
193  if (traj.empty()) {
194  //set the currentState to be the one from the trajectory seed starting point
195  PTrajectoryStateOnDet const& ptod = seed.startingState();
196  DetId id(ptod.detId());
198  const Surface* surface = &g->surface();
199 
200  TSOS currentState(
203  return StateAndLayers(currentState,
204  theNavigationSchool->nextLayers(*lastLayer, *currentState.freeState(), traj.direction()));
205  } else {
206  TSOS const& currentState = traj.lastMeasurement().updatedState();
207  return StateAndLayers(
208  currentState, theNavigationSchool->nextLayers(*traj.lastLayer(), *currentState.freeState(), traj.direction()));
209  }
210 }
211 
213  // possibly do some sanity check here
215 }
216 
218  std::cerr << "ERROR SetEvent called on " << typeid(*this).name()
219  << (theMeasurementTracker ? " with valid " : "witout any ") << "MeasurementTrackerEvent" << std::endl;
220 }
221 
223  std::cerr << "ERROR unSet called on " << typeid(*this).name()
224  << (theMeasurementTracker ? " with valid " : "witout any ") << "MeasurementTrackerEvent" << std::endl;
225 }
226 
228  const edm::EventSetup& iSetup,
229  const MeasurementTrackerEvent* data) {
231  edm::ESHandle<Propagator> propagatorAlongHandle;
232  edm::ESHandle<Propagator> propagatorOppositeHandle;
235 
236  iSetup.get<TrackingComponentsRecord>().get(theUpdatorName, updatorHandle);
237  iSetup.get<TrackingComponentsRecord>().get(thePropagatorAlongName, propagatorAlongHandle);
238  iSetup.get<TrackingComponentsRecord>().get(thePropagatorOppositeName, propagatorOppositeHandle);
239  iSetup.get<TrackingComponentsRecord>().get(theEstimatorName, estimatorHandle);
240  iSetup.get<TransientRecHitRecord>().get(theRecHitBuilderName, recHitBuilderHandle);
241 
242  theUpdator = updatorHandle.product();
243  thePropagatorAlong = propagatorAlongHandle.product();
244  thePropagatorOpposite = propagatorOppositeHandle.product();
245  theEstimator = estimatorHandle.product();
246  theTTRHBuilder = recHitBuilderHandle.product();
247 
248  setData(data);
249  if (theFilter)
250  theFilter->setEvent(iEvent, iSetup);
251  if (theInOutFilter)
252  theInOutFilter->setEvent(iEvent, iSetup);
253  setEvent_(iEvent, iSetup);
254 }
BaseCkfTrajectoryBuilder::addToResult
void addToResult(std::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
Definition: BaseCkfTrajectoryBuilder.cc:142
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
Chi2MeasurementEstimatorBase.h
Propagator.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
electrons_cff.bool
bool
Definition: electrons_cff.py:366
TempTrajectory::direction
PropagationDirection direction() const
Definition: TempTrajectory.cc:118
MeasurementTrackerEvent.h
MessageLogger.h
GeomDet
Definition: GeomDet.h:27
BaseCkfTrajectoryBuilder::thePropagatorAlong
const Propagator * thePropagatorAlong
Definition: BaseCkfTrajectoryBuilder.h:171
TrajectoryFilter.h
ESHandle.h
DetLayer::subDetector
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel,...
DetLayer
Definition: DetLayer.h:21
BaseCkfTrajectoryBuilder::theFilter
std::unique_ptr< TrajectoryFilter > theFilter
Definition: BaseCkfTrajectoryBuilder.h:181
BaseCkfTrajectoryBuilder::setEvent
void setEvent(const edm::Event &event) const override
Definition: BaseCkfTrajectoryBuilder.cc:217
TempTrajectory
Definition: TempTrajectory.h:40
TransientRecHitRecord.h
BaseCkfTrajectoryBuilder::TrajectoryContainer
std::vector< Trajectory > TrajectoryContainer
Definition: BaseCkfTrajectoryBuilder.h:62
BaseCkfTrajectoryBuilder::theEstimator
const Chi2MeasurementEstimatorBase * theEstimator
Definition: BaseCkfTrajectoryBuilder.h:173
TransientRecHitRecord
Definition: TransientRecHitRecord.h:14
BaseCkfTrajectoryBuilder::findStateAndLayers
StateAndLayers findStateAndLayers(const TrajectorySeed &seed, const TempTrajectory &traj) const
Definition: BaseCkfTrajectoryBuilder.cc:191
MeasurementTrackerEvent::geomTracker
const TrackerGeometry * geomTracker() const
Definition: MeasurementTrackerEvent.h:72
Surface
Definition: Surface.h:36
BaseCkfTrajectoryBuilder::~BaseCkfTrajectoryBuilder
~BaseCkfTrajectoryBuilder() override
Definition: BaseCkfTrajectoryBuilder.cc:43
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
Propagator::magneticField
virtual const MagneticField * magneticField() const =0
TrackingRecHit::RecHitPointer
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: TrackingRecHit.h:24
Trajectory::foundHits
int foundHits() const
Definition: Trajectory.h:206
BaseCkfTrajectoryBuilder::qualityFilter
bool qualityFilter(const TempTrajectory &traj, bool inOut=false) const
Definition: BaseCkfTrajectoryBuilder.cc:131
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
BaseCkfTrajectoryBuilder::setData
void setData(const MeasurementTrackerEvent *data)
Definition: BaseCkfTrajectoryBuilder.cc:212
BaseCkfTrajectoryBuilder::theTTRHBuilder
const TransientTrackingRecHitBuilder * theTTRHBuilder
Definition: BaseCkfTrajectoryBuilder.h:174
Trajectory::lostHits
int lostHits() const
Definition: Trajectory.h:217
TrajectoryStateUpdator.h
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
TkTransientTrackingRecHitBuilder.h
BaseCkfTrajectoryBuilder::theSeedAs5DHit
bool theSeedAs5DHit
Definition: BaseCkfTrajectoryBuilder.h:179
TRecHit5DParamConstraint.h
BaseCkfTrajectoryBuilder::theInOutFilter
std::unique_ptr< TrajectoryFilter > theInOutFilter
Definition: BaseCkfTrajectoryBuilder.h:182
fileCollector.seed
seed
Definition: fileCollector.py:127
DetId
Definition: DetId.h:17
GeometricSearchTracker.h
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
BaseCkfTrajectoryBuilder::BaseCkfTrajectoryBuilder
BaseCkfTrajectoryBuilder(const edm::ParameterSet &conf, std::unique_ptr< TrajectoryFilter > filter, std::unique_ptr< TrajectoryFilter > inOutFilter=nullptr)
Definition: BaseCkfTrajectoryBuilder.cc:27
BaseCkfTrajectoryBuilder::toBeContinued
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
Definition: BaseCkfTrajectoryBuilder.cc:111
PTrajectoryStateOnDet::detId
unsigned int detId() const
Definition: PTrajectoryStateOnDet.h:65
TrajectoryMeasurement::predictedState
TrajectoryStateOnSurface const & predictedState() const
Definition: TrajectoryMeasurement.h:174
NavigationSchool::nextLayers
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&... args) const
Definition: NavigationSchool.h:33
TrajectoryStateOnSurface::freeState
FreeTrajectoryState const * freeState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:58
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
BaseCkfTrajectoryBuilder::createTrajectoryFilter
static std::unique_ptr< TrajectoryFilter > createTrajectoryFilter(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
Definition: BaseCkfTrajectoryBuilder.cc:45
cmsutils::bqueue::size
size_type size() const
Definition: bqueue.h:201
BaseCkfTrajectoryBuilder::theUpdator
const TrajectoryStateUpdator * theUpdator
Definition: BaseCkfTrajectoryBuilder.h:170
Trajectory::setSharedSeed
void setSharedSeed(const std::shared_ptr< const TrajectorySeed > &seed)
Definition: Trajectory.h:316
TempTrajectory::lastMeasurement
const TrajectoryMeasurement & lastMeasurement() const
Definition: TempTrajectory.h:159
LayerMeasurements.h
GeometricSearchTracker::detLayer
const DetLayer * detLayer(const DetId &id) const
obsolete method. Use idToLayer() instead.
Definition: GeometricSearchTracker.h:60
TempTrajectory::measurements
const DataContainer & measurements() const
Definition: TempTrajectory.h:177
BaseCkfTrajectoryBuilder::backwardPropagator
const Propagator * backwardPropagator(const TrajectorySeed &seed) const
Definition: BaseCkfTrajectoryBuilder.h:163
TempTrajectory::foundHits
int foundHits() const
Definition: TempTrajectory.h:184
edm::ESHandle< TrajectoryStateUpdator >
BaseCkfTrajectoryBuilder::thePropagatorAlongName
const std::string thePropagatorAlongName
Definition: BaseCkfTrajectoryBuilder.h:186
BaseCkfTrajectoryBuilder::theMeasurementTracker
const MeasurementTrackerEvent * theMeasurementTracker
Definition: BaseCkfTrajectoryBuilder.h:175
BaseCkfTrajectoryBuilder::moveToResult
void moveToResult(TempTrajectory &&traj, TempTrajectoryContainer &result, bool inOut=false) const
Definition: BaseCkfTrajectoryBuilder.cc:178
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
TrajectoryFilterFactory.h
BaseCkfTrajectoryBuilder::theUpdatorName
const std::string theUpdatorName
Definition: BaseCkfTrajectoryBuilder.h:185
BaseCkfTrajectoryBuilder::StateAndLayers
std::pair< TSOS, std::vector< const DetLayer * > > StateAndLayers
Definition: BaseCkfTrajectoryBuilder.h:59
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BaseCkfTrajectoryBuilder::TempTrajectoryContainer
std::vector< TempTrajectory > TempTrajectoryContainer
Definition: BaseCkfTrajectoryBuilder.h:63
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
PrintoutHelper::dumpCandidate
static std::string dumpCandidate(const Candidate &candidate, bool showErrors=false)
Definition: PrintoutHelper.h:25
BaseCkfTrajectoryBuilder::theRecHitBuilderName
const std::string theRecHitBuilderName
Definition: BaseCkfTrajectoryBuilder.h:189
TrajectoryStateUpdator::update
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
MeasurementTrackerEvent
Definition: MeasurementTrackerEvent.h:16
edm::ParameterSet
Definition: ParameterSet.h:47
BaseCkfTrajectoryBuilder::seedMeasurements
void seedMeasurements(const TrajectorySeed &seed, TempTrajectory &result, bool as5D) const
Definition: BaseCkfTrajectoryBuilder.cc:51
BaseCkfTrajectoryBuilder::thePropagatorOpposite
const Propagator * thePropagatorOpposite
Definition: BaseCkfTrajectoryBuilder.h:172
TempTrajectory::lostHits
int lostHits() const
Definition: TempTrajectory.h:194
TempTrajectory::toTrajectory
Trajectory toTrajectory() const
Convert to a standard Trajectory.
Definition: TempTrajectory.cc:176
MeasurementTrackerEvent::geometricSearchTracker
const GeometricSearchTracker * geometricSearchTracker() const
Definition: MeasurementTrackerEvent.h:73
BaseCkfTrajectoryBuilder::setEvent_
virtual void setEvent_(const edm::Event &iEvent, const edm::EventSetup &iSetup)=0
Trajectory::lastMeasurement
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:150
iEvent
int iEvent
Definition: GenABIO.cc:224
trajectoryStateTransform::transientState
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
Definition: TrajectoryStateTransform.cc:35
BaseCkfTrajectoryBuilder::theNavigationSchool
const NavigationSchool * theNavigationSchool
Definition: BaseCkfTrajectoryBuilder.h:176
BaseCkfTrajectoryBuilder::forwardPropagator
const Propagator * forwardPropagator(const TrajectorySeed &seed) const
Definition: BaseCkfTrajectoryBuilder.h:160
edm::EventSetup
Definition: EventSetup.h:58
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
Trajectory::pop
void pop()
Definition: Trajectory.cc:30
get
#define get
Trajectory::measurements
DataContainer const & measurements() const
Definition: Trajectory.h:178
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
BaseCkfTrajectoryBuilder::unset
void unset() const override
Definition: BaseCkfTrajectoryBuilder.cc:222
Trajectory.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
BaseCkfTrajectoryBuilder::thePropagatorOppositeName
const std::string thePropagatorOppositeName
Definition: BaseCkfTrajectoryBuilder.h:187
Trajectory
Definition: Trajectory.h:38
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
TrackingComponentsRecord.h
BaseCkfTrajectoryBuilder.h
TrajectorySeed
Definition: TrajectorySeed.h:18
EventSetup.h
TempTrajectory::lastLayer
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
Definition: TempTrajectory.h:237
TrajectoryStateTransform.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
mps_fire.result
result
Definition: mps_fire.py:311
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
NavigationSchool.h
TRecHit5DParamConstraint
Definition: TRecHit5DParamConstraint.h:9
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
BaseCkfTrajectoryBuilder::theEstimatorName
const std::string theEstimatorName
Definition: BaseCkfTrajectoryBuilder.h:188
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
edm::Log
Definition: MessageLogger.h:70
TempTrajectory.h
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
TempTrajectory::pop
void pop()
Definition: TempTrajectory.cc:44
BaseCkfTrajectoryBuilder::createStartingTrajectory
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
Definition: BaseCkfTrajectoryBuilder.cc:102
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MeasurementTracker.h
TempTrajectory::empty
bool empty() const
True if trajectory has no measurements.
Definition: TempTrajectory.h:210
Trajectory::empty
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:233
TrackingComponentsRecord
Definition: TrackingComponentsRecord.h:12