CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Member Functions | Private Attributes

ecaldqm::LedTask Class Reference

#include <LedTask.h>

Inheritance diagram for ecaldqm::LedTask:
ecaldqm::DQWorkerTask ecaldqm::DQWorker

List of all members.

Public Types

enum  Constants { nWL = 2, nPNGain = 2 }
enum  MESets {
  kAmplitudeSummary, kAmplitude = kAmplitudeSummary + nWL, kOccupancy = kAmplitude + nWL, kShape = kOccupancy + nWL,
  kTiming = kShape + nWL, kAOverP = kTiming + nWL, kPNAmplitude = kAOverP + nWL, kPNOccupancy = kPNAmplitude + nWL * nPNGain,
  nMESets
}

Public Member Functions

void analyze (const void *, Collections)
void beginRun (const edm::Run &, const edm::EventSetup &)
void bookMEs ()
void endEvent (const edm::Event &, const edm::EventSetup &)
bool filterRunType (const std::vector< short > &)
 LedTask (const edm::ParameterSet &, const edm::ParameterSet &)
void runOnDigis (const EcalDigiCollection &)
void runOnPnDigis (const EcalPnDiodeDigiCollection &)
void runOnRawData (const EcalRawDataCollection &)
void runOnUncalibRecHits (const EcalUncalibratedRecHitCollection &)
 ~LedTask ()

Static Public Member Functions

static void setMEData (std::vector< MEData > &)

Private Attributes

bool enable_ [BinService::nDCC]
std::vector< int > ledWavelengths_
std::vector< int > MGPAGainsPN_
std::map< int, std::vector
< float > > 
pnAmp_
int wavelength_ [BinService::nDCC]

Detailed Description

Definition at line 12 of file LedTask.h.


Member Enumeration Documentation

Enumerator:
nWL 
nPNGain 

Definition at line 31 of file LedTask.h.

                   {
      nWL = 2,
      nPNGain = 2
    };
Enumerator:
kAmplitudeSummary 
kAmplitude 
kOccupancy 
kShape 
kTiming 
kAOverP 
kPNAmplitude 
kPNOccupancy 
nMESets 

Reimplemented from ecaldqm::DQWorker.

Definition at line 36 of file LedTask.h.

                {
      kAmplitudeSummary, // profile2d
      kAmplitude = kAmplitudeSummary + nWL, // profile2d
      kOccupancy = kAmplitude + nWL,
      kShape = kOccupancy + nWL,
      kTiming = kShape + nWL, // profile2d
      kAOverP = kTiming + nWL, // profile2d
      kPNAmplitude = kAOverP + nWL, // profile2d
      kPNOccupancy = kPNAmplitude + nWL * nPNGain, // profile2d
      nMESets
    };

Constructor & Destructor Documentation

data refman pasoursint CMSSW_5_3_10_patch1 src DQM EcalBarrelMonitorTasks src LedTask cc ecaldqm::LedTask::LedTask ( const edm::ParameterSet _params,
const edm::ParameterSet _paths 
)

Definition at line 11 of file LedTask.cc.

