CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Attributes
L1TOccupancyClientHistogramService Class Reference

#include <L1TOccupancyClientHistogramService.h>

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 

Public Member Functions

TH2F * getDifferentialHistogram (std::string test)
 
std::vector< int > getLSCertification (std::string iHistName)
 
std::vector< std::pair< int,
int > > 
getMaskedBins (std::string test)
 
unsigned int getNBinsHistogram (std::string test)
 
unsigned int getNBinsMasked (std::string test)
 
TH2F * getRebinnedHistogram (DQMStore::IGetter &igetter, std::string iHistName, std::string iHistLocation)
 
bool isMasked (std::string test, int x, int y)
 
bool isStripMasked (std::string test, int binStrip, int axis)
 
 L1TOccupancyClientHistogramService ()
 
 L1TOccupancyClientHistogramService (const edm::ParameterSet &iParameters, DQMStore::IBooker &ibooker, bool iVerbose)
 
TH2F * loadHisto (DQMStore::IGetter &igetter, std::string test, std::string histo)
 
int maskBins (std::string test, TH2F *histo, int strip, int axis)
 
void resetHisto (std::string test)
 
void setMaskedBins (std::string test, const std::vector< edm::ParameterSet > &mask)
 
void updateHistogramEndLS (DQMStore::IGetter &igetter, std::string test, std::string histo, int iLS)
 
void updateHistogramEndRun (std::string iHistName)
 

Private Attributes

std::map< std::string, TH2F * > mHistDiffMinus1
 
std::map< std::string,
std::pair< TH2F *, TH2F * > > 
mHistograms
 
std::map< std::string, bool > mHistValid
 
std::map< std::string,
std::vector< int > > 
mLSListDiff
 
std::map< std::string,
std::vector< int > > 
mLSListDiffMinus1
 
std::map< std::string,
std::vector< std::pair< int,
int > > * > 
mMaskedBins
 
edm::ParameterSet mParameters
 
bool mVerbose
 

Detailed Description

Definition at line 22 of file L1TOccupancyClientHistogramService.h.

Member Typedef Documentation

Definition at line 24 of file L1TOccupancyClientHistogramService.h.

Definition at line 25 of file L1TOccupancyClientHistogramService.h.

Constructor & Destructor Documentation

L1TOccupancyClientHistogramService::L1TOccupancyClientHistogramService ( )

Definition at line 18 of file L1TOccupancyClientHistogramService.cc.

18 {}
L1TOccupancyClientHistogramService::L1TOccupancyClientHistogramService ( const edm::ParameterSet iParameters,
DQMStore::IBooker ibooker,
bool  iVerbose 
)

Definition at line 28 of file L1TOccupancyClientHistogramService.cc.

References reco::mVerbose().

30  {
31  //mDBE = iDBE;
32  mVerbose = iVerbose;
33  mParameters = iParameters;
34 }

Member Function Documentation

TH2F * L1TOccupancyClientHistogramService::getDifferentialHistogram ( std::string  test)

Definition at line 449 of file L1TOccupancyClientHistogramService.cc.

449  {
450  if (mHistValid[iHistName]) {
451  return mHistograms[iHistName].second;
452  }
453  return nullptr;
454 }
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
vector< int > L1TOccupancyClientHistogramService::getLSCertification ( std::string  iHistName)

Definition at line 439 of file L1TOccupancyClientHistogramService.cc.

439 { return mLSListDiff[iHistName]; }
std::map< std::string, std::vector< int > > mLSListDiff
vector< pair< int, int > > L1TOccupancyClientHistogramService::getMaskedBins ( std::string  test)

Definition at line 163 of file L1TOccupancyClientHistogramService.cc.

163  {
164  return (*mMaskedBins[iHistName]);
165 }
std::map< std::string, std::vector< std::pair< int, int > > * > mMaskedBins
unsigned int L1TOccupancyClientHistogramService::getNBinsHistogram ( std::string  test)

Definition at line 45 of file L1TOccupancyClientHistogramService.cc.

