test
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 
91  // try to recover if propagation failed
92  if unlikely(!innerState.isValid())
93  innerState =
94  trajectoryStateTransform::transientState(pState, &(hitGeomDet->surface()),
96 
97  if(innerState.isValid()) {
98  TSOS innerUpdated = theUpdator->update(innerState,*recHit);
99  result.emplace(invalidState, innerUpdated, recHit, 0, hitLayer);
100  }
101  }
102  }
103 
104  // method for debugging
105  // fix somehow
106  // fillSeedHistoDebugger(result.begin(),result.end());
107 
108 }
109 
110 
113 {
115  seedMeasurements(seed, result);
116 
117  LogDebug("CkfPattern")
118  <<" initial trajectory from the seed: "<<PrintoutHelper::dumpCandidate(result,true);
119 
120  return result;
121 }
122 
123 
125 {
126  if unlikely(traj.measurements().size() > 400) {
127  edm::LogError("BaseCkfTrajectoryBuilder_InfiniteLoop");
128  LogTrace("BaseCkfTrajectoryBuilder_InfiniteLoop") <<
129  "Cropping Track After 400 Measurements:\n" <<
130  " Last predicted state: " << traj.lastMeasurement().predictedState() << "\n" <<
131  " Last layer subdetector: " << (traj.lastLayer() ? traj.lastLayer()->subDetector() : -1) << "\n" <<
132  " Found hits: " << traj.foundHits() << ", lost hits: " << traj.lostHits() << "\n\n";
133  return false;
134  }
135  // Called after each new hit is added to the trajectory, to see if it is
136  // worth continuing to build this track candidate.
137  if (inOut) {
138  // if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
139  return theInOutFilter->toBeContinued(traj);
140  } else {
141  return theFilter->toBeContinued(traj);
142  }
143 }
144 
145 
146  bool BaseCkfTrajectoryBuilder::qualityFilter( const TempTrajectory& traj, bool inOut) const
147 {
148  // Called after building a trajectory is completed, to see if it is good enough
149  // to keep.
150  if (inOut) {
151  // if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
152  return theInOutFilter->qualityFilter(traj);
153  } else {
154  return theFilter->qualityFilter(traj);
155  }
156 }
157 
158 
159 void
160 BaseCkfTrajectoryBuilder::addToResult (boost::shared_ptr<const TrajectorySeed> const & seed, TempTrajectory& tmptraj,
162  bool inOut) const
163 {
164  // quality check
165  if ( !qualityFilter(tmptraj, inOut) ) return;
166  Trajectory traj = tmptraj.toTrajectory();
167  traj.setSharedSeed(seed);
168  // discard latest dummy measurements
169  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid()) traj.pop();
170  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a Trajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits()
171  <<" lost hits. Popped :"<<(tmptraj.measurements().size())-(traj.measurements().size())<<" hits.";
172  result.push_back(std::move(traj));
173 }
174 
175 
176 void
179  bool inOut) const
180 {
181  // quality check
182  if ( !qualityFilter(tmptraj, inOut) ) return;
183  // discard latest dummy measurements
184  TempTrajectory traj = tmptraj;
185  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid()) traj.pop();
186  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a TempTrajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits()
187  <<" lost hits. Popped :"<<(tmptraj.measurements().size())-(traj.measurements().size())<<" hits.";
188  result.push_back(std::move(traj));
189 }
190 
191 void
194  bool inOut) const
195 {
196  // quality check
197  if ( !qualityFilter(traj, inOut) ) return;
198  // discard latest dummy measurements
199  while (!traj.empty() && !traj.lastMeasurement().recHitR().isValid()) traj.pop();
200  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a TempTrajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits();
201  // <<" lost hits. Popped :"<<(ttraj.measurements().size())-(traj.measurements().size())<<" hits.";
202  result.push_back(std::move(traj));
203 }
204 
205 
206 
209 {
210  if (traj.empty())
211  {
212  //set the currentState to be the one from the trajectory seed starting point
213  PTrajectoryStateOnDet const & ptod = seed.startingState();
214  DetId id(ptod.detId());
216  const Surface * surface=&g->surface();
217 
218 
221  return StateAndLayers(currentState,theNavigationSchool->nextLayers(*lastLayer,*currentState.freeState(), traj.direction()) );
222  }
223  else
224  {
225  TSOS const & currentState = traj.lastMeasurement().updatedState();
226  return StateAndLayers(currentState,theNavigationSchool->nextLayers(*traj.lastLayer(), *currentState.freeState(), traj.direction()) );
227  }
228 }
229 
232  //assert(!traj.empty());
233  if ( traj.empty() ) {
234  edm::LogWarning("CkfPattern")<< "empty traj. Skipping.";
235  return StateAndLayers();
236  }
237 
238  TSOS const & currentState = traj.lastMeasurement().updatedState();
239  return StateAndLayers(currentState,theNavigationSchool->nextLayers(*traj.lastLayer(), *currentState.freeState(), traj.direction()) );
240 }
241 
242 
244 {
245  // possibly do some sanity check here
247 }
248 
250 {
251  std::cerr << "ERROR SetEvent called on " << typeid(*this).name() << ( theMeasurementTracker ? " with valid " : "witout any ") << "MeasurementTrackerEvent" << std::endl;
252 }
253 
255 {
256  std::cerr << "ERROR unSet called on " << typeid(*this).name() << ( theMeasurementTracker ? " with valid " : "witout any ") << "MeasurementTrackerEvent" << std::endl;
257 }
258 
261  edm::ESHandle<Propagator> propagatorAlongHandle;
262  edm::ESHandle<Propagator> propagatorOppositeHandle;
265 
266  iSetup.get<TrackingComponentsRecord>().get(theUpdatorName, updatorHandle);
267  iSetup.get<TrackingComponentsRecord>().get(thePropagatorAlongName, propagatorAlongHandle);
268  iSetup.get<TrackingComponentsRecord>().get(thePropagatorOppositeName, propagatorOppositeHandle);
269  iSetup.get<TrackingComponentsRecord>().get(theEstimatorName, estimatorHandle);
270  iSetup.get<TransientRecHitRecord>().get(theRecHitBuilderName, recHitBuilderHandle);
271 
272  theUpdator = updatorHandle.product();
273  thePropagatorAlong = propagatorAlongHandle.product();
274  thePropagatorOpposite = propagatorOppositeHandle.product();
275  theEstimator = estimatorHandle.product();
276  theTTRHBuilder = recHitBuilderHandle.product();
277 
278  setData(data);
279  if(theFilter) theFilter->setEvent(iEvent, iSetup);
280  if(theInOutFilter) theInOutFilter->setEvent(iEvent, iSetup);
281  setEvent_(iEvent, iSetup);
282 }
#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
def move
Definition: eostools.py:510
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:56
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