CMS 3D CMS Logo

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

#include <DTTimeEvolutionHisto.h>

Public Member Functions

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

Private Attributes

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 16 of file DTTimeEvolutionHisto.h.

Constructor & Destructor Documentation

DTTimeEvolutionHisto::DTTimeEvolutionHisto ( DQMStore dbe,
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::DTTimeEvolutionHisto ( DQMStore dbe,
const std::string &  name,
const std::string &  title,
int  nbins,
int  firstLS,
int  lsPrescale,
bool  sliding,
int  mode = 0 
)
DTTimeEvolutionHisto::DTTimeEvolutionHisto ( DQMStore dbe,
const std::string &  name 
)

retrieve the monitor element from DQMStore

DTTimeEvolutionHisto::~DTTimeEvolutionHisto ( )
virtual

Destructor.

Definition at line 137 of file DTTimeEvolutionHisto.cc.

137 {}

Member Function Documentation

void DTTimeEvolutionHisto::accumulateValueTimeSlot ( float  value)
void DTTimeEvolutionHisto::normalizeTo ( const MonitorElement histForNorm)

Definition at line 257 of file DTTimeEvolutionHisto.cc.

References newFWLiteAna::bin, MonitorElement::getBinContent(), MonitorElement::getNbinsX(), histo, and MonitorElement::setBinContent().

Referenced by DTSegmentAnalysisTest::endRun().

257  {
258  if(histo == 0) {
259  LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
260  << "[DTTimeEvolutionHisto]***Error: pointer to ME is NULL" << endl;
261  return;
262  }
263  int nBins = histo->getNbinsX();
264  if(histForNorm->getNbinsX() != nBins) {
265  LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
266  << "[DTTimeEvolutionHisto]***Error: normalizing histos with != # of bins" << endl;
267  return;
268  }
269  for(int bin = 1; bin <= nBins; ++bin) { // loop over bins
270  if(histForNorm->getBinContent(bin) != 0) {
271  double normValue = histo->getBinContent(bin)/histForNorm->getBinContent(bin);
272  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
273  << "[DTTimeEvolutionHisto] Normalizing bin: " << bin << " to: " << histo->getBinContent(bin) << " / " << histForNorm->getBinContent(bin)
274  << " = " << normValue << endl;
275  histo->setBinContent(bin, normValue);
276  } else {
277  histo->setBinContent(bin, 0);
278  }
279  }
280 }
void setBinContent(int binx, double content)
set content of bin (1-D)
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX(void) const
get # of bins in X-axis
void DTTimeEvolutionHisto::setTimeSlotValue ( float  value,
int  timeSlot 
)

Definition at line 141 of file DTTimeEvolutionHisto.cc.

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

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

141  {
142  // LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
143  // << "[DTTimeEvolutionHisto] ME name: " << histo->getName() << endl;
144  if(!doSlide) {
145  // LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
146  // << " fill bin: " << timeSlot << " with value: " << value << endl;
147  histo->Fill(timeSlot,value);
148  } else {
149  for(int bin = 1; bin != nBookedBins; ++bin) {
150  float value = histo->getBinContent(bin);
151  // LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
152  // << " bin: " << bin << " has value: " << value << endl;
153  if(bin == 1) { // average of previous time slots (fixme)
154  histo->setBinContent(bin, (value + histo->getBinContent(bin+1))/2.);
155  } else if(bin != nBookedBins) {
158  histo->setBinLabel(bin, histo->getTH1F()->GetXaxis()->GetBinLabel(bin+1),1);
159  }
160  }
162  }
163 }
void setBinContent(int binx, double content)
set content of bin (1-D)
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)
void Fill(long long x)
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
TH1F * getTH1F(void) const
double getBinContent(int binx) const
get content of bin (1-D)
void DTTimeEvolutionHisto::updateTimeSlot ( int  ls,
int  nEventsInLS 
)

Definition at line 172 of file DTTimeEvolutionHisto.cc.

References doSlide, MonitorElement::getBinContent(), histo, python.rootplot.utilities::ls(), nBookedBins, nEvents, nEventsInLastTimeSlot, nLumiTrInLastTimeSlot, MonitorElement::setBinLabel(), setTimeSlotValue(), theFirstLS, theLSPrescale, theMode, relativeConstraints::value, and valueLastTimeSlot.

Referenced by DTSegmentAnalysisTask::endLuminosityBlock(), and DTBlockedROChannelsTest::performClientDiagnostic().

