CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

ClusterRemovalRefSetter Class Reference

#include <ClusterRemovalRefSetter.h>

List of all members.

Public Member Functions

 ClusterRemovalRefSetter (const edm::Event &iEvent, const edm::InputTag tag)
void reKey (TrackingRecHit *hit) const

Private Types

typedef
OmniClusterRef::ClusterPixelRef 
ClusterPixelRef
typedef
OmniClusterRef::ClusterRegionalRef 
ClusterRegionalRef
typedef
OmniClusterRef::ClusterStripRef 
ClusterStripRef

Private Member Functions

void reKeyPixel (OmniClusterRef &clusRef) const
void reKeyStrip (OmniClusterRef &clusRef) const

Private Attributes

const reco::ClusterRemovalInfocri_

Detailed Description

Definition at line 20 of file ClusterRemovalRefSetter.h.


Member Typedef Documentation

Definition at line 25 of file ClusterRemovalRefSetter.h.

Definition at line 27 of file ClusterRemovalRefSetter.h.

Definition at line 26 of file ClusterRemovalRefSetter.h.


Constructor & Destructor Documentation

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;
}

Member Function Documentation

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(), ProjectedSiStripRecHit2D::originalHit(), PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, reKeyPixel(), reKeyStrip(), and DetId::subdetId().

Referenced by SeedCombiner::produce(), cms::TrackListMerger::produce(), cms::SimpleTrackListMerger::produce(), reco::modules::DuplicateListMerger::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;
        reKeyPixel(reinterpret_cast<SiPixelRecHit *>(hit)->omniCluster());
    } else {
        if (!cri_->hasStrip()) return;
        const std::type_info &type = typeid(*hit);
        if (type == typeid(SiStripRecHit2D)) {
            reKeyStrip(reinterpret_cast<SiStripRecHit2D *>(hit)->omniCluster());
        } else if (type == typeid(SiStripRecHit1D)) {
            reKeyStrip(reinterpret_cast<SiStripRecHit1D *>(hit)->omniCluster());
        } else if (type == typeid(SiStripMatchedRecHit2D)) {
            SiStripMatchedRecHit2D *mhit = reinterpret_cast<SiStripMatchedRecHit2D *>(hit);
            reKeyStrip(mhit->monoClusterRef());
            reKeyStrip(mhit->stereoClusterRef());
        } else if (type == typeid(ProjectedSiStripRecHit2D)) {
            ProjectedSiStripRecHit2D *phit = reinterpret_cast<ProjectedSiStripRecHit2D *>(hit);
            reKeyStrip(phit->originalHit().omniCluster());
        } else throw cms::Exception("Unknown RecHit Type") << "RecHit of type " << type.name() << " not supported. (use c++filt to demangle the name)";
    }
}
void ClusterRemovalRefSetter::reKeyPixel ( OmniClusterRef clusRef) const [private]

Definition at line 39 of file ClusterRemovalRefSetter.cc.

References cri_, Exception, edm::RefProd< C >::id(), OmniClusterRef::id(), OmniClusterRef::key(), reco::ClusterRemovalInfo::pixelIndices(), reco::ClusterRemovalInfo::pixelNewRefProd(), and reco::ClusterRemovalInfo::pixelRefProd().

Referenced by reKey().

                                                                     {
  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
  using reco::ClusterRemovalInfo;
  const ClusterRemovalInfo::Indices &indices = cri_->pixelIndices();
  
  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];
  ClusterPixelRef oldRef(cri_->pixelRefProd(), oldIndex);
  newRef = OmniClusterRef(oldRef);
}
void ClusterRemovalRefSetter::reKeyStrip ( OmniClusterRef clusRef) const [private]

Definition at line 57 of file ClusterRemovalRefSetter.cc.

References cri_, Exception, OmniClusterRef::id(), OmniClusterRef::key(), reco::ClusterRemovalInfo::stripIndices(), reco::ClusterRemovalInfo::stripNewRefProd(), and reco::ClusterRemovalInfo::stripRefProd().

Referenced by reKey().

                                                                     {
  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
  using reco::ClusterRemovalInfo;
  const ClusterRemovalInfo::Indices &indices = cri_->stripIndices();
  
  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];
  ClusterStripRef oldRef(cri_->stripRefProd(), oldIndex);
  newRef = OmniClusterRef(oldRef);
}

Member Data Documentation

Definition at line 33 of file ClusterRemovalRefSetter.h.

Referenced by ClusterRemovalRefSetter(), reKey(), reKeyPixel(), and reKeyStrip().