CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CondTools/RPC/plugins/CondReader.cc

Go to the documentation of this file.
00001 #include <string>
00002 #include <map>
00003 #include <vector>
00004 
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "FWCore/Framework/interface/EDAnalyzer.h"
00007 #include "FWCore/Framework/interface/MakerMacros.h"
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include "CondTools/RPC/interface/RPCDBSimSetUp.h"
00011 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00012 #include "CondFormats/RPCObjects/interface/RPCObCond.h"
00013 #include "CondFormats/DataRecord/interface/RPCObCondRcd.h"
00014 #include "CondTools/RPC/interface/RPCFw.h"
00015 #include "CoralBase/TimeStamp.h"
00016 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00017 #include "FWCore/ServiceRegistry/interface/Service.h"
00018 
00019 class  CondReader : public edm::EDAnalyzer {
00020 public:
00021   CondReader(const edm::ParameterSet& iConfig);
00022     
00023   ~CondReader();
00024   void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup);
00025 
00026 private:
00027   unsigned long long since;
00028   unsigned long long till;
00029 };
00030 
00031 
00032 CondReader::CondReader(const edm::ParameterSet& iConfig) : 
00033   since(iConfig.getUntrackedParameter<unsigned long long>("since",0)),
00034   till(iConfig.getUntrackedParameter<unsigned long long>("till",0))
00035 {}
00036 
00037 CondReader::~CondReader(){}
00038 
00039 void CondReader::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup)
00040 {
00041   
00042   edm::Service<cond::service::PoolDBOutputService> mydbservice;
00043 
00044   edm::ESHandle<RPCObImon> condRcd;
00045   evtSetup.get<RPCObImonRcd>().get(condRcd);
00046   edm::LogInfo("CondReader") << "[CondReader::analyze] End Reading Cond" << std::endl;
00047   
00048   std::cout << "Run start: " << since << " - Run stop: " << till << std::endl;
00049   
00050   RPCFw time ("", "", "");
00051   coral::TimeStamp sTime = time.UTtoT(since);
00052   coral::TimeStamp tTime = time.UTtoT(till);
00053   int ndateS = (sTime.day() * 10000) + (sTime.month() * 100) + (sTime.year()-2000);
00054   int ntimeS = (sTime.hour() * 10000) + (sTime.minute() * 100) + sTime.second();
00055   int ndateT = (tTime.day() * 10000) + (tTime.month() * 100) + (tTime.year()-2000);
00056   int ntimeT = (tTime.hour() * 10000) + (tTime.minute() * 100) + tTime.second();
00057   std::cout << "Run start: " << ndateS << " " << ntimeS << " - Run stop: " << ndateT << " " << ntimeT << std::endl;
00058 
00059   const RPCObImon* cond = condRcd.product();
00060   std::vector<RPCObImon::I_Item> mycond = cond->ObImon_rpc; 
00061   std::vector<RPCObImon::I_Item>::iterator icond;
00062 
00063   std::cout << "************************************" << std::endl;
00064   for(icond = mycond.begin(); icond < mycond.end(); ++icond){
00065 
00066     if (icond->day >= ndateS && icond->time >= ntimeS && icond->day <= ndateT && icond->time <= ntimeT)
00067       std::cout<<"dpid = " << icond->dpid << " - value = " << icond->value << " - day = " << icond->day << " - time = " << icond->time << std::endl;
00068   }
00069   
00070 }
00071 
00072 //define this as a plug-in
00073 DEFINE_FWK_MODULE(CondReader);
00074