CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ProvenanceDumper Class Reference

Public Member Functions

void dump ()
 
int exitCode () const
 
ProvenanceDumperoperator= (ProvenanceDumper const &)=delete
 
void printErrors (std::ostream &os)
 
 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)
 
 ProvenanceDumper (ProvenanceDumper const &)=delete
 

Private Member Functions

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 addDescendants (edm::BranchID const &branchID, std::set< edm::BranchID > &descendantBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::BranchID >> &parentToChildren) const
 
void dumpEventFilteringParameterSets (edm::EventSelectionIDVector const &ids)
 
void dumpEventFilteringParameterSets_ (TFile *file)
 
void dumpParameterSetForID_ (edm::ParameterSetID const &id)
 
void dumpProcessHistory_ ()
 
void work_ ()
 

Private Attributes

bool dontPrintProducts_
 
std::string dumpPSetID_
 
int errorCount_
 
std::stringstream errorLog_
 
bool excludeESModules_
 
int exitCode_
 
bool extendedAncestors_
 
bool extendedDescendants_
 
std::string filename_
 
std::vector< std::string > findMatch_
 
HistoryNode historyGraph_
 
edm::propagate_const< std::unique_ptr< TFile > > inputFile_
 
edm::ProcessConfigurationVector phc_
 
edm::ProcessHistoryVector phv_
 
bool productRegistryPresent_
 
ParameterSetMap psm_
 
edm::ProductRegistry reg_
 
bool showDependencies_
 
bool showOtherModules_
 
bool showTopLevelPSets_
 

Detailed Description

Definition at line 436 of file EdmProvDump.cc.

Constructor & Destructor Documentation

ProvenanceDumper::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 at line 498 of file EdmProvDump.cc.

508  : filename_(filename),
509  inputFile_(makeTFile(filename)),
510  exitCode_(0),
511  errorLog_(),
512  errorCount_(0),
513  showDependencies_(showDependencies),
514  extendedAncestors_(extendedAncestors),
515  extendedDescendants_(extendedDescendants),
516  excludeESModules_(excludeESModules),
517  showOtherModules_(showOtherModules),
519  showTopLevelPSets_(showTopLevelPSets),
520  findMatch_(findMatch),
521  dontPrintProducts_(dontPrintProducts),
522  dumpPSetID_(dumpPSetID) {}
std::stringstream errorLog_
Definition: EdmProvDump.cc:473
std::string dumpPSetID_
Definition: EdmProvDump.cc:489
bool productRegistryPresent_
Definition: EdmProvDump.cc:485
edm::propagate_const< std::unique_ptr< TFile > > inputFile_
Definition: EdmProvDump.cc:471
std::string filename_
Definition: EdmProvDump.cc:470
std::vector< std::string > findMatch_
Definition: EdmProvDump.cc:487
ProvenanceDumper::ProvenanceDumper ( ProvenanceDumper const &  )
delete

Member Function Documentation

void ProvenanceDumper::addAncestors ( edm::BranchID const &  branchID,
std::set< edm::BranchID > &  ancestorBranchIDs,
std::ostringstream &  sout,
std::map< edm::BranchID, std::set< edm::ParentageID >> &  perProductParentage 
) const
private

Definition at line 995 of file EdmProvDump.cc.

References MicroEventContent_cff::branch, edm::ParentageRegistry::getMapped(), edm::ParentageRegistry::instance(), edm::Parentage::parents(), and PhysicsTools::registry.

Referenced by work_().

998  {
1000 
1001  std::set<edm::ParentageID> const& parentIDs = perProductParentage[branchID];
1002  for (auto const& parentageID : parentIDs) {
1003  edm::Parentage const* parentage = registry.getMapped(parentageID);
1004  if (nullptr != parentage) {
1005  for (auto const& branch : parentage->parents()) {
1006  if (ancestorBranchIDs.insert(branch).second) {
1007  addAncestors(branch, ancestorBranchIDs, sout, perProductParentage);
1008  }
1009  }
1010  } else {
1011  sout << " ERROR:parentage info not in registry ParentageID=" << parentageID << std::endl;
1012  }
1013  }
1014 }
void addAncestors(edm::BranchID const &branchID, std::set< edm::BranchID > &ancestorBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::ParentageID >> &perProductParentage) const
Definition: EdmProvDump.cc:995
std::vector< BranchID > const & parents() const
Definition: Parentage.h:44
bool getMapped(key_type const &k, value_type &result) const
static Interceptor::Registry registry("Interceptor")
static ParentageRegistry * instance()
void ProvenanceDumper::addDescendants ( edm::BranchID const &  branchID,
std::set< edm::BranchID > &  descendantBranchIDs,
std::ostringstream &  sout,
std::map< edm::BranchID, std::set< edm::BranchID >> &  parentToChildren 
) const
private

