File indexing completed on 2023-03-17 11:16:39
0001 #include <iostream>
0002 #include <TSystem.h>
0003
0004 #include "FWCore/FWLite/interface/FWLiteEnabler.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
0009
0010 #include "Utilities/OpenSSL/interface/openssl_init.h"
0011
0012 using namespace std;
0013
0014 int main(int argc, char** argv) {
0015
0016 gSystem->Load("libFWCoreFWLite");
0017 FWLiteEnabler::enable();
0018
0019 if (argc < 3) {
0020 std::cout << "Usage : " << argv[0] << " [your_cutflow_only.py] "
0021 << "[cutflow_name] " << std::endl;
0022 return 0;
0023 }
0024
0025 if (!edm::readPSetsFrom(argv[1])->existsAs<edm::ParameterSet>(argv[2])) {
0026 std::cout << " ERROR: ParametersSet '" << argv[2] << "' is missing in your configuration file" << std::endl;
0027 exit(0);
0028 }
0029
0030 edm::ParameterSet conf = edm::readPSetsFrom(argv[1])->getParameterSet(argv[2]);
0031 edm::ParameterSet trackedconf = conf.trackedPart();
0032
0033 std::string tracked(trackedconf.dump()), untracked(conf.dump());
0034
0035 if (tracked != untracked) {
0036 throw cms::Exception("InvalidConfiguration") << "IDs are not allowed to have untracked parameters"
0037 << " in the configuration ParameterSet!";
0038 }
0039
0040
0041 cms::openssl_init();
0042 EVP_MD_CTX* mdctx = EVP_MD_CTX_new();
0043 const EVP_MD* md = EVP_get_digestbyname("SHA1");
0044 unsigned int md_len = 0;
0045 unsigned char id_md5_[EVP_MAX_MD_SIZE];
0046
0047 EVP_DigestInit_ex(mdctx, md, nullptr);
0048 EVP_DigestUpdate(mdctx, (const unsigned char*)tracked.c_str(), tracked.size());
0049 EVP_DigestFinal_ex(mdctx, id_md5_, &md_len);
0050 EVP_MD_CTX_free(mdctx);
0051
0052 printf("%s : ", argv[2]);
0053 for (unsigned i = 0; i < md_len; ++i) {
0054 printf("%02x", id_md5_[i]);
0055 }
0056 printf("\n");
0057
0058 return 0;
0059 }