CMS 3D CMS Logo

SiStripCablingDQM.cc
Go to the documentation of this file.
4 #include "TCanvas.h"
5 using namespace std;
6 // -----
7 
9  edm::RunNumber_t iRun,
10  edm::ParameterSet const &hPSet,
11  edm::ParameterSet const &fPSet)
12  : SiStripBaseCondObjDQM(eSetup, iRun, hPSet, fPSet) {
13  // Build the Histo_TkMap:
14  if (HistoMaps_On_) {
15  edm::ESHandle<TkDetMap> tkDetMapHandle;
16  eSetup.get<TrackerTopologyRcd>().get(tkDetMapHandle);
17  Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMapHandle.product(), "SiStrip/Histo_Map", "Cabling_TkMap", 0.);
18  }
19 }
20 // -----
21 
22 // -----
24 // -----
25 
26 // -----
28  // Retrieve tracker topology from geometry
30  eSetup.get<TrackerTopologyRcd>().get(tTopoHandle);
31  const TrackerTopology *const tTopo = tTopoHandle.product();
32 
33  // Get active and total detIds
34  getConditionObject(eSetup);
35  if (!cablingHandle_.isValid()) {
36  edm::LogError("InvalidCablingHandle") << "Invalid Cabling Handle";
37  return;
38  }
41 
42  // Initialize arrays for counting:
43  int counterTIB[4];
44  for (int i = 0; i < 4; i++)
45  counterTIB[i] = 0;
46  int counterTID[2][3];
47  for (int i = 0; i < 2; i++) {
48  for (int j = 0; j < 3; j++)
49  counterTID[i][j] = 0;
50  }
51  int counterTOB[6];
52  for (int i = 0; i < 6; i++)
53  counterTOB[i] = 0;
54  int counterTEC[2][9];
55  for (int i = 0; i < 2; i++) {
56  for (int j = 0; j < 9; j++)
57  counterTEC[i][j] = 0;
58  }
59 
60  std::vector<uint32_t>::const_iterator idet = activeDetIds.begin();
61 
62  // fill arrays for counting and fill Histo_Map with value for connected :
63  for (; idet != activeDetIds.end(); ++idet) {
64  uint32_t detId = *idet;
65  StripSubdetector subdet(detId);
66 
67  if (HistoMaps_On_) {
68  Tk_HM_->fill(detId, cablingHandle_->nApvPairs(detId) * 2);
69  }
70  if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
71  int32_t n_conn = 0;
72  for (uint32_t connDet_i = 0; connDet_i < cablingHandle_->getConnections(detId).size(); connDet_i++) {
73  if (cablingHandle_->getConnections(detId)[connDet_i] != nullptr &&
74  cablingHandle_->getConnections(detId)[connDet_i]->isConnected() != 0)
75  n_conn++;
76  }
77  fillTkMap(detId, n_conn * 2.);
78  }
79  switch (subdet.subdetId()) {
80  case StripSubdetector::TIB: {
81  int i = tTopo->tibLayer(detId) - 1;
82  counterTIB[i]++;
83  break;
84  }
85  case StripSubdetector::TID: {
86  int j = tTopo->tidWheel(detId) - 1;
87  int side = tTopo->tidSide(detId);
88  if (side == 2) {
89  counterTID[0][j]++;
90  } else if (side == 1) {
91  counterTID[1][j]++;
92  }
93  break;
94  }
95  case StripSubdetector::TOB: {
96  int i = tTopo->tobLayer(detId) - 1;
97  counterTOB[i]++;
98  break;
99  }
100  case StripSubdetector::TEC: {
101  int j = tTopo->tecWheel(detId) - 1;
102  int side = tTopo->tecSide(detId);
103  if (side == 2) {
104  counterTEC[0][j]++;
105  } else if (side == 1) {
106  counterTEC[1][j]++;
107  }
108  break;
109  }
110  }
111 
112  } // idet
113 
114  // obtained from tracker.dat and hard-coded
115  int TIBDetIds[4] = {672, 864, 540, 648};
116  int TIDDetIds[2][3] = {{136, 136, 136}, {136, 136, 136}};
117  int TOBDetIds[6] = {1008, 1152, 648, 720, 792, 888};
118  int TECDetIds[2][9] = {{408, 408, 408, 360, 360, 360, 312, 312, 272}, {408, 408, 408, 360, 360, 360, 312, 312, 272}};
119 
121 
122  std::string FolderName = fPSet_.getParameter<std::string>("FolderName_For_QualityAndCabling_SummaryHistos");
123 
124  dqmStore_->setCurrentFolder(FolderName);
125 
126  // dqmStore_->cd("SiStrip/MechanicalView/");
128  ME = dqmStore_->book2D("SummaryOfCabling", "SummaryOfCabling", 6, 0.5, 6.5, 9, 0.5, 9.5);
129  ME->setAxisTitle("Sub Det", 1);
130  ME->setAxisTitle("Layer", 2);
131 
132  ME->getTH1()->GetXaxis()->SetBinLabel(1, "TIB");
133  ME->getTH1()->GetXaxis()->SetBinLabel(2, "TID F");
134  ME->getTH1()->GetXaxis()->SetBinLabel(3, "TID B");
135  ME->getTH1()->GetXaxis()->SetBinLabel(4, "TOB");
136  ME->getTH1()->GetXaxis()->SetBinLabel(5, "TEC F");
137  ME->getTH1()->GetXaxis()->SetBinLabel(6, "TEC B");
138 
139  for (int i = 0; i < 4; i++) {
140  ME->Fill(1, i + 1, float(counterTIB[i]) / TIBDetIds[i]);
141  }
142 
143  for (int i = 0; i < 2; i++) {
144  for (int j = 0; j < 3; j++) {
145  ME->Fill(i + 2, j + 1, float(counterTID[i][j]) / TIDDetIds[i][j]);
146  }
147  }
148 
149  for (int i = 0; i < 6; i++) {
150  ME->Fill(4, i + 1, float(counterTOB[i]) / TOBDetIds[i]);
151  }
152 
153  for (int i = 0; i < 2; i++) {
154  for (int j = 0; j < 9; j++) {
155  ME->Fill(i + 5, j + 1, float(counterTEC[i][j]) / TECDetIds[i][j]);
156  }
157  }
158 
159  if (fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")) {
160  TCanvas c1("c1");
161  ME->getTH1()->Draw("TEXT");
162  ME->getTH1()->SetStats(kFALSE);
163  std::string name(ME->getTH1()->GetTitle());
164  name += ".png";
165  c1.Print(name.c_str());
166  }
167 }
T getParameter(std::string const &) const
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
unsigned int tibLayer(const DetId &id) const
void getConditionObject(const edm::EventSetup &eSetup) override
TH1 * getTH1() const
unsigned int tidWheel(const DetId &id) const
void fillTkMap(const uint32_t &detid, const float &value)
void getActiveDetIds(const edm::EventSetup &eSetup) override
void Fill(long long x)
~SiStripCablingDQM() override
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
unsigned int tidSide(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
edm::ESHandle< SiStripDetCabling > cablingHandle_
const uint16_t nApvPairs(uint32_t det_id) const
MonitorElement ME
T get() const
Definition: EventSetup.h:71
std::vector< uint32_t > activeDetIds
SiStripCablingDQM(const edm::EventSetup &eSetup, edm::RunNumber_t iRun, edm::ParameterSet const &hPSet, edm::ParameterSet const &fPSet)
unsigned int RunNumber_t
bool isValid() const
Definition: ESHandle.h:44
void addAllDetectorsRawIds(std::vector< uint32_t > &vector_to_fill_with_detids) const
unsigned int tecWheel(const DetId &id) const
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
Definition: ESHandle.h:86
std::unique_ptr< TkHistoMap > Tk_HM_
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const