CMS 3D CMS Logo

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

#include <DTTimeEvolutionHisto.h>

Public Types

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

Public Member Functions

void accumulateValueTimeSlot (float value)
 
 DTTimeEvolutionHisto (DQMStore::IBooker &ibooker, const std::string &name, const std::string &title, int nbins, int lsPrescale, bool sliding, int mode=0)
 
 DTTimeEvolutionHisto (DQMStore::IBooker &ibooker, const std::string &name, const std::string &title, int nbins, int firstLS, int lsPrescale, bool sliding, int mode=0)
 
 DTTimeEvolutionHisto (MonitorElement *)
 
void normalizeTo (const MonitorElement *histForNorm)
 
void setTimeSlotValue (float value, int timeSlot)
 
void updateTimeSlot (int ls, int nEventsInLS)
 
virtual ~DTTimeEvolutionHisto ()
 Destructor. More...
 

Private Attributes

int binLabelCounter
 
bool doSlide
 
MonitorElementhisto
 
int nBookedBins
 
std::map< int, int > nEventsInLastTimeSlot
 
std::map< int, int > nLumiTrInLastTimeSlot
 
int theFirstLS
 
int theLSPrescale
 
int theMode
 
float valueLastTimeSlot
 

Detailed Description

No description available.

Author
G. Cerminara - INFN Torino

Definition at line 15 of file DTTimeEvolutionHisto.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 17 of file DTTimeEvolutionHisto.h.

◆ MonitorElement

Definition at line 18 of file DTTimeEvolutionHisto.h.

Constructor & Destructor Documentation

◆ DTTimeEvolutionHisto() [1/3]

DTTimeEvolutionHisto::DTTimeEvolutionHisto ( DQMStore::IBooker ibooker,
const std::string &  name,
const std::string &  title,
int  nbins,
int  lsPrescale,
bool  sliding,
int  mode = 0 
)

Constructor Parameters are:

  • pointer to DQMStore
  • name of the MonitorElement
  • title of the MonitorElement
  • # of bins
  • # of LumiSections per bin
  • mode:
    0 -> rate (over event)
    need to fill using accumulateValueTimeSlot and updateTimeSlot methods
    1 -> # of entries
    2 -> # of events
    3 -> mean over LSs

◆ DTTimeEvolutionHisto() [2/3]

DTTimeEvolutionHisto::DTTimeEvolutionHisto ( DQMStore::IBooker ibooker,
const std::string &  name,
const std::string &  title,
int  nbins,
int  firstLS,
int  lsPrescale,
bool  sliding,
int  mode = 0 
)

◆ DTTimeEvolutionHisto() [3/3]

DTTimeEvolutionHisto::DTTimeEvolutionHisto ( MonitorElement histoGot)

Definition at line 74 of file DTTimeEvolutionHisto.cc.

References histo.

75  : valueLastTimeSlot(0),
76  theFirstLS(1),
77  theLSPrescale(-1),
78  doSlide(false),
79  theMode(0) { // FIXME: set other memebers to sensible values
80  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
81  << "[DTTimeEvolutionHisto] Retrieve ME with name: "
82  << " " << endl;
83  histo = histoGot;
84 }
Log< level::Info, true > LogVerbatim

◆ ~DTTimeEvolutionHisto()

DTTimeEvolutionHisto::~DTTimeEvolutionHisto ( )
virtual

Destructor.

Definition at line 86 of file DTTimeEvolutionHisto.cc.

86 {}

Member Function Documentation

◆ accumulateValueTimeSlot()

void DTTimeEvolutionHisto::accumulateValueTimeSlot ( float  value)

◆ normalizeTo()

void DTTimeEvolutionHisto::normalizeTo ( const MonitorElement histForNorm)

Definition at line 196 of file DTTimeEvolutionHisto.cc.

References newFWLiteAna::bin, dqm::impl::MonitorElement::getBinContent(), dqm::impl::MonitorElement::getNbinsX(), histo, ecalPedestalPCLworker_cfi::nBins, and dqm::impl::MonitorElement::setBinContent().

