Public Member Functions | |
void | dump (std::ostream &os) |
int | exitCode () const |
void | printErrors (std::ostream &os) |
ProvenanceDumper (const char *filename) | |
Private Member Functions | |
void | dumpEventFilteringParameterSets_ (TTree &history) |
void | dumpParameterSetForID_ (edm::ParameterSetID const &id) |
void | dumpProcessHistory_ (TTree &history) |
void | work_ () |
Private Attributes | |
int | errorCount_ |
std::stringstream | errorLog_ |
int | exitCode_ |
std::string | filename_ |
HistoryNode | historyGraph_ |
boost::scoped_ptr< TFile > | inputFile_ |
edm::ProcessHistoryMap | phm_ |
ParameterSetMap | psm_ |
edm::ProductRegistry | reg_ |
Definition at line 210 of file EdmProvDump.cc.
ProvenanceDumper::ProvenanceDumper | ( | const char * | filename | ) | [explicit] |
Definition at line 239 of file EdmProvDump.cc.
00239 : 00240 filename_( filename), 00241 inputFile_(makeTFile(filename)), 00242 exitCode_(0), 00243 errorLog_(), 00244 errorCount_(0) 00245 { 00246 }
void ProvenanceDumper::dump | ( | std::ostream & | os | ) |
void ProvenanceDumper::dumpEventFilteringParameterSets_ | ( | TTree & | history | ) | [private] |
Definition at line 267 of file EdmProvDump.cc.
References GenMuonPlsPt100GeV_cfg::cout, dumpParameterSetForID_(), edm::poolNames::eventHistoryBranchName(), edm::History::eventSelectionIDs(), h, and i.
Referenced by dumpProcessHistory_().
00268 { 00269 // This is how one reads a TTree ... 00270 edm::History h; 00271 edm::History* ph = &h; 00272 00273 history.SetBranchAddress(edm::poolNames::eventHistoryBranchName().c_str(), &ph); 00274 if (history.GetEntry(0) <= 0) 00275 { 00276 std::cout << "No event filtering information is available; the event history tree has no entries\n"; 00277 } 00278 else 00279 { 00280 edm::EventSelectionIDVector const& ids = h.eventSelectionIDs(); 00281 edm::EventSelectionIDVector::size_type num_ids = ids.size(); 00282 if ( num_ids == 0) 00283 { 00284 std::cout << "No event filtering information is available.\n"; 00285 std::cout << "------------------------------\n"; 00286 } 00287 else 00288 { 00289 std::cout << "Event filtering information for " 00290 << num_ids 00291 << " processing steps is available.\n" 00292 << "The ParameterSets will be printed out, " 00293 << "with the oldest printed first.\n"; 00294 for (edm::EventSelectionIDVector::size_type i = 0; i != num_ids; ++i) 00295 dumpParameterSetForID_(ids[i]); 00296 } 00297 } 00298 }
void ProvenanceDumper::dumpParameterSetForID_ | ( | edm::ParameterSetID const & | id | ) | [private] |
Definition at line 301 of file EdmProvDump.cc.
References GenMuonPlsPt100GeV_cfg::cout, empty, i, edm::ParameterSet::id(), and psm_.
Referenced by dumpEventFilteringParameterSets_().
00302 { 00303 std::cout << "ParameterSetID: " << id << '\n'; 00304 if (id.isValid()) 00305 { 00306 ParameterSetMap::const_iterator i = psm_.find(id); 00307 if (i == psm_.end()) 00308 { 00309 std::cout << "We are unable to find the corresponding ParameterSet\n"; 00310 edm::ParameterSet empty; 00311 if (id == empty.id()) 00312 { 00313 std::cout << "But it would have been empty anyway\n"; 00314 } 00315 } 00316 else 00317 { 00318 edm::ParameterSet ps(i->second.pset_); 00319 std::cout << ps << '\n'; 00320 } 00321 } 00322 else 00323 { 00324 std::cout << "This ID is not valid\n"; 00325 } 00326 std::cout << " -------------------------\n"; 00327 }
void ProvenanceDumper::dumpProcessHistory_ | ( | TTree & | history | ) | [private] |
Definition at line 330 of file EdmProvDump.cc.
References GenMuonPlsPt100GeV_cfg::cout, dumpEventFilteringParameterSets_(), e, lat::endl(), historyGraph_, it, dbtoconf::parent, and phm_.
Referenced by work_().
00331 { 00332 dumpEventFilteringParameterSets_(history); 00333 std::cout << "Processing History:"<<std::endl; 00334 if (1 == phm_.size()) { 00335 std::cout << phm_.begin()->second; 00336 historyGraph_.addChild(HistoryNode(*(phm_.begin()->second.begin()), 1)); 00337 } else { 00338 bool multipleHistories =false; 00339 std::map<edm::ProcessConfigurationID, unsigned int> simpleIDs; 00340 for (edm::ProcessHistoryMap::const_iterator it = phm_.begin(), itEnd = phm_.end(); 00341 it != itEnd; 00342 ++it) { 00343 //loop over the history entries looking for matches 00344 HistoryNode* parent = &historyGraph_; 00345 for (edm::ProcessHistory::const_iterator itH = it->second.begin(), e = it->second.end(); 00346 itH != e; 00347 ++itH) { 00348 if (parent->size() == 0) { 00349 unsigned int id = simpleIDs[itH->id()]; 00350 if (0 == id) { 00351 id = 1; 00352 simpleIDs[itH->id()] = id; 00353 } 00354 parent->addChild(HistoryNode(*itH,id)); 00355 parent = parent->lastChildAddress(); 00356 } else { 00357 //see if this is unique 00358 bool unique = true; 00359 for (HistoryNode::iterator itChild = parent->begin(), itChildEnd = parent->end(); 00360 itChild != itChildEnd; 00361 ++itChild) { 00362 if (itChild->configurationID() == itH->id()) { 00363 unique = false; 00364 parent = &(*itChild); 00365 break; 00366 } 00367 } 00368 if (unique) { 00369 multipleHistories = true; 00370 simpleIDs[itH->id()]=parent->size()+1; 00371 parent->addChild(HistoryNode(*itH,simpleIDs[itH->id()])); 00372 parent = parent->lastChildAddress(); 00373 } 00374 } 00375 } 00376 } 00377 historyGraph_.printHistory(); 00378 } 00379 }
int ProvenanceDumper::exitCode | ( | ) | const |
Definition at line 261 of file EdmProvDump.cc.
References exitCode_.
Referenced by main().
00262 { 00263 return exitCode_; 00264 }
void ProvenanceDumper::printErrors | ( | std::ostream & | os | ) |
Definition at line 255 of file EdmProvDump.cc.
References lat::endl(), errorCount_, and errorLog_.
00256 { 00257 if (errorCount_ > 0) os << errorLog_.str() << std::endl; 00258 }
void ProvenanceDumper::work_ | ( | ) | [private] |
Definition at line 382 of file EdmProvDump.cc.
References GenMuonPlsPt100GeV_cfg::cout, dumpProcessHistory_(), lat::endl(), errorCount_, errorLog_, edm::poolNames::eventHistoryTreeName(), exitCode_, f, filename_, historyGraph_, it, makeTFile(), edm::poolNames::metaDataTreeName(), edm::poolNames::parameterSetMapBranchName(), phm_, edm::poolNames::processHistoryMapBranchName(), edm::poolNames::productDescriptionBranchName(), edm::ProductRegistry::productList(), psm_, reg_, s, and edm::ProductRegistry::setFrozen().
Referenced by dump().
00382 { 00383 00384 std::auto_ptr<TFile> f = makeTFile(filename_.c_str()); 00385 00386 TTree* history = dynamic_cast<TTree*>(f->Get(edm::poolNames::eventHistoryTreeName().c_str())); 00387 assert(0!=history); 00388 00389 TTree* meta = dynamic_cast<TTree*>(f->Get(edm::poolNames::metaDataTreeName().c_str())); 00390 assert(0!=meta); 00391 00392 edm::ProductRegistry* pReg=®_; 00393 meta->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(),&pReg); 00394 00395 ParameterSetMap* pPsm =&psm_; 00396 meta->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(),&pPsm); 00397 00398 edm::ProcessHistoryMap* pPhm=&phm_; 00399 meta->SetBranchAddress(edm::poolNames::processHistoryMapBranchName().c_str(),&pPhm); 00400 00401 meta->GetEntry(0); 00402 assert(0!=pReg); 00403 pReg->setFrozen(); 00404 00405 dumpProcessHistory_(*history); 00406 00407 std::cout <<"---------Event---------"<<std::endl; 00408 /* 00409 for (std::vector<edm::ProcessHistory>::const_iterator it = uniqueLongHistories.begin(), 00410 itEnd = uniqueLongHistories.end(); 00411 it != itEnd; 00412 ++it) { 00413 //ParameterSetMap::const_iterator itpsm = psm.find(psid); 00414 for (edm::ProcessHistory::const_iterator itH = it->begin(), e = it->end(); 00415 itH != e; 00416 ++itH) { 00417 std::cout << edm::ParameterSet(psm[ itH->parameterSetID() ].pset_) <<std::endl; 00418 } 00419 } 00420 */ 00421 //using edm::ParameterSetID as the key does not work 00422 // typedef std::map<edm::ParameterSetID,std::vector<edm::BranchDescription> > IdToBranches 00423 typedef std::map<std::string,std::vector<edm::BranchDescription> > IdToBranches; 00424 typedef std::map<std::pair<std::string,std::string>,IdToBranches> ModuleToIdBranches; 00425 ModuleToIdBranches moduleToIdBranches; 00426 //IdToBranches idToBranches; 00427 for (edm::ProductRegistry::ProductList::const_iterator it = 00428 reg_.productList().begin(), itEnd = reg_.productList().end(); 00429 it != itEnd; 00430 ++it) { 00431 //force it to rebuild the branch name 00432 it->second.init(); 00433 00434 /* 00435 std::cout << it->second.branchName() 00436 << " id " << it->second.productID() << std::endl; 00437 */ 00438 for (std::set<edm::ParameterSetID>::const_iterator itId = it->second.psetIDs().begin(), 00439 itIdEnd = it->second.psetIDs().end(); 00440 itId != itIdEnd; 00441 ++itId) { 00442 00443 std::stringstream s; 00444 s <<*itId; 00445 moduleToIdBranches[std::make_pair(it->second.processName(),it->second.moduleLabel())][s.str()].push_back(it->second); 00446 //idToBranches[*itId].push_back(it->second); 00447 } 00448 } 00449 for (ModuleToIdBranches::const_iterator it = moduleToIdBranches.begin(), 00450 itEnd = moduleToIdBranches.end(); 00451 it != itEnd; 00452 ++it) { 00453 std::cout <<"Module: "<<it->first.second<<" "<<it->first.first<<std::endl; 00454 const IdToBranches& idToBranches = it->second; 00455 for (IdToBranches::const_iterator itIdBranch = idToBranches.begin(), 00456 itIdBranchEnd = idToBranches.end(); 00457 itIdBranch != itIdBranchEnd; 00458 ++itIdBranch) { 00459 std::cout <<" PSet id:"<<itIdBranch->first<<std::endl; 00460 std::cout <<" products: {"<<std::endl; 00461 for (std::vector<edm::BranchDescription>::const_iterator itBranch = itIdBranch->second.begin(), 00462 itBranchEnd = itIdBranch->second.end(); 00463 itBranch != itBranchEnd; 00464 ++itBranch) { 00465 std::cout << " "<< itBranch->branchName()<<std::endl; 00466 } 00467 std::cout <<"}"<<std::endl; 00468 edm::ParameterSetID psid(itIdBranch->first); 00469 ParameterSetMap::const_iterator itpsm = psm_.find(psid); 00470 if (psm_.end() == itpsm) { 00471 ++errorCount_; 00472 errorLog_ << "No ParameterSetID for " << psid << std::endl; 00473 exitCode_ = 1; 00474 } else { 00475 std::cout <<" parameters: "<< 00476 edm::ParameterSet((*itpsm).second.pset_)<<std::endl; 00477 } 00478 std::cout << std::endl; 00479 } 00480 } 00481 std::cout <<"---------EventSetup---------"<<std::endl; 00482 historyGraph_.printEventSetupHistory(psm_, errorLog_); 00483 if (errorCount_ != 0) { 00484 exitCode_ = 1; 00485 } 00486 }
int ProvenanceDumper::errorCount_ [private] |
std::stringstream ProvenanceDumper::errorLog_ [private] |
int ProvenanceDumper::exitCode_ [private] |
std::string ProvenanceDumper::filename_ [private] |
HistoryNode ProvenanceDumper::historyGraph_ [private] |
boost::scoped_ptr<TFile> ProvenanceDumper::inputFile_ [private] |
Definition at line 224 of file EdmProvDump.cc.
edm::ProcessHistoryMap ProvenanceDumper::phm_ [private] |
ParameterSetMap ProvenanceDumper::psm_ [private] |
edm::ProductRegistry ProvenanceDumper::reg_ [private] |