CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/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.14 2009/07/28 08:39:55 demattia Exp $
00021 //
00022 
00023 
00024 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
00025 #include "FWCore/ParameterSet/interface/FileInPath.h"
00026 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00028 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00029 #include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
00030 #include "CondFormats/RunInfo/interface/RunInfo.h"
00031 #include <vector>
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     LogTrace("SiStripQuality") << "SiStripQuality destructor" << std::endl; 
00055     delete reader;
00056   }
00057 
00058   void clear(){
00059     v_badstrips.clear();
00060     indexes.clear();
00061     BadComponentVect.clear();
00062     toCleanUp=false;
00063   }
00064 
00065   void add(const uint32_t&,const SiStripBadStrip::Range&);
00066   void add(const SiStripBadStrip*);
00067   void add(const SiStripDetCabling*);
00068   void add(const SiStripDetVOff*);
00075   void add(const RunInfo *);
00076   void addInvalidConnectionFromCabling();
00077   void addNotConnectedConnectionFromCabling();
00078 
00079   bool cleanUp(bool force=false);
00080 
00081   void fillBadComponents();
00082 
00083   void ReduceGranularity(double); 
00084 
00085   SiStripQuality& operator +=(const SiStripQuality&); 
00086   SiStripQuality& operator -=(const SiStripQuality&);
00087   const SiStripQuality operator -(const SiStripQuality&) const ;
00088   bool operator ==(const SiStripQuality&) const;
00089   bool operator !=(const SiStripQuality&) const;
00090   
00091   edm::FileInPath getFileInPath() const {return FileInPath_;}
00092 
00093   //------- Interface for the user ----------//
00094   bool IsModuleUsable(const uint32_t& detid) const;
00095 
00096   bool IsModuleBad(const uint32_t& detid) const;
00097   bool IsFiberBad(const uint32_t& detid, const short& fiberNb) const;
00098   bool IsApvBad(const uint32_t& detid, const short& apvNb) const;
00099   bool IsStripBad(const uint32_t& detid, const short& strip) const;
00100   bool IsStripBad(const Range& range, const short& strip) const;
00101   int  nBadStripsOnTheLeft(const Range& range, const short& strip) const; //provides number of consecutive bad strips on the left of strip (including strip)
00102   int  nBadStripsOnTheRight(const Range& range, const short& strip) const; //provides number of consecutive bad strips on the right of strip (including strip)
00103   
00104   short getBadApvs(const uint32_t& detid) const; 
00105   //each bad apv correspond to a bit to 1: num=
00106   //0 <-> all good apvs
00107   //1 <-> only apv 0 bad
00108   //2<-> only apv 1 bad
00109   //3<->  apv 0 and 1 bad
00110   // 4 <-> only apv 2 bad
00111   //...
00112   short getBadFibers(const uint32_t& detid) const; 
00113   //each bad fiber correspond to a bit to 1: num=
00114   //0 <-> all good fibers
00115   //1 <-> only fiber 0 bad
00116   //2<-> only fiber 1 bad
00117   //3<->  fiber 0 and 1 bad
00118   // 4 <-> only fiber 2 bad
00119   //...
00120   
00121   const std::vector<BadComponent>& getBadComponentList() const { return BadComponentVect; }   
00122 
00123   void compact(unsigned int&,std::vector<unsigned int>&);
00124 
00125   inline void setPrintDebugOutput(const bool printDebug) { printDebug_ = printDebug; }
00126   inline void setUseEmptyRunInfo(const bool useEmptyRunInfo) { useEmptyRunInfo_ = useEmptyRunInfo; }
00127 
00128  private:
00129 
00130   void compact(std::vector<unsigned int>&,std::vector<unsigned int>&,unsigned short&);
00131   void subtract(std::vector<unsigned int>&,const std::vector<unsigned int>&);
00132   void subtraction(std::vector<unsigned int>&,const unsigned int&);
00133   bool put_replace(const uint32_t& DetId, Range input);
00134 
00139   void turnOffFeds(const std::vector<int> & fedsList, const bool turnOffStrips, const bool printDebug);
00140 
00142   void printDetInfo(const uint32_t &detId, const uint32_t &apvPairNumber, std::stringstream &ss);
00144   void printActiveFedsInfo( const std::vector<uint16_t> & activeFedsFromCabling,
00145                             const std::vector<int> & activeFedsFromRunInfo,
00146                             const std::vector<int> & differentFeds,
00147                             const bool printDebug );
00148 
00149   bool toCleanUp;
00150   edm::FileInPath FileInPath_;
00151   SiStripDetInfoFileReader* reader;
00152 
00153   std::vector<BadComponent> BadComponentVect;
00154 
00155   const SiStripDetCabling *SiStripDetCabling_;  
00156   bool printDebug_;
00157   bool useEmptyRunInfo_;
00158 };
00159 
00160 #endif