Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:47

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