CMS 3D CMS Logo

ESIntegrityClient.cc
Go to the documentation of this file.
2 
5 
6 #include <memory>
7 #include <iostream>
8 #include <fstream>
9 #include <iomanip>
10 
11 using namespace std;
12 
14  ESClient(ps),
15  hFED_(0),
16  hFiberOff_(0),
17  hFiberBadStatus_(0),
18  hKF1_(0),
19  hKF2_(0),
20  hKBC_(0),
21  hKEC_(0),
22  hL1ADiff_(0),
23  hBXDiff_(0),
24  hOrbitNumberDiff_(0),
25  hSLinkCRCErr_(0)
26 {
27  // read in look-up table
28  for (int i=0; i<2; ++i)
29  for (int j=0; j<2; ++j)
30  for (int k=0; k<40; ++k)
31  for (int m=0; m<40; ++m) {
32  fed_[i][j][k][m] = -1;
33  kchip_[i][j][k][m] = -1;
34  fiber_[i][j][k][m] = -1;
35  }
36 
37  for (int i=0; i<56; ++i) {
38  fedStatus_[i] = -1;
39  syncStatus_[i] = -1;
40  slinkCRCStatus_[i] = -1;
41  for (int j=0; j<36; ++j)
42  fiberStatus_[i][j] = -1;
43  }
44 
45  for(int i=0; i<2; ++i)
46  for(int j=0; j<2; ++j){
47  meFED_[i][j] = 0;
48  meKCHIP_[i][j] = 0;
49  }
50 
51  std::string lutPath(ps.getUntrackedParameter<edm::FileInPath>("LookupTable").fullPath());
52 
53  int nLines, z, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
54  ifstream file(lutPath);
55 
56  if( file.is_open() ) {
57 
58  file >> nLines;
59 
60  for (int i=0; i<nLines; ++i) {
61  file>> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
62 
63  z = (iz==-1) ? 2:iz;
64  fed_[z-1][ip-1][ix-1][iy-1] = fed;
65  kchip_[z-1][ip-1][ix-1][iy-1] = kchip;
66  fiber_[z-1][ip-1][ix-1][iy-1] = (fiber-1)+(optorx-1)*12;
67  }
68 
69  file.close();
70  }
71  else {
72  cout<<"ESIntegrityClient : Look up table file can not be found in "<<lutPath<<endl;
73  }
74 }
75 
77 }
78 
80 
81  char histo[200];
82 
83  _ibooker.setCurrentFolder( prefixME_ + "/ESIntegrityClient" );
84 
85  for (int i=0 ; i<2; ++i)
86  for (int j=0 ; j<2; ++j) {
87  int iz = (i==0)? 1:-1;
88  snprintf(histo, 200, "ES Integrity Summary 1 Z %d P %d", iz, j+1);
89  meFED_[i][j] = _ibooker.book2D(histo, histo, 40, 0.5, 40.5, 40, 0.5, 40.5);
90  meFED_[i][j]->setAxisTitle("Si X", 1);
91  meFED_[i][j]->setAxisTitle("Si Y", 2);
92 
93  snprintf(histo, 200, "ES Integrity Summary 2 Z %d P %d", iz, j+1);
94  meKCHIP_[i][j] = _ibooker.book2D(histo, histo, 40, 0.5, 40.5, 40, 0.5, 40.5);
95  meKCHIP_[i][j]->setAxisTitle("Si X", 1);
96  meKCHIP_[i][j]->setAxisTitle("Si Y", 2);
97  }
98 }
99 
101 
102  double nDI_FedErr[56];
103  for (int i=0; i<56; ++i) nDI_FedErr[i] = 0;
104 
105  MonitorElement* me = 0;
106 
107  me = _igetter.get(prefixME_ + "/ESIntegrityTask/ES FEDs used for data taking");
108  hFED_ = getHisto(me, cloneME_, hFED_);
109 
110  me = _igetter.get(prefixME_ + "/ESIntegrityTask/ES Fiber Off");
112 
113  me = _igetter.get(prefixME_ + "/ESIntegrityTask/ES Fiber Bad Status");
115 
116  me = _igetter.get(prefixME_ + "/ESIntegrityTask/ES SLink CRC Errors");
118 
119  int xval = 0;
120  int nevFEDs = 0;
121  if (hFED_) {
122  for (int i=1; i<=56; ++i)
123  if (nevFEDs < hFED_->GetBinContent(i))
124  nevFEDs = (int) hFED_->GetBinContent(i);
125  }
126 
127  // FED integrity
128  for (int i=1; i<=56; ++i) {
129  if (hFED_) {
130  if (hFED_->GetBinContent(i) > 0)
131  fedStatus_[i-1] = 1;
132  }
133  if (hSLinkCRCErr_) {
134  if (hSLinkCRCErr_->GetBinContent(i) > 0)
135  slinkCRCStatus_[i-1] = 1;
136  }
137  for (int j=0; j<36; ++j) {
138  if (hFiberBadStatus_) {
139  if (hFiberBadStatus_->GetBinContent(i, j+1) > 0)
140  fiberStatus_[i-1][j] = 2; // bad
141  else
142  fiberStatus_[i-1][j] = 1; // good
143  }
144  if (hFiberOff_)
145  if (hFiberOff_->GetBinContent(i, j+1) > 0) {
146  fiberStatus_[i-1][j] = 0; // off
147  }
148  }
149  }
150 
151  // obtain MEs from ESRawDataTask
152  me = _igetter.get(prefixME_ + "/ESRawDataTask/ES L1A DCC errors");
154 
155  me = _igetter.get(prefixME_ + "/ESRawDataTask/ES BX DCC errors");
157 
158  me = _igetter.get(prefixME_ + "/ESRawDataTask/ES Orbit Number DCC errors");
160 
161  for (int i=1; i<=56; ++i) {
162  if (hL1ADiff_ && hBXDiff_) {
163  if (hL1ADiff_->GetBinContent(i) > 0 || hBXDiff_->GetBinContent(i) > 0) {
164  syncStatus_[i-1] = 1;
165  if (hL1ADiff_->GetBinContent(i) > nDI_FedErr[i-1]) nDI_FedErr[i-1] = hL1ADiff_->GetBinContent(i);
166  if (hBXDiff_->GetBinContent(i) > nDI_FedErr[i-1]) nDI_FedErr[i-1] = hBXDiff_->GetBinContent(i);
167  }
168  }
169  //if (hOrbitNumberDiff_->GetBinContent(i) > 0) syncStatus_[i-1] = 1;
170  }
171 
172  // KCHIP integrity
173  me = _igetter.get(prefixME_ + "/ESIntegrityTask/ES KChip Flag 1 Error codes");
174  hKF1_ = getHisto(me, cloneME_, hKF1_);
175 
176  me = _igetter.get(prefixME_ + "/ESIntegrityTask/ES KChip Flag 2 Error codes");
177  hKF2_ = getHisto(me, cloneME_, hKF2_);
178 
179  me = _igetter.get(prefixME_ + "/ESIntegrityTask/ES KChip BC mismatch with OptoRX");
180  hKBC_ = getHisto(me, cloneME_, hKBC_);
181 
182  me = _igetter.get(prefixME_ + "/ESIntegrityTask/ES KChip EC mismatch with OptoRX");
183  hKEC_ = getHisto(me, cloneME_, hKEC_);
184 
185  Int_t kchip_xval[1550];
186  for (int i=0; i<1550; ++i) {
187 
188  xval = 3;
189  Int_t kErr = 0;
190  for (int j=1; j<16; ++j) {
191  if (hKF1_) {
192  if (hKF1_->GetBinContent(i, j+1)>0) {
193  xval = 2;
194  kErr++;
195  }
196  }
197  if (hKF2_) {
198  if (hKF2_->GetBinContent(i, j+1)>0) {
199  xval = 4;
200  kErr++;
201  }
202  }
203  }
204  if (hKBC_) {
205  if (hKBC_->GetBinContent(i)>0) {
206  xval = 5;
207  kErr++;
208  }
209  }
210  if (hKEC_) {
211  if (hKEC_->GetBinContent(i)>0) {
212  xval = 6;
213  kErr++;
214  }
215  }
216  if (kErr>1) xval = 7;
217  kchip_xval[i] = xval;
218  }
219 
220  // detailed KCHIP summary (i.e. summary 2)
221  for (int iz=0; iz<2; ++iz)
222  for (int ip=0; ip<2; ++ip)
223  for (int ix=0; ix<40; ++ix)
224  for (int iy=0; iy<40; ++iy) {
225  if (fed_[iz][ip][ix][iy] == -1) continue;
226  if (fedStatus_[fed_[iz][ip][ix][iy]-520]==-1 || fiberStatus_[fed_[iz][ip][ix][iy]-520][fiber_[iz][ip][ix][iy]] == 0)
227  kchip_xval[kchip_[iz][ip][ix][iy]-1] = 0;
228  if ((kchip_[iz][ip][ix][iy]-2) >= 0)
229  meKCHIP_[iz][ip]->setBinContent(ix+1, iy+1, kchip_xval[kchip_[iz][ip][ix][iy]-2]);
230  }
231 
232  // FED, Fiber, KCHIP summary (i.e. summary 1)
233  Int_t nErr = 0;
234  for (int iz=0; iz<2; ++iz)
235  for (int ip=0; ip<2; ++ip)
236  for (int ix=0; ix<40; ++ix)
237  for (int iy=0; iy<40; ++iy) {
238 
239  if (fed_[iz][ip][ix][iy] == -1) continue;
240  nErr = 0;
241 
242  if (fedStatus_[fed_[iz][ip][ix][iy]-520] == 1) {
243 
244  if (hFED_) {
245  if (hFED_->GetBinContent(fed_[iz][ip][ix][iy]-520+1) == nevFEDs)
246  xval = 3;
247  else {
248  xval = 4; // FED problem
249  nErr++;
250  }
251  }
252 
253  if (fiberStatus_[fed_[iz][ip][ix][iy]-520][fiber_[iz][ip][ix][iy]] == 2) {
254  xval = 2; // fiber problem
255  nErr++;
256  }
257  if (fiberStatus_[fed_[iz][ip][ix][iy]-520][fiber_[iz][ip][ix][iy]] == 0) {
258  xval = 0; // fiber off
259  }
260  if (kchip_xval[kchip_[iz][ip][ix][iy]-1] != 3 && kchip_xval[kchip_[iz][ip][ix][iy]-1] != 0) {
261  xval = 5; // kchip problem
262  nErr++;
263  }
264  if (syncStatus_[fed_[iz][ip][ix][iy]-520] == 1) {
265  xval = 6;
266  nErr++;
267  }
268  if (slinkCRCStatus_[fed_[iz][ip][ix][iy]-520] == 1) {
269  xval = 8;
270  nErr++;
271  }
272  if (nErr > 1) xval = 7;
273  } else if (fedStatus_[fed_[iz][ip][ix][iy]-520] == -1) {
274  xval = 0;
275  }
276 
277  meFED_[iz][ip]->setBinContent(ix+1, iy+1, xval);
278  }
279 
280 }
MonitorElement * meFED_[2][2]
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
bool cloneME_
Definition: ESClient.h:32
int kchip_[2][2][40][40]
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
int fed_[2][2][40][40]
~ESIntegrityClient()
Destructor.
std::string prefixME_
Definition: ESClient.h:31
MonitorElement * meKCHIP_[2][2]
void endLumiAnalyze(DQMStore::IGetter &) override
Analyze.
int k[5][pyjets_maxn]
int fiberStatus_[56][36]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
ESIntegrityClient(const edm::ParameterSet &ps)
Constructor.
T * getHisto(MonitorElement *, bool=false, T *=0) const
Definition: ESClient.h:40
std::string fullPath() const
Definition: FileInPath.cc:184
int fiber_[2][2][40][40]
void book(DQMStore::IBooker &) override
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)