CMS 3D CMS Logo

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 {
16 
17  // load framework libraries
18  gSystem->Load( "libFWCoreFWLite" );
20 
21  if ( argc < 3 ) {
22  std::cout << "Usage : " << argv[0]
23  << " [your_cutflow_only.py] "
24  << "[cutflow_name] "<< std::endl;
25  return 0;
26  }
27 
28  if( !edm::readPSetsFrom(argv[1])->existsAs<edm::ParameterSet>(argv[2]) ){
29  std::cout << " ERROR: ParametersSet '"<< argv[2]
30  << "' is missing in your configuration file"
31  << std::endl; exit(0);
32  }
33 
34  edm::ParameterSet conf = edm::readPSetsFrom(argv[1])->getParameterSet(argv[2]);
35  edm::ParameterSet trackedconf = conf.trackedPart();
36 
37  std::string tracked(trackedconf.dump()), untracked(conf.dump());
38 
39  if ( tracked != untracked ) {
40  throw cms::Exception("InvalidConfiguration")
41  << "IDs are not allowed to have untracked parameters"
42  << " in the configuration ParameterSet!";
43  }
44 
45  // now setup the md5 and cute accessor functions
46  unsigned char id_md5_[MD5_DIGEST_LENGTH];
47  memset(id_md5_,0,MD5_DIGEST_LENGTH*sizeof(unsigned char));
48  MD5((const unsigned char*)tracked.c_str(), tracked.size(), id_md5_);
49  printf("%s : ",argv[2]);
50  for( unsigned i=0; i<MD5_DIGEST_LENGTH; ++i ){
51  printf("%02x", id_md5_[i]);
52  }
53  printf("\n");
54 
55  return 0;
56 }
std::string dump(unsigned int indent=0) const
ParameterSet trackedPart() const
int main(int argc, char **argv)
static void enable()
enable automatic library loading
std::unique_ptr< edm::ParameterSet > readPSetsFrom(std::string const &fileOrString)