CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Typedefs | Functions | Variables
EdmProvDump.cc File Reference
#include "DataFormats/Provenance/interface/BranchType.h"
#include "DataFormats/Provenance/interface/EventSelectionID.h"
#include "DataFormats/Provenance/interface/History.h"
#include "DataFormats/Provenance/interface/ParameterSetBlob.h"
#include "DataFormats/Provenance/interface/ProcessConfigurationRegistry.h"
#include "DataFormats/Provenance/interface/ParameterSetID.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include "DataFormats/Provenance/interface/ProcessConfigurationID.h"
#include "DataFormats/Provenance/interface/ProductRegistry.h"
#include "DataFormats/Provenance/interface/Parentage.h"
#include "DataFormats/Provenance/interface/ProductProvenance.h"
#include "DataFormats/Provenance/interface/StoredProductProvenance.h"
#include "DataFormats/Provenance/interface/ParentageRegistry.h"
#include "FWCore/Catalog/interface/InputFileCatalog.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/Registry.h"
#include "FWCore/ParameterSet/interface/FillProductRegistryTransients.h"
#include "FWCore/ServiceRegistry/interface/ServiceRegistry.h"
#include "FWCore/Services/src/SiteLocalConfigService.h"
#include "FWCore/Utilities/interface/Algorithms.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "Cintex/Cintex.h"
#include "TError.h"
#include "TFile.h"
#include "TTree.h"
#include "boost/program_options.hpp"
#include <assert.h>
#include <iostream>
#include <memory>
#include <map>
#include <set>
#include <sstream>
#include <vector>

Go to the source code of this file.

Classes

class  ProvenanceDumper
 

Typedefs

typedef std::map< std::string,
std::vector
< edm::BranchDescription > > 
IdToBranches
 
typedef std::map< std::pair
< std::string, std::string >
, IdToBranches
ModuleToIdBranches
 

Functions

static void appendToSet (std::set< std::string > &iSet, std::vector< std::string > const &iFrom)
 
std::string eventSetupComponent (char const *iType, std::string const &iCompName, edm::ParameterSet const &iProcessConfig, std::string const &iProcessName)
 
int main (int argc, char *argv[])
 
std::string nonProducerComponent (std::string const &iCompName, edm::ParameterSet const &iProcessConfig, std::string const &iProcessName)
 
std::ostream & operator<< (std::ostream &os, edm::ProcessHistory &iHist)
 
static std::ostream & prettyPrint (std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
 
static std::ostream & prettyPrint (std::ostream &os, edm::ParameterSetEntry const &psetEntry, std::string const &iIndent, std::string const &iIndentDelta)
 
static std::ostream & prettyPrint (std::ostream &os, edm::VParameterSetEntry const &vpsetEntry, std::string const &iIndent, std::string const &iIndentDelta)
 
static std::string topLevelPSet (std::string const &iName, edm::ParameterSet const &iProcessConfig, std::string const &iProcessName)
 

Variables

static char const *const kDependenciesCommandOpt = "dependencies,d"
 
static char const *const kDependenciesOpt = "dependencies"
 
static char const *const kExcludeESModulesCommandOpt = "excludeESModules,e"
 
static char const *const kExcludeESModulesOpt = "excludeESModules"
 
static char const *const kFileNameCommandOpt = "input-file"
 
static char const *const kFileNameOpt = "input-file"
 
static char const *const kFindMatchCommandOpt = "findMatch,f"
 
static char const *const kFindMatchOpt = "findMatch"
 
static char const *const kHelpCommandOpt = "help,h"
 
static char const *const kHelpOpt = "help"
 
static char const *const kShowAllModulesCommandOpt = "showAllModules,a"
 
static char const *const kShowAllModulesOpt = "showAllModules"
 
static char const *const kShowTopLevelPSetsCommandOpt ="showTopLevelPSets,t"
 
static char const *const kShowTopLevelPSetsOpt = "showTopLevelPSets"
 
static char const *const kSortCommandOpt = "sort,s"
 
static char const *const kSortOpt = "sort"
 

Typedef Documentation

typedef std::map<std::string, std::vector<edm::BranchDescription> > IdToBranches

Definition at line 39 of file EdmProvDump.cc.

typedef std::map<std::pair<std::string, std::string>, IdToBranches> ModuleToIdBranches

Definition at line 40 of file EdmProvDump.cc.

Function Documentation

static void appendToSet ( std::set< std::string > &  iSet,
std::vector< std::string > const &  iFrom 
)
static

Definition at line 277 of file EdmProvDump.cc.

References n.

277  {
278  for( auto const& n: iFrom){
279  iSet.insert(n);
280  }
281 }
std::string eventSetupComponent ( char const *  iType,
std::string const &  iCompName,
edm::ParameterSet const &  iProcessConfig,
std::string const &  iProcessName 
)

Definition at line 161 of file EdmProvDump.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), mergeVDriftHistosByStation::name, prettyPrint(), and query::result.

