CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Static Protected Attributes | Private Attributes

EEDataCertificationTask Class Reference

#include <EEDataCertificationTask.h>

Inheritance diagram for EEDataCertificationTask:
edm::EDAnalyzer

List of all members.

Public Member Functions

 EEDataCertificationTask (const edm::ParameterSet &ps)
 Constructor.
virtual ~EEDataCertificationTask ()
 Destructor.

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze.
void beginJob (void)
 BeginJob.
void beginLuminosityBlock (const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
 BeginLuminosityBlock.
void beginRun (const edm::Run &r, const edm::EventSetup &c)
 BeginRun.
void cleanup (void)
 Cleanup.
void endJob (void)
 EndJob.
void endLuminosityBlock (const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup)
 EndLuminosityBlock.
void endRun (const edm::Run &r, const edm::EventSetup &c)
 EndRun.
void reset (void)
 Reset.

Static Protected Attributes

static const int DccId_ [18]
static const int nTowerMax_ = 44

Private Attributes

bool cloneME_
DQMStoredqmStore_
bool enableCleanup_
TH2F * hDAQ_
TH2F * hDCS_
TH2F * hDQM_
TH1F * hFrontendByLumi_
TH1F * hIntegrityByLumi_
TH1F * hSynchronizationByLumi_
MonitorElementmeEEDataCertification_ [18]
MonitorElementmeEEDataCertificationSummary_
MonitorElementmeEEDataCertificationSummaryMap_
MonitorElementmeEEReportSummary_
MonitorElementmeEEReportSummaryContents_ [36]
bool mergeRuns_
std::string prefixME_

Detailed Description

Definition at line 19 of file EEDataCertificationTask.h.


Constructor & Destructor Documentation

EEDataCertificationTask::EEDataCertificationTask ( const edm::ParameterSet ps)
EEDataCertificationTask::~EEDataCertificationTask ( ) [virtual]

Destructor.

Definition at line 58 of file EEDataCertificationTask.cc.

                                                  {

}

Member Function Documentation

void EEDataCertificationTask::analyze ( const edm::Event e,
const edm::EventSetup c 
) [protected, virtual]

Analyze.

Implements edm::EDAnalyzer.

Definition at line 418 of file EEDataCertificationTask.cc.

                                                                              {

}
void EEDataCertificationTask::beginJob ( void  ) [protected, virtual]
void EEDataCertificationTask::beginLuminosityBlock ( const edm::LuminosityBlock lumiBlock,
const edm::EventSetup iSetup 
) [protected, virtual]

BeginLuminosityBlock.

Reimplemented from edm::EDAnalyzer.

Definition at line 95 of file EEDataCertificationTask.cc.

                                                                                                                   {

}
void EEDataCertificationTask::beginRun ( const edm::Run r,
const edm::EventSetup c 
) [protected, virtual]

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 269 of file EEDataCertificationTask.cc.

References mergeRuns_, and reset().

                                                                              {

  if ( ! mergeRuns_ ) this->reset();

}
void EEDataCertificationTask::cleanup ( void  ) [protected]
void EEDataCertificationTask::endJob ( void  ) [protected, virtual]

EndJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 89 of file EEDataCertificationTask.cc.

References cleanup(), and enableCleanup_.

                                         {

  if ( enableCleanup_ ) this->cleanup();

}
void EEDataCertificationTask::endLuminosityBlock ( const edm::LuminosityBlock lumiBlock,
const edm::EventSetup iSetup 
) [protected, virtual]

EndLuminosityBlock.

Reimplemented from edm::EDAnalyzer.

Definition at line 99 of file EEDataCertificationTask.cc.

References abs, cloneME_, DccId_, EcalElectronicsMapping::dccTowerConstituents(), dqmStore_, benchmark_cfg::errors, MonitorElement::Fill(), edm::EventSetup::get(), DQMStore::get(), EcalElectronicsMapping::getEcalScDetId(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), patZpeak::handle, hDAQ_, hDCS_, hFrontendByLumi_, hIntegrityByLumi_, hSynchronizationByLumi_, i, errorMatrix2Lands_multiChannel::id, Association::map, meEEDataCertification_, meEEDataCertificationSummary_, meEEDataCertificationSummaryMap_, min, nTowerMax_, prefixME_, edm::ESHandle< T >::product(), reset(), Numbers::sEE(), MonitorElement::setBinContent(), and lumiQTWidget::t.

                                                                                                                   {

  this->reset();

  MonitorElement* me;

  // evaluate the DQM quality of observables checked by lumi
  float DQMVal[18];
  for (int i = 0; i < 18; i++) {
    DQMVal[i] = -1.;
  }

  edm::ESHandle< EcalElectronicsMapping > handle;
  iSetup.get< EcalMappingRcd >().get(handle);
  const EcalElectronicsMapping *map = handle.product();
  if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";

  me = dqmStore_->get( prefixME_ + "/EEIntegrityTask/EEIT weighted integrity errors by lumi" );
  hIntegrityByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hIntegrityByLumi_ );

  me = dqmStore_->get( prefixME_ + "/EEStatusFlagsTask/FEStatus/EESFT weighted frontend errors by lumi" );
  hFrontendByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hFrontendByLumi_ );

  me = dqmStore_->get( prefixME_ + "/EERawDataTask/EERDT FE synchronization errors by lumi" );
  hSynchronizationByLumi_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, hSynchronizationByLumi_ );

  if( hIntegrityByLumi_ && hFrontendByLumi_ && hSynchronizationByLumi_ && map) {

    float integrityErrSum = 0.;
    float integrityQual = 1.0;
    float frontendErrSum = 0.;
    float frontendQual = 1.0;
    float synchronizationErrSum = 0.;
    float synchronizationQual = 1.0;

    for ( int i=0; i<18; i++) {
      float ismIntegrityQual = 1.0;
      if( hIntegrityByLumi_->GetBinContent(0) > 0 ) {
        float errors = hIntegrityByLumi_->GetBinContent(i+1);
        ismIntegrityQual = 1.0 - errors/hIntegrityByLumi_->GetBinContent(0);
        integrityErrSum += errors;
      }
      float ismFrontendQual = 1.0;
      if( hFrontendByLumi_->GetBinContent(0) > 0 ) {
        float errors = hFrontendByLumi_->GetBinContent(i+1);
        ismFrontendQual = 1.0 - errors/hFrontendByLumi_->GetBinContent(0);
        frontendErrSum += errors;
      }
      float ismSynchronizationQual = 1.0;
      if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) {
        float errors = hSynchronizationByLumi_->GetBinContent(i+1);
        ismSynchronizationQual = 1.0 - errors/hSynchronizationByLumi_->GetBinContent(0);
        synchronizationErrSum += errors;
      }
      float minVal= std::min(ismIntegrityQual,ismFrontendQual);
      DQMVal[i] = std::min(minVal,ismSynchronizationQual);
    }

    if( hIntegrityByLumi_->GetBinContent(0) > 0 ) integrityQual = 1.0 - integrityErrSum/hIntegrityByLumi_->GetBinContent(0)/18.;
    if( hFrontendByLumi_->GetBinContent(0) > 0 ) frontendQual = 1.0 - frontendErrSum/hFrontendByLumi_->GetBinContent(0)/18.;
    if( hSynchronizationByLumi_->GetBinContent(0) > 0 ) synchronizationQual = 1.0 - synchronizationErrSum/hSynchronizationByLumi_->GetBinContent(0)/36.;
    float minVal = std::min(integrityQual,frontendQual);
    float totDQMVal = std::min(minVal,synchronizationQual);

    me = dqmStore_->get( prefixME_ + "/EventInfo/reportSummary" );
    if( me ) me->Fill(totDQMVal);

    for ( int i=0; i<18; i++) {
      me = dqmStore_->get( prefixME_ + "/EventInfo/reportSummaryContents/EcalEndcap_" + Numbers::sEE(i+1) );
      if( me ) me->Fill(DQMVal[i]);

      me = dqmStore_->get( prefixME_ + "/EventInfo/reportSummaryMap" );
      if( me ) {
        for(int t=1 ; t<=nTowerMax_ ; t++){
          if(! map->dccTowerConstituents(DccId_[i], t).size() ) continue;
          std::vector<EcalScDetId> scs = map->getEcalScDetId(DccId_[i], t, false);
          for(unsigned u=0 ; u<scs.size() ; u++){
            int jx = scs[u].ix() + (scs[u].zside()<0 ? 0 : 20);
            int jy = scs[u].iy();
            me->setBinContent(jx,jy, DQMVal[i]);
          }
        }
      }
    }

  }

  // now combine reduced DQM with DCS and DAQ
  me = dqmStore_->get( prefixME_ + "/EventInfo/DAQSummaryMap" );
  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );

  me = dqmStore_->get( prefixME_ + "/EventInfo/DCSSummaryMap" );
  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );

  float sumCert = 0.;
  float sumCertEE[18];
  int nValidChannels = 0;
  int nValidChannelsEE[18];

  if ( meEEDataCertificationSummaryMap_ ){
    for(int ix=1 ; ix<=meEEDataCertificationSummaryMap_->getNbinsX() ; ix++){
      for(int iy=1 ; iy<=meEEDataCertificationSummaryMap_->getNbinsY() ; iy++){
        meEEDataCertificationSummaryMap_->setBinContent( ix, iy, -1.0 );
      }
    }
  }

  for (int i = 0; i < 18; i++) {
    sumCertEE[i] = 0;
    nValidChannelsEE[i] = 0;

    for(int t=1 ; t<=nTowerMax_ ; t++){

      std::vector<DetId> crystals = map->dccTowerConstituents(DccId_[i], t);
      if(!crystals.size()) continue; // getEcalScDetId throws an exception when no crystal is found

      std::vector<EcalScDetId> scs = map->getEcalScDetId(DccId_[i], t, false);
      for(unsigned u=0 ; u<scs.size() ; u++){

        int jx = scs[u].ix() + (scs[u].zside()<0 ? 0 : 20);
        int jy = scs[u].iy();

        float xvalDQM = DQMVal[i];

        float xvalDAQ, xvalDCS;
        xvalDAQ = xvalDCS = -1.;
        float xcert = -1.;

        if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( jx, jy );
        if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( jx, jy );

        if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
          // problems: DQM empty or DAQ and DCS not available
          xcert = 0.0;
        } else {
          // do not consider the white value of DAQ and DCS (problems with DB)
          xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
        }

        if ( meEEDataCertificationSummaryMap_ ) meEEDataCertificationSummaryMap_->setBinContent( jx, jy, xcert );

        int ncrystals = 0;

        for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
          EEDetId id(*it);
          if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
        }

        sumCertEE[i] += xcert * ncrystals;
        nValidChannelsEE[i] += ncrystals;

        sumCert += xcert * ncrystals;
        nValidChannels += ncrystals;

      }
    }

    if( meEEDataCertification_[i] ) {
      if( nValidChannelsEE[i]>0 ) meEEDataCertification_[i]->Fill( sumCertEE[i]/nValidChannelsEE[i] );
      else meEEDataCertification_[i]->Fill( 0.0 );
    }
  }

  if( meEEDataCertificationSummary_ ) {
    if( nValidChannels>0 ) meEEDataCertificationSummary_->Fill( sumCert/nValidChannels );
    else meEEDataCertificationSummary_->Fill( 0.0 );
  }

}
void EEDataCertificationTask::endRun ( const edm::Run r,
const edm::EventSetup c 
) [protected, virtual]

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 275 of file EEDataCertificationTask.cc.

