44 static const uint32_t NonMatchedTrackId = (uint32_t)-1;
54 bool operator < (
const MatchedHit &other)
const
56 if (detId < other.detId)
58 else if (detId > other.detId)
60 else if (collision < other.collision)
62 else if (other.collision < collision)
65 return simTrackId < other.simTrackId;
70 return detId == other.detId &&
71 collision == other.collision &&
72 simTrackId == other.simTrackId;
78 return hit.detId < detId;
82 return detId < hit.detId;
86 typedef std::pair<TrackQuality::Layer::SubDet, short int>
DetLayer;
183 associatorPSet_(config.getParameter<edm::
ParameterSet>(
"hitAssociator"))
195 std::vector<MatchedHit> matchedHits;
202 DetId detId = (*hit)->geographicalId();
207 if (!(*hit)->isValid())
209 MatchedHit matchedHit;
210 matchedHit.detId = detId;
211 matchedHit.simTrackId = NonMatchedTrackId;
213 switch ((*hit)->getType())
227 matchedHits.push_back(matchedHit);
232 std::vector<SimHitIdpr> simIds =
associator_->associateHitId(**
hit);
237 MatchedHit matchedHit;
238 matchedHit.detId = detId;
239 matchedHit.simTrackId = NonMatchedTrackId;
242 matchedHits.push_back(matchedHit);
247 for (std::vector<SimHitIdpr>::const_iterator
i = simIds.begin();
248 i != simIds.end(); ++
i)
250 MatchedHit matchedHit;
251 matchedHit.detId = detId;
252 matchedHit.simTrackId =
i->first;
253 matchedHit.collision =
i->second;
261 matchedHits.push_back(matchedHit);
266 std::stable_sort(matchedHits.begin(), matchedHits.end());
271 for (SimParticleTrail::const_iterator track = spt.begin();
272 track != spt.end(); ++track)
275 for (std::vector<PSimHit>::const_iterator
hit =
276 (*track)->pSimHit_begin();
277 hit != (*track)->pSimHit_end(); ++
hit)
279 MatchedHit matchedHit;
280 matchedHit.detId =
DetId(
hit->detUnitId());
281 matchedHit.simTrackId =
hit->trackId();
282 matchedHit.collision =
hit->eventId();
285 std::pair<std::vector<MatchedHit>::iterator,
286 std::vector<MatchedHit>::iterator>
287 range = std::equal_range(
289 matchedHits.begin() +
size,
293 if (range.first == range.second)
296 matchedHit.recHitId = -1;
297 matchedHits.push_back(matchedHit);
302 std::vector<MatchedHit>::iterator
pos =
303 std::lower_bound(range.first,
308 if (pos != range.second)
310 if (range.second - range.first > 1)
319 std::stable_sort(matchedHits.begin(), matchedHits.end());
322 typedef std::multimap<DetLayer, const MatchedHit*> LayerHitMap;
323 LayerHitMap layerHitMap;
326 for (std::vector<MatchedHit>::const_iterator
hit = matchedHits.begin();
327 hit != matchedHits.end();)
330 const MatchedHit *best = 0;
337 statePriorities[
hit->state] > statePriorities[best->state] ||
338 best->simTrackId == NonMatchedTrackId)
344 while (
hit != matchedHits.end() &&
345 hit->detId == best->detId);
348 if (best->simTrackId != NonMatchedTrackId ||
351 layerHitMap.insert(std::make_pair(
358 #ifdef DEBUG_TRACK_QUALITY
359 std::cout <<
"---------------------" << std::endl;
362 for (LayerHitMap::const_iterator
hit = layerHitMap.begin();
363 hit != layerHitMap.end(); ++
hit)
365 #ifdef DEBUG_TRACK_QUALITY
367 <<
"detLayer (" <<
hit->first.first <<
", " <<
hit->first.second <<
")"
368 <<
" [" << (uint32_t)
hit->second->detId <<
"] sim(" << (
int)
hit->second->simTrackId <<
")"
369 <<
" hit(" <<
hit->second->recHitId <<
") -> " <<
hit->second->state << std::endl;
390 layer->
hits.push_back(newHit);
static DetLayer getDetLayer(DetId detId)
void evaluate(SimParticleTrail const &, reco::TrackBaseRef const &)
Compute information about the track reconstruction quality.
unsigned int layer() const
layer id
std::vector< TrackingParticleRef > SimParticleTrail
std::pair< TrackQuality::Layer::SubDet, short int > DetLayer
std::auto_ptr< TrackerHitAssociator > associator_
bool operator==(const CaloTower &t1, const CaloTower &t2)
TrackQuality(const edm::ParameterSet &)
Constructor by pset.
unsigned int layer() const
layer id
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const Layer & layer(unsigned int index) const
Return information about the given layer by index.
std::vector< Layer > layers_
unsigned int disk() const
disk id
unsigned int wheel() const
wheel id
unsigned int layer() const
layer id
void newEvent(const edm::Event &, const edm::EventSetup &)
Pre-process event information (for accessing reconstruction information)
Detector det() const
get the detector field from this detid
tuple size
Write out results.
const edm::ParameterSet associatorPSet_
static const int statePriorities[]
unsigned int wheel() const
wheel id
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.