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 
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  reKeyPixel(reinterpret_cast<SiPixelRecHit *>(hit)->omniCluster());
20  } else {
21  if (!cri_->hasStrip()) return;
22  const std::type_info &type = typeid(*hit);
23  if (type == typeid(SiStripRecHit2D)) {
24  reKeyStrip(reinterpret_cast<SiStripRecHit2D *>(hit)->omniCluster());
25  } else if (type == typeid(SiStripRecHit1D)) {
26  reKeyStrip(reinterpret_cast<SiStripRecHit1D *>(hit)->omniCluster());
27  } else if (type == typeid(SiStripMatchedRecHit2D)) {
28  SiStripMatchedRecHit2D *mhit = reinterpret_cast<SiStripMatchedRecHit2D *>(hit);
29  reKeyStrip(mhit->monoClusterRef());
30  reKeyStrip(mhit->stereoClusterRef());
31  } else if (type == typeid(ProjectedSiStripRecHit2D)) {
32  ProjectedSiStripRecHit2D *phit = reinterpret_cast<ProjectedSiStripRecHit2D *>(hit);
33  reKeyStrip(phit->originalHit().omniCluster());
34  } else throw cms::Exception("Unknown RecHit Type") << "RecHit of type " << type.name() << " not supported. (use c++filt to demangle the name)";
35  }
36 }
37 
38 
40  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
43 
44  if (newRef.id() != cri_->pixelNewRefProd().id()) {
45  throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " <<
46  "Existing pixel cluster refers to product ID " << newRef.id() <<
47  " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->pixelNewRefProd().id() << "\n";
48  }
49  size_t newIndex = newRef.key();
50  assert(newIndex < indices.size());
51  size_t oldIndex = indices[newIndex];
52  ClusterPixelRef oldRef(cri_->pixelRefProd(), oldIndex);
53  newRef = OmniClusterRef(oldRef);
54 }
55 
56 
58  // "newRef" as it refs to the "new"(=cleaned) collection, instead of the old one
61 
62  if (newRef.id() != cri_->stripNewRefProd().id()) { // this is a cfg error in the tracking configuration, much more likely
63  throw cms::Exception("Inconsistent Data") << "ClusterRemovalRefSetter: " <<
64  "Existing strip cluster refers to product ID " << newRef.id() <<
65  " while the ClusterRemovalInfo expects as *new* cluster collection the ID " << cri_->stripNewRefProd().id() << "\n";
66  }
67 
68  size_t newIndex = newRef.key();
69  assert(newIndex < indices.size());
70  size_t oldIndex = indices[newIndex];
71  ClusterStripRef oldRef(cri_->stripRefProd(), oldIndex);
72  newRef = OmniClusterRef(oldRef);
73 }
74 
75 
const SiPixelClusterRefProd & pixelRefProd() const
type
Definition: HCALResponse.h:22
const SiStripClusterRefProd & stripRefProd() const
void reKey(TrackingRecHit *hit) const
void reKeyPixel(OmniClusterRef &clusRef) const
const SiPixelClusterRefProd & pixelNewRefProd() const
int iEvent
Definition: GenABIO.cc:243
Indices
Definition: EdmEventSize.cc:30
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:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
Definition: DetId.h:20
ClusterRemovalRefSetter(const edm::Event &iEvent, const edm::InputTag tag)
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
const SiStripRecHit2D & originalHit() const