CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
L1TOccupancyClientHistogramService Class Reference

#include <L1TOccupancyClientHistogramService.h>

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 23 of file L1TOccupancyClientHistogramService.h.

Constructor & Destructor Documentation

L1TOccupancyClientHistogramService::L1TOccupancyClientHistogramService ( )

Definition at line 20 of file L1TOccupancyClientHistogramService.cc.

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

Definition at line 30 of file L1TOccupancyClientHistogramService.cc.

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

Member Function Documentation

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

Definition at line 441 of file L1TOccupancyClientHistogramService.cc.

441  {
442  if(mHistValid[iHistName]){return mHistograms[iHistName].second;}
443  return nullptr;
444 }
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
vector< int > L1TOccupancyClientHistogramService::getLSCertification ( std::string  iHistName)

Definition at line 431 of file L1TOccupancyClientHistogramService.cc.

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

Definition at line 150 of file L1TOccupancyClientHistogramService.cc.

150  {
151  return (*mMaskedBins[iHistName]);
152 }
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 
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 
55 }
unsigned int L1TOccupancyClientHistogramService::getNBinsMasked ( std::string  test)

Definition at line 162 of file L1TOccupancyClientHistogramService.cc.

162  {
163  return mMaskedBins[iHistName]->size();
164 }
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 317 of file L1TOccupancyClientHistogramService.cc.

References DQMStore::IGetter::get(), edm::ParameterSet::getParameter(), MonitorElement::getTH2F(), edm::ParameterSet::getUntrackedParameter(), and mps_fire::i.

