CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
calculateIdMD5.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <TSystem.h>
3 
6 
9 
10 #include <openssl/md5.h>
11 
12 using namespace std;
13 
14 int main(int argc, char** argv) {
15  // load framework libraries
16  gSystem->Load("libFWCoreFWLite");
18 
19  if (argc < 3) {
20  std::cout << "Usage : " << argv[0] << " [your_cutflow_only.py] "
21  << "[cutflow_name] " << std::endl;
22  return 0;
23  }
24 
25  if (!edm::readPSetsFrom(argv[1])->existsAs<edm::ParameterSet>(argv[2])) {
26  std::cout << " ERROR: ParametersSet '" << argv[2] << "' is missing in your configuration file" << std::endl;
27  exit(0);
28  }
29 
30  edm::ParameterSet conf = edm::readPSetsFrom(argv[1])->getParameterSet(argv[2]);
31  edm::ParameterSet trackedconf = conf.trackedPart();
32 
33  std::string tracked(trackedconf.dump()), untracked(conf.dump());
34 
35  if (tracked != untracked) {
36  throw cms::Exception("InvalidConfiguration") << "IDs are not allowed to have untracked parameters"
37  << " in the configuration ParameterSet!";
38  }
39 
40  // now setup the md5 and cute accessor functions
41  unsigned char id_md5_[MD5_DIGEST_LENGTH];
42  memset(id_md5_, 0, MD5_DIGEST_LENGTH * sizeof(unsigned char));
43  MD5((const unsigned char*)tracked.c_str(), tracked.size(), id_md5_);
44  printf("%s : ", argv[2]);
45  for (unsigned i = 0; i < MD5_DIGEST_LENGTH; ++i) {
46  printf("%02x", id_md5_[i]);
47  }
48  printf("\n");
49 
50  return 0;
51 }
std::string dump(unsigned int indent=0) const
ParameterSet trackedPart() const
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
static void enable()
enable automatic library loading
std::unique_ptr< edm::ParameterSet > readPSetsFrom(std::string const &fileOrString)
tuple argc
Definition: dir2webdir.py:39
tuple cout
Definition: gather_cfg.py:144
tuple untracked
Definition: Types.py:34