CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DQM/SiPixelCommon/src/SiPixelFolderOrganizer.cc

Go to the documentation of this file.
00001 
00002 #include "DQM/SiPixelCommon/interface/SiPixelFolderOrganizer.h"
00003 //#include "DQMServices/Core/interface/DQMStore.h"
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/PixelEndcapName.h"
00011 #include <sstream>
00012 #include <cstdio>
00013 
00015 SiPixelFolderOrganizer::SiPixelFolderOrganizer() :
00016   rootFolder("Pixel"),
00017   slash("/"),
00018   dbe_(edm::Service<DQMStore>().operator->())
00019 {  
00020 }
00021 
00022 SiPixelFolderOrganizer::~SiPixelFolderOrganizer() {}
00023 
00024 bool SiPixelFolderOrganizer::setModuleFolder(const uint32_t& rawdetid, int type) {
00025 
00026   bool flag = false;
00027 
00028    if(rawdetid == 0) {
00029      dbe_->setCurrentFolder(rootFolder);
00030      flag = true;
00031    }
00035    else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
00036 
00037      //for endcap types there is nothing to do: 
00038      if(type>3 && type!=7) return true;
00039 
00040      std::string subDetectorFolder = "Barrel";
00041      PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
00042      int DBlayer  = PixelBarrelName(DetId(rawdetid)).layerName();
00043      int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
00044      int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
00045      
00046      char slayer[80];  sprintf(slayer, "Layer_%i",   DBlayer);
00047      char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00048      char smodule[80]; sprintf(smodule,"Module_%i",  DBmodule);
00049      
00050      std::ostringstream sfolder;
00051      
00052      sfolder << rootFolder << "/" << subDetectorFolder; 
00053      if(type<4){
00054      sfolder << "/Shell_" <<DBshell
00055              << "/" << slayer;
00056      }
00057      if(type<2){
00058        sfolder << "/" << sladder;
00059        if ( PixelBarrelName(DetId(rawdetid)).isHalfModule() ) sfolder <<"H"; 
00060        else sfolder <<"F";
00061      }
00062      if(type==0) sfolder << "/" <<smodule;
00063      //if(type==3) sfolder << "/all_" << smodule;
00064      
00065      //std::cout<<"set barrel folder: "<<rawdetid<<" : "<<sfolder.str().c_str()<<std::endl;
00066      
00067      dbe_->setCurrentFolder(sfolder.str().c_str());
00068      flag = true;
00069    } 
00073    else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
00074 
00075      //for barrel types there is nothing to do: 
00076      if(type>0 && type < 4) return true;
00077 
00078      std::string subDetectorFolder = "Endcap";
00079      PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(rawdetid)).halfCylinder();
00080       int disk   = PixelEndcapName(DetId(rawdetid)).diskName();
00081       int blade  = PixelEndcapName(DetId(rawdetid)).bladeName();
00082       int panel  = PixelEndcapName(DetId(rawdetid)).pannelName();
00083       int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
00084 
00085       char sdisk[80];  sprintf(sdisk,  "Disk_%i",disk);
00086       char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00087       char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00088       char smodule[80];sprintf(smodule,"Module_%i",module);
00089 
00090       std::ostringstream sfolder;
00091 
00092       sfolder <<rootFolder <<"/" << subDetectorFolder << 
00093         "/HalfCylinder_" << side << "/" << sdisk; 
00094       if(type==0 || type ==4){
00095         sfolder << "/" << sblade; 
00096       }
00097       if(type==0){
00098         sfolder << "/" << spanel << "/" << smodule;
00099       }
00100 //       if(type==6){
00101 //      sfolder << "/" << spanel << "_all_" << smodule;
00102 //       }
00103      
00104      //std::cout<<"set endcap folder: "<<rawdetid<<" : "<<sfolder.str().c_str()<<std::endl;
00105      
00106       dbe_->setCurrentFolder(sfolder.str().c_str());
00107       flag = true;
00108 
00109    } else throw cms::Exception("LogicError")
00110      << "[SiPixelFolderOrganizer::setModuleFolder] Not a Pixel detector DetId ";
00111    
00112    return flag;
00113 
00114 }
00115 
00116 bool SiPixelFolderOrganizer::setFedFolder(const uint32_t FedId) {
00117 
00118   std::string subDetectorFolder = "AdditionalPixelErrors";
00119   char sFed[80];  sprintf(sFed,  "FED_%i",FedId);
00120   std::ostringstream sfolder;
00121   
00122   sfolder << rootFolder << "/" << subDetectorFolder << "/" << sFed;
00123   dbe_->setCurrentFolder(sfolder.str().c_str());
00124   
00125   return true;
00126 
00127 }
00128 
00129 void SiPixelFolderOrganizer::getModuleFolder(const uint32_t& rawdetid, 
00130                                              std::string& path) {
00131 
00132   path = rootFolder;
00133   //std::cout<<"rawdetis: "<<rawdetid<<" , path= "<<path<<std::endl;
00134   if(rawdetid == 0) {
00135     return;
00136   }else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelBarrel)) {
00137     std::string subDetectorFolder = "Barrel";
00138     PixelBarrelName::Shell DBshell = PixelBarrelName(DetId(rawdetid)).shell();
00139     int DBlayer  = PixelBarrelName(DetId(rawdetid)).layerName();
00140     int DBladder = PixelBarrelName(DetId(rawdetid)).ladderName();
00141     int DBmodule = PixelBarrelName(DetId(rawdetid)).moduleName();
00142     
00143     //char sshell[80];  sprintf(sshell, "Shell_%i",   DBshell);
00144     char slayer[80];  sprintf(slayer, "Layer_%i",   DBlayer);
00145     char sladder[80]; sprintf(sladder,"Ladder_%02i",DBladder);
00146     char smodule[80]; sprintf(smodule,"Module_%i",  DBmodule);
00147     
00148     std::ostringstream sfolder;
00149     sfolder << rootFolder << "/" << subDetectorFolder << "/Shell_" <<DBshell << "/" << slayer << "/" << sladder;
00150     if ( PixelBarrelName(DetId(rawdetid)).isHalfModule() ) sfolder <<"H"; 
00151     else sfolder <<"F";
00152     sfolder << "/" <<smodule;
00153     path = sfolder.str().c_str();
00154    
00155     //path = path + "/" + subDetectorFolder + "/" + sshell + "/" + slayer + "/" + sladder;
00156     //if(PixelBarrelName(DetId(rawdetid)).isHalfModule() )
00157     //  path = path + "H"; 
00158     //else path = path + "F";
00159     //path = path + "/" + smodule;
00160 
00161   }else if(DetId(rawdetid).subdetId() == static_cast<int>(PixelSubdetector::PixelEndcap)) {
00162     std::string subDetectorFolder = "Endcap";
00163     PixelEndcapName::HalfCylinder side = PixelEndcapName(DetId(rawdetid)).halfCylinder();
00164     int disk   = PixelEndcapName(DetId(rawdetid)).diskName();
00165     int blade  = PixelEndcapName(DetId(rawdetid)).bladeName();
00166     int panel  = PixelEndcapName(DetId(rawdetid)).pannelName();
00167     int module = PixelEndcapName(DetId(rawdetid)).plaquetteName();
00168 
00169     //char shc[80];  sprintf(shc,  "HalfCylinder_%i",side);
00170     char sdisk[80];  sprintf(sdisk,  "Disk_%i",disk);
00171     char sblade[80]; sprintf(sblade, "Blade_%02i",blade);
00172     char spanel[80]; sprintf(spanel, "Panel_%i",panel);
00173     char smodule[80];sprintf(smodule,"Module_%i",module);
00174 
00175     std::ostringstream sfolder;
00176     sfolder <<rootFolder <<"/" << subDetectorFolder << "/HalfCylinder_" << side << "/" << sdisk << "/" << sblade << "/" << spanel << "/" << smodule;
00177     path = sfolder.str().c_str();
00178     
00179     //path = path + "/" + subDetectorFolder + "/" + shc + "/" + sdisk + "/" + sblade + "/" + spanel + "/" + smodule;
00180 
00181   }else throw cms::Exception("LogicError")
00182      << "[SiPixelFolderOrganizer::getModuleFolder] Not a Pixel detector DetId ";
00183      
00184   //std::cout<<"resulting final path name: "<<path<<std::endl;   
00185      
00186   return;
00187 }