CMS 3D CMS Logo

HLXMonitor.cc
Go to the documentation of this file.
1 /*
2  Author: Adam Hunt
3  email: ahunt@princeton.edu
4 */
7 
8 // STL Headers
9 
10 #include <cmath>
11 #include <iomanip>
12 #include <TSystem.h>
13 
14 using std::cout;
15 using std::endl;
16 
18  NUM_HLX = iConfig.getUntrackedParameter<unsigned int>("numHlx", 36);
19  NUM_BUNCHES = iConfig.getUntrackedParameter<unsigned int>("numBunches", 3564);
20  MAX_LS = iConfig.getUntrackedParameter<unsigned int>("maximumNumLS", 480);
21  listenPort = iConfig.getUntrackedParameter<unsigned int>("SourcePort", 51001);
23  iConfig.getUntrackedParameter<std::string>("outputFile", "lumi");
24  OutputDir = iConfig.getUntrackedParameter<std::string>("outputDir", " data");
25  SavePeriod = iConfig.getUntrackedParameter<unsigned int>("SavePeriod", 10);
26  NBINS = iConfig.getUntrackedParameter<unsigned int>("NBINS",
27  297); // 12 BX per bin
28  XMIN = iConfig.getUntrackedParameter<double>("XMIN", 0);
29  XMAX = iConfig.getUntrackedParameter<double>("XMAX", 3564);
30  Style = iConfig.getUntrackedParameter<std::string>("Style", "BX");
31  AquireMode = iConfig.getUntrackedParameter<unsigned int>("AquireMode", 0);
32  Accumulate = iConfig.getUntrackedParameter<bool>("Accumulate", true); // all
33  TriggerBX = iConfig.getUntrackedParameter<unsigned int>("TriggerBX", 50);
35  iConfig.getUntrackedParameter<unsigned int>("MinLSBeforeSave", 1);
36  reconnTime =
37  iConfig.getUntrackedParameter<unsigned int>("ReconnectionTime", 5);
38  DistribIP1 = iConfig.getUntrackedParameter<std::string>("PrimaryHLXDAQIP",
39  "vmepcs2f17-18");
40  DistribIP2 = iConfig.getUntrackedParameter<std::string>("SecondaryHLXDAQIP",
41  "vmepcs2f17-19");
42  ResetAtNewRun = iConfig.getUntrackedParameter<bool>("NewRun_Reset", true);
43 
45  "eventInfoFolderHLX", "EventInfoHLX");
47  "eventInfoFolder", "EventInfo");
49  iConfig.getUntrackedParameter<std::string>("subSystemName", "HLX");
50 
51  // Set the lumi section counter
52  lsBinOld = 0;
53  previousSection = 0;
54  lumiSectionCount = 0;
62 
63  // HLX Config info
64  set1BelowIndex = 0;
65  set1BetweenIndex = 1;
66  set1AboveIndex = 2;
67  set2BelowIndex = 3;
68  set2BetweenIndex = 4;
69  set2AboveIndex = 5;
70 
71  runNumLength = 9;
72  secNumLength = 8;
73 
74  if (NUM_HLX > 36) NUM_HLX = 36;
75 
76  if (NUM_BUNCHES > 3564) NUM_BUNCHES = 3564;
77 
78  if (XMAX <= XMIN) {
79  XMIN = 0;
80  if (XMAX <= 0) XMAX = 3564;
81  }
82 
83  if ((Style == "History") || (NBINS == 0)) {
84  NBINS = (unsigned int)(XMAX - XMIN);
85  }
86 
87  monitorName_ =
88  iConfig.getUntrackedParameter<std::string>("monitorName", "HLX");
89  // cout << "Monitor name = " << monitorName_ << endl;
90  prescaleEvt_ = iConfig.getUntrackedParameter<int>("prescaleEvt", -1);
91  // cout << "===>DQM event prescale = " << prescaleEvt_ << " events "<< endl;
92 
93  unsigned int HLXHFMapTemp[] = {31, 32, 33, 34, 35, 18, // s2f07 hf-
94  13, 14, 15, 16, 17, 0, // s2f07 hf+
95  25, 26, 27, 28, 29, 30, // s2f05 hf-
96  7, 8, 9, 10, 11, 12, // s2f05 hf+
97  19, 20, 21, 22, 23, 24, // s2f02 hf-
98  1, 2, 3, 4, 5, 6}; // s2f02 hf+
99 
100  currentRunEnded_ = true;
101  runNumber_ = 0;
102  expectedNibbles_ = 0;
103 
104  for (int iHLX = 0; iHLX < 36; ++iHLX) {
105  HLXHFMap[iHLX] = HLXHFMapTemp[iHLX];
106  // std::cout << "At " << iHLX << " Wedge " << HLXHFMap[iHLX] << std::endl;
107  totalNibbles_[iHLX] = 0;
108  }
109 
110  num4NibblePerLS_ = 16.0;
111 
112  connectHLXTCP(); // this was originally done in beginJob()
113 }
114 
116  HLXTCP.Disconnect();
117  EndRun();
118 }
119 
120 // Method called once each job just before starting event loop
123  int errorCode = HLXTCP.SetPort(listenPort);
124  cout << "SetPort: " << listenPort << " Success: " << errorCode << endl;
125  errorCode = HLXTCP.SetMode(AquireMode);
126  cout << "AquireMode: " << AquireMode << " Success: " << errorCode << endl;
127 
128  while (HLXTCP.IsConnected() == false) {
130  if (HLXTCP.Connect() != 1) {
131  std::cout << "Failed to connect to " << DistribIP1 << "." << std::endl;
132  sleep(1);
133  std::cout << "Trying " << DistribIP2 << std::endl;
135  if (HLXTCP.Connect() == 1) break;
136  std::cout << "Failed to connect to " << DistribIP2 << "." << std::endl;
137  std::cout << " Reconnect in " << reconnTime << " seconds." << std::endl;
138  sleep(reconnTime);
139  }
140  }
141  if (HLXTCP.IsConnected() == true) {
142  std::cout << "Successfully connected." << std::endl;
143  }
144 }
145 
146 // ------------ Setup the monitoring elements ---------------
148  edm::EventSetup const&) {
149  SetupHists(iBooker);
150  SetupEventInfo(iBooker);
151 }
152 
154  iBooker.setCurrentFolder(monitorName_ + "/HFPlus");
155 
156  for (unsigned int iWedge = 0; iWedge < 18 && iWedge < NUM_HLX; ++iWedge) {
157  std::ostringstream tempStreamer;
158  tempStreamer << std::dec << std::setw(2) << std::setfill('0')
159  << (iWedge + 1);
160 
161  std::ostringstream wedgeNum;
162  wedgeNum << std::dec << (iWedge % 18) + 1;
163 
164  iBooker.setCurrentFolder(monitorName_ + "/HFPlus/Wedge" +
165  tempStreamer.str());
166 
167  Set1Below[iWedge] = iBooker.book1D(
168  "Set1_Below",
169  "HF+ Wedge " + wedgeNum.str() + ": Below Threshold 1 - Set 1", NBINS,
170  XMIN, XMAX);
171  Set1Between[iWedge] = iBooker.book1D(
172  "Set1_Between",
173  "HF+ Wedge " + wedgeNum.str() + ": Between Threshold 1 & 2 - Set 1",
174  NBINS, XMIN, XMAX);
175  Set1Above[iWedge] = iBooker.book1D(
176  "Set1_Above",
177  "HF+ Wedge " + wedgeNum.str() + ": Above Threshold 2 - Set 1", NBINS,
178  XMIN, XMAX);
179  Set2Below[iWedge] = iBooker.book1D(
180  "Set2_Below",
181  "HF+ Wedge " + wedgeNum.str() + ": Below Threshold 1 - Set 2", NBINS,
182  XMIN, XMAX);
183  Set2Between[iWedge] = iBooker.book1D(
184  "Set2_Between",
185  "HF+ Wedge " + wedgeNum.str() + ": Between Threshold 1 & 2 - Set 2",
186  NBINS, XMIN, XMAX);
187  Set2Above[iWedge] = iBooker.book1D(
188  "Set2_Above",
189  "HF+ Wedge " + wedgeNum.str() + ": Above Threshold 2 - Set 2", NBINS,
190  XMIN, XMAX);
191  ETSum[iWedge] = iBooker.book1D(
192  "ETSum", "HF+ Wedge " + wedgeNum.str() + ": Transverse Energy", NBINS,
193  XMIN, XMAX);
194 
195  iBooker.tagContents(monitorName_ + "/HFPlus/Wedge" + tempStreamer.str(),
196  iWedge + 1);
197  }
198 
199  if (NUM_HLX > 17) {
200  iBooker.setCurrentFolder(monitorName_ + "/HFMinus");
201 
202  for (unsigned int iWedge = 18; iWedge < NUM_HLX; ++iWedge) {
203  std::ostringstream tempStreamer;
204  tempStreamer << std::dec << std::setw(2) << std::setfill('0')
205  << (iWedge + 1);
206 
207  std::ostringstream wedgeNum;
208  wedgeNum << std::dec << (iWedge % 18) + 1;
209 
210  iBooker.setCurrentFolder(monitorName_ + "/HFMinus/Wedge" +
211  tempStreamer.str());
212  Set1Below[iWedge] = iBooker.book1D(
213  "Set1_Below",
214  "HF- Wedge " + wedgeNum.str() + ": Below Threshold 1 - Set 1", NBINS,
215  XMIN, XMAX);
216  Set1Between[iWedge] = iBooker.book1D(
217  "Set1_Between",
218  "HF- Wedge " + wedgeNum.str() + ": Between Threshold 1 & 2 - Set 1",
219  NBINS, XMIN, XMAX);
220  Set1Above[iWedge] = iBooker.book1D(
221  "Set1_Above",
222  "HF- Wedge " + wedgeNum.str() + ": Above Threshold 2 - Set 1", NBINS,
223  XMIN, XMAX);
224  Set2Below[iWedge] = iBooker.book1D(
225  "Set2_Below",
226  "HF- Wedge " + wedgeNum.str() + ": Below Threshold 1 - Set 2", NBINS,
227  XMIN, XMAX);
228  Set2Between[iWedge] = iBooker.book1D(
229  "Set2_Between",
230  "HF- Wedge " + wedgeNum.str() + ": Between Threshold 1 & 2 - Set 2",
231  NBINS, XMIN, XMAX);
232  Set2Above[iWedge] = iBooker.book1D(
233  "Set2_Above",
234  "HF- Wedge " + wedgeNum.str() + ": Above Threshold 2 - Set 2", NBINS,
235  XMIN, XMAX);
236  ETSum[iWedge] = iBooker.book1D(
237  "ETSum", "HF- Wedge " + wedgeNum.str() + ": Transverse Energy", NBINS,
238  XMIN, XMAX);
239 
240  iBooker.tagContents(monitorName_ + "/HFMinus/Wedge" + tempStreamer.str(),
241  iWedge + 1);
242  }
243  }
244 
245  if (!Accumulate) {
246  for (unsigned int iWedge = 0; iWedge < NUM_HLX; ++iWedge) {
247  Set1Below[iWedge]->setResetMe(true);
248  Set1Between[iWedge]->setResetMe(true);
249  Set1Above[iWedge]->setResetMe(true);
250  Set2Below[iWedge]->setResetMe(true);
251  Set2Between[iWedge]->setResetMe(true);
252  Set2Above[iWedge]->setResetMe(true);
253  ETSum[iWedge]->setResetMe(true);
254  }
255  }
256 
257  if (Style == "BX") {
258  OccXAxisTitle = "Bunch Crossing";
259  OccYAxisTitle = "Tower Occupancy";
260  EtXAxisTitle = "Bunch Crossing";
261  EtYAxisTitle = "E_{T} Sum";
262  } else if (Style == "Distribution") {
263  OccXAxisTitle = "Tower Occupancy";
264  OccYAxisTitle = "Count";
265  EtXAxisTitle = "E_{T} Sum";
266  EtYAxisTitle = "Count";
267  }
268 
269  for (unsigned int iWedge = 0; iWedge < NUM_HLX; ++iWedge) {
270  Set1Below[iWedge]->setAxisTitle(OccXAxisTitle, 1);
271  Set1Below[iWedge]->setAxisTitle(OccYAxisTitle, 2);
274  Set1Above[iWedge]->setAxisTitle(OccXAxisTitle, 1);
275  Set1Above[iWedge]->setAxisTitle(OccYAxisTitle, 2);
276  Set2Below[iWedge]->setAxisTitle(OccXAxisTitle, 1);
277  Set2Below[iWedge]->setAxisTitle(OccYAxisTitle, 2);
280  Set2Above[iWedge]->setAxisTitle(OccXAxisTitle, 1);
281  Set2Above[iWedge]->setAxisTitle(OccYAxisTitle, 2);
282  ETSum[iWedge]->setAxisTitle(EtXAxisTitle, 1);
283  ETSum[iWedge]->setAxisTitle(EtYAxisTitle, 2);
284  }
285 
286  // Comparison Histograms
287 
288  iBooker.setCurrentFolder(monitorName_ + "/HFCompare");
289 
290  std::string CompXTitle = "HF Wedge";
291  std::string CompEtSumYTitle = "E_{T} Sum per active tower";
292  std::string CompOccYTitle = "Occupancy per active tower";
293 
295  iBooker.book1D("HFCompareEtSum", "E_{T} Sum", NUM_HLX, 0, NUM_HLX);
296  HFCompareEtSum->setAxisTitle(CompXTitle, 1);
297  HFCompareEtSum->setAxisTitle(CompEtSumYTitle, 2);
298 
299  HFCompareOccBelowSet1 = iBooker.book1D("HFCompareOccBelowSet1",
300  "Occupancy Below Threshold 1 - Set 1",
301  NUM_HLX, 0, NUM_HLX);
302  HFCompareOccBelowSet1->setAxisTitle(CompXTitle, 1);
303  HFCompareOccBelowSet1->setAxisTitle(CompOccYTitle, 2);
304 
306  "HFCompareOccBetweenSet1", "Occupancy Between Threshold 1 & 2 - Set 1",
307  NUM_HLX, 0, NUM_HLX);
308  HFCompareOccBetweenSet1->setAxisTitle(CompXTitle, 1);
309  HFCompareOccBetweenSet1->setAxisTitle(CompOccYTitle, 2);
310 
311  HFCompareOccAboveSet1 = iBooker.book1D("HFCompareOccAboveSet1",
312  "Occupancy Above Threshold 2 - Set 1",
313  NUM_HLX, 0, NUM_HLX);
314  HFCompareOccAboveSet1->setAxisTitle(CompXTitle, 1);
315  HFCompareOccAboveSet1->setAxisTitle(CompOccYTitle, 2);
316 
317  HFCompareOccBelowSet2 = iBooker.book1D("HFCompareOccBelowSet2",
318  "Occupancy Below Threshold 1 - Set 2",
319  NUM_HLX, 0, NUM_HLX);
320  HFCompareOccBelowSet2->setAxisTitle(CompXTitle, 1);
321  HFCompareOccBelowSet2->setAxisTitle(CompOccYTitle, 2);
322 
324  "HFCompareOccBetweenSet2", "Occupancy Between Threshold 1 & 2 - Set 2",
325  NUM_HLX, 0, NUM_HLX);
326  HFCompareOccBetweenSet2->setAxisTitle(CompXTitle, 1);
327  HFCompareOccBetweenSet2->setAxisTitle(CompOccYTitle, 2);
328 
329  HFCompareOccAboveSet2 = iBooker.book1D("HFCompareOccAboveSet2",
330  "Occupancy Above Threshold 2 - Set 2",
331  NUM_HLX, 0, NUM_HLX);
332  HFCompareOccAboveSet2->setAxisTitle(CompXTitle, 1);
333  HFCompareOccAboveSet2->setAxisTitle(CompOccYTitle, 2);
334 
335  // Average Histograms
336 
337  iBooker.setCurrentFolder(monitorName_ + "/Average");
338 
339  int OccBins = 10000; // This does absolutely nothing.
340  double OccMin = 0;
341  double OccMax = 0; // If min and max are zero, no bounds on the data are set.
342 
343  int EtSumBins = 10000; // This does absolutely nothing. The Variable is not
344  // used in the function.
345  double EtSumMin = 0;
346  double EtSumMax =
347  0; // If min and max are zero, no bounds on the data are set.
348 
349  std::string errorOpt = "i";
350 
351  std::string AvgXTitle = "HF Wedge";
352  std::string AvgEtSumYTitle = "Average E_{T} Sum";
353  std::string AvgOccYTitle = "Average Tower Occupancy";
354 
355  AvgEtSum = iBooker.bookProfile("AvgEtSum", "Average E_{T} Sum", NUM_HLX, 0,
356  NUM_HLX, EtSumBins, EtSumMin, EtSumMax);
357  AvgEtSum->setAxisTitle(AvgXTitle, 1);
358  AvgEtSum->setAxisTitle(AvgEtSumYTitle, 2);
359 
360  AvgOccBelowSet1 = iBooker.bookProfile(
361  "AvgOccBelowSet1", "Average Occupancy Below Threshold 1 - Set1", NUM_HLX,
362  0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
363  AvgOccBelowSet1->setAxisTitle(AvgXTitle, 1);
364  AvgOccBelowSet1->setAxisTitle(AvgOccYTitle, 2);
365 
366  AvgOccBetweenSet1 = iBooker.bookProfile(
367  "AvgOccBetweenSet1", "Average Occupancy Between Threhold 1 & 2 - Set1",
368  NUM_HLX, 0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
369  AvgOccBetweenSet1->setAxisTitle(AvgXTitle, 1);
370  AvgOccBetweenSet1->setAxisTitle(AvgOccYTitle, 2);
371 
372  AvgOccAboveSet1 = iBooker.bookProfile(
373  "AvgOccAboveSet1", "Average Occupancy Above Threshold 2 - Set1", NUM_HLX,
374  0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
375  AvgOccAboveSet1->setAxisTitle(AvgXTitle, 1);
376  AvgOccAboveSet1->setAxisTitle(AvgOccYTitle, 2);
377 
378  AvgOccBelowSet2 = iBooker.bookProfile(
379  "AvgOccBelowSet2", "Average Occupancy Below Threshold 1 - Set2", NUM_HLX,
380  0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
381  AvgOccBelowSet2->setAxisTitle(AvgXTitle, 1);
382  AvgOccBelowSet2->setAxisTitle(AvgOccYTitle, 2);
383 
384  AvgOccBetweenSet2 = iBooker.bookProfile(
385  "AvgOccBetweenSet2", "Average Occupancy Between Threshold 1 & 2 - Set2",
386  NUM_HLX, 0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
387  AvgOccBetweenSet2->setAxisTitle(AvgXTitle, 1);
388  AvgOccBetweenSet2->setAxisTitle(AvgOccYTitle, 2);
389 
390  AvgOccAboveSet2 = iBooker.bookProfile(
391  "AvgOccAboveSet2", "Average Occupancy Above Threshold 2 - Set2", NUM_HLX,
392  0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
393  AvgOccAboveSet2->setAxisTitle(AvgXTitle, 1);
394  AvgOccAboveSet2->setAxisTitle(AvgOccYTitle, 2);
395 
396  // Luminosity Histograms
397  iBooker.setCurrentFolder(monitorName_ + "/Luminosity");
398 
399  std::string LumiXTitle = "Bunch Crossing";
400  std::string LumiEtSumYTitle = "Luminosity: E_{T} Sum";
401  std::string LumiOccYTitle = "Luminosity: Occupancy";
402 
403  LumiAvgEtSum = iBooker.bookProfile("LumiAvgEtSum", "Average Luminosity ",
404  int(XMAX - XMIN), XMIN, XMAX, EtSumBins,
405  EtSumMin, EtSumMax);
406  LumiAvgEtSum->setAxisTitle(LumiXTitle, 1);
407  LumiAvgEtSum->setAxisTitle(LumiEtSumYTitle, 2);
408 
409  LumiAvgOccSet1 = iBooker.bookProfile(
410  "LumiAvgOccSet1", "Average Luminosity - Set 1", int(XMAX - XMIN), XMIN,
411  XMAX, OccBins, OccMax, OccMin);
412  LumiAvgOccSet1->setAxisTitle(LumiXTitle, 1);
413  LumiAvgOccSet1->setAxisTitle(LumiOccYTitle, 2);
414 
415  LumiAvgOccSet2 = iBooker.bookProfile(
416  "LumiAvgOccSet2", "Average Luminosity - Set 2", int(XMAX - XMIN), XMIN,
417  XMAX, OccBins, OccMax, OccMin);
418  LumiAvgOccSet2->setAxisTitle(LumiXTitle, 1);
419  LumiAvgOccSet2->setAxisTitle(LumiOccYTitle, 2);
420 
422  iBooker.book1D("LumiInstantEtSum", "Instantaneous Luminosity ",
423  int(XMAX - XMIN), XMIN, XMAX);
424  LumiInstantEtSum->setAxisTitle(LumiXTitle, 1);
425  LumiInstantEtSum->setAxisTitle(LumiEtSumYTitle, 2);
426 
428  iBooker.book1D("LumiInstantOccSet1", "Instantaneous Luminosity - Set 1",
429  int(XMAX - XMIN), XMIN, XMAX);
430  LumiInstantOccSet1->setAxisTitle(LumiXTitle, 1);
431  LumiInstantOccSet1->setAxisTitle(LumiOccYTitle, 2);
432 
434  iBooker.book1D("LumiInstantOccSet2", "Instantaneous Luminosity - Set 2",
435  int(XMAX - XMIN), XMIN, XMAX);
436  LumiInstantOccSet2->setAxisTitle(LumiXTitle, 1);
437  LumiInstantOccSet2->setAxisTitle(LumiOccYTitle, 2);
438 
440  iBooker.book1D("LumiIntegratedEtSum", "Integrated Luminosity ",
441  int(XMAX - XMIN), XMIN, XMAX);
442  LumiIntegratedEtSum->setAxisTitle(LumiXTitle, 1);
443  LumiIntegratedEtSum->setAxisTitle(LumiEtSumYTitle, 2);
444 
446  iBooker.book1D("LumiIntegratedOccSet1", "Integrated Luminosity - Set 1",
447  int(XMAX - XMIN), XMIN, XMAX);
448  LumiIntegratedOccSet1->setAxisTitle(LumiXTitle, 1);
449  LumiIntegratedOccSet1->setAxisTitle(LumiOccYTitle, 2);
450 
452  iBooker.book1D("LumiIntegratedOccSet2", "Integrated Luminosity - Set 2",
453  int(XMAX - XMIN), XMIN, XMAX);
454  LumiIntegratedOccSet2->setAxisTitle(LumiXTitle, 1);
455  LumiIntegratedOccSet2->setAxisTitle(LumiOccYTitle, 2);
456 
457  // Sanity check sum histograms
458  iBooker.setCurrentFolder(monitorName_ + "/CheckSums");
459 
460  std::string sumXTitle = "HF Wedge";
461  std::string sumYTitle = "Occupancy Sum (Below+Above+Between)";
462 
463  SumAllOccSet1 =
464  iBooker.bookProfile("SumAllOccSet1", "Occupancy Check - Set 1", NUM_HLX,
465  0, NUM_HLX, OccBins, OccMax, OccMin);
466  SumAllOccSet1->setAxisTitle(sumXTitle, 1);
467  SumAllOccSet1->setAxisTitle(sumYTitle, 2);
468 
469  SumAllOccSet2 =
470  iBooker.bookProfile("SumAllOccSet2", "Occupancy Check - Set 2", NUM_HLX,
471  0, NUM_HLX, OccBins, OccMax, OccMin);
472  SumAllOccSet2->setAxisTitle(sumXTitle, 1);
473  SumAllOccSet2->setAxisTitle(sumYTitle, 2);
474 
476  iBooker.book1D("MissingDQMDataCheck", "Missing Data Count", 1, 0, 1);
478  MissingDQMDataCheck->setAxisTitle("Number Missing Nibbles", 2);
479 
480  // Signal & Background monitoring histograms
481  iBooker.setCurrentFolder(monitorName_ + "/SigBkgLevels");
482 
484  iBooker.book1D("MaxInstLumiBX1", "Max Instantaneous Luminosity BX: 1st",
485  10000, -1e-5, 0.01);
486  MaxInstLumiBX1->setAxisTitle("Max Inst. L (10^{30}cm^{-2}s^{-1})", 1);
487  MaxInstLumiBX1->setAxisTitle("Entries", 2);
489  iBooker.book1D("MaxInstLumiBX2", "Max Instantaneous Luminosity BX: 2nd",
490  10000, -1e-5, 0.01);
491  MaxInstLumiBX2->setAxisTitle("Max Inst. L (10^{30}cm^{-2}s^{-1})", 1);
492  MaxInstLumiBX2->setAxisTitle("Entries", 2);
494  iBooker.book1D("MaxInstLumiBX3", "Max Instantaneous Luminosity BX: 3rd",
495  10000, -1e-5, 0.01);
496  MaxInstLumiBX3->setAxisTitle("Max Inst. L (10^{30}cm^{-2}s^{-1})", 1);
497  MaxInstLumiBX3->setAxisTitle("Entries", 2);
499  iBooker.book1D("MaxInstLumiBX4", "Max Instantaneous Luminosity BX: 4th",
500  10000, -1e-5, 0.01);
501  MaxInstLumiBX4->setAxisTitle("Max Inst. L (10^{30}cm^{-2}s^{-1})", 1);
502  MaxInstLumiBX4->setAxisTitle("Entries", 2);
503 
504  MaxInstLumiBXNum1 = iBooker.book1D("MaxInstLumiBXNum1",
505  "BX Number of Max: 1st", 3564, 0, 3564);
507  MaxInstLumiBXNum1->setAxisTitle("Num Time Max", 2);
508  MaxInstLumiBXNum2 = iBooker.book1D("MaxInstLumiBXNum2",
509  "BX Number of Max: 2nd", 3564, 0, 3564);
511  MaxInstLumiBXNum2->setAxisTitle("Num Time Max", 2);
512  MaxInstLumiBXNum3 = iBooker.book1D("MaxInstLumiBXNum3",
513  "BX Number of Max: 3rd", 3564, 0, 3564);
515  MaxInstLumiBXNum3->setAxisTitle("Num Time Max", 2);
516  MaxInstLumiBXNum4 = iBooker.book1D("MaxInstLumiBXNum4",
517  "BX Number of Max: 4th", 3564, 0, 3564);
519  MaxInstLumiBXNum4->setAxisTitle("Num Time Max", 2);
520 
521  // History histograms
522  iBooker.setCurrentFolder(monitorName_ + "/HistoryRaw");
523 
524  std::string HistXTitle = "Time (LS)";
525  std::string RecentHistXTitle = "Time (LS/16)";
526  std::string HistEtSumYTitle = "Average E_{T} Sum";
527  std::string HistOccYTitle = "Average Occupancy";
528  std::string HistLumiYTitle = "Luminosity";
529  std::string HistLumiErrorYTitle = "Luminosity Error (%)";
530  std::string BXvsTimeXTitle = "Time (LS)";
531  std::string BXvsTimeYTitle = "BX";
532 
533  // Et Sum histories
535  iBooker.bookProfile("HistAvgEtSumHFP", "Average Et Sum: HF+", MAX_LS, 0.5,
536  (double)MAX_LS + 0.5, EtSumBins, EtSumMin, EtSumMax);
537  HistAvgEtSumHFP->setAxisTitle(HistXTitle, 1);
538  HistAvgEtSumHFP->setAxisTitle(HistEtSumYTitle, 2);
539 
541  iBooker.bookProfile("HistAvgEtSumHFM", "Average Et Sum: HF-", MAX_LS, 0.5,
542  (double)MAX_LS + 0.5, EtSumBins, EtSumMin, EtSumMax);
543  HistAvgEtSumHFM->setAxisTitle(HistXTitle, 1);
544  HistAvgEtSumHFM->setAxisTitle(HistEtSumYTitle, 2);
545 
546  // Tower Occupancy Histories
548  "HistAvgOccBelowSet1HFP", "Average Occ Set1Below: HF+", MAX_LS, 0.5,
549  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
550  HistAvgOccBelowSet1HFP->setAxisTitle(HistXTitle, 1);
551  HistAvgOccBelowSet1HFP->setAxisTitle(HistOccYTitle, 2);
552 
554  "HistAvgOccBelowSet1HFM", "Average Occ Set1Below: HF-", MAX_LS, 0.5,
555  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
556  HistAvgOccBelowSet1HFM->setAxisTitle(HistXTitle, 1);
557  HistAvgOccBelowSet1HFM->setAxisTitle(HistOccYTitle, 2);
558 
560  "HistAvgOccBetweenSet1HFP", "Average Occ Set1Between: HF+", MAX_LS, 0.5,
561  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
562  HistAvgOccBetweenSet1HFP->setAxisTitle(HistXTitle, 1);
563  HistAvgOccBetweenSet1HFP->setAxisTitle(HistOccYTitle, 2);
564 
566  "HistAvgOccBetweenSet1HFM", "Average Occ Set1Between: HF-", MAX_LS, 0.5,
567  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
568  HistAvgOccBetweenSet1HFM->setAxisTitle(HistXTitle, 1);
569  HistAvgOccBetweenSet1HFM->setAxisTitle(HistOccYTitle, 2);
570 
572  "HistAvgOccAboveSet1HFP", "Average Occ Set1Above: HF+", MAX_LS, 0.5,
573  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
574  HistAvgOccAboveSet1HFP->setAxisTitle(HistXTitle, 1);
575  HistAvgOccAboveSet1HFP->setAxisTitle(HistOccYTitle, 2);
576 
578  "HistAvgOccAboveSet1HFM", "Average Occ Set1Above: HF-", MAX_LS, 0.5,
579  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
580  HistAvgOccAboveSet1HFM->setAxisTitle(HistXTitle, 1);
581  HistAvgOccAboveSet1HFM->setAxisTitle(HistOccYTitle, 2);
582 
584  "HistAvgOccBelowSet2HFP", "Average Occ Set2Below: HF+", MAX_LS, 0.5,
585  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
586  HistAvgOccBelowSet2HFP->setAxisTitle(HistXTitle, 1);
587  HistAvgOccBelowSet2HFP->setAxisTitle(HistOccYTitle, 2);
588 
590  "HistAvgOccBelowSet2HFM", "Average Occ Set2Below: HF-", MAX_LS, 0.5,
591  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
592  HistAvgOccBelowSet2HFM->setAxisTitle(HistXTitle, 1);
593  HistAvgOccBelowSet2HFM->setAxisTitle(HistOccYTitle, 2);
594 
596  "HistAvgOccBetweenSet2HFP", "Average Occ Set2Between: HF+", MAX_LS, 0.5,
597  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
598  HistAvgOccBetweenSet2HFP->setAxisTitle(HistXTitle, 1);
599  HistAvgOccBetweenSet2HFP->setAxisTitle(HistOccYTitle, 2);
600 
602  "HistAvgOccBetweenSet2HFM", "Average Occ Set2Between: HF-", MAX_LS, 0.5,
603  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
604  HistAvgOccBetweenSet2HFM->setAxisTitle(HistXTitle, 1);
605  HistAvgOccBetweenSet2HFM->setAxisTitle(HistOccYTitle, 2);
606 
608  "HistAvgOccAboveSet2HFP", "Average Occ Set2Above: HF+", MAX_LS, 0.5,
609  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
610  HistAvgOccAboveSet2HFP->setAxisTitle(HistXTitle, 1);
611  HistAvgOccAboveSet2HFP->setAxisTitle(HistOccYTitle, 2);
612 
614  "HistAvgOccAboveSet2HFM", "Average Occ Set2Above: HF-", MAX_LS, 0.5,
615  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
616  HistAvgOccAboveSet2HFM->setAxisTitle(HistXTitle, 1);
617  HistAvgOccAboveSet2HFM->setAxisTitle(HistOccYTitle, 2);
618 
619  // Et Sum histories
621  iBooker.book2D("BXvsTimeAvgEtSumHFP", "Average Et Sum: HF+", MAX_LS, 0.5,
622  (double)MAX_LS + 0.5, NBINS, (double)XMIN, (double)XMAX);
623  BXvsTimeAvgEtSumHFP->setAxisTitle(BXvsTimeXTitle, 1);
624  BXvsTimeAvgEtSumHFP->setAxisTitle(BXvsTimeYTitle, 2);
625 
627  iBooker.book2D("BXvsTimeAvgEtSumHFM", "Average Et Sum: HF-", MAX_LS, 0.5,
628  (double)MAX_LS + 0.5, NBINS, (double)XMIN, (double)XMAX);
629  BXvsTimeAvgEtSumHFM->setAxisTitle(BXvsTimeXTitle, 1);
630  BXvsTimeAvgEtSumHFM->setAxisTitle(BXvsTimeYTitle, 2);
631 
632  iBooker.setCurrentFolder(monitorName_ + "/HistoryLumi");
633 
634  // Lumi Histories
635  HistAvgLumiEtSum = iBooker.bookProfile(
636  "HistAvgLumiEtSum", "Average Instant Luminosity: Et Sum", MAX_LS, 0.5,
637  (double)MAX_LS + 0.5, EtSumBins, EtSumMin, EtSumMax);
638  HistAvgLumiEtSum->setAxisTitle(HistXTitle, 1);
639  HistAvgLumiEtSum->setAxisTitle(HistLumiYTitle, 2);
640 
642  "HistAvgLumiOccSet1", "Average Instant Luminosity: Occ Set1", MAX_LS, 0.5,
643  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
644  HistAvgLumiOccSet1->setAxisTitle(HistXTitle, 1);
645  HistAvgLumiOccSet1->setAxisTitle(HistLumiYTitle, 2);
646 
648  "HistAvgLumiOccSet2", "Average Instant Luminosity: Occ Set2", MAX_LS, 0.5,
649  (double)MAX_LS + 0.5, OccBins, OccMin, OccMax);
650  HistAvgLumiOccSet2->setAxisTitle(HistXTitle, 1);
651  HistAvgLumiOccSet2->setAxisTitle(HistLumiYTitle, 2);
652 
654  iBooker.book1D("HistInstantLumiEtSum", "Instant Luminosity: Et Sum",
655  MAX_LS, 0.5, (double)MAX_LS + 0.5);
656  HistInstantLumiEtSum->setAxisTitle(HistXTitle, 1);
657  HistInstantLumiEtSum->setAxisTitle(HistLumiYTitle, 2);
658 
660  iBooker.book1D("HistInstantLumiOccSet1", "Instant Luminosity: Occ Set1",
661  MAX_LS, 0.5, (double)MAX_LS + 0.5);
662  HistInstantLumiOccSet1->setAxisTitle(HistXTitle, 1);
663  HistInstantLumiOccSet1->setAxisTitle(HistLumiYTitle, 2);
664 
666  iBooker.book1D("HistInstantLumiOccSet2", "Instant Luminosity: Occ Set2",
667  MAX_LS, 0.5, (double)MAX_LS + 0.5);
668  HistInstantLumiOccSet2->setAxisTitle(HistXTitle, 1);
669  HistInstantLumiOccSet2->setAxisTitle(HistLumiYTitle, 2);
670 
672  iBooker.book1D("HistInstantLumiEtSumError", "Luminosity Error: Et Sum",
673  MAX_LS, 0.5, (double)MAX_LS + 0.5);
674  HistInstantLumiEtSumError->setAxisTitle(HistXTitle, 1);
675  HistInstantLumiEtSumError->setAxisTitle(HistLumiErrorYTitle, 2);
676 
678  "HistInstantLumiOccSet1Error", "Luminosity Error: Occ Set1", MAX_LS, 0.5,
679  (double)MAX_LS + 0.5);
681  HistInstantLumiOccSet1Error->setAxisTitle(HistLumiErrorYTitle, 2);
682 
684  "HistInstantLumiOccSet2Error", "Luminosity Error: Occ Set2", MAX_LS, 0.5,
685  (double)MAX_LS + 0.5);
687  HistInstantLumiOccSet2Error->setAxisTitle(HistLumiErrorYTitle, 2);
688 
690  iBooker.book1D("HistIntegratedLumiEtSum", "Integrated Luminosity: Et Sum",
691  MAX_LS, 0.5, (double)MAX_LS + 0.5);
692  HistIntegratedLumiEtSum->setAxisTitle(HistXTitle, 1);
693  HistIntegratedLumiEtSum->setAxisTitle(HistLumiYTitle, 2);
694 
695  HistIntegratedLumiOccSet1 = iBooker.book1D("HistIntegratedLumiOccSet1",
696  "Integrated Luminosity: Occ Set1",
697  MAX_LS, 0.5, (double)MAX_LS + 0.5);
698  HistIntegratedLumiOccSet1->setAxisTitle(HistXTitle, 1);
699  HistIntegratedLumiOccSet1->setAxisTitle(HistLumiYTitle, 2);
700 
701  HistIntegratedLumiOccSet2 = iBooker.book1D("HistIntegratedLumiOccSet2",
702  "Integrated Luminosity: Occ Set2",
703  MAX_LS, 0.5, (double)MAX_LS + 0.5);
704  HistIntegratedLumiOccSet2->setAxisTitle(HistXTitle, 1);
705  HistIntegratedLumiOccSet2->setAxisTitle(HistLumiYTitle, 2);
706 
707  iBooker.setCurrentFolder(monitorName_ + "/RecentHistoryLumi");
708 
709  // Lumi Recent Histories (past 128 short sections)
711  iBooker.book1D("RecentInstantLumiEtSum", "Instant Luminosity: Et Sum",
712  128, 0.5, (double)128 + 0.5);
713  RecentInstantLumiEtSum->setAxisTitle(RecentHistXTitle, 1);
714  RecentInstantLumiEtSum->setAxisTitle(HistLumiYTitle, 2);
715 
717  iBooker.book1D("RecentInstantLumiOccSet1", "Instant Luminosity: Occ Set1",
718  128, 0.5, (double)128 + 0.5);
719  RecentInstantLumiOccSet1->setAxisTitle(RecentHistXTitle, 1);
720  RecentInstantLumiOccSet1->setAxisTitle(HistLumiYTitle, 2);
721 
723  iBooker.book1D("RecentInstantLumiOccSet2", "Instant Luminosity: Occ Set2",
724  128, 0.5, (double)128 + 0.5);
725  RecentInstantLumiOccSet2->setAxisTitle(RecentHistXTitle, 1);
726  RecentInstantLumiOccSet2->setAxisTitle(HistLumiYTitle, 2);
727 
728  RecentIntegratedLumiEtSum = iBooker.book1D("RecentIntegratedLumiEtSum",
729  "Integrated Luminosity: Et Sum",
730  128, 0.5, (double)128 + 0.5);
731  RecentIntegratedLumiEtSum->setAxisTitle(RecentHistXTitle, 1);
732  RecentIntegratedLumiEtSum->setAxisTitle(HistLumiYTitle, 2);
733 
735  "RecentIntegratedLumiOccSet1", "Integrated Luminosity: Occ Set1", 128,
736  0.5, (double)128 + 0.5);
737  RecentIntegratedLumiOccSet1->setAxisTitle(RecentHistXTitle, 1);
738  RecentIntegratedLumiOccSet1->setAxisTitle(HistLumiYTitle, 2);
739 
741  "RecentIntegratedLumiOccSet2", "Integrated Luminosity: Occ Set2", 128,
742  0.5, (double)128 + 0.5);
743  RecentIntegratedLumiOccSet2->setAxisTitle(RecentHistXTitle, 1);
744  RecentIntegratedLumiOccSet2->setAxisTitle(HistLumiYTitle, 2);
745 }
746 
748  using std::string;
749 
750  string currentfolder = subSystemName_ + "/" + eventInfoFolderHLX_;
751  // cout << "currentfolder " << currentfolder << endl;
752 
753  iBooker.setCurrentFolder(currentfolder);
754 
755  pEvent_ = 0;
756  evtRateCount_ = 0;
757  gettimeofday(&currentTime_, nullptr);
759  evtRateWindow_ = 0.5;
760 
761  // Event specific contents
762  runId_ = iBooker.bookInt("iRun");
763  lumisecId_ = iBooker.bookInt("iLumiSection");
764 
765  eventId_ = iBooker.bookInt("iEvent");
766  eventId_->Fill(-1);
767  eventTimeStamp_ = iBooker.bookFloat("eventTimeStamp");
768 
769  iBooker.setCurrentFolder(currentfolder);
770  // Process specific contents
771  processTimeStamp_ = iBooker.bookFloat("processTimeStamp");
773  processLatency_ = iBooker.bookFloat("processLatency");
774  processTimeStamp_->Fill(-1);
775  processEvents_ = iBooker.bookInt("processedEvents");
777  processEventRate_ = iBooker.bookFloat("processEventRate");
778  processEventRate_->Fill(-1);
779  nUpdates_ = iBooker.bookInt("processUpdates");
780  nUpdates_->Fill(-1);
781 
782  // Static Contents
783  processId_ = iBooker.bookInt("processID");
784  processId_->Fill(gSystem->GetPid());
785  processStartTimeStamp_ = iBooker.bookFloat("processStartTimeStamp");
787  runStartTimeStamp_ = iBooker.bookFloat("runStartTimeStamp");
788  hostName_ = iBooker.bookString("hostName", gSystem->HostName());
789  processName_ = iBooker.bookString("processName", subSystemName_);
790  workingDir_ = iBooker.bookString("workingDir", gSystem->pwd());
791  cmsswVer_ = iBooker.bookString("CMSSW_Version", edm::getReleaseVersion());
792 
793  // Go to the standard EventInfo folder (in the case online case where this
794  // is different).
795  currentfolder = subSystemName_ + "/" + eventInfoFolder_;
796  iBooker.setCurrentFolder(currentfolder);
797 
798  reportSummary_ = iBooker.bookFloat("reportSummary");
799  reportSummaryMap_ = iBooker.book2D("reportSummaryMap", "reportSummaryMap", 18,
800  0., 18., 2, -1.5, 1.5);
801 
802  currentfolder = subSystemName_ + "/" + eventInfoFolderHLX_;
803  iBooker.setCurrentFolder(currentfolder);
804 
805  TH2F* summaryHist = reportSummaryMap_->getTH2F();
806  summaryHist->GetYaxis()->SetBinLabel(1, "HF-");
807  summaryHist->GetYaxis()->SetBinLabel(2, "HF+");
808  summaryHist->GetXaxis()->SetTitle("Wedge #");
809 
810  // Fill the report summary objects with default values, since these will only
811  // be filled at the change of run.
812  reportSummary_->Fill(1.0);
813 
814  for (unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX) {
815  unsigned int iWedge = HLXHFMap[iHLX] + 1;
816  unsigned int iEta = 2;
817  if (iWedge >= 19) {
818  iEta = 1;
819  iWedge -= 18;
820  }
821  reportSummaryMap_->setBinContent(iWedge, iEta, 1.0);
822  }
823 }
824 
825 // ------------ method called to for each event ------------
827  const edm::EventSetup& iSetup) {
828  using namespace edm;
829 
830  while (HLXTCP.IsConnected() == false) {
832  if (HLXTCP.Connect() != 1) {
833  std::cout << "Failed to connect to " << DistribIP1 << "." << std::endl;
834  sleep(1);
835  std::cout << "Trying " << DistribIP2 << std::endl;
837  if (HLXTCP.Connect() == 1) break;
838  std::cout << "Failed to connect to " << DistribIP2 << "." << std::endl;
839  std::cout << " Reconnect in " << reconnTime << " seconds." << std::endl;
840  sleep(reconnTime);
841  }
842  }
843  if (HLXTCP.IsConnected() == true) {
844  std::cout << "Successfully connected." << std::endl;
845  }
846 
848  // If this is the first time through, set the runNumber ...
850  if (!currentRunEnded_ && runNumber_ != 0) {
851  EndRun();
852  }
854  currentRunEnded_ = false;
855  // std::cout << "Run number is: " << runNumber_ << std::endl;
856  timeval startruntime;
857  gettimeofday(&startruntime, nullptr);
858  runStartTimeStamp_->Fill(getUTCtime(&startruntime));
859  }
860 
861  // Fill the monitoring histograms
864  FillEventInfo(lumiSection, iEvent);
866 
867  cout << "Run: " << lumiSection.hdr.runNumber
868  << " Section: " << lumiSection.hdr.sectionNumber
869  << " Orbit: " << lumiSection.hdr.startOrbit << endl;
870  cout << "Et Lumi: " << lumiSection.lumiSummary.InstantETLumi << endl;
871  cout << "Occ Lumi 1: " << lumiSection.lumiSummary.InstantOccLumi[0] << endl;
872  cout << "Occ Lumi 2: " << lumiSection.lumiSummary.InstantOccLumi[1] << endl;
873  } else {
874  HLXTCP.Disconnect();
875  EndRun();
876  }
877 }
878 
881 
882  // Do some things that should be done at the end of the run ...
883  expectedNibbles_ = 0;
884  for (unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX) totalNibbles_[iHLX] = 0;
885 
886  std::cout << "** Here in end run **" << std::endl;
887  if (ResetAtNewRun) ResetAll();
888  runNumber_ = 0;
889  currentRunEnded_ = true;
896  sectionInstantNorm = 0;
897  lsBinOld = 0;
898  lumiSectionCount = 0;
899  previousSection = 0;
900 }
901 
903  // Check for missing data
904  if (previousSection != (section.hdr.sectionNumber - 1)) {
905  double weight = (double)(section.hdr.sectionNumber - previousSection - 1);
906  // std::cout << "Filling missing data! " << weight << std::endl;
907  MissingDQMDataCheck->Fill(0.5, weight);
908  }
910 
911  int lsBin = int(lumiSectionCount / num4NibblePerLS_);
912  int lsBinBX = int(lumiSectionCount / num4NibblePerLS_);
916 
917  int fillBin = lumiSectionCount + 1;
918  if (fillBin > 128) {
919  // If we are already more than 2 LS's in, move everything back by one bin
920  // and fill the last bin with the new value.
921  for (int iBin = 1; iBin < 128; ++iBin) {
923  iBin, RecentInstantLumiEtSum->getBinContent(iBin + 1));
925  iBin, RecentInstantLumiOccSet1->getBinContent(iBin + 1));
927  iBin, RecentInstantLumiOccSet2->getBinContent(iBin + 1));
929  iBin, RecentIntegratedLumiEtSum->getBinContent(iBin + 1));
931  iBin, RecentIntegratedLumiOccSet1->getBinContent(iBin + 1));
933  iBin, RecentIntegratedLumiOccSet2->getBinContent(iBin + 1));
934  }
935  fillBin = 128;
936  }
937 
939  section.lumiSummary.InstantETLumi);
941  section.lumiSummary.InstantETLumiErr);
943  fillBin, section.lumiSummary.InstantOccLumi[0]);
945  fillBin, section.lumiSummary.InstantOccLumiErr[0]);
947  fillBin, section.lumiSummary.InstantOccLumi[1]);
949  fillBin, section.lumiSummary.InstantOccLumiErr[1]);
950 
951  double recentOldBinContent =
953  if (fillBin == 1) recentOldBinContent = 0;
954  double recentNewBinContent =
955  recentOldBinContent + section.lumiSummary.InstantETLumi;
956  RecentIntegratedLumiEtSum->setBinContent(fillBin, recentNewBinContent);
957  recentOldBinContent = RecentIntegratedLumiOccSet1->getBinContent(fillBin - 1);
958  if (fillBin == 1) recentOldBinContent = 0;
959  recentNewBinContent =
960  recentOldBinContent + section.lumiSummary.InstantOccLumi[0];
961  RecentIntegratedLumiOccSet1->setBinContent(fillBin, recentNewBinContent);
962  recentOldBinContent = RecentIntegratedLumiOccSet2->getBinContent(fillBin - 1);
963  if (fillBin == 1) recentOldBinContent = 0;
964  recentNewBinContent =
965  recentOldBinContent + section.lumiSummary.InstantOccLumi[0];
966  RecentIntegratedLumiOccSet2->setBinContent(fillBin, recentNewBinContent);
967 
968  double recentOldBinError =
970  if (fillBin == 1) recentOldBinError = 0;
971  double recentNewBinError = sqrt(recentOldBinError * recentOldBinError +
972  section.lumiSummary.InstantETLumiErr *
973  section.lumiSummary.InstantETLumiErr);
974  RecentIntegratedLumiEtSum->setBinError(fillBin, recentNewBinError);
975  recentOldBinError = RecentIntegratedLumiOccSet1->getBinError(fillBin - 1);
976  if (fillBin == 1) recentOldBinError = 0;
977  recentNewBinError = sqrt(recentOldBinError * recentOldBinError +
978  section.lumiSummary.InstantOccLumiErr[0] *
979  section.lumiSummary.InstantOccLumiErr[0]);
980  RecentIntegratedLumiOccSet1->setBinError(fillBin, recentNewBinError);
981  recentOldBinError = RecentIntegratedLumiOccSet2->getBinError(fillBin - 1);
982  if (fillBin == 1) recentOldBinError = 0;
983  recentNewBinError = sqrt(recentOldBinError * recentOldBinError +
984  section.lumiSummary.InstantOccLumiErr[1] *
985  section.lumiSummary.InstantOccLumiErr[1]);
986  RecentIntegratedLumiOccSet2->setBinError(fillBin, recentNewBinError);
987 
988  if (lsBinOld != lsBin) {
995 
996  double etDenom = fabs(sectionInstantSumEt);
997  if (etDenom < 1e-10) etDenom = 1e-10;
998  double occ1Denom = fabs(sectionInstantSumOcc1);
999  if (occ1Denom < 1e-10) occ1Denom = 1e-10;
1000  double occ2Denom = fabs(sectionInstantSumOcc2);
1001  if (occ2Denom < 1e-10) occ2Denom = 1e-10;
1002  double etError = 100.0 * sqrt(sectionInstantErrSumEt) / etDenom;
1003  double occ1Error = 100.0 * sqrt(sectionInstantErrSumOcc1) / occ1Denom;
1004  double occ2Error = 100.0 * sqrt(sectionInstantErrSumOcc2) / occ2Denom;
1008 
1009  double histOldBinContent = HistIntegratedLumiEtSum->getBinContent(lsBinOld);
1010  if (lsBinOld == 0) histOldBinContent = 0;
1011  double histNewBinContent = histOldBinContent + sectionInstantSumEt;
1012  HistIntegratedLumiEtSum->setBinContent(lsBin, histNewBinContent);
1013  histOldBinContent = HistIntegratedLumiOccSet1->getBinContent(lsBinOld);
1014  if (lsBinOld == 0) histOldBinContent = 0;
1015  histNewBinContent = histOldBinContent + sectionInstantSumOcc1;
1016  HistIntegratedLumiOccSet1->setBinContent(lsBin, histNewBinContent);
1017  histOldBinContent = HistIntegratedLumiOccSet2->getBinContent(lsBinOld);
1018  if (lsBinOld == 0) histOldBinContent = 0;
1019  histNewBinContent = histOldBinContent + sectionInstantSumOcc2;
1020  HistIntegratedLumiOccSet2->setBinContent(lsBin, histNewBinContent);
1021 
1022  double histOldBinError = HistIntegratedLumiEtSum->getBinError(lsBinOld);
1023  if (lsBinOld == 0) histOldBinError = 0;
1024  double histNewBinError =
1025  sqrt(histOldBinError * histOldBinError + sectionInstantErrSumEt);
1026  HistIntegratedLumiEtSum->setBinError(lsBin, histNewBinError);
1027  histOldBinError = HistIntegratedLumiOccSet1->getBinError(lsBinOld);
1028  if (lsBinOld == 0) histOldBinError = 0;
1029  histNewBinError =
1030  sqrt(histOldBinError * histOldBinError + sectionInstantErrSumOcc1);
1031  HistIntegratedLumiOccSet1->setBinError(lsBin, histNewBinError);
1032  histOldBinError = HistIntegratedLumiOccSet2->getBinError(lsBinOld);
1033  if (lsBinOld == 0) histOldBinError = 0;
1034  histNewBinError =
1035  sqrt(histOldBinError * histOldBinError + sectionInstantErrSumOcc2);
1036  HistIntegratedLumiOccSet2->setBinError(lsBin, histNewBinError);
1037 
1038  sectionInstantSumEt = 0;
1040  sectionInstantSumOcc1 = 0;
1042  sectionInstantSumOcc2 = 0;
1044  sectionInstantNorm = 0;
1045  lsBinOld = lsBin;
1046  }
1047 
1050  section.lumiSummary.InstantETLumiErr;
1053  section.lumiSummary.InstantOccLumiErr[0];
1056  section.lumiSummary.InstantOccLumiErr[1];
1058 
1062 
1063  for (int iHLX = 0; iHLX < (int)NUM_HLX; ++iHLX) {
1064  unsigned int utotal1 = 0;
1065  unsigned int utotal2 = 0;
1066  unsigned int iWedge = HLXHFMap[iHLX];
1067  if (section.occupancy[iHLX].hdr.numNibbles != 0) {
1068  // Don't include the last one hundred BX in the average.
1069  for (unsigned int iBX = 0; iBX < NUM_BUNCHES; ++iBX) {
1070  // Normalize to number of towers
1071  unsigned int norm[2] = {0, 0};
1072  norm[0] += section.occupancy[iHLX].data[set1BelowIndex][iBX];
1073  norm[0] += section.occupancy[iHLX].data[set1BetweenIndex][iBX];
1074  norm[0] += section.occupancy[iHLX].data[set1AboveIndex][iBX];
1075  if (norm[0] == 0) norm[0] = 1;
1076  norm[1] += section.occupancy[iHLX].data[set2BelowIndex][iBX];
1077  norm[1] += section.occupancy[iHLX].data[set2BetweenIndex][iBX];
1078  norm[1] += section.occupancy[iHLX].data[set2AboveIndex][iBX];
1079  if (norm[1] == 0) norm[1] = 1;
1080 
1081  double normEt =
1082  section.etSum[iHLX].data[iBX] / (double)(norm[0] + norm[1]);
1083  double normOccSet1Below =
1084  (double)section.occupancy[iHLX].data[set1BelowIndex][iBX] /
1085  (double)norm[0];
1086  double normOccSet1Between =
1087  (double)section.occupancy[iHLX].data[set1BetweenIndex][iBX] /
1088  (double)norm[0];
1089  double normOccSet1Above =
1090  (double)section.occupancy[iHLX].data[set1AboveIndex][iBX] /
1091  (double)norm[0];
1092  double normOccSet2Below =
1093  (double)section.occupancy[iHLX].data[set2BelowIndex][iBX] /
1094  (double)norm[1];
1095  double normOccSet2Between =
1096  (double)section.occupancy[iHLX].data[set2BetweenIndex][iBX] /
1097  (double)norm[1];
1098  double normOccSet2Above =
1099  (double)section.occupancy[iHLX].data[set2AboveIndex][iBX] /
1100  (double)norm[1];
1101 
1102  // Averages & check sum
1103  if (iBX < NUM_BUNCHES - 100) {
1104  AvgEtSum->Fill(iWedge, normEt);
1105 
1106  AvgOccBelowSet1->Fill(iWedge, normOccSet1Below);
1107  AvgOccBetweenSet1->Fill(iWedge, normOccSet1Between);
1108  AvgOccAboveSet1->Fill(iWedge, normOccSet1Above);
1109 
1110  AvgOccBelowSet2->Fill(iWedge, normOccSet2Below);
1111  AvgOccBetweenSet2->Fill(iWedge, normOccSet2Between);
1112  AvgOccAboveSet2->Fill(iWedge, normOccSet2Above);
1113 
1114  if (iWedge < 18) {
1115  HistAvgEtSumHFP->Fill(lsBin, normEt);
1116  HistAvgOccBelowSet1HFP->Fill(lsBin, normOccSet1Below);
1117  HistAvgOccBetweenSet1HFP->Fill(lsBin, normOccSet1Between);
1118  HistAvgOccAboveSet1HFP->Fill(lsBin, normOccSet1Above);
1119  HistAvgOccBelowSet2HFP->Fill(lsBin, normOccSet2Below);
1120  HistAvgOccBetweenSet2HFP->Fill(lsBin, normOccSet2Between);
1121  HistAvgOccAboveSet2HFP->Fill(lsBin, normOccSet2Above);
1122 
1123  if (iBX >= (XMIN - 1) && iBX <= (XMAX - 1))
1125  lsBinBX, iBX, normEt / (num4NibblePerLS_ * 18.0 * 12.0));
1126  } else {
1127  HistAvgEtSumHFM->Fill(lsBin, normEt);
1128  HistAvgOccBelowSet1HFM->Fill(lsBin, normOccSet1Below);
1129  HistAvgOccBetweenSet1HFM->Fill(lsBin, normOccSet1Between);
1130  HistAvgOccAboveSet1HFM->Fill(lsBin, normOccSet1Above);
1131  HistAvgOccBelowSet2HFM->Fill(lsBin, normOccSet2Below);
1132  HistAvgOccBetweenSet2HFM->Fill(lsBin, normOccSet2Between);
1133  HistAvgOccAboveSet2HFM->Fill(lsBin, normOccSet2Above);
1134 
1135  if (iBX >= (XMIN - 1) && iBX <= (XMAX - 1))
1137  lsBinBX, iBX, normEt / (num4NibblePerLS_ * 18.0 * 12.0));
1138  }
1139 
1140  utotal1 += section.occupancy[iHLX].data[set1BelowIndex][iBX];
1141  utotal1 += section.occupancy[iHLX].data[set1BetweenIndex][iBX];
1142  utotal1 += section.occupancy[iHLX].data[set1AboveIndex][iBX];
1143 
1144  utotal2 += section.occupancy[iHLX].data[set2BelowIndex][iBX];
1145  utotal2 += section.occupancy[iHLX].data[set2BetweenIndex][iBX];
1146  utotal2 += section.occupancy[iHLX].data[set2AboveIndex][iBX];
1147  }
1148 
1149  if (Style == "BX") {
1150  // Get the correct bin ...
1151  TH1F* Set1BelowHist = Set1Below[iWedge]->getTH1F();
1152  int iBin = Set1BelowHist->FindBin((float)iBX);
1153 
1154  // Adjust the old bin content to make the new, unnormalize and
1155  // renormalize
1156  if (lumiSectionCount > 0) {
1157  double oldNormOccSet1Below =
1158  (Set1Below[iWedge]->getBinContent(iBin)) *
1159  (double)(lumiSectionCount);
1160  normOccSet1Below += oldNormOccSet1Below;
1161  normOccSet1Below /= (double)(lumiSectionCount + 1);
1162  double oldNormOccSet2Below =
1163  (Set2Below[iWedge]->getBinContent(iBin)) *
1164  (double)(lumiSectionCount);
1165  normOccSet2Below += oldNormOccSet2Below;
1166  normOccSet2Below /= (double)(lumiSectionCount + 1);
1167 
1168  double oldNormOccSet1Between =
1169  (Set1Between[iWedge]->getBinContent(iBin)) *
1170  (double)(lumiSectionCount);
1171  normOccSet1Between += oldNormOccSet1Between;
1172  normOccSet1Between /= (double)(lumiSectionCount + 1);
1173  double oldNormOccSet2Between =
1174  (Set2Between[iWedge]->getBinContent(iBin)) *
1175  (double)(lumiSectionCount);
1176  normOccSet2Between += oldNormOccSet2Between;
1177  normOccSet2Between /= (double)(lumiSectionCount + 1);
1178 
1179  double oldNormOccSet1Above =
1180  (Set1Above[iWedge]->getBinContent(iBin)) *
1181  (double)(lumiSectionCount);
1182  normOccSet1Above += oldNormOccSet1Above;
1183  normOccSet1Above /= (double)(lumiSectionCount + 1);
1184  double oldNormOccSet2Above =
1185  (Set2Above[iWedge]->getBinContent(iBin)) *
1186  (double)(lumiSectionCount);
1187  normOccSet2Above += oldNormOccSet2Above;
1188  normOccSet2Above /= (double)(lumiSectionCount + 1);
1189 
1190  double oldNormEt =
1191  ETSum[iWedge]->getBinContent(iBin) * (double)(lumiSectionCount);
1192  normEt += oldNormEt;
1193  normEt /= (double)(lumiSectionCount + 1);
1194  }
1195  Set1Below[iWedge]->setBinContent(iBin, normOccSet1Below);
1196  Set1Between[iWedge]->setBinContent(iBin, normOccSet1Between);
1197  Set1Above[iWedge]->setBinContent(iBin, normOccSet1Above);
1198  Set2Below[iWedge]->setBinContent(iBin, normOccSet2Below);
1199  Set2Between[iWedge]->setBinContent(iBin, normOccSet2Between);
1200  Set2Above[iWedge]->setBinContent(iBin, normOccSet2Above);
1201  ETSum[iWedge]->setBinContent(iBin, normEt);
1202  } else if (Style == "Dist") {
1203  Set1Below[iWedge]->Fill(normOccSet1Below);
1204  Set1Between[iWedge]->Fill(normOccSet1Between);
1205  Set1Above[iWedge]->Fill(normOccSet1Above);
1206  Set2Below[iWedge]->Fill(normOccSet2Below);
1207  Set2Between[iWedge]->Fill(normOccSet2Between);
1208  Set2Above[iWedge]->Fill(normOccSet2Above);
1209  ETSum[iWedge]->Fill(normEt);
1210  }
1211  }
1212 
1213  // Get the number of towers per wedge per BX (assuming non-zero numbers)
1214  double total1 = 0;
1215  double total2 = 0;
1216  if ((NUM_BUNCHES - 100) > 0) {
1217  total1 = (double)utotal1 / (double)(NUM_BUNCHES - 100);
1218  total2 = (double)utotal2 / (double)(NUM_BUNCHES - 100);
1219  }
1220  if (section.hdr.numOrbits > 0) {
1221  total1 = total1 / (double)section.hdr.numOrbits;
1222  total2 = total2 / (double)section.hdr.numOrbits;
1223  }
1224 
1225  SumAllOccSet1->Fill(iWedge, total1);
1226  SumAllOccSet2->Fill(iWedge, total2);
1227  }
1228  }
1229 
1230  double max[4] = {-1000.0, -1000.0, -1000.0, -1000.0};
1231  int bxmax[4] = {-1, -1, -1, -1};
1232  for (unsigned int iBX = 0; iBX < NUM_BUNCHES; ++iBX) {
1233  LumiAvgEtSum->Fill(iBX, section.lumiDetail.ETLumi[iBX]);
1234  LumiAvgOccSet1->Fill(iBX, section.lumiDetail.OccLumi[0][iBX]);
1235  LumiAvgOccSet2->Fill(iBX, section.lumiDetail.OccLumi[1][iBX]);
1236 
1237  if (section.lumiDetail.OccLumi[0][iBX] > max[0]) {
1238  max[3] = max[2];
1239  bxmax[3] = bxmax[2];
1240  max[2] = max[1];
1241  bxmax[2] = bxmax[1];
1242  max[1] = max[0];
1243  bxmax[1] = bxmax[0];
1244  max[0] = section.lumiDetail.OccLumi[0][iBX];
1245  bxmax[0] = iBX;
1246  } else if (section.lumiDetail.OccLumi[0][iBX] > max[1]) {
1247  max[3] = max[2];
1248  bxmax[3] = bxmax[2];
1249  max[2] = max[1];
1250  bxmax[2] = bxmax[1];
1251  max[1] = section.lumiDetail.OccLumi[0][iBX];
1252  bxmax[1] = iBX;
1253  } else if (section.lumiDetail.OccLumi[0][iBX] > max[2]) {
1254  max[3] = max[2];
1255  bxmax[3] = bxmax[2];
1256  max[2] = section.lumiDetail.OccLumi[0][iBX];
1257  bxmax[2] = iBX;
1258  } else if (section.lumiDetail.OccLumi[0][iBX] > max[3]) {
1259  max[3] = section.lumiDetail.OccLumi[0][iBX];
1260  bxmax[3] = iBX;
1261  }
1262 
1263  int iBin = iBX - (int)XMIN + 1;
1264  if (iBin <= int(XMAX - XMIN) && iBin >= 1) {
1265  LumiInstantEtSum->setBinContent(iBin, section.lumiDetail.ETLumi[iBX]);
1267  section.lumiDetail.OccLumi[0][iBX]);
1269  section.lumiDetail.OccLumi[1][iBX]);
1270  LumiInstantEtSum->setBinError(iBin, section.lumiDetail.ETLumiErr[iBX]);
1272  section.lumiDetail.OccLumiErr[0][iBX]);
1274  section.lumiDetail.OccLumiErr[1][iBX]);
1275 
1276  double oldBinContent = LumiIntegratedEtSum->getBinContent(iBin);
1277  if (lumiSectionCount == 0) oldBinContent = 0;
1278  double newBinContent = oldBinContent + section.lumiDetail.ETLumi[iBX];
1279  LumiIntegratedEtSum->setBinContent(iBin, newBinContent);
1280  oldBinContent = LumiIntegratedOccSet1->getBinContent(iBin);
1281  if (lumiSectionCount == 0) oldBinContent = 0;
1282  newBinContent = oldBinContent + section.lumiDetail.OccLumi[0][iBX];
1283  LumiIntegratedOccSet1->setBinContent(iBin, newBinContent);
1284  oldBinContent = LumiIntegratedOccSet2->getBinContent(iBin);
1285  if (lumiSectionCount == 0) oldBinContent = 0;
1286  newBinContent = oldBinContent + section.lumiDetail.OccLumi[1][iBX];
1287  LumiIntegratedOccSet2->setBinContent(iBin, newBinContent);
1288 
1289  double oldBinError = LumiIntegratedEtSum->getBinError(iBin);
1290  if (lumiSectionCount == 0) oldBinError = 0;
1291  double newBinError = sqrt(oldBinError * oldBinError +
1292  section.lumiDetail.ETLumiErr[iBX] *
1293  section.lumiDetail.ETLumiErr[iBX]);
1294  LumiIntegratedEtSum->setBinError(iBin, newBinError);
1295  oldBinError = LumiIntegratedOccSet1->getBinError(iBin);
1296  if (lumiSectionCount == 0) oldBinError = 0;
1297  newBinError = sqrt(oldBinError * oldBinError +
1298  section.lumiDetail.OccLumiErr[0][iBX] *
1299  section.lumiDetail.OccLumiErr[0][iBX]);
1300  LumiIntegratedOccSet1->setBinError(iBin, newBinError);
1301  oldBinError = LumiIntegratedOccSet1->getBinError(iBin);
1302  if (lumiSectionCount == 0) oldBinError = 0;
1303  newBinError = sqrt(oldBinError * oldBinError +
1304  section.lumiDetail.OccLumiErr[1][iBX] *
1305  section.lumiDetail.OccLumiErr[1][iBX]);
1306  LumiIntegratedOccSet2->setBinError(iBin, newBinError);
1307  }
1308  }
1309 
1310  // Now fill the maximum hists, but ordered by BX, so that
1311  // collision BX's or satellite BX's will always appear in the
1312  // same histogram.
1313  int flag = 1;
1314  for (int iM = 0; (iM < 4) && flag; ++iM) {
1315  flag = 0;
1316  for (int iN = 0; iN < 3; ++iN) {
1317  if (bxmax[iN + 1] < bxmax[iN]) {
1318  int tmp = bxmax[iN];
1319  bxmax[iN] = bxmax[iN + 1];
1320  bxmax[iN + 1] = tmp;
1321 
1322  double tmp2 = max[iN];
1323  max[iN] = max[iN + 1];
1324  max[iN + 1] = tmp2;
1325  flag = 1;
1326  }
1327  }
1328  }
1329 
1330  // 0.9e1 = Conversion constant for occ1 at 900GeV COM.
1331  MaxInstLumiBX1->Fill(max[0] * 0.9e1);
1332  MaxInstLumiBXNum1->Fill(bxmax[0]);
1333  MaxInstLumiBX2->Fill(max[1] * 0.9e1);
1334  MaxInstLumiBXNum2->Fill(bxmax[1]);
1335  MaxInstLumiBX3->Fill(max[2] * 0.9e1);
1336  MaxInstLumiBXNum3->Fill(bxmax[2]);
1337  MaxInstLumiBX4->Fill(max[3] * 0.9e1);
1338  MaxInstLumiBXNum4->Fill(bxmax[3]);
1339 
1340  TH1F* tmpHist = MaxInstLumiBX1->getTH1F();
1341  double minX = tmpHist->GetBinLowEdge(1);
1342  double maxX = tmpHist->GetBinLowEdge(tmpHist->GetNbinsX() + 1);
1343 
1344  int inum4NibblePerLS = (int)num4NibblePerLS_;
1345  if (lumiSectionCount % inum4NibblePerLS == 0) {
1346  double mean1 = MaxInstLumiBX1->getMean();
1347  double rms1 = MaxInstLumiBX1->getRMS();
1348  if (rms1 > 0 && mean1 - 5 * rms1 > minX && mean1 + 5 * rms1 < maxX)
1349  MaxInstLumiBX1->setAxisRange(mean1 - 5 * rms1, mean1 + 5 * rms1);
1350 
1351  double mean2 = MaxInstLumiBX2->getMean();
1352  double rms2 = MaxInstLumiBX2->getRMS();
1353  if (rms2 > 0 && mean2 - 5 * rms2 > minX && mean2 + 5 * rms2 < maxX)
1354  MaxInstLumiBX2->setAxisRange(mean2 - 5 * rms2, mean2 + 5 * rms2);
1355 
1356  double mean3 = MaxInstLumiBX3->getMean();
1357  double rms3 = MaxInstLumiBX3->getRMS();
1358  if (rms3 > 0 && mean3 - 5 * rms3 > minX && mean3 + 5 * rms3 < maxX)
1359  MaxInstLumiBX3->setAxisRange(mean3 - 5 * rms3, mean3 + 5 * rms3);
1360 
1361  double mean4 = MaxInstLumiBX4->getMean();
1362  double rms4 = MaxInstLumiBX4->getRMS();
1363  if (rms4 > 0 && mean4 - 5 * rms4 > minX && mean4 + 5 * rms4 < maxX)
1364  MaxInstLumiBX4->setAxisRange(mean4 - 5 * rms4, mean4 + 5 * rms4);
1365  }
1366 
1367  // Add one to the section count (usually short sections)
1368  ++lumiSectionCount;
1369 }
1370 
1372  for (unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX) {
1373  unsigned int iWedge = HLXHFMap[iHLX];
1374 
1375  if (section.occupancy[iHLX].hdr.numNibbles != 0) {
1376  float nActvTwrsSet1 =
1377  section.occupancy[iHLX].data[set1AboveIndex][TriggerBX] +
1378  section.occupancy[iHLX].data[set1BetweenIndex][TriggerBX] +
1379  section.occupancy[iHLX].data[set1BelowIndex][TriggerBX];
1380 
1381  float nActvTwrsSet2 =
1382  section.occupancy[iHLX].data[set2AboveIndex][TriggerBX] +
1383  section.occupancy[iHLX].data[set2BetweenIndex][TriggerBX] +
1384  section.occupancy[iHLX].data[set2BelowIndex][TriggerBX];
1385 
1386  float total = nActvTwrsSet1 + nActvTwrsSet2;
1387 
1388  if (total > 0) {
1389  float tempData = section.etSum[iHLX].data[TriggerBX] / total;
1390  // cout << "Filling HFCompare Et sum " << tempData << endl;
1391  HFCompareEtSum->Fill(iWedge, tempData);
1392  }
1393 
1394  if (nActvTwrsSet1 > 0) {
1395  float tempData =
1396  (float)section.occupancy[iHLX].data[set1BelowIndex][TriggerBX] /
1397  nActvTwrsSet1;
1398  HFCompareOccBelowSet1->Fill(iWedge, tempData);
1399 
1400  tempData =
1401  (float)section.occupancy[iHLX].data[set1BetweenIndex][TriggerBX] /
1402  nActvTwrsSet1;
1403  HFCompareOccBetweenSet1->Fill(iWedge, tempData);
1404 
1405  tempData =
1406  (float)section.occupancy[iHLX].data[set1AboveIndex][TriggerBX] /
1407  nActvTwrsSet1;
1408  HFCompareOccAboveSet1->Fill(iWedge, tempData);
1409  }
1410 
1411  if (nActvTwrsSet2 > 0) {
1412  float tempData =
1413  (float)section.occupancy[iHLX].data[set2BelowIndex][TriggerBX] /
1414  nActvTwrsSet2;
1415  HFCompareOccBelowSet2->Fill(iWedge, tempData);
1416 
1417  tempData =
1418  (float)section.occupancy[iHLX].data[set2BetweenIndex][TriggerBX] /
1419  nActvTwrsSet2;
1420  HFCompareOccBetweenSet2->Fill(iWedge, tempData);
1421 
1422  tempData =
1423  (float)section.occupancy[iHLX].data[set2AboveIndex][TriggerBX] /
1424  nActvTwrsSet2;
1425  HFCompareOccAboveSet2->Fill(iWedge, tempData);
1426  }
1427  }
1428  }
1429 }
1430 
1432  const edm::Event& e) {
1433  // New run .. set the run number and fill run summaries ...
1434  // std::cout << "Run number " << runNumber_ << " Section hdr run number "
1435  // << section.hdr.runNumber << std::endl;
1436 
1437  runId_->Fill(section.hdr.runNumber);
1438  lumisecId_->Fill((int)(section.hdr.sectionNumber / num4NibblePerLS_) + 1);
1439 
1440  // Update the total nibbles & the expected number
1441  expectedNibbles_ += section.hdr.numOrbits / 4096;
1442  for (unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX) {
1443  unsigned int iWedge = HLXHFMap[iHLX] + 1;
1444  totalNibbles_[iWedge - 1] += section.occupancy[iHLX].hdr.numNibbles;
1445  }
1446 
1447  eventId_->Fill(e.id().event());
1448  eventTimeStamp_->Fill(e.time().value() / (double)0xffffffff);
1449 
1450  pEvent_++;
1451  evtRateCount_++;
1453 
1455  gettimeofday(&currentTime_, nullptr);
1458 
1460  if (time >= (evtRateWindow_ * 60.0)) {
1461  processEventRate_->Fill((float)evtRateCount_ / time);
1462  evtRateCount_ = 0;
1464  }
1465 }
1466 
1468  // Run summary - Loop over the HLX's and fill the map,
1469  // also calculate the overall quality.
1470  float overall = 0.0;
1471  for (unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX) {
1472  unsigned int iWedge = HLXHFMap[iHLX] + 1;
1473  unsigned int iEta = 2;
1474  float frac = 0.0;
1475  if (expectedNibbles_ > 0)
1476  frac = (float)totalNibbles_[iWedge - 1] / (float)expectedNibbles_;
1477  if (iWedge >= 19) {
1478  iEta = 1;
1479  iWedge -= 18;
1480  }
1481  reportSummaryMap_->setBinContent(iWedge, iEta, frac);
1482  overall += frac;
1483  }
1484 
1485  overall /= (float)NUM_HLX;
1486  if (overall > 1.0) overall = 0.0;
1487  // std::cout << "Filling report summary! Main. " << overall << std::endl;
1488  reportSummary_->Fill(overall);
1489 }
1490 
1492  for (unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX) {
1493  Set1Below[iHLX]->softReset();
1494  Set1Between[iHLX]->softReset();
1495  Set1Above[iHLX]->softReset();
1496  Set2Below[iHLX]->softReset();
1497  Set2Between[iHLX]->softReset();
1498  Set2Above[iHLX]->softReset();
1499  ETSum[iHLX]->softReset();
1500  }
1501 
1509 
1510  AvgEtSum->softReset();
1517 
1518  // Luminosity Monitoring
1528 
1529  // Sanity Check for Occupancy
1533 
1538 
1543 
1544  // History
1545  lumiSectionCount = 0;
1546  previousSection = 0;
1549 
1556 
1563 
1576 
1583 
1586 }
1587 
1588 double HLXMonitor::getUTCtime(timeval* a, timeval* b) {
1589  double deltaT = (*a).tv_sec * 1000.0 + (*a).tv_usec / 1000.0;
1590  if (b != nullptr) deltaT = (*b).tv_sec * 1000.0 + (*b).tv_usec / 1000.0 - deltaT;
1591  return deltaT / 1000.0;
1592 }
1593 
1594 // define this as a plug-in
double sectionInstantSumEt
Definition: HLXMonitor.h:268
MonitorElement * HistAvgOccBetweenSet1HFP
Definition: HLXMonitor.h:135
MonitorElement * HFCompareOccAboveSet1
Definition: HLXMonitor.h:90
EventNumber_t event() const
Definition: EventID.h:41
MonitorElement * Set2Between[36]
Definition: HLXMonitor.h:83
MonitorElement * processLatency_
The UTC time of the last event.
Definition: HLXMonitor.h:187
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * HistInstantLumiOccSet1
Definition: HLXMonitor.h:152
std::string OutputDir
Definition: HLXMonitor.h:218
MonitorElement * HFCompareOccAboveSet2
Definition: HLXMonitor.h:93
MonitorElement * RecentIntegratedLumiOccSet2
Definition: HLXMonitor.h:166
MonitorElement * MaxInstLumiBX4
Definition: HLXMonitor.h:123
unsigned int totalNibbles_[36]
Definition: HLXMonitor.h:261
MonitorElement * processTimeStamp_
The UTC time of the first event processed.
Definition: HLXMonitor.h:186
void FillReportSummary()
Definition: HLXMonitor.cc:1467
void SetupHists(DQMStore::IBooker &)
Definition: HLXMonitor.cc:153
void setBinContent(int binx, double content)
set content of bin (1-D)
unsigned int HLXHFMap[36]
Definition: HLXMonitor.h:263
int SetPort(unsigned short int)
Definition: TCPReceiver.cc:182
MonitorElement * HistAvgLumiOccSet2
Definition: HLXMonitor.h:150
unsigned int secNumLength
Definition: HLXMonitor.h:249
MonitorElement * HistAvgOccBelowSet2HFM
Definition: HLXMonitor.h:140
void EndRun()
Definition: HLXMonitor.cc:879
MonitorElement * RecentIntegratedLumiEtSum
Definition: HLXMonitor.h:164
double XMAX
Definition: HLXMonitor.h:214
MonitorElement * LumiIntegratedEtSum
Definition: HLXMonitor.h:110
MonitorElement * SumAllOccSet1
Definition: HLXMonitor.h:115
MonitorElement * LumiInstantOccSet2
Definition: HLXMonitor.h:109
MonitorElement * AvgOccBetweenSet2
Definition: HLXMonitor.h:100
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
int prescaleEvt_
Definition: HLXMonitor.h:229
MonitorElement * AvgOccBelowSet1
Definition: HLXMonitor.h:96
MonitorElement * HistAvgEtSumHFM
Definition: HLXMonitor.h:132
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
MonitorElement * AvgOccAboveSet2
Definition: HLXMonitor.h:101
MonitorElement * HistAvgEtSumHFP
Definition: HLXMonitor.h:131
MonitorElement * HistAvgOccAboveSet1HFP
Definition: HLXMonitor.h:137
TH1F * getTH1F() const
MonitorElement * LumiInstantEtSum
Definition: HLXMonitor.h:107
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::string OccYAxisTitle
Definition: HLXMonitor.h:252
MonitorElement * LumiAvgOccSet2
Definition: HLXMonitor.h:106
MonitorElement * cmsswVer_
Current working directory of the job.
Definition: HLXMonitor.h:194
MonitorElement * HistInstantLumiOccSet2Error
Definition: HLXMonitor.h:156
unsigned int NUM_HLX
Definition: HLXMonitor.h:221
MonitorElement * processEventRate_
Time elapsed since the last event.
Definition: HLXMonitor.h:188
MonitorElement * bookInt(Args &&...args)
Definition: DQMStore.h:106
unsigned int runNumber_
Definition: HLXMonitor.h:259
MonitorElement * bookString(Args &&...args)
Definition: DQMStore.h:100
int lsBinOld
Definition: HLXMonitor.h:267
MonitorElement * MissingDQMDataCheck
Definition: HLXMonitor.h:117
Definition: weight.py:1
MonitorElement * HistInstantLumiOccSet2
Definition: HLXMonitor.h:153
MonitorElement * LumiInstantOccSet1
Definition: HLXMonitor.h:108
MonitorElement * HistAvgOccAboveSet1HFM
Definition: HLXMonitor.h:138
float evtRateWindow_
Definition: HLXMonitor.h:279
std::string OutputFilePrefix
Definition: HLXMonitor.h:217
MonitorElement * LumiIntegratedOccSet1
Definition: HLXMonitor.h:111
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
double sectionInstantErrSumEt
Definition: HLXMonitor.h:269
double sectionInstantErrSumOcc2
Definition: HLXMonitor.h:273
unsigned int set2AboveIndex
Definition: HLXMonitor.h:240
MonitorElement * Set1Below[36]
Definition: HLXMonitor.h:79
void SetIP(std::string IP)
Definition: TCPReceiver.cc:222
int evtRateCount_
Definition: HLXMonitor.h:280
double XMIN
Definition: HLXMonitor.h:214
void Fill(long long x)
std::string EtYAxisTitle
Definition: HLXMonitor.h:254
std::string eventInfoFolderHLX_
Definition: HLXMonitor.h:244
MonitorElement * HistInstantLumiEtSumError
Definition: HLXMonitor.h:154
std::string DistribIP2
Definition: HLXMonitor.h:233
MonitorElement * eventId_
UTC time of the run start.
Definition: HLXMonitor.h:175
int listenPort
Definition: HLXMonitor.h:213
MonitorElement * processId_
Number of collector updates (TBD)
Definition: HLXMonitor.h:183
MonitorElement * MaxInstLumiBX1
Definition: HLXMonitor.h:120
MonitorElement * reportSummaryMap_
Definition: HLXMonitor.h:203
unsigned int MAX_LS
Definition: HLXMonitor.h:223
int iEvent
Definition: GenABIO.cc:230
MonitorElement * HistAvgOccBelowSet1HFP
Definition: HLXMonitor.h:133
MonitorElement * HFCompareEtSum
Definition: HLXMonitor.h:87
double getUTCtime(timeval *a, timeval *b=0)
Definition: HLXMonitor.cc:1588
MonitorElement * runStartTimeStamp_
Definition: HLXMonitor.h:174
MonitorElement * Set1Between[36]
Definition: HLXMonitor.h:80
unsigned int set2BetweenIndex
Definition: HLXMonitor.h:239
double sectionInstantSumOcc1
Definition: HLXMonitor.h:270
timeval lastUpdateTime_
Definition: HLXMonitor.h:277
unsigned int set2BelowIndex
Definition: HLXMonitor.h:238
T sqrt(T t)
Definition: SSEVec.h:18
double sectionInstantSumOcc2
Definition: HLXMonitor.h:272
MonitorElement * HistIntegratedLumiOccSet1
Definition: HLXMonitor.h:158
MonitorElement * RecentInstantLumiOccSet1
Definition: HLXMonitor.h:162
MonitorElement * HistIntegratedLumiOccSet2
Definition: HLXMonitor.h:159
MonitorElement * BXvsTimeAvgEtSumHFM
Definition: HLXMonitor.h:146
MonitorElement * HistAvgOccBetweenSet2HFM
Definition: HLXMonitor.h:142
void connectHLXTCP()
Definition: HLXMonitor.cc:121
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
MonitorElement * AvgOccAboveSet1
Definition: HLXMonitor.h:98
MonitorElement * HistInstantLumiOccSet1Error
Definition: HLXMonitor.h:155
HCAL_HLX::LUMI_SECTION lumiSection
Definition: HLXMonitor.h:256
MonitorElement * hostName_
of event processed so far
Definition: HLXMonitor.h:191
MonitorElement * HFCompareOccBelowSet1
Definition: HLXMonitor.h:88
unsigned int NBINS
Definition: HLXMonitor.h:215
MonitorElement * ETSum[36]
Definition: HLXMonitor.h:85
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
bool ResetAtNewRun
Definition: HLXMonitor.h:242
MonitorElement * Set2Below[36]
Definition: HLXMonitor.h:82
MonitorElement * MaxInstLumiBXNum2
Definition: HLXMonitor.h:126
Definition: Style.py:1
MonitorElement * MaxInstLumiBX2
Definition: HLXMonitor.h:121
MonitorElement * SumAllOccSet2
Definition: HLXMonitor.h:116
std::string monitorName_
Definition: HLXMonitor.h:228
MonitorElement * AvgEtSum
Definition: HLXMonitor.h:95
MonitorElement * nUpdates_
These MEs are either static or updated upon each analyze() call.
Definition: HLXMonitor.h:182
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: HLXMonitor.cc:826
MonitorElement * HistAvgOccAboveSet2HFM
Definition: HLXMonitor.h:144
TH2F * getTH2F() const
OCCUPANCY_SECTION occupancy[36]
bool Accumulate
Definition: HLXMonitor.h:216
MonitorElement * LumiAvgEtSum
Definition: HLXMonitor.h:104
MonitorElement * eventTimeStamp_
Definition: HLXMonitor.h:177
MonitorElement * BXvsTimeAvgEtSumHFP
Definition: HLXMonitor.h:145
MonitorElement * HistAvgOccBetweenSet1HFM
Definition: HLXMonitor.h:136
MonitorElement * RecentIntegratedLumiOccSet1
Definition: HLXMonitor.h:165
unsigned int TriggerBX
Definition: HLXMonitor.h:225
MonitorElement * MaxInstLumiBXNum4
Definition: HLXMonitor.h:128
std::string getReleaseVersion()
unsigned int NUM_BUNCHES
Definition: HLXMonitor.h:222
MonitorElement * HistAvgLumiOccSet1
Definition: HLXMonitor.h:149
MonitorElement * HistAvgOccAboveSet2HFP
Definition: HLXMonitor.h:143
Float e1
Definition: deltaR.h:20
unsigned int MinLSBeforeSave
Definition: HLXMonitor.h:226
MonitorElement * HistAvgOccBelowSet1HFM
Definition: HLXMonitor.h:134
MonitorElement * RecentInstantLumiOccSet2
Definition: HLXMonitor.h:163
MonitorElement * Set2Above[36]
Definition: HLXMonitor.h:84
MonitorElement * HistAvgLumiEtSum
Definition: HLXMonitor.h:148
MonitorElement * HistIntegratedLumiEtSum
Definition: HLXMonitor.h:157
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
void tagContents(const std::string &, unsigned int)
Definition: DQMStore.cc:295
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
TCPReceiver HLXTCP
Definition: HLXMonitor.h:77
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
MonitorElement * HistAvgOccBelowSet2HFP
Definition: HLXMonitor.h:139
MonitorElement * processEvents_
Definition: HLXMonitor.h:190
double sectionInstantNorm
Definition: HLXMonitor.h:274
MonitorElement * MaxInstLumiBXNum3
Definition: HLXMonitor.h:127
MonitorElement * MaxInstLumiBX3
Definition: HLXMonitor.h:122
void setResetMe(bool)
double sectionInstantErrSumOcc1
Definition: HLXMonitor.h:271
unsigned int previousSection
Definition: HLXMonitor.h:265
std::string subSystemName_
Definition: HLXMonitor.h:246
bool currentRunEnded_
Definition: HLXMonitor.h:258
double b
Definition: hdecay.h:120
MonitorElement * processName_
Hostname of the local machine.
Definition: HLXMonitor.h:192
void FillEventInfo(const LUMI_SECTION &, const edm::Event &e)
Definition: HLXMonitor.cc:1431
unsigned int runNumLength
Definition: HLXMonitor.h:248
timeval lastAvgTime_
Definition: HLXMonitor.h:277
int ReceiveLumiSection(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:88
MonitorElement * Set1Above[36]
Definition: HLXMonitor.h:81
int SavePeriod
Definition: HLXMonitor.h:220
MonitorElement * processStartTimeStamp_
The PID associated with this job.
Definition: HLXMonitor.h:185
~HLXMonitor() override
Definition: HLXMonitor.cc:115
unsigned int expectedNibbles_
Definition: HLXMonitor.h:260
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int SetMode(unsigned char)
Definition: TCPReceiver.cc:202
MonitorElement * MaxInstLumiBXNum1
Definition: HLXMonitor.h:125
MonitorElement * AvgOccBelowSet2
Definition: HLXMonitor.h:99
double getBinContent(int binx) const
get content of bin (1-D)
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
HLXMonitor(const edm::ParameterSet &)
Definition: HLXMonitor.cc:17
double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
double num4NibblePerLS_
Definition: HLXMonitor.h:284
double a
Definition: hdecay.h:121
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HLXMonitor.cc:147
std::string OccXAxisTitle
Definition: HLXMonitor.h:251
MonitorElement * HistInstantLumiEtSum
Definition: HLXMonitor.h:151
MonitorElement * runId_
Definition: HLXMonitor.h:173
unsigned int AquireMode
Definition: HLXMonitor.h:224
MonitorElement * HFCompareOccBetweenSet2
Definition: HLXMonitor.h:92
unsigned int set1BelowIndex
Definition: HLXMonitor.h:235
unsigned int lumiSectionCount
Definition: HLXMonitor.h:266
std::string eventInfoFolder_
Definition: HLXMonitor.h:245
MonitorElement * LumiIntegratedOccSet2
Definition: HLXMonitor.h:112
MonitorElement * HFCompareOccBelowSet2
Definition: HLXMonitor.h:91
MonitorElement * HFCompareOccBetweenSet1
Definition: HLXMonitor.h:89
void FillHistograms(const LUMI_SECTION &)
Definition: HLXMonitor.cc:902
void ResetAll()
Definition: HLXMonitor.cc:1491
timeval currentTime_
Definition: HLXMonitor.h:277
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:112
MonitorElement * LumiAvgOccSet1
Definition: HLXMonitor.h:105
std::string DistribIP1
Definition: HLXMonitor.h:232
MonitorElement * workingDir_
DQM "name" of the job (eg, Hcal or DT)
Definition: HLXMonitor.h:193
MonitorElement * AvgOccBetweenSet1
Definition: HLXMonitor.h:97
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
MonitorElement * RecentInstantLumiEtSum
Definition: HLXMonitor.h:161
TimeValue_t value() const
Definition: Timestamp.h:56
edm::Timestamp time() const
Definition: EventBase.h:61
MonitorElement * reportSummary_
Definition: HLXMonitor.h:202
MonitorElement * HistAvgOccBetweenSet2HFP
Definition: HLXMonitor.h:141
unsigned int set1AboveIndex
Definition: HLXMonitor.h:237
std::string EtXAxisTitle
Definition: HLXMonitor.h:253
MonitorElement * lumisecId_
Definition: HLXMonitor.h:176
unsigned int reconnTime
Definition: HLXMonitor.h:231
void SetupEventInfo(DQMStore::IBooker &)
Definition: HLXMonitor.cc:747
Definition: Run.h:43
unsigned int set1BetweenIndex
Definition: HLXMonitor.h:236
void FillHistoHFCompare(const LUMI_SECTION &)
Definition: HLXMonitor.cc:1371