CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/CondFormats/SiStripObjects/interface/SiStripBadStrip.h

Go to the documentation of this file.
00001 #ifndef SiStripBadStrip_h
00002 #define SiStripBadStrip_h
00003 
00004 #include<vector>
00005 #include<map>
00006 #include<iostream>
00007 #include<boost/cstdint.hpp>
00008 #include "DataFormats/SiStripCommon/interface/ConstantsForCondObjects.h"
00009 
00027 class SiStripBadStrip {
00028 
00029  public:
00030 
00031   struct data{
00032     unsigned short firstStrip;
00033     unsigned short range;
00034     unsigned short flag;
00035   };
00036 
00037   struct DetRegistry{
00038     uint32_t detid;
00039     uint32_t ibegin;
00040     uint32_t iend;
00041   };
00042 
00043   class StrictWeakOrdering{
00044   public:
00045     bool operator() (const DetRegistry& p,const uint32_t& i) const {return p.detid < i;}
00046   };
00047 
00048   typedef std::vector<unsigned int>                        Container;
00049   typedef std::vector<unsigned int>::const_iterator        ContainerIterator;
00050   typedef std::pair<ContainerIterator, ContainerIterator>  Range;
00051   typedef std::vector<DetRegistry>                         Registry;
00052   typedef Registry::const_iterator                         RegistryIterator;
00053   typedef Container                                        InputVector;
00054  
00055   SiStripBadStrip(){};
00056   SiStripBadStrip(const SiStripBadStrip& orig){
00057     v_badstrips=orig.v_badstrips; 
00058     indexes=orig.indexes;
00059   }
00060   virtual ~SiStripBadStrip(){};
00061 
00062   bool put(const uint32_t& detID,const InputVector& vect){return put(detID,Range(vect.begin(),vect.end()));}
00063   bool put(const uint32_t& detID,Range input);
00064   const Range getRange(const uint32_t& detID) const;
00065   void getDetIds(std::vector<uint32_t>& DetIds_) const;
00066   void printSummary(std::stringstream & ss) const;
00067   void printDebug(std::stringstream & ss) const;
00068 
00069   ContainerIterator getDataVectorBegin()    const {return v_badstrips.begin();}
00070   ContainerIterator getDataVectorEnd()      const {return v_badstrips.end();}
00071   RegistryIterator getRegistryVectorBegin() const {return indexes.begin();}
00072   RegistryIterator getRegistryVectorEnd()   const{return indexes.end();}
00073 
00074 
00075   inline data decode (const unsigned int& value) const {
00076     data a;
00077     a.firstStrip = ((value>>sistrip::FirstBadStripShift_)&sistrip::FirstBadStripMask_);
00078     a.range      = ((value>>sistrip::RangeBadStripShift_)&sistrip::RangeBadStripMask_);
00079     a.flag       = ((value>>sistrip::FlagBadStripShift_)&sistrip::FlagBadStripMask_);
00080     return a;
00081   }
00082   
00083   inline unsigned int encode (const unsigned short& first, const unsigned short& NconsecutiveBadStrips, const unsigned short& flag=0) {
00084     return   ((first & sistrip::FirstBadStripMask_)<<sistrip::FirstBadStripShift_) | ((NconsecutiveBadStrips & sistrip::RangeBadStripMask_)<<sistrip::RangeBadStripShift_) | ((flag & sistrip::FlagBadStripMask_)<<sistrip::FlagBadStripShift_);
00085   }
00086 
00087 protected:
00088   Container v_badstrips; 
00089   Registry indexes;
00090 };
00091 
00092 #endif