Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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/DTT0Write.h"
0018 #include "CondFormats/DTObjects/interface/DTT0.h"
0019 
0020 #include <string>
0021 #include <map>
0022 #include <iostream>
0023 #include <fstream>
0024 
0025 namespace edmtest {
0026 
0027   DTT0Write::DTT0Write(edm::ParameterSet const& p) {}
0028 
0029   DTT0Write::DTT0Write(int i) {}
0030 
0031   void DTT0Write::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 DTT0Write::endJob() {
0037     std::cout << "DTT0Write::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     DTT0 t0("cmssw_t0");
0045 
0046     int status = 0;
0047     std::ifstream ifile("testT0.txt");
0048     int whe;
0049     int sta;
0050     int sec;
0051     int qua;
0052     int lay;
0053     int cel;
0054     float t0m;
0055     float rms;
0056     while (ifile >> whe >> sta >> sec >> qua >> lay >> cel >> t0m >> rms) {
0057       status = t0.set(whe, sta, sec, qua, lay, cel, t0m, rms, DTTimeUnits::counts);
0058       std::cout << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << " " << t0m << " " << rms
0059                 << "  -> ";
0060       std::cout << "insert status: " << status << std::endl;
0061     }
0062 
0063     if (dbservice->isNewTagRequest("DTT0Rcd")) {
0064       dbservice->createOneIOV<DTT0>(t0, dbservice->beginOfTime(), "DTT0Rcd");
0065     } else {
0066       std::cout << "already present tag" << std::endl;
0067       //      dbservice->appendSinceTime<DTT0>(
0068       //                 t0,dbservice->currentTime(),"DTT0Rcd");
0069     }
0070   }
0071   DEFINE_FWK_MODULE(DTT0Write);
0072 }  // namespace edmtest