Go to the documentation of this file.00001 #include "CondCore/PopCon/interface/PopCon.h"
00002 #include "CondCore/PopCon/interface/Exception.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include <iostream>
00006
00007 namespace popcon {
00008
00009 PopCon::PopCon(const edm::ParameterSet& pset):
00010 m_record(pset.getParameter<std::string> ("record")),
00011 m_payload_name(pset.getUntrackedParameter<std::string> ("name","")),
00012 m_LoggingOn(pset.getUntrackedParameter< bool > ("loggingOn",true)),
00013 m_IsDestDbCheckedInQueryLog(pset.getUntrackedParameter< bool > ("IsDestDbCheckedInQueryLog",true)),
00014 m_close(pset.getUntrackedParameter< bool > ("closeIOV",false)),
00015 m_lastTill(pset.getUntrackedParameter< bool > ("lastTill",0))
00016 {
00017
00018
00019
00020 edm::LogInfo ("PopCon") << "This is PopCon (Populator of Condition) V4.0\n"
00021 << "Please report any problem and feature request through the savannah portal under the category conditions\n" ;
00022
00023 }
00024
00025 PopCon::~PopCon(){}
00026
00027
00028 void PopCon::initialize() {
00029 edm::LogInfo ("PopCon")<<"payload name "<<m_payload_name<<std::endl;
00030 if(!m_dbService.isAvailable() ) throw Exception("DBService not available");
00031 const std::string & connectionStr = m_dbService->session().connectionString();
00032 m_tag = m_dbService->tag(m_record);
00033 m_tagInfo.name = m_tag;
00034 if( !m_dbService->isNewTagRequest(m_record) ) {
00035 m_dbService->tagInfo(m_record,m_tagInfo);
00036
00037 if(m_IsDestDbCheckedInQueryLog) {
00038 m_dbService->queryLog().LookupLastEntryByTag(m_tag, connectionStr , m_logDBEntry);
00039 std::cout << " ------ log info searched in the same db: " << connectionStr << "------" <<std::endl;
00040 } else {
00041 m_dbService->queryLog().LookupLastEntryByTag(m_tag , m_logDBEntry);
00042 std::cout << " ------ log info found in another db " << "------" <<std::endl;
00043 }
00044
00045 edm::LogInfo ("PopCon") << "DB: " << connectionStr << "\n"
00046 << "TAG: " << m_tag
00047 << ", last since/till: " << m_tagInfo.lastInterval.first
00048 << "/" << m_tagInfo.lastInterval.second
00049 << ", , size: " << m_tagInfo.size << "\n"
00050 << "Last writer: " << m_logDBEntry.provenance
00051 << ", size: " << m_logDBEntry.payloadIdx+1 << std::endl;
00052 } else {
00053 edm::LogInfo ("PopCon") << "DB: " << connectionStr << "\n"
00054 << "TAG: " << m_tag
00055 << "; First writer to this new tag." << std::endl;
00056 }
00057 }
00058
00059
00060 void PopCon::finalize(Time_t lastTill) {
00061
00062 if (m_close) {
00063
00064 if (m_lastTill>lastTill) lastTill=m_lastTill;
00065 m_dbService->closeIOV(lastTill,m_record);
00066 }
00067 }
00068
00069 }