CMS 3D CMS Logo

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