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 kDontPrintProductsCommandOpt = "dontPrintProducts,p"
 
static char const *const kDontPrintProductsOpt = "dontPrintProducts"
 
static char const *const kExcludeESModulesCommandOpt = "excludeESModules,e"
 
static char const *const kExcludeESModulesOpt = "excludeESModules"
 
static char const *const kExtendedAncestorsCommandOpt = "extendedAncestors,x"
 
static char const *const kExtendedAncestorsOpt = "extendedAncestors"
 
static char const *const kExtendedDescendantsCommandOpt = "extendedDescendants,c"
 
static char const *const kExtendedDescendantsOpt = "extendedDescendants"
 
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 304 of file EdmProvDump.cc.

References n.

304  {
305  for( auto const& n: iFrom){
306  iSet.insert(n);
307  }
308 }
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(), query::result, and AlCaHLTBitMon_QueryRunRegistry::string.

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:451
ParameterSet const & getParameterSet(std::string const &) const
int main ( int  argc,
char *  argv[] 
)

Definition at line 1088 of file EdmProvDump.cc.

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

1088  {
1089  using namespace boost::program_options;
1090 
1091  std::string descString(argv[0]);
1092  descString += " [options] <filename>";
1093  descString += "\nAllowed options";
1094  options_description desc(descString);
1095  desc.add_options()
1096  (kHelpCommandOpt, "show help message")
1098  , "alphabetially sort EventSetup components")
1100  , "print what data each EDProducer is directly dependent upon")
1102  , "print what data each EDProducer is dependent upon including indirect dependences")
1104  , "print what data depends on the data each EDProducer produces including indirect dependences")
1106  , "do not print ES module information")
1108  , "show all modules (not just those that created data in the file)")
1109  (kShowTopLevelPSetsCommandOpt,"show all top level PSets")
1110  (kFindMatchCommandOpt, boost::program_options::value<std::vector<std::string> >(),
1111  "show only modules whose information contains the matching string (or all the matching strings, this option can be repeated with different strings)")
1113  , "do not print products produced by module")
1114  ;
1115  //we don't want users to see these in the help messages since this
1116  // name only exists since the parser needs it
1117  options_description hidden;
1118  hidden.add_options()(kFileNameOpt, value<std::string>(), "file name");
1119 
1120  //full list of options for the parser
1121  options_description cmdline_options;
1122  cmdline_options.add(desc).add(hidden);
1123 
1124  positional_options_description p;
1125  p.add(kFileNameOpt, -1);
1126 
1127  variables_map vm;
1128  try {
1129  store(command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm);
1130  notify(vm);
1131  } catch(error const& iException) {
1132  std::cerr << iException.what();
1133  return 1;
1134  }
1135 
1136  if(vm.count(kHelpOpt)) {
1137  std::cout << desc << std::endl;
1138  return 0;
1139  }
1140 
1141  if(vm.count(kSortOpt)) {
1142  HistoryNode::sort_ = true;
1143  }
1144 
1145  bool showDependencies = false;
1146  if(vm.count(kDependenciesOpt)) {
1147  showDependencies = true;
1148  }
1149 
1150  bool extendedAncestors = false;
1151  if(vm.count(kExtendedAncestorsOpt)) {
1152  extendedAncestors = true;
1153  }
1154 
1155  bool extendedDescendants = false;
1156  if(vm.count(kExtendedDescendantsOpt)) {
1157  extendedDescendants = true;
1158  }
1159 
1160  bool excludeESModules = false;
1161  if(vm.count(kExcludeESModulesOpt)) {
1162  excludeESModules = true;
1163  }
1164 
1165  bool showAllModules = false;
1166  if(vm.count(kShowAllModulesOpt)) {
1167  showAllModules = true;
1168  }
1169 
1170  bool showTopLevelPSets = false;
1171  if(vm.count(kShowTopLevelPSetsOpt)) {
1172  showTopLevelPSets=true;
1173  }
1174 
1176  if(vm.count(kFileNameOpt)) {
1177  try {
1178  fileName = vm[kFileNameOpt].as<std::string>();
1179  } catch(boost::bad_any_cast const& e) {
1180  std::cout << e.what() << std::endl;
1181  return 2;
1182  }
1183  } else {
1184  std::cout << "Data file not specified." << std::endl;
1185  std::cout << desc << std::endl;
1186  return 2;
1187  }
1188 
1189  std::vector<std::string> findMatch;
1190  if(vm.count(kFindMatchOpt)) {
1191  try {
1192  findMatch = vm[kFindMatchOpt].as<std::vector<std::string> >();
1193  } catch(boost::bad_any_cast const& e) {
1194  std::cout << e.what() << std::endl;
1195  return 2;
1196  }
1197  }
1198 
1199  bool dontPrintProducts = false;
1200  if(vm.count(kDontPrintProductsOpt)) {
1201  dontPrintProducts=true;
1202  }
1203 
1204  //silence ROOT warnings about missing dictionaries
1205  gErrorIgnoreLevel = kError;
1206 
1207  //make sure dictionaries can be used for reading
1208  ROOT::Cintex::Cintex::Enable();
1209 
1210  ProvenanceDumper dumper(fileName, showDependencies, extendedAncestors, extendedDescendants,
1211  excludeESModules, showAllModules, showTopLevelPSets, findMatch, dontPrintProducts);
1212  int exitCode(0);
1213  try {
1214  dumper.dump();
1215  exitCode = dumper.exitCode();
1216  }
1217  catch (cms::Exception const& x) {
1218  std::cerr << "cms::Exception caught\n";
1219  std::cerr << x.what() << '\n';
1220  exitCode = 2;
1221  }
1222  catch (std::exception& x) {
1223  std::cerr << "std::exception caught\n";
1224  std::cerr << x.what() << '\n';
1225  exitCode = 3;
1226  }
1227  catch (...) {
1228  std::cerr << "Unknown exception caught\n";
1229  exitCode = 4;
1230  }
1231 
1232  dumper.printErrors(std::cerr);
1233  return exitCode;
1234 }
static char const *const kDontPrintProductsCommandOpt
virtual char const * what() const
Definition: Exception.cc:141
static char const *const kDependenciesOpt
static char const *const kFindMatchCommandOpt
static char const *const kShowTopLevelPSetsCommandOpt
static char const *const kHelpOpt
static char const *const kDontPrintProductsOpt
static char const *const kDependenciesCommandOpt
static char const *const kHelpCommandOpt
static char const *const kShowTopLevelPSetsOpt
static char const *const kShowAllModulesCommandOpt
static char const *const kExcludeESModulesCommandOpt
static char const *const kSortOpt
static char const *const kExcludeESModulesOpt
static char const *const kSortCommandOpt
static char const *const kExtendedAncestorsCommandOpt
static char const *const kShowAllModulesOpt
tuple argc
Definition: dir2webdir.py:41
static char const *const kExtendedDescendantsOpt
static char const *const kFileNameOpt
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
static char const *const kExtendedAncestorsOpt
static char const *const kExtendedDescendantsCommandOpt
static char const *const kFindMatchOpt
std::string nonProducerComponent ( std::string const &  iCompName,
edm::ParameterSet const &  iProcessConfig,
std::string const &  iProcessName 
)