Definition at line 1016 of file EdmProvDump.cc.

Referenced by work_().

1019  {
1020  for (auto const& childBranchID : parentToChildren[branchID]) {
1021  if (descendantBranchIDs.insert(childBranchID).second) {
1022  addDescendants(childBranchID, descendantBranchIDs, sout, parentToChildren);
1023  }
1024  }
1025 }
void addDescendants(edm::BranchID const &branchID, std::set< edm::BranchID > &descendantBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::BranchID >> &parentToChildren) const
void ProvenanceDumper::dump ( void  )

Definition at line 524 of file EdmProvDump.cc.

References work_().

Referenced by main().

524 { work_(); }
void ProvenanceDumper::dumpEventFilteringParameterSets ( edm::EventSelectionIDVector const &  ids)
private

Definition at line 533 of file EdmProvDump.cc.

References gather_cfg::cout, dumpParameterSetForID_(), and mps_fire::i.

Referenced by dumpEventFilteringParameterSets_().

533  {
534  edm::EventSelectionIDVector::size_type num_ids = ids.size();
535  if (num_ids == 0) {
536  std::cout << "No event filtering information is available.\n";
537  std::cout << "------------------------------\n";
538  } else {
539  std::cout << "Event filtering information for " << num_ids << " processing steps is available.\n"
540  << "The ParameterSets will be printed out, "
541  << "with the oldest printed first.\n";
542  for (edm::EventSelectionIDVector::size_type i = 0; i != num_ids; ++i) {
544  }
545  }
546 }
void dumpParameterSetForID_(edm::ParameterSetID const &id)
Definition: EdmProvDump.cc:577
uint16_t size_type
void ProvenanceDumper::dumpEventFilteringParameterSets_ ( TFile *  file)
private

Definition at line 548 of file EdmProvDump.cc.

References gather_cfg::cout, dumpEventFilteringParameterSets(), edm::poolNames::eventHistoryBranchName(), edm::poolNames::eventHistoryTreeName(), PatBasicFWLiteAnalyzer::events, edm::History::eventSelectionIDs(), edm::poolNames::eventSelectionsBranchName(), edm::poolNames::eventTreeName(), and h.

Referenced by work_().

548  {
549  TTree* history = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventHistoryTreeName().c_str()));
550  if (history != nullptr) {
551  edm::History h;
552  edm::History* ph = &h;
553 
554  history->SetBranchAddress(edm::poolNames::eventHistoryBranchName().c_str(), &ph);
555  if (history->GetEntry(0) <= 0) {
556  std::cout << "No event filtering information is available; the event history tree has no entries\n";
557  } else {
559  }
560  } else {
561  TTree* events = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventTreeName().c_str()));
562  assert(events != nullptr);
563  TBranch* eventSelectionsBranch = events->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
564  if (eventSelectionsBranch == nullptr)
565  return;
567  edm::EventSelectionIDVector* pids = &ids;
568  eventSelectionsBranch->SetAddress(&pids);
569  if (eventSelectionsBranch->GetEntry(0) <= 0) {
570  std::cout << "No event filtering information is available; the event selections branch has no entries\n";
571  } else {
573  }
574  }
575 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:249
std::vector< EventSelectionID > EventSelectionIDVector
EventSelectionIDVector const & eventSelectionIDs() const
Definition: History.h:42
void dumpEventFilteringParameterSets(edm::EventSelectionIDVector const &ids)
Definition: EdmProvDump.cc:533
std::string const & eventHistoryBranchName()
Definition: BranchType.cc:244
std::string const & eventTreeName()
Definition: BranchType.cc:266
std::string const & eventHistoryTreeName()
Definition: BranchType.cc:274
void ProvenanceDumper::dumpParameterSetForID_ ( edm::ParameterSetID const &  id)
private

Definition at line 577 of file EdmProvDump.cc.

References gather_cfg::cout, relativeConstraints::empty, mps_fire::i, edm::ParameterSet::id(), prettyPrint(), psm_, and edm::ParameterSet::registerIt().

Referenced by dumpEventFilteringParameterSets(), and work_().

