CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/FWCore/Services/src/UpdaterService.cc

Go to the documentation of this file.
00001 #include "FWCore/Services/interface/UpdaterService.h"
00002 
00003 #include "DataFormats/Provenance/interface/EventID.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00007 
00008 #include <iostream>
00009 
00010 UpdaterService::UpdaterService(edm::ParameterSet const&, edm::ActivityRegistry& r) :
00011   theEventId(0) {
00012   r.watchPreProcessEvent(this, &UpdaterService::init);
00013   theInit();
00014 }
00015 
00016 UpdaterService::~UpdaterService() {
00017 }
00018 
00019 void UpdaterService::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00020   edm::ParameterSetDescription desc;
00021   descriptions.add("UpdaterService", desc);
00022 }
00023 
00024 void UpdaterService::init(edm::EventID const& eId, edm::Timestamp const&) {
00025   theInit();
00026   theEventId = &eId;
00027 }
00028 
00029 void UpdaterService::theInit() {
00030   theCounts.clear();
00031 }
00032 
00033 bool UpdaterService::checkOnce(std::string tag) {
00034   bool answer = true;
00035 
00036   std::map<std::string, unsigned int>::iterator i = theCounts.find(tag);
00037   if(i != theCounts.end()) {
00038     ++i->second;
00039     answer = false;
00040   } else{
00041     theCounts[tag] = 1;
00042     answer = true;
00043   }
00044 
00045   if(theEventId) {
00046     LogDebug("UpdaterService")
00047       << "checking ONCE on tag: " << tag << "on run: " << theEventId->run()
00048       << " event: " << theEventId->event() << ((answer) ? " -> true" : " -> false");
00049   }
00050   return answer;
00051 }
00052 
00053 bool UpdaterService::check(std::string /*tag*/, std::string /*label*/) {
00054   return true;
00055 }