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 "TFile.h"
#include "TTree.h"
#include "TError.h"
#include "Cintex/Cintex.h"
#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/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 <assert.h>
#include <iostream>
#include <memory>
#include <sstream>
#include <map>
#include <vector>
#include <set>
#include "boost/scoped_ptr.hpp"
#include "boost/program_options.hpp"

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

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)
 

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 kSortCommandOpt = "sort,s"
 
static char const *const kSortOpt = "sort"
 

Typedef Documentation

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

Definition at line 40 of file EdmProvDump.cc.

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

Definition at line 41 of file EdmProvDump.cc.

Function Documentation

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(), AlCaRecoCosmics_cfg::name, prettyPrint(), CrabTask::pset, 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
tuple pset
Definition: CrabTask.py:85
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:348
int main ( int  argc,
char *  argv[] 
)

Definition at line 822 of file EdmProvDump.cc.

References ExpressReco_HICollisions_FallBack::cerr, gather_cfg::cout, ProvenanceDumper::dump(), error, cmsCodeRules.cppFunctionSkipper::exception, ProvenanceDumper::exitCode(), convertXMLtoSQLite_cfg::fileName, kDependenciesCommandOpt, fwlog::kError, kFileNameOpt, kFindMatchOpt, kHelpCommandOpt, kShowAllModulesCommandOpt, loadConditions::options, L1TEmulatorMonitor_cff::p, ProvenanceDumper::printErrors(), CrabTask::run, cms::Exception::what(), and ExpressReco_HICollisions_FallBack::x.

822  {
823  using namespace boost::program_options;
824 
825 
826  std::string descString(argv[0]);
827  descString += " [options] <filename>";
828  descString += "\nAllowed options";
829  options_description desc(descString);
830  desc.add_options()
831  (kHelpCommandOpt, "show help message")
833  , "alphabetially sort EventSetup components")
835  , "print what data each EDProducer is dependent upon")
837  , "do not print ES module information")
839  , "show all modules (not just those that created data in the file)")
840  (kFindMatchCommandOpt, boost::program_options::value<std::string>(),
841  "show only modules whose information contains the matching string")
842  ;
843  //we don't want users to see these in the help messages since this
844  // name only exists since the parser needs it
845  options_description hidden;
846  hidden.add_options()(kFileNameOpt, value<std::string>(), "file name");
847 
848  //full list of options for the parser
849  options_description cmdline_options;
850  cmdline_options.add(desc).add(hidden);
851 
852  positional_options_description p;
853  p.add(kFileNameOpt, -1);
854 
855 
856  variables_map vm;
857  try {
858  store(command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm);
859  notify(vm);
860  } catch(error const& iException) {
861  std::cerr << iException.what();
862  return 1;
863  }
864 
865  if(vm.count(kHelpOpt)) {
866  std::cout << desc << std::endl;
867  return 0;
868  }
869 
870  if(vm.count(kSortOpt)) {
871  HistoryNode::sort_ = true;
872  }
873 
874  bool showDependencies = false;
875  if(vm.count(kDependenciesOpt)) {
876  showDependencies=true;
877  }
878 
879  bool excludeESModules = false;
880  if(vm.count(kExcludeESModulesOpt)) {
881  excludeESModules=true;
882  }
883 
884  bool showAllModules = false;
885  if(vm.count(kShowAllModulesOpt)) {
886  showAllModules=true;
887  }
888 
889  std::string fileName;
890  if(vm.count(kFileNameOpt)) {
891  fileName = vm[kFileNameOpt].as<std::string>();
892  } else {
893  std::cout << "Data file not specified." << std::endl;
894  std::cout << desc << std::endl;
895  return 2;
896  }
897 
898  std::string findMatch;
899  if(vm.count(kFindMatchOpt)) {
900  findMatch = vm[kFindMatchOpt].as<std::string>();
901  }
902 
903  //silence ROOT warnings about missing dictionaries
904  gErrorIgnoreLevel = kError;
905 
906  //make sure dictionaries can be used for reading
907  ROOT::Cintex::Cintex::Enable();
908 
909  ProvenanceDumper dumper(fileName, showDependencies, excludeESModules, showAllModules, findMatch);
910  int exitCode(0);
911  try {
912  dumper.dump(std::cout);
913  }
914  catch (cms::Exception const& x) {
915  std::cerr << "cms::Exception caught\n";
916  std::cerr << x.what() << '\n';
917  exitCode = 2;
918  }
919  catch (std::exception& x) {
920  std::cerr << "std::exception caught\n";
921  std::cerr << x.what() << '\n';
922  exitCode = 3;
923  }
924  catch (...) {
925  std::cerr << "Unknown exception caught\n";
926  exitCode = 4;
927  }
928 
929  dumper.printErrors(std::cerr);
930  return dumper.exitCode();
931 }
virtual char const * what() const
Definition: Exception.cc:97
static char const *const kDependenciesOpt
Definition: EdmProvDump.cc:808
static char const *const kFindMatchCommandOpt
Definition: EdmProvDump.cc:815
static char const *const kHelpOpt
Definition: EdmProvDump.cc:816
static char const *const kDependenciesCommandOpt
Definition: EdmProvDump.cc:809
static char const *const kHelpCommandOpt
Definition: EdmProvDump.cc:817
static char const *const kShowAllModulesCommandOpt
Definition: EdmProvDump.cc:813
static char const *const kExcludeESModulesCommandOpt
Definition: EdmProvDump.cc:811
static char const *const kSortOpt
Definition: EdmProvDump.cc:806
static char const *const kExcludeESModulesOpt
Definition: EdmProvDump.cc:810
static char const *const kSortCommandOpt
Definition: EdmProvDump.cc:807
static char const *const kShowAllModulesOpt
Definition: EdmProvDump.cc:812
static char const *const kFileNameOpt
Definition: EdmProvDump.cc:818
tuple cout
Definition: gather_cfg.py:41
static char const *const kFindMatchOpt
Definition: EdmProvDump.cc:814
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(), label, prettyPrint(), CrabTask::pset, 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"
235  << " parameters: ";
236  prettyPrint(result, pset, " ", " ");
237  return result.str();
238 }
T getParameter(std::string const &) const
const std::string & label
Definition: MVAComputer.cc:186
tuple result
Definition: query.py:137
tuple pset
Definition: CrabTask.py:85
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:348
std::ostream& operator<< ( std::ostream &  os,
edm::ProcessHistory iHist 
)

