CMS 3D CMS Logo

EdmProvDump.cc
Go to the documentation of this file.
17 
21 
22 #include "TError.h"
23 #include "TFile.h"
24 #include "TTree.h"
25 
26 #include "boost/program_options.hpp"
27 
28 #include <cassert>
29 #include <iostream>
30 #include <memory>
31 #include <map>
32 #include <set>
33 #include <sstream>
34 #include <vector>
35 
36 typedef std::map<std::string, std::vector<edm::BranchDescription> > IdToBranches;
37 typedef std::map<std::pair<std::string, std::string>, IdToBranches> ModuleToIdBranches;
38 
39 static std::ostream& prettyPrint(std::ostream& oStream, edm::ParameterSet const& iPSet, std::string const& iIndent, std::string const& iIndentDelta);
40 
41 static std::string const triggerResults = std::string("TriggerResults");
42 static std::string const triggerPaths = std::string("@trigger_paths");
43 static std::string const source = std::string("source");
44 static std::string const input = std::string("@main_input");
45 
46 namespace {
47 typedef std::map<edm::ParameterSetID, edm::ParameterSetBlob> ParameterSetMap;
48 
49  class HistoryNode {
50  public:
51  HistoryNode() :
52  config_(),
53  simpleId_(0) {
54  }
55 
56  HistoryNode(edm::ProcessConfiguration const& iConfig, unsigned int iSimpleId) :
57  config_(iConfig),
58  simpleId_(iSimpleId) {
59  }
60 
61  void addChild(HistoryNode const& child) {
62  children_.push_back(child);
63  }
64 
65  edm::ParameterSetID const&
66  parameterSetID() const {
67  return config_.parameterSetID();
68  }
69 
70  std::string const&
71  processName() const {
72  return config_.processName();
73  }
74 
75  std::size_t
76  size() const {
77  return children_.size();
78  }
79 
80  HistoryNode *
81  lastChildAddress() {
82  return &children_.back();
83  }
84 
85  typedef std::vector<HistoryNode>::const_iterator const_iterator;
86  typedef std::vector<HistoryNode>::iterator iterator;
87 
88  iterator begin() { return children_.begin();}
89  iterator end() { return children_.end();}
90 
91  const_iterator begin() const { return children_.begin();}
92  const_iterator end() const { return children_.end();}
93 
94  void print(std::ostream& os) const {
95  os << config_.processName()
96  << " '" << config_.passID() << "' '"
97  << config_.releaseVersion() << "' ["
98  << simpleId_ << "] ("
99  << config_.parameterSetID() << ")"
100  << std::endl;
101  }
102 
103  void printHistory(std::string const& iIndent = std::string(" ")) const;
104  void printEventSetupHistory(ParameterSetMap const& iPSM,
105  std::vector<std::string> const& iFindMatch,
106  std::ostream& oErrorLog) const;
107  void printOtherModulesHistory(ParameterSetMap const& iPSM,
108  ModuleToIdBranches const&,
109  std::vector<std::string> const& iFindMatch,
110  std::ostream& oErrorLog) const;
111  void printTopLevelPSetsHistory(ParameterSetMap const& iPSM,
112  std::vector<std::string> const& iFindMatch,
113  std::ostream& oErrorLog) const;
114 
116  configurationID() const {
117  return config_.id();
118  }
119 
120  static bool sort_;
121  private:
123  std::vector<HistoryNode> children_;
124  unsigned int simpleId_;
125  };
126 
127  std::ostream& operator<<(std::ostream& os, HistoryNode const& node) {
128  node.print(os);
129  return os;
130  }
131  bool HistoryNode::sort_ = false;
132 }
133 
134 std::ostream&
135 operator<<(std::ostream& os, edm::ProcessHistory& iHist) {
136  std::string const indentDelta(" ");
137  std::string indent = indentDelta;
138  for(auto const& process : iHist) {
139  os << indent
140  << process.processName() << " '"
141  << process.passID() << "' '"
142  << process.releaseVersion() << "' ("
143  << process.parameterSetID() << ")"
144  << std::endl;
145  indent += indentDelta;
146  }
147  return os;
148 }
149 
150 void HistoryNode::printHistory(std::string const& iIndent) const {
151  std::string const indentDelta(" ");
152  const std::string& indent = iIndent;
153  for(auto const& item : *this) {
154  std::cout << indent << item;
155  item.printHistory(indent + indentDelta);
156  }
157 }
158 
160  std::string const& iCompName,
161  edm::ParameterSet const& iProcessConfig,
162  std::string const& iProcessName) {
163  std::ostringstream result;
164  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iCompName);
165  std::string name(pset.getParameter<std::string>("@module_label"));
166  if(name.empty()) {
167  name = pset.getParameter<std::string>("@module_type");
168  }
169 
170  result << iType << ": " << name << " " << iProcessName << "\n"
171  << " parameters: ";
172  prettyPrint(result, pset, " ", " ");
173  return result.str();
174 }
175 
176 void HistoryNode::printEventSetupHistory(ParameterSetMap const& iPSM,
177  std::vector<std::string> const& iFindMatch,
178  std::ostream& oErrorLog) const {
179  for(auto const& itH : *this) {
180  //Get ParameterSet for process
181  ParameterSetMap::const_iterator itFind = iPSM.find(itH.parameterSetID());
182  if(itFind == iPSM.end()){
183  oErrorLog << "No ParameterSetID for " << itH.parameterSetID() << std::endl;
184  } else {
185  edm::ParameterSet processConfig(itFind->second.pset());
186  std::vector<std::string> sourceStrings, moduleStrings;
187  //get the sources
188  std::vector<std::string> sources = processConfig.getParameter<std::vector<std::string> >("@all_essources");
189  for(auto& itM : sources) {
190  std::string retValue = eventSetupComponent("ESSource",
191  itM,
192  processConfig,
193  itH.processName());
194  bool foundMatch = true;
195  if(!iFindMatch.empty()) {
196  for (auto const& stringToFind : iFindMatch) {
197  if (retValue.find(stringToFind) == std::string::npos) {
198  foundMatch = false;
199  break;
200  }
201  }
202  }
203  if (foundMatch) {
204  sourceStrings.push_back(std::move(retValue));
205  }
206  }
207  //get the modules
208  std::vector<std::string> modules = processConfig.getParameter<std::vector<std::string> >("@all_esmodules");
209  for(auto& itM : modules) {
210  std::string retValue = eventSetupComponent("ESModule",
211  itM,
212  processConfig,
213  itH.processName());
214  bool foundMatch = true;
215  if(!iFindMatch.empty()) {
216  for (auto const& stringToFind : iFindMatch) {
217  if (retValue.find(stringToFind) == std::string::npos) {
218  foundMatch = false;
219  break;
220  }
221  }
222  }
223  if (foundMatch) {
224  moduleStrings.push_back(std::move(retValue));
225  }
226  }
227  if(sort_) {
228  std::sort(sourceStrings.begin(), sourceStrings.end());
229  std::sort(moduleStrings.begin(), moduleStrings.end());
230  }
231  std::copy(sourceStrings.begin(), sourceStrings.end(),
232  std::ostream_iterator<std::string>(std::cout, "\n"));
233  std::copy(moduleStrings.begin(), moduleStrings.end(),
234  std::ostream_iterator<std::string>(std::cout, "\n"));
235 
236  }
237  itH.printEventSetupHistory(iPSM, iFindMatch, oErrorLog);
238  }
239 }
240 
242  edm::ParameterSet const& iProcessConfig,
243  std::string const& iProcessName) {
244  std::ostringstream result;
245  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iCompName);
246  std::string label(pset.getParameter<std::string>("@module_label"));
247 
248  result << "Module: " << label << " " << iProcessName << "\n" << " parameters: ";
249  prettyPrint(result, pset, " ", " ");
250  return result.str();
251 }
252 
253 void HistoryNode::printOtherModulesHistory(ParameterSetMap const& iPSM,
254  ModuleToIdBranches const& iModules,
255  std::vector<std::string> const& iFindMatch,
256  std::ostream& oErrorLog) const {
257  for(auto const& itH : *this) {
258  //Get ParameterSet for process
259  ParameterSetMap::const_iterator itFind = iPSM.find(itH.parameterSetID());
260  if(itFind == iPSM.end()){
261  oErrorLog << "No ParameterSetID for " << itH.parameterSetID() << std::endl;
262  } else {
263  edm::ParameterSet processConfig(itFind->second.pset());
264  std::vector<std::string> moduleStrings;
265  //get all modules
266  std::vector<std::string> modules = processConfig.getParameter<std::vector<std::string> >("@all_modules");
267  for(auto& itM : modules) {
268  //if we didn't already handle this from the branches
269  if(iModules.end() == iModules.find(std::make_pair(itH.processName(), itM))) {
271  itM,
272  processConfig,
273  itH.processName()));
274  bool foundMatch = true;
275  if(!iFindMatch.empty()) {
276  for (auto const& stringToFind : iFindMatch) {
277  if (retValue.find(stringToFind) == std::string::npos) {
278  foundMatch = false;
279  break;
280  }
281  }
282  }
283  if (foundMatch) {
284  moduleStrings.push_back(std::move(retValue));
285  }
286  }
287  }
288  if(sort_) {
289  std::sort(moduleStrings.begin(), moduleStrings.end());
290  }
291  std::copy(moduleStrings.begin(), moduleStrings.end(),
292  std::ostream_iterator<std::string>(std::cout, "\n"));
293  }
294  itH.printOtherModulesHistory(iPSM, iModules, iFindMatch, oErrorLog);
295  }
296 }
297 
298 static void appendToSet(std::set<std::string>&iSet, std::vector<std::string> const& iFrom){
299  for(auto const& n : iFrom) {
300  iSet.insert(n);
301  }
302 }
303 
305  edm::ParameterSet const& iProcessConfig,
306  std::string const& iProcessName) {
307  std::ostringstream result;
308  edm::ParameterSet const& pset = iProcessConfig.getParameterSet(iName);
309 
310  result << "PSet: " << iName << " " << iProcessName << "\n" << " parameters: ";
311  prettyPrint(result, pset, " ", " ");
312  return result.str();
313 }
314 
315 
316 void HistoryNode::printTopLevelPSetsHistory(ParameterSetMap const& iPSM,
317  std::vector<std::string> const& iFindMatch,
318  std::ostream& oErrorLog) const {
319  for(auto const& itH : *this) {
320  //Get ParameterSet for process
321  ParameterSetMap::const_iterator itFind = iPSM.find(itH.parameterSetID());
322  if(itFind == iPSM.end()){
323  oErrorLog << "No ParameterSetID for " << itH.parameterSetID() << std::endl;
324  } else {
325  edm::ParameterSet processConfig(itFind->second.pset());
326  //Need to get the names of PSets which are used by the framework (e.g. names of modules)
327  std::set<std::string> namesToExclude;
328  appendToSet(namesToExclude,processConfig.getParameter<std::vector<std::string> >("@all_modules"));
329  appendToSet(namesToExclude,processConfig.getParameter<std::vector<std::string> >("@all_sources"));
330  appendToSet(namesToExclude,processConfig.getParameter<std::vector<std::string> >("@all_loopers"));
331  //appendToSet(namesToExclude,processConfig.getParameter<std::vector<std::string> >("@all_subprocesses"));//untracked
332  appendToSet(namesToExclude,processConfig.getParameter<std::vector<std::string> >("@all_esmodules"));
333  appendToSet(namesToExclude,processConfig.getParameter<std::vector<std::string> >("@all_essources"));
334  appendToSet(namesToExclude,processConfig.getParameter<std::vector<std::string> >("@all_esprefers"));
335  if (processConfig.existsAs<std::vector<std::string>>("all_aliases")) {
336  appendToSet(namesToExclude,processConfig.getParameter<std::vector<std::string> >("@all_aliases"));
337  }
338 
339  std::vector<std::string> allNames{};
340  processConfig.getParameterSetNames(allNames);
341 
342  std::vector<std::string> results;
343  for(auto const& name: allNames){
344  if (name.empty() || '@' == name[0] || namesToExclude.find(name)!=namesToExclude.end()) {
345  continue;
346  }
347  std::string retValue = topLevelPSet(name,processConfig,itH.processName());
348 
349  bool foundMatch = true;
350  if(!iFindMatch.empty()) {
351  for (auto const& stringToFind : iFindMatch) {
352  if (retValue.find(stringToFind) == std::string::npos) {
353  foundMatch = false;
354  break;
355  }
356  }
357  }
358  if (foundMatch) {
359  results.push_back(std::move(retValue));
360  }
361  }
362  if(sort_) {
363  std::sort(results.begin(), results.end());
364  }
365  std::copy(results.begin(), results.end(),
366  std::ostream_iterator<std::string>(std::cout, "\n"));
367  }
368  itH.printTopLevelPSetsHistory(iPSM, iFindMatch, oErrorLog);
369  }
370 }
371 
372 
373 namespace {
374  std::unique_ptr<TFile>
375  makeTFileWithLookup(std::string const& filename) {
376  // See if it is a logical file name.
377  std::unique_ptr<edm::SiteLocalConfig> slcptr = std::make_unique<edm::service::SiteLocalConfigService>(edm::ParameterSet());
378  auto slc = std::make_shared<edm::serviceregistry::ServiceWrapper<edm::SiteLocalConfig> >(std::move(slcptr));
381  std::string override;
382  std::vector<std::string> fileNames;
383  fileNames.push_back(filename);
384  edm::InputFileCatalog catalog(fileNames, override, true);
385  if(catalog.fileNames()[0] == filename) {
386  throw cms::Exception("FileNotFound", "RootFile::RootFile()")
387  << "File " << filename << " was not found or could not be opened.\n";
388  }
389  // filename is a valid LFN.
390  std::unique_ptr<TFile> result(TFile::Open(catalog.fileNames()[0].c_str()));
391  if(!result.get()) {
392  throw cms::Exception("FileNotFound", "RootFile::RootFile()")
393  << "File " << fileNames[0] << " was not found or could not be opened.\n";
394  }
395  return result;
396  }
397 
398  // Open the input file, returning the TFile object that represents it.
399  // The returned unique_ptr will not be null. The argument must not be null.
400  // We first try the file name as a PFN, so that the catalog and related
401  // services are not loaded unless needed.
402  std::unique_ptr<TFile>
403  makeTFile(std::string const& filename) {
404  gErrorIgnoreLevel = kFatal;
405  std::unique_ptr<TFile> result(TFile::Open(filename.c_str()));
407  if(!result.get()) {
408  // Try again with catalog.
409  return makeTFileWithLookup(filename);
410  }
411  return result;
412  }
413 }
414 
415 
416 static std::ostream& prettyPrint(std::ostream& os, edm::ParameterSetEntry const& psetEntry, std::string const& iIndent, std::string const& iIndentDelta) {
417  char const* trackiness = (psetEntry.isTracked()?"tracked":"untracked");
418  os << "PSet " << trackiness << " = (";
419  prettyPrint(os, psetEntry.pset(), iIndent + iIndentDelta, iIndentDelta);
420  os << ")";
421  return os;
422 }
423 
424 static std::ostream& prettyPrint(std::ostream& os, edm::VParameterSetEntry const& vpsetEntry, std::string const& iIndent, std::string const& iIndentDelta) {
425  std::vector<edm::ParameterSet> const& vps = vpsetEntry.vpset();
426  os << "VPSet " << (vpsetEntry.isTracked() ? "tracked" : "untracked") << " = ({" << std::endl;
427  std::string newIndent = iIndent+iIndentDelta;
429  std::string const between(",\n");
430  for(auto const& item : vps) {
431  os << start << newIndent;
432  prettyPrint(os, item, newIndent, iIndentDelta);
433  start = between;
434  }
435  if(!vps.empty()) {
436  os << std::endl;
437  }
438  os << iIndent<< "})";
439  return os;
440 }
441 
442 
443 static std::ostream& prettyPrint(std::ostream& oStream, edm::ParameterSet const& iPSet, std::string const& iIndent, std::string const& iIndentDelta) {
444  std::string newIndent = iIndent+iIndentDelta;
445 
446  oStream << "{" << std::endl;
447  for(auto const& item : iPSet.tbl()) {
448  // indent a bit
449  oStream << newIndent<< item.first << ": " << item.second << std::endl;
450  }
451  for(auto const& item : iPSet.psetTable()) {
452  // indent a bit
453  edm::ParameterSetEntry const& pe = item.second;
454  oStream << newIndent << item.first << ": ";
455  prettyPrint(oStream, pe, iIndent, iIndentDelta);
456  oStream<< std::endl;
457  }
458  for(auto const& item : iPSet.vpsetTable()) {
459  // indent a bit
460  edm::VParameterSetEntry const& pe = item.second;
461  oStream << newIndent << item.first << ": ";
462  prettyPrint(oStream, pe, newIndent, iIndentDelta);
463  oStream<< std::endl;
464  }
465  oStream << iIndent<< "}";
466 
467  return oStream;
468 }
469 
470 
472 public:
473  // It is illegal to call this constructor with a null pointer; a
474  // legal C-style string is required.
476  bool showDependencies,
477  bool extendedAncestors,
478  bool extendedDescendants,
479  bool excludeESModules,
480  bool showAllModules,
481  bool showTopLevelPSets,
482  std::vector<std::string> const& findMatch,
483  bool dontPrintProducts,
484  std::string const& dumpPSetID);
485 
486  ProvenanceDumper(ProvenanceDumper const&) = delete; // Disallow copying and moving
487  ProvenanceDumper& operator=(ProvenanceDumper const&) = delete; // Disallow copying and moving
488 
489  // Write the provenenace information to the given stream.
490  void dump();
491  void printErrors(std::ostream& os);
492  int exitCode() const;
493 
494 private:
495 
496  void addAncestors(edm::BranchID const& branchID,
497  std::set<edm::BranchID>& ancestorBranchIDs,
498  std::ostringstream& sout,
499  std::map<edm::BranchID, std::set<edm::ParentageID> >& perProductParentage) const;
500 
501  void addDescendants(edm::BranchID const& branchID, std::set<edm::BranchID>& descendantBranchIDs,
502  std::ostringstream& sout,
503  std::map<edm::BranchID, std::set<edm::BranchID> >& parentToChildren) const;
504 
508  std::stringstream errorLog_;
513  ParameterSetMap psm_;
514  HistoryNode historyGraph_;
522  std::vector<std::string> findMatch_;
525 
526  void work_();
527  void dumpProcessHistory_();
528  void dumpEventFilteringParameterSets_(TFile * file);
529  void dumpEventFilteringParameterSets(edm::EventSelectionIDVector const& ids);
530  void dumpParameterSetForID_(edm::ParameterSetID const& id);
531 };
532 
534  bool showDependencies,
535  bool extendedAncestors,
536  bool extendedDescendants,
537  bool excludeESModules,
538  bool showOtherModules,
539  bool showTopLevelPSets,
540  std::vector<std::string> const& findMatch,
541  bool dontPrintProducts,
542  std::string const& dumpPSetID) :
543  filename_(filename),
544  inputFile_(makeTFile(filename)),
545  exitCode_(0),
546  errorLog_(),
547  errorCount_(0),
548  showDependencies_(showDependencies),
549  extendedAncestors_(extendedAncestors),
550  extendedDescendants_(extendedDescendants),
551  excludeESModules_(excludeESModules),
552  showOtherModules_(showOtherModules),
553  productRegistryPresent_(true),
554  showTopLevelPSets_(showTopLevelPSets),
555  findMatch_(findMatch),
556  dontPrintProducts_(dontPrintProducts),
557  dumpPSetID_(dumpPSetID) {
558 }
559 
560 void
562  work_();
563 }
564 
565 void
566 ProvenanceDumper::printErrors(std::ostream& os) {
567  if(errorCount_ > 0) os << errorLog_.str() << std::endl;
568 }
569 
570 int
572  return exitCode_;
573 }
574 
575 void
577  edm::EventSelectionIDVector::size_type num_ids = ids.size();
578  if(num_ids == 0) {
579  std::cout << "No event filtering information is available.\n";
580  std::cout << "------------------------------\n";
581  } else {
582  std::cout << "Event filtering information for "
583  << num_ids
584  << " processing steps is available.\n"
585  << "The ParameterSets will be printed out, "
586  << "with the oldest printed first.\n";
587  for(edm::EventSelectionIDVector::size_type i = 0; i != num_ids; ++i) {
589  }
590  }
591 }
592 
593 void
595 
596  TTree* history = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventHistoryTreeName().c_str()));
597  if(history != nullptr) {
598  edm::History h;
599  edm::History* ph = &h;
600 
601  history->SetBranchAddress(edm::poolNames::eventHistoryBranchName().c_str(), &ph);
602  if(history->GetEntry(0) <= 0) {
603  std::cout << "No event filtering information is available; the event history tree has no entries\n";
604  } else {
606  }
607  } else {
608  TTree* events = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventTreeName().c_str()));
609  assert (events != nullptr);
610  TBranch* eventSelectionsBranch = events->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
611  if (eventSelectionsBranch == nullptr) return;
614  eventSelectionsBranch->SetAddress(&pids);
615  if(eventSelectionsBranch->GetEntry(0) <= 0) {
616  std::cout << "No event filtering information is available; the event selections branch has no entries\n";
617  } else {
619  }
620  }
621 }
622 
623 void
625  std::cout << "ParameterSetID: " << id << '\n';
626  if(id.isValid()) {
627  ParameterSetMap::const_iterator i = psm_.find(id);
628  if(i == psm_.end()) {
629  std::cout << "We are unable to find the corresponding ParameterSet\n";
631  empty.registerIt();
632  if(id == empty.id()) {
633  std::cout << "But it would have been empty anyway\n";
634  }
635  } else {
636  edm::ParameterSet ps(i->second.pset());
637  prettyPrint(std::cout, ps, " ", " ");
638  std::cout<< '\n';
639  }
640  } else {
641  std::cout << "This ID is not valid\n";
642  }
643  std::cout << " -------------------------\n";
644 }
645 
646 void
648  std::cout << "Processing History:" << std::endl;
649  if(1 == phv_.size()) {
650  std::cout << *phv_.begin();
651  historyGraph_.addChild(HistoryNode(*(phv_.begin()->begin()), 1));
652  } else {
653  std::map<edm::ProcessConfigurationID, unsigned int> simpleIDs;
654  for(auto const& ph : phv_) {
655  //loop over the history entries looking for matches
656  HistoryNode* parent = &historyGraph_;
657  for(auto const& pc : ph) {
658  if(parent->size() == 0) {
659  unsigned int id = simpleIDs[pc.id()];
660  if(0 == id) {
661  id = 1;
662  simpleIDs[pc.id()] = id;
663  }
664  parent->addChild(HistoryNode(pc, id));
665  parent = parent->lastChildAddress();
666  } else {
667  //see if this is unique
668  bool isUnique = true;
669  for(auto& child : *parent) {
670  if(child.configurationID() == pc.id()) {
671  isUnique = false;
672  parent = &child;
673  break;
674  }
675  }
676  if(isUnique) {
677  simpleIDs[pc.id()] = parent->size() + 1;
678  parent->addChild(HistoryNode(pc, simpleIDs[pc.id()]));
679  parent = parent->lastChildAddress();
680  }
681  }
682  }
683  }
684  historyGraph_.printHistory();
685  }
686 }
687 
688 void
690 
691  TTree* meta = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::metaDataTreeName().c_str()));
692  assert(nullptr != meta);
693 
694  edm::ProductRegistry* pReg = &reg_;
695  if(meta->FindBranch(edm::poolNames::productDescriptionBranchName().c_str()) != nullptr) {
696  meta->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(), &pReg);
697  } else {
698  productRegistryPresent_ = false;
699  }
700 
701  ParameterSetMap* pPsm = &psm_;
702  if(meta->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != nullptr) {
703  meta->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(), &pPsm);
704  } else {
705  TTree* psetTree = dynamic_cast<TTree *>(inputFile_->Get(edm::poolNames::parameterSetsTreeName().c_str()));
706  assert(nullptr != psetTree);
707  typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs;
708  IdToBlobs idToBlob;
709  IdToBlobs* pIdToBlob = &idToBlob;
710  psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
711  for(long long i = 0; i != psetTree->GetEntries(); ++i) {
712  psetTree->GetEntry(i);
713  psm_.insert(idToBlob);
714  }
715  }
716 
718  if(meta->FindBranch(edm::poolNames::processHistoryBranchName().c_str()) != nullptr) {
719  meta->SetBranchAddress(edm::poolNames::processHistoryBranchName().c_str(), &pPhv);
720  }
721 
723  edm::ProcessHistoryMap* pPhm = &phm;
724  if(meta->FindBranch(edm::poolNames::processHistoryMapBranchName().c_str()) != nullptr) {
725  meta->SetBranchAddress(edm::poolNames::processHistoryMapBranchName().c_str(), &pPhm);
726  }
727 
728  if(meta->FindBranch(edm::poolNames::moduleDescriptionMapBranchName().c_str()) != nullptr) {
729  if(meta->GetBranch(edm::poolNames::moduleDescriptionMapBranchName().c_str())->GetSplitLevel() != 0) {
730  meta->SetBranchStatus((edm::poolNames::moduleDescriptionMapBranchName() + ".*").c_str(), false);
731  } else {
732  meta->SetBranchStatus(edm::poolNames::moduleDescriptionMapBranchName().c_str(), false);
733  }
734  }
735 
736  meta->GetEntry(0);
737  assert(nullptr != pReg);
738 
740  for(auto const& item : psm_) {
741  edm::ParameterSet pset(item.second.pset());
742  pset.setID(item.first);
743  psetRegistry.insertMapped(pset);
744  }
745 
746 
747  if(!phv_.empty()) {
748  for(auto const& history : phv_) {
749  for(auto const& process : history) {
750  phc_.push_back(process);
751  }
752  }
754  phc_.erase(std::unique(phc_.begin(), phc_.end()), phc_.end());
755 
756  }
757  // backward compatibility
758  else if(!phm.empty()) {
759  for(auto const& history : phm) {
760  phv_.push_back(history.second);
761  for(auto const& process : history.second) {
762  phc_.push_back(process);
763  }
764  }
766  phc_.erase(std::unique(phc_.begin(), phc_.end()), phc_.end());
767  }
768 
769  if(!dumpPSetID_.empty()) {
770  edm::ParameterSetID psetID;
771  try {
773  } catch (cms::Exception const& x) {
774  throw cms::Exception("Command Line Argument") << "Illegal ParameterSetID string. It should contain 32 hexadecimal characters";
775  }
776  dumpParameterSetForID_(psetID);
777  return;
778  }
779 
780  //Prepare the parentage information if requested
781  std::map<edm::BranchID, std::set<edm::ParentageID> > perProductParentage;
782 
784  TTree* parentageTree = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::parentageTreeName().c_str()));
785  if(nullptr == parentageTree) {
786  std::cerr << "ERROR, no Parentage tree available so cannot show dependencies, ancestors, or descendants.\n";
787  std::cerr << "Possibly this is not a standard EDM format file. For example, dependency, ancestor, and\n";
788  std::cerr << "descendant options to edmProvDump will not work with nanoAOD format files.\n\n";
789  showDependencies_ = false;
790  extendedAncestors_ = false;
791  extendedDescendants_ = false;
792  } else {
793 
795 
796  std::vector<edm::ParentageID> orderedParentageIDs;
797  orderedParentageIDs.reserve(parentageTree->GetEntries());
798  for(Long64_t i = 0, numEntries = parentageTree->GetEntries(); i < numEntries; ++i) {
799  edm::Parentage parentageBuffer;
800  edm::Parentage *pParentageBuffer = &parentageBuffer;
801  parentageTree->SetBranchAddress(edm::poolNames::parentageBranchName().c_str(), &pParentageBuffer);
802  parentageTree->GetEntry(i);
803  registry.insertMapped(parentageBuffer);
804  orderedParentageIDs.push_back(parentageBuffer.id());
805  }
806  parentageTree->SetBranchAddress(edm::poolNames::parentageBranchName().c_str(), nullptr);
807 
808  TTree* eventMetaTree = dynamic_cast<TTree*>(inputFile_->Get(edm::BranchTypeToMetaDataTreeName(edm::InEvent).c_str()));
809  if(nullptr == eventMetaTree) {
810  eventMetaTree = dynamic_cast<TTree*>(inputFile_->Get(edm::BranchTypeToProductTreeName(edm::InEvent).c_str()));
811  }
812  if(nullptr == eventMetaTree) {
813  std::cerr << "ERROR, no '" << edm::BranchTypeToProductTreeName(edm::InEvent)<< "' Tree in file so can not show dependencies\n";
814  showDependencies_ = false;
815  extendedAncestors_ = false;
816  extendedDescendants_ = false;
817  } else {
818  TBranch* storedProvBranch = eventMetaTree->GetBranch(edm::BranchTypeToProductProvenanceBranchName(edm::InEvent).c_str());
819 
820  if(nullptr!=storedProvBranch) {
821  std::vector<edm::StoredProductProvenance> info;
822  std::vector<edm::StoredProductProvenance>* pInfo = &info;
823  storedProvBranch->SetAddress(&pInfo);
824  for(Long64_t i = 0, numEntries = eventMetaTree->GetEntries(); i < numEntries; ++i) {
825  storedProvBranch->GetEntry(i);
826  for(auto const& item : info) {
827  edm::BranchID bid(item.branchID_);
828  perProductParentage[bid].insert(orderedParentageIDs.at(item.parentageIDIndex_));
829  }
830  }
831  } else {
832  //backwards compatible check
833  TBranch* productProvBranch = eventMetaTree->GetBranch(edm::BranchTypeToBranchEntryInfoBranchName(edm::InEvent).c_str());
834  if (nullptr != productProvBranch) {
835  std::vector<edm::ProductProvenance> info;
836  std::vector<edm::ProductProvenance>* pInfo = &info;
837  productProvBranch->SetAddress(&pInfo);
838  for(Long64_t i = 0, numEntries = eventMetaTree->GetEntries(); i < numEntries; ++i) {
839  productProvBranch->GetEntry(i);
840  for(auto const& item : info) {
841  perProductParentage[item.branchID()].insert(item.parentageID());
842  }
843  }
844  } else {
845  std::cerr <<" ERROR, could not find provenance information so can not show dependencies\n";
846  showDependencies_=false;
847  extendedAncestors_ = false;
848  extendedDescendants_ = false;
849  }
850  }
851  }
852  }
853  }
854 
855  std::map<edm::BranchID, std::set<edm::BranchID> > parentToChildren;
857 
858  if (extendedDescendants_) {
859  for (auto const& itParentageSet : perProductParentage) {
860  edm::BranchID childBranchID = itParentageSet.first;
861  for (auto const& itParentageID : itParentageSet.second) {
862  edm::Parentage const* parentage = registry.getMapped(itParentageID);
863  if(nullptr != parentage) {
864  for(auto const& branch : parentage->parents()) {
865  parentToChildren[branch].insert(childBranchID);
866  }
867  } else {
868  std::cerr << " ERROR:parentage info not in registry ParentageID=" << itParentageID << std::endl;
869  }
870  }
871  }
872  }
873 
875 
877 
879  std::cout << "---------Producers with data in file---------" << std::endl;
880  }
881 
882  //using edm::ParameterSetID as the key does not work
883  // typedef std::map<edm::ParameterSetID, std::vector<edm::BranchDescription> > IdToBranches
884  ModuleToIdBranches moduleToIdBranches;
885  //IdToBranches idToBranches;
886 
887  std::map<edm::BranchID, std::string> branchIDToBranchName;
888 
889  for(auto const& processConfig : phc_) {
890  edm::ParameterSet const* processParameterSet = edm::pset::Registry::instance()->getMapped(processConfig.parameterSetID());
891  if(nullptr == processParameterSet || processParameterSet->empty()) {
892  continue;
893  }
894  for(auto& item : reg_.productListUpdator()) {
895  auto& product = item.second;
896  if(product.processName() != processConfig.processName()) {
897  continue;
898  }
899  //force it to rebuild the branch name
900  product.init();
901 
903  branchIDToBranchName[product.branchID()] = product.branchName();
904  }
905  /*
906  std::cout << product.branchName()
907  << " id " << product.productID() << std::endl;
908  */
909  std::string moduleLabel = product.moduleLabel();
910  if(moduleLabel == source) {
911  moduleLabel = input;
912  } else if (moduleLabel == triggerResults) {
913  moduleLabel = triggerPaths;
914  }
915 
916  std::stringstream s;
917 
918  if(processParameterSet->existsAs<edm::ParameterSet>(moduleLabel)) {
919  edm::ParameterSet const& moduleParameterSet = processParameterSet->getParameterSet(moduleLabel);
920  if(!moduleParameterSet.isRegistered()) {
921  edm::ParameterSet moduleParameterSetCopy = processParameterSet->getParameterSet(moduleLabel);
922  moduleParameterSetCopy.registerIt();
923  s << moduleParameterSetCopy.id();
924  } else {
925  s << moduleParameterSet.id();
926  }
927  moduleToIdBranches[std::make_pair(product.processName(), product.moduleLabel())][s.str()].push_back(product);
928  }
929  }
930  }
931 
932  for(auto const& item : moduleToIdBranches) {
933  std::ostringstream sout;
934  sout << "Module: " << item.first.second << " " << item.first.first << std::endl;
935  std::set<edm::BranchID> allBranchIDsForLabelAndProcess;
936  IdToBranches const& idToBranches = item.second;
937  for(auto const& idBranch : idToBranches) {
938  sout << " PSet id:" << idBranch.first << std::endl;
939  if(!dontPrintProducts_) {
940  sout << " products: {" << std::endl;
941  }
942  std::set<edm::BranchID> branchIDs;
943  for(auto const& branch : idBranch.second) {
944  if(!dontPrintProducts_) {
945  sout << " " << branch.branchName() << std::endl;
946  }
947  branchIDs.insert(branch.branchID());
948  allBranchIDsForLabelAndProcess.insert(branch.branchID());
949  }
950  sout << " }" << std::endl;
951  edm::ParameterSetID psid(idBranch.first);
952  ParameterSetMap::const_iterator itpsm = psm_.find(psid);
953  if(psm_.end() == itpsm) {
954  ++errorCount_;
955  errorLog_ << "No ParameterSetID for " << psid << std::endl;
956  exitCode_ = 1;
957  } else {
958  sout << " parameters: ";
959  prettyPrint(sout, edm::ParameterSet((*itpsm).second.pset()), " ", " ");
960  sout << std::endl;
961  }
962  if(showDependencies_) {
963 
964  sout << " dependencies: {" << std::endl;
965  std::set<edm::ParentageID> parentageIDs;
966  for(auto const& branch : branchIDs) {
967 
968  //Save these BranchIDs
969  std::set<edm::ParentageID> const& temp = perProductParentage[branch];
970  parentageIDs.insert(temp.begin(), temp.end());
971  }
972  for(auto const& parentID : parentageIDs) {
973  edm::Parentage const* parentage = registry.getMapped(parentID);
974  if(nullptr != parentage) {
975  for(auto const& branch : parentage->parents()) {
976  sout << " " << branchIDToBranchName[branch] << std::endl;
977  }
978  } else {
979  sout << " ERROR:parentage info not in registry ParentageID=" << parentID << std::endl;
980  }
981  }
982  if(parentageIDs.empty()) {
983  sout << " no dependencies recorded (event may not contain data from this module)" << std::endl;
984  }
985  sout << " }" << std::endl;
986  }
987  } // end loop over PSetIDs
988  if (extendedAncestors_) {
989  sout << " extendedAncestors: {" << std::endl;
990  std::set<edm::BranchID> ancestorBranchIDs;
991  for (auto const& branchID : allBranchIDsForLabelAndProcess) {
992  addAncestors(branchID, ancestorBranchIDs, sout, perProductParentage);
993  }
994  for (auto const& ancestorBranchID : ancestorBranchIDs) {
995  sout << " " << branchIDToBranchName[ancestorBranchID] << "\n";
996  }
997  sout << " }" << std::endl;
998  }
999 
1000  if (extendedDescendants_) {
1001  sout << " extendedDescendants: {" << std::endl;
1002  std::set<edm::BranchID> descendantBranchIDs;
1003  for (auto const& branchID : allBranchIDsForLabelAndProcess) {
1004  addDescendants(branchID, descendantBranchIDs, sout, parentToChildren);
1005  }
1006  for (auto const& descendantBranchID : descendantBranchIDs) {
1007  sout << " " << branchIDToBranchName[descendantBranchID] << "\n";
1008  }
1009  sout << " }" << std::endl;
1010  }
1011  bool foundMatch = true;
1012  if(!findMatch_.empty()) {
1013  for (auto const& stringToFind : findMatch_) {
1014  if (sout.str().find(stringToFind) == std::string::npos) {
1015  foundMatch = false;
1016  break;
1017  }
1018  }
1019  }
1020  if (foundMatch) {
1021  std::cout <<sout.str()<<std::endl;
1022  }
1023  } // end loop over module label/process
1025  std::cout << "---------Other Modules---------" << std::endl;
1026  historyGraph_.printOtherModulesHistory(psm_, moduleToIdBranches, findMatch_, errorLog_);
1027  } else if (!productRegistryPresent_) {
1028  std::cout << "---------All Modules---------" << std::endl;
1029  historyGraph_.printOtherModulesHistory(psm_, moduleToIdBranches, findMatch_, errorLog_);
1030  }
1031 
1032  if(!excludeESModules_) {
1033  std::cout << "---------EventSetup---------" << std::endl;
1034  historyGraph_.printEventSetupHistory(psm_, findMatch_, errorLog_);
1035  }
1036 
1037  if(showTopLevelPSets_) {
1038  std::cout << "---------Top Level PSets---------" << std::endl;
1039  historyGraph_.printTopLevelPSetsHistory(psm_, findMatch_, errorLog_);
1040  }
1041  if(errorCount_ != 0) {
1042  exitCode_ = 1;
1043  }
1044 }
1045 
1046 void
1047 ProvenanceDumper::addAncestors(edm::BranchID const& branchID, std::set<edm::BranchID>& ancestorBranchIDs, std::ostringstream& sout,
1048  std::map<edm::BranchID, std::set<edm::ParentageID> >& perProductParentage) const {
1049 
1051 
1052  std::set<edm::ParentageID> const& parentIDs = perProductParentage[branchID];
1053  for (auto const& parentageID : parentIDs) {
1054  edm::Parentage const* parentage = registry.getMapped(parentageID);
1055  if(nullptr != parentage) {
1056  for(auto const& branch : parentage->parents()) {
1057 
1058  if(ancestorBranchIDs.insert(branch).second) {
1059  addAncestors(branch, ancestorBranchIDs, sout, perProductParentage);
1060  }
1061  }
1062  } else {
1063  sout << " ERROR:parentage info not in registry ParentageID=" << parentageID << std::endl;
1064  }
1065  }
1066 }
1067 
1068 void
1069 ProvenanceDumper::addDescendants(edm::BranchID const& branchID, std::set<edm::BranchID>& descendantBranchIDs, std::ostringstream& sout,
1070  std::map<edm::BranchID, std::set<edm::BranchID> >& parentToChildren) const {
1071 
1072  for (auto const& childBranchID : parentToChildren[branchID]) {
1073  if (descendantBranchIDs.insert(childBranchID).second) {
1074  addDescendants(childBranchID, descendantBranchIDs, sout, parentToChildren);
1075  }
1076  }
1077 }
1078 
1079 static char const* const kSortOpt = "sort";
1080 static char const* const kSortCommandOpt = "sort,s";
1081 static char const* const kDependenciesOpt = "dependencies";
1082 static char const* const kDependenciesCommandOpt = "dependencies,d";
1083 static char const* const kExtendedAncestorsOpt = "extendedAncestors";
1084 static char const* const kExtendedAncestorsCommandOpt = "extendedAncestors,x";
1085 static char const* const kExtendedDescendantsOpt = "extendedDescendants";
1086 static char const* const kExtendedDescendantsCommandOpt = "extendedDescendants,c";
1087 static char const* const kExcludeESModulesOpt = "excludeESModules";
1088 static char const* const kExcludeESModulesCommandOpt = "excludeESModules,e";
1089 static char const* const kShowAllModulesOpt = "showAllModules";
1090 static char const* const kShowAllModulesCommandOpt = "showAllModules,a";
1091 static char const* const kFindMatchOpt = "findMatch";
1092 static char const* const kFindMatchCommandOpt = "findMatch,f";
1093 static char const* const kDontPrintProductsOpt = "dontPrintProducts";
1094 static char const* const kDontPrintProductsCommandOpt = "dontPrintProducts,p";
1095 static char const* const kShowTopLevelPSetsOpt = "showTopLevelPSets";
1096 static char const* const kShowTopLevelPSetsCommandOpt ="showTopLevelPSets,t";
1097 static char const* const kHelpOpt = "help";
1098 static char const* const kHelpCommandOpt = "help,h";
1099 static char const* const kFileNameOpt = "input-file";
1100 static char const* const kDumpPSetIDOpt = "dumpPSetID";
1101 static char const* const kDumpPSetIDCommandOpt = "dumpPSetID,i";
1102 
1103 int main(int argc, char* argv[]) {
1104  using namespace boost::program_options;
1105 
1106  std::string descString(argv[0]);
1107  descString += " [options] <filename>";
1108  descString += "\nAllowed options";
1109  options_description desc(descString);
1110  desc.add_options()
1111  (kHelpCommandOpt, "show help message")
1112  (kSortCommandOpt
1113  , "alphabetially sort EventSetup components")
1115  , "print what data each EDProducer is directly dependent upon")
1116  (kExtendedAncestorsCommandOpt
1117  , "print what data each EDProducer is dependent upon including indirect dependences")
1119  , "print what data depends on the data each EDProducer produces including indirect dependences")
1120  (kExcludeESModulesCommandOpt
1121  , "do not print ES module information")
1123  , "show all modules (not just those that created data in the file)")
1124  (kShowTopLevelPSetsCommandOpt,"show all top level PSets")
1125  (kFindMatchCommandOpt, boost::program_options::value<std::vector<std::string> >(),
1126  "show only modules whose information contains the matching string (or all the matching strings, this option can be repeated with different strings)")
1128  , "do not print products produced by module")
1129  (kDumpPSetIDCommandOpt, value<std::string>()
1130  , "print the parameter set associated with the parameter set ID string (and print nothing else)")
1131  ;
1132  //we don't want users to see these in the help messages since this
1133  // name only exists since the parser needs it
1134  options_description hidden;
1135  hidden.add_options()(kFileNameOpt, value<std::string>(), "file name");
1136 
1137  //full list of options for the parser
1138  options_description cmdline_options;
1139  cmdline_options.add(desc).add(hidden);
1140 
1141  positional_options_description p;
1142  p.add(kFileNameOpt, -1);
1143 
1144  variables_map vm;
1145  try {
1146  store(command_line_parser(argc, argv).options(cmdline_options).positional(p).run(), vm);
1147  notify(vm);
1148  } catch(error const& iException) {
1149  std::cerr << iException.what();
1150  return 1;
1151  }
1152 
1153  if(vm.count(kHelpOpt)) {
1154  std::cout << desc << std::endl;
1155  return 0;
1156  }
1157 
1158  if(vm.count(kSortOpt)) {
1159  HistoryNode::sort_ = true;
1160  }
1161 
1162  bool showDependencies = false;
1163  if(vm.count(kDependenciesOpt)) {
1164  showDependencies = true;
1165  }
1166 
1167  bool extendedAncestors = false;
1168  if(vm.count(kExtendedAncestorsOpt)) {
1169  extendedAncestors = true;
1170  }
1171 
1172  bool extendedDescendants = false;
1173  if(vm.count(kExtendedDescendantsOpt)) {
1174  extendedDescendants = true;
1175  }
1176 
1177  bool excludeESModules = false;
1178  if(vm.count(kExcludeESModulesOpt)) {
1179  excludeESModules = true;
1180  }
1181 
1182  bool showAllModules = false;
1183  if(vm.count(kShowAllModulesOpt)) {
1184  showAllModules = true;
1185  }
1186 
1187  bool showTopLevelPSets = false;
1188  if(vm.count(kShowTopLevelPSetsOpt)) {
1189  showTopLevelPSets=true;
1190  }
1191 
1193  if(vm.count(kFileNameOpt)) {
1194  try {
1195  fileName = vm[kFileNameOpt].as<std::string>();
1196  } catch(boost::bad_any_cast const& e) {
1197  std::cout << e.what() << std::endl;
1198  return 2;
1199  }
1200  } else {
1201  std::cout << "Data file not specified." << std::endl;
1202  std::cout << desc << std::endl;
1203  return 2;
1204  }
1205 
1206  std::string dumpPSetID;
1207  if(vm.count(kDumpPSetIDOpt)) {
1208  try {
1209  dumpPSetID = vm[kDumpPSetIDOpt].as<std::string>();
1210  } catch(boost::bad_any_cast const& e) {
1211  std::cout << e.what() << std::endl;
1212  return 2;
1213  }
1214  }
1215 
1216  std::vector<std::string> findMatch;
1217  if(vm.count(kFindMatchOpt)) {
1218  try {
1219  findMatch = vm[kFindMatchOpt].as<std::vector<std::string> >();
1220  } catch(boost::bad_any_cast const& e) {
1221  std::cout << e.what() << std::endl;
1222  return 2;
1223  }
1224  }
1225 
1226  bool dontPrintProducts = false;
1227  if(vm.count(kDontPrintProductsOpt)) {
1228  dontPrintProducts=true;
1229  }
1230 
1231  //silence ROOT warnings about missing dictionaries
1233 
1234  ProvenanceDumper dumper(fileName, showDependencies, extendedAncestors, extendedDescendants,
1235  excludeESModules, showAllModules, showTopLevelPSets, findMatch, dontPrintProducts, dumpPSetID);
1236  int exitCode(0);
1237  try {
1238  dumper.dump();
1239  exitCode = dumper.exitCode();
1240  }
1241  catch (cms::Exception const& x) {
1242  std::cerr << "cms::Exception caught\n";
1243  std::cerr << x.what() << '\n';
1244  exitCode = 2;
1245  }
1246  catch (std::exception& x) {
1247  std::cerr << "std::exception caught\n";
1248  std::cerr << x.what() << '\n';
1249  exitCode = 3;
1250  }
1251  catch (...) {
1252  std::cerr << "Unknown exception caught\n";
1253  exitCode = 4;
1254  }
1255 
1256  dumper.printErrors(std::cerr);
1257  return exitCode;
1258 }
std::stringstream errorLog_
Definition: EdmProvDump.cc:508
static char const *const kDontPrintProductsCommandOpt
std::vector< ProcessHistory > ProcessHistoryVector
size
Write out results.
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:218
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:255
std::vector< ProcessConfiguration > ProcessConfigurationVector
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
Definition: BranchType.cc:107
static const TGPicture * info(bool iBackgroundIsBlack)
static char const *const kDumpPSetIDOpt
static char const *const kDependenciesOpt
std::string const & parentageTreeName()
Definition: BranchType.cc:159
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
static char const *const kFindMatchCommandOpt
std::string dumpPSetID_
Definition: EdmProvDump.cc:524
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static char const *const kShowTopLevelPSetsCommandOpt
bool productRegistryPresent_
Definition: EdmProvDump.cc:520
ParameterSetID id() const
ParentageID id() const
Definition: Parentage.cc:23
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
edm::ProductRegistry reg_
Definition: EdmProvDump.cc:510
ParameterSetMap psm_
Definition: EdmProvDump.cc:513
void addAncestors(edm::BranchID const &branchID, std::set< edm::BranchID > &ancestorBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::ParentageID > > &perProductParentage) const
void dumpParameterSetForID_(edm::ParameterSetID const &id)
Definition: EdmProvDump.cc:624
static char const *const kHelpOpt
HistoryNode historyGraph_
Definition: EdmProvDump.cc:514
char const * what() const override
Definition: Exception.cc:141
static char const *const kDontPrintProductsOpt
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:243
void dumpEventFilteringParameterSets_(TFile *file)
Definition: EdmProvDump.cc:594
uint16_t size_type
edm::ProcessHistoryVector phv_
Definition: EdmProvDump.cc:512
static char const *const kDependenciesCommandOpt
std::vector< EventSelectionID > EventSelectionIDVector
static char const *const kHelpCommandOpt
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:251
static std::string const input
Definition: EdmProvDump.cc:44
static char const *const kShowTopLevelPSetsOpt
std::ostream & operator<<(std::ostream &os, edm::ProcessHistory &iHist)
Definition: EdmProvDump.cc:135
std::vector< BranchID > const & parents() const
Definition: Parentage.h:44
static char const *const kShowAllModulesCommandOpt
ParameterSet const & pset() const
returns the PSet
static char const *const kExcludeESModulesCommandOpt
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:193
edm::propagate_const< std::unique_ptr< TFile > > inputFile_
Definition: EdmProvDump.cc:506
static char const *const kSortOpt
bool getMapped(key_type const &k, value_type &result) const
EventSelectionIDVector const & eventSelectionIDs() const
Definition: History.h:42
static char const *const kExcludeESModulesOpt
std::map< std::pair< std::string, std::string >, IdToBranches > ModuleToIdBranches
Definition: EdmProvDump.cc:37
void dumpEventFilteringParameterSets(edm::EventSelectionIDVector const &ids)
Definition: EdmProvDump.cc:576
std::string const & eventHistoryBranchName()
Definition: BranchType.cc:238
Long64_t numEntries(TFile *hdl, std::string const &trname)
Definition: CollUtil.cc:50
def unique(seq, keepstr=True)
Definition: tier0.py:24
static char const *const kSortCommandOpt
std::string eventSetupComponent(char const *iType, std::string const &iCompName, edm::ParameterSet const &iProcessConfig, std::string const &iProcessName)
Definition: EdmProvDump.cc:159
std::string nonProducerComponent(std::string const &iCompName, edm::ParameterSet const &iProcessConfig, std::string const &iProcessName)
Definition: EdmProvDump.cc:241
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:18
std::string const & BranchTypeToBranchEntryInfoBranchName(BranchType const &branchType)
Definition: BranchType.cc:127
std::vector< ParameterSet > const & vpset() const
returns the VPSet
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:35
ProvenanceDumper(std::string const &filename, bool showDependencies, bool extendedAncestors, bool extendedDescendants, bool excludeESModules, bool showAllModules, bool showTopLevelPSets, std::vector< std::string > const &findMatch, bool dontPrintProducts, std::string const &dumpPSetID)
Definition: EdmProvDump.cc:533
#define end
Definition: vmac.h:37
std::string const & metaDataTreeName()
Definition: BranchType.cc:168
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
Definition: BranchType.cc:103
static char const *const kExtendedAncestorsCommandOpt
static std::string const triggerResults
Definition: EdmProvDump.cc:41
bool isRegistered() const
Definition: ParameterSet.h:65
Hash< ParameterSetType > ParameterSetID
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:183
element_type const * get() const
static void appendToSet(std::set< std::string > &iSet, std::vector< std::string > const &iFrom)
Definition: EdmProvDump.cc:298
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:443
std::string const & processHistoryBranchName()
Definition: BranchType.cc:198
std::map< std::string, std::vector< edm::BranchDescription > > IdToBranches
Definition: EdmProvDump.cc:36
int main(int argc, char *argv[])
void dumpProcessHistory_()
Definition: EdmProvDump.cc:647
edm::ProcessConfigurationVector phc_
Definition: EdmProvDump.cc:511
psettable const & psetTable() const
Definition: ParameterSet.h:257
std::vector< std::string > const & fileNames() const
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
std::string filename_
Definition: EdmProvDump.cc:505
ParameterSet const & getParameterSet(std::string const &) const
static char const *const kShowAllModulesOpt
std::string const & parentageBranchName()
Definition: BranchType.cc:163
ProductList & productListUpdator()
void addDescendants(edm::BranchID const &branchID, std::set< edm::BranchID > &descendantBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::BranchID > > &parentToChildren) const
gErrorIgnoreLevel
Definition: utils.py:25
std::vector< std::string > findMatch_
Definition: EdmProvDump.cc:522
std::map< ParameterSetID, ParameterSetBlob > ParameterSetMap
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:173
static char const *const kExtendedDescendantsOpt
#define begin
Definition: vmac.h:30
vpsettable const & vpsetTable() const
Definition: ParameterSet.h:260
static char const *const kFileNameOpt
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
Definition: BranchType.cc:131
std::string const & eventTreeName()
Definition: BranchType.cc:260
std::string const & eventHistoryTreeName()
Definition: BranchType.cc:268
static char const *const kExtendedAncestorsOpt
static Interceptor::Registry registry("Interceptor")
table const & tbl() const
Definition: ParameterSet.h:254
static ParentageRegistry * instance()
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
ParameterSet const & registerIt()
static std::string const source
Definition: EdmProvDump.cc:43
int exitCode() const
Definition: EdmProvDump.cc:571
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
std::string const & moduleDescriptionMapBranchName()
Definition: BranchType.cc:188
bool insertMapped(value_type const &v)
def move(src, dest)
Definition: eostools.py:510
static Registry * instance()
Definition: Registry.cc:12
static std::string topLevelPSet(std::string const &iName, edm::ParameterSet const &iProcessConfig, std::string const &iProcessName)
Definition: EdmProvDump.cc:304
static char const *const kDumpPSetIDCommandOpt
static char const *const kExtendedDescendantsCommandOpt
def operate(timelog, memlog, json_f, num)
void printErrors(std::ostream &os)
Definition: EdmProvDump.cc:566
static char const *const kFindMatchOpt