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/DTDeadFlagValidateHandler.h"
0014
0015
0016
0017
0018 #include "CondFormats/DTObjects/interface/DTDeadFlag.h"
0019
0020
0021
0022
0023 #include <iostream>
0024 #include <fstream>
0025 #include <sstream>
0026
0027
0028
0029
0030
0031
0032
0033
0034 DTDeadFlagValidateHandler::DTDeadFlagValidateHandler(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 DTDeadFlagValidateHandler::~DTDeadFlagValidateHandler() {}
0047
0048
0049
0050
0051 void DTDeadFlagValidateHandler::getNewObjects() {
0052 int runNumber = firstRun;
0053 while (runNumber <= lastRun)
0054 addNewObject(runNumber++);
0055 return;
0056 }
0057
0058 void DTDeadFlagValidateHandler::addNewObject(int runNumber) {
0059 DTDeadFlag* df = new DTDeadFlag(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 qua;
0071 int lay;
0072 int cel;
0073
0074 bool dead_HV;
0075 bool dead_TP;
0076 bool dead_RO;
0077 bool discCat;
0078 bool ckdead_HV;
0079 bool ckdead_TP;
0080 bool ckdead_RO;
0081 bool ckdiscCat;
0082
0083 int sampleLimit = 100;
0084
0085 whe = 3;
0086 while (--whe >= -2) {
0087 sta = 5;
0088 while (--sta) {
0089 if (sta == 4)
0090 sec = 15;
0091 else
0092 sec = 13;
0093 while (--sec) {
0094 qua = 4;
0095 while (--qua) {
0096 if ((sta == 4) && (qua == 2))
0097 continue;
0098 lay = 5;
0099 while (--lay) {
0100 cel = 48;
0101 while (--cel) {
0102 dead_HV = ((random() & 0x0000ffff) < 500);
0103 dead_TP = ((random() & 0x0000ffff) < 500);
0104 dead_RO = ((random() & 0x0000ffff) < 500);
0105 discCat = ((random() & 0x0000ffff) < 500);
0106 ckdead_HV = ckdead_TP = ckdead_RO = ckdiscCat = false;
0107 if (dead_HV || dead_TP || dead_RO || discCat) {
0108 if (sampleLimit--) {
0109 status = df->set(whe, sta, sec, qua, lay, cel, dead_HV, dead_TP, dead_RO, discCat);
0110 } else {
0111 status = df->setCellDead_HV(whe, sta, sec, qua, lay, cel, dead_HV);
0112 status = df->setCellDead_TP(whe, sta, sec, qua, lay, cel, dead_TP);
0113 status = df->setCellDead_RO(whe, sta, sec, qua, lay, cel, dead_RO);
0114 status = df->setCellDiscCat(whe, sta, sec, qua, lay, cel, discCat);
0115 }
0116 } else {
0117 status = 0;
0118 }
0119
0120 outFile << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel << " " << dead_HV
0121 << " " << dead_TP << " " << dead_RO << " " << discCat << std::endl;
0122 if (status)
0123 logFile << "ERROR while setting cell flags " << whe << " " << sta << " " << sec << " " << qua << " "
0124 << lay << " " << cel << " , status = " << status << std::endl;
0125 if (dead_HV || dead_TP || dead_RO || discCat)
0126 status = df->get(whe, sta, sec, qua, lay, cel, ckdead_HV, ckdead_TP, ckdead_RO, ckdiscCat);
0127 else
0128 status = 0;
0129 if (status)
0130 logFile << "ERROR while checking cell flags " << whe << " " << sta << " " << sec << " " << qua << " "
0131 << lay << " " << cel << " , status = " << status << std::endl;
0132 if ((ckdead_HV != dead_HV) || (ckdead_TP != dead_TP) || (ckdead_RO != dead_RO) || (ckdiscCat != discCat))
0133 logFile << "MISMATCH WHEN WRITING cell flags " << whe << " " << sta << " " << sec << " " << qua << " "
0134 << lay << " " << cel << " : " << dead_HV << " " << dead_TP << " " << dead_RO << " " << discCat
0135 << " -> " << ckdead_HV << " " << ckdead_TP << " " << ckdead_RO << " " << ckdiscCat << std::endl;
0136
0137 }
0138 }
0139 }
0140 }
0141 }
0142 }
0143
0144 cond::Time_t snc = runNumber;
0145 m_to_transfer.push_back(std::make_pair(df, snc));
0146
0147 return;
0148 }
0149
0150 std::string DTDeadFlagValidateHandler::id() const { return dataVersion; }