#include <ClusterRemovalRefSetter.h>
Public Member Functions | |
ClusterRemovalRefSetter (const edm::Event &iEvent, const edm::InputTag tag) | |
void | reKey (SiPixelRecHit *hit, uint32_t detid) const |
void | reKey (SiStripRecHit1D *hit, uint32_t detid) const |
void | reKey (SiStripRecHit2D *hit, uint32_t detid) const |
void | reKey (TrackingRecHit *hit) const |
Private Attributes | |
const reco::ClusterRemovalInfo * | cri_ |
Definition at line 20 of file ClusterRemovalRefSetter.h.
ClusterRemovalRefSetter::ClusterRemovalRefSetter | ( | const edm::Event & | iEvent, |
const edm::InputTag | tag | ||
) |
Definition at line 4 of file ClusterRemovalRefSetter.cc.
References cri_, and edm::Event::getByLabel().
{ edm::Handle<reco::ClusterRemovalInfo> hCRI; iEvent.getByLabel(tag, hCRI); cri_ = &*hCRI; //std::cout << "Rekeying PIXEL ProdID " << cri_->pixelNewRefProd().id() << " => " << cri_->pixelRefProd().id() << std::endl; //std::cout << "Rekeying STRIP ProdID " << cri_->stripNewRefProd().id() << " => " << cri_->stripRefProd().id() << std::endl; }
void ClusterRemovalRefSetter::reKey | ( | TrackingRecHit * | hit | ) | const |
Definition at line 13 of file ClusterRemovalRefSetter.cc.
References cri_, cond::rpcobgas::detid, Exception, TrackingRecHit::geographicalId(), reco::ClusterRemovalInfo::hasPixel(), reco::ClusterRemovalInfo::hasStrip(), TrackingRecHit::isValid(), SiStripMatchedRecHit2D::monoHit(), ProjectedSiStripRecHit2D::originalHit(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, DetId::rawId(), SiStripMatchedRecHit2D::stereoHit(), and DetId::subdetId().
Referenced by SeedCombiner::produce(), cms::TrackListMerger::produce(), cms::SimpleTrackListMerger::produce(), and KfTrackProducerBase::putInEvt().
{ if (!hit->isValid()) return; DetId detid = hit->geographicalId(); uint32_t subdet = detid.subdetId(); if ((subdet == PixelSubdetector::PixelBarrel) || (subdet == PixelSubdetector::PixelEndcap)) { if (!cri_->hasPixel()) return; reKey(reinterpret_cast<SiPixelRecHit *>(hit), detid.rawId()); } else { if (!cri_->hasStrip()) return; const std::type_info &type = typeid(*hit); if (type == typeid(SiStripRecHit2D)) { reKey(reinterpret_cast<SiStripRecHit2D *>(hit), detid.rawId()); } else if (type == typeid(SiStripRecHit1D)) { reKey(reinterpret_cast<SiStripRecHit1D *>(hit), detid.rawId()); } else if (type == typeid(SiStripMatchedRecHit2D)) { SiStripMatchedRecHit2D *mhit = reinterpret_cast<SiStripMatchedRecHit2D *>(hit); // const_cast is needed: monoHit() e stereoHit() are const only - at least for now reKey(mhit->monoHit(), mhit->monoHit()->geographicalId().rawId()); reKey(mhit->stereoHit(), mhit->stereoHit()->geographicalId().rawId()); } else if (type == typeid(ProjectedSiStripRecHit2D)) { ProjectedSiStripRecHit2D *phit = reinterpret_cast<ProjectedSiStripRecHit2D *>(hit); reKey(&phit->originalHit(), phit->originalHit().geographicalId().rawId()); } else throw cms::Exception("Unknown RecHit Type") << "RecHit of type " << type.name() << " not supported. (use c++filt to demangle the name)"; } }
void ClusterRemovalRefSetter::reKey | ( | SiPixelRecHit * | hit, |
uint32_t | detid | ||
) | const |
Definition at line 77 of file ClusterRemovalRefSetter.cc.
References SiPixelRecHit::cluster(), cri_, Exception, edm::Ref< C, T, F >::id(), edm::RefProd< C >::id(), edm::Ref< C, T, F >::key(), reco::ClusterRemovalInfo::pixelIndices(), reco::ClusterRemovalInfo::pixelNewRefProd(), reco::ClusterRemovalInfo::pixelRefProd(), and SiPixelRecHit::setClusterRef().
{ using reco::ClusterRemovalInfo; const ClusterRemovalInfo::Indices &indices = cri_->pixelIndices(); SiPixelRecHit::ClusterRef newRef = hit->cluster(); // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one if (newRef.id() != cri_->pixelNewRefProd().id()) { throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " << "Existing pixel cluster refers to product ID " << newRef.id() << " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->pixelNewRefProd().id() << "\n"; } size_t newIndex = newRef.key(); assert(newIndex < indices.size()); size_t oldIndex = indices[newIndex]; SiPixelRecHit::ClusterRef oldRef(cri_->pixelRefProd(), oldIndex); hit->setClusterRef(oldRef); }
void ClusterRemovalRefSetter::reKey | ( | SiStripRecHit1D * | hit, |
uint32_t | detid | ||
) | const |
Definition at line 58 of file ClusterRemovalRefSetter.cc.
References SiStripRecHit1D::cluster(), cri_, Exception, edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), SiStripRecHit1D::setClusterRef(), reco::ClusterRemovalInfo::stripIndices(), reco::ClusterRemovalInfo::stripNewRefProd(), and reco::ClusterRemovalInfo::stripRefProd().
{ using reco::ClusterRemovalInfo; const ClusterRemovalInfo::Indices &indices = cri_->stripIndices(); SiStripRecHit1D::ClusterRef newRef = hit->cluster(); // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one if (newRef.id() != cri_->stripNewRefProd().id()) { // this is a cfg error in the tracking configuration, much more likely throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " << "Existing strip cluster refers to product ID " << newRef.id() << " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->stripNewRefProd().id() << "\n"; } size_t newIndex = newRef.key(); assert(newIndex < indices.size()); size_t oldIndex = indices[newIndex]; SiStripRecHit1D::ClusterRef oldRef(cri_->stripRefProd(), oldIndex); hit->setClusterRef(oldRef); }
void ClusterRemovalRefSetter::reKey | ( | SiStripRecHit2D * | hit, |
uint32_t | detid | ||
) | const |
Definition at line 39 of file ClusterRemovalRefSetter.cc.
References SiStripRecHit2D::cluster(), cri_, Exception, edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), SiStripRecHit2D::setClusterRef(), reco::ClusterRemovalInfo::stripIndices(), reco::ClusterRemovalInfo::stripNewRefProd(), and reco::ClusterRemovalInfo::stripRefProd().
{ using reco::ClusterRemovalInfo; const ClusterRemovalInfo::Indices &indices = cri_->stripIndices(); SiStripRecHit2D::ClusterRef newRef = hit->cluster(); // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one if (newRef.id() != cri_->stripNewRefProd().id()) { // this is a cfg error in the tracking configuration, much more likely throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " << "Existing strip cluster refers to product ID " << newRef.id() << " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->stripNewRefProd().id() << "\n"; } size_t newIndex = newRef.key(); assert(newIndex < indices.size()); size_t oldIndex = indices[newIndex]; SiStripRecHit2D::ClusterRef oldRef(cri_->stripRefProd(), oldIndex); hit->setClusterRef(oldRef); }
const reco::ClusterRemovalInfo* ClusterRemovalRefSetter::cri_ [private] |
Definition at line 28 of file ClusterRemovalRefSetter.h.
Referenced by ClusterRemovalRefSetter(), and reKey().