317  {
318 
319  MonitorElement* me = igetter.get(iHistLocation);
320 
321  TH2F* histMonitor;
322 
323  if(!me){
324  histMonitor = nullptr;
325  mHistValid[iHistName] = false;
326  }
327  else{
328  mHistValid[iHistName] = true;
329  histMonitor = new TH2F(*(igetter.get(iHistLocation)->getTH2F()));
330 
331  // Default rebin factors
332  int rebinFactorX=1;
333  int rebinFactorY=1;
334 
335  vector<ParameterSet> testParameters = mParameters.getParameter< vector<ParameterSet> >("testParams");
336  for(unsigned int i=0 ; i<testParameters.size() ; i++){
337  if(testParameters[i].getParameter<string>("testName")==iHistName){
338  ParameterSet algoParameters = testParameters[i].getParameter<ParameterSet>("algoParams");
339  rebinFactorX = algoParameters.getUntrackedParameter<int>("rebinFactorX",1);
340  rebinFactorY = algoParameters.getUntrackedParameter<int>("rebinFactorY",1);
341  break;
342  }
343  }
344 
345  // Rebinning
346  if(rebinFactorX!=1){histMonitor->RebinY(rebinFactorX);}
347  if(rebinFactorY!=1){histMonitor->RebinY(rebinFactorY);}
348 
349  }
350 
351  return histMonitor;
352 
353 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
TH2F * getTH2F(void) const
bool L1TOccupancyClientHistogramService::isMasked ( std::string  test,
int  x,
int  y 
)

Definition at line 220 of file L1TOccupancyClientHistogramService.cc.

References mps_fire::i.

220  {
221 
222  vector<pair<int,int> > *thisHistMaskedBins = mMaskedBins[iHistName];
223 
224  bool binIsMasked = false;
225 
226  for(unsigned int i=0; i<thisHistMaskedBins->size(); i++) {
227  if((*thisHistMaskedBins)[i].first ==iBinX &&
228  (*thisHistMaskedBins)[i].second==iBinY){
229  binIsMasked=true;
230  break;
231  }
232  }
233 
234  return binIsMasked;
235 }
std::map< std::string, std::vector< std::pair< int, int > > * > mMaskedBins
bool L1TOccupancyClientHistogramService::isStripMasked ( std::string  test,
int  binStrip,
int  axis 
)

Definition at line 247 of file L1TOccupancyClientHistogramService.cc.

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

247  {
248 
249  bool stripIsMasked = true;
250  vector<pair<int,int> > *thisHistMaskedBins = mMaskedBins[iHistName];
251 
252  // If the histogram to be tested had strips defined along Y
253  if(iAxis==1) {
254  int count=0;
255  for(unsigned int i=0; i<thisHistMaskedBins->size(); i++) {
256  if((*thisHistMaskedBins)[i].first==iBinStrip){count++;}
257  }
258  stripIsMasked = getDifferentialHistogram(iHistName)->GetYaxis()->GetNbins()==count;
259  }
260  // If the histogram to be tested had strips defined along X
261  else {
262  int count=0;
263  for(unsigned int i=0; i<thisHistMaskedBins->size(); i++) {
264  if((*thisHistMaskedBins)[i].second==iBinStrip){count++;}
265  }
266  stripIsMasked = getDifferentialHistogram(iHistName)->GetXaxis()->GetNbins()==count;
267  }
268 
269  return stripIsMasked;
270 }
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 282 of file L1TOccupancyClientHistogramService.cc.

282  {
283 
284  pair<TH2F*,TH2F*> histPair;
285 
286  // Histogram to be monitored should be loaded in the begining of the run
287  TH2F* pHist = getRebinnedHistogram(igetter, iHistName,iHistLocation);
288 
289  if(mHistValid[iHistName]){
290 
291  histPair.first = pHist;
292 
293  TH2F* histDiff = new TH2F(*histPair.first); // Clone the rebinned histogram to be monitored
294  histDiff->Reset(); // We reset histDiff so we are sure it is empty
295  histPair.second=histDiff;
296 
297  mHistograms[iHistName]=histPair;
298 
299  // Stating the previous closed LS Block Histogram Diff
300  mHistDiffMinus1[iHistName]=new TH2F(*histDiff);
301 
302  }
303 
304  return pHist; //return pointer to the differential histogram
305 
306 }
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 178 of file L1TOccupancyClientHistogramService.cc.

References KineDebug3::count(), gather_cfg::cout, mps_fire::i, funct::m, and AlCaHLTBitMon_ParallelJobs::p.

178  {
179 
180  vector<pair<int,int> > m = (*mMaskedBins[iHistName]);
181  int count=0;
182 
183  // iAxis==1 : Means symmetry axis is vertical
184  if(iAxis==1) {
185  for(unsigned int i=0;i<m.size();i++) {
186  pair<int,int> &p = m[i];
187  if(p.first==iStrip) {
188  oHist->SetBinContent(p.first,p.second,0.0);
189  count++;
190  }
191  }
192  }
193  // iAxis==2 : Means symmetry axis is horizontal
194  else if(iAxis==2) {
195  for(unsigned int i=0;i<m.size();i++) {
196  pair<int,int> &p = m[i];
197  if(p.second==iStrip) {
198  oHist->SetBinContent(p.first,p.second,0.0);
199  count++;
200  }
201  }
202  }
203  else {
204  if(mVerbose) {cout << "invalid axis" << endl;}
205  }
206 
207  return count;
208 }
std::map< std::string, std::vector< std::pair< int, int > > * > mMaskedBins
void L1TOccupancyClientHistogramService::resetHisto ( std::string  test)

Definition at line 404 of file L1TOccupancyClientHistogramService.cc.

References edm::second().

404  {
405 
406  if(mHistValid[iHistName]){
407 
408  // Replacing mHistDiffMinus1
409  delete mHistDiffMinus1[iHistName];
410  mHistDiffMinus1[iHistName] = new TH2F(*mHistograms[iHistName].second);
411 
412  // Resetting
413  mHistograms[iHistName].second->Reset();
414 
415  // LS Accounting
416  mLSListDiffMinus1[iHistName] = mLSListDiff[iHistName]; // Replacing
417  mLSListDiff [iHistName].clear(); // Resetting
418 
419  }
420 }
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
U second(std::pair< T, U > const &p)
std::map< std::string, std::vector< int > > mLSListDiffMinus1
std::map< std::string, std::vector< int > > mLSListDiff
void L1TOccupancyClientHistogramService::setMaskedBins ( std::string  test,
const std::vector< edm::ParameterSet > &  mask 
)

Definition at line 65 of file L1TOccupancyClientHistogramService.cc.

References edm::ParameterSet::getParameter(), trackerHits::histo, mps_fire::i, createfilelist::int, funct::m, AlCaHLTBitMon_ParallelJobs::p, xlast, TrackerOfflineValidation_Dqm_cff::xmax, TrackerOfflineValidation_Dqm_cff::xmin, Phase2TrackerMonitorDigi_cff::ymax, and Phase2TrackerMonitorDigi_cff::ymin.

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

References edm::first().

362  {
363 
364  if(mHistValid[iHistName]){
365 
366  TH2F* histo_curr = getRebinnedHistogram(igetter, iHistLocation,iHistLocation); // Get the rebinned histogram current cumulative iHistLocation
367 
368  TH2F* histo_old = new TH2F(*histo_curr); // Clonecout <<"WP01"<<end;
369  histo_curr->Add(mHistograms[iHistName].first,-1.0); //calculate the difference to previous cumulative histo
370 
371  mLSListDiff[iHistName].push_back(iLS);
372 
373  delete mHistograms[iHistName].first; //delete old cumulateive histo
374  mHistograms[iHistName].first=histo_old; //save old as new
375  mHistograms[iHistName].second->Add(histo_curr); //save new as current
376  delete histo_curr;
377  }
378 }
TH2F * getRebinnedHistogram(DQMStore::IGetter &igetter, std::string iHistName, std::string iHistLocation)
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
std::map< std::string, std::vector< int > > mLSListDiff
void L1TOccupancyClientHistogramService::updateHistogramEndRun ( std::string  iHistName)

Definition at line 387 of file L1TOccupancyClientHistogramService.cc.

References begin, and end.

387  {
388 
389  if(mHistValid[iHistName]){
390 
391  mHistograms[iHistName].second->Add(mHistDiffMinus1[iHistName]);
392  mLSListDiff[iHistName].insert(mLSListDiff [iHistName].end(),
393  mLSListDiffMinus1[iHistName].begin(),
394  mLSListDiffMinus1[iHistName].end());
395  }
396 }
std::map< std::string, std::pair< TH2F *, TH2F * > > mHistograms
std::map< std::string, std::vector< int > > mLSListDiffMinus1
#define end
Definition: vmac.h:37
std::map< std::string, std::vector< int > > mLSListDiff
#define begin
Definition: vmac.h:30

Member Data Documentation

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

Definition at line 66 of file L1TOccupancyClientHistogramService.h.

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

Definition at line 64 of file L1TOccupancyClientHistogramService.h.

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

Definition at line 63 of file L1TOccupancyClientHistogramService.h.

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

Definition at line 67 of file L1TOccupancyClientHistogramService.h.

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

Definition at line 68 of file L1TOccupancyClientHistogramService.h.

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

Definition at line 65 of file L1TOccupancyClientHistogramService.h.

edm::ParameterSet L1TOccupancyClientHistogramService::mParameters
private

Definition at line 60 of file L1TOccupancyClientHistogramService.h.

bool L1TOccupancyClientHistogramService::mVerbose
private

Definition at line 59 of file L1TOccupancyClientHistogramService.h.