CMS 3D CMS Logo

Public Member Functions | Private Attributes

DTTimeEvolutionHisto Class Reference

#include <DTTimeEvolutionHisto.h>

List of all members.

Public Member Functions

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

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.

Date:
2011/06/10 13:23:25
Revision:
1.4
Author:
G. Cerminara - INFN Torino

Definition at line 18 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 139 of file DTTimeEvolutionHisto.cc.

{}

Member Function Documentation

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

Definition at line 259 of file DTTimeEvolutionHisto.cc.

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

Referenced by DTSegmentAnalysisTest::endRun().

                                                                        {
  if(histo == 0) {
    LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
      << "[DTTimeEvolutionHisto]***Error: pointer to ME is NULL" << endl;
    return;
  }
  int nBins = histo->getNbinsX();
  if(histForNorm->getNbinsX() != nBins) {
    LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
      << "[DTTimeEvolutionHisto]***Error: normalizing histos with != # of bins" << endl;
    return;
  }
  for(int bin = 1; bin <= nBins; ++bin) { // loop over bins
    if(histForNorm->getBinContent(bin) != 0) {
      double normValue = histo->getBinContent(bin)/histForNorm->getBinContent(bin);
      LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
        << "[DTTimeEvolutionHisto] Normalizing bin: " << bin << " to: " <<  histo->getBinContent(bin) << " / " << histForNorm->getBinContent(bin)
        << " = " << normValue << endl;
      histo->setBinContent(bin, normValue);
    } else {
      histo->setBinContent(bin, 0);
    }
  }
}
void DTTimeEvolutionHisto::setTimeSlotValue ( float  value,
int  timeSlot 
)

Definition at line 143 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 updateTimeSlot().

                                                                     {
  //   LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
  //   << "[DTTimeEvolutionHisto] ME name: " <<  histo->getName() << endl;
  if(!doSlide) {
    //     LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
    //     << "        fill bin: " << timeSlot << " with value: " << value << endl;
    histo->Fill(timeSlot,value);
  } else {
    for(int bin = 1; bin != nBookedBins; ++bin) {
      float value = histo->getBinContent(bin);
      //       LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
      //  << "        bin: " << bin << " has value: " << value << endl;
      if(bin == 1) { // average of previous time slots (fixme)
        histo->setBinContent(bin, (value + histo->getBinContent(bin+1))/2.);
      } else if(bin != nBookedBins) {
        histo->setBinContent(bin, histo->getBinContent(bin+1));
        histo->setBinError(bin, histo->getBinError(bin+1));
        histo->setBinLabel(bin, histo->getTH1F()->GetXaxis()->GetBinLabel(bin+1),1);
      }
    }
    histo->setBinContent(nBookedBins, value);
  }
}
void DTTimeEvolutionHisto::updateTimeSlot ( int  ls,
int  nEventsInLS 
)

Definition at line 174 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().

                                                                 {
  
  if(doSlide) { // sliding bins
    // count LS in this time-slot
    if (nEventsInLastTimeSlot.find(ls) != nEventsInLastTimeSlot.end()) {
      nEventsInLastTimeSlot[ls] += nEventsInLS;
      nLumiTrInLastTimeSlot[ls]++;
    } else {
      nEventsInLastTimeSlot[ls] = nEventsInLS;
      nLumiTrInLastTimeSlot[ls] = 1;
    }
    

    if(nEventsInLastTimeSlot.size() > 0 && nEventsInLastTimeSlot.size()%theLSPrescale==0) { // update the value of the slot and reset the counters
      int firstLSinTimeSlot = nEventsInLastTimeSlot.begin()->first;
      int lastLSinTimeSlot  = nEventsInLastTimeSlot.rbegin()->first;
      
      map<int,int>::const_iterator nEventsIt  = nEventsInLastTimeSlot.begin();
      map<int,int>::const_iterator nEventsEnd = nEventsInLastTimeSlot.end();

      int nEvents = 0;
      for (;nEventsIt!=nEventsEnd;++nEventsIt) 
        nEvents+=nEventsIt->second;     
        
      LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
        << "[DTTimeEvolutionHisto] Update time-slot, # entries: " << valueLastTimeSlot 
        << " # events: " << nEvents << endl;
      // set the bin content

      float value = 0;
      if(theMode == 0) {
        if(nEvents != 0) value = valueLastTimeSlot/(float)nEvents;
      } else if(theMode == 1) {
        value = valueLastTimeSlot;
      } else if(theMode == 2) {
        value = nEvents;
      } else if(theMode == 3) {
        map<int,int>::const_iterator nLumiTrIt  = nLumiTrInLastTimeSlot.begin();
        map<int,int>::const_iterator nLumiTrEnd = nLumiTrInLastTimeSlot.end();

        float nLumiTr = 0.;
        for (;nLumiTrIt!=nLumiTrEnd;++nLumiTrIt) 
          nLumiTr+=nLumiTrIt->second;   

        value = valueLastTimeSlot/nLumiTr;
      }
      setTimeSlotValue(value, nBookedBins);
      LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
        << "       updated value: " << histo->getBinContent(nBookedBins) << endl;

      // set the bin label
      stringstream binLabel; 
      binLabel << "LS " << firstLSinTimeSlot;
      if(nEventsInLastTimeSlot.size() > 1) 
        binLabel << "-" << lastLSinTimeSlot;

      histo->setBinLabel(nBookedBins,binLabel.str(),1);

      // reset the counters for the time slot
      nEventsInLastTimeSlot.clear();
      nLumiTrInLastTimeSlot.clear();
      valueLastTimeSlot = 0;
    }


  } else {
    int binN = (int)ls-(theFirstLS-1)/(int)theLSPrescale;
    // set the bin content
    float value = 0;
    if(theMode == 1) {
      value = valueLastTimeSlot;
    } else if(theMode == 2) {
      value = nEventsInLS;
    } else if(theMode == 3) {
      value = valueLastTimeSlot/theLSPrescale;
    }
    LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
      << "[DTTimeEvolutionHisto] Update time-slot: "<< binN << " with value: " << value << endl;
    setTimeSlotValue(value,binN);
  }
}

Member Data Documentation

Definition at line 75 of file DTTimeEvolutionHisto.h.

Referenced by setTimeSlotValue(), and updateTimeSlot().

Definition at line 78 of file DTTimeEvolutionHisto.h.

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

Definition at line 76 of file DTTimeEvolutionHisto.h.

Referenced by setTimeSlotValue(), and updateTimeSlot().

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

Definition at line 71 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

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

Definition at line 72 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

Definition at line 73 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

Definition at line 74 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

Definition at line 77 of file DTTimeEvolutionHisto.h.

Referenced by updateTimeSlot().

Definition at line 70 of file DTTimeEvolutionHisto.h.

Referenced by accumulateValueTimeSlot(), and updateTimeSlot().