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 <fstream>
0012 #include <map>
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 
0015 #include "FWCore/ServiceRegistry/interface/Service.h"
0016 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0017 
0018 #include "CondFormats/DTObjects/test/stubs/DTDeadWrite.h"
0019 #include "CondFormats/DTObjects/interface/DTDeadFlag.h"
0020 
0021 namespace edmtest {
0022 
0023   DTDeadWrite::DTDeadWrite(edm::ParameterSet const& p) {}
0024 
0025   DTDeadWrite::DTDeadWrite(int i) {}
0026 
0027   void DTDeadWrite::analyze(const edm::Event& e, const edm::EventSetup& context) {
0028     std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0029     std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl;
0030   }
0031 
0032   void DTDeadWrite::endJob() {
0033     std::cout << "DTDeadWrite::analyze " << std::endl;
0034     edm::Service<cond::service::PoolDBOutputService> dbservice;
0035     if (!dbservice.isAvailable()) {
0036       std::cout << "db service unavailable" << std::endl;
0037       return;
0038     }
0039 
0040     DTDeadFlag dlist("deadList");
0041 
0042     fill_dead_HV("dead_HV_list.txt", &dlist);
0043     fill_dead_TP("dead_TP_list.txt", &dlist);
0044     fill_dead_RO("dead_RO_list.txt", &dlist);
0045     fill_discCat("discCat_list.txt", &dlist);
0046 
0047     if (dbservice->isNewTagRequest("DTDeadFlagRcd")) {
0048       dbservice->createOneIOV<DTDeadFlag>(dlist, dbservice->beginOfTime(), "DTDeadFlagRcd");
0049     } else {
0050       std::cout << "already present tag" << std::endl;
0051       int currentRun = 10;
0052       //      dbservice->appendTillTime<DTDeadFlag>(
0053       dbservice->appendOneIOV<DTDeadFlag>(dlist, currentRun, "DTDeadFlagRcd");
0054       //      dbservice->appendSinceTime<DTDeadFlag>(
0055       //                 dlist,dbservice->currentTime(),"DTDeadFlagRcd");
0056     }
0057   }
0058 
0059   void DTDeadWrite::fill_dead_HV(const char* file, DTDeadFlag* deadList) {
0060     int status = 0;
0061     int whe;
0062     int sta;
0063     int sec;
0064     int qua;
0065     int lay;
0066     int cel;
0067     std::ifstream ifile(file);
0068     while (ifile >> whe >> sta >> sec >> qua >> lay >> cel) {
0069       status = deadList->setCellDead_HV(whe, sta, sec, qua, lay, cel, true);
0070       std::cout << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << "  -> ";
0071       std::cout << "insert status: " << status << std::endl;
0072     }
0073     return;
0074   }
0075   void DTDeadWrite::fill_dead_TP(const char* file, DTDeadFlag* deadList) {
0076     int status = 0;
0077     int whe;
0078     int sta;
0079     int sec;
0080     int qua;
0081     int lay;
0082     int cel;
0083     std::ifstream ifile(file);
0084     while (ifile >> whe >> sta >> sec >> qua >> lay >> cel) {
0085       status = deadList->setCellDead_TP(whe, sta, sec, qua, lay, cel, true);
0086       std::cout << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << "  -> ";
0087       std::cout << "insert status: " << status << std::endl;
0088     }
0089     return;
0090   }
0091   void DTDeadWrite::fill_dead_RO(const char* file, DTDeadFlag* deadList) {
0092     int status = 0;
0093     int whe;
0094     int sta;
0095     int sec;
0096     int qua;
0097     int lay;
0098     int cel;
0099     std::ifstream ifile(file);
0100     while (ifile >> whe >> sta >> sec >> qua >> lay >> cel) {
0101       status = deadList->setCellDead_RO(whe, sta, sec, qua, lay, cel, true);
0102       std::cout << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << "  -> ";
0103       std::cout << "insert status: " << status << std::endl;
0104     }
0105     return;
0106   }
0107   void DTDeadWrite::fill_discCat(const char* file, DTDeadFlag* deadList) {
0108     int status = 0;
0109     int whe;
0110     int sta;
0111     int sec;
0112     int qua;
0113     int lay;
0114     int cel;
0115     std::ifstream ifile(file);
0116     while (ifile >> whe >> sta >> sec >> qua >> lay >> cel) {
0117       status = deadList->setCellDiscCat(whe, sta, sec, qua, lay, cel, true);
0118       std::cout << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << "  -> ";
0119       std::cout << "insert status: " << status << std::endl;
0120     }
0121     return;
0122   }
0123 
0124   DEFINE_FWK_MODULE(DTDeadWrite);
0125 }  // namespace edmtest