References Exception, edm::ParameterSet::getUntrackedParameter(), edm::ParameterSet::getUntrackedParameterSet(), ecaldqm::kEBUncalibRecHit, ecaldqm::kEcalRawData, ecaldqm::kEEDigi, ecaldqm::kEEUncalibRecHit, ecaldqm::kPnDiodeDigi, and evf::evtn::offset().

  {
    using namespace std;

    collectionMask_ = 
      (0x1 << kEcalRawData) |
      (0x1 << kEEDigi) |
      (0x1 << kPnDiodeDigi) |
      (0x1 << kEBUncalibRecHit) |
      (0x1 << kEEUncalibRecHit);

    edm::ParameterSet const& commonParams(_params.getUntrackedParameterSet("Common"));
    MGPAGainsPN_ = commonParams.getUntrackedParameter<std::vector<int> >("MGPAGainsPN");

    edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
    ledWavelengths_ = taskParams.getUntrackedParameter<std::vector<int> >("ledWavelengths");

    for(std::vector<int>::iterator wlItr(ledWavelengths_.begin()); wlItr != ledWavelengths_.end(); ++wlItr)
      if(*wlItr != 1 && *wlItr != 2) throw cms::Exception("InvalidConfiguration") << "Led Wavelength" << std::endl;

    for(std::vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr)
      if(*gainItr != 1 && *gainItr != 16) throw cms::Exception("InvalidConfiguration") << "PN diode gain" << std::endl; 

    map<string, string> replacements;
    stringstream ss;

    for(vector<int>::iterator wlItr(ledWavelengths_.begin()); wlItr != ledWavelengths_.end(); ++wlItr){
      ss.str("");
      ss << *wlItr;
      replacements["wl"] = ss.str();

      unsigned offset(*wlItr - 1);

      MEs_[kAmplitudeSummary + offset]->name(replacements);
      MEs_[kAmplitude + offset]->name(replacements);
      MEs_[kOccupancy + offset]->name(replacements);
      MEs_[kShape + offset]->name(replacements);
      MEs_[kTiming + offset]->name(replacements);
      MEs_[kAOverP + offset]->name(replacements);

      for(vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr){
        ss.str("");
        ss << *gainItr;
        replacements["pngain"] = ss.str();

        offset = (*wlItr - 1) * nPNGain + (*gainItr == 1 ? 0 : 1);

        MEs_[kPNAmplitude + offset]->name(replacements);
      }
    }
  }

ecaldqm::LedTask::~LedTask ( )

Definition at line 67 of file LedTask.cc.

  {
  }


Member Function Documentation

void ecaldqm::LedTask::analyze ( const void *  _p,
Collections  _collection 
) [inline, virtual]

Reimplemented from ecaldqm::DQWorkerTask.

Definition at line 59 of file LedTask.h.

References ecaldqm::kEBUncalibRecHit, ecaldqm::kEcalRawData, ecaldqm::kEEDigi, ecaldqm::kEEUncalibRecHit, ecaldqm::kPnDiodeDigi, runOnDigis(), runOnPnDigis(), runOnRawData(), and runOnUncalibRecHits().

                                                                     {
    switch(_collection){
    case kEcalRawData:
      runOnRawData(*static_cast<const EcalRawDataCollection*>(_p));
      break;
    case kEEDigi:
      runOnDigis(*static_cast<const EcalDigiCollection*>(_p));
      break;
    case kPnDiodeDigi:
      runOnPnDigis(*static_cast<const EcalPnDiodeDigiCollection*>(_p));
      break;
    case kEBUncalibRecHit:
    case kEEUncalibRecHit:
      runOnUncalibRecHits(*static_cast<const EcalUncalibratedRecHitCollection*>(_p));
      break;
    default:
      break;
    }
  }
void ecaldqm::LedTask::beginRun ( const edm::Run ,
const edm::EventSetup _es 
) [virtual]

Reimplemented from ecaldqm::DQWorker.

Definition at line 95 of file LedTask.cc.

References enable_, EcalDQMBinningService::nDCC, pnAmp_, and wavelength_.

  {
    for(int iDCC(0); iDCC < BinService::nDCC; iDCC++){
      enable_[iDCC] = false;
      wavelength_[iDCC] = -1;
    }
    pnAmp_.clear();
  }

void ecaldqm::LedTask::bookMEs ( ) [virtual]

Reimplemented from ecaldqm::DQWorker.

Definition at line 72 of file LedTask.cc.

