File indexing completed on 2024-04-06 12:22:26
0001 #include <iomanip>
0002 #include <iostream>
0003
0004 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0005
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008
0009 #include "FWCore/Framework/interface/EventSetup.h"
0010 #include "FWCore/Framework/interface/ESHandle.h"
0011
0012 #include "CondFormats/DataRecord/interface/L1TMuonBarrelKalmanParamsRcd.h"
0013 #include "CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h"
0014 #include "FWCore/ServiceRegistry/interface/Service.h"
0015 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0016 #include "CondCore/CondDB/interface/Session.h"
0017
0018 #include <iostream>
0019 using namespace std;
0020
0021 class L1TMuonBarrelKalmanParamsViewer : public edm::one::EDAnalyzer<> {
0022 private:
0023 edm::ESGetToken<L1TMuonBarrelKalmanParams, L1TMuonBarrelKalmanParamsRcd> token_;
0024 std::string hash(void *buf, size_t len) const;
0025
0026 public:
0027 void analyze(const edm::Event &, const edm::EventSetup &) override;
0028
0029 L1TMuonBarrelKalmanParamsViewer(const edm::ParameterSet &) : token_{esConsumes()} {};
0030 };
0031
0032 #include "Utilities/OpenSSL/interface/openssl_init.h"
0033 #include <cmath>
0034 #include <iostream>
0035 using namespace std;
0036
0037 std::string L1TMuonBarrelKalmanParamsViewer::hash(void *buf, size_t len) const {
0038 cms::openssl_init();
0039 EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
0040 const EVP_MD *md = EVP_get_digestbyname("SHA1");
0041 if (!EVP_DigestInit_ex(mdctx, md, nullptr))
0042 throw cms::Exception("L1TMuonBarrelKalmanParamsViewer::hash") << "SHA1 initialization error";
0043
0044 if (!EVP_DigestUpdate(mdctx, buf, len))
0045 throw cms::Exception("L1TMuonBarrelKalmanParamsViewer::hash") << "SHA1 processing error";
0046
0047 unsigned char hash[EVP_MAX_MD_SIZE];
0048 unsigned int md_len = 0;
0049 if (!EVP_DigestFinal_ex(mdctx, hash, &md_len))
0050 throw cms::Exception("L1TMuonBarrelKalmanParamsViewer::hash") << "SHA1 finalization error";
0051
0052 EVP_MD_CTX_free(mdctx);
0053
0054
0055 char tmp[EVP_MAX_MD_SIZE * 2 + 1];
0056 if (md_len > 20)
0057 md_len = 20;
0058 for (unsigned int i = 0; i < md_len; i++)
0059 ::sprintf(&tmp[i * 2], "%02x", hash[i]);
0060
0061 tmp[md_len * 2] = 0;
0062 return std::string(tmp);
0063 }
0064
0065 void L1TMuonBarrelKalmanParamsViewer::analyze(const edm::Event &iEvent, const edm::EventSetup &evSetup) {
0066 L1TMuonBarrelKalmanParams const &ptr = evSetup.getData(token_);
0067
0068
0069 auto pnodes = ptr.pnodes_[ptr.CONFIG];
0070 cout << "version : " << ptr.version_ << endl;
0071 cout << "fwVersion : " << hex << pnodes.fwVersion_ << dec << endl;
0072 cout << "LUTsPath : " << pnodes.kalmanLUTsPath_ << endl;
0073
0074
0075 }
0076
0077 #include "FWCore/PluginManager/interface/ModuleDef.h"
0078 #include "FWCore/Framework/interface/MakerMacros.h"
0079 #include "FWCore/Framework/interface/ModuleFactory.h"
0080
0081 DEFINE_FWK_MODULE(L1TMuonBarrelKalmanParamsViewer);