CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelFolderOrganizer.cc
Go to the documentation of this file.
3 //#include "DQMServices/Core/interface/DQMStore.h"
13 #include <cstdio>
14 #include <sstream>
15 
17 SiPixelFolderOrganizer::SiPixelFolderOrganizer(bool getStore) : topFolderName("Pixel") {
18  // Not allowed in multithread framework, but can still be called by other
19  // modules not from DQM.
20  if (getStore)
22 }
23 
25 
26 // Overloaded function for calling outside of DQM framework
27 bool SiPixelFolderOrganizer::setModuleFolder(const uint32_t &rawdetid, int type, bool isUpgrade) {
28  bool flag = false;
29 
30  if (rawdetid == 0) {
32  flag = true;
33  }
37  else if (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
38  if (!isUpgrade) {
39  // for endcap types there is nothing to do:
40  if (type > 3 && type != 7)
41  return true;
42 
43  std::string subDetectorFolder = "Barrel";
44  PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
45  int DBlayer = PixelBarrelName(DetId(rawdetid)).layerName();
46  int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
47  int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
48 
49  char slayer[80];
50  sprintf(slayer, "Layer_%i", DBlayer);
51  char sladder[80];
52  sprintf(sladder, "Ladder_%02i", DBladder);
53  char smodule[80];
54  sprintf(smodule, "Module_%i", DBmodule);
55 
56  std::ostringstream sfolder;
57 
58  sfolder << topFolderName << "/" << subDetectorFolder;
59  if (type < 4) {
60  sfolder << "/Shell_" << DBshell << "/" << slayer;
61  }
62  if (type < 2) {
63  sfolder << "/" << sladder;
64  if (PixelBarrelName(DetId(rawdetid)).isHalfModule())
65  sfolder << "H";
66  else
67  sfolder << "F";
68  }
69  if (type == 0)
70  sfolder << "/" << smodule;
71  // if(type==3) sfolder << "/all_" << smodule;
72 
73  // std::cout<<"set barrel folder: "<<rawdetid<<" :
74  // "<<sfolder.str().c_str()<<std::endl;
75 
76  dbe_->setCurrentFolder(sfolder.str());
77  flag = true;
78  } else if (isUpgrade) {
79  // for endcap types there is nothing to do:
80  if (type > 3 && type != 7)
81  return true;
82 
83  std::string subDetectorFolder = "Barrel";
85  int DBlayer = PixelBarrelNameUpgrade(DetId(rawdetid)).layerName();
86  int DBladder = PixelBarrelNameUpgrade(DetId(rawdetid)).ladderName();
87  int DBmodule = PixelBarrelNameUpgrade(DetId(rawdetid)).moduleName();
88 
89  char slayer[80];
90  sprintf(slayer, "Layer_%i", DBlayer);
91  char sladder[80];
92  sprintf(sladder, "Ladder_%02i", DBladder);
93  char smodule[80];
94  sprintf(smodule, "Module_%i", DBmodule);
95 
96  std::ostringstream sfolder;
97 
98  sfolder << topFolderName << "/" << subDetectorFolder;
99  if (type < 4) {
100  sfolder << "/Shell_" << DBshell << "/" << slayer;
101  }
102  if (type < 2) {
103  sfolder << "/" << sladder;
104  if (PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule())
105  sfolder << "H";
106  else
107  sfolder << "F";
108  }
109  if (type == 0)
110  sfolder << "/" << smodule;
111  // if(type==3) sfolder << "/all_" << smodule;
112 
113  // std::cout<<"set barrel folder: "<<rawdetid<<" :
114  // "<<sfolder.str().c_str()<<std::endl;
115 
116  dbe_->setCurrentFolder(sfolder.str());
117  flag = true;
118  } // endif(isUpgrade)
119  }
120 
124  else if (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
125  if (!isUpgrade) {
126  // for barrel types there is nothing to do:
127  if (type > 0 && type < 4)
128  return true;
129 
130  std::string subDetectorFolder = "Endcap";
132  int disk = PixelEndcapName(DetId(rawdetid)).diskName();
133  int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
134  int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
135  int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
136 
137  char sdisk[80];
138  sprintf(sdisk, "Disk_%i", disk);
139  char sblade[80];
140  sprintf(sblade, "Blade_%02i", blade);
141  char spanel[80];
142  sprintf(spanel, "Panel_%i", panel);
143  char smodule[80];
144  sprintf(smodule, "Module_%i", module);
145 
146  std::ostringstream sfolder;
147 
148  sfolder << topFolderName << "/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk;
149  if (type == 0 || type == 4) {
150  sfolder << "/" << sblade;
151  }
152  if (type == 0) {
153  sfolder << "/" << spanel << "/" << smodule;
154  }
155  // if(type==6){
156  // sfolder << "/" << spanel << "_all_" << smodule;
157  // }
158 
159  // std::cout<<"set endcap folder: "<<rawdetid<<" :
160  // "<<sfolder.str().c_str()<<std::endl;
161 
162  dbe_->setCurrentFolder(sfolder.str());
163  flag = true;
164 
165  } else if (isUpgrade) {
166  // for barrel types there is nothing to do:
167  if (type > 0 && type < 4)
168  return true;
169 
170  std::string subDetectorFolder = "Endcap";
172  int disk = PixelEndcapNameUpgrade(DetId(rawdetid)).diskName();
173  int blade = PixelEndcapNameUpgrade(DetId(rawdetid)).bladeName();
174  int panel = PixelEndcapNameUpgrade(DetId(rawdetid)).pannelName();
176 
177  char sdisk[80];
178  sprintf(sdisk, "Disk_%i", disk);
179  char sblade[80];
180  sprintf(sblade, "Blade_%02i", blade);
181  char spanel[80];
182  sprintf(spanel, "Panel_%i", panel);
183  char smodule[80];
184  sprintf(smodule, "Module_%i", module);
185 
186  std::ostringstream sfolder;
187 
188  sfolder << topFolderName << "/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk;
189  if (type == 0 || type == 4) {
190  sfolder << "/" << sblade;
191  }
192  if (type == 0) {
193  sfolder << "/" << spanel << "/" << smodule;
194  }
195  // if(type==6){
196  // sfolder << "/" << spanel << "_all_" << smodule;
197  // }
198 
199  // std::cout<<"set endcap folder: "<<rawdetid<<" :
200  // "<<sfolder.str().c_str()<<std::endl;
201 
202  dbe_->setCurrentFolder(sfolder.str());
203  flag = true;
204  } // endifendcap&&isUpgrade
205  } else
206  throw cms::Exception("LogicError") << "[SiPixelFolderOrganizer::setModuleFolder] Not a Pixel detector "
207  "DetId ";
208 
209  return flag;
210 }
211 
212 // Overloaded setModuleFolder for multithread safe operation
214  const uint32_t &rawdetid,
215  int type,
216  bool isUpgrade) {
217  bool flag = false;
218 
219  if (rawdetid == 0) {
221  flag = true;
222  }
226  else if (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
227  if (!isUpgrade) {
228  // for endcap types there is nothing to do:
229  if (type > 3 && type != 7)
230  return true;
231 
232  std::string subDetectorFolder = "Barrel";
233  PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
234  int DBlayer = PixelBarrelName(DetId(rawdetid)).layerName();
235  int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
236  int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
237 
238  char slayer[80];
239  sprintf(slayer, "Layer_%i", DBlayer);
240  char sladder[80];
241  sprintf(sladder, "Ladder_%02i", DBladder);
242  char smodule[80];
243  sprintf(smodule, "Module_%i", DBmodule);
244 
245  std::ostringstream sfolder;
246 
247  sfolder << topFolderName << "/" << subDetectorFolder;
248  if (type < 4) {
249  sfolder << "/Shell_" << DBshell << "/" << slayer;
250  }
251  if (type < 2) {
252  sfolder << "/" << sladder;
253  if (PixelBarrelName(DetId(rawdetid)).isHalfModule())
254  sfolder << "H";
255  else
256  sfolder << "F";
257  }
258  if (type == 0)
259  sfolder << "/" << smodule;
260  // if(type==3) sfolder << "/all_" << smodule;
261 
262  // std::cout<<"set barrel folder: "<<rawdetid<<" :
263  // "<<sfolder.str().c_str()<<std::endl;
264 
265  iBooker.setCurrentFolder(sfolder.str());
266  flag = true;
267  } else if (isUpgrade) {
268  // for endcap types there is nothing to do:
269  if (type > 3 && type != 7)
270  return true;
271 
272  std::string subDetectorFolder = "Barrel";
274  int DBlayer = PixelBarrelNameUpgrade(DetId(rawdetid)).layerName();
275  int DBladder = PixelBarrelNameUpgrade(DetId(rawdetid)).ladderName();
276  int DBmodule = PixelBarrelNameUpgrade(DetId(rawdetid)).moduleName();
277 
278  char slayer[80];
279  sprintf(slayer, "Layer_%i", DBlayer);
280  char sladder[80];
281  sprintf(sladder, "Ladder_%02i", DBladder);
282  char smodule[80];
283  sprintf(smodule, "Module_%i", DBmodule);
284 
285  std::ostringstream sfolder;
286 
287  sfolder << topFolderName << "/" << subDetectorFolder;
288  if (type < 4) {
289  sfolder << "/Shell_" << DBshell << "/" << slayer;
290  }
291  if (type < 2) {
292  sfolder << "/" << sladder;
293  if (PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule())
294  sfolder << "H";
295  else
296  sfolder << "F";
297  }
298  if (type == 0)
299  sfolder << "/" << smodule;
300  // if(type==3) sfolder << "/all_" << smodule;
301 
302  // std::cout<<"set barrel folder: "<<rawdetid<<" :
303  // "<<sfolder.str().c_str()<<std::endl;
304 
305  iBooker.setCurrentFolder(sfolder.str());
306  flag = true;
307  } // endif(isUpgrade)
308  }
309 
313  else if (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
314  if (!isUpgrade) {
315  // for barrel types there is nothing to do:
316  if (type > 0 && type < 4)
317  return true;
318 
319  std::string subDetectorFolder = "Endcap";
321  int disk = PixelEndcapName(DetId(rawdetid)).diskName();
322  int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
323  int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
324  int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
325 
326  char sdisk[80];
327  sprintf(sdisk, "Disk_%i", disk);
328  char sblade[80];
329  sprintf(sblade, "Blade_%02i", blade);
330  char spanel[80];
331  sprintf(spanel, "Panel_%i", panel);
332  char smodule[80];
333  sprintf(smodule, "Module_%i", module);
334 
335  std::ostringstream sfolder;
336 
337  sfolder << topFolderName << "/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk;
338  if (type == 0 || type == 4) {
339  sfolder << "/" << sblade;
340  }
341  if (type == 0) {
342  sfolder << "/" << spanel << "/" << smodule;
343  }
344  // if(type==6){
345  // sfolder << "/" << spanel << "_all_" << smodule;
346  // }
347 
348  // std::cout<<"set endcap folder: "<<rawdetid<<" :
349  // "<<sfolder.str().c_str()<<std::endl;
350 
351  iBooker.setCurrentFolder(sfolder.str());
352  flag = true;
353 
354  } else if (isUpgrade) {
355  // for barrel types there is nothing to do:
356  if (type > 0 && type < 4)
357  return true;
358 
359  std::string subDetectorFolder = "Endcap";
361  int disk = PixelEndcapNameUpgrade(DetId(rawdetid)).diskName();
362  int blade = PixelEndcapNameUpgrade(DetId(rawdetid)).bladeName();
363  int panel = PixelEndcapNameUpgrade(DetId(rawdetid)).pannelName();
365 
366  char sdisk[80];
367  sprintf(sdisk, "Disk_%i", disk);
368  char sblade[80];
369  sprintf(sblade, "Blade_%02i", blade);
370  char spanel[80];
371  sprintf(spanel, "Panel_%i", panel);
372  char smodule[80];
373  sprintf(smodule, "Module_%i", module);
374 
375  std::ostringstream sfolder;
376 
377  sfolder << topFolderName << "/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk;
378  if (type == 0 || type == 4) {
379  sfolder << "/" << sblade;
380  }
381  if (type == 0) {
382  sfolder << "/" << spanel << "/" << smodule;
383  }
384  // if(type==6){
385  // sfolder << "/" << spanel << "_all_" << smodule;
386  // }
387 
388  // std::cout<<"set endcap folder: "<<rawdetid<<" :
389  // "<<sfolder.str().c_str()<<std::endl;
390 
391  iBooker.setCurrentFolder(sfolder.str());
392  flag = true;
393  } // endifendcap&&isUpgrade
394  } else
395  throw cms::Exception("LogicError") << "[SiPixelFolderOrganizer::setModuleFolder] Not a Pixel detector "
396  "DetId ";
397 
398  return flag;
399 }
400 
401 // Overloaded setFedFolder for use outside of DQM framework
402 bool SiPixelFolderOrganizer::setFedFolder(const uint32_t FedId) {
403  std::string subDetectorFolder = "AdditionalPixelErrors";
404  char sFed[80];
405  sprintf(sFed, "FED_%i", FedId);
406  std::ostringstream sfolder;
407 
408  sfolder << topFolderName << "/" << subDetectorFolder << "/" << sFed;
409  dbe_->setCurrentFolder(sfolder.str());
410 
411  return true;
412 }
413 
414 // Overloaded setFedFolder to avoid accessing DQMStore directly.
415 bool SiPixelFolderOrganizer::setFedFolder(DQMStore::IBooker &iBooker, const uint32_t FedId) {
416  std::string subDetectorFolder = "AdditionalPixelErrors";
417  char sFed[80];
418  sprintf(sFed, "FED_%i", FedId);
419  std::ostringstream sfolder;
420 
421  sfolder << topFolderName << "/" << subDetectorFolder << "/" << sFed;
422  iBooker.setCurrentFolder(sfolder.str());
423 
424  return true;
425 }
426 
427 void SiPixelFolderOrganizer::getModuleFolder(const uint32_t &rawdetid, std::string &path, bool isUpgrade) {
428  path = topFolderName;
429  if (rawdetid == 0) {
430  return;
431  } else if ((DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) && (!isUpgrade)) {
432  std::string subDetectorFolder = "Barrel";
433  PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
434  int DBlayer = PixelBarrelName(DetId(rawdetid)).layerName();
435  int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
436  int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
437 
438  // char sshell[80]; sprintf(sshell, "Shell_%i", DBshell);
439  char slayer[80];
440  sprintf(slayer, "Layer_%i", DBlayer);
441  char sladder[80];
442  sprintf(sladder, "Ladder_%02i", DBladder);
443  char smodule[80];
444  sprintf(smodule, "Module_%i", DBmodule);
445 
446  std::ostringstream sfolder;
447  sfolder << topFolderName << "/" << subDetectorFolder << "/Shell_" << DBshell << "/" << slayer << "/" << sladder;
448  if (PixelBarrelName(DetId(rawdetid)).isHalfModule())
449  sfolder << "H";
450  else
451  sfolder << "F";
452  sfolder << "/" << smodule;
453  path = sfolder.str();
454 
455  // path = path + "/" + subDetectorFolder + "/" + sshell + "/" + slayer + "/"
456  // + sladder; if(PixelBarrelName(DetId(rawdetid)).isHalfModule() )
457  // path = path + "H";
458  // else path = path + "F";
459  // path = path + "/" + smodule;
460 
461  } else if ((DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) && (isUpgrade)) {
462  std::string subDetectorFolder = "Barrel";
464  int DBlayer = PixelBarrelNameUpgrade(DetId(rawdetid)).layerName();
465  int DBladder = PixelBarrelNameUpgrade(DetId(rawdetid)).ladderName();
466  int DBmodule = PixelBarrelNameUpgrade(DetId(rawdetid)).moduleName();
467 
468  // char sshell[80]; sprintf(sshell, "Shell_%i", DBshell);
469  char slayer[80];
470  sprintf(slayer, "Layer_%i", DBlayer);
471  char sladder[80];
472  sprintf(sladder, "Ladder_%02i", DBladder);
473  char smodule[80];
474  sprintf(smodule, "Module_%i", DBmodule);
475 
476  std::ostringstream sfolder;
477  sfolder << topFolderName << "/" << subDetectorFolder << "/Shell_" << DBshell << "/" << slayer << "/" << sladder;
478  if (PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule())
479  sfolder << "H";
480  else
481  sfolder << "F";
482  sfolder << "/" << smodule;
483  path = sfolder.str();
484 
485  // path = path + "/" + subDetectorFolder + "/" + sshell + "/" + slayer + "/"
486  // + sladder; if(PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule() )
487  // path = path + "H";
488  // else path = path + "F";
489  // path = path + "/" + smodule;
490 
491  } else if ((DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (!isUpgrade)) {
492  std::string subDetectorFolder = "Endcap";
494  int disk = PixelEndcapName(DetId(rawdetid)).diskName();
495  int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
496  int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
497  int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
498 
499  // char shc[80]; sprintf(shc, "HalfCylinder_%i",side);
500  char sdisk[80];
501  sprintf(sdisk, "Disk_%i", disk);
502  char sblade[80];
503  sprintf(sblade, "Blade_%02i", blade);
504  char spanel[80];
505  sprintf(spanel, "Panel_%i", panel);
506  char smodule[80];
507  sprintf(smodule, "Module_%i", module);
508 
509  std::ostringstream sfolder;
510  sfolder << topFolderName << "/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk << "/" << sblade
511  << "/" << spanel << "/" << smodule;
512  path = sfolder.str();
513 
514  // path = path + "/" + subDetectorFolder + "/" + shc + "/" + sdisk + "/" +
515  // sblade + "/" + spanel + "/" + smodule;
516 
517  } else if ((DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (isUpgrade)) {
518  std::string subDetectorFolder = "Endcap";
520  int disk = PixelEndcapNameUpgrade(DetId(rawdetid)).diskName();
521  int blade = PixelEndcapNameUpgrade(DetId(rawdetid)).bladeName();
522  int panel = PixelEndcapNameUpgrade(DetId(rawdetid)).pannelName();
524 
525  // char shc[80]; sprintf(shc, "HalfCylinder_%i",side);
526  char sdisk[80];
527  sprintf(sdisk, "Disk_%i", disk);
528  char sblade[80];
529  sprintf(sblade, "Blade_%02i", blade);
530  char spanel[80];
531  sprintf(spanel, "Panel_%i", panel);
532  char smodule[80];
533  sprintf(smodule, "Module_%i", module);
534 
535  std::ostringstream sfolder;
536  sfolder << topFolderName << "/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk << "/" << sblade
537  << "/" << spanel << "/" << smodule;
538  path = sfolder.str();
539 
540  // path = path + "/" + subDetectorFolder + "/" + shc + "/" + sdisk + "/" +
541  // sblade + "/" + spanel + "/" + smodule;
542 
543  } else
544  throw cms::Exception("LogicError") << "[SiPixelFolderOrganizer::getModuleFolder] Not a Pixel detector "
545  "DetId ";
546 
547  // std::cout<<"resulting final path name: "<<path<<std::endl;
548 
549  return;
550 }
int plaquetteName() const
plaquetteId (in pannel)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
int moduleName() const
module id (index in z)
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
int plaquetteName() const
plaquetteId (in pannel)
int bladeName() const
blade id
bool setFedFolder(const uint32_t FedId)
Set folder name for a FED (used in the case of errors without detId)
SiPixelFolderOrganizer(bool getStore=true)
DQM and Framework services.
void getModuleFolder(const uint32_t &rawdetid, std::string &path, bool isUpgrade)
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0, bool isUpgrade=false)
Set folder name for a module or plaquette.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
int bladeName() const
blade id
int diskName() const
disk id
Definition: DetId.h:17
int ladderName() const
ladder id (index in phi)
int ladderName() const
ladder id (index in phi)
int moduleName() const
module id (index in z)
int layerName() const
layer id
Shell shell() const
int pannelName() const
pannel id
int diskName() const
disk id
virtual ~SiPixelFolderOrganizer()
Destructor.
HalfCylinder halfCylinder() const
HalfCylinder halfCylinder() const
int pannelName() const
pannel id
int layerName() const
layer id
tuple module
Definition: callgraph.py:69