Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:20

0001 #ifndef RecoLuminosity_LumiProducer_HLTConfDummy2DB_h
0002 #define RecoLuminosity_LumiProducer_HLTConfDummy2DB_h
0003 #include "RelationalAccess/ConnectionService.h"
0004 #include "RelationalAccess/ISessionProxy.h"
0005 #include "RelationalAccess/ITransaction.h"
0006 #include "RelationalAccess/ISchema.h"
0007 #include "RelationalAccess/IQuery.h"
0008 #include "RelationalAccess/ICursor.h"
0009 #include "RelationalAccess/ITable.h"
0010 #include "RelationalAccess/ITableDataEditor.h"
0011 #include "RelationalAccess/IBulkOperation.h"
0012 #include "CoralBase/AttributeList.h"
0013 #include "CoralBase/AttributeSpecification.h"
0014 #include "CoralBase/Attribute.h"
0015 #include "CoralBase/Exception.h"
0016 #include "RecoLuminosity/LumiProducer/interface/DataPipe.h"
0017 #include "RecoLuminosity/LumiProducer/interface/LumiNames.h"
0018 #include "RecoLuminosity/LumiProducer/interface/Exception.h"
0019 #include "RecoLuminosity/LumiProducer/interface/DBConfig.h"
0020 #include <iostream>
0021 #include <cstdio>
0022 
0023 namespace lumi {
0024   class HLTConfDummy2DB : public DataPipe {
0025   public:
0026     explicit HLTConfDummy2DB(const std::string& dest);
0027     unsigned long long retrieveData(unsigned int runnumber) override;
0028     const std::string dataType() const override;
0029     const std::string sourceType() const override;
0030     ~HLTConfDummy2DB() override;
0031   };  //cl HLTConfDummy2DB
0032   //
0033   //implementation
0034   //
0035   HLTConfDummy2DB::HLTConfDummy2DB(const std::string& dest) : DataPipe(dest) {}
0036   unsigned long long HLTConfDummy2DB::retrieveData(unsigned int runnumber) {
0037     //
0038     //generate dummy configuration data for the given hltconfid and write data to LumiDB
0039     //
0040     //std::cout<<"retrieving data for run "<<runnumber<<std::endl;
0041     std::string fakehltkey("/cdaq/Cosmic/V12");
0042     coral::ConnectionService* svc = new coral::ConnectionService;
0043     lumi::DBConfig dbconf(*svc);
0044     if (!m_authpath.empty()) {
0045       dbconf.setAuthentication(m_authpath);
0046     }
0047     coral::ISessionProxy* session = svc->connect(m_dest, coral::Update);
0048     try {
0049       unsigned int totalhltpath = 126;
0050       session->transaction().start(false);
0051       coral::ISchema& schema = session->nominalSchema();
0052       coral::ITable& hltconftable = schema.tableHandle(LumiNames::trghltMapTableName());
0053       coral::AttributeList hltconfData;
0054       hltconfData.extend<std::string>("HLTKEY");
0055       hltconfData.extend<std::string>("HLTPATHNAME");
0056       hltconfData.extend<std::string>("L1SEED");
0057       coral::IBulkOperation* hltconfInserter = hltconftable.dataEditor().bulkInsert(hltconfData, 200);
0058       //
0059       //loop over hltpaths
0060       //
0061       hltconfData["HLTKEY"].data<std::string>() = fakehltkey;
0062       std::string& hltpathname = hltconfData["HLTPATHNAME"].data<std::string>();
0063       std::string& l1seed = hltconfData["L1SEED"].data<std::string>();
0064       for (unsigned int i = 1; i <= totalhltpath; ++i) {
0065         char c[10];
0066         ::sprintf(c, "-%d", i);
0067         hltpathname = std::string("FakeHLTPATH_") + std::string(c);
0068         l1seed = std::string("FakeL1SeedExpression_") + std::string(c);
0069         hltconfInserter->processNextIteration();
0070       }
0071       hltconfInserter->flush();
0072       delete hltconfInserter;
0073       session->transaction().commit();
0074     } catch (const coral::Exception& er) {
0075       std::cout << "database problem " << er.what() << std::endl;
0076       session->transaction().rollback();
0077       delete session;
0078       delete svc;
0079       throw er;
0080     }
0081     delete session;
0082     delete svc;
0083     return 0;
0084   }
0085   const std::string HLTConfDummy2DB::dataType() const { return "HLTCONF"; }
0086   const std::string HLTConfDummy2DB::sourceType() const { return "DUMMY"; }
0087   HLTConfDummy2DB::~HLTConfDummy2DB() {}
0088 }  // namespace lumi
0089 #include "RecoLuminosity/LumiProducer/interface/DataPipeFactory.h"
0090 DEFINE_EDM_PLUGIN(lumi::DataPipeFactory, lumi::HLTConfDummy2DB, "HLTConfDummy2DB");
0091 #endif