Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-17 23:26:26

0001 #include "DQM/EcalMonitorTasks/interface/PNDiodeTask.h"
0002 
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 
0006 namespace ecaldqm {
0007 
0008   PNDiodeTask::PNDiodeTask() : DQWorkerTask() { std::fill_n(enable_, nDCC, false); }
0009 
0010   bool PNDiodeTask::filterRunType(short const* _runType) {
0011     bool enable(false);
0012 
0013     for (int iDCC(0); iDCC < 54; iDCC++) {
0014       if (_runType[iDCC] == EcalDCCHeaderBlock::LASER_STD || _runType[iDCC] == EcalDCCHeaderBlock::LASER_GAP ||
0015           _runType[iDCC] == EcalDCCHeaderBlock::LED_STD || _runType[iDCC] == EcalDCCHeaderBlock::LED_GAP ||
0016           _runType[iDCC] == EcalDCCHeaderBlock::TESTPULSE_MGPA || _runType[iDCC] == EcalDCCHeaderBlock::TESTPULSE_GAP ||
0017           _runType[iDCC] == EcalDCCHeaderBlock::PEDESTAL_STD || _runType[iDCC] == EcalDCCHeaderBlock::PEDESTAL_GAP) {
0018         enable = true;
0019         enable_[iDCC] = true;
0020       } else
0021         enable_[iDCC] = false;
0022     }
0023 
0024     return enable;
0025   }
0026 
0027   void PNDiodeTask::runOnErrors(EcalElectronicsIdCollection const& _ids, Collections _collection) {
0028     if (_ids.empty())
0029       return;
0030 
0031     MESet* meMEMErrors = &MEs_.at("MEMErrors");
0032 
0033     // MEM Box Integrity Errors (TowerIds 69 and 70)
0034     // errorType matches to the following labels in DQM plot
0035     // 0 = TOWERID
0036     // 1 = BLOCKSIZE
0037     // 2 = CHID
0038     // 3 = GAIN
0039     int errorType(-1);
0040     switch (_collection) {
0041       case kMEMTowerIdErrors:
0042         errorType = 0;
0043         break;
0044       case kMEMBlockSizeErrors:
0045         errorType = 1;
0046         break;
0047       case kMEMChIdErrors:
0048         errorType = 2;
0049         break;
0050       case kMEMGainErrors:
0051         errorType = 3;
0052         break;
0053       default:
0054         return;
0055     }
0056 
0057     // Integrity errors for MEM boxes (towerIds 69/70)
0058     // Plot contains two bins per dccId. Integer number
0059     // bins correspond to towerId 69 and half integer
0060     // number bins correspond to towerId 70.
0061     std::for_each(_ids.begin(),
0062                   _ids.end(),
0063                   [&](EcalElectronicsIdCollection::value_type const& id) {
0064                     if (id.towerId() == 69)
0065                       meMEMErrors->fill(getEcalDQMSetupObjects(), id.dccId() + 0.0, errorType);
0066                     else if (id.towerId() == 70)
0067                       meMEMErrors->fill(getEcalDQMSetupObjects(), id.dccId() + 0.5, errorType);
0068                     else {
0069                       edm::LogWarning("EcalDQM")
0070                           << "PNDiodeTask::runOnErrors : one of the ids in the electronics ID collection does not "
0071                           << "correspond to one of the MEM box towerIds (69/70) in lumi number " << timestamp_.iLumi
0072                           << ", event number " << timestamp_.iEvt;
0073                     }
0074                   });
0075   }
0076 
0077   void PNDiodeTask::runOnPnDigis(EcalPnDiodeDigiCollection const& _digis) {
0078     MESet& meOccupancy(MEs_.at("Occupancy"));
0079     MESet& meOccupancySummary(MEs_.at("OccupancySummary"));
0080     MESet& mePedestal(MEs_.at("Pedestal"));
0081 
0082     std::for_each(_digis.begin(), _digis.end(), [&](EcalPnDiodeDigiCollection::value_type const& digi) {
0083       const EcalPnDiodeDetId& id(digi.id());
0084 
0085       if (!enable_[dccId(id, GetElectronicsMap()) - 1])
0086         return;
0087 
0088       meOccupancy.fill(getEcalDQMSetupObjects(), id);
0089       meOccupancySummary.fill(getEcalDQMSetupObjects(), id);
0090 
0091       for (int iSample(0); iSample < 4; iSample++) {
0092         if (digi.sample(iSample).gainId() != 1)
0093           break;
0094         mePedestal.fill(getEcalDQMSetupObjects(), id, double(digi.sample(iSample).adc()));
0095       }
0096     });
0097   }
0098 
0099   DEFINE_ECALDQM_WORKER(PNDiodeTask);
0100 }  // namespace ecaldqm