CMS 3D CMS Logo

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