Public Member Functions | |
void | dump () |
int | exitCode () const |
ProvenanceDumper & | operator= (ProvenanceDumper const &) |
void | printErrors (std::ostream &os) |
ProvenanceDumper (std::string const &filename, bool showDependencies, bool excludeESModules, bool showAllModules, bool showTopLevelPSets, std::string const &findMatch) | |
ProvenanceDumper (ProvenanceDumper const &) | |
Private Member Functions | |
void | dumpEventFilteringParameterSets (edm::EventSelectionIDVector const &ids) |
void | dumpEventFilteringParameterSets_ (TFile *file) |
void | dumpParameterSetForID_ (edm::ParameterSetID const &id) |
void | dumpProcessHistory_ () |
void | work_ () |
Private Attributes | |
int | errorCount_ |
std::stringstream | errorLog_ |
bool | excludeESModules_ |
int | exitCode_ |
std::string | filename_ |
std::string | findMatch_ |
HistoryNode | historyGraph_ |
std::unique_ptr< TFile > | inputFile_ |
edm::ProcessConfigurationVector | phc_ |
edm::ProcessHistoryVector | phv_ |
ParameterSetMap | psm_ |
edm::ProductRegistry | reg_ |
bool | showDependencies_ |
bool | showOtherModules_ |
bool | showTopLevelPSets_ |
Definition at line 442 of file EdmProvDump.cc.
ProvenanceDumper::ProvenanceDumper | ( | std::string const & | filename, |
bool | showDependencies, | ||
bool | excludeESModules, | ||
bool | showAllModules, | ||
bool | showTopLevelPSets, | ||
std::string const & | findMatch | ||
) |
Definition at line 485 of file EdmProvDump.cc.
: filename_(filename), inputFile_(makeTFile(filename)), exitCode_(0), errorLog_(), errorCount_(0), showDependencies_(showDependencies), excludeESModules_(excludeESModules), showOtherModules_(showOtherModules), showTopLevelPSets_(showTopLevelPSets), findMatch_(findMatch) { }
ProvenanceDumper::ProvenanceDumper | ( | ProvenanceDumper const & | ) |
void ProvenanceDumper::dump | ( | void | ) |
Definition at line 504 of file EdmProvDump.cc.
References work_().
Referenced by main().
{ work_(); }
void ProvenanceDumper::dumpEventFilteringParameterSets | ( | edm::EventSelectionIDVector const & | ids | ) | [private] |
Definition at line 519 of file EdmProvDump.cc.
References gather_cfg::cout, dumpParameterSetForID_(), and i.
Referenced by dumpEventFilteringParameterSets_().
{ edm::EventSelectionIDVector::size_type num_ids = ids.size(); if(num_ids == 0) { std::cout << "No event filtering information is available.\n"; std::cout << "------------------------------\n"; } else { std::cout << "Event filtering information for " << num_ids << " processing steps is available.\n" << "The ParameterSets will be printed out, " << "with the oldest printed first.\n"; for(edm::EventSelectionIDVector::size_type i = 0; i != num_ids; ++i) { dumpParameterSetForID_(ids[i]); } } }
void ProvenanceDumper::dumpEventFilteringParameterSets_ | ( | TFile * | file | ) | [private] |
Definition at line 537 of file EdmProvDump.cc.
References gather_cfg::cout, dumpEventFilteringParameterSets(), edm::poolNames::eventHistoryBranchName(), edm::poolNames::eventHistoryTreeName(), patZpeak::events, edm::History::eventSelectionIDs(), edm::poolNames::eventSelectionsBranchName(), edm::poolNames::eventTreeName(), and h.
Referenced by work_().
{ TTree* history = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventHistoryTreeName().c_str())); if(history != 0) { edm::History h; edm::History* ph = &h; history->SetBranchAddress(edm::poolNames::eventHistoryBranchName().c_str(), &ph); if(history->GetEntry(0) <= 0) { std::cout << "No event filtering information is available; the event history tree has no entries\n"; } else { dumpEventFilteringParameterSets(h.eventSelectionIDs()); } } else { TTree* events = dynamic_cast<TTree*>(file->Get(edm::poolNames::eventTreeName().c_str())); assert (events != 0); TBranch* eventSelectionsBranch = events->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str()); assert (eventSelectionsBranch != 0); edm::EventSelectionIDVector ids; edm::EventSelectionIDVector* pids = &ids; eventSelectionsBranch->SetAddress(&pids); if(eventSelectionsBranch->GetEntry(0) <= 0) { std::cout << "No event filtering information is available; the event selections branch has no entries\n"; } else { dumpEventFilteringParameterSets(ids); } } }
void ProvenanceDumper::dumpParameterSetForID_ | ( | edm::ParameterSetID const & | id | ) | [private] |
Definition at line 567 of file EdmProvDump.cc.
References gather_cfg::cout, relativeConstraints::empty, i, edm::ParameterSet::id(), prettyPrint(), and psm_.
Referenced by dumpEventFilteringParameterSets().
{ std::cout << "ParameterSetID: " << id << '\n'; if(id.isValid()) { ParameterSetMap::const_iterator i = psm_.find(id); if(i == psm_.end()) { std::cout << "We are unable to find the corresponding ParameterSet\n"; edm::ParameterSet empty; if(id == empty.id()) { std::cout << "But it would have been empty anyway\n"; } } else { edm::ParameterSet ps(i->second.pset()); prettyPrint(std::cout, ps, " ", " "); std::cout<< '\n'; } } else { std::cout << "This ID is not valid\n"; } std::cout << " -------------------------\n"; }
void ProvenanceDumper::dumpProcessHistory_ | ( | ) | [private] |
Definition at line 589 of file EdmProvDump.cc.
References gather_cfg::cout, alignCSCRings::e, historyGraph_, dbtoconf::parent, and phv_.
Referenced by work_().
{ std::cout << "Processing History:" << std::endl; if(1 == phv_.size()) { std::cout << *phv_.begin(); historyGraph_.addChild(HistoryNode(*(phv_.begin()->begin()), 1)); } else { std::map<edm::ProcessConfigurationID, unsigned int> simpleIDs; for(edm::ProcessHistoryVector::const_iterator it = phv_.begin(), itEnd = phv_.end(); it != itEnd; ++it) { //loop over the history entries looking for matches HistoryNode* parent = &historyGraph_; for(edm::ProcessHistory::const_iterator itH = it->begin(), e = it->end(); itH != e; ++itH) { if(parent->size() == 0) { unsigned int id = simpleIDs[itH->id()]; if(0 == id) { id = 1; simpleIDs[itH->id()] = id; } parent->addChild(HistoryNode(*itH, id)); parent = parent->lastChildAddress(); } else { //see if this is unique bool isUnique = true; for(HistoryNode::iterator itChild = parent->begin(), itChildEnd = parent->end(); itChild != itChildEnd; ++itChild) { if(itChild->configurationID() == itH->id()) { isUnique = false; parent = &(*itChild); break; } } if(isUnique) { simpleIDs[itH->id()] = parent->size() + 1; parent->addChild(HistoryNode(*itH, simpleIDs[itH->id()])); parent = parent->lastChildAddress(); } } } } historyGraph_.printHistory(); } }
int ProvenanceDumper::exitCode | ( | ) | const |
Definition at line 514 of file EdmProvDump.cc.
References exitCode_.
Referenced by main().
{ return exitCode_; }
ProvenanceDumper& ProvenanceDumper::operator= | ( | ProvenanceDumper const & | ) |
void ProvenanceDumper::printErrors | ( | std::ostream & | os | ) |
Definition at line 509 of file EdmProvDump.cc.
References errorCount_, and errorLog_.
Referenced by main().
{ if(errorCount_ > 0) os << errorLog_.str() << std::endl; }
void ProvenanceDumper::work_ | ( | ) | [private] |
Definition at line 637 of file EdmProvDump.cc.
References edm::BranchTypeToBranchEntryInfoBranchName(), edm::BranchTypeToMetaDataTreeName(), edm::BranchTypeToProductProvenanceBranchName(), edm::BranchTypeToProductTreeName(), dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, dumpEventFilteringParameterSets_(), dumpProcessHistory_(), alignCSCRings::e, errorCount_, errorLog_, excludeESModules_, exitCode_, f, edm::fillProductRegistryTransients(), findMatch_, edm::detail::ThreadSafeRegistry< KEY, T, E >::getMapped(), historyGraph_, i, edm::Parentage::id(), edm::poolNames::idToParameterSetBlobsBranchName(), edm::InEvent, info, inputFile_, edm::detail::ThreadSafeRegistry< KEY, T, E >::insertMapped(), instance, j, 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(), edm::poolNames::processConfigurationBranchName(), edm::poolNames::processHistoryBranchName(), edm::poolNames::processHistoryMapBranchName(), edm::poolNames::productDescriptionBranchName(), edm::ProductRegistry::productList(), psm_, reg_, PhysicsTools::registry, alignCSCRings::s, edm::ParameterSet::setID(), showDependencies_, showOtherModules_, showTopLevelPSets_, edm::sort_all(), and groupFilesInBlocks::temp.
Referenced by dump().
{ TTree* meta = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::metaDataTreeName().c_str())); assert(0 != meta); edm::ProductRegistry* pReg = ®_; meta->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(), &pReg); ParameterSetMap* pPsm = &psm_; if(meta->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != 0) { meta->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(), &pPsm); } else { TTree* psetTree = dynamic_cast<TTree *>(inputFile_->Get(edm::poolNames::parameterSetsTreeName().c_str())); assert(0 != psetTree); typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs; IdToBlobs idToBlob; IdToBlobs* pIdToBlob = &idToBlob; psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob); for(long long i = 0; i != psetTree->GetEntries(); ++i) { psetTree->GetEntry(i); psm_.insert(idToBlob); } } edm::ProcessConfigurationVector* pPhc = &phc_; if(meta->FindBranch(edm::poolNames::processConfigurationBranchName().c_str()) != 0) { meta->SetBranchAddress(edm::poolNames::processConfigurationBranchName().c_str(), &pPhc); } edm::ProcessHistoryVector* pPhv = &phv_; if(meta->FindBranch(edm::poolNames::processHistoryBranchName().c_str()) != 0) { meta->SetBranchAddress(edm::poolNames::processHistoryBranchName().c_str(), &pPhv); } edm::ProcessHistoryMap phm; edm::ProcessHistoryMap* pPhm = &phm; if(meta->FindBranch(edm::poolNames::processHistoryMapBranchName().c_str()) != 0) { meta->SetBranchAddress(edm::poolNames::processHistoryMapBranchName().c_str(), &pPhm); } if(meta->FindBranch(edm::poolNames::moduleDescriptionMapBranchName().c_str()) != 0) { if(meta->GetBranch(edm::poolNames::moduleDescriptionMapBranchName().c_str())->GetSplitLevel() != 0) { meta->SetBranchStatus((edm::poolNames::moduleDescriptionMapBranchName() + ".*").c_str(), 0); } else { meta->SetBranchStatus(edm::poolNames::moduleDescriptionMapBranchName().c_str(), 0); } } meta->GetEntry(0); assert(0 != pReg); edm::pset::Registry& psetRegistry = *edm::pset::Registry::instance(); for(ParameterSetMap::const_iterator i = psm_.begin(), iEnd = psm_.end(); i != iEnd; ++i) { edm::ParameterSet pset(i->second.pset()); pset.setID(i->first); psetRegistry.insertMapped(pset); } // backward compatibility if(!phm.empty()) { for(edm::ProcessHistoryMap::const_iterator i = phm.begin(), e = phm.end(); i != e; ++i) { phv_.push_back(i->second); for(edm::ProcessConfigurationVector::const_iterator j = i->second.begin(), f = i->second.end(); j != f; ++j) { phc_.push_back(*j); } } edm::sort_all(phc_); phc_.erase(std::unique(phc_.begin(), phc_.end()), phc_.end()); } fillProductRegistryTransients(phc_, reg_, true); //Prepare the parentage information if requested std::map<edm::BranchID, std::set<edm::ParentageID> > perProductParentage; if(showDependencies_){ TTree* parentageTree = dynamic_cast<TTree*>(inputFile_->Get(edm::poolNames::parentageTreeName().c_str())); if(0 == parentageTree) { std::cerr << "no Parentage tree available so can not show dependencies/n"; showDependencies_ = false; } else { edm::ParentageRegistry& registry = *edm::ParentageRegistry::instance(); std::vector<edm::ParentageID> orderedParentageIDs; orderedParentageIDs.reserve(parentageTree->GetEntries()); for(Long64_t i = 0, numEntries = parentageTree->GetEntries(); i < numEntries; ++i) { edm::Parentage parentageBuffer; edm::Parentage *pParentageBuffer = &parentageBuffer; parentageTree->SetBranchAddress(edm::poolNames::parentageBranchName().c_str(), &pParentageBuffer); parentageTree->GetEntry(i); registry.insertMapped(parentageBuffer); orderedParentageIDs.push_back(parentageBuffer.id()); } parentageTree->SetBranchAddress(edm::poolNames::parentageBranchName().c_str(), 0); TTree* eventMetaTree = dynamic_cast<TTree*>(inputFile_->Get(edm::BranchTypeToMetaDataTreeName(edm::InEvent).c_str())); if(0 == eventMetaTree) { eventMetaTree = dynamic_cast<TTree*>(inputFile_->Get(edm::BranchTypeToProductTreeName(edm::InEvent).c_str())); } if(0 == eventMetaTree) { std::cerr << "no '" << edm::BranchTypeToProductTreeName(edm::InEvent)<< "' Tree in file so can not show dependencies\n"; showDependencies_ = false; } else { TBranch* storedProvBranch = eventMetaTree->GetBranch(edm::BranchTypeToProductProvenanceBranchName(edm::InEvent).c_str()); if(0!=storedProvBranch) { std::vector<edm::StoredProductProvenance> info; std::vector<edm::StoredProductProvenance>* pInfo = &info; storedProvBranch->SetAddress(&pInfo); for(Long64_t i = 0, numEntries = eventMetaTree->GetEntries(); i < numEntries; ++i) { storedProvBranch->GetEntry(i); for(std::vector<edm::StoredProductProvenance>::const_iterator it = info.begin(), itEnd = info.end(); it != itEnd; ++it) { edm::BranchID bid(it->branchID_); perProductParentage[bid].insert(orderedParentageIDs[it->parentageIDIndex_]); } } } else { //backwards compatible check TBranch* productProvBranch = eventMetaTree->GetBranch(edm::BranchTypeToBranchEntryInfoBranchName(edm::InEvent).c_str()); if (0 != productProvBranch) { std::vector<edm::ProductProvenance> info; std::vector<edm::ProductProvenance>* pInfo = &info; productProvBranch->SetAddress(&pInfo); for(Long64_t i = 0, numEntries = eventMetaTree->GetEntries(); i < numEntries; ++i) { productProvBranch->GetEntry(i); for(std::vector<edm::ProductProvenance>::const_iterator it = info.begin(), itEnd = info.end(); it != itEnd; ++it) { perProductParentage[it->branchID()].insert(it->parentageID()); } } } else { std::cerr <<" could not find provenance information so can not show dependencies\n"; showDependencies_=false; } } } } } dumpEventFilteringParameterSets_(inputFile_.get()); dumpProcessHistory_(); std::cout << "---------Producers with data in file---------" << std::endl; //using edm::ParameterSetID as the key does not work // typedef std::map<edm::ParameterSetID, std::vector<edm::BranchDescription> > IdToBranches ModuleToIdBranches moduleToIdBranches; //IdToBranches idToBranches; std::map<edm::BranchID, std::string> branchIDToBranchName; for(edm::ProductRegistry::ProductList::const_iterator it = reg_.productList().begin(), itEnd = reg_.productList().end(); it != itEnd; ++it) { //force it to rebuild the branch name it->second.init(); if(showDependencies_) { branchIDToBranchName[it->second.branchID()] = it->second.branchName(); } /* std::cout << it->second.branchName() << " id " << it->second.productID() << std::endl; */ for(std::map<edm::ProcessConfigurationID, edm::ParameterSetID>::const_iterator itId = it->second.parameterSetIDs().begin(), itIdEnd = it->second.parameterSetIDs().end(); itId != itIdEnd; ++itId) { std::stringstream s; s << itId->second; moduleToIdBranches[std::make_pair(it->second.processName(), it->second.moduleLabel())][s.str()].push_back(it->second); //idToBranches[*itId].push_back(it->second); } } for(ModuleToIdBranches::const_iterator it = moduleToIdBranches.begin(), itEnd = moduleToIdBranches.end(); it != itEnd; ++it) { std::ostringstream sout; sout << "Module: " << it->first.second << " " << it->first.first << std::endl; IdToBranches const& idToBranches = it->second; for(IdToBranches::const_iterator itIdBranch = idToBranches.begin(), itIdBranchEnd = idToBranches.end(); itIdBranch != itIdBranchEnd; ++itIdBranch) { sout << " PSet id:" << itIdBranch->first << std::endl; sout << " products: {" << std::endl; std::set<edm::BranchID> branchIDs; for(std::vector<edm::BranchDescription>::const_iterator itBranch = itIdBranch->second.begin(), itBranchEnd = itIdBranch->second.end(); itBranch != itBranchEnd; ++itBranch) { sout << " " << itBranch->branchName() << std::endl; branchIDs.insert(itBranch->branchID()); } sout << " }" << std::endl; edm::ParameterSetID psid(itIdBranch->first); ParameterSetMap::const_iterator itpsm = psm_.find(psid); if(psm_.end() == itpsm) { ++errorCount_; errorLog_ << "No ParameterSetID for " << psid << std::endl; exitCode_ = 1; } else { sout << " parameters: "; prettyPrint(sout, edm::ParameterSet((*itpsm).second.pset()), " ", " "); sout << std::endl; } if(showDependencies_) { edm::ParentageRegistry& registry = *edm::ParentageRegistry::instance(); sout << " dependencies: {" << std::endl; std::set<edm::ParentageID> parentageIDs; for(std::set<edm::BranchID>::const_iterator itBranch = branchIDs.begin(), itBranchEnd = branchIDs.end(); itBranch != itBranchEnd; ++itBranch) { std::set<edm::ParentageID> const& temp = perProductParentage[*itBranch]; parentageIDs.insert(temp.begin(), temp.end()); } for(std::set<edm::ParentageID>::const_iterator itParentID = parentageIDs.begin(), itEndParentID = parentageIDs.end(); itParentID != itEndParentID; ++itParentID) { edm::Parentage const* parentage = registry.getMapped(*itParentID); if(0 != parentage) { for(std::vector<edm::BranchID>::const_iterator itBranch = parentage->parents().begin(), itEndBranch = parentage->parents().end(); itBranch != itEndBranch; ++itBranch) { sout << " " << branchIDToBranchName[*itBranch] << std::endl; } } else { sout << " ERROR:parentage info not in registry ParentageID=" << *itParentID << std::endl; } } if(parentageIDs.empty()) { sout << " no dependencies recorded (event may not contain data from this module)" << std::endl; } sout << " }" << std::endl; } if(findMatch_.empty() or sout.str().find(findMatch_) != std::string::npos) { std::cout <<sout.str()<<std::endl; } } } if(showOtherModules_) { std::cout << "---------Other Modules---------" << std::endl; historyGraph_.printOtherModulesHistory(psm_, moduleToIdBranches, findMatch_, errorLog_); } if(!excludeESModules_) { std::cout << "---------EventSetup---------" << std::endl; historyGraph_.printEventSetupHistory(psm_, findMatch_, errorLog_); } if(showTopLevelPSets_) { std::cout << "---------Top Level PSets---------" << std::endl; historyGraph_.printTopLevelPSetsHistory(psm_, findMatch_, errorLog_); } if(errorCount_ != 0) { exitCode_ = 1; } }
int ProvenanceDumper::errorCount_ [private] |
Definition at line 466 of file EdmProvDump.cc.
Referenced by printErrors(), and work_().
std::stringstream ProvenanceDumper::errorLog_ [private] |
Definition at line 465 of file EdmProvDump.cc.
Referenced by printErrors(), and work_().
bool ProvenanceDumper::excludeESModules_ [private] |
Definition at line 473 of file EdmProvDump.cc.
Referenced by work_().
int ProvenanceDumper::exitCode_ [private] |
Definition at line 464 of file EdmProvDump.cc.
Referenced by exitCode(), and work_().
std::string ProvenanceDumper::filename_ [private] |
Definition at line 462 of file EdmProvDump.cc.
std::string ProvenanceDumper::findMatch_ [private] |
Definition at line 476 of file EdmProvDump.cc.
Referenced by work_().
HistoryNode ProvenanceDumper::historyGraph_ [private] |
Definition at line 471 of file EdmProvDump.cc.
Referenced by dumpProcessHistory_(), and work_().
std::unique_ptr<TFile> ProvenanceDumper::inputFile_ [private] |
Definition at line 463 of file EdmProvDump.cc.
Referenced by work_().
Definition at line 468 of file EdmProvDump.cc.
Referenced by work_().
Definition at line 469 of file EdmProvDump.cc.
Referenced by dumpProcessHistory_(), and work_().
ParameterSetMap ProvenanceDumper::psm_ [private] |
Definition at line 470 of file EdmProvDump.cc.
Referenced by dumpParameterSetForID_(), and work_().
edm::ProductRegistry ProvenanceDumper::reg_ [private] |
Definition at line 467 of file EdmProvDump.cc.
Referenced by work_().
bool ProvenanceDumper::showDependencies_ [private] |
Definition at line 472 of file EdmProvDump.cc.
Referenced by work_().
bool ProvenanceDumper::showOtherModules_ [private] |
Definition at line 474 of file EdmProvDump.cc.
Referenced by work_().
bool ProvenanceDumper::showTopLevelPSets_ [private] |
Definition at line 475 of file EdmProvDump.cc.
Referenced by work_().