00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include <algorithm>
00012
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017
00018 #include "DQMServices/Core/interface/MonitorElement.h"
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020
00021 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00022
00023 #include "DQM/EcalCommon/interface/Numbers.h"
00024 #include "DQM/EcalCommon/interface/UtilsClient.h"
00025
00026 #include "DQM/EcalBarrelMonitorTasks/interface/EBDataCertificationTask.h"
00027
00028 EBDataCertificationTask::EBDataCertificationTask(const edm::ParameterSet& ps) {
00029
00030 dqmStore_ = edm::Service<DQMStore>().operator->();
00031
00032
00033 cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00034
00035 prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00036
00037 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00038
00039 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00040
00041 meEBDataCertificationSummary_ = 0;
00042 meEBDataCertificationSummaryMap_ = 0;
00043 for (int i = 0; i < 36; i++) {
00044 meEBDataCertification_[i] = 0;
00045 }
00046
00047 hDQM_ = 0;
00048 hDAQ_ = 0;
00049 hDCS_ = 0;
00050 hIntegrityByLumi_ = 0;
00051 hFrontendByLumi_ = 0;
00052 hSynchronizationByLumi_ = 0;
00053
00054 }
00055
00056 EBDataCertificationTask::~EBDataCertificationTask() {
00057
00058 }
00059
00060 void EBDataCertificationTask::beginJob(void){
00061
00062 std::string name;
00063
00064 if ( dqmStore_ ) {
00065
00066 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
00067
00068 name = "CertificationSummary";
00069 meEBDataCertificationSummary_ = dqmStore_->bookFloat(name);
00070 meEBDataCertificationSummary_->Fill(-1.0);
00071
00072 name = "CertificationSummaryMap";
00073 meEBDataCertificationSummaryMap_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, 0., 34.);
00074 meEBDataCertificationSummaryMap_->setAxisTitle("jphi", 1);
00075 meEBDataCertificationSummaryMap_->setAxisTitle("jeta", 2);
00076
00077 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
00078
00079 for (int i = 0; i < 36; i++) {
00080 name = "EcalBarrel_" + Numbers::sEB(i+1);
00081 meEBDataCertification_[i] = dqmStore_->bookFloat(name);
00082 meEBDataCertification_[i]->Fill(-1.0);
00083 }
00084
00085 }
00086
00087 }
00088
00089 void EBDataCertificationTask::endJob(void) {
00090
00091 if ( enableCleanup_ ) this->cleanup();
00092
00093 }
00094
00095 void EBDataCertificationTask::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup){
00096
00097 }
00098
00099 void EBDataCertificationTask::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup) {
00100
00101 this->reset();
00102
00103 MonitorElement* me;
00104
00105
00106 float DQMVal[36];
00107 for (int i = 0; i < 36; i++) {
00108 DQMVal[i] = -1.;
00109 }
00110
00111 me = dqmStore_->get(prefixME_ + "/EBIntegrityTask/EBIT weighted integrity errors by lumi");
00112 hIntegrityByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hIntegrityByLumi_ );
00113
00114 me = dqmStore_->get(prefixME_ + "/EBStatusFlagsTask/FEStatus/EBSFT weighted frontend errors by lumi");
00115 hFrontendByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hFrontendByLumi_ );
00116
00117 me = dqmStore_->get(prefixME_ + "/EBRawDataTask/EBRDT FE synchronization errors by lumi");
00118 hSynchronizationByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hSynchronizationByLumi_ );
00119
00120 if( hIntegrityByLumi_ && hFrontendByLumi_ && hSynchronizationByLumi_ ) {
00121
00122 float integrityErrSum = 0.;
00123 float integrityQual = 1.0;
00124 float frontendErrSum = 0.;
00125 float frontendQual = 1.0;
00126 float synchronizationErrSum = 0.;
00127 float synchronizationQual = 1.0;
00128
00129 for ( int i=0; i<36; i++) {
00130 float ismIntegrityQual = 1.0;
00131 if( hIntegrityByLumi_->GetBinContent(0) > 0 ) {
00132 float errors = hIntegrityByLumi_->GetBinContent(i+1);
00133 ismIntegrityQual = 1.0 - errors/hIntegrityByLumi_->GetBinContent(0);
00134 integrityErrSum += errors;
00135 }
00136 float ismFrontendQual = 1.0;
00137 if( hFrontendByLumi_->GetBinContent(0) > 0 ) {
00138 float errors = hFrontendByLumi_->GetBinContent(i+1);
00139 ismFrontendQual = 1.0 - errors/hFrontendByLumi_->GetBinContent(0);
00140 frontendErrSum += errors;
00141 }
00142 float ismSynchronizationQual = 1.0;
00143 if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) {
00144 float errors = hSynchronizationByLumi_->GetBinContent(i+1);
00145 ismSynchronizationQual = 1.0 - errors/hSynchronizationByLumi_->GetBinContent(0);
00146 synchronizationErrSum += errors;
00147 }
00148 float minVal= std::min(ismIntegrityQual,ismFrontendQual);
00149 DQMVal[i] = std::min(minVal,ismSynchronizationQual);
00150 }
00151
00152 if( hIntegrityByLumi_->GetBinContent(0) > 0 ) integrityQual = 1.0 - integrityErrSum/hIntegrityByLumi_->GetBinContent(0)/36.;
00153 if( hFrontendByLumi_->GetBinContent(0) > 0 ) frontendQual = 1.0 - frontendErrSum/hFrontendByLumi_->GetBinContent(0)/36.;
00154 if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) synchronizationQual = 1.0 - synchronizationErrSum/hSynchronizationByLumi_->GetBinContent(0)/36.;
00155 float minVal = std::min(integrityQual,frontendQual);
00156 float totDQMVal = std::min(minVal,synchronizationQual);
00157
00158 me = dqmStore_->get((prefixME_ + "/EventInfo/reportSummary"));
00159 if( me ) me->Fill(totDQMVal);
00160 for ( int i=0; i<36; i++) {
00161 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/EcalBarrel_" + Numbers::sEB(i+1) ) ;
00162 if( me ) me->Fill(DQMVal[i]);
00163
00164 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
00165 if( me ) {
00166 for ( int iett = 0; iett < 34; iett++ ) {
00167 for ( int iptt = 0; iptt < 72; iptt++ ) {
00168 int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
00169 if( i == (ism-1) ) me->setBinContent(iptt+1, iett+1, DQMVal[ism-1]);
00170 }
00171 }
00172 }
00173 }
00174
00175 }
00176
00177
00178 me = dqmStore_->get(prefixME_ + "/EventInfo/DAQSummaryMap");
00179 hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
00180
00181 me = dqmStore_->get(prefixME_ + "/EventInfo/DCSSummaryMap");
00182 hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
00183
00184 float sumCert = 0.;
00185 float sumCertEB[36];
00186 int nValidChannels = 0;
00187 int nValidChannelsEB[36];
00188
00189 for (int i = 0; i < 36; i++) {
00190 sumCertEB[i] = 0.;
00191 nValidChannelsEB[i] = 0;
00192 }
00193
00194 for ( int iett = 0; iett < 34; iett++ ) {
00195 for ( int iptt = 0; iptt < 72; iptt++ ) {
00196
00197 int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
00198
00199 float xvalDQM = DQMVal[ism-1];
00200
00201 float xvalDAQ, xvalDCS;
00202 xvalDAQ = xvalDCS = -1.;
00203 float xcert = -1.;
00204
00205 if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( iptt+1, iett+1 );
00206 if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( iptt+1, iett+1 );
00207
00208 if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
00209
00210 xcert = 0.0;
00211 } else {
00212
00213 xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
00214 }
00215
00216 if ( meEBDataCertificationSummaryMap_ ) meEBDataCertificationSummaryMap_->setBinContent( iptt+1, iett+1, xcert );
00217
00218 sumCertEB[ism-1] += xcert;
00219 nValidChannelsEB[ism-1]++;
00220
00221 sumCert += xcert;
00222 nValidChannels++;
00223
00224 }
00225 }
00226
00227 if( meEBDataCertificationSummary_ ) {
00228 if( nValidChannels>0 ) meEBDataCertificationSummary_->Fill( sumCert/nValidChannels );
00229 else meEBDataCertificationSummary_->Fill( 0.0 );
00230 }
00231
00232 for (int i = 0; i < 36; i++) {
00233 if( meEBDataCertification_[i] ) {
00234 if( nValidChannelsEB[i]>0 ) meEBDataCertification_[i]->Fill( sumCertEB[i]/nValidChannelsEB[i] );
00235 else meEBDataCertification_[i]->Fill( 0.0 );
00236 }
00237 }
00238
00239 }
00240
00241 void EBDataCertificationTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00242
00243 if ( ! mergeRuns_ ) this->reset();
00244
00245 }
00246
00247 void EBDataCertificationTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00248
00249 this->reset();
00250
00251 MonitorElement* me;
00252
00253 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
00254 hDQM_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDQM_ );
00255
00256 me = dqmStore_->get(prefixME_ + "/EventInfo/DAQSummaryMap");
00257 hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );
00258
00259 me = dqmStore_->get(prefixME_ + "/EventInfo/DCSSummaryMap");
00260 hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );
00261
00262 float sumCert = 0.;
00263 float sumCertEB[36];
00264 int nValidChannels = 0;
00265 int nValidChannelsEB[36];
00266
00267 for (int i = 0; i < 36; i++) {
00268 sumCertEB[i] = 0.;
00269 nValidChannelsEB[i] = 0;
00270 }
00271
00272 for ( int iett = 0; iett < 34; iett++ ) {
00273 for ( int iptt = 0; iptt < 72; iptt++ ) {
00274
00275 float xvalDQM, xvalDAQ, xvalDCS;
00276 xvalDQM = xvalDAQ = xvalDCS = -1.;
00277 float xcert = -1;
00278
00279 if ( hDQM_ ) xvalDQM = hDQM_->GetBinContent( iptt+1, iett+1 );
00280 if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( iptt+1, iett+1 );
00281 if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( iptt+1, iett+1 );
00282
00283 if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
00284
00285 xcert = 0.0;
00286 } else {
00287
00288 xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
00289 }
00290
00291 if ( meEBDataCertificationSummaryMap_ ) meEBDataCertificationSummaryMap_->setBinContent( iptt+1, iett+1, xcert );
00292
00293 int ism = ( iett<17 ) ? iptt/4+1 : 18+iptt/4+1;
00294
00295 sumCertEB[ism-1] += xcert;
00296 nValidChannelsEB[ism-1]++;
00297
00298 sumCert += xcert;
00299 nValidChannels++;
00300
00301 }
00302 }
00303
00304 if( meEBDataCertificationSummary_ ) {
00305 if( nValidChannels>0 ) {
00306 meEBDataCertificationSummary_->Fill( sumCert/nValidChannels );
00307 } else {
00308 meEBDataCertificationSummary_->Fill( 0.0 );
00309 }
00310 }
00311
00312 for (int i = 0; i < 36; i++) {
00313 if( meEBDataCertification_[i] ) {
00314 if( nValidChannelsEB[i]>0 ) {
00315 meEBDataCertification_[i]->Fill( sumCertEB[i]/nValidChannelsEB[i] );
00316 } else {
00317 meEBDataCertification_[i]->Fill( 0.0 );
00318 }
00319 }
00320 }
00321
00322 }
00323
00324 void EBDataCertificationTask::reset(void) {
00325
00326 if ( meEBDataCertificationSummary_ ) meEBDataCertificationSummary_->Reset();
00327
00328 for (int i = 0; i < 36; i++) {
00329 if ( meEBDataCertification_[i] ) meEBDataCertification_[i]->Reset();
00330 }
00331
00332 if ( meEBDataCertificationSummaryMap_ ) meEBDataCertificationSummaryMap_->Reset();
00333
00334 }
00335
00336
00337 void EBDataCertificationTask::cleanup(void){
00338
00339 if ( cloneME_ ) {
00340 if( hDQM_ ) delete hDQM_;
00341 if( hDAQ_ ) delete hDAQ_;
00342 if( hDCS_ ) delete hDCS_;
00343 if( hIntegrityByLumi_ ) delete hIntegrityByLumi_;
00344 if( hFrontendByLumi_ ) delete hFrontendByLumi_;
00345 if( hSynchronizationByLumi_ ) delete hSynchronizationByLumi_;
00346 }
00347 hDQM_ = 0;
00348 hDAQ_ = 0;
00349 hDCS_ = 0;
00350 hIntegrityByLumi_ = 0;
00351 hFrontendByLumi_ = 0;
00352 hSynchronizationByLumi_ = 0;
00353
00354 if ( dqmStore_ ) {
00355 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
00356 if ( meEBDataCertificationSummary_ ) dqmStore_->removeElement( meEBDataCertificationSummary_->getName() );
00357 if ( meEBDataCertificationSummaryMap_ ) dqmStore_->removeElement( meEBDataCertificationSummaryMap_->getName() );
00358
00359 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/CertificationContents");
00360 for (int i = 0; i < 36; i++) {
00361 if ( meEBDataCertification_[i] ) dqmStore_->removeElement( meEBDataCertification_[i]->getName() );
00362 }
00363 }
00364
00365 }
00366
00367 void EBDataCertificationTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00368
00369 }