Definition at line 245 of file EdmProvDump.cc.

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

247  {
248  std::ostringstream result;
249  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iCompName);
250  std::string label(pset.getParameter<std::string>("@module_label"));
251 
252  result << "Module: " << label << " " << iProcessName << "\n" << " parameters: ";
253  prettyPrint(result, pset, " ", " ");
254  return result.str();
255 }
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:451
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, dataformats::indent(), and AlCaHLTBitMon_QueryRunRegistry::string.

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 451 of file EdmProvDump.cc.

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

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

451  {
452  std::string newIndent = iIndent+iIndentDelta;
453 
454  oStream << "{" << std::endl;
455  for(edm::ParameterSet::table::const_iterator i = iPSet.tbl().begin(), e = iPSet.tbl().end(); i != e; ++i) {
456  // indent a bit
457  oStream << newIndent<< i->first << ": " << i->second << std::endl;
458  }
459  for(edm::ParameterSet::psettable::const_iterator i = iPSet.psetTable().begin(), e = iPSet.psetTable().end(); i != e; ++i) {
460  // indent a bit
461  edm::ParameterSetEntry const& pe = i->second;
462  oStream << newIndent << i->first << ": ";
463  prettyPrint(oStream, pe, iIndent, iIndentDelta);
464  oStream<< std::endl;
465  }
466  for(edm::ParameterSet::vpsettable::const_iterator i = iPSet.vpsetTable().begin(), e = iPSet.vpsetTable().end(); i != e; ++i) {
467  // indent a bit
468  edm::VParameterSetEntry const& pe = i->second;
469  oStream << newIndent << i->first << ": ";
470  prettyPrint(oStream, pe, newIndent, iIndentDelta);
471  oStream<< std::endl;
472  }
473  oStream << iIndent<< "}";
474 
475  return oStream;
476 }
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:451
static std::ostream& prettyPrint ( std::ostream &  os,
edm::ParameterSetEntry const &  psetEntry,
std::string const &  iIndent,
std::string const &  iIndentDelta 
)
static