196  {
197  if (histo == nullptr) {
198  LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
199  << "[DTTimeEvolutionHisto]***Error: pointer to ME is NULL" << endl;
200  return;
201  }
202  int nBins = histo->getNbinsX();
203  if (histForNorm->getNbinsX() != nBins) {
204  LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
205  << "[DTTimeEvolutionHisto]***Error: normalizing histos with != # of bins" << endl;
206  return;
207  }
208  for (int bin = 1; bin <= nBins; ++bin) { // loop over bins
209  if (histForNorm->getBinContent(bin) != 0) {
210  double normValue = histo->getBinContent(bin) / histForNorm->getBinContent(bin);
211  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
212  << "[DTTimeEvolutionHisto] Normalizing bin: " << bin << " to: " << histo->getBinContent(bin) << " / "
213  << histForNorm->getBinContent(bin) << " = " << normValue << endl;
214  histo->setBinContent(bin, normValue);
215  } else {
216  histo->setBinContent(bin, 0);
217  }
218  }
219 }
Log< level::Info, true > LogVerbatim
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual int getNbinsX() const
get # of bins in X-axis
Log< level::Warning, false > LogWarning
virtual double getBinContent(int binx) const
get content of bin (1-D)

◆ setTimeSlotValue()

void DTTimeEvolutionHisto::setTimeSlotValue ( float  value,
int  timeSlot 
)

Definition at line 88 of file DTTimeEvolutionHisto.cc.

References newFWLiteAna::bin, doSlide, dqm::impl::MonitorElement::Fill(), dqm::impl::MonitorElement::getBinContent(), dqm::impl::MonitorElement::getBinError(), dqm::legacy::MonitorElement::getTH1F(), histo, nBookedBins, dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), and dqm::impl::MonitorElement::setBinLabel().

Referenced by DTDCSByLumiSummary::dqmEndJob(), and updateTimeSlot().

88  {
89  if (!doSlide) {
90  histo->Fill(timeSlot, value);
91  } else {
92  for (int bin = 1; bin != nBookedBins; ++bin) {
93  float value = histo->getBinContent(bin);
94 
95  if (bin == 1) { // average of previous time slots (fixme)
97  } else if (bin != nBookedBins) {
100  histo->setBinLabel(bin, histo->getTH1F()->GetXaxis()->GetBinLabel(bin + 1), 1); //slide to left
101  histo->setBinLabel(bin + 1, "", 1); //delete old label to avoid duplication
102  }
103  }
105  }
106 }
void Fill(long long x)
Definition: value.py:1
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)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual TH1F * getTH1F() const
virtual double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
virtual double getBinContent(int binx) const
get content of bin (1-D)

◆ updateTimeSlot()

void DTTimeEvolutionHisto::updateTimeSlot ( int  ls,
int  nEventsInLS 
)

Definition at line 110 of file DTTimeEvolutionHisto.cc.

References binLabelCounter, doSlide, ALCARECOEcalPhiSym_cff::float, dqm::impl::MonitorElement::getBinContent(), histo, createfilelist::int, relval_nano::ls, nBookedBins, createIOVlist::nEvents, nEventsInLastTimeSlot, nLumiTrInLastTimeSlot, dqm::impl::MonitorElement::setBinLabel(), setTimeSlotValue(), theFirstLS, theLSPrescale, theMode, and valueLastTimeSlot.

Referenced by DTBlockedROChannelsTest::performClientDiagnostic().

