test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1Scalers.cc
Go to the documentation of this file.
1 #include <iostream>
2 
3 // FW
5 
7 
9 
11 
12 // L1
14 
19 
21 
28 
29 // HACK START
33 // HACK END
34 
35 using namespace edm;
36 
38  : nev_(0),
39  verbose_(ps.getUntrackedParameter<bool>("verbose", false)),
40  l1GtDataSource_(ps.getParameter<edm::InputTag>("l1GtData")),
41  denomIsTech_(ps.getUntrackedParameter<bool>("denomIsTech", true)),
42  denomBit_(ps.getUntrackedParameter<unsigned int>("denomBit", 40)),
43  tfIsTech_(ps.getUntrackedParameter<bool>("tfIsTech", true)),
44  tfBit_(ps.getUntrackedParameter<unsigned int>("tfBit", 41)),
45  algoSelected_(ps.getUntrackedParameter<std::vector<unsigned int> >(
46  "algoMonitorBits", std::vector<unsigned int>())),
47  techSelected_(ps.getUntrackedParameter<std::vector<unsigned int> >(
48  "techMonitorBits", std::vector<unsigned int>())),
49  folderName_(ps.getUntrackedParameter<std::string>(
50  "dqmFolder", std::string("L1T/L1Scalers_EvF"))),
51  l1scalers_(0),
52  l1techScalers_(0),
53  l1Correlations_(0),
54  bxNum_(0),
55  l1scalersBx_(0),
56  l1techScalersBx_(0),
57  nLumiBlock_(0),
58  l1AlgoCounter_(0),
59  l1TtCounter_(0),
60  fedStart_(ps.getUntrackedParameter<unsigned int>("firstFED", 0)),
61  fedStop_(ps.getUntrackedParameter<unsigned int>("lastFED", 931)),
62  rateAlgoCounter_(0),
63  rateTtCounter_(0),
64  fedRawCollection_(ps.getParameter<edm::InputTag>("fedRawData")),
65  maskedList_(ps.getUntrackedParameter<std::vector<int> >(
66  "maskedChannels",
67  std::vector<int>())), // this is using the ashed index
68  HcalRecHitCollection_(
69  ps.getParameter<edm::InputTag>("HFRecHitCollection")) {
70  LogDebug("Status") << "constructor";
71 }
72 
74  edm::EventSetup const&) {
76  l1scalers_ =
77  iBooker.book1D("l1AlgoBits", "L1 Algorithm Bits", 128, -0.5, 127.5);
78  l1scalersBx_ = iBooker.book2D("l1AlgoBits_Vs_Bx",
79  "L1 Algorithm Bits vs "
80  "Bunch Number",
81  3600, -0.5, 3599.5, 128, -0.5, 127.5);
82  l1Correlations_ = iBooker.book2D("l1Correlations",
83  "L1 Algorithm Bits "
84  "Correlations",
85  128, -0.5, 127.5, 128, -0.5, 127.5);
87  iBooker.book1D("l1TechBits", "L1 Tech. Trigger Bits", 64, -0.5, 63.5);
88  l1techScalersBx_ = iBooker.book2D("l1TechBits_Vs_Bx",
89  "L1 Technical "
90  "Trigger "
91  "Bits vs Bunch Number",
92  3600, -0.5, 3599.5, 64, -0.5, 63.5);
93  bxNum_ = iBooker.book1D("bxNum", "Bunch number from GTFE", 3600, -0.5, 3599.5);
94 
95  nLumiBlock_ = iBooker.bookInt("nLumiBlock");
96 
97  // l1 total rate
98  l1AlgoCounter_ = iBooker.bookInt("l1AlgoCounter");
99  l1TtCounter_ = iBooker.bookInt("l1TtCounter");
100 
101  // timing plots
102  std::stringstream sdenom;
103  if (denomIsTech_)
104  sdenom << "tech";
105  else
106  sdenom << "algo";
107 
108  iBooker.setCurrentFolder(folderName_ + "/Synch");
109  algoBxDiff_.clear();
110  algoBxDiff_.clear();
111  algoBxDiffLumi_.clear();
112  techBxDiffLumi_.clear();
113  for (uint ibit = 0; ibit < algoSelected_.size(); ibit++) {
114  std::stringstream ss;
115  ss << algoSelected_[ibit] << "_" << sdenom.str() << denomBit_;
116  algoBxDiff_.push_back(iBooker.book1D("BX_diff_algo" + ss.str(),
117  "BX_diff_algo" + ss.str(), 9, -4, 5));
118  algoBxDiffLumi_.push_back(
119  iBooker.book2D("BX_diffvslumi_algo" + ss.str(), "BX_diff_algo" + ss.str(),
120  MAX_LUMI_BIN, -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5));
121  // algoBxDiffLumi_[ibit]->setAxisTitle("Lumi Section", 1);
122  }
123  for (uint ibit = 0; ibit < techSelected_.size(); ibit++) {
124  std::stringstream ss;
125  ss << techSelected_[ibit] << "_" << sdenom.str() << denomBit_;
126  techBxDiff_.push_back(iBooker.book1D("BX_diff_tech" + ss.str(),
127  "BX_diff_tech" + ss.str(), 9, -4, 5));
128  techBxDiffLumi_.push_back(
129  iBooker.book2D("BX_diffvslumi_tech" + ss.str(), "BX_diff_tech" + ss.str(),
130  MAX_LUMI_BIN, -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5));
131  // techBxDiffLumi_[ibit]->setAxisTitle("Lumi Section", 1);
132  }
133 
134  // GMT timing plots
135  std::stringstream ss1;
136  ss1 << "_" << sdenom.str() << denomBit_;
137  dtBxDiff_ = iBooker.book1D("BX_diff_DT" + ss1.str(), "BX_diff_DT" + ss1.str(),
138  9, -4, 5);
139  dtBxDiffLumi_ = iBooker.book2D("BX_diffvslumi_DT" + ss1.str(),
140  "BX_diffvslumi_DT" + ss1.str(), MAX_LUMI_BIN,
141  -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5);
142  cscBxDiff_ = iBooker.book1D("BX_diff_CSC" + ss1.str(),
143  "BX_diff_CSC" + ss1.str(), 9, -4, 5);
144  cscBxDiffLumi_ = iBooker.book2D("BX_diffvslumi_CSC" + ss1.str(),
145  "BX_diffvslumi_CSC" + ss1.str(), MAX_LUMI_BIN,
146  -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5);
147  rpcbBxDiff_ = iBooker.book1D("BX_diff_RPCb" + ss1.str(),
148  "BX_diff_RPCb" + ss1.str(), 9, -4, 5);
149  rpcbBxDiffLumi_ = iBooker.book2D("BX_diffvslumi_RPCb" + ss1.str(),
150  "BX_diffvslumi_RPCb" + ss1.str(), MAX_LUMI_BIN,
151  -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5);
152  rpcfBxDiff_ = iBooker.book1D("BX_diff_RPCf" + ss1.str(),
153  "BX_diff_RPCf" + ss1.str(), 9, -4, 5);
154  rpcfBxDiffLumi_ = iBooker.book2D("BX_diffvslumi_RPCf" + ss1.str(),
155  "BX_diffvslumi_RPCf" + ss1.str(), MAX_LUMI_BIN,
156  -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5);
157 }
158 
159 void L1Scalers::analyze(const edm::Event& e, const edm::EventSetup& iSetup) {
160  nev_++;
161 
162  LogDebug("Status") << "L1Scalers::analyze event " << nev_;
163 
164  // int myGTFEbx = -1;
165  // get Global Trigger decision and the decision word
166  // these are locally derived
168  bool t = e.getByLabel(l1GtDataSource_, gtRecord);
169 
170  if (!t) {
171  LogDebug("Product") << "can't find L1GlobalTriggerReadoutRecord "
172  << "with label " << l1GtDataSource_.label();
173  } else {
174  L1GtfeWord gtfeWord = gtRecord->gtfeWord();
175  int gtfeBx = gtfeWord.bxNr();
176  bxNum_->Fill(gtfeBx);
177 
178  bool tfBitGood = false;
179 
180  // First, the default
181  // vector of bool
182  for (int iebx = 0; iebx <= 4; iebx++) {
183  // Algorithm Bits
184  DecisionWord gtDecisionWord = gtRecord->decisionWord(iebx - 2);
185  // DecisionWord gtDecisionWord = gtRecord->decisionWord();
186  if (!gtDecisionWord.empty()) { // if board not there this is zero
187  // loop over dec. bit to get total rate (no overlap)
188  for (uint i = 0; i < gtDecisionWord.size(); ++i) {
189  if (gtDecisionWord[i]) {
192  break;
193  }
194  }
195  // loop over decision bits
196  for (uint i = 0; i < gtDecisionWord.size(); ++i) {
197  if (gtDecisionWord[i]) {
198  l1scalers_->Fill(i);
199  l1scalersBx_->Fill(gtfeBx - 2 + iebx, i);
200  for (uint j = i + 1; j < gtDecisionWord.size(); ++j) {
201  if (gtDecisionWord[j]) {
202  l1Correlations_->Fill(i, j);
203  l1Correlations_->Fill(j, i);
204  }
205  }
206  }
207  }
208  }
209 
210  // loop over technical triggers
211  // vector of bool again.
212  TechnicalTriggerWord tw = gtRecord->technicalTriggerWord(iebx - 2);
213  // TechnicalTriggerWord tw = gtRecord->technicalTriggerWord();
214  if (!tw.empty()) {
215  // loop over dec. bit to get total rate (no overlap)
216  for (uint i = 0; i < tw.size(); ++i) {
217  if (tw[i]) {
218  rateTtCounter_++;
220  break;
221  }
222  }
223  for (uint i = 0; i < tw.size(); ++i) {
224  if (tw[i]) {
225  l1techScalers_->Fill(i);
226  l1techScalersBx_->Fill(gtfeBx - 2 + iebx, i);
227  }
228  }
229 
230  // check if bit used to filter timing plots fired in this event
231  // (anywhere in the bx window)
232  if (tfIsTech_) {
233  if (tfBit_ < tw.size()) {
234  if (tw[tfBit_]) tfBitGood = true;
235  }
236  }
237  } // ! tw.empty
238 
239  } // bx
240 
241  // timing plots
242  earliestDenom_ = 9;
243  earliestAlgo_.clear();
244  earliestTech_.clear();
245  for (uint i = 0; i < techSelected_.size(); i++) earliestTech_.push_back(9);
246  for (uint i = 0; i < algoSelected_.size(); i++) earliestAlgo_.push_back(9);
247 
248  // GMT information
250  e.getByLabel(l1GtDataSource_, gmtCollection);
251 
252  if (!gmtCollection.isValid()) {
253  edm::LogInfo("DataNotFound")
254  << "can't find L1MuGMTReadoutCollection with label "
255  << l1GtDataSource_.label();
256  }
257 
258  // remember the bx of 1st candidate of each system (9=none)
259  int bx1st[4] = {9, 9, 9, 9};
260 
261  if (tfBitGood) { // to avoid single BSC hits
262 
263  for (int iebx = 0; iebx <= 4; iebx++) {
264  TechnicalTriggerWord tw = gtRecord->technicalTriggerWord(iebx - 2);
265  DecisionWord gtDecisionWord = gtRecord->decisionWord(iebx - 2);
266 
267  bool denomBitGood = false;
268 
269  // check if reference bit is valid
270  if (denomIsTech_) {
271  if (!tw.empty()) {
272  if (denomBit_ < tw.size()) {
273  denomBitGood = true;
274  if (tw[denomBit_] && earliestDenom_ == 9) earliestDenom_ = iebx;
275  }
276  }
277  } else {
278  if (!gtDecisionWord.empty()) {
279  if (denomBit_ < gtDecisionWord.size()) {
280  denomBitGood = true;
281  if (gtDecisionWord[denomBit_] && earliestDenom_ == 9)
282  earliestDenom_ = iebx;
283  }
284  }
285  }
286 
287  if (denomBitGood) {
288  // get earliest tech bx's
289  if (!tw.empty()) {
290  for (uint ibit = 0; ibit < techSelected_.size(); ibit++) {
291  if (techSelected_[ibit] < tw.size()) {
292  if (tw[techSelected_[ibit]] && earliestTech_[ibit] == 9)
293  earliestTech_[ibit] = iebx;
294  }
295  }
296  }
297 
298  // get earliest algo bx's
299  if (!gtDecisionWord.empty()) {
300  for (uint ibit = 0; ibit < algoSelected_.size(); ibit++) {
301  if (algoSelected_[ibit] < gtDecisionWord.size()) {
302  if (gtDecisionWord[algoSelected_[ibit]] &&
303  earliestAlgo_[ibit] == 9)
304  earliestAlgo_[ibit] = iebx;
305  }
306  }
307  }
308  } // denomBitGood
309  } // bx
310 
311  // get earliest single muon trigger system bx's
312  if (gmtCollection.isValid()) {
313  // get GMT readout collection
314  L1MuGMTReadoutCollection const* gmtrc = gmtCollection.product();
315  // get record vector
316  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
317  // loop over records of individual bx's
318  std::vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
319 
320  for (RRItr = gmt_records.begin(); RRItr != gmt_records.end();
321  RRItr++) { // loop from BX=-2 to BX=2
322  std::vector<L1MuRegionalCand> INPCands[4] = {
323  RRItr->getDTBXCands(), RRItr->getBrlRPCCands(),
324  RRItr->getCSCCands(), RRItr->getFwdRPCCands()};
325  std::vector<L1MuRegionalCand>::const_iterator INPItr;
326  int BxInEvent = RRItr->getBxInEvent();
327 
328  // find the first non-empty candidate in this bx
329  for (int i = 0; i < 4; i++) { // for each single muon trigger system
330  for (INPItr = INPCands[i].begin(); INPItr != INPCands[i].end();
331  ++INPItr) {
332  if (!INPItr->empty()) {
333  if (bx1st[i] == 9)
334  bx1st[i] = BxInEvent +
335  2; // must go from 0 to 4 (consistent with above)
336  }
337  }
338  }
339  }
340  } // gmtCollection.isValid
341  // calculated bx difference
342  if (earliestDenom_ != 9) {
343  for (uint ibit = 0; ibit < techSelected_.size(); ibit++) {
344  if (earliestTech_[ibit] != 9) {
345  int diff = earliestTech_[ibit] - earliestDenom_;
346  techBxDiff_[ibit]->Fill(diff);
347  techBxDiffLumi_[ibit]->Fill(e.luminosityBlock(), diff);
348  }
349  }
350  for (uint ibit = 0; ibit < algoSelected_.size(); ibit++) {
351  if (earliestAlgo_[ibit] != 9) {
352  int diff = earliestAlgo_[ibit] - earliestDenom_;
353  algoBxDiff_[ibit]->Fill(diff);
354  algoBxDiffLumi_[ibit]->Fill(e.luminosityBlock(), diff);
355  }
356  }
357 
358  if (bx1st[0] != 9) {
359  int diff = bx1st[0] - earliestDenom_;
360  dtBxDiff_->Fill(diff);
362  }
363  if (bx1st[1] != 9) {
364  int diff = bx1st[1] - earliestDenom_;
365  rpcbBxDiff_->Fill(diff);
367  }
368  if (bx1st[2] != 9) {
369  int diff = bx1st[2] - earliestDenom_;
370  cscBxDiff_->Fill(diff);
372  }
373  if (bx1st[3] != 9) {
374  int diff = bx1st[3] - earliestDenom_;
375  rpcfBxDiff_->Fill(diff);
377  }
378  }
379  } // tt41Good
380  }
381  return;
382 }
383 
385  const edm::EventSetup& iSetup) {
386  nLumiBlock_->Fill(lumiSeg.id().luminosityBlock());
387 }
#define LogDebug(id)
LuminosityBlockID id() const
int i
Definition: DBlmapReader.cc:9
bool tfIsTech_
Definition: L1Scalers.h:33
MonitorElement * l1scalers_
Definition: L1Scalers.h:39
std::vector< MonitorElement * > techBxDiff_
Definition: L1Scalers.h:55
std::vector< MonitorElement * > algoBxDiffLumi_
Definition: L1Scalers.h:56
edm::InputTag l1GtDataSource_
Definition: L1Scalers.h:29
std::vector< MonitorElement * > algoBxDiff_
Definition: L1Scalers.h:54
std::string folderName_
Definition: L1Scalers.h:38
MonitorElement * rpcfBxDiffLumi_
Definition: L1Scalers.h:65
MonitorElement * bookInt(Args &&...args)
Definition: DQMStore.h:103
L1Scalers(const edm::ParameterSet &ps)
Definition: L1Scalers.cc:37
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: L1Scalers.cc:73
MonitorElement * rpcbBxDiffLumi_
Definition: L1Scalers.h:63
MonitorElement * dtBxDiffLumi_
Definition: L1Scalers.h:59
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
DQM Client Diagnostic should be performed here:
Definition: L1Scalers.cc:384
std::vector< int > earliestTech_
Definition: L1Scalers.h:80
void Fill(long long x)
bool denomIsTech_
Definition: L1Scalers.h:31
#define MAX_LUMI_SEG
Definition: L1Scalers.h:11
void analyze(const edm::Event &e, const edm::EventSetup &c)
Definition: L1Scalers.cc:159
MonitorElement * cscBxDiff_
Definition: L1Scalers.h:60
MonitorElement * l1techScalers_
Definition: L1Scalers.h:40
std::vector< bool > DecisionWord
typedefs
MonitorElement * l1scalersBx_
Definition: L1Scalers.h:45
int nev_
Definition: L1Scalers.h:26
#define MAX_LUMI_BIN
Definition: L1Scalers.h:12
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
MonitorElement * l1TtCounter_
Definition: L1Scalers.h:51
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
std::vector< MonitorElement * > techBxDiffLumi_
Definition: L1Scalers.h:57
bool isValid() const
Definition: HandleBase.h:75
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
std::vector< unsigned int > algoSelected_
Definition: L1Scalers.h:35
const cms_uint16_t bxNr() const
get/set bunch cross number as counted in the GTFE board
Definition: L1GtfeWord.h:122
MonitorElement * l1Correlations_
Definition: L1Scalers.h:41
std::vector< unsigned int > techSelected_
Definition: L1Scalers.h:36
MonitorElement * rpcbBxDiff_
Definition: L1Scalers.h:62
MonitorElement * dtBxDiff_
Definition: L1Scalers.h:58
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
T const * product() const
Definition: Handle.h:81
unsigned int rateAlgoCounter_
Definition: L1Scalers.h:71
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::vector< int > earliestAlgo_
Definition: L1Scalers.h:81
int earliestDenom_
Definition: L1Scalers.h:79
MonitorElement * nLumiBlock_
Definition: L1Scalers.h:49
unsigned int tfBit_
Definition: L1Scalers.h:34
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * bxNum_
Definition: L1Scalers.h:42
MonitorElement * l1techScalersBx_
Definition: L1Scalers.h:46
std::string const & label() const
Definition: InputTag.h:43
#define begin
Definition: vmac.h:30
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
MonitorElement * l1AlgoCounter_
Definition: L1Scalers.h:50
unsigned int denomBit_
Definition: L1Scalers.h:32
volatile std::atomic< bool > shutdown_flag false
MonitorElement * rpcfBxDiff_
Definition: L1Scalers.h:64
Definition: Run.h:43
unsigned int rateTtCounter_
Definition: L1Scalers.h:72
MonitorElement * cscBxDiffLumi_
Definition: L1Scalers.h:61