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