Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:18

0001 #ifndef SiStripObjects_SiStripQuality_h
0002 #define SiStripObjects_SiStripQuality_h
0003 // -*- C++ -*-
0004 // -*- C++ -*-
0005 //
0006 // Package:     SiStripObjects
0007 // Class  :     SiStripQuality
0008 //
0009 /**\class SiStripQuality SiStripQuality.h SiStripQuality.cc
0010 
0011  Description: <one line class summary>
0012 
0013  Usage:
0014     <usage>
0015 
0016 */
0017 //
0018 // Author:      Domenico Giordano
0019 // Created:     Wed Sep 26 17:42:12 CEST 2007
0020 //
0021 
0022 #include "CondFormats/RunInfo/interface/RunInfo.h"
0023 #include "CondFormats/SiStripObjects/interface/SiStripBadStrip.h"
0024 #include "CondFormats/SiStripObjects/interface/SiStripDetVOff.h"
0025 #include "CalibFormats/SiStripObjects/interface/SiStripDetInfo.h"
0026 #include <vector>
0027 
0028 class SiStripDetCabling;
0029 class SiStripDetInfo;
0030 class TrackerTopology;
0031 
0032 class SiStripQuality final : public SiStripBadStrip {
0033 public:
0034   struct BadComponent {
0035     uint32_t detid;
0036     unsigned short BadApvs : 6;
0037     unsigned short BadFibers : 3;
0038     bool BadModule : 1;
0039   };
0040 
0041   class BadComponentStrictWeakOrdering {
0042   public:
0043     bool operator()(const BadComponent &p, uint32_t i) const { return p.detid < i; }
0044   };
0045 
0046   SiStripQuality() = delete;
0047   explicit SiStripQuality(SiStripDetInfo);
0048   SiStripQuality(const SiStripQuality &) = default;
0049   SiStripQuality(SiStripQuality &&) = default;
0050 
0051   ~SiStripQuality() override = default;
0052 
0053   void clear() {
0054     v_badstrips.clear();
0055     indexes.clear();
0056     BadComponentVect.clear();
0057     toCleanUp = false;
0058   }
0059 
0060   void add(uint32_t, const SiStripBadStrip::Range &);
0061   void add(const SiStripBadStrip *);
0062   void add(const SiStripDetCabling *);
0063   void add(const SiStripDetVOff *);
0064   /**
0065    * Used to get the cabling from RunInfo. <br>
0066    * It compares the feds from cabling with those from runInfo and it
0067    * turns off all the strips associated to feds that are off for the RunInfo
0068    * but not for FedCabling.
0069    */
0070   void add(const RunInfo *);
0071   void addInvalidConnectionFromCabling();
0072   void addNotConnectedConnectionFromCabling();
0073 
0074   bool cleanUp(bool force = false);
0075 
0076   void fillBadComponents();
0077 
0078   void ReduceGranularity(double);
0079 
0080   SiStripQuality difference(const SiStripQuality &) const;
0081 
0082   //------- Interface for the user ----------//
0083   bool IsModuleUsable(uint32_t detid) const;
0084 
0085   bool IsModuleBad(uint32_t detid) const;
0086   bool IsFiberBad(uint32_t detid, short fiberNb) const;
0087   bool IsApvBad(uint32_t detid, short apvNb) const;
0088   bool IsStripBad(uint32_t detid, short strip) const;
0089   bool IsStripBad(const Range &range, short strip) const;
0090   int nBadStripsOnTheLeft(const Range &range,
0091                           short strip) const;  // provides number of consecutive bad strips on the left of strip
0092                                                // (including strip)
0093   int nBadStripsOnTheRight(const Range &range,
0094                            short strip) const;  // provides number of consecutive bad strips on the right of strip
0095                                                 // (including strip)
0096 
0097   short getBadApvs(uint32_t detid) const;
0098   // each bad apv correspond to a bit to 1: num=
0099   // 0 <-> all good apvs
0100   // 1 <-> only apv 0 bad
0101   // 2<-> only apv 1 bad
0102   // 3<->  apv 0 and 1 bad
0103   // 4 <-> only apv 2 bad
0104   //...
0105   short getBadFibers(uint32_t detid) const;
0106   // each bad fiber correspond to a bit to 1: num=
0107   // 0 <-> all good fibers
0108   // 1 <-> only fiber 0 bad
0109   // 2<-> only fiber 1 bad
0110   // 3<->  fiber 0 and 1 bad
0111   // 4 <-> only fiber 2 bad
0112   //...
0113 
0114   const std::vector<BadComponent> &getBadComponentList() const { return BadComponentVect; }
0115 
0116   void compact(uint32_t detid, std::vector<unsigned int> &);
0117 
0118   inline void setPrintDebugOutput(const bool printDebug) { printDebug_ = printDebug; }
0119   inline void setUseEmptyRunInfo(const bool useEmptyRunInfo) { useEmptyRunInfo_ = useEmptyRunInfo; }
0120 
0121   SiStripDetCabling const *cabling() const { return SiStripDetCabling_; }
0122 
0123 private:
0124   void compact(std::vector<unsigned int> &, std::vector<unsigned int> &, unsigned short &);
0125   void subtract(std::vector<unsigned int> &, const std::vector<unsigned int> &);
0126   void subtraction(std::vector<unsigned int> &, const unsigned int &);
0127   bool put_replace(uint32_t detId, Range input);
0128 
0129   /**
0130    * Loop on all the fedIds, take the fedChannels and then the detId.
0131    * Depending on the value of a bool turn off or not the strips in the list.
0132    */
0133   void turnOffFeds(const std::vector<int> &fedsList, const bool turnOffStrips, const bool printDebug);
0134 
0135   /// Prints debug output for a given detId
0136   void printDetInfo(const TrackerTopology *const tTopo, uint32_t detId, uint32_t apvPairNumber, std::stringstream &ss);
0137   /// Prints debug output for the active feds comparing the list in RunInfo and
0138   /// FedCabling
0139   void printActiveFedsInfo(const std::vector<uint16_t> &activeFedsFromCabling,
0140                            const std::vector<int> &activeFedsFromRunInfo,
0141                            const std::vector<int> &differentFeds,
0142                            const bool printDebug);
0143 
0144   SiStripDetInfo info_;
0145   bool toCleanUp;
0146   std::vector<BadComponent> BadComponentVect;
0147 
0148   const SiStripDetCabling *SiStripDetCabling_;
0149   bool printDebug_;
0150   bool useEmptyRunInfo_;
0151 };
0152 
0153 #endif