00001 #ifndef SiStripObjects_SiStripQuality_h
00002 #define SiStripObjects_SiStripQuality_h
00003
00004
00005
00006
00007
00008
00017
00018
00019
00020
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 <vector>
00030
00031 class SiStripQuality: public SiStripBadStrip {
00032
00033 public:
00034
00035 struct BadComponent{
00036 uint32_t detid;
00037 unsigned short BadApvs : 6;
00038 unsigned short BadFibers :3;
00039 bool BadModule :1;
00040 };
00041
00042 class BadComponentStrictWeakOrdering{
00043 public:
00044 bool operator() (const BadComponent& p,const uint32_t i) const {return p.detid < i;}
00045 };
00046
00047 SiStripQuality();
00048 SiStripQuality(edm::FileInPath&);
00049 SiStripQuality(const SiStripQuality&);
00050
00051 ~SiStripQuality(){
00052 LogTrace("SiStripQuality") << "SiStripQuality destructor" << std::endl;
00053 delete reader;
00054 }
00055
00056 void clear(){
00057 v_badstrips.clear();
00058 indexes.clear();
00059 BadComponentVect.clear();
00060 toCleanUp=false;
00061 }
00062
00063 void add(const uint32_t&,const SiStripBadStrip::Range&);
00064 void add(const SiStripBadStrip*);
00065 void add(const SiStripDetCabling*);
00066 void addInvalidConnectionFromCabling();
00067 void addNotConnectedConnectionFromCabling();
00068
00069 bool cleanUp(bool force=false);
00070
00071 void fillBadComponents();
00072
00073 void ReduceGranularity(double);
00074
00075 SiStripQuality& operator +=(const SiStripQuality&);
00076 SiStripQuality& operator -=(const SiStripQuality&);
00077 const SiStripQuality operator -(const SiStripQuality&) const ;
00078 bool operator ==(const SiStripQuality&) const;
00079 bool operator !=(const SiStripQuality&) const;
00080
00081 edm::FileInPath getFileInPath() const {return FileInPath_;}
00082
00083
00084 bool IsModuleUsable(const uint32_t& detid) const;
00085
00086 bool IsModuleBad(const uint32_t& detid) const;
00087 bool IsFiberBad(const uint32_t& detid, const short& fiberNb) const;
00088 bool IsApvBad(const uint32_t& detid, const short& apvNb) const;
00089 bool IsStripBad(const uint32_t& detid, const short& strip) const;
00090 bool IsStripBad(const Range& range, const short& strip) const;
00091 int nBadStripsOnTheLeft(const Range& range, const short& strip) const;
00092 int nBadStripsOnTheRight(const Range& range, const short& strip) const;
00093
00094 short getBadApvs(const uint32_t& detid) const;
00095
00096
00097
00098
00099
00100
00101
00102 short getBadFibers(const uint32_t& detid) const;
00103
00104
00105
00106
00107
00108
00109
00110
00111 const std::vector<BadComponent>& getBadComponentList() const { return BadComponentVect; }
00112
00113 void compact(unsigned int&,std::vector<unsigned int>&);
00114
00115 private:
00116
00117 void compact(std::vector<unsigned int>&,std::vector<unsigned int>&,unsigned short&);
00118 void subtract(std::vector<unsigned int>&,const std::vector<unsigned int>&);
00119 void subtraction(std::vector<unsigned int>&,const unsigned int&);
00120 bool put_replace(const uint32_t& DetId, Range input);
00121
00122 bool toCleanUp;
00123 edm::FileInPath FileInPath_;
00124 SiStripDetInfoFileReader* reader;
00125
00126 std::vector<BadComponent> BadComponentVect;
00127
00128 const SiStripDetCabling *SiStripDetCabling_;
00129 };
00130
00131 #endif