References kAmplitude, kAmplitudeSummary, kAOverP, kOccupancy, kPNAmplitude, kPNOccupancy, kShape, kTiming, ledWavelengths_, ecaldqm::DQWorker::MEs_, MGPAGainsPN_, nPNGain, and evf::evtn::offset().

  {
    for(std::vector<int>::iterator wlItr(ledWavelengths_.begin()); wlItr != ledWavelengths_.end(); ++wlItr){
      unsigned offset(*wlItr - 1);

      MEs_[kAmplitudeSummary + offset]->book();
      MEs_[kAmplitude + offset]->book();
      MEs_[kOccupancy + offset]->book();
      MEs_[kTiming + offset]->book();
      MEs_[kShape + offset]->book();
      MEs_[kAOverP + offset]->book();

      for(std::vector<int>::iterator gainItr(MGPAGainsPN_.begin()); gainItr != MGPAGainsPN_.end(); ++gainItr){
        offset = (*wlItr - 1) * nPNGain + (*gainItr == 1 ? 0 : 1);

        MEs_[kPNAmplitude + offset]->book();
      }
    }

    MEs_[kPNOccupancy]->book();
  }

void ecaldqm::LedTask::endEvent ( const edm::Event ,
const edm::EventSetup  
) [virtual]

Reimplemented from ecaldqm::DQWorkerTask.

Definition at line 105 of file LedTask.cc.

References enable_, EcalDQMBinningService::nDCC, pnAmp_, and wavelength_.

  {
    for(int iDCC(0); iDCC < BinService::nDCC; iDCC++){
      enable_[iDCC] = false;
      wavelength_[iDCC] = -1;
    }
    pnAmp_.clear();
  }

bool ecaldqm::LedTask::filterRunType ( const std::vector< short > &  _runType) [virtual]

Reimplemented from ecaldqm::DQWorkerTask.

Definition at line 115 of file LedTask.cc.

References enable_, EcalDCCHeaderBlock::LED_GAP, EcalDCCHeaderBlock::LED_STD, and EcalDQMBinningService::nDCC.

  {
    bool enable(false);

    for(int iDCC(0); iDCC < BinService::nDCC; iDCC++){
      if(_runType[iDCC] == EcalDCCHeaderBlock::LED_STD ||
         _runType[iDCC] == EcalDCCHeaderBlock::LED_GAP){
        enable = true;
        enable_[iDCC] = true;
      }
    }

    return enable;
  }

void ecaldqm::LedTask::runOnDigis ( const EcalDigiCollection _digis)

Definition at line 145 of file LedTask.cc.

References EcalMGPASample::adc(), edm::DataFrameContainer::begin(), ecaldqm::dccId(), enable_, edm::DataFrameContainer::end(), lumiContext::fill, errorMatrix2Lands_multiChannel::id, kOccupancy, kShape, ecaldqm::DQWorker::MEs_, evf::evtn::offset(), EcalDataFrame::sample(), and wavelength_.

Referenced by analyze().

  {
    for(EcalDigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
      const DetId& id(digiItr->id());

      int iDCC(dccId(id) - 1);

      if(!enable_[iDCC]) continue;

      unsigned offset(-1);
      switch(wavelength_[iDCC]){
      case 1: offset = 0; break;
      case 3: offset = 1; break;
      default: continue;
      }

      MEs_[kOccupancy + offset]->fill(id);

      // EcalDataFrame is not a derived class of edm::DataFrame, but can take edm::DataFrame in the constructor
      EcalDataFrame dataFrame(*digiItr);

      for(int iSample(0); iSample < 10; iSample++)
        MEs_[kShape + offset]->fill(id, iSample + 0.5, float(dataFrame.sample(iSample).adc()));
    }
  }

void ecaldqm::LedTask::runOnPnDigis ( const EcalPnDiodeDigiCollection _digis)

Definition at line 172 of file LedTask.cc.

References edm::SortedCollection< T, SORT >::begin(), ecaldqm::dccId(), enable_, edm::SortedCollection< T, SORT >::end(), errorMatrix2Lands_multiChannel::id, kPNAmplitude, kPNOccupancy, max(), ecaldqm::DQWorker::MEs_, nPNGain, evf::evtn::offset(), pnAmp_, compare_using_db::sample, and wavelength_.

