CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BaseCkfTrajectoryBuilder.cc
Go to the documentation of this file.
2 
8 
9 
17 
21 
27 
30  TrajectoryFilter *inOutFilter):
31  theUpdator(nullptr),
32  thePropagatorAlong(nullptr),
33  thePropagatorOpposite(nullptr),
34  theEstimator(nullptr),
35  theTTRHBuilder(nullptr),
36  theMeasurementTracker(nullptr),
37  theFilter(filter),
38  theInOutFilter(inOutFilter),
39  theUpdatorName(conf.getParameter<std::string>("updator")),
40  thePropagatorAlongName(conf.getParameter<std::string>("propagatorAlong")),
41  thePropagatorOppositeName(conf.getParameter<std::string>("propagatorOpposite")),
42  theEstimatorName(conf.getParameter<std::string>("estimator")),
43  theRecHitBuilderName(conf.getParameter<std::string>("TTRHBuilder"))
44 {
45  if (conf.exists("clustersToSkip")) edm::LogError("BaseCkfTrajectoryBuilder") << "ERROR: " << typeid(*this).name() << " has a clustersToSkip parameter set";
46 }
47 
48 
50 }
51 
53  return TrajectoryFilterFactory::get()->create(pset.getParameter<std::string>("ComponentType"), pset, iC);
54 }
55 
56 void
58 {
59 
60 
61  TrajectorySeed::range hitRange = seed.recHits();
62 
63  PTrajectoryStateOnDet pState( seed.startingState());
64  const GeomDet* gdet = theMeasurementTracker->geomTracker()->idToDet(pState.detId());
65  TSOS outerState = trajectoryStateTransform::transientState(pState, &(gdet->surface()),
67 
68 
69  for (TrajectorySeed::const_iterator ihit = hitRange.first; ihit != hitRange.second; ihit++) {
70 
71  TrackingRecHit::RecHitPointer recHit = ihit->cloneSH();
72  const GeomDet* hitGeomDet = recHit->det();
73 
74  const DetLayer* hitLayer =
75  theMeasurementTracker->geometricSearchTracker()->detLayer(ihit->geographicalId());
76 
77  TSOS invalidState( hitGeomDet->surface());
78  if (ihit == hitRange.second - 1) {
79  // the seed trajectory state should correspond to this hit
80  if (&gdet->surface() != &hitGeomDet->surface()) {
81  edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: the seed state is not on the surface of the detector of the last seed hit";
82  return; // FIXME: should throw exception
83  }
84 
85  //TSOS updatedState = outerstate;
86  result.emplace(invalidState, outerState, recHit, 0, hitLayer);
87  }
88  else {
89  TSOS innerState = backwardPropagator(seed)->propagate(outerState,hitGeomDet->surface());
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 }
102 
103 
106 {
108  seedMeasurements(seed, result);
109 
110  LogDebug("CkfPattern")
111  <<" initial trajectory from the seed: "<<PrintoutHelper::dumpCandidate(result,true);
112 
113  return result;
114 }
115 
116 
118 {
119  if unlikely(traj.measurements().size() > 400) {
120  edm::LogError("BaseCkfTrajectoryBuilder_InfiniteLoop");
121  LogTrace("BaseCkfTrajectoryBuilder_InfiniteLoop") <<
122  "Cropping Track After 400 Measurements:\n" <<
123  " Last predicted state: " << traj.lastMeasurement().predictedState() << "\n" <<
124  " Last layer subdetector: " << (traj.lastLayer() ? traj.lastLayer()->subDetector() : -1) << "\n" <<
125  " Found hits: " << traj.foundHits() << ", lost hits: " << traj.lostHits() << "\n\n";
126  return false;
127  }
128  // Called after each new hit is added to the trajectory, to see if it is
129  // worth continuing to build this track candidate.
130  if (inOut) {
131  // if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
132  return theInOutFilter->toBeContinued(traj);
133  } else {
134  return theFilter->toBeContinued(traj);
135  }
136 }
137 
138 
139  bool BaseCkfTrajectoryBuilder::qualityFilter( const TempTrajectory& traj, bool inOut) const
140 {
141  // Called after building a trajectory is completed, to see if it is good enough
142  // to keep.
143  if (inOut) {
144  // if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
145  return theInOutFilter->qualityFilter(traj);
146  } else {
147  return theFilter->qualityFilter(traj);
148  }
149 }
150 
151 
152 void
153 BaseCkfTrajectoryBuilder::addToResult (boost::shared_ptr<const TrajectorySeed> const & seed, TempTrajectory& tmptraj,
155  bool inOut) const
156 {
157  // quality check
158  if ( !qualityFilter(tmptraj, inOut) ) return;
159  Trajectory traj = tmptraj.toTrajectory();
160  traj.setSharedSeed(seed);
161  // discard latest dummy measurements
162  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid()) traj.pop();
163  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a Trajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits()
164  <<" lost hits. Popped :"<<(tmptraj.measurements().size())-(traj.measurements().size())<<" hits.";
165  result.push_back(std::move(traj));
166 }
167 
168 
169 void
172  bool inOut) const
173 {
174  // quality check
175  if ( !qualityFilter(tmptraj, inOut) ) return;
176  // discard latest dummy measurements
177  TempTrajectory traj = tmptraj;
178  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid()) traj.pop();
179  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a TempTrajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits()
180  <<" lost hits. Popped :"<<(tmptraj.measurements().size())-(traj.measurements().size())<<" hits.";
181  result.push_back(std::move(traj));
182 }
183 
184 void
187  bool inOut) const
188 {
189  // quality check
190  if ( !qualityFilter(traj, inOut) ) return;
191  // discard latest dummy measurements
192  while (!traj.empty() && !traj.lastMeasurement().recHitR().isValid()) traj.pop();
193  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a TempTrajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits();
194  // <<" lost hits. Popped :"<<(ttraj.measurements().size())-(traj.measurements().size())<<" hits.";
195  result.push_back(std::move(traj));
196 }
197 
198 
199 
202 {
203  if (traj.empty())
204  {
205  //set the currentState to be the one from the trajectory seed starting point
206  PTrajectoryStateOnDet const & ptod = seed.startingState();
207  DetId id(ptod.detId());
209  const Surface * surface=&g->surface();
210 
211 
214  return StateAndLayers(currentState,theNavigationSchool->nextLayers(*lastLayer,*currentState.freeState(), traj.direction()) );
215  }
216  else
217  {
218  TSOS const & currentState = traj.lastMeasurement().updatedState();
219  return StateAndLayers(currentState,theNavigationSchool->nextLayers(*traj.lastLayer(), *currentState.freeState(), traj.direction()) );
220  }
221 }
222 
225  //assert(!traj.empty());
226  if ( traj.empty() ) {
227  edm::LogWarning("CkfPattern")<< "empty traj. Skipping.";
228  return StateAndLayers();
229  }
230 
231  TSOS const & currentState = traj.lastMeasurement().updatedState();
232  return StateAndLayers(currentState,theNavigationSchool->nextLayers(*traj.lastLayer(), *currentState.freeState(), traj.direction()) );
233 }
234 
235 
237 {
238  // possibly do some sanity check here
240 }
241 
243 {
244  std::cerr << "ERROR SetEvent called on " << typeid(*this).name() << ( theMeasurementTracker ? " with valid " : "witout any ") << "MeasurementTrackerEvent" << std::endl;
245 }
246 
248 {
249  std::cerr << "ERROR unSet called on " << typeid(*this).name() << ( theMeasurementTracker ? " with valid " : "witout any ") << "MeasurementTrackerEvent" << std::endl;
250 }
251 
254  edm::ESHandle<Propagator> propagatorAlongHandle;
255  edm::ESHandle<Propagator> propagatorOppositeHandle;
258 
259  iSetup.get<TrackingComponentsRecord>().get(theUpdatorName, updatorHandle);
260  iSetup.get<TrackingComponentsRecord>().get(thePropagatorAlongName, propagatorAlongHandle);
261  iSetup.get<TrackingComponentsRecord>().get(thePropagatorOppositeName, propagatorOppositeHandle);
262  iSetup.get<TrackingComponentsRecord>().get(theEstimatorName, estimatorHandle);
263  iSetup.get<TransientRecHitRecord>().get(theRecHitBuilderName, recHitBuilderHandle);
264 
265  theUpdator = updatorHandle.product();
266  thePropagatorAlong = propagatorAlongHandle.product();
267  thePropagatorOpposite = propagatorOppositeHandle.product();
268  theEstimator = estimatorHandle.product();
269  theTTRHBuilder = recHitBuilderHandle.product();
270 
271  setData(data);
272  if(theFilter) theFilter->setEvent(iEvent, iSetup);
273  if(theInOutFilter) theInOutFilter->setEvent(iEvent, iSetup);
274  setEvent_(iEvent, iSetup);
275 }
#define LogDebug(id)
PropagationDirection direction() const
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:244
T getParameter(std::string const &) const
int foundHits() const
Definition: Trajectory.h:234
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
int lostHits() const
Definition: Trajectory.h:241
const TrackingGeometry * geomTracker() const
TrajectoryStateOnSurface const & predictedState() const
ConstRecHitPointer const & recHit() const
bool empty() const
True if trajectory has no measurements.
void setData(const MeasurementTrackerEvent *data)
virtual void setEvent(const edm::Event &event) const
const Propagator * forwardPropagator(const TrajectorySeed &seed) const
static TrajectoryFilter * createTrajectoryFilter(const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
const DataContainer & measurements() const
bool exists(std::string const &parameterName) const
checks if a parameter exists
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
const TrajectoryStateUpdator * theUpdator
int foundHits() const
#define nullptr
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
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
const TrajectoryMeasurement & lastMeasurement() const
bool qualityFilter(const TempTrajectory &traj, bool inOut=false) const
#define unlikely(x)
virtual void setEvent_(const edm::Event &iEvent, const edm::EventSetup &iSetup)=0
PropagationDirection direction() const
DataContainer const & measurements() const
Definition: Trajectory.h:203
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const =0
int iEvent
Definition: GenABIO.cc:230
void seedMeasurements(const TrajectorySeed &seed, TempTrajectory &result) const
Trajectory toTrajectory() const
Convert to a standard Trajectory.
recHitContainer::const_iterator const_iterator
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
FreeTrajectoryState const * freeState(bool withErrors=true) const
const TransientTrackingRecHitBuilder * theTTRHBuilder
tuple result
Definition: query.py:137
const DetLayer * detLayer(const DetId &id) const
obsolete method. Use idToLayer() instead.
std::pair< const_iterator, const_iterator > range
std::unique_ptr< TrajectoryFilter > theInOutFilter
unsigned int detId() const
void addToResult(boost::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
const std::string thePropagatorAlongName
#define LogTrace(id)
BaseCkfTrajectoryBuilder(const edm::ParameterSet &conf, TrajectoryFilter *filter, TrajectoryFilter *inOutFilter=0)
static std::string dumpCandidate(const Candidate &candidate, bool showErrors=false)
std::shared_ptr< TrackingRecHit const > RecHitPointer
tuple conf
Definition: dbtoconf.py:185
void setSharedSeed(const boost::shared_ptr< const TrajectorySeed > &seed)
Definition: Trajectory.h:319
StateAndLayers findStateAndLayers(const TrajectorySeed &seed, const TempTrajectory &traj) const
const MeasurementTrackerEvent * theMeasurementTracker
Definition: DetId.h:18
PTrajectoryStateOnDet const & startingState() const
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
virtual const GeomDet * idToDet(DetId) const =0
void pop()
Definition: Trajectory.cc:12
std::vector< const DetLayer * > nextLayers(const DetLayer &detLayer, Args &&...args) const
NavigationDirection.
std::vector< TempTrajectory > TempTrajectoryContainer
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
range recHits() const
const Propagator * thePropagatorOpposite
void moveToResult(TempTrajectory &&traj, TempTrajectoryContainer &result, bool inOut=false) const
void emplace(Args &&...args)
virtual const MagneticField * magneticField() const =0
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
std::pair< TSOS, std::vector< const DetLayer * > > StateAndLayers
const NavigationSchool * theNavigationSchool
const Propagator * backwardPropagator(const TrajectorySeed &seed) const
TrajectoryStateOnSurface const & updatedState() const
size_type size() const
Definition: bqueue.h:167
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
const GeometricSearchTracker * geometricSearchTracker() const
std::vector< Trajectory > TrajectoryContainer
const std::string thePropagatorOppositeName
T get(const Candidate &c)
Definition: component.h:55
const Chi2MeasurementEstimatorBase * theEstimator
std::unique_ptr< TrajectoryFilter > theFilter
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
int lostHits() const