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 
20 
21 namespace cscdqm {
22 
27  void EventProcessor::processDDU(const CSCDDUEventData& dduData, const CSCDCCExaminer& binChecker) {
28 
29  CSCDDUHeader dduHeader = dduData.header();
30  CSCDDUTrailer dduTrailer = dduData.trailer();
31  if (!dduTrailer.check()) {
33  return;
34  }
35 
37  int dduID = dduHeader.source_id() & 0xFF;
38 
39  MonitorObject* mo = 0;
40 
41  if (getEMUHisto(h::EMU_ALL_DDUS_IN_READOUT, mo)) {
42  mo->Fill(dduID);
43  }
44 
45  std::string dduTag = DDUHistoDef::getPath(dduID);
46 
47  uint32_t dduEvtSize = dduData.sizeInWords()*2;
48 
49  // if (dduEvtSize > 48)
50  {
51 
53  int trl_word_count = 0;
54  trl_word_count = dduTrailer.wordcount();
55 
56  if (getDDUHisto(h::DDU_BUFFER_SIZE, dduID, mo)) mo->Fill(dduEvtSize);
57 
58  if (getDDUHisto(h::DDU_WORD_COUNT, dduID, mo)) mo->Fill(trl_word_count );
59 
62  if (trl_word_count > 0) {
63  if (getEMUHisto(h::EMU_ALL_DDUS_EVENT_SIZE, mo)) {
64  mo->Fill(dduID, log10((double)trl_word_count));
65  }
66  }
67 
68  if (getEMUHisto(h::EMU_ALL_DDUS_AVERAGE_EVENT_SIZE, mo)) {
69  mo->Fill(dduID, trl_word_count);
70  }
71 
72  }
73 
74  fCloseL1As = dduTrailer.reserved() & 0x1; // Get status if Close L1As bit
78  BXN = dduHeader.bxnum();
80  if (getEMUHisto(h::EMU_DDU_BXN, mo)) mo->Fill(BXN);
81  if (getDDUHisto(h::DDU_BXN, dduID, mo)) mo->Fill(BXN);
82 
84  int L1ANumber_previous_event = L1ANumbers[dduID];
85  L1ANumbers[dduID] = (int)(dduHeader.lvl1num());
86  L1ANumber = L1ANumbers[dduID];
88  int L1A_inc = L1ANumber - L1ANumber_previous_event;
89 
91  if ( L1A_inc < 0 ) L1A_inc = 0xFFFFFF + L1A_inc;
92 
93  // if (!fFirstEvent) {
94  if (fNotFirstEvent[dduID]) {
95  if (getDDUHisto(h::DDU_L1A_INCREMENT, dduID, mo)) mo->Fill(L1A_inc);
96  if (getEMUHisto(h::EMU_ALL_DDUS_L1A_INCREMENT, mo)) {
97  if (L1A_inc > 100000){ L1A_inc = 19;}
98  else if (L1A_inc > 30000) { L1A_inc = 18;}
99  else if (L1A_inc > 10000) { L1A_inc = 17;}
100  else if (L1A_inc > 3000) { L1A_inc = 16;}
101  else if (L1A_inc > 1000) { L1A_inc = 15;}
102  else if (L1A_inc > 300) { L1A_inc = 14;}
103  else if (L1A_inc > 100) { L1A_inc = 13;}
104  else if (L1A_inc > 30) { L1A_inc = 12;}
105  else if (L1A_inc > 10) { L1A_inc = 11;}
106  mo->Fill(dduID, L1A_inc);
107  }
108  }
109 
111  int dmb_dav_header = 0;
112  int dmb_dav_header_cnt = 0;
113 
114  int ddu_connected_inputs= 0;
115  int ddu_connected_inputs_cnt = 0;
116 
117  int csc_error_state = 0;
118  int csc_warning_state = 0;
119 
121  int dmb_active_header = 0;
122 
123  dmb_dav_header = dduHeader.dmb_dav();
124  dmb_active_header = (int)(dduHeader.ncsc() & 0xF);
125  csc_error_state = dduTrailer.dmb_full() & 0x7FFF; // Only 15 inputs for DDU
126  csc_warning_state = dduTrailer.dmb_warn() & 0x7FFF; // Only 15 inputs for DDU
127  ddu_connected_inputs = dduHeader.live_cscs();
128 
132  double freq = 0;
133  for (int i = 0; i < 15; ++i) {
134  if ((dmb_dav_header >> i) & 0x1) {
135  dmb_dav_header_cnt++;
136  if (getDDUHisto(h::DDU_DMB_DAV_HEADER_OCCUPANCY_RATE, dduID, mo)) {
137  mo->Fill(i + 1);
138  freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
139  if (getDDUHisto(h::DDU_DMB_DAV_HEADER_OCCUPANCY, dduID, mo))
140  mo->SetBinContent(i+1,freq);
141  }
142  if (getEMUHisto(h::EMU_ALL_DDUS_INPUTS_WITH_DATA, mo)) {
143  mo->Fill(dduID, i);
144  }
145  }
146 
147  if( (ddu_connected_inputs >> i) & 0x1 ){
148  ddu_connected_inputs_cnt++;
149  if (getDDUHisto(h::DDU_DMB_CONNECTED_INPUTS_RATE, dduID, mo)) {
150  mo->Fill(i + 1);
151  freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
152  if (getDDUHisto(h::DDU_DMB_CONNECTED_INPUTS, dduID, mo))
153  mo->SetBinContent(i + 1, freq);
154  }
155  if (getEMUHisto(h::EMU_ALL_DDUS_LIVE_INPUTS, mo)) {
156  mo->Fill(dduID, i);
157  }
158  }
159 
160  if( (csc_error_state >> i) & 0x1 ){
161  if (getDDUHisto(h::DDU_CSC_ERRORS_RATE, dduID, mo)) {
162  mo->Fill(i + 1);
163  freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
164  if (getDDUHisto(h::DDU_CSC_ERRORS, dduID, mo))
165  mo->SetBinContent(i + 1, freq);
166  }
167  if (getEMUHisto(h::EMU_ALL_DDUS_INPUTS_ERRORS, mo)) {
168  mo->Fill(dduID, i + 2);
169  }
170  }
171 
172  if((csc_warning_state >> i) & 0x1 ){
173  if (getDDUHisto(h::DDU_CSC_WARNINGS_RATE, dduID, mo)) {
174  mo->Fill(i + 1);
175  freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
176  if (getDDUHisto(h::DDU_CSC_WARNINGS, dduID, mo)) mo->SetBinContent(i + 1, freq);
177  }
178  if (getEMUHisto(h::EMU_ALL_DDUS_INPUTS_WARNINGS, mo)) {
179  mo->Fill(dduID, i + 2);
180  }
181  }
182  }
183 
184  if (getEMUHisto(h::EMU_ALL_DDUS_AVERAGE_LIVE_INPUTS, mo)) {
185  mo->Fill(dduID, ddu_connected_inputs_cnt);
186  }
187 
188  // if (dduEvtSize > 48)
189  {
190  if (getEMUHisto(h::EMU_ALL_DDUS_AVERAGE_INPUTS_WITH_DATA, mo)) {
191  mo->Fill(dduID, dmb_dav_header_cnt);
192  }
193  }
194 
195  if (getEMUHisto(h::EMU_ALL_DDUS_INPUTS_ERRORS, mo)) {
196  if (csc_error_state > 0) {
197  mo->Fill(dduID, 1); // Any Input
198  } else {
199  mo->Fill(dduID, 0); // No errors
200  }
201  }
202 
203  if (getEMUHisto(h::EMU_ALL_DDUS_INPUTS_WARNINGS, mo)) {
204  if (csc_warning_state > 0) {
205  mo->Fill(dduID, 1); // Any Input
206  } else {
207  mo->Fill(dduID, 0); // No errors
208  }
209  }
210 
211  if (getDDUHisto(h::DDU_DMB_DAV_HEADER_OCCUPANCY, dduID, mo)) mo->SetEntries(config->getNEvents());
212  if (getDDUHisto(h::DDU_DMB_CONNECTED_INPUTS, dduID, mo)) mo->SetEntries(config->getNEvents());
213  if (getDDUHisto(h::DDU_CSC_ERRORS, dduID, mo)) mo->SetEntries(config->getNEvents());
214  if (getDDUHisto(h::DDU_CSC_WARNINGS, dduID, mo)) mo->SetEntries(config->getNEvents());
215  if (getDDUHisto(h::DDU_DMB_ACTIVE_HEADER_COUNT, dduID, mo)) mo->Fill(dmb_active_header);
216  if (getDDUHisto(h::DDU_DMB_DAV_HEADER_COUNT_VS_DMB_ACTIVE_HEADER_COUNT, dduID, mo))
217  mo->Fill(dmb_active_header, dmb_dav_header_cnt);
218 
220  uint32_t trl_errorstat = dduTrailer.errorstat();
221  if (dmb_dav_header_cnt == 0) trl_errorstat &= ~0x20000000; // Ignore No Good DMB CRC bit of no DMB is present
223  for (int i = 0; i < 32; i++) {
224  if ((trl_errorstat >> i) & 0x1) {
225  if (getDDUHisto(h::DDU_TRAILER_ERRORSTAT_RATE, dduID, mo)) {
226  mo->Fill(i);
227  double freq = (100.0 * mo->GetBinContent(i + 1)) / config->getNEvents();
228  if (getDDUHisto(h::DDU_TRAILER_ERRORSTAT_FREQUENCY, dduID, mo))
229  mo->SetBinContent(i+1, freq);
230  }
231  if (getDDUHisto(h::DDU_TRAILER_ERRORSTAT_TABLE, dduID, mo))
232  mo->Fill(0.,i);
233  }
234  }
235  if (getEMUHisto(h::EMU_ALL_DDUS_TRAILER_ERRORS, mo)) {
236  if (trl_errorstat) {
237  mo->Fill(dduID, 1); // Any Error
238  for (int i = 0; i < 32; i++) {
239  if ((trl_errorstat >> i) & 0x1) {
240  mo->Fill(dduID, i + 2);
241  }
242  }
243  } else {
244  mo->Fill(dduID, 0); // No Errors
245  }
246  }
247 
248  if (getDDUHisto(h::DDU_TRAILER_ERRORSTAT_TABLE, dduID, mo)) mo->SetEntries(config->getNEvents());
249  if (getDDUHisto(h::DDU_TRAILER_ERRORSTAT_FREQUENCY, dduID, mo)) mo->SetEntries(config->getNEvents());
250 
251 
252  uint32_t nCSCs = 0;
253 
255  if (config->getPROCESS_CSC()) {
256 
257  std::vector<CSCEventData> chamberDatas;
258  chamberDatas.clear();
259  chamberDatas = dduData.cscData();
260 
261  nCSCs = chamberDatas.size();
262 
263  for(uint32_t i = 0; i < nCSCs; i++) {
264  processCSC(chamberDatas[i], dduID, binChecker);
265  }
266 
267  }
268 
269  if (getDDUHisto(h::DDU_DMB_UNPACKED_VS_DAV, dduID, mo)) mo->Fill(dmb_active_header, nCSCs);
270 
271  // fFirstEvent = false;
272 
274  fNotFirstEvent[dduID] = true;
275 
276  }
277 
278 }
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:23
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
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:22
int dmb_dav() const
Definition: CSCDDUHeader.h:26
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
virtual double GetBinContent(const int binX)=0
CSCDDUTrailer trailer() const
bool fCloseL1As
Total Number of TMBs per event from DMB DAV.
unsigned wordcount() const
Definition: CSCDDUTrailer.h:42
int ncsc() const
Definition: CSCDDUHeader.h:25
int source_id() const
Definition: CSCDDUHeader.h:21
int live_cscs() const
Definition: CSCDDUHeader.h:29
std::map< uint32_t, bool > fNotFirstEvent
const bool getEMUHisto(const HistoId &histo, MonitorObject *&me)
Get EMU (Top Level) Monitoring Object.
int sizeInWords() const