File indexing completed on 2024-08-23 12:58:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
0023
0024 #include "FWCore/Framework/interface/ModuleFactory.h"
0025 #include "FWCore/Framework/interface/ESProducer.h"
0026 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0027
0028 #include "CalibCalorimetry/CaloTPG/interface/CaloTPGTranscoderULUT.h"
0029 #include "CalibFormats/CaloTPG/interface/CaloTPGRecord.h"
0030 #include "FWCore/Framework/interface/ValidityInterval.h"
0031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032
0033 #include "FWCore/Framework/interface/ESHandle.h"
0034 #include "CondFormats/HcalObjects/interface/HcalLutMetadata.h"
0035 #include "Geometry/HcalTowerAlgo/interface/HcalTrigTowerGeometry.h"
0036 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0037 #include "Geometry/Records/interface/HcalRecNumberingRecord.h"
0038
0039
0040
0041
0042
0043 class CaloTPGTranscoderULUTs : public edm::ESProducer {
0044 public:
0045 CaloTPGTranscoderULUTs(const edm::ParameterSet&);
0046 ~CaloTPGTranscoderULUTs() override;
0047
0048 typedef std::unique_ptr<CaloTPGTranscoder> ReturnType;
0049
0050 ReturnType produce(const CaloTPGRecord&);
0051
0052 private:
0053
0054 const edm::FileInPath hfilename1_;
0055 const edm::FileInPath hfilename2_;
0056 const bool read_Ascii_Compression;
0057 const bool read_Ascii_RCT;
0058 const std::vector<int> ietal;
0059 const std::vector<int> ietah;
0060 const std::vector<int> ZS;
0061 const std::vector<int> LUTfactor;
0062 const bool linearLUTs_;
0063 const double nominal_gain;
0064 const double RCTLSB;
0065 const int NCTScaleShift;
0066 const int RCTScaleShift;
0067 const double lsbQIE8;
0068 const double lsbQIE11;
0069 edm::ESGetToken<HcalLutMetadata, HcalLutMetadataRcd> lutMetadataToken;
0070 edm::ESGetToken<HcalTrigTowerGeometry, CaloGeometryRecord> theTrigTowerGeometryToken;
0071 edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> topoToken;
0072 };
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 CaloTPGTranscoderULUTs::CaloTPGTranscoderULUTs(const edm::ParameterSet& iConfig)
0086 : hfilename1_(iConfig.getParameter<edm::FileInPath>("hcalLUT1")),
0087 hfilename2_(iConfig.getParameter<edm::FileInPath>("hcalLUT2")),
0088 read_Ascii_Compression(iConfig.getParameter<bool>("read_Ascii_Compression_LUTs")),
0089 read_Ascii_RCT(iConfig.getParameter<bool>("read_Ascii_RCT_LUTs")),
0090 ietal(iConfig.getParameter<std::vector<int>>("ietaLowerBound")),
0091 ietah(iConfig.getParameter<std::vector<int>>("ietaUpperBound")),
0092 ZS(iConfig.getParameter<std::vector<int>>("ZS")),
0093 LUTfactor(iConfig.getParameter<std::vector<int>>("LUTfactor")),
0094 linearLUTs_(iConfig.getParameter<bool>("linearLUTs")),
0095 nominal_gain(iConfig.getParameter<double>("nominal_gain")),
0096 RCTLSB(iConfig.getParameter<double>("RCTLSB")),
0097 NCTScaleShift(iConfig.getParameter<edm::ParameterSet>("tpScales")
0098 .getParameter<edm::ParameterSet>("HF")
0099 .getParameter<int>("NCTShift")),
0100 RCTScaleShift(iConfig.getParameter<edm::ParameterSet>("tpScales")
0101 .getParameter<edm::ParameterSet>("HF")
0102 .getParameter<int>("RCTShift")),
0103 lsbQIE8(iConfig.getParameter<edm::ParameterSet>("tpScales")
0104 .getParameter<edm::ParameterSet>("HBHE")
0105 .getParameter<double>("LSBQIE8")),
0106 lsbQIE11(iConfig.getParameter<edm::ParameterSet>("tpScales")
0107 .getParameter<edm::ParameterSet>("HBHE")
0108 .getParameter<double>("LSBQIE11")) {
0109 auto cc = setWhatProduced(this);
0110 lutMetadataToken = cc.consumes();
0111 theTrigTowerGeometryToken = cc.consumes();
0112 topoToken = cc.consumes();
0113 }
0114
0115 CaloTPGTranscoderULUTs::~CaloTPGTranscoderULUTs() {
0116
0117
0118 }
0119
0120
0121
0122
0123
0124
0125 CaloTPGTranscoderULUTs::ReturnType CaloTPGTranscoderULUTs::produce(const CaloTPGRecord& iRecord) {
0126 using namespace edm::es;
0127 std::string file1 = "";
0128 std::string file2 = "";
0129 if (read_Ascii_RCT && read_Ascii_Compression) {
0130 edm::LogInfo("Level1") << "Using " << hfilename1_.fullPath() << " & " << hfilename2_.fullPath()
0131 << " for CaloTPGTranscoderULUTs HCAL initialization";
0132
0133
0134 file1 = hfilename1_.fullPath();
0135 file2 = hfilename2_.fullPath();
0136 } else if (read_Ascii_RCT && !read_Ascii_Compression) {
0137 edm::LogInfo("Level1") << "Using analytical compression and " << hfilename2_.fullPath()
0138 << " RCT decompression for CaloTPGTranscoderULUTs HCAL initialization";
0139
0140
0141 file2 = hfilename2_.fullPath();
0142 } else if (read_Ascii_Compression && !read_Ascii_RCT) {
0143 edm::LogInfo("Level1") << "Using ASCII compression tables " << hfilename1_.fullPath()
0144 << " and automatic RCT decompression for CaloTPGTranscoderULUTs HCAL initialization";
0145
0146
0147 file1 = hfilename1_.fullPath();
0148 } else {
0149 edm::LogInfo("Level1")
0150 << "Using analytical compression and RCT decompression for CaloTPGTranscoderULUTs HCAL initialization";
0151
0152
0153 }
0154
0155
0156 const auto& lutMetadata = iRecord.get(lutMetadataToken);
0157 const auto& theTrigTowerGeometry = iRecord.get(theTrigTowerGeometryToken);
0158 const auto& topoRecord = iRecord.getRecord<HcalLutMetadataRcd>();
0159 const auto& topo = topoRecord.get(topoToken);
0160
0161 HcalLutMetadata fullLut{lutMetadata};
0162 fullLut.setTopo(&topo);
0163
0164 auto pTCoder = std::make_unique<CaloTPGTranscoderULUT>(file1, file2);
0165 pTCoder->setup(fullLut, theTrigTowerGeometry, NCTScaleShift, RCTScaleShift, lsbQIE8, lsbQIE11, linearLUTs_);
0166 return pTCoder;
0167 }
0168
0169
0170 DEFINE_FWK_EVENTSETUP_MODULE(CaloTPGTranscoderULUTs);