Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:20

0001 // -*- C++ -*-
0002 //
0003 // Package:    CondTools/SiPhase2Tracker
0004 // Class:      DTCCablingMapTestReader
0005 //
0006 /**\class DTCCablingMapTestReader DTCCablingMapTestReader.cc CondTools/SiPhase2Tracker/plugins/DTCCablingMapTestReader.cc
0007 
0008 Description: [one line class summary]
0009 
0010 Implementation:
0011         [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Luigi Calligaris, SPRACE, São Paulo, BR
0015 // Created        :  Wed, 27 Feb 2019 21:41:13 GMT
0016 //
0017 //
0018 
0019 #include <memory>
0020 #include <utility>
0021 #include <unordered_map>
0022 
0023 #include <string>
0024 #include <iostream>
0025 
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 #include "FWCore/ServiceRegistry/interface/Service.h"
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 
0035 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0036 
0037 #include "CondFormats/SiPhase2TrackerObjects/interface/TrackerDetToDTCELinkCablingMap.h"
0038 #include "CondFormats/SiPhase2TrackerObjects/interface/DTCELinkId.h"
0039 #include "CondFormats/DataRecord/interface/TrackerDetToDTCELinkCablingMapRcd.h"
0040 
0041 class DTCCablingMapTestReader : public edm::one::EDAnalyzer<> {
0042 public:
0043   explicit DTCCablingMapTestReader(const edm::ParameterSet&);
0044   ~DTCCablingMapTestReader() override;
0045 
0046   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0047 
0048 private:
0049   void beginJob() override;
0050   void analyze(const edm::Event&, const edm::EventSetup&) override;
0051   void endJob() override;
0052 
0053   // ----------member data ---------------------------
0054   const edm::ESGetToken<TrackerDetToDTCELinkCablingMap, TrackerDetToDTCELinkCablingMapRcd> cablingMapToken_;
0055 };
0056 
0057 void DTCCablingMapTestReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0058   //The following says we do not know what parameters are allowed so do no validation
0059   // Please change this to state exactly what you do use, even if it is no parameters
0060   edm::ParameterSetDescription desc;
0061   desc.setUnknown();
0062   descriptions.add("DTCCablingMapTestReader", desc);
0063 }
0064 
0065 DTCCablingMapTestReader::DTCCablingMapTestReader(const edm::ParameterSet& iConfig) : cablingMapToken_(esConsumes()) {}
0066 
0067 DTCCablingMapTestReader::~DTCCablingMapTestReader() {}
0068 
0069 void DTCCablingMapTestReader::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0070   using namespace edm;
0071   using namespace std;
0072 
0073   const auto p_cablingMap = &iSetup.getData(cablingMapToken_);
0074 
0075   {
0076     ostringstream dump_DetToElink;
0077 
0078     dump_DetToElink << "Det To DTC ELink map elements dump (Python-style):" << endl;
0079     std::vector<uint32_t> const knownDetIds = p_cablingMap->getKnownDetIds();
0080 
0081     dump_DetToElink << "{";
0082     for (uint32_t detId : knownDetIds) {
0083       dump_DetToElink << "(" << detId << " : [";
0084       auto equal_range = p_cablingMap->detIdToDTCELinkId(detId);
0085 
0086       for (auto it = equal_range.first; it != equal_range.second; ++it)
0087         dump_DetToElink << "(" << unsigned(it->second.dtc_id()) << ", " << unsigned(it->second.gbtlink_id()) << ", "
0088                         << unsigned(it->second.elink_id()) << "), ";
0089 
0090       dump_DetToElink << "], ";
0091     }
0092     dump_DetToElink << "}" << endl;
0093 
0094     edm::LogInfo("DetToElinkCablingMapDump") << dump_DetToElink.str();
0095   }
0096 
0097   {
0098     ostringstream dump_ElinkToDet;
0099 
0100     dump_ElinkToDet << "DTC Elink To Det map elements dump (Python-style):" << endl;
0101     std::vector<DTCELinkId> const knownDTCELinkIds = p_cablingMap->getKnownDTCELinkIds();
0102 
0103     dump_ElinkToDet << "{";
0104     for (DTCELinkId const& currentELink : knownDTCELinkIds) {
0105       dump_ElinkToDet << "(" << unsigned(currentELink.dtc_id()) << ", " << unsigned(currentELink.gbtlink_id()) << ", "
0106                       << unsigned(currentELink.elink_id()) << ") "
0107                       << " : ";
0108       auto detId_it = p_cablingMap->dtcELinkIdToDetId(currentELink);
0109 
0110       dump_ElinkToDet << detId_it->second << ", ";
0111     }
0112     dump_ElinkToDet << "}" << endl;
0113 
0114     edm::LogInfo("DetToElinkCablingMapDump") << dump_ElinkToDet.str();
0115   }
0116 }
0117 
0118 void DTCCablingMapTestReader::beginJob() {}
0119 
0120 void DTCCablingMapTestReader::endJob() {}
0121 
0122 //define this as a plug-in
0123 DEFINE_FWK_MODULE(DTCCablingMapTestReader);