CMS 3D CMS Logo

Classes | Typedefs | Functions | Variables

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/IOPool/Common/bin/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.

                                                               {
  std::ostringstream result;
  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iCompName);
  std::string name(pset.getParameter<std::string>("@module_label"));
  if(0 == name.size()) {
    name = pset.getParameter<std::string>("@module_type");
  }

  result << iType << ": " << name << " " << iProcessName << "\n"
         << " parameters: ";
  prettyPrint(result, pset, " ", " ");
  return result.str();
}
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, 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.

                                 {
  using namespace boost::program_options;


  std::string descString(argv[0]);
  descString += " [options] <filename>";
  descString += "\nAllowed options";
  options_description desc(descString);
  desc.add_options()
  (kHelpCommandOpt, "show help message")
  (kSortCommandOpt
   , "alphabetially sort EventSetup components")
  (kDependenciesCommandOpt
   , "print what data each EDProducer is dependent upon")
  (kExcludeESModulesCommandOpt
   , "do not print ES module information")
  (kShowAllModulesCommandOpt
   , "show all modules (not just those that created data in the file)")
  (kFindMatchCommandOpt, boost::program_options::value<std::string>(),
    "show only modules whose information contains the matching string")
  ;
  //we don't want users to see these in the help messages since this
  // name only exists since the parser needs it
  options_description hidden;
  hidden.add_options()(kFileNameOpt, value<std::string>(), "file name");

  //full list of options for the parser
  options_description cmdline_options;
  cmdline_options.add(desc).add(hidden);

  positional_options_description p;
  p.add(kFileNameOpt, -1);


  variables_map vm;
  try {
    store(command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm);
    notify(vm);
  } catch(error const& iException) {
    std::cerr << iException.what();
    return 1;
  }

  if(vm.count(kHelpOpt)) {
    std::cout << desc << std::endl;
    return 0;
  }

  if(vm.count(kSortOpt)) {
    HistoryNode::sort_ = true;
  }

  bool showDependencies = false;
  if(vm.count(kDependenciesOpt)) {
    showDependencies=true;
  }

  bool excludeESModules = false;
  if(vm.count(kExcludeESModulesOpt)) {
    excludeESModules=true;
  }

  bool showAllModules = false;
  if(vm.count(kShowAllModulesOpt)) {
    showAllModules=true;
  }

  std::string fileName;
  if(vm.count(kFileNameOpt)) {
    fileName = vm[kFileNameOpt].as<std::string>();
  } else {
    std::cout << "Data file not specified." << std::endl;
    std::cout << desc << std::endl;
    return 2;
  }

  std::string findMatch;
  if(vm.count(kFindMatchOpt)) {
    findMatch = vm[kFindMatchOpt].as<std::string>();
  }

  //silence ROOT warnings about missing dictionaries
  gErrorIgnoreLevel = kError;

  //make sure dictionaries can be used for reading
  ROOT::Cintex::Cintex::Enable();

  ProvenanceDumper dumper(fileName, showDependencies, excludeESModules, showAllModules, findMatch);
  int exitCode(0);
  try {
    dumper.dump(std::cout);
  }
  catch (cms::Exception const& x) {
    std::cerr << "cms::Exception caught\n";
    std::cerr << x.what() << '\n';
    exitCode = 2;
  }
  catch (std::exception& x) {
    std::cerr << "std::exception caught\n";
    std::cerr << x.what() << '\n';
    exitCode = 3;
  }
  catch (...) {
    std::cerr << "Unknown exception caught\n";
    exitCode = 4;
  }

  dumper.printErrors(std::cerr);
  return dumper.exitCode();
}
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.

                                                                {
  std::ostringstream result;
  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iCompName);
  std::string label(pset.getParameter<std::string>("@module_label"));

  result <<"Module: " << label << " " << iProcessName << "\n"
  << " parameters: ";
  prettyPrint(result, pset, " ", " ");
  return result.str();
}
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().

                                                     {
  std::string const indentDelta("  ");
  std::string indent = indentDelta;
  for (edm::ProcessHistory::const_iterator i = iHist.begin(), e = iHist.end();
       i != e;
       ++i) {
    os << indent
       << i->processName() << " '"
       << i->passID()      << "' '"
       << i->releaseVersion() << "' ("
       << i->parameterSetID() << ")"
       << std::endl;
    indent += indentDelta;
  }
  return os;
}
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_().

                                                                                                                                           {
  std::string newIndent = iIndent+iIndentDelta;

  oStream << "{" << std::endl;
  for(edm::ParameterSet::table::const_iterator i = iPSet.tbl().begin(), e = iPSet.tbl().end(); i != e; ++i) {
    // indent a bit
    oStream << newIndent<< i->first << ": " << i->second << std::endl;
  }
  for(edm::ParameterSet::psettable::const_iterator i = iPSet.psetTable().begin(), e = iPSet.psetTable().end(); i != e; ++i) {
    // indent a bit
    edm::ParameterSetEntry const& pe = i->second;
    oStream << newIndent << i->first << ": ";
    prettyPrint(oStream, pe, iIndent, iIndentDelta);
    oStream<<  std::endl;
  }
  for(edm::ParameterSet::vpsettable::const_iterator i = iPSet.vpsetTable().begin(), e = iPSet.vpsetTable().end(); i != e; ++i) {
    // indent a bit
    edm::VParameterSetEntry const& pe = i->second;
    oStream << newIndent << i->first << ": ";
    prettyPrint(oStream, pe, newIndent, iIndentDelta);
    oStream<<  std::endl;
  }
  oStream << iIndent<< "}";

  return oStream;
}
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().

                                                                                                                                               {
  char const* trackiness = (psetEntry.isTracked()?"tracked":"untracked");
  os << "PSet " << trackiness << " = (";
  prettyPrint(os, psetEntry.pset(), iIndent + iIndentDelta, iIndentDelta);
  os << ")";
  return os;
}
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().

                                                                                                                                                 {
  std::vector<edm::ParameterSet> const& vps = vpsetEntry.vpset();
  os << "VPSet " << (vpsetEntry.isTracked() ? "tracked" : "untracked") << " = ({" << std::endl;
  std::string newIndent = iIndent+iIndentDelta;
  std::string start;
  std::string const between(",\n");
  for(std::vector<edm::ParameterSet>::const_iterator i = vps.begin(), e = vps.end(); i != e; ++i) {
    os << start << newIndent;
    prettyPrint(os, *i, newIndent, iIndentDelta);
    start = between;
  }
  if (!vps.empty()) {
    os << std::endl;
  }
  os << iIndent<< "})";
  return os;
}

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.