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 
7 
8 
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 MeasurementTracker* measurementTracker,
31  const TrajectoryFilter* filter,
32  const TrajectoryFilter* inOutFilter):
33  theUpdator(updator),
34  thePropagatorAlong(propagatorAlong),thePropagatorOpposite(propagatorOpposite),
35  theEstimator(estimator),theTTRHBuilder(recHitBuilder),
36  theMeasurementTracker(measurementTracker),
37  theLayerMeasurements(new LayerMeasurements(theMeasurementTracker)),
38  theForwardPropagator(0),theBackwardPropagator(0),
39  theFilter(filter),
40  theInOutFilter(inOutFilter)
41 {
42  if (conf.exists("clustersToSkip")){
43  skipClusters_=true;
44  clustersToSkip_=conf.getParameter<edm::InputTag>("clustersToSkip");
45  }
46  else
47  skipClusters_=false;
48 }
49 
51  delete theLayerMeasurements;
52 }
53 
54 
55 void
56 BaseCkfTrajectoryBuilder::seedMeasurements(const TrajectorySeed& seed, std::vector<TrajectoryMeasurement> & result) const
57 {
58 
59 
60  TrajectorySeed::range hitRange = seed.recHits();
61  for (TrajectorySeed::const_iterator ihit = hitRange.first;
62  ihit != hitRange.second; ihit++) {
64  const GeomDet* hitGeomDet =
65  theMeasurementTracker->geomTracker()->idToDet( ihit->geographicalId());
66 
67  const DetLayer* hitLayer =
68  theMeasurementTracker->geometricSearchTracker()->detLayer(ihit->geographicalId());
69 
70  TSOS invalidState( new BasicSingleTrajectoryState( hitGeomDet->surface()));
71  if (ihit == hitRange.second - 1) {
72  // the seed trajectory state should correspond to this hit
73  PTrajectoryStateOnDet pState( seed.startingState());
74  const GeomDet* gdet = theMeasurementTracker->geomTracker()->idToDet( DetId(pState.detId()));
75  if (&gdet->surface() != &hitGeomDet->surface()) {
76  edm::LogError("CkfPattern") << "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 = trajectoryStateTransform::transientState( pState, &(gdet->surface()),
82  result.push_back(TM( invalidState, updatedState, recHit, 0, hitLayer));
83  }
84  else {
85  PTrajectoryStateOnDet pState( seed.startingState());
86 
89  (hitRange.second - 1)->geographicalId()))->surface()),
91  TSOS innerState = theBackwardPropagator->propagate(outerState,hitGeomDet->surface());
92  if(innerState.isValid()) {
93  TSOS innerUpdated = theUpdator->update(innerState,*recHit);
94  result.push_back(TM( invalidState, innerUpdated, recHit, 0, hitLayer));
95  }
96  }
97  }
98 
99  // method for debugging
100  fillSeedHistoDebugger(result.begin(),result.end());
101 
102 }
103 
104 
107 {
108  TempTrajectory result( seed, seed.direction());
109  if ( seed.direction() == alongMomentum) {
110  theForwardPropagator = &(*thePropagatorAlong);
111  theBackwardPropagator = &(*thePropagatorOpposite);
112  }
113  else {
114  theForwardPropagator = &(*thePropagatorOpposite);
115  theBackwardPropagator = &(*thePropagatorAlong);
116  }
117 
118  std::vector<TM> seedMeas;
119  seedMeasurements(seed, seedMeas);
120  for (std::vector<TM>::const_iterator i=seedMeas.begin(); i!=seedMeas.end(); i++)
121  result.push(*i);
122 
123  LogDebug("CkfPattern")
124  <<" initial trajectory from the seed: "<<PrintoutHelper::dumpCandidate(result,true);
125 
126  return result;
127 }
128 
129 
131 {
132  if (traj.measurements().size() > 400) {
133  edm::LogError("BaseCkfTrajectoryBuilder_InfiniteLoop");
134  LogTrace("BaseCkfTrajectoryBuilder_InfiniteLoop") <<
135  "Cropping Track After 400 Measurements:\n" <<
136  " Last predicted state: " << traj.lastMeasurement().predictedState() << "\n" <<
137  " Last layer subdetector: " << (traj.lastLayer() ? traj.lastLayer()->subDetector() : -1) << "\n" <<
138  " Found hits: " << traj.foundHits() << ", lost hits: " << traj.lostHits() << "\n\n";
139  return false;
140  }
141  // Called after each new hit is added to the trajectory, to see if it is
142  // worth continuing to build this track candidate.
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->toBeContinued(traj);
146  } else {
147  return theFilter->toBeContinued(traj);
148  }
149 }
150 
151 
152  bool BaseCkfTrajectoryBuilder::qualityFilter( const TempTrajectory& traj, bool inOut) const
153 {
154  // Called after building a trajectory is completed, to see if it is good enough
155  // to keep.
156  if (inOut) {
157  if (theInOutFilter == 0) edm::LogError("CkfPattern") << "CkfTrajectoryBuilder error: trying to use dedicated filter for in-out tracking phase, when none specified";
158  return theInOutFilter->qualityFilter(traj);
159  } else {
160  return theFilter->qualityFilter(traj);
161  }
162 }
163 
164 
165 void
168  bool inOut) const
169 {
170  // quality check
171  if ( !qualityFilter(tmptraj, inOut) ) return;
172  Trajectory traj = tmptraj.toTrajectory();
173  // discard latest dummy measurements
174  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid()) traj.pop();
175  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a Trajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits()
176  <<" lost hits. Popped :"<<(tmptraj.measurements().size())-(traj.measurements().size())<<" hits.";
177  result.push_back( traj);
178 }
179 void
182  bool inOut) const
183 {
184  // quality check
185  if ( !qualityFilter(tmptraj, inOut) ) return;
186  // discard latest dummy measurements
187  TempTrajectory traj = tmptraj;
188  while (!traj.empty() && !traj.lastMeasurement().recHit()->isValid()) traj.pop();
189  LogDebug("CkfPattern")<<inOut<<"=inOut option. pushing a TempTrajectory with: "<<traj.foundHits()<<" found hits. "<<traj.lostHits()
190  <<" lost hits. Popped :"<<(tmptraj.measurements().size())-(traj.measurements().size())<<" hits.";
191  result.push_back( traj );
192 }
193 
194 
195 
198 {
199  if (traj.empty())
200  {
201  //set the currentState to be the one from the trajectory seed starting point
202  PTrajectoryStateOnDet ptod = traj.seed().startingState();
203  DetId id(ptod.detId());
205  const Surface * surface=&g->surface();
206 
207 
210  return StateAndLayers(currentState,lastLayer->nextLayers( *currentState.freeState(), traj.direction()) );
211  }
212  else
213  {
214  TSOS currentState = traj.lastMeasurement().updatedState();
215  return StateAndLayers(currentState,traj.lastLayer()->nextLayers( *currentState.freeState(), traj.direction()) );
216  }
217 }
218 
220  {
222  if (skipClusters_)
224  }
225 
227 {
228  if (skipClusters_)
230 }
#define LogDebug(id)
PropagationDirection direction() const
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:234
T getParameter(std::string const &) const
const TrajectorySeed & seed() const
Access to the seed used to reconstruct the Trajectory.
int foundHits() const
Definition: Trajectory.h:224
int i
Definition: DBlmapReader.cc:9
int lostHits() const
Definition: Trajectory.h:231
const Propagator * theBackwardPropagator
virtual void update(const edm::Event &) const =0
bool empty() const
True if trajectory has no measurements.
virtual void setEvent(const edm::Event &event) const
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const =0
void addToResult(TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
const DataContainer & measurements() const
virtual std::vector< const DetLayer * > nextLayers(NavigationDirection direction) const
Definition: DetLayer.cc:35
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
ConstRecHitPointer recHit() const
int foundHits() const
obsolete name, use measurements() instead.
BaseCkfTrajectoryBuilder(const edm::ParameterSet &conf, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *RecHitBuilder, const MeasurementTracker *measurementTracker, const TrajectoryFilter *filter, const TrajectoryFilter *inOutFilter=0)
const TrajectoryFilter * theFilter
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
void seedMeasurements(const TrajectorySeed &seed, std::vector< TrajectoryMeasurement > &result) const
const TrajectoryMeasurement & lastMeasurement() const
bool qualityFilter(const TempTrajectory &traj, bool inOut=false) const
const LayerMeasurements * theLayerMeasurements
PropagationDirection direction() const
DataContainer const & measurements() const
Definition: Trajectory.h:203
virtual void setClusterToSkip(const edm::InputTag &cluster, const edm::Event &event) const =0
FreeTrajectoryState * freeState(bool withErrors=true) const
Trajectory toTrajectory() const
Convert to a standard Trajectory.
recHitContainer::const_iterator const_iterator
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
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
const TrackingGeometry * geomTracker() const
unsigned int detId() const
TrajectoryStateOnSurface updatedState() const
virtual bool qualityFilter(const TempTrajectory &) const =0
TrajectoryStateOnSurface predictedState() 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
#define LogTrace(id)
static std::string dumpCandidate(const Candidate &candidate, bool showErrors=false)
tuple conf
Definition: dbtoconf.py:185
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
Definition: Propagator.cc:12
Definition: DetId.h:20
virtual void unsetClusterToSkip() const =0
const MeasurementTracker * theMeasurementTracker
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
virtual const MagneticField * magneticField() const =0
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
std::pair< TSOS, std::vector< const DetLayer * > > StateAndLayers
StateAndLayers findStateAndLayers(const TempTrajectory &traj) const
virtual bool toBeContinued(TempTrajectory &) const =0
size_type size() const
Definition: bqueue.h:146
const TrajectoryFilter * theInOutFilter
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
const GeometricSearchTracker * geometricSearchTracker() const
virtual void fillSeedHistoDebugger(std::vector< TrajectoryMeasurement >::iterator begin, std::vector< TrajectoryMeasurement >::iterator end) const
std::vector< Trajectory > TrajectoryContainer
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
int lostHits() const
const Propagator * theForwardPropagator