CMS 3D CMS Logo

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