CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
33 #include <numeric>
34 #include <cmath>
35 #include <memory>
36 #include <TMath.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  }
488  reportSummaryContents[n] = iBooker.bookFloat(histo);
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  int nthlumi = lumiSeg.luminosityBlock();
513  const edm::TimeValue_t fbegintimestamp = lumiSeg.beginTime().value();
514  const std::time_t ftmptime = fbegintimestamp >> 32;
515 
516  if (countLumi_ == 0 && (!processed_)) {
518  refBStime[0] = refPVtime[0] = ftmptime;
519  mapBeginBSLS[countLumi_] = nthlumi;
520  mapBeginPVLS[countLumi_] = nthlumi;
521  mapBeginBSTime[countLumi_] = ftmptime;
522  mapBeginPVTime[countLumi_] = ftmptime;
523  } //for the first record
524 
525  if (nthlumi > nextlumi_) {
526  if (processed_) {
527  countLumi_++;
528  //store here them will need when we remove the first one of Last N LS
529  mapBeginBSLS[countLumi_] = nthlumi;
530  mapBeginPVLS[countLumi_] = nthlumi;
531  mapBeginBSTime[countLumi_] = ftmptime;
532  mapBeginPVTime[countLumi_] = ftmptime;
533  } //processed passed but not the first lumi
534  if ((!processed_) && countLumi_ != 0) {
535  mapBeginBSLS[countLumi_] = nthlumi;
536  mapBeginPVLS[countLumi_] = nthlumi;
537  mapBeginBSTime[countLumi_] = ftmptime;
538  mapBeginPVTime[countLumi_] = ftmptime;
539  } //processed fails for last lumi
540  } //nthLumi > nextlumi
541 
542  if (StartAverage_) {
543  //Just Make sure it get rest
544  refBStime[0] = 0;
545  refPVtime[0] = 0;
546  beginLumiOfPVFit_ = 0;
547  beginLumiOfBSFit_ = 0;
548 
549  if (debug_)
550  edm::LogInfo("FakeBeamMonitor") << " beginLuminosityBlock: Size of mapBeginBSLS before = "
551  << mapBeginBSLS.size() << endl;
552  if (nthlumi >
553  nextlumi_) { //this make sure that it does not take into account this lumi for fitting and only look forward for new lumi
554  //as countLumi also remains the same so map value get overwritten once return to normal running.
555  //even if few LS are misssing and DQM module do not sees them then it catchs up again
556  map<int, int>::iterator itbs = mapBeginBSLS.begin();
557  map<int, int>::iterator itpv = mapBeginPVLS.begin();
558  map<int, std::time_t>::iterator itbstime = mapBeginBSTime.begin();
559  map<int, std::time_t>::iterator itpvtime = mapBeginPVTime.begin();
560 
561  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
562  mapBeginBSLS.erase(itbs);
563  mapBeginPVLS.erase(itpv);
564  mapBeginBSTime.erase(itbstime);
565  mapBeginPVTime.erase(itpvtime);
566  }
567  /*//not sure if want this or not ??
568  map<int, int>::iterator itgapb=mapBeginBSLS.begin();
569  map<int, int>::iterator itgape=mapBeginBSLS.end(); itgape--;
570  countGapLumi_ = ( (itgape->second) - (itgapb->second) );
571  //if we see Gap more than then 2*resetNFitLumi !!!!!!!
572  //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
573  // so better start as fresh and reset everything like starting in the begining!
574  if(countGapLumi_ >= 2*resetFitNLumi_){RestartFitting(); mapBeginBSLS[countLumi_] = nthlumi;}
575  */
576  }
577 
578  if (debug_)
579  edm::LogInfo("FakeBeamMonitor") << " beginLuminosityBlock:: Size of mapBeginBSLS After = " << mapBeginBSLS.size()
580  << endl;
581 
582  map<int, int>::iterator bbs = mapBeginBSLS.begin();
583  map<int, int>::iterator bpv = mapBeginPVLS.begin();
584  map<int, std::time_t>::iterator bbst = mapBeginBSTime.begin();
585  map<int, std::time_t>::iterator bpvt = mapBeginPVTime.begin();
586 
587  if (beginLumiOfPVFit_ == 0)
588  beginLumiOfPVFit_ = bpv->second; //new begin time after removing the LS
589  if (beginLumiOfBSFit_ == 0)
590  beginLumiOfBSFit_ = bbs->second;
591  if (refBStime[0] == 0)
592  refBStime[0] = bbst->second;
593  if (refPVtime[0] == 0)
594  refPVtime[0] = bpvt->second;
595 
596  } //same logic for average fit as above commented line
597 
598  map<int, std::time_t>::iterator nbbst = mapBeginBSTime.begin();
599  map<int, std::time_t>::iterator nbpvt = mapBeginPVTime.begin();
600 
601  if (onlineMode_ && (nthlumi < nextlumi_))
602  return;
603 
604  if (onlineMode_) {
605  if (nthlumi > nextlumi_) {
606  if (countLumi_ != 0 && processed_)
607  FitAndFill(lumiSeg, lastlumi_, nextlumi_, nthlumi);
608  nextlumi_ = nthlumi;
609  edm::LogInfo("FakeBeamMonitor") << "beginLuminosityBlock:: Next Lumi to Fit: " << nextlumi_ << endl;
610  if ((StartAverage_) && refBStime[0] == 0)
611  refBStime[0] = nbbst->second;
612  if ((StartAverage_) && refPVtime[0] == 0)
613  refPVtime[0] = nbpvt->second;
614  }
615  } else {
616  if (processed_)
617  FitAndFill(lumiSeg, lastlumi_, nextlumi_, nthlumi);
618  nextlumi_ = nthlumi;
619  edm::LogInfo("FakeBeamMonitor") << " beginLuminosityBlock:: Next Lumi to Fit: " << nextlumi_ << endl;
620  if ((StartAverage_) && refBStime[0] == 0)
621  refBStime[0] = nbbst->second;
622  if ((StartAverage_) && refPVtime[0] == 0)
623  refPVtime[0] = nbpvt->second;
624  }
625 
626  //countLumi_++;
627  if (processed_)
628  processed_ = false;
629  edm::LogInfo("FakeBeamMonitor") << " beginLuminosityBlock:: Begin of Lumi: " << nthlumi << endl;
630 }
631 
632 // ----------------------------------------------------------
633 void FakeBeamMonitor::analyze(const Event& iEvent, const EventSetup& iSetup) {
634  const int nthlumi = iEvent.luminosityBlock();
635 
636  if (onlineMode_ && (nthlumi < nextlumi_)) {
637  edm::LogInfo("FakeBeamMonitor") << "analyze:: Spilt event from previous lumi section!" << std::endl;
638  return;
639  }
640  if (onlineMode_ && (nthlumi > nextlumi_)) {
641  edm::LogInfo("FakeBeamMonitor") << "analyze:: Spilt event from next lumi section!!!" << std::endl;
642  return;
643  }
644 
645  countEvt_++;
646  // theBeamFitter->readEvent(
647  // iEvent); //Remember when track fitter read the event in the same place the PVFitter read the events !!!!!!!!!
648 
649  // Handle<reco::BeamSpot> recoBeamSpotHandle;
650  // iEvent.getByToken(bsSrc_, recoBeamSpotHandle);
651  // refBS = *recoBeamSpotHandle;
652 
653  // //------Cut Flow Table filled every event!--------------------------------------
654  // {
655  // // Make a copy of the cut flow table from the beam fitter.
656  // auto tmphisto = static_cast<TH1F*>(theBeamFitter->getCutFlow());
657  // cutFlowTable->getTH1()->SetBins(
658  // tmphisto->GetNbinsX(), tmphisto->GetXaxis()->GetXmin(), tmphisto->GetXaxis()->GetXmax());
659  // // Update the bin labels
660  // if (countEvt_ == 1) // SetLabel just once
661  // for (int n = 0; n < tmphisto->GetNbinsX(); n++)
662  // cutFlowTable->setBinLabel(n + 1, tmphisto->GetXaxis()->GetBinLabel(n + 1), 1);
663  // cutFlowTable->Reset();
664  // cutFlowTable->getTH1()->Add(tmphisto);
665  // }
666 
667  //----Reco tracks -------------------------------------
668  // Handle<reco::TrackCollection> TrackCollection;
669  // iEvent.getByToken(tracksLabel_, TrackCollection);
670  // const reco::TrackCollection* tracks = TrackCollection.product();
671  // for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
672  // h_trkPt->Fill(track->pt()); //no need to change here for average bs
673  // h_trkVz->Fill(track->vz());
674  // }
675 
676  //-------HLT Trigger --------------------------------
677  // edm::Handle<TriggerResults> triggerResults;
678  // bool JetTrigPass = false;
679  // if (iEvent.getByToken(hltSrc_, triggerResults)) {
680  // const edm::TriggerNames& trigNames = iEvent.triggerNames(*triggerResults);
681  // for (unsigned int i = 0; i < triggerResults->size(); i++) {
682  // const std::string& trigName = trigNames.triggerName(i);
683  //
684  // if (JetTrigPass)
685  // continue;
686  //
687  // for (size_t t = 0; t < jetTrigger_.size(); ++t) {
688  // if (JetTrigPass)
689  // continue;
690  //
691  // string string_search(jetTrigger_[t]);
692  // size_t found = trigName.find(string_search);
693  //
694  // if (found != string::npos) {
695  // int thisTrigger_ = trigNames.triggerIndex(trigName);
696  // if (triggerResults->accept(thisTrigger_))
697  // JetTrigPass = true;
698  // } //if trigger found
699  // } //for(t=0;..)
700  // } //for(i=0; ..)
701  // } //if trigger colleciton exist)
702 
703  //------ Primary Vertices-------
704  // edm::Handle<reco::VertexCollection> PVCollection;
705 
706  // if (iEvent.getByToken(pvSrc_, PVCollection)) {
707  int nPVcount = 0;
708  int nPVcount_ST = 0; //For Single Trigger(hence ST)
709 
710  // for (reco::VertexCollection::const_iterator pv = PVCollection->begin(); pv != PVCollection->end(); ++pv) {
711  for (int tmp_idx = 0; tmp_idx < 10; tmp_idx++) {
712  //--- vertex selection
713  // if (pv->isFake() || pv->tracksSize() == 0)
714  // continue;
715  nPVcount++; // count non fake pv:
716 
717  //if (JetTrigPass)
718  nPVcount_ST++; //non-fake pv with a specific trigger
719 
720  // if (pv->ndof() < minVtxNdf_ || (pv->ndof() + 3.) / pv->tracksSize() < 2 * minVtxWgt_)
721  // continue;
722 
723  //Fill this map to store xyx for pv so that later we can remove the first one for run aver
724  mapPVx[countLumi_].push_back(tmp_idx);
725  mapPVy[countLumi_].push_back(tmp_idx);
726  mapPVz[countLumi_].push_back(tmp_idx);
727 
728  // if (!StartAverage_) { //for first N LS
729  // h_PVx[0]->Fill(pv->x());
730  // h_PVy[0]->Fill(pv->y());
731  // h_PVz[0]->Fill(pv->z());
732  // h_PVxz->Fill(pv->z(), pv->x());
733  // h_PVyz->Fill(pv->z(), pv->y());
734  // } //for first N LiS
735  // else {
736  // h_PVxz->Fill(pv->z(), pv->x());
737  // h_PVyz->Fill(pv->z(), pv->y());
738  // }
739 
740  } //loop over pvs
741 
742  // h_nVtx->Fill(nPVcount * 1.); //no need to change it for average BS
743 
744  mapNPV[countLumi_].push_back((nPVcount_ST));
745 
746  // if (!StartAverage_) {
747  // h_nVtx_st->Fill(nPVcount_ST * 1.);
748  // }
749 
750  // } //if pv collection is availaable
751 
752  if (StartAverage_) {
753  map<int, std::vector<float> >::iterator itpvx = mapPVx.begin();
754  map<int, std::vector<float> >::iterator itpvy = mapPVy.begin();
755  map<int, std::vector<float> >::iterator itpvz = mapPVz.begin();
756 
757  map<int, std::vector<int> >::iterator itbspvinfo = mapNPV.begin();
758 
759  if ((int)mapPVx.size() > resetFitNLumi_) { //sometimes the events is not there but LS is there!
760  mapPVx.erase(itpvx);
761  mapPVy.erase(itpvy);
762  mapPVz.erase(itpvz);
763  mapNPV.erase(itbspvinfo);
764  } //loop over Last N lumi collected
765 
766  } //StartAverage==true
767 
768  processed_ = true;
769 }
770 
771 //--------------------------------------------------------
773  int nthlumi = lumiSeg.id().luminosityBlock();
774  edm::LogInfo("FakeBeamMonitor") << "endLuminosityBlock:: Lumi of the last event before endLuminosityBlock: "
775  << nthlumi << endl;
776 
777  if (onlineMode_ && nthlumi < nextlumi_)
778  return;
779  const edm::TimeValue_t fendtimestamp = lumiSeg.endTime().value();
780  const std::time_t fendtime = fendtimestamp >> 32;
781  tmpTime = refBStime[1] = refPVtime[1] = fendtime;
782 }
783 
784 //--------------------------------------------------------
785 void FakeBeamMonitor::FitAndFill(const LuminosityBlock& lumiSeg, int& lastlumi, int& nextlumi, int& nthlumi) {
786  if (onlineMode_ && (nthlumi <= nextlumi))
787  return;
788 
789  //set the correct run number when no event in the LS for fake output
790  // if ((processed_) && theBeamFitter->getRunNumber() != frun)
791  // theBeamFitter->setRun(frun);
792 
793  int currentlumi = nextlumi;
794  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: Lumi of the current fit: " << currentlumi << endl;
795  lastlumi = currentlumi;
796  endLumiOfBSFit_ = currentlumi;
797  endLumiOfPVFit_ = currentlumi;
798 
799  //---------Fix for Runninv average-------------
800  mapLSPVStoreSize[countLumi_] = 10; //theBeamFitter->getPVvectorSize();
801 
802  // if (StartAverage_) {
803  // std::map<int, std::size_t>::iterator rmLSPVi = mapLSPVStoreSize.begin();
804  // size_t SizeToRemovePV = rmLSPVi->second;
805  // for (std::map<int, std::size_t>::iterator rmLSPVe = mapLSPVStoreSize.end(); ++rmLSPVi != rmLSPVe;)
806  // rmLSPVi->second -= SizeToRemovePV;
807  //
808  // theBeamFitter->resizePVvector(SizeToRemovePV);
809  //
810  // map<int, std::size_t>::iterator tmpItpv = mapLSPVStoreSize.begin();
811  // mapLSPVStoreSize.erase(tmpItpv);
812  // }
813  // if (debug_)
814  // edm::LogInfo("BeamMonitor") << "FitAndFill:: Size of thePVvector After removing the PVs = "
815  // << theBeamFitter->getPVvectorSize() << endl;
816 
817  //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
818  bool resetHistoFlag_ = false;
819  if ((int)mapPVx.size() >= resetFitNLumi_ && (StartAverage_)) {
820  h_PVx[0]->Reset();
821  h_PVy[0]->Reset();
822  h_PVz[0]->Reset();
823  h_nVtx_st->Reset();
824  resetHistoFlag_ = true;
825  }
826 
827  int MaxPVs = 0;
828  int countEvtLastNLS_ = 0;
829  int countTotPV_ = 0;
830 
831  std::map<int, std::vector<int> >::iterator mnpv = mapNPV.begin();
832  std::map<int, std::vector<float> >::iterator mpv2 = mapPVy.begin();
833  std::map<int, std::vector<float> >::iterator mpv3 = mapPVz.begin();
834 
835  for (std::map<int, std::vector<float> >::iterator mpv1 = mapPVx.begin(); mpv1 != mapPVx.end();
836  ++mpv1, ++mpv2, ++mpv3, ++mnpv) {
837  std::vector<float>::iterator mpvs2 = (mpv2->second).begin();
838  std::vector<float>::iterator mpvs3 = (mpv3->second).begin();
839  for (std::vector<float>::iterator mpvs1 = (mpv1->second).begin(); mpvs1 != (mpv1->second).end();
840  ++mpvs1, ++mpvs2, ++mpvs3) {
841  if (resetHistoFlag_) {
842  h_PVx[0]->Fill(*mpvs1); //these histogram are reset after StartAverage_ flag is ON
843  h_PVy[0]->Fill(*mpvs2);
844  h_PVz[0]->Fill(*mpvs3);
845  }
846  } //loop over second
847 
848  //Do the same here for nPV distr.
849  for (std::vector<int>::iterator mnpvs = (mnpv->second).begin(); mnpvs != (mnpv->second).end(); ++mnpvs) {
850  if ((*mnpvs > 0) && (resetHistoFlag_))
851  h_nVtx_st->Fill((*mnpvs) * (1.0));
852  countEvtLastNLS_++;
853  countTotPV_ += (*mnpvs);
854  if ((*mnpvs) > MaxPVs)
855  MaxPVs = (*mnpvs);
856  } //loop over second of mapNPV
857 
858  } //loop over last N lumis
859 
860  char tmpTitlePV[100];
861  sprintf(tmpTitlePV, "%s %i %s %i", "Num. of reco. vertices for LS: ", beginLumiOfPVFit_, " to ", endLumiOfPVFit_);
862  h_nVtx_st->setAxisTitle(tmpTitlePV, 1);
863 
864  // std::vector<float> DipPVInfo_;
865  // DipPVInfo_.clear();
866  //
867  // if (countTotPV_ != 0) {
868  // DipPVInfo_.push_back((float)countEvtLastNLS_);
869  // DipPVInfo_.push_back(h_nVtx_st->getMean());
870  // DipPVInfo_.push_back(h_nVtx_st->getMeanError());
871  // DipPVInfo_.push_back(h_nVtx_st->getRMS());
872  // DipPVInfo_.push_back(h_nVtx_st->getRMSError());
873  // DipPVInfo_.push_back((float)MaxPVs);
874  // DipPVInfo_.push_back((float)countTotPV_);
875  // MaxPVs = 0;
876  // } else {
877  // for (size_t i = 0; i < 7; i++) {
878  // if (i > 0) {
879  // DipPVInfo_.push_back(0.);
880  // } else {
881  // DipPVInfo_.push_back((float)countEvtLastNLS_);
882  // }
883  // }
884  // }
885  // theBeamFitter->SetPVInfo(DipPVInfo_);
886  countEvtLastNLS_ = 0;
887 
888  if (onlineMode_) { // filling LS gap
889  // FIXME: need to add protection for the case if the gap is at the resetting LS!
890  const int countLS_bs = hs[k_x0_lumi]->getTH1()->GetEntries();
891  const int countLS_pv = hs[k_PVx_lumi]->getTH1()->GetEntries();
892  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: countLS_bs = " << countLS_bs << " ; countLS_pv = " << countLS_pv
893  << std::endl;
894  int LSgap_bs = currentlumi / fitNLumi_ - countLS_bs;
895  int LSgap_pv = currentlumi / fitPVNLumi_ - countLS_pv;
896  if (currentlumi % fitNLumi_ == 0)
897  LSgap_bs--;
898  if (currentlumi % fitPVNLumi_ == 0)
899  LSgap_pv--;
900  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: LSgap_bs = " << LSgap_bs << " ; LSgap_pv = " << LSgap_pv
901  << std::endl;
902  // filling previous fits if LS gap ever exists
903  for (int ig = 0; ig < LSgap_bs; ig++) {
904  hs[k_x0_lumi]->ShiftFillLast(0., 0., fitNLumi_); //x0 , x0err, fitNLumi_; see DQMCore....
905  hs[k_y0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
906  hs[k_z0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
907  hs[k_sigmaX0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
908  hs[k_sigmaY0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
909  hs[k_sigmaZ0_lumi]->ShiftFillLast(0., 0., fitNLumi_);
911  }
912  for (int ig = 0; ig < LSgap_pv; ig++) {
913  hs[k_PVx_lumi]->ShiftFillLast(0., 0., fitPVNLumi_);
914  hs[k_PVy_lumi]->ShiftFillLast(0., 0., fitPVNLumi_);
915  hs[k_PVz_lumi]->ShiftFillLast(0., 0., fitPVNLumi_);
916  }
917  const int previousLS = h_nTrk_lumi->getTH1()->GetEntries();
918  for (int i = 1; i < (currentlumi - previousLS);
919  i++) //if (current-previoius)= 1 then never go inside the for loop!!!!!!!!!!!
921  }
922 
923  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: Time lapsed since last scroll = " << tmpTime - refTime << std::endl;
924 
925  if (testScroll(tmpTime, refTime)) {
926  scrollTH1(hs[k_x0_time]->getTH1(), refTime);
927  scrollTH1(hs[k_y0_time]->getTH1(), refTime);
928  scrollTH1(hs[k_z0_time]->getTH1(), refTime);
929  scrollTH1(hs[k_sigmaX0_time]->getTH1(), refTime);
930  scrollTH1(hs[k_sigmaY0_time]->getTH1(), refTime);
931  scrollTH1(hs[k_sigmaZ0_time]->getTH1(), refTime);
932  scrollTH1(hs[k_PVx_time]->getTH1(), refTime);
933  scrollTH1(hs[k_PVy_time]->getTH1(), refTime);
934  scrollTH1(hs[k_PVz_time]->getTH1(), refTime);
935  }
936 
937  // bool doPVFit = false;
938  //
939  // if (fitPVNLumi_ > 0) {
940  // if (onlineMode_) {
941  // if (currentlumi % fitPVNLumi_ == 0)
942  // doPVFit = true;
943  // } else if (countLumi_ % fitPVNLumi_ == 0)
944  // doPVFit = true;
945  // } else
946  // doPVFit = true;
947  //
948  // if (doPVFit) {
949  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: Do PV Fitting for LS = " << beginLumiOfPVFit_ << " to "
950  << endLumiOfPVFit_ << std::endl;
951  // Primary Vertex Fit:
952  if (h_PVx[0]->getTH1()->GetEntries() > minNrVertices_) {
953  pvResults->Reset();
954  char tmpTitle[50];
955  sprintf(tmpTitle, "%s %i %s %i", "Fitted Primary Vertex (cm) of LS: ", beginLumiOfPVFit_, " to ", endLumiOfPVFit_);
956  pvResults->setAxisTitle(tmpTitle, 1);
957 
958  std::unique_ptr<TF1> fgaus{new TF1("fgaus", "gaus")};
959  double mean, width, meanErr, widthErr;
960  fgaus->SetLineColor(4);
961  h_PVx[0]->getTH1()->Fit(fgaus.get(), "QLM0");
962  mean = fgaus->GetParameter(1);
963  width = fgaus->GetParameter(2);
964  meanErr = fgaus->GetParError(1);
965  widthErr = fgaus->GetParError(2);
966 
967  hs[k_PVx_lumi]->ShiftFillLast(mean, width, fitPVNLumi_);
968  hs[k_PVx_lumi_all]->setBinContent(currentlumi, mean);
969  hs[k_PVx_lumi_all]->setBinError(currentlumi, width);
970  int nthBin = tmpTime - refTime;
971  if (nthBin < 0)
972  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: Event time outside current range of time histograms!"
973  << std::endl;
974  if (nthBin > 0) {
975  hs[k_PVx_time]->setBinContent(nthBin, mean);
976  hs[k_PVx_time]->setBinError(nthBin, width);
977  }
978  int jthBin = tmpTime - startTime;
979  if (jthBin > 0) {
980  hs[k_PVx_time_all]->setBinContent(jthBin, mean);
981  hs[k_PVx_time_all]->setBinError(jthBin, width);
982  }
983  pvResults->setBinContent(1, 6, mean);
984  pvResults->setBinContent(1, 3, width);
985  pvResults->setBinContent(2, 6, meanErr);
986  pvResults->setBinContent(2, 3, widthErr);
987 
988  {
989  // snap shot of the fit
990  auto tmphisto = h_PVx[0]->getTH1F();
991  h_PVx[1]->getTH1()->SetBins(
992  tmphisto->GetNbinsX(), tmphisto->GetXaxis()->GetXmin(), tmphisto->GetXaxis()->GetXmax());
993  h_PVx[1]->Reset();
994  h_PVx[1]->getTH1()->Add(tmphisto);
995  h_PVx[1]->getTH1()->Fit(fgaus.get(), "QLM");
996  }
997 
998  h_PVy[0]->getTH1()->Fit(fgaus.get(), "QLM0");
999  mean = fgaus->GetParameter(1);
1000  width = fgaus->GetParameter(2);
1001  meanErr = fgaus->GetParError(1);
1002  widthErr = fgaus->GetParError(2);
1003  hs[k_PVy_lumi]->ShiftFillLast(mean, width, fitPVNLumi_);
1004  hs[k_PVy_lumi_all]->setBinContent(currentlumi, mean);
1005  hs[k_PVy_lumi_all]->setBinError(currentlumi, width);
1006  if (nthBin > 0) {
1007  hs[k_PVy_time]->setBinContent(nthBin, mean);
1008  hs[k_PVy_time]->setBinError(nthBin, width);
1009  }
1010  if (jthBin > 0) {
1011  hs[k_PVy_time_all]->setBinContent(jthBin, mean);
1012  hs[k_PVy_time_all]->setBinError(jthBin, width);
1013  }
1014  pvResults->setBinContent(1, 5, mean);
1015  pvResults->setBinContent(1, 2, width);
1016  pvResults->setBinContent(2, 5, meanErr);
1017  pvResults->setBinContent(2, 2, widthErr);
1018  // snap shot of the fit
1019  {
1020  auto tmphisto = h_PVy[0]->getTH1F();
1021  h_PVy[1]->getTH1()->SetBins(
1022  tmphisto->GetNbinsX(), tmphisto->GetXaxis()->GetXmin(), tmphisto->GetXaxis()->GetXmax());
1023  h_PVy[1]->Reset();
1024  h_PVy[1]->getTH1()->Add(tmphisto);
1025  h_PVy[1]->getTH1()->Fit(fgaus.get(), "QLM");
1026  }
1027 
1028  h_PVz[0]->getTH1()->Fit(fgaus.get(), "QLM0");
1029  mean = fgaus->GetParameter(1);
1030  width = fgaus->GetParameter(2);
1031  meanErr = fgaus->GetParError(1);
1032  widthErr = fgaus->GetParError(2);
1033  hs[k_PVz_lumi]->ShiftFillLast(mean, width, fitPVNLumi_);
1034  hs[k_PVz_lumi_all]->setBinContent(currentlumi, mean);
1035  hs[k_PVz_lumi_all]->setBinError(currentlumi, width);
1036  if (nthBin > 0) {
1037  hs[k_PVz_time]->setBinContent(nthBin, mean);
1038  hs[k_PVz_time]->setBinError(nthBin, width);
1039  }
1040  if (jthBin > 0) {
1041  hs[k_PVz_time_all]->setBinContent(jthBin, mean);
1042  hs[k_PVz_time_all]->setBinError(jthBin, width);
1043  }
1044  pvResults->setBinContent(1, 4, mean);
1045  pvResults->setBinContent(1, 1, width);
1046  pvResults->setBinContent(2, 4, meanErr);
1047  pvResults->setBinContent(2, 1, widthErr);
1048  {
1049  // snap shot of the fit
1050  auto tmphisto = h_PVz[0]->getTH1F();
1051  h_PVz[1]->getTH1()->SetBins(
1052  tmphisto->GetNbinsX(), tmphisto->GetXaxis()->GetXmin(), tmphisto->GetXaxis()->GetXmax());
1053  h_PVz[1]->Reset();
1054  h_PVz[1]->getTH1()->Add(tmphisto);
1055  h_PVz[1]->getTH1()->Fit(fgaus.get(), "QLM");
1056  }
1057  } //check if found min Vertices
1058  // } //do PVfit
1059 
1060  if ((resetPVNLumi_ > 0 && countLumi_ == resetPVNLumi_) || StartAverage_) {
1061  beginLumiOfPVFit_ = 0;
1062  refPVtime[0] = 0;
1063  }
1064 
1065  //---------Readjustment of theBSvector, RefTime, beginLSofFit---------
1066  // vector<BSTrkParameters> theBSvector1 = theBeamFitter->getBSvector();
1067  // mapLSBSTrkSize[countLumi_] = (theBSvector1.size());
1068  size_t PreviousRecords = 0; //needed to fill nth record of tracks in GUI
1069 
1070  // if (StartAverage_) {
1071  // size_t SizeToRemove = 0;
1072  // std::map<int, std::size_t>::iterator rmls = mapLSBSTrkSize.begin();
1073  // SizeToRemove = rmls->second;
1074  // if (debug_)
1075  // edm::LogInfo("BeamMonitor") << " The size to remove is = " << SizeToRemove << endl;
1076  // int changedAfterThis = 0;
1077  // for (std::map<int, std::size_t>::iterator rmLS = mapLSBSTrkSize.begin(); rmLS != mapLSBSTrkSize.end();
1078  // ++rmLS, ++changedAfterThis) {
1079  // if (changedAfterThis > 0) {
1080  // (rmLS->second) = (rmLS->second) - SizeToRemove;
1081  // if ((mapLSBSTrkSize.size() - (size_t)changedAfterThis) == 2)
1082  // PreviousRecords = (rmLS->second);
1083  // }
1084  // }
1085  //
1086  // theBeamFitter->resizeBSvector(SizeToRemove);
1087  //
1088  // map<int, std::size_t>::iterator tmpIt = mapLSBSTrkSize.begin();
1089  // mapLSBSTrkSize.erase(tmpIt);
1090  //
1091  // std::pair<int, int> checkfitLS = theBeamFitter->getFitLSRange();
1092  // std::pair<time_t, time_t> checkfitTime = theBeamFitter->getRefTime();
1093  // theBeamFitter->setFitLSRange(beginLumiOfBSFit_, checkfitLS.second);
1094  // theBeamFitter->setRefTime(refBStime[0], checkfitTime.second);
1095  // }
1096 
1097  //Fill the track for this fit
1098  // vector<BSTrkParameters> theBSvector = theBeamFitter->getBSvector();
1099  // h_nTrk_lumi->ShiftFillLast(theBSvector.size());
1100  //
1101  // if (debug_)
1102  // edm::LogInfo("BeamMonitor") << "FitAndFill:: Size of theBSViector.size() After =" << theBSvector.size() << endl;
1103 
1104  // bool countFitting = false;
1105  // if (theBSvector.size() >= PreviousRecords && theBSvector.size() >= min_Ntrks_) {
1106  // countFitting = true;
1107  // }
1108 
1109  //---Fix for Cut Flow Table for Running average in a same way//the previous code has problem for resetting!!!
1110  // mapLSCF[countLumi_] = *theBeamFitter->getCutFlow();
1111  // if (StartAverage_ && !mapLSCF.empty()) {
1112  // const TH1F& cutFlowToSubtract = mapLSCF.begin()->second;
1113  // // Subtract the last cut flow from all of the others.
1114  // std::map<int, TH1F>::iterator cf = mapLSCF.begin();
1115  // // Start on second entry
1116  // for (; cf != mapLSCF.end(); ++cf) {
1117  // cf->second.Add(&cutFlowToSubtract, -1);
1118  // }
1119  // theBeamFitter->subtractFromCutFlow(&cutFlowToSubtract);
1120  // // Remove the obsolete lumi section
1121  // mapLSCF.erase(mapLSCF.begin());
1122  // }
1123 
1124  if (resetHistos_) {
1125  h_d0_phi0->Reset();
1126  h_vx_vy->Reset();
1127  h_vx_dz->Reset();
1128  h_vy_dz->Reset();
1129  h_trk_z0->Reset();
1130  resetHistos_ = false;
1131  }
1132 
1133  if (StartAverage_)
1134  nthBSTrk_ = PreviousRecords; //after average proccess is ON//for 2-6 LS fit PreviousRecords is size from 2-5 LS
1135 
1136  edm::LogInfo("FakeBeamMonitor") << " The Previous Recored for this fit is =" << nthBSTrk_ << endl;
1137 
1138  // unsigned int itrk = 0;
1139  // for (vector<BSTrkParameters>::const_iterator BSTrk = theBSvector.begin(); BSTrk != theBSvector.end();
1140  // ++BSTrk, ++itrk) {
1141  // if (itrk >= nthBSTrk_) { //fill for this record only !!
1142  // h_d0_phi0->Fill(BSTrk->phi0(), BSTrk->d0());
1143  // double vx = BSTrk->vx();
1144  // double vy = BSTrk->vy();
1145  // double z0 = BSTrk->z0();
1146  // h_vx_vy->Fill(vx, vy);
1147  // h_vx_dz->Fill(z0, vx);
1148  // h_vy_dz->Fill(z0, vy);
1149  // h_trk_z0->Fill(z0);
1150  // }
1151  // }
1152 
1153  // nthBSTrk_ = theBSvector.size(); // keep track of num of tracks filled so far
1154 
1155  edm::LogInfo("FakeBeamMonitor") << " The Current Recored for this fit is =" << nthBSTrk_ << endl;
1156 
1157  // if (countFitting)
1158  // edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: Num of tracks collected = " << nthBSTrk_ << endl;
1159 
1160  if (fitNLumi_ > 0) {
1161  if (onlineMode_) {
1162  if (currentlumi % fitNLumi_ != 0) {
1163  // for (std::map<TString,MonitorElement*>::iterator itAll = hs.begin();
1164  // itAll != hs.end(); ++itAll) {
1165  // if ((*itAll).first.Contains("all")) {
1166  // (*itAll).second->setBinContent(currentlumi,0.);
1167  // (*itAll).second->setBinError(currentlumi,0.);
1168  // }
1169  // }
1170  return;
1171  }
1172  } else if (countLumi_ % fitNLumi_ != 0)
1173  return;
1174  }
1175 
1176  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: [DebugTime] refBStime[0] = " << refBStime[0]
1177  << "; address = " << &refBStime[0] << std::endl;
1178  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: [DebugTime] refBStime[1] = " << refBStime[1]
1179  << "; address = " << &refBStime[1] << std::endl;
1180 
1181  //Fill for all LS even if fit fails
1182  // h_nVtx_lumi->ShiftFillLast((theBeamFitter->getPVvectorSize()), 0., fitNLumi_);
1183  // h_nVtx_lumi_all->setBinContent(currentlumi, (theBeamFitter->getPVvectorSize()));
1184 
1185  // if (countFitting) {
1186  nFits_++;
1187  // std::pair<int, int> fitLS = theBeamFitter->getFitLSRange();
1188  std::pair<int, int> fitLS(beginLumiOfBSFit_, endLumiOfBSFit_);
1189  // edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamFitter] Do BeamSpot Fit for LS = " << fitLS.first << " to "
1190  // << fitLS.second << std::endl;
1191  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: [FakeBeamMonitor] Do BeamSpot Fit for LS = " << beginLumiOfBSFit_
1192  << " to " << endLumiOfBSFit_ << std::endl;
1193 
1194  //Now Run the PV and Track Fitter over the collected tracks and pvs
1195  // if (theBeamFitter->runPVandTrkFitter()) {
1196  // reco::BeamSpot bs = theBeamFitter->getBeamSpot();
1197 
1198  //Create fake BS here
1200  for (int j = 0; j < 7; ++j) {
1201  for (int k = j; k < 7; ++k) {
1202  matrix(j, k) = 0;
1203  }
1204  }
1205 
1206  // random values for fake BeamSpot
1207  float tmp_BSx = rndm_->Gaus(0.1, 0.1); // [cm]
1208  float tmp_BSy = rndm_->Gaus(0.1, 0.1); // [cm]
1209  float tmp_BSz = rndm_->Gaus(0.1, 0.1); // [cm]
1210  float tmp_BSwidthX = rndm_->Gaus(0.001, 0.0005); // [cm]
1211  float tmp_BSwidthY = rndm_->Gaus(0.001, 0.0005); // [cm]
1212  float tmp_BSwidthZ = rndm_->Gaus(3.5, 0.5); // [cm]
1213 
1214  reco::BeamSpot bs(reco::BeamSpot::Point(tmp_BSx, tmp_BSy, tmp_BSz),
1215  tmp_BSwidthZ,
1216  0,
1217  0,
1218  tmp_BSwidthX,
1219  matrix,
1221  bs.setBeamWidthY(tmp_BSwidthY);
1222 
1223  if (bs.type() > 0) // with good beamwidth fit
1224  preBS = bs; // cache good fit results
1225 
1226  edm::LogInfo("FakeBeamMonitor") << "\n RESULTS OF DEFAULT FIT:" << endl;
1227  edm::LogInfo("FakeBeamMonitor") << bs << endl;
1228  edm::LogInfo("FakeBeamMonitor") << "[BeamFitter] fitting done \n" << endl;
1229 
1230  hs[k_x0_lumi]->ShiftFillLast(bs.x0(), bs.x0Error(), fitNLumi_);
1231  hs[k_y0_lumi]->ShiftFillLast(bs.y0(), bs.y0Error(), fitNLumi_);
1232  hs[k_z0_lumi]->ShiftFillLast(bs.z0(), bs.z0Error(), fitNLumi_);
1233  hs[k_sigmaX0_lumi]->ShiftFillLast(bs.BeamWidthX(), bs.BeamWidthXError(), fitNLumi_);
1234  hs[k_sigmaY0_lumi]->ShiftFillLast(bs.BeamWidthY(), bs.BeamWidthYError(), fitNLumi_);
1235  hs[k_sigmaZ0_lumi]->ShiftFillLast(bs.sigmaZ(), bs.sigmaZ0Error(), fitNLumi_);
1236  hs[k_x0_lumi_all]->setBinContent(currentlumi, bs.x0());
1237  hs[k_x0_lumi_all]->setBinError(currentlumi, bs.x0Error());
1238  hs[k_y0_lumi_all]->setBinContent(currentlumi, bs.y0());
1239  hs[k_y0_lumi_all]->setBinError(currentlumi, bs.y0Error());
1240  hs[k_z0_lumi_all]->setBinContent(currentlumi, bs.z0());
1241  hs[k_z0_lumi_all]->setBinError(currentlumi, bs.z0Error());
1242  hs[k_sigmaX0_lumi_all]->setBinContent(currentlumi, bs.BeamWidthX());
1243  hs[k_sigmaX0_lumi_all]->setBinError(currentlumi, bs.BeamWidthXError());
1244  hs[k_sigmaY0_lumi_all]->setBinContent(currentlumi, bs.BeamWidthY());
1245  hs[k_sigmaY0_lumi_all]->setBinError(currentlumi, bs.BeamWidthYError());
1246  hs[k_sigmaZ0_lumi_all]->setBinContent(currentlumi, bs.sigmaZ());
1247  hs[k_sigmaZ0_lumi_all]->setBinError(currentlumi, bs.sigmaZ0Error());
1248 
1249  int nthBin = tmpTime - refTime;
1250  if (nthBin > 0) {
1251  hs[k_x0_time]->setBinContent(nthBin, bs.x0());
1252  hs[k_y0_time]->setBinContent(nthBin, bs.y0());
1253  hs[k_z0_time]->setBinContent(nthBin, bs.z0());
1254  hs[k_sigmaX0_time]->setBinContent(nthBin, bs.BeamWidthX());
1255  hs[k_sigmaY0_time]->setBinContent(nthBin, bs.BeamWidthY());
1256  hs[k_sigmaZ0_time]->setBinContent(nthBin, bs.sigmaZ());
1257  hs[k_x0_time]->setBinError(nthBin, bs.x0Error());
1258  hs[k_y0_time]->setBinError(nthBin, bs.y0Error());
1259  hs[k_z0_time]->setBinError(nthBin, bs.z0Error());
1260  hs[k_sigmaX0_time]->setBinError(nthBin, bs.BeamWidthXError());
1261  hs[k_sigmaY0_time]->setBinError(nthBin, bs.BeamWidthYError());
1262  hs[k_sigmaZ0_time]->setBinError(nthBin, bs.sigmaZ0Error());
1263  }
1264 
1265  int jthBin = tmpTime - startTime;
1266  if (jthBin > 0) {
1267  hs[k_x0_time_all]->setBinContent(jthBin, bs.x0());
1268  hs[k_y0_time_all]->setBinContent(jthBin, bs.y0());
1269  hs[k_z0_time_all]->setBinContent(jthBin, bs.z0());
1270  hs[k_sigmaX0_time_all]->setBinContent(jthBin, bs.BeamWidthX());
1271  hs[k_sigmaY0_time_all]->setBinContent(jthBin, bs.BeamWidthY());
1272  hs[k_sigmaZ0_time_all]->setBinContent(jthBin, bs.sigmaZ());
1273  hs[k_x0_time_all]->setBinError(jthBin, bs.x0Error());
1274  hs[k_y0_time_all]->setBinError(jthBin, bs.y0Error());
1275  hs[k_z0_time_all]->setBinError(jthBin, bs.z0Error());
1276  hs[k_sigmaX0_time_all]->setBinError(jthBin, bs.BeamWidthXError());
1277  hs[k_sigmaY0_time_all]->setBinError(jthBin, bs.BeamWidthYError());
1278  hs[k_sigmaZ0_time_all]->setBinError(jthBin, bs.sigmaZ0Error());
1279  }
1280 
1281  h_x0->Fill(bs.x0());
1282  h_y0->Fill(bs.y0());
1283  h_z0->Fill(bs.z0());
1284  if (bs.type() > 0) { // with good beamwidth fit
1285  h_sigmaX0->Fill(bs.BeamWidthX());
1286  h_sigmaY0->Fill(bs.BeamWidthY());
1287  }
1288  h_sigmaZ0->Fill(bs.sigmaZ());
1289 
1290  if (nthBSTrk_ >= 2 * min_Ntrks_) {
1291  double amp = std::sqrt(bs.x0() * bs.x0() + bs.y0() * bs.y0());
1292  double alpha = std::atan2(bs.y0(), bs.x0());
1293  std::unique_ptr<TF1> f1{new TF1("f1", "[0]*sin(x-[1])", -3.14, 3.14)};
1294  f1->SetParameters(amp, alpha);
1295  f1->SetParLimits(0, amp - 0.1, amp + 0.1);
1296  f1->SetParLimits(1, alpha - 0.577, alpha + 0.577);
1297  f1->SetLineColor(4);
1298  h_d0_phi0->getTProfile()->Fit(f1.get(), "QR");
1299 
1300  double mean = bs.z0();
1301  double width = bs.sigmaZ();
1302  std::unique_ptr<TF1> fgaus{new TF1("fgaus", "gaus")};
1303  fgaus->SetParameters(mean, width);
1304  fgaus->SetLineColor(4);
1305  h_trk_z0->getTH1()->Fit(fgaus.get(), "QLRM", "", mean - 3 * width, mean + 3 * width);
1306  }
1307 
1308  fitResults->Reset();
1309  std::pair<int, int> LSRange(beginLumiOfBSFit_, endLumiOfBSFit_); //= theBeamFitter->getFitLSRange();
1310  char tmpTitle[50];
1311  sprintf(tmpTitle, "%s %i %s %i", "Fitted Beam Spot (cm) of LS: ", LSRange.first, " to ", LSRange.second);
1312  fitResults->setAxisTitle(tmpTitle, 1);
1313  fitResults->setBinContent(1, 8, bs.x0());
1314  fitResults->setBinContent(1, 7, bs.y0());
1315  fitResults->setBinContent(1, 6, bs.z0());
1316  fitResults->setBinContent(1, 5, bs.sigmaZ());
1317  fitResults->setBinContent(1, 4, bs.dxdz());
1318  fitResults->setBinContent(1, 3, bs.dydz());
1319  if (bs.type() > 0) { // with good beamwidth fit
1320  fitResults->setBinContent(1, 2, bs.BeamWidthX());
1321  fitResults->setBinContent(1, 1, bs.BeamWidthY());
1322  } else { // fill cached widths
1325  }
1326 
1327  fitResults->setBinContent(2, 8, bs.x0Error());
1328  fitResults->setBinContent(2, 7, bs.y0Error());
1329  fitResults->setBinContent(2, 6, bs.z0Error());
1330  fitResults->setBinContent(2, 5, bs.sigmaZ0Error());
1331  fitResults->setBinContent(2, 4, bs.dxdzError());
1332  fitResults->setBinContent(2, 3, bs.dydzError());
1333  if (bs.type() > 0) { // with good beamwidth fit
1334  fitResults->setBinContent(2, 2, bs.BeamWidthXError());
1335  fitResults->setBinContent(2, 1, bs.BeamWidthYError());
1336  } else { // fill cached width errors
1339  }
1340 
1341  // count good fit
1342  // if (std::fabs(refBS.x0()-bs.x0())/bs.x0Error() < deltaSigCut_) { // disabled temporarily
1343  summaryContent_[0] += 1.;
1344  // }
1345  // if (std::fabs(refBS.y0()-bs.y0())/bs.y0Error() < deltaSigCut_) { // disabled temporarily
1346  summaryContent_[1] += 1.;
1347  // }
1348  // if (std::fabs(refBS.z0()-bs.z0())/bs.z0Error() < deltaSigCut_) { // disabled temporarily
1349  summaryContent_[2] += 1.;
1350  // }
1351 
1352  // Create the BeamSpotOnlineObjects object
1353  BeamSpotOnlineObjects* BSOnline = new BeamSpotOnlineObjects();
1354  BSOnline->SetLastAnalyzedLumi(fitLS.second);
1355  BSOnline->SetLastAnalyzedRun(frun);
1356  BSOnline->SetLastAnalyzedFill(0); // To be updated with correct LHC Fill number
1357  BSOnline->SetPosition(bs.x0(), bs.y0(), bs.z0());
1358  BSOnline->SetSigmaZ(bs.sigmaZ());
1359  BSOnline->SetBeamWidthX(bs.BeamWidthX());
1360  BSOnline->SetBeamWidthY(bs.BeamWidthY());
1361  BSOnline->SetBeamWidthXError(bs.BeamWidthXError());
1362  BSOnline->SetBeamWidthYError(bs.BeamWidthYError());
1363  BSOnline->Setdxdz(bs.dxdz());
1364  BSOnline->Setdydz(bs.dydz());
1365  BSOnline->SetType(bs.type());
1366  BSOnline->SetEmittanceX(bs.emittanceX());
1367  BSOnline->SetEmittanceY(bs.emittanceY());
1368  BSOnline->SetBetaStar(bs.betaStar());
1369  for (int i = 0; i < 7; ++i) {
1370  for (int j = 0; j < 7; ++j) {
1371  BSOnline->SetCovariance(i, j, bs.covariance(i, j));
1372  }
1373  }
1374  // BSOnline->SetNumTracks(theBeamFitter->getNTracks());
1375  // BSOnline->SetNumPVs(theBeamFitter->getNPVs());
1376  BSOnline->SetNumTracks(50);
1377  BSOnline->SetNumPVs(10);
1378 
1379  edm::LogInfo("FakeBeamMonitor") << "FitAndFill::[PayloadCreation] BeamSpotOnline object created: \n" << std::endl;
1380  edm::LogInfo("FakeBeamMonitor") << *BSOnline << std::endl;
1381  //std::cout << "------------------> fitted BS: " << *BSOnline << std::endl;
1382 
1383  // Create the payload for BeamSpotOnlineObjects object
1385  if (onlineDbService.isAvailable()) {
1386  edm::LogInfo("FakeBeamMonitor") << "FitAndFill::[PayloadCreation] onlineDbService available \n" << std::endl;
1387  BSOnline->SetCreationTime(onlineDbService->currentTime());
1388  onlineDbService->writeForNextLumisection(BSOnline, recordName_);
1389  }
1390  edm::LogInfo("FakeBeamMonitor") << "FitAndFill::[PayloadCreation] BeamSpotOnline payload created \n" << std::endl;
1391 
1392  // } //if (theBeamFitter->runPVandTrkFitter())
1393  // else { // beam fit fails
1394  // reco::BeamSpot bs = theBeamFitter->getBeamSpot();
1395  // edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] Beam fit fails!!! \n" << endl;
1396  // edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] Output beam spot for DIP \n" << endl;
1397  // edm::LogInfo("BeamMonitor") << bs << endl;
1398  //
1399  // hs[k_sigmaX0_lumi]->ShiftFillLast(bs.BeamWidthX(), bs.BeamWidthXError(), fitNLumi_);
1400  // hs[k_sigmaY0_lumi]->ShiftFillLast(bs.BeamWidthY(), bs.BeamWidthYError(), fitNLumi_);
1401  // hs[k_sigmaZ0_lumi]->ShiftFillLast(bs.sigmaZ(), bs.sigmaZ0Error(), fitNLumi_);
1402  // hs[k_x0_lumi]->ShiftFillLast(bs.x0(), bs.x0Error(), fitNLumi_);
1403  // hs[k_y0_lumi]->ShiftFillLast(bs.y0(), bs.y0Error(), fitNLumi_);
1404  // hs[k_z0_lumi]->ShiftFillLast(bs.z0(), bs.z0Error(), fitNLumi_);
1405  // } // end of beam fit fails
1406 
1407  // } //-------- end of countFitting------------------------------------------
1408  // else { // no fit
1409  // // Overwrite Fit LS and fit time when no event processed or no track selected
1410  // theBeamFitter->setFitLSRange(beginLumiOfBSFit_, endLumiOfBSFit_);
1411  // theBeamFitter->setRefTime(refBStime[0], refBStime[1]);
1412  // if (theBeamFitter->runPVandTrkFitter()) {
1413  // } // Dump fake beam spot for DIP
1414  // reco::BeamSpot bs = theBeamFitter->getBeamSpot();
1415  // edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] No fitting \n" << endl;
1416  // edm::LogInfo("BeamMonitor") << "FitAndFill:: [BeamMonitor] Output fake beam spot for DIP \n" << endl;
1417  // edm::LogInfo("BeamMonitor") << bs << endl;
1418  //
1419  // hs[k_sigmaX0_lumi]->ShiftFillLast(bs.BeamWidthX(), bs.BeamWidthXError(), fitNLumi_);
1420  // hs[k_sigmaY0_lumi]->ShiftFillLast(bs.BeamWidthY(), bs.BeamWidthYError(), fitNLumi_);
1421  // hs[k_sigmaZ0_lumi]->ShiftFillLast(bs.sigmaZ(), bs.sigmaZ0Error(), fitNLumi_);
1422  // hs[k_x0_lumi]->ShiftFillLast(bs.x0(), bs.x0Error(), fitNLumi_);
1423  // hs[k_y0_lumi]->ShiftFillLast(bs.y0(), bs.y0Error(), fitNLumi_);
1424  // hs[k_z0_lumi]->ShiftFillLast(bs.z0(), bs.z0Error(), fitNLumi_);
1425  // }
1426 
1427  // Fill summary report
1428  // if (countFitting) {
1429  for (int n = 0; n < nFitElements_; n++) {
1431  }
1432 
1433  summarySum_ = 0;
1434  for (int ii = 0; ii < nFitElements_; ii++) {
1436  }
1438  if (reportSummary)
1440 
1441  for (int bi = 0; bi < nFitElements_; bi++) {
1442  reportSummaryMap->setBinContent(1, bi + 1, summaryContent_[bi] / (float)nFits_);
1443  }
1444  // }
1445 
1446  if ((resetFitNLumi_ > 0 &&
1447  ((onlineMode_ &&
1448  countLumi_ == resetFitNLumi_) || //OR it should be currentLumi_ (if in sequence then does not mattar)
1449  (!onlineMode_ && countLumi_ == resetFitNLumi_))) ||
1450  (StartAverage_)) {
1451  edm::LogInfo("FakeBeamMonitor") << "FitAndFill:: The flag is ON for running average Beam Spot fit" << endl;
1452  StartAverage_ = true;
1453  firstAverageFit_++;
1454  resetHistos_ = true;
1455  nthBSTrk_ = 0;
1456  beginLumiOfBSFit_ = 0;
1457  refBStime[0] = 0;
1458  }
1459 }
1460 
1461 //--------------------------------------------------------
1463  if (debug_)
1464  edm::LogInfo("FakeBeamMonitor")
1465  << " RestartingFitting:: Restart Beami everything to a fresh start !!! because Gap is > 10 LS" << endl;
1466  //track based fit reset here
1467  resetHistos_ = true;
1468  nthBSTrk_ = 0;
1469  // theBeamFitter->resetTrkVector();
1470  // theBeamFitter->resetLSRange();
1471  // theBeamFitter->resetRefTime();
1472  // theBeamFitter->resetPVFitter();
1473  // theBeamFitter->resetCutFlow();
1474  beginLumiOfBSFit_ = 0;
1475  refBStime[0] = 0;
1476  //pv based fit iis reset here
1477  h_PVx[0]->Reset();
1478  h_PVy[0]->Reset();
1479  h_PVz[0]->Reset();
1480  beginLumiOfPVFit_ = 0;
1481  refPVtime[0] = 0;
1482  //Clear all the Maps here
1483  mapPVx.clear();
1484  mapPVy.clear();
1485  mapPVz.clear();
1486  mapNPV.clear();
1487  mapBeginBSLS.clear();
1488  mapBeginPVLS.clear();
1489  mapBeginBSTime.clear();
1490  mapBeginPVTime.clear();
1491  mapLSBSTrkSize.clear();
1492  mapLSPVStoreSize.clear();
1493  mapLSCF.clear();
1494  countGapLumi_ = 0;
1495  countLumi_ = 0;
1496  StartAverage_ = false;
1497 }
1498 
1499 //-------------------------------------------------------
1500 void FakeBeamMonitor::dqmEndRun(const Run& r, const EventSetup& context) {
1501  if (debug_)
1502  edm::LogInfo("FakeBeamMonitor") << "dqmEndRun:: Clearing all the Maps " << endl;
1503  //Clear all the Maps here
1504  mapPVx.clear();
1505  mapPVy.clear();
1506  mapPVz.clear();
1507  mapNPV.clear();
1508  mapBeginBSLS.clear();
1509  mapBeginPVLS.clear();
1510  mapBeginBSTime.clear();
1511  mapBeginPVTime.clear();
1512  mapLSBSTrkSize.clear();
1513  mapLSPVStoreSize.clear();
1514  mapLSCF.clear();
1515 }
1516 
1517 //--------------------------------------------------------
1518 void FakeBeamMonitor::scrollTH1(TH1* h, time_t ref) {
1519  char offsetTime[64];
1520  formatFitTime(offsetTime, ref);
1521  TDatime da(offsetTime);
1522  if (lastNZbin > 0) {
1523  double val = h->GetBinContent(lastNZbin);
1524  double valErr = h->GetBinError(lastNZbin);
1525  h->Reset();
1526  h->GetXaxis()->SetTimeOffset(da.Convert(kTRUE));
1527  int bin = (lastNZbin > buffTime ? buffTime : 1);
1528  h->SetBinContent(bin, val);
1529  h->SetBinError(bin, valErr);
1530  } else {
1531  h->Reset();
1532  h->GetXaxis()->SetTimeOffset(da.Convert(kTRUE));
1533  }
1534 }
1535 
1536 //--------------------------------------------------------
1537 // Method to check whether to chane histogram time offset (forward only)
1538 bool FakeBeamMonitor::testScroll(time_t& tmpTime_, time_t& refTime_) {
1539  bool scroll_ = false;
1540  if (tmpTime_ - refTime_ >= intervalInSec_) {
1541  scroll_ = true;
1542  edm::LogInfo("FakeBeamMonitor") << "testScroll:: Reset Time Offset" << std::endl;
1544  for (int bin = intervalInSec_; bin >= 1; bin--) {
1545  if (hs[k_x0_time]->getBinContent(bin) > 0) {
1546  lastNZbin = bin;
1547  break;
1548  }
1549  }
1550  edm::LogInfo("FakeBeamMonitor") << "testScroll:: Last non zero bin = " << lastNZbin << std::endl;
1551  if (tmpTime_ - refTime_ >= intervalInSec_ + lastNZbin) {
1552  edm::LogInfo("FakeBeamMonitor") << "testScroll:: Time difference too large since last readout" << std::endl;
1553  lastNZbin = 0;
1554  refTime_ = tmpTime_ - buffTime;
1555  } else {
1556  edm::LogInfo("FakeBeamMonitor") << "testScroll:: Offset to last record" << std::endl;
1557  int offset = ((lastNZbin > buffTime) ? (lastNZbin - buffTime) : (lastNZbin - 1));
1558  refTime_ += offset;
1559  }
1560  }
1561  return scroll_;
1562 }
1563 
1565 
1566 // Local Variables:
1567 // show-trailing-whitespace: t
1568 // truncate-lines: t
1569 // End:
FakeBeamMonitor::h_z0
MonitorElement * h_z0
Definition: FakeBeamMonitor.h:130
FakeBeamMonitor::rndm_
TRandom3 * rndm_
Definition: FakeBeamMonitor.h:175
FakeBeamMonitor::refTime
std::time_t refTime
Definition: FakeBeamMonitor.h:169
FakeBeamMonitor::phiMax_
const double phiMax_
Definition: FakeBeamMonitor.h:67
FakeBeamMonitor::mapPVz
std::map< int, std::vector< float > > mapPVz
Definition: FakeBeamMonitor.h:145
FakeBeamMonitor::nFitElements_
int nFitElements_
Definition: FakeBeamMonitor.h:94
FakeBeamMonitor::reportSummaryContents
MonitorElement * reportSummaryContents[3]
Definition: FakeBeamMonitor.h:161
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
FakeBeamMonitor::cutFlowTable
MonitorElement * cutFlowTable
Definition: FakeBeamMonitor.h:163
FakeBeamMonitor::h_vy_dz
MonitorElement * h_vy_dz
Definition: FakeBeamMonitor.h:124
mps_fire.i
i
Definition: mps_fire.py:355
FakeBeamMonitor::mapLSCF
std::map< int, TH1F > mapLSCF
Definition: FakeBeamMonitor.h:154
FakeBeamMonitor::dxMin_
const double dxMin_
Definition: FakeBeamMonitor.h:58
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:141
cond::service::OnlineDBOutputService::writeForNextLumisection
bool writeForNextLumisection(const PayloadType *payload, const std::string &recordName)
Definition: OnlineDBOutputService.h:45
makeMuonMisalignmentScenario.matrix
list matrix
Definition: makeMuonMisalignmentScenario.py:141
TrackCandidateCollection.h
FakeBeamMonitor
Definition: FakeBeamMonitor.h:33
FakeBeamMonitor::FakeBeamMonitor
FakeBeamMonitor(const edm::ParameterSet &)
Definition: FakeBeamMonitor.cc:97
FakeBeamMonitor::h_PVy
MonitorElement * h_PVy[2]
Definition: FakeBeamMonitor.h:137
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:81
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:142
edm::LuminosityBlockBase::beginTime
Timestamp const & beginTime() const
Definition: LuminosityBlockBase.h:46
FakeBeamMonitor::scrollTH1
void scrollTH1(TH1 *, std::time_t)
Definition: FakeBeamMonitor.cc:1518
CEST
#define CEST
edm::LogInfo
Definition: MessageLogger.h:254
FakeBeamMonitor::firstAverageFit_
int firstAverageFit_
Definition: FakeBeamMonitor.h:105
FakeBeamMonitor::h_nVtx_lumi_all
MonitorElement * h_nVtx_lumi_all
Definition: FakeBeamMonitor.h:119
FakeBeamMonitor::mapLSPVStoreSize
std::map< int, size_t > mapLSPVStoreSize
Definition: FakeBeamMonitor.h:152
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:62
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:172
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:99
FakeBeamMonitor::h_vx_vy
MonitorElement * h_vx_vy
Definition: FakeBeamMonitor.h:122
FakeBeamMonitor::h_sigmaY0
MonitorElement * h_sigmaY0
Definition: FakeBeamMonitor.h:132
FakeBeamMonitor::h_vx_dz
MonitorElement * h_vx_dz
Definition: FakeBeamMonitor.h:123
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:129
FakeBeamMonitor::lastNZbin
int lastNZbin
Definition: FakeBeamMonitor.h:173
FakeBeamMonitor::endLuminosityBlock
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
Definition: FakeBeamMonitor.cc:772
end
#define end
Definition: vmac.h:39
FakeBeamMonitor::h_PVxz
MonitorElement * h_PVxz
Definition: FakeBeamMonitor.h:139
BeamSpotObjects::SetSigmaZ
void SetSigmaZ(double val)
set sigma Z, RMS bunch length
Definition: BeamSpotObjects.h:42
FakeBeamMonitor::dzBin_
const int dzBin_
Definition: FakeBeamMonitor.h:69
FakeBeamMonitor::fitPVNLumi_
int fitPVNLumi_
Definition: FakeBeamMonitor.h:76
FakeBeamMonitor::reportSummary
MonitorElement * reportSummary
Definition: FakeBeamMonitor.h:160
FakeBeamMonitor::nthBSTrk_
unsigned int nthBSTrk_
Definition: FakeBeamMonitor.h:93
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:70
FakeBeamMonitor::refBStime
std::time_t refBStime[2]
Definition: FakeBeamMonitor.h:91
FakeBeamMonitor::refPVtime
std::time_t refPVtime[2]
Definition: FakeBeamMonitor.h:92
FakeBeamMonitor::reportSummaryMap
MonitorElement * reportSummaryMap
Definition: FakeBeamMonitor.h:162
h
edm::LuminosityBlockBase::endTime
Timestamp const & endTime() const
Definition: LuminosityBlockBase.h:47
FakeBeamMonitor::nextlumi_
int nextlumi_
Definition: FakeBeamMonitor.h:90
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
FakeBeamMonitor::h_trkVz
MonitorElement * h_trkVz
Definition: FakeBeamMonitor.h:126
FakeBeamMonitor::debug_
bool debug_
Definition: FakeBeamMonitor.h:80
FakeBeamMonitor::monitorName_
std::string monitorName_
Definition: FakeBeamMonitor.h:72
FakeBeamMonitor::h_PVx
MonitorElement * h_PVx[2]
Definition: FakeBeamMonitor.h:136
Service.h
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:117
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
FakeBeamMonitor::h_sigmaZ0
MonitorElement * h_sigmaZ0
Definition: FakeBeamMonitor.h:133
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:128
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
dqmdumpme.k
k
Definition: dqmdumpme.py:60
FakeBeamMonitor::fitResults
MonitorElement * fitResults
Definition: FakeBeamMonitor.h:127
OrderedSet.t
t
Definition: OrderedSet.py:90
FakeBeamMonitor::deltaSigCut_
double deltaSigCut_
Definition: FakeBeamMonitor.h:96
FakeBeamMonitor::resetHistos_
bool resetHistos_
Definition: FakeBeamMonitor.h:103
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:106
FakeBeamMonitor::mapBeginPVTime
std::map< int, std::time_t > mapBeginPVTime
Definition: FakeBeamMonitor.h:149
FakeBeamMonitor::h_nVtx
MonitorElement * h_nVtx
Definition: FakeBeamMonitor.h:134
FakeBeamMonitor::testScroll
bool testScroll(std::time_t &, std::time_t &)
Definition: FakeBeamMonitor.cc:1538
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:149
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
FakeBeamMonitor::mapBeginBSLS
std::map< int, int > mapBeginBSLS
Definition: FakeBeamMonitor.h:148
FakeBeamMonitor::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: FakeBeamMonitor.cc:633
B2GTnPMonitor_cfi.histTitle
histTitle
Definition: B2GTnPMonitor_cfi.py:112
FakeBeamMonitor::resetFitNLumi_
int resetFitNLumi_
Definition: FakeBeamMonitor.h:77
FakeBeamMonitor::summarySum_
Float_t summarySum_
Definition: FakeBeamMonitor.h:158
FakeBeamMonitor::summaryContent_
Float_t summaryContent_[3]
Definition: FakeBeamMonitor.h:159
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:65
FakeBeamMonitor::beginLumiOfBSFit_
int beginLumiOfBSFit_
Definition: FakeBeamMonitor.h:85
FakeBeamMonitor::countEvt_
int countEvt_
Definition: FakeBeamMonitor.h:83
FakeBeamMonitor::reportSummary_
Float_t reportSummary_
Definition: FakeBeamMonitor.h:157
FakeBeamMonitor::h_d0_phi0
MonitorElement * h_d0_phi0
Definition: FakeBeamMonitor.h:120
edm::Service
Definition: Service.h:30
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:97
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:108
FakeBeamMonitor::h_trk_z0
MonitorElement * h_trk_z0
Definition: FakeBeamMonitor.h:121
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:63
dqm::impl::MonitorElement::getTProfile
virtual TProfile * getTProfile()
Definition: MonitorElement.cc:1016
FakeBeamMonitor::dzMax_
const double dzMax_
Definition: FakeBeamMonitor.h:71
FakeBeamMonitor::h_PVz
MonitorElement * h_PVz[2]
Definition: FakeBeamMonitor.h:138
FakeBeamMonitor::FitAndFill
void FitAndFill(const edm::LuminosityBlock &lumiSeg, int &, int &, int &)
Definition: FakeBeamMonitor.cc:785
FakeBeamMonitor::vxBin_
const int vxBin_
Definition: FakeBeamMonitor.h:61
FakeBeamMonitor::dxMax_
const double dxMax_
Definition: FakeBeamMonitor.h:59
reco::BeamSpot::BeamWidthYError
double BeamWidthYError() const
error on beam width Y, assume error in X = Y
Definition: BeamSpot.h:101
Hists
Hists
Definition: BeamMonitor.cc:166
FakeBeamMonitor::mapPVx
std::map< int, std::vector< float > > mapPVx
Definition: FakeBeamMonitor.h:145
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:66
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:1500
FakeBeamMonitor::countLumi_
int countLumi_
Definition: FakeBeamMonitor.h:84
FakeBeamMonitor::h_sigmaX0
MonitorElement * h_sigmaX0
Definition: FakeBeamMonitor.h:131
FakeBeamMonitor::StartAverage_
bool StartAverage_
Definition: FakeBeamMonitor.h:104
alignCSCRings.r
r
Definition: alignCSCRings.py:93
FakeBeamMonitor::ftimestamp
edm::TimeValue_t ftimestamp
Definition: FakeBeamMonitor.h:170
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
FakeBeamMonitor::recordName_
std::string recordName_
Definition: FakeBeamMonitor.h:73
FakeBeamMonitor::dxBin_
const int dxBin_
Definition: FakeBeamMonitor.h:57
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
FakeBeamMonitor::minVtxNdf_
double minVtxNdf_
Definition: FakeBeamMonitor.h:100
FakeBeamMonitor::mapLSBSTrkSize
std::map< int, std::size_t > mapLSBSTrkSize
Definition: FakeBeamMonitor.h:151
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:114
FakeBeamMonitor::h_nVtx_st
MonitorElement * h_nVtx_st
Definition: FakeBeamMonitor.h:135
FakeBeamMonitor::h_PVyz
MonitorElement * h_PVyz
Definition: FakeBeamMonitor.h:140
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
OnlineDBOutputService.h
FakeBeamMonitor::mapBeginPVLS
std::map< int, int > mapBeginPVLS
Definition: FakeBeamMonitor.h:148
BeamSpotOnlineObjects::SetLastAnalyzedLumi
void SetLastAnalyzedLumi(int val)
Setters Methods.
Definition: BeamSpotOnlineObjects.h:44
BeamSpotOnlineObjects
Definition: BeamSpotOnlineObjects.h:25
FakeBeamMonitor::~FakeBeamMonitor
~FakeBeamMonitor() override
Definition: FakeBeamMonitor.cc:95
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:118
FakeBeamMonitor::mapNPV
std::map< int, std::vector< int > > mapNPV
Definition: FakeBeamMonitor.h:146
AlcaSiPixelAliHarvester0T_cff.options
options
Definition: AlcaSiPixelAliHarvester0T_cff.py:42
FakeBeamMonitor::minVtxWgt_
double minVtxWgt_
Definition: FakeBeamMonitor.h:101
FakeBeamMonitor::nFits_
int nFits_
Definition: FakeBeamMonitor.h:95
FakeBeamMonitor::mapPVy
std::map< int, std::vector< float > > mapPVy
Definition: FakeBeamMonitor.h:145
FakeBeamMonitor::maxZ_
double maxZ_
Definition: FakeBeamMonitor.h:98
FakeBeamMonitor::lastlumi_
int lastlumi_
Definition: FakeBeamMonitor.h:89
FakeBeamMonitor::h_trkPt
MonitorElement * h_trkPt
Definition: FakeBeamMonitor.h:125
FakeBeamMonitor::endLumiOfBSFit_
int endLumiOfBSFit_
Definition: FakeBeamMonitor.h:86
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:167
BSFitter.h
ntuplemaker.time
time
Definition: ntuplemaker.py:310
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
edm::Event
Definition: Event.h:73
FakeBeamMonitor::intervalInSec_
int intervalInSec_
Definition: FakeBeamMonitor.h:79
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:78
cond::service::PoolDBOutputService::currentTime
cond::Time_t currentTime() const
Definition: PoolDBOutputService.cc:179
FakeBeamMonitor::endLumiOfPVFit_
int endLumiOfPVFit_
Definition: FakeBeamMonitor.h:88
FakeBeamMonitor::RestartFitting
void RestartFitting()
Definition: FakeBeamMonitor.cc:1462
FakeBeamMonitor::beginLumiOfPVFit_
int beginLumiOfPVFit_
Definition: FakeBeamMonitor.h:87
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:168
BeamSpotOnlineObjects::SetNumPVs
void SetNumPVs(int val)
Definition: BeamSpotOnlineObjects.cc:63
FakeBeamMonitor::fitNLumi_
int fitNLumi_
Definition: FakeBeamMonitor.h:75
hgcalPlots.ytitle
ytitle
Definition: hgcalPlots.py:1410