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