Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-12 23:11:13

0001 // -*- C++ -*-
0002 //
0003 // Package:    CaloTPGTranscoderULUTs
0004 // Class:      CaloTPGTranscoderULUTs
0005 //
0006 /**\class CaloTPGTranscoderULUTs CaloTPGTranscoderULUTs.h src/CaloTPGTranscoderULUTs/interface/CaloTPGTranscoderULUTs.h
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Jeremiah Mans
0015 //         Created:  Fri Sep 15 11:49:44 CDT 2006
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
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 // class decleration
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   // ----------member data ---------------------------
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 // constants, enums and typedefs
0076 //
0077 
0078 //
0079 // static data member definitions
0080 //
0081 
0082 //
0083 // constructors and destructor
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   // do anything here that needs to be done at desctruction time
0117   // (e.g. close files, deallocate resources etc.)
0118 }
0119 
0120 //
0121 // member functions
0122 //
0123 
0124 // ------------ method called to produce the data  ------------
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     //std::unique_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT(hfilename1_.fullPath(), hfilename2_.fullPath()));
0133     //return pTCoder;
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     //std::unique_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT("", hfilename2_.fullPath()));
0140     //return pTCoder;
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     //std::unique_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT(hfilename1_.fullPath(),""));
0146     //return pTCoder;
0147     file1 = hfilename1_.fullPath();
0148   } else {
0149     edm::LogInfo("Level1")
0150         << "Using analytical compression and RCT decompression for CaloTPGTranscoderULUTs HCAL initialization";
0151     //std::unique_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT());
0152     //return pTCoder;
0153   }
0154   //std::unique_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT(ietal, ietah, ZS, LUTfactor, RCTLSB, nominal_gain, file1, file2));
0155 
0156   const auto& lutMetadata = iRecord.get(lutMetadataToken);
0157   const auto& theTrigTowerGeometry = iRecord.get(theTrigTowerGeometryToken);
0158   const auto& topo = iRecord.getRecord<HcalLutMetadataRcd>().get(topoToken);
0159 
0160   HcalLutMetadata fullLut{lutMetadata};
0161   fullLut.setTopo(&topo);
0162 
0163   auto pTCoder = std::make_unique<CaloTPGTranscoderULUT>(file1, file2);
0164   pTCoder->setup(fullLut, theTrigTowerGeometry, NCTScaleShift, RCTScaleShift, lsbQIE8, lsbQIE11, linearLUTs_);
0165   return pTCoder;
0166 }
0167 
0168 //define this as a plug-in
0169 DEFINE_FWK_EVENTSETUP_MODULE(CaloTPGTranscoderULUTs);