CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoLuminosity/LumiProducer/plugins/HLTConfDummy2DB.cc

Go to the documentation of this file.
00001 #ifndef RecoLuminosity_LumiProducer_HLTConfDummy2DB_h 
00002 #define RecoLuminosity_LumiProducer_HLTConfDummy2DB_h 
00003 #include "RelationalAccess/ConnectionService.h"
00004 #include "RelationalAccess/ISessionProxy.h"
00005 #include "RelationalAccess/ITransaction.h"
00006 #include "RelationalAccess/ISchema.h"
00007 #include "RelationalAccess/IQuery.h"
00008 #include "RelationalAccess/ICursor.h"
00009 #include "RelationalAccess/ITable.h"
00010 #include "RelationalAccess/ITableDataEditor.h"
00011 #include "RelationalAccess/IBulkOperation.h"
00012 #include "CoralBase/AttributeList.h"
00013 #include "CoralBase/AttributeSpecification.h"
00014 #include "CoralBase/Attribute.h"
00015 #include "CoralBase/Exception.h"
00016 #include "RecoLuminosity/LumiProducer/interface/DataPipe.h"
00017 #include "RecoLuminosity/LumiProducer/interface/LumiNames.h"
00018 #include "RecoLuminosity/LumiProducer/interface/Exception.h"
00019 #include "RecoLuminosity/LumiProducer/interface/DBConfig.h"
00020 #include <iostream>
00021 #include <cstdio>
00022 
00023 namespace lumi{
00024   class HLTConfDummy2DB : public DataPipe{
00025   public:
00026     explicit HLTConfDummy2DB(const std::string& dest);
00027     virtual void retrieveData( unsigned int runnumber);
00028     virtual const std::string dataType() const;
00029     virtual const std::string sourceType() const;
00030     virtual ~HLTConfDummy2DB();
00031   };//cl HLTConfDummy2DB
00032   //
00033   //implementation
00034   //
00035   HLTConfDummy2DB::HLTConfDummy2DB(const std::string& dest):DataPipe(dest){}
00036   void HLTConfDummy2DB::retrieveData( unsigned int runnumber){
00037     //
00038     //generate dummy configuration data for the given hltconfid and write data to LumiDB
00039     //
00040     //std::cout<<"retrieving data for run "<<runnumber<<std::endl;
00041     std::string fakehltkey("/cdaq/Cosmic/V12");
00042     coral::ConnectionService* svc=new coral::ConnectionService;
00043     lumi::DBConfig dbconf(*svc);
00044     if(!m_authpath.empty()){
00045       dbconf.setAuthentication(m_authpath);
00046     }
00047     coral::ISessionProxy* session=svc->connect(m_dest,coral::Update);
00048     try{
00049       unsigned int totalhltpath=126;
00050       session->transaction().start(false);
00051       coral::ISchema& schema=session->nominalSchema();
00052       coral::ITable& hltconftable=schema.tableHandle(LumiNames::trghltMapTableName());
00053       coral::AttributeList hltconfData;
00054       hltconfData.extend<std::string>("HLTKEY");
00055       hltconfData.extend<std::string>("HLTPATHNAME");
00056       hltconfData.extend<std::string>("L1SEED");
00057       coral::IBulkOperation* hltconfInserter=hltconftable.dataEditor().bulkInsert(hltconfData,200);
00058       //
00059       //loop over hltpaths
00060       //
00061       hltconfData["HLTKEY"].data<std::string>()=fakehltkey;
00062       std::string& hltpathname=hltconfData["HLTPATHNAME"].data<std::string>();
00063       std::string& l1seed=hltconfData["L1SEED"].data<std::string>();
00064       for(unsigned int i=1;i<=totalhltpath;++i){
00065         char c[10];
00066         ::sprintf(c,"-%d",i);
00067         hltpathname=std::string("FakeHLTPATH_")+std::string(c);
00068         l1seed=std::string("FakeL1SeedExpression_")+std::string(c);
00069         hltconfInserter->processNextIteration();
00070       }
00071       hltconfInserter->flush();
00072       delete hltconfInserter;
00073       session->transaction().commit();
00074     }catch( const coral::Exception& er){
00075       std::cout<<"database problem "<<er.what()<<std::endl;
00076       session->transaction().rollback();
00077       delete session;
00078       delete svc;
00079       throw er;
00080     }
00081     delete session;
00082     delete svc;
00083   }
00084   const std::string HLTConfDummy2DB::dataType() const{
00085     return "HLTCONF";
00086   }
00087   const std::string HLTConfDummy2DB::sourceType() const{
00088     return "DUMMY";
00089   }
00090   HLTConfDummy2DB::~HLTConfDummy2DB(){}
00091 }//ns lumi
00092 #include "RecoLuminosity/LumiProducer/interface/DataPipeFactory.h"
00093 DEFINE_EDM_PLUGIN(lumi::DataPipeFactory,lumi::HLTConfDummy2DB,"HLTConfDummy2DB");
00094 #endif