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_(consumes<L1GlobalTriggerReadoutRecord>(ps.getParameter<edm::InputTag>("l1GtData"))),
41  l1GmtDataSource_(consumes<L1MuGMTReadoutCollection>(ps.getParameter<edm::InputTag>("l1GtData"))),
42  denomIsTech_(ps.getUntrackedParameter<bool>("denomIsTech", true)),
43  denomBit_(ps.getUntrackedParameter<unsigned int>("denomBit", 40)),
44  tfIsTech_(ps.getUntrackedParameter<bool>("tfIsTech", true)),
45  tfBit_(ps.getUntrackedParameter<unsigned int>("tfBit", 41)),
46  algoSelected_(ps.getUntrackedParameter<std::vector<unsigned int> >(
47  "algoMonitorBits", std::vector<unsigned int>())),
48  techSelected_(ps.getUntrackedParameter<std::vector<unsigned int> >(
49  "techMonitorBits", std::vector<unsigned int>())),
50  folderName_(ps.getUntrackedParameter<std::string>(
51  "dqmFolder", std::string("L1T/L1Scalers_EvF"))),
52  l1scalers_(0),
53  l1techScalers_(0),
54  l1Correlations_(0),
55  bxNum_(0),
56  l1scalersBx_(0),
57  l1techScalersBx_(0),
58  nLumiBlock_(0),
59  l1AlgoCounter_(0),
60  l1TtCounter_(0),
61  fedStart_(ps.getUntrackedParameter<unsigned int>("firstFED", 0)),
62  fedStop_(ps.getUntrackedParameter<unsigned int>("lastFED", 931)),
63  rateAlgoCounter_(0),
64  rateTtCounter_(0),
65  fedRawCollection_(ps.getParameter<edm::InputTag>("fedRawData")),
66  maskedList_(ps.getUntrackedParameter<std::vector<int> >(
67  "maskedChannels",
68  std::vector<int>())), // this is using the ashed index
69  HcalRecHitCollection_(
70  ps.getParameter<edm::InputTag>("HFRecHitCollection")) {
71  LogDebug("Status") << "constructor";
72 }
73 
75  edm::EventSetup const&) {
77  l1scalers_ =
78  iBooker.book1D("l1AlgoBits", "L1 Algorithm Bits", 128, -0.5, 127.5);
79  l1scalersBx_ = iBooker.book2D("l1AlgoBits_Vs_Bx",
80  "L1 Algorithm Bits vs "
81  "Bunch Number",
82  3600, -0.5, 3599.5, 128, -0.5, 127.5);
83  l1Correlations_ = iBooker.book2D("l1Correlations",
84  "L1 Algorithm Bits "
85  "Correlations",
86  128, -0.5, 127.5, 128, -0.5, 127.5);
88  iBooker.book1D("l1TechBits", "L1 Tech. Trigger Bits", 64, -0.5, 63.5);
89  l1techScalersBx_ = iBooker.book2D("l1TechBits_Vs_Bx",
90  "L1 Technical "
91  "Trigger "
92  "Bits vs Bunch Number",
93  3600, -0.5, 3599.5, 64, -0.5, 63.5);
94  bxNum_ = iBooker.book1D("bxNum", "Bunch number from GTFE", 3600, -0.5, 3599.5);
95 
96  nLumiBlock_ = iBooker.bookInt("nLumiBlock");
97 
98  // l1 total rate
99  l1AlgoCounter_ = iBooker.bookInt("l1AlgoCounter");
100  l1TtCounter_ = iBooker.bookInt("l1TtCounter");
101 
102  // timing plots
103  std::stringstream sdenom;
104  if (denomIsTech_)
105  sdenom << "tech";
106  else
107  sdenom << "algo";
108 
109  iBooker.setCurrentFolder(folderName_ + "/Synch");
110  algoBxDiff_.clear();
111  algoBxDiff_.clear();
112  algoBxDiffLumi_.clear();
113  techBxDiffLumi_.clear();
114  for (uint ibit = 0; ibit < algoSelected_.size(); ibit++) {
115  std::stringstream ss;
116  ss << algoSelected_[ibit] << "_" << sdenom.str() << denomBit_;
117  algoBxDiff_.push_back(iBooker.book1D("BX_diff_algo" + ss.str(),
118  "BX_diff_algo" + ss.str(), 9, -4, 5));
119  algoBxDiffLumi_.push_back(
120  iBooker.book2D("BX_diffvslumi_algo" + ss.str(), "BX_diff_algo" + ss.str(),
121  MAX_LUMI_BIN, -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5));
122  // algoBxDiffLumi_[ibit]->setAxisTitle("Lumi Section", 1);
123  }
124  for (uint ibit = 0; ibit < techSelected_.size(); ibit++) {
125  std::stringstream ss;
126  ss << techSelected_[ibit] << "_" << sdenom.str() << denomBit_;
127  techBxDiff_.push_back(iBooker.book1D("BX_diff_tech" + ss.str(),
128  "BX_diff_tech" + ss.str(), 9, -4, 5));
129  techBxDiffLumi_.push_back(
130  iBooker.book2D("BX_diffvslumi_tech" + ss.str(), "BX_diff_tech" + ss.str(),
131  MAX_LUMI_BIN, -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5));
132  // techBxDiffLumi_[ibit]->setAxisTitle("Lumi Section", 1);
133  }
134 
135  // GMT timing plots
136  std::stringstream ss1;
137  ss1 << "_" << sdenom.str() << denomBit_;
138  dtBxDiff_ = iBooker.book1D("BX_diff_DT" + ss1.str(), "BX_diff_DT" + ss1.str(),
139  9, -4, 5);
140  dtBxDiffLumi_ = iBooker.book2D("BX_diffvslumi_DT" + ss1.str(),
141  "BX_diffvslumi_DT" + ss1.str(), MAX_LUMI_BIN,
142  -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5);
143  cscBxDiff_ = iBooker.book1D("BX_diff_CSC" + ss1.str(),
144  "BX_diff_CSC" + ss1.str(), 9, -4, 5);
145  cscBxDiffLumi_ = iBooker.book2D("BX_diffvslumi_CSC" + ss1.str(),
146  "BX_diffvslumi_CSC" + ss1.str(), MAX_LUMI_BIN,
147  -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5);
148  rpcbBxDiff_ = iBooker.book1D("BX_diff_RPCb" + ss1.str(),
149  "BX_diff_RPCb" + ss1.str(), 9, -4, 5);
150  rpcbBxDiffLumi_ = iBooker.book2D("BX_diffvslumi_RPCb" + ss1.str(),
151  "BX_diffvslumi_RPCb" + ss1.str(), MAX_LUMI_BIN,
152  -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5);
153  rpcfBxDiff_ = iBooker.book1D("BX_diff_RPCf" + ss1.str(),
154  "BX_diff_RPCf" + ss1.str(), 9, -4, 5);
155  rpcfBxDiffLumi_ = iBooker.book2D("BX_diffvslumi_RPCf" + ss1.str(),
156  "BX_diffvslumi_RPCf" + ss1.str(), MAX_LUMI_BIN,
157  -0.5, double(MAX_LUMI_SEG) - 0.5, 9, -4, 5);
158 }
159 
160 void L1Scalers::analyze(const edm::Event& e, const edm::EventSetup& iSetup) {
161  nev_++;
162 
163  LogDebug("Status") << "L1Scalers::analyze event " << nev_;
164 
165  // int myGTFEbx = -1;
166  // get Global Trigger decision and the decision word
167  // these are locally derived
169  bool t = e.getByToken(l1GtDataSource_, gtRecord);
170 
171  if (!t) {
172  LogDebug("Product") << "can't find L1GlobalTriggerReadoutRecord";
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.getByToken(l1GmtDataSource_, gmtCollection);
251 
252  if (!gmtCollection.isValid()) {
253  edm::LogInfo("DataNotFound")
254  << "can't find L1MuGMTReadoutCollection with label";
255  }
256 
257  // remember the bx of 1st candidate of each system (9=none)
258  int bx1st[4] = {9, 9, 9, 9};
259 
260  if (tfBitGood) { // to avoid single BSC hits
261 
262  for (int iebx = 0; iebx <= 4; iebx++) {
263  TechnicalTriggerWord tw = gtRecord->technicalTriggerWord(iebx - 2);
264  DecisionWord gtDecisionWord = gtRecord->decisionWord(iebx - 2);
265 
266  bool denomBitGood = false;
267 
268  // check if reference bit is valid
269  if (denomIsTech_) {
270  if (!tw.empty()) {
271  if (denomBit_ < tw.size()) {
272  denomBitGood = true;
273  if (tw[denomBit_] && earliestDenom_ == 9) earliestDenom_ = iebx;
274  }
275  }
276  } else {
277  if (!gtDecisionWord.empty()) {
278  if (denomBit_ < gtDecisionWord.size()) {
279  denomBitGood = true;
280  if (gtDecisionWord[denomBit_] && earliestDenom_ == 9)
281  earliestDenom_ = iebx;
282  }
283  }
284  }
285 
286  if (denomBitGood) {
287  // get earliest tech bx's
288  if (!tw.empty()) {
289  for (uint ibit = 0; ibit < techSelected_.size(); ibit++) {
290  if (techSelected_[ibit] < tw.size()) {
291  if (tw[techSelected_[ibit]] && earliestTech_[ibit] == 9)
292  earliestTech_[ibit] = iebx;
293  }
294  }
295  }
296 
297  // get earliest algo bx's
298  if (!gtDecisionWord.empty()) {
299  for (uint ibit = 0; ibit < algoSelected_.size(); ibit++) {
300  if (algoSelected_[ibit] < gtDecisionWord.size()) {
301  if (gtDecisionWord[algoSelected_[ibit]] &&
302  earliestAlgo_[ibit] == 9)
303  earliestAlgo_[ibit] = iebx;
304  }
305  }
306  }
307  } // denomBitGood
308  } // bx
309 
310  // get earliest single muon trigger system bx's
311  if (gmtCollection.isValid()) {
312  // get GMT readout collection
313  L1MuGMTReadoutCollection const* gmtrc = gmtCollection.product();
314  // get record vector
315  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
316  // loop over records of individual bx's
317  std::vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
318 
319  for (RRItr = gmt_records.begin(); RRItr != gmt_records.end();
320  RRItr++) { // loop from BX=-2 to BX=2
321  std::vector<L1MuRegionalCand> INPCands[4] = {
322  RRItr->getDTBXCands(), RRItr->getBrlRPCCands(),
323  RRItr->getCSCCands(), RRItr->getFwdRPCCands()};
324  std::vector<L1MuRegionalCand>::const_iterator INPItr;
325  int BxInEvent = RRItr->getBxInEvent();
326 
327  // find the first non-empty candidate in this bx
328  for (int i = 0; i < 4; i++) { // for each single muon trigger system
329  for (INPItr = INPCands[i].begin(); INPItr != INPCands[i].end();
330  ++INPItr) {
331  if (!INPItr->empty()) {
332  if (bx1st[i] == 9)
333  bx1st[i] = BxInEvent +
334  2; // must go from 0 to 4 (consistent with above)
335  }
336  }
337  }
338  }
339  } // gmtCollection.isValid
340  // calculated bx difference
341  if (earliestDenom_ != 9) {
342  for (uint ibit = 0; ibit < techSelected_.size(); ibit++) {
343  if (earliestTech_[ibit] != 9) {
344  int diff = earliestTech_[ibit] - earliestDenom_;
345  techBxDiff_[ibit]->Fill(diff);
346  techBxDiffLumi_[ibit]->Fill(e.luminosityBlock(), diff);
347  }
348  }
349  for (uint ibit = 0; ibit < algoSelected_.size(); ibit++) {
350  if (earliestAlgo_[ibit] != 9) {
351  int diff = earliestAlgo_[ibit] - earliestDenom_;
352  algoBxDiff_[ibit]->Fill(diff);
353  algoBxDiffLumi_[ibit]->Fill(e.luminosityBlock(), diff);
354  }
355  }
356 
357  if (bx1st[0] != 9) {
358  int diff = bx1st[0] - earliestDenom_;
359  dtBxDiff_->Fill(diff);
361  }
362  if (bx1st[1] != 9) {
363  int diff = bx1st[1] - earliestDenom_;
364  rpcbBxDiff_->Fill(diff);
366  }
367  if (bx1st[2] != 9) {
368  int diff = bx1st[2] - earliestDenom_;
369  cscBxDiff_->Fill(diff);
371  }
372  if (bx1st[3] != 9) {
373  int diff = bx1st[3] - earliestDenom_;
374  rpcfBxDiff_->Fill(diff);
376  }
377  }
378  } // tt41Good
379  }
380  return;
381 }
382 
384  const edm::EventSetup& iSetup) {
385  nLumiBlock_->Fill(lumiSeg.id().luminosityBlock());
386 }
#define LogDebug(id)
LuminosityBlockID id() const
int i
Definition: DBlmapReader.cc:9
bool tfIsTech_
Definition: L1Scalers.h:37
MonitorElement * l1scalers_
Definition: L1Scalers.h:43
std::vector< MonitorElement * > techBxDiff_
Definition: L1Scalers.h:59
std::vector< MonitorElement * > algoBxDiffLumi_
Definition: L1Scalers.h:60
std::vector< MonitorElement * > algoBxDiff_
Definition: L1Scalers.h:58
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::string folderName_
Definition: L1Scalers.h:42
MonitorElement * rpcfBxDiffLumi_
Definition: L1Scalers.h:69
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:62
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: L1Scalers.cc:74
MonitorElement * rpcbBxDiffLumi_
Definition: L1Scalers.h:67
MonitorElement * dtBxDiffLumi_
Definition: L1Scalers.h:63
list diff
Definition: mps_update.py:85
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
DQM Client Diagnostic should be performed here:
Definition: L1Scalers.cc:383
std::vector< int > earliestTech_
Definition: L1Scalers.h:84
void Fill(long long x)
bool denomIsTech_
Definition: L1Scalers.h:35
#define MAX_LUMI_SEG
Definition: L1Scalers.h:14
void analyze(const edm::Event &e, const edm::EventSetup &c)
Definition: L1Scalers.cc:160
MonitorElement * cscBxDiff_
Definition: L1Scalers.h:64
MonitorElement * l1techScalers_
Definition: L1Scalers.h:44
std::vector< bool > DecisionWord
typedefs
MonitorElement * l1scalersBx_
Definition: L1Scalers.h:49
int nev_
Definition: L1Scalers.h:29
#define MAX_LUMI_BIN
Definition: L1Scalers.h:15
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
MonitorElement * l1TtCounter_
Definition: L1Scalers.h:55
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
std::vector< MonitorElement * > techBxDiffLumi_
Definition: L1Scalers.h:61
bool isValid() const
Definition: HandleBase.h:75
std::vector< unsigned int > algoSelected_
Definition: L1Scalers.h:39
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:45
std::vector< unsigned int > techSelected_
Definition: L1Scalers.h:40
MonitorElement * rpcbBxDiff_
Definition: L1Scalers.h:66
MonitorElement * dtBxDiff_
Definition: L1Scalers.h:62
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > l1GtDataSource_
Definition: L1Scalers.h:32
T const * product() const
Definition: Handle.h:81
unsigned int rateAlgoCounter_
Definition: L1Scalers.h:75
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::vector< int > earliestAlgo_
Definition: L1Scalers.h:85
edm::EDGetTokenT< L1MuGMTReadoutCollection > l1GmtDataSource_
Definition: L1Scalers.h:33
int earliestDenom_
Definition: L1Scalers.h:83
MonitorElement * nLumiBlock_
Definition: L1Scalers.h:53
unsigned int tfBit_
Definition: L1Scalers.h:38
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * bxNum_
Definition: L1Scalers.h:46
MonitorElement * l1techScalersBx_
Definition: L1Scalers.h:50
#define begin
Definition: vmac.h:30
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
MonitorElement * l1AlgoCounter_
Definition: L1Scalers.h:54
unsigned int denomBit_
Definition: L1Scalers.h:36
volatile std::atomic< bool > shutdown_flag false
MonitorElement * rpcfBxDiff_
Definition: L1Scalers.h:68
Definition: Run.h:43
unsigned int rateTtCounter_
Definition: L1Scalers.h:76
MonitorElement * cscBxDiffLumi_
Definition: L1Scalers.h:65