Definition at line 133 of file EdmProvDump.cc.

References edm::ProcessHistory::begin(), ExpressReco_HICollisions_FallBack::e, edm::ProcessHistory::end(), i, and tablePrinter::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 348 of file EdmProvDump.cc.

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

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

348  {
349  std::string newIndent = iIndent+iIndentDelta;
350 
351  oStream << "{" << std::endl;
352  for(edm::ParameterSet::table::const_iterator i = iPSet.tbl().begin(), e = iPSet.tbl().end(); i != e; ++i) {
353  // indent a bit
354  oStream << newIndent<< i->first << ": " << i->second << std::endl;
355  }
356  for(edm::ParameterSet::psettable::const_iterator i = iPSet.psetTable().begin(), e = iPSet.psetTable().end(); i != e; ++i) {
357  // indent a bit
358  edm::ParameterSetEntry const& pe = i->second;
359  oStream << newIndent << i->first << ": ";
360  prettyPrint(oStream, pe, iIndent, iIndentDelta);
361  oStream<< std::endl;
362  }
363  for(edm::ParameterSet::vpsettable::const_iterator i = iPSet.vpsetTable().begin(), e = iPSet.vpsetTable().end(); i != e; ++i) {
364  // indent a bit
365  edm::VParameterSetEntry const& pe = i->second;
366  oStream << newIndent << i->first << ": ";
367  prettyPrint(oStream, pe, newIndent, iIndentDelta);
368  oStream<< std::endl;
369  }
370  oStream << iIndent<< "}";
371 
372  return oStream;
373 }
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:348
static std::ostream& prettyPrint ( std::ostream &  os,
edm::ParameterSetEntry const &  psetEntry,
std::string const &  iIndent,
std::string const &  iIndentDelta 
)
static

Definition at line 321 of file EdmProvDump.cc.

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

321  {
322  char const* trackiness = (psetEntry.isTracked()?"tracked":"untracked");
323  os << "PSet " << trackiness << " = (";
324  prettyPrint(os, psetEntry.pset(), iIndent + iIndentDelta, iIndentDelta);
325  os << ")";
326  return os;
327 }
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:348
static std::ostream& prettyPrint ( std::ostream &  os,
edm::VParameterSetEntry const &  vpsetEntry,
std::string const &  iIndent,
std::string const &  iIndentDelta 
)
static

Definition at line 329 of file EdmProvDump.cc.

References ExpressReco_HICollisions_FallBack::e, i, edm::VParameterSetEntry::isTracked(), prettyPrint(), and edm::VParameterSetEntry::vpset().

329  {
330  std::vector<edm::ParameterSet> const& vps = vpsetEntry.vpset();
331  os << "VPSet " << (vpsetEntry.isTracked() ? "tracked" : "untracked") << " = ({" << std::endl;
332  std::string newIndent = iIndent+iIndentDelta;
333  std::string start;
334  std::string const between(",\n");
335  for(std::vector<edm::ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
336  os << start << newIndent;
337  prettyPrint(os, *i, newIndent, iIndentDelta);
338  start = between;
339  }
340  if (!vps.empty()) {
341  os << std::endl;
342  }
343  os << iIndent<< "})";
344  return os;
345 }
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:348

Variable Documentation

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

Definition at line 809 of file EdmProvDump.cc.

Referenced by main().

char const* const kDependenciesOpt = "dependencies"
static

Definition at line 808 of file EdmProvDump.cc.

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

Definition at line 811 of file EdmProvDump.cc.

char const* const kExcludeESModulesOpt = "excludeESModules"
static

Definition at line 810 of file EdmProvDump.cc.

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

Definition at line 819 of file EdmProvDump.cc.

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

Definition at line 818 of file EdmProvDump.cc.

Referenced by main().

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

Definition at line 815 of file EdmProvDump.cc.

char const* const kFindMatchOpt = "findMatch"
static

Definition at line 814 of file EdmProvDump.cc.

Referenced by main().

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

Definition at line 817 of file EdmProvDump.cc.

Referenced by main().

char const* const kHelpOpt = "help"
static

Definition at line 816 of file EdmProvDump.cc.

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

Definition at line 813 of file EdmProvDump.cc.

Referenced by main().

char const* const kShowAllModulesOpt = "showAllModules"
static

Definition at line 812 of file EdmProvDump.cc.

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

Definition at line 807 of file EdmProvDump.cc.

char const* const kSortOpt = "sort"
static

Definition at line 806 of file EdmProvDump.cc.