Definition at line 424 of file EdmProvDump.cc.

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

424  {
425  char const* trackiness = (psetEntry.isTracked()?"tracked":"untracked");
426  os << "PSet " << trackiness << " = (";
427  prettyPrint(os, psetEntry.pset(), iIndent + iIndentDelta, iIndentDelta);
428  os << ")";
429  return os;
430 }
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:451
static std::ostream& prettyPrint ( std::ostream &  os,
edm::VParameterSetEntry const &  vpsetEntry,
std::string const &  iIndent,
std::string const &  iIndentDelta 
)
static

Definition at line 432 of file EdmProvDump.cc.

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

432  {
433  std::vector<edm::ParameterSet> const& vps = vpsetEntry.vpset();
434  os << "VPSet " << (vpsetEntry.isTracked() ? "tracked" : "untracked") << " = ({" << std::endl;
435  std::string newIndent = iIndent+iIndentDelta;
437  std::string const between(",\n");
438  for(std::vector<edm::ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
439  os << start << newIndent;
440  prettyPrint(os, *i, newIndent, iIndentDelta);
441  start = between;
442  }
443  if(!vps.empty()) {
444  os << std::endl;
445  }
446  os << iIndent<< "})";
447  return os;
448 }
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:451
static std::string topLevelPSet ( std::string const &  iName,
edm::ParameterSet const &  iProcessConfig,
std::string const &  iProcessName 
)
static

Definition at line 310 of file EdmProvDump.cc.

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

312  {
313  std::ostringstream result;
314  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iName);
315 
316  result << "PSet: " << iName << " " << iProcessName << "\n" << " parameters: ";
317  prettyPrint(result, pset, " ", " ");
318  return result.str();
319 }
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:451
ParameterSet const & getParameterSet(std::string const &) const

Variable Documentation

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

Definition at line 1068 of file EdmProvDump.cc.

Referenced by main().

char const* const kDependenciesOpt = "dependencies"
static

Definition at line 1067 of file EdmProvDump.cc.

char const* const kDontPrintProductsCommandOpt = "dontPrintProducts,p"
static

Definition at line 1080 of file EdmProvDump.cc.

Referenced by main().

char const* const kDontPrintProductsOpt = "dontPrintProducts"
static

Definition at line 1079 of file EdmProvDump.cc.

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

Definition at line 1074 of file EdmProvDump.cc.

char const* const kExcludeESModulesOpt = "excludeESModules"
static

Definition at line 1073 of file EdmProvDump.cc.

char const* const kExtendedAncestorsCommandOpt = "extendedAncestors,x"
static

Definition at line 1070 of file EdmProvDump.cc.

char const* const kExtendedAncestorsOpt = "extendedAncestors"
static

Definition at line 1069 of file EdmProvDump.cc.

char const* const kExtendedDescendantsCommandOpt = "extendedDescendants,c"
static

Definition at line 1072 of file EdmProvDump.cc.

Referenced by main().

char const* const kExtendedDescendantsOpt = "extendedDescendants"
static

Definition at line 1071 of file EdmProvDump.cc.

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

Definition at line 1086 of file EdmProvDump.cc.

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

Definition at line 1085 of file EdmProvDump.cc.

Referenced by main().

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

Definition at line 1078 of file EdmProvDump.cc.

Referenced by main().

char const* const kFindMatchOpt = "findMatch"
static

Definition at line 1077 of file EdmProvDump.cc.

Referenced by main().

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

Definition at line 1084 of file EdmProvDump.cc.

Referenced by main().

char const* const kHelpOpt = "help"
static

Definition at line 1083 of file EdmProvDump.cc.

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

Definition at line 1076 of file EdmProvDump.cc.

Referenced by main().

char const* const kShowAllModulesOpt = "showAllModules"
static

Definition at line 1075 of file EdmProvDump.cc.

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

Definition at line 1082 of file EdmProvDump.cc.

char const* const kShowTopLevelPSetsOpt = "showTopLevelPSets"
static

Definition at line 1081 of file EdmProvDump.cc.

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

Definition at line 1066 of file EdmProvDump.cc.

char const* const kSortOpt = "sort"
static

Definition at line 1065 of file EdmProvDump.cc.