577  {
578  std::cout << "ParameterSetID: " << id << '\n';
579  if (id.isValid()) {
580  ParameterSetMap::const_iterator i = psm_.find(id);
581  if (i == psm_.end()) {
582  std::cout << "We are unable to find the corresponding ParameterSet\n";
584  empty.registerIt();
585  if (id == empty.id()) {
586  std::cout << "But it would have been empty anyway\n";
587  }
588  } else {
589  edm::ParameterSet ps(i->second.pset());
590  prettyPrint(std::cout, ps, " ", " ");
591  std::cout << '\n';
592  }
593  } else {
594  std::cout << "This ID is not valid\n";
595  }
596  std::cout << " -------------------------\n";
597 }
ParameterSetID id() const
ParameterSetMap psm_
Definition: EdmProvDump.cc:478
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:406
ParameterSet const & registerIt()
void ProvenanceDumper::dumpProcessHistory_ ( )
private

Definition at line 599 of file EdmProvDump.cc.

References class-composition::child, gather_cfg::cout, historyGraph_, triggerObjects_cff::id, class-composition::parent, and phv_.

Referenced by work_().

599  {
600  std::cout << "Processing History:" << std::endl;
601  std::map<edm::ProcessConfigurationID, unsigned int> simpleIDs;
602  for (auto const& ph : phv_) {
603  //loop over the history entries looking for matches
604  HistoryNode* parent = &historyGraph_;
605  for (auto const& pc : ph) {
606  if (parent->size() == 0) {
607  unsigned int id = simpleIDs[pc.id()];
608  if (0 == id) {
609  id = 1;
610  simpleIDs[pc.id()] = id;
611  }
612  parent->addChild(HistoryNode(pc, id));
613  parent = parent->lastChildAddress();
614  } else {
615  //see if this is unique
616  bool isUnique = true;
617  for (auto& child : *parent) {
618  if (child.configurationID() == pc.id()) {
619  isUnique = false;
620  parent = &child;
621  break;
622  }
623  }
624  if (isUnique) {
625  simpleIDs[pc.id()] = parent->size() + 1;
626  parent->addChild(HistoryNode(pc, simpleIDs[pc.id()]));
627  parent = parent->lastChildAddress();
628  }
629  }
630  }
631  }
632  historyGraph_.printHistory();
633 }
HistoryNode historyGraph_
Definition: EdmProvDump.cc:479
edm::ProcessHistoryVector phv_
Definition: EdmProvDump.cc:477
int ProvenanceDumper::exitCode ( ) const

Definition at line 531 of file EdmProvDump.cc.

References exitCode_.

Referenced by main().

531 { return exitCode_; }
ProvenanceDumper& ProvenanceDumper::operator= ( ProvenanceDumper const &  )
delete
void ProvenanceDumper::printErrors ( std::ostream &  os)

Definition at line 526 of file EdmProvDump.cc.

References errorCount_, and errorLog_.

Referenced by main().

526  {
527  if (errorCount_ > 0)
528  os << errorLog_.str() << std::endl;
529 }
std::stringstream errorLog_
Definition: EdmProvDump.cc:473
void ProvenanceDumper::work_ ( )
private

Definition at line 635 of file EdmProvDump.cc.

References addAncestors(), addDescendants(), MicroEventContent_cff::branch, edm::BranchTypeToBranchEntryInfoBranchName(), edm::BranchTypeToMetaDataTreeName(), edm::BranchTypeToProductProvenanceBranchName(), edm::BranchTypeToProductTreeName(), MessageLogger_cfi::cerr, gather_cfg::cout, dontPrintProducts_, dumpEventFilteringParameterSets_(), dumpParameterSetForID_(), dumpProcessHistory_(), dumpPSetID_, edm::ParameterSet::empty(), errorCount_, errorLog_, Exception, excludeESModules_, edm::ParameterSet::existsAs(), exitCode_, extendedAncestors_, extendedDescendants_, findMatch_, edm::propagate_const< T >::get(), edm::ParentageRegistry::getMapped(), edm::pset::Registry::getMapped(), edm::ParameterSet::getParameterSet(), historyGraph_, mps_fire::i, edm::Parentage::id(), edm::ParameterSet::id(), edm::poolNames::idToParameterSetBlobsBranchName(), edm::InEvent, info(), input, inputFile_, edm::ParentageRegistry::insertMapped(), edm::pset::Registry::insertMapped(), edm::ParentageRegistry::instance(), edm::pset::Registry::instance(), edm::ParameterSet::isRegistered(), edm::poolNames::metaDataTreeName(), edm::poolNames::moduleDescriptionMapBranchName(), edm::numEntries(), edm::poolNames::parameterSetMapBranchName(), edm::poolNames::parameterSetsTreeName(), edm::poolNames::parentageBranchName(), edm::poolNames::parentageTreeName(), edm::Parentage::parents(), phc_, phv_, prettyPrint(), LaserDQM_cfg::process, edm::poolNames::processHistoryBranchName(), edm::poolNames::processHistoryMapBranchName(), edm::poolNames::productDescriptionBranchName(), edm::ProductRegistry::productListUpdator(), productRegistryPresent_, muonDTDigis_cfi::pset, psm_, reg_, edm::ParameterSet::registerIt(), PhysicsTools::registry, alignCSCRings::s, edm::setIsMergeable(), showDependencies_, showOtherModules_, showTopLevelPSets_, edm::sort_all(), source, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, triggerPaths, triggerResults, tier0::unique(), and x.

