Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:48

0001 
0002 /*----------------------------------------------------------------------
0003 
0004 Toy EDAnalyzer for testing purposes only.
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     // Context is not used.
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     // get configuration for current run
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     // loop over chambers
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       // get chamber id
0057       const DTCCBId& ccbId = iter->first;
0058       std::cout << ccbId.wheelId << " " << ccbId.stationId << " " << ccbId.sectorId << " -> ";
0059       std::cout << std::endl;
0060       // get brick identifiers list
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       // loop over configuration bricks
0066       while (cfgIter != cfgIend) {
0067         // get brick identifier
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 }  // namespace edmtest