CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
TrackQuality Class Reference

This class analyses the reconstruction quality for a given track. More...

#include <TrackQuality.h>

Classes

struct  Layer
 

Public Types

typedef std::vector< TrackingParticleRefSimParticleTrail
 

Public Member Functions

void evaluate (SimParticleTrail const &, reco::TrackBaseRef const &, const TrackerTopology *tTopo)
 Compute information about the track reconstruction quality. More...
 
const Layerlayer (unsigned int index) const
 Return information about the given layer by index. More...
 
void newEvent (const edm::Event &, const edm::EventSetup &)
 Pre-process event information (for accessing reconstruction information) More...
 
unsigned int numberOfLayers () const
 Return the number of layers with simulated and/or reconstructed hits. More...
 
 TrackQuality (const edm::ParameterSet &, edm::ConsumesCollector &iC)
 Constructor by pset. More...
 

Private Attributes

std::unique_ptr< TrackerHitAssociatorassociator_
 
std::vector< Layerlayers_
 
TrackerHitAssociator::Config trackerHitAssociatorConfig_
 

Detailed Description

This class analyses the reconstruction quality for a given track.

Definition at line 28 of file TrackQuality.h.

Member Typedef Documentation

Definition at line 30 of file TrackQuality.h.

Constructor & Destructor Documentation

TrackQuality::TrackQuality ( const edm::ParameterSet config,
edm::ConsumesCollector iC 
)

Constructor by pset.

Definition at line 133 of file TrackQuality.cc.

134  : trackerHitAssociatorConfig_(config.getParameter<edm::ParameterSet>("hitAssociator"), std::move(iC)) {}
T getParameter(std::string const &) const
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: TrackQuality.h:80
def move(src, dest)
Definition: eostools.py:511

Member Function Documentation

void TrackQuality::evaluate ( SimParticleTrail const &  spt,
reco::TrackBaseRef const &  tr,
const TrackerTopology tTopo 
)

Compute information about the track reconstruction quality.

Definition at line 140 of file TrackQuality.cc.

References associator_, TrackQuality::Layer::Bad, TrackingRecHit::bad, gather_cfg::cout, TrackQuality::Layer::Dead, DetId::det(), getDetLayer(), TrackQuality::Layer::hits, mps_fire::i, TrackingRecHit::inactive, TrackQuality::Layer::layer, layer(), layers_, TrackQuality::Layer::Misassoc, TrackQuality::Layer::Missed, DetId::Muon, TrackQuality::Layer::Noise, TrackQuality::Layer::Hit::recHitId, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), TrackQuality::Layer::Hit::state, TrackQuality::Layer::subDet, and TrackQuality::Layer::Unknown.

Referenced by TrackClassifier::qualityInformation().

