CMS 3D CMS Logo

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

EBTimingTask Class Reference

#include <EBTimingTask.h>

Inheritance diagram for EBTimingTask:
edm::EDAnalyzer edm::EDConsumerBase

List of all members.

Public Member Functions

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

Static Public Attributes

static const float shiftProf2D_ = 50.

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze.
void beginJob (void)
 BeginJob.
void beginRun (const edm::Run &r, const edm::EventSetup &c)
 BeginRun.
void cleanup (void)
 Cleanup.
void endJob (void)
 EndJob.
void endRun (const edm::Run &r, const edm::EventSetup &c)
 EndRun.
void reset (void)
 Reset.
void setup (void)
 Setup.

Private Attributes

DQMStoredqmStore_
edm::InputTag EcalRawDataCollection_
edm::InputTag EcalRecHitCollection_
bool enableCleanup_
float energyThreshold_
int ievt_
bool init_
edm::InputTag L1GtEvmReadoutRecord_
bool mergeRuns_
MonitorElementmeTime_ [36]
MonitorElementmeTimeAmpli_ [36]
MonitorElementmeTimeAmpliSummary_
MonitorElementmeTimeMap_ [36]
MonitorElementmeTimeSummary1D_
MonitorElementmeTimeSummaryMap_
MonitorElementmeTimeSummaryMapProjEta_
MonitorElementmeTimeSummaryMapProjPhi_
std::string prefixME_
bool stableBeamsDeclared_
bool useBeamStatus_

Detailed Description

Definition at line 20 of file EBTimingTask.h.


Constructor & Destructor Documentation

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

Destructor.

Definition at line 71 of file EBTimingTask.cc.

                           {

}

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 218 of file EBTimingTask.cc.

References EcalDCCHeaderBlock::COSMIC, EcalDCCHeaderBlock::COSMICS_GLOBAL, EcalDCCHeaderBlock::COSMICS_LOCAL, EcalBarrel, EcalRawDataCollection_, EcalRecHitCollection_, energyThreshold_, MonitorElement::Fill(), edm::EventSetup::get(), edm::Event::getByLabel(), i, EBDetId::ic(), ievt_, init_, Numbers::iSM(), ecalpyutils::ism(), EcalRecHit::kGood, EcalRecHit::kOutOfTime, EcalSeverityLevel::kWeird, L1GtEvmReadoutRecord_, LogDebug, meTime_, meTimeAmpli_, meTimeAmpliSummary_, meTimeMap_, meTimeSummary1D_, meTimeSummaryMap_, EcalDCCHeaderBlock::MTCC, EcalDCCHeaderBlock::PHYSICS_GLOBAL, EcalDCCHeaderBlock::PHYSICS_LOCAL, reset(), environment_file_cff::runType, setup(), shiftProf2D_, stableBeamsDeclared_, Numbers::subDet(), and useBeamStatus_.

                                                                   {

  const unsigned STABLE_BEAMS = 11;

  bool isData = true;
  bool enable = false;
  int runType[36];
  for (int i=0; i<36; i++) runType[i] = -1;

  edm::Handle<EcalRawDataCollection> dcchs;

  if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {

    for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {

      if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;

      int ism = Numbers::iSM( *dcchItr, EcalBarrel );

      runType[ism-1] = dcchItr->getRunType();

      if ( dcchItr->getRunType() == EcalDCCHeaderBlock::COSMIC ||
           dcchItr->getRunType() == EcalDCCHeaderBlock::MTCC ||
           dcchItr->getRunType() == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
           dcchItr->getRunType() == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
           dcchItr->getRunType() == EcalDCCHeaderBlock::COSMICS_LOCAL ||
           dcchItr->getRunType() == EcalDCCHeaderBlock::PHYSICS_LOCAL ) enable = true;

    }

  } else {

    isData = false; enable = true;
    edm::LogWarning("EBTimingTask") << EcalRawDataCollection_ << " not available";

  }

  if ( ! enable ) return;

  if ( ! init_ ) this->setup();

  ievt_++;

  // resetting plots when stable beam is declared
  if( useBeamStatus_ && !stableBeamsDeclared_ ) {
    edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtRecord;
    if( e.getByLabel(L1GtEvmReadoutRecord_, gtRecord) ) {

      unsigned lhcBeamMode = gtRecord->gtfeWord().beamMode();

      if( lhcBeamMode == STABLE_BEAMS ){

        reset();

        stableBeamsDeclared_ = true;

      }
    }
  }

  edm::ESHandle<EcalSeverityLevelAlgo> sevlv;
  c.get<EcalSeverityLevelAlgoRcd>().get(sevlv);

  edm::Handle<EcalRecHitCollection> hits;

  if ( e.getByLabel(EcalRecHitCollection_, hits) ) {

    int neh = hits->size();
    LogDebug("EBTimingTask") << "event " << ievt_ << " hits collection size " << neh;

    for ( EcalRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {

      EBDetId id = hitItr->id();

      int ic = id.ic();
      int ie = (ic-1)/20 + 1;
      int ip = (ic-1)%20 + 1;

      int ism = Numbers::iSM( id );

      float xie = ie - 0.5;
      float xip = ip - 0.5;

      if ( isData ) {

        if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::COSMIC ||
                 runType[ism-1] == EcalDCCHeaderBlock::MTCC ||
                 runType[ism-1] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
                 runType[ism-1] == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
                 runType[ism-1] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
                 runType[ism-1] == EcalDCCHeaderBlock::PHYSICS_LOCAL ) ) continue;

      }

      MonitorElement* meTime = 0;
      MonitorElement* meTimeMap = 0;
      MonitorElement* meTimeAmpli = 0;

      meTime = meTime_[ism-1];
      meTimeMap = meTimeMap_[ism-1];
      meTimeAmpli = meTimeAmpli_[ism-1];

      float xval = hitItr->energy();
      float yval = hitItr->time();

      uint32_t flag = hitItr->recoFlag();

      uint32_t sev = sevlv->severityLevel(id, *hits);

      if ( (flag == EcalRecHit::kGood || flag == EcalRecHit::kOutOfTime) && sev != EcalSeverityLevel::kWeird ) {
        if ( meTimeAmpli ) meTimeAmpli->Fill(xval, yval);
        if ( meTimeAmpliSummary_ ) meTimeAmpliSummary_->Fill(xval, yval);

        if ( xval > energyThreshold_ ) {
          if ( meTime ) meTime->Fill(yval);
          if ( meTimeMap ) meTimeMap->Fill(xie, xip, yval+shiftProf2D_);
          if ( meTimeSummary1D_ ) meTimeSummary1D_->Fill(yval);

          float xebeta = id.ieta() - 0.5 * id.zside();
          float xebphi = id.iphi() - 0.5;
          if ( meTimeSummaryMap_ ) meTimeSummaryMap_->Fill(xebphi, xebeta, yval+shiftProf2D_);
        }

      }
    }

  } else {

    edm::LogWarning("EBTimingTask") << EcalRecHitCollection_ << " not available";

  }

}
void EBTimingTask::beginJob ( void  ) [protected, virtual]

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 75 of file EBTimingTask.cc.

