CMS 3D CMS Logo

GEMDQMStatusDigi.cc
Go to the documentation of this file.
9 
10 
14 
18 
19 #include <string>
20 
21 //----------------------------------------------------------------------------------------------------
22 
24 {
25 public:
27  ~GEMDQMStatusDigi() override {};
28  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
29 
30 protected:
31  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
32  void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
33  void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override {};
34  void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& eSetup) override {};
35  void endRun(edm::Run const& run, edm::EventSetup const& eSetup) override {};
36 
37 private:
38  int nVfat_ = 24;
39  int cBit_ = 9;
40  int eBit_ = 13;
44 
45  int AMCBinN(uint16_t BID_);
46  int GEBBinN(uint16_t BID_);
47 
51 
54 
58 
61 
65 
68 
72 
75 
81 
87 
88  std::unordered_map<uint16_t, int> mlAMCID_;
89  std::unordered_map<uint16_t, int> mlGEBID_;
90 
91 
92 };
93 
94 using namespace std;
95 using namespace edm;
96 
98 {
99 
100  tagVFAT_ = consumes<GEMVfatStatusDigiCollection>(cfg.getParameter<edm::InputTag>("VFATInputLabel"));
101  tagGEB_ = consumes<GEMGEBStatusDigiCollection>(cfg.getParameter<edm::InputTag>("GEBInputLabel"));
102  tagAMC_ = consumes<GEMAMCStatusDigiCollection>(cfg.getParameter<edm::InputTag>("AMCInputLabel"));
103 
104 }
105 
107 {
109  desc.add<edm::InputTag>("VFATInputLabel", edm::InputTag("muonGEMDigis", "vfatStatus"));
110  desc.add<edm::InputTag>("GEBInputLabel", edm::InputTag("muonGEMDigis", "GEBStatus"));
111  desc.add<edm::InputTag>("AMCInputLabel", edm::InputTag("muonGEMDigis", "AMCStatus"));
112  descriptions.add("GEMDQMStatusDigi", desc);
113 }
114 
115 int GEMDQMStatusDigi::AMCBinN(uint16_t BID_) {
116 
117  if(mlAMCID_.find(BID_) == mlAMCID_.end()){
118  int addIdx = mlAMCID_.size();
119  mlAMCID_[BID_] = addIdx;
120 
121  int nNumAMC = (int)mlAMCID_.size();
122  string strLabel = "BID: "+to_string(BID_);
123  const char* tmpLabel = strLabel.data();
124  ( (TH2F *)GEMDAV2D_->getTH2F() )->SetBins(24, 0, 24, nNumAMC, 0, nNumAMC);
125  ( (TH2F *)GEMDAV2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel);
126 
127  ( (TH2F *)Tstate2D_->getTH2F() )->SetBins(15, 0, 15, nNumAMC, 0, nNumAMC);
128  ( (TH2F *)Tstate2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel);
129 
130  ( (TH2F *)GDcount2D_->getTH2F() )->SetBins(32, 0, 32, nNumAMC, 0, nNumAMC);
131  ( (TH2F *)GDcount2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel);
132 
133  ( (TH2F *)ChamT2D_->getTH2F() )->SetBins(24, 0, 24, nNumAMC, 0, nNumAMC);
134  ( (TH2F *)ChamT2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel);
135 
136  ( (TH2F *)OOSG2D_->getTH2F() )->SetBins(1, 0, 1, nNumAMC, 0, nNumAMC);
137  ( (TH2F *)OOSG2D_->getTH2F() )->GetYaxis()->SetBinLabel(nNumAMC,tmpLabel);
138  }
139 
140  return mlAMCID_[BID_];
141 }
142 
143 int GEMDQMStatusDigi::GEBBinN(uint16_t BID_){
144  if(mlGEBID_.find(BID_) == mlGEBID_.end()){
145  int addIdx = mlGEBID_.size();
146  mlGEBID_[BID_] = addIdx;
147 
148  int nNumGEB = (int)mlGEBID_.size();
149  string strLabel = "BID: "+to_string(BID_);
150  const char* tmpLabel = strLabel.data();
151  ( (TH2F *)h2B1010All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB);
152  ( (TH2F *)h2B1010All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
153 
154  ( (TH2F *)h2B1100All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB);
155  ( (TH2F *)h2B1100All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
156 
157  ( (TH2F *)h2B1110All_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB);
158  ( (TH2F *)h2B1110All_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
159 
160  ( (TH2F *)h2FlagAll_->getTH2F() )->SetBins(15, 0x0 , 0xf, nNumGEB, 0, nNumGEB);
161  ( (TH2F *)h2FlagAll_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
162 
163  ( (TH2F *)h2CRCAll_->getTH2F() )->SetBins(0xffff, -32768, 32768, nNumGEB, 0, nNumGEB);
164  ( (TH2F *)h2CRCAll_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
165 
166  ( (TH2F *)h2InputID_->getTH2F() )->SetBins(31, 0x0 , 0b11111, nNumGEB, 0, nNumGEB);
167  ( (TH2F *)h2InputID_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
168 
169  ( (TH2F *)h2Vwh_->getTH2F() )->SetBins(4095, 0x0 , 0xfff, nNumGEB, 0, nNumGEB);
170  ( (TH2F *)h2Vwh_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
171 
172  ( (TH2F *)h2Vwt_->getTH2F() )->SetBins(4095, 0x0 , 0xfff, nNumGEB, 0, nNumGEB);
173  ( (TH2F *)h2Vwt_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
174 
175  ( (TH2F *)h2GEBError_->getTH2F() )->SetBins(5, 0, 5, nNumGEB, 0, nNumGEB);
176  ( (TH2F *)h2GEBError_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
177 
178  ( (TH2F *)h2GEBWarning_->getTH2F() )->SetBins(10, 0, 10, nNumGEB, 0, nNumGEB);
179  ( (TH2F *)h2GEBWarning_->getTH2F() )->GetYaxis()->SetBinLabel(nNumGEB,tmpLabel);
180 
181  }
182  return mlGEBID_[BID_];
183 }
184 
185 //----------------------------------------------------------------------------------------------------
186 
187 
189 {
190 
191  ibooker.cd();
192  ibooker.setCurrentFolder("GEM/StatusDigi");
193 
194  h1B1010All_ = ibooker.book1D("vfatErrors_all_b1010", "Control Bit 1010", 15, 0x0 , 0xf);
195  h1B1100All_ = ibooker.book1D("vfatErrors_all_b1100", "Control Bit 1100", 15, 0x0 , 0xf);
196  h1B1110All_ = ibooker.book1D("vfatErrors_all_b1110", "Control Bit 1110", 15, 0x0 , 0xf);
197  h2B1010All_ = ibooker.book2D("vfatErrors_all_b1010_PerGEB", "Control Bit 1010", 15, 0x0 , 0xf, 1, 0, 1);
198  h2B1100All_ = ibooker.book2D("vfatErrors_all_b1100_PerGEB", "Control Bit 1100", 15, 0x0 , 0xf, 1, 0, 1);
199  h2B1110All_ = ibooker.book2D("vfatErrors_all_b1110_PerGEB", "Control Bit 1110", 15, 0x0 , 0xf, 1, 0, 1);
200 
201  h1FlagAll_ = ibooker.book1D("vfatErrors_all_flag", "Control Flags", 15, 0x0 , 0xf);
202  h1CRCAll_ = ibooker.book1D("vfatErrors_all_CRC", "CRC Mismatches", 0xffff, -32768, 32768);
203  h2FlagAll_ = ibooker.book2D("vfatErrors_all_flag_PerGEB", "Control Flags", 15, 0x0 , 0xf, 1, 0, 1);
204  h2CRCAll_ = ibooker.book2D("vfatErrors_all_CRC_PerGEB", "CRC Mismatches", 0xffff, -32768, 32768, 1, 0, 1);
205 
206  h1InputID_ = ibooker.book1D("GEB_InputID", "GEB GLIB input ID", 31, 0x0 , 0b11111);
207  h1Vwh_ = ibooker.book1D("VFAT_Vwh", "VFAT word count", 4095, 0x0 , 0xfff);
208  h1Vwt_ = ibooker.book1D("VFAT_Vwt", "VFAT word count", 4095, 0x0 , 0xfff);
209  h2InputID_ = ibooker.book2D("GEB_InputID_PerGEB", "GEB GLIB input ID", 31, 0x0 , 0b11111, 1, 0, 1);
210  h2Vwh_ = ibooker.book2D("VFAT_Vwh_PerGEB", "VFAT word count", 4095, 0x0 , 0xfff, 1, 0, 1);
211  h2Vwt_ = ibooker.book2D("VFAT_Vwt_PerGEB", "VFAT word count", 4095, 0x0 , 0xfff, 1, 0, 1);
212 
213  h1GEBError_ = ibooker.book1D("GEB_Errors", "GEB Critical Errors", 5, 0, 5);
214  h2GEBError_ = ibooker.book2D("GEB_Errors_PerGEB", "GEB Critical Errors", 5, 0, 5, 1, 0, 1);
215  TH1F *histErr1D = h1GEBError_->getTH1F();
216  TH2F *histErr2D = h2GEBError_->getTH2F();
217  const char *error_flags[5] = {"Event Size Overflow", "L1AFIFO Full", "InFIFO Full", "Evt FIFO Full","InFIFO Underflow"};
218  for (int i = 1; i< histErr1D->GetNbinsX()+1; i++) {histErr1D->GetXaxis()->SetBinLabel(i, error_flags[i-1]); histErr2D->GetXaxis()->SetBinLabel(i, error_flags[i-1]);}
219  h1GEBWarning_ = ibooker.book1D("GEB_Warnings", "GEB Warnings", 10, 0, 10);
220  h2GEBWarning_ = ibooker.book2D("GEB_Warnings_PerGEB", "GEB Warnings", 10, 0, 10, 1, 0, 1);
221  TH1F *histWar1D = h1GEBWarning_->getTH1F();
222  TH2F *histWar2D = h2GEBWarning_->getTH2F();
223  const char *warning_flags[10] = {"BX AMC-OH Mismatch", "BX AMC-VFAT Mismatch", "OOS AMC OH", "OOS AMC VFAT","No VFAT Marker","Event Size Warn", "L1AFIFO Near Full", "InFIFO Near Full", "EvtFIFO Near Full", "Stuck Data"};
224  for (int i = 1; i<histWar1D->GetNbinsX()+1; i++) {histWar1D->GetXaxis()->SetBinLabel(i, warning_flags[i-1]); histWar2D->GetXaxis()->SetBinLabel(i, warning_flags[i-1]);}
225 
226  GEMDAV_ = ibooker.book1D("GEMDAV", "GEM DAV list", 24, 0, 24);
227  Tstate_ = ibooker.book1D("Tstate", "TTS state", 15, 0, 15);
228  GDcount_ = ibooker.book1D("GDcount", "GEM DAV count", 32, 0, 32);
229  ChamT_ = ibooker.book1D("ChamT", "Chamber Timeout", 24, 0, 24);
230  OOSG_ = ibooker.book1D("OOSG", "OOS GLIB", 1, 0, 1);
231 
232  GEMDAV2D_ = ibooker.book2D("GEMDAV_PerAMC", "GEM DAV list", 24, 0, 24, 1, 0, 1);
233  Tstate2D_ = ibooker.book2D("Tstate_PerAMC", "TTS state", 15, 0, 15, 1, 0, 1);
234  GDcount2D_ = ibooker.book2D("GDcount_PerAMC", "GEM DAV count", 32, 0, 32, 1, 0, 1);
235  ChamT2D_ = ibooker.book2D("ChamT_PerAMC", "Chamber Timeout", 24, 0, 24, 1, 0, 1);
236  OOSG2D_ = ibooker.book2D("OOSG_PerAMC", "OOS GLIB", 1, 0, 1, 1, 0, 1);
237 }
238 
240 {
244  event.getByToken( this->tagVFAT_, gemVFAT);
245  event.getByToken( this->tagGEB_, gemGEB);
246  event.getByToken( this->tagAMC_, gemAMC);
247 
248  for (GEMVfatStatusDigiCollection::DigiRangeIterator vfatIt = gemVFAT->begin(); vfatIt != gemVFAT->end(); ++vfatIt){
249  const GEMVfatStatusDigiCollection::Range& range = (*vfatIt).second;
250  uint16_t tmpID = (*vfatIt).first;
251  int nIdx = GEBBinN(tmpID);
252  for ( auto vfatError = range.first; vfatError != range.second; ++vfatError ) {
253 
254  h1B1010All_->Fill(vfatError->getB1010());
255  h1B1100All_->Fill(vfatError->getB1100());
256  h1B1110All_->Fill(vfatError->getB1110());
257  h1FlagAll_->Fill(vfatError->getFlag());
258  h1CRCAll_->Fill(vfatError->getCrc());
259 
260  h2B1010All_->Fill(vfatError->getB1010(), nIdx);
261  h2B1100All_->Fill(vfatError->getB1100(), nIdx);
262  h2B1110All_->Fill(vfatError->getB1110(), nIdx);
263  h2FlagAll_->Fill(vfatError->getFlag(), nIdx);
264  h2CRCAll_->Fill(vfatError->getCrc(), nIdx);
265  }
266  }
267 
268  for (GEMGEBStatusDigiCollection::DigiRangeIterator gebIt = gemGEB->begin(); gebIt != gemGEB->end(); ++gebIt){
269  const GEMGEBStatusDigiCollection::Range& range = (*gebIt).second;
270  for ( auto GEBStatus = range.first; GEBStatus != range.second; ++GEBStatus ) {
271  uint16_t tmpID = (*gebIt).first;
272  h1InputID_->Fill(tmpID);
273  h1Vwh_->Fill(GEBStatus->getVwh());
274  h1Vwt_->Fill(GEBStatus->getVwt());
275 
276  int nIdx = GEBBinN(tmpID);
277  h2InputID_->Fill(tmpID, nIdx);
278  h2Vwh_->Fill(GEBStatus->getVwh(), nIdx);
279  h2Vwt_->Fill(GEBStatus->getVwt(), nIdx);
280 
281  for ( int bin = 0 ; bin < cBit_ ; bin++ ) {
282  if ( ( ( GEBStatus->getErrorC() >> bin ) & 0x1 ) != 0 ) {
284  h2GEBWarning_->Fill(bin, nIdx);
285  }
286  }
287  for ( int bin = cBit_ ; bin < eBit_ ; bin++ ) {
288  if ( ( ( GEBStatus->getErrorC() >> bin ) & 0x1 ) != 0 ) {
289  h1GEBError_->Fill(bin - 9);
290  h2GEBError_->Fill(bin - 9, nIdx);
291  }
292  }
293 
294  if ( ( GEBStatus->getInFu() & 0x1 ) != 0 ) {
295  h1GEBError_->Fill(9);
296  h2GEBError_->Fill(9, nIdx);
297  }
298  if ( ( GEBStatus->getStuckd() & 0x1 ) != 0 ) {
299  h1GEBWarning_->Fill(9);
300  h2GEBWarning_->Fill(9, nIdx);
301  }
302  }
303  }
304 
305  for (GEMAMCStatusDigiCollection::DigiRangeIterator amcIt = gemAMC->begin(); amcIt != gemAMC->end(); ++amcIt){
306  const GEMAMCStatusDigiCollection::Range& range = (*amcIt).second;
307  for ( auto amc = range.first; amc != range.second; ++amc ) {
308  uint16_t tmpID = (*amcIt).first;
309  int nIdxAMC = AMCBinN(tmpID);
310  uint8_t binFired = 0;
311  for (int bin = 0; bin < nVfat_; bin++){
312  binFired = ((amc->GEMDAV() >> bin) & 0x1);
313  if (binFired) {GEMDAV_->Fill(bin); GEMDAV2D_->Fill(bin, nIdxAMC);}
314  binFired = ((amc->ChamT() >> bin) & 0x1);
315  if (binFired) {ChamT_->Fill(bin); ChamT2D_->Fill(bin, nIdxAMC);}
316  }
317 
318  Tstate_->Fill(amc->Tstate());
319  GDcount_->Fill(amc->GDcount());
320  OOSG_->Fill(amc->OOSG());
321 
322  Tstate2D_->Fill(amc->Tstate(), nIdxAMC);
323  GDcount2D_->Fill(amc->GDcount(), nIdxAMC);
324  OOSG2D_->Fill(amc->OOSG(), nIdxAMC);
325  }
326  }
327 }
328 
MonitorElement * GEMDAV2D_
T getParameter(std::string const &) const
MonitorElement * Tstate_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
MonitorElement * h1B1110All_
MonitorElement * OOSG_
MonitorElement * GEMDAV_
TH1F * getTH1F() const
edm::EDGetToken tagVFAT_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
GEMDQMStatusDigi(const edm::ParameterSet &cfg)
MonitorElement * ChamT_
MonitorElement * h2GEBError_
MonitorElement * h1Vwh_
void Fill(long long x)
int AMCBinN(uint16_t BID_)
MonitorElement * h1GEBWarning_
std::unordered_map< uint16_t, int > mlAMCID_
MonitorElement * GDcount_
MonitorElement * h2InputID_
MonitorElement * h2CRCAll_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
MonitorElement * h2B1110All_
MonitorElement * h2B1100All_
MonitorElement * h1CRCAll_
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
int GEBBinN(uint16_t BID_)
TH2F * getTH2F() const
MonitorElement * h2Vwt_
MonitorElement * h2Vwh_
bin
set the eta bin as selection string.
MonitorElement * h1FlagAll_
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
MonitorElement * h1InputID_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * Tstate2D_
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
std::unordered_map< uint16_t, int > mlGEBID_
MonitorElement * h2B1010All_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
MonitorElement * h2FlagAll_
HLT enums.
MonitorElement * ChamT2D_
MonitorElement * h2GEBWarning_
~GEMDQMStatusDigi() override
MonitorElement * OOSG2D_
MonitorElement * h1GEBError_
MonitorElement * h1Vwt_
std::pair< const_iterator, const_iterator > Range
edm::EDGetToken tagGEB_
MonitorElement * h1B1100All_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: AMCSpec.h:8
MonitorElement * GDcount2D_
DigiRangeIterator end() const
edm::EDGetToken tagAMC_
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) override
Definition: event.py:1
Definition: Run.h:43
DigiRangeIterator begin() const
MonitorElement * h1B1010All_