File indexing completed on 2024-04-06 12:02:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "CondTools/DT/test/validate/DTLVStatusValidateHandler.h"
0014
0015
0016
0017
0018 #include "CondFormats/DTObjects/interface/DTLVStatus.h"
0019
0020
0021
0022
0023 #include <iostream>
0024 #include <fstream>
0025 #include <sstream>
0026
0027
0028
0029
0030
0031
0032
0033
0034 DTLVStatusValidateHandler::DTLVStatusValidateHandler(const edm::ParameterSet& ps)
0035 : firstRun(ps.getParameter<unsigned int>("firstRun")),
0036 lastRun(ps.getParameter<unsigned int>("lastRun")),
0037 dataVersion(ps.getParameter<std::string>("version")),
0038 dataFileName(ps.getParameter<std::string>("outFile")),
0039 elogFileName(ps.getParameter<std::string>("logFile")) {
0040 std::ofstream logFile(elogFileName.c_str());
0041 }
0042
0043
0044
0045
0046 DTLVStatusValidateHandler::~DTLVStatusValidateHandler() {}
0047
0048
0049
0050
0051 void DTLVStatusValidateHandler::getNewObjects() {
0052 int runNumber = firstRun;
0053 while (runNumber <= lastRun)
0054 addNewObject(runNumber++);
0055 return;
0056 }
0057
0058 void DTLVStatusValidateHandler::addNewObject(int runNumber) {
0059 DTLVStatus* lv = new DTLVStatus(dataVersion);
0060
0061 std::stringstream run_fn;
0062 run_fn << "run" << runNumber << dataFileName;
0063
0064 int status = 0;
0065 std::ofstream outFile(run_fn.str().c_str());
0066 std::ofstream logFile(elogFileName.c_str(), std::ios_base::app);
0067 int whe;
0068 int sta;
0069 int sec;
0070 int flagCFE;
0071 int flagDFE;
0072 int flagCMC;
0073 int flagDMC;
0074 int ckflagCFE;
0075 int ckflagDFE;
0076 int ckflagCMC;
0077 int ckflagDMC;
0078
0079 whe = 3;
0080 while (--whe >= -2) {
0081 sta = 5;
0082 while (--sta) {
0083 if (sta == 4)
0084 sec = 15;
0085 else
0086 sec = 13;
0087 while (--sec) {
0088 flagCFE = random() & 0x0000000f;
0089 flagDFE = random() & 0x0000000f;
0090 flagCMC = random() & 0x0000000f;
0091 flagDMC = random() & 0x0000000f;
0092 if ((flagCFE == 3) || (flagCFE >= 7))
0093 flagCFE = 0;
0094 if ((flagDFE == 3) || (flagDFE >= 7))
0095 flagDFE = 0;
0096 if ((flagCMC == 3) || (flagCMC >= 7))
0097 flagCMC = 0;
0098 if ((flagDMC == 3) || (flagDMC >= 7))
0099 flagDMC = 0;
0100 if (flagCFE || flagDFE || flagCMC || flagDMC)
0101 status = lv->set(whe, sta, sec, flagCFE, flagDFE, flagCMC, flagDMC);
0102 else
0103 status = 0;
0104 outFile << whe << " " << sta << " " << sec << " " << flagCFE << " " << flagDFE << " " << flagCMC << " "
0105 << flagDMC << std::endl;
0106 if (status)
0107 logFile << "ERROR while setting LV status" << whe << " " << sta << " " << sec << " , status = " << status
0108 << std::endl;
0109 ckflagCFE = ckflagDFE = ckflagCMC = ckflagDMC = 0;
0110 if (flagCFE || flagDFE || flagCMC || flagDMC)
0111 status = lv->get(whe, sta, sec, ckflagCFE, ckflagDFE, ckflagCMC, ckflagDMC);
0112 else
0113 status = 0;
0114 if (status)
0115 logFile << "ERROR while checking LV status " << whe << " " << sta << " " << sec << " , status = " << status
0116 << std::endl;
0117 if ((ckflagCFE != flagCFE) || (ckflagDFE != flagDFE) || (ckflagCMC != flagCMC) || (ckflagDMC != flagDMC))
0118 logFile << "MISMATCH WHEN WRITING LV status " << whe << " " << sta << " " << sec << " " << flagCFE << " "
0119 << flagDFE << " " << flagCMC << " " << flagDMC << " -> " << ckflagCFE << " " << ckflagDFE << " "
0120 << ckflagCMC << " " << ckflagDMC << std::endl;
0121 }
0122 }
0123 }
0124
0125 cond::Time_t snc = runNumber;
0126 m_to_transfer.push_back(std::make_pair(lv, snc));
0127
0128 return;
0129 }
0130
0131 std::string DTLVStatusValidateHandler::id() const { return dataVersion; }