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  rootFolder("Pixel"),
19  slash("/"),
20  dbe_(edm::Service<DQMStore>().operator->())
21 {
22 }
23 
25 
26 bool SiPixelFolderOrganizer::setModuleFolder(const uint32_t& rawdetid, int type, bool isUpgrade) {
27 
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 
39  if (!isUpgrade) {
40  //for endcap types there is nothing to do:
41  if(type>3 && type!=7) 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]; sprintf(slayer, "Layer_%i", DBlayer);
50  char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
51  char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
52 
53  std::ostringstream sfolder;
54 
55  sfolder << rootFolder << "/" << subDetectorFolder;
56  if(type<4){
57  sfolder << "/Shell_" <<DBshell
58  << "/" << slayer;
59  }
60  if(type<2){
61  sfolder << "/" << sladder;
62  if ( PixelBarrelName(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
63  else sfolder <<"F";
64  }
65  if(type==0) sfolder << "/" <<smodule;
66  //if(type==3) sfolder << "/all_" << smodule;
67 
68  //std::cout<<"set barrel folder: "<<rawdetid<<" : "<<sfolder.str().c_str()<<std::endl;
69 
70  dbe_->setCurrentFolder(sfolder.str().c_str());
71  flag = true;
72  } else if (isUpgrade) {
73  //for endcap types there is nothing to do:
74  if(type>3 && type!=7) return true;
75 
76  std::string subDetectorFolder = "Barrel";
78  int DBlayer = PixelBarrelNameUpgrade(DetId(rawdetid)).layerName();
79  int DBladder = PixelBarrelNameUpgrade(DetId(rawdetid)).ladderName();
80  int DBmodule = PixelBarrelNameUpgrade(DetId(rawdetid)).moduleName();
81 
82  char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
83  char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
84  char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
85 
86  std::ostringstream sfolder;
87 
88  sfolder << rootFolder << "/" << subDetectorFolder;
89  if(type<4){
90  sfolder << "/Shell_" <<DBshell
91  << "/" << slayer;
92  }
93  if(type<2){
94  sfolder << "/" << sladder;
95  if ( PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
96  else sfolder <<"F";
97  }
98  if(type==0) sfolder << "/" <<smodule;
99  //if(type==3) sfolder << "/all_" << smodule;
100 
101  //std::cout<<"set barrel folder: "<<rawdetid<<" : "<<sfolder.str().c_str()<<std::endl;
102 
103  dbe_->setCurrentFolder(sfolder.str().c_str());
104  flag = true;
105  }//endif(isUpgrade)
106  }
107 
111  else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
112 
113  if (!isUpgrade) {
114  //for barrel types there is nothing to do:
115  if(type>0 && type < 4) return true;
116 
117  std::string subDetectorFolder = "Endcap";
119  int disk = PixelEndcapName(DetId(rawdetid)).diskName();
120  int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
121  int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
122  int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
123 
124  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
125  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
126  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
127  char smodule[80];sprintf(smodule,"Module_%i",module);
128 
129  std::ostringstream sfolder;
130 
131  sfolder <<rootFolder <<"/" << subDetectorFolder <<
132  "/HalfCylinder_" << side << "/" << sdisk;
133  if(type==0 || type ==4){
134  sfolder << "/" << sblade;
135  }
136  if(type==0){
137  sfolder << "/" << spanel << "/" << smodule;
138  }
139 // if(type==6){
140 // sfolder << "/" << spanel << "_all_" << smodule;
141 // }
142 
143  //std::cout<<"set endcap folder: "<<rawdetid<<" : "<<sfolder.str().c_str()<<std::endl;
144 
145  dbe_->setCurrentFolder(sfolder.str().c_str());
146  flag = true;
147 
148  } else if (isUpgrade) {
149  //for barrel types there is nothing to do:
150  if(type>0 && type < 4) return true;
151 
152  std::string subDetectorFolder = "Endcap";
154  int disk = PixelEndcapNameUpgrade(DetId(rawdetid)).diskName();
155  int blade = PixelEndcapNameUpgrade(DetId(rawdetid)).bladeName();
156  int panel = PixelEndcapNameUpgrade(DetId(rawdetid)).pannelName();
158 
159 
160  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
161  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
162  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
163  char smodule[80];sprintf(smodule,"Module_%i",module);
164 
165  std::ostringstream sfolder;
166 
167  sfolder <<rootFolder <<"/" << subDetectorFolder <<
168  "/HalfCylinder_" << side << "/" << sdisk;
169  if(type==0 || type ==4){
170  sfolder << "/" << sblade;
171  }
172  if(type==0){
173  sfolder << "/" << spanel << "/" << smodule;
174  }
175 // if(type==6){
176 // sfolder << "/" << spanel << "_all_" << smodule;
177 // }
178 
179  //std::cout<<"set endcap folder: "<<rawdetid<<" : "<<sfolder.str().c_str()<<std::endl;
180 
181  dbe_->setCurrentFolder(sfolder.str().c_str());
182  flag = true;
183  }//endifendcap&&isUpgrade
184  } else throw cms::Exception("LogicError")
185  << "[SiPixelFolderOrganizer::setModuleFolder] Not a Pixel detector DetId ";
186 
187  return flag;
188 
189 }
190 
191 bool SiPixelFolderOrganizer::setFedFolder(const uint32_t FedId) {
192 
193  std::string subDetectorFolder = "AdditionalPixelErrors";
194  char sFed[80]; sprintf(sFed, "FED_%i",FedId);
195  std::ostringstream sfolder;
196 
197  sfolder << rootFolder << "/" << subDetectorFolder << "/" << sFed;
198  dbe_->setCurrentFolder(sfolder.str().c_str());
199 
200  return true;
201 
202 }
203 
204 void SiPixelFolderOrganizer::getModuleFolder(const uint32_t& rawdetid,
205  std::string& path,
206  bool isUpgrade) {
207 
208  path = rootFolder;
209  if(rawdetid == 0) {
210  return;
211  }else if( (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) && (!isUpgrade) ) {
212  std::string subDetectorFolder = "Barrel";
213  PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
214  int DBlayer = PixelBarrelName(DetId(rawdetid)).layerName();
215  int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
216  int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
217 
218  //char sshell[80]; sprintf(sshell, "Shell_%i", DBshell);
219  char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
220  char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
221  char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
222 
223  std::ostringstream sfolder;
224  sfolder << rootFolder << "/" << subDetectorFolder << "/Shell_" <<DBshell << "/" << slayer << "/" << sladder;
225  if ( PixelBarrelName(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
226  else sfolder <<"F";
227  sfolder << "/" <<smodule;
228  path = sfolder.str().c_str();
229 
230  //path = path + "/" + subDetectorFolder + "/" + sshell + "/" + slayer + "/" + sladder;
231  //if(PixelBarrelName(DetId(rawdetid)).isHalfModule() )
232  // path = path + "H";
233  //else path = path + "F";
234  //path = path + "/" + smodule;
235 
236  }else if( (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) && (isUpgrade) ) {
237  std::string subDetectorFolder = "Barrel";
239  int DBlayer = PixelBarrelNameUpgrade(DetId(rawdetid)).layerName();
240  int DBladder = PixelBarrelNameUpgrade(DetId(rawdetid)).ladderName();
241  int DBmodule = PixelBarrelNameUpgrade(DetId(rawdetid)).moduleName();
242 
243  //char sshell[80]; sprintf(sshell, "Shell_%i", DBshell);
244  char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
245  char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
246  char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
247 
248  std::ostringstream sfolder;
249  sfolder << rootFolder << "/" << subDetectorFolder << "/Shell_" <<DBshell << "/" << slayer << "/" << sladder;
250  if ( PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
251  else sfolder <<"F";
252  sfolder << "/" <<smodule;
253  path = sfolder.str().c_str();
254 
255  //path = path + "/" + subDetectorFolder + "/" + sshell + "/" + slayer + "/" + sladder;
256  //if(PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule() )
257  // path = path + "H";
258  //else path = path + "F";
259  //path = path + "/" + smodule;
260 
261  } else if( (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (!isUpgrade) ) {
262  std::string subDetectorFolder = "Endcap";
264  int disk = PixelEndcapName(DetId(rawdetid)).diskName();
265  int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
266  int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
267  int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
268 
269  //char shc[80]; sprintf(shc, "HalfCylinder_%i",side);
270  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
271  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
272  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
273  char smodule[80];sprintf(smodule,"Module_%i",module);
274 
275  std::ostringstream sfolder;
276  sfolder <<rootFolder <<"/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk << "/" << sblade << "/" << spanel << "/" << smodule;
277  path = sfolder.str().c_str();
278 
279  //path = path + "/" + subDetectorFolder + "/" + shc + "/" + sdisk + "/" + sblade + "/" + spanel + "/" + smodule;
280 
281  } else if( (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (isUpgrade) ) {
282  std::string subDetectorFolder = "Endcap";
284  int disk = PixelEndcapNameUpgrade(DetId(rawdetid)).diskName();
285  int blade = PixelEndcapNameUpgrade(DetId(rawdetid)).bladeName();
286  int panel = PixelEndcapNameUpgrade(DetId(rawdetid)).pannelName();
288 
289  //char shc[80]; sprintf(shc, "HalfCylinder_%i",side);
290  char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
291  char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
292  char spanel[80]; sprintf(spanel, "Panel_%i",panel);
293  char smodule[80];sprintf(smodule,"Module_%i",module);
294 
295  std::ostringstream sfolder;
296  sfolder <<rootFolder <<"/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk << "/" << sblade << "/" << spanel << "/" << smodule;
297  path = sfolder.str().c_str();
298 
299  //path = path + "/" + subDetectorFolder + "/" + shc + "/" + sdisk + "/" + sblade + "/" + spanel + "/" + smodule;
300 
301  }else throw cms::Exception("LogicError")
302  << "[SiPixelFolderOrganizer::getModuleFolder] Not a Pixel detector DetId ";
303 
304  //std::cout<<"resulting final path name: "<<path<<std::endl;
305 
306  return;
307 }
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)
void getModuleFolder(const uint32_t &rawdetid, std::string &path, bool isUpgrade)
tuple path
else: Piece not in the list, fine.
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
DQMStore * dbe_
int diskName() const
disk id
Definition: DetId.h:18
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
Definition: vlib.h:208
int layerName() const
layer id
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:655