CMS 3D CMS Logo

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