Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:37

0001 #ifndef SiPixelStatusHarvester_H
0002 #define SiPixelStatusHarvester_H
0003 
0004 /** \class SiPixelStatusHarvester
0005  *  harvest per-lumi prduced SiPixelDetector status and make the payload for SiPixelQualityFromDB
0006  *
0007  */
0008 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 
0012 #include "FWCore/Utilities/interface/ESGetToken.h"
0013 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
0014 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
0015 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0016 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0017 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0018 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0019 #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
0020 #include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h"
0021 
0022 // Pixel quality harvester
0023 #include "CalibTracker/SiPixelQuality/interface/SiPixelStatusManager.h"
0024 // PixelDQM Framework
0025 #include "DQM/SiPixelPhase1Common/interface/SiPixelPhase1Base.h"
0026 // PixelPhase1 HelperClass
0027 #include "DQM/SiPixelPhase1Common/interface/SiPixelCoordinates.h"
0028 
0029 // Threshold testing
0030 #include "TH1.h"
0031 #include "TFile.h"
0032 
0033 class SiPixelStatusHarvester : public DQMOneEDAnalyzer<edm::one::WatchLuminosityBlocks>,
0034                                private HistogramManagerHolder {
0035   enum { BADROC, PERMANENTBADROC, FEDERRORROC, STUCKTBMROC, OTHERBADROC, PROMPTBADROC };
0036 
0037 public:
0038   // Constructor
0039   SiPixelStatusHarvester(const edm::ParameterSet&);
0040 
0041   // Destructor
0042   ~SiPixelStatusHarvester() override;
0043 
0044   // Operations
0045   void beginJob() override;
0046   void bookHistograms(DQMStore::IBooker& iBooker, edm::Run const&, const edm::EventSetup&) final;
0047   void dqmEndRun(const edm::Run&, const edm::EventSetup&) final;
0048   void analyze(const edm::Event& iEvent, const edm::EventSetup&) final;
0049 
0050   void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) final;
0051   void endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) final;
0052 
0053 private:
0054   // Parameters
0055   double thresholdL1_, thresholdL2_, thresholdL3_, thresholdL4_, thresholdRNG1_, thresholdRNG2_;
0056   std::string outputBase_;
0057   int aveDigiOcc_;
0058   int nLumi_;
0059   std::string moduleName_;
0060   std::string label_;
0061   // harvest helper classs that setup the IOV structure
0062   SiPixelStatusManager siPixelStatusManager_;
0063   // debug mode
0064   bool debug_;
0065   // for DB output naming
0066   std::string recordName_;
0067 
0068   // permanent known bad components
0069   const SiPixelQuality* badPixelInfo_;
0070 
0071   // totoal number of lumi blocks with non-zero pixel DIGIs
0072   int countLumi_ = 0;
0073   // last lumi section of the SiPixeDetectorStatus data
0074   edm::LuminosityBlockNumber_t endLumiBlock_;
0075 
0076   const TrackerGeometry* trackerGeometry_ = nullptr;
0077   const SiPixelFedCabling* cablingMap_ = nullptr;
0078   std::map<int, unsigned int> sensorSize_;
0079 
0080   SiPixelCoordinates coord_;
0081 
0082   // pixel online to offline pixel row/column
0083   std::map<int, std::map<int, std::pair<int, int> > > pixelO2O_;
0084 
0085   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeometryToken_;
0086   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopologyToken_;
0087   edm::ESGetToken<SiPixelFedCablingMap, SiPixelFedCablingMapRcd> siPixelFedCablingMapToken_;
0088   edm::ESGetToken<SiPixelQuality, SiPixelQualityFromDbRcd> siPixelQualityToken_;
0089 
0090   //Helper functions
0091   std::vector<std::string> substructures;
0092   double perLayerRingAverage(int detid, SiPixelDetectorStatus tmpSiPixelStatus);
0093   std::string substructure(int detid);
0094 
0095   // "step function" for IOV
0096   edm::LuminosityBlockNumber_t stepIOV(edm::LuminosityBlockNumber_t pin,
0097                                        std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t> IOV);
0098 
0099   // boolean function to check whether two SiPixelQualitys (pyloads) are identical
0100   bool equal(SiPixelQuality a, SiPixelQuality b);
0101 
0102   // Tag constructor
0103   void constructTag(std::map<int, SiPixelQuality> siPixelQualityTag,
0104                     edm::Service<cond::service::PoolDBOutputService>& poolDbService,
0105                     std::string tagName,
0106                     edm::Run const& iRun);
0107 };
0108 
0109 #endif