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 471 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 533 of file EdmProvDump.cc.

542  :
544  inputFile_(makeTFile(filename)),
545  exitCode_(0),
546  errorLog_(),
547  errorCount_(0),
548  showDependencies_(showDependencies),
549  extendedAncestors_(extendedAncestors),
550  extendedDescendants_(extendedDescendants),
551  excludeESModules_(excludeESModules),
552  showOtherModules_(showOtherModules),
554  showTopLevelPSets_(showTopLevelPSets),
555  findMatch_(findMatch),
556  dontPrintProducts_(dontPrintProducts),
557  dumpPSetID_(dumpPSetID) {
558 }
std::stringstream errorLog_
Definition: EdmProvDump.cc:508
std::string dumpPSetID_
Definition: EdmProvDump.cc:524
bool productRegistryPresent_
Definition: EdmProvDump.cc:520
edm::propagate_const< std::unique_ptr< TFile > > inputFile_
Definition: EdmProvDump.cc:506
std::string filename_
Definition: EdmProvDump.cc:505
std::vector< std::string > findMatch_
Definition: EdmProvDump.cc:522
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 1047 of file EdmProvDump.cc.

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

Referenced by work_().

1048  {
1049 
1051 
1052  std::set<edm::ParentageID> const& parentIDs = perProductParentage[branchID];
1053  for (auto const& parentageID : parentIDs) {
1054  edm::Parentage const* parentage = registry.getMapped(parentageID);
1055  if(nullptr != parentage) {
1056  for(auto const& branch : parentage->parents()) {
1057 
1058  if(ancestorBranchIDs.insert(branch).second) {
1059  addAncestors(branch, ancestorBranchIDs, sout, perProductParentage);
1060  }
1061  }
1062  } else {
1063  sout << " ERROR:parentage info not in registry ParentageID=" << parentageID << std::endl;
1064  }
1065  }
1066 }
void addAncestors(edm::BranchID const &branchID, std::set< edm::BranchID > &ancestorBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::ParentageID > > &perProductParentage) const
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 1069 of file EdmProvDump.cc.

Referenced by work_().

1070  {
1071 
1072  for (auto const& childBranchID : parentToChildren[branchID]) {
1073  if (descendantBranchIDs.insert(childBranchID).second) {
1074  addDescendants(childBranchID, descendantBranchIDs, sout, parentToChildren);
1075  }
1076  }
1077 }
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 561 of file EdmProvDump.cc.

References work_().

Referenced by main().

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

Definition at line 576 of file EdmProvDump.cc.

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

Referenced by dumpEventFilteringParameterSets_().

576  {
578  if(num_ids == 0) {
579  std::cout << "No event filtering information is available.\n";
580  std::cout << "------------------------------\n";
581  } else {
582  std::cout << "Event filtering information for "
583  << num_ids
584  << " processing steps is available.\n"
585  << "The ParameterSets will be printed out, "
586  << "with the oldest printed first.\n";
587  for(edm::EventSelectionIDVector::size_type i = 0; i != num_ids; ++i) {
589  }
590  }
591 }
void dumpParameterSetForID_(edm::ParameterSetID const &id)
Definition: EdmProvDump.cc:624
uint16_t size_type
void ProvenanceDumper::dumpEventFilteringParameterSets_ ( TFile *  file)
private

Definition at line 594 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(), h, and electrons_cff::ids.

Referenced by work_().

594  {
595 
596  TTree* history = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventHistoryTreeName().c_str()));
597  if(history != nullptr) {
598  edm::History h;
599  edm::History* ph = &h;
600 
601  history->SetBranchAddress(edm::poolNames::eventHistoryBranchName().c_str(), &ph);
602  if(history->GetEntry(0) <= 0) {
603  std::cout << "No event filtering information is available; the event history tree has no entries\n";
604  } else {
606  }
607  } else {
608  TTree* events = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventTreeName().c_str()));
609  assert (events != nullptr);
610  TBranch* eventSelectionsBranch = events->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
611  if (eventSelectionsBranch == nullptr) return;
614  eventSelectionsBranch->SetAddress(&pids);
615  if(eventSelectionsBranch->GetEntry(0) <= 0) {
616  std::cout << "No event filtering information is available; the event selections branch has no entries\n";
617  } else {
619  }
620  }
621 }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:243
std::vector< EventSelectionID > EventSelectionIDVector
EventSelectionIDVector const & eventSelectionIDs() const
Definition: History.h:42
void dumpEventFilteringParameterSets(edm::EventSelectionIDVector const &ids)
Definition: EdmProvDump.cc:576
std::string const & eventHistoryBranchName()
Definition: BranchType.cc:238
std::string const & eventTreeName()
Definition: BranchType.cc:260
std::string const & eventHistoryTreeName()
Definition: BranchType.cc:268
void ProvenanceDumper::dumpParameterSetForID_ ( edm::ParameterSetID const &  id)
private