45  {
46  TH2F* pHistogram = getDifferentialHistogram(iHistName);
47  int nBinsX = pHistogram->GetNbinsX();
48  int nBinsY = pHistogram->GetNbinsY();
49  int nMasked = getNBinsMasked(iHistName);
50  unsigned int nBinsActive = (nBinsX * nBinsY) - nMasked;
51 
52  return nBinsActive;
53 }
unsigned int L1TOccupancyClientHistogramService::getNBinsMasked ( std::string  test)

Definition at line 175 of file L1TOccupancyClientHistogramService.cc.

175  {
176  return mMaskedBins[iHistName]->size();
177 }
std::map< std::string, std::vector< std::pair< int, int > > * > mMaskedBins
TH2F * L1TOccupancyClientHistogramService::getRebinnedHistogram ( DQMStore::IGetter igetter,
std::string  iHistName,
std::string  iHistLocation 
)

Definition at line 327 of file L1TOccupancyClientHistogramService.cc.

References dqm::implementation::IGetter::get(), edm::ParameterSet::getParameter(), dqm::legacy::MonitorElement::getTH2F(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, and hlt_dqm_clientPB-live_cfg::me.

329  {
330  MonitorElement* me = igetter.get(iHistLocation);
331 
332  TH2F* histMonitor;
333 
334  if (!me) {
335  histMonitor = nullptr;
336  mHistValid[iHistName] = false;
337  } else {
338  mHistValid[iHistName] = true;
339  histMonitor = new TH2F(*(igetter.get(iHistLocation)->getTH2F()));
340 
341  // Default rebin factors
342  int rebinFactorX = 1;
343  int rebinFactorY = 1;
344 
345  vector<ParameterSet> testParameters = mParameters.getParameter<vector<ParameterSet> >("testParams");
346  for (unsigned int i = 0; i < testParameters.size(); i++) {
347  if (testParameters[i].getParameter<string>("testName") == iHistName) {
348  ParameterSet algoParameters = testParameters[i].getParameter<ParameterSet>("algoParams");
349  rebinFactorX = algoParameters.getUntrackedParameter<int>("rebinFactorX", 1);
350  rebinFactorY = algoParameters.getUntrackedParameter<int>("rebinFactorY", 1);
351  break;
352  }
353  }
354 
355  // Rebinning
356  if (rebinFactorX != 1) {
357  histMonitor->RebinY(rebinFactorX);
358  }
359  if (rebinFactorY != 1) {
360  histMonitor->RebinY(rebinFactorY);
361  }
362  }
363 
364  return histMonitor;
365 }
T getUntrackedParameter(std::string const &, T const &) const
virtual TH2F * getTH2F() const
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool L1TOccupancyClientHistogramService::isMasked ( std::string  test,
int  x,
int  y 
)

Definition at line 232 of file L1TOccupancyClientHistogramService.cc.

References mps_fire::i.

232  {
233  vector<pair<int, int> >* thisHistMaskedBins = mMaskedBins[iHistName];
234 
235  bool binIsMasked = false;
236 
237  for (unsigned int i = 0; i < thisHistMaskedBins->size(); i++) {
238  if ((*thisHistMaskedBins)[i].first == iBinX && (*thisHistMaskedBins)[i].second == iBinY) {
239  binIsMasked = true;
240  break;
241  }
242  }
243 
244  return binIsMasked;
245 }
std::map< std::string, std::vector< std::pair< int, int > > * > mMaskedBins
bool L1TOccupancyClientHistogramService::isStripMasked ( std::string  test,
int  binStrip,
int  axis 
)

Definition at line 257 of file L1TOccupancyClientHistogramService.cc.

References submitPVResolutionJobs::count, and mps_fire::i.

257  {
258  bool stripIsMasked = true;
259  vector<pair<int, int> >* thisHistMaskedBins = mMaskedBins[iHistName];
260 
261  // If the histogram to be tested had strips defined along Y
262  if (iAxis == 1) {
263  int count = 0;
264  for (unsigned int i = 0; i < thisHistMaskedBins->size(); i++) {
265  if ((*thisHistMaskedBins)[i].first == iBinStrip) {
266  count++;
267  }
268  }
269  stripIsMasked = getDifferentialHistogram(iHistName)->GetYaxis()->GetNbins() == count;
270  }
271  // If the histogram to be tested had strips defined along X
272  else {
273  int count = 0;
274  for (unsigned int i = 0; i < thisHistMaskedBins->size(); i++) {
275  if ((*thisHistMaskedBins)[i].second == iBinStrip) {
276  count++;
277  }
278  }
279  stripIsMasked = getDifferentialHistogram(iHistName)->GetXaxis()->GetNbins() == count;
280  }
281 
282  return stripIsMasked;
283 }
std::map< std::string, std::vector< std::pair< int, int > > * > mMaskedBins
TH2F * L1TOccupancyClientHistogramService::loadHisto ( DQMStore::IGetter igetter,
std::string  test,
std::string  histo 
)

Definition at line 294 of file L1TOccupancyClientHistogramService.cc.

296  {
297  pair<TH2F*, TH2F*> histPair;
298 
299  // Histogram to be monitored should be loaded in the begining of the run
300  TH2F* pHist = getRebinnedHistogram(igetter, iHistName, iHistLocation);
301 
302  if (mHistValid[iHistName]) {
303  histPair.first = pHist;
304 
305  TH2F* histDiff = new TH2F(*histPair.first); // Clone the rebinned histogram to be monitored
306  histDiff->Reset(); // We reset histDiff so we are sure it is empty
307  histPair.second = histDiff;
308 
309  mHistograms[iHistName] = histPair;
310 
311  // Stating the previous closed LS Block Histogram Diff
312  mHistDiffMinus1[iHistName] = new TH2F(*histDiff);
313  }
314 
315  return pHist; //return pointer to the differential histogram
316 }
TH2F * getRebinnedHistogram(DQMStore::IGetter &igetter, std::string iHistName, std::string iHistLocation)
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
int L1TOccupancyClientHistogramService::maskBins ( std::string  test,
TH2F *  histo,
int  strip,
int  axis 
)

Definition at line 190 of file L1TOccupancyClientHistogramService.cc.

References submitPVResolutionJobs::count, gather_cfg::cout, mps_fire::i, visualization-live-secondInstance_cfg::m, reco::mVerbose(), and AlCaHLTBitMon_ParallelJobs::p.

190  {
191  vector<pair<int, int> > m = (*mMaskedBins[iHistName]);
192  int count = 0;
193 
194  // iAxis==1 : Means symmetry axis is vertical
195  if (iAxis == 1) {
196  for (unsigned int i = 0; i < m.size(); i++) {
197  pair<int, int>& p = m[i];
198  if (p.first == iStrip) {
199  oHist->SetBinContent(p.first, p.second, 0.0);
200  count++;
201  }
202  }
203  }
204  // iAxis==2 : Means symmetry axis is horizontal
205  else if (iAxis == 2) {
206  for (unsigned int i = 0; i < m.size(); i++) {
207  pair<int, int>& p = m[i];
208  if (p.second == iStrip) {
209  oHist->SetBinContent(p.first, p.second, 0.0);
210  count++;
211  }
212  }
213  } else {
214  if (mVerbose) {
215  cout << "invalid axis" << endl;
216  }
217  }
218 
219  return count;
220 }
std::map< std::string, std::vector< std::pair< int, int > > * > mMaskedBins
tuple cout
Definition: gather_cfg.py:144
void L1TOccupancyClientHistogramService::resetHisto ( std::string  test)

Definition at line 415 of file L1TOccupancyClientHistogramService.cc.

References edm::second().

415  {
416  if (mHistValid[iHistName]) {
417  // Replacing mHistDiffMinus1
418  delete mHistDiffMinus1[iHistName];
419  mHistDiffMinus1[iHistName] = new TH2F(*mHistograms[iHistName].second);
420 
421  // Resetting
422  mHistograms[iHistName].second->Reset();
423 
424  // LS Accounting
425  mLSListDiffMinus1[iHistName] = mLSListDiff[iHistName]; // Replacing
426  mLSListDiff[iHistName].clear(); // Resetting
427  }
428 }
U second(std::pair< T, U > const &p)
std::map< std::string, std::vector< int > > mLSListDiff
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
std::map< std::string, std::vector< int > > mLSListDiffMinus1
void L1TOccupancyClientHistogramService::setMaskedBins ( std::string  test,
const std::vector< edm::ParameterSet > &  mask 
)

Definition at line 63 of file L1TOccupancyClientHistogramService.cc.

References edm::ParameterSet::getParameter(), timingPdfMaker::histo, mps_fire::i, visualization-live-secondInstance_cfg::m, reco::mVerbose(), AlCaHLTBitMon_ParallelJobs::p, gpuVertexFinder::printf(), xlast, hlt_dqm_clientPB-live_cfg::xmax, hlt_dqm_clientPB-live_cfg::xmin, SiStrip_OfflineMonitoring_cff::ymax, and SiStrip_OfflineMonitoring_cff::ymin.

63  {
64  TH2F* histo = mHistograms[iHistName].first;
65  vector<pair<int, int> >* m = new vector<pair<int, int> >();
66 
67  if (mVerbose) {
68  printf("Masked areas for: %s\n", iHistName.c_str());
69  }
70 
71  for (unsigned int i = 0; i < iMaskedAreas.size(); i++) {
72  ParameterSet iMA = iMaskedAreas[i];
73  int iTypeUnits = iMA.getParameter<int>("kind");
74 
75  //get boundaries from python
76  double xmin = iMA.getParameter<double>("xmin");
77  double xmax = iMA.getParameter<double>("xmax");
78  double ymin = iMA.getParameter<double>("ymin");
79  double ymax = iMA.getParameter<double>("ymax");
80 
81  if (mVerbose) {
82  string sTypeUnits;
83  if (iTypeUnits == 0) {
84  sTypeUnits = "Histogram Units";
85  } else if (iTypeUnits == 1) {
86  sTypeUnits = "Bin Units";
87  } else {
88  sTypeUnits = "Unknown Units";
89  }
90  printf(
91  "Area %3i: xmin=%6.2f xmax=%6.2f ymin=%6.2f ymax=%6.2f %s\n", i, xmin, xmax, ymin, ymax, sTypeUnits.c_str());
92  }
93 
94  int xfirst, yfirst, xlast, ylast;
95 
96  //if min < max: change
97  if (!(xmin <= xmax)) {
98  int z = xmax;
99  xmax = xmin;
100  xmin = z;
101  }
102  if (!(ymin <= ymax)) {
103  int z = ymax;
104  ymax = ymin;
105  ymin = z;
106  }
107 
108  // If masked area are defined in terms of units of the histogram get bin coordinates
109  if (iTypeUnits == 0) {
110  // We get the global bin number for this coordinates
111  int globalMaxBin = histo->FindBin(xmax, ymax);
112  int globalMinBin = histo->FindBin(xmax, ymax);
113 
114  // Dummy value for this variable since is a 2D histogram
115  int binZ = 0;
116 
117  // We convert global bins in axis bin numbers
118  histo->GetBinXYZ(globalMinBin, xfirst, yfirst, binZ);
119  histo->GetBinXYZ(globalMaxBin, xlast, ylast, binZ);
120 
121  // If the max edge (on X or Y) coincide with the lower edge of the current bin
122  // pass one bin bellow (since bins are defined from [a,b[)
123  if (histo->GetXaxis()->GetBinLowEdge(globalMaxBin) == xmax) {
124  xlast--;
125  }
126  if (histo->GetYaxis()->GetBinLowEdge(globalMaxBin) == ymax) {
127  ylast--;
128  }
129 
130  }
131  // Else units are bin coordinates just convert from double to int
132  else {
133  xfirst = (int)xmin;
134  xlast = (int)xmax;
135  yfirst = (int)ymin;
136  ylast = (int)ymax;
137  }
138 
139  // Now we generate coordinate pairs for each bin in the masked area
140  // and we store them for future use
141  for (int x = xfirst; x <= xlast; x++) {
142  for (int y = yfirst; y <= ylast; y++) {
143  pair<int, int> p;
144  p.first = x;
145  p.second = y;
146  m->push_back(p);
147  }
148  }
149  }
150 
151  delete[] mMaskedBins[iHistName];
152  mMaskedBins[iHistName] = m;
153 }
float xlast[150001][4]
Definition: AMPTWrapper.h:55
std::map< std::string, std::vector< std::pair< int, int > > * > mMaskedBins
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void L1TOccupancyClientHistogramService::updateHistogramEndLS ( DQMStore::IGetter igetter,
std::string  test,
std::string  histo,
int  iLS 
)

Definition at line 374 of file L1TOccupancyClientHistogramService.cc.

References edm::first().

377  {
378  if (mHistValid[iHistName]) {
379  TH2F* histo_curr = getRebinnedHistogram(
380  igetter, iHistLocation, iHistLocation); // Get the rebinned histogram current cumulative iHistLocation
381 
382  TH2F* histo_old = new TH2F(*histo_curr); // Clonecout <<"WP01"<<end;
383  histo_curr->Add(mHistograms[iHistName].first, -1.0); //calculate the difference to previous cumulative histo
384 
385  mLSListDiff[iHistName].push_back(iLS);
386 
387  delete mHistograms[iHistName].first; //delete old cumulateive histo
388  mHistograms[iHistName].first = histo_old; //save old as new
389  mHistograms[iHistName].second->Add(histo_curr); //save new as current
390  delete histo_curr;
391  }
392 }
TH2F * getRebinnedHistogram(DQMStore::IGetter &igetter, std::string iHistName, std::string iHistLocation)
std::map< std::string, std::vector< int > > mLSListDiff
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
void L1TOccupancyClientHistogramService::updateHistogramEndRun ( std::string  iHistName)

Definition at line 401 of file L1TOccupancyClientHistogramService.cc.

References SplitLinear::begin, and dataset::end.

401  {
402  if (mHistValid[iHistName]) {
403  mHistograms[iHistName].second->Add(mHistDiffMinus1[iHistName]);
404  mLSListDiff[iHistName].insert(
405  mLSListDiff[iHistName].end(), mLSListDiffMinus1[iHistName].begin(), mLSListDiffMinus1[iHistName].end());
406  }
407 }
std::map< std::string, std::vector< int > > mLSListDiff
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
std::map< std::string, std::vector< int > > mLSListDiffMinus1
string end
Definition: dataset.py:937

Member Data Documentation

std::map<std::string, TH2F*> L1TOccupancyClientHistogramService::mHistDiffMinus1
private

Definition at line 68 of file L1TOccupancyClientHistogramService.h.

std::map<std::string, std::pair<TH2F*, TH2F*> > L1TOccupancyClientHistogramService::mHistograms
private

Definition at line 66 of file L1TOccupancyClientHistogramService.h.

std::map<std::string, bool> L1TOccupancyClientHistogramService::mHistValid
private

Definition at line 65 of file L1TOccupancyClientHistogramService.h.

std::map<std::string, std::vector<int> > L1TOccupancyClientHistogramService::mLSListDiff
private

Definition at line 69 of file L1TOccupancyClientHistogramService.h.

std::map<std::string, std::vector<int> > L1TOccupancyClientHistogramService::mLSListDiffMinus1
private

Definition at line 70 of file L1TOccupancyClientHistogramService.h.

std::map<std::string, std::vector<std::pair<int, int> >*> L1TOccupancyClientHistogramService::mMaskedBins
private

Definition at line 67 of file L1TOccupancyClientHistogramService.h.

edm::ParameterSet L1TOccupancyClientHistogramService::mParameters
private

Definition at line 62 of file L1TOccupancyClientHistogramService.h.

bool L1TOccupancyClientHistogramService::mVerbose
private

Definition at line 61 of file L1TOccupancyClientHistogramService.h.