References dqmStore_, ievt_, prefixME_, DQMStore::rmdir(), and DQMStore::setCurrentFolder().

                               {

  ievt_ = 0;

  if ( dqmStore_ ) {
    dqmStore_->setCurrentFolder(prefixME_ + "/EBTimingTask");
    dqmStore_->rmdir(prefixME_ + "/EBTimingTask");
  }

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

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 86 of file EBTimingTask.cc.

References Numbers::initGeometry(), mergeRuns_, reset(), and stableBeamsDeclared_.

                                                                   {

  Numbers::initGeometry(c, false);

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

  stableBeamsDeclared_ = false;

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

EndJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 210 of file EBTimingTask.cc.

References cleanup(), enableCleanup_, and ievt_.

                             {

  edm::LogInfo("EBTimingTask") << "analyzed " << ievt_ << " events";

  if ( enableCleanup_ ) this->cleanup();

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 96 of file EBTimingTask.cc.

                                                                 {

}
void EBTimingTask::reset ( void  ) [protected]
void EBTimingTask::setup ( void  ) [protected]

Setup.

Definition at line 114 of file EBTimingTask.cc.

References DQMStore::book1D(), DQMStore::book2D(), DQMStore::bookProfile2D(), dqmStore_, i, init_, meTime_, meTimeAmpli_, meTimeAmpliSummary_, meTimeMap_, meTimeSummary1D_, meTimeSummaryMap_, mergeVDriftHistosByStation::name, funct::pow(), prefixME_, Numbers::sEB(), MonitorElement::setAxisTitle(), DQMStore::setCurrentFolder(), shiftProf2D_, AlCaHLTBitMon_QueryRunRegistry::string, and DQMStore::tag().

Referenced by analyze().

                            {

  init_ = true;

  std::string name;

  // for timing vs amplitude plots
  const int nbinsE = 25;
  const float minlogE = -0.5;
  const float maxlogE = 2.;
  float binEdgesE[nbinsE + 1];
  for(int i = 0; i <= nbinsE; i++)
    binEdgesE[i] = std::pow((float)10., minlogE + (maxlogE - minlogE) / nbinsE * i);

  const int nbinsT = 200;
  const float minT = -50.;
  const float maxT = 50.;
  float binEdgesT[nbinsT + 1];
  for(int i = 0; i <= nbinsT; i++)
    binEdgesT[i] = minT + (maxT - minT) / nbinsT * i;

  if ( dqmStore_ ) {
    dqmStore_->setCurrentFolder(prefixME_ + "/EBTimingTask");

    for (int i = 0; i < 36; i++) {
      name = "EBTMT timing 1D " + Numbers::sEB(i+1);
      meTime_[i] = dqmStore_->book1D(name, name, 50, -25., 25.);
      meTime_[i]->setAxisTitle("time (ns)", 1);
      dqmStore_->tag(meTime_[i], i+1);

      name = "EBTMT timing " + Numbers::sEB(i+1);
      meTimeMap_[i] = dqmStore_->bookProfile2D(name, name, 85, 0., 85., 20, 0., 20., -20.+shiftProf2D_, 20.+shiftProf2D_, "s");
      meTimeMap_[i]->setAxisTitle("ieta", 1);
      meTimeMap_[i]->setAxisTitle("iphi", 2);
      meTimeMap_[i]->setAxisTitle("time (ns)", 3);
      dqmStore_->tag(meTimeMap_[i], i+1);

      name = "EBTMT timing vs amplitude " + Numbers::sEB(i+1);
      meTimeAmpli_[i] = dqmStore_->book2D(name, name, nbinsE, binEdgesE, nbinsT, binEdgesT);
      meTimeAmpli_[i]->setAxisTitle("energy (GeV)", 1);
      meTimeAmpli_[i]->setAxisTitle("time (ns)", 2);
      dqmStore_->tag(meTimeAmpli_[i], i+1);
    }

    name = "EBTMT timing vs amplitude summary";
    meTimeAmpliSummary_ = dqmStore_->book2D(name, name, nbinsE, binEdgesE, nbinsT, binEdgesT);
    meTimeAmpliSummary_->setAxisTitle("energy (GeV)", 1);
    meTimeAmpliSummary_->setAxisTitle("time (ns)", 2);

    name = "EBTMT timing 1D summary";
    meTimeSummary1D_ = dqmStore_->book1D(name, name, 50, -25., 25.);
    meTimeSummary1D_->setAxisTitle("time (ns)", 1);

    name = "EBTMT timing map";
    meTimeSummaryMap_ = dqmStore_->bookProfile2D(name, name, 72, 0., 360., 34, -85, 85, -20.+shiftProf2D_, 20.+shiftProf2D_, "s");
    meTimeSummaryMap_->setAxisTitle("jphi", 1);
    meTimeSummaryMap_->setAxisTitle("jeta", 2);
    meTimeSummaryMap_->setAxisTitle("time (ns)", 3);

  }

}

Member Data Documentation

Definition at line 62 of file EBTimingTask.h.

Referenced by beginJob(), cleanup(), EBTimingTask(), and setup().

Definition at line 72 of file EBTimingTask.h.

Referenced by analyze(), and EBTimingTask().

Definition at line 73 of file EBTimingTask.h.

Referenced by analyze(), and EBTimingTask().

Definition at line 66 of file EBTimingTask.h.

Referenced by EBTimingTask(), and endJob().

Definition at line 70 of file EBTimingTask.h.

Referenced by analyze(), and EBTimingTask().

int EBTimingTask::ievt_ [private]

Definition at line 60 of file EBTimingTask.h.

Referenced by analyze(), beginJob(), and endJob().

bool EBTimingTask::init_ [private]

Definition at line 84 of file EBTimingTask.h.

Referenced by analyze(), cleanup(), EBTimingTask(), and setup().

Definition at line 74 of file EBTimingTask.h.

Referenced by analyze(), and EBTimingTask().

bool EBTimingTask::mergeRuns_ [private]

Definition at line 68 of file EBTimingTask.h.

Referenced by beginRun(), and EBTimingTask().

Definition at line 76 of file EBTimingTask.h.

Referenced by analyze(), cleanup(), EBTimingTask(), reset(), and setup().

Definition at line 78 of file EBTimingTask.h.

Referenced by analyze(), cleanup(), EBTimingTask(), reset(), and setup().

Definition at line 80 of file EBTimingTask.h.

Referenced by analyze(), cleanup(), EBTimingTask(), reset(), and setup().

Definition at line 77 of file EBTimingTask.h.

Referenced by analyze(), cleanup(), EBTimingTask(), reset(), and setup().

Definition at line 81 of file EBTimingTask.h.

Referenced by analyze(), cleanup(), EBTimingTask(), reset(), and setup().

Definition at line 82 of file EBTimingTask.h.

Referenced by analyze(), cleanup(), EBTimingTask(), reset(), and setup().

Definition at line 82 of file EBTimingTask.h.

Definition at line 82 of file EBTimingTask.h.

std::string EBTimingTask::prefixME_ [private]

Definition at line 64 of file EBTimingTask.h.

Referenced by beginJob(), cleanup(), EBTimingTask(), and setup().

const float EBTimingTask::shiftProf2D_ = 50. [static]

Definition at line 30 of file EBTimingTask.h.

Referenced by analyze(), and setup().

Definition at line 87 of file EBTimingTask.h.

Referenced by analyze(), beginRun(), and EBTimingTask().

Definition at line 86 of file EBTimingTask.h.

Referenced by analyze(), and EBTimingTask().