File indexing completed on 2024-08-23 12:58:59
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& geomDetRcd = record.getRecord<TrackerDigiGeometryRecord>();
0035 const auto& geomDet = geomDetRcd.get(geomDetToken_);
0036
0037 const std::vector<uint32_t> dets = TrackerGeometryUtils::getSiStripDetIds(geomDet);
0038 edm::LogVerbatim("HashedDetId") << "[SiStripHashedDetIdFakeESSource::" << __func__ << "]"
0039 << " Retrieved " << dets.size() << " DetIds from IdealGeometry!";
0040
0041 auto hash = std::make_unique<SiStripHashedDetId>(dets);
0042 LogTrace("HashedDetId") << "[SiStripHashedDetIdFakeESSource::" << __func__ << "]"
0043 << " DetId hash map: " << std::endl
0044 << *hash;
0045
0046 return hash;
0047 }
0048
0049 #include "FWCore/Framework/interface/MakerMacros.h"
0050 #include "FWCore/Framework/interface/ModuleFactory.h"
0051 DEFINE_FWK_EVENTSETUP_MODULE(SiStripHashedDetIdFakeESSource);