Definition at line 624 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_().

624  {
625  std::cout << "ParameterSetID: " << id << '\n';
626  if(id.isValid()) {
627  ParameterSetMap::const_iterator i = psm_.find(id);
628  if(i == psm_.end()) {
629  std::cout << "We are unable to find the corresponding ParameterSet\n";
631  empty.registerIt();
632  if(id == empty.id()) {
633  std::cout << "But it would have been empty anyway\n";
634  }
635  } else {
636  edm::ParameterSet ps(i->second.pset());
637  prettyPrint(std::cout, ps, " ", " ");
638  std::cout<< '\n';
639  }
640  } else {
641  std::cout << "This ID is not valid\n";
642  }
643  std::cout << " -------------------------\n";
644 }
ParameterSetID id() const
ParameterSetMap psm_
Definition: EdmProvDump.cc:513
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:443
ParameterSet const & registerIt()
void ProvenanceDumper::dumpProcessHistory_ ( )
private

Definition at line 647 of file EdmProvDump.cc.

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

Referenced by work_().

647  {
648  std::cout << "Processing History:" << std::endl;
649  if(1 == phv_.size()) {
650  std::cout << *phv_.begin();
651  historyGraph_.addChild(HistoryNode(*(phv_.begin()->begin()), 1));
652  } else {
653  std::map<edm::ProcessConfigurationID, unsigned int> simpleIDs;
654  for(auto const& ph : phv_) {
655  //loop over the history entries looking for matches
656  HistoryNode* parent = &historyGraph_;
657  for(auto const& pc : ph) {
658  if(parent->size() == 0) {
659  unsigned int id = simpleIDs[pc.id()];
660  if(0 == id) {
661  id = 1;
662  simpleIDs[pc.id()] = id;
663  }
664  parent->addChild(HistoryNode(pc, id));
665  parent = parent->lastChildAddress();
666  } else {
667  //see if this is unique
668  bool isUnique = true;
669  for(auto& child : *parent) {
670  if(child.configurationID() == pc.id()) {
671  isUnique = false;
672  parent = &child;
673  break;
674  }
675  }
676  if(isUnique) {
677  simpleIDs[pc.id()] = parent->size() + 1;
678  parent->addChild(HistoryNode(pc, simpleIDs[pc.id()]));
679  parent = parent->lastChildAddress();
680  }
681  }
682  }
683  }
684  historyGraph_.printHistory();
685  }
686 }
HistoryNode historyGraph_
Definition: EdmProvDump.cc:514
edm::ProcessHistoryVector phv_
Definition: EdmProvDump.cc:512
int ProvenanceDumper::exitCode ( ) const

Definition at line 571 of file EdmProvDump.cc.

References exitCode_.

Referenced by main().

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

Definition at line 566 of file EdmProvDump.cc.

References errorCount_, and errorLog_.

Referenced by main().

566  {
567  if(errorCount_ > 0) os << errorLog_.str() << std::endl;
568 }
std::stringstream errorLog_
Definition: EdmProvDump.cc:508
void ProvenanceDumper::work_ ( )
private

Definition at line 689 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, showDependencies_, showOtherModules_, showTopLevelPSets_, edm::sort_all(), source, AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, triggerPaths, triggerResults, tier0::unique(), and x.

Referenced by dump().

