Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:14:51

0001 #include "FWCore/Framework/interface/ESProducer.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0006 #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h"
0007 #include "Geometry/TrackerNumberingBuilder/interface/utils.h"
0008 
0009 #include "CalibFormats/SiStripObjects/interface/SiStripHashedDetId.h"
0010 #include "CalibTracker/Records/interface/SiStripHashedDetIdRcd.h"
0011 
0012 class SiStripHashedDetIdFakeESSource : public edm::ESProducer {
0013 public:
0014   explicit SiStripHashedDetIdFakeESSource(const edm::ParameterSet&);
0015   ~SiStripHashedDetIdFakeESSource() override;
0016 
0017   virtual std::unique_ptr<SiStripHashedDetId> produce(const SiStripHashedDetIdRcd&);
0018 
0019 private:
0020   const edm::ESGetToken<GeometricDet, IdealGeometryRecord> geomDetToken_;
0021 };
0022 
0023 using namespace sistrip;
0024 
0025 SiStripHashedDetIdFakeESSource::SiStripHashedDetIdFakeESSource(const edm::ParameterSet& pset)
0026     : geomDetToken_(setWhatProduced(this).consumes()) {}
0027 
0028 SiStripHashedDetIdFakeESSource::~SiStripHashedDetIdFakeESSource() {}
0029 
0030 std::unique_ptr<SiStripHashedDetId> SiStripHashedDetIdFakeESSource::produce(const SiStripHashedDetIdRcd& record) {
0031   edm::LogVerbatim("HashedDetId") << "[SiStripHashedDetIdFakeESSource::" << __func__ << "]"
0032                                   << " Building \"fake\" hashed DetId map from IdealGeometry";
0033 
0034   const auto& geomDet = record.getRecord<TrackerDigiGeometryRecord>().get(geomDetToken_);
0035 
0036   const std::vector<uint32_t> dets = TrackerGeometryUtils::getSiStripDetIds(geomDet);
0037   edm::LogVerbatim("HashedDetId") << "[SiStripHashedDetIdFakeESSource::" << __func__ << "]"
0038                                   << " Retrieved " << dets.size() << " DetIds from IdealGeometry!";
0039 
0040   auto hash = std::make_unique<SiStripHashedDetId>(dets);
0041   LogTrace("HashedDetId") << "[SiStripHashedDetIdFakeESSource::" << __func__ << "]"
0042                           << " DetId hash map: " << std::endl
0043                           << *hash;
0044 
0045   return hash;
0046 }
0047 
0048 #include "FWCore/Framework/interface/MakerMacros.h"
0049 #include "FWCore/Framework/interface/ModuleFactory.h"
0050 DEFINE_FWK_EVENTSETUP_MODULE(SiStripHashedDetIdFakeESSource);