140  {
141  std::vector<MatchedHit> matchedHits;
142 
143  // iterate over reconstructed hits
144  for (trackingRecHit_iterator hit = tr->recHitsBegin(); hit != tr->recHitsEnd(); ++hit) {
145  // on which module the hit lies
146  DetId detId = (*hit)->geographicalId();
147 
148  // FIXME: check for double-sided modules?
149 
150  // didn't find a hit on that module
151  if (!(*hit)->isValid()) {
152  MatchedHit matchedHit;
153  matchedHit.detId = detId;
154  matchedHit.simTrackId = NonMatchedTrackId;
155  // check why hit wasn't valid and propagate information
156  switch ((*hit)->getType()) {
158  matchedHit.state = Layer::Dead;
159  break;
160 
161  case TrackingRecHit::bad:
162  matchedHit.state = Layer::Bad;
163  break;
164 
165  default:
166  matchedHit.state = Layer::Missed;
167  }
168  matchedHit.recHitId = hit - tr->recHitsBegin();
169  matchedHits.push_back(matchedHit);
170  continue;
171  }
172 
173  // find simulated tracks causing hit that was reconstructed
174  std::vector<SimHitIdpr> simIds = associator_->associateHitId(**hit);
175 
176  // must be noise or so
177  if (simIds.empty()) {
178  MatchedHit matchedHit;
179  matchedHit.detId = detId;
180  matchedHit.simTrackId = NonMatchedTrackId;
181  matchedHit.state = Layer::Noise;
182  matchedHit.recHitId = hit - tr->recHitsBegin();
183  matchedHits.push_back(matchedHit);
184  continue;
185  }
186 
187  // register all simulated tracks contributing
188  for (std::vector<SimHitIdpr>::const_iterator i = simIds.begin(); i != simIds.end(); ++i) {
189  MatchedHit matchedHit;
190  matchedHit.detId = detId;
191  matchedHit.simTrackId = i->first;
192  matchedHit.collision = i->second;
193  // RecHit <-> SimHit matcher currently doesn't support muon system
194  if (detId.det() == DetId::Muon)
195  matchedHit.state = Layer::Unknown;
196  else
197  // assume hit was mismatched (until possible confirmation)
198  matchedHit.state = Layer::Misassoc;
199  matchedHit.recHitId = hit - tr->recHitsBegin();
200  matchedHits.push_back(matchedHit);
201  }
202  }
203 
204  // sort hits found so far by module id
205  std::stable_sort(matchedHits.begin(), matchedHits.end());
206 
207  // in case we added missed modules, re-sort
208  std::stable_sort(matchedHits.begin(), matchedHits.end());
209 
210  // prepare for ordering results by layer enum and layer/disk number
211  typedef std::multimap<DetLayer, const MatchedHit *> LayerHitMap;
212  LayerHitMap layerHitMap;
213 
214  // iterate over all simulated/reconstructed hits again
215  for (std::vector<MatchedHit>::const_iterator hit = matchedHits.begin(); hit != matchedHits.end();) {
216  // we can have multiple reco-to-sim matches per module, find best one
217  const MatchedHit *best = nullptr;
218 
219  // this loop iterates over all subsequent hits in the same module
220  do {
221  // update our best hit pointer
222  if (!best || statePriorities[hit->state] > statePriorities[best->state] ||
223  best->simTrackId == NonMatchedTrackId) {
224  best = &*hit;
225  }
226  ++hit;
227  } while (hit != matchedHits.end() && hit->detId == best->detId);
228 
229  // ignore hit in case track reco was looking at the wrong module
230  if (best->simTrackId != NonMatchedTrackId || best->state != Layer::Missed) {
231  layerHitMap.insert(std::make_pair(getDetLayer(best->detId, tTopo), best));
232  }
233  }
234 
235  layers_.clear();
236 
237 #ifdef DEBUG_TRACK_QUALITY
238  std::cout << "---------------------" << std::endl;
239 #endif
240  // now prepare final collection
241  for (LayerHitMap::const_iterator hit = layerHitMap.begin(); hit != layerHitMap.end(); ++hit) {
242 #ifdef DEBUG_TRACK_QUALITY
243  std::cout << "detLayer (" << hit->first.first << ", " << hit->first.second << ")"
244  << " [" << (uint32_t)hit->second->detId << "] sim(" << (int)hit->second->simTrackId << ")"
245  << " hit(" << hit->second->recHitId << ") -> " << hit->second->state << std::endl;
246 #endif
247 
248  // find out if we need to start a new layer
249  Layer *layer = layers_.empty() ? nullptr : &layers_.back();
250  if (!layer || hit->first.first != layer->subDet || hit->first.second != layer->layer) {
251  Layer newLayer;
252  newLayer.subDet = hit->first.first;
253  newLayer.layer = hit->first.second;
254  layers_.push_back(newLayer);
255  layer = &layers_.back();
256  }
257 
258  // create hit and add it to layer
259  Layer::Hit newHit;
260  newHit.recHitId = hit->second->recHitId;
261  newHit.state = hit->second->state;
262 
263  layer->hits.push_back(newHit);
264  }
265 }
std::unique_ptr< TrackerHitAssociator > associator_
Definition: TrackQuality.h:81
SeedingLayerSetsHits::SeedingLayer Layer
Definition: LayerTriplets.h:14
DetLayer getDetLayer(DetId detId, const TrackerTopology *tTopo)
Definition: TrackQuality.cc:90
const Layer & layer(unsigned int index) const
Return information about the given layer by index.
Definition: TrackQuality.h:77
std::vector< Layer > layers_
Definition: TrackQuality.h:83
SeedingHitSet::ConstRecHitPointer Hit
Definition: DetId.h:18
static const int statePriorities[]
Definition: TrackQuality.cc:80
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
const Layer& TrackQuality::layer ( unsigned int  index) const
inline

Return information about the given layer by index.

Definition at line 77 of file TrackQuality.h.

References layers_.

Referenced by evaluate(), geometryXMLparser.DTAlignable::index(), geometryXMLparser.CSCAlignable::index(), and TrackClassifier::qualityInformation().

77 { return layers_[index]; }
std::vector< Layer > layers_
Definition: TrackQuality.h:83
void TrackQuality::newEvent ( const edm::Event ev,
const edm::EventSetup es 
)

Pre-process event information (for accessing reconstruction information)

Definition at line 136 of file TrackQuality.cc.

References associator_, and trackerHitAssociatorConfig_.

Referenced by TrackClassifier::newEvent().

136  {
138 }
std::unique_ptr< TrackerHitAssociator > associator_
Definition: TrackQuality.h:81
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: TrackQuality.h:80
unsigned int TrackQuality::numberOfLayers ( ) const
inline

Return the number of layers with simulated and/or reconstructed hits.

Definition at line 74 of file TrackQuality.h.

References layers_.

Referenced by TrackClassifier::qualityInformation().

74 { return layers_.size(); }
std::vector< Layer > layers_
Definition: TrackQuality.h:83

Member Data Documentation

std::unique_ptr<TrackerHitAssociator> TrackQuality::associator_
private

Definition at line 81 of file TrackQuality.h.

Referenced by evaluate(), and newEvent().

std::vector<Layer> TrackQuality::layers_
private

Definition at line 83 of file TrackQuality.h.

Referenced by evaluate(), layer(), and numberOfLayers().

TrackerHitAssociator::Config TrackQuality::trackerHitAssociatorConfig_
private

Definition at line 80 of file TrackQuality.h.

Referenced by newEvent().