CMS 3D CMS Logo

Functions
calculateIdMD5.cc File Reference
#include <iostream>
#include <TSystem.h>
#include "FWCore/FWLite/interface/FWLiteEnabler.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSetReader/interface/ParameterSetReader.h"
#include <openssl/md5.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 14 of file calculateIdMD5.cc.

14  {
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 }

References dir2webdir::argc, cmsBatch::argv, gather_cfg::cout, edm::ParameterSet::dump(), FWLiteEnabler::enable(), Exception, beamvalidation::exit(), mps_fire::i, edm::readPSetsFrom(), AlCaHLTBitMon_QueryRunRegistry::string, edm::ParameterSet::trackedPart(), and Types::untracked.

cmsBatch.argv
argv
Definition: cmsBatch.py:279
mps_fire.i
i
Definition: mps_fire.py:428
dir2webdir.argc
argc
Definition: dir2webdir.py:39
edm::readPSetsFrom
std::unique_ptr< edm::ParameterSet > readPSetsFrom(std::string const &fileOrString)
Definition: ParameterSetReader.cc:23
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ParameterSet::dump
std::string dump(unsigned int indent=0) const
Definition: ParameterSet.cc:832
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWLiteEnabler::enable
static void enable()
enable automatic library loading
Definition: FWLiteEnabler.cc:46
edm::ParameterSet
Definition: ParameterSet.h:47
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::trackedPart
ParameterSet trackedPart() const
Definition: ParameterSet.cc:686
Types.untracked
untracked
Definition: Types.py:35
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53