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