CMS 3D CMS Logo

DTTimeEvolutionHisto.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Cerminara - INFN Torino
6  */
7 
9 
12 
13 using namespace std;
14 using namespace edm;
15 
17  const string& name,
18  const string& title,
19  int nbins,
20  int lsPrescale,
21  bool sliding,
22  int mode)
23  : DTTimeEvolutionHisto(ibooker, name, title, nbins, 1, lsPrescale, sliding, mode) {
24  nBookedBins = histo->getNbinsX();
25 }
26 
28  const string& name,
29  const string& title,
30  int nbins,
31  int firstLS,
32  int lsPrescale,
33  bool sliding,
34  int mode)
35  : valueLastTimeSlot(0), theFirstLS(firstLS), theLSPrescale(lsPrescale), doSlide(sliding), theMode(mode) {
36  // set the number of bins to be booked
37  nBookedBins = nbins;
38  if (sliding)
39  nBookedBins++;
40  if (!sliding && theMode == 0)
41  LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
42  << "[DTTimeEvolutionHisto]***Error: wrong configuration" << endl;
43 
44  stringstream realTitle;
45  realTitle << title << "/" << theLSPrescale << " LS";
46 
47  // book the ME
48 
49  histo = ibooker.book1D(name, realTitle.str(), nBookedBins, (float)theFirstLS, nBookedBins + 1.);
50 
51  // set the axis label
52  if (sliding) {
53  histo->setBinLabel(1, "avg. previous", 1);
54  } else {
55  // loop over bins and
56 
57  for (int bin = 1; bin != nBookedBins + 1; ++bin) {
58  stringstream label;
59  if (theLSPrescale > 1) {
60  label << "LS " << ((bin - 1) * theLSPrescale) + theFirstLS << "-" << bin * theLSPrescale + theFirstLS;
61  } else {
62  label << "LS " << ((bin - 1) * theLSPrescale) + theFirstLS;
63  }
64  if (bin % (2 * (int)theLSPrescale) == 0)
65  histo->setBinLabel(bin, label.str(), 1); //JF to allow easy reading of x-axis
66  }
67  }
68 }
69 
70 //FR changed previous constructor with 2 arguments:
71 //no igetter here!! so I get the histo from the client and just instanciate here a DTTimeEvolutionHisto
72 
74  : valueLastTimeSlot(0),
75  theFirstLS(1),
76  theLSPrescale(-1),
77  doSlide(false),
78  theMode(0) { // FIXME: set other memebers to sensible values
79  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
80  << "[DTTimeEvolutionHisto] Retrieve ME with name: "
81  << " " << endl;
82  histo = histoGot;
83 }
84 
86 
87 void DTTimeEvolutionHisto::setTimeSlotValue(float value, int timeSlot) {
88  if (!doSlide) {
89  histo->Fill(timeSlot, value);
90  } else {
91  for (int bin = 1; bin != nBookedBins; ++bin) {
92  float value = histo->getBinContent(bin);
93 
94  if (bin == 1) { // average of previous time slots (fixme)
96  } else if (bin != nBookedBins) {
99  histo->setBinLabel(bin, histo->getTH1F()->GetXaxis()->GetBinLabel(bin + 1), 1);
100  }
101  }
103  }
104 }
105 
107 
108 void DTTimeEvolutionHisto::updateTimeSlot(int ls, int nEventsInLS) {
109  if (doSlide) { // sliding bins
110  // count LS in this time-slot
111  if (nEventsInLastTimeSlot.find(ls) != nEventsInLastTimeSlot.end()) {
112  nEventsInLastTimeSlot[ls] += nEventsInLS;
114  } else {
115  nEventsInLastTimeSlot[ls] = nEventsInLS;
117  }
118 
119  if (!nEventsInLastTimeSlot.empty() &&
120  nEventsInLastTimeSlot.size() % theLSPrescale == 0) { // update the value of the slot and reset the counters
121  int firstLSinTimeSlot = nEventsInLastTimeSlot.begin()->first;
122  int lastLSinTimeSlot = nEventsInLastTimeSlot.rbegin()->first;
123 
124  map<int, int>::const_iterator nEventsIt = nEventsInLastTimeSlot.begin();
125  map<int, int>::const_iterator nEventsEnd = nEventsInLastTimeSlot.end();
126 
127  int nEvents = 0;
128  for (; nEventsIt != nEventsEnd; ++nEventsIt)
129  nEvents += nEventsIt->second;
130 
131  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
132  << "[DTTimeEvolutionHisto] Update time-slot, # entries: " << valueLastTimeSlot << " # events: " << nEvents
133  << endl;
134  // set the bin content
135 
136  float value = 0;
137  if (theMode == 0) {
138  if (nEvents != 0)
140  } else if (theMode == 1) {
142  } else if (theMode == 2) {
143  value = nEvents;
144  } else if (theMode == 3) {
145  map<int, int>::const_iterator nLumiTrIt = nLumiTrInLastTimeSlot.begin();
146  map<int, int>::const_iterator nLumiTrEnd = nLumiTrInLastTimeSlot.end();
147 
148  float nLumiTr = 0.;
149  for (; nLumiTrIt != nLumiTrEnd; ++nLumiTrIt)
150  nLumiTr += nLumiTrIt->second;
151 
152  value = valueLastTimeSlot / nLumiTr;
153  }
155  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
156  << " updated value: " << histo->getBinContent(nBookedBins) << endl;
157 
158  // set the bin label
159  stringstream binLabel;
160  binLabel << "LS " << firstLSinTimeSlot;
161  if (nEventsInLastTimeSlot.size() > 1)
162  binLabel << "-" << lastLSinTimeSlot;
163 
164  //if(lastLSinTimeSlot%(3*(int)theLSPrescale)==0)
165  histo->setBinLabel(nBookedBins, binLabel.str(), 1);
166 
167  // reset the counters for the time slot
168  nEventsInLastTimeSlot.clear();
169  nLumiTrInLastTimeSlot.clear();
170  valueLastTimeSlot = 0;
171  }
172 
173  } else {
174  int binN = (int)ls - (theFirstLS - 1) / (int)theLSPrescale;
175  // set the bin content
176  float value = 0;
177  if (theMode == 1) {
179  } else if (theMode == 2) {
180  value = nEventsInLS;
181  } else if (theMode == 3) {
183  }
184  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
185  << "[DTTimeEvolutionHisto] Update time-slot: " << binN << " with value: " << value << endl;
186  setTimeSlotValue(value, binN);
187  }
188 }
189 
191  if (histo == nullptr) {
192  LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
193  << "[DTTimeEvolutionHisto]***Error: pointer to ME is NULL" << endl;
194  return;
195  }
196  int nBins = histo->getNbinsX();
197  if (histForNorm->getNbinsX() != nBins) {
198  LogWarning("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
199  << "[DTTimeEvolutionHisto]***Error: normalizing histos with != # of bins" << endl;
200  return;
201  }
202  for (int bin = 1; bin <= nBins; ++bin) { // loop over bins
203  if (histForNorm->getBinContent(bin) != 0) {
204  double normValue = histo->getBinContent(bin) / histForNorm->getBinContent(bin);
205  LogVerbatim("DTDQM|DTMonitorModule|DTMonitorClient|DTTimeEvolutionHisto")
206  << "[DTTimeEvolutionHisto] Normalizing bin: " << bin << " to: " << histo->getBinContent(bin) << " / "
207  << histForNorm->getBinContent(bin) << " = " << normValue << endl;
208  histo->setBinContent(bin, normValue);
209  } else {
210  histo->setBinContent(bin, 0);
211  }
212  }
213 }
214 
215 // Local Variables:
216 // show-trailing-whitespace: t
217 // truncate-lines: t
218 // End:
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
funct::false
false
Definition: Factorize.h:29
edm
HLT enums.
Definition: AlignableModifier.h:19
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
DTTimeEvolutionHisto::~DTTimeEvolutionHisto
virtual ~DTTimeEvolutionHisto()
Destructor.
Definition: DTTimeEvolutionHisto.cc:85
DTTimeEvolutionHisto::nBookedBins
int nBookedBins
Definition: DTTimeEvolutionHisto.h:73
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:478
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DTTimeEvolutionHisto::updateTimeSlot
void updateTimeSlot(int ls, int nEventsInLS)
Definition: DTTimeEvolutionHisto.cc:108
DTTimeEvolutionHisto::valueLastTimeSlot
float valueLastTimeSlot
Definition: DTTimeEvolutionHisto.h:67
DTTimeEvolutionHisto::nEventsInLastTimeSlot
std::map< int, int > nEventsInLastTimeSlot
Definition: DTTimeEvolutionHisto.h:68
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
DTTimeEvolutionHisto::accumulateValueTimeSlot
void accumulateValueTimeSlot(float value)
Definition: DTTimeEvolutionHisto.cc:106
DTTimeEvolutionHisto::theLSPrescale
int theLSPrescale
Definition: DTTimeEvolutionHisto.h:71
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
DTTimeEvolutionHisto::doSlide
bool doSlide
Definition: DTTimeEvolutionHisto.h:72
seedmultiplicitymonitor_newtracking_cfi.nBins
nBins
Definition: seedmultiplicitymonitor_newtracking_cfi.py:8
DTTimeEvolutionHisto.h
DTTimeEvolutionHisto::theMode
int theMode
Definition: DTTimeEvolutionHisto.h:74
createfilelist.int
int
Definition: createfilelist.py:10
value
Definition: value.py:1
dqm::impl::MonitorElement::setBinLabel
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)
Definition: MonitorElement.cc:771
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
DTTimeEvolutionHisto::theFirstLS
int theFirstLS
Definition: DTTimeEvolutionHisto.h:70
std
Definition: JetResolutionObject.h:76
DTTimeEvolutionHisto::nLumiTrInLastTimeSlot
std::map< int, int > nLumiTrInLastTimeSlot
Definition: DTTimeEvolutionHisto.h:69
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DTTimeEvolutionHisto
Definition: DTTimeEvolutionHisto.h:15
relativeConstraints.value
value
Definition: relativeConstraints.py:53
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
dqm::impl::MonitorElement::setBinError
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
Definition: MonitorElement.cc:709
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
dqm::implementation::IBooker
Definition: DQMStore.h:43
DTTimeEvolutionHisto::DTTimeEvolutionHisto
DTTimeEvolutionHisto(DQMStore::IBooker &ibooker, const std::string &name, const std::string &title, int nbins, int lsPrescale, bool sliding, int mode=0)
dqm::impl::MonitorElement::getBinError
virtual double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
Definition: MonitorElement.cc:610
DTTimeEvolutionHisto::normalizeTo
void normalizeTo(const MonitorElement *histForNorm)
Definition: DTTimeEvolutionHisto.cc:190
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:41
DTTimeEvolutionHisto::histo
MonitorElement * histo
Definition: DTTimeEvolutionHisto.h:75
edm::Log
Definition: MessageLogger.h:70
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
label
const char * label
Definition: PFTauDecayModeTools.cc:11
DTTimeEvolutionHisto::setTimeSlotValue
void setTimeSlotValue(float value, int timeSlot)
Definition: DTTimeEvolutionHisto.cc:87
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98