164  {
165  std::ostringstream result;
166  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iCompName);
167  std::string name(pset.getParameter<std::string>("@module_label"));
168  if(0 == name.size()) {
169  name = pset.getParameter<std::string>("@module_type");
170  }
171 
172  result << iType << ": " << name << " " << iProcessName << "\n"
173  << " parameters: ";
174  prettyPrint(result, pset, " ", " ");
175  return result.str();
176 }
T getParameter(std::string const &) const
tuple result
Definition: query.py:137
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:414
ParameterSet const & getParameterSet(std::string const &) const
int main ( int  argc,
char *  argv[] 
)

Definition at line 922 of file EdmProvDump.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ProvenanceDumper::dump(), alignCSCRings::e, error, cppFunctionSkipper::exception, ProvenanceDumper::exitCode(), convertXMLtoSQLite_cfg::fileName, kDependenciesCommandOpt, fwlog::kError, kFileNameOpt, kFindMatchCommandOpt, kFindMatchOpt, kHelpCommandOpt, kShowAllModulesCommandOpt, AlCaHLTBitMon_ParallelJobs::options, AlCaHLTBitMon_ParallelJobs::p, ProvenanceDumper::printErrors(), DTTTrigCorrFirst::run, cms::Exception::what(), and x.

922  {
923  using namespace boost::program_options;
924 
925  std::string descString(argv[0]);
926  descString += " [options] <filename>";
927  descString += "\nAllowed options";
928  options_description desc(descString);
929  desc.add_options()
930  (kHelpCommandOpt, "show help message")
932  , "alphabetially sort EventSetup components")
934  , "print what data each EDProducer is dependent upon")
936  , "do not print ES module information")
938  , "show all modules (not just those that created data in the file)")
939  (kShowTopLevelPSetsCommandOpt,"show all top level PSets")
940  (kFindMatchCommandOpt, boost::program_options::value<std::string>(),
941  "show only modules whose information contains the matching string")
942  ;
943  //we don't want users to see these in the help messages since this
944  // name only exists since the parser needs it
945  options_description hidden;
946  hidden.add_options()(kFileNameOpt, value<std::string>(), "file name");
947 
948  //full list of options for the parser
949  options_description cmdline_options;
950  cmdline_options.add(desc).add(hidden);
951 
952  positional_options_description p;
953  p.add(kFileNameOpt, -1);
954 
955  variables_map vm;
956  try {
957  store(command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm);
958  notify(vm);
959  } catch(error const& iException) {
960  std::cerr << iException.what();
961  return 1;
962  }
963 
964  if(vm.count(kHelpOpt)) {
965  std::cout << desc << std::endl;
966  return 0;
967  }
968 
969  if(vm.count(kSortOpt)) {
970  HistoryNode::sort_ = true;
971  }
972 
973  bool showDependencies = false;
974  if(vm.count(kDependenciesOpt)) {
975  showDependencies = true;
976  }
977 
978  bool excludeESModules = false;
979  if(vm.count(kExcludeESModulesOpt)) {
980  excludeESModules = true;
981  }
982 
983  bool showAllModules = false;
984  if(vm.count(kShowAllModulesOpt)) {
985  showAllModules = true;
986  }
987 
988  bool showTopLevelPSets = false;
989  if(vm.count(kShowTopLevelPSetsOpt)) {
990  showTopLevelPSets=true;
991  }
992 
993  std::string fileName;
994  if(vm.count(kFileNameOpt)) {
995  try {
996  fileName = vm[kFileNameOpt].as<std::string>();
997  } catch(boost::bad_any_cast const& e) {
998  std::cout << e.what() << std::endl;
999  return 2;
1000  }
1001  } else {
1002  std::cout << "Data file not specified." << std::endl;
1003  std::cout << desc << std::endl;
1004  return 2;
1005  }
1006 
1007  std::string findMatch;
1008  if(vm.count(kFindMatchOpt)) {
1009  try {
1010  findMatch = vm[kFindMatchOpt].as<std::string>();
1011  } catch(boost::bad_any_cast const& e) {
1012  std::cout << e.what() << std::endl;
1013  return 2;
1014  }
1015  }
1016 
1017  //silence ROOT warnings about missing dictionaries
1018  gErrorIgnoreLevel = kError;
1019 
1020  //make sure dictionaries can be used for reading
1021  ROOT::Cintex::Cintex::Enable();
1022 
1023  ProvenanceDumper dumper(fileName, showDependencies, excludeESModules, showAllModules, showTopLevelPSets, findMatch);
1024  int exitCode(0);
1025  try {
1026  dumper.dump();
1027  exitCode = dumper.exitCode();
1028  }
1029  catch (cms::Exception const& x) {
1030  std::cerr << "cms::Exception caught\n";
1031  std::cerr << x.what() << '\n';
1032  exitCode = 2;
1033  }
1034  catch (std::exception& x) {
1035  std::cerr << "std::exception caught\n";
1036  std::cerr << x.what() << '\n';
1037  exitCode = 3;
1038  }
1039  catch (...) {
1040  std::cerr << "Unknown exception caught\n";
1041  exitCode = 4;
1042  }
1043 
1044  dumper.printErrors(std::cerr);
1045  return exitCode;
1046 }
virtual char const * what() const
Definition: Exception.cc:141
static char const *const kDependenciesOpt
Definition: EdmProvDump.cc:907
static char const *const kFindMatchCommandOpt
Definition: EdmProvDump.cc:914
static char const *const kShowTopLevelPSetsCommandOpt
Definition: EdmProvDump.cc:916
static char const *const kHelpOpt
Definition: EdmProvDump.cc:917
static char const *const kDependenciesCommandOpt
Definition: EdmProvDump.cc:908
static char const *const kHelpCommandOpt
Definition: EdmProvDump.cc:918
static char const *const kShowTopLevelPSetsOpt
Definition: EdmProvDump.cc:915
static char const *const kShowAllModulesCommandOpt
Definition: EdmProvDump.cc:912
static char const *const kExcludeESModulesCommandOpt
Definition: EdmProvDump.cc:910
static char const *const kSortOpt
Definition: EdmProvDump.cc:905
static char const *const kExcludeESModulesOpt
Definition: EdmProvDump.cc:909
static char const *const kSortCommandOpt
Definition: EdmProvDump.cc:906
static char const *const kShowAllModulesOpt
Definition: EdmProvDump.cc:911
tuple argc
Definition: dir2webdir.py:41
static char const *const kFileNameOpt
Definition: EdmProvDump.cc:919
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
static char const *const kFindMatchOpt
Definition: EdmProvDump.cc:913
std::string nonProducerComponent ( std::string const &  iCompName,
edm::ParameterSet const &  iProcessConfig,
std::string const &  iProcessName 
)

