CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CalibFormats/SiStripObjects/interface/SiStripQuality.h

Go to the documentation of this file.
00001 #ifndef SiStripObjects_SiStripQuality_h
00002 #define SiStripObjects_SiStripQuality_h
00003 // -*- C++ -*-
00004 // -*- C++ -*-
00005 //
00006 // Package:     SiStripObjects
00007 // Class  :     SiStripQuality
00008 //
00017 //
00018 // Author:      Domenico Giordano
00019 // Created:     Wed Sep 26 17:42:12 CEST 2007
00020 // $Id: SiStripQuality.h,v 1.15 2013/01/22 17:03:17 chrjones Exp $
00021 //
00022 
00023 
00024 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
00025 #include "FWCore/ParameterSet/interface/FileInPath.h"
00026 #include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
00027 #include "CondFormats/RunInfo/interface/RunInfo.h"
00028 #include <vector>
00029 
00030 class SiStripDetCabling;
00031 class SiStripDetInfoFileReader;
00032 
00033 class SiStripQuality: public SiStripBadStrip {
00034 
00035  public:
00036 
00037   struct BadComponent{
00038     uint32_t detid;
00039     unsigned short BadApvs : 6;
00040     unsigned short BadFibers :3;
00041     bool BadModule :1;
00042   };
00043 
00044   class BadComponentStrictWeakOrdering{
00045   public:
00046     bool operator() (const BadComponent& p,const uint32_t i) const {return p.detid < i;}
00047   };
00048   
00049   SiStripQuality(); //takes default file for SiStripDetInfoFileReader
00050   SiStripQuality(edm::FileInPath&);
00051   SiStripQuality(const SiStripQuality&); //copy constructor
00052 
00053   ~SiStripQuality();
00054 
00055   void clear(){
00056     v_badstrips.clear();
00057     indexes.clear();
00058     BadComponentVect.clear();
00059     toCleanUp=false;
00060   }
00061 
00062   void add(const uint32_t&,const SiStripBadStrip::Range&);
00063   void add(const SiStripBadStrip*);
00064   void add(const SiStripDetCabling*);
00065   void add(const SiStripDetVOff*);
00072   void add(const RunInfo *);
00073   void addInvalidConnectionFromCabling();
00074   void addNotConnectedConnectionFromCabling();
00075 
00076   bool cleanUp(bool force=false);
00077 
00078   void fillBadComponents();
00079 
00080   void ReduceGranularity(double); 
00081 
00082   SiStripQuality& operator +=(const SiStripQuality&); 
00083   SiStripQuality& operator -=(const SiStripQuality&);
00084   const SiStripQuality operator -(const SiStripQuality&) const ;
00085   bool operator ==(const SiStripQuality&) const;
00086   bool operator !=(const SiStripQuality&) const;
00087   
00088   edm::FileInPath getFileInPath() const {return FileInPath_;}
00089 
00090   //------- Interface for the user ----------//
00091   bool IsModuleUsable(const uint32_t& detid) const;
00092 
00093   bool IsModuleBad(const uint32_t& detid) const;
00094   bool IsFiberBad(const uint32_t& detid, const short& fiberNb) const;
00095   bool IsApvBad(const uint32_t& detid, const short& apvNb) const;
00096   bool IsStripBad(const uint32_t& detid, const short& strip) const;
00097   bool IsStripBad(const Range& range, const short& strip) const;
00098   int  nBadStripsOnTheLeft(const Range& range, const short& strip) const; //provides number of consecutive bad strips on the left of strip (including strip)
00099   int  nBadStripsOnTheRight(const Range& range, const short& strip) const; //provides number of consecutive bad strips on the right of strip (including strip)
00100   
00101   short getBadApvs(const uint32_t& detid) const; 
00102   //each bad apv correspond to a bit to 1: num=
00103   //0 <-> all good apvs
00104   //1 <-> only apv 0 bad
00105   //2<-> only apv 1 bad
00106   //3<->  apv 0 and 1 bad
00107   // 4 <-> only apv 2 bad
00108   //...
00109   short getBadFibers(const uint32_t& detid) const; 
00110   //each bad fiber correspond to a bit to 1: num=
00111   //0 <-> all good fibers
00112   //1 <-> only fiber 0 bad
00113   //2<-> only fiber 1 bad
00114   //3<->  fiber 0 and 1 bad
00115   // 4 <-> only fiber 2 bad
00116   //...
00117   
00118   const std::vector<BadComponent>& getBadComponentList() const { return BadComponentVect; }   
00119 
00120   void compact(unsigned int&,std::vector<unsigned int>&);
00121 
00122   inline void setPrintDebugOutput(const bool printDebug) { printDebug_ = printDebug; }
00123   inline void setUseEmptyRunInfo(const bool useEmptyRunInfo) { useEmptyRunInfo_ = useEmptyRunInfo; }
00124 
00125  private:
00126 
00127   void compact(std::vector<unsigned int>&,std::vector<unsigned int>&,unsigned short&);
00128   void subtract(std::vector<unsigned int>&,const std::vector<unsigned int>&);
00129   void subtraction(std::vector<unsigned int>&,const unsigned int&);
00130   bool put_replace(const uint32_t& DetId, Range input);
00131 
00136   void turnOffFeds(const std::vector<int> & fedsList, const bool turnOffStrips, const bool printDebug);
00137 
00139   void printDetInfo(const uint32_t &detId, const uint32_t &apvPairNumber, std::stringstream &ss);
00141   void printActiveFedsInfo( const std::vector<uint16_t> & activeFedsFromCabling,
00142                             const std::vector<int> & activeFedsFromRunInfo,
00143                             const std::vector<int> & differentFeds,
00144                             const bool printDebug );
00145 
00146   bool toCleanUp;
00147   edm::FileInPath FileInPath_;
00148   SiStripDetInfoFileReader* reader;
00149 
00150   std::vector<BadComponent> BadComponentVect;
00151 
00152   const SiStripDetCabling *SiStripDetCabling_;  
00153   bool printDebug_;
00154   bool useEmptyRunInfo_;
00155 };
00156 
00157 #endif