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 // $Id: SiStripFolderOrganizer.cc,v 1.32 2013/01/03 18:59:35 wmtan Exp $
13 //
14 
15 #include <iostream>
16 #include <sstream>
17 
19 
23 
25 
27 
29 #define CONTROL_FOLDER_NAME "ControlView"
30 #define MECHANICAL_FOLDER_NAME "MechanicalView"
31 #define SEP "/"
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 
153 void SiStripFolderOrganizer::setDetectorFolder(uint32_t rawdetid, const TrackerTopology* tTopo){
154  std::string folder_name;
155  getFolderName(rawdetid, tTopo, folder_name);
156  dbe_->setCurrentFolder(folder_name);
157 }
158 
159 void SiStripFolderOrganizer::getSubDetLayerFolderName(std::stringstream& ss, SiStripDetId::SubDetector subDet, uint32_t layer, uint32_t side){
161 
162  if(subDet == SiStripDetId::TIB){
163  ss << SEP << "TIB" << SEP << "layer_" << layer << SEP;
164  } else if(subDet == SiStripDetId::TID){
165  ss << SEP << "TID" << SEP << "side_" << side << SEP << "wheel_" << layer << SEP;
166  } else if( subDet == SiStripDetId::TOB){
167  ss << SEP << "TOB" << SEP << "layer_" << layer << SEP;
168  }else if(subDet == SiStripDetId::TEC){
169  ss << SEP << "TEC" << SEP << "side_" << side << SEP << "wheel_" << layer << SEP;
170  }else{
171  // --------------------------- ??? --------------------------- //
172  edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such SubDet :"<< subDet <<" no folder set!"<<std::endl;
173  }
174 }
175 
176 
177 void SiStripFolderOrganizer::getFolderName(int32_t rawdetid, const TrackerTopology* tTopo, std::string& lokal_folder){
178  lokal_folder = "";
179  if(rawdetid == 0 ){ // just top MechanicalFolder if rawdetid==0;
180  return;
181  }
182  std::stringstream rest;
183  SiStripDetId stripdet = SiStripDetId(rawdetid);
184 
185  if (stripdet.subDetector() == SiStripDetId::TIB){
186  // --------------------------- TIB --------------------------- //
187 
188  getSubDetLayerFolderName(rest,stripdet.subDetector(),tTopo->tibLayer(rawdetid));
189 
190  if (tTopo->tibIsZMinusSide(rawdetid)) rest << "backward_strings" << SEP;
191  else rest << "forward_strings" << SEP;
192  if (tTopo->tibIsExternalString(rawdetid)) rest << "external_strings" << SEP;
193  else rest << "internal_strings" << SEP;
194  rest << "string_" << tTopo->tibString(rawdetid) << SEP << "module_" << rawdetid;
195  } else if(stripdet.subDetector() == SiStripDetId::TID){
196  // --------------------------- TID --------------------------- //
197 
198  getSubDetLayerFolderName(rest,stripdet.subDetector(),tTopo->tidWheel(rawdetid),tTopo->tidSide(rawdetid));
199  rest<< "ring_" << tTopo->tidRing(rawdetid) << SEP;
200 
201  if (tTopo->tidIsStereo(rawdetid)) rest << "stereo_modules" << SEP;
202  else rest << "mono_modules" << SEP;
203  rest << "module_" << rawdetid;
204  } else if( stripdet.subDetector() == SiStripDetId::TOB){
205  // --------------------------- TOB --------------------------- //
206 
207  getSubDetLayerFolderName(rest,stripdet.subDetector(),tTopo->tobLayer(rawdetid));
208  if (tTopo->tobIsZMinusSide(rawdetid)) rest << "backward_rods" << SEP;
209  else rest << "forward_rods" << SEP;
210  rest << "rod_" << tTopo->tobRod(rawdetid) << SEP<< "module_" << rawdetid;
211  }else if(stripdet.subDetector() == SiStripDetId::TEC){
212  // --------------------------- TEC --------------------------- //
213 
214  getSubDetLayerFolderName(rest,stripdet.subDetector(),tTopo->tecWheel(rawdetid),tTopo->tecSide(rawdetid));
215  if (tTopo->tecIsBackPetal(rawdetid)) rest << "backward_petals" << SEP;
216  else rest << "forward_petals" << SEP;
217 
218  rest << "petal_" << tTopo->tecPetalNumber(rawdetid) << SEP
219  << "ring_"<< tTopo->tecRing(rawdetid) << SEP;
220 
221  if (tTopo->tecIsStereo(rawdetid)) rest << "stereo_modules" << SEP;
222  else rest << "mono_modules" << SEP;
223 
224  rest << "module_" << rawdetid;
225  }else{
226  // --------------------------- ??? --------------------------- //
227  edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<stripdet.subDetector() <<" no folder set!"<<std::endl;
228  return;
229  }
230  lokal_folder += rest.str();
231 
232 }
233 
234 void SiStripFolderOrganizer::setLayerFolder(uint32_t rawdetid, const TrackerTopology* tTopo, int32_t layer, bool ring_flag){
236  if(rawdetid == 0 ){ // just top MechanicalFolder if rawdetid==0;
237  dbe_->setCurrentFolder(lokal_folder);
238  return;
239  }
240 
241  std::ostringstream rest;
242  SiStripDetId stripdet = SiStripDetId(rawdetid);
243  if(stripdet.subDetector() == SiStripDetId::TIB ){
244  // --------------------------- TIB --------------------------- //
245 
246  int tib_layer = tTopo->tibLayer(rawdetid);
247  if (abs(layer) != tib_layer) {
248  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tTopo->tibLayer(rawdetid) <<std::endl;
249  return;
250  }
251  rest<<SEP<<"TIB"<<SEP<<"layer_"<<tTopo->tibLayer(rawdetid);
252  }else if(stripdet.subDetector() == SiStripDetId::TID){
253  // --------------------------- TID --------------------------- //
254 
255  int tid_ring = tTopo->tidRing(rawdetid);
256  if(ring_flag){
257  if(abs(layer) != tid_ring) {
258  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tTopo->tidRing(rawdetid) <<std::endl;
259  return;
260  }
261  rest<<SEP<<"TID"<<SEP<<"side_"<<tTopo->tidSide(rawdetid)<<SEP<<"ring_"<<tTopo->tidRing(rawdetid);
262  }else{
263  int tid_wheel = tTopo->tidWheel(rawdetid);
264  if (abs(layer) != tid_wheel) {
265  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tTopo->tidWheel(rawdetid) <<std::endl;
266  return;
267  }
268  rest<<SEP<<"TID"<<SEP<<"side_"<<tTopo->tidSide(rawdetid)<<SEP<<"wheel_"<<tTopo->tidWheel(rawdetid);
269  }
270  }else if(stripdet.subDetector() == SiStripDetId::TOB){
271  // --------------------------- TOB --------------------------- //
272 
273  int tob_layer = tTopo->tobLayer(rawdetid);
274  if (abs(layer) != tob_layer) {
275  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tTopo->tobLayer(rawdetid) <<std::endl;
276  return;
277  }
278  rest<<SEP<<"TOB"<<SEP<<"layer_"<<tTopo->tobLayer(rawdetid);
279  }else if( stripdet.subDetector() == SiStripDetId::TEC){
280  // --------------------------- TEC --------------------------- //
281 
282  if(ring_flag){
283  int tec_ring = tTopo->tecRing(rawdetid);
284  if (abs(layer) != tec_ring) {
285  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tTopo->tecRing(rawdetid) <<std::endl;
286  return;
287  }
288  rest<<SEP<<"TEC"<<SEP<<"side_"<<tTopo->tecSide(rawdetid)<<SEP<<"ring_"<<tTopo->tecRing(rawdetid);
289  }else{
290  int tec_wheel = tTopo->tecWheel(rawdetid);
291  if (abs(layer) != tec_wheel) {
292  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tTopo->tecWheel(rawdetid) <<std::endl;
293  return;
294  }
295  rest<<SEP<<"TEC"<<SEP<<"side_"<<tTopo->tecSide(rawdetid)<<SEP<<"wheel_"<<tTopo->tecWheel(rawdetid);
296  }
297  }else{
298  // --------------------------- ??? --------------------------- //
299  edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<stripdet.subDetector()<<" no folder set!"<<std::endl;
300  return;
301  }
302 
303  lokal_folder += rest.str();
304  dbe_->setCurrentFolder(lokal_folder);
305 }
306 
307 void SiStripFolderOrganizer::getSubDetFolder(const uint32_t& detid, const TrackerTopology* tTopo, std::string& folder_name){
308 
309  std::pair<std::string, std::string> subdet_and_tag = getSubDetFolderAndTag(detid, tTopo);
310  folder_name = subdet_and_tag.first;
311 }
312 //
313 // -- Get the name of Subdetector Layer folder
314 //
315 void SiStripFolderOrganizer::getLayerFolderName(std::stringstream& ss, uint32_t rawdetid, const TrackerTopology* tTopo, bool ring_flag){
317  if(rawdetid == 0 ){ // just top MechanicalFolder if rawdetid==0;
318  return;
319  }
320 
321  SiStripDetId stripdet = SiStripDetId(rawdetid);
322  if(stripdet.subDetector() == SiStripDetId::TIB ){
323  // --------------------------- TIB --------------------------- //
324 
325  ss<<SEP<<"TIB"<<SEP<<"layer_"<<tTopo->tibLayer(rawdetid);
326  }else if(stripdet.subDetector() == SiStripDetId::TID){
327  // --------------------------- TID --------------------------- //
328 
329  if(ring_flag){
330  ss<<SEP<<"TID"<<SEP<<"side_"<<tTopo->tidSide(rawdetid)<<SEP<<"ring_"<<tTopo->tidRing(rawdetid);
331  }else{
332  ss<<SEP<<"TID"<<SEP<<"side_"<<tTopo->tidSide(rawdetid)<<SEP<<"wheel_"<<tTopo->tidWheel(rawdetid);
333  }
334  }else if(stripdet.subDetector() == SiStripDetId::TOB){
335  // --------------------------- TOB --------------------------- //
336 
337  ss<<SEP<<"TOB"<<SEP<<"layer_"<<tTopo->tobLayer(rawdetid);
338  }else if( stripdet.subDetector() == SiStripDetId::TEC){
339  // --------------------------- TEC --------------------------- //
340 
341  if(ring_flag){
342  ss<<SEP<<"TEC"<<SEP<<"side_"<<tTopo->tecSide(rawdetid)<<SEP<<"ring_"<<tTopo->tecRing(rawdetid);
343  }else{
344  ss<<SEP<<"TEC"<<SEP<<"side_"<<tTopo->tecSide(rawdetid)<<SEP<<"wheel_"<<tTopo->tecWheel(rawdetid);
345  }
346  }else{
347  // --------------------------- ??? --------------------------- //
348  edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<stripdet.subDetector()<<" no folder set!"<<std::endl;
349  return;
350  }
351 }
352 //
353 // -- Get Subdetector Folder name and the Tag
354 //
355 std::pair<std::string, std::string> SiStripFolderOrganizer::getSubDetFolderAndTag(const uint32_t& detid, const TrackerTopology* tTopo) {
356  std::pair<std::string, std::string> result;
357  result.first = TopFolderName + SEP MECHANICAL_FOLDER_NAME SEP;
358  std::string subdet_folder;
359  switch(StripSubdetector::SubDetector(StripSubdetector(detid).subdetId()))
360  {
362  subdet_folder = "TIB";
363  result.second = subdet_folder;
364  break;
366  subdet_folder = "TOB";
367  result.second = subdet_folder;
368  break;
370  if (tTopo->tidSide(detid) == 2) {
371  subdet_folder = "TID/side_2";
372  result.second = "TID__side__2";
373  } else if (tTopo->tidSide(detid) == 1) {
374  subdet_folder = "TID/side_1";
375  result.second = "TID__side__1";
376  }
377  break;
379  if (tTopo->tecSide(detid) == 2) {
380  subdet_folder = "TEC/side_2";
381  result.second = "TEC__side__2";
382  } else if (tTopo->tecSide(detid) == 1) {
383  subdet_folder = "TEC/side_1";
384  result.second = "TEC__side__1";
385  }
386  break;
387  default:
388  {
389  edm::LogWarning("SiStripCommon") << "WARNING!!! this detid does not belong to tracker" << std::endl;
390  subdet_folder = "";
391  }
392  }
393  result.first += subdet_folder;
394  return result;
395 }
396 
397 
398 // This is the deprecated version, still needed for now.
403 
404 void SiStripFolderOrganizer::getFolderName(int32_t rawdetid, std::string& lokal_folder){
405  lokal_folder = "";
406  if(rawdetid == 0 ){ // just top MechanicalFolder if rawdetid==0;
407  return;
408  }
409  std::stringstream rest;
410  SiStripDetId stripdet = SiStripDetId(rawdetid);
411 
412  if (stripdet.subDetector() == SiStripDetId::TIB){
413  // --------------------------- TIB --------------------------- //
414  TIBDetId tib = TIBDetId(rawdetid);
415  getSubDetLayerFolderName(rest,stripdet.subDetector(),tib.layerNumber());
416  if (tib.isZMinusSide()) rest << "backward_strings" << SEP;
417  else rest << "forward_strings" << SEP;
418  if (tib.isExternalString()) rest << "external_strings" << SEP;
419  else rest << "internal_strings" << SEP;
420  rest << "string_" << tib.stringNumber() << SEP << "module_" << rawdetid;
421  } else if(stripdet.subDetector() == SiStripDetId::TID){
422  // --------------------------- TID --------------------------- //
423  TIDDetId tid = TIDDetId(rawdetid);
424  getSubDetLayerFolderName(rest,stripdet.subDetector(),tid.wheel(),tid.side());
425  rest<< "ring_" << tid.ring() << SEP;
426 
427  if (tid.isStereo()) rest << "stereo_modules" << SEP;
428  else rest << "mono_modules" << SEP;
429  rest << "module_" << rawdetid;
430  } else if( stripdet.subDetector() == SiStripDetId::TOB){
431  // --------------------------- TOB --------------------------- //
432  TOBDetId tob = TOBDetId(rawdetid);
433  getSubDetLayerFolderName(rest,stripdet.subDetector(),tob.layerNumber());
434  if (tob.isZMinusSide()) rest << "backward_rods" << SEP;
435  else rest << "forward_rods" << SEP;
436  rest << "rod_" << tob.rodNumber() << SEP<< "module_" << rawdetid;
437  }else if(stripdet.subDetector() == SiStripDetId::TEC){
438  // --------------------------- TEC --------------------------- //
439  TECDetId tec = TECDetId(rawdetid);
440  getSubDetLayerFolderName(rest,stripdet.subDetector(),tec.wheel(),tec.side());
441  if (tec.isBackPetal()) rest << "backward_petals" << SEP;
442  else rest << "forward_petals" << SEP;
443 
444  rest << "petal_" << tec.petalNumber() << SEP
445  << "ring_"<< tec.ringNumber() << SEP;
446 
447  if (tec.isStereo()) rest << "stereo_modules" << SEP;
448  else rest << "mono_modules" << SEP;
449 
450  rest << "module_" << rawdetid;
451  }else{
452  // --------------------------- ??? --------------------------- //
453  edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such subdetector type :"<<stripdet.subDetector() <<" no folder set!"<<std::endl;
454  return;
455  }
456  lokal_folder += rest.str();
457 }
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)
#define abs(x)
Definition: mlp_lapack.h:159
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
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:434
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