File indexing completed on 2023-03-17 10:47:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "CondTools/DT/test/validate/DTPerformanceValidateHandler.h"
0014
0015
0016
0017
0018 #include "CondFormats/DTObjects/interface/DTPerformance.h"
0019
0020
0021
0022
0023 #include <cmath>
0024 #include <iostream>
0025 #include <fstream>
0026 #include <sstream>
0027
0028
0029
0030
0031
0032
0033
0034
0035 DTPerformanceValidateHandler::DTPerformanceValidateHandler(const edm::ParameterSet& ps)
0036 : firstRun(ps.getParameter<unsigned int>("firstRun")),
0037 lastRun(ps.getParameter<unsigned int>("lastRun")),
0038 dataVersion(ps.getParameter<std::string>("version")),
0039 dataFileName(ps.getParameter<std::string>("outFile")),
0040 elogFileName(ps.getParameter<std::string>("logFile")) {
0041 std::ofstream logFile(elogFileName.c_str());
0042 }
0043
0044
0045
0046
0047 DTPerformanceValidateHandler::~DTPerformanceValidateHandler() {}
0048
0049
0050
0051
0052 void DTPerformanceValidateHandler::getNewObjects() {
0053 int runNumber = firstRun;
0054 while (runNumber <= lastRun)
0055 addNewObject(runNumber++);
0056 return;
0057 }
0058
0059 void DTPerformanceValidateHandler::addNewObject(int runNumber) {
0060 DTPerformance* mp = new DTPerformance(dataVersion);
0061
0062 std::stringstream run_fn;
0063 run_fn << "run" << runNumber << dataFileName;
0064
0065 int status = 0;
0066 std::ofstream outFile(run_fn.str().c_str());
0067 std::ofstream logFile(elogFileName.c_str(), std::ios_base::app);
0068 int whe;
0069 int sta;
0070 int sec;
0071 int qua;
0072 float meanT0;
0073 float meanTtrig;
0074 float meanMtime;
0075 float meanNoise;
0076 float meanAfterPulse;
0077 float meanResolution;
0078 float meanEfficiency;
0079 float ckmeanT0;
0080 float ckmeanTtrig;
0081 float ckmeanMtime;
0082 float ckmeanNoise;
0083 float ckmeanAfterPulse;
0084 float ckmeanResolution;
0085 float ckmeanEfficiency;
0086
0087 whe = 3;
0088 while (--whe >= -2) {
0089 sta = 5;
0090 while (--sta) {
0091 if (sta == 4)
0092 sec = 15;
0093 else
0094 sec = 13;
0095 while (--sec) {
0096 qua = 4;
0097 while (--qua) {
0098 if ((sta == 4) && (qua == 2))
0099 continue;
0100 meanT0 = random() * 10.0 / 0x7fffffff;
0101 meanTtrig = random() * 1000.0 / 0x0fffffff;
0102 meanMtime = random() * 10.0 / 0x7fffffff;
0103 meanNoise = random() * 1.0 / 0x0fffffff;
0104 meanAfterPulse = random() * 1.0 / 0x7fffffff;
0105 meanResolution = random() * 10.0 / 0x0fffffff;
0106 meanEfficiency = random() * 0.02 / 0x7fffffff;
0107 meanT0 -= 5.0;
0108 meanMtime += 470.0;
0109 meanEfficiency = 1.0 - meanEfficiency;
0110 status = mp->set(whe,
0111 sta,
0112 sec,
0113 qua,
0114 meanT0,
0115 meanTtrig,
0116 meanMtime,
0117 meanNoise,
0118 meanAfterPulse,
0119 meanResolution,
0120 meanEfficiency,
0121 DTTimeUnits::counts);
0122 outFile << whe << " " << sta << " " << sec << " " << qua << " " << meanT0 << " " << meanTtrig << " "
0123 << meanMtime << " " << meanNoise << " " << meanAfterPulse << " " << meanResolution << " "
0124 << meanEfficiency << std::endl;
0125 if (status)
0126 logFile << "ERROR while setting sl performance " << whe << " " << sta << " " << sec << " " << qua
0127 << " , status = " << status << std::endl;
0128 status = mp->get(whe,
0129 sta,
0130 sec,
0131 qua,
0132 ckmeanT0,
0133 ckmeanTtrig,
0134 ckmeanMtime,
0135 ckmeanNoise,
0136 ckmeanAfterPulse,
0137 ckmeanResolution,
0138 ckmeanEfficiency,
0139 DTTimeUnits::counts);
0140 if (status)
0141 logFile << "ERROR while checking sl performance " << whe << " " << sta << " " << sec << " " << qua
0142 << " , status = " << status << std::endl;
0143 if ((fabs(ckmeanT0 - meanT0) > 0.0001) || (fabs(ckmeanTtrig - meanTtrig) > 0.1) ||
0144 (fabs(ckmeanMtime - meanMtime) > 0.01) || (fabs(ckmeanNoise - meanNoise) > 0.0001) ||
0145 (fabs(ckmeanAfterPulse - meanAfterPulse) > 0.0001) || (fabs(ckmeanResolution - meanResolution) > 0.01) ||
0146 (fabs(ckmeanEfficiency - meanEfficiency) > 0.0001))
0147 logFile << "MISMATCH WHEN WRITING sl performance " << whe << " " << sta << " " << sec << " " << qua << " : "
0148 << meanT0 << " " << meanTtrig << " " << meanMtime << " " << meanNoise << " " << meanAfterPulse
0149 << " " << meanResolution << " " << meanEfficiency << " -> " << ckmeanT0 << " " << ckmeanTtrig << " "
0150 << ckmeanMtime << " " << ckmeanNoise << " " << ckmeanAfterPulse << " " << ckmeanResolution << " "
0151 << ckmeanEfficiency << std::endl;
0152
0153
0154 }
0155 }
0156 }
0157 }
0158
0159 cond::Time_t snc = runNumber;
0160 m_to_transfer.push_back(std::make_pair(mp, snc));
0161
0162 return;
0163 }
0164
0165 std::string DTPerformanceValidateHandler::id() const { return dataVersion; }