CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESIntegrityClient.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <iostream>
3 #include <fstream>
4 #include <iomanip>
5 
7 
10 
11 using namespace edm;
12 using namespace std;
13 
15 
16  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
17  verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
18  debug_ = ps.getUntrackedParameter<bool>("debug", false);
19  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
20  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
21  lookup_ = ps.getUntrackedParameter<FileInPath>("LookupTable", edm::FileInPath("EventFilter/ESDigiToRaw/data/ES_lookup_table.dat"));
22 
23  // read in look-up table
24  for (int i=0; i<2; ++i)
25  for (int j=0; j<2; ++j)
26  for (int k=0; k<40; ++k)
27  for (int m=0; m<40; ++m) {
28  fed_[i][j][k][m] = -1;
29  kchip_[i][j][k][m] = -1;
30  }
31 
32  for (int i=0; i<56; ++i) {
33  fedStatus_[i] = -1;
34  syncStatus_[i] = -1;
35  slinkCRCStatus_[i] = -1;
36  for (int j=0; j<36; ++j)
37  fiberStatus_[i][j] = -1;
38  }
39 
40  int nLines_, z, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
41  ifstream file;
42  file.open(lookup_.fullPath().c_str());
43  if( file.is_open() ) {
44 
45  file >> nLines_;
46 
47  for (int i=0; i<nLines_; ++i) {
48  file>> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
49 
50  z = (iz==-1) ? 2:iz;
51  fed_[z-1][ip-1][ix-1][iy-1] = fed;
52  kchip_[z-1][ip-1][ix-1][iy-1] = kchip;
53  fiber_[z-1][ip-1][ix-1][iy-1] = (fiber-1)+(optorx-1)*12;
54  }
55  }
56  else {
57  cout<<"ESIntegrityClient : Look up table file can not be found in "<<lookup_.fullPath().c_str()<<endl;
58  }
59 
60  hFED_ = 0;
61  hFiberOff_ = 0;
62  hFiberBadStatus_ = 0;
63  hKF1_ = 0;
64  hKF2_ = 0;
65  hKBC_ = 0;
66  hKEC_ = 0;
67  hL1ADiff_ = 0;
68  hBXDiff_ = 0;
69  hOrbitNumberDiff_ = 0;
70  hSLinkCRCErr_ = 0;
71 
72  ievt_ = 0;
73  jevt_ = 0;
74 }
75 
77 }
78 
80 
81  dqmStore_ = dqmStore;
82 
83  if ( debug_ ) cout << "ESIntegrityClient: beginJob" << endl;
84 
85  ievt_ = 0;
86  jevt_ = 0;
87 }
88 
90 
91  if ( debug_ ) cout << "ESIntegrityClient: beginRun" << endl;
92 
93  jevt_ = 0;
94 
95  this->setup();
96 
97 }
98 
100 
101  if ( debug_ ) cout << "ESIntegrityClient: endJob, ievt = " << ievt_ << endl;
102 
103  this->cleanup();
104 
105 }
106 
108 
109  if ( debug_ ) cout << "ESIntegrityClient: endRun, jevt = " << jevt_ << endl;
110 
111  this->cleanup();
112 
113 }
114 
116 
117  char histo[200];
118 
119  dqmStore_->setCurrentFolder( prefixME_ + "/ESIntegrityClient" );
120 
121  for (int i=0 ; i<2; ++i)
122  for (int j=0 ; j<2; ++j) {
123  int iz = (i==0)? 1:-1;
124  snprintf(histo, 200, "ES Integrity Summary 1 Z %d P %d", iz, j+1);
125  meFED_[i][j] = dqmStore_->book2D(histo, histo, 40, 0.5, 40.5, 40, 0.5, 40.5);
126  meFED_[i][j]->setAxisTitle("Si X", 1);
127  meFED_[i][j]->setAxisTitle("Si Y", 2);
128 
129  snprintf(histo, 200, "ES Integrity Summary 2 Z %d P %d", iz, j+1);
130  meKCHIP_[i][j] = dqmStore_->book2D(histo, histo, 40, 0.5, 40.5, 40, 0.5, 40.5);
131  meKCHIP_[i][j]->setAxisTitle("Si X", 1);
132  meKCHIP_[i][j]->setAxisTitle("Si Y", 2);
133  }
134 }
135 
137 
138  if ( ! enableCleanup_ ) return;
139 
140 }
141 
143 
144  double nDI_FedErr[56];
145  for (int i=0; i<56; ++i) nDI_FedErr[i] = 0;
146 
147  MonitorElement* me = 0;
148 
149  me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/ES FEDs used for data taking");
150  hFED_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hFED_ );
151 
152  me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/ES Fiber Off");
153  hFiberOff_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hFiberOff_ );
154 
155  me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/ES Fiber Bad Status");
156  hFiberBadStatus_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hFiberBadStatus_ );
157 
158  me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/ES SLink CRC Errors");
159  hSLinkCRCErr_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hSLinkCRCErr_ );
160 
161  int xval = 0;
162  int nevFEDs = 0;
163  if (hFED_) {
164  for (int i=1; i<=56; ++i)
165  if (nevFEDs < hFED_->GetBinContent(i))
166  nevFEDs = (int) hFED_->GetBinContent(i);
167  }
168 
169  // FED integrity
170  for (int i=1; i<=56; ++i) {
171  if (hFED_) {
172  if (hFED_->GetBinContent(i) > 0)
173  fedStatus_[i-1] = 1;
174  }
175  if (hSLinkCRCErr_) {
176  if (hSLinkCRCErr_->GetBinContent(i) > 0)
177  slinkCRCStatus_[i-1] = 1;
178  }
179  for (int j=0; j<36; ++j) {
180  if (hFiberBadStatus_) {
181  if (hFiberBadStatus_->GetBinContent(i, j+1) > 0)
182  fiberStatus_[i-1][j] = 2; // bad
183  else
184  fiberStatus_[i-1][j] = 1; // good
185  }
186  if (hFiberOff_)
187  if (hFiberOff_->GetBinContent(i, j+1) > 0) {
188  fiberStatus_[i-1][j] = 0; // off
189  }
190  }
191  }
192 
193  // obtain MEs from ESRawDataTask
194  me = dqmStore_->get(prefixME_ + "/ESRawDataTask/ES L1A DCC errors");
195  hL1ADiff_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hL1ADiff_ );
196 
197  me = dqmStore_->get(prefixME_ + "/ESRawDataTask/ES BX DCC errors");
198  hBXDiff_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hBXDiff_ );
199 
200  me = dqmStore_->get(prefixME_ + "/ESRawDataTask/ES Orbit Number DCC errors");
201  hOrbitNumberDiff_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hOrbitNumberDiff_ );
202 
203  for (int i=1; i<=56; ++i) {
204  if (hL1ADiff_ && hBXDiff_) {
205  if (hL1ADiff_->GetBinContent(i) > 0 || hBXDiff_->GetBinContent(i) > 0) {
206  syncStatus_[i-1] = 1;
207  if (hL1ADiff_->GetBinContent(i) > nDI_FedErr[i-1]) nDI_FedErr[i-1] = hL1ADiff_->GetBinContent(i);
208  if (hBXDiff_->GetBinContent(i) > nDI_FedErr[i-1]) nDI_FedErr[i-1] = hBXDiff_->GetBinContent(i);
209  }
210  }
211  //if (hOrbitNumberDiff_->GetBinContent(i) > 0) syncStatus_[i-1] = 1;
212  }
213 
214  // KCHIP integrity
215  me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/ES KChip Flag 1 Error codes");
216  hKF1_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hKF1_ );
217 
218  me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/ES KChip Flag 2 Error codes");
219  hKF2_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hKF2_ );
220 
221  me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/ES KChip BC mismatch with OptoRX");
222  hKBC_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hKBC_ );
223 
224  me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/ES KChip EC mismatch with OptoRX");
225  hKEC_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hKEC_ );
226 
227  Int_t kchip_xval[1550];
228  for (int i=0; i<1550; ++i) {
229 
230  xval = 3;
231  Int_t kErr = 0;
232  for (int j=1; j<16; ++j) {
233  if (hKF1_) {
234  if (hKF1_->GetBinContent(i, j+1)>0) {
235  xval = 2;
236  kErr++;
237  }
238  }
239  if (hKF2_) {
240  if (hKF2_->GetBinContent(i, j+1)>0) {
241  xval = 4;
242  kErr++;
243  }
244  }
245  }
246  if (hKBC_) {
247  if (hKBC_->GetBinContent(i)>0) {
248  xval = 5;
249  kErr++;
250  }
251  }
252  if (hKEC_) {
253  if (hKEC_->GetBinContent(i)>0) {
254  xval = 6;
255  kErr++;
256  }
257  }
258  if (kErr>1) xval = 7;
259  kchip_xval[i] = xval;
260  }
261 
262  // detailed KCHIP summary (i.e. summary 2)
263  for (int iz=0; iz<2; ++iz)
264  for (int ip=0; ip<2; ++ip)
265  for (int ix=0; ix<40; ++ix)
266  for (int iy=0; iy<40; ++iy) {
267  if (fed_[iz][ip][ix][iy] == -1) continue;
268  if (fedStatus_[fed_[iz][ip][ix][iy]-520]==-1 || fiberStatus_[fed_[iz][ip][ix][iy]-520][fiber_[iz][ip][ix][iy]] == 0)
269  kchip_xval[kchip_[iz][ip][ix][iy]-1] = 0;
270  if ((kchip_[iz][ip][ix][iy]-2) >= 0)
271  meKCHIP_[iz][ip]->setBinContent(ix+1, iy+1, kchip_xval[kchip_[iz][ip][ix][iy]-2]);
272  }
273 
274  // FED, Fiber, KCHIP summary (i.e. summary 1)
275  Int_t nErr = 0;
276  for (int iz=0; iz<2; ++iz)
277  for (int ip=0; ip<2; ++ip)
278  for (int ix=0; ix<40; ++ix)
279  for (int iy=0; iy<40; ++iy) {
280 
281  if (fed_[iz][ip][ix][iy] == -1) continue;
282  nErr = 0;
283 
284  if (fedStatus_[fed_[iz][ip][ix][iy]-520] == 1) {
285 
286  if (hFED_) {
287  if (hFED_->GetBinContent(fed_[iz][ip][ix][iy]-520+1) == nevFEDs)
288  xval = 3;
289  else {
290  xval = 4; // FED problem
291  nErr++;
292  }
293  }
294 
295  if (fiberStatus_[fed_[iz][ip][ix][iy]-520][fiber_[iz][ip][ix][iy]] == 2) {
296  xval = 2; // fiber problem
297  nErr++;
298  }
299  if (fiberStatus_[fed_[iz][ip][ix][iy]-520][fiber_[iz][ip][ix][iy]] == 0) {
300  xval = 0; // fiber off
301  }
302  if (kchip_xval[kchip_[iz][ip][ix][iy]-1] != 3 && kchip_xval[kchip_[iz][ip][ix][iy]-1] != 0) {
303  xval = 5; // kchip problem
304  nErr++;
305  }
306  if (syncStatus_[fed_[iz][ip][ix][iy]-520] == 1) {
307  xval = 6;
308  nErr++;
309  }
310  if (slinkCRCStatus_[fed_[iz][ip][ix][iy]-520] == 1) {
311  xval = 8;
312  nErr++;
313  }
314  if (nErr > 1) xval = 7;
315  } else if (fedStatus_[fed_[iz][ip][ix][iy]-520] == -1) {
316  xval = 0;
317  }
318 
319  meFED_[iz][ip]->setBinContent(ix+1, iy+1, xval);
320  }
321 
322 }
323 
325 
326 }
327 
328 
void softReset(bool flag)
SoftReset.
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void setBinContent(int binx, double content)
set content of bin (1-D)
void beginRun(void)
BeginRun.
static void cleanup(const Factory::MakerMap::value_type &v)
Definition: Factory.cc:12
void setup(void)
Setup.
float float float z
virtual ~ESIntegrityClient()
Destructor.
void cleanup(void)
Cleanup.
void beginJob(DQMStore *dqmStore)
BeginJob.
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
Ecal Monitor Utils for Client.
ESIntegrityClient(const edm::ParameterSet &ps)
Constructor.
tuple cout
Definition: gather_cfg.py:121
void endRun(void)
EndRun.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void endJob(void)
EndJob.
void analyze(void)
Analyze.