CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 431 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 493 of file EdmProvDump.cc.

503  : filename_(filename),
504  inputFile_(makeTFile(filename)),
505  exitCode_(0),
506  errorLog_(),
507  errorCount_(0),
508  showDependencies_(showDependencies),
509  extendedAncestors_(extendedAncestors),
510  extendedDescendants_(extendedDescendants),
511  excludeESModules_(excludeESModules),
512  showOtherModules_(showOtherModules),
514  showTopLevelPSets_(showTopLevelPSets),
515  findMatch_(findMatch),
516  dontPrintProducts_(dontPrintProducts),
517  dumpPSetID_(dumpPSetID) {}
std::stringstream errorLog_
Definition: EdmProvDump.cc:468
std::string dumpPSetID_
Definition: EdmProvDump.cc:484
bool productRegistryPresent_
Definition: EdmProvDump.cc:480
edm::propagate_const< std::unique_ptr< TFile > > inputFile_
Definition: EdmProvDump.cc:466
std::string filename_
Definition: EdmProvDump.cc:465
std::vector< std::string > findMatch_
Definition: EdmProvDump.cc:482
tuple filename
Definition: lut2db_cfg.py:20
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 990 of file EdmProvDump.cc.

References edm::ParentageRegistry::getMapped(), edm::ParentageRegistry::instance(), and edm::Parentage::parents().

Referenced by work_().

993  {
995 
996  std::set<edm::ParentageID> const& parentIDs = perProductParentage[branchID];
997  for (auto const& parentageID : parentIDs) {
998  edm::Parentage const* parentage = registry.getMapped(parentageID);
999  if (nullptr != parentage) {
1000  for (auto const& branch : parentage->parents()) {
1001  if (ancestorBranchIDs.insert(branch).second) {
1002  addAncestors(branch, ancestorBranchIDs, sout, perProductParentage);
1003  }
1004  }
1005  } else {
1006  sout << " ERROR:parentage info not in registry ParentageID=" << parentageID << std::endl;
1007  }
1008  }
1009 }
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:990
std::vector< BranchID > const & parents() const
Definition: Parentage.h:44
bool getMapped(key_type const &k, value_type &result) const
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 1011 of file EdmProvDump.cc.

Referenced by work_().

1014  {
1015  for (auto const& childBranchID : parentToChildren[branchID]) {
1016  if (descendantBranchIDs.insert(childBranchID).second) {
1017  addDescendants(childBranchID, descendantBranchIDs, sout, parentToChildren);
1018  }
1019  }
1020 }
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 519 of file EdmProvDump.cc.

References work_().

Referenced by main().

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

Definition at line 528 of file EdmProvDump.cc.

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

Referenced by dumpEventFilteringParameterSets_().

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

Definition at line 543 of file EdmProvDump.cc.

References cms::cuda::assert(), gather_cfg::cout, dumpEventFilteringParameterSets(), edm::poolNames::eventHistoryBranchName(), edm::poolNames::eventHistoryTreeName(), patZpeak::events, edm::History::eventSelectionIDs(), edm::poolNames::eventSelectionsBranchName(), edm::poolNames::eventTreeName(), h, and isotrackTrainRegressor::history.

Referenced by work_().

543  {
544  TTree* history = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventHistoryTreeName().c_str()));
545  if (history != nullptr) {
546  edm::History h;
547  edm::History* ph = &h;
548 
549  history->SetBranchAddress(edm::poolNames::eventHistoryBranchName().c_str(), &ph);
550  if (history->GetEntry(0) <= 0) {
551  std::cout << "No event filtering information is available; the event history tree has no entries\n";
552  } else {
554  }
555  } else {
556  TTree* events = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventTreeName().c_str()));
557  assert(events != nullptr);
558  TBranch* eventSelectionsBranch = events->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
559  if (eventSelectionsBranch == nullptr)
560  return;
562  edm::EventSelectionIDVector* pids = &ids;
563  eventSelectionsBranch->SetAddress(&pids);
564  if (eventSelectionsBranch->GetEntry(0) <= 0) {
565  std::cout << "No event filtering information is available; the event selections branch has no entries\n";
566  } else {
568  }
569  }
570 }
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:210
assert(be >=bs)
std::vector< EventSelectionID > EventSelectionIDVector
EventSelectionIDVector const & eventSelectionIDs() const
Definition: History.h:42
void dumpEventFilteringParameterSets(edm::EventSelectionIDVector const &ids)
Definition: EdmProvDump.cc:528
std::string const & eventHistoryBranchName()
Definition: BranchType.cc:207
tuple events
Definition: patZpeak.py:20
std::string const & eventTreeName()
Definition: BranchType.cc:220
tuple cout
Definition: gather_cfg.py:144
std::string const & eventHistoryTreeName()
Definition: BranchType.cc:224
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void ProvenanceDumper::dumpParameterSetForID_ ( edm::ParameterSetID const &  id)
private

Definition at line 572 of file EdmProvDump.cc.

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

Referenced by dumpEventFilteringParameterSets(), and work_().

572  {
573  std::cout << "ParameterSetID: " << id << '\n';
574  if (id.isValid()) {
575  ParameterSetMap::const_iterator i = psm_.find(id);
576  if (i == psm_.end()) {
577  std::cout << "We are unable to find the corresponding ParameterSet\n";
579  empty.registerIt();
580  if (id == empty.id()) {
581  std::cout << "But it would have been empty anyway\n";
582  }
583  } else {
584  edm::ParameterSet ps(i->second.pset());
585  prettyPrint(std::cout, ps, " ", " ");
586  std::cout << '\n';
587  }
588  } else {
589  std::cout << "This ID is not valid\n";
590  }
591  std::cout << " -------------------------\n";
592 }
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
ParameterSetID id() const
ParameterSetMap psm_
Definition: EdmProvDump.cc:473
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:401
tuple cout
Definition: gather_cfg.py:144
ParameterSet const & registerIt()
void ProvenanceDumper::dumpProcessHistory_ ( )
private

Definition at line 594 of file EdmProvDump.cc.

References submitPVValidationJobs::child, gather_cfg::cout, historyGraph_, gpuClustering::id, SpecificationBuilder_cfi::parent(), and phv_.

Referenced by work_().

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

Definition at line 526 of file EdmProvDump.cc.

References exitCode_.

Referenced by main().

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

Definition at line 521 of file EdmProvDump.cc.

References errorCount_, and errorLog_.

Referenced by main().

521  {
522  if (errorCount_ > 0)
523  os << errorLog_.str() << std::endl;
524 }
std::stringstream errorLog_
Definition: EdmProvDump.cc:468
void ProvenanceDumper::work_ ( )
private

Definition at line 630 of file EdmProvDump.cc.

References addAncestors(), addDescendants(), cms::cuda::assert(), edm::BranchTypeToBranchEntryInfoBranchName(), edm::BranchTypeToMetaDataTreeName(), edm::BranchTypeToProductProvenanceBranchName(), edm::BranchTypeToProductTreeName(), EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::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(), isotrackTrainRegressor::history, 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(), B2GTnPMonitor_cfi::item, 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_, TrackValidation_cff::pset, psm_, reg_, edm::ParameterSet::registerIt(), 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().

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

Member Data Documentation

bool ProvenanceDumper::dontPrintProducts_
private

Definition at line 483 of file EdmProvDump.cc.

Referenced by work_().

std::string ProvenanceDumper::dumpPSetID_
private

Definition at line 484 of file EdmProvDump.cc.

Referenced by work_().

int ProvenanceDumper::errorCount_
private

Definition at line 469 of file EdmProvDump.cc.

Referenced by printErrors(), and work_().

std::stringstream ProvenanceDumper::errorLog_
private

Definition at line 468 of file EdmProvDump.cc.

Referenced by printErrors(), and work_().

bool ProvenanceDumper::excludeESModules_
private

Definition at line 478 of file EdmProvDump.cc.

Referenced by work_().

int ProvenanceDumper::exitCode_
private

Definition at line 467 of file EdmProvDump.cc.

Referenced by exitCode(), and work_().

bool ProvenanceDumper::extendedAncestors_
private

Definition at line 476 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::extendedDescendants_
private

Definition at line 477 of file EdmProvDump.cc.

Referenced by work_().

std::string ProvenanceDumper::filename_
private

Definition at line 465 of file EdmProvDump.cc.

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

Definition at line 482 of file EdmProvDump.cc.

Referenced by work_().

HistoryNode ProvenanceDumper::historyGraph_
private

Definition at line 474 of file EdmProvDump.cc.

Referenced by dumpProcessHistory_(), and work_().

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

Definition at line 466 of file EdmProvDump.cc.

Referenced by work_().

edm::ProcessConfigurationVector ProvenanceDumper::phc_
private

Definition at line 471 of file EdmProvDump.cc.

Referenced by work_().

edm::ProcessHistoryVector ProvenanceDumper::phv_
private

Definition at line 472 of file EdmProvDump.cc.

Referenced by dumpProcessHistory_(), and work_().

bool ProvenanceDumper::productRegistryPresent_
private

Definition at line 480 of file EdmProvDump.cc.

Referenced by work_().

ParameterSetMap ProvenanceDumper::psm_
private

Definition at line 473 of file EdmProvDump.cc.

Referenced by dumpParameterSetForID_(), and work_().

edm::ProductRegistry ProvenanceDumper::reg_
private

Definition at line 470 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showDependencies_
private

Definition at line 475 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showOtherModules_
private

Definition at line 479 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showTopLevelPSets_
private

Definition at line 481 of file EdmProvDump.cc.

Referenced by work_().