CMS 3D CMS Logo

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