#include <FWCore/Modules/src/EventContentAnalyzer.h>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | endJob () |
EventContentAnalyzer (const edm::ParameterSet &) | |
~EventContentAnalyzer () | |
Private Attributes | |
std::map< std::string, int > | cumulates_ |
int | evno_ |
bool | getData_ |
std::vector< std::string > | getModuleLabels_ |
std::string | indentation_ |
std::vector< std::string > | moduleLabels_ |
bool | verbose_ |
std::string | verboseIndentation_ |
Usage: <usage>
Definition at line 32 of file EventContentAnalyzer.h.
EventContentAnalyzer::EventContentAnalyzer | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 248 of file EventContentAnalyzer.cc.
References moduleLabels_, and edm::sort_all().
00248 : 00249 indentation_(iConfig.getUntrackedParameter("indentation",std::string("++"))), 00250 verboseIndentation_(iConfig.getUntrackedParameter("verboseIndention",std::string(" "))), 00251 moduleLabels_(iConfig.getUntrackedParameter("verboseForModuleLabels",std::vector<std::string>())), 00252 verbose_(iConfig.getUntrackedParameter("verbose",false) || moduleLabels_.size()>0), 00253 getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels",std::vector<std::string>())), 00254 getData_(iConfig.getUntrackedParameter("getData",false) || getModuleLabels_.size()>0), 00255 evno_(1) 00256 { 00257 //now do what ever initialization is needed 00258 edm::sort_all(moduleLabels_); 00259 }
EventContentAnalyzer::~EventContentAnalyzer | ( | ) |
Definition at line 261 of file EventContentAnalyzer.cc.
00262 { 00263 00264 // do anything here that needs to be done at destruction time 00265 // (e.g. close files, deallocate resources etc.) 00266 00267 }
void EventContentAnalyzer::analyze | ( | const edm::Event & | iEvent, | |
const edm::EventSetup & | iSetup | |||
) | [virtual] |
Implements edm::EDAnalyzer.
Definition at line 275 of file EventContentAnalyzer.cc.
References edm::binary_search_all(), className(), cumulates_, lat::endl(), evno_, edm::friendlyname::friendlyName(), edm::Event::getAllProvenance(), edm::Event::getByLabel(), getData_, getModuleLabels_, indentation_, getDQMSummary::key, moduleLabels_, printObject(), verbose_, and verboseIndentation_.
00276 { 00277 using namespace edm; 00278 00279 typedef std::vector< Provenance const*> Provenances; 00280 Provenances provenances; 00281 std::string friendlyName; 00282 std::string modLabel; 00283 std::string instanceName; 00284 std::string processName; 00285 std::string key; 00286 00287 iEvent.getAllProvenance(provenances); 00288 00289 edm::LogAbsolute("EventContent") << "\n" << indentation_ << "Event " << std::setw(5) << evno_ << " contains " 00290 << provenances.size() << " product" << (provenances.size()==1 ?"":"s") 00291 << " with friendlyClassName, moduleLabel, productInstanceName and processName:" 00292 << std::endl; 00293 00294 std::string startIndent = indentation_+verboseIndentation_; 00295 for(Provenances::iterator itProv = provenances.begin(), itProvEnd = provenances.end(); 00296 itProv != itProvEnd; 00297 ++itProv) { 00298 friendlyName = (*itProv)->friendlyClassName(); 00299 //if(friendlyName.empty()) friendlyName = std::string("||"); 00300 00301 modLabel = (*itProv)->moduleLabel(); 00302 //if(modLabel.empty()) modLabel = std::string("||"); 00303 00304 instanceName = (*itProv)->productInstanceName(); 00305 //if(instanceName.empty()) instanceName = std::string("||"); 00306 00307 processName = (*itProv)->processName(); 00308 00309 edm::LogAbsolute("EventContent") << indentation_ << friendlyName 00310 << " \"" << modLabel 00311 << "\" \"" << instanceName <<"\" \"" 00312 << processName<<"\"" 00313 << std::endl; 00314 00315 key = friendlyName 00316 + std::string(" + \"") + modLabel 00317 + std::string("\" + \"") + instanceName+"\" \""+processName+"\""; 00318 ++cumulates_[key]; 00319 00320 if(verbose_) { 00321 if(moduleLabels_.empty() || 00322 edm::binary_search_all(moduleLabels_, modLabel)) { 00323 //indent one level before starting to print 00324 printObject(iEvent, 00325 (*itProv)->className(), 00326 (*itProv)->moduleLabel(), 00327 (*itProv)->productInstanceName(), 00328 (*itProv)->processName(), 00329 startIndent, 00330 verboseIndentation_); 00331 continue; 00332 } 00333 } 00334 if(getData_) { 00335 if(getModuleLabels_.empty() || 00336 edm::binary_search_all(getModuleLabels_, modLabel)) { 00337 const std::string& className = (*itProv)->className(); 00338 using namespace edm; 00339 try { 00340 GenericHandle handle(className); 00341 }catch(const edm::Exception&) { 00342 edm::LogAbsolute("EventContent") <<startIndent<<" \""<<className<<"\""<<" is an unknown type"<<std::endl; 00343 return; 00344 } 00345 GenericHandle handle(className); 00346 iEvent.getByLabel(edm::InputTag((*itProv)->moduleLabel(), 00347 (*itProv)->productInstanceName(), 00348 (*itProv)->processName()), 00349 handle); 00350 } 00351 } 00352 } 00353 //std::cout <<"Mine"<<std::endl; 00354 ++evno_; 00355 }
Reimplemented from edm::EDAnalyzer.
Definition at line 359 of file EventContentAnalyzer.cc.
References cumulates_, lat::endl(), and it.
00360 { 00361 typedef std::map<std::string,int> nameMap; 00362 00363 edm::LogAbsolute("EventContent") <<"\nSummary for key being the concatenation of friendlyClassName, moduleLabel, productInstanceName and processName" << std::endl; 00364 for(nameMap::const_iterator it = cumulates_.begin(), itEnd = cumulates_.end(); 00365 it != itEnd; 00366 ++it) { 00367 edm::LogAbsolute("EventContent") << std::setw(6) << it->second << " occurrences of key " << it->first << std::endl; 00368 } 00369 00370 // Test boost::lexical_cast We don't need this right now so comment it out. 00371 // int k = 137; 00372 // std::string ktext = boost::lexical_cast<std::string>(k); 00373 // std::cout << "\nInteger " << k << " expressed as a string is |" << ktext << "|" << std::endl; 00374 }
std::map<std::string, int> EventContentAnalyzer::cumulates_ [private] |
int EventContentAnalyzer::evno_ [private] |
bool EventContentAnalyzer::getData_ [private] |
std::vector<std::string> EventContentAnalyzer::getModuleLabels_ [private] |
std::string EventContentAnalyzer::indentation_ [private] |
std::vector<std::string> EventContentAnalyzer::moduleLabels_ [private] |
Definition at line 45 of file EventContentAnalyzer.h.
Referenced by analyze(), and EventContentAnalyzer().
bool EventContentAnalyzer::verbose_ [private] |
std::string EventContentAnalyzer::verboseIndentation_ [private] |