CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDQM_EventProcessor_processDDU.cc
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: EventProcessor.cc
5  *
6  * Description: EventProcessor Object
7  *
8  * Version: 1.0
9  * Created: 10/03/2008 10:47:11 AM
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch
14  * Company: CERN, CH
15  *
16  * =====================================================================================
17  */
18 
19 #include "CSCDQM_EventProcessor.h"
20 
21 namespace cscdqm
22 {
23 
28 void EventProcessor::processDDU(const CSCDDUEventData& dduData, const CSCDCCExaminer& binChecker)
29 {
30 
31  CSCDDUHeader dduHeader = dduData.header();
32  CSCDDUTrailer dduTrailer = dduData.trailer();
33  if (!dduTrailer.check())
34  {
36  return;
37  }
38 
39  int dduID = dduHeader.source_id();
40 
41  if ( (dduID >= FEDNumbering::MINCSCDDUFEDID) && (dduID <= FEDNumbering::MAXCSCDDUFEDID) )
42  {
43  // dduID -= (FEDNumbering::MINCSCDDUFEDID - 1); /// TODO: Can require DDU-RUI remapping for actual system
44  dduID = cscdqm::Utility::getRUIfromDDUId(dduHeader.source_id());
45  if (dduID < 0)
46  {
47  LOG_WARN << "DDU source ID (" << dduHeader.source_id() << ") is out of valid range. Remapping to DDU ID 1.";
48  dduID = 1;
49  }
50  }
51  else
52  {
53 
55  dduID = dduID & 0xFF;
56  }
57 
58 
59  MonitorObject* mo = 0;
60 
62  {
63  mo->Fill(dduID);
64  }
65 
66  std::string dduTag = DDUHistoDef::getPath(dduID);
67 
68  uint32_t dduEvtSize = dduData.sizeInWords()*2;
69 
70  // if (dduEvtSize > 48)
71  {
72 
74  int trl_word_count = 0;
75  trl_word_count = dduTrailer.wordcount();
76 
77  if (getDDUHisto(h::DDU_BUFFER_SIZE, dduID, mo)) mo->Fill(dduEvtSize);
78 
79  if (getDDUHisto(h::DDU_WORD_COUNT, dduID, mo)) mo->Fill(trl_word_count );
80 
83  if (trl_word_count > 0)
84  {
86  {
87  mo->Fill(dduID, log10((double)trl_word_count));
88  }
89  }
90 
92  {
93  mo->Fill(dduID, trl_word_count);
94  }
95 
96  }
97 
98  fCloseL1As = dduTrailer.reserved() & 0x1; // Get status if Close L1As bit
102  BXN = dduHeader.bxnum();
104  if (getEMUHisto(h::EMU_DDU_BXN, mo)) mo->Fill(BXN);
105  if (getDDUHisto(h::DDU_BXN, dduID, mo)) mo->Fill(BXN);
106 
108  int L1ANumber_previous_event = L1ANumbers[dduID];
109  L1ANumbers[dduID] = (int)(dduHeader.lvl1num());
110  L1ANumber = L1ANumbers[dduID];
112  int L1A_inc = L1ANumber - L1ANumber_previous_event;
113 
115  if ( L1A_inc < 0 ) L1A_inc = 0xFFFFFF + L1A_inc;
116 
117  // if (!fFirstEvent) {
118  if (fNotFirstEvent[dduID])
119  {
120  if (getDDUHisto(h::DDU_L1A_INCREMENT, dduID, mo)) mo->Fill(L1A_inc);
122  {
123  if (L1A_inc > 100000)
124  {
125  L1A_inc = 19;
126  }
127  else if (L1A_inc > 30000)
128  {
129  L1A_inc = 18;
130  }
131  else if (L1A_inc > 10000)
132  {
133  L1A_inc = 17;
134  }
135  else if (L1A_inc > 3000)
136  {
137  L1A_inc = 16;
138  }
139  else if (L1A_inc > 1000)
140  {
141  L1A_inc = 15;
142  }
143  else if (L1A_inc > 300)
144  {
145  L1A_inc = 14;
146  }
147  else if (L1A_inc > 100)
148  {
149  L1A_inc = 13;
150  }
151  else if (L1A_inc > 30)
152  {
153  L1A_inc = 12;
154  }
155  else if (L1A_inc > 10)
156  {
157  L1A_inc = 11;
158  }
159  mo->Fill(dduID, L1A_inc);
160  }
161  }
162 
164  int dmb_dav_header = 0;
165  int dmb_dav_header_cnt = 0;
166 
167  int ddu_connected_inputs= 0;
168  int ddu_connected_inputs_cnt = 0;
169 
170  int csc_error_state = 0;
171  int csc_warning_state = 0;
172 
174  int dmb_active_header = 0;
175 
176  dmb_dav_header = dduHeader.dmb_dav();
177  dmb_active_header = (int)(dduHeader.ncsc() & 0xF);
178  csc_error_state = dduTrailer.dmb_full() & 0x7FFF; // Only 15 inputs for DDU
179  csc_warning_state = dduTrailer.dmb_warn() & 0x7FFF; // Only 15 inputs for DDU
180  ddu_connected_inputs = dduHeader.live_cscs();
181 
185  double freq = 0;
186  for (int i = 0;
187  i < 15;
188  ++i)
189  {
190  if ((dmb_dav_header >> i) & 0x1)
191  {
192  dmb_dav_header_cnt++;
194  {
195  mo->Fill(i + 1);
196  freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
198  mo->SetBinContent(i+1,freq);
199  }
201  {
202  mo->Fill(dduID, i);
203  }
204  }
205 
206  if ( (ddu_connected_inputs >> i) & 0x1 )
207  {
208  ddu_connected_inputs_cnt++;
210  {
211  mo->Fill(i + 1);
212  freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
214  mo->SetBinContent(i + 1, freq);
215  }
217  {
218  mo->Fill(dduID, i);
219  }
220  }
221 
222  if ( (csc_error_state >> i) & 0x1 )
223  {
224  if (getDDUHisto(h::DDU_CSC_ERRORS_RATE, dduID, mo))
225  {
226  mo->Fill(i + 1);
227  freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
228  if (getDDUHisto(h::DDU_CSC_ERRORS, dduID, mo))
229  mo->SetBinContent(i + 1, freq);
230  }
232  {
233  mo->Fill(dduID, i + 2);
234  }
235  }
236 
237  if ((csc_warning_state >> i) & 0x1 )
238  {
239  if (getDDUHisto(h::DDU_CSC_WARNINGS_RATE, dduID, mo))
240  {
241  mo->Fill(i + 1);
242  freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
243  if (getDDUHisto(h::DDU_CSC_WARNINGS, dduID, mo)) mo->SetBinContent(i + 1, freq);
244  }
246  {
247  mo->Fill(dduID, i + 2);
248  }
249  }
250  }
251 
253  {
254  mo->Fill(dduID, ddu_connected_inputs_cnt);
255  }
256 
257  // if (dduEvtSize > 48)
258  {
260  {
261  mo->Fill(dduID, dmb_dav_header_cnt);
262  }
263  }
264 
266  {
267  if (csc_error_state > 0)
268  {
269  mo->Fill(dduID, 1); // Any Input
270  }
271  else
272  {
273  mo->Fill(dduID, 0); // No errors
274  }
275  }
276 
278  {
279  if (csc_warning_state > 0)
280  {
281  mo->Fill(dduID, 1); // Any Input
282  }
283  else
284  {
285  mo->Fill(dduID, 0); // No errors
286  }
287  }
288 
291  if (getDDUHisto(h::DDU_CSC_ERRORS, dduID, mo)) mo->SetEntries(config->getNEvents());
293  if (getDDUHisto(h::DDU_DMB_ACTIVE_HEADER_COUNT, dduID, mo)) mo->Fill(dmb_active_header);
295  mo->Fill(dmb_active_header, dmb_dav_header_cnt);
296 
298  uint32_t trl_errorstat = dduTrailer.errorstat();
299  if (dmb_dav_header_cnt == 0) trl_errorstat &= ~0x20000000; // Ignore No Good DMB CRC bit of no DMB is present
301  for (int i = 0; i < 32; i++)
302  {
303  if ((trl_errorstat >> i) & 0x1)
304  {
306  {
307  mo->Fill(i);
308  double freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
310  mo->SetBinContent(i+1, freq);
311  }
313  mo->Fill(0.,i);
314  }
315  }
317  {
318  if (trl_errorstat)
319  {
320  mo->Fill(dduID, 1); // Any Error
321  for (int i = 0; i < 32; i++)
322  {
323  if ((trl_errorstat >> i) & 0x1)
324  {
325  mo->Fill(dduID, i + 2);
326  }
327  }
328  }
329  else
330  {
331  mo->Fill(dduID, 0); // No Errors
332  }
333  }
334 
337 
339  uint32_t ddu_output_path_status = dduHeader.output_path_status();
341  {
342  if (ddu_output_path_status)
343  {
344  mo->Fill(dduID,1); // Any Error
345  for (int i=0; i<16; i++)
346  {
347  if ((ddu_output_path_status>>i) & 0x1)
348  {
349  mo->Fill(dduID,i+2); // Fill Summary Histo
350  }
351  }
352  }
353  else
354  {
355  mo->Fill(dduID,0); // No Errors
356  }
357  }
358 
359 
360  uint32_t nCSCs = 0;
361 
363  if (config->getPROCESS_CSC())
364  {
365 
366  std::vector<CSCEventData> chamberDatas;
367  chamberDatas.clear();
368  chamberDatas = dduData.cscData();
369 
370  nCSCs = chamberDatas.size();
371 
372  for (uint32_t i = 0; i < nCSCs; i++)
373  {
374  processCSC(chamberDatas[i], dduID, binChecker);
375  }
376 
377  }
378 
379  if (getDDUHisto(h::DDU_DMB_UNPACKED_VS_DAV, dduID, mo)) mo->Fill(dmb_active_header, nCSCs);
380 
381  // fFirstEvent = false;
382 
384  fNotFirstEvent[dduID] = true;
385 
386 }
387 
388 }
int i
Definition: DBlmapReader.cc:9
CSCDDUHeader header() const
const unsigned long getNEvents() const
virtual void SetEntries(const double value)=0
int lvl1num() const
Definition: CSCDDUHeader.h:25
const bool getDDUHisto(const HistoId &histo, const HwId &dduID, MonitorObject *&me)
Get DDU Level Monitoring Object.
virtual void Fill(float x)=0
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
unsigned errorstat() const
Definition: CSCDDUTrailer.h:41
static int getRUIfromDDUId(unsigned ddu_id)
Get RUI Number from DDU source ID for post LS1 configuration.
void processCSC(const CSCEventData &data, const int dduID, const CSCDCCExaminer &binChecker)
Process Chamber Data and fill MOs.
unsigned dmb_warn() const
Definition: CSCDDUTrailer.h:46
std::map< uint32_t, uint32_t > L1ANumbers
int bxnum() const
Definition: CSCDDUHeader.h:24
int output_path_status() const
Definition: CSCDDUHeader.h:31
int dmb_dav() const
Definition: CSCDDUHeader.h:28
virtual void SetBinContent(const int binX, const double value)=0
unsigned reserved() const
Definition: CSCDDUTrailer.h:48
bool check() const
Definition: CSCDDUTrailer.h:30
void processDDU(const CSCDDUEventData &data, const CSCDCCExaminer &binChecker)
Process DDU output and fill MOs.
const std::vector< CSCEventData > & cscData() const
accessor to data
const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
unsigned dmb_full() const
Definition: CSCDDUTrailer.h:47
#define LOG_WARN
Definition: CSCDQM_Logger.h:42
virtual double GetBinContent(const int binX)=0
CSCDDUTrailer trailer() const
bool fCloseL1As
Data Format version (2005, 2013)
unsigned wordcount() const
Definition: CSCDDUTrailer.h:42
int ncsc() const
Definition: CSCDDUHeader.h:27
int source_id() const
Definition: CSCDDUHeader.h:23
int live_cscs() const
Definition: CSCDDUHeader.h:30
std::map< uint32_t, bool > fNotFirstEvent
const bool getEMUHisto(const HistoId &histo, MonitorObject *&me)
Get EMU (Top Level) Monitoring Object.
int sizeInWords() const