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 472 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 534 of file EdmProvDump.cc.

543  :
545  inputFile_(makeTFile(filename)),
546  exitCode_(0),
547  errorLog_(),
548  errorCount_(0),
549  showDependencies_(showDependencies),
550  extendedAncestors_(extendedAncestors),
551  extendedDescendants_(extendedDescendants),
552  excludeESModules_(excludeESModules),
553  showOtherModules_(showOtherModules),
555  showTopLevelPSets_(showTopLevelPSets),
556  findMatch_(findMatch),
557  dontPrintProducts_(dontPrintProducts),
558  dumpPSetID_(dumpPSetID) {
559 }
std::stringstream errorLog_
Definition: EdmProvDump.cc:509
std::string dumpPSetID_
Definition: EdmProvDump.cc:525
bool productRegistryPresent_
Definition: EdmProvDump.cc:521
edm::propagate_const< std::unique_ptr< TFile > > inputFile_
Definition: EdmProvDump.cc:507
std::string filename_
Definition: EdmProvDump.cc:506
std::vector< std::string > findMatch_
Definition: EdmProvDump.cc:523
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 1046 of file EdmProvDump.cc.

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

Referenced by work_().

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

Referenced by work_().

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

References work_().

Referenced by main().

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

Definition at line 577 of file EdmProvDump.cc.

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

Referenced by dumpEventFilteringParameterSets_().

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

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

595  {
596 
597  TTree* history = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventHistoryTreeName().c_str()));
598  if(history != nullptr) {
599  edm::History h;
600  edm::History* ph = &h;
601 
602  history->SetBranchAddress(edm::poolNames::eventHistoryBranchName().c_str(), &ph);
603  if(history->GetEntry(0) <= 0) {
604  std::cout << "No event filtering information is available; the event history tree has no entries\n";
605  } else {
607  }
608  } else {
609  TTree* events = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventTreeName().c_str()));
610  assert (events != nullptr);
611  TBranch* eventSelectionsBranch = events->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
612  if (eventSelectionsBranch == nullptr) return;
615  eventSelectionsBranch->SetAddress(&pids);
616  if(eventSelectionsBranch->GetEntry(0) <= 0) {
617  std::cout << "No event filtering information is available; the event selections branch has no entries\n";
618  } else {
620  }
621  }
622 }
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:577
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 625 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_().

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

Definition at line 648 of file EdmProvDump.cc.

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

Referenced by work_().

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

Definition at line 572 of file EdmProvDump.cc.

References exitCode_.

Referenced by main().

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

Definition at line 567 of file EdmProvDump.cc.

References errorCount_, and errorLog_.

Referenced by main().

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

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

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

Member Data Documentation

bool ProvenanceDumper::dontPrintProducts_
private

Definition at line 524 of file EdmProvDump.cc.

Referenced by work_().

std::string ProvenanceDumper::dumpPSetID_
private

Definition at line 525 of file EdmProvDump.cc.

Referenced by work_().

int ProvenanceDumper::errorCount_
private

Definition at line 510 of file EdmProvDump.cc.

Referenced by printErrors(), and work_().

std::stringstream ProvenanceDumper::errorLog_
private

Definition at line 509 of file EdmProvDump.cc.

Referenced by printErrors(), and work_().

bool ProvenanceDumper::excludeESModules_
private

Definition at line 519 of file EdmProvDump.cc.

Referenced by work_().

int ProvenanceDumper::exitCode_
private

Definition at line 508 of file EdmProvDump.cc.

Referenced by exitCode(), and work_().

bool ProvenanceDumper::extendedAncestors_
private

Definition at line 517 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::extendedDescendants_
private

Definition at line 518 of file EdmProvDump.cc.

Referenced by work_().

std::string ProvenanceDumper::filename_
private

Definition at line 506 of file EdmProvDump.cc.

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

Definition at line 523 of file EdmProvDump.cc.

Referenced by work_().

HistoryNode ProvenanceDumper::historyGraph_
private

Definition at line 515 of file EdmProvDump.cc.

Referenced by dumpProcessHistory_(), and work_().

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

Definition at line 507 of file EdmProvDump.cc.

Referenced by work_().

edm::ProcessConfigurationVector ProvenanceDumper::phc_
private

Definition at line 512 of file EdmProvDump.cc.

Referenced by work_().

edm::ProcessHistoryVector ProvenanceDumper::phv_
private

Definition at line 513 of file EdmProvDump.cc.

Referenced by dumpProcessHistory_(), and work_().

bool ProvenanceDumper::productRegistryPresent_
private

Definition at line 521 of file EdmProvDump.cc.

Referenced by work_().

ParameterSetMap ProvenanceDumper::psm_
private

Definition at line 514 of file EdmProvDump.cc.

Referenced by dumpParameterSetForID_(), and work_().

edm::ProductRegistry ProvenanceDumper::reg_
private

Definition at line 511 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showDependencies_
private

Definition at line 516 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showOtherModules_
private

Definition at line 520 of file EdmProvDump.cc.

Referenced by work_().

bool ProvenanceDumper::showTopLevelPSets_
private

Definition at line 522 of file EdmProvDump.cc.

Referenced by work_().