References abs, cloneME_, DccId_, EcalElectronicsMapping::dccTowerConstituents(), dqmStore_, MonitorElement::Fill(), edm::EventSetup::get(), DQMStore::get(), EcalElectronicsMapping::getEcalScDetId(), MonitorElement::getNbinsX(), MonitorElement::getNbinsY(), patZpeak::handle, hDAQ_, hDCS_, hDQM_, i, errorMatrix2Lands_multiChannel::id, Association::map, meEEDataCertification_, meEEDataCertificationSummary_, meEEDataCertificationSummaryMap_, nTowerMax_, prefixME_, edm::ESHandle< T >::product(), reset(), MonitorElement::setBinContent(), and lumiQTWidget::t.

                                                                            {

  this->reset();

  edm::ESHandle< EcalElectronicsMapping > handle;
  c.get< EcalMappingRcd >().get(handle);
  const EcalElectronicsMapping *map = handle.product();
  if( ! map ){
    edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
    return;
  }

  MonitorElement* me;

  me = dqmStore_->get( prefixME_ + "/EventInfo/reportSummaryMap" );
  hDQM_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDQM_ );

  me = dqmStore_->get( prefixME_ + "/EventInfo/DAQSummaryMap" );
  hDAQ_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDAQ_ );

  me = dqmStore_->get( prefixME_ + "/EventInfo/DCSSummaryMap" );
  hDCS_ = UtilsClient::getHisto<TH2F*>( me, cloneME_, hDCS_ );

  float sumCert = 0.;
  float sumCertEE[18];
  int nValidChannels = 0;
  int nValidChannelsEE[18];

  if ( meEEDataCertificationSummaryMap_ ){
    for(int ix=1 ; ix<=meEEDataCertificationSummaryMap_->getNbinsX() ; ix++){
      for(int iy=1 ; iy<=meEEDataCertificationSummaryMap_->getNbinsY() ; iy++){
        meEEDataCertificationSummaryMap_->setBinContent( ix, iy, -1.0 );
      }
    }
  }

  for (int i = 0; i < 18; i++) {
    sumCertEE[i] = 0;
    nValidChannelsEE[i] = 0;

    for(int t=1 ; t<=nTowerMax_ ; t++){

      std::vector<DetId> crystals = map->dccTowerConstituents(DccId_[i], t);
      if(!crystals.size()) continue;

      std::vector<EcalScDetId> scs = map->getEcalScDetId(DccId_[i], t, false);
      for(unsigned u=0 ; u<scs.size() ; u++){

        int jx = scs[u].ix() + (scs[u].zside()<0 ? 0 : 20);
        int jy = scs[u].iy();

        float xvalDQM, xvalDAQ, xvalDCS;
        xvalDQM = xvalDAQ = xvalDCS = -1.;
        float xcert = -1.;

        if ( hDQM_ ) xvalDQM = hDQM_->GetBinContent( jx, jy );
        if ( hDAQ_ ) xvalDAQ = hDAQ_->GetBinContent( jx, jy );
        if ( hDCS_ ) xvalDCS = hDCS_->GetBinContent( jx, jy );

        if ( xvalDQM == -1 || ( xvalDAQ == -1 && xvalDCS == -1 ) ) {
          // problems: DQM empty or DAQ and DCS not available
          xcert = 0.0;
        } else {
          // do not consider the white value of DAQ and DCS (problems with DB)
          xcert = std::abs(xvalDQM) * std::abs(xvalDAQ) * std::abs(xvalDCS);
        }

        if ( meEEDataCertificationSummaryMap_ ) meEEDataCertificationSummaryMap_->setBinContent( jx, jy, xcert );

        int ncrystals = 0;

        for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
          EEDetId id(*it);
          if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
        }

        sumCertEE[i] += xcert * ncrystals;
        nValidChannelsEE[i] += ncrystals;

        sumCert += xcert * ncrystals;
        nValidChannels += ncrystals;

      }
    }

    if( meEEDataCertification_[i] ) {
      if( nValidChannelsEE[i]>0 ) meEEDataCertification_[i]->Fill( sumCertEE[i]/nValidChannelsEE[i] );
      else meEEDataCertification_[i]->Fill( 0.0 );
    }
  }

  if( meEEDataCertificationSummary_ ) {
    if( nValidChannels>0 ) meEEDataCertificationSummary_->Fill( sumCert/nValidChannels );
    else meEEDataCertificationSummary_->Fill( 0.0 );
  }

}
void EEDataCertificationTask::reset ( void  ) [protected]

