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"
11 #include <sstream>
12 #include <cstdio>
13 
16  rootFolder("Pixel"),
17  slash("/"),
18  dbe_(edm::Service<DQMStore>().operator->())
19 {
20 }
21 
23 
24 bool SiPixelFolderOrganizer::setModuleFolder(const uint32_t& rawdetid, int type) {
25 
26  bool flag = false;
27 
28  if(rawdetid == 0) {
30  flag = true;
31  }
35  else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
36 
37  //for endcap types there is nothing to do:
38  if(type>3 && type!=7) return true;
39 
40  std::string subDetectorFolder = "Barrel";
41  PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
42  int DBlayer = PixelBarrelName(DetId(rawdetid)).layerName();
43  int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
44  int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
45 
46  char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
47  char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
48  char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
49 
50  std::ostringstream sfolder;
51 
52  sfolder << rootFolder << "/" << subDetectorFolder;
53  if(type<4){
54  sfolder << "/Shell_" <<DBshell
55  << "/" << slayer;
56  }
57  if(type<2){
58  sfolder << "/" << sladder;
59  if ( PixelBarrelName(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
60  else sfolder <<"F";
61  }
62  if(type==0) sfolder << "/" <<smodule;
63  //if(type==3) sfolder << "/all_" << smodule;
64 
65  //std::cout<<"set barrel folder: "<<rawdetid<<" : "<<sfolder.str().c_str()<<std::endl;
66 
67  dbe_->setCurrentFolder(sfolder.str().c_str());
68  flag = true;
69  }
73  else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
74 
75  //for barrel types there is nothing to do:
76  if(type>0 && type < 4) return true;
77 
78  std::string subDetectorFolder = "Endcap";
80  int disk = PixelEndcapName(DetId(rawdetid)).diskName();
81  int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
82  int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
83  int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
84 
85  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
86  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
87  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
88  char smodule[80];sprintf(smodule,"Module_%i",module);
89 
90  std::ostringstream sfolder;
91 
92  sfolder <<rootFolder <<"/" << subDetectorFolder <<
93  "/HalfCylinder_" << side << "/" << sdisk;
94  if(type==0 || type ==4){
95  sfolder << "/" << sblade;
96  }
97  if(type==0){
98  sfolder << "/" << spanel << "/" << smodule;
99  }
100 // if(type==6){
101 // sfolder << "/" << spanel << "_all_" << smodule;
102 // }
103 
104  //std::cout<<"set endcap folder: "<<rawdetid<<" : "<<sfolder.str().c_str()<<std::endl;
105 
106  dbe_->setCurrentFolder(sfolder.str().c_str());
107  flag = true;
108 
109  } else throw cms::Exception("LogicError")
110  << "[SiPixelFolderOrganizer::setModuleFolder] Not a Pixel detector DetId ";
111 
112  return flag;
113 
114 }
115 
116 bool SiPixelFolderOrganizer::setFedFolder(const uint32_t FedId) {
117 
118  std::string subDetectorFolder = "AdditionalPixelErrors";
119  char sFed[80]; sprintf(sFed, "FED_%i",FedId);
120  std::ostringstream sfolder;
121 
122  sfolder << rootFolder << "/" << subDetectorFolder << "/" << sFed;
123  dbe_->setCurrentFolder(sfolder.str().c_str());
124 
125  return true;
126 
127 }
128 
129 void SiPixelFolderOrganizer::getModuleFolder(const uint32_t& rawdetid,
130  std::string& path) {
131 
132  path = rootFolder;
133  //std::cout<<"rawdetis: "<<rawdetid<<" , path= "<<path<<std::endl;
134  if(rawdetid == 0) {
135  return;
136  }else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
137  std::string subDetectorFolder = "Barrel";
138  PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
139  int DBlayer = PixelBarrelName(DetId(rawdetid)).layerName();
140  int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
141  int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
142 
143  //char sshell[80]; sprintf(sshell, "Shell_%i", DBshell);
144  char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
145  char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
146  char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
147 
148  std::ostringstream sfolder;
149  sfolder << rootFolder << "/" << subDetectorFolder << "/Shell_" <<DBshell << "/" << slayer << "/" << sladder;
150  if ( PixelBarrelName(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
151  else sfolder <<"F";
152  sfolder << "/" <<smodule;
153  path = sfolder.str().c_str();
154 
155  //path = path + "/" + subDetectorFolder + "/" + sshell + "/" + slayer + "/" + sladder;
156  //if(PixelBarrelName(DetId(rawdetid)).isHalfModule() )
157  // path = path + "H";
158  //else path = path + "F";
159  //path = path + "/" + smodule;
160 
161  }else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
162  std::string subDetectorFolder = "Endcap";
164  int disk = PixelEndcapName(DetId(rawdetid)).diskName();
165  int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
166  int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
167  int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
168 
169  //char shc[80]; sprintf(shc, "HalfCylinder_%i",side);
170  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
171  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
172  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
173  char smodule[80];sprintf(smodule,"Module_%i",module);
174 
175  std::ostringstream sfolder;
176  sfolder <<rootFolder <<"/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk << "/" << sblade << "/" << spanel << "/" << smodule;
177  path = sfolder.str().c_str();
178 
179  //path = path + "/" + subDetectorFolder + "/" + shc + "/" + sdisk + "/" + sblade + "/" + spanel + "/" + smodule;
180 
181  }else throw cms::Exception("LogicError")
182  << "[SiPixelFolderOrganizer::getModuleFolder] Not a Pixel detector DetId ";
183 
184  //std::cout<<"resulting final path name: "<<path<<std::endl;
185 
186  return;
187 }
int plaquetteName() const
plaquetteId (in pannel)
type
Definition: HCALResponse.h:21
int moduleName() const
module id (index in z)
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)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
DQMStore * dbe_
Definition: DetId.h:18
int ladderName() const
ladder id (index in phi)
void getModuleFolder(const uint32_t &rawdetid, std::string &path)
int layerName() const
layer id
Shell shell() const
int pannelName() const
pannel id
int diskName() const
disk id
virtual ~SiPixelFolderOrganizer()
Destructor.
HalfCylinder halfCylinder() const
Definition: vlib.h:208
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
bool setModuleFolder(const uint32_t &rawdetid=0, int type=0)
Set folder name for a module or plaquette.