00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <memory>
00013 #include <iostream>
00014 #include <fstream>
00015 #include <iomanip>
00016
00017 #include "FWCore/ServiceRegistry/interface/Service.h"
00018
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020 #include "DQMServices/Core/interface/MonitorElement.h"
00021
00022 #ifdef WITH_ECAL_COND_DB
00023 #include "OnlineDB/EcalCondDB/interface/RunTag.h"
00024 #include "OnlineDB/EcalCondDB/interface/RunIOV.h"
00025 #include "OnlineDB/EcalCondDB/interface/MonCrystalConsistencyDat.h"
00026 #include "OnlineDB/EcalCondDB/interface/MonTTConsistencyDat.h"
00027 #include "OnlineDB/EcalCondDB/interface/MonMemChConsistencyDat.h"
00028 #include "OnlineDB/EcalCondDB/interface/MonMemTTConsistencyDat.h"
00029 #include "OnlineDB/EcalCondDB/interface/RunCrystalErrorsDat.h"
00030 #include "OnlineDB/EcalCondDB/interface/RunTTErrorsDat.h"
00031 #include "OnlineDB/EcalCondDB/interface/RunPNErrorsDat.h"
00032 #include "OnlineDB/EcalCondDB/interface/RunMemChErrorsDat.h"
00033 #include "OnlineDB/EcalCondDB/interface/RunMemTTErrorsDat.h"
00034 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00035 #include "DQM/EcalCommon/interface/LogicID.h"
00036 #endif
00037
00038 #include "DQM/EcalCommon/interface/Masks.h"
00039
00040 #include "DQM/EcalCommon/interface/UtilsClient.h"
00041 #include "DQM/EcalCommon/interface/Numbers.h"
00042
00043 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00044
00045 #include "DQM/EcalEndcapMonitorClient/interface/EEIntegrityClient.h"
00046
00047 EEIntegrityClient::EEIntegrityClient(const edm::ParameterSet& ps) {
00048
00049
00050 cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00051
00052
00053 verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00054
00055
00056 debug_ = ps.getUntrackedParameter<bool>("debug", false);
00057
00058
00059 prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00060
00061 subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
00062
00063
00064 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00065
00066
00067 superModules_.reserve(18);
00068 for ( unsigned int i = 1; i <= 18; i++ ) superModules_.push_back(i);
00069 superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00070
00071 h00_ = 0;
00072
00073 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00074
00075 int ism = superModules_[i];
00076
00077 h_[ism-1] = 0;
00078 hmem_[ism-1] = 0;
00079
00080 h01_[ism-1] = 0;
00081 h02_[ism-1] = 0;
00082 h03_[ism-1] = 0;
00083 h04_[ism-1] = 0;
00084 h05_[ism-1] = 0;
00085 h06_[ism-1] = 0;
00086 h07_[ism-1] = 0;
00087 h08_[ism-1] = 0;
00088 h09_[ism-1] = 0;
00089
00090 }
00091
00092 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00093
00094 int ism = superModules_[i];
00095
00096
00097 meg01_[ism-1] = 0;
00098 meg02_[ism-1] = 0;
00099
00100 }
00101
00102 threshCry_ = 0.01;
00103
00104 }
00105
00106 EEIntegrityClient::~EEIntegrityClient() {
00107
00108 }
00109
00110 void EEIntegrityClient::beginJob(void) {
00111
00112 dqmStore_ = edm::Service<DQMStore>().operator->();
00113
00114 if ( debug_ ) std::cout << "EEIntegrityClient: beginJob" << std::endl;
00115
00116 ievt_ = 0;
00117 jevt_ = 0;
00118
00119 }
00120
00121 void EEIntegrityClient::beginRun(void) {
00122
00123 if ( debug_ ) std::cout << "EEIntegrityClient: beginRun" << std::endl;
00124
00125 jevt_ = 0;
00126
00127 this->setup();
00128
00129 }
00130
00131 void EEIntegrityClient::endJob(void) {
00132
00133 if ( debug_ ) std::cout << "EEIntegrityClient: endJob, ievt = " << ievt_ << std::endl;
00134
00135 this->cleanup();
00136
00137 }
00138
00139 void EEIntegrityClient::endRun(void) {
00140
00141 if ( debug_ ) std::cout << "EEIntegrityClient: endRun, jevt = " << jevt_ << std::endl;
00142
00143 this->cleanup();
00144
00145 }
00146
00147 void EEIntegrityClient::setup(void) {
00148
00149 std::string name;
00150
00151 dqmStore_->setCurrentFolder( prefixME_ + "/EEIntegrityClient" );
00152
00153 if(subfolder_.size())
00154 dqmStore_->setCurrentFolder(prefixME_ + "/EEIntegrityClient/" + subfolder_);
00155
00156 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00157
00158 int ism = superModules_[i];
00159
00160 if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00161 name = "EEIT data integrity quality " + Numbers::sEE(ism);
00162 meg01_[ism-1] = dqmStore_->book2D(name, name, 50, Numbers::ix0EE(ism)+0., Numbers::ix0EE(ism)+50., 50, Numbers::iy0EE(ism)+0., Numbers::iy0EE(ism)+50.);
00163 meg01_[ism-1]->setAxisTitle("ix", 1);
00164 if ( ism >= 1 && ism <= 9 ) meg01_[ism-1]->setAxisTitle("101-ix", 1);
00165 meg01_[ism-1]->setAxisTitle("iy", 2);
00166
00167 if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00168 name = "EEIT data integrity quality MEM " + Numbers::sEE(ism);
00169 meg02_[ism-1] = dqmStore_->book2D(name, name, 10, 0., 10., 5, 0.,5.);
00170 meg02_[ism-1]->setAxisTitle("pseudo-strip", 1);
00171 meg02_[ism-1]->setAxisTitle("channel", 2);
00172
00173 }
00174
00175 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00176
00177 int ism = superModules_[i];
00178
00179 if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
00180 if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
00181
00182 for ( int ix = 1; ix <= 50; ix++ ) {
00183 for ( int iy = 1; iy <= 50; iy++ ) {
00184
00185 if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 6. );
00186
00187 int jx = ix + Numbers::ix0EE(ism);
00188 int jy = iy + Numbers::iy0EE(ism);
00189
00190 if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00191
00192 if ( Numbers::validEE(ism, jx, jy) ) {
00193 if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 2. );
00194 }
00195
00196 }
00197 }
00198
00199 for ( int ie = 1; ie <= 10; ie++ ) {
00200 for ( int ip = 1; ip <= 5; ip++ ) {
00201
00202 if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 6. );
00203
00204
00205 if ( (ism >= 3 && ism <= 4) || (ism >= 7 && ism <= 9) ) continue;
00206 if ( (ism >= 12 && ism <= 3) || (ism >= 16 && ism <= 18) ) continue;
00207
00208 if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 2. );
00209
00210 }
00211 }
00212
00213 }
00214
00215 }
00216
00217 void EEIntegrityClient::cleanup(void) {
00218
00219 if ( ! enableCleanup_ ) return;
00220
00221 if ( cloneME_ ) {
00222 if ( h00_ ) delete h00_;
00223 }
00224
00225 h00_ = 0;
00226
00227 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00228
00229 int ism = superModules_[i];
00230
00231 if ( cloneME_ ) {
00232 if ( h_[ism-1] ) delete h_[ism-1];
00233 if ( hmem_[ism-1] ) delete hmem_[ism-1];
00234
00235 if ( h01_[ism-1] ) delete h01_[ism-1];
00236 if ( h02_[ism-1] ) delete h02_[ism-1];
00237 if ( h03_[ism-1] ) delete h03_[ism-1];
00238 if ( h04_[ism-1] ) delete h04_[ism-1];
00239 if ( h05_[ism-1] ) delete h05_[ism-1];
00240 if ( h06_[ism-1] ) delete h06_[ism-1];
00241 if ( h07_[ism-1] ) delete h07_[ism-1];
00242 if ( h08_[ism-1] ) delete h08_[ism-1];
00243 if ( h09_[ism-1] ) delete h09_[ism-1];
00244 }
00245
00246 h_[ism-1] = 0;
00247 hmem_[ism-1] = 0;
00248
00249 h01_[ism-1] = 0;
00250 h02_[ism-1] = 0;
00251 h03_[ism-1] = 0;
00252 h04_[ism-1] = 0;
00253 h05_[ism-1] = 0;
00254 h06_[ism-1] = 0;
00255 h07_[ism-1] = 0;
00256 h08_[ism-1] = 0;
00257 h09_[ism-1] = 0;
00258
00259 }
00260
00261 dqmStore_->setCurrentFolder( prefixME_ + "/EEIntegrityClient" );
00262
00263 if(subfolder_.size())
00264 dqmStore_->setCurrentFolder(prefixME_ + "/EEIntegrityClient/" + subfolder_);
00265
00266 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00267
00268 int ism = superModules_[i];
00269
00270 if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00271 meg01_[ism-1] = 0;
00272
00273 if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00274 meg02_[ism-1] = 0;
00275
00276 }
00277
00278 }
00279
00280 #ifdef WITH_ECAL_COND_DB
00281 bool EEIntegrityClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00282
00283 status = true;
00284
00285 EcalLogicID ecid;
00286
00287 MonCrystalConsistencyDat c1;
00288 std::map<EcalLogicID, MonCrystalConsistencyDat> dataset1;
00289 MonTTConsistencyDat c2;
00290 std::map<EcalLogicID, MonTTConsistencyDat> dataset2;
00291 MonMemChConsistencyDat c3;
00292 std::map<EcalLogicID, MonMemChConsistencyDat> dataset3;
00293 MonMemTTConsistencyDat c4;
00294 std::map<EcalLogicID, MonMemTTConsistencyDat> dataset4;
00295
00296 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00297
00298 int ism = superModules_[i];
00299
00300 if ( h00_ && h00_->GetBinContent(ism) != 0 ) {
00301 std::cerr << std::endl;
00302 std::cerr << " DCC failed " << h00_->GetBinContent(ism) << " times" << std::endl;
00303 std::cerr << std::endl;
00304 }
00305
00306 if ( verbose_ ) {
00307 std::cout << " " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00308 std::cout << std::endl;
00309 UtilsClient::printBadChannels(meg01_[ism-1], h01_[ism-1], true);
00310 UtilsClient::printBadChannels(meg01_[ism-1], h02_[ism-1], true);
00311 UtilsClient::printBadChannels(meg01_[ism-1], h03_[ism-1], true);
00312 UtilsClient::printBadChannels(meg01_[ism-1], h04_[ism-1], true);
00313 UtilsClient::printBadChannels(meg01_[ism-1], h05_[ism-1], true);
00314
00315 UtilsClient::printBadChannels(meg02_[ism-1], h06_[ism-1], true);
00316 UtilsClient::printBadChannels(meg02_[ism-1], h07_[ism-1], true);
00317 UtilsClient::printBadChannels(meg02_[ism-1], h08_[ism-1], true);
00318 UtilsClient::printBadChannels(meg02_[ism-1], h09_[ism-1], true);
00319 }
00320
00321 float num00;
00322
00323 num00 = 0.;
00324
00325 bool update0 = false;
00326
00327 if ( h00_ ) {
00328 num00 = h00_->GetBinContent(ism);
00329 if ( num00 > 0 ) update0 = true;
00330 }
00331
00332 float num01, num02, num03;
00333
00334 for ( int ix = 1; ix <= 50; ix++ ) {
00335 for ( int iy = 1; iy <= 50; iy++ ) {
00336
00337 int jx = ix + Numbers::ix0EE(ism);
00338 int jy = iy + Numbers::iy0EE(ism);
00339
00340 if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00341
00342 if ( ! Numbers::validEE(ism, jx, jy) ) continue;
00343
00344 num01 = num02 = num03 = 0.;
00345
00346 bool update1 = false;
00347
00348 float numTot = -1.;
00349
00350 if ( h_[ism-1] ) numTot = h_[ism-1]->GetBinContent(ix, iy);
00351
00352 if ( h01_[ism-1] ) {
00353 num01 = h01_[ism-1]->GetBinContent(ix, iy);
00354 if ( num01 > 0 ) update1 = true;
00355 }
00356
00357 if ( h02_[ism-1] ) {
00358 num02 = h02_[ism-1]->GetBinContent(ix, iy);
00359 if ( num02 > 0 ) update1 = true;
00360 }
00361
00362 if ( h03_[ism-1] ) {
00363 num03 = h03_[ism-1]->GetBinContent(ix, iy);
00364 if ( num03 > 0 ) update1 = true;
00365 }
00366
00367 if ( update0 || update1 ) {
00368
00369 if ( Numbers::icEE(ism, jx, jy) == 1 ) {
00370
00371 if ( verbose_ ) {
00372 std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00373 std::cout << "(" << Numbers::ix0EE(i+1)+ix << "," << Numbers::iy0EE(i+1)+iy << ") " << num00 << " " << num01 << " " << num02 << " " << num03 << std::endl;
00374 std::cout << std::endl;
00375 }
00376
00377 }
00378
00379 c1.setProcessedEvents(int(numTot));
00380 c1.setProblematicEvents(int(num01+num02+num03));
00381 c1.setProblemsGainZero(int(num01));
00382 c1.setProblemsID(int(num02));
00383 c1.setProblemsGainSwitch(int(num03));
00384
00385 bool val;
00386
00387 val = false;
00388 if ( numTot > 0 ) {
00389 float errorRate1 = num00 / ( numTot + num01 + num02 + num03 );
00390 if ( errorRate1 > threshCry_ )
00391 val = true;
00392 errorRate1 = ( num01 + num02 + num03 ) / ( numTot + num01 + num02 + num03 ) / 3.;
00393 if ( errorRate1 > threshCry_ )
00394 val = true;
00395 } else {
00396 if ( num00 > 0 )
00397 val = true;
00398 if ( ( num01 + num02 + num03 ) > 0 )
00399 val = true;
00400 }
00401 c1.setTaskStatus(val);
00402
00403 int ic = Numbers::indexEE(ism, jx, jy);
00404
00405 if ( ic == -1 ) continue;
00406
00407 if ( econn ) {
00408 ecid = LogicID::getEcalLogicID("EE_crystal_number", Numbers::iSM(ism, EcalEndcap), ic);
00409 dataset1[ecid] = c1;
00410 }
00411
00412 status = status && !val;
00413
00414 }
00415
00416 }
00417 }
00418
00419 float num04, num05;
00420
00421 for ( int ixt = 1; ixt <= 10; ixt++ ) {
00422 for ( int iyt = 1; iyt <= 10; iyt++ ) {
00423
00424 int jxt = Numbers::ix0EE(ism) + 1 + 5*(ixt-1);
00425 int jyt = Numbers::iy0EE(ism) + 1 + 5*(iyt-1);
00426
00427 if ( ism >= 1 && ism <= 9 ) jxt = 101 - jxt;
00428
00429 num04 = num05 = 0.;
00430
00431 bool update1 = false;
00432
00433 float numTot = -1.;
00434
00435 if ( h_[ism-1] ) {
00436 numTot = 0.;
00437 for ( int ix = 1 + 5*(ixt-1); ix <= 5*ixt; ix++ ) {
00438 for ( int iy = 1 + 5*(iyt-1); iy <= 5*iyt; iy++ ) {
00439 int jx = ix + Numbers::ix0EE(ism);
00440 int jy = iy + Numbers::iy0EE(ism);
00441 if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00442 if ( ! Numbers::validEE(ism, jx, jy) ) continue;
00443 numTot += h_[ism-1]->GetBinContent(ix, iy);
00444 }
00445 }
00446 }
00447
00448 if ( h04_[ism-1] ) {
00449 for ( int ix = 1 + 5*(ixt-1); ix <= 5*ixt; ix++ ) {
00450 for ( int iy = 1 + 5*(iyt-1); iy <= 5*iyt; iy++ ) {
00451 int jx = ix + Numbers::ix0EE(ism);
00452 int jy = iy + Numbers::iy0EE(ism);
00453 if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00454 if ( ! Numbers::validEE(ism, jx, jy) ) continue;
00455 num04 = h04_[ism-1]->GetBinContent(ix, iy);
00456 if ( num04 > 0 ) update1 = true;
00457 }
00458 }
00459 }
00460
00461 if ( h05_[ism-1] ) {
00462 for ( int ix = 1 + 5*(ixt-1); ix <= 5*ixt; ix++ ) {
00463 for ( int iy = 1 + 5*(iyt-1); iy <= 5*iyt; iy++ ) {
00464 int jx = ix + Numbers::ix0EE(ism);
00465 int jy = iy + Numbers::iy0EE(ism);
00466 if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00467 if ( ! Numbers::validEE(ism, jx, jy) ) continue;
00468 num05 = h05_[ism-1]->GetBinContent(ix, iy);
00469 if ( num05 > 0 ) update1 = true;
00470 }
00471 }
00472 }
00473
00474 if ( update0 || update1 ) {
00475
00476 if ( Numbers::iSC(ism, EcalEndcap, jxt, jyt) == 1 ) {
00477
00478 if ( verbose_ ) {
00479 std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00480 std::cout << "(" << 1+(Numbers::ix0EE(ism)+1+5*(ixt-1))/5 << "," << 1+(Numbers::iy0EE(ism)+1+5*(iyt-1))/5 << ") " << num00 << " " << num04 << " " << num05 << std::endl;
00481 std::cout << std::endl;
00482 }
00483
00484 }
00485
00486 c2.setProcessedEvents(int(numTot));
00487 c2.setProblematicEvents(int(num04+num05));
00488 c2.setProblemsID(int(num04));
00489 c2.setProblemsSize(int(num05));
00490 c2.setProblemsLV1(int(-1.));
00491 c2.setProblemsBunchX(int(-1.));
00492
00493 bool val;
00494
00495 val = false;
00496 if ( numTot > 0 ) {
00497 float errorRate2 = num00 / ( numTot + num04 + num05 );
00498 if ( errorRate2 > threshCry_ )
00499 val = true;
00500 errorRate2 = ( num04 + num05 ) / ( numTot + num04 + num05 ) / 2.;
00501 if ( errorRate2 > threshCry_ )
00502 val = true;
00503 } else {
00504 if ( num00 > 0 )
00505 val = true;
00506 if ( ( num04 + num05 ) > 0 )
00507 val = true;
00508 }
00509 c2.setTaskStatus(val);
00510
00511 int itt = Numbers::iSC(ism, EcalEndcap, jxt, jyt);
00512
00513 if ( itt == -1 ) continue;
00514
00515 if ( econn ) {
00516 ecid = LogicID::getEcalLogicID("EE_readout_tower", Numbers::iSM(ism, EcalEndcap), itt);
00517 dataset2[ecid] = c2;
00518 }
00519
00520 status = status && !val;
00521
00522 }
00523
00524 }
00525 }
00526
00527 float num06, num07;
00528
00529 for ( int ix = 1; ix <= 10; ix++ ) {
00530 for ( int iy = 1; iy <= 5; iy++ ) {
00531
00532 num06 = num07 = 0.;
00533
00534 bool update1 = false;
00535
00536 float numTot = -1.;
00537
00538 if ( hmem_[ism-1] ) numTot = hmem_[ism-1]->GetBinContent(ix, iy);
00539
00540 if ( h06_[ism-1] ) {
00541 num06 = h06_[ism-1]->GetBinContent(ix, iy);
00542 if ( num06 > 0 ) update1 = true;
00543 }
00544
00545 if ( h07_[ism-1] ) {
00546 num07 = h07_[ism-1]->GetBinContent(ix, iy);
00547 if ( num07 > 0 ) update1 = true;
00548 }
00549
00550 if ( update0 || update1 ) {
00551
00552 if ( ix ==1 && iy == 1 ) {
00553
00554 if ( verbose_ ) {
00555 std::cout << "Preparing dataset for mem of SM=" << ism << std::endl;
00556 std::cout << "(" << ix << "," << iy << ") " << num06 << " " << num07 << std::endl;
00557 std::cout << std::endl;
00558 }
00559
00560 }
00561
00562 c3.setProcessedEvents( int (numTot));
00563 c3.setProblematicEvents(int (num06+num07));
00564 c3.setProblemsID(int (num06) );
00565 c3.setProblemsGainZero(int (num07));
00566
00567
00568 bool val;
00569
00570 val = false;
00571 if ( numTot > 0 ) {
00572 float errorRate1 = num00 / ( numTot + num06 + num07 );
00573 if ( errorRate1 > threshCry_ )
00574 val = true;
00575 errorRate1 = ( num06 + num07 ) / ( numTot + num06 + num07 ) / 2.;
00576 if ( errorRate1 > threshCry_ )
00577 val = true;
00578 } else {
00579 if ( num00 > 0 )
00580 val = true;
00581 if ( ( num06 + num07 ) > 0 )
00582 val = true;
00583 }
00584 c3. setTaskStatus(val);
00585
00586 int ic = EEIntegrityClient::chNum[ (ix-1)%5 ][ (iy-1) ] + (ix-1)/5 * 25;
00587
00588 if ( econn ) {
00589 ecid = LogicID::getEcalLogicID("EE_mem_channel", Numbers::iSM(ism, EcalEndcap), ic);
00590 dataset3[ecid] = c3;
00591 }
00592
00593 status = status && !val;
00594
00595 }
00596
00597 }
00598 }
00599
00600 float num08, num09;
00601
00602 for ( int ixt = 1; ixt <= 2; ixt++ ) {
00603
00604 num08 = num09 = 0.;
00605
00606 bool update1 = false;
00607
00608 float numTot = -1.;
00609
00610 if ( hmem_[ism-1] ) {
00611 numTot = 0.;
00612 for ( int ix = 1 + 5*(ixt-1); ix <= 5*ixt; ix++ ) {
00613 for ( int iy = 1 ; iy <= 5; iy++ ) {
00614 numTot += hmem_[ism-1]->GetBinContent(ix, iy);
00615 }
00616 }
00617 }
00618
00619 if ( h08_[ism-1] ) {
00620 num08 = h08_[ism-1]->GetBinContent(ixt, 1);
00621 if ( num08 > 0 ) update1 = true;
00622 }
00623
00624 if ( h09_[ism-1] ) {
00625 num09 = h09_[ism-1]->GetBinContent(ixt, 1);
00626 if ( num09 > 0 ) update1 = true;
00627 }
00628
00629 if ( update0 || update1 ) {
00630
00631 if ( ixt == 1 ) {
00632
00633 if ( verbose_ ) {
00634 std::cout << "Preparing dataset for " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00635 std::cout << "(" << ixt << ") " << num08 << " " << num09 << std::endl;
00636 std::cout << std::endl;
00637 }
00638
00639 }
00640
00641 c4.setProcessedEvents( int(numTot) );
00642 c4.setProblematicEvents( int(num08 + num09) );
00643 c4.setProblemsID( int(num08) );
00644 c4.setProblemsSize(int (num09) );
00645
00646
00647
00648 bool val;
00649
00650 val = false;
00651 if ( numTot > 0 ) {
00652 float errorRate2 = num00 / ( numTot + num08 + num09 );
00653 if ( errorRate2 > threshCry_ )
00654 val = true;
00655 errorRate2 = ( num08 + num09 ) / ( numTot/25. + num08 + num09 ) / 2.;
00656 if ( errorRate2 > threshCry_ )
00657 val = true;
00658 } else {
00659 if ( num00 > 0 )
00660 val = true;
00661 if ( ( num08 + num09 ) > 0 )
00662 val = true;
00663 }
00664 c4.setTaskStatus(val);
00665
00666 int itt = 68 + ixt;
00667
00668 if ( econn ) {
00669 ecid = LogicID::getEcalLogicID("EE_mem_TT", Numbers::iSM(ism, EcalEndcap), itt);
00670 dataset4[ecid] = c4;
00671 }
00672
00673 status = status && !val;
00674
00675 }
00676
00677 }
00678
00679 }
00680
00681 if ( econn ) {
00682 try {
00683 if ( verbose_ ) std::cout << "Inserting MonConsistencyDat ..." << std::endl;
00684 if ( dataset1.size() != 0 ) econn->insertDataArraySet(&dataset1, moniov);
00685 if ( dataset2.size() != 0 ) econn->insertDataArraySet(&dataset2, moniov);
00686 if ( dataset3.size() != 0 ) econn->insertDataArraySet(&dataset3, moniov);
00687 if ( dataset4.size() != 0 ) econn->insertDataArraySet(&dataset4, moniov);
00688 if ( verbose_ ) std::cout << "done." << std::endl;
00689 } catch (std::runtime_error &e) {
00690 std::cerr << e.what() << std::endl;
00691 }
00692 }
00693
00694 return true;
00695
00696 }
00697 #endif
00698
00699 void EEIntegrityClient::analyze(void) {
00700
00701 ievt_++;
00702 jevt_++;
00703 if ( ievt_ % 10 == 0 ) {
00704 if ( debug_ ) std::cout << "EEIntegrityClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
00705 }
00706
00707 uint32_t bits01 = 0;
00708 bits01 |= 1 << EcalDQMStatusHelper::CH_ID_ERROR;
00709 bits01 |= 1 << EcalDQMStatusHelper::CH_GAIN_ZERO_ERROR;
00710 bits01 |= 1 << EcalDQMStatusHelper::CH_GAIN_SWITCH_ERROR;
00711 bits01 |= 1 << EcalDQMStatusHelper::TT_ID_ERROR;
00712 bits01 |= 1 << EcalDQMStatusHelper::TT_SIZE_ERROR;
00713
00714 std::string subdir(subfolder_.size() ? subfolder_ + "/" : "");
00715
00716 MonitorElement* me;
00717
00718 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "EEIT DCC size error" );
00719 h00_ = UtilsClient::getHisto( me, cloneME_, h00_ );
00720
00721 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00722
00723 int ism = superModules_[i];
00724
00725 me = dqmStore_->get( prefixME_ + "/EEOccupancyTask/" + subdir + "EEOT digi occupancy " + Numbers::sEE(ism) );
00726 h_[ism-1] = UtilsClient::getHisto( me, cloneME_, h_[ism-1] );
00727
00728 me = dqmStore_->get( prefixME_ + "/EEOccupancyTask/" + subdir + "EEOT MEM digi occupancy " + Numbers::sEE(ism) );
00729 hmem_[ism-1] = UtilsClient::getHisto( me, cloneME_, hmem_[ism-1] );
00730
00731 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "Gain/EEIT gain " + Numbers::sEE(ism) );
00732 h01_[ism-1] = UtilsClient::getHisto( me, cloneME_, h01_[ism-1] );
00733
00734 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "ChId/EEIT ChId " + Numbers::sEE(ism) );
00735 h02_[ism-1] = UtilsClient::getHisto( me, cloneME_, h02_[ism-1] );
00736
00737 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "GainSwitch/EEIT gain switch " + Numbers::sEE(ism) );
00738 h03_[ism-1] = UtilsClient::getHisto( me, cloneME_, h03_[ism-1] );
00739
00740 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "TTId/EEIT TTId " + Numbers::sEE(ism) );
00741 h04_[ism-1] = UtilsClient::getHisto( me, cloneME_, h04_[ism-1] );
00742
00743 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "TTBlockSize/EEIT TTBlockSize " + Numbers::sEE(ism) );
00744 h05_[ism-1] = UtilsClient::getHisto( me, cloneME_, h05_[ism-1] );
00745
00746 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "MemChId/EEIT MemChId " + Numbers::sEE(ism) );
00747 h06_[ism-1] = UtilsClient::getHisto( me, cloneME_, h06_[ism-1] );
00748
00749 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "MemGain/EEIT MemGain " + Numbers::sEE(ism) );
00750 h07_[ism-1] = UtilsClient::getHisto( me, cloneME_, h07_[ism-1] );
00751
00752 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "MemTTId/EEIT MemTTId " + Numbers::sEE(ism) );
00753 h08_[ism-1] = UtilsClient::getHisto( me, cloneME_, h08_[ism-1] );
00754
00755 me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/" + subdir + "MemSize/EEIT MemSize " + Numbers::sEE(ism) );
00756 h09_[ism-1] = UtilsClient::getHisto( me, cloneME_, h09_[ism-1] );
00757
00758 float num00;
00759
00760
00761 if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
00762 if ( meg01_[ism-1] ) meg02_[ism-1]->Reset();
00763
00764 num00 = 0.;
00765
00766 bool update0 = false;
00767
00768
00769 if ( h00_ ) {
00770 num00 = h00_->GetBinContent(ism);
00771 update0 = true;
00772 }
00773
00774 float num01, num02, num03, num04, num05;
00775
00776 for ( int ix = 1; ix <= 50; ix++ ) {
00777 for ( int iy = 1; iy <= 50; iy++ ) {
00778
00779 num01 = num02 = num03 = num04 = num05 = 0.;
00780
00781 if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, 6. );
00782
00783 bool update1 = false;
00784 bool update2 = false;
00785
00786 float numTot = -1.;
00787
00788 if ( h_[ism-1] ) numTot = h_[ism-1]->GetBinContent(ix, iy);
00789
00790 if ( h01_[ism-1] ) {
00791 num01 = h01_[ism-1]->GetBinContent(ix, iy);
00792 update1 = true;
00793 }
00794
00795 if ( h02_[ism-1] ) {
00796 num02 = h02_[ism-1]->GetBinContent(ix, iy);
00797 update1 = true;
00798 }
00799
00800 if ( h03_[ism-1] ) {
00801 num03 = h03_[ism-1]->GetBinContent(ix, iy);
00802 update1 = true;
00803 }
00804
00805 if ( h04_[ism-1] ) {
00806 num04 = h04_[ism-1]->GetBinContent(ix, iy);
00807 update2 = true;
00808 }
00809
00810 if ( h05_[ism-1] ) {
00811 num05 = h05_[ism-1]->GetBinContent(ix, iy);
00812 update2 = true;
00813 }
00814
00815 if ( update0 || update1 || update2 ) {
00816
00817 float val;
00818
00819 val = 1.;
00820
00821 if ( numTot > 0 ) {
00822 float errorRate1 = num00 / ( numTot + num01 + num02 + num03 );
00823 if ( errorRate1 > threshCry_ )
00824 val = 0.;
00825 errorRate1 = ( num01 + num02 + num03 ) / ( numTot + num01 + num02 + num03 ) / 3.;
00826 if ( errorRate1 > threshCry_ )
00827 val = 0.;
00828 float errorRate2 = ( num04 + num05 ) / ( numTot + num04 + num05 ) / 2.;
00829 if ( errorRate2 > threshCry_ )
00830 val = 0.;
00831 } else {
00832 val = 2.;
00833 if ( num00 > 0 )
00834 val = 0.;
00835 if ( ( num01 + num02 + num03 ) > 0 )
00836 val = 0.;
00837 if ( ( num04 + num05 ) > 0 )
00838 val = 0.;
00839 }
00840
00841 int jx = ix + Numbers::ix0EE(ism);
00842 int jy = iy + Numbers::iy0EE(ism);
00843
00844 if ( ism >= 1 && ism <= 9 ) jx = 101 - jx;
00845
00846
00847 if ( Numbers::validEE(ism, jx, jy) ) {
00848 if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ix, iy, val );
00849 }
00850
00851 }
00852
00853 if ( Masks::maskChannel(ism, ix, iy, bits01, EcalEndcap) ) UtilsClient::maskBinContent( meg01_[ism-1], ix, iy );
00854
00855 }
00856 }
00857
00858
00859 float num06, num07, num08, num09;
00860
00861 for ( int ie = 1; ie <= 10; ie++ ) {
00862 for ( int ip = 1; ip <= 5; ip++ ) {
00863
00864 num06 = num07 = num08 = num09 = 0.;
00865
00866
00867 if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 6. );
00868
00869
00870 if ( (ism >= 3 && ism <= 4) || (ism >= 7 && ism <= 9) ) continue;
00871 if ( (ism >= 12 && ism <= 13) || (ism >= 16 && ism <= 18) ) continue;
00872
00873 if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 2. );
00874
00875 bool update1 = false;
00876 bool update2 = false;
00877
00878 float numTotmem = -1.;
00879
00880 if ( hmem_[ism-1] ) numTotmem = hmem_[ism-1]->GetBinContent(ie, ip);
00881
00882 if ( h06_[ism-1] ) {
00883 num06 = h06_[ism-1]->GetBinContent(ie, ip);
00884 update1 = true;
00885 }
00886
00887 if ( h07_[ism-1] ) {
00888 num07 = h07_[ism-1]->GetBinContent(ie, ip);
00889 update1 = true;
00890 }
00891
00892 int iet = 1 + ((ie-1)/5);
00893 int ipt = 1;
00894
00895 if ( h08_[ism-1] ) {
00896 num08 = h08_[ism-1]->GetBinContent(iet, ipt);
00897 update2 = true;
00898 }
00899
00900 if ( h09_[ism-1] ) {
00901 num09 = h09_[ism-1]->GetBinContent(iet, ipt);
00902 update2 = true;
00903 }
00904
00905 if ( update0 || update1 || update2 ) {
00906
00907 float val;
00908
00909 val = 1.;
00910
00911 if ( numTotmem > 0 ) {
00912 float errorRate1 = ( num06 + num07 ) / ( numTotmem + num06 + num07 )/ 2.;
00913 if ( errorRate1 > threshCry_ )
00914 val = 0.;
00915 float errorRate2 = ( num08 + num09 ) / ( numTotmem/25. + num08 + num09 ) / 2.;
00916 if ( errorRate2 > threshCry_ )
00917 val = 0.;
00918 } else {
00919 val = 2.;
00920 if ( ( num06 + num07 ) > 0 )
00921 val = 0.;
00922 if ( ( num08 + num09 ) > 0 )
00923 val = 0.;
00924 }
00925
00926
00927 if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, val );
00928
00929 }
00930
00931 if ( Masks::maskPn(ism, ie, bits01, EcalEndcap) ) UtilsClient::maskBinContent( meg02_[ism-1], ie, ip );
00932
00933 }
00934 }
00935
00936 }
00937
00938 }
00939
00940 const int EEIntegrityClient::chNum[5][5] = {
00941 { 1, 2, 3, 4, 5},
00942 {10, 9, 8, 7, 6},
00943 {11, 12, 13, 14, 15},
00944 {20, 19, 18, 17, 16},
00945 {21, 22, 23, 24, 25}
00946 };
00947