Member Data Documentation

const int EEDataCertificationTask::DccId_ [static, protected]
Initial value:
 {1,2,3,4,5,6,7,8,9,
                                       46,47,48,49,50,51,52,53,54}

Definition at line 58 of file EEDataCertificationTask.h.

Referenced by endLuminosityBlock(), and endRun().

Definition at line 69 of file EEDataCertificationTask.h.

Referenced by EEDataCertificationTask(), and endJob().

Definition at line 75 of file EEDataCertificationTask.h.

Referenced by cleanup(), endLuminosityBlock(), and endRun().

Definition at line 73 of file EEDataCertificationTask.h.

Referenced by cleanup(), EEDataCertificationTask(), and endRun().

Definition at line 77 of file EEDataCertificationTask.h.

Referenced by cleanup(), EEDataCertificationTask(), and endLuminosityBlock().

Definition at line 76 of file EEDataCertificationTask.h.

Referenced by cleanup(), EEDataCertificationTask(), and endLuminosityBlock().

Definition at line 78 of file EEDataCertificationTask.h.

Referenced by cleanup(), EEDataCertificationTask(), and endLuminosityBlock().

Definition at line 83 of file EEDataCertificationTask.h.

Definition at line 84 of file EEDataCertificationTask.h.

Definition at line 71 of file EEDataCertificationTask.h.

Referenced by beginRun(), and EEDataCertificationTask().

const int EEDataCertificationTask::nTowerMax_ = 44 [static, protected]

Definition at line 59 of file EEDataCertificationTask.h.

Referenced by endLuminosityBlock(), and endRun().

std::string EEDataCertificationTask::prefixME_ [private]