00001
00002 #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h"
00003
00004 #include "FWCore/ServiceRegistry/interface/Service.h"
00005 #include "FWCore/Utilities/interface/Exception.h"
00007 #include "DataFormats/DetId/interface/DetId.h"
00008 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00009 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00010 #include "DataFormats/SiPixelDetId/interface/PixelBarrelNameUpgrade.h"
00011 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00012 #include "DataFormats/SiPixelDetId/interface/PixelEndcapNameUpgrade.h"
00013 #include <sstream>
00014 #include <cstdio>
00015
00017 SiPixelFolderOrganizer::SiPixelFolderOrganizer() :
00018 rootFolder("Pixel"),
00019 slash("/"),
00020 dbe_(edm::Service<DQMStore>().operator->())
00021 {
00022 }
00023
00024 SiPixelFolderOrganizer::~SiPixelFolderOrganizer() {}
00025
00026 bool SiPixelFolderOrganizer::setModuleFolder(const uint32_t& rawdetid, int type, bool isUpgrade) {
00027
00028 bool flag = false;
00029
00030 if(rawdetid == 0) {
00031 dbe_->setCurrentFolder(rootFolder);
00032 flag = true;
00033 }
00037 else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
00038
00039 if (!isUpgrade) {
00040
00041 if(type>3 && type!=7) return true;
00042
00043 std::string subDetectorFolder = "Barrel";
00044 PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
00045 int DBlayer = PixelBarrelName(DetId(rawdetid)).layerName();
00046 int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
00047 int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
00048
00049 char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
00050 char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00051 char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
00052
00053 std::ostringstream sfolder;
00054
00055 sfolder << rootFolder << "/" << subDetectorFolder;
00056 if(type<4){
00057 sfolder << "/Shell_" <<DBshell
00058 << "/" << slayer;
00059 }
00060 if(type<2){
00061 sfolder << "/" << sladder;
00062 if ( PixelBarrelName(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
00063 else sfolder <<"F";
00064 }
00065 if(type==0) sfolder << "/" <<smodule;
00066
00067
00068
00069
00070 dbe_->setCurrentFolder(sfolder.str().c_str());
00071 flag = true;
00072 } else if (isUpgrade) {
00073
00074 if(type>3 && type!=7) return true;
00075
00076 std::string subDetectorFolder = "Barrel";
00077 PixelBarrelNameUpgrade::Shell DBshell = PixelBarrelNameUpgrade(DetId(rawdetid)).shell();
00078 int DBlayer = PixelBarrelNameUpgrade(DetId(rawdetid)).layerName();
00079 int DBladder = PixelBarrelNameUpgrade(DetId(rawdetid)).ladderName();
00080 int DBmodule = PixelBarrelNameUpgrade(DetId(rawdetid)).moduleName();
00081
00082 char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
00083 char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00084 char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
00085
00086 std::ostringstream sfolder;
00087
00088 sfolder << rootFolder << "/" << subDetectorFolder;
00089 if(type<4){
00090 sfolder << "/Shell_" <<DBshell
00091 << "/" << slayer;
00092 }
00093 if(type<2){
00094 sfolder << "/" << sladder;
00095 if ( PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
00096 else sfolder <<"F";
00097 }
00098 if(type==0) sfolder << "/" <<smodule;
00099
00100
00101
00102
00103 dbe_->setCurrentFolder(sfolder.str().c_str());
00104 flag = true;
00105 }
00106 }
00107
00111 else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
00112
00113 if (!isUpgrade) {
00114
00115 if(type>0 && type < 4) return true;
00116
00117 std::string subDetectorFolder = "Endcap";
00118 PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(rawdetid)).halfCylinder();
00119 int disk = PixelEndcapName(DetId(rawdetid)).diskName();
00120 int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
00121 int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
00122 int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
00123
00124 char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00125 char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00126 char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00127 char smodule[80];sprintf(smodule,"Module_%i",module);
00128
00129 std::ostringstream sfolder;
00130
00131 sfolder <<rootFolder <<"/" << subDetectorFolder <<
00132 "/HalfCylinder_" << side << "/" << sdisk;
00133 if(type==0 || type ==4){
00134 sfolder << "/" << sblade;
00135 }
00136 if(type==0){
00137 sfolder << "/" << spanel << "/" << smodule;
00138 }
00139
00140
00141
00142
00143
00144
00145 dbe_->setCurrentFolder(sfolder.str().c_str());
00146 flag = true;
00147
00148 } else if (isUpgrade) {
00149
00150 if(type>0 && type < 4) return true;
00151
00152 std::string subDetectorFolder = "Endcap";
00153 PixelEndcapNameUpgrade::HalfCylinder side = PixelEndcapNameUpgrade(DetId(rawdetid)).halfCylinder();
00154 int disk = PixelEndcapNameUpgrade(DetId(rawdetid)).diskName();
00155 int blade = PixelEndcapNameUpgrade(DetId(rawdetid)).bladeName();
00156 int panel = PixelEndcapNameUpgrade(DetId(rawdetid)).pannelName();
00157 int module = PixelEndcapNameUpgrade(DetId(rawdetid)).plaquetteName();
00158
00159
00160 char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00161 char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00162 char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00163 char smodule[80];sprintf(smodule,"Module_%i",module);
00164
00165 std::ostringstream sfolder;
00166
00167 sfolder <<rootFolder <<"/" << subDetectorFolder <<
00168 "/HalfCylinder_" << side << "/" << sdisk;
00169 if(type==0 || type ==4){
00170 sfolder << "/" << sblade;
00171 }
00172 if(type==0){
00173 sfolder << "/" << spanel << "/" << smodule;
00174 }
00175
00176
00177
00178
00179
00180
00181 dbe_->setCurrentFolder(sfolder.str().c_str());
00182 flag = true;
00183 }
00184 } else throw cms::Exception("LogicError")
00185 << "[SiPixelFolderOrganizer::setModuleFolder] Not a Pixel detector DetId ";
00186
00187 return flag;
00188
00189 }
00190
00191 bool SiPixelFolderOrganizer::setFedFolder(const uint32_t FedId) {
00192
00193 std::string subDetectorFolder = "AdditionalPixelErrors";
00194 char sFed[80]; sprintf(sFed, "FED_%i",FedId);
00195 std::ostringstream sfolder;
00196
00197 sfolder << rootFolder << "/" << subDetectorFolder << "/" << sFed;
00198 dbe_->setCurrentFolder(sfolder.str().c_str());
00199
00200 return true;
00201
00202 }
00203
00204 void SiPixelFolderOrganizer::getModuleFolder(const uint32_t& rawdetid,
00205 std::string& path,
00206 bool isUpgrade) {
00207
00208 path = rootFolder;
00209 if(rawdetid == 0) {
00210 return;
00211 }else if( (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) && (!isUpgrade) ) {
00212 std::string subDetectorFolder = "Barrel";
00213 PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
00214 int DBlayer = PixelBarrelName(DetId(rawdetid)).layerName();
00215 int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
00216 int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
00217
00218
00219 char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
00220 char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00221 char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
00222
00223 std::ostringstream sfolder;
00224 sfolder << rootFolder << "/" << subDetectorFolder << "/Shell_" <<DBshell << "/" << slayer << "/" << sladder;
00225 if ( PixelBarrelName(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
00226 else sfolder <<"F";
00227 sfolder << "/" <<smodule;
00228 path = sfolder.str().c_str();
00229
00230
00231
00232
00233
00234
00235
00236 }else if( (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) && (isUpgrade) ) {
00237 std::string subDetectorFolder = "Barrel";
00238 PixelBarrelNameUpgrade::Shell DBshell = PixelBarrelNameUpgrade(DetId(rawdetid)).shell();
00239 int DBlayer = PixelBarrelNameUpgrade(DetId(rawdetid)).layerName();
00240 int DBladder = PixelBarrelNameUpgrade(DetId(rawdetid)).ladderName();
00241 int DBmodule = PixelBarrelNameUpgrade(DetId(rawdetid)).moduleName();
00242
00243
00244 char slayer[80]; sprintf(slayer, "Layer_%i", DBlayer);
00245 char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00246 char smodule[80]; sprintf(smodule,"Module_%i", DBmodule);
00247
00248 std::ostringstream sfolder;
00249 sfolder << rootFolder << "/" << subDetectorFolder << "/Shell_" <<DBshell << "/" << slayer << "/" << sladder;
00250 if ( PixelBarrelNameUpgrade(DetId(rawdetid)).isHalfModule() ) sfolder <<"H";
00251 else sfolder <<"F";
00252 sfolder << "/" <<smodule;
00253 path = sfolder.str().c_str();
00254
00255
00256
00257
00258
00259
00260
00261 } else if( (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (!isUpgrade) ) {
00262 std::string subDetectorFolder = "Endcap";
00263 PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(rawdetid)).halfCylinder();
00264 int disk = PixelEndcapName(DetId(rawdetid)).diskName();
00265 int blade = PixelEndcapName(DetId(rawdetid)).bladeName();
00266 int panel = PixelEndcapName(DetId(rawdetid)).pannelName();
00267 int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
00268
00269
00270 char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00271 char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00272 char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00273 char smodule[80];sprintf(smodule,"Module_%i",module);
00274
00275 std::ostringstream sfolder;
00276 sfolder <<rootFolder <<"/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk << "/" << sblade << "/" << spanel << "/" << smodule;
00277 path = sfolder.str().c_str();
00278
00279
00280
00281 } else if( (DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) && (isUpgrade) ) {
00282 std::string subDetectorFolder = "Endcap";
00283 PixelEndcapNameUpgrade::HalfCylinder side = PixelEndcapNameUpgrade(DetId(rawdetid)).halfCylinder();
00284 int disk = PixelEndcapNameUpgrade(DetId(rawdetid)).diskName();
00285 int blade = PixelEndcapNameUpgrade(DetId(rawdetid)).bladeName();
00286 int panel = PixelEndcapNameUpgrade(DetId(rawdetid)).pannelName();
00287 int module = PixelEndcapNameUpgrade(DetId(rawdetid)).plaquetteName();
00288
00289
00290 char sdisk[80]; sprintf(sdisk, "Disk_%i",disk);
00291 char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00292 char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00293 char smodule[80];sprintf(smodule,"Module_%i",module);
00294
00295 std::ostringstream sfolder;
00296 sfolder <<rootFolder <<"/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk << "/" << sblade << "/" << spanel << "/" << smodule;
00297 path = sfolder.str().c_str();
00298
00299
00300
00301 } else throw cms::Exception("LogicError")
00302 << "[SiPixelFolderOrganizer::getModuleFolder] Not a Pixel detector DetId ";
00303
00304
00305
00306 return;
00307 }