HLXMonitor

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
// -*- C++ -*-
//
// Package:    HLXMonitor
// Class:      HLXMonitor
//
/**\class HLXMonitor HLXMonitor.cc DQM/HLXMonitor/src/HLXMonitor.cc

Description: DQM Source for HLX histograms

Implementation:
<Notes on implementation>
*/
//
// Original Author:  Adam Hunt - Princeton University
//           email:  ahunt@princeton.edu
//         Created:  Thu Jul 19 02:29:59 EDT 2007
//
//

#ifndef _HLXMONITOR_H_
#define _HLXMONITOR_H_

// system include fileshlx_dqm_sourceclient-live.cfg
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <memory>
#include <string>
#include <sys/time.h>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"  // Not included in example

#include "FWCore/Framework/interface/Event.h"        // Not included in example
#include "FWCore/Framework/interface/MakerMacros.h"  // Not included in example

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DQMServices/Core/interface/DQMEDAnalyzer.h"
#include "DQMServices/Core/interface/DQMStore.h"

#include "FWCore/ServiceRegistry/interface/Service.h"

#include "RecoLuminosity/TCPReceiver/interface/LumiStructures.hh"
#include "RecoLuminosity/TCPReceiver/interface/TCPReceiver.h"

class HLXMonitor : public DQMEDAnalyzer {
public:
  typedef HCAL_HLX::LUMI_SECTION LUMI_SECTION;
  typedef HCAL_HLX::TCPReceiver TCPReceiver;
  explicit HLXMonitor(const edm::ParameterSet &);
  ~HLXMonitor() override;

private:
  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
  void analyze(const edm::Event &, const edm::EventSetup &) override;

  void connectHLXTCP();

  void SetupHists(DQMStore::IBooker &);
  void SetupEventInfo(DQMStore::IBooker &);

  void FillHistograms(const LUMI_SECTION &);
  void FillHistoHFCompare(const LUMI_SECTION &);
  void FillReportSummary();
  void FillEventInfo(const LUMI_SECTION &, const edm::Event &e);

  void EndRun();

  double getUTCtime(timeval *a, timeval *b = nullptr);

  // ----------member data ---------------------------
  TCPReceiver HLXTCP;

  MonitorElement *Set1Below[36];
  MonitorElement *Set1Between[36];
  MonitorElement *Set1Above[36];
  MonitorElement *Set2Below[36];
  MonitorElement *Set2Between[36];
  MonitorElement *Set2Above[36];
  MonitorElement *ETSum[36];

  MonitorElement *HFCompareEtSum;
  MonitorElement *HFCompareOccBelowSet1;
  MonitorElement *HFCompareOccBetweenSet1;
  MonitorElement *HFCompareOccAboveSet1;
  MonitorElement *HFCompareOccBelowSet2;
  MonitorElement *HFCompareOccBetweenSet2;
  MonitorElement *HFCompareOccAboveSet2;

  MonitorElement *AvgEtSum;
  MonitorElement *AvgOccBelowSet1;
  MonitorElement *AvgOccBetweenSet1;
  MonitorElement *AvgOccAboveSet1;
  MonitorElement *AvgOccBelowSet2;
  MonitorElement *AvgOccBetweenSet2;
  MonitorElement *AvgOccAboveSet2;

  // Luminosity Monitoring
  MonitorElement *LumiAvgEtSum;
  MonitorElement *LumiAvgOccSet1;
  MonitorElement *LumiAvgOccSet2;
  MonitorElement *LumiInstantEtSum;
  MonitorElement *LumiInstantOccSet1;
  MonitorElement *LumiInstantOccSet2;
  MonitorElement *LumiIntegratedEtSum;
  MonitorElement *LumiIntegratedOccSet1;
  MonitorElement *LumiIntegratedOccSet2;

  // Sanity Check for Occupancy
  MonitorElement *SumAllOccSet1;
  MonitorElement *SumAllOccSet2;
  MonitorElement *MissingDQMDataCheck;

  // Signal and Background Levels
  MonitorElement *MaxInstLumiBX1;
  MonitorElement *MaxInstLumiBX2;
  MonitorElement *MaxInstLumiBX3;
  MonitorElement *MaxInstLumiBX4;

  MonitorElement *MaxInstLumiBXNum1;
  MonitorElement *MaxInstLumiBXNum2;
  MonitorElement *MaxInstLumiBXNum3;
  MonitorElement *MaxInstLumiBXNum4;

  // History plots - fill once per LS
  MonitorElement *HistAvgEtSumHFP;
  MonitorElement *HistAvgEtSumHFM;
  MonitorElement *HistAvgOccBelowSet1HFP;
  MonitorElement *HistAvgOccBelowSet1HFM;
  MonitorElement *HistAvgOccBetweenSet1HFP;
  MonitorElement *HistAvgOccBetweenSet1HFM;
  MonitorElement *HistAvgOccAboveSet1HFP;
  MonitorElement *HistAvgOccAboveSet1HFM;
  MonitorElement *HistAvgOccBelowSet2HFP;
  MonitorElement *HistAvgOccBelowSet2HFM;
  MonitorElement *HistAvgOccBetweenSet2HFP;
  MonitorElement *HistAvgOccBetweenSet2HFM;
  MonitorElement *HistAvgOccAboveSet2HFP;
  MonitorElement *HistAvgOccAboveSet2HFM;
  MonitorElement *BXvsTimeAvgEtSumHFP;
  MonitorElement *BXvsTimeAvgEtSumHFM;

