Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:32

0001 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0002 #include "FWCore/ServiceRegistry/interface/Service.h"
0003 
0004 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0005 #include "CondCore/DBOutputService/interface/KeyedElement.h"
0006 #include "CondFormats/Calibration/interface/Conf.h"
0007 
0008 #include <iostream>
0009 #include <string>
0010 
0011 class writeKeyed : public edm::one::EDAnalyzer<> {
0012 public:
0013   explicit writeKeyed(const edm::ParameterSet& iConfig);
0014   virtual void analyze(const edm::Event&, const edm::EventSetup&) {}
0015   virtual void endJob();
0016 
0017 private:
0018   std::string confcont, confiov;
0019 };
0020 
0021 void writeKeyed::endJob() {
0022   std::vector<std::string> dict;
0023   dict.push_back("Sneezy");
0024   dict.push_back("Sleepy");
0025   dict.push_back("Dopey");
0026   dict.push_back("Doc");
0027   dict.push_back("Happy");
0028   dict.push_back("Bashful");
0029   dict.push_back("Grumpy");
0030 
0031   char const* nums[] = {"1", "2", "3", "4", "5", "6", "7"};
0032 
0033   edm::Service<cond::service::PoolDBOutputService> outdb;
0034 
0035   std::map<cond::Time_t, cond::BaseKeyed*> keys;
0036   // populated with the keyed payloads (configurations)
0037   for (size_t i = 0; i < dict.size(); ++i)
0038     for (size_t j = 0; j < 7; ++j) {
0039       cond::BaseKeyed* bk = 0;
0040       cond::KeyedElement k((0 == i % 2) ? bk = new condex::ConfI(dict[i] + nums[j], 10 * i + j)
0041                                         : bk = new condex::ConfF(dict[i] + nums[j], i + 0.1 * j),
0042                            dict[i] + nums[j]);
0043       std::cout << k.m_skey << " " << k.m_key << std::endl;
0044 
0045       keys.insert(std::make_pair(k.m_key, k.m_obj));
0046     }
0047 
0048   std::cout << "# uploading keys..." << std::endl;
0049   for (auto k : keys)
0050     outdb->writeOneIOV(k.second, k.first, confcont);
0051 
0052   std::cout << "# uploading master payloads..." << std::endl;
0053   // populate the master payload
0054   int run = 10;
0055   for (size_t j = 0; j < 7; ++j) {
0056     std::vector<cond::Time_t> kl;
0057     for (size_t i = 0; i < dict.size(); ++i)
0058       (kl).at(i) = cond::KeyedElement::convert(dict[i] + nums[j]);
0059     outdb->writeOneIOV(kl, run, confiov);
0060     run += 10;
0061   }
0062 }
0063 
0064 writeKeyed::writeKeyed(const edm::ParameterSet& iConfig) : confcont("confcont"), confiov("confiov") {}
0065 
0066 #include "FWCore/Framework/interface/MakerMacros.h"
0067 DEFINE_FWK_MODULE(writeKeyed);