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