Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    HLXMonitor
0004 // Class:      HLXMonitor
0005 //
0006 /**\class HLXMonitor HLXMonitor.cc DQM/HLXMonitor/src/HLXMonitor.cc
0007 
0008 Description: DQM Source for HLX histograms
0009 
0010 Implementation:
0011 <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Adam Hunt - Princeton University
0015 //           email:  ahunt@princeton.edu
0016 //         Created:  Thu Jul 19 02:29:59 EDT 2007
0017 //
0018 //
0019 
0020 #ifndef _HLXMONITOR_H_
0021 #define _HLXMONITOR_H_
0022 
0023 // system include fileshlx_dqm_sourceclient-live.cfg
0024 #include <cstdlib>
0025 #include <iomanip>
0026 #include <iostream>
0027 #include <memory>
0028 #include <string>
0029 #include <sys/time.h>
0030 
0031 // user include files
0032 #include "FWCore/Framework/interface/Frameworkfwd.h"  // Not included in example
0033 
0034 #include "FWCore/Framework/interface/Event.h"        // Not included in example
0035 #include "FWCore/Framework/interface/MakerMacros.h"  // Not included in example
0036 
0037 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0038 
0039 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0040 #include "DQMServices/Core/interface/DQMStore.h"
0041 
0042 #include "FWCore/ServiceRegistry/interface/Service.h"
0043 
0044 #include "RecoLuminosity/TCPReceiver/interface/LumiStructures.hh"
0045 #include "RecoLuminosity/TCPReceiver/interface/TCPReceiver.h"
0046 
0047 class HLXMonitor : public DQMEDAnalyzer {
0048 public:
0049   typedef HCAL_HLX::LUMI_SECTION LUMI_SECTION;
0050   typedef HCAL_HLX::TCPReceiver TCPReceiver;
0051   explicit HLXMonitor(const edm::ParameterSet &);
0052   ~HLXMonitor() override;
0053 
0054 private:
0055   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0056   void analyze(const edm::Event &, const edm::EventSetup &) override;
0057 
0058   void connectHLXTCP();
0059 
0060   void SetupHists(DQMStore::IBooker &);
0061   void SetupEventInfo(DQMStore::IBooker &);
0062 
0063   void FillHistograms(const LUMI_SECTION &);
0064   void FillHistoHFCompare(const LUMI_SECTION &);
0065   void FillReportSummary();
0066   void FillEventInfo(const LUMI_SECTION &, const edm::Event &e);
0067 
0068   void EndRun();
0069 
0070   double getUTCtime(timeval *a, timeval *b = nullptr);
0071 
0072   // ----------member data ---------------------------
0073   TCPReceiver HLXTCP;
0074 
0075   MonitorElement *Set1Below[36];
0076   MonitorElement *Set1Between[36];
0077   MonitorElement *Set1Above[36];
0078   MonitorElement *Set2Below[36];
0079   MonitorElement *Set2Between[36];
0080   MonitorElement *Set2Above[36];
0081   MonitorElement *ETSum[36];
0082 
0083   MonitorElement *HFCompareEtSum;
0084   MonitorElement *HFCompareOccBelowSet1;
0085   MonitorElement *HFCompareOccBetweenSet1;
0086   MonitorElement *HFCompareOccAboveSet1;
0087   MonitorElement *HFCompareOccBelowSet2;
0088   MonitorElement *HFCompareOccBetweenSet2;
0089   MonitorElement *HFCompareOccAboveSet2;
0090 
0091   MonitorElement *AvgEtSum;
0092   MonitorElement *AvgOccBelowSet1;
0093   MonitorElement *AvgOccBetweenSet1;
0094   MonitorElement *AvgOccAboveSet1;
0095   MonitorElement *AvgOccBelowSet2;
0096   MonitorElement *AvgOccBetweenSet2;
0097   MonitorElement *AvgOccAboveSet2;
0098 
0099   // Luminosity Monitoring
0100   MonitorElement *LumiAvgEtSum;
0101   MonitorElement *LumiAvgOccSet1;
0102   MonitorElement *LumiAvgOccSet2;
0103   MonitorElement *LumiInstantEtSum;
0104   MonitorElement *LumiInstantOccSet1;
0105   MonitorElement *LumiInstantOccSet2;
0106   MonitorElement *LumiIntegratedEtSum;
0107   MonitorElement *LumiIntegratedOccSet1;
0108   MonitorElement *LumiIntegratedOccSet2;
0109 
0110   // Sanity Check for Occupancy
0111   MonitorElement *SumAllOccSet1;
0112   MonitorElement *SumAllOccSet2;
0113   MonitorElement *MissingDQMDataCheck;
0114 
0115   // Signal and Background Levels
0116   MonitorElement *MaxInstLumiBX1;
0117   MonitorElement *MaxInstLumiBX2;
0118   MonitorElement *MaxInstLumiBX3;
0119   MonitorElement *MaxInstLumiBX4;
0120 
0121   MonitorElement *MaxInstLumiBXNum1;
0122   MonitorElement *MaxInstLumiBXNum2;
0123   MonitorElement *MaxInstLumiBXNum3;
0124   MonitorElement *MaxInstLumiBXNum4;
0125 
0126   // History plots - fill once per LS
0127   MonitorElement *HistAvgEtSumHFP;
0128   MonitorElement *HistAvgEtSumHFM;
0129   MonitorElement *HistAvgOccBelowSet1HFP;
0130   MonitorElement *HistAvgOccBelowSet1HFM;
0131   MonitorElement *HistAvgOccBetweenSet1HFP;
0132   MonitorElement *HistAvgOccBetweenSet1HFM;
0133   MonitorElement *HistAvgOccAboveSet1HFP;
0134   MonitorElement *HistAvgOccAboveSet1HFM;
0135   MonitorElement *HistAvgOccBelowSet2HFP;
0136   MonitorElement *HistAvgOccBelowSet2HFM;
0137   MonitorElement *HistAvgOccBetweenSet2HFP;
0138   MonitorElement *HistAvgOccBetweenSet2HFM;
0139   MonitorElement *HistAvgOccAboveSet2HFP;
0140   MonitorElement *HistAvgOccAboveSet2HFM;
0141   MonitorElement *BXvsTimeAvgEtSumHFP;
0142   MonitorElement *BXvsTimeAvgEtSumHFM;
0143 
0144   MonitorElement *HistAvgLumiEtSum;
0145   MonitorElement *HistAvgLumiOccSet1;
0146   MonitorElement *HistAvgLumiOccSet2;
0147   MonitorElement *HistInstantLumiEtSum;
0148   MonitorElement *HistInstantLumiOccSet1;
0149   MonitorElement *HistInstantLumiOccSet2;
0150   MonitorElement *HistInstantLumiEtSumError;
0151   MonitorElement *HistInstantLumiOccSet1Error;
0152   MonitorElement *HistInstantLumiOccSet2Error;
0153   MonitorElement *HistIntegratedLumiEtSum;
0154   MonitorElement *HistIntegratedLumiOccSet1;
0155   MonitorElement *HistIntegratedLumiOccSet2;
0156 
0157   MonitorElement *RecentInstantLumiEtSum;
0158   MonitorElement *RecentInstantLumiOccSet1;
0159   MonitorElement *RecentInstantLumiOccSet2;
0160   MonitorElement *RecentIntegratedLumiEtSum;
0161   MonitorElement *RecentIntegratedLumiOccSet1;
0162   MonitorElement *RecentIntegratedLumiOccSet2;
0163 
0164   // EventInfo Clone
0165   //////////////////////////////////////////////////////////////////
0166   /// These MEs are filled with the info from the most recent event
0167   ///   by the module
0168   //////////////////////////////////////////////////////////////////
0169   MonitorElement *runId_;
0170   MonitorElement *runStartTimeStamp_;  /// UTC time of the run start
0171   MonitorElement *eventId_;
0172   MonitorElement *lumisecId_;
0173   MonitorElement *eventTimeStamp_;
0174 
0175   //////////////////////////////////////////////////////////////////
0176   /// These MEs are either static or updated upon each analyze() call
0177   //////////////////////////////////////////////////////////////////
0178   MonitorElement *nUpdates_;               /// Number of collector updates (TBD)
0179   MonitorElement *processId_;              /// The PID associated with this job
0180   MonitorElement *processStartTimeStamp_;  /// The UTC time of the first event processed
0181   MonitorElement *processTimeStamp_;       /// The UTC time of the last event
0182   MonitorElement *processLatency_;         /// Time elapsed since the last event
0183   MonitorElement *processEventRate_;       /// Avg # of events in programmable window
0184                                            /// (default: 5 min)
0185   MonitorElement *processEvents_;          ///# of event processed so far
0186   MonitorElement *hostName_;               /// Hostname of the local machine
0187   MonitorElement *processName_;            /// DQM "name" of the job (eg, Hcal or DT)
0188   MonitorElement *workingDir_;             /// Current working directory of the job
0189   MonitorElement *cmsswVer_;               /// CMSSW version run for this job
0190   MonitorElement *dqmPatch_;               /// DQM patch version for this job
0191   MonitorElement *errSummary_;             /// Subdetector-specific error summary (float)
0192   MonitorElement *errSummaryEtaPhi_;       /// Subdetector-specific etaPhi summary (float)
0193   MonitorElement *errSummarySegment_[10];
0194 
0195   // Report Summary
0196   MonitorElement *reportSummary_;
0197   MonitorElement *reportSummaryMap_;
0198 
0199   unsigned int numActiveTowersSet1;
0200   unsigned int numActiveTowersSet2;
0201 
0202   unsigned int counter;
0203   unsigned char *rData;
0204   short int SectionComplete;
0205 
0206   // Parameters
0207   int listenPort;
0208   double XMIN, XMAX;
0209   unsigned int NBINS;
0210   bool Accumulate;
0211   std::string OutputFilePrefix;
0212   std::string OutputDir;
0213   std::string Style;  // BX, History, Distribution
0214   int SavePeriod;
0215   unsigned int NUM_HLX;
0216   unsigned int NUM_BUNCHES;
0217   unsigned int MAX_LS;
0218   unsigned int AquireMode;
0219   unsigned int TriggerBX;
0220   unsigned int MinLSBeforeSave;
0221 
0222   std::string monitorName_;
0223   int prescaleEvt_;
0224 
0225   unsigned int reconnTime;
0226   std::string DistribIP1;
0227   std::string DistribIP2;
0228 
0229   unsigned int set1BelowIndex;
0230   unsigned int set1BetweenIndex;
0231   unsigned int set1AboveIndex;
0232   unsigned int set2BelowIndex;
0233   unsigned int set2BetweenIndex;
0234   unsigned int set2AboveIndex;
0235 
0236   std::string eventInfoFolderHLX_;
0237   std::string eventInfoFolder_;
0238   std::string subSystemName_;
0239 
0240   unsigned int runNumLength;
0241   unsigned int secNumLength;
0242 
0243   std::string OccXAxisTitle;
0244   std::string OccYAxisTitle;
0245   std::string EtXAxisTitle;
0246   std::string EtYAxisTitle;
0247 
0248   HCAL_HLX::LUMI_SECTION lumiSection;
0249 
0250   bool currentRunEnded_;
0251   unsigned int runNumber_;
0252   unsigned int expectedNibbles_;
0253   unsigned int totalNibbles_[36];
0254 
0255   unsigned int HLXHFMap[36];
0256 
0257   unsigned int previousSection;
0258   unsigned int lumiSectionCount;
0259   int lsBinOld;
0260   double sectionInstantSumEt;
0261   double sectionInstantErrSumEt;
0262   double sectionInstantSumOcc1;
0263   double sectionInstantErrSumOcc1;
0264   double sectionInstantSumOcc2;
0265   double sectionInstantErrSumOcc2;
0266   double sectionInstantNorm;
0267 
0268   // EventInfo Parameters
0269   timeval currentTime_, lastUpdateTime_, lastAvgTime_;
0270   timeval runStartTime_;
0271   float evtRateWindow_;
0272   int evtRateCount_;
0273   int pEvent_;
0274 
0275   // Lumi section info
0276   double num4NibblePerLS_;
0277 };
0278 
0279 #endif