Definition at line 227 of file EdmProvDump.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), diffTwoXMLs::label, prettyPrint(), and query::result.

229  {
230  std::ostringstream result;
231  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iCompName);
232  std::string label(pset.getParameter<std::string>("@module_label"));
233 
234  result << "Module: " << label << " " << iProcessName << "\n" << " parameters: ";
235  prettyPrint(result, pset, " ", " ");
236  return result.str();
237 }
T getParameter(std::string const &) const
tuple result
Definition: query.py:137
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:414
ParameterSet const & getParameterSet(std::string const &) const
std::ostream& operator<< ( std::ostream &  os,
edm::ProcessHistory iHist 
)

Definition at line 133 of file EdmProvDump.cc.

References edm::ProcessHistory::begin(), alignCSCRings::e, edm::ProcessHistory::end(), i, and dataformats::indent().

133  {
134  std::string const indentDelta(" ");
135  std::string indent = indentDelta;
136  for(edm::ProcessHistory::const_iterator i = iHist.begin(), e = iHist.end();
137  i != e;
138  ++i) {
139  os << indent
140  << i->processName() << " '"
141  << i->passID() << "' '"
142  << i->releaseVersion() << "' ("
143  << i->parameterSetID() << ")"
144  << std::endl;
145  indent += indentDelta;
146  }
147  return os;
148 }
collection_type::const_iterator const_iterator
const_iterator begin() const
int i
Definition: DBlmapReader.cc:9
const_iterator end() const
static std::ostream & prettyPrint ( std::ostream &  oStream,
edm::ParameterSet const &  iPSet,
std::string const &  iIndent,
std::string const &  iIndentDelta 
)
static

