CMS 3D CMS Logo

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 19 of file L1TOccupancyClientHistogramService.cc.

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

Definition at line 29 of file L1TOccupancyClientHistogramService.cc.

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

Member Function Documentation

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

Definition at line 450 of file L1TOccupancyClientHistogramService.cc.

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

Definition at line 440 of file L1TOccupancyClientHistogramService.cc.

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

Definition at line 164 of file L1TOccupancyClientHistogramService.cc.

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

Definition at line 46 of file L1TOccupancyClientHistogramService.cc.

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

Definition at line 176 of file L1TOccupancyClientHistogramService.cc.

176  {
177  return mMaskedBins[iHistName]->size();
178 }
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 328 of file L1TOccupancyClientHistogramService.cc.

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

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

Definition at line 233 of file L1TOccupancyClientHistogramService.cc.

References mps_fire::i.

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

Definition at line 258 of file L1TOccupancyClientHistogramService.cc.

References KineDebug3::count(), and mps_fire::i.

258  {
259  bool stripIsMasked = true;
260  vector<pair<int, int> >* thisHistMaskedBins = mMaskedBins[iHistName];
261 
262  // If the histogram to be tested had strips defined along Y
263  if (iAxis == 1) {
264  int count = 0;
265  for (unsigned int i = 0; i < thisHistMaskedBins->size(); i++) {
266  if ((*thisHistMaskedBins)[i].first == iBinStrip) {
267  count++;
268  }
269  }
270  stripIsMasked = getDifferentialHistogram(iHistName)->GetYaxis()->GetNbins() == count;
271  }
272  // If the histogram to be tested had strips defined along X
273  else {
274  int count = 0;
275  for (unsigned int i = 0; i < thisHistMaskedBins->size(); i++) {
276  if ((*thisHistMaskedBins)[i].second == iBinStrip) {
277  count++;
278  }
279  }
280  stripIsMasked = getDifferentialHistogram(iHistName)->GetXaxis()->GetNbins() == count;
281  }
282 
283  return stripIsMasked;
284 }
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 295 of file L1TOccupancyClientHistogramService.cc.

297  {
298  pair<TH2F*, TH2F*> histPair;
299 
300  // Histogram to be monitored should be loaded in the begining of the run
301  TH2F* pHist = getRebinnedHistogram(igetter, iHistName, iHistLocation);
302 
303  if (mHistValid[iHistName]) {
304  histPair.first = pHist;
305 
306  TH2F* histDiff = new TH2F(*histPair.first); // Clone the rebinned histogram to be monitored
307  histDiff->Reset(); // We reset histDiff so we are sure it is empty
308  histPair.second = histDiff;
309 
310  mHistograms[iHistName] = histPair;
311 
312  // Stating the previous closed LS Block Histogram Diff
313  mHistDiffMinus1[iHistName] = new TH2F(*histDiff);
314  }
315 
316  return pHist; //return pointer to the differential histogram
317 }
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 191 of file L1TOccupancyClientHistogramService.cc.

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

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

Definition at line 416 of file L1TOccupancyClientHistogramService.cc.

References edm::second().

416  {
417  if (mHistValid[iHistName]) {
418  // Replacing mHistDiffMinus1
419  delete mHistDiffMinus1[iHistName];
420  mHistDiffMinus1[iHistName] = new TH2F(*mHistograms[iHistName].second);
421 
422  // Resetting
423  mHistograms[iHistName].second->Reset();
424 
425  // LS Accounting
426  mLSListDiffMinus1[iHistName] = mLSListDiff[iHistName]; // Replacing
427  mLSListDiff[iHistName].clear(); // Resetting
428  }
429 }
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 64 of file L1TOccupancyClientHistogramService.cc.

References edm::ParameterSet::getParameter(), timingPdfMaker::histo, mps_fire::i, createfilelist::int, visualization-live-secondInstance_cfg::m, AlCaHLTBitMon_ParallelJobs::p, xlast, TrackerOfflineValidation_Dqm_cff::xmax, TrackerOfflineValidation_Dqm_cff::xmin, L1TOccupancyClient_cfi::ymax, and L1TOccupancyClient_cfi::ymin.

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

Definition at line 375 of file L1TOccupancyClientHistogramService.cc.

References edm::first().

378  {
379  if (mHistValid[iHistName]) {
380  TH2F* histo_curr = getRebinnedHistogram(
381  igetter, iHistLocation, iHistLocation); // Get the rebinned histogram current cumulative iHistLocation
382 
383  TH2F* histo_old = new TH2F(*histo_curr); // Clonecout <<"WP01"<<end;
384  histo_curr->Add(mHistograms[iHistName].first, -1.0); //calculate the difference to previous cumulative histo
385 
386  mLSListDiff[iHistName].push_back(iLS);
387 
388  delete mHistograms[iHistName].first; //delete old cumulateive histo
389  mHistograms[iHistName].first = histo_old; //save old as new
390  mHistograms[iHistName].second->Add(histo_curr); //save new as current
391  delete histo_curr;
392  }
393 }
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 402 of file L1TOccupancyClientHistogramService.cc.

References begin, and end.

402  {
403  if (mHistValid[iHistName]) {
404  mHistograms[iHistName].second->Add(mHistDiffMinus1[iHistName]);
405  mLSListDiff[iHistName].insert(
406  mLSListDiff[iHistName].end(), mLSListDiffMinus1[iHistName].begin(), mLSListDiffMinus1[iHistName].end());
407  }
408 }
std::map< std::string, std::vector< int > > mLSListDiff
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
#define end
Definition: vmac.h:39
std::map< std::string, std::vector< int > > mLSListDiffMinus1
#define begin
Definition: vmac.h:32

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.