CMS 3D CMS Logo

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