CMS 3D CMS Logo

DTCCablingMapTestReader.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CondTools/SiPhase2Tracker
4 // Class: DTCCablingMapTestReader
5 //
13 //
14 // Original Author: Luigi Calligaris, SPRACE, São Paulo, BR
15 // Created : Wed, 27 Feb 2019 21:41:13 GMT
16 //
17 //
18 
19 #include <memory>
20 #include <utility>
21 #include <unordered_map>
22 
23 #include <string>
24 #include <iostream>
25 
35 
37 
41 
42 
44 {
45  public:
47  ~DTCCablingMapTestReader() override;
48 
49  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50 
51 
52  private:
53  void beginJob() override;
54  void analyze(const edm::Event&, const edm::EventSetup&) override;
55  void endJob() override;
56 
57 };
58 
59 
61 {
62  //The following says we do not know what parameters are allowed so do no validation
63  // Please change this to state exactly what you do use, even if it is no parameters
65  desc.setUnknown();
66  descriptions.add("DTCCablingMapTestReader", desc);
67 }
68 
69 
71 {
72 
73 }
74 
75 
77 {
78 
79 }
80 
81 
83 {
84  using namespace edm;
85  using namespace std;
86 
88  iSetup.get<TrackerDetToDTCELinkCablingMapRcd>().get( cablingMapHandle );
89  TrackerDetToDTCELinkCablingMap const* p_cablingMap = cablingMapHandle.product();
90 
91  {
92  ostringstream dump_DetToElink;
93 
94  dump_DetToElink << "Det To DTC ELink map elements dump (Python-style):" << endl;
95  std::vector<uint32_t> const knownDetIds = p_cablingMap->getKnownDetIds();
96 
97  dump_DetToElink << "{";
98  for (uint32_t detId : knownDetIds)
99  {
100 
101  dump_DetToElink << "(" << detId << " : [";
102  auto equal_range = p_cablingMap->detIdToDTCELinkId(detId);
103 
104  for (auto it = equal_range.first; it != equal_range.second; ++it)
105  dump_DetToElink << "(" << unsigned(it->second.dtc_id()) << ", " << unsigned(it->second.gbtlink_id()) << ", " << unsigned(it->second.elink_id()) << "), ";
106 
107  dump_DetToElink << "], ";
108  }
109  dump_DetToElink << "}" << endl;
110 
111  edm::LogInfo("DetToElinkCablingMapDump") << dump_DetToElink.str();
112  }
113 
114  {
115  ostringstream dump_ElinkToDet;
116 
117  dump_ElinkToDet << "DTC Elink To Det map elements dump (Python-style):" << endl;
118  std::vector<DTCELinkId> const knownDTCELinkIds = p_cablingMap->getKnownDTCELinkIds();
119 
120  dump_ElinkToDet << "{";
121  for (DTCELinkId const& currentELink : knownDTCELinkIds)
122  {
123  dump_ElinkToDet << "(" << unsigned(currentELink.dtc_id()) << ", " << unsigned(currentELink.gbtlink_id()) << ", " << unsigned(currentELink.elink_id()) << ") " << " : ";
124  auto detId_it = p_cablingMap->dtcELinkIdToDetId(currentELink);
125 
126  dump_ElinkToDet << detId_it->second << ", ";
127  }
128  dump_ElinkToDet << "}" << endl;
129 
130  edm::LogInfo("DetToElinkCablingMapDump") << dump_ElinkToDet.str();
131  }
132 }
133 
134 
136 {
137 
138 }
139 
140 
142 {
143 
144 }
145 
146 //define this as a plug-in
void analyze(const edm::Event &, const edm::EventSetup &) override
std::unordered_map< DTCELinkId, uint32_t >::const_iterator dtcELinkIdToDetId(DTCELinkId const &) const
Resolves the raw DetId of the detector connected to the eLink identified by a DTCELinkId.
std::vector< DTCELinkId > getKnownDTCELinkIds() const
Returns a vector containing all elink DTCELinkId nown to the map.
DTCCablingMapTestReader(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< uint32_t > getKnownDetIds() const
Returns a vector containing all detector DetId known to the map.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::pair< std::unordered_multimap< uint32_t, DTCELinkId >::const_iterator, std::unordered_multimap< uint32_t, DTCELinkId >::const_iterator > detIdToDTCELinkId(uint32_t const) const
Resolves one or more DTCELinkId of eLinks which are connected to the detector identified by the given...
HLT enums.
T get() const
Definition: EventSetup.h:71
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
Definition: ESHandle.h:86