Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:36

0001 #include "CondCore/DBCommon/interface/DbConnection.h"
0002 #include "CondCore/DBCommon/interface/DbTransaction.h"
0003 #include "CondCore/DBCommon/interface/Time.h"
0004 #include "CondCore/DBCommon/interface/Exception.h"
0005 #include "CondCore/IOVService/interface/IOVEditor.h"
0006 #include "CondCore/MetaDataService/interface/MetaData.h"
0007 #include "CondFormats/Calibration/interface/Pedestals.h"
0008 #include "FWCore/PluginManager/interface/PluginManager.h"
0009 #include "FWCore/PluginManager/interface/standard.h"
0010 #include <iostream>
0011 
0012 int main() {
0013   try {
0014     // for runnumber
0015     cond::TimeType timetype = cond::runnumber;
0016     cond::Time_t globalTill = cond::timeTypeSpecs[timetype].endValue;
0017     edmplugin::PluginManager::Config config;
0018     edmplugin::PluginManager::configure(edmplugin::standard::config());
0019 
0020     cond::DbConnection connection;
0021     connection.configuration().setMessageLevel(coral::Error);
0022     connection.configure();
0023     cond::DbSession session = connection.createSession();
0024     session.open("sqlite_file:extradata.db");
0025     cond::IOVEditor ioveditor(session);
0026     session.transaction().start(false);
0027     ioveditor.create(timetype, globalTill);
0028     std::string mytestiovtoken;
0029     for (unsigned int i = 0; i < 3; ++i) {  //inserting 3 payloads
0030       std::shared_ptr<Pedestals> myped(new Pedestals);
0031       for (int ichannel = 1; ichannel <= 5; ++ichannel) {
0032         Pedestals::Item item;
0033         item.m_mean = 1.11 * ichannel + i;
0034         item.m_variance = 1.12 * ichannel + i * 2;
0035         myped->m_pedestals.push_back(item);
0036       }
0037       std::string payloadToken = session.storeObject(myped.get(), "anotherPedestalsRcd");
0038       std::cout << "payloadToken " << payloadToken << std::endl;
0039       ioveditor.append(cond::Time_t(2 + 2 * i), payloadToken);
0040     }
0041     std::string mytoken = ioveditor.token();
0042     cond::MetaData metadata(session);
0043     metadata.addMapping("anothertag", mytoken, cond::runnumber);
0044     session.transaction().commit();
0045   } catch (const cond::Exception& er) {
0046     std::cout << "error " << er.what() << std::endl;
0047   } catch (const std::exception& er) {
0048     std::cout << "std error " << er.what() << std::endl;
0049   }
0050 }