CMS 3D CMS Logo

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

EETimingTask Class Reference

#include <EETimingTask.h>

Inheritance diagram for EETimingTask:
edm::EDAnalyzer

List of all members.

Public Member Functions

 EETimingTask (const edm::ParameterSet &ps)
 Constructor.
virtual ~EETimingTask ()
 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_
bool initCaloGeometry_
edm::InputTag L1GtEvmReadoutRecord_
bool mergeRuns_
MonitorElementmeTime_ [18]
MonitorElementmeTimeAmpli_ [18]
MonitorElementmeTimeAmpliSummary_ [2]
MonitorElementmeTimeDelta2D_
MonitorElementmeTimeDelta_
MonitorElementmeTimeMap_ [18]
MonitorElementmeTimeSummary1D_ [2]
MonitorElementmeTimeSummaryMap_ [2]
edm::ESHandle< CaloGeometrypGeometry_
std::string prefixME_
bool stableBeamsDeclared_
bool useBeamStatus_

Detailed Description

Definition at line 26 of file EETimingTask.h.


Constructor & Destructor Documentation

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

Destructor.

Definition at line 76 of file EETimingTask.cc.

                           {

}

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 267 of file EETimingTask.cc.

References EcalDCCHeaderBlock::COSMIC, EcalDCCHeaderBlock::COSMICS_GLOBAL, EcalDCCHeaderBlock::COSMICS_LOCAL, EcalEndcap, EcalRawDataCollection_, EcalRecHitCollection_, energyThreshold_, MonitorElement::Fill(), edm::EventSetup::get(), edm::Event::getByLabel(), i, ievt_, init_, Numbers::iSM(), ecalpyutils::ism(), EEDetId::ix(), EcalRecHit::kGood, EcalRecHit::kOutOfTime, EcalSeverityLevel::kWeird, L1GtEvmReadoutRecord_, LogDebug, meTime_, meTimeAmpli_, meTimeAmpliSummary_, meTimeDelta2D_, meTimeDelta_, 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[18];
  for (int i=0; i<18; 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 ) != EcalEndcap ) continue;

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

      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("EETimingTask") << 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;

      }
    }
  }

  float sumTime_hithr[2] = {0.,0.};
  int n_hithr[2] = {0,0};

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

  edm::Handle<EcalRecHitCollection> hits;

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

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

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

      EEDetId id = hitItr->id();

      int ix = id.ix();
      int iy = id.iy();
      int iz = ( id.positiveZ() ) ? 1 : 0;

      int ism = Numbers::iSM( id );

      if ( ism >= 1 && ism <= 9 ) ix = 101 - ix;

      float xix = ix - 0.5;
      float xiy = iy - 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_[iz] ) meTimeAmpliSummary_[iz]->Fill(xval, yval);
        if ( hitItr->energy() > energyThreshold_ ) {
          if ( meTimeMap ) meTimeMap->Fill(xix, xiy, yval+shiftProf2D);
          if ( meTime ) meTime->Fill(yval);
          if ( meTimeSummary1D_[iz] ) meTimeSummary1D_[iz]->Fill(yval);

          if ( meTimeSummaryMap_[iz] ) meTimeSummaryMap_[iz]->Fill(id.ix()-0.5, xiy, yval+shiftProf2D);

          sumTime_hithr[iz] += yval;
          n_hithr[iz]++;
        }
      } // good rh for timing
    } // loop over rh

    if (n_hithr[0] > 0 && n_hithr[1] > 0 ) {
      if ( meTimeDelta_ ) meTimeDelta_->Fill( sumTime_hithr[1]/n_hithr[1] - sumTime_hithr[0]/n_hithr[0] );
      if ( meTimeDelta2D_ ) meTimeDelta2D_->Fill( sumTime_hithr[1]/n_hithr[1], sumTime_hithr[0]/n_hithr[0] );
    }

  } else {

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

  }

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 80 of file EETimingTask.cc.

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

                               {

  ievt_ = 0;

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

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

EndJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 259 of file EETimingTask.cc.

References cleanup(), enableCleanup_, and ievt_.

                             {

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

  if ( enableCleanup_ ) this->cleanup();

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 106 of file EETimingTask.cc.

                                                                 {

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

Reset.

Definition at line 110 of file EETimingTask.cc.

References i, meTime_, meTimeAmpli_, meTimeAmpliSummary_, meTimeDelta2D_, meTimeDelta_, meTimeMap_, meTimeSummary1D_, meTimeSummaryMap_, and MonitorElement::Reset().

Referenced by analyze(), and beginRun().

                             {

  for (int i = 0; i < 18; i++) {
    if ( meTime_[i] ) meTime_[i]->Reset();
    if ( meTimeMap_[i] ) meTimeMap_[i]->Reset();
    if ( meTimeAmpli_[i] ) meTimeAmpli_[i]->Reset();
  }

  for (int i = 0; i < 2; i++) {
    if ( meTimeAmpliSummary_[i] ) meTimeAmpliSummary_[i]->Reset();
    if ( meTimeSummary1D_[i] ) meTimeSummary1D_[i]->Reset();
    if ( meTimeSummaryMap_[i] ) meTimeSummaryMap_[i]->Reset();
  }

  if ( meTimeDelta_ ) meTimeDelta_->Reset();
  if ( meTimeDelta2D_ ) meTimeDelta2D_->Reset();

}
void EETimingTask::setup ( void  ) [protected]

Setup.

Definition at line 129 of file EETimingTask.cc.

References DQMStore::book1D(), DQMStore::book2D(), DQMStore::bookProfile2D(), dqmStore_, i, init_, Numbers::ix0EE(), Numbers::iy0EE(), meTime_, meTimeAmpli_, meTimeAmpliSummary_, meTimeDelta2D_, meTimeDelta_, meTimeMap_, meTimeSummary1D_, meTimeSummaryMap_, mergeVDriftHistosByStation::name, funct::pow(), prefixME_, Numbers::sEE(), MonitorElement::setAxisTitle(), DQMStore::setCurrentFolder(), shiftProf2D, 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_ + "/EETimingTask");

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

      name = "EETMT timing " + Numbers::sEE(i+1);
      meTimeMap_[i] = dqmStore_->bookProfile2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50., -20.+shiftProf2D, 20.+shiftProf2D, "s");
      meTimeMap_[i]->setAxisTitle("ix", 1);
      if ( i+1 >= 1 && i+1 <= 9 ) meTimeMap_[i]->setAxisTitle("101-ix", 1);
      meTimeMap_[i]->setAxisTitle("iy", 2);
      meTimeMap_[i]->setAxisTitle("time (ns)", 3);
      dqmStore_->tag(meTimeMap_[i], i+1);

      name = "EETMT timing vs amplitude " + Numbers::sEE(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 = "EETMT timing vs amplitude summary EE -";
    meTimeAmpliSummary_[0] = dqmStore_->book2D(name, name, nbinsE, binEdgesE, nbinsT, binEdgesT);
    meTimeAmpliSummary_[0]->setAxisTitle("energy (GeV)", 1);
    meTimeAmpliSummary_[0]->setAxisTitle("time (ns)", 2);

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

    name = "EETMT timing 1D summary EE -";
    meTimeSummary1D_[0] = dqmStore_->book1D(name, name, 50, -25., 25.);
    meTimeSummary1D_[0]->setAxisTitle("time (ns)", 1);

    name = "EETMT timing 1D summary EE +";
    meTimeSummary1D_[1] = dqmStore_->book1D(name, name, 50, -25., 25.);
    meTimeSummary1D_[1]->setAxisTitle("time (ns)", 1);

    name = "EETMT timing map EE -";
    meTimeSummaryMap_[0] = dqmStore_->bookProfile2D(name, name, 20, 0., 100., 20, 0., 100., -20.+shiftProf2D, 20.+shiftProf2D, "s");
    meTimeSummaryMap_[0]->setAxisTitle("ix'", 1);
    meTimeSummaryMap_[0]->setAxisTitle("101-iy'", 2);
    meTimeSummaryMap_[0]->setAxisTitle("time (ns)", 3);

    name = "EETMT timing map EE +";
    meTimeSummaryMap_[1] = dqmStore_->bookProfile2D(name, name, 20, 0., 100., 20, 0., 100., -20.+shiftProf2D, 20.+shiftProf2D, "s");
    meTimeSummaryMap_[1]->setAxisTitle("ix'", 1);
    meTimeSummaryMap_[1]->setAxisTitle("iy'", 2);
    meTimeSummaryMap_[1]->setAxisTitle("time (ns)", 3);

    name = "EETMT timing EE+ - EE-";
    meTimeDelta_ = dqmStore_->book1D(name, name, 100, -3., 3.);
    meTimeDelta_->setAxisTitle("time (ns)", 1);

    name = "EETMT timing EE+ vs EE-";
    meTimeDelta2D_ = dqmStore_->book2D(name, name, 50, -25., 25., 50, -25., 25.);
    meTimeDelta2D_->setAxisTitle("EE+ average time (ns)", 1);
    meTimeDelta2D_->setAxisTitle("EE- average time (ns)", 2);

  }

}