Referenced by dump().

635  {
636  TTree* meta = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::metaDataTreeName().c_str()));
637  assert(nullptr != meta);
638 
639  edm::ProductRegistry* pReg = &reg_;
640  if (meta->FindBranch(edm::poolNames::productDescriptionBranchName().c_str()) != nullptr) {
641  meta->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(), &pReg);
642  } else {
643  productRegistryPresent_ = false;
644  }
645 
646  ParameterSetMap* pPsm = &psm_;
647  if (meta->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != nullptr) {
648  meta->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(), &pPsm);
649  } else {
650  TTree* psetTree = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::parameterSetsTreeName().c_str()));
651  assert(nullptr != psetTree);
652  typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs;
653  IdToBlobs idToBlob;
654  IdToBlobs* pIdToBlob = &idToBlob;
655  psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
656  for (long long i = 0; i != psetTree->GetEntries(); ++i) {
657  psetTree->GetEntry(i);
658  psm_.insert(idToBlob);
659  }
660  }
661 
663  if (meta->FindBranch(edm::poolNames::processHistoryBranchName().c_str()) != nullptr) {
664  meta->SetBranchAddress(edm::poolNames::processHistoryBranchName().c_str(), &pPhv);
665  }
666 
668  edm::ProcessHistoryMap* pPhm = &phm;
669  if (meta->FindBranch(edm::poolNames::processHistoryMapBranchName().c_str()) != nullptr) {
670  meta->SetBranchAddress(edm::poolNames::processHistoryMapBranchName().c_str(), &pPhm);
671  }
672 
673  if (meta->FindBranch(edm::poolNames::moduleDescriptionMapBranchName().c_str()) != nullptr) {
674  if (meta->GetBranch(edm::poolNames::moduleDescriptionMapBranchName().c_str())->GetSplitLevel() != 0) {
675  meta->SetBranchStatus((edm::poolNames::moduleDescriptionMapBranchName() + ".*").c_str(), false);
676  } else {
677  meta->SetBranchStatus(edm::poolNames::moduleDescriptionMapBranchName().c_str(), false);
678  }
679  }
680 
681  meta->GetEntry(0);
682  assert(nullptr != pReg);
683 
685  for (auto const& item : psm_) {
686  edm::ParameterSet pset(item.second.pset());
687  pset.setID(item.first);
688  psetRegistry.insertMapped(pset);
689  }
690 
691  if (!phv_.empty()) {
692  for (auto const& history : phv_) {
693  for (auto const& process : history) {
694  phc_.push_back(process);
695  }
696  }
698  phc_.erase(std::unique(phc_.begin(), phc_.end()), phc_.end());
699 
700  }
701  // backward compatibility
702  else if (!phm.empty()) {
703  for (auto const& history : phm) {
704  phv_.push_back(history.second);
705  for (auto const& process : history.second) {
706  phc_.push_back(process);
707  }
708  }
710  phc_.erase(std::unique(phc_.begin(), phc_.end()), phc_.end());
711  }
712 
713  if (!dumpPSetID_.empty()) {
714  edm::ParameterSetID psetID;
715  try {
717  } catch (cms::Exception const& x) {
718  throw cms::Exception("Command Line Argument")
719  << "Illegal ParameterSetID string. It should contain 32 hexadecimal characters";
720  }
721  dumpParameterSetForID_(psetID);
722  return;
723  }
724 
725  //Prepare the parentage information if requested
726  std::map<edm::BranchID, std::set<edm::ParentageID>> perProductParentage;
727 
729  TTree* parentageTree = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::parentageTreeName().c_str()));
730  if (nullptr == parentageTree) {
731  std::cerr << "ERROR, no Parentage tree available so cannot show dependencies, ancestors, or descendants.\n";
732  std::cerr << "Possibly this is not a standard EDM format file. For example, dependency, ancestor, and\n";
733  std::cerr << "descendant options to edmProvDump will not work with nanoAOD format files.\n\n";
734  showDependencies_ = false;
735  extendedAncestors_ = false;
736  extendedDescendants_ = false;
737  } else {
739 
740  std::vector<edm::ParentageID> orderedParentageIDs;
741  orderedParentageIDs.reserve(parentageTree->GetEntries());
742  for (Long64_t i = 0, numEntries = parentageTree->GetEntries(); i < numEntries; ++i) {
743  edm::Parentage parentageBuffer;
744  edm::Parentage* pParentageBuffer = &parentageBuffer;
745  parentageTree->SetBranchAddress(edm::poolNames::parentageBranchName().c_str(), &pParentageBuffer);
746  parentageTree->GetEntry(i);
747  registry.insertMapped(parentageBuffer);
748  orderedParentageIDs.push_back(parentageBuffer.id());
749  }
750  parentageTree->SetBranchAddress(edm::poolNames::parentageBranchName().c_str(), nullptr);
751 
752  TTree* eventMetaTree =
753  dynamic_cast<TTree*>(inputFile_->Get(edm::BranchTypeToMetaDataTreeName(edm::InEvent).c_str()));
754  if (nullptr == eventMetaTree) {
755  eventMetaTree = dynamic_cast<TTree*>(inputFile_->Get(edm::BranchTypeToProductTreeName(edm::InEvent).c_str()));
756  }
757  if (nullptr == eventMetaTree) {
759  << "' Tree in file so can not show dependencies\n";
760  showDependencies_ = false;
761  extendedAncestors_ = false;
762  extendedDescendants_ = false;
763  } else {
764  TBranch* storedProvBranch =
765  eventMetaTree->GetBranch(edm::BranchTypeToProductProvenanceBranchName(edm::InEvent).c_str());
766 
767  if (nullptr != storedProvBranch) {
768  std::vector<edm::StoredProductProvenance> info;
769  std::vector<edm::StoredProductProvenance>* pInfo = &info;
770  storedProvBranch->SetAddress(&pInfo);
771  for (Long64_t i = 0, numEntries = eventMetaTree->GetEntries(); i < numEntries; ++i) {
772  storedProvBranch->GetEntry(i);
773  for (auto const& item : info) {
774  edm::BranchID bid(item.branchID_);
775  perProductParentage[bid].insert(orderedParentageIDs.at(item.parentageIDIndex_));
776  }
777  }
778  } else {
779  //backwards compatible check
780  TBranch* productProvBranch =
781  eventMetaTree->GetBranch(edm::BranchTypeToBranchEntryInfoBranchName(edm::InEvent).c_str());
782  if (nullptr != productProvBranch) {
783  std::vector<edm::ProductProvenance> info;
784  std::vector<edm::ProductProvenance>* pInfo = &info;
785  productProvBranch->SetAddress(&pInfo);
786  for (Long64_t i = 0, numEntries = eventMetaTree->GetEntries(); i < numEntries; ++i) {
787  productProvBranch->GetEntry(i);
788  for (auto const& item : info) {
789  perProductParentage[item.branchID()].insert(item.parentageID());
790  }
791  }
792  } else {
793  std::cerr << " ERROR, could not find provenance information so can not show dependencies\n";
794  showDependencies_ = false;
795  extendedAncestors_ = false;
796  extendedDescendants_ = false;
797  }
798  }
799  }
800  }
801  }
802 
803  std::map<edm::BranchID, std::set<edm::BranchID>> parentToChildren;
805 
806  if (extendedDescendants_) {
807  for (auto const& itParentageSet : perProductParentage) {
808  edm::BranchID childBranchID = itParentageSet.first;
809  for (auto const& itParentageID : itParentageSet.second) {
810  edm::Parentage const* parentage = registry.getMapped(itParentageID);
811  if (nullptr != parentage) {
812  for (auto const& branch : parentage->parents()) {
813  parentToChildren[branch].insert(childBranchID);
814  }
815  } else {
816  std::cerr << " ERROR:parentage info not in registry ParentageID=" << itParentageID << std::endl;
817  }
818  }
819  }
820  }
821 
823 
825 
827  std::cout << "---------Producers with data in file---------" << std::endl;
828  }
829 
830  //using edm::ParameterSetID as the key does not work
831  // typedef std::map<edm::ParameterSetID, std::vector<edm::BranchDescription> > IdToBranches
832  ModuleToIdBranches moduleToIdBranches;
833  //IdToBranches idToBranches;
834 
835  std::map<edm::BranchID, std::string> branchIDToBranchName;
836 
837  for (auto const& processConfig : phc_) {
838  edm::ParameterSet const* processParameterSet =
839  edm::pset::Registry::instance()->getMapped(processConfig.parameterSetID());
840  if (nullptr == processParameterSet || processParameterSet->empty()) {
841  continue;
842  }
843  for (auto& item : reg_.productListUpdator()) {
844  auto& product = item.second;
845  if (product.processName() != processConfig.processName()) {
846  continue;
847  }
848  //force it to rebuild the branch name
849  product.init();
850  setIsMergeable(product);
851 
853  branchIDToBranchName[product.branchID()] = product.branchName();
854  }
855  /*
856  std::cout << product.branchName()
857  << " id " << product.productID() << std::endl;
858  */
859  std::string moduleLabel = product.moduleLabel();
860  if (moduleLabel == source) {
861  moduleLabel = input;
862  } else if (moduleLabel == triggerResults) {
863  moduleLabel = triggerPaths;
864  }
865 
866  std::stringstream s;
867 
868  if (processParameterSet->existsAs<edm::ParameterSet>(moduleLabel)) {
869  edm::ParameterSet const& moduleParameterSet = processParameterSet->getParameterSet(moduleLabel);
870  if (!moduleParameterSet.isRegistered()) {
871  edm::ParameterSet moduleParameterSetCopy = processParameterSet->getParameterSet(moduleLabel);
872  moduleParameterSetCopy.registerIt();
873  s << moduleParameterSetCopy.id();
874  } else {
875  s << moduleParameterSet.id();
876  }
877  moduleToIdBranches[std::make_pair(product.processName(), product.moduleLabel())][s.str()].push_back(product);
878  }
879  }
880  }
881 
882  for (auto const& item : moduleToIdBranches) {
883  std::ostringstream sout;
884  sout << "Module: " << item.first.second << " " << item.first.first << std::endl;
885  std::set<edm::BranchID> allBranchIDsForLabelAndProcess;
886  IdToBranches const& idToBranches = item.second;
887  for (auto const& idBranch : idToBranches) {
888  sout << " PSet id:" << idBranch.first << std::endl;
889  if (!dontPrintProducts_) {
890  sout << " products: {" << std::endl;
891  }
892  std::set<edm::BranchID> branchIDs;
893  for (auto const& branch : idBranch.second) {
894  if (!dontPrintProducts_) {
895  sout << " " << branch.branchName() << std::endl;
896  }
897  branchIDs.insert(branch.branchID());
898  allBranchIDsForLabelAndProcess.insert(branch.branchID());
899  }
900  sout << " }" << std::endl;
901  edm::ParameterSetID psid(idBranch.first);
902  ParameterSetMap::const_iterator itpsm = psm_.find(psid);
903  if (psm_.end() == itpsm) {
904  ++errorCount_;
905  errorLog_ << "No ParameterSetID for " << psid << std::endl;
906  exitCode_ = 1;
907  } else {
908  sout << " parameters: ";
909  prettyPrint(sout, edm::ParameterSet((*itpsm).second.pset()), " ", " ");
910  sout << std::endl;
911  }
912  if (showDependencies_) {
913  sout << " dependencies: {" << std::endl;
914  std::set<edm::ParentageID> parentageIDs;
915  for (auto const& branch : branchIDs) {
916  //Save these BranchIDs
917  std::set<edm::ParentageID> const& temp = perProductParentage[branch];
918  parentageIDs.insert(temp.begin(), temp.end());
919  }
920  for (auto const& parentID : parentageIDs) {
921  edm::Parentage const* parentage = registry.getMapped(parentID);
922  if (nullptr != parentage) {
923  for (auto const& branch : parentage->parents()) {
924  sout << " " << branchIDToBranchName[branch] << std::endl;
925  }
926  } else {
927  sout << " ERROR:parentage info not in registry ParentageID=" << parentID << std::endl;
928  }
929  }
930  if (parentageIDs.empty()) {
931  sout << " no dependencies recorded (event may not contain data from this module)" << std::endl;
932  }
933  sout << " }" << std::endl;
934  }
935  } // end loop over PSetIDs
936  if (extendedAncestors_) {
937  sout << " extendedAncestors: {" << std::endl;
938  std::set<edm::BranchID> ancestorBranchIDs;
939  for (auto const& branchID : allBranchIDsForLabelAndProcess) {
940  addAncestors(branchID, ancestorBranchIDs, sout, perProductParentage);
941  }
942  for (auto const& ancestorBranchID : ancestorBranchIDs) {
943  sout << " " << branchIDToBranchName[ancestorBranchID] << "\n";
944  }
945  sout << " }" << std::endl;
946  }
947 
948  if (extendedDescendants_) {
949  sout << " extendedDescendants: {" << std::endl;
950  std::set<edm::BranchID> descendantBranchIDs;
951  for (auto const& branchID : allBranchIDsForLabelAndProcess) {
952  addDescendants(branchID, descendantBranchIDs, sout, parentToChildren);
953  }
954  for (auto const& descendantBranchID : descendantBranchIDs) {
955  sout << " " << branchIDToBranchName[descendantBranchID] << "\n";
956  }
957  sout << " }" << std::endl;
958  }
959  bool foundMatch = true;
960  if (!findMatch_.empty()) {
961  for (auto const& stringToFind : findMatch_) {
962  if (sout.str().find(stringToFind) == std::string::npos) {
963  foundMatch = false;
964  break;
965  }
966  }
967  }
968  if (foundMatch) {
969  std::cout << sout.str() << std::endl;
970  }
971  } // end loop over module label/process
972 
974  std::cout << "---------Other Modules---------" << std::endl;
975  historyGraph_.printOtherModulesHistory(psm_, moduleToIdBranches, findMatch_, errorLog_);
976  } else if (!productRegistryPresent_) {
977  std::cout << "---------All Modules---------" << std::endl;
978  historyGraph_.printOtherModulesHistory(psm_, moduleToIdBranches, findMatch_, errorLog_);
979  }
980 
981  if (!excludeESModules_) {
982  std::cout << "---------EventSetup---------" << std::endl;
983  historyGraph_.printEventSetupHistory(psm_, findMatch_, errorLog_);
984  }
985 
986  if (showTopLevelPSets_) {
987  std::cout << "---------Top Level PSets---------" << std::endl;
988  historyGraph_.printTopLevelPSetsHistory(psm_, findMatch_, errorLog_);
989  }
990  if (errorCount_ != 0) {
991  exitCode_ = 1;
992  }
993 }
std::stringstream errorLog_
Definition: EdmProvDump.cc:473
std::vector< ProcessHistory > ProcessHistoryVector
bool empty() const
Definition: ParameterSet.h:191
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:261
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
Definition: BranchType.cc:108
void addDescendants(edm::BranchID const &branchID, std::set< edm::BranchID > &descendantBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::BranchID >> &parentToChildren) const
static const TGPicture * info(bool iBackgroundIsBlack)
std::string const & parentageTreeName()
Definition: BranchType.cc:160
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
void addAncestors(edm::BranchID const &branchID, std::set< edm::BranchID > &ancestorBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::ParentageID >> &perProductParentage) const
Definition: EdmProvDump.cc:995
std::string dumpPSetID_
Definition: EdmProvDump.cc:489
bool productRegistryPresent_
Definition: EdmProvDump.cc:485
ParameterSetID id() const
ParentageID id() const
Definition: Parentage.cc:23
edm::ProductRegistry reg_
Definition: EdmProvDump.cc:475
ParameterSetMap psm_
Definition: EdmProvDump.cc:478
void dumpParameterSetForID_(edm::ParameterSetID const &id)
Definition: EdmProvDump.cc:577
HistoryNode historyGraph_
Definition: EdmProvDump.cc:479
void dumpEventFilteringParameterSets_(TFile *file)
Definition: EdmProvDump.cc:548
edm::ProcessHistoryVector phv_
Definition: EdmProvDump.cc:477
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:257
static std::string const input
Definition: EdmProvDump.cc:48
std::vector< BranchID > const & parents() const
Definition: Parentage.h:44
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:194
edm::propagate_const< std::unique_ptr< TFile > > inputFile_
Definition: EdmProvDump.cc:471
bool getMapped(key_type const &k, value_type &result) const
std::map< std::pair< std::string, std::string >, IdToBranches > ModuleToIdBranches
Definition: EdmProvDump.cc:38
Long64_t numEntries(TFile *hdl, std::string const &trname)
Definition: CollUtil.cc:50
def unique(seq, keepstr=True)
Definition: tier0.py:25
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
std::string const & BranchTypeToBranchEntryInfoBranchName(BranchType const &branchType)
Definition: BranchType.cc:128
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:32
std::string const & metaDataTreeName()
Definition: BranchType.cc:169
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
Definition: BranchType.cc:104
static std::string const triggerResults
Definition: EdmProvDump.cc:45
bool isRegistered() const
Definition: ParameterSet.h:61
Hash< ParameterSetType > ParameterSetID
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:184
element_type const * get() const
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:406
std::string const & processHistoryBranchName()
Definition: BranchType.cc:199
std::map< std::string, std::vector< edm::BranchDescription > > IdToBranches
Definition: EdmProvDump.cc:37
void dumpProcessHistory_()
Definition: EdmProvDump.cc:599
edm::ProcessConfigurationVector phc_
Definition: EdmProvDump.cc:476
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
ParameterSet const & getParameterSet(std::string const &) const
std::string const & parentageBranchName()
Definition: BranchType.cc:164
ProductList & productListUpdator()
std::vector< std::string > findMatch_
Definition: EdmProvDump.cc:487
std::map< ParameterSetID, ParameterSetBlob > ParameterSetMap
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:174
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
Definition: BranchType.cc:132
static Interceptor::Registry registry("Interceptor")
static ParentageRegistry * instance()
static std::string const triggerPaths
Definition: EdmProvDump.cc:46
ParameterSet const & registerIt()
static std::string const source
Definition: EdmProvDump.cc:47
void setIsMergeable(BranchDescription &)
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
std::string const & moduleDescriptionMapBranchName()
Definition: BranchType.cc:189
bool insertMapped(value_type const &v)
static Registry * instance()
Definition: Registry.cc:12