Definition at line 414 of file EdmProvDump.cc.

References alignCSCRings::e, i, edm::ParameterSet::psetTable(), edm::ParameterSet::tbl(), and edm::ParameterSet::vpsetTable().

Referenced by ProvenanceDumper::dumpParameterSetForID_(), eventSetupComponent(), nonProducerComponent(), prettyPrint(), topLevelPSet(), and ProvenanceDumper::work_().

414  {
415  std::string newIndent = iIndent+iIndentDelta;
416 
417  oStream << "{" << std::endl;
418  for(edm::ParameterSet::table::const_iterator i = iPSet.tbl().begin(), e = iPSet.tbl().end(); i != e; ++i) {
419  // indent a bit
420  oStream << newIndent<< i->first << ": " << i->second << std::endl;
421  }
422  for(edm::ParameterSet::psettable::const_iterator i = iPSet.psetTable().begin(), e = iPSet.psetTable().end(); i != e; ++i) {
423  // indent a bit
424  edm::ParameterSetEntry const& pe = i->second;
425  oStream << newIndent << i->first << ": ";
426  prettyPrint(oStream, pe, iIndent, iIndentDelta);
427  oStream<< std::endl;
428  }
429  for(edm::ParameterSet::vpsettable::const_iterator i = iPSet.vpsetTable().begin(), e = iPSet.vpsetTable().end(); i != e; ++i) {
430  // indent a bit
431  edm::VParameterSetEntry const& pe = i->second;
432  oStream << newIndent << i->first << ": ";
433  prettyPrint(oStream, pe, newIndent, iIndentDelta);
434  oStream<< std::endl;
435  }
436  oStream << iIndent<< "}";
437 
438  return oStream;
439 }
int i
Definition: DBlmapReader.cc:9
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:414
static std::ostream& prettyPrint ( std::ostream &  os,
edm::ParameterSetEntry const &  psetEntry,
std::string const &  iIndent,
std::string const &  iIndentDelta 
)
static

Definition at line 387 of file EdmProvDump.cc.

References edm::ParameterSetEntry::isTracked(), prettyPrint(), and edm::ParameterSetEntry::pset().

