File indexing completed on 2023-03-17 10:42:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 #include "FWCore/Framework/interface/SourceFactory.h"
0016 #include "FWCore/Framework/interface/ModuleFactory.h"
0017
0018 #include "FWCore/Framework/interface/ESHandle.h"
0019 #include "FWCore/Framework/interface/ESProducer.h"
0020 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0021 #include "FWCore/Framework/interface/ESProducts.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024
0025 #include "CondFormats/PPSObjects/interface/PPSPixelTopology.h"
0026 #include "CondFormats/DataRecord/interface/PPSPixelTopologyRcd.h"
0027 #include "FWCore/Utilities/interface/Exception.h"
0028
0029 #include <memory>
0030
0031
0032
0033
0034
0035 class PPSPixelTopologyESSource : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
0036 public:
0037 PPSPixelTopologyESSource(const edm::ParameterSet&);
0038 ~PPSPixelTopologyESSource() override = default;
0039
0040 std::unique_ptr<PPSPixelTopology> produce(const PPSPixelTopologyRcd&);
0041 static void fillDescriptions(edm::ConfigurationDescriptions&);
0042
0043 private:
0044
0045 void setPPSPixelTopology(const edm::ParameterSet&);
0046
0047 std::unique_ptr<PPSPixelTopology> fillPPSPixelTopology();
0048
0049
0050 std::string runType_;
0051 double pitch_simY_;
0052 double pitch_simX_;
0053 double thickness_;
0054 unsigned short no_of_pixels_simX_;
0055 unsigned short no_of_pixels_simY_;
0056 unsigned short no_of_pixels_;
0057 double simX_width_;
0058 double simY_width_;
0059 double dead_edge_width_;
0060 double active_edge_sigma_;
0061 double phys_active_edge_dist_;
0062
0063 protected:
0064
0065 void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0066 const edm::IOVSyncValue&,
0067 edm::ValidityInterval&) override;
0068 };
0069
0070
0071
0072 PPSPixelTopologyESSource::PPSPixelTopologyESSource(const edm::ParameterSet& iConfig)
0073 : runType_(""),
0074 pitch_simY_(0.),
0075 pitch_simX_(0.),
0076 thickness_(0.),
0077 no_of_pixels_simX_(0.),
0078 no_of_pixels_simY_(0.),
0079 no_of_pixels_(0.),
0080 simX_width_(0.),
0081 simY_width_(0.),
0082 dead_edge_width_(0.),
0083 active_edge_sigma_(0.),
0084 phys_active_edge_dist_(0.) {
0085 setPPSPixelTopology(iConfig);
0086
0087
0088 if (runType_ != "Run2" && runType_ != "Run3")
0089 throw cms::Exception("PPS") << runType_ << " is not valid runType.";
0090
0091 setWhatProduced(this);
0092 findingRecord<PPSPixelTopologyRcd>();
0093 }
0094
0095
0096
0097 std::unique_ptr<PPSPixelTopology> PPSPixelTopologyESSource::produce(const PPSPixelTopologyRcd&) {
0098 auto topo = fillPPSPixelTopology();
0099
0100 edm::LogInfo("PPS") << "PixelTopologyESSource::produce \n" << *topo;
0101
0102 return topo;
0103 }
0104
0105
0106
0107 void PPSPixelTopologyESSource::setPPSPixelTopology(const edm::ParameterSet& iConfig) {
0108 runType_ = iConfig.getParameter<std::string>("RunType");
0109 pitch_simY_ = iConfig.getParameter<double>("PitchSimY");
0110 pitch_simX_ = iConfig.getParameter<double>("PitchSimX");
0111 thickness_ = iConfig.getParameter<double>("thickness");
0112 no_of_pixels_simX_ = iConfig.getParameter<int>("noOfPixelSimX");
0113 no_of_pixels_simY_ = iConfig.getParameter<int>("noOfPixelSimY");
0114 no_of_pixels_ = iConfig.getParameter<int>("noOfPixels");
0115 simX_width_ = iConfig.getParameter<double>("simXWidth");
0116 simY_width_ = iConfig.getParameter<double>("simYWidth");
0117 dead_edge_width_ = iConfig.getParameter<double>("deadEdgeWidth");
0118 active_edge_sigma_ = iConfig.getParameter<double>("activeEdgeSigma");
0119 phys_active_edge_dist_ = iConfig.getParameter<double>("physActiveEdgeDist");
0120 }
0121
0122
0123
0124 std::unique_ptr<PPSPixelTopology> PPSPixelTopologyESSource::fillPPSPixelTopology() {
0125 auto p = std::make_unique<PPSPixelTopology>();
0126
0127 p->setRunType(runType_);
0128 p->setPitchSimY(pitch_simY_);
0129 p->setPitchSimX(pitch_simX_);
0130 p->setThickness(thickness_);
0131 p->setNoPixelsSimX(no_of_pixels_simX_);
0132 p->setNoPixelsSimY(no_of_pixels_simY_);
0133 p->setNoPixels(no_of_pixels_);
0134 p->setSimXWidth(simX_width_);
0135 p->setSimYWidth(simY_width_);
0136 p->setDeadEdgeWidth(dead_edge_width_);
0137 p->setActiveEdgeSigma(active_edge_sigma_);
0138 p->setPhysActiveEdgeDist(phys_active_edge_dist_);
0139 p->setActiveEdgeX(simX_width_ / 2. - phys_active_edge_dist_);
0140 p->setActiveEdgeY(simY_width_ / 2. - phys_active_edge_dist_);
0141
0142 return p;
0143 }
0144
0145
0146
0147 void PPSPixelTopologyESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey& key,
0148 const edm::IOVSyncValue& iosv,
0149 edm::ValidityInterval& oValidity) {
0150 edm::LogInfo("PPS") << ">> PPSPixelTopologyESSource::setIntervalFor(" << key.name() << ")\n"
0151 << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
0152
0153 edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
0154 oValidity = infinity;
0155 }
0156
0157
0158
0159 void PPSPixelTopologyESSource::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0160 edm::ParameterSetDescription desc;
0161 desc.add<std::string>("RunType", "Run3");
0162 desc.add<double>("PitchSimY", 150e-3);
0163 desc.add<double>("PitchSimX", 100e-3);
0164 desc.add<double>("thickness", 0.23);
0165 desc.add<int>("noOfPixelSimX", 160);
0166 desc.add<int>("noOfPixelSimY", 104);
0167 desc.add<int>("noOfPixels", 160 * 104);
0168 desc.add<double>("simXWidth", 16.6);
0169 desc.add<double>("simYWidth", 16.2);
0170 desc.add<double>("deadEdgeWidth", 200e-3);
0171 desc.add<double>("activeEdgeSigma", 0.02);
0172 desc.add<double>("physActiveEdgeDist", 0.150);
0173
0174 descriptions.add("ppsPixelTopologyESSource", desc);
0175 }
0176
0177
0178
0179 DEFINE_FWK_EVENTSETUP_SOURCE(PPSPixelTopologyESSource);