Referenced by analyze().

  {
    for(EcalPnDiodeDigiCollection::const_iterator digiItr(_digis.begin()); digiItr != _digis.end(); ++digiItr){
      const EcalPnDiodeDetId& id(digiItr->id());

      int iDCC(dccId(id) - 1);

      if(!enable_[iDCC]) continue;

      MEs_[kPNOccupancy]->fill(id);

      float pedestal(0.);
      for(int iSample(0); iSample < 4; iSample++)
        pedestal += digiItr->sample(iSample).adc();
      pedestal /= 4.;

      float max(0.);
      for(int iSample(0); iSample < 50; iSample++){
        EcalFEMSample sample(digiItr->sample(iSample));

        float amp(digiItr->sample(iSample).adc() - pedestal);

        if(amp > max) max = amp;
      }

      int gain(digiItr->sample(0).gainId() == 0 ? 1 : 16);
      max *= (16. / gain);

      unsigned offset(-1);
      switch(wavelength_[iDCC]){
      case 1: offset = (gain == 1 ? 0 : 1); break;
      case 3: offset = nPNGain + (gain == 1 ? 0 : 1); break;
      default: continue;
      }

      MEs_[kPNAmplitude + offset]->fill(id, max);

      if(pnAmp_.find(iDCC) == pnAmp_.end()) pnAmp_[iDCC].resize(10);
      pnAmp_[iDCC][id.iPnId() - 1] = max;
    }
  }

void ecaldqm::LedTask::runOnRawData ( const EcalRawDataCollection _dcchs)

Definition at line 131 of file LedTask.cc.

References edm::SortedCollection< T, SORT >::begin(), enable_, edm::SortedCollection< T, SORT >::end(), spr::find(), ledWavelengths_, and wavelength_.

Referenced by analyze().

  {
    for(EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr){
      int iDCC(dcchItr->id() - 1);

      if(!enable_[iDCC]) continue;

      wavelength_[iDCC] = dcchItr->getEventSettings().wavelength + 1;

      if(std::find(ledWavelengths_.begin(), ledWavelengths_.end(), wavelength_[iDCC]) == ledWavelengths_.end()) enable_[iDCC] = false;
    }
  }

void ecaldqm::LedTask::runOnUncalibRecHits ( const EcalUncalibratedRecHitCollection _uhits)

Definition at line 215 of file LedTask.cc.

References edm::SortedCollection< T, SORT >::begin(), ecaldqm::dccId(), MEEEGeom::dee(), enable_, edm::SortedCollection< T, SORT >::end(), ecaldqm::getEEPnDCC(), errorMatrix2Lands_multiChannel::id, EcalScDetId::ix(), EcalScDetId::iy(), kAmplitude, kAmplitudeSummary, kAOverP, kTiming, MEEEGeom::lmmod(), max(), ecaldqm::DQWorker::MEs_, evf::evtn::offset(), MEEEGeom::pn(), pnAmp_, wavelength_, and EcalScDetId::zside().

Referenced by analyze().

  {
    using namespace std;

    for(EcalUncalibratedRecHitCollection::const_iterator uhitItr(_uhits.begin()); uhitItr != _uhits.end(); ++uhitItr){
      EEDetId id(uhitItr->id());

      int iDCC(dccId(id) - 1);

      if(!enable_[iDCC]) continue;

      unsigned offset(-1);
      switch(wavelength_[iDCC]){
      case 1: offset = 0; break;
      case 3: offset = 1; break;
      default: continue;
      }

      float amp(max((double)uhitItr->amplitude(), 0.));
      float jitter(max((double)uhitItr->jitter() + 5.0, 0.));

      MEs_[kAmplitudeSummary + offset]->fill(id, amp);
      MEs_[kAmplitude + offset]->fill(id, amp);
      MEs_[kTiming + offset]->fill(id, jitter);

      if(pnAmp_.find(iDCC) == pnAmp_.end()) continue;

      float aop(0.);
      float pn0(0.), pn1(0.);

      EcalScDetId scid(id.sc());

      int dee(MEEEGeom::dee(scid.ix(), scid.iy(), scid.zside()));
      int lmmod(MEEEGeom::lmmod(scid.ix(), scid.iy()));
      pair<int, int> pnPair(MEEEGeom::pn(dee, lmmod));

      int pnAFED(getEEPnDCC(dee, 0)), pnBFED(getEEPnDCC(dee, 1));

      pn0 = pnAmp_[pnAFED][pnPair.first];
      pn1 = pnAmp_[pnBFED][pnPair.second];

      if(pn0 < 10 && pn1 > 10){
        aop = amp / pn1;
      }else if(pn0 > 10 && pn1 < 10){
        aop = amp / pn0;
      }else if(pn0 + pn1 > 1){
        aop = amp / (0.5 * (pn0 + pn1));
      }else{
        aop = 1000.;
      }

      MEs_[kAOverP + offset]->fill(id, aop);
    }
  }