387  {
388  char const* trackiness = (psetEntry.isTracked()?"tracked":"untracked");
389  os << "PSet " << trackiness << " = (";
390  prettyPrint(os, psetEntry.pset(), iIndent + iIndentDelta, iIndentDelta);
391  os << ")";
392  return os;
393 }
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:414
static std::ostream& prettyPrint ( std::ostream &  os,
edm::VParameterSetEntry const &  vpsetEntry,
std::string const &  iIndent,
std::string const &  iIndentDelta 
)
static

Definition at line 395 of file EdmProvDump.cc.

References alignCSCRings::e, i, edm::VParameterSetEntry::isTracked(), prettyPrint(), errorMatrix2Lands_multiChannel::start, and edm::VParameterSetEntry::vpset().

395  {
396  std::vector<edm::ParameterSet> const& vps = vpsetEntry.vpset();
397  os << "VPSet " << (vpsetEntry.isTracked() ? "tracked" : "untracked") << " = ({" << std::endl;
398  std::string newIndent = iIndent+iIndentDelta;
399  std::string start;
400  std::string const between(",\n");
401  for(std::vector<edm::ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
402  os << start << newIndent;
403  prettyPrint(os, *i, newIndent, iIndentDelta);
404  start = between;
405  }
406  if(!vps.empty()) {
407  os << std::endl;
408  }
409  os << iIndent<< "})";
410  return os;
411 }
int i
Definition: DBlmapReader.cc:9
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:414
static std::string topLevelPSet ( std::string const &  iName,
edm::ParameterSet const &  iProcessConfig,
std::string const &  iProcessName 
)
static

Definition at line 283 of file EdmProvDump.cc.

References edm::ParameterSet::getParameterSet(), prettyPrint(), and query::result.

285  {
286  std::ostringstream result;
287  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iName);
288 
289  result << "PSet: " << iName << " " << iProcessName << "\n" << " parameters: ";
290  prettyPrint(result, pset, " ", " ");
291  return result.str();
292 }
tuple result
Definition: query.py:137
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:414
ParameterSet const & getParameterSet(std::string const &) const

Variable Documentation

char const* const kDependenciesCommandOpt = "dependencies,d"
static

Definition at line 908 of file EdmProvDump.cc.

Referenced by main().

char const* const kDependenciesOpt = "dependencies"
static

Definition at line 907 of file EdmProvDump.cc.

char const* const kExcludeESModulesCommandOpt = "excludeESModules,e"
static

Definition at line 910 of file EdmProvDump.cc.

char const* const kExcludeESModulesOpt = "excludeESModules"
static

Definition at line 909 of file EdmProvDump.cc.

char const* const kFileNameCommandOpt = "input-file"
static

Definition at line 920 of file EdmProvDump.cc.

char const* const kFileNameOpt = "input-file"
static

Definition at line 919 of file EdmProvDump.cc.

Referenced by main().

char const* const kFindMatchCommandOpt = "findMatch,f"
static

Definition at line 914 of file EdmProvDump.cc.

Referenced by main().

char const* const kFindMatchOpt = "findMatch"
static

Definition at line 913 of file EdmProvDump.cc.

Referenced by main().

char const* const kHelpCommandOpt = "help,h"
static

Definition at line 918 of file EdmProvDump.cc.

Referenced by main().

char const* const kHelpOpt = "help"
static

Definition at line 917 of file EdmProvDump.cc.

char const* const kShowAllModulesCommandOpt = "showAllModules,a"
static

Definition at line 912 of file EdmProvDump.cc.

Referenced by main().

char const* const kShowAllModulesOpt = "showAllModules"
static

Definition at line 911 of file EdmProvDump.cc.

char const* const kShowTopLevelPSetsCommandOpt ="showTopLevelPSets,t"
static

Definition at line 916 of file EdmProvDump.cc.

char const* const kShowTopLevelPSetsOpt = "showTopLevelPSets"
static

Definition at line 915 of file EdmProvDump.cc.

char const* const kSortCommandOpt = "sort,s"
static

Definition at line 906 of file EdmProvDump.cc.

char const* const kSortOpt = "sort"
static

Definition at line 905 of file EdmProvDump.cc.