689  {
690 
691  TTree* meta = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::metaDataTreeName().c_str()));
692  assert(nullptr != meta);
693 
694  edm::ProductRegistry* pReg = &reg_;
695  if(meta->FindBranch(edm::poolNames::productDescriptionBranchName().c_str()) != nullptr) {
696  meta->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(), &pReg);
697  } else {
698  productRegistryPresent_ = false;
699  }
700 
701  ParameterSetMap* pPsm = &psm_;
702  if(meta->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != nullptr) {
703  meta->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(), &pPsm);
704  } else {
705  TTree* psetTree = dynamic_cast<TTree *>(inputFile_->Get(edm::poolNames::parameterSetsTreeName().c_str()));
706  assert(nullptr != psetTree);
707  typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs;
708  IdToBlobs idToBlob;
709  IdToBlobs* pIdToBlob = &idToBlob;
710  psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
711  for(long long i = 0; i != psetTree->GetEntries(); ++i) {
712  psetTree->GetEntry(i);
713  psm_.insert(idToBlob);
714  }
715  }
716 
718  if(meta->FindBranch(edm::poolNames::processHistoryBranchName().c_str()) != nullptr) {
719  meta->SetBranchAddress(edm::poolNames::processHistoryBranchName().c_str(), &pPhv);
720  }
721 
723  edm::ProcessHistoryMap* pPhm = &phm;
724  if(meta->FindBranch(edm::poolNames::processHistoryMapBranchName().c_str()) != nullptr) {
725  meta->SetBranchAddress(edm::poolNames::processHistoryMapBranchName().c_str(), &pPhm);
726  }
727 
728  if(meta->FindBranch(edm::poolNames::moduleDescriptionMapBranchName().c_str()) != nullptr) {
729  if(meta->GetBranch(edm::poolNames::moduleDescriptionMapBranchName().c_str())->GetSplitLevel() != 0) {
730  meta->SetBranchStatus((edm::poolNames::moduleDescriptionMapBranchName() + ".*").c_str(), false);
731  } else {
732  meta->SetBranchStatus(edm::poolNames::moduleDescriptionMapBranchName().c_str(), false);
733  }
734  }
735 
736  meta->GetEntry(0);
737  assert(nullptr != pReg);
738 
740  for(auto const& item : psm_) {
741  edm::ParameterSet pset(item.second.pset());
742  pset.setID(item.first);
743  psetRegistry.insertMapped(pset);
744  }
745 
746 
747  if(!phv_.empty()) {
748  for(auto const& history : phv_) {
749  for(auto const& process : history) {
750  phc_.push_back(process);
751  }
752  }
754  phc_.erase(std::unique(phc_.begin(), phc_.end()), phc_.end());
755 
756  }
757  // backward compatibility
758  else if(!phm.empty()) {
759  for(auto const& history : phm) {
760  phv_.push_back(history.second);
761  for(auto const& process : history.second) {
762  phc_.push_back(process);
763  }
764  }
766  phc_.erase(std::unique(phc_.begin(), phc_.end()), phc_.end());
767  }
768 
769  if(!dumpPSetID_.empty()) {
770  edm::ParameterSetID psetID;
771  try {
773  } catch (cms::Exception const& x) {
774  throw cms::Exception("Command Line Argument") << "Illegal ParameterSetID string. It should contain 32 hexadecimal characters";
775  }
776  dumpParameterSetForID_(psetID);
777  return;
778  }
779 
780  //Prepare the parentage information if requested
781  std::map<edm::BranchID, std::set<edm::ParentageID> > perProductParentage;
782 
784  TTree* parentageTree = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::parentageTreeName().c_str()));
785  if(nullptr == parentageTree) {
786  std::cerr << "ERROR, no Parentage tree available so cannot show dependencies, ancestors, or descendants.\n";
787  std::cerr << "Possibly this is not a standard EDM format file. For example, dependency, ancestor, and\n";
788  std::cerr << "descendant options to edmProvDump will not work with nanoAOD format files.\n\n";
789  showDependencies_ = false;
790  extendedAncestors_ = false;
791  extendedDescendants_ = false;
792  } else {
793 
795 
796  std::vector<edm::ParentageID> orderedParentageIDs;
797  orderedParentageIDs.reserve(parentageTree->GetEntries());
798  for(Long64_t i = 0, numEntries = parentageTree->GetEntries(); i < numEntries; ++i) {
799  edm::Parentage parentageBuffer;
800  edm::Parentage *pParentageBuffer = &parentageBuffer;
801  parentageTree->SetBranchAddress(edm::poolNames::parentageBranchName().c_str(), &pParentageBuffer);
802  parentageTree->GetEntry(i);
803  registry.insertMapped(parentageBuffer);
804  orderedParentageIDs.push_back(parentageBuffer.id());
805  }
806  parentageTree->SetBranchAddress(edm::poolNames::parentageBranchName().c_str(), nullptr);
807 
808  TTree* eventMetaTree = dynamic_cast<TTree*>(inputFile_->Get(edm::BranchTypeToMetaDataTreeName(edm::InEvent).c_str()));
809  if(nullptr == eventMetaTree) {
810  eventMetaTree = dynamic_cast<TTree*>(inputFile_->Get(edm::BranchTypeToProductTreeName(edm::InEvent).c_str()));
811  }
812  if(nullptr == eventMetaTree) {
813  std::cerr << "ERROR, no '" << edm::BranchTypeToProductTreeName(edm::InEvent)<< "' Tree in file so can not show dependencies\n";
814  showDependencies_ = false;
815  extendedAncestors_ = false;
816  extendedDescendants_ = false;
817  } else {
818  TBranch* storedProvBranch = eventMetaTree->GetBranch(edm::BranchTypeToProductProvenanceBranchName(edm::InEvent).c_str());
819 
820  if(nullptr!=storedProvBranch) {
821  std::vector<edm::StoredProductProvenance> info;
822  std::vector<edm::StoredProductProvenance>* pInfo = &info;
823  storedProvBranch->SetAddress(&pInfo);
824  for(Long64_t i = 0, numEntries = eventMetaTree->GetEntries(); i < numEntries; ++i) {
825  storedProvBranch->GetEntry(i);
826  for(auto const& item : info) {
827  edm::BranchID bid(item.branchID_);
828  perProductParentage[bid].insert(orderedParentageIDs.at(item.parentageIDIndex_));
829  }
830  }
831  } else {
832  //backwards compatible check
833  TBranch* productProvBranch = eventMetaTree->GetBranch(edm::BranchTypeToBranchEntryInfoBranchName(edm::InEvent).c_str());
834  if (nullptr != productProvBranch) {
835  std::vector<edm::ProductProvenance> info;
836  std::vector<edm::ProductProvenance>* pInfo = &info;
837  productProvBranch->SetAddress(&pInfo);
838  for(Long64_t i = 0, numEntries = eventMetaTree->GetEntries(); i < numEntries; ++i) {
839  productProvBranch->GetEntry(i);
840  for(auto const& item : info) {
841  perProductParentage[item.branchID()].insert(item.parentageID());
842  }
843  }
844  } else {
845  std::cerr <<" ERROR, could not find provenance information so can not show dependencies\n";
846  showDependencies_=false;
847  extendedAncestors_ = false;
848  extendedDescendants_ = false;
849  }
850  }
851  }
852  }
853  }
854 
855  std::map<edm::BranchID, std::set<edm::BranchID> > parentToChildren;
857 
858  if (extendedDescendants_) {
859  for (auto const& itParentageSet : perProductParentage) {
860  edm::BranchID childBranchID = itParentageSet.first;
861  for (auto const& itParentageID : itParentageSet.second) {
862  edm::Parentage const* parentage = registry.getMapped(itParentageID);
863  if(nullptr != parentage) {
864  for(auto const& branch : parentage->parents()) {
865  parentToChildren[branch].insert(childBranchID);
866  }
867  } else {
868  std::cerr << " ERROR:parentage info not in registry ParentageID=" << itParentageID << std::endl;
869  }
870  }
871  }
872  }
873 
875 
877 
879  std::cout << "---------Producers with data in file---------" << std::endl;
880  }
881 
882  //using edm::ParameterSetID as the key does not work
883  // typedef std::map<edm::ParameterSetID, std::vector<edm::BranchDescription> > IdToBranches
884  ModuleToIdBranches moduleToIdBranches;
885  //IdToBranches idToBranches;
886 
887  std::map<edm::BranchID, std::string> branchIDToBranchName;
888 
889  for(auto const& processConfig : phc_) {
890  edm::ParameterSet const* processParameterSet = edm::pset::Registry::instance()->getMapped(processConfig.parameterSetID());
891  if(nullptr == processParameterSet || processParameterSet->empty()) {
892  continue;
893  }
894  for(auto& item : reg_.productListUpdator()) {
895  auto& product = item.second;
896  if(product.processName() != processConfig.processName()) {
897  continue;
898  }
899  //force it to rebuild the branch name
900  product.init();
901 
903  branchIDToBranchName[product.branchID()] = product.branchName();
904  }
905  /*
906  std::cout << product.branchName()
907  << " id " << product.productID() << std::endl;
908  */
909  std::string moduleLabel = product.moduleLabel();
910  if(moduleLabel == source) {
911  moduleLabel = input;
912  } else if (moduleLabel == triggerResults) {
913  moduleLabel = triggerPaths;
914  }
915 
916  std::stringstream s;
917 
918  if(processParameterSet->existsAs<edm::ParameterSet>(moduleLabel)) {
919  edm::ParameterSet const& moduleParameterSet = processParameterSet->getParameterSet(moduleLabel);
920  if(!moduleParameterSet.isRegistered()) {
921  edm::ParameterSet moduleParameterSetCopy = processParameterSet->getParameterSet(moduleLabel);
922  moduleParameterSetCopy.registerIt();
923  s << moduleParameterSetCopy.id();
924  } else {
925  s << moduleParameterSet.id();
926  }
927  moduleToIdBranches[std::make_pair(product.processName(), product.moduleLabel())][s.str()].push_back(product);
928  }
929  }
930  }
931 
932  for(auto const& item : moduleToIdBranches) {
933  std::ostringstream sout;
934  sout << "Module: " << item.first.second << " " << item.first.first << std::endl;
935  std::set<edm::BranchID> allBranchIDsForLabelAndProcess;
936  IdToBranches const& idToBranches = item.second;
937  for(auto const& idBranch : idToBranches) {
938  sout << " PSet id:" << idBranch.first << std::endl;
939  if(!dontPrintProducts_) {
940  sout << " products: {" << std::endl;
941  }
942  std::set<edm::BranchID> branchIDs;
943  for(auto const& branch : idBranch.second) {
944  if(!dontPrintProducts_) {
945  sout << " " << branch.branchName() << std::endl;
946  }
947  branchIDs.insert(branch.branchID());
948  allBranchIDsForLabelAndProcess.insert(branch.branchID());
949  }
950  sout << " }" << std::endl;
951  edm::ParameterSetID psid(idBranch.first);
952  ParameterSetMap::const_iterator itpsm = psm_.find(psid);
953  if(psm_.end() == itpsm) {
954  ++errorCount_;
955  errorLog_ << "No ParameterSetID for " << psid << std::endl;
956  exitCode_ = 1;
957  } else {
958  sout << " parameters: ";
959  prettyPrint(sout, edm::ParameterSet((*itpsm).second.pset()), " ", " ");
960  sout << std::endl;
961  }
962  if(showDependencies_) {
963 
964  sout << " dependencies: {" << std::endl;
965  std::set<edm::ParentageID> parentageIDs;
966  for(auto const& branch : branchIDs) {
967 
968  //Save these BranchIDs
969  std::set<edm::ParentageID> const& temp = perProductParentage[branch];
970  parentageIDs.insert(temp.begin(), temp.end());
971  }
972  for(auto const& parentID : parentageIDs) {
973  edm::Parentage const* parentage = registry.getMapped(parentID);
974  if(nullptr != parentage) {
975  for(auto const& branch : parentage->parents()) {
976  sout << " " << branchIDToBranchName[branch] << std::endl;
977  }
978  } else {
979  sout << " ERROR:parentage info not in registry ParentageID=" << parentID << std::endl;
980  }
981  }
982  if(parentageIDs.empty()) {
983  sout << " no dependencies recorded (event may not contain data from this module)" << std::endl;
984  }
985  sout << " }" << std::endl;
986  }
987  } // end loop over PSetIDs
988  if (extendedAncestors_) {
989  sout << " extendedAncestors: {" << std::endl;
990  std::set<edm::BranchID> ancestorBranchIDs;
991  for (auto const& branchID : allBranchIDsForLabelAndProcess) {
992  addAncestors(branchID, ancestorBranchIDs, sout, perProductParentage);
993  }
994  for (auto const& ancestorBranchID : ancestorBranchIDs) {
995  sout << " " << branchIDToBranchName[ancestorBranchID] << "\n";
996  }
997  sout << " }" << std::endl;
998  }
999 
1000  if (extendedDescendants_) {
1001  sout << " extendedDescendants: {" << std::endl;
1002  std::set<edm::BranchID> descendantBranchIDs;
1003  for (auto const& branchID : allBranchIDsForLabelAndProcess) {
1004  addDescendants(branchID, descendantBranchIDs, sout, parentToChildren);
1005  }
1006  for (auto const& descendantBranchID : descendantBranchIDs) {
1007  sout << " " << branchIDToBranchName[descendantBranchID] << "\n";
1008  }
1009  sout << " }" << std::endl;
1010  }
1011  bool foundMatch = true;
1012  if(!findMatch_.empty()) {
1013  for (auto const& stringToFind : findMatch_) {
1014  if (sout.str().find(stringToFind) == std::string::npos) {
1015  foundMatch = false;
1016  break;
1017  }
1018  }
1019  }
1020  if (foundMatch) {
1021  std::cout <<sout.str()<<std::endl;
1022  }
1023  } // end loop over module label/process
1025  std::cout << "---------Other Modules---------" << std::endl;
1026  historyGraph_.printOtherModulesHistory(psm_, moduleToIdBranches, findMatch_, errorLog_);
1027  } else if (!productRegistryPresent_) {
1028  std::cout << "---------All Modules---------" << std::endl;
1029  historyGraph_.printOtherModulesHistory(psm_, moduleToIdBranches, findMatch_, errorLog_);
1030  }
1031 
1032  if(!excludeESModules_) {
1033  std::cout << "---------EventSetup---------" << std::endl;
1034  historyGraph_.printEventSetupHistory(psm_, findMatch_, errorLog_);
1035  }
1036 
1037  if(showTopLevelPSets_) {
1038  std::cout << "---------Top Level PSets---------" << std::endl;
1039  historyGraph_.printTopLevelPSetsHistory(psm_, findMatch_, errorLog_);
1040  }
1041  if(errorCount_ != 0) {
1042  exitCode_ = 1;
1043  }
1044 }
std::stringstream errorLog_
Definition: EdmProvDump.cc:508
std::vector< ProcessHistory > ProcessHistoryVector
bool empty() const
Definition: ParameterSet.h:218
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:255
std::string const & BranchTypeToMetaDataTreeName(BranchType const &branchType)
Definition: BranchType.cc:107
static const TGPicture * info(bool iBackgroundIsBlack)
std::string const & parentageTreeName()
Definition: BranchType.cc:159
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
std::string dumpPSetID_
Definition: EdmProvDump.cc:524
bool productRegistryPresent_
Definition: EdmProvDump.cc:520
ParameterSetID id() const
ParentageID id() const
Definition: Parentage.cc:23
edm::ProductRegistry reg_
Definition: EdmProvDump.cc:510
ParameterSetMap psm_
Definition: EdmProvDump.cc:513
void addAncestors(edm::BranchID const &branchID, std::set< edm::BranchID > &ancestorBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::ParentageID > > &perProductParentage) const
void dumpParameterSetForID_(edm::ParameterSetID const &id)
Definition: EdmProvDump.cc:624
HistoryNode historyGraph_
Definition: EdmProvDump.cc:514
void dumpEventFilteringParameterSets_(TFile *file)
Definition: EdmProvDump.cc:594
edm::ProcessHistoryVector phv_
Definition: EdmProvDump.cc:512
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:251
static std::string const input
Definition: EdmProvDump.cc:44
std::vector< BranchID > const & parents() const
Definition: Parentage.h:44
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:193
edm::propagate_const< std::unique_ptr< TFile > > inputFile_
Definition: EdmProvDump.cc:506
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
def unique(seq, keepstr=True)
Definition: tier0.py:24
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:18
std::string const & BranchTypeToBranchEntryInfoBranchName(BranchType const &branchType)
Definition: BranchType.cc:127
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:35
std::string const & metaDataTreeName()
Definition: BranchType.cc:168
std::string const & BranchTypeToProductTreeName(BranchType const &branchType)
Definition: BranchType.cc:103
static std::string const triggerResults
Definition: EdmProvDump.cc:41
bool isRegistered() const
Definition: ParameterSet.h:65
Hash< ParameterSetType > ParameterSetID
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:183
element_type const * get() const
static std::ostream & prettyPrint(std::ostream &oStream, edm::ParameterSet const &iPSet, std::string const &iIndent, std::string const &iIndentDelta)
Definition: EdmProvDump.cc:443
std::string const & processHistoryBranchName()
Definition: BranchType.cc:198
std::map< std::string, std::vector< edm::BranchDescription > > IdToBranches
Definition: EdmProvDump.cc:36
void dumpProcessHistory_()
Definition: EdmProvDump.cc:647
edm::ProcessConfigurationVector phc_
Definition: EdmProvDump.cc:511
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
ParameterSet const & getParameterSet(std::string const &) const
std::string const & parentageBranchName()
Definition: BranchType.cc:163
ProductList & productListUpdator()
void addDescendants(edm::BranchID const &branchID, std::set< edm::BranchID > &descendantBranchIDs, std::ostringstream &sout, std::map< edm::BranchID, std::set< edm::BranchID > > &parentToChildren) const
std::vector< std::string > findMatch_
Definition: EdmProvDump.cc:522
std::map< ParameterSetID, ParameterSetBlob > ParameterSetMap
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:173
std::string const & BranchTypeToProductProvenanceBranchName(BranchType const &BranchType)
Definition: BranchType.cc:131
static Interceptor::Registry registry("Interceptor")
static ParentageRegistry * instance()
static std::string const triggerPaths
Definition: EdmProvDump.cc:42
ParameterSet const & registerIt()
static std::string const source
Definition: EdmProvDump.cc:43
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
std::string const & moduleDescriptionMapBranchName()
Definition: BranchType.cc:188
bool insertMapped(value_type const &v)
static Registry * instance()
Definition: Registry.cc:12