110  {
111  if (doSlide) { // sliding bins
112  // count LS in this time-slot
113  if (nEventsInLastTimeSlot.find(ls) != nEventsInLastTimeSlot.end()) {
114  nEventsInLastTimeSlot[ls] += nEventsInLS;
116  } else {
117  nEventsInLastTimeSlot[ls] = nEventsInLS;
119  }
120 
121  if (!nEventsInLastTimeSlot.empty() &&
122  nEventsInLastTimeSlot.size() % theLSPrescale == 0) { // update the value of the slot and reset the counters
123  int firstLSinTimeSlot = nEventsInLastTimeSlot.begin()->first;
124  int lastLSinTimeSlot = nEventsInLastTimeSlot.rbegin()->first;
125 
126  map<int, int>::const_iterator nEventsIt = nEventsInLastTimeSlot.begin();
127  map<int, int>::const_iterator nEventsEnd = nEventsInLastTimeSlot.end();
128 
129  int nEvents = 0;
130  for (; nEventsIt != nEventsEnd; ++nEventsIt)
131  nEvents += nEventsIt->second;
132 
133  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
134  << "[DTTimeEvolutionHisto] Update time-slot, # entries: " << valueLastTimeSlot << " # events: " << nEvents
135  << endl;
136  // set the bin content
137 
138  float value = 0;
139  if (theMode == 0) {
140  if (nEvents != 0)
142  } else if (theMode == 1) {
144  } else if (theMode == 2) {
145  value = nEvents;
146  } else if (theMode == 3) {
147  map<int, int>::const_iterator nLumiTrIt = nLumiTrInLastTimeSlot.begin();
148  map<int, int>::const_iterator nLumiTrEnd = nLumiTrInLastTimeSlot.end();
149 
150  float nLumiTr = 0.;
151  for (; nLumiTrIt != nLumiTrEnd; ++nLumiTrIt)
152  nLumiTr += nLumiTrIt->second;
153 
154  value = valueLastTimeSlot / nLumiTr;
155  }
157  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
158  << " updated value: " << histo->getBinContent(nBookedBins) << endl;
159 
160  // set the bin label
161  stringstream binLabel;
162  binLabel << "LS " << firstLSinTimeSlot;
163  if (nEventsInLastTimeSlot.size() > 1) {
164  binLabel << "-" << lastLSinTimeSlot;
165  binLabelCounter++;
166  }
167 
168  // Set only labels which can be seen in the plot without zooming
169  if (nBookedBins >= 25 && binLabelCounter % (nBookedBins / 25) == 0) //around 25 labels fit in a full size hist
170  histo->setBinLabel(nBookedBins, binLabel.str(), 1);
171  //first label, LS=1 ideally, is guaranteed by setting binLabelCounter=-1 in constructor
172 
173  // reset the counters for the time slot
174  nEventsInLastTimeSlot.clear();
175  nLumiTrInLastTimeSlot.clear();
176  valueLastTimeSlot = 0;
177  }
178 
179  } else {
180  int binN = (int)ls - (theFirstLS - 1) / (int)theLSPrescale;
181  // set the bin content
182  float value = 0;
183  if (theMode == 1) {
185  } else if (theMode == 2) {
186  value = nEventsInLS;
187  } else if (theMode == 3) {
189  }
190  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
191  << "[DTTimeEvolutionHisto] Update time-slot: " << binN << " with value: " << value << endl;
192  setTimeSlotValue(value, binN);
193  }
194 }
Log< level::Info, true > LogVerbatim
std::map< int, int > nLumiTrInLastTimeSlot
void setTimeSlotValue(float value, int timeSlot)
Definition: value.py:1
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)
std::map< int, int > nEventsInLastTimeSlot
virtual double getBinContent(int binx) const
get content of bin (1-D)

Member Data Documentation

◆ binLabelCounter

int DTTimeEvolutionHisto::binLabelCounter
private

Definition at line 76 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

◆ doSlide

bool DTTimeEvolutionHisto::doSlide
private

Definition at line 72 of file DTTimeEvolutionHisto.h.

Referenced by setTimeSlotValue(), and updateTimeSlot().

◆ histo

MonitorElement* DTTimeEvolutionHisto::histo
private

◆ nBookedBins

int DTTimeEvolutionHisto::nBookedBins
private

Definition at line 73 of file DTTimeEvolutionHisto.h.

Referenced by setTimeSlotValue(), and updateTimeSlot().

◆ nEventsInLastTimeSlot

std::map<int, int> DTTimeEvolutionHisto::nEventsInLastTimeSlot
private

Definition at line 68 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

◆ nLumiTrInLastTimeSlot

std::map<int, int> DTTimeEvolutionHisto::nLumiTrInLastTimeSlot
private

Definition at line 69 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

◆ theFirstLS

int DTTimeEvolutionHisto::theFirstLS
private

Definition at line 70 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

◆ theLSPrescale

int DTTimeEvolutionHisto::theLSPrescale
private

Definition at line 71 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

◆ theMode

int DTTimeEvolutionHisto::theMode
private

Definition at line 74 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

◆ valueLastTimeSlot

float DTTimeEvolutionHisto::valueLastTimeSlot
private

Definition at line 67 of file DTTimeEvolutionHisto.h.

Referenced by accumulateValueTimeSlot(), and updateTimeSlot().