CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CalibTracker/SiStripCommon/interface/TkDetMap.h

Go to the documentation of this file.
00001 #ifndef CalibTracker_SiStripCommon_TKHistoMap_h
00002 #define CalibTracker_SiStripCommon_TKHistoMap_h
00003 
00004 
00005 #include <map>
00006 #include <boost/cstdint.hpp>
00007 #include "FWCore/ServiceRegistry/interface/Service.h"
00008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00009 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00010 
00011 class TkLayerMap{
00012 
00013  public:
00014 
00015   struct XYbin{
00016     XYbin(const XYbin& in){ix=in.ix;iy=in.iy;x=in.x;y=in.y;}
00017     XYbin(int16_t _ix=-999, int16_t _iy=-999, float _x=-999., float _y=-999.){ix=_ix;iy=_iy;x=_x;y=_y;}
00018     int16_t ix,iy;
00019     float x,y;
00020   };
00021   
00022   enum  TkLayerEnum { INVALID=0,
00023                       TIB_L1, //1
00024                       TIB_L2,
00025                       TIB_L3,
00026                       TIB_L4,         
00027                       TIDM_D1, //5
00028                       TIDM_D2,
00029                       TIDM_D3,
00030                       TIDP_D1, //8
00031                       TIDP_D2,
00032                       TIDP_D3,
00033                       TOB_L1, //11
00034                       TOB_L2,
00035                       TOB_L3, 
00036                       TOB_L4,
00037                       TOB_L5,
00038                       TOB_L6,
00039                       TECM_W1, //17
00040                       TECM_W2,
00041                       TECM_W3,
00042                       TECM_W4,
00043                       TECM_W5,
00044                       TECM_W6,
00045                       TECM_W7,
00046                       TECM_W8,
00047                       TECM_W9,
00048                       TECP_W1, //26
00049                       TECP_W2,
00050                       TECP_W3,
00051                       TECP_W4,
00052                       TECP_W5,
00053                       TECP_W6,
00054                       TECP_W7,
00055                       TECP_W8,
00056                       TECP_W9 //34
00057   };
00058 
00059   
00060   TkLayerMap(int in);
00061   ~TkLayerMap(){
00062     delete [] binToDet;
00063   };
00064   
00065   const XYbin getXY(uint32_t& detid, int layerEnumNb=0);
00066 
00067   int& get_nchX(){return nchX;}
00068   int& get_nchY(){return nchY;}
00069   double& get_lowX(){return lowX;}
00070   double& get_highX(){return highX;}
00071   double& get_lowY(){return lowY;}
00072   double& get_highY(){return highY;}
00073 
00074   static const int16_t layerSearch(uint32_t detid);
00075 
00076   uint32_t getDetFromBin(int ix, int iy);
00077   uint32_t* getBinToDet(){return binToDet;}
00078 
00079  private:
00080 
00081   XYbin getXY_TIB(uint32_t& detid, int layerEnumNb=0);
00082   XYbin getXY_TOB(uint32_t& detid, int layerEnumNb=0);
00083   XYbin getXY_TID(uint32_t& detid, int layerEnumNb=0);
00084   XYbin getXY_TEC(uint32_t& detid, int layerEnumNb=0);
00085 
00086   void initialize(int layer);
00087 
00088   void createTIB(std::vector<uint32_t>& TkDetIdList, int layer);
00089   void createTOB(std::vector<uint32_t>& TkDetIdList, int layer);
00090   void createTID(std::vector<uint32_t>& TkDetIdList, int layer);
00091   void createTEC(std::vector<uint32_t>& TkDetIdList, int layer);
00092 
00093  private:
00094   uint32_t* binToDet;
00095   XYbin xybin;
00096 
00097   int layerEnumNb_; //In the enumerator sequence
00098   int nchX;
00099   int nchY;
00100   double lowX,highX;
00101   double lowY, highY;
00102 
00103   std::vector<uint32_t> SingleExtString,ModulesInRingFront,ModulesInRingBack,BinForRing;
00104   uint32_t Nstring_ext, Nrod, Offset;
00105 
00106 };
00107 
00108 class TkDetMap{
00109 
00110  public:
00111   TkDetMap();
00112   TkDetMap(const edm::ParameterSet&,const edm::ActivityRegistry&);
00113   ~TkDetMap();
00114 
00115   const TkLayerMap::XYbin& getXY(uint32_t&);
00116   std::string getLayerName(int& in);
00117   int getLayerNum(std::string& in);
00118   void getSubDetLayerSide(int& in,SiStripDetId::SubDetector&,uint32_t& layer,uint32_t& side);
00119 
00120   int16_t FindLayer(uint32_t& detid);
00121 
00122   void getComponents(int& layer,
00123                      int& nchX,double& lowX,double& highX,
00124                      int& nchY,double& lowY,double& highY);
00125  
00126   uint32_t getDetFromBin(int layer, int ix, int iy){ return TkMap[layer]->getDetFromBin(ix,iy); }
00127   uint32_t getDetFromBin(std::string layerName, int ix, int iy){return getDetFromBin(getLayerNum(layerName),ix,iy);}
00128 
00129   void getDetsForLayer(int layer,std::vector<uint32_t>& output);
00130 
00131  private:
00132 
00133   void doMe();
00134 
00135  private:
00136   typedef std::vector<TkLayerMap*> detmapType;
00137   detmapType TkMap;
00138   uint32_t cached_detid;
00139   int16_t cached_layer;
00140   TkLayerMap::XYbin cached_XYbin;
00141 };
00142 
00143 
00144 #endif