CMS 3D CMS Logo

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