This class analyses the reconstruction quality for a given track. More...
#include <TrackQuality.h>
Classes | |
struct | Layer |
Public Types | |
typedef std::vector < TrackingParticleRef > | SimParticleTrail |
Public Member Functions | |
void | evaluate (SimParticleTrail const &, reco::TrackBaseRef const &) |
Compute information about the track reconstruction quality. | |
const Layer & | layer (unsigned int index) const |
Return information about the given layer by index. | |
void | newEvent (const edm::Event &, const edm::EventSetup &) |
Pre-process event information (for accessing reconstruction information) | |
unsigned int | numberOfLayers () const |
Return the number of layers with simulated and/or reconstructed hits. | |
TrackQuality (const edm::ParameterSet &) | |
Constructor by pset. | |
Private Attributes | |
std::auto_ptr < TrackerHitAssociator > | associator_ |
const edm::ParameterSet | associatorPSet_ |
std::vector< Layer > | layers_ |
This class analyses the reconstruction quality for a given track.
Definition at line 26 of file TrackQuality.h.
typedef std::vector<TrackingParticleRef> TrackQuality::SimParticleTrail |
Definition at line 29 of file TrackQuality.h.
TrackQuality::TrackQuality | ( | const edm::ParameterSet & | config | ) |
Constructor by pset.
Definition at line 182 of file TrackQuality.cc.
: associatorPSet_(config.getParameter<edm::ParameterSet>("hitAssociator")) { }
void TrackQuality::evaluate | ( | SimParticleTrail const & | spt, |
reco::TrackBaseRef const & | tr | ||
) |
Compute information about the track reconstruction quality.
Definition at line 192 of file TrackQuality.cc.
References associator_, TrackingRecHit::bad, TrackQuality::Layer::Bad, gather_cfg::cout, TrackQuality::Layer::Dead, DetId::det(), getDetLayer(), TrackQuality::Layer::Good, TrackQuality::Layer::hits, i, TrackingRecHit::inactive, layer(), TrackQuality::Layer::layer, layers_, TrackQuality::Layer::Misassoc, TrackQuality::Layer::Missed, DetId::Muon, TrackQuality::Layer::Noise, pos, TrackQuality::Layer::Hit::recHitId, TrackQuality::Layer::Shared, findQualityFiles::size, TrackQuality::Layer::Hit::state, TrackQuality::Layer::subDet, ExpressReco_HICollisions_FallBack::track, and TrackQuality::Layer::Unknown.
Referenced by TrackClassifier::qualityInformation().
{ std::vector<MatchedHit> matchedHits; // iterate over reconstructed hits for (trackingRecHit_iterator hit = tr->recHitsBegin(); hit != tr->recHitsEnd(); ++hit) { // on which module the hit lies DetId detId = (*hit)->geographicalId(); // FIXME: check for double-sided modules? // didn't find a hit on that module if (!(*hit)->isValid()) { MatchedHit matchedHit; matchedHit.detId = detId; matchedHit.simTrackId = NonMatchedTrackId; // check why hit wasn't valid and propagate information switch ((*hit)->getType()) { case TrackingRecHit::inactive: matchedHit.state = Layer::Dead; break; case TrackingRecHit::bad: matchedHit.state = Layer::Bad; break; default: matchedHit.state = Layer::Missed; } matchedHit.recHitId = hit - tr->recHitsBegin(); matchedHits.push_back(matchedHit); continue; } // find simulated tracks causing hit that was reconstructed std::vector<SimHitIdpr> simIds = associator_->associateHitId(**hit); // must be noise or so if (simIds.empty()) { MatchedHit matchedHit; matchedHit.detId = detId; matchedHit.simTrackId = NonMatchedTrackId; matchedHit.state = Layer::Noise; matchedHit.recHitId = hit - tr->recHitsBegin(); matchedHits.push_back(matchedHit); continue; } // register all simulated tracks contributing for (std::vector<SimHitIdpr>::const_iterator i = simIds.begin(); i != simIds.end(); ++i) { MatchedHit matchedHit; matchedHit.detId = detId; matchedHit.simTrackId = i->first; matchedHit.collision = i->second; // RecHit <-> SimHit matcher currently doesn't support muon system if (detId.det() == DetId::Muon) matchedHit.state = Layer::Unknown; else // assume hit was mismatched (until possible confirmation) matchedHit.state = Layer::Misassoc; matchedHit.recHitId = hit - tr->recHitsBegin(); matchedHits.push_back(matchedHit); } } // sort hits found so far by module id std::stable_sort(matchedHits.begin(), matchedHits.end()); std::vector<MatchedHit>::size_type size = matchedHits.size(); // now iterate over simulated hits and compare (tracks in chain first) for (SimParticleTrail::const_iterator track = spt.begin(); track != spt.end(); ++track) { // iterate over all hits in track for (std::vector<PSimHit>::const_iterator hit = (*track)->pSimHit_begin(); hit != (*track)->pSimHit_end(); ++hit) { MatchedHit matchedHit; matchedHit.detId = DetId(hit->detUnitId()); matchedHit.simTrackId = hit->trackId(); matchedHit.collision = hit->eventId(); // find range of reconstructed hits belonging to this module std::pair<std::vector<MatchedHit>::iterator, std::vector<MatchedHit>::iterator> range = std::equal_range( matchedHits.begin(), matchedHits.begin() + size, matchedHit.detId); // no reconstructed hit found, remember this as a missed module if (range.first == range.second) { matchedHit.state = Layer::Missed; matchedHit.recHitId = -1; matchedHits.push_back(matchedHit); continue; } // now find if the hit belongs to the correct simulated track std::vector<MatchedHit>::iterator pos = std::lower_bound(range.first, range.second, matchedHit); // if it does, check for being a shared hit (was Misassoc before) if (pos != range.second) { if (range.second - range.first > 1) // more than one SimHit pos->state = Layer::Shared; else pos->state = Layer::Good; // only hit -> good hit } } } // in case we added missed modules, re-sort std::stable_sort(matchedHits.begin(), matchedHits.end()); // prepare for ordering results by layer enum and layer/disk number typedef std::multimap<DetLayer, const MatchedHit*> LayerHitMap; LayerHitMap layerHitMap; // iterate over all simulated/reconstructed hits again for (std::vector<MatchedHit>::const_iterator hit = matchedHits.begin(); hit != matchedHits.end();) { // we can have multiple reco-to-sim matches per module, find best one const MatchedHit *best = 0; // this loop iterates over all subsequent hits in the same module do { // update our best hit pointer if (!best || statePriorities[hit->state] > statePriorities[best->state] || best->simTrackId == NonMatchedTrackId) { best = &*hit; } ++hit; } while (hit != matchedHits.end() && hit->detId == best->detId); // ignore hit in case track reco was looking at the wrong module if (best->simTrackId != NonMatchedTrackId || best->state != Layer::Missed) { layerHitMap.insert(std::make_pair( getDetLayer(best->detId), best)); } } layers_.clear(); #ifdef DEBUG_TRACK_QUALITY std::cout << "---------------------" << std::endl; #endif // now prepare final collection for (LayerHitMap::const_iterator hit = layerHitMap.begin(); hit != layerHitMap.end(); ++hit) { #ifdef DEBUG_TRACK_QUALITY std::cout << "detLayer (" << hit->first.first << ", " << hit->first.second << ")" << " [" << (uint32_t)hit->second->detId << "] sim(" << (int)hit->second->simTrackId << ")" << " hit(" << hit->second->recHitId << ") -> " << hit->second->state << std::endl; #endif // find out if we need to start a new layer Layer *layer = layers_.empty() ? 0 : &layers_.back(); if (!layer || hit->first.first != layer->subDet || hit->first.second != layer->layer) { Layer newLayer; newLayer.subDet = hit->first.first; newLayer.layer = hit->first.second; layers_.push_back(newLayer); layer = &layers_.back(); } // create hit and add it to layer Layer::Hit newHit; newHit.recHitId = hit->second->recHitId; newHit.state = hit->second->state; layer->hits.push_back(newHit); } }
const Layer& TrackQuality::layer | ( | unsigned int | index | ) | const [inline] |
Return information about the given layer by index.
Definition at line 85 of file TrackQuality.h.
References getHLTprescales::index, and layers_.
Referenced by evaluate(), and TrackClassifier::qualityInformation().
void TrackQuality::newEvent | ( | const edm::Event & | ev, |
const edm::EventSetup & | es | ||
) |
Pre-process event information (for accessing reconstruction information)
Definition at line 187 of file TrackQuality.cc.
References associator_, and associatorPSet_.
Referenced by TrackClassifier::newEvent().
{ associator_.reset(new TrackerHitAssociator(ev, associatorPSet_)); }
unsigned int TrackQuality::numberOfLayers | ( | ) | const [inline] |
Return the number of layers with simulated and/or reconstructed hits.
Definition at line 79 of file TrackQuality.h.
References layers_.
Referenced by TrackClassifier::qualityInformation().
{ return layers_.size(); }
std::auto_ptr<TrackerHitAssociator> TrackQuality::associator_ [private] |
Definition at line 92 of file TrackQuality.h.
Referenced by evaluate(), and newEvent().
const edm::ParameterSet TrackQuality::associatorPSet_ [private] |
Definition at line 91 of file TrackQuality.h.
Referenced by newEvent().
std::vector<Layer> TrackQuality::layers_ [private] |
Definition at line 94 of file TrackQuality.h.
Referenced by evaluate(), layer(), and numberOfLayers().