Member Data Documentation

bool ProvenanceDumper::dontPrintProducts_
private

Definition at line 488 of file EdmProvDump.cc.

Referenced by work_().

std::string ProvenanceDumper::dumpPSetID_
private

Definition at line 489 of file EdmProvDump.cc.

Referenced by work_().

int ProvenanceDumper::errorCount_
private

Definition at line 474 of file EdmProvDump.cc.

Referenced by printErrors(), and work_().

std::stringstream ProvenanceDumper::errorLog_
private

Definition at line 473 of file EdmProvDump.cc.

Referenced by printErrors(), and work_().

bool ProvenanceDumper::excludeESModules_
private

Definition at line 483 of file EdmProvDump.cc.

Referenced by work_().

int ProvenanceDumper::exitCode_
private

Definition at line 472 of file EdmProvDump.cc.

Referenced by exitCode(), and work_().

bool ProvenanceDumper::extendedAncestors_
private

Definition at line 481 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::extendedDescendants_
private

Definition at line 482 of file EdmProvDump.cc.

Referenced by work_().

std::string ProvenanceDumper::filename_
private

Definition at line 470 of file EdmProvDump.cc.

std::vector<std::string> ProvenanceDumper::findMatch_
private

Definition at line 487 of file EdmProvDump.cc.

