CMS 3D CMS Logo

SiStripFolderOrganizer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripCommon
4 // Class : SiStripFolderOrganizer
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: dkcira
10 // Created: Thu Jan 26 23:52:43 CET 2006
11 
12 //
13 
14 #include <iostream>
15 #include <sstream>
16 
18 
21 
23 
25 
27 #define CONTROL_FOLDER_NAME "ControlView"
28 #define MECHANICAL_FOLDER_NAME "MechanicalView"
29 #define SEP "/"
30 
31 #include <cstring>
32 
34  TopFolderName = "SiStrip";
35  // get a pointer to DQMStore
37 }
38 
40 
42 
44 
47  return;
48 }
49 
52  return lokal_folder;
53 }
54 
57  dbe_->setCurrentFolder(lokal_folder);
58  return;
59 }
60 
62  // unsigned short crate,
63  unsigned short slot,
64  unsigned short ring,
65  unsigned short addr,
66  unsigned short chan
67  // unsigned short i2c
68 ) {
69  std::stringstream lokal_folder;
70  lokal_folder << getSiStripTopControlFolder();
71  // if ( crate != all_ ) {// if ==all_ then remain in top control folder
72  // lokal_folder << SEP << "FecCrate" << crate;
73  if (slot != all_) {
74  lokal_folder << SEP << "FecSlot" << slot;
75  if (ring != all_) {
76  lokal_folder << SEP << "FecRing" << ring;
77  if (addr != all_) {
78  lokal_folder << SEP << "CcuAddr" << addr;
79  if (chan != all_) {
80  lokal_folder << SEP << "CcuChan" << chan;
81  // if ( i2c != all_ ) {
82  // lokal_folder << SEP << "I2cAddr" << i2c;
83  // }
84  }
85  }
86  }
87  }
88  // }
89  std::string folder_name = lokal_folder.str();
90  return folder_name;
91 }
92 
94  // unsigned short crate,
95  unsigned short slot,
96  unsigned short ring,
97  unsigned short addr,
98  unsigned short chan
99  // unsigned short i2c
100 ) {
102  dbe_->setCurrentFolder(lokal_folder);
103  return;
104 }
105 
106 std::pair<std::string, int32_t> SiStripFolderOrganizer::GetSubDetAndLayer(const uint32_t& detid,
107  const TrackerTopology* tTopo,
108  bool ring_flag) {
109  std::string cSubDet;
110  int32_t layer = 0;
111  switch (StripSubdetector::SubDetector(StripSubdetector(detid).subdetId())) {
113  cSubDet = "TIB";
114  layer = tTopo->tibLayer(detid);
115  break;
117  cSubDet = "TOB";
118  layer = tTopo->tobLayer(detid);
119  break;
121  cSubDet = "TID";
122  if (ring_flag)
123  layer = tTopo->tidRing(detid) * (tTopo->tidSide(detid) == 1 ? -1 : +1);
124  else
125  layer = tTopo->tidWheel(detid) * (tTopo->tidSide(detid) == 1 ? -1 : +1);
126  break;
128  cSubDet = "TEC";
129  if (ring_flag)
130  layer = tTopo->tecRing(detid) * (tTopo->tecSide(detid) == 1 ? -1 : +1);
131  else
132  layer = tTopo->tecWheel(detid) * (tTopo->tecSide(detid) == 1 ? -1 : +1);
133  break;
134  default:
135  edm::LogWarning("SiStripMonitorTrack") << "WARNING!!! this detid does not belong to tracker" << std::endl;
136  }
137  return std::make_pair(cSubDet, layer);
138 }
139 
140 std::pair<std::string, int32_t> SiStripFolderOrganizer::GetSubDetAndLayerThickness(const uint32_t& detid,
141  const TrackerTopology* tTopo,
142  std::string& cThickness) {
143  std::string cSubDet;
144  int32_t layer = 0;
145  int32_t ring = 0;
146  switch (StripSubdetector::SubDetector(StripSubdetector(detid).subdetId())) {
148  cSubDet = "TIB";
149  layer = tTopo->tibLayer(detid);
150  cThickness = "THIN";
151  break;
153  cSubDet = "TOB";
154  layer = tTopo->tobLayer(detid);
155  cThickness = "THICK";
156  break;
158  cSubDet = "TID";
159  layer = tTopo->tidWheel(detid) * (tTopo->tidSide(detid) == 1 ? -1 : +1);
160  cThickness = "THIN";
161  break;
163  cSubDet = "TEC";
164  layer = tTopo->tecWheel(detid) * (tTopo->tecSide(detid) == 1 ? -1 : +1);
165  ring = tTopo->tecRing(detid) * (tTopo->tecSide(detid) == 1 ? -1 : +1);
166  if (ring >= 1 && ring <= 4)
167  cThickness = "THIN";
168  else
169  cThickness = "THICK";
170  break;
171  default:
172  edm::LogWarning("SiStripMonitorTrack") << "WARNING!!! this detid does not belong to tracker" << std::endl;
173  }
174  return std::make_pair(cSubDet, layer);
175 }
176 
177 std::pair<std::string, int32_t> SiStripFolderOrganizer::GetSubDetAndRing(const uint32_t& detid,
178  const TrackerTopology* tTopo) {
179  std::string cSubDet;
180  int32_t ring = 0;
181  switch (StripSubdetector::SubDetector(StripSubdetector(detid).subdetId())) {
183  cSubDet = "TIB";
184  break;
186  cSubDet = "TOB";
187  break;
189  cSubDet = "TID";
190  ring = tTopo->tidRing(detid) * (tTopo->tidSide(detid) == 1 ? -1 : +1);
191  break;
193  cSubDet = "TEC";
194  ring = tTopo->tecRing(detid) * (tTopo->tecSide(detid) == 1 ? -1 : +1);
195  break;
196  default:
197  edm::LogWarning("SiStripMonitorTrack") << "WARNING!!! this detid does not belong to tracker" << std::endl;
198  }
199  return std::make_pair(cSubDet, ring);
200 }
201 
202 void SiStripFolderOrganizer::setDetectorFolder(uint32_t rawdetid, const TrackerTopology* tTopo) {
204  getFolderName(rawdetid, tTopo, folder_name);
206 }
207 
210  uint32_t layer,
211  uint32_t side) {
212  // std::cout << "[SiStripFolderOrganizer::getSubDetLayerFolderName] TopFolderName: " << TopFolderName << std::endl;
214 
215  std::stringstream sside;
216  if (side == 1) {
217  sside << "MINUS";
218  } else if (side == 2) {
219  sside << "PLUS";
220  }
221 
222  if (subDet == SiStripDetId::TIB) {
223  ss << SEP << "TIB" << SEP << "layer_" << layer << SEP;
224  } else if (subDet == SiStripDetId::TID) {
225  ss << SEP << "TID" << SEP << sside.str() << SEP << "wheel_" << layer << SEP;
226  } else if (subDet == SiStripDetId::TOB) {
227  ss << SEP << "TOB" << SEP << "layer_" << layer << SEP;
228  } else if (subDet == SiStripDetId::TEC) {
229  ss << SEP << "TEC" << SEP << sside.str() << SEP << "wheel_" << layer << SEP;
230  } else {
231  // --------------------------- ??? --------------------------- //
232  edm::LogWarning("SiStripTkDQM|WrongInput") << "no such SubDet :" << subDet << " no folder set!" << std::endl;
233  }
234 }
235 
236 void SiStripFolderOrganizer::getFolderName(int32_t rawdetid, const TrackerTopology* tTopo, std::string& lokal_folder) {
237  lokal_folder = "";
238  if (rawdetid == 0) { // just top MechanicalFolder if rawdetid==0;
239  return;
240  }
241  std::stringstream rest;
242  SiStripDetId stripdet = SiStripDetId(rawdetid);
243 
244  if (stripdet.subDetector() == SiStripDetId::TIB) {
245  // --------------------------- TIB --------------------------- //
246 
247  getSubDetLayerFolderName(rest, stripdet.subDetector(), tTopo->tibLayer(rawdetid));
248 
249  if (tTopo->tibIsZMinusSide(rawdetid))
250  rest << "backward_strings" << SEP;
251  else
252  rest << "forward_strings" << SEP;
253  if (tTopo->tibIsExternalString(rawdetid))
254  rest << "external_strings" << SEP;
255  else
256  rest << "internal_strings" << SEP;
257  rest << "string_" << tTopo->tibString(rawdetid) << SEP << "module_" << rawdetid;
258  } else if (stripdet.subDetector() == SiStripDetId::TID) {
259  // --------------------------- TID --------------------------- //
260 
261  getSubDetLayerFolderName(rest, stripdet.subDetector(), tTopo->tidWheel(rawdetid), tTopo->tidSide(rawdetid));
262  rest << "ring_" << tTopo->tidRing(rawdetid) << SEP;
263 
264  if (tTopo->tidIsStereo(rawdetid))
265  rest << "stereo_modules" << SEP;
266  else
267  rest << "mono_modules" << SEP;
268  rest << "module_" << rawdetid;
269  } else if (stripdet.subDetector() == SiStripDetId::TOB) {
270  // --------------------------- TOB --------------------------- //
271 
272  getSubDetLayerFolderName(rest, stripdet.subDetector(), tTopo->tobLayer(rawdetid));
273  if (tTopo->tobIsZMinusSide(rawdetid))
274  rest << "backward_rods" << SEP;
275  else
276  rest << "forward_rods" << SEP;
277  rest << "rod_" << tTopo->tobRod(rawdetid) << SEP << "module_" << rawdetid;
278  } else if (stripdet.subDetector() == SiStripDetId::TEC) {
279  // --------------------------- TEC --------------------------- //
280 
281  getSubDetLayerFolderName(rest, stripdet.subDetector(), tTopo->tecWheel(rawdetid), tTopo->tecSide(rawdetid));
282  if (tTopo->tecIsBackPetal(rawdetid))
283  rest << "backward_petals" << SEP;
284  else
285  rest << "forward_petals" << SEP;
286 
287  rest << "petal_" << tTopo->tecPetalNumber(rawdetid) << SEP << "ring_" << tTopo->tecRing(rawdetid) << SEP;
288 
289  if (tTopo->tecIsStereo(rawdetid))
290  rest << "stereo_modules" << SEP;
291  else
292  rest << "mono_modules" << SEP;
293 
294  rest << "module_" << rawdetid;
295  } else {
296  // --------------------------- ??? --------------------------- //
297  edm::LogWarning("SiStripTkDQM|WrongInput")
298  << "no such subdetector type :" << stripdet.subDetector() << " no folder set!" << std::endl;
299  return;
300  }
301  lokal_folder += rest.str();
302 }
303 
305  const TrackerTopology* tTopo,
306  int32_t layer,
307  bool ring_flag) {
309  if (rawdetid == 0) { // just top MechanicalFolder if rawdetid==0;
310  dbe_->setCurrentFolder(lokal_folder);
311  return;
312  }
313 
314  std::ostringstream rest;
315  SiStripDetId stripdet = SiStripDetId(rawdetid);
316  if (stripdet.subDetector() == SiStripDetId::TIB) {
317  // --------------------------- TIB --------------------------- //
318 
319  int tib_layer = tTopo->tibLayer(rawdetid);
320  if (abs(layer) != tib_layer) {
321  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")
322  << " expect " << abs(layer) << " but getting " << tTopo->tibLayer(rawdetid) << std::endl;
323  return;
324  }
325  rest << SEP << "TIB" << SEP << "layer_" << tTopo->tibLayer(rawdetid);
326  } else if (stripdet.subDetector() == SiStripDetId::TID) {
327  // --------------------------- TID --------------------------- //
328 
329  int tid_ring = tTopo->tidRing(rawdetid);
330 
331  // side
332  uint32_t side = tTopo->tidSide(rawdetid);
333  std::stringstream sside;
334  if (side == 1) {
335  sside << "MINUS";
336  } else if (side == 2) {
337  sside << "PLUS";
338  }
339 
340  if (ring_flag) {
341  if (abs(layer) != tid_ring) {
342  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")
343  << " expect " << abs(layer) << " but getting " << tTopo->tidRing(rawdetid) << std::endl;
344  return;
345  }
346  rest << SEP << "TID" << SEP << sside.str() << SEP << "ring_" << tTopo->tidRing(rawdetid);
347  } else {
348  int tid_wheel = tTopo->tidWheel(rawdetid);
349  if (abs(layer) != tid_wheel) {
350  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")
351  << " expect " << abs(layer) << " but getting " << tTopo->tidWheel(rawdetid) << std::endl;
352  return;
353  }
354  rest << SEP << "TID" << SEP << sside.str() << SEP << "wheel_" << tTopo->tidWheel(rawdetid);
355  }
356  } else if (stripdet.subDetector() == SiStripDetId::TOB) {
357  // --------------------------- TOB --------------------------- //
358 
359  int tob_layer = tTopo->tobLayer(rawdetid);
360  if (abs(layer) != tob_layer) {
361  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")
362  << " expect " << abs(layer) << " but getting " << tTopo->tobLayer(rawdetid) << std::endl;
363  return;
364  }
365  rest << SEP << "TOB" << SEP << "layer_" << tTopo->tobLayer(rawdetid);
366  } else if (stripdet.subDetector() == SiStripDetId::TEC) {
367  // --------------------------- TEC --------------------------- //
368 
369  // side
370  uint32_t side = tTopo->tecSide(rawdetid);
371  std::stringstream sside;
372  if (side == 1) {
373  sside << "MINUS";
374  } else if (side == 2) {
375  sside << "PLUS";
376  }
377 
378  if (ring_flag) {
379  int tec_ring = tTopo->tecRing(rawdetid);
380  if (abs(layer) != tec_ring) {
381  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")
382  << " expect " << abs(layer) << " but getting " << tTopo->tecRing(rawdetid) << std::endl;
383  return;
384  }
385  rest << SEP << "TEC" << SEP << sside.str() << SEP << "ring_" << tTopo->tecRing(rawdetid);
386  } else {
387  int tec_wheel = tTopo->tecWheel(rawdetid);
388  if (abs(layer) != tec_wheel) {
389  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")
390  << " expect " << abs(layer) << " but getting " << tTopo->tecWheel(rawdetid) << std::endl;
391  return;
392  }
393  rest << SEP << "TEC" << SEP << sside.str() << SEP << "wheel_" << tTopo->tecWheel(rawdetid);
394  }
395  } else {
396  // --------------------------- ??? --------------------------- //
397  edm::LogWarning("SiStripTkDQM|WrongInput")
398  << "no such subdetector type :" << stripdet.subDetector() << " no folder set!" << std::endl;
399  return;
400  }
401 
402  lokal_folder += rest.str();
403  dbe_->setCurrentFolder(lokal_folder);
404 }
405 
406 void SiStripFolderOrganizer::getSubDetFolder(const uint32_t& detid,
407  const TrackerTopology* tTopo,
409  std::pair<std::string, std::string> subdet_and_tag = getSubDetFolderAndTag(detid, tTopo);
410  folder_name = subdet_and_tag.first;
411 }
412 //
413 // -- Get the name of Subdetector Layer folder
414 //
416  uint32_t rawdetid,
417  const TrackerTopology* tTopo,
418  bool ring_flag) {
420  if (rawdetid == 0) { // just top MechanicalFolder if rawdetid==0;
421  return;
422  }
423 
424  SiStripDetId stripdet = SiStripDetId(rawdetid);
425  if (stripdet.subDetector() == SiStripDetId::TIB) {
426  // --------------------------- TIB --------------------------- //
427 
428  ss << SEP << "TIB" << SEP << "layer_" << tTopo->tibLayer(rawdetid);
429  } else if (stripdet.subDetector() == SiStripDetId::TID) {
430  // --------------------------- TID --------------------------- //
431 
432  uint32_t side = tTopo->tidSide(rawdetid);
433  std::stringstream sside;
434  if (side == 1) {
435  sside << "MINUS";
436  } else if (side == 2) {
437  sside << "PLUS";
438  }
439 
440  if (ring_flag) {
441  ss << SEP << "TID" << SEP << sside.str() << SEP << "ring_" << tTopo->tidRing(rawdetid);
442  } else {
443  ss << SEP << "TID" << SEP << sside.str() << SEP << "wheel_" << tTopo->tidWheel(rawdetid);
444  }
445  } else if (stripdet.subDetector() == SiStripDetId::TOB) {
446  // --------------------------- TOB --------------------------- //
447 
448  ss << SEP << "TOB" << SEP << "layer_" << tTopo->tobLayer(rawdetid);
449  } else if (stripdet.subDetector() == SiStripDetId::TEC) {
450  // --------------------------- TEC --------------------------- //
451 
452  uint32_t side = tTopo->tecSide(rawdetid);
453  std::stringstream sside;
454  if (side == 1) {
455  sside << "MINUS";
456  } else if (side == 2) {
457  sside << "PLUS";
458  }
459 
460  if (ring_flag) {
461  ss << SEP << "TEC" << SEP << sside.str() << SEP << "ring_" << tTopo->tecRing(rawdetid);
462  } else {
463  ss << SEP << "TEC" << SEP << sside.str() << SEP << "wheel_" << tTopo->tecWheel(rawdetid);
464  }
465  } else {
466  // --------------------------- ??? --------------------------- //
467  edm::LogWarning("SiStripTkDQM|WrongInput")
468  << "no such subdetector type :" << stripdet.subDetector() << " no folder set!" << std::endl;
469  return;
470  }
471 }
472 //
473 // -- Get Subdetector Folder name and the Tag
474 //
475 std::pair<const std::string, const char*> SiStripFolderOrganizer::getSubDetFolderAndTag(const uint32_t& detid,
476  const TrackerTopology* tTopo) {
477  const char* subdet_folder = "";
478  const char* tag = "";
479  switch (StripSubdetector::SubDetector(StripSubdetector(detid).subdetId())) {
481  subdet_folder = "TIB";
482  tag = subdet_folder;
483  break;
485  subdet_folder = "TOB";
486  tag = subdet_folder;
487  break;
489  if (tTopo->tidSide(detid) == 2) {
490  subdet_folder = "TID/PLUS";
491  tag = "TID__PLUS";
492  } else if (tTopo->tidSide(detid) == 1) {
493  subdet_folder = "TID/MINUS";
494  tag = "TID__MINUS";
495  }
496  break;
498  if (tTopo->tecSide(detid) == 2) {
499  subdet_folder = "TEC/PLUS";
500  tag = "TEC__PLUS";
501  } else if (tTopo->tecSide(detid) == 1) {
502  subdet_folder = "TEC/MINUS";
503  tag = "TEC__MINUS";
504  }
505  break;
506  default: {
507  edm::LogWarning("SiStripCommon") << "WARNING!!! this detid does not belong to tracker" << std::endl;
508  subdet_folder = "";
509  }
510  }
511 
513  folder.reserve(TopFolderName.size() + strlen(SEP MECHANICAL_FOLDER_NAME SEP) + strlen(subdet_folder) + 1);
514  folder = TopFolderName + SEP MECHANICAL_FOLDER_NAME SEP + subdet_folder;
515 
516  return std::pair<const std::string, const char*>(folder, tag);
517 }
void setSiStripControlFolder(unsigned short slot=all_, unsigned short ring=all_, unsigned short addr=all_, unsigned short chan=all_)
unsigned int tecPetalNumber(const DetId &id) const
static constexpr auto TEC
unsigned int tobLayer(const DetId &id) const
void setSiStripFolderName(std::string name)
void getSubDetFolder(const uint32_t &detid, const TrackerTopology *tTopo, std::string &folder_name)
bool tobIsZMinusSide(const DetId &id) const
std::pair< const std::string, const char * > getSubDetFolderAndTag(const uint32_t &detid, const TrackerTopology *tTopo)
std::string getSiStripTopControlFolder()
static constexpr auto TID
Definition: SiStripDetId.h:38
unsigned int tidSide(const DetId &id) const
#define CONTROL_FOLDER_NAME
bool tibIsExternalString(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
bool tibIsZMinusSide(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:656
unsigned int tibString(const DetId &id) const
SubDetector subDetector() const
Definition: SiStripDetId.h:105
void getLayerFolderName(std::stringstream &ss, uint32_t rawdetid, const TrackerTopology *tTopo, bool ring_flag=false)
void setLayerFolder(uint32_t rawdetid, const TrackerTopology *tTopo, int32_t layer=0, bool ring_flag=false)
std::pair< std::string, int32_t > GetSubDetAndRing(const uint32_t &detid, const TrackerTopology *tTopo)
unsigned int tecRing(const DetId &id) const
ring id
void setDetectorFolder(uint32_t rawdetid, const TrackerTopology *tTopo)
void getSubDetLayerFolderName(std::stringstream &ss, SiStripDetId::SubDetector subDet, uint32_t layer, uint32_t side=0)
std::string getSiStripControlFolder(unsigned short slot=all_, unsigned short ring=all_, unsigned short addr=all_, unsigned short chan=all_)
unsigned int tecSide(const DetId &id) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static unsigned short const all_
static constexpr auto TOB
static constexpr auto TOB
Definition: SiStripDetId.h:39
std::pair< std::string, int32_t > GetSubDetAndLayerThickness(const uint32_t &detid, const TrackerTopology *tTopo, std::string &cThickness)
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:18
bool tecIsBackPetal(const DetId &id) const
#define SEP
static constexpr auto TIB
bool tecIsStereo(const DetId &id) const
unsigned int tobRod(const DetId &id) const
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
static constexpr auto TIB
Definition: SiStripDetId.h:37
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, const TrackerTopology *tTopo, bool ring_flag=false)
bool tidIsStereo(const DetId &id) const
void getFolderName(int32_t rawdetid, const TrackerTopology *tTopo, std::string &lokal_folder)
unsigned int tidRing(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
Log< level::Warning, false > LogWarning
static constexpr auto TID
static constexpr auto TEC
Definition: SiStripDetId.h:40
#define MECHANICAL_FOLDER_NAME