CMS 3D CMS Logo

BeamMonitor.cc
Go to the documentation of this file.
1 /*
2  * \file BeamMonitor.cc
3  * \author Geng-yuan Jeng/UC Riverside
4  * Francisco Yumiceva/FNAL
5  */
6 
7 /*
8 The code has been modified for running average
9 mode, and it gives results for the last NLS which is
10 configurable.
11 Sushil S. Chauhan /UCDavis
12 Evan Friis /UCDavis
13 The last tag for working versions without this change is
14 V00-03-25
15 */
16 
32 #include <numeric>
33 #include <cmath>
34 #include <memory>
35 #include <TMath.h>
36 #include <iostream>
37 #include <TStyle.h>
38 #include <ctime>
39 
40 using namespace std;
41 using namespace edm;
42 
43 void BeamMonitor::formatFitTime(char* ts, const time_t& t) {
44  //constexpr int CET(+1);
45  constexpr int CEST(+2);
46 
47  //tm * ptm;
48  //ptm = gmtime ( &t );
49  //int year = ptm->tm_year;
50 
51  //get correct year from ctime
52  time_t currentTime;
53  struct tm* localTime;
54  time(&currentTime); // Get the current time
55  localTime = localtime(&currentTime); // Convert the current time to the local time
56  int year = localTime->tm_year + 1900;
57 
58  tm* ptm;
59  ptm = gmtime(&t);
60 
61  //check if year is ok
62  if (year <= 37)
63  year += 2000;
64  if (year >= 70 && year <= 137)
65  year += 1900;
66 
67  if (year < 1995) {
68  edm::LogError("BadTimeStamp") << "year reported is " << year << " !!" << std::endl;
69  //year = 2015; //overwritten later by BeamFitter.cc for fits but needed here for TH1
70  //edm::LogError("BadTimeStamp") << "Resetting to " <<year<<std::endl;
71  }
72  sprintf(ts,
73  "%4d-%02d-%02d %02d:%02d:%02d",
74  year,
75  ptm->tm_mon + 1,
76  ptm->tm_mday,
77  (ptm->tm_hour + CEST) % 24,
78  ptm->tm_min,
79  ptm->tm_sec);
80 
81 #ifdef STRIP_TRAILING_BLANKS_IN_TIMEZONE
82  unsigned int b = strlen(ts);
83  while (ts[--b] == ' ') {
84  ts[b] = 0;
85  }
86 #endif
87 }
88 
89 static constexpr int buffTime = 23;
90 
91 std::string BeamMonitor::getGMTstring(const time_t& timeToConvert) {
92  char buff[32];
93  std::strftime(buff, sizeof(buff), "%Y.%m.%d %H:%M:%S GMT", gmtime(&timeToConvert));
94  std::string timeStr(buff);
95  return timeStr;
96 }
97 
98 //
99 // constructors and destructor
100 //
102  : dxBin_(ps.getParameter<int>("dxBin")),
103  dxMin_(ps.getParameter<double>("dxMin")),
104  dxMax_(ps.getParameter<double>("dxMax")),
105 
106  vxBin_(ps.getParameter<int>("vxBin")),
107  vxMin_(ps.getParameter<double>("vxMin")),
108  vxMax_(ps.getParameter<double>("vxMax")),
109 
110  phiBin_(ps.getParameter<int>("phiBin")),
111  phiMin_(ps.getParameter<double>("phiMin")),
112  phiMax_(ps.getParameter<double>("phiMax")),
113 
114  dzBin_(ps.getParameter<int>("dzBin")),
115  dzMin_(ps.getParameter<double>("dzMin")),
116  dzMax_(ps.getParameter<double>("dzMax")),
117 
118  countEvt_(0),
119  countLumi_(0),
120  nthBSTrk_(0),
121  nFitElements_(3),
122  resetHistos_(false),
123  StartAverage_(false),
124  firstAverageFit_(0),
125  countGapLumi_(0) {
126  monitorName_ = ps.getUntrackedParameter<string>("monitorName", "YourSubsystemName");
127  recordName_ = ps.getUntrackedParameter<string>("recordName");
128  bsSrc_ = consumes<reco::BeamSpot>(ps.getUntrackedParameter<InputTag>("beamSpot"));
129  tracksLabel_ = consumes<reco::TrackCollection>(
130  ps.getParameter<ParameterSet>("BeamFitter").getUntrackedParameter<InputTag>("TrackCollection"));
131  pvSrc_ = consumes<reco::VertexCollection>(ps.getUntrackedParameter<InputTag>("primaryVertex"));
132  hltSrc_ = consumes<TriggerResults>(ps.getParameter<InputTag>("hltResults"));
133  intervalInSec_ = ps.getUntrackedParameter<int>("timeInterval", 920); //40 LS X 23"
134  fitNLumi_ = ps.getUntrackedParameter<int>("fitEveryNLumi", -1);
135  resetFitNLumi_ = ps.getUntrackedParameter<int>("resetEveryNLumi", -1);
136  fitPVNLumi_ = ps.getUntrackedParameter<int>("fitPVEveryNLumi", -1);
137  resetPVNLumi_ = ps.getUntrackedParameter<int>("resetPVEveryNLumi", -1);
138  deltaSigCut_ = ps.getUntrackedParameter<double>("deltaSignificanceCut", 15);
139  debug_ = ps.getUntrackedParameter<bool>("Debug");
140  onlineMode_ = ps.getUntrackedParameter<bool>("OnlineMode");
141  jetTrigger_ = ps.getUntrackedParameter<std::vector<std::string> >("jetTrigger");
142  min_Ntrks_ = ps.getParameter<ParameterSet>("BeamFitter").getUntrackedParameter<int>("MinimumInputTracks");
143  maxZ_ = ps.getParameter<ParameterSet>("BeamFitter").getUntrackedParameter<double>("MaximumZ");
144  minNrVertices_ = ps.getParameter<ParameterSet>("PVFitter").getUntrackedParameter<unsigned int>("minNrVerticesForFit");
145  minVtxNdf_ = ps.getParameter<ParameterSet>("PVFitter").getUntrackedParameter<double>("minVertexNdf");
146  minVtxWgt_ = ps.getParameter<ParameterSet>("PVFitter").getUntrackedParameter<double>("minVertexMeanWeight");
147  useLockRecords_ = ps.getUntrackedParameter<bool>("useLockRecords");
148 
149  if (!monitorName_.empty())
150  monitorName_ = monitorName_ + "/";
151 
152  theBeamFitter = std::make_unique<BeamFitter>(ps, consumesCollector());
153  theBeamFitter->resetTrkVector();
154  theBeamFitter->resetLSRange();
155  theBeamFitter->resetRefTime();
156  theBeamFitter->resetPVFitter();
157 
158  if (fitNLumi_ <= 0)
159  fitNLumi_ = 1;
161  refBStime[0] = refBStime[1] = refPVtime[0] = refPVtime[1] = 0;
162  maxZ_ = std::fabs(maxZ_);
163  lastlumi_ = 0;
164  nextlumi_ = 0;
165  processed_ = false;
166 }
167 
168 //--------------------------------------------------------
169 namespace {
170  /*The order of the enums is identical to the order in which
171  MonitorElements are added to hs
172  */
173  enum Hists {
174  k_x0_lumi,
175  k_x0_lumi_all,
176  k_y0_lumi,
177  k_y0_lumi_all,
178  k_z0_lumi,
179  k_z0_lumi_all,
180  k_sigmaX0_lumi,
181  k_sigmaX0_lumi_all,
182  k_sigmaY0_lumi,
183  k_sigmaY0_lumi_all,
184  k_sigmaZ0_lumi,
185  k_sigmaZ0_lumi_all,
186  k_x0_time,
187  k_x0_time_all,
188  k_y0_time,
189  k_y0_time_all,
190  k_z0_time,
191  k_z0_time_all,
192  k_sigmaX0_time,
193  k_sigmaX0_time_all,
194  k_sigmaY0_time,
195  k_sigmaY0_time_all,
196  k_sigmaZ0_time,
197  k_sigmaZ0_time_all,
198  k_PVx_lumi,
199  k_PVx_lumi_all,
200  k_PVy_lumi,
201  k_PVy_lumi_all,
202  k_PVz_lumi,
203  k_PVz_lumi_all,
204  k_PVx_time,
205  k_PVx_time_all,
206  k_PVy_time,
207  k_PVy_time_all,
208  k_PVz_time,
209  k_PVz_time_all,
210  kNumHists
211  };
212 } // namespace
213 
217  }
218 }
219 
220 void BeamMonitor::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& iRun, edm::EventSetup const& iSetup) {
221  frun = iRun.run();
222  ftimestamp = iRun.beginTime().value();
223  tmpTime = ftimestamp >> 32;
225  char eventTime[64];
226  formatFitTime(eventTime, tmpTime);
227  edm::LogInfo("BeamMonitor") << "TimeOffset = " << eventTime << std::endl;
228  TDatime da(eventTime);
229  if (debug_) {
230  edm::LogInfo("BeamMonitor") << "TimeOffset = ";
231  da.Print();
232  }
233  auto daTime = da.Convert(kTRUE);
234 
235  // book some histograms here
236 
237  // create and cd into new folder
238  iBooker.setCurrentFolder(monitorName_ + "Fit");
239 
240  h_nTrk_lumi = iBooker.book1D("nTrk_lumi", "Num. of selected tracks vs lumi (Fit)", 20, 0.5, 20.5);
241  h_nTrk_lumi->setAxisTitle("Lumisection", 1);
242  h_nTrk_lumi->setAxisTitle("Num of Tracks for Fit", 2);
243 
244  //store vtx vs lumi for monitoring why fits fail
245  h_nVtx_lumi = iBooker.book1D("nVtx_lumi", "Num. of selected Vtx vs lumi (Fit)", 20, 0.5, 20.5);
246  h_nVtx_lumi->setAxisTitle("Lumisection", 1);
247  h_nVtx_lumi->setAxisTitle("Num of Vtx for Fit", 2);
248 
249  h_nVtx_lumi_all = iBooker.book1D("nVtx_lumi_all", "Num. of selected Vtx vs lumi (Fit) all", 20, 0.5, 20.5);
250  h_nVtx_lumi_all->getTH1()->SetCanExtend(TH1::kAllAxes);
251  h_nVtx_lumi_all->setAxisTitle("Lumisection", 1);
252  h_nVtx_lumi_all->setAxisTitle("Num of Vtx for Fit", 2);
253 
254  h_d0_phi0 = iBooker.bookProfile(
255  "d0_phi0", "d_{0} vs. #phi_{0} (Selected Tracks)", phiBin_, phiMin_, phiMax_, dxBin_, dxMin_, dxMax_, "");
256  h_d0_phi0->setAxisTitle("#phi_{0} (rad)", 1);
257  h_d0_phi0->setAxisTitle("d_{0} (cm)", 2);
258 
259  h_vx_vy = iBooker.book2D(
260  "trk_vx_vy", "Vertex (PCA) position of selected tracks", vxBin_, vxMin_, vxMax_, vxBin_, vxMin_, vxMax_);
261  h_vx_vy->setOption("COLZ");
262  // h_vx_vy->getTH1()->SetCanExtend(TH1::kAllAxes);
263  h_vx_vy->setAxisTitle("x coordinate of input track at PCA (cm)", 1);
264  h_vx_vy->setAxisTitle("y coordinate of input track at PCA (cm)", 2);
265 
266  {
267  TDatime* da = new TDatime();
268  gStyle->SetTimeOffset(da->Convert(kTRUE));
269  }
270 
271  const int nvar_ = 6;
272  string coord[nvar_] = {"x", "y", "z", "sigmaX", "sigmaY", "sigmaZ"};
273  string label[nvar_] = {
274  "x_{0} (cm)", "y_{0} (cm)", "z_{0} (cm)", "#sigma_{X_{0}} (cm)", "#sigma_{Y_{0}} (cm)", "#sigma_{Z_{0}} (cm)"};
275 
276  hs.reserve(kNumHists);
277  for (int i = 0; i < 4; i++) {
278  iBooker.setCurrentFolder(monitorName_ + "Fit");
279  for (int ic = 0; ic < nvar_; ++ic) {
280  TString histName(coord[ic]);
281  TString histTitle(coord[ic]);
282  string ytitle(label[ic]);
283  string xtitle("");
284  string options("E1");
285  bool createHisto = true;
286  switch (i) {
287  case 1: // BS vs time
288  histName += "0_time";
289  xtitle = "Time [UTC]";
290  if (ic < 3)
291  histTitle += " coordinate of beam spot vs time (Fit)";
292  else
293  histTitle = histTitle.Insert(5, " ") + " of beam spot vs time (Fit)";
294  break;
295  case 2: // PV vs lumi
296  if (ic < 3) {
297  iBooker.setCurrentFolder(monitorName_ + "PrimaryVertex");
298  histName.Insert(0, "PV");
299  histName += "_lumi";
300  histTitle.Insert(0, "Avg. ");
301  histTitle += " position of primary vtx vs lumi";
302  xtitle = "Lumisection";
303  ytitle.insert(0, "PV");
304  ytitle += " #pm #sigma_{PV";
305  ytitle += coord[ic];
306  ytitle += "} (cm)";
307  } else
308  createHisto = false;
309  break;
310  case 3: // PV vs time
311  if (ic < 3) {
312  iBooker.setCurrentFolder(monitorName_ + "PrimaryVertex");
313  histName.Insert(0, "PV");
314  histName += "_time";
315  histTitle.Insert(0, "Avg. ");
316  histTitle += " position of primary vtx vs time";
317  xtitle = "Time [UTC]";
318  ytitle.insert(0, "PV");
319  ytitle += " #pm #sigma_{PV";
320  ytitle += coord[ic];
321  ytitle += "} (cm)";
322  } else
323  createHisto = false;
324  break;
325  default: // BS vs lumi
326  histName += "0_lumi";
327  xtitle = "Lumisection";
328  if (ic < 3)
329  histTitle += " coordinate of beam spot vs lumi (Fit)";
330  else
331  histTitle = histTitle.Insert(5, " ") + " of beam spot vs lumi (Fit)";
332  break;
333  }
334  if (createHisto) {
335  edm::LogInfo("BeamMonitor") << "hitsName = " << histName << "; histTitle = " << histTitle << std::endl;
336  auto tmpHs = iBooker.book1D(histName, histTitle, 40, 0.5, 40.5);
337  hs.push_back(tmpHs);
338  tmpHs->setAxisTitle(xtitle, 1);
339  tmpHs->setAxisTitle(ytitle, 2);
340  tmpHs->getTH1()->SetOption("E1");
341  if (histName.Contains("time")) {
342  //int nbins = (intervalInSec_/23 > 0 ? intervalInSec_/23 : 40);
343  tmpHs->getTH1()->SetBins(intervalInSec_, 0.5, intervalInSec_ + 0.5);
344  tmpHs->setAxisTimeDisplay(1);
345  tmpHs->setAxisTimeFormat("%H:%M:%S", 1);
346  tmpHs->getTH1()->GetXaxis()->SetTimeOffset(daTime);
347  }
348  histName += "_all";
349  histTitle += " all";
350  tmpHs = iBooker.book1D(histName, histTitle, 40, 0.5, 40.5);
351  hs.push_back(tmpHs);
352  tmpHs->getTH1()->SetCanExtend(TH1::kAllAxes);
353  tmpHs->setAxisTitle(xtitle, 1);
354  tmpHs->setAxisTitle(ytitle, 2);
355  tmpHs->getTH1()->SetOption("E1");
356  if (histName.Contains("time")) {
357  //int nbins = (intervalInSec_/23 > 0 ? intervalInSec_/23 : 40);
358  tmpHs->getTH1()->SetBins(intervalInSec_, 0.5, intervalInSec_ + 0.5);
359  tmpHs->setAxisTimeDisplay(1);
360  tmpHs->setAxisTimeFormat("%H:%M:%S", 1);
361  tmpHs->getTH1()->GetXaxis()->SetTimeOffset(daTime);
362  }
363  }
364  }
365  }
366  assert(hs.size() == kNumHists);
367  assert(0 == strcmp(hs[k_sigmaY0_time]->getTH1()->GetName(), "sigmaY0_time"));
368  assert(0 == strcmp(hs[k_PVz_lumi_all]->getTH1()->GetName(), "PVz_lumi_all"));
369 
370  iBooker.setCurrentFolder(monitorName_ + "Fit");
371 
372  h_trk_z0 = iBooker.book1D("trk_z0", "z_{0} of selected tracks", dzBin_, dzMin_, dzMax_);
373  h_trk_z0->setAxisTitle("z_{0} of selected tracks (cm)", 1);
374 
375  h_vx_dz = iBooker.bookProfile(
376  "vx_dz", "v_{x} vs. dz of selected tracks", dzBin_, dzMin_, dzMax_, dxBin_, dxMin_, dxMax_, "");
377  h_vx_dz->setAxisTitle("dz (cm)", 1);
378  h_vx_dz->setAxisTitle("x coordinate of input track at PCA (cm)", 2);
379 
380  h_vy_dz = iBooker.bookProfile(
381  "vy_dz", "v_{y} vs. dz of selected tracks", dzBin_, dzMin_, dzMax_, dxBin_, dxMin_, dxMax_, "");
382  h_vy_dz->setAxisTitle("dz (cm)", 1);
383  h_vy_dz->setAxisTitle("y coordinate of input track at PCA (cm)", 2);
384 
385  h_x0 = iBooker.book1D("BeamMonitorFeedBack_x0", "x coordinate of beam spot (Fit)", 100, -0.01, 0.01);
386  h_x0->setAxisTitle("x_{0} (cm)", 1);
387  h_x0->getTH1()->SetCanExtend(TH1::kAllAxes);
388 
389  h_y0 = iBooker.book1D("BeamMonitorFeedBack_y0", "y coordinate of beam spot (Fit)", 100, -0.01, 0.01);
390  h_y0->setAxisTitle("y_{0} (cm)", 1);
391  h_y0->getTH1()->SetCanExtend(TH1::kAllAxes);
392 
393  h_z0 = iBooker.book1D("BeamMonitorFeedBack_z0", "z coordinate of beam spot (Fit)", dzBin_, dzMin_, dzMax_);
394  h_z0->setAxisTitle("z_{0} (cm)", 1);
395  h_z0->getTH1()->SetCanExtend(TH1::kAllAxes);
396 
397  h_sigmaX0 = iBooker.book1D("BeamMonitorFeedBack_sigmaX0", "sigma x0 of beam spot (Fit)", 100, 0, 0.05);
398  h_sigmaX0->setAxisTitle("#sigma_{X_{0}} (cm)", 1);
399  h_sigmaX0->getTH1()->SetCanExtend(TH1::kAllAxes);
400 
401  h_sigmaY0 = iBooker.book1D("BeamMonitorFeedBack_sigmaY0", "sigma y0 of beam spot (Fit)", 100, 0, 0.05);
402  h_sigmaY0->setAxisTitle("#sigma_{Y_{0}} (cm)", 1);
403  h_sigmaY0->getTH1()->SetCanExtend(TH1::kAllAxes);
404 
405  h_sigmaZ0 = iBooker.book1D("BeamMonitorFeedBack_sigmaZ0", "sigma z0 of beam spot (Fit)", 100, 0, 10);
406  h_sigmaZ0->setAxisTitle("#sigma_{Z_{0}} (cm)", 1);
407  h_sigmaZ0->getTH1()->SetCanExtend(TH1::kAllAxes);
408 
409  // Histograms of all reco tracks (without cuts):
410  h_trkPt = iBooker.book1D("trkPt", "p_{T} of all reco'd tracks (no selection)", 200, 0., 50.);
411  h_trkPt->setAxisTitle("p_{T} (GeV/c)", 1);
412 
413  h_trkVz = iBooker.book1D("trkVz", "Z coordinate of PCA of all reco'd tracks (no selection)", dzBin_, dzMin_, dzMax_);
414  h_trkVz->setAxisTitle("V_{Z} (cm)", 1);
415 
416  cutFlowTable = iBooker.book1D("cutFlowTable", "Cut flow table of track selection", 9, 0, 9);
417 
418  // Results of previous good fit:
419  fitResults = iBooker.book2D("fitResults", "Results of previous good beam fit", 2, 0, 2, 8, 0, 8);
420  fitResults->setAxisTitle("Fitted Beam Spot (cm)", 1);
421  fitResults->setBinLabel(8, "x_{0}", 2);
422  fitResults->setBinLabel(7, "y_{0}", 2);
423  fitResults->setBinLabel(6, "z_{0}", 2);
424  fitResults->setBinLabel(5, "#sigma_{Z}", 2);
425  fitResults->setBinLabel(4, "#frac{dx}{dz} (rad)", 2);
426  fitResults->setBinLabel(3, "#frac{dy}{dz} (rad)", 2);
427  fitResults->setBinLabel(2, "#sigma_{X}", 2);
428  fitResults->setBinLabel(1, "#sigma_{Y}", 2);
429  fitResults->setBinLabel(1, "Mean", 1);
430  fitResults->setBinLabel(2, "Stat. Error", 1);
431  fitResults->getTH1()->SetOption("text");
432 
433  // Histos of PrimaryVertices:
434  iBooker.setCurrentFolder(monitorName_ + "PrimaryVertex");
435 
436  h_nVtx = iBooker.book1D("vtxNbr", "Reconstructed Vertices(non-fake) in all Event", 60, -0.5, 59.5);
437  h_nVtx->setAxisTitle("Num. of reco. vertices", 1);
438 
439  //For one Trigger only
440  h_nVtx_st = iBooker.book1D("vtxNbr_SelectedTriggers", "Reconstructed Vertices(non-fake) in Events", 60, -0.5, 59.5);
441  //h_nVtx_st->setAxisTitle("Num. of reco. vertices for Un-Prescaled Jet Trigger",1);
442 
443  // Monitor only the PV with highest sum pt of assoc. trks:
444  h_PVx[0] = iBooker.book1D("PVX", "x coordinate of Primary Vtx", 50, -0.01, 0.01);
445  h_PVx[0]->setAxisTitle("PVx (cm)", 1);
446  h_PVx[0]->getTH1()->SetCanExtend(TH1::kAllAxes);
447 
448  h_PVy[0] = iBooker.book1D("PVY", "y coordinate of Primary Vtx", 50, -0.01, 0.01);
449  h_PVy[0]->setAxisTitle("PVy (cm)", 1);
450  h_PVy[0]->getTH1()->SetCanExtend(TH1::kAllAxes);
451 
452  h_PVz[0] = iBooker.book1D("PVZ", "z coordinate of Primary Vtx", dzBin_, dzMin_, dzMax_);
453  h_PVz[0]->setAxisTitle("PVz (cm)", 1);
454 
455  h_PVx[1] = iBooker.book1D("PVXFit", "x coordinate of Primary Vtx (Last Fit)", 50, -0.01, 0.01);
456  h_PVx[1]->setAxisTitle("PVx (cm)", 1);
457  h_PVx[1]->getTH1()->SetCanExtend(TH1::kAllAxes);
458 
459  h_PVy[1] = iBooker.book1D("PVYFit", "y coordinate of Primary Vtx (Last Fit)", 50, -0.01, 0.01);
460  h_PVy[1]->setAxisTitle("PVy (cm)", 1);
461  h_PVy[1]->getTH1()->SetCanExtend(TH1::kAllAxes);
462 
463  h_PVz[1] = iBooker.book1D("PVZFit", "z coordinate of Primary Vtx (Last Fit)", dzBin_, dzMin_, dzMax_);
464  h_PVz[1]->setAxisTitle("PVz (cm)", 1);
465 
466  h_PVxz = iBooker.bookProfile("PVxz", "PVx vs. PVz", dzBin_ / 2, dzMin_, dzMax_, dxBin_ / 2, dxMin_, dxMax_, "");
467  h_PVxz->setAxisTitle("PVz (cm)", 1);
468  h_PVxz->setAxisTitle("PVx (cm)", 2);
469 
470  h_PVyz = iBooker.bookProfile("PVyz", "PVy vs. PVz", dzBin_ / 2, dzMin_, dzMax_, dxBin_ / 2, dxMin_, dxMax_, "");
471  h_PVyz->setAxisTitle("PVz (cm)", 1);
472  h_PVyz->setAxisTitle("PVy (cm)", 2);
473 
474  // Results of previous good fit:
475  pvResults = iBooker.book2D("pvResults", "Results of fitting Primary Vertices", 2, 0, 2, 6, 0, 6);
476  pvResults->setAxisTitle("Fitted Primary Vertex (cm)", 1);
477  pvResults->setBinLabel(6, "PVx", 2);
478  pvResults->setBinLabel(5, "PVy", 2);
479  pvResults->setBinLabel(4, "PVz", 2);
480  pvResults->setBinLabel(3, "#sigma_{X}", 2);
481  pvResults->setBinLabel(2, "#sigma_{Y}", 2);
482  pvResults->setBinLabel(1, "#sigma_{Z}", 2);
483  pvResults->setBinLabel(1, "Mean", 1);
484  pvResults->setBinLabel(2, "Stat. Error", 1);
485  pvResults->getTH1()->SetOption("text");
486 
487  // Summary plots:
488  iBooker.setCurrentFolder(monitorName_ + "EventInfo");
489 
490  reportSummary = iBooker.bookFloat("reportSummary");
491  if (reportSummary)
492  reportSummary->Fill(std::numeric_limits<double>::quiet_NaN());
493 
494  char histo[20];
495  iBooker.setCurrentFolder(monitorName_ + "EventInfo/reportSummaryContents");
496  for (int n = 0; n < nFitElements_; n++) {
497  switch (n) {
498  case 0:
499  sprintf(histo, "x0_status");
500  break;
501  case 1:
502  sprintf(histo, "y0_status");
503  break;
504  case 2:
505  sprintf(histo, "z0_status");
506  break;
507  }
509  }
510 
511  for (int i = 0; i < nFitElements_; i++) {
512  summaryContent_[i] = 0.;
513  reportSummaryContents[i]->Fill(std::numeric_limits<double>::quiet_NaN());
514  }
515 
516  iBooker.setCurrentFolder(monitorName_ + "EventInfo");
517 
518  reportSummaryMap = iBooker.book2D("reportSummaryMap", "Beam Spot Summary Map", 1, 0, 1, 3, 0, 3);
520  reportSummaryMap->setAxisTitle("Fitted Beam Spot", 2);
521  reportSummaryMap->setBinLabel(1, " ", 1);
522  reportSummaryMap->setBinLabel(1, "x_{0}", 2);
523  reportSummaryMap->setBinLabel(2, "y_{0}", 2);
524  reportSummaryMap->setBinLabel(3, "z_{0}", 2);
525  for (int i = 0; i < nFitElements_; i++) {
526  reportSummaryMap->setBinContent(1, i + 1, -1.);
527  }
528 }
529 
530 //--------------------------------------------------------
532  // start DB logger
533  DBloggerReturn_ = 0;
536  onlineDbService_->logger().logInfo() << "BeamMonitor::beginLuminosityBlock - LS: " << lumiSeg.luminosityBlock()
537  << " - Run: " << lumiSeg.getRun().run();
538  }
539 
540  int nthlumi = lumiSeg.luminosityBlock();
541  const edm::TimeValue_t fbegintimestamp = lumiSeg.beginTime().value();
542  const std::time_t ftmptime = fbegintimestamp >> 32;
543 
544  if (countLumi_ == 0 && (!processed_)) {
546  refBStime[0] = refPVtime[0] = ftmptime;
547  mapBeginBSLS[countLumi_] = nthlumi;
548  mapBeginPVLS[countLumi_] = nthlumi;
549  mapBeginBSTime[countLumi_] = ftmptime;
550  mapBeginPVTime[countLumi_] = ftmptime;
551  } //for the first record
552 
553  if (nthlumi > nextlumi_) {
554  if (processed_) {
555  countLumi_++;
556  //store here them will need when we remove the first one of Last N LS
557  mapBeginBSLS[countLumi_] = nthlumi;
558  mapBeginPVLS[countLumi_] = nthlumi;
559  mapBeginBSTime[countLumi_] = ftmptime;
560  mapBeginPVTime[countLumi_] = ftmptime;
561  } //processed passed but not the first lumi
562  if ((!processed_) && countLumi_ != 0) {
563  mapBeginBSLS[countLumi_] = nthlumi;
564  mapBeginPVLS[countLumi_] = nthlumi;
565  mapBeginBSTime[countLumi_] = ftmptime;
566  mapBeginPVTime[countLumi_] = ftmptime;
567  } //processed fails for last lumi
568  } //nthLumi > nextlumi
569 
570  if (StartAverage_) {
571  //Just Make sure it get rest
572  refBStime[0] = 0;
573  refPVtime[0] = 0;
574  beginLumiOfPVFit_ = 0;
575  beginLumiOfBSFit_ = 0;
576 
577  if (debug_)
578  edm::LogInfo("BeamMonitor") << " beginLuminosityBlock: Size of mapBeginBSLS before = " << mapBeginBSLS.size()
579  << endl;
580  if (nthlumi >
581  nextlumi_) { //this make sure that it does not take into account this lumi for fitting and only look forward for new lumi
582  //as countLumi also remains the same so map value get overwritten once return to normal running.
583  //even if few LS are misssing and DQM module do not sees them then it catchs up again
584  map<int, int>::iterator itbs = mapBeginBSLS.begin();
585  map<int, int>::iterator itpv = mapBeginPVLS.begin();
586  map<int, std::time_t>::iterator itbstime = mapBeginBSTime.begin();
587  map<int, std::time_t>::iterator itpvtime = mapBeginPVTime.begin();
588 
589  if (processed_) { // otherwise if false then LS range of fit get messed up because we don't remove trk/pvs but we remove LS begin value . This prevent it as it happened if LS is there but no event are processed for some reason
590  mapBeginBSLS.erase(itbs);
591  mapBeginPVLS.erase(itpv);
592  mapBeginBSTime.erase(itbstime);
593  mapBeginPVTime.erase(itpvtime);
594  }
595  /*//not sure if want this or not ??
596  map<int, int>::iterator itgapb=mapBeginBSLS.begin();
597  map<int, int>::iterator itgape=mapBeginBSLS.end(); itgape--;
598  countGapLumi_ = ( (itgape->second) - (itgapb->second) );
599  //if we see Gap more than then 2*resetNFitLumi !!!!!!!
600  //for example if 10-15 is fitted and if 16-25 are missing then we next fit will be for range 11-26 but BS can change in between
601  // so better start as fresh and reset everything like starting in the begining!
602  if(countGapLumi_ >= 2*resetFitNLumi_){RestartFitting(); mapBeginBSLS[countLumi_] = nthlumi;}
603  */
604  }
605 
606  if (debug_)
607  edm::LogInfo("BeamMonitor") << " beginLuminosityBlock:: Size of mapBeginBSLS After = " << mapBeginBSLS.size()
608  << endl;
609 
610  map<int, int>::iterator bbs = mapBeginBSLS.begin();
611  map<int, int>::iterator bpv = mapBeginPVLS.begin();
612  map<int, std::time_t>::iterator bbst = mapBeginBSTime.begin();
613  map<int, std::time_t>::iterator bpvt = mapBeginPVTime.begin();
614 
615  if (beginLumiOfPVFit_ == 0)
616  beginLumiOfPVFit_ = bpv->second; //new begin time after removing the LS
617  if (beginLumiOfBSFit_ == 0)
618  beginLumiOfBSFit_ = bbs->second;
619  if (refBStime[0] == 0)
620  refBStime[0] = bbst->second;
621  if (refPVtime[0] == 0)
622  refPVtime[0] = bpvt->second;
623 
624  } //same logic for average fit as above commented line
625 
626  map<int, std::time_t>::iterator nbbst = mapBeginBSTime.begin();
627  map<int, std::time_t>::iterator nbpvt = mapBeginPVTime.begin();
628 
629  if (onlineMode_ && (nthlumi < nextlumi_))
630  return;
631 
632  if (onlineMode_) {
633  if (nthlumi > nextlumi_) {
634  if (countLumi_ != 0 && processed_)
635  FitAndFill(lumiSeg, lastlumi_, nextlumi_, nthlumi);
636  nextlumi_ = nthlumi;
637  edm::LogInfo("BeamMonitor") << "beginLuminosityBlock:: Next Lumi to Fit: " << nextlumi_ << endl;
638  if ((StartAverage_) && refBStime[0] == 0)
639  refBStime[0] = nbbst->second;
640  if ((StartAverage_) && refPVtime[0] == 0)
641  refPVtime[0] = nbpvt->second;
642  }
643  } else {
644  if (processed_)
645  FitAndFill(lumiSeg, lastlumi_, nextlumi_, nthlumi);
646  nextlumi_ = nthlumi;
647  edm::LogInfo("BeamMonitor") << " beginLuminosityBlock:: Next Lumi to Fit: " << nextlumi_ << endl;
648  if ((StartAverage_) && refBStime[0] == 0)
649  refBStime[0] = nbbst->second;
650  if ((StartAverage_) && refPVtime[0] == 0)
651  refPVtime[0] = nbpvt->second;
652  }
653 
654  //countLumi_++;
655  if (processed_)
656  processed_ = false;
657  edm::LogInfo("BeamMonitor") << " beginLuminosityBlock:: Begin of Lumi: " << nthlumi << endl;
658 }
659 
660 // ----------------------------------------------------------
661 void BeamMonitor::analyze(const Event& iEvent, const EventSetup& iSetup) {
662  const int nthlumi = iEvent.luminosityBlock();
663  if (onlineMode_ && (nthlumi < nextlumi_)) {
664  edm::LogInfo("BeamMonitor") << "analyze:: Spilt event from previous lumi section!" << std::endl;
665  return;
666  }
667  if (onlineMode_ && (nthlumi > nextlumi_)) {
668  edm::LogInfo("BeamMonitor") << "analyze:: Spilt event from next lumi section!!!" << std::endl;
669  return;
670  }
671 
672  countEvt_++;
673  theBeamFitter->readEvent(
674  iEvent); //Remember when track fitter read the event in the same place the PVFitter read the events !!!!!!!!!
675 
676  Handle<reco::BeamSpot> recoBeamSpotHandle;
677  iEvent.getByToken(bsSrc_, recoBeamSpotHandle);
678  refBS = *recoBeamSpotHandle;
679 
680  //------Cut Flow Table filled every event!--------------------------------------
681  {
682  // Make a copy of the cut flow table from the beam fitter.
683  auto tmphisto = static_cast<TH1F*>(theBeamFitter->getCutFlow());
684  cutFlowTable->getTH1()->SetBins(
685  tmphisto->GetNbinsX(), tmphisto->GetXaxis()->GetXmin(), tmphisto->GetXaxis()->GetXmax());
686  // Update the bin labels
687  if (countEvt_ == 1) // SetLabel just once
688  for (int n = 0; n < tmphisto->GetNbinsX(); n++)
689  cutFlowTable->setBinLabel(n + 1, tmphisto->GetXaxis()->GetBinLabel(n + 1), 1);
690  cutFlowTable->Reset();
691  cutFlowTable->getTH1()->Add(tmphisto);
692  }
693 
694  //----Reco tracks -------------------------------------
696  iEvent.getByToken(tracksLabel_, TrackCollection);
697  const reco::TrackCollection* tracks = TrackCollection.product();
698  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
699  h_trkPt->Fill(track->pt()); //no need to change here for average bs
700  h_trkVz->Fill(track->vz());
701  }
702 
703  //-------HLT Trigger --------------------------------
705  bool JetTrigPass = false;
706  if (iEvent.getByToken(hltSrc_, triggerResults)) {
707  const edm::TriggerNames& trigNames = iEvent.triggerNames(*triggerResults);
708  for (unsigned int i = 0; i < triggerResults->size(); i++) {
709  const std::string& trigName = trigNames.triggerName(i);
710 
711  if (JetTrigPass)
712  continue;
713 
714  for (size_t t = 0; t < jetTrigger_.size(); ++t) {
715  if (JetTrigPass)
716  continue;
717 
718  string string_search(jetTrigger_[t]);
719  size_t found = trigName.find(string_search);
720 
721  if (found != string::npos) {
722  int thisTrigger_ = trigNames.triggerIndex(trigName);
723  if (triggerResults->accept(thisTrigger_))
724  JetTrigPass = true;
725  } //if trigger found
726  } //for(t=0;..)
727  } //for(i=0; ..)
728  } //if trigger colleciton exist)
729 
730  //------ Primary Vertices-------
732 
733  if (iEvent.getByToken(pvSrc_, PVCollection)) {
734  int nPVcount = 0;
735  int nPVcount_ST = 0; //For Single Trigger(hence ST)
736 
737  for (reco::VertexCollection::const_iterator pv = PVCollection->begin(); pv != PVCollection->end(); ++pv) {
738  //--- vertex selection
739  if (pv->isFake() || pv->tracksSize() == 0)
740  continue;
741  nPVcount++; // count non fake pv:
742 
743  if (JetTrigPass)
744  nPVcount_ST++; //non-fake pv with a specific trigger
745 
746  if (pv->ndof() < minVtxNdf_ || (pv->ndof() + 3.) / pv->tracksSize() < 2 * minVtxWgt_)
747  continue;
748 
749  //Fill this map to store xyx for pv so that later we can remove the first one for run aver
750  mapPVx[countLumi_].push_back(pv->x());
751  mapPVy[countLumi_].push_back(pv->y());
752  mapPVz[countLumi_].push_back(pv->z());
753 
754  if (!StartAverage_) { //for first N LS
755  h_PVx[0]->Fill(pv->x());
756  h_PVy[0]->Fill(pv->y());
757  h_PVz[0]->Fill(pv->z());
758  h_PVxz->Fill(pv->z(), pv->x());
759  h_PVyz->Fill(pv->z(), pv->y());
760  } //for first N LiS
761  else {
762  h_PVxz->Fill(pv->z(), pv->x());
763  h_PVyz->Fill(pv->z(), pv->y());
764  }
765 
766  } //loop over pvs
767 
768  h_nVtx->Fill(nPVcount * 1.); //no need to change it for average BS
769 
770  mapNPV[countLumi_].push_back((nPVcount_ST));
771 
772  if (!StartAverage_) {
773  h_nVtx_st->Fill(nPVcount_ST * 1.);
774  }
775 
776  } //if pv collection is availaable
777 
778  if (StartAverage_) {
779  map<int, std::vector<float> >::iterator itpvx = mapPVx.begin();
780  map<int, std::vector<float> >::iterator itpvy = mapPVy.begin();
781  map<int, std::vector<float> >::iterator itpvz = mapPVz.begin();
782 
783  map<int, std::vector<int> >::iterator itbspvinfo = mapNPV.begin();
784 
785  if ((int)mapPVx.size() > resetFitNLumi_) { //sometimes the events is not there but LS is there!
786  mapPVx.erase(itpvx);
787  mapPVy.erase(itpvy);
788  mapPVz.erase(itpvz);
789  mapNPV.erase(itbspvinfo);
790  } //loop over Last N lumi collected
791 
792  } //StartAverage==true
793 
794  processed_ = true;
795 }
796 
797 //--------------------------------------------------------
798 void BeamMonitor::endLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& iSetup) {
799  int nthlumi = lumiSeg.id().luminosityBlock();
800  edm::LogInfo("BeamMonitor") << "endLuminosityBlock:: Lumi of the last event before endLuminosityBlock: " << nthlumi
801  << endl;
802 
803  if (onlineMode_ && nthlumi < nextlumi_)
804  return;
805  const edm::TimeValue_t fendtimestamp = lumiSeg.endTime().value();
806  const std::time_t fendtime = fendtimestamp >> 32;
807  tmpTime = refBStime[1] = refPVtime[1] = fendtime;
808 
809  // end DB logger
811  onlineDbService_->logger().logInfo() << "BeamMonitor::endLuminosityBlock";
813  }
814 }
815 
816 //--------------------------------------------------------
817 void BeamMonitor::FitAndFill(const LuminosityBlock& lumiSeg, int& lastlumi, int& nextlumi, int& nthlumi) {
818  if (onlineMode_ && (nthlumi <= nextlumi))
819  return;
820 
821  //set the correct run number when no event in the LS for fake output
822  if ((processed_) && theBeamFitter->getRunNumber() != frun)
823  theBeamFitter->setRun(frun);
824 
825  int currentlumi = nextlumi;
826  edm::LogInfo("BeamMonitor") << "FitAndFill:: Lumi of the current fit: " << currentlumi << endl;
827  lastlumi = currentlumi;
828  endLumiOfBSFit_ = currentlumi;
829  endLumiOfPVFit_ = currentlumi;
830 
831  //---------Fix for Runninv average-------------
832  mapLSPVStoreSize[countLumi_] = theBeamFitter->getPVvectorSize();
833 
834  if (StartAverage_) {
835  std::map<int, std::size_t>::iterator rmLSPVi = mapLSPVStoreSize.begin();
836  size_t SizeToRemovePV = rmLSPVi->second;
837  for (std::map<int, std::size_t>::iterator rmLSPVe = mapLSPVStoreSize.end(); ++rmLSPVi != rmLSPVe;)
838  rmLSPVi->second -= SizeToRemovePV;
839 
840  theBeamFitter->resizePVvector(SizeToRemovePV);
841 
842  map<int, std::size_t>::iterator tmpItpv = mapLSPVStoreSize.begin();
843  mapLSPVStoreSize.erase(tmpItpv);
844  }
845  if (debug_)
846  edm::LogInfo("BeamMonitor") << "FitAndFill:: Size of thePVvector After removing the PVs = "
847  << theBeamFitter->getPVvectorSize() << endl;
848 
849  //lets filt the PV for GUI here: It was in analyzer in preivous versiton but moved here due to absence of event in some lumis, works OK
850  bool resetHistoFlag_ = false;
851  if ((int)mapPVx.size() >= resetFitNLumi_ && (StartAverage_)) {
852  h_PVx[0]->Reset();
853  h_PVy[0]->Reset();
854  h_PVz[0]->Reset();
855  h_nVtx_st->Reset();
856  resetHistoFlag_ = true;
857  }
858 
859  int MaxPVs = 0;
860  int countEvtLastNLS_ = 0;
861  int countTotPV_ = 0;
862 
863  std::map<int, std::vector<int> >::iterator mnpv = mapNPV.begin();
864  std::map<int, std::vector<float> >::iterator mpv2 = mapPVy.begin();
865  std::map<int, std::vector<float> >::iterator mpv3 = mapPVz.begin();
866 
867  for (std::map<int, std::vector<float> >::iterator mpv1 = mapPVx.begin(); mpv1 != mapPVx.end();
868  ++mpv1, ++mpv2, ++mpv3, ++mnpv) {
869  std::vector<float>::iterator mpvs2 = (mpv2->second).begin();
870  std::vector<float>::iterator mpvs3 = (mpv3->second).begin();
871  for (std::vector<float>::iterator mpvs1 = (mpv1->second).begin(); mpvs1 != (mpv1->second).end();
872  ++mpvs1, ++mpvs2, ++mpvs3) {
873  if (resetHistoFlag_) {
874  h_PVx[0]->Fill(*mpvs1); //these histogram are reset after StartAverage_ flag is ON
875  h_PVy[0]->Fill(*mpvs2);
876  h_PVz[0]->Fill(*mpvs3);
877  }
878  } //loop over second
879 
880  //Do the same here for nPV distr.
881  for (std::vector<int>::iterator mnpvs = (mnpv->second).begin(); mnpvs != (mnpv->second).end(); ++mnpvs) {
882  if ((*mnpvs > 0) && (resetHistoFlag_))
883  h_nVtx_st->Fill((*mnpvs) * (1.0));
884  countEvtLastNLS_++;
885  countTotPV_ += (*mnpvs);
886  if ((*mnpvs) > MaxPVs)
887  MaxPVs = (*mnpvs);
888  } //loop over second of mapNPV
889 
890  } //loop over last N lumis
891 
892  char tmpTitlePV[100];
893  sprintf(tmpTitlePV, "%s %i %s %i", "Num. of reco. vertices for LS: ", beginLumiOfPVFit_, " to ", endLumiOfPVFit_);
894  h_nVtx_st->setAxisTitle(tmpTitlePV, 1);
895 
896  std::vector<float> DipPVInfo_;
897  DipPVInfo_.clear();
898 
899  if (countTotPV_ != 0) {
900  DipPVInfo_.push_back((float)countEvtLastNLS_);
901  DipPVInfo_.push_back(h_nVtx_st->getMean());
902  DipPVInfo_.push_back(h_nVtx_st->getMeanError());
903  DipPVInfo_.push_back(h_nVtx_st->getRMS());
904  DipPVInfo_.push_back(h_nVtx_st->getRMSError());
905  DipPVInfo_.push_back((float)MaxPVs);
906  DipPVInfo_.push_back((float)countTotPV_);
907  MaxPVs = 0;
908  } else {
909  for (size_t i = 0; i < 7; i++) {
910  if (i > 0) {
911  DipPVInfo_.push_back(0.);
912  } else {
913  DipPVInfo_.push_back((float)countEvtLastNLS_);
914  }
915  }
916  }
917  theBeamFitter->SetPVInfo(DipPVInfo_);
918  countEvtLastNLS_ = 0;
919 
920  if (onlineMode_) { // filling LS gap
921  // FIXME: need to add protection for the case if the gap is at the resetting LS!
922  const int countLS_bs = hs[k_x0_lumi]->getTH1()->GetEntries();
923  const int countLS_pv = hs[k_PVx_lumi]->getTH1()->GetEntries();
924  edm::LogInfo("BeamMonitor") << "FitAndFill:: countLS_bs = " << countLS_bs << " ; countLS_pv = " << countLS_pv
925  << std::endl;
926  int LSgap_bs = currentlumi / fitNLumi_ - countLS_bs;
927  int LSgap_pv = currentlumi / fitPVNLumi_ - countLS_pv;
928  if (currentlumi % fitNLumi_ == 0)
929  LSgap_bs--;
930  if (currentlumi % fitPVNLumi_ == 0)
931  LSgap_pv--;
932  edm::LogInfo("BeamMonitor") << "FitAndFill:: LSgap_bs = " << LSgap_bs << " ; LSgap_pv = " << LSgap_pv << std::endl;
933  // filling previous fits if LS gap ever exists
934  for (int ig = 0; ig < LSgap_bs; ig++) {
935  hs[k_x0_lumi]->ShiftFillLast(0., 0., fitNLumi_); //x0 , x0err, fitNLumi_; see DQMCore....
936  hs[k_y0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
937  hs[k_z0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
938  hs[k_sigmaX0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
939  hs[k_sigmaY0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
940  hs[k_sigmaZ0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
942  }
943  for (int ig = 0; ig < LSgap_pv; ig++) {
944  hs[k_PVx_lumi]->ShiftFillLast(0., 0., fitPVNLumi_);
945  hs[k_PVy_lumi]->ShiftFillLast(0., 0., fitPVNLumi_);
946  hs[k_PVz_lumi]->ShiftFillLast(0., 0., fitPVNLumi_);
947  }
948  const int previousLS = h_nTrk_lumi->getTH1()->GetEntries();
949  for (int i = 1; i < (currentlumi - previousLS);
950  i++) //if (current-previoius)= 1 then never go inside the for loop!!!!!!!!!!!
952  }
953 
954  edm::LogInfo("BeamMonitor") << "FitAndFill:: Time lapsed since last scroll = " << tmpTime - refTime << std::endl;
955 
956  if (testScroll(tmpTime, refTime)) {
957  scrollTH1(hs[k_x0_time]->getTH1(), refTime);
958  scrollTH1(hs[k_y0_time]->getTH1(), refTime);
959  scrollTH1(hs[k_z0_time]->getTH1(), refTime);
960  scrollTH1(hs[k_sigmaX0_time]->getTH1(), refTime);
961  scrollTH1(hs[k_sigmaY0_time]->getTH1(), refTime);
962  scrollTH1(hs[k_sigmaZ0_time]->getTH1(), refTime);
963  scrollTH1(hs[k_PVx_time]->getTH1(), refTime);
964  scrollTH1(hs[k_PVy_time]->getTH1(), refTime);
965  scrollTH1(hs[k_PVz_time]->getTH1(), refTime);
966  }
967 
968  bool doPVFit = false;
969 
970  if (fitPVNLumi_ > 0) {
971  if (onlineMode_) {
972  if (currentlumi % fitPVNLumi_ == 0)
973  doPVFit = true;
974  } else if (countLumi_ % fitPVNLumi_ == 0)
975  doPVFit = true;
976  } else
977  doPVFit = true;
978 
979  if (doPVFit) {
980  edm::LogInfo("BeamMonitor") << "FitAndFill:: Do PV Fitting for LS = " << beginLumiOfPVFit_ << " to "
981  << endLumiOfPVFit_ << std::endl;
982  // Primary Vertex Fit:
983  if (h_PVx[0]->getTH1()->GetEntries() > minNrVertices_) {
984  pvResults->Reset();
985  char tmpTitle[50];
986  sprintf(
987  tmpTitle, "%s %i %s %i", "Fitted Primary Vertex (cm) of LS: ", beginLumiOfPVFit_, " to ", endLumiOfPVFit_);
988  pvResults->setAxisTitle(tmpTitle, 1);
989 
990  std::unique_ptr<TF1> fgaus{new TF1("fgaus", "gaus")};
991  double mean, width, meanErr, widthErr;
992  fgaus->SetLineColor(4);
993  h_PVx[0]->getTH1()->Fit(fgaus.get(), "QLM0");
994  mean = fgaus->GetParameter(1);
995  width = fgaus->GetParameter(2);
996  meanErr = fgaus->GetParError(1);
997  widthErr = fgaus->GetParError(2);
998 
999  hs[k_PVx_lumi]->ShiftFillLast(mean, width, fitPVNLumi_);
1000  hs[k_PVx_lumi_all]->setBinContent(currentlumi, mean);
1001  hs[k_PVx_lumi_all]->setBinError(currentlumi, width);
1002  int nthBin = tmpTime - refTime;
1003  if (nthBin < 0)
1004  edm::LogInfo("BeamMonitor") << "FitAndFill:: Event time outside current range of time histograms!"
1005  << std::endl;
1006  if (nthBin > 0) {
1007  hs[k_PVx_time]->setBinContent(nthBin, mean);
1008  hs[k_PVx_time]->setBinError(nthBin, width);
1009  }
1010  int jthBin = tmpTime - startTime;
1011  if (jthBin > 0) {
1012  hs[k_PVx_time_all]->setBinContent(jthBin, mean);
1013  hs[k_PVx_time_all]->setBinError(jthBin, width);
1014  }
1015  pvResults->setBinContent(1, 6, mean);
1016  pvResults->setBinContent(1, 3, width);
1017  pvResults->setBinContent(2, 6, meanErr);
1018  pvResults->setBinContent(2, 3, widthErr);
1019 
1020  {
1021  // snap shot of the fit
1022  auto tmphisto = h_PVx[0]->getTH1F();
1023  h_PVx[1]->getTH1()->SetBins(
1024  tmphisto->GetNbinsX(), tmphisto->GetXaxis()->GetXmin(), tmphisto->GetXaxis()->GetXmax());
1025  h_PVx[1]->Reset();
1026  h_PVx[1]->getTH1()->Add(tmphisto);
1027  h_PVx[1]->getTH1()->Fit(fgaus.get(), "QLM");
1028  }
1029 
1030  h_PVy[0]->getTH1()->Fit(fgaus.get(), "QLM0");
1031  mean = fgaus->GetParameter(1);
1032  width = fgaus->GetParameter(2);
1033  meanErr = fgaus->GetParError(1);
1034  widthErr = fgaus->GetParError(2);
1035  hs[k_PVy_lumi]->ShiftFillLast(mean, width, fitPVNLumi_);
1036  hs[k_PVy_lumi_all]->setBinContent(currentlumi, mean);
1037  hs[k_PVy_lumi_all]->setBinError(currentlumi, width);
1038  if (nthBin > 0) {
1039  hs[k_PVy_time]->setBinContent(nthBin, mean);
1040  hs[k_PVy_time]->setBinError(nthBin, width);
1041  }
1042  if (jthBin > 0) {
1043  hs[k_PVy_time_all]->setBinContent(jthBin, mean);
1044  hs[k_PVy_time_all]->setBinError(jthBin, width);
1045  }
1046  pvResults->setBinContent(1, 5, mean);
1047  pvResults->setBinContent(1, 2, width);
1048  pvResults->setBinContent(2, 5, meanErr);
1049  pvResults->setBinContent(2, 2, widthErr);
1050  // snap shot of the fit
1051  {
1052  auto tmphisto = h_PVy[0]->getTH1F();
1053  h_PVy[1]->getTH1()->SetBins(
1054  tmphisto->GetNbinsX(), tmphisto->GetXaxis()->GetXmin(), tmphisto->GetXaxis()->GetXmax());
1055  h_PVy[1]->Reset();
1056  h_PVy[1]->getTH1()->Add(tmphisto);
1057  h_PVy[1]->getTH1()->Fit(fgaus.get(), "QLM");
1058  }
1059 
1060  h_PVz[0]->getTH1()->Fit(fgaus.get(), "QLM0");
1061  mean = fgaus->GetParameter(1);
1062  width = fgaus->GetParameter(2);
1063  meanErr = fgaus->GetParError(1);
1064  widthErr = fgaus->GetParError(2);
1065  hs[k_PVz_lumi]->ShiftFillLast(mean, width, fitPVNLumi_);
1066  hs[k_PVz_lumi_all]->setBinContent(currentlumi, mean);
1067  hs[k_PVz_lumi_all]->setBinError(currentlumi, width);
1068  if (nthBin > 0) {
1069  hs[k_PVz_time]->setBinContent(nthBin, mean);
1070  hs[k_PVz_time]->setBinError(nthBin, width);
1071  }
1072  if (jthBin > 0) {
1073  hs[k_PVz_time_all]->setBinContent(jthBin, mean);
1074  hs[k_PVz_time_all]->setBinError(jthBin, width);
1075  }
1076  pvResults->setBinContent(1, 4, mean);
1077  pvResults->setBinContent(1, 1, width);
1078  pvResults->setBinContent(2, 4, meanErr);
1079  pvResults->setBinContent(2, 1, widthErr);
1080  {
1081  // snap shot of the fit
1082  auto tmphisto = h_PVz[0]->getTH1F();
1083  h_PVz[1]->getTH1()->SetBins(
1084  tmphisto->GetNbinsX(), tmphisto->GetXaxis()->GetXmin(), tmphisto->GetXaxis()->GetXmax());
1085  h_PVz[1]->Reset();
1086  h_PVz[1]->getTH1()->Add(tmphisto);
1087  h_PVz[1]->getTH1()->Fit(fgaus.get(), "QLM");
1088  }
1089  } //check if found min Vertices
1090  } //do PVfit
1091 
1092  if ((resetPVNLumi_ > 0 && countLumi_ == resetPVNLumi_) || StartAverage_) {
1093  beginLumiOfPVFit_ = 0;
1094  refPVtime[0] = 0;
1095  }
1096 
1097  //---------Readjustment of theBSvector, RefTime, beginLSofFit---------
1098  vector<BSTrkParameters> theBSvector1 = theBeamFitter->getBSvector();
1099  mapLSBSTrkSize[countLumi_] = (theBSvector1.size());
1100  size_t PreviousRecords = 0; //needed to fill nth record of tracks in GUI
1101 
1102  if (StartAverage_) {
1103  size_t SizeToRemove = 0;
1104  std::map<int, std::size_t>::iterator rmls = mapLSBSTrkSize.begin();
1105  SizeToRemove = rmls->second;
1106  if (debug_)
1107  edm::LogInfo("BeamMonitor") << " The size to remove is = " << SizeToRemove << endl;
1108  int changedAfterThis = 0;
1109  for (std::map<int, std::size_t>::iterator rmLS = mapLSBSTrkSize.begin(); rmLS != mapLSBSTrkSize.end();
1110  ++rmLS, ++changedAfterThis) {
1111  if (changedAfterThis > 0) {
1112  (rmLS->second) = (rmLS->second) - SizeToRemove;
1113  if ((mapLSBSTrkSize.size() - (size_t)changedAfterThis) == 2)
1114  PreviousRecords = (rmLS->second);
1115  }
1116  }
1117 
1118  theBeamFitter->resizeBSvector(SizeToRemove);
1119 
1120  map<int, std::size_t>::iterator tmpIt = mapLSBSTrkSize.begin();
1121  mapLSBSTrkSize.erase(tmpIt);
1122 
1123  std::pair<int, int> checkfitLS = theBeamFitter->getFitLSRange();
1124  std::pair<time_t, time_t> checkfitTime = theBeamFitter->getRefTime();
1125  theBeamFitter->setFitLSRange(beginLumiOfBSFit_, checkfitLS.second);
1126  theBeamFitter->setRefTime(refBStime[0], checkfitTime.second);
1127  }
1128 
1129  //Fill the track for this fit
1130  vector<BSTrkParameters> theBSvector = theBeamFitter->getBSvector();
1131  h_nTrk_lumi->ShiftFillLast(theBSvector.size());
1132 
1133  if (debug_)
1134  edm::LogInfo("BeamMonitor") << "FitAndFill:: Size of theBSViector.size() After =" << theBSvector.size() << endl;
1135 
1136  bool countFitting = false;
1137  if (theBSvector.size() >= PreviousRecords && theBSvector.size() >= min_Ntrks_) {
1138  countFitting = true;
1139  }
1140 
1141  //---Fix for Cut Flow Table for Running average in a same way//the previous code has problem for resetting!!!
1142  mapLSCF[countLumi_] = *theBeamFitter->getCutFlow();
1143  if (StartAverage_ && !mapLSCF.empty()) {
1144  const TH1F& cutFlowToSubtract = mapLSCF.begin()->second;
1145  // Subtract the last cut flow from all of the others.
1146  std::map<int, TH1F>::iterator cf = mapLSCF.begin();
1147  // Start on second entry
1148  for (; cf != mapLSCF.end(); ++cf) {
1149  cf->second.Add(&cutFlowToSubtract, -1);
1150  }
1151  theBeamFitter->subtractFromCutFlow(&cutFlowToSubtract);
1152  // Remove the obsolete lumi section
1153  mapLSCF.erase(mapLSCF.begin());
1154  }
1155 
1156  if (resetHistos_) {
1157  h_d0_phi0->Reset();
1158  h_vx_vy->Reset();
1159  h_vx_dz->Reset();
1160  h_vy_dz->Reset();
1161  h_trk_z0->Reset();
1162  resetHistos_ = false;
1163  }
1164 
1165  if (StartAverage_)
1166  nthBSTrk_ = PreviousRecords; //after average proccess is ON//for 2-6 LS fit PreviousRecords is size from 2-5 LS
1167 
1168  edm::LogInfo("BeamMonitor") << " The Previous Recored for this fit is =" << nthBSTrk_ << endl;
1169 
1170  unsigned int itrk = 0;
1171  for (vector<BSTrkParameters>::const_iterator BSTrk = theBSvector.begin(); BSTrk != theBSvector.end();
1172  ++BSTrk, ++itrk) {
1173  if (itrk >= nthBSTrk_) { //fill for this record only !!
1174  h_d0_phi0->Fill(BSTrk->phi0(), BSTrk->d0());
1175  double vx = BSTrk->vx();
1176  double vy = BSTrk->vy();
1177  double z0 = BSTrk->z0();
1178  h_vx_vy->Fill(vx, vy);
1179  h_vx_dz->Fill(z0, vx);
1180  h_vy_dz->Fill(z0, vy);
1181  h_trk_z0->Fill(z0);
1182  }
1183  }
1184 
1185  nthBSTrk_ = theBSvector.size(); // keep track of num of tracks filled so far
1186 
1187  edm::LogInfo("BeamMonitor") << " The Current Recored for this fit is =" << nthBSTrk_ << endl;
1188 
1189  if (countFitting)
1190  edm::LogInfo("BeamMonitor") << "FitAndFill:: Num of tracks collected = " << nthBSTrk_ << endl;
1191 
1192  if (fitNLumi_ > 0) {
1193  if (onlineMode_) {
1194  if (currentlumi % fitNLumi_ != 0) {
1195  // for (std::map<TString,MonitorElement*>::iterator itAll = hs.begin();
1196  // itAll != hs.end(); ++itAll) {
1197  // if ((*itAll).first.Contains("all")) {
1198  // (*itAll).second->setBinContent(currentlumi,0.);
1199  // (*itAll).second->setBinError(currentlumi,0.);
1200  // }
1201  // }
1202  return;
1203  }
1204  } else if (countLumi_ % fitNLumi_ != 0)
1205  return;
1206  }
1207 
1208  edm::LogInfo("BeamMonitor") << "FitAndFill:: [DebugTime] refBStime[0] = " << refBStime[0]
1209  << "; address = " << &refBStime[0] << std::endl;
1210  edm::LogInfo("BeamMonitor") << "FitAndFill:: [DebugTime] refBStime[1] = " << refBStime[1]
1211  << "; address = " << &refBStime[1] << std::endl;
1212 
1213  //Fill for all LS even if fit fails
1214  h_nVtx_lumi->ShiftFillLast((theBeamFitter->getPVvectorSize()), 0., fitNLumi_);
1215  h_nVtx_lumi_all->setBinContent(currentlumi, (theBeamFitter->getPVvectorSize()));
1216 
1217  if (countFitting) {
1218  nFits_++;
1219  std::pair<int, int> fitLS = theBeamFitter->getFitLSRange();
1220  edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamFitter] Do BeamSpot Fit for LS = " << fitLS.first << " to "
1221  << fitLS.second << std::endl;
1222  edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] Do BeamSpot Fit for LS = " << beginLumiOfBSFit_
1223  << " to " << endLumiOfBSFit_ << std::endl;
1224 
1225  //Now Run the PV and Track Fitter over the collected tracks and pvs
1226  if (theBeamFitter->runPVandTrkFitter()) {
1227  reco::BeamSpot bs = theBeamFitter->getBeamSpot();
1228  if (bs.type() > 0) // with good beamwidth fit
1229  preBS = bs; // cache good fit results
1230 
1231  edm::LogInfo("BeamMonitor") << "\n RESULTS OF DEFAULT FIT:" << endl;
1232  edm::LogInfo("BeamMonitor") << bs << endl;
1233  edm::LogInfo("BeamMonitor") << "[BeamFitter] fitting done \n" << endl;
1234 
1235  hs[k_x0_lumi]->ShiftFillLast(bs.x0(), bs.x0Error(), fitNLumi_);
1236  hs[k_y0_lumi]->ShiftFillLast(bs.y0(), bs.y0Error(), fitNLumi_);
1237  hs[k_z0_lumi]->ShiftFillLast(bs.z0(), bs.z0Error(), fitNLumi_);
1238  hs[k_sigmaX0_lumi]->ShiftFillLast(bs.BeamWidthX(), bs.BeamWidthXError(), fitNLumi_);
1239  hs[k_sigmaY0_lumi]->ShiftFillLast(bs.BeamWidthY(), bs.BeamWidthYError(), fitNLumi_);
1240  hs[k_sigmaZ0_lumi]->ShiftFillLast(bs.sigmaZ(), bs.sigmaZ0Error(), fitNLumi_);
1241  hs[k_x0_lumi_all]->setBinContent(currentlumi, bs.x0());
1242  hs[k_x0_lumi_all]->setBinError(currentlumi, bs.x0Error());
1243  hs[k_y0_lumi_all]->setBinContent(currentlumi, bs.y0());
1244  hs[k_y0_lumi_all]->setBinError(currentlumi, bs.y0Error());
1245  hs[k_z0_lumi_all]->setBinContent(currentlumi, bs.z0());
1246  hs[k_z0_lumi_all]->setBinError(currentlumi, bs.z0Error());
1247  hs[k_sigmaX0_lumi_all]->setBinContent(currentlumi, bs.BeamWidthX());
1248  hs[k_sigmaX0_lumi_all]->setBinError(currentlumi, bs.BeamWidthXError());
1249  hs[k_sigmaY0_lumi_all]->setBinContent(currentlumi, bs.BeamWidthY());
1250  hs[k_sigmaY0_lumi_all]->setBinError(currentlumi, bs.BeamWidthYError());
1251  hs[k_sigmaZ0_lumi_all]->setBinContent(currentlumi, bs.sigmaZ());
1252  hs[k_sigmaZ0_lumi_all]->setBinError(currentlumi, bs.sigmaZ0Error());
1253 
1254  int nthBin = tmpTime - refTime;
1255  if (nthBin > 0) {
1256  hs[k_x0_time]->setBinContent(nthBin, bs.x0());
1257  hs[k_y0_time]->setBinContent(nthBin, bs.y0());
1258  hs[k_z0_time]->setBinContent(nthBin, bs.z0());
1259  hs[k_sigmaX0_time]->setBinContent(nthBin, bs.BeamWidthX());
1260  hs[k_sigmaY0_time]->setBinContent(nthBin, bs.BeamWidthY());
1261  hs[k_sigmaZ0_time]->setBinContent(nthBin, bs.sigmaZ());
1262  hs[k_x0_time]->setBinError(nthBin, bs.x0Error());
1263  hs[k_y0_time]->setBinError(nthBin, bs.y0Error());
1264  hs[k_z0_time]->setBinError(nthBin, bs.z0Error());
1265  hs[k_sigmaX0_time]->setBinError(nthBin, bs.BeamWidthXError());
1266  hs[k_sigmaY0_time]->setBinError(nthBin, bs.BeamWidthYError());
1267  hs[k_sigmaZ0_time]->setBinError(nthBin, bs.sigmaZ0Error());
1268  }
1269 
1270  int jthBin = tmpTime - startTime;
1271  if (jthBin > 0) {
1272  hs[k_x0_time_all]->setBinContent(jthBin, bs.x0());
1273  hs[k_y0_time_all]->setBinContent(jthBin, bs.y0());
1274  hs[k_z0_time_all]->setBinContent(jthBin, bs.z0());
1275  hs[k_sigmaX0_time_all]->setBinContent(jthBin, bs.BeamWidthX());
1276  hs[k_sigmaY0_time_all]->setBinContent(jthBin, bs.BeamWidthY());
1277  hs[k_sigmaZ0_time_all]->setBinContent(jthBin, bs.sigmaZ());
1278  hs[k_x0_time_all]->setBinError(jthBin, bs.x0Error());
1279  hs[k_y0_time_all]->setBinError(jthBin, bs.y0Error());
1280  hs[k_z0_time_all]->setBinError(jthBin, bs.z0Error());
1281  hs[k_sigmaX0_time_all]->setBinError(jthBin, bs.BeamWidthXError());
1282  hs[k_sigmaY0_time_all]->setBinError(jthBin, bs.BeamWidthYError());
1283  hs[k_sigmaZ0_time_all]->setBinError(jthBin, bs.sigmaZ0Error());
1284  }
1285 
1286  h_x0->Fill(bs.x0());
1287  h_y0->Fill(bs.y0());
1288  h_z0->Fill(bs.z0());
1289  if (bs.type() > 0) { // with good beamwidth fit
1290  h_sigmaX0->Fill(bs.BeamWidthX());
1291  h_sigmaY0->Fill(bs.BeamWidthY());
1292  }
1293  h_sigmaZ0->Fill(bs.sigmaZ());
1294 
1295  if (nthBSTrk_ >= 2 * min_Ntrks_) {
1296  double amp = std::sqrt(bs.x0() * bs.x0() + bs.y0() * bs.y0());
1297  double alpha = std::atan2(bs.y0(), bs.x0());
1298  std::unique_ptr<TF1> f1{new TF1("f1", "[0]*sin(x-[1])", -3.14, 3.14)};
1299  f1->SetParameters(amp, alpha);
1300  f1->SetParLimits(0, amp - 0.1, amp + 0.1);
1301  f1->SetParLimits(1, alpha - 0.577, alpha + 0.577);
1302  f1->SetLineColor(4);
1303  h_d0_phi0->getTProfile()->Fit(f1.get(), "QR");
1304 
1305  double mean = bs.z0();
1306  double width = bs.sigmaZ();
1307  std::unique_ptr<TF1> fgaus{new TF1("fgaus", "gaus")};
1308  fgaus->SetParameters(mean, width);
1309  fgaus->SetLineColor(4);
1310  h_trk_z0->getTH1()->Fit(fgaus.get(), "QLRM", "", mean - 3 * width, mean + 3 * width);
1311  }
1312 
1313  fitResults->Reset();
1314  std::pair<int, int> LSRange = theBeamFitter->getFitLSRange();
1315  char tmpTitle[50];
1316  sprintf(tmpTitle, "%s %i %s %i", "Fitted Beam Spot (cm) of LS: ", LSRange.first, " to ", LSRange.second);
1317  fitResults->setAxisTitle(tmpTitle, 1);
1318  fitResults->setBinContent(1, 8, bs.x0());
1319  fitResults->setBinContent(1, 7, bs.y0());
1320  fitResults->setBinContent(1, 6, bs.z0());
1321  fitResults->setBinContent(1, 5, bs.sigmaZ());
1322  fitResults->setBinContent(1, 4, bs.dxdz());
1323  fitResults->setBinContent(1, 3, bs.dydz());
1324  if (bs.type() > 0) { // with good beamwidth fit
1325  fitResults->setBinContent(1, 2, bs.BeamWidthX());
1326  fitResults->setBinContent(1, 1, bs.BeamWidthY());
1327  } else { // fill cached widths
1330  }
1331 
1332  fitResults->setBinContent(2, 8, bs.x0Error());
1333  fitResults->setBinContent(2, 7, bs.y0Error());
1334  fitResults->setBinContent(2, 6, bs.z0Error());
1335  fitResults->setBinContent(2, 5, bs.sigmaZ0Error());
1336  fitResults->setBinContent(2, 4, bs.dxdzError());
1337  fitResults->setBinContent(2, 3, bs.dydzError());
1338  if (bs.type() > 0) { // with good beamwidth fit
1339  fitResults->setBinContent(2, 2, bs.BeamWidthXError());
1340  fitResults->setBinContent(2, 1, bs.BeamWidthYError());
1341  } else { // fill cached width errors
1344  }
1345 
1346  // count good fit
1347  // if (std::fabs(refBS.x0()-bs.x0())/bs.x0Error() < deltaSigCut_) { // disabled temporarily
1348  summaryContent_[0] += 1.;
1349  // }
1350  // if (std::fabs(refBS.y0()-bs.y0())/bs.y0Error() < deltaSigCut_) { // disabled temporarily
1351  summaryContent_[1] += 1.;
1352  // }
1353  // if (std::fabs(refBS.z0()-bs.z0())/bs.z0Error() < deltaSigCut_) { // disabled temporarily
1354  summaryContent_[2] += 1.;
1355  // }
1356 
1357  // Create the BeamSpotOnlineObjects object
1358  BeamSpotOnlineObjects* BSOnline = new BeamSpotOnlineObjects();
1359  BSOnline->SetLastAnalyzedLumi(LSRange.second);
1360  BSOnline->SetLastAnalyzedRun(theBeamFitter->getRunNumber());
1361  BSOnline->SetLastAnalyzedFill(0); // To be updated with correct LHC Fill number
1362  BSOnline->SetPosition(bs.x0(), bs.y0(), bs.z0());
1363  BSOnline->SetSigmaZ(bs.sigmaZ());
1364  BSOnline->SetBeamWidthX(bs.BeamWidthX());
1365  BSOnline->SetBeamWidthY(bs.BeamWidthY());
1366  BSOnline->SetBeamWidthXError(bs.BeamWidthXError());
1367  BSOnline->SetBeamWidthYError(bs.BeamWidthYError());
1368  BSOnline->Setdxdz(bs.dxdz());
1369  BSOnline->Setdydz(bs.dydz());
1370  BSOnline->SetType(bs.type());
1371  BSOnline->SetEmittanceX(bs.emittanceX());
1372  BSOnline->SetEmittanceY(bs.emittanceY());
1373  BSOnline->SetBetaStar(bs.betaStar());
1374  for (int i = 0; i < 7; ++i) {
1375  for (int j = 0; j < 7; ++j) {
1376  BSOnline->SetCovariance(i, j, bs.covariance(i, j));
1377  }
1378  }
1379  BSOnline->SetNumTracks(theBeamFitter->getNTracks());
1380  BSOnline->SetNumPVs(theBeamFitter->getNPVs());
1381  BSOnline->SetUsedEvents((int)DipPVInfo_[0]);
1382  BSOnline->SetMeanPV(DipPVInfo_[1]);
1383  BSOnline->SetMeanErrorPV(DipPVInfo_[2]);
1384  BSOnline->SetRmsPV(DipPVInfo_[3]);
1385  BSOnline->SetRmsErrorPV(DipPVInfo_[4]);
1386  BSOnline->SetMaxPVs((int)DipPVInfo_[5]);
1387  auto creationTime =
1388  std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch())
1389  .count();
1390  BSOnline->SetCreationTime(creationTime);
1391 
1392  std::pair<time_t, time_t> timeForDIP = theBeamFitter->getRefTime();
1393  BSOnline->SetStartTimeStamp(timeForDIP.first);
1394  BSOnline->SetStartTime(getGMTstring(timeForDIP.first));
1395  BSOnline->SetEndTimeStamp(timeForDIP.second);
1396  BSOnline->SetEndTime(getGMTstring(timeForDIP.second));
1397 
1398  edm::LogInfo("BeamMonitor") << "FitAndFill::[PayloadCreation] BeamSpotOnline object created: \n" << std::endl;
1399  edm::LogInfo("BeamMonitor") << *BSOnline << std::endl;
1400 
1401  // Create the payload for BeamSpotOnlineObjects object
1402  if (onlineDbService_.isAvailable()) {
1403  edm::LogInfo("BeamMonitor") << "FitAndFill::[PayloadCreation] onlineDbService available \n" << std::endl;
1404  onlineDbService_->logger().logInfo() << "BeamMonitor::FitAndFill - Lumi of the current fit: " << currentlumi;
1406  << "BeamMonitor::FitAndFill - Do PV Fitting for LS = " << beginLumiOfPVFit_ << " to " << endLumiOfPVFit_;
1408  << "BeamMonitor::FitAndFill - [BeamFitter] Do BeamSpot Fit for LS = " << LSRange.first << " to "
1409  << LSRange.second;
1411  << "BeamMonitor::FitAndFill - [BeamMonitor] Do BeamSpot Fit for LS = " << beginLumiOfBSFit_ << " to "
1412  << endLumiOfBSFit_;
1413  onlineDbService_->logger().logInfo() << "BeamMonitor - RESULTS OF DEFAULT FIT:";
1414  onlineDbService_->logger().logInfo() << "\n" << bs;
1416  << "BeamMonitor::FitAndFill - [PayloadCreation] BeamSpotOnline object created:";
1417  onlineDbService_->logger().logInfo() << "\n" << *BSOnline;
1418  onlineDbService_->logger().logInfo() << "BeamMonitor - Additional parameters for DIP:";
1419  onlineDbService_->logger().logInfo() << "Events used in the fit: " << BSOnline->GetUsedEvents();
1420  onlineDbService_->logger().logInfo() << "Mean PV : " << BSOnline->GetMeanPV();
1421  onlineDbService_->logger().logInfo() << "Mean PV Error : " << BSOnline->GetMeanErrorPV();
1422  onlineDbService_->logger().logInfo() << "Rms PV : " << BSOnline->GetRmsPV();
1423  onlineDbService_->logger().logInfo() << "Rms PV Error : " << BSOnline->GetRmsErrorPV();
1424  onlineDbService_->logger().logInfo() << "Max PVs : " << BSOnline->GetMaxPVs();
1425  onlineDbService_->logger().logInfo() << "StartTime : " << BSOnline->GetStartTime();
1426  onlineDbService_->logger().logInfo() << "StartTimeStamp : " << BSOnline->GetStartTimeStamp();
1427  onlineDbService_->logger().logInfo() << "EndTime : " << BSOnline->GetEndTime();
1428  onlineDbService_->logger().logInfo() << "EndTimeStamp : " << BSOnline->GetEndTimeStamp();
1429  onlineDbService_->logger().logInfo() << "BeamMonitor::FitAndFill - [PayloadCreation] onlineDbService available";
1431  << "BeamMonitor::FitAndFill - [PayloadCreation] SetCreationTime: " << creationTime
1432  << " [epoch in microseconds]";
1433  try {
1436  << "BeamMonitor::FitAndFill - [PayloadCreation] writeForNextLumisection executed correctly";
1437  } catch (const std::exception& e) {
1438  onlineDbService_->logger().logError() << "BeamMonitor - Error writing record: " << recordName_
1439  << " for Run: " << frun << " - Lumi: " << LSRange.second;
1440  onlineDbService_->logger().logError() << "Error is: " << e.what();
1441  onlineDbService_->logger().logError() << "RESULTS OF DEFAULT FIT WAS:";
1442  onlineDbService_->logger().logError() << "\n" << bs;
1443  DBloggerReturn_ = 2;
1444  }
1445  }
1446  edm::LogInfo("BeamMonitor") << "FitAndFill::[PayloadCreation] BeamSpotOnline payload created \n" << std::endl;
1447 
1448  } //if (theBeamFitter->runPVandTrkFitter())
1449  else { // beam fit fails
1450  reco::BeamSpot bs = theBeamFitter->getBeamSpot();
1451  edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] Beam fit fails!!! \n" << endl;
1452  edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] Output beam spot for DIP \n" << endl;
1453  edm::LogInfo("BeamMonitor") << bs << endl;
1454 
1455  if (onlineDbService_.isAvailable()) {
1456  onlineDbService_->logger().logInfo() << "BeamMonitor::FitAndFill - Beam fit fails!!!";
1457  onlineDbService_->logger().logInfo() << "BeamMonitor::FitAndFill - Output beam spot for DIP";
1458  onlineDbService_->logger().logInfo() << "\n" << bs;
1459  DBloggerReturn_ = 2;
1460  }
1461 
1462  hs[k_sigmaX0_lumi]->ShiftFillLast(bs.BeamWidthX(), bs.BeamWidthXError(), fitNLumi_);
1463  hs[k_sigmaY0_lumi]->ShiftFillLast(bs.BeamWidthY(), bs.BeamWidthYError(), fitNLumi_);
1464  hs[k_sigmaZ0_lumi]->ShiftFillLast(bs.sigmaZ(), bs.sigmaZ0Error(), fitNLumi_);
1465  hs[k_x0_lumi]->ShiftFillLast(bs.x0(), bs.x0Error(), fitNLumi_);
1466  hs[k_y0_lumi]->ShiftFillLast(bs.y0(), bs.y0Error(), fitNLumi_);
1467  hs[k_z0_lumi]->ShiftFillLast(bs.z0(), bs.z0Error(), fitNLumi_);
1468  } // end of beam fit fails
1469 
1470  } //-------- end of countFitting------------------------------------------
1471  else { // no fit
1472  // Overwrite Fit LS and fit time when no event processed or no track selected
1474  theBeamFitter->setRefTime(refBStime[0], refBStime[1]);
1475  if (theBeamFitter->runPVandTrkFitter()) {
1476  } // Dump fake beam spot for DIP
1477  reco::BeamSpot bs = theBeamFitter->getBeamSpot();
1478  edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] No fitting \n" << endl;
1479  edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] Output fake beam spot for DIP \n" << endl;
1480  edm::LogInfo("BeamMonitor") << bs << endl;
1481 
1482  if (onlineDbService_.isAvailable()) {
1483  onlineDbService_->logger().logInfo() << "BeamMonitor::FitAndFill - No fitting";
1484  onlineDbService_->logger().logInfo() << "BeamMonitor::FitAndFill - Output fake beam spot for DIP";
1485  onlineDbService_->logger().logInfo() << "\n" << bs;
1486  DBloggerReturn_ = 2;
1487  }
1488 
1489  hs[k_sigmaX0_lumi]->ShiftFillLast(bs.BeamWidthX(), bs.BeamWidthXError(), fitNLumi_);
1490  hs[k_sigmaY0_lumi]->ShiftFillLast(bs.BeamWidthY(), bs.BeamWidthYError(), fitNLumi_);
1491  hs[k_sigmaZ0_lumi]->ShiftFillLast(bs.sigmaZ(), bs.sigmaZ0Error(), fitNLumi_);
1492  hs[k_x0_lumi]->ShiftFillLast(bs.x0(), bs.x0Error(), fitNLumi_);
1493  hs[k_y0_lumi]->ShiftFillLast(bs.y0(), bs.y0Error(), fitNLumi_);
1494  hs[k_z0_lumi]->ShiftFillLast(bs.z0(), bs.z0Error(), fitNLumi_);
1495  }
1496 
1497  // Fill summary report
1498  if (countFitting) {
1499  for (int n = 0; n < nFitElements_; n++) {
1501  }
1502 
1503  summarySum_ = 0;
1504  for (int ii = 0; ii < nFitElements_; ii++) {
1506  }
1508  if (reportSummary)
1510 
1511  for (int bi = 0; bi < nFitElements_; bi++) {
1512  reportSummaryMap->setBinContent(1, bi + 1, summaryContent_[bi] / (float)nFits_);
1513  }
1514  }
1515 
1516  if ((resetFitNLumi_ > 0 &&
1517  ((onlineMode_ &&
1518  countLumi_ == resetFitNLumi_) || //OR it should be currentLumi_ (if in sequence then does not mattar)
1519  (!onlineMode_ && countLumi_ == resetFitNLumi_))) ||
1520  (StartAverage_)) {
1521  edm::LogInfo("BeamMonitor") << "FitAndFill:: The flag is ON for running average Beam Spot fit" << endl;
1522  StartAverage_ = true;
1523  firstAverageFit_++;
1524  resetHistos_ = true;
1525  nthBSTrk_ = 0;
1526  beginLumiOfBSFit_ = 0;
1527  refBStime[0] = 0;
1528  }
1529 }
1530 
1531 //--------------------------------------------------------
1533  if (debug_)
1534  edm::LogInfo("BeamMonitor")
1535  << " RestartingFitting:: Restart Beami everything to a fresh start !!! because Gap is > 10 LS" << endl;
1536  //track based fit reset here
1537  resetHistos_ = true;
1538  nthBSTrk_ = 0;
1539  theBeamFitter->resetTrkVector();
1540  theBeamFitter->resetLSRange();
1541  theBeamFitter->resetRefTime();
1542  theBeamFitter->resetPVFitter();
1543  theBeamFitter->resetCutFlow();
1544  beginLumiOfBSFit_ = 0;
1545  refBStime[0] = 0;
1546  //pv based fit iis reset here
1547  h_PVx[0]->Reset();
1548  h_PVy[0]->Reset();
1549  h_PVz[0]->Reset();
1550  beginLumiOfPVFit_ = 0;
1551  refPVtime[0] = 0;
1552  //Clear all the Maps here
1553  mapPVx.clear();
1554  mapPVy.clear();
1555  mapPVz.clear();
1556  mapNPV.clear();
1557  mapBeginBSLS.clear();
1558  mapBeginPVLS.clear();
1559  mapBeginBSTime.clear();
1560  mapBeginPVTime.clear();
1561  mapLSBSTrkSize.clear();
1562  mapLSPVStoreSize.clear();
1563  mapLSCF.clear();
1564  countGapLumi_ = 0;
1565  countLumi_ = 0;
1566  StartAverage_ = false;
1567 }
1568 
1569 //-------------------------------------------------------
1571  if (debug_)
1572  edm::LogInfo("BeamMonitor") << "dqmEndRun:: Clearing all the Maps " << endl;
1573  //Clear all the Maps here
1574  mapPVx.clear();
1575  mapPVy.clear();
1576  mapPVz.clear();
1577  mapNPV.clear();
1578  mapBeginBSLS.clear();
1579  mapBeginPVLS.clear();
1580  mapBeginBSTime.clear();
1581  mapBeginPVTime.clear();
1582  mapLSBSTrkSize.clear();
1583  mapLSPVStoreSize.clear();
1584  mapLSCF.clear();
1585 
1588  }
1589 }
1590 //--------------------------------------------------------
1591 void BeamMonitor::scrollTH1(TH1* h, time_t ref) {
1592  char offsetTime[64];
1593  formatFitTime(offsetTime, ref);
1594  TDatime da(offsetTime);
1595  if (lastNZbin > 0) {
1596  double val = h->GetBinContent(lastNZbin);
1597  double valErr = h->GetBinError(lastNZbin);
1598  h->Reset();
1599  h->GetXaxis()->SetTimeOffset(da.Convert(kTRUE));
1600  int bin = (lastNZbin > buffTime ? buffTime : 1);
1601  h->SetBinContent(bin, val);
1602  h->SetBinError(bin, valErr);
1603  } else {
1604  h->Reset();
1605  h->GetXaxis()->SetTimeOffset(da.Convert(kTRUE));
1606  }
1607 }
1608 
1609 //--------------------------------------------------------
1610 // Method to check whether to chane histogram time offset (forward only)
1611 bool BeamMonitor::testScroll(time_t& tmpTime_, time_t& refTime_) {
1612  bool scroll_ = false;
1613  if (tmpTime_ - refTime_ >= intervalInSec_) {
1614  scroll_ = true;
1615  edm::LogInfo("BeamMonitor") << "testScroll:: Reset Time Offset" << std::endl;
1617  for (int bin = intervalInSec_; bin >= 1; bin--) {
1618  if (hs[k_x0_time]->getBinContent(bin) > 0) {
1619  lastNZbin = bin;
1620  break;
1621  }
1622  }
1623  edm::LogInfo("BeamMonitor") << "testScroll:: Last non zero bin = " << lastNZbin << std::endl;
1624  if (tmpTime_ - refTime_ >= intervalInSec_ + lastNZbin) {
1625  edm::LogInfo("BeamMonitor") << "testScroll:: Time difference too large since last readout" << std::endl;
1626  lastNZbin = 0;
1627  refTime_ = tmpTime_ - buffTime;
1628  } else {
1629  edm::LogInfo("BeamMonitor") << "testScroll:: Offset to last record" << std::endl;
1630  int offset = ((lastNZbin > buffTime) ? (lastNZbin - buffTime) : (lastNZbin - 1));
1631  refTime_ += offset;
1632  }
1633  }
1634  return scroll_;
1635 }
1636 
1638 
1639 // Local Variables:
1640 // show-trailing-whitespace: t
1641 // truncate-lines: t
1642 // End:
BeamMonitor::recordName_
std::string recordName_
Definition: BeamMonitor.h:76
buffTime
static constexpr int buffTime
Definition: BeamMonitor.cc:89
BeamMonitor::h_vx_vy
MonitorElement * h_vx_vy
Definition: BeamMonitor.h:134
BeamMonitor::refBStime
std::time_t refBStime[2]
Definition: BeamMonitor.h:103
BeamMonitor::lastNZbin
int lastNZbin
Definition: BeamMonitor.h:185
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
BeamMonitor::phiMin_
const double phiMin_
Definition: BeamMonitor.h:69
BeamMonitor::tmpTime
std::time_t tmpTime
Definition: BeamMonitor.h:179
mps_fire.i
i
Definition: mps_fire.py:428
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
BeamMonitor::ftimestamp
edm::TimeValue_t ftimestamp
Definition: BeamMonitor.h:182
MessageLogger.h
BeamMonitor::firstAverageFit_
int firstAverageFit_
Definition: BeamMonitor.h:117
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
reco::BeamSpot::BeamWidthXError
double BeamWidthXError() const
error on beam width X, assume error in X = Y
Definition: BeamSpot.h:99
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
BeamMonitor::dzMin_
const double dzMin_
Definition: BeamMonitor.h:73
dqm::implementation::IBooker::bookFloat
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
BeamSpotObjects::SetBetaStar
void SetBetaStar(double val)
set beta star
Definition: BeamSpotObjects.h:64
BeamMonitor::monitorName_
std::string monitorName_
Definition: BeamMonitor.h:75
cond::service::OnlineDBOutputService::writeForNextLumisection
bool writeForNextLumisection(const PayloadType *payload, const std::string &recordName)
Definition: OnlineDBOutputService.h:40
trigNames
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:57
TrackCandidateCollection.h
BeamMonitor::hs
std::vector< MonitorElement * > hs
Definition: BeamMonitor.h:154
BeamMonitor::beginLumiOfBSFit_
int beginLumiOfBSFit_
Definition: BeamMonitor.h:97
BeamMonitor::minNrVertices_
unsigned int minNrVertices_
Definition: BeamMonitor.h:111
BeamMonitor::cutFlowTable
MonitorElement * cutFlowTable
Definition: BeamMonitor.h:175
dqm::impl::MonitorElement::setOption
virtual void setOption(const char *option)
Definition: MonitorElement.cc:878
BeamMonitor
Definition: BeamMonitor.h:34
BeamSpotOnlineObjects::SetCreationTime
void SetCreationTime(cond::Time_t val)
Definition: BeamSpotOnlineObjects.cc:139
BeamMonitor::bookHistograms
void bookHistograms(DQMStore::IBooker &i, const edm::Run &r, const edm::EventSetup &c) override
Definition: BeamMonitor.cc:220
BeamMonitor::mapPVx
std::map< int, std::vector< float > > mapPVx
Definition: BeamMonitor.h:157
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
BeamMonitor::h_PVxz
MonitorElement * h_PVxz
Definition: BeamMonitor.h:151
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
BeamMonitor::frun
int frun
Definition: BeamMonitor.h:184
edm::Run
Definition: Run.h:45
BeamSpotOnlineObjects::SetNumTracks
void SetNumTracks(int val)
Definition: BeamSpotOnlineObjects.cc:97
BeamMonitor::pvSrc_
edm::EDGetTokenT< reco::VertexCollection > pvSrc_
Definition: BeamMonitor.h:79
TriggerEvent.h
LuminosityBlock.h
BeamMonitor::endLumiOfPVFit_
int endLumiOfPVFit_
Definition: BeamMonitor.h:100
edm
HLT enums.
Definition: AlignableModifier.h:19
BeamMonitor::onlineMode_
bool onlineMode_
Definition: BeamMonitor.h:90
BeamMonitor::jetTrigger_
std::vector< std::string > jetTrigger_
Definition: BeamMonitor.h:91
edm::LuminosityBlockBase::beginTime
Timestamp const & beginTime() const
Definition: LuminosityBlockBase.h:46
BeamMonitor.h
cond::persistency::Logger::end
void end(int retCode)
Definition: Logger.cc:80
CEST
#define CEST
BeamSpotOnlineObjects::SetEndTimeStamp
void SetEndTimeStamp(cond::Time_t val)
Definition: BeamSpotOnlineObjects.cc:147
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
BeamSpotOnlineObjects::SetEndTime
void SetEndTime(std::string val)
Definition: BeamSpotOnlineObjects.cc:131
BeamMonitor::dxBin_
const int dxBin_
Definition: BeamMonitor.h:60
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:278
BeamSpotOnlineObjects::GetEndTimeStamp
cond::Time_t GetEndTimeStamp() const
Definition: BeamSpotOnlineObjects.cc:92
BeamSpotOnlineObjects::GetUsedEvents
int GetUsedEvents() const
Definition: BeamSpotOnlineObjects.cc:54
Calorimetry_cff.da
da
Definition: Calorimetry_cff.py:155
cms::cuda::assert
assert(be >=bs)
protons_cff.time
time
Definition: protons_cff.py:35
BeamMonitor::DBloggerReturn_
int DBloggerReturn_
Definition: BeamMonitor.h:82
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:47
DQMStore.h
alpha
float alpha
Definition: AMPTWrapper.h:105
BeamMonitor::nFits_
int nFits_
Definition: BeamMonitor.h:107
BeamSpotObjects::SetBeamWidthY
void SetBeamWidthY(double val)
set average transverse beam width Y
Definition: BeamSpotObjects.h:50
BeamMonitor::mapNPV
std::map< int, std::vector< int > > mapNPV
Definition: BeamMonitor.h:158
BeamMonitor::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: BeamMonitor.cc:661
dqm::impl::MonitorElement::getRMSError
virtual double getRMSError(int axis=1) const
get RMS uncertainty of histogram along x, y or z axis(axis=1,2,3 respectively)
Definition: MonitorElement.cc:559
BeamMonitor::mapLSBSTrkSize
std::map< int, std::size_t > mapLSBSTrkSize
Definition: BeamMonitor.h:163
BeamMonitor::reportSummary
MonitorElement * reportSummary
Definition: BeamMonitor.h:172
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Timestamp::value
TimeValue_t value() const
Definition: Timestamp.h:45
BeamMonitor::vxBin_
const int vxBin_
Definition: BeamMonitor.h:64
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
BeamMonitor::fitResults
MonitorElement * fitResults
Definition: BeamMonitor.h:139
cond::persistency::Logger::logInfo
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
BeamSpotOnlineObjects::GetMaxPVs
int GetMaxPVs() const
Definition: BeamSpotOnlineObjects.cc:58
BeamMonitor::h_sigmaY0
MonitorElement * h_sigmaY0
Definition: BeamMonitor.h:144
BeamMonitor::h_nVtx
MonitorElement * h_nVtx
Definition: BeamMonitor.h:146
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle< reco::BeamSpot >
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
BeamSpotOnlineObjects::SetMeanErrorPV
void SetMeanErrorPV(float val)
Definition: BeamSpotOnlineObjects.cc:115
BeamMonitor::countEvt_
int countEvt_
Definition: BeamMonitor.h:95
BeamMonitor::minVtxWgt_
double minVtxWgt_
Definition: BeamMonitor.h:113
BeamMonitor::h_PVz
MonitorElement * h_PVz[2]
Definition: BeamMonitor.h:150
BeamSpotObjects::SetSigmaZ
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:42
BeamSpotOnlineObjects::SetStartTime
void SetStartTime(std::string val)
Definition: BeamSpotOnlineObjects.cc:127
BeamMonitor::h_nTrk_lumi
MonitorElement * h_nTrk_lumi
Definition: BeamMonitor.h:129
BeamMonitor::testScroll
bool testScroll(std::time_t &, std::time_t &)
Definition: BeamMonitor.cc:1611
visDQMUpload.context
context
Definition: visDQMUpload.py:37
BeamMonitor::nextlumi_
int nextlumi_
Definition: BeamMonitor.h:102
BeamMonitor::h_y0
MonitorElement * h_y0
Definition: BeamMonitor.h:141
BeamMonitor::minVtxNdf_
double minVtxNdf_
Definition: BeamMonitor.h:112
BeamMonitor::processed_
bool processed_
Definition: BeamMonitor.h:120
BeamMonitor::h_PVyz
MonitorElement * h_PVyz
Definition: BeamMonitor.h:152
MakerMacros.h
BeamSpotOnlineObjects::GetMeanErrorPV
float GetMeanErrorPV() const
Definition: BeamSpotOnlineObjects.cc:62
cms::cuda::bs
bs
Definition: HistoContainer.h:76
BeamSpotOnlineObjects::GetStartTime
std::string GetStartTime() const
Definition: BeamSpotOnlineObjects.cc:72
BeamMonitor::fitPVNLumi_
int fitPVNLumi_
Definition: BeamMonitor.h:85
BeamMonitor::pvResults
MonitorElement * pvResults
Definition: BeamMonitor.h:153
BeamSpotOnlineObjects::GetMeanPV
float GetMeanPV() const
Definition: BeamSpotOnlineObjects.cc:60
h
edm::LuminosityBlockBase::endTime
Timestamp const & endTime() const
Definition: LuminosityBlockBase.h:47
BeamMonitor::dxMin_
const double dxMin_
Definition: BeamMonitor.h:61
BeamMonitor::refBS
reco::BeamSpot refBS
Definition: BeamMonitor.h:125
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamMonitor::countGapLumi_
int countGapLumi_
Definition: BeamMonitor.h:118
Service.h
edm::LuminosityBlockBase::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockBase.h:40
L1TEGammaOffline_cfi.PVCollection
PVCollection
Definition: L1TEGammaOffline_cfi.py:34
BeamMonitor::mapPVz
std::map< int, std::vector< float > > mapPVz
Definition: BeamMonitor.h:157
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
BeamMonitor::endLuminosityBlock
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
Definition: BeamMonitor.cc:798
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
mps_fire.end
end
Definition: mps_fire.py:242
BeamMonitor::h_sigmaZ0
MonitorElement * h_sigmaZ0
Definition: BeamMonitor.h:145
reco::BeamSpot
Definition: BeamSpot.h:21
BeamSpotOnlineObjects::GetEndTime
std::string GetEndTime() const
Definition: BeamSpotOnlineObjects.cc:76
dqm::impl::MonitorElement::Reset
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
Definition: MonitorElement.cc:345
dqm::impl::MonitorElement::ShiftFillLast
DQM_DEPRECATED void ShiftFillLast(double y, double ye=0., int32_t xscale=1)
Definition: MonitorElement.cc:247
Run.h
BeamMonitor::reportSummary_
Float_t reportSummary_
Definition: BeamMonitor.h:169
dqm::implementation::IBooker::bookProfile
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:322
BeamMonitor::mapBeginBSTime
std::map< int, std::time_t > mapBeginBSTime
Definition: BeamMonitor.h:161
hgcalPlots.xtitle
xtitle
Definition: hgcalPlots.py:93
dqm::impl::MonitorElement::getRMS
virtual double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:553
BeamSpotObjects::SetEmittanceY
void SetEmittanceY(double val)
set emittance
Definition: BeamSpotObjects.h:62
dqm::impl::MonitorElement::getTH1F
virtual TH1F * getTH1F()
Definition: MonitorElement.cc:977
HLTMuonOfflineAnalyzer_cfi.z0
z0
Definition: HLTMuonOfflineAnalyzer_cfi.py:98
cond::persistency::Logger::start
void start()
Definition: Logger.cc:69
b
double b
Definition: hdecay.h:118
BeamMonitor::h_nVtx_lumi_all
MonitorElement * h_nVtx_lumi_all
Definition: BeamMonitor.h:131
dqm::impl::MonitorElement::getTH1
virtual TH1 * getTH1()
Definition: MonitorElement.cc:972
BeamMonitor::startTime
std::time_t startTime
Definition: BeamMonitor.h:180
BeamSpotObjects::SetPosition
void SetPosition(double x, double y, double z)
set XYZ position
Definition: BeamSpotObjects.h:36
BeamMonitor::tracksLabel_
edm::EDGetTokenT< reco::TrackCollection > tracksLabel_
Definition: BeamMonitor.h:78
BeamMonitor::mapBeginPVTime
std::map< int, std::time_t > mapBeginPVTime
Definition: BeamMonitor.h:161
BeamMonitor::h_vy_dz
MonitorElement * h_vy_dz
Definition: BeamMonitor.h:136
BeamMonitor::getGMTstring
std::string getGMTstring(const std::time_t &)
Definition: BeamMonitor.cc:91
EgHLTOffTrigSelection_cfi.trigName
trigName
Definition: EgHLTOffTrigSelection_cfi.py:8
BeamMonitor::h_sigmaX0
MonitorElement * h_sigmaX0
Definition: BeamMonitor.h:143
BeamSpotOnlineObjects::SetRmsErrorPV
void SetRmsErrorPV(float val)
Definition: BeamSpotOnlineObjects.cc:123
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
BeamMonitor::vxMin_
const double vxMin_
Definition: BeamMonitor.h:65
BeamMonitor::dzMax_
const double dzMax_
Definition: BeamMonitor.h:74
BeamSpotObjects::SetType
void SetType(int type)
set beam type
Definition: BeamSpotObjects.h:58
edm::ParameterSet
Definition: ParameterSet.h:47
BeamMonitor::refTime
std::time_t refTime
Definition: BeamMonitor.h:181
BeamMonitor::formatFitTime
void formatFitTime(char *, const std::time_t &)
Definition: BeamMonitor.cc:43
BeamMonitor::endLumiOfBSFit_
int endLumiOfBSFit_
Definition: BeamMonitor.h:98
BeamMonitor::intervalInSec_
int intervalInSec_
Definition: BeamMonitor.h:88
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
B2GTnPMonitor_cfi.histTitle
histTitle
Definition: B2GTnPMonitor_cfi.py:112
BeamMonitor::h_nVtx_lumi
MonitorElement * h_nVtx_lumi
Definition: BeamMonitor.h:130
BeamSpotOnlineObjects::SetMaxPVs
void SetMaxPVs(int val)
Definition: BeamSpotOnlineObjects.cc:107
BeamMonitor::refPVtime
std::time_t refPVtime[2]
Definition: BeamMonitor.h:104
BeamMonitor::RestartFitting
void RestartFitting()
Definition: BeamMonitor.cc:1532
BeamSpotObjects::SetEmittanceX
void SetEmittanceX(double val)
set emittance
Definition: BeamSpotObjects.h:60
BeamSpotObjects::SetCovariance
void SetCovariance(int i, int j, double val)
set i,j element of the full covariance matrix 7x7
Definition: BeamSpotObjects.h:56
BeamSpotOnlineObjects::SetUsedEvents
void SetUsedEvents(int val)
Definition: BeamSpotOnlineObjects.cc:103
BeamMonitor::vxMax_
const double vxMax_
Definition: BeamMonitor.h:66
createfilelist.int
int
Definition: createfilelist.py:10
TriggerNames.h
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
BeamMonitor::StartAverage_
bool StartAverage_
Definition: BeamMonitor.h:116
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:762
plotBeamSpotDB.ptm
ptm
Definition: plotBeamSpotDB.py:396
dqm::impl::MonitorElement::getTProfile
virtual TProfile * getTProfile()
Definition: MonitorElement.cc:1019
BeamSpotPI::creationTime
Definition: BeamSpotPayloadInspectorHelper.h:44
reco::BeamSpot::BeamWidthYError
double BeamWidthYError() const
error on beam width Y, assume error in X = Y
Definition: BeamSpot.h:101
Hists
Hists
Definition: BeamMonitor.cc:173
edm::EventSetup
Definition: EventSetup.h:58
BeamMonitor::reportSummaryContents
MonitorElement * reportSummaryContents[3]
Definition: BeamMonitor.h:173
reco::BeamSpot::BeamWidthX
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:82
BeamSpotObjects::Setdxdz
void Setdxdz(double val)
set dxdz slope, crossing angle
Definition: BeamSpotObjects.h:44
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::LuminosityBlock::getRun
Run const & getRun() const
Definition: LuminosityBlock.h:107
BeamSpotOnlineObjects::SetLastAnalyzedFill
void SetLastAnalyzedFill(int val)
Definition: BeamSpotOnlineObjects.h:54
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BeamMonitor::h_x0
MonitorElement * h_x0
Definition: BeamMonitor.h:140
BeamSpotOnlineObjects::GetRmsErrorPV
float GetRmsErrorPV() const
Definition: BeamSpotOnlineObjects.cc:68
alignCSCRings.r
r
Definition: alignCSCRings.py:93
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
BeamMonitor::dqmBeginRun
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
Definition: BeamMonitor.cc:214
BeamMonitor::bsSrc_
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
Definition: BeamMonitor.h:77
cond::service::PoolDBOutputService::releaseLocks
void releaseLocks()
Definition: PoolDBOutputService.cc:109
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:682
BeamMonitor::h_z0
MonitorElement * h_z0
Definition: BeamMonitor.h:142
BeamMonitor::mapLSCF
std::map< int, TH1F > mapLSCF
Definition: BeamMonitor.h:166
BeamMonitor::beginLumiOfPVFit_
int beginLumiOfPVFit_
Definition: BeamMonitor.h:99
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
BeamMonitor::deltaSigCut_
double deltaSigCut_
Definition: BeamMonitor.h:108
BeamMonitor::dzBin_
const int dzBin_
Definition: BeamMonitor.h:72
BeamMonitor::h_PVx
MonitorElement * h_PVx[2]
Definition: BeamMonitor.h:148
BeamMonitor::useLockRecords_
bool useLockRecords_
Definition: BeamMonitor.h:121
BeamSpotOnlineObjects::SetLastAnalyzedLumi
void SetLastAnalyzedLumi(int val)
Setters Methods.
Definition: BeamSpotOnlineObjects.h:48
cond::service::PoolDBOutputService::logger
cond::persistency::Logger & logger()
Definition: PoolDBOutputService.h:195
BeamSpotOnlineObjects
Definition: BeamSpotOnlineObjects.h:25
BeamMonitor::maxZ_
double maxZ_
Definition: BeamMonitor.h:110
BeamMonitor::resetPVNLumi_
int resetPVNLumi_
Definition: BeamMonitor.h:87
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
BeamMonitor::debug_
bool debug_
Definition: BeamMonitor.h:89
BeamSpotObjects::SetBeamWidthX
void SetBeamWidthX(double val)
set average transverse beam width X
Definition: BeamSpotObjects.h:48
BeamMonitor::phiBin_
const int phiBin_
Definition: BeamMonitor.h:68
edm::TriggerNames
Definition: TriggerNames.h:55
BeamMonitor::preBS
reco::BeamSpot preBS
Definition: BeamMonitor.h:126
BeamMonitor::lastlumi_
int lastlumi_
Definition: BeamMonitor.h:101
BeamMonitor::h_nVtx_st
MonitorElement * h_nVtx_st
Definition: BeamMonitor.h:147
BeamMonitor::reportSummaryMap
MonitorElement * reportSummaryMap
Definition: BeamMonitor.h:174
BeamMonitor::summaryContent_
Float_t summaryContent_[3]
Definition: BeamMonitor.h:171
BeamMonitor::onlineDbService_
edm::Service< cond::service::OnlineDBOutputService > onlineDbService_
Definition: BeamMonitor.h:81
BeamMonitor::FitAndFill
void FitAndFill(const edm::LuminosityBlock &lumiSeg, int &, int &, int &)
Definition: BeamMonitor.cc:817
AlcaSiPixelAliHarvester0T_cff.options
options
Definition: AlcaSiPixelAliHarvester0T_cff.py:42
BeamMonitor::fitNLumi_
int fitNLumi_
Definition: BeamMonitor.h:84
BeamMonitor::countLumi_
int countLumi_
Definition: BeamMonitor.h:96
BeamMonitor::scrollTH1
void scrollTH1(TH1 *, std::time_t)
Definition: BeamMonitor.cc:1591
BeamMonitor::dxMax_
const double dxMax_
Definition: BeamMonitor.h:62
dqm::impl::MonitorElement::getMean
virtual double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:540
BeamSpotOnlineObjects::SetRmsPV
void SetRmsPV(float val)
Definition: BeamSpotOnlineObjects.cc:119
BeamSpotOnlineObjects::GetRmsPV
float GetRmsPV() const
Definition: BeamSpotOnlineObjects.cc:66
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
BeamMonitor::resetHistos_
bool resetHistos_
Definition: BeamMonitor.h:115
BeamSpotOnlineObjects::SetMeanPV
void SetMeanPV(float val)
Definition: BeamSpotOnlineObjects.cc:111
BeamMonitor::h_PVy
MonitorElement * h_PVy[2]
Definition: BeamMonitor.h:149
dqm::implementation::IBooker
Definition: DQMStore.h:43
BeamMonitor::mapLSPVStoreSize
std::map< int, size_t > mapLSPVStoreSize
Definition: BeamMonitor.h:164
BeamMonitor::h_trkPt
MonitorElement * h_trkPt
Definition: BeamMonitor.h:137
cond::persistency::Logger::logError
EchoedLogStream< edm::LogError > logError()
Definition: Logger.cc:165
BeamSpotOnlineObjects::SetLastAnalyzedRun
void SetLastAnalyzedRun(int val)
Definition: BeamSpotOnlineObjects.h:51
BeamMonitor::h_trkVz
MonitorElement * h_trkVz
Definition: BeamMonitor.h:138
cond::service::PoolDBOutputService::lockRecords
void lockRecords()
Definition: PoolDBOutputService.cc:94
BeamSpotObjects::SetBeamWidthXError
void SetBeamWidthXError(double val)
set beam width X error
Definition: BeamSpotObjects.h:52
BeamSpotOnlineObjects.h
BeamMonitor::hltSrc_
edm::EDGetTokenT< edm::TriggerResults > hltSrc_
Definition: BeamMonitor.h:80
ConsumesCollector.h
BeamMonitor::phiMax_
const double phiMax_
Definition: BeamMonitor.h:70
genParticles_cff.map
map
Definition: genParticles_cff.py:11
BeamSpotObjects::SetBeamWidthYError
void SetBeamWidthYError(double val)
set beam width Y error
Definition: BeamSpotObjects.h:54
View.h
BeamMonitor::nthBSTrk_
unsigned int nthBSTrk_
Definition: BeamMonitor.h:105
dqm::impl::MonitorElement::getMeanError
virtual double getMeanError(int axis=1) const
Definition: MonitorElement.cc:547
TrackCandidate.h
BeamMonitor::h_trk_z0
MonitorElement * h_trk_z0
Definition: BeamMonitor.h:133
BeamMonitor::h_d0_phi0
MonitorElement * h_d0_phi0
Definition: BeamMonitor.h:132
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
BeamMonitor::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
Definition: BeamMonitor.cc:531
BSFitter.h
BeamMonitor::min_Ntrks_
unsigned int min_Ntrks_
Definition: BeamMonitor.h:109
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
BeamMonitor::nFitElements_
int nFitElements_
Definition: BeamMonitor.h:106
BeamMonitor::mapBeginBSLS
std::map< int, int > mapBeginBSLS
Definition: BeamMonitor.h:160
edm::Event
Definition: Event.h:73
BeamMonitor::summarySum_
Float_t summarySum_
Definition: BeamMonitor.h:170
BeamSpotOnlineObjects::SetStartTimeStamp
void SetStartTimeStamp(cond::Time_t val)
Definition: BeamSpotOnlineObjects.cc:143
DeadROC_duringRun.f1
f1
Definition: DeadROC_duringRun.py:219
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
BeamSpotObjects::Setdydz
void Setdydz(double val)
set dydz slope, crossing angle in XZ
Definition: BeamSpotObjects.h:46
BeamMonitor::resetFitNLumi_
int resetFitNLumi_
Definition: BeamMonitor.h:86
edm::RunBase::beginTime
Timestamp const & beginTime() const
Definition: RunBase.h:41
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:791
BeamMonitor::h_vx_dz
MonitorElement * h_vx_dz
Definition: BeamMonitor.h:135
cuy.ii
ii
Definition: cuy.py:589
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
label
const char * label
Definition: PFTauDecayModeTools.cc:11
BeamMonitor::BeamMonitor
BeamMonitor(const edm::ParameterSet &)
Definition: BeamMonitor.cc:101
BeamSpotOnlineObjects::GetStartTimeStamp
cond::Time_t GetStartTimeStamp() const
Definition: BeamSpotOnlineObjects.cc:88
reco::BeamSpot::BeamWidthY
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:84
edm::TimeValue_t
unsigned long long TimeValue_t
Definition: Timestamp.h:28
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
BeamMonitor::dqmEndRun
void dqmEndRun(const edm::Run &r, const edm::EventSetup &c) override
Definition: BeamMonitor.cc:1570
BeamSpotOnlineObjects::SetNumPVs
void SetNumPVs(int val)
Definition: BeamSpotOnlineObjects.cc:101
BeamMonitor::theBeamFitter
std::unique_ptr< BeamFitter > theBeamFitter
Definition: BeamMonitor.h:93
BeamMonitor::mapBeginPVLS
std::map< int, int > mapBeginPVLS
Definition: BeamMonitor.h:160
BeamMonitor::mapPVy
std::map< int, std::vector< float > > mapPVy
Definition: BeamMonitor.h:157
hgcalPlots.ytitle
ytitle
Definition: hgcalPlots.py:1109
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37