CMS 3D CMS Logo

SiStripFedCabling_PayloadInspector.cc
Go to the documentation of this file.
1 
12 
16 
21 
22 #include <memory>
23 #include <sstream>
24 #include <TCanvas.h>
25 #include <TH2D.h>
26 #include <TLatex.h>
27 
28 namespace {
29 
30  using namespace cond::payloadInspector;
31 
32  /************************************************
33  TrackerMap of SiStrip FED Cabling
34  *************************************************/
35  class SiStripFedCabling_TrackerMap : public PlotImage<SiStripFedCabling, SINGLE_IOV> {
36  public:
37  SiStripFedCabling_TrackerMap() : PlotImage<SiStripFedCabling, SINGLE_IOV>("Tracker Map SiStrip Fed Cabling") {}
38 
39  bool fill() override {
40  auto tag = PlotBase::getTag<0>();
41  auto iov = tag.iovs.front();
42  std::shared_ptr<SiStripFedCabling> payload = fetchPayload(std::get<1>(iov));
43 
44  std::unique_ptr<TrackerMap> tmap = std::make_unique<TrackerMap>("SiStripFedCabling");
45  tmap->setPalette(1);
46  std::string titleMap = "TrackerMap of SiStrip Fed Cabling per module, IOV : " + std::to_string(std::get<0>(iov));
47  tmap->setTitle(titleMap);
48 
50  edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath());
51  std::unique_ptr<SiStripDetCabling> detCabling_ = std::make_unique<SiStripDetCabling>(*(payload.get()), &tTopo);
52 
53  std::vector<uint32_t> activeDetIds;
54  detCabling_->addActiveDetectorsRawIds(activeDetIds);
55 
56  for (const auto& detId : activeDetIds) {
57  int32_t n_conn = 0;
58  for (uint32_t connDet_i = 0; connDet_i < detCabling_->getConnections(detId).size(); connDet_i++) {
59  if (detCabling_->getConnections(detId)[connDet_i] != nullptr &&
60  detCabling_->getConnections(detId)[connDet_i]->isConnected() != 0)
61  n_conn++;
62  }
63  if (n_conn != 0) {
64  tmap->fill(detId, n_conn * 2);
65  }
66  }
67 
68  std::string fileName(m_imageFileName);
69  tmap->save(true, 0., 6., fileName);
70 
71  return true;
72  }
73  };
74 
75  /************************************************
76  Summary Plot of SiStrip FED Cabling
77  *************************************************/
78  class SiStripFedCabling_Summary : public PlotImage<SiStripFedCabling, SINGLE_IOV> {
79  public:
80  SiStripFedCabling_Summary() : PlotImage<SiStripFedCabling, SINGLE_IOV>("SiStrip Fed Cabling Summary") {}
81 
82  bool fill() override {
83  auto tag = PlotBase::getTag<0>();
84  auto iov = tag.iovs.front();
85  std::shared_ptr<SiStripFedCabling> payload = fetchPayload(std::get<1>(iov));
86  int IOV = std::get<0>(iov);
87  std::vector<uint32_t> activeDetIds;
88 
90  edm::FileInPath("Geometry/TrackerCommonData/data/trackerParameters.xml").fullPath());
91  std::unique_ptr<SiStripDetCabling> detCabling_ = std::make_unique<SiStripDetCabling>(*(payload.get()), &tTopo);
92 
93  detCabling_->addActiveDetectorsRawIds(activeDetIds);
94 
95  containers myCont;
96  containers allCounts;
97 
98  const auto detInfo =
100  for (const auto& it : detInfo.getAllData()) {
101  // check if det id is correct and if it is actually cabled in the detector
102  if (it.first == 0 || it.first == 0xFFFFFFFF) {
103  edm::LogError("DetIdNotGood") << "@SUB=analyze"
104  << "Wrong det id: " << it.first << " ... neglecting!" << std::endl;
105  continue;
106  }
107  updateCounters(it.first, allCounts, tTopo);
108  }
109 
110  for (const auto& detId : activeDetIds) {
111  updateCounters(detId, myCont, tTopo);
112  }
113 
114  TH2D* ME = new TH2D("SummaryOfCabling", "SummaryOfCabling", 6, 0.5, 6.5, 9, 0.5, 9.5);
115  ME->GetXaxis()->SetTitle("Sub Det");
116  ME->GetYaxis()->SetTitle("Layer");
117 
118  ME->SetTitle("");
119 
120  ME->GetXaxis()->SetBinLabel(1, "TIB");
121  ME->GetXaxis()->SetBinLabel(2, "TID F");
122  ME->GetXaxis()->SetBinLabel(3, "TID B");
123  ME->GetXaxis()->SetBinLabel(4, "TOB");
124  ME->GetXaxis()->SetBinLabel(5, "TEC F");
125  ME->GetXaxis()->SetBinLabel(6, "TEC B");
126 
127  for (int i = 0; i < 4; i++) {
128  ME->Fill(1, i + 1, float(myCont.counterTIB[i]) / allCounts.counterTIB[i]);
129  }
130 
131  for (int i = 0; i < 2; i++) {
132  for (int j = 0; j < 3; j++) {
133  ME->Fill(i + 2, j + 1, float(myCont.counterTID[i][j]) / allCounts.counterTID[i][j]);
134  }
135  }
136 
137  for (int i = 0; i < 6; i++) {
138  ME->Fill(4, i + 1, float(myCont.counterTOB[i]) / allCounts.counterTOB[i]);
139  }
140 
141  for (int i = 0; i < 2; i++) {
142  for (int j = 0; j < 9; j++) {
143  ME->Fill(i + 5, j + 1, float(myCont.counterTEC[i][j]) / allCounts.counterTEC[i][j]);
144  }
145  }
146 
147  TCanvas c1("SiStrip FED cabling summary", "SiStrip FED cabling summary", 800, 600);
148  c1.SetTopMargin(0.07);
149  c1.SetBottomMargin(0.10);
150  c1.SetLeftMargin(0.07);
151  c1.SetRightMargin(0.10);
152 
153  ME->Draw("colz");
154  ME->Draw("TEXTsame");
155  ME->SetStats(kFALSE);
156 
157  TLatex t1;
158  t1.SetNDC();
159  t1.SetTextAlign(26);
160  t1.SetTextSize(0.05);
161  t1.DrawLatex(0.5, 0.96, Form("SiStrip FedCabling, IOV %i", IOV));
162 
163  std::string fileName(m_imageFileName);
164  c1.SaveAs(fileName.c_str());
165 
166  return true;
167  }
168 
169  private:
170  struct containers {
171  public:
172  int counterTIB[4] = {0};
173  int counterTID[2][3] = {{0}};
174  int counterTOB[6] = {0};
175  int counterTEC[2][9] = {{0}};
176  };
177 
178  void updateCounters(int detId, containers& cont, const TrackerTopology& tTopo) {
179  StripSubdetector subdet(detId);
180 
181  switch (subdet.subdetId()) {
182  case StripSubdetector::TIB: {
183  int i = tTopo.tibLayer(detId) - 1;
184  cont.counterTIB[i]++;
185  break;
186  }
187  case StripSubdetector::TID: {
188  int j = tTopo.tidWheel(detId) - 1;
189  int side = tTopo.tidSide(detId);
190  if (side == 2) {
191  cont.counterTID[0][j]++;
192  } else if (side == 1) {
193  cont.counterTID[1][j]++;
194  }
195  break;
196  }
197  case StripSubdetector::TOB: {
198  int i = tTopo.tobLayer(detId) - 1;
199  cont.counterTOB[i]++;
200  break;
201  }
202  case StripSubdetector::TEC: {
203  int j = tTopo.tecWheel(detId) - 1;
204  int side = tTopo.tecSide(detId);
205  if (side == 2) {
206  cont.counterTEC[0][j]++;
207  } else if (side == 1) {
208  cont.counterTEC[1][j]++;
209  }
210  break;
211  }
212  }
213  }
214  };
215 
216 } // namespace
217 
219  PAYLOAD_INSPECTOR_CLASS(SiStripFedCabling_TrackerMap);
220  PAYLOAD_INSPECTOR_CLASS(SiStripFedCabling_Summary);
221 }
static constexpr auto TEC
unsigned int tobLayer(const DetId &id) const
unsigned int tidSide(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
Definition: ME.h:11
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
unsigned int tecSide(const DetId &id) const
SiStripDetInfo read(std::string filePath)
static constexpr auto TOB
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
static constexpr auto TIB
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
static constexpr char const *const kDefaultFile
unsigned int tibLayer(const DetId &id) const
static constexpr auto TID
cont
load Luminosity info ##
Definition: generateEDF.py:628