Referenced by work_().

HistoryNode ProvenanceDumper::historyGraph_
private

Definition at line 479 of file EdmProvDump.cc.

Referenced by dumpProcessHistory_(), and work_().

edm::propagate_const<std::unique_ptr<TFile> > ProvenanceDumper::inputFile_
private

Definition at line 471 of file EdmProvDump.cc.

Referenced by work_().

edm::ProcessConfigurationVector ProvenanceDumper::phc_
private

Definition at line 476 of file EdmProvDump.cc.

Referenced by work_().

edm::ProcessHistoryVector ProvenanceDumper::phv_
private

Definition at line 477 of file EdmProvDump.cc.

Referenced by dumpProcessHistory_(), and work_().

bool ProvenanceDumper::productRegistryPresent_
private

Definition at line 485 of file EdmProvDump.cc.

Referenced by work_().

ParameterSetMap ProvenanceDumper::psm_
private

Definition at line 478 of file EdmProvDump.cc.

Referenced by dumpParameterSetForID_(), and work_().

edm::ProductRegistry ProvenanceDumper::reg_
private

Definition at line 475 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showDependencies_
private

Definition at line 480 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showOtherModules_
private

Definition at line 484 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showTopLevelPSets_
private

Definition at line 486 of file EdmProvDump.cc.

Referenced by work_().