Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:07

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 "CondFormats/DTObjects/test/stubs/DTConfigPrint.h"
0015 
0016 namespace edmtest {
0017 
0018   DTConfigPrint::DTConfigPrint(edm::ParameterSet const& p) {
0019     // parameters to setup
0020     connect = p.getParameter<std::string>("connect");
0021     auth_path = p.getParameter<std::string>("authenticationPath");
0022     token = p.getParameter<std::string>("token");
0023     local = p.getParameter<bool>("siteLocalConfig");
0024     if (local)
0025       catalog = "";
0026     else
0027       catalog = p.getParameter<std::string>("catalog");
0028     es_token = esConsumes();
0029   }
0030 
0031   DTConfigPrint::DTConfigPrint(int i) {}
0032 
0033   void DTConfigPrint::analyze(const edm::Event& e, const edm::EventSetup& context) {
0034     using namespace edm::eventsetup;
0035     // Context is not used.
0036     std::cout << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0037     std::cout << " ---EVENT NUMBER " << e.id().event() << std::endl;
0038 
0039     // get configuration for current run
0040     const auto& conf = context.getData(es_token);
0041     std::cout << conf.version() << std::endl;
0042     std::cout << std::distance(conf.begin(), conf.end()) << " data in the container" << std::endl;
0043 
0044     // loop over chambers
0045     DTCCBConfig::ccb_config_map configKeys(conf.configKeyMap());
0046     DTCCBConfig::ccb_config_iterator iter = configKeys.begin();
0047     DTCCBConfig::ccb_config_iterator iend = configKeys.end();
0048     while (iter != iend) {
0049       // get chamber id
0050       const DTCCBId& ccbId = iter->first;
0051       std::cout << "chamber " << ccbId.wheelId << " " << ccbId.stationId << " " << ccbId.sectorId << " -> ";
0052       std::cout << std::endl;
0053       // get brick identifiers list
0054       const std::vector<int>& ccbConf = iter->second;
0055       std::vector<int>::const_iterator cfgIter = ccbConf.begin();
0056       std::vector<int>::const_iterator cfgIend = ccbConf.end();
0057 
0058       // loop over configuration bricks
0059       while (cfgIter != cfgIend) {
0060         // get brick identifier
0061         int id = *cfgIter++;
0062         std::cout << " " << id;
0063         std::cout << std::endl;
0064       }
0065       std::cout << std::endl;
0066       ++iter;
0067     }
0068   }
0069   DEFINE_FWK_MODULE(DTConfigPrint);
0070 }  // namespace edmtest