CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CalibFormats/SiPixelObjects/interface/PixelROCName.h

Go to the documentation of this file.
00001 #ifndef PixelROCName_h
00002 #define PixelROCName_h
00003 
00009 #include <iostream>
00010 #include <fstream>
00011 #include <string>
00012 #include <cassert>
00013 
00014 namespace pos{
00020   class PixelROCName {
00021 
00022   public:
00023 
00024     PixelROCName();
00025 
00026     explicit PixelROCName(std::string rocname);
00027 
00028 
00029     explicit PixelROCName(std::ifstream& s);
00030     
00031     std::string rocname() const; 
00032 
00033     char detsub() const {return (id_&0x80000000)?'B':'F';}    
00034     char mp() const {return id_&0x40000000?'p':'m';}    
00035     char IO() const {return id_&0x20000000?'I':'O';}    
00036     int roc() const {return id_&0xf;}    
00037 
00038     //These methods only for FPix
00039     int disk() const {assert((id_&0x80000000)==0); return (id_>>12)&0x3;}    
00040     int blade() const {assert((id_&0x80000000)==0); return (id_>>7)&0x1f;}    
00041     int panel() const {assert((id_&0x80000000)==0); return ((id_>>6)&0x1)+1;}    
00042     int plaquet() const {assert((id_&0x80000000)==0); return ((id_>>4)&0x3)+1;}    
00043 
00044     //These methods only for BPix
00045     int sec() const {assert((id_&0x80000000)!=0); return ((id_>>14)&0x7)+1;}    
00046     int layer() const {assert((id_&0x80000000)!=0); return (id_>>12)&0x3;}    
00047     int ladder() const {assert((id_&0x80000000)!=0); return (id_>>6)&0x1f;}    
00048     char HF() const {assert((id_&0x80000000)!=0); return id_&0x00000800?'F':'H';}
00049     int module() const {assert((id_&0x80000000)!=0); return ((id_>>4)&0x3)+1;}    
00050 
00051 
00052     friend std::ostream& pos::operator<<(std::ostream& s, const PixelROCName& pixelroc);
00053 
00054 
00055     const PixelROCName& operator=(const PixelROCName& aROC);
00056 
00057     const bool operator<(const PixelROCName& aROC) const{
00058       return id_<aROC.id_;
00059     }
00060 
00061     const bool operator==(const PixelROCName& aROC) const{
00062       return id_==aROC.id_;
00063     }
00064 
00065     unsigned int id() const {return id_;}
00066 
00067   private:
00068 
00069     void parsename(std::string name);
00070 
00071     void check(bool check, const std::string& name);
00072 
00073     void setIdFPix(char np, char LR,int disk,
00074                    int blade, int panel, int plaquet, int roc);
00075 
00076     void setIdBPix(char np, char LR,int sec,
00077                    int layer, int ladder, char HF, 
00078                    int module, int roc);
00079 
00080     
00081 
00082     //BPix_BpI_SEC1_LYR1_LDR3F_MOD1_ROC0
00083 
00084 
00085     //The id_ holds the following values for BPix
00086     //bit [0,1,2,3] the ROC #
00087     //bit [4,5] the module#
00088     //bit [6,7,8,9,10] the ladder#
00089     //bit [11] H or F (0 or 1)#
00090     //bit [12,13] the layer#
00091     //bit [14,15,16] the section#
00092     //bit [29] I or 0 (0 or 1)
00093     //bit [30] m or p (0 or 1)
00094     //bit [31] = 1
00095 
00096 
00097     //FPix_BpI_D1_BLD1_PNL1_PLQ1_ROC1
00098 
00099     //The id_ holds the following values for FPix
00100     //bit [0,1,2,3] the ROC #
00101     //bit [4,5] the plaquet#
00102     //bit [6] the panel#
00103     //bit [7,8,9,10,11] the blade#
00104     //bit [12,13] the disk#
00105     //bit [29] I or O (0 or 1)
00106     //bit [30] m or p (0 or 1)
00107     //bit [31] = 0
00108 
00109     unsigned int id_;
00110     
00111   };
00112   std::ostream& operator<<(std::ostream& s, const PixelROCName& pixelroc);
00113 }
00114 #endif