File indexing completed on 2023-03-17 10:47:50
0001
0002
0003
0004
0005
0006
0007
0008 #include <stdexcept>
0009 #include <iostream>
0010 #include <map>
0011 #include "FWCore/Framework/interface/ESHandle.h"
0012 #include "FWCore/Framework/interface/MakerMacros.h"
0013
0014 #include "CondTools/DT/test/stubs/DTKeyedConfigDump.h"
0015 #include "CondFormats/DTObjects/interface/DTKeyedConfig.h"
0016
0017 namespace edmtest {
0018
0019 DTKeyedConfigDump::DTKeyedConfigDump(edm::ParameterSet const& p)
0020 : dumpCCBKeys{p.getParameter<bool>("dumpCCBKeys")},
0021 dumpAllData{p.getParameter<bool>("dumpAllData")},
0022 configToken_{esConsumes<DTCCBConfig, DTCCBConfigRcd>()} {
0023 if (dumpCCBKeys) {
0024 keyListToken_ = esConsumes<cond::persistency::KeyList, DTKeyedConfigListRcd>();
0025 }
0026 }
0027
0028 void DTKeyedConfigDump::analyze(const edm::Event& e, const edm::EventSetup& context) {
0029 using namespace edm::eventsetup;
0030
0031 std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0032 std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl;
0033
0034
0035 auto const& conf = context.getData(configToken_);
0036
0037 std::cout << conf.version() << std::endl;
0038 std::cout << std::distance(conf.begin(), conf.end()) << " data in the container" << std::endl;
0039 edm::ValidityInterval iov(context.get<DTCCBConfigRcd>().validityInterval());
0040 unsigned int currValidityStart = iov.first().eventID().run();
0041 unsigned int currValidityEnd = iov.last().eventID().run();
0042 std::cout << "valid since run " << currValidityStart << " to run " << currValidityEnd << std::endl;
0043
0044 if (!dumpCCBKeys)
0045 return;
0046
0047 const DTKeyedConfig** allBricks = new const DTKeyedConfig*[100000];
0048 int nBricks = 0;
0049
0050 auto const& keyList = context.getData(keyListToken_);
0051
0052 DTCCBConfig::ccb_config_map configKeys(conf.configKeyMap());
0053 DTCCBConfig::ccb_config_iterator iter = configKeys.begin();
0054 DTCCBConfig::ccb_config_iterator iend = configKeys.end();
0055 while (iter != iend) {
0056
0057 const DTCCBId& ccbId = iter->first;
0058 std::cout << ccbId.wheelId << " " << ccbId.stationId << " " << ccbId.sectorId << " -> ";
0059 std::cout << std::endl;
0060
0061 const std::vector<int>& ccbConf = iter->second;
0062 std::vector<int>::const_iterator cfgIter = ccbConf.begin();
0063 std::vector<int>::const_iterator cfgIend = ccbConf.end();
0064
0065
0066 while (cfgIter != cfgIend) {
0067
0068 int id = *cfgIter++;
0069 std::cout << " " << id;
0070 std::cout << std::endl;
0071 if (!dumpAllData)
0072 continue;
0073 const DTKeyedConfig* kBrick = nullptr;
0074 cfgCache.get(keyList, id, kBrick);
0075 allBricks[nBricks++] = kBrick;
0076 if (kBrick == nullptr) {
0077 std::cout << "brick missing" << std::endl;
0078 continue;
0079 }
0080 std::vector<std::string>::const_iterator s_iter = kBrick->dataBegin();
0081 std::vector<std::string>::const_iterator s_iend = kBrick->dataEnd();
0082 while (s_iter != s_iend)
0083 std::cout << " ----> " << *s_iter++ << std::endl;
0084 }
0085 std::cout << std::endl;
0086 ++iter;
0087 }
0088 }
0089 DEFINE_FWK_MODULE(DTKeyedConfigDump);
0090 }