CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/CondCore/PopCon/src/PopCon.cc

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 
00006 #include<iostream>
00007 
00008 namespace popcon {
00009 
00010   PopCon::PopCon(const edm::ParameterSet& pset):
00011     m_record(pset.getParameter<std::string> ("record")),
00012     m_payload_name(pset.getUntrackedParameter<std::string> ("name","")),
00013     m_LoggingOn(pset.getUntrackedParameter< bool > ("loggingOn",true)),
00014     m_IsDestDbCheckedInQueryLog(pset.getUntrackedParameter< bool > ("IsDestDbCheckedInQueryLog",true)),
00015     m_close(pset.getUntrackedParameter< bool > ("closeIOV",false)),
00016     m_lastTill(pset.getUntrackedParameter< bool > ("lastTill",0))
00017     {
00018       //TODO set the policy (cfg or global configuration?)
00019       //Policy if corrupted data found
00020       
00021       edm::LogInfo ("PopCon") << "This is PopCon (Populator of Condition) V4.0\n"
00022                               << "Please report any problem and feature request through the savannah portal under the category conditions\n" ; 
00023 
00024     }
00025   
00026   PopCon::~PopCon(){}
00027  
00028 
00029   void PopCon::initialize() {   
00030     edm::LogInfo ("PopCon")<<"payload name "<<m_payload_name<<std::endl;
00031     if(!m_dbService.isAvailable() ) throw Exception("DBService not available");
00032     const std::string & connectionStr = m_dbService->session().connectionString();
00033     m_tag = m_dbService->tag(m_record);
00034     if( !m_dbService->isNewTagRequest(m_record) ) {
00035       m_dbService->tagInfo(m_record,m_tagInfo);
00036       // m_dbService->queryLog().LookupLastEntryByTag(m_tag, m_logDBEntry);
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     }
00053   }
00054   
00055   
00056   void PopCon::finalize(Time_t lastTill) {
00057     
00058     if (m_close) {
00059       // avoid to close it before lastSince
00060       if (m_lastTill>lastTill) lastTill=m_lastTill;
00061       m_dbService->closeIOV(lastTill,m_record);
00062     }
00063   }
00064   
00065 }