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