CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

EBCosmicTask Class Reference

#include <EBCosmicTask.h>

Inheritance diagram for EBCosmicTask:
edm::EDAnalyzer

List of all members.

Public Member Functions

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

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_
edm::InputTag EcalUncalibratedRecHitCollection_
bool enableCleanup_
int ievt_
bool init_
double maxJitter_
MonitorElementmeCutMap_ [36]
bool mergeRuns_
MonitorElementmeSelMap_ [36]
MonitorElementmeSpectrum_ [2][36]
double minJitter_
std::string prefixME_
double threshold_

Detailed Description

Definition at line 20 of file EBCosmicTask.h.


Constructor & Destructor Documentation

EBCosmicTask::EBCosmicTask ( const edm::ParameterSet ps)

Constructor.

Definition at line 29 of file EBCosmicTask.cc.

References dqmStore_, EcalRawDataCollection_, EcalRecHitCollection_, EcalUncalibratedRecHitCollection_, enableCleanup_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, init_, maxJitter_, mergeRuns_, meSelMap_, meSpectrum_, minJitter_, cmsCodeRules::cppFunctionSkipper::operator, prefixME_, and threshold_.

                                                   {

  init_ = false;

  dqmStore_ = edm::Service<DQMStore>().operator->();

  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");

  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);

  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);

  EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
  EcalUncalibratedRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalUncalibratedRecHitCollection");
  EcalRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalRecHitCollection");

  threshold_ = 0.12500; // typical muon energy deposit is 250 MeV

  minJitter_ = -2.0;
  maxJitter_ =  1.5;

  for (int i = 0; i < 36; i++) {
    meSelMap_[i] = 0;
    meSpectrum_[0][i] = 0;
    meSpectrum_[1][i] = 0;
  }

}
EBCosmicTask::~EBCosmicTask ( ) [virtual]

Destructor.

Definition at line 58 of file EBCosmicTask.cc.

                           {

}

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 168 of file EBCosmicTask.cc.

References EcalDCCHeaderBlock::COSMIC, EcalDCCHeaderBlock::COSMICS_GLOBAL, EcalDCCHeaderBlock::COSMICS_LOCAL, EcalBarrel, EcalRawDataCollection_, EcalRecHitCollection_, EcalUncalibratedRecHitCollection_, EBDetId::ETAPHIMODE, MonitorElement::Fill(), edm::Event::getByLabel(), i, EBDetId::ic(), ievt_, init_, Numbers::iSM(), ecalpyutils::ism(), edm::HandleBase::isValid(), LogDebug, maxJitter_, meSelMap_, meSpectrum_, minJitter_, EcalDCCHeaderBlock::MTCC, EcalDCCHeaderBlock::PHYSICS_GLOBAL, EcalDCCHeaderBlock::PHYSICS_LOCAL, ExpressReco_HICollisions_FallBack::runType, setup(), Numbers::subDet(), threshold_, and EBDetId::validDetId().

                                                                   {

  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("EBCosmicTask") << EcalRawDataCollection_ << " not available";

  }

  if ( ! enable ) return;

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

  ievt_++;

  edm::Handle<EcalRecHitCollection> hits;

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

    int nebh = hits->size();
    LogDebug("EBCosmicTask") << "event " << ievt_ << " hits collection size " << nebh;

    edm::Handle<EcalUncalibratedRecHitCollection> uhits;

    if ( ! e.getByLabel(EcalUncalibratedRecHitCollection_, uhits) ) {
      edm::LogWarning("EBCosmicTask") << EcalUncalibratedRecHitCollection_ << " not available";
    }

    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;

      }

      float xval = hitItr->energy();
      if ( xval <= 0. ) xval = 0.0;

      // look for the seeds
      float e3x3 = 0.;
      bool isSeed = true;

      // evaluate 3x3 matrix around a seed
      for(int icry=0; icry<9; ++icry) {
        unsigned int row    = icry/3;
        unsigned int column = icry%3;
        int icryEta = id.ieta()+column-1;
        int icryPhi = id.iphi()+row-1;
        if ( EBDetId::validDetId(icryEta, icryPhi) ) {
          EBDetId id3x3 = EBDetId(icryEta, icryPhi, EBDetId::ETAPHIMODE);
          if ( hits->find(id3x3) != hits->end() ) {
            float neighbourEnergy = hits->find(id3x3)->energy();
            e3x3 += neighbourEnergy;
            if ( neighbourEnergy > xval ) isSeed = false;
          }
        }
      }

      // find the jitter of the seed
      float jitter = -999.;
      if ( isSeed ) {
        if ( uhits.isValid() ) {
          if ( uhits->find(id) != uhits->end() ) {
            jitter = uhits->find(id)->jitter();
          }
        }
      }

      if ( isSeed && e3x3 >= threshold_ && jitter > minJitter_ && jitter < maxJitter_ ) {
        if ( meSelMap_[ism-1] ) meSelMap_[ism-1]->Fill(xie, xip, e3x3);
      }

      if ( meSpectrum_[0][ism-1] ) meSpectrum_[0][ism-1]->Fill(xval);

      if ( isSeed && xval >= threshold_ && jitter > minJitter_ && jitter < maxJitter_ ) {
        if ( meSpectrum_[1][ism-1] ) meSpectrum_[1][ism-1]->Fill(e3x3);
      }

    }

  } else {

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

  }

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 62 of file EBCosmicTask.cc.

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

                               {

  ievt_ = 0;

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

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

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 73 of file EBCosmicTask.cc.

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

                                                                   {

  Numbers::initGeometry(c, false);

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

}
void EBCosmicTask::cleanup ( void  ) [protected]

Cleanup.

Definition at line 127 of file EBCosmicTask.cc.

References dqmStore_, edm::getName(), i, init_, meCutMap_, meSelMap_, meSpectrum_, prefixME_, DQMStore::removeElement(), and DQMStore::setCurrentFolder().

Referenced by endJob().

                              {

  if ( ! init_ ) return;

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

    dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Cut");
    for (int i = 0; i < 36; i++) {
      if ( meCutMap_[i] ) dqmStore_->removeElement( meCutMap_[i]->getName() );
      meCutMap_[i] = 0;
    }

    dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Sel");
    for (int i = 0; i < 36; i++) {
      if ( meSelMap_[i] ) dqmStore_->removeElement( meSelMap_[i]->getName() );
      meSelMap_[i] = 0;
    }

    dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Spectrum");
    for (int i = 0; i < 36; i++) {
      if ( meSpectrum_[0][i] ) dqmStore_->removeElement( meSpectrum_[0][i]->getName() );
      meSpectrum_[0][i] = 0;
      if ( meSpectrum_[1][i] ) dqmStore_->removeElement( meSpectrum_[1][i]->getName() );
      meSpectrum_[1][i] = 0;
    }

  }

  init_ = false;

}
void EBCosmicTask::endJob ( void  ) [protected, virtual]

EndJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 160 of file EBCosmicTask.cc.

References cleanup(), enableCleanup_, and ievt_.

                             {

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

  if ( enableCleanup_ ) this->cleanup();

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 81 of file EBCosmicTask.cc.

                                                                 {

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

Reset.

Definition at line 85 of file EBCosmicTask.cc.

References i, meSelMap_, meSpectrum_, and MonitorElement::Reset().

Referenced by beginRun().

                             {

  for (int i = 0; i < 36; i++) {
    if ( meSelMap_[i] ) meSelMap_[i]->Reset();
    if ( meSpectrum_[0][i] ) meSpectrum_[0][i]->Reset();
    if ( meSpectrum_[1][i] ) meSpectrum_[1][i]->Reset();
  }

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

Setup.

Definition at line 95 of file EBCosmicTask.cc.

References DQMStore::book1D(), DQMStore::bookProfile2D(), dqmStore_, trackerHits::histo, i, init_, meSelMap_, meSpectrum_, prefixME_, Numbers::sEB(), MonitorElement::setAxisTitle(), and DQMStore::setCurrentFolder().

Referenced by analyze().

                            {

  init_ = true;

  char histo[200];

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

    dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Sel");
    for (int i = 0; i < 36; i++) {
      sprintf(histo, "EBCT energy sel %s", Numbers::sEB(i+1).c_str());
      meSelMap_[i] = dqmStore_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 4096, 0., 4096., "s");
      meSelMap_[i]->setAxisTitle("ieta", 1);
      meSelMap_[i]->setAxisTitle("iphi", 2);
      meSelMap_[i]->setAxisTitle("energy (GeV)", 3);
    }

    dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Spectrum");
    for (int i = 0; i < 36; i++) {
      sprintf(histo, "EBCT 1x1 energy spectrum %s", Numbers::sEB(i+1).c_str());
      meSpectrum_[0][i] = dqmStore_->book1D(histo, histo, 100, 0., 1.5);
      meSpectrum_[0][i]->setAxisTitle("energy (GeV)", 1);
      sprintf(histo, "EBCT 3x3 energy spectrum %s", Numbers::sEB(i+1).c_str());
      meSpectrum_[1][i] = dqmStore_->book1D(histo, histo, 100, 0., 1.5);
      meSpectrum_[1][i]->setAxisTitle("energy (GeV)", 1);
    }

  }

}

Member Data Documentation

Definition at line 60 of file EBCosmicTask.h.

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

Definition at line 68 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

Definition at line 70 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

Definition at line 69 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

Definition at line 64 of file EBCosmicTask.h.

Referenced by EBCosmicTask(), and endJob().

int EBCosmicTask::ievt_ [private]

Definition at line 58 of file EBCosmicTask.h.

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

bool EBCosmicTask::init_ [private]

Definition at line 82 of file EBCosmicTask.h.

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

double EBCosmicTask::maxJitter_ [private]

Definition at line 80 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

Definition at line 72 of file EBCosmicTask.h.

Referenced by cleanup().

bool EBCosmicTask::mergeRuns_ [private]

Definition at line 66 of file EBCosmicTask.h.

Referenced by beginRun(), and EBCosmicTask().

Definition at line 74 of file EBCosmicTask.h.

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

Definition at line 76 of file EBCosmicTask.h.

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

double EBCosmicTask::minJitter_ [private]

Definition at line 79 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

std::string EBCosmicTask::prefixME_ [private]

Definition at line 62 of file EBCosmicTask.h.

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

double EBCosmicTask::threshold_ [private]

Definition at line 78 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().