Member Data Documentation

Definition at line 68 of file EETimingTask.h.

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

Definition at line 78 of file EETimingTask.h.

Referenced by analyze(), and EETimingTask().

Definition at line 79 of file EETimingTask.h.

Referenced by analyze(), and EETimingTask().

Definition at line 72 of file EETimingTask.h.

Referenced by EETimingTask(), and endJob().

Definition at line 76 of file EETimingTask.h.

Referenced by analyze(), and EETimingTask().

int EETimingTask::ievt_ [private]

Definition at line 66 of file EETimingTask.h.

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

bool EETimingTask::init_ [private]

Definition at line 93 of file EETimingTask.h.

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

Definition at line 94 of file EETimingTask.h.

Referenced by beginRun(), and EETimingTask().

Definition at line 80 of file EETimingTask.h.

Referenced by analyze(), and EETimingTask().

bool EETimingTask::mergeRuns_ [private]

Definition at line 74 of file EETimingTask.h.

Referenced by beginRun(), and EETimingTask().

Definition at line 82 of file EETimingTask.h.

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

Definition at line 84 of file EETimingTask.h.

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

Definition at line 86 of file EETimingTask.h.

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

Definition at line 89 of file EETimingTask.h.

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

Definition at line 89 of file EETimingTask.h.

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

Definition at line 83 of file EETimingTask.h.

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

Definition at line 87 of file EETimingTask.h.

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

Definition at line 88 of file EETimingTask.h.

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

Definition at line 91 of file EETimingTask.h.

Referenced by beginRun().

std::string EETimingTask::prefixME_ [private]

Definition at line 70 of file EETimingTask.h.

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

const float EETimingTask::shiftProf2D = 50. [static]

Definition at line 36 of file EETimingTask.h.

Referenced by analyze(), and setup().

Definition at line 97 of file EETimingTask.h.

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

Definition at line 96 of file EETimingTask.h.

Referenced by analyze(), and EETimingTask().