00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <memory>
00012 #include <iostream>
00013 #include <fstream>
00014 #include <iomanip>
00015 #include <math.h>
00016
00017 #include "TCanvas.h"
00018 #include "TStyle.h"
00019
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021
00022 #include "OnlineDB/EcalCondDB/interface/MonTestPulseDat.h"
00023 #include "OnlineDB/EcalCondDB/interface/MonPulseShapeDat.h"
00024 #include "OnlineDB/EcalCondDB/interface/MonPNMGPADat.h"
00025 #include "OnlineDB/EcalCondDB/interface/RunCrystalErrorsDat.h"
00026 #include "OnlineDB/EcalCondDB/interface/RunTTErrorsDat.h"
00027 #include "OnlineDB/EcalCondDB/interface/RunPNErrorsDat.h"
00028
00029 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00030
00031 #include "CondTools/Ecal/interface/EcalErrorDictionary.h"
00032
00033 #include "DQM/EcalCommon/interface/EcalErrorMask.h"
00034 #include "DQM/EcalCommon/interface/UtilsClient.h"
00035 #include "DQM/EcalCommon/interface/LogicID.h"
00036 #include "DQM/EcalCommon/interface/Numbers.h"
00037
00038 #include <DQM/EcalBarrelMonitorClient/interface/EBTestPulseClient.h>
00039
00040 using namespace cms;
00041 using namespace edm;
00042 using namespace std;
00043
00044 EBTestPulseClient::EBTestPulseClient(const ParameterSet& ps) {
00045
00046
00047 cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00048
00049
00050 verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00051
00052
00053 debug_ = ps.getUntrackedParameter<bool>("debug", false);
00054
00055
00056 prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00057
00058
00059 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00060
00061
00062 superModules_.reserve(36);
00063 for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
00064 superModules_ = ps.getUntrackedParameter<vector<int> >("superModules", superModules_);
00065
00066 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00067
00068 int ism = superModules_[i];
00069
00070 ha01_[ism-1] = 0;
00071 ha02_[ism-1] = 0;
00072 ha03_[ism-1] = 0;
00073
00074 hs01_[ism-1] = 0;
00075 hs02_[ism-1] = 0;
00076 hs03_[ism-1] = 0;
00077
00078 i01_[ism-1] = 0;
00079 i02_[ism-1] = 0;
00080 i03_[ism-1] = 0;
00081 i04_[ism-1] = 0;
00082
00083 }
00084
00085 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00086
00087 int ism = superModules_[i];
00088
00089 meg01_[ism-1] = 0;
00090 meg02_[ism-1] = 0;
00091 meg03_[ism-1] = 0;
00092
00093 meg04_[ism-1] = 0;
00094 meg05_[ism-1] = 0;
00095
00096 mea01_[ism-1] = 0;
00097 mea02_[ism-1] = 0;
00098 mea03_[ism-1] = 0;
00099
00100 mer04_[ism-1] = 0;
00101 mer05_[ism-1] = 0;
00102
00103 me_hs01_[ism-1] = 0;
00104 me_hs02_[ism-1] = 0;
00105 me_hs03_[ism-1] = 0;
00106
00107 }
00108
00109 percentVariation_ = 0.2;
00110 RMSThreshold_ = 300.0;
00111
00112 amplitudeThreshold_ = 100.;
00113
00114 amplitudeThresholdPnG01_ = 200./16.;
00115 amplitudeThresholdPnG16_ = 200.;
00116
00117 pedPnExpectedMean_[0] = 750.0;
00118 pedPnExpectedMean_[1] = 750.0;
00119
00120 pedPnDiscrepancyMean_[0] = 100.0;
00121 pedPnDiscrepancyMean_[1] = 100.0;
00122
00123 pedPnRMSThreshold_[0] = 1.0;
00124 pedPnRMSThreshold_[1] = 3.0;
00125
00126 }
00127
00128 EBTestPulseClient::~EBTestPulseClient() {
00129
00130 }
00131
00132 void EBTestPulseClient::beginJob(DQMStore* dqmStore) {
00133
00134 dqmStore_ = dqmStore;
00135
00136 if ( debug_ ) cout << "EBTestPulseClient: beginJob" << endl;
00137
00138 ievt_ = 0;
00139 jevt_ = 0;
00140
00141 }
00142
00143 void EBTestPulseClient::beginRun(void) {
00144
00145 if ( debug_ ) cout << "EBTestPulseClient: beginRun" << endl;
00146
00147 jevt_ = 0;
00148
00149 this->setup();
00150
00151 }
00152
00153 void EBTestPulseClient::endJob(void) {
00154
00155 if ( debug_ ) cout << "EBTestPulseClient: endJob, ievt = " << ievt_ << endl;
00156
00157 this->cleanup();
00158
00159 }
00160
00161 void EBTestPulseClient::endRun(void) {
00162
00163 if ( debug_ ) cout << "EBTestPulseClient: endRun, jevt = " << jevt_ << endl;
00164
00165 this->cleanup();
00166
00167 }
00168
00169 void EBTestPulseClient::setup(void) {
00170
00171 char histo[200];
00172
00173 dqmStore_->setCurrentFolder( prefixME_ + "/EBTestPulseClient" );
00174
00175 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00176
00177 int ism = superModules_[i];
00178
00179 if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00180 sprintf(histo, "EBTPT test pulse quality G01 %s", Numbers::sEB(ism).c_str());
00181 meg01_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00182 meg01_[ism-1]->setAxisTitle("ieta", 1);
00183 meg01_[ism-1]->setAxisTitle("iphi", 2);
00184 if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00185 sprintf(histo, "EBTPT test pulse quality G06 %s", Numbers::sEB(ism).c_str());
00186 meg02_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00187 meg02_[ism-1]->setAxisTitle("ieta", 1);
00188 meg02_[ism-1]->setAxisTitle("iphi", 2);
00189 if ( meg03_[ism-1] ) dqmStore_->removeElement( meg03_[ism-1]->getName() );
00190 sprintf(histo, "EBTPT test pulse quality G12 %s", Numbers::sEB(ism).c_str());
00191 meg03_[ism-1] = dqmStore_->book2D(histo, histo, 85, 0., 85., 20, 0., 20.);
00192 meg03_[ism-1]->setAxisTitle("ieta", 1);
00193 meg03_[ism-1]->setAxisTitle("iphi", 2);
00194
00195 if ( meg04_[ism-1] ) dqmStore_->removeElement( meg04_[ism-1]->getName() );
00196 sprintf(histo, "EBTPT test pulse quality PNs G01 %s", Numbers::sEB(ism).c_str());
00197 meg04_[ism-1] = dqmStore_->book2D(histo, histo, 10, 0., 10., 1, 0., 5.);
00198 meg04_[ism-1]->setAxisTitle("pseudo-strip", 1);
00199 meg04_[ism-1]->setAxisTitle("channel", 2);
00200 if ( meg05_[ism-1] ) dqmStore_->removeElement( meg05_[ism-1]->getName() );
00201 sprintf(histo, "EBTPT test pulse quality PNs G16 %s", Numbers::sEB(ism).c_str());
00202 meg05_[ism-1] = dqmStore_->book2D(histo, histo, 10, 0., 10., 1, 0., 5.);
00203 meg05_[ism-1]->setAxisTitle("pseudo-strip", 1);
00204 meg05_[ism-1]->setAxisTitle("channel", 2);
00205
00206 if ( mea01_[ism-1] ) dqmStore_->removeElement( mea01_[ism-1]->getName() );
00207 sprintf(histo, "EBTPT test pulse amplitude G01 %s", Numbers::sEB(ism).c_str());
00208 mea01_[ism-1] = dqmStore_->book1D(histo, histo, 1700, 0., 1700.);
00209 mea01_[ism-1]->setAxisTitle("channel", 1);
00210 mea01_[ism-1]->setAxisTitle("amplitude", 2);
00211 if ( mea02_[ism-1] ) dqmStore_->removeElement( mea02_[ism-1]->getName() );
00212 sprintf(histo, "EBTPT test pulse amplitude G06 %s", Numbers::sEB(ism).c_str());
00213 mea02_[ism-1] = dqmStore_->book1D(histo, histo, 1700, 0., 1700.);
00214 mea02_[ism-1]->setAxisTitle("channel", 1);
00215 mea02_[ism-1]->setAxisTitle("amplitude", 2);
00216 if ( mea03_[ism-1] ) dqmStore_->removeElement( mea03_[ism-1]->getName() );
00217 sprintf(histo, "EBTPT test pulse amplitude G12 %s", Numbers::sEB(ism).c_str());
00218 mea03_[ism-1] = dqmStore_->book1D(histo, histo, 1700, 0., 1700.);
00219 mea03_[ism-1]->setAxisTitle("channel", 1);
00220 mea03_[ism-1]->setAxisTitle("amplitude", 2);
00221
00222 if ( mer04_[ism-1] ) dqmStore_->removeElement( mer04_[ism-1]->getName() );
00223 sprintf(histo, "EBPDT PNs pedestal rms %s G01", Numbers::sEB(ism).c_str());
00224 mer04_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00225 mer04_[ism-1]->setAxisTitle("rms", 1);
00226 if ( mer05_[ism-1] ) dqmStore_->removeElement( mer05_[ism-1]->getName() );
00227 sprintf(histo, "EBPDT PNs pedestal rms %s G16", Numbers::sEB(ism).c_str());
00228 mer05_[ism-1] = dqmStore_->book1D(histo, histo, 100, 0., 10.);
00229 mer05_[ism-1]->setAxisTitle("rms", 1);
00230
00231 if ( me_hs01_[ism-1] ) dqmStore_->removeElement( me_hs01_[ism-1]->getName() );
00232 sprintf(histo, "EBTPT test pulse shape G01 %s", Numbers::sEB(ism).c_str());
00233 me_hs01_[ism-1] = dqmStore_->book1D(histo, histo, 10, 0., 10.);
00234 me_hs01_[ism-1]->setAxisTitle("sample", 1);
00235 me_hs01_[ism-1]->setAxisTitle("amplitude", 2);
00236 if ( me_hs02_[ism-1] ) dqmStore_->removeElement( me_hs02_[ism-1]->getName() );
00237 sprintf(histo, "EBTPT test pulse shape G06 %s", Numbers::sEB(ism).c_str());
00238 me_hs02_[ism-1] = dqmStore_->book1D(histo, histo, 10, 0., 10.);
00239 me_hs02_[ism-1]->setAxisTitle("sample", 1);
00240 me_hs02_[ism-1]->setAxisTitle("amplitude", 2);
00241 if ( me_hs03_[ism-1] ) dqmStore_->removeElement( me_hs03_[ism-1]->getName() );
00242 sprintf(histo, "EBTPT test pulse shape G12 %s", Numbers::sEB(ism).c_str());
00243 me_hs03_[ism-1] = dqmStore_->book1D(histo, histo, 10, 0., 10.);
00244 me_hs03_[ism-1]->setAxisTitle("sample", 1);
00245 me_hs03_[ism-1]->setAxisTitle("amplitude", 2);
00246
00247 }
00248
00249 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00250
00251 int ism = superModules_[i];
00252
00253 meg01_[ism-1]->Reset();
00254 meg02_[ism-1]->Reset();
00255 meg03_[ism-1]->Reset();
00256
00257 meg04_[ism-1]->Reset();
00258 meg05_[ism-1]->Reset();
00259
00260 for ( int ie = 1; ie <= 85; ie++ ) {
00261 for ( int ip = 1; ip <= 20; ip++ ) {
00262
00263 meg01_[ism-1]->setBinContent( ie, ip, 2. );
00264 meg02_[ism-1]->setBinContent( ie, ip, 2. );
00265 meg03_[ism-1]->setBinContent( ie, ip, 2. );
00266
00267 }
00268 }
00269
00270 for ( int i = 1; i <= 10; i++ ) {
00271
00272 meg04_[ism-1]->setBinContent( i, 1, 2. );
00273 meg05_[ism-1]->setBinContent( i, 1, 2. );
00274
00275 }
00276
00277 mea01_[ism-1]->Reset();
00278 mea02_[ism-1]->Reset();
00279 mea03_[ism-1]->Reset();
00280
00281 mer04_[ism-1]->Reset();
00282 mer05_[ism-1]->Reset();
00283
00284 me_hs01_[ism-1]->Reset();
00285 me_hs02_[ism-1]->Reset();
00286 me_hs03_[ism-1]->Reset();
00287
00288 }
00289
00290 }
00291
00292 void EBTestPulseClient::cleanup(void) {
00293
00294 if ( ! enableCleanup_ ) return;
00295
00296 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00297
00298 int ism = superModules_[i];
00299
00300 if ( cloneME_ ) {
00301 if ( ha01_[ism-1] ) delete ha01_[ism-1];
00302 if ( ha02_[ism-1] ) delete ha02_[ism-1];
00303 if ( ha03_[ism-1] ) delete ha03_[ism-1];
00304
00305 if ( hs01_[ism-1] ) delete hs01_[ism-1];
00306 if ( hs02_[ism-1] ) delete hs02_[ism-1];
00307 if ( hs03_[ism-1] ) delete hs03_[ism-1];
00308
00309 if ( i01_[ism-1] ) delete i01_[ism-1];
00310 if ( i02_[ism-1] ) delete i02_[ism-1];
00311 if ( i03_[ism-1] ) delete i03_[ism-1];
00312 if ( i04_[ism-1] ) delete i04_[ism-1];
00313 }
00314
00315 ha01_[ism-1] = 0;
00316 ha02_[ism-1] = 0;
00317 ha03_[ism-1] = 0;
00318
00319 hs01_[ism-1] = 0;
00320 hs02_[ism-1] = 0;
00321 hs03_[ism-1] = 0;
00322
00323 i01_[ism-1] = 0;
00324 i02_[ism-1] = 0;
00325 i03_[ism-1] = 0;
00326 i04_[ism-1] = 0;
00327
00328 }
00329
00330 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00331
00332 int ism = superModules_[i];
00333
00334 dqmStore_->setCurrentFolder( prefixME_ + "/EBTestPulseClient" );
00335
00336 if ( meg01_[ism-1] ) dqmStore_->removeElement( meg01_[ism-1]->getName() );
00337 meg01_[ism-1] = 0;
00338 if ( meg02_[ism-1] ) dqmStore_->removeElement( meg02_[ism-1]->getName() );
00339 meg02_[ism-1] = 0;
00340 if ( meg03_[ism-1] ) dqmStore_->removeElement( meg03_[ism-1]->getName() );
00341 meg03_[ism-1] = 0;
00342
00343 if ( meg04_[ism-1] ) dqmStore_->removeElement( meg04_[ism-1]->getName() );
00344 meg04_[ism-1] = 0;
00345 if ( meg05_[ism-1] ) dqmStore_->removeElement( meg05_[ism-1]->getName() );
00346 meg05_[ism-1] = 0;
00347
00348 if ( mea01_[ism-1] ) dqmStore_->removeElement( mea01_[ism-1]->getName() );
00349 mea01_[ism-1] = 0;
00350 if ( mea02_[ism-1] ) dqmStore_->removeElement( mea02_[ism-1]->getName() );
00351 mea02_[ism-1] = 0;
00352 if ( mea03_[ism-1] ) dqmStore_->removeElement( mea03_[ism-1]->getName() );
00353 mea03_[ism-1] = 0;
00354
00355 if ( mer04_[ism-1] ) dqmStore_->removeElement( mer04_[ism-1]->getName() );
00356 mer04_[ism-1] = 0;
00357 if ( mer05_[ism-1] ) dqmStore_->removeElement( mer05_[ism-1]->getName() );
00358 mer05_[ism-1] = 0;
00359
00360 if ( me_hs01_[ism-1] ) dqmStore_->removeElement( me_hs01_[ism-1]->getName() );
00361 me_hs01_[ism-1] = 0;
00362 if ( me_hs02_[ism-1] ) dqmStore_->removeElement( me_hs02_[ism-1]->getName() );
00363 me_hs02_[ism-1] = 0;
00364 if ( me_hs03_[ism-1] ) dqmStore_->removeElement( me_hs03_[ism-1]->getName() );
00365 me_hs03_[ism-1] = 0;
00366
00367 }
00368
00369 }
00370
00371 bool EBTestPulseClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status, bool flag) {
00372
00373 status = true;
00374
00375 if ( ! flag ) return false;
00376
00377 EcalLogicID ecid;
00378
00379 MonTestPulseDat adc;
00380 map<EcalLogicID, MonTestPulseDat> dataset1;
00381 MonPulseShapeDat shape;
00382 map<EcalLogicID, MonPulseShapeDat> dataset2;
00383
00384 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00385
00386 int ism = superModules_[i];
00387
00388 if ( verbose_ ) {
00389 cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << endl;
00390 cout << endl;
00391 UtilsClient::printBadChannels(meg01_[ism-1], ha01_[ism-1]);
00392 UtilsClient::printBadChannels(meg02_[ism-1], ha02_[ism-1]);
00393 UtilsClient::printBadChannels(meg03_[ism-1], ha03_[ism-1]);
00394 }
00395
00396 for ( int ie = 1; ie <= 85; ie++ ) {
00397 for ( int ip = 1; ip <= 20; ip++ ) {
00398
00399 bool update01;
00400 bool update02;
00401 bool update03;
00402
00403 float num01, num02, num03;
00404 float mean01, mean02, mean03;
00405 float rms01, rms02, rms03;
00406
00407 update01 = UtilsClient::getBinStatistics(ha01_[ism-1], ie, ip, num01, mean01, rms01);
00408 update02 = UtilsClient::getBinStatistics(ha02_[ism-1], ie, ip, num02, mean02, rms02);
00409 update03 = UtilsClient::getBinStatistics(ha03_[ism-1], ie, ip, num03, mean03, rms03);
00410
00411 if ( update01 || update02 || update03 ) {
00412
00413 if ( Numbers::icEB(ism, ie, ip) == 1 ) {
00414
00415 if ( verbose_ ) {
00416 cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << endl;
00417 cout << "G01 (" << ie << "," << ip << ") " << num01 << " " << mean01 << " " << rms01 << endl;
00418 cout << "G06 (" << ie << "," << ip << ") " << num02 << " " << mean02 << " " << rms02 << endl;
00419 cout << "G12 (" << ie << "," << ip << ") " << num03 << " " << mean03 << " " << rms03 << endl;
00420 cout << endl;
00421 }
00422
00423 }
00424
00425 adc.setADCMeanG1(mean01);
00426 adc.setADCRMSG1(rms01);
00427
00428 adc.setADCMeanG6(mean02);
00429 adc.setADCRMSG6(rms02);
00430
00431 adc.setADCMeanG12(mean03);
00432 adc.setADCRMSG12(rms03);
00433
00434 if ( UtilsClient::getBinStatus(meg01_[ism-1], ie, ip) &&
00435 UtilsClient::getBinStatus(meg02_[ism-1], ie, ip) &&
00436 UtilsClient::getBinStatus(meg03_[ism-1], ie, ip) ) {
00437 adc.setTaskStatus(true);
00438 } else {
00439 adc.setTaskStatus(false);
00440 }
00441
00442 status = status && UtilsClient::getBinQuality(meg01_[ism-1], ie, ip) &&
00443 UtilsClient::getBinQuality(meg02_[ism-1], ie, ip) &&
00444 UtilsClient::getBinQuality(meg03_[ism-1], ie, ip);
00445
00446 if ( Numbers::icEB(ism, ie, ip) == 1 ) {
00447
00448 vector<float> sample01, sample02, sample03;
00449
00450 sample01.clear();
00451 sample02.clear();
00452 sample03.clear();
00453
00454 if ( me_hs01_[ism-1] ) {
00455 for ( int i = 1; i <= 10; i++ ) {
00456 sample01.push_back(int(me_hs01_[ism-1]->getBinContent(i)));
00457 }
00458 } else {
00459 for ( int i = 1; i <= 10; i++ ) { sample01.push_back(-1.); }
00460 }
00461
00462 if ( me_hs02_[ism-1] ) {
00463 for ( int i = 1; i <= 10; i++ ) {
00464 sample02.push_back(int(me_hs02_[ism-1]->getBinContent(i)));
00465 }
00466 } else {
00467 for ( int i = 1; i <= 10; i++ ) { sample02.push_back(-1.); }
00468 }
00469
00470 if ( me_hs03_[ism-1] ) {
00471 for ( int i = 1; i <= 10; i++ ) {
00472 sample03.push_back(int(me_hs03_[ism-1]->getBinContent(i)));
00473 }
00474 } else {
00475 for ( int i = 1; i <= 10; i++ ) { sample03.push_back(-1.); }
00476 }
00477
00478 if ( verbose_ ) {
00479 cout << "sample01 = " << flush;
00480 for ( unsigned int i = 0; i < sample01.size(); i++ ) {
00481 cout << sample01[i] << " " << flush;
00482 }
00483 cout << endl;
00484
00485 cout << "sample02 = " << flush;
00486 for ( unsigned int i = 0; i < sample02.size(); i++ ) {
00487 cout << sample02[i] << " " << flush;
00488 }
00489 cout << endl;
00490
00491 cout << "sample03 = " << flush;
00492 for ( unsigned int i = 0; i < sample03.size(); i++ ) {
00493 cout << sample03[i] << " " << flush;
00494 }
00495 cout << endl;
00496 }
00497
00498 if ( verbose_ ) cout << endl;
00499
00500 shape.setSamples(sample01, 1);
00501 shape.setSamples(sample02, 6);
00502 shape.setSamples(sample03, 12);
00503
00504 }
00505
00506 int ic = Numbers::indexEB(ism, ie, ip);
00507
00508 if ( econn ) {
00509 ecid = LogicID::getEcalLogicID("EB_crystal_number", Numbers::iSM(ism, EcalBarrel), ic);
00510 dataset1[ecid] = adc;
00511 if ( Numbers::icEB(ism, ie, ip) == 1 ) dataset2[ecid] = shape;
00512 }
00513
00514 }
00515
00516 }
00517 }
00518
00519 }
00520
00521 if ( econn ) {
00522 try {
00523 if ( verbose_ ) cout << "Inserting MonTestPulseDat ..." << endl;
00524 if ( dataset1.size() != 0 ) econn->insertDataArraySet(&dataset1, moniov);
00525 if ( dataset2.size() != 0 ) econn->insertDataSet(&dataset2, moniov);
00526 if ( verbose_ ) cout << "done." << endl;
00527 } catch (runtime_error &e) {
00528 cerr << e.what() << endl;
00529 }
00530 }
00531
00532 if ( verbose_ ) cout << endl;
00533
00534 MonPNMGPADat pn;
00535 map<EcalLogicID, MonPNMGPADat> dataset3;
00536
00537 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00538
00539 int ism = superModules_[i];
00540
00541 if ( verbose_ ) {
00542 cout << " " << Numbers::sEB(ism) << " (ism=" << ism << ")" << endl;
00543 cout << endl;
00544 UtilsClient::printBadChannels(meg04_[ism-1], i01_[ism-1]);
00545 UtilsClient::printBadChannels(meg04_[ism-1], i03_[ism-1]);
00546 UtilsClient::printBadChannels(meg05_[ism-1], i02_[ism-1]);
00547 UtilsClient::printBadChannels(meg05_[ism-1], i04_[ism-1]);
00548 }
00549
00550 for ( int i = 1; i <= 10; i++ ) {
00551
00552 bool update01;
00553 bool update02;
00554 bool update03;
00555 bool update04;
00556
00557 float num01, num02, num03, num04;
00558 float mean01, mean02, mean03, mean04;
00559 float rms01, rms02, rms03, rms04;
00560
00561 update01 = UtilsClient::getBinStatistics(i01_[ism-1], i, 0, num01, mean01, rms01);
00562 update02 = UtilsClient::getBinStatistics(i02_[ism-1], i, 0, num02, mean02, rms02);
00563 update03 = UtilsClient::getBinStatistics(i03_[ism-1], i, 1, num03, mean03, rms03);
00564 update04 = UtilsClient::getBinStatistics(i04_[ism-1], i, 1, num04, mean04, rms04);
00565
00566 if ( update01 || update02 || update03 || update04 ) {
00567
00568 if ( i == 1 ) {
00569
00570 if ( verbose_ ) {
00571 cout << "Preparing dataset for " << Numbers::sEB(ism) << " (ism=" << ism << ")" << endl;
00572 cout << "PNs (" << i << ") G01 " << num01 << " " << mean01 << " " << rms01 << " " << num03 << " " << mean03 << " " << rms03 << endl;
00573 cout << "PNs (" << i << ") G16 " << num02 << " " << mean02 << " " << rms02 << " " << num04 << " " << mean04 << " " << rms04 << endl;
00574 cout << endl;
00575 }
00576
00577 }
00578
00579 pn.setADCMeanG1(mean01);
00580 pn.setADCRMSG1(rms01);
00581
00582 pn.setPedMeanG1(mean03);
00583 pn.setPedRMSG1(rms03);
00584
00585 pn.setADCMeanG16(mean02);
00586 pn.setADCRMSG16(rms02);
00587
00588 pn.setPedMeanG16(mean04);
00589 pn.setPedRMSG16(rms04);
00590
00591 if ( UtilsClient::getBinStatus(meg04_[ism-1], i, 1) &&
00592 UtilsClient::getBinStatus(meg05_[ism-1], i, 1) ) {
00593 pn.setTaskStatus(true);
00594 } else {
00595 pn.setTaskStatus(false);
00596 }
00597
00598 status = status && UtilsClient::getBinQuality(meg04_[ism-1], i, 1) &&
00599 UtilsClient::getBinQuality(meg05_[ism-1], i, 1);
00600
00601 if ( econn ) {
00602 ecid = LogicID::getEcalLogicID("EB_LM_PN", Numbers::iSM(ism, EcalBarrel), i-1);
00603 dataset3[ecid] = pn;
00604 }
00605
00606 }
00607
00608 }
00609
00610 }
00611
00612 if ( econn ) {
00613 try {
00614 if ( verbose_ ) cout << "Inserting MonPNMGPADat ..." << endl;
00615 if ( dataset3.size() != 0 ) econn->insertDataArraySet(&dataset3, moniov);
00616 if ( verbose_ ) cout << "done." << endl;
00617 } catch (runtime_error &e) {
00618 cerr << e.what() << endl;
00619 }
00620 }
00621
00622 return true;
00623
00624 }
00625
00626 void EBTestPulseClient::analyze(void) {
00627
00628 ievt_++;
00629 jevt_++;
00630 if ( ievt_ % 10 == 0 ) {
00631 if ( debug_ ) cout << "EBTestPulseClient: ievt/jevt = " << ievt_ << "/" << jevt_ << endl;
00632 }
00633
00634 uint64_t bits01 = 0;
00635 bits01 |= EcalErrorDictionary::getMask("TESTPULSE_LOW_GAIN_MEAN_WARNING");
00636 bits01 |= EcalErrorDictionary::getMask("TESTPULSE_LOW_GAIN_RMS_WARNING");
00637
00638 uint64_t bits02 = 0;
00639 bits02 |= EcalErrorDictionary::getMask("TESTPULSE_MIDDLE_GAIN_MEAN_WARNING");
00640 bits02 |= EcalErrorDictionary::getMask("TESTPULSE_MIDDLE_GAIN_RMS_WARNING");
00641
00642 uint64_t bits03 = 0;
00643 bits03 |= EcalErrorDictionary::getMask("TESTPULSE_HIGH_GAIN_MEAN_WARNING");
00644 bits03 |= EcalErrorDictionary::getMask("TESTPULSE_HIGH_GAIN_RMS_WARNING");
00645
00646 uint64_t bits04 = 0;
00647 bits04 |= EcalErrorDictionary::getMask("PEDESTAL_LOW_GAIN_MEAN_WARNING");
00648 bits04 |= EcalErrorDictionary::getMask("PEDESTAL_LOW_GAIN_RMS_WARNING");
00649 bits04 |= EcalErrorDictionary::getMask("PEDESTAL_LOW_GAIN_MEAN_ERROR");
00650 bits04 |= EcalErrorDictionary::getMask("PEDESTAL_LOW_GAIN_RMS_ERROR");
00651
00652 uint64_t bits05 = 0;
00653 bits05 |= EcalErrorDictionary::getMask("PEDESTAL_MIDDLE_GAIN_MEAN_WARNING");
00654 bits05 |= EcalErrorDictionary::getMask("PEDESTAL_MIDDLE_GAIN_RMS_WARNING");
00655 bits05 |= EcalErrorDictionary::getMask("PEDESTAL_MIDDLE_GAIN_MEAN_ERROR");
00656 bits05 |= EcalErrorDictionary::getMask("PEDESTAL_MIDDLE_GAIN_RMS_ERROR");
00657
00658 uint64_t bits06 = 0;
00659 bits06 |= EcalErrorDictionary::getMask("PEDESTAL_HIGH_GAIN_MEAN_WARNING");
00660 bits06 |= EcalErrorDictionary::getMask("PEDESTAL_HIGH_GAIN_RMS_WARNING");
00661 bits06 |= EcalErrorDictionary::getMask("PEDESTAL_HIGH_GAIN_MEAN_ERROR");
00662 bits06 |= EcalErrorDictionary::getMask("PEDESTAL_HIGH_GAIN_RMS_ERROR");
00663
00664 map<EcalLogicID, RunCrystalErrorsDat> mask1;
00665 map<EcalLogicID, RunPNErrorsDat> mask2;
00666 map<EcalLogicID, RunTTErrorsDat> mask3;
00667
00668 EcalErrorMask::fetchDataSet(&mask1);
00669 EcalErrorMask::fetchDataSet(&mask2);
00670 EcalErrorMask::fetchDataSet(&mask3);
00671
00672 char histo[200];
00673
00674 MonitorElement* me;
00675
00676 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00677
00678 int ism = superModules_[i];
00679
00680 sprintf(histo, (prefixME_ + "/EBTestPulseTask/Gain01/EBTPT amplitude %s G01").c_str(), Numbers::sEB(ism).c_str());
00681 me = dqmStore_->get(histo);
00682 ha01_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, ha01_[ism-1] );
00683
00684 sprintf(histo, (prefixME_ + "/EBTestPulseTask/Gain06/EBTPT amplitude %s G06").c_str(), Numbers::sEB(ism).c_str());
00685 me = dqmStore_->get(histo);
00686 ha02_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, ha02_[ism-1] );
00687
00688 sprintf(histo, (prefixME_ + "/EBTestPulseTask/Gain12/EBTPT amplitude %s G12").c_str(), Numbers::sEB(ism).c_str());
00689 me = dqmStore_->get(histo);
00690 ha03_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, ha03_[ism-1] );
00691
00692 sprintf(histo, (prefixME_ + "/EBTestPulseTask/Gain01/EBTPT shape %s G01").c_str(), Numbers::sEB(ism).c_str());
00693 me = dqmStore_->get(histo);
00694 hs01_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, hs01_[ism-1] );
00695
00696 sprintf(histo, (prefixME_ + "/EBTestPulseTask/Gain06/EBTPT shape %s G06").c_str(), Numbers::sEB(ism).c_str());
00697 me = dqmStore_->get(histo);
00698 hs02_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, hs02_[ism-1] );
00699
00700 sprintf(histo, (prefixME_ + "/EBTestPulseTask/Gain12/EBTPT shape %s G12").c_str(), Numbers::sEB(ism).c_str());
00701 me = dqmStore_->get(histo);
00702 hs03_[ism-1] = UtilsClient::getHisto<TProfile2D*>( me, cloneME_, hs03_[ism-1] );
00703
00704 sprintf(histo, (prefixME_ + "/EBTestPulseTask/PN/Gain01/EBPDT PNs amplitude %s G01").c_str(), Numbers::sEB(ism).c_str());
00705 me = dqmStore_->get(histo);
00706 i01_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i01_[ism-1] );
00707
00708 sprintf(histo, (prefixME_ + "/EBTestPulseTask/PN/Gain16/EBPDT PNs amplitude %s G16").c_str(), Numbers::sEB(ism).c_str());
00709 me = dqmStore_->get(histo);
00710 i02_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i02_[ism-1] );
00711
00712 sprintf(histo, (prefixME_ + "/EBTestPulseTask/PN/Gain01/EBPDT PNs pedestal %s G01").c_str(), Numbers::sEB(ism).c_str());
00713 me = dqmStore_->get(histo);
00714 i03_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i03_[ism-1] );
00715
00716 sprintf(histo, (prefixME_ + "/EBTestPulseTask/PN/Gain16/EBPDT PNs pedestal %s G16").c_str(), Numbers::sEB(ism).c_str());
00717 me = dqmStore_->get(histo);
00718 i04_[ism-1] = UtilsClient::getHisto<TProfile*>( me, cloneME_, i04_[ism-1] );
00719
00720 if ( meg01_[ism-1] ) meg01_[ism-1]->Reset();
00721 if ( meg02_[ism-1] ) meg02_[ism-1]->Reset();
00722 if ( meg03_[ism-1] ) meg03_[ism-1]->Reset();
00723
00724 if ( meg04_[ism-1] ) meg04_[ism-1]->Reset();
00725 if ( meg05_[ism-1] ) meg05_[ism-1]->Reset();
00726
00727 if ( mea01_[ism-1] ) mea01_[ism-1]->Reset();
00728 if ( mea02_[ism-1] ) mea02_[ism-1]->Reset();
00729 if ( mea03_[ism-1] ) mea03_[ism-1]->Reset();
00730
00731 if ( mer04_[ism-1] ) mer04_[ism-1]->Reset();
00732 if ( mer05_[ism-1] ) mer05_[ism-1]->Reset();
00733
00734 if ( me_hs01_[ism-1] ) me_hs01_[ism-1]->Reset();
00735 if ( me_hs02_[ism-1] ) me_hs02_[ism-1]->Reset();
00736 if ( me_hs03_[ism-1] ) me_hs03_[ism-1]->Reset();
00737
00738 float meanAmpl01, meanAmpl02, meanAmpl03;
00739
00740 int nCry01, nCry02, nCry03;
00741
00742 meanAmpl01 = meanAmpl02 = meanAmpl03 = 0.;
00743
00744 nCry01 = nCry02 = nCry03 = 0;
00745
00746 for ( int ie = 1; ie <= 85; ie++ ) {
00747 for ( int ip = 1; ip <= 20; ip++ ) {
00748
00749 bool update01;
00750 bool update02;
00751 bool update03;
00752
00753 float num01, num02, num03;
00754 float mean01, mean02, mean03;
00755 float rms01, rms02, rms03;
00756
00757 update01 = UtilsClient::getBinStatistics(ha01_[ism-1], ie, ip, num01, mean01, rms01);
00758 update02 = UtilsClient::getBinStatistics(ha02_[ism-1], ie, ip, num02, mean02, rms02);
00759 update03 = UtilsClient::getBinStatistics(ha03_[ism-1], ie, ip, num03, mean03, rms03);
00760
00761 if ( update01 ) {
00762 meanAmpl01 += mean01;
00763 nCry01++;
00764 }
00765
00766 if ( update02 ) {
00767 meanAmpl02 += mean02;
00768 nCry02++;
00769 }
00770
00771 if ( update03 ) {
00772 meanAmpl03 += mean03;
00773 nCry03++;
00774 }
00775
00776 }
00777 }
00778
00779 if ( nCry01 > 0 ) meanAmpl01 /= float (nCry01);
00780 if ( nCry02 > 0 ) meanAmpl02 /= float (nCry02);
00781 if ( nCry03 > 0 ) meanAmpl03 /= float (nCry03);
00782
00783 for ( int ie = 1; ie <= 85; ie++ ) {
00784 for ( int ip = 1; ip <= 20; ip++ ) {
00785
00786 if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ie, ip, 2. );
00787 if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, 2. );
00788 if ( meg03_[ism-1] ) meg03_[ism-1]->setBinContent( ie, ip, 2. );
00789
00790 float numEventsinCry[3] = {0., 0., 0.};
00791
00792 if ( ha01_[ism-1] ) numEventsinCry[0] = ha01_[ism-1]->GetBinEntries(ha01_[ism-1]->GetBin(ie, ip));
00793 if ( ha02_[ism-1] ) numEventsinCry[1] = ha02_[ism-1]->GetBinEntries(ha02_[ism-1]->GetBin(ie, ip));
00794 if ( ha03_[ism-1] ) numEventsinCry[2] = ha03_[ism-1]->GetBinEntries(ha03_[ism-1]->GetBin(ie, ip));
00795
00796 bool update01;
00797 bool update02;
00798 bool update03;
00799
00800 float num01, num02, num03;
00801 float mean01, mean02, mean03;
00802 float rms01, rms02, rms03;
00803
00804 update01 = UtilsClient::getBinStatistics(ha01_[ism-1], ie, ip, num01, mean01, rms01);
00805 update02 = UtilsClient::getBinStatistics(ha02_[ism-1], ie, ip, num02, mean02, rms02);
00806 update03 = UtilsClient::getBinStatistics(ha03_[ism-1], ie, ip, num03, mean03, rms03);
00807
00808 if ( update01 ) {
00809
00810 float val;
00811
00812 val = 1.;
00813 if ( fabs(mean01 - meanAmpl01) > fabs(percentVariation_ * meanAmpl01) || mean01 < amplitudeThreshold_ )
00814 val = 0.;
00815 if ( rms01 > RMSThreshold_ )
00816 val = 0.;
00817 if ( meg01_[ism-1] ) meg01_[ism-1]->setBinContent( ie, ip, val );
00818
00819 int ic = Numbers::icEB(ism, ie, ip);
00820
00821 if ( mea01_[ism-1] ) {
00822 if ( mean01 > 0. ) {
00823 mea01_[ism-1]->setBinContent( ic, mean01 );
00824 mea01_[ism-1]->setBinError( ic, rms01 );
00825 } else {
00826 mea01_[ism-1]->setEntries( 1.+mea01_[ism-1]->getEntries() );
00827 }
00828 }
00829
00830 }
00831
00832 if ( update02 ) {
00833
00834 float val;
00835
00836 val = 1.;
00837 if ( fabs(mean02 - meanAmpl02) > fabs(percentVariation_ * meanAmpl02) || mean02 < amplitudeThreshold_ )
00838 val = 0.;
00839 if ( rms02 > RMSThreshold_ )
00840 val = 0.;
00841 if ( meg02_[ism-1] ) meg02_[ism-1]->setBinContent( ie, ip, val );
00842
00843 int ic = Numbers::icEB(ism, ie, ip);
00844
00845 if ( mea02_[ism-1] ) {
00846 if ( mean02 > 0. ) {
00847 mea02_[ism-1]->setBinContent( ic, mean02 );
00848 mea02_[ism-1]->setBinError( ic, rms02 );
00849 } else {
00850 mea02_[ism-1]->setEntries( 1.+mea02_[ism-1]->getEntries() );
00851 }
00852 }
00853
00854 }
00855
00856 if ( update03 ) {
00857
00858 float val;
00859
00860 val = 1.;
00861 if ( fabs(mean03 - meanAmpl03) > fabs(percentVariation_ * meanAmpl03) || mean03 < amplitudeThreshold_ )
00862 val = 0.;
00863 if ( rms03 > RMSThreshold_ )
00864 val = 0.;
00865 if ( meg03_[ism-1] ) meg03_[ism-1]->setBinContent( ie, ip, val );
00866
00867 int ic = Numbers::icEB(ism, ie, ip);
00868
00869 if ( mea03_[ism-1] ) {
00870 if ( mean03 > 0. ) {
00871 mea03_[ism-1]->setBinContent( ic, mean03 );
00872 mea03_[ism-1]->setBinError( ic, rms03 );
00873 } else {
00874 mea03_[ism-1]->setEntries( 1.+mea03_[ism-1]->getEntries() );
00875 }
00876 }
00877
00878 }
00879
00880
00881
00882 if ( mask1.size() != 0 ) {
00883 map<EcalLogicID, RunCrystalErrorsDat>::const_iterator m;
00884 for (m = mask1.begin(); m != mask1.end(); m++) {
00885
00886 EcalLogicID ecid = m->first;
00887
00888 int ic = Numbers::indexEB(ism, ie, ip);
00889
00890 if ( ecid.getLogicID() == LogicID::getEcalLogicID("EB_crystal_number", Numbers::iSM(ism, EcalBarrel), ic).getLogicID() ) {
00891 if ( (m->second).getErrorBits() & bits01 ) {
00892 UtilsClient::maskBinContent( meg01_[ism-1], ie, ip );
00893 }
00894 if ( (m->second).getErrorBits() & bits02 ) {
00895 UtilsClient::maskBinContent( meg02_[ism-1], ie, ip );
00896 }
00897 if ( (m->second).getErrorBits() & bits03 ) {
00898 UtilsClient::maskBinContent( meg03_[ism-1], ie, ip );
00899 }
00900 }
00901
00902 }
00903 }
00904
00905
00906
00907 if ( mask3.size() != 0 ) {
00908 map<EcalLogicID, RunTTErrorsDat>::const_iterator m;
00909 for (m = mask3.begin(); m != mask3.end(); m++) {
00910
00911 EcalLogicID ecid = m->first;
00912
00913 int itt = Numbers::iTT(ism, EcalBarrel, ie, ip);
00914
00915 if ( ecid.getLogicID() == LogicID::getEcalLogicID("EB_trigger_tower", Numbers::iSM(ism, EcalBarrel), itt).getLogicID() ) {
00916 if ( (m->second).getErrorBits() & bits01 ) {
00917 UtilsClient::maskBinContent( meg01_[ism-1], ie, ip );
00918 }
00919 if ( (m->second).getErrorBits() & bits02 ) {
00920 UtilsClient::maskBinContent( meg02_[ism-1], ie, ip );
00921 }
00922 if ( (m->second).getErrorBits() & bits03 ) {
00923 UtilsClient::maskBinContent( meg03_[ism-1], ie, ip );
00924 }
00925 }
00926
00927 }
00928 }
00929
00930 }
00931 }
00932
00933 for ( int i = 1; i <= 10; i++ ) {
00934
00935 if ( meg04_[ism-1] ) meg04_[ism-1]->setBinContent( i, 1, 2. );
00936 if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent( i, 1, 2. );
00937
00938 bool update01;
00939 bool update02;
00940 bool update03;
00941 bool update04;
00942
00943 float num01, num02, num03, num04;
00944 float mean01, mean02, mean03, mean04;
00945 float rms01, rms02, rms03, rms04;
00946
00947 update01 = UtilsClient::getBinStatistics(i01_[ism-1], i, 0, num01, mean01, rms01);
00948 update02 = UtilsClient::getBinStatistics(i02_[ism-1], i, 0, num02, mean02, rms02);
00949 update03 = UtilsClient::getBinStatistics(i03_[ism-1], i, 0, num03, mean03, rms03);
00950 update04 = UtilsClient::getBinStatistics(i04_[ism-1], i, 0, num04, mean04, rms04);
00951
00952 if ( mer04_[ism-1] ) mer04_[ism-1]->Fill(rms03);
00953 if ( mer05_[ism-1] ) mer05_[ism-1]->Fill(rms04);
00954
00955 if ( update01 && update03 ) {
00956
00957 float val;
00958
00959 val = 1.;
00960 if ( mean01 < amplitudeThresholdPnG01_ )
00961 val = 0.;
00962 if ( mean03 < pedPnExpectedMean_[0] - pedPnDiscrepancyMean_[0] ||
00963 pedPnExpectedMean_[0] + pedPnDiscrepancyMean_[0] < mean03)
00964 val = 0.;
00965 if ( rms03 > pedPnRMSThreshold_[0] )
00966 val = 0.;
00967 if ( meg04_[ism-1] ) meg04_[ism-1]->setBinContent(i, 1, val);
00968
00969 }
00970
00971 if ( update02 && update04 ) {
00972
00973 float val;
00974
00975 val = 1.;
00976 if ( mean02 < amplitudeThresholdPnG16_ )
00977 val = 0.;
00978 if ( mean04 < pedPnExpectedMean_[1] - pedPnDiscrepancyMean_[1] ||
00979 pedPnExpectedMean_[1] + pedPnDiscrepancyMean_[1] < mean04)
00980 val = 0.;
00981 if ( rms04 > pedPnRMSThreshold_[1] )
00982 val = 0.;
00983 if ( meg05_[ism-1] ) meg05_[ism-1]->setBinContent(i, 1, val);
00984
00985 }
00986
00987
00988
00989 if ( mask2.size() != 0 ) {
00990 map<EcalLogicID, RunPNErrorsDat>::const_iterator m;
00991 for (m = mask2.begin(); m != mask2.end(); m++) {
00992
00993 EcalLogicID ecid = m->first;
00994
00995 if ( ecid.getLogicID() == LogicID::getEcalLogicID("EB_LM_PN", Numbers::iSM(ism, EcalBarrel), i-1).getLogicID() ) {
00996 if ( (m->second).getErrorBits() & (bits01|bits04) ) {
00997 UtilsClient::maskBinContent( meg04_[ism-1], i, 1 );
00998 }
00999 if ( (m->second).getErrorBits() & (bits03|bits06) ) {
01000 UtilsClient::maskBinContent( meg05_[ism-1], i, 1 );
01001 }
01002 }
01003
01004 }
01005 }
01006
01007 }
01008
01009 for ( int i = 1; i <= 10; i++ ) {
01010
01011 if ( hs01_[ism-1] ) {
01012 int ic = UtilsClient::getFirstNonEmptyChannel( hs01_[ism-1] );
01013 if ( me_hs01_[ism-1] ) {
01014 me_hs01_[ism-1]->setBinContent( i, hs01_[ism-1]->GetBinContent(ic, i) );
01015 me_hs01_[ism-1]->setBinError( i, hs01_[ism-1]->GetBinError(ic, i) );
01016 }
01017 }
01018
01019 if ( hs02_[ism-1] ) {
01020 int ic = UtilsClient::getFirstNonEmptyChannel( hs02_[ism-1] );
01021 if ( me_hs02_[ism-1] ) {
01022 me_hs02_[ism-1]->setBinContent( i, hs02_[ism-1]->GetBinContent(ic, i) );
01023 me_hs02_[ism-1]->setBinError( i, hs02_[ism-1]->GetBinError(ic, i) );
01024 }
01025 }
01026
01027 if ( hs03_[ism-1] ) {
01028 int ic = UtilsClient::getFirstNonEmptyChannel( hs03_[ism-1] );
01029 if ( me_hs03_[ism-1] ) {
01030 me_hs03_[ism-1]->setBinContent( i, hs03_[ism-1]->GetBinContent(ic, i) );
01031 me_hs03_[ism-1]->setBinError( i, hs03_[ism-1]->GetBinError(ic, i) );
01032 }
01033 }
01034
01035 }
01036
01037 }
01038
01039
01040 }
01041
01042 void EBTestPulseClient::softReset(bool flag) {
01043
01044 }
01045
01046 void EBTestPulseClient::htmlOutput(int run, string& htmlDir, string& htmlName) {
01047
01048 if ( verbose_ ) cout << "Preparing EBTestPulseClient html output ..." << endl;
01049
01050 ofstream htmlFile;
01051
01052 htmlFile.open((htmlDir + htmlName).c_str());
01053
01054
01055 htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << endl;
01056 htmlFile << "<html> " << endl;
01057 htmlFile << "<head> " << endl;
01058 htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << endl;
01059 htmlFile << " https-equiv=\"content-type\"> " << endl;
01060 htmlFile << " <title>Monitor:TestPulseTask output</title> " << endl;
01061 htmlFile << "</head> " << endl;
01062 htmlFile << "<style type=\"text/css\"> td { font-weight: bold } </style>" << endl;
01063 htmlFile << "<body> " << endl;
01064
01065 htmlFile << "<a name=""top""></a>" << endl;
01066 htmlFile << "<h2>Run: " << endl;
01067 htmlFile << " <span " << endl;
01068 htmlFile << " style=\"color: rgb(0, 0, 153);\">" << run << "</span></h2>" << endl;
01069 htmlFile << "<h2>Monitoring task: <span " << endl;
01070 htmlFile << " style=\"color: rgb(0, 0, 153);\">TEST PULSE</span></h2> " << endl;
01071 htmlFile << "<hr>" << endl;
01072 htmlFile << "<table border=1><tr><td bgcolor=red>channel has problems in this task</td>" << endl;
01073 htmlFile << "<td bgcolor=lime>channel has NO problems</td>" << endl;
01074 htmlFile << "<td bgcolor=yellow>channel is missing</td></table>" << endl;
01075 htmlFile << "<br>" << endl;
01076 htmlFile << "<table border=1>" << std::endl;
01077 for ( unsigned int i=0; i<superModules_.size(); i ++ ) {
01078 htmlFile << "<td bgcolor=white><a href=""#"
01079 << Numbers::sEB(superModules_[i]) << ">"
01080 << setfill( '0' ) << setw(2) << superModules_[i] << "</a></td>";
01081 }
01082 htmlFile << std::endl << "</table>" << std::endl;
01083
01084
01085
01086 const int csize = 250;
01087
01088
01089
01090 int pCol3[7] = { 301, 302, 303, 304, 305, 306, 307 };
01091
01092 TH2C dummy( "dummy", "dummy for sm", 85, 0., 85., 20, 0., 20. );
01093 for ( int i = 0; i < 68; i++ ) {
01094 int a = 2 + ( i/4 ) * 5;
01095 int b = 2 + ( i%4 ) * 5;
01096 dummy.Fill( a, b, i+1 );
01097 }
01098 dummy.SetMarkerSize(2);
01099 dummy.SetMinimum(0.1);
01100
01101 TH2C dummy1( "dummy1", "dummy1 for sm mem", 10, 0, 10, 5, 0, 5 );
01102 for ( short i=0; i<2; i++ ) {
01103 int a = 2 + i*5;
01104 int b = 2;
01105 dummy1.Fill( a, b, i+1+68 );
01106 }
01107 dummy1.SetMarkerSize(2);
01108 dummy1.SetMinimum(0.1);
01109
01110 string imgNameQual[3], imgNameAmp[3], imgNameShape[3], imgNameMEPnQual[2], imgNameMEPn[2], imgNameMEPnPed[2], imgNameMEPnPedRms[2], imgName, meName;
01111
01112 TCanvas* cQual = new TCanvas("cQual", "Temp", 3*csize, csize);
01113 TCanvas* cAmp = new TCanvas("cAmp", "Temp", csize, csize);
01114 TCanvas* cShape = new TCanvas("cShape", "Temp", csize, csize);
01115 TCanvas* cPed = new TCanvas("cPed", "Temp", csize, csize);
01116
01117 TH2F* obj2f;
01118 TH1F* obj1f;
01119 TProfile* objp;
01120
01121
01122
01123 for ( unsigned int i=0; i<superModules_.size(); i ++ ) {
01124
01125 int ism = superModules_[i];
01126
01127
01128
01129 for ( int iCanvas = 1 ; iCanvas <= 3 ; iCanvas++ ) {
01130
01131
01132
01133 imgNameQual[iCanvas-1] = "";
01134
01135 obj2f = 0;
01136 switch ( iCanvas ) {
01137 case 1:
01138 obj2f = UtilsClient::getHisto<TH2F*>( meg01_[ism-1] );
01139 break;
01140 case 2:
01141 obj2f = UtilsClient::getHisto<TH2F*>( meg02_[ism-1] );
01142 break;
01143 case 3:
01144 obj2f = UtilsClient::getHisto<TH2F*>( meg03_[ism-1] );
01145 break;
01146 default:
01147 break;
01148 }
01149
01150 if ( obj2f ) {
01151
01152 meName = obj2f->GetName();
01153
01154 replace(meName.begin(), meName.end(), ' ', '_');
01155 imgNameQual[iCanvas-1] = meName + ".png";
01156 imgName = htmlDir + imgNameQual[iCanvas-1];
01157
01158 cQual->cd();
01159 gStyle->SetOptStat(" ");
01160 gStyle->SetPalette(7, pCol3);
01161 obj2f->GetXaxis()->SetNdivisions(17);
01162 obj2f->GetYaxis()->SetNdivisions(4);
01163 cQual->SetGridx();
01164 cQual->SetGridy();
01165 obj2f->SetMinimum(-0.00000001);
01166 obj2f->SetMaximum(7.0);
01167 obj2f->Draw("col");
01168 dummy.Draw("text,same");
01169 cQual->Update();
01170 cQual->SaveAs(imgName.c_str());
01171
01172 }
01173
01174
01175
01176 imgNameAmp[iCanvas-1] = "";
01177
01178 obj1f = 0;
01179 switch ( iCanvas ) {
01180 case 1:
01181 obj1f = UtilsClient::getHisto<TH1F*>( mea01_[ism-1] );
01182 break;
01183 case 2:
01184 obj1f = UtilsClient::getHisto<TH1F*>( mea02_[ism-1] );
01185 break;
01186 case 3:
01187 obj1f = UtilsClient::getHisto<TH1F*>( mea03_[ism-1] );
01188 break;
01189 default:
01190 break;
01191 }
01192
01193 if ( obj1f ) {
01194
01195 meName = obj1f->GetName();
01196
01197 replace(meName.begin(), meName.end(), ' ', '_');
01198 imgNameAmp[iCanvas-1] = meName + ".png";
01199 imgName = htmlDir + imgNameAmp[iCanvas-1];
01200
01201 cAmp->cd();
01202 gStyle->SetOptStat("euo");
01203 obj1f->SetStats(kTRUE);
01204
01205
01206
01207
01208
01209 obj1f->SetMinimum(0.0);
01210 obj1f->Draw();
01211 cAmp->Update();
01212 gPad->SetLogy(kFALSE);
01213 cAmp->SaveAs(imgName.c_str());
01214 gPad->SetLogy(kFALSE);
01215
01216 }
01217
01218
01219
01220 imgNameShape[iCanvas-1] = "";
01221
01222 obj1f = 0;
01223 switch ( iCanvas ) {
01224 case 1:
01225 obj1f = UtilsClient::getHisto<TH1F*>( me_hs01_[ism-1] );
01226 break;
01227 case 2:
01228 obj1f = UtilsClient::getHisto<TH1F*>( me_hs02_[ism-1] );
01229 break;
01230 case 3:
01231 obj1f = UtilsClient::getHisto<TH1F*>( me_hs03_[ism-1] );
01232 break;
01233 default:
01234 break;
01235 }
01236
01237 if ( obj1f ) {
01238
01239 meName = obj1f->GetName();
01240
01241 replace(meName.begin(), meName.end(), ' ', '_');
01242 imgNameShape[iCanvas-1] = meName + ".png";
01243 imgName = htmlDir + imgNameShape[iCanvas-1];
01244
01245 cShape->cd();
01246 gStyle->SetOptStat("euo");
01247 obj1f->SetStats(kTRUE);
01248
01249
01250
01251
01252
01253 obj1f->Draw();
01254 cShape->Update();
01255 cShape->SaveAs(imgName.c_str());
01256 gPad->SetLogy(kFALSE);
01257
01258 }
01259
01260 }
01261
01262
01263
01264 for ( int iCanvas = 1 ; iCanvas <= 2 ; iCanvas++ ) {
01265
01266
01267
01268 imgNameMEPnQual[iCanvas-1] = "";
01269
01270 obj2f = 0;
01271 switch ( iCanvas ) {
01272 case 1:
01273 obj2f = UtilsClient::getHisto<TH2F*>( meg04_[ism-1] );
01274 break;
01275 case 2:
01276 obj2f = UtilsClient::getHisto<TH2F*>( meg05_[ism-1] );
01277 break;
01278 default:
01279 break;
01280 }
01281
01282 if ( obj2f ) {
01283
01284 meName = obj2f->GetName();
01285
01286 replace(meName.begin(), meName.end(), ' ', '_');
01287 imgNameMEPnQual[iCanvas-1] = meName + ".png";
01288 imgName = htmlDir + imgNameMEPnQual[iCanvas-1];
01289
01290 cQual->cd();
01291 gStyle->SetOptStat(" ");
01292 gStyle->SetPalette(7, pCol3);
01293 obj2f->GetXaxis()->SetNdivisions(10);
01294 obj2f->GetYaxis()->SetNdivisions(5);
01295 cQual->SetGridx();
01296 cQual->SetGridy(0);
01297 obj2f->SetMinimum(-0.00000001);
01298 obj2f->SetMaximum(7.0);
01299 obj2f->Draw("col");
01300 dummy1.Draw("text,same");
01301 cQual->Update();
01302 cQual->SaveAs(imgName.c_str());
01303
01304 }
01305
01306 imgNameMEPn[iCanvas-1] = "";
01307
01308 objp = 0;
01309 switch ( iCanvas ) {
01310 case 1:
01311 objp = i01_[ism-1];
01312 break;
01313 case 2:
01314 objp = i02_[ism-1];
01315 break;
01316 default:
01317 break;
01318 }
01319
01320 if ( objp ) {
01321
01322 meName = objp->GetName();
01323
01324 replace(meName.begin(), meName.end(), ' ', '_');
01325 imgNameMEPn[iCanvas-1] = meName + ".png";
01326 imgName = htmlDir + imgNameMEPn[iCanvas-1];
01327
01328 cAmp->cd();
01329 gStyle->SetOptStat("euo");
01330 objp->SetStats(kTRUE);
01331
01332
01333
01334
01335
01336 objp->SetMinimum(0.0);
01337 objp->Draw();
01338 cAmp->Update();
01339 cAmp->SaveAs(imgName.c_str());
01340 gPad->SetLogy(kFALSE);
01341
01342 }
01343
01344
01345
01346 imgNameMEPnPed[iCanvas-1] = "";
01347
01348 objp = 0;
01349 switch ( iCanvas ) {
01350 case 1:
01351 objp = i03_[ism-1];
01352 break;
01353 case 2:
01354 objp = i04_[ism-1];
01355 break;
01356 default:
01357 break;
01358 }
01359
01360 if ( objp ) {
01361
01362 meName = objp->GetName();
01363
01364 replace(meName.begin(), meName.end(), ' ', '_');
01365 imgNameMEPnPed[iCanvas-1] = meName + ".png";
01366 imgName = htmlDir + imgNameMEPnPed[iCanvas-1];
01367
01368 cPed->cd();
01369 gStyle->SetOptStat("euo");
01370 objp->SetStats(kTRUE);
01371
01372
01373
01374
01375
01376 objp->SetMinimum(0.0);
01377 objp->Draw();
01378 cPed->Update();
01379 cPed->SaveAs(imgName.c_str());
01380 gPad->SetLogy(kFALSE);
01381
01382 }
01383
01384 imgNameMEPnPedRms[iCanvas-1] = "";
01385
01386 obj1f = 0;
01387 switch ( iCanvas ) {
01388 case 1:
01389 if ( mer04_[ism-1] ) obj1f = UtilsClient::getHisto<TH1F*>(mer04_[ism-1]);
01390 break;
01391 case 2:
01392 if ( mer05_[ism-1] ) obj1f = UtilsClient::getHisto<TH1F*>(mer05_[ism-1]);
01393 break;
01394 default:
01395 break;
01396 }
01397
01398 if ( obj1f ) {
01399
01400 meName = obj1f->GetName();
01401
01402 replace(meName.begin(), meName.end(), ' ', '_');
01403 imgNameMEPnPedRms[iCanvas-1] = meName + ".png";
01404 imgName = htmlDir + imgNameMEPnPedRms[iCanvas-1];
01405
01406 cPed->cd();
01407 gStyle->SetOptStat("euo");
01408 obj1f->SetStats(kTRUE);
01409
01410
01411
01412
01413
01414 obj1f->SetMinimum(0.0);
01415 obj1f->Draw();
01416 cPed->Update();
01417 cPed->SaveAs(imgName.c_str());
01418 gPad->SetLogy(kFALSE);
01419
01420 }
01421
01422 }
01423
01424 if( i>0 ) htmlFile << "<a href=""#top"">Top</a>" << std::endl;
01425 htmlFile << "<hr>" << std::endl;
01426 htmlFile << "<h3><a name="""
01427 << Numbers::sEB(ism) << """></a><strong>"
01428 << Numbers::sEB(ism) << "</strong></h3>" << endl;
01429 htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
01430 htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01431 htmlFile << "<tr align=\"center\">" << endl;
01432
01433 for ( int iCanvas = 1 ; iCanvas <= 3 ; iCanvas++ ) {
01434
01435 if ( imgNameQual[iCanvas-1].size() != 0 )
01436 htmlFile << "<td colspan=\"2\"><img src=\"" << imgNameQual[iCanvas-1] << "\"></td>" << endl;
01437 else
01438 htmlFile << "<td colspan=\"2\"><img src=\"" << " " << "\"></td>" << endl;
01439
01440 }
01441
01442 htmlFile << "</tr>" << endl;
01443 htmlFile << "<tr>" << endl;
01444
01445 for ( int iCanvas = 1 ; iCanvas <= 3 ; iCanvas++ ) {
01446
01447 if ( imgNameAmp[iCanvas-1].size() != 0 )
01448 htmlFile << "<td><img src=\"" << imgNameAmp[iCanvas-1] << "\"></td>" << endl;
01449 else
01450 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01451
01452 if ( imgNameShape[iCanvas-1].size() != 0 )
01453 htmlFile << "<td><img src=\"" << imgNameShape[iCanvas-1] << "\"></td>" << endl;
01454 else
01455 htmlFile << "<td><img src=\"" << " " << "\"></td>" << endl;
01456
01457 }
01458
01459 htmlFile << "</tr>" << endl;
01460
01461 htmlFile << "<tr align=\"center\"><td colspan=\"2\">Gain 1</td><td colspan=\"2\">Gain 6</td><td colspan=\"2\">Gain 12</td></tr>" << endl;
01462 htmlFile << "</table>" << endl;
01463 htmlFile << "<br>" << endl;
01464
01465 htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
01466 htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01467 htmlFile << "<tr align=\"center\">" << endl;
01468
01469 for ( int iCanvas = 1 ; iCanvas <= 2 ; iCanvas++ ) {
01470
01471 if ( imgNameMEPnQual[iCanvas-1].size() != 0 )
01472 htmlFile << "<td colspan=\"2\"><img src=\"" << imgNameMEPnQual[iCanvas-1] << "\"></td>" << endl;
01473 else
01474 htmlFile << "<td colspan=\"2\"><img src=\"" << " " << "\"></td>" << endl;
01475
01476 }
01477
01478 htmlFile << "</tr>" << endl;
01479 htmlFile << "</table>" << endl;
01480 htmlFile << "<br>" << endl;
01481
01482 htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
01483 htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01484 htmlFile << "<tr align=\"center\">" << endl;
01485
01486 for ( int iCanvas = 1 ; iCanvas <= 2 ; iCanvas++ ) {
01487
01488 if ( imgNameMEPnPed[iCanvas-1].size() != 0 )
01489 htmlFile << "<td colspan=\"2\"><img src=\"" << imgNameMEPnPed[iCanvas-1] << "\"></td>" << endl;
01490
01491 else
01492 htmlFile << "<td colspan=\"2\"><img src=\"" << " " << "\"></td>" << endl;
01493
01494 if ( imgNameMEPnPedRms[iCanvas-1].size() != 0 )
01495 htmlFile << "<td colspan=\"2\"><img src=\"" << imgNameMEPnPedRms[iCanvas-1] << "\"></td>" << endl;
01496 else
01497 htmlFile << "<td colspan=\"2\"><img src=\"" << " " << "\"></td>" << endl;
01498
01499 if ( imgNameMEPn[iCanvas-1].size() != 0 )
01500 htmlFile << "<td colspan=\"2\"><img src=\"" << imgNameMEPn[iCanvas-1] << "\"></td>" << endl;
01501 else
01502 htmlFile << "<td colspan=\"2\"><img src=\"" << " " << "\"></td>" << endl;
01503
01504 }
01505
01506 htmlFile << "</tr>" << endl;
01507
01508 htmlFile << "<tr align=\"center\"> <td colspan=\"2\"> </td> <td colspan=\"2\">Gain 1</td> <td colspan=\"2\"> </td> <td colspan=\"2\"> </td> <td colspan=\"2\">Gain 16</td></tr>" << endl;
01509 htmlFile << "</table>" << endl;
01510 htmlFile << "<br>" << endl;
01511
01512 }
01513
01514 delete cQual;
01515 delete cAmp;
01516 delete cShape;
01517 delete cPed;
01518
01519
01520 htmlFile << "</body> " << endl;
01521 htmlFile << "</html> " << endl;
01522
01523 htmlFile.close();
01524
01525 }
01526