Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:07

0001 
0002 /*----------------------------------------------------------------------
0003 
0004 Toy EDAnalyzer for testing purposes only.
0005 
0006 ----------------------------------------------------------------------*/
0007 
0008 #include <stdexcept>
0009 #include <string>
0010 #include <iostream>
0011 #include <map>
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013 
0014 #include "FWCore/ServiceRegistry/interface/Service.h"
0015 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0016 
0017 #include "CondFormats/DTObjects/test/stubs/DTConfigWrite.h"
0018 #include "CondFormats/DTObjects/interface/DTCCBConfig.h"
0019 
0020 #include <string>
0021 #include <map>
0022 #include <iostream>
0023 #include <fstream>
0024 
0025 namespace edmtest {
0026 
0027   DTConfigWrite::DTConfigWrite(edm::ParameterSet const& p) {}
0028 
0029   DTConfigWrite::DTConfigWrite(int i) {}
0030 
0031   void DTConfigWrite::analyze(const edm::Event& e, const edm::EventSetup& context) {
0032     std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0033     std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl;
0034   }
0035 
0036   void DTConfigWrite::endJob() {
0037     std::cout << "DTConfigWrite::analyze " << std::endl;
0038     edm::Service<cond::service::PoolDBOutputService> dbservice;
0039     if (!dbservice.isAvailable()) {
0040       std::cout << "db service unavailable" << std::endl;
0041       return;
0042     }
0043 
0044     DTCCBConfig conf("test_config");
0045 
0046     int status = 0;
0047     std::ifstream ifile("testConfig.txt");
0048     int run;
0049     int nty;
0050     int kty;
0051     int key;
0052     int whe;
0053     int sta;
0054     int sec;
0055     int nbr;
0056     int ibr;
0057     ifile >> run >> nty;
0058     conf.setStamp(run);
0059     std::vector<DTConfigKey> fullKey;
0060     while (nty--) {
0061       ifile >> kty >> key;
0062       DTConfigKey confList;
0063       confList.confType = kty;
0064       confList.confKey = key;
0065       fullKey.push_back(confList);
0066     }
0067     conf.setFullKey(fullKey);
0068     while (ifile >> whe >> sta >> sec >> nbr) {
0069       std::vector<int> cfg;
0070       while (nbr--) {
0071         ifile >> ibr;
0072         cfg.push_back(ibr);
0073       }
0074       status = conf.setConfigKey(whe, sta, sec, cfg);
0075       std::cout << whe << " " << sta << " " << sec << "  -> ";
0076       std::cout << "insert status: " << status << std::endl;
0077     }
0078 
0079     std::cout << "end of time : " << dbservice->endOfTime() << std::endl;
0080     if (dbservice->isNewTagRequest("DTCCBConfigRcd")) {
0081       dbservice->createOneIOV<DTCCBConfig>(conf, dbservice->beginOfTime(), "DTCCBConfigRcd");
0082       //                      0xffffffff,"DTCCBConfigRcd");
0083     } else {
0084       std::cout << "already present tag" << std::endl;
0085       //      dbservice->appendSinceTime<DTCCBConfig>(
0086       //                 conf,dbservice->currentTime(),"DTCCBConfigRcd");
0087     }
0088   }
0089   DEFINE_FWK_MODULE(DTConfigWrite);
0090 }  // namespace edmtest