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 
15 
19 
21 
22 
25  const TrajectoryStateUpdator* updator,
26  const Propagator* propagatorAlong,
27  const Propagator* propagatorOpposite,
28  const Chi2MeasurementEstimatorBase* estimator,
29  const TransientTrackingRecHitBuilder* recHitBuilder,
30  const TrajectoryFilter* filter,
31  const TrajectoryFilter* inOutFilter):
32  theUpdator(updator),
33  thePropagatorAlong(propagatorAlong),thePropagatorOpposite(propagatorOpposite),
34  theEstimator(estimator),theTTRHBuilder(recHitBuilder),
35  theMeasurementTracker(0),
36  theForwardPropagator(0),theBackwardPropagator(0),
37  theFilter(filter),
38  theInOutFilter(inOutFilter)
39 {
40  if (conf.exists("clustersToSkip")) std::cerr << "ERROR: " << typeid(*this).name() << " with label " << conf.getParameter<std::string>("@module_label") << " has a clustersToSkip parameter set" << std::endl;
41 }
42 
43 
45 }
46 
47 
48 void
50 {
51 
52 
53  TrajectorySeed::range hitRange = seed.recHits();
54 
55  PTrajectoryStateOnDet pState( seed.startingState());
56  const GeomDet* gdet = theMeasurementTracker->geomTracker()->idToDet(pState.detId());
57  TSOS outerState = trajectoryStateTransform::transientState(pState, &(gdet->surface()),
59 
60 
61  for (TrajectorySeed::const_iterator ihit = hitRange.first; ihit != hitRange.second; ihit++) {
62 
64  const GeomDet* hitGeomDet = recHit->det();
65 
66  const DetLayer* hitLayer =
67  theMeasurementTracker->geometricSearchTracker()->detLayer(ihit->geographicalId());
68 
69  TSOS invalidState( hitGeomDet->surface());
70  if (ihit == hitRange.second - 1) {
71  // the seed trajectory state should correspond to this hit
72  if (&gdet->surface() != &hitGeomDet->surface()) {
73  edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: the seed state is not on the surface of the detector of the last seed hit";
74  return; // FIXME: should throw exception
75  }
76 
77  //TSOS updatedState = outerstate;
78  result.emplace(invalidState, outerState, recHit, 0, hitLayer);
79  }
80  else {
81  TSOS innerState = theBackwardPropagator->propagate(outerState,hitGeomDet->surface());
82  if(innerState.isValid()) {
83  TSOS innerUpdated = theUpdator->update(innerState,*recHit);
84  result.emplace(invalidState, innerUpdated, recHit, 0, hitLayer);
85  }
86  }
87  }
88 
89  // method for debugging
90  // fix somehow
91  // fillSeedHistoDebugger(result.begin(),result.end());
92 
93 }
94 
95 
98 {
100  if ( seed.direction() == alongMomentum) {
101  theForwardPropagator = &(*thePropagatorAlong);
102  theBackwardPropagator = &(*thePropagatorOpposite);
103  }
104  else {
105  theForwardPropagator = &(*thePropagatorOpposite);
106  theBackwardPropagator = &(*thePropagatorAlong);
107  }
108 
109  seedMeasurements(seed, result);
110 
111  LogDebug("CkfPattern")
112  <<" initial trajectory from the seed: "<<PrintoutHelper::dumpCandidate(result,true);
113 
114  return result;
115 }
116 
117 
119 {
120  if (traj.measurements().size() > 400) {
121  edm::LogError("BaseCkfTrajectoryBuilder_InfiniteLoop");
122  LogTrace("BaseCkfTrajectoryBuilder_InfiniteLoop") <<
123  "Cropping Track After 400 Measurements:\n" <<
124  " Last predicted state: " << traj.lastMeasurement().predictedState() << "\n" <<
125  " Last layer subdetector: " << (traj.lastLayer() ? traj.lastLayer()->subDetector() : -1) << "\n" <<
126  " Found hits: " << traj.foundHits() << ", lost hits: " << traj.lostHits() << "\n\n";
127  return false;
128  }
129  // Called after each new hit is added to the trajectory, to see if it is
130  // worth continuing to build this track candidate.
131  if (inOut) {
132  if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
133  return theInOutFilter->toBeContinued(traj);
134  } else {
135  return theFilter->toBeContinued(traj);
136  }
137 }
138 
139 
140  bool BaseCkfTrajectoryBuilder::qualityFilter( const TempTrajectory& traj, bool inOut) const
141 {
142  // Called after building a trajectory is completed, to see if it is good enough
143  // to keep.
144  if (inOut) {
145  if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
146  return theInOutFilter->qualityFilter(traj);
147  } else {
148  return theFilter->qualityFilter(traj);
149  }
150 }
151 
152 
153 void
154 BaseCkfTrajectoryBuilder::addToResult (boost::shared_ptr<const TrajectorySeed> const & seed, TempTrajectory& tmptraj,
156  bool inOut) const
157 {
158  // quality check
159  if ( !qualityFilter(tmptraj, inOut) ) return;
160  Trajectory traj = tmptraj.toTrajectory();
161  traj.setSharedSeed(seed);
162  // discard latest dummy measurements
163  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid()) traj.pop();
164  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a Trajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits()
165  <<" lost hits. Popped :"<<(tmptraj.measurements().size())-(traj.measurements().size())<<" hits.";
166  result.push_back(std::move(traj));
167 }
168 
169 
170 void
173  bool inOut) const
174 {
175  // quality check
176  if ( !qualityFilter(tmptraj, inOut) ) return;
177  // discard latest dummy measurements
178  TempTrajectory traj = tmptraj;
179  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid()) traj.pop();
180  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a TempTrajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits()
181  <<" lost hits. Popped :"<<(tmptraj.measurements().size())-(traj.measurements().size())<<" hits.";
182  result.push_back(std::move(traj));
183 }
184 
185 void
188  bool inOut) const
189 {
190  // quality check
191  if ( !qualityFilter(traj, inOut) ) return;
192  // discard latest dummy measurements
193  while (!traj.empty() && !traj.lastMeasurement().recHitR().isValid()) traj.pop();
194  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a TempTrajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits();
195  // <<" lost hits. Popped :"<<(ttraj.measurements().size())-(traj.measurements().size())<<" hits.";
196  result.push_back(std::move(traj));
197 }
198 
199 
200 
203 {
204  if (traj.empty())
205  {
206  //set the currentState to be the one from the trajectory seed starting point
207  PTrajectoryStateOnDet const & ptod = seed.startingState();
208  DetId id(ptod.detId());
210  const Surface * surface=&g->surface();
211 
212 
215  return StateAndLayers(currentState,lastLayer->nextLayers( *currentState.freeState(), traj.direction()) );
216  }
217  else
218  {
219  TSOS const & currentState = traj.lastMeasurement().updatedState();
220  return StateAndLayers(currentState,traj.lastLayer()->nextLayers( *currentState.freeState(), traj.direction()) );
221  }
222 }
223 
226  assert(!traj.empty());
227 
228  TSOS const & currentState = traj.lastMeasurement().updatedState();
229  return StateAndLayers(currentState,traj.lastLayer()->nextLayers( *currentState.freeState(), traj.direction()) );
230 }
231 
232 
234 {
235  // possibly do some sanity check here
237 }
238 
240 {
241  std::cerr << "ERROR SetEvent called on " << typeid(*this).name() << ( theMeasurementTracker ? " with valid " : "witout any ") << "MeasurementTrackerEvent" << std::endl;
242 }
243 
245 {
246  std::cerr << "ERROR unSet called on " << typeid(*this).name() << ( theMeasurementTracker ? " with valid " : "witout any ") << "MeasurementTrackerEvent" << std::endl;
247 }
#define LogDebug(id)
PropagationDirection direction() const
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:246
T getParameter(std::string const &) const
int foundHits() const
Definition: Trajectory.h:236
int lostHits() const
Definition: Trajectory.h:243
const TrackingGeometry * geomTracker() const
TrajectoryStateOnSurface const & predictedState() const
ConstRecHitPointer const & recHit() const
const Propagator * theBackwardPropagator
bool empty() const
True if trajectory has no measurements.
void setData(const MeasurementTrackerEvent *data)
virtual void setEvent(const edm::Event &event) const
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const =0
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
obsolete name, use measurements() instead.
const TrajectoryFilter * theFilter
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
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
PropagationDirection direction() const
DataContainer const & measurements() const
Definition: Trajectory.h:215
void seedMeasurements(const TrajectorySeed &seed, TempTrajectory &result) const
Trajectory toTrajectory() const
Convert to a standard Trajectory.
recHitContainer::const_iterator const_iterator
BaseCkfTrajectoryBuilder(const edm::ParameterSet &conf, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *RecHitBuilder, const TrajectoryFilter *filter, const TrajectoryFilter *inOutFilter=0)
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:193
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
unsigned int detId() const
void addToResult(boost::shared_ptr< const TrajectorySeed > const &seed, TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
virtual bool qualityFilter(const TempTrajectory &) const =0
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
#define LogTrace(id)
static std::string dumpCandidate(const Candidate &candidate, bool showErrors=false)
tuple conf
Definition: dbtoconf.py:185
void setSharedSeed(const boost::shared_ptr< const TrajectorySeed > &seed)
Definition: Trajectory.h:321
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
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:17
std::vector< TempTrajectory > TempTrajectoryContainer
range recHits() const
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
virtual bool toBeContinued(TempTrajectory &) const =0
TrajectoryStateOnSurface const & updatedState() const
size_type size() const
Definition: bqueue.h:167
const TrajectoryFilter * theInOutFilter
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
const GeometricSearchTracker * geometricSearchTracker() const
std::vector< Trajectory > TrajectoryContainer
std::vector< const DetLayer * > nextLayers(Args &&...args) const
Definition: DetLayer.h:60
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
int lostHits() const
const Propagator * theForwardPropagator