CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterRemovalRefSetter.cc
Go to the documentation of this file.
3 
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 }
12 
16  iEvent.getByToken(token, hCRI);
17  cri_ = &*hCRI;
18 }
19 
21  if (!hit->isValid()) return;
22  DetId detid = hit->geographicalId();
23  uint32_t subdet = detid.subdetId();
24  if ((subdet == PixelSubdetector::PixelBarrel) || (subdet == PixelSubdetector::PixelEndcap)) {
25  if (!cri_->hasPixel()) return;
26  reKeyPixel(reinterpret_cast<SiPixelRecHit *>(hit)->omniCluster());
27  } else {
28  if (!cri_->hasStrip()) return;
29  const std::type_info &type = typeid(*hit);
30  if (type == typeid(SiStripRecHit2D)) {
31  reKeyStrip(reinterpret_cast<SiStripRecHit2D *>(hit)->omniCluster());
32  } else if (type == typeid(SiStripRecHit1D)) {
33  reKeyStrip(reinterpret_cast<SiStripRecHit1D *>(hit)->omniCluster());
34  } else if (type == typeid(SiStripMatchedRecHit2D)) {
35  SiStripMatchedRecHit2D *mhit = reinterpret_cast<SiStripMatchedRecHit2D *>(hit);
36  reKeyStrip(mhit->monoClusterRef());
37  reKeyStrip(mhit->stereoClusterRef());
38  } else if (type == typeid(ProjectedSiStripRecHit2D)) {
39  ProjectedSiStripRecHit2D *phit = reinterpret_cast<ProjectedSiStripRecHit2D *>(hit);
40  reKeyStrip(phit->originalHit().omniCluster());
41  } else throw cms::Exception("Unknown RecHit Type") << "RecHit of type " << type.name() << " not supported. (use c++filt to demangle the name)";
42  }
43 }
44 
45 
47  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
49  const ClusterRemovalInfo::Indices &indices = cri_->pixelIndices();
50 
51  if (newRef.id() != cri_->pixelNewRefProd().id()) {
52  throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " <<
53  "Existing pixel cluster refers to product ID " << newRef.id() <<
54  " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->pixelNewRefProd().id() << "\n";
55  }
56  size_t newIndex = newRef.key();
57  assert(newIndex < indices.size());
58  size_t oldIndex = indices[newIndex];
59  ClusterPixelRef oldRef(cri_->pixelRefProd(), oldIndex);
60  newRef = OmniClusterRef(oldRef);
61 }
62 
63 
65  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
67  const ClusterRemovalInfo::Indices &indices = cri_->stripIndices();
68 
69  if (newRef.id() != cri_->stripNewRefProd().id()) { // this is a cfg error in the tracking configuration, much more likely
70  throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " <<
71  "Existing strip cluster refers to product ID " << newRef.id() <<
72  " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->stripNewRefProd().id() << "\n";
73  }
74 
75  size_t newIndex = newRef.key();
76  assert(newIndex < indices.size());
77  size_t oldIndex = indices[newIndex];
78  ClusterStripRef oldRef(cri_->stripRefProd(), oldIndex);
79  newRef = OmniClusterRef(oldRef);
80 }
81 
82 
const SiPixelClusterRefProd & pixelRefProd() const
type
Definition: HCALResponse.h:21
const SiStripClusterRefProd & stripRefProd() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void reKey(TrackingRecHit *hit) const
void reKeyPixel(OmniClusterRef &clusRef) const
const SiPixelClusterRefProd & pixelNewRefProd() const
int iEvent
Definition: GenABIO.cc:230
Indices
Definition: EdmEventSize.cc:30
ClusterRemovalRefSetter(const edm::Event &iEvent, const edm::InputTag &tag)
void reKeyStrip(OmniClusterRef &clusRef) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
Definition: DetId.h:18
bool isValid() const
const SiStripClusterRefProd & stripNewRefProd() const
edm::ProductID id() const
ProductID id() const
Accessor for product ID.
Definition: RefProd.h:140
DetId geographicalId() const
const reco::ClusterRemovalInfo * cri_
unsigned int key() const