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