File indexing completed on 2023-03-17 10:47:51
0001
0002
0003
0004
0005
0006
0007
0008 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include <cmath>
0013 #include <fstream>
0014 #include <iostream>
0015 #include <map>
0016 #include <sstream>
0017 #include <stdexcept>
0018 #include <string>
0019
0020 #include "FWCore/Framework/interface/EventSetup.h"
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022
0023 #include "CondTools/DT/test/validate/DTCompMapValidateDBRead.h"
0024 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
0025 #include "CondFormats/DataRecord/interface/DTReadOutMappingRcd.h"
0026
0027 DTCompMapValidateDBRead::DTCompMapValidateDBRead(edm::ParameterSet const& p)
0028 : dataFileName(p.getParameter<std::string>("chkFile")),
0029 elogFileName(p.getParameter<std::string>("logFile")),
0030 dtreadoutmappingToken_(esConsumes()) {}
0031
0032 DTCompMapValidateDBRead::DTCompMapValidateDBRead(int i) : dtreadoutmappingToken_(esConsumes()) {}
0033
0034 void DTCompMapValidateDBRead::analyze(const edm::Event& e, const edm::EventSetup& context) {
0035 using namespace edm::eventsetup;
0036
0037 std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0038 std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl;
0039 std::stringstream run_fn;
0040
0041
0042 std::ifstream chkFile(dataFileName.c_str());
0043 std::ofstream logFile(elogFileName.c_str(), std::ios_base::app);
0044 auto ro = context.getHandle(dtreadoutmappingToken_);
0045 std::cout << ro->mapRobRos() << " " << ro->mapCellTdc() << std::endl;
0046 std::cout << std::distance(ro->begin(), ro->end()) << " data in the container" << std::endl;
0047 int whe;
0048 int sta;
0049 int sec;
0050 int qua;
0051 int lay;
0052 int cel;
0053 int ddu;
0054 int ros;
0055 int rob;
0056 int tdc;
0057 int cha;
0058 int ckwhe;
0059 int cksta;
0060 int cksec;
0061 int ckqua;
0062 int cklay;
0063 int ckcel;
0064 int ckddu;
0065 int ckros;
0066 int ckrob;
0067 int cktdc;
0068 int ckcha;
0069 while (chkFile >> ckddu >> ckros >> ckrob >> cktdc >> ckcha >> ckwhe >> cksta >> cksec >> ckqua >> cklay >> ckcel) {
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 ro->readOutToGeometry(ckddu, ckros, ckrob, cktdc, ckcha, whe, sta, sec, qua, lay, cel);
0097 if ((ckwhe != whe) || (cksta != sta) || (cksec != sec) || (ckqua != qua) || (cklay != lay) || (ckcel != cel))
0098 logFile << "MISMATCH IN WRITING AND READING chan->cell map " << ckddu << " " << ckros << " " << ckrob << " "
0099 << cktdc << " " << ckcha << " : " << ckwhe << " " << cksta << " " << cksec << " " << ckqua << " " << cklay
0100 << " " << ckcel << " -> " << whe << " " << sta << " " << sec << " " << qua << " " << lay << " " << cel
0101 << std::endl;
0102 ro->geometryToReadOut(ckwhe, cksta, cksec, ckqua, cklay, ckcel, ddu, ros, rob, tdc, cha);
0103 if ((ckddu != ddu) || (ckros != ros) || (ckrob != rob) || (cktdc != tdc) || (ckcha != cha))
0104 logFile << "MISMATCH IN WRITING AND READING cell->chan map " << ckwhe << " " << cksta << " " << cksec << " "
0105 << ckqua << " " << cklay << " " << ckcel << " : " << ckddu << " " << ckros << " " << ckrob << " " << cktdc
0106 << " " << ckcha << " -> " << ddu << " " << ros << " " << rob << " " << tdc << " " << cha << std::endl;
0107 }
0108 }
0109
0110 void DTCompMapValidateDBRead::endJob() {
0111 std::ifstream logFile(elogFileName.c_str());
0112 char* line = new char[1000];
0113 int errors = 0;
0114 std::cout << "ReadOut Map validation result:" << std::endl;
0115 while (logFile.getline(line, 1000)) {
0116 std::cout << line << std::endl;
0117 errors++;
0118 }
0119 if (!errors) {
0120 std::cout << " ********************************* " << std::endl;
0121 std::cout << " *** *** " << std::endl;
0122 std::cout << " *** NO ERRORS FOUND *** " << std::endl;
0123 std::cout << " *** *** " << std::endl;
0124 std::cout << " ********************************* " << std::endl;
0125 }
0126 return;
0127 }
0128
0129 DEFINE_FWK_MODULE(DTCompMapValidateDBRead);