  MonitorElement *HistAvgLumiEtSum;
  MonitorElement *HistAvgLumiOccSet1;
  MonitorElement *HistAvgLumiOccSet2;
  MonitorElement *HistInstantLumiEtSum;
  MonitorElement *HistInstantLumiOccSet1;
  MonitorElement *HistInstantLumiOccSet2;
  MonitorElement *HistInstantLumiEtSumError;
  MonitorElement *HistInstantLumiOccSet1Error;
  MonitorElement *HistInstantLumiOccSet2Error;
  MonitorElement *HistIntegratedLumiEtSum;
  MonitorElement *HistIntegratedLumiOccSet1;
  MonitorElement *HistIntegratedLumiOccSet2;

  MonitorElement *RecentInstantLumiEtSum;
  MonitorElement *RecentInstantLumiOccSet1;
  MonitorElement *RecentInstantLumiOccSet2;
  MonitorElement *RecentIntegratedLumiEtSum;
  MonitorElement *RecentIntegratedLumiOccSet1;
  MonitorElement *RecentIntegratedLumiOccSet2;

  // EventInfo Clone
  //////////////////////////////////////////////////////////////////
  /// These MEs are filled with the info from the most recent event
  ///   by the module
  //////////////////////////////////////////////////////////////////
  MonitorElement *runId_;
  MonitorElement *runStartTimeStamp_;  /// UTC time of the run start
  MonitorElement *eventId_;
  MonitorElement *lumisecId_;
  MonitorElement *eventTimeStamp_;

  //////////////////////////////////////////////////////////////////
  /// These MEs are either static or updated upon each analyze() call
  //////////////////////////////////////////////////////////////////
  MonitorElement *nUpdates_;               /// Number of collector updates (TBD)
  MonitorElement *processId_;              /// The PID associated with this job
  MonitorElement *processStartTimeStamp_;  /// The UTC time of the first event processed
  MonitorElement *processTimeStamp_;       /// The UTC time of the last event
  MonitorElement *processLatency_;         /// Time elapsed since the last event
  MonitorElement *processEventRate_;       /// Avg # of events in programmable window
                                           /// (default: 5 min)
  MonitorElement *processEvents_;          ///# of event processed so far
  MonitorElement *hostName_;               /// Hostname of the local machine
  MonitorElement *processName_;            /// DQM "name" of the job (eg, Hcal or DT)
  MonitorElement *workingDir_;             /// Current working directory of the job
  MonitorElement *cmsswVer_;               /// CMSSW version run for this job
  MonitorElement *dqmPatch_;               /// DQM patch version for this job
  MonitorElement *errSummary_;             /// Subdetector-specific error summary (float)
  MonitorElement *errSummaryEtaPhi_;       /// Subdetector-specific etaPhi summary (float)
  MonitorElement *errSummarySegment_[10];

  // Report Summary
  MonitorElement *reportSummary_;
  MonitorElement *reportSummaryMap_;

  unsigned int numActiveTowersSet1;
  unsigned int numActiveTowersSet2;

  unsigned int counter;
  unsigned char *rData;
  short int SectionComplete;

  // Parameters
  int listenPort;
  double XMIN, XMAX;
  unsigned int NBINS;
  bool Accumulate;
  std::string OutputFilePrefix;
  std::string OutputDir;
  std::string Style;  // BX, History, Distribution
  int SavePeriod;
  unsigned int NUM_HLX;
  unsigned int NUM_BUNCHES;
  unsigned int MAX_LS;
  unsigned int AquireMode;
  unsigned int TriggerBX;
  unsigned int MinLSBeforeSave;

  std::string monitorName_;
  int prescaleEvt_;

  unsigned int reconnTime;
  std::string DistribIP1;
  std::string DistribIP2;

  unsigned int set1BelowIndex;
  unsigned int set1BetweenIndex;
  unsigned int set1AboveIndex;
  unsigned int set2BelowIndex;
  unsigned int set2BetweenIndex;
  unsigned int set2AboveIndex;

  std::string eventInfoFolderHLX_;
  std::string eventInfoFolder_;
  std::string subSystemName_;

  unsigned int runNumLength;
  unsigned int secNumLength;

  std::string OccXAxisTitle;
  std::string OccYAxisTitle;
  std::string EtXAxisTitle;
  std::string EtYAxisTitle;

  HCAL_HLX::LUMI_SECTION lumiSection;

  bool currentRunEnded_;
  unsigned int runNumber_;
  unsigned int expectedNibbles_;
  unsigned int totalNibbles_[36];

  unsigned int HLXHFMap[36];

  unsigned int previousSection;
  unsigned int lumiSectionCount;
  int lsBinOld;
  double sectionInstantSumEt;
  double sectionInstantErrSumEt;
  double sectionInstantSumOcc1;
  double sectionInstantErrSumOcc1;
  double sectionInstantSumOcc2;
  double sectionInstantErrSumOcc2;
  double sectionInstantNorm;

  // EventInfo Parameters
  timeval currentTime_, lastUpdateTime_, lastAvgTime_;
  timeval runStartTime_;
  float evtRateWindow_;
  int evtRateCount_;
  int pEvent_;

  // Lumi section info
  double num4NibblePerLS_;
};

#endif