172  {
173 
174  if(doSlide) { // sliding bins
175  // count LS in this time-slot
176  if (nEventsInLastTimeSlot.find(ls) != nEventsInLastTimeSlot.end()) {
177  nEventsInLastTimeSlot[ls] += nEventsInLS;
179  } else {
180  nEventsInLastTimeSlot[ls] = nEventsInLS;
182  }
183 
184 
185  if(nEventsInLastTimeSlot.size() > 0 && nEventsInLastTimeSlot.size()%theLSPrescale==0) { // update the value of the slot and reset the counters
186  int firstLSinTimeSlot = nEventsInLastTimeSlot.begin()->first;
187  int lastLSinTimeSlot = nEventsInLastTimeSlot.rbegin()->first;
188 
189  map<int,int>::const_iterator nEventsIt = nEventsInLastTimeSlot.begin();
190  map<int,int>::const_iterator nEventsEnd = nEventsInLastTimeSlot.end();
191 
192  int nEvents = 0;
193  for (;nEventsIt!=nEventsEnd;++nEventsIt)
194  nEvents+=nEventsIt->second;
195 
196  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
197  << "[DTTimeEvolutionHisto] Update time-slot, # entries: " << valueLastTimeSlot
198  << " # events: " << nEvents << endl;
199  // set the bin content
200 
201  float value = 0;
202  if(theMode == 0) {
203  if(nEvents != 0) value = valueLastTimeSlot/(float)nEvents;
204  } else if(theMode == 1) {
205  value = valueLastTimeSlot;
206  } else if(theMode == 2) {
207  value = nEvents;
208  } else if(theMode == 3) {
209  map<int,int>::const_iterator nLumiTrIt = nLumiTrInLastTimeSlot.begin();
210  map<int,int>::const_iterator nLumiTrEnd = nLumiTrInLastTimeSlot.end();
211 
212  float nLumiTr = 0.;
213  for (;nLumiTrIt!=nLumiTrEnd;++nLumiTrIt)
214  nLumiTr+=nLumiTrIt->second;
215 
216  value = valueLastTimeSlot/nLumiTr;
217  }
219  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
220  << " updated value: " << histo->getBinContent(nBookedBins) << endl;
221 
222  // set the bin label
223  stringstream binLabel;
224  binLabel << "LS " << firstLSinTimeSlot;
225  if(nEventsInLastTimeSlot.size() > 1)
226  binLabel << "-" << lastLSinTimeSlot;
227 
228  histo->setBinLabel(nBookedBins,binLabel.str(),1);
229 
230  // reset the counters for the time slot
231  nEventsInLastTimeSlot.clear();
232  nLumiTrInLastTimeSlot.clear();
233  valueLastTimeSlot = 0;
234  }
235 
236 
237  } else {
238  int binN = (int)ls-(theFirstLS-1)/(int)theLSPrescale;
239  // set the bin content
240  float value = 0;
241  if(theMode == 1) {
242  value = valueLastTimeSlot;
243  } else if(theMode == 2) {
244  value = nEventsInLS;
245  } else if(theMode == 3) {
247  }
248  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
249  << "[DTTimeEvolutionHisto] Update time-slot: "<< binN << " with value: " << value << endl;
250  setTimeSlotValue(value,binN);
251  }
252 }
std::map< int, int > nLumiTrInLastTimeSlot
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)
void setTimeSlotValue(float value, int timeSlot)
std::map< int, int > nEventsInLastTimeSlot
double getBinContent(int binx) const
get content of bin (1-D)
UInt_t nEvents
Definition: hcalCalib.cc:42

Member Data Documentation

bool DTTimeEvolutionHisto::doSlide
private

Definition at line 73 of file DTTimeEvolutionHisto.h.

Referenced by setTimeSlotValue(), and updateTimeSlot().

MonitorElement* DTTimeEvolutionHisto::histo
private

Definition at line 76 of file DTTimeEvolutionHisto.h.

Referenced by normalizeTo(), setTimeSlotValue(), and updateTimeSlot().

int DTTimeEvolutionHisto::nBookedBins
private

Definition at line 74 of file DTTimeEvolutionHisto.h.

Referenced by setTimeSlotValue(), and updateTimeSlot().

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

Definition at line 69 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

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

Definition at line 70 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

int DTTimeEvolutionHisto::theFirstLS
private

Definition at line 71 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

int DTTimeEvolutionHisto::theLSPrescale
private

Definition at line 72 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

int DTTimeEvolutionHisto::theMode
private

Definition at line 75 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

float DTTimeEvolutionHisto::valueLastTimeSlot
private

Definition at line 68 of file DTTimeEvolutionHisto.h.

Referenced by accumulateValueTimeSlot(), and updateTimeSlot().