Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:55:32

0001 #ifndef DQM_L1TMONITORCLIENT_L1TOCCUPANCYCLIENT_H
0002 #define DQM_L1TMONITORCLIENT_L1TOCCUPANCYCLIENT_H
0003 
0004 #include "FWCore/Framework/interface/Frameworkfwd.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 
0009 #include "DQMServices/Core/interface/DQMStore.h"
0010 #include "FWCore/Framework/interface/LuminosityBlock.h"
0011 #include "DQM/L1TMonitorClient/interface/L1TOccupancyClientHistogramService.h"
0012 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0013 
0014 #include <memory>
0015 #include <iostream>
0016 #include <fstream>
0017 #include <string>
0018 #include <vector>
0019 #include <map>
0020 #include <TH1F.h>
0021 #include <TH1D.h>
0022 #include <TH2F.h>
0023 #include <TF1.h>
0024 #include <TProfile2D.h>
0025 #include <TNamed.h>
0026 #include <TRandom3.h>
0027 #include <TDirectory.h>
0028 
0029 class L1TOccupancyClient : public DQMEDHarvester {
0030 public:
0031   /// Constructor
0032   L1TOccupancyClient(const edm::ParameterSet& ps);
0033 
0034   /// Destructor
0035   ~L1TOccupancyClient() override;
0036 
0037 protected:
0038   void dqmEndJob(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) override;
0039   void book(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter);
0040   void dqmEndLuminosityBlock(DQMStore::IBooker& ibooker,
0041                              DQMStore::IGetter& igetter,
0042                              const edm::LuminosityBlock& lumiSeg,
0043                              const edm::EventSetup& c) override;  // DQM Client Diagnostic
0044 
0045   //DQM test routines
0046   double xySymmetry(const edm::ParameterSet& ps,
0047                     std::string test_name,
0048                     std::vector<std::pair<int, double> >& deadChannels,
0049                     std::vector<std::pair<int, double> >& statDev,
0050                     bool& enoughStats);  // Performs the checking of enough statistics and invokes compareWithStrip()
0051 
0052 private:
0053   edm::ParameterSet parameters_;                  //parameter set from python
0054   L1TOccupancyClientHistogramService* hservice_;  //histogram service
0055   TFile* file_;                                   //output file for test results
0056 
0057   // bool
0058   bool verbose_;  //verbose mode
0059 
0060   // vector
0061   std::vector<edm::ParameterSet> tests_;        // all tests defined in python file
0062   std::vector<edm::ParameterSet*> mValidTests;  // Valid tests
0063   // map
0064   std::map<std::string, MonitorElement*> meResults;
0065   std::map<std::string, MonitorElement*> meDifferential;
0066   std::map<std::string, MonitorElement*> meCertification;
0067 
0068 private:
0069   // performs the actual test
0070   int compareWithStrip(TH2F* histo,
0071                        std::string test,
0072                        int binStrip,
0073                        int nBins,
0074                        int axis,
0075                        double avg,
0076                        const edm::ParameterSet& ps,
0077                        std::vector<std::pair<int, double> >& deadChannels);
0078 
0079   // Gets the bin-number of a bin with content and on axis
0080   void getBinCoordinateOnAxisWithValue(TH2F* h2f, double content, int& coord, int axis);
0081 
0082   // Puts out the bad and masked channels of a specific test to h2f
0083   void printDeadChannels(const std::vector<std::pair<int, double> >& deadChannels,
0084                          TH2F* h2f,
0085                          const std::vector<std::pair<int, double> >& statDev,
0086                          std::string test_name);
0087 
0088   // Gets the average (avrgMode=1 arithmetic, avrgMode=2 median) for a specific binStrip in histo h2f for a specific test
0089   double getAvrg(TH2F* h2f, std::string test, int axis, int nBins, int binStrip, int avrgMode);
0090 };
0091 
0092 #endif