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.30 2011/05/31 10:38:46 eulisse Exp $
13 //
14 
15 #include <iostream>
16 #include <sstream>
17 
19 
24 
26 
28 
30 #define CONTROL_FOLDER_NAME "ControlView"
31 #define MECHANICAL_FOLDER_NAME "MechanicalView"
32 #define SEP "/"
33 
35 {
36  TopFolderName="SiStrip";
37  // get a pointer to DQMStore
39 }
40 
41 
43 {
44 }
45 
48 }
49 
51  return TopFolderName;
52 }
53 
54 
57  return;
58 }
59 
60 
62  std::string lokal_folder = TopFolderName + CONTROL_FOLDER_NAME;
63  return lokal_folder;
64 }
65 
66 
68  std::string lokal_folder = TopFolderName + CONTROL_FOLDER_NAME;
69  dbe_->setCurrentFolder(lokal_folder);
70  return;
71 }
72 
73 
75  // unsigned short crate,
76  unsigned short slot,
77  unsigned short ring,
78  unsigned short addr,
79  unsigned short chan
80  // unsigned short i2c
81  ) {
82  std::stringstream lokal_folder;
83  lokal_folder << getSiStripTopControlFolder();
84  // if ( crate != all_ ) {// if ==all_ then remain in top control folder
85  // lokal_folder << SEP << "FecCrate" << crate;
86  if ( slot != all_ ) {
87  lokal_folder << SEP << "FecSlot" << slot;
88  if ( ring != all_ ) {
89  lokal_folder << SEP << "FecRing" << ring;
90  if ( addr != all_ ) {
91  lokal_folder << SEP << "CcuAddr" << addr;
92  if ( chan != all_ ) {
93  lokal_folder << SEP << "CcuChan" << chan;
94  // if ( i2c != all_ ) {
95  // lokal_folder << SEP << "I2cAddr" << i2c;
96  // }
97  }
98  }
99  }
100  }
101  // }
102  std::string folder_name = lokal_folder.str();
103  return folder_name;
104 }
105 
106 
108  // unsigned short crate,
109  unsigned short slot,
110  unsigned short ring,
111  unsigned short addr,
112  unsigned short chan
113  // unsigned short i2c
114  ) {
115  std::string lokal_folder = getSiStripControlFolder(slot, ring, addr, chan);
116  dbe_->setCurrentFolder(lokal_folder);
117  return;
118 }
119 
120 std::pair<std::string,int32_t> SiStripFolderOrganizer::GetSubDetAndLayer(const uint32_t& detid, bool ring_flag){
121  std::string cSubDet;
122  int32_t layer=0;
123  switch(StripSubdetector::SubDetector(StripSubdetector(detid).subdetId()))
124  {
126  cSubDet="TIB";
127  layer=TIBDetId(detid).layer();
128  break;
130  cSubDet="TOB";
131  layer=TOBDetId(detid).layer();
132  break;
134  cSubDet="TID";
135  if(ring_flag)
136  layer=TIDDetId(detid).ring() * ( TIDDetId(detid).side()==1 ? -1 : +1);
137  else
138  layer=TIDDetId(detid).wheel() * ( TIDDetId(detid).side()==1 ? -1 : +1);
139  break;
141  cSubDet="TEC";
142  if(ring_flag)
143  layer=TECDetId(detid).ring() * ( TECDetId(detid).side()==1 ? -1 : +1);
144  else
145  layer=TECDetId(detid).wheel() * ( TECDetId(detid).side()==1 ? -1 : +1);
146  break;
147  default:
148  edm::LogWarning("SiStripMonitorTrack") << "WARNING!!! this detid does not belong to tracker" << std::endl;
149  }
150  return std::make_pair(cSubDet,layer);
151 }
152 
153 
155  std::string folder_name;
156  getFolderName(rawdetid, folder_name);
157  dbe_->setCurrentFolder(folder_name);
158 }
159 
160 void SiStripFolderOrganizer::getSubDetLayerFolderName(std::stringstream& ss, SiStripDetId::SubDetector subDet, uint32_t layer, uint32_t side){
162 
163  if(subDet == SiStripDetId::TIB){
164  ss << SEP << "TIB" << SEP << "layer_" << layer << SEP;
165  } else if(subDet == SiStripDetId::TID){
166  ss << SEP << "TID" << SEP << "side_" << side << SEP << "wheel_" << layer << SEP;
167  } else if( subDet == SiStripDetId::TOB){
168  ss << SEP << "TOB" << SEP << "layer_" << layer << SEP;
169  }else if(subDet == SiStripDetId::TEC){
170  ss << SEP << "TEC" << SEP << "side_" << side << SEP << "wheel_" << layer << SEP;
171  }else{
172  // --------------------------- ??? --------------------------- //
173  edm::LogWarning("SiStripTkDQM|WrongInput")<<"no such SubDet :"<< subDet <<" no folder set!"<<std::endl;
174  }
175 }
176 
177 
178 void SiStripFolderOrganizer::getFolderName(int32_t rawdetid, std::string& lokal_folder){
179  lokal_folder = "";
180  if(rawdetid == 0 ){ // just top MechanicalFolder if rawdetid==0;
181  return;
182  }
183  std::stringstream rest;
184  SiStripDetId stripdet = SiStripDetId(rawdetid);
185 
186  if (stripdet.subDetector() == SiStripDetId::TIB){
187  // --------------------------- TIB --------------------------- //
188  TIBDetId tib = TIBDetId(rawdetid);
189  getSubDetLayerFolderName(rest,stripdet.subDetector(),tib.layerNumber());
190  if (tib.isZMinusSide()) rest << "backward_strings" << SEP;
191  else rest << "forward_strings" << SEP;
192  if (tib.isExternalString()) rest << "external_strings" << SEP;
193  else rest << "internal_strings" << SEP;
194  rest << "string_" << tib.stringNumber() << SEP << "module_" << rawdetid;
195  } else if(stripdet.subDetector() == SiStripDetId::TID){
196  // --------------------------- TID --------------------------- //
197  TIDDetId tid = TIDDetId(rawdetid);
198  getSubDetLayerFolderName(rest,stripdet.subDetector(),tid.wheel(),tid.side());
199  rest<< "ring_" << tid.ring() << SEP;
200 
201  if (tid.isStereo()) rest << "stereo_modules" << SEP;
202  else rest << "mono_modules" << SEP;
203  rest << "module_" << rawdetid;
204  } else if( stripdet.subDetector() == SiStripDetId::TOB){
205  // --------------------------- TOB --------------------------- //
206  TOBDetId tob = TOBDetId(rawdetid);
207  getSubDetLayerFolderName(rest,stripdet.subDetector(),tob.layerNumber());
208  if (tob.isZMinusSide()) rest << "backward_rods" << SEP;
209  else rest << "forward_rods" << SEP;
210  rest << "rod_" << tob.rodNumber() << SEP<< "module_" << rawdetid;
211  }else if(stripdet.subDetector() == SiStripDetId::TEC){
212  // --------------------------- TEC --------------------------- //
213  TECDetId tec = TECDetId(rawdetid);
214  getSubDetLayerFolderName(rest,stripdet.subDetector(),tec.wheel(),tec.side());
215  if (tec.isBackPetal()) rest << "backward_petals" << SEP;
216  else rest << "forward_petals" << SEP;
217 
218  rest << "petal_" << tec.petalNumber() << SEP
219  << "ring_"<< tec.ringNumber() << SEP;
220 
221  if (tec.isStereo()) 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, int32_t layer, bool ring_flag){
235  std::string lokal_folder = TopFolderName + SEP + MECHANICAL_FOLDER_NAME;
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  TIBDetId tib1 = TIBDetId(rawdetid);
246  int tib_layer = tib1.layer();
247  if (abs(layer) != tib_layer) {
248  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tib1.layer() <<std::endl;
249  return;
250  }
251  rest<<SEP<<"TIB"<<SEP<<"layer_"<<tib1.layer();
252  }else if(stripdet.subDetector() == SiStripDetId::TID){
253  // --------------------------- TID --------------------------- //
254  TIDDetId tid1 = TIDDetId(rawdetid);
255  int tid_ring = tid1.ring();
256  if(ring_flag){
257  if(abs(layer) != tid_ring) {
258  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tid1.ring() <<std::endl;
259  return;
260  }
261  rest<<SEP<<"TID"<<SEP<<"side_"<<tid1.side()<<SEP<<"ring_"<<tid1.ring();
262  }else{
263  int tid_wheel = tid1.wheel();
264  if (abs(layer) != tid_wheel) {
265  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tid1.wheel() <<std::endl;
266  return;
267  }
268  rest<<SEP<<"TID"<<SEP<<"side_"<<tid1.side()<<SEP<<"wheel_"<<tid1.wheel();
269  }
270  }else if(stripdet.subDetector() == SiStripDetId::TOB){
271  // --------------------------- TOB --------------------------- //
272  TOBDetId tob1 = TOBDetId(rawdetid);
273  int tob_layer = tob1.layer();
274  if (abs(layer) != tob_layer) {
275  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tob1.layer() <<std::endl;
276  return;
277  }
278  rest<<SEP<<"TOB"<<SEP<<"layer_"<<tob1.layer();
279  }else if( stripdet.subDetector() == SiStripDetId::TEC){
280  // --------------------------- TEC --------------------------- //
281  TECDetId tec1 = TECDetId(rawdetid);
282  if(ring_flag){
283  int tec_ring = tec1.ring();
284  if (abs(layer) != tec_ring) {
285  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tec1.ring() <<std::endl;
286  return;
287  }
288  rest<<SEP<<"TEC"<<SEP<<"side_"<<tec1.side()<<SEP<<"ring_"<<tec1.ring();
289  }else{
290  int tec_wheel = tec1.wheel();
291  if (abs(layer) != tec_wheel) {
292  edm::LogWarning("SiStripTkDQM|Layer mismatch!!!")<< " expect "<< abs(layer) << " but getting " << tec1.wheel() <<std::endl;
293  return;
294  }
295  rest<<SEP<<"TEC"<<SEP<<"side_"<<tec1.side()<<SEP<<"wheel_"<<tec1.wheel();
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, std::string& folder_name){
308 
309  std::pair<std::string, std::string> subdet_and_tag = getSubDetFolderAndTag(detid);
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,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  TIBDetId tib1 = TIBDetId(rawdetid);
325  ss<<SEP<<"TIB"<<SEP<<"layer_"<<tib1.layer();
326  }else if(stripdet.subDetector() == SiStripDetId::TID){
327  // --------------------------- TID --------------------------- //
328  TIDDetId tid1 = TIDDetId(rawdetid);
329  if(ring_flag){
330  ss<<SEP<<"TID"<<SEP<<"side_"<<tid1.side()<<SEP<<"ring_"<<tid1.ring();
331  }else{
332  ss<<SEP<<"TID"<<SEP<<"side_"<<tid1.side()<<SEP<<"wheel_"<<tid1.wheel();
333  }
334  }else if(stripdet.subDetector() == SiStripDetId::TOB){
335  // --------------------------- TOB --------------------------- //
336  TOBDetId tob1 = TOBDetId(rawdetid);
337  ss<<SEP<<"TOB"<<SEP<<"layer_"<<tob1.layer();
338  }else if( stripdet.subDetector() == SiStripDetId::TEC){
339  // --------------------------- TEC --------------------------- //
340  TECDetId tec1 = TECDetId(rawdetid);
341  if(ring_flag){
342  ss<<SEP<<"TEC"<<SEP<<"side_"<<tec1.side()<<SEP<<"ring_"<<tec1.ring();
343  }else{
344  ss<<SEP<<"TEC"<<SEP<<"side_"<<tec1.side()<<SEP<<"wheel_"<<tec1.wheel();
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) {
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 (TIDDetId(detid).side() == 2) {
371  subdet_folder = "TID/side_2";
372  result.second = "TID__side__2";
373  } else if (TIDDetId(detid).side() == 1) {
374  subdet_folder = "TID/side_1";
375  result.second = "TID__side__1";
376  }
377  break;
379  if (TECDetId(detid).side() == 2) {
380  subdet_folder = "TEC/side_2";
381  result.second = "TEC__side__2";
382  } else if (TECDetId(detid).side() == 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 }
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 layer() const
layer id
Definition: TOBDetId.h:39
void getSubDetFolder(const uint32_t &detid, std::string &folder_name)
std::string getSiStripTopControlFolder()
bool isStereo()
Definition: TIDDetId.h:109
#define CONTROL_FOLDER_NAME
#define abs(x)
Definition: mlp_lapack.h:159
unsigned int side() const
positive or negative id
Definition: TECDetId.h:47
unsigned int layerNumber() const
Definition: TIBDetId.h:83
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 isZMinusSide() const
Definition: TOBDetId.h:69
std::pair< std::string, std::string > getSubDetFolderAndTag(const uint32_t &detid)
unsigned int layerNumber() const
Definition: TOBDetId.h:73
tuple result
Definition: query.py:137
bool isStereo()
Definition: TECDetId.h:118
unsigned int ring() const
ring id
Definition: TIDDetId.h:55
static unsigned short const all_
void getLayerFolderName(std::stringstream &ss, uint32_t rawdetid, bool ring_flag=0)
void setDetectorFolder(uint32_t rawdetid=0)
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
SubDetector subDetector() const
Definition: SiStripDetId.h:114
void getFolderName(int32_t rawdetid, std::string &lokal_folder)
#define SEP
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
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
unsigned int ringNumber() const
Definition: TECDetId.h:98
unsigned int ring() const
ring id
Definition: TECDetId.h:71
std::pair< std::string, int32_t > GetSubDetAndLayer(const uint32_t &detid, bool ring_flag=0)
void setLayerFolder(uint32_t rawdetid=0, int32_t layer=0, bool ring_flag=0)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
#define MECHANICAL_FOLDER_NAME
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50