CMS 3D CMS Logo

L1ScalersClient.cc
Go to the documentation of this file.
1 #include <cassert>
2 #include <sstream>
3 
5 
10 
12 
13 using edm::LogInfo;
14 using edm::LogWarning;
15 
16 #define SECS_PER_LUMI_SECTION 23.31040958083832;
17 const int kPerHisto = 20;
18 const int kNumAlgoHistos = MAX_ALGOS / kPerHisto; // this hasta be w/o remainders
19 const int kNumTTHistos = MAX_TT / kPerHisto; // this hasta be w/o remainders
20 
23  : dbe_(nullptr),
24  nLumi_(0),
25  l1AlgoCurrentRate_(nullptr),
26  l1TechTrigCurrentRate_(nullptr),
27  selected_(nullptr),
28  bxSelected_(nullptr),
29  algoSelected_(ps.getUntrackedParameter<std::vector<int>>("algoMonitorBits", std::vector<int>())),
30  techSelected_(ps.getUntrackedParameter<std::vector<int>>("techMonitorBits", std::vector<int>())),
31  folderName_(ps.getUntrackedParameter<std::string>("dqmFolder", "L1T/L1Scalers_EvF")),
32  currentLumiBlockNumber_(0),
33  first_algo(true),
34  first_tt(true) {
35  LogDebug("Status") << "constructor";
36  // get back-end interface
37  dbe_ = edm::Service<DQMStore>().operator->();
38  assert(dbe_ != nullptr); // blammo!
40 
42  dbe_->book1D("algo_cur_rate", "current lumi section rate per Algo Bits", MAX_ALGOS, -0.5, MAX_ALGOS - 0.5);
43 
45  dbe_->book1D("tt_cur_rate", "current lumi section rate per Tech. Trig.s", MAX_TT, -0.5, MAX_TT - 0.5);
46  // ----------------------
47  numSelected_ = algoSelected_.size() + techSelected_.size();
48  selected_ = dbe_->book1D("l1BitsSel",
49  "Selected L1 Algorithm"
50  " and tech Bits",
52  -0.5,
53  numSelected_ - 0.5);
55  "l1BitsBxSel", "Selected L1 Algorithm Bits vs Bx", 3600, -0.5, 3599.5, numSelected_, -0.5, numSelected_ - 0.5);
56  int j = 1;
57  for (unsigned int i = 0; i < algoSelected_.size(); ++i) {
58  char title[256];
59  snprintf(title, 256, "Algo %d", algoSelected_[i]);
62  ++j;
63  }
64  for (unsigned int i = 0; i < techSelected_.size(); ++i) {
65  char title[256];
66  snprintf(title, 256, "Tech %d", techSelected_[i]);
69  ++j;
70  }
71 
72  // book individual bit rates vs lumi for algo bits.
73  totalAlgoRate_ = dbe_->book1D("totAlgoRate", "Total Algo Rate", MAX_LUMI_SEG, -0.5, MAX_LUMI_SEG - 0.5);
74  totalTtRate_ = dbe_->book1D("totTtRate", "Total Tech Rate", MAX_LUMI_SEG, -0.5, MAX_LUMI_SEG - 0.5);
75 
76  totAlgoPrevCount = 0UL;
77  totTtPrevCount = 0UL;
78 
79  std::string algodir = "/AlgoRates";
80  dbe_->setCurrentFolder(folderName_ + algodir);
81 
82  for (int i = 0; i < MAX_ALGOS; ++i) {
83  l1AlgoScalerCounters_[i] = 0UL;
84  l1AlgoRateHistories_[i] = nullptr; // not really needed but ...
85  char name[256];
86  snprintf(name, 256, "rate_algobit%03d", i);
87  LogDebug("Parameter") << "name " << i << " is " << name;
89  }
90 
91  // book individual bit rates vs lumi for technical trigger bits.
92 
93  std::string techdir = "/TechRates";
94  dbe_->setCurrentFolder(folderName_ + techdir);
95 
96  for (int i = 0; i < MAX_TT; ++i) {
98  l1TechTrigRateHistories_[i] = nullptr; // not really needed but ...
99  char name[256];
100  snprintf(name, 256, "rate_ttbit%03d", i);
101  LogDebug("Parameter") << "name " << i << " is " << name;
103  }
104 
105  // split l1 scalers up into groups of 20, assuming total of 140 bits
106  std::string algodir2 = "/AlgoBits";
107  dbe_->setCurrentFolder(folderName_ + algodir2);
108 
109  char metitle1[64]; // histo name
110  char mename1[64]; // ME name
111  for (int k = 0; k < kNumAlgoHistos; k++) {
112  int npath_low = kPerHisto * k;
113  int npath_high = kPerHisto * (k + 1) - 1;
114  snprintf(mename1, 64, "L1AlgoBits_%0d", k);
115  snprintf(metitle1, 64, "L1 rates - Algo Bits %d to %d", npath_low, npath_high);
116  l1AlgoCurrentRatePerAlgo_[k] = dbe_->book1D(mename1, metitle1, kPerHisto, -0.5 + npath_low, npath_high + 0.5);
117  }
118 
119  // split l1 scalers up into groups of 20, assuming total of 80 technical bits
120 
121  std::string techdir2 = "/TechBits";
122  dbe_->setCurrentFolder(folderName_ + techdir2);
123 
124  char metitle2[64]; // histo name
125  char mename2[64]; // ME name
126  for (int k = 0; k < kNumTTHistos; k++) {
127  int npath_low = kPerHisto * k;
128  int npath_high = kPerHisto * (k + 1) - 1;
129  snprintf(mename2, 64, "L1TechBits_%0d", k);
130  snprintf(metitle2, 64, "L1 rates - Tech. Trig. Bits %d to %d", npath_low, npath_high);
131  l1TechTrigCurrentRatePerAlgo_[k] = dbe_->book1D(mename2, metitle2, kPerHisto, -0.5 + npath_low, npath_high + 0.5);
132  }
133 
134  std::ostringstream params;
135  params << "Algo: ";
136  for (unsigned int i = 0; i < algoSelected_.size(); ++i) {
137  params << algoSelected_[i] << " ";
138  }
139  params << ", Tech: ";
140  for (unsigned int i = 0; i < techSelected_.size(); ++i) {
141  params << techSelected_[i] << " ";
142  }
143  LogDebug("Parameter") << "L1 bits to monitor are " << params.str();
144 }
145 
148  LogDebug("Status") << "beingJob";
149  if (dbe_) {
151  }
152 }
153 
156 
159 
163  nLumi_ = lumiSeg.id().luminosityBlock();
164 
165  // get EvF data
166 
167  MonitorElement *algoScalers = dbe_->get(folderName_ + std::string("/l1AlgoBits"));
168  MonitorElement *ttScalers = dbe_->get(folderName_ + std::string("/l1TechBits"));
169 
170  if (algoScalers == nullptr || ttScalers == nullptr) {
171  LogInfo("Status") << "cannot get l1 scalers histogram, bailing out.";
172  return;
173  }
174 
175  int nalgobits = algoScalers->getNbinsX();
176  int nttbits = ttScalers->getNbinsX();
177 
178  if (nalgobits > MAX_ALGOS)
179  nalgobits = MAX_ALGOS; // HARD CODE FOR NOW
180  if (nttbits > MAX_TT)
181  nttbits = MAX_TT; // HARD CODE FOR NOW
182 
183  LogDebug("Status") << "I see " << nalgobits << " algo paths. ";
184  LogDebug("Status") << "I see " << nttbits << " tt paths. ";
185 
186  // set the bin labels on the first go-through
187  if (first_algo) {
188  for (int i = 0; i < nalgobits; ++i) {
189  int whichHisto = i / kPerHisto;
190  int whichBin = i % kPerHisto + 1;
191  char pname[256];
192  snprintf(pname, 256, "AlgoBit%03d", i);
193  l1AlgoCurrentRatePerAlgo_[whichHisto]->setBinLabel(whichBin, pname);
194  snprintf(pname, 256, "Rate - Algorithm Bit %03d", i);
196  }
197  first_algo = false;
198  }
199 
200  // set the bin labels on the first go-through
201  if (first_tt) {
202  for (int i = 0; i < nttbits; ++i) {
203  int whichHisto = i / kPerHisto;
204  int whichBin = i % kPerHisto + 1;
205  char pname[256];
206  snprintf(pname, 256, "TechBit%03d", i);
207  l1TechTrigCurrentRatePerAlgo_[whichHisto]->setBinLabel(whichBin, pname);
208  snprintf(pname, 256, "Rate - Technical Bit %03d", i);
210  }
211  first_tt = false;
212  }
213 
214  MonitorElement *nLumi = dbe_->get(folderName_ + std::string("nLumiBlock"));
215 
216  int testval = (nLumi != nullptr ? nLumi->getIntValue() : -1);
217  LogDebug("Parameter") << "Lumi Block from DQM: " << testval << ", local is " << nLumi_;
218 
219  int nL = (nLumi != nullptr ? nLumi->getIntValue() : nLumi_);
220  if (nL > MAX_LUMI_SEG) {
221  LogDebug("Status") << "Too many Lumi segments, " << nL << " is greater than MAX_LUMI_SEG,"
222  << " wrapping to " << (nL % MAX_LUMI_SEG);
223  nL = nL % MAX_LUMI_SEG;
224  }
225  float delta_t = (nL - currentLumiBlockNumber_) * SECS_PER_LUMI_SECTION;
226  if (delta_t < 0) {
227  LogDebug("Status") << " time is negative ... " << delta_t;
228  delta_t = -delta_t;
229  } else if (nL == currentLumiBlockNumber_) { // divide-by-zero
230  LogInfo("Status") << "divide by zero: same lumi section 2x " << nL;
231  return;
232  }
233  // selected --------------------- fill in the rates for th
234  int currSlot = 1; // for selected bits histogram
235  MonitorElement *algoBx = dbe_->get(folderName_ + std::string("/l1AlgoBits_Vs_Bx"));
236  // selected --------------------- end
237  for (int i = 1; i <= nalgobits; ++i) { // bins start at 1
238  float current_count = algoScalers->getBinContent(i);
239  // selected -------------------- start
240  int bit = i - 1; //
241  if (std::find(algoSelected_.begin(), algoSelected_.end(), bit) != algoSelected_.end()) {
242  selected_->setBinContent(currSlot, current_count);
243  if (algoBx) {
244  for (int j = 1; j <= 3600; ++j) {
245  bxSelected_->setBinContent(j, currSlot, algoBx->getBinContent(j, i));
246  }
247  }
248  ++currSlot;
249  }
250  // selected -------------------- end
251  float rate = (current_count - l1AlgoScalerCounters_[i - 1]) / delta_t;
252  if (rate > 1E-3) {
253  LogDebug("Parameter") << "rate path " << i << " is " << rate;
254  }
257  // currentRate_->setBinError(i, error);
258  l1AlgoScalerCounters_[i - 1] = (unsigned long)(current_count);
260  }
261  // selected ----------------- start
262  MonitorElement *techBx = dbe_->get(folderName_ + std::string("/l1TechBits_Vs_Bx"));
263  // selected ----------------- end
264 
265  for (int i = 1; i <= nttbits; ++i) { // bins start at 1
266  float current_count = ttScalers->getBinContent(i);
267  // selected -------------------- start
268  int bit = i - 1; //
269  if (std::find(techSelected_.begin(), techSelected_.end(), bit) != techSelected_.end()) {
270  selected_->setBinContent(currSlot, current_count);
271  if (techBx) {
272  for (int j = 1; j <= 3600; ++j) {
273  bxSelected_->setBinContent(j, currSlot, techBx->getBinContent(j, i));
274  }
275  }
276  ++currSlot;
277  }
278  // selected -------------------- end
279  float rate = (current_count - l1TechTrigScalerCounters_[i - 1]) / delta_t;
280  if (rate > 1E-3) {
281  LogDebug("Parameter") << "rate path " << i << " is " << rate;
282  }
285  // currentRate_->setBinError(i, error);
286  l1TechTrigScalerCounters_[i - 1] = (unsigned long)(current_count);
288  }
289 
290  // compute total rate
291  MonitorElement *l1AlgoCounter = dbe_->get(folderName_ + std::string("/l1AlgoCounter"));
292  MonitorElement *l1TtCounter = dbe_->get(folderName_ + std::string("/l1TtCounter"));
293  if (l1AlgoCounter != nullptr && l1TtCounter != nullptr) {
294  float totAlgoCount = l1AlgoCounter->getIntValue();
295  float totTtCount = l1TtCounter->getIntValue();
296  float totAlgRate = (totAlgoCount - totAlgoPrevCount) / delta_t;
297  float totTtRate = (totTtCount - totTtPrevCount) / delta_t;
298  totalAlgoRate_->setBinContent(nL, totAlgRate);
299  totAlgoPrevCount = totAlgoCount;
300  totalTtRate_->setBinContent(nL, totTtRate);
301  totTtPrevCount = totTtCount;
302  }
303 
305 }
306 
307 // unused
SECS_PER_LUMI_SECTION
#define SECS_PER_LUMI_SECTION
Definition: L1ScalersClient.cc:16
mps_fire.i
i
Definition: mps_fire.py:355
L1ScalersClient::beginJob
void beginJob(void) override
BeginJob.
Definition: L1ScalersClient.cc:147
MessageLogger.h
dqm::impl::MonitorElement::setTitle
virtual void setTitle(const std::string &title)
set (ie. change) histogram/profile title
Definition: MonitorElement.cc:818
L1ScalersClient.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::Run
Definition: Run.h:45
LuminosityBlock.h
edm::LogInfo
Definition: MessageLogger.h:254
L1ScalersClient::totalAlgoRate_
MonitorElement * totalAlgoRate_
Definition: L1ScalersClient.h:66
L1ScalersClient::selected_
MonitorElement * selected_
Definition: L1ScalersClient.h:75
L1ScalersClient::L1ScalersClient
L1ScalersClient(const edm::ParameterSet &ps)
Constructors.
Definition: L1ScalersClient.cc:22
cms::cuda::assert
assert(be >=bs)
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
L1ScalersClient::dbe_
DQMStore * dbe_
Definition: L1ScalersClient.h:53
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
RPCpg::rate
double rate(double x)
Definition: Constants.cc:3
MAX_TT
#define MAX_TT
Definition: L1ScalersClient.h:19
L1ScalersClient::currentLumiBlockNumber_
int currentLumiBlockNumber_
Definition: L1ScalersClient.h:82
L1ScalersClient::l1AlgoScalerCounters_
unsigned long int l1AlgoScalerCounters_[140]
Definition: L1ScalersClient.h:62
L1ScalersClient::totAlgoPrevCount
float totAlgoPrevCount
Definition: L1ScalersClient.h:59
L1ScalersClient::l1TechTrigRateHistories_
MonitorElement * l1TechTrigRateHistories_[80]
Definition: L1ScalersClient.h:70
L1ScalersClient::numSelected_
int numSelected_
Definition: L1ScalersClient.h:80
kNumAlgoHistos
const int kNumAlgoHistos
Definition: L1ScalersClient.cc:18
L1ScalersClient::l1AlgoCurrentRatePerAlgo_
MonitorElement * l1AlgoCurrentRatePerAlgo_[140]
Definition: L1ScalersClient.h:65
Service.h
L1ScalersClient::first_tt
bool first_tt
Definition: L1ScalersClient.h:84
L1ScalersClient::totTtPrevCount
float totTtPrevCount
Definition: L1ScalersClient.h:60
kNumTTHistos
const int kNumTTHistos
Definition: L1ScalersClient.cc:19
L1ScalersClient::l1TechTrigCurrentRatePerAlgo_
MonitorElement * l1TechTrigCurrentRatePerAlgo_[80]
Definition: L1ScalersClient.h:71
L1ScalersClient::bxSelected_
MonitorElement * bxSelected_
Definition: L1ScalersClient.h:76
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
dbe_
dqm::legacy::DQMStore * dbe_
Definition: PFJetBenchmarkAnalyzer.cc:77
dqmdumpme.k
k
Definition: dqmdumpme.py:60
unpackData-CaloStage2.pname
pname
Definition: unpackData-CaloStage2.py:76
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1ScalersClient::totalTtRate_
MonitorElement * totalTtRate_
Definition: L1ScalersClient.h:72
edm::LogWarning
Definition: MessageLogger.h:141
L1ScalersClient::l1TechTrigScalerCounters_
unsigned long int l1TechTrigScalerCounters_[80]
Definition: L1ScalersClient.h:68
funct::true
true
Definition: Factorize.h:173
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
L1ScalersClient::folderName_
std::string folderName_
Definition: L1ScalersClient.h:79
edm::Service
Definition: Service.h:30
createfilelist.int
int
Definition: createfilelist.py:10
L1ScalersClient::nLumi_
int nLumi_
Definition: L1ScalersClient.h:56
MAX_ALGOS
#define MAX_ALGOS
Definition: L1ScalersClient.h:18
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
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
edm::EventSetup
Definition: EventSetup.h:57
L1ScalersClient::first_algo
bool first_algo
Definition: L1ScalersClient.h:83
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
L1ScalersClient::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: L1ScalersClient.cc:308
overlapproblemtsosanalyzer_cfi.title
title
Definition: overlapproblemtsosanalyzer_cfi.py:7
L1ScalersClient::techSelected_
std::vector< int > techSelected_
Definition: L1ScalersClient.h:78
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
kPerHisto
const int kPerHisto
Definition: L1ScalersClient.cc:17
L1ScalersClient::l1AlgoRateHistories_
MonitorElement * l1AlgoRateHistories_[140]
Definition: L1ScalersClient.h:64
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
dqm::impl::MonitorElement::getNbinsX
virtual int getNbinsX() const
get # of bins in X-axis
Definition: MonitorElement.cc:574
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
L1ScalersClient::l1TechTrigCurrentRate_
MonitorElement * l1TechTrigCurrentRate_
Definition: L1ScalersClient.h:69
L1ScalersClient::l1AlgoCurrentRate_
MonitorElement * l1AlgoCurrentRate_
Definition: L1ScalersClient.h:63
L1ScalersClient::endLuminosityBlock
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
Definition: L1ScalersClient.cc:162
L1ScalersClient::endRun
void endRun(const edm::Run &run, const edm::EventSetup &c) override
EndRun.
Definition: L1ScalersClient.cc:158
L1ScalersClient::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
BeginRun.
Definition: L1ScalersClient.cc:155
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
MAX_LUMI_SEG
#define MAX_LUMI_SEG
Definition: L1Scalers.h:13
dqm::impl::MonitorElement::getBinContent
virtual double getBinContent(int binx) const
get content of bin (1-D)
Definition: MonitorElement.cc:592
dqm::impl::MonitorElement::getIntValue
virtual int64_t getIntValue() const
Definition: MonitorElement.cc:912
L1ScalersClient::algoSelected_
std::vector< int > algoSelected_
Definition: L1ScalersClient.h:77
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
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37