void ecaldqm::LedTask::setMEData ( std::vector< MEData > &  _data) [static]

Reimplemented from ecaldqm::DQWorker.

Definition at line 272 of file LedTask.cc.

References MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE, MonitorElement::DQM_KIND_TPROFILE2D, EcalDQMBinningService::AxisSpecs::high, kAmplitude, kAmplitudeSummary, kAOverP, EcalDQMBinningService::kCrystal, EcalDQMBinningService::kEcal2P, EcalDQMBinningService::kEcalMEM2P, kOccupancy, kPNAmplitude, kPNOccupancy, kShape, EcalDQMBinningService::kSM, EcalDQMBinningService::kSMMEM, EcalDQMBinningService::kSuperCrystal, kTiming, EcalDQMBinningService::AxisSpecs::low, EcalDQMBinningService::AxisSpecs::nbins, nPNGain, nWL, and evf::evtn::offset().

  {
    BinService::AxisSpecs axis;
    axis.nbins = 10;
    axis.low = 0.;
    axis.high = 10.;

    for(unsigned iWL(0); iWL < nWL; iWL++){
      _data[kAmplitudeSummary + iWL] = MEData("AmplitudeSummary", BinService::kEcal2P, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TPROFILE2D);
      _data[kAmplitude + iWL] = MEData("Amplitude", BinService::kSM, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TPROFILE2D);
      _data[kOccupancy + iWL] = MEData("Occupancy", BinService::kEcal2P, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TH2F);
      _data[kShape + iWL] = MEData("Shape", BinService::kSM, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TPROFILE2D, 0, &axis);
      _data[kTiming + iWL] = MEData("Timing", BinService::kSM, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TPROFILE2D);
      _data[kAOverP + iWL] = MEData("AOverP", BinService::kSM, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TPROFILE2D);

      for(unsigned iPNGain(0); iPNGain < nPNGain; iPNGain++){
        unsigned offset(iWL * nPNGain + iPNGain);
        _data[kPNAmplitude + offset] = MEData("PNAmplitude", BinService::kSMMEM, BinService::kCrystal, MonitorElement::DQM_KIND_TPROFILE);
      }
    }
    _data[kPNOccupancy] = MEData("PNOccupancy", BinService::kEcalMEM2P, BinService::kCrystal, MonitorElement::DQM_KIND_TH2F);
  }


Member Data Documentation

bool ecaldqm::LedTask::enable_[BinService::nDCC] [private]
std::vector<int> ecaldqm::LedTask::ledWavelengths_ [private]

Definition at line 51 of file LedTask.h.

Referenced by bookMEs(), and runOnRawData().

std::vector<int> ecaldqm::LedTask::MGPAGainsPN_ [private]

Definition at line 52 of file LedTask.h.

Referenced by bookMEs().

std::map<int, std::vector<float> > ecaldqm::LedTask::pnAmp_ [private]

Definition at line 56 of file LedTask.h.

Referenced by beginRun(), endEvent(), runOnPnDigis(), and runOnUncalibRecHits().

int ecaldqm::LedTask::wavelength_[BinService::nDCC] [private]