Member Data Documentation

bool ProvenanceDumper::dontPrintProducts_
private

Definition at line 523 of file EdmProvDump.cc.

Referenced by work_().

std::string ProvenanceDumper::dumpPSetID_
private

Definition at line 524 of file EdmProvDump.cc.

Referenced by work_().

int ProvenanceDumper::errorCount_
private

Definition at line 509 of file EdmProvDump.cc.

Referenced by printErrors(), and work_().

std::stringstream ProvenanceDumper::errorLog_
private

Definition at line 508 of file EdmProvDump.cc.

Referenced by printErrors(), and work_().

bool ProvenanceDumper::excludeESModules_
private

Definition at line 518 of file EdmProvDump.cc.

Referenced by work_().

int ProvenanceDumper::exitCode_
private

Definition at line 507 of file EdmProvDump.cc.

Referenced by exitCode(), and work_().

bool ProvenanceDumper::extendedAncestors_
private

Definition at line 516 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::extendedDescendants_
private

Definition at line 517 of file EdmProvDump.cc.

Referenced by work_().

std::string ProvenanceDumper::filename_
private

Definition at line 505 of file EdmProvDump.cc.

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

Definition at line 522 of file EdmProvDump.cc.

Referenced by work_().

HistoryNode ProvenanceDumper::historyGraph_
private

Definition at line 514 of file EdmProvDump.cc.

Referenced by dumpProcessHistory_(), and work_().

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

Definition at line 506 of file EdmProvDump.cc.

Referenced by work_().

edm::ProcessConfigurationVector ProvenanceDumper::phc_
private

Definition at line 511 of file EdmProvDump.cc.

Referenced by work_().

edm::ProcessHistoryVector ProvenanceDumper::phv_
private

Definition at line 512 of file EdmProvDump.cc.

Referenced by dumpProcessHistory_(), and work_().

bool ProvenanceDumper::productRegistryPresent_
private

Definition at line 520 of file EdmProvDump.cc.

Referenced by work_().

ParameterSetMap ProvenanceDumper::psm_
private

Definition at line 513 of file EdmProvDump.cc.

Referenced by dumpParameterSetForID_(), and work_().

edm::ProductRegistry ProvenanceDumper::reg_
private

Definition at line 510 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showDependencies_
private

Definition at line 515 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showOtherModules_
private

Definition at line 519 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showTopLevelPSets_
private

Definition at line 521 of file EdmProvDump.cc.

Referenced by work_().