test
CMS 3D CMS Logo

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