CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ClusterRemovalRefSetter Class Reference

#include <ClusterRemovalRefSetter.h>

Public Member Functions

 ClusterRemovalRefSetter (const edm::Event &iEvent, const edm::InputTag tag)
 
void reKey (TrackingRecHit *hit) const
 
void reKey (SiStripRecHit2D *hit, uint32_t detid) const
 
void reKey (SiStripRecHit1D *hit, uint32_t detid) const
 
void reKey (SiPixelRecHit *hit, uint32_t detid) const
 

Private Attributes

const reco::ClusterRemovalInfocri_
 

Detailed Description

Definition at line 20 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().

4  {
6  iEvent.getByLabel(tag, hCRI);
7  cri_ = &*hCRI;
8 
9  //std::cout << "Rekeying PIXEL ProdID " << cri_->pixelNewRefProd().id() << " => " << cri_->pixelRefProd().id() << std::endl;
10  //std::cout << "Rekeying STRIP ProdID " << cri_->stripNewRefProd().id() << " => " << cri_->stripRefProd().id() << std::endl;
11 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
const reco::ClusterRemovalInfo * cri_

Member Function Documentation

void ClusterRemovalRefSetter::reKey ( TrackingRecHit hit) const

Definition at line 13 of file ClusterRemovalRefSetter.cc.

References cri_, cond::rpcobgas::detid, edm::hlt::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::SimpleTrackListMerger::produce(), and KfTrackProducerBase::putInEvt().

13  {
14  if (!hit->isValid()) return;
15  DetId detid = hit->geographicalId();
16  uint32_t subdet = detid.subdetId();
17  if ((subdet == PixelSubdetector::PixelBarrel) || (subdet == PixelSubdetector::PixelEndcap)) {
18  if (!cri_->hasPixel()) return;
19  reKey(reinterpret_cast<SiPixelRecHit *>(hit), detid.rawId());
20  } else {
21  if (!cri_->hasStrip()) return;
22  const std::type_info &type = typeid(*hit);
23  if (type == typeid(SiStripRecHit2D)) {
24  reKey(reinterpret_cast<SiStripRecHit2D *>(hit), detid.rawId());
25  } else if (type == typeid(SiStripRecHit1D)) {
26  reKey(reinterpret_cast<SiStripRecHit1D *>(hit), detid.rawId());
27  } else if (type == typeid(SiStripMatchedRecHit2D)) {
28  SiStripMatchedRecHit2D *mhit = reinterpret_cast<SiStripMatchedRecHit2D *>(hit);
29  // const_cast is needed: monoHit() e stereoHit() are const only - at least for now
30  reKey(mhit->monoHit(), mhit->monoHit()->geographicalId().rawId());
31  reKey(mhit->stereoHit(), mhit->stereoHit()->geographicalId().rawId());
32  } else if (type == typeid(ProjectedSiStripRecHit2D)) {
33  ProjectedSiStripRecHit2D *phit = reinterpret_cast<ProjectedSiStripRecHit2D *>(hit);
34  reKey(&phit->originalHit(), phit->originalHit().geographicalId().rawId());
35  } else throw cms::Exception("Unknown RecHit Type") << "RecHit of type " << type.name() << " not supported. (use c++filt to demangle the name)";
36  }
37 }
type
Definition: HCALResponse.h:22
const SiStripRecHit2D * stereoHit() const
void reKey(TrackingRecHit *hit) const
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
Definition: DetId.h:20
bool isValid() const
DetId geographicalId() const
const SiStripRecHit2D * monoHit() const
const reco::ClusterRemovalInfo * cri_
const SiStripRecHit2D & originalHit() const
void ClusterRemovalRefSetter::reKey ( SiStripRecHit2D hit,
uint32_t  detid 
) const

Definition at line 39 of file ClusterRemovalRefSetter.cc.

References SiStripRecHit2D::cluster(), cri_, edm::hlt::Exception, edm::RefProd< T >::id(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), SiStripRecHit2D::setClusterRef(), reco::ClusterRemovalInfo::stripIndices(), reco::ClusterRemovalInfo::stripNewRefProd(), and reco::ClusterRemovalInfo::stripRefProd().

39  {
41  const ClusterRemovalInfo::Indices &indices = cri_->stripIndices();
42  SiStripRecHit2D::ClusterRef newRef = hit->cluster();
43  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
44 
45  if (newRef.id() != cri_->stripNewRefProd().id()) { // this is a cfg error in the tracking configuration, much more likely
46  throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " <<
47  "Existing strip cluster refers to product ID " << newRef.id() <<
48  " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->stripNewRefProd().id() << "\n";
49  }
50 
51  size_t newIndex = newRef.key();
52  assert(newIndex < indices.size());
53  size_t oldIndex = indices[newIndex];
54  SiStripRecHit2D::ClusterRef oldRef(cri_->stripRefProd(), oldIndex);
55  hit->setClusterRef(oldRef);
56 }
const SiStripClusterRefProd & stripRefProd() const
void setClusterRef(ClusterRef const &ref)
ClusterRef const & cluster() const
key_type key() const
Accessor for product key.
Definition: Ref.h:264
const SiStripClusterRefProd & stripNewRefProd() const
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:141
ProductID id() const
Accessor for product ID.
Definition: Ref.h:254
const reco::ClusterRemovalInfo * cri_
void ClusterRemovalRefSetter::reKey ( SiStripRecHit1D hit,
uint32_t  detid 
) const

Definition at line 58 of file ClusterRemovalRefSetter.cc.

References SiStripRecHit1D::cluster(), cri_, edm::hlt::Exception, edm::RefProd< T >::id(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), SiStripRecHit1D::setClusterRef(), reco::ClusterRemovalInfo::stripIndices(), reco::ClusterRemovalInfo::stripNewRefProd(), and reco::ClusterRemovalInfo::stripRefProd().

58  {
60  const ClusterRemovalInfo::Indices &indices = cri_->stripIndices();
61  SiStripRecHit1D::ClusterRef newRef = hit->cluster();
62  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
63 
64  if (newRef.id() != cri_->stripNewRefProd().id()) { // this is a cfg error in the tracking configuration, much more likely
65  throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " <<
66  "Existing strip cluster refers to product ID " << newRef.id() <<
67  " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->stripNewRefProd().id() << "\n";
68  }
69 
70  size_t newIndex = newRef.key();
71  assert(newIndex < indices.size());
72  size_t oldIndex = indices[newIndex];
73  SiStripRecHit1D::ClusterRef oldRef(cri_->stripRefProd(), oldIndex);
74  hit->setClusterRef(oldRef);
75 }
const SiStripClusterRefProd & stripRefProd() const
void setClusterRef(ClusterRef const &ref)
key_type key() const
Accessor for product key.
Definition: Ref.h:264
const SiStripClusterRefProd & stripNewRefProd() const
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:141
ClusterRef const & cluster() const
ProductID id() const
Accessor for product ID.
Definition: Ref.h:254
const reco::ClusterRemovalInfo * cri_
void ClusterRemovalRefSetter::reKey ( SiPixelRecHit hit,
uint32_t  detid 
) const

Definition at line 77 of file ClusterRemovalRefSetter.cc.

References SiPixelRecHit::cluster(), cri_, edm::hlt::Exception, edm::RefProd< T >::id(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::key(), reco::ClusterRemovalInfo::pixelIndices(), reco::ClusterRemovalInfo::pixelNewRefProd(), reco::ClusterRemovalInfo::pixelRefProd(), and SiPixelRecHit::setClusterRef().

77  {
79  const ClusterRemovalInfo::Indices &indices = cri_->pixelIndices();
80  SiPixelRecHit::ClusterRef newRef = hit->cluster();
81  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
82 
83  if (newRef.id() != cri_->pixelNewRefProd().id()) {
84  throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " <<
85  "Existing pixel cluster refers to product ID " << newRef.id() <<
86  " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->pixelNewRefProd().id() << "\n";
87  }
88  size_t newIndex = newRef.key();
89  assert(newIndex < indices.size());
90  size_t oldIndex = indices[newIndex];
91  SiPixelRecHit::ClusterRef oldRef(cri_->pixelRefProd(), oldIndex);
92  hit->setClusterRef(oldRef);
93 }
const SiPixelClusterRefProd & pixelRefProd() const
void setClusterRef(const ClusterRef &ref)
Definition: SiPixelRecHit.h:43
const SiPixelClusterRefProd & pixelNewRefProd() const
key_type key() const
Accessor for product key.
Definition: Ref.h:264
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:141
ProductID id() const
Accessor for product ID.
Definition: Ref.h:254
const reco::ClusterRemovalInfo * cri_
ClusterRef const & cluster() const
Definition: SiPixelRecHit.h:42

Member Data Documentation

const reco::ClusterRemovalInfo* ClusterRemovalRefSetter::cri_
private

Definition at line 28 of file ClusterRemovalRefSetter.h.

Referenced by ClusterRemovalRefSetter(), and reKey().