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