Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:12

0001 #include "DQM/EcalCommon/interface/EcalMonitorPrescaler.h"
0002 
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 
0010 #include <cmath>
0011 #include <iostream>
0012 
0013 const uint32_t EcalMonitorPrescaler::filterBits_[ecaldqm::nPrescalers] = {
0014     (1 << EcalDCCHeaderBlock::MTCC) | (1 << EcalDCCHeaderBlock::PHYSICS_GLOBAL) |
0015         (1 << EcalDCCHeaderBlock::PHYSICS_LOCAL),  // kPhysics
0016     (1 << EcalDCCHeaderBlock::COSMIC) | (1 << EcalDCCHeaderBlock::COSMICS_GLOBAL) |
0017         (1 << EcalDCCHeaderBlock::COSMICS_LOCAL),  // kCosmics
0018     (1 << EcalDCCHeaderBlock::LASER_STD) | (1 << EcalDCCHeaderBlock::LASER_GAP) | (1 << EcalDCCHeaderBlock::LED_STD) |
0019         (1 << EcalDCCHeaderBlock::LED_GAP) | (1 << EcalDCCHeaderBlock::PEDESTAL_STD) |
0020         (1 << EcalDCCHeaderBlock::PEDESTAL_GAP) | (1 << EcalDCCHeaderBlock::TESTPULSE_MGPA) |
0021         (1 << EcalDCCHeaderBlock::TESTPULSE_GAP) | (1 << EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN),  // kCalibration
0022     (1 << EcalDCCHeaderBlock::LASER_STD) | (1 << EcalDCCHeaderBlock::LASER_GAP),                     // kLaser
0023     (1 << EcalDCCHeaderBlock::LED_STD) | (1 << EcalDCCHeaderBlock::LED_GAP),                         // kLed
0024     (1 << EcalDCCHeaderBlock::TESTPULSE_MGPA) | (1 << EcalDCCHeaderBlock::TESTPULSE_GAP),            // kTestPulse
0025     (1 << EcalDCCHeaderBlock::PEDESTAL_STD) | (1 << EcalDCCHeaderBlock::PEDESTAL_GAP) |
0026         (1 << EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN)  // kPedestal
0027 };
0028 
0029 EcalMonitorPrescaler::EcalMonitorPrescaler(edm::ParameterSet const &_ps)
0030     : EcalRawDataCollection_(
0031           consumes<EcalRawDataCollection>(_ps.getParameter<edm::InputTag>("EcalRawDataCollection"))) {
0032   prescalers_[ecaldqm::kPhysics] = _ps.getUntrackedParameter<unsigned>("physics", -1);
0033   prescalers_[ecaldqm::kCosmics] = _ps.getUntrackedParameter<unsigned>("cosmics", -1);
0034   prescalers_[ecaldqm::kCalibration] = _ps.getUntrackedParameter<unsigned>("calibration", -1);
0035   prescalers_[ecaldqm::kLaser] = _ps.getUntrackedParameter<unsigned>("laser", -1);
0036   prescalers_[ecaldqm::kLed] = _ps.getUntrackedParameter<unsigned>("led", -1);
0037   prescalers_[ecaldqm::kTestPulse] = _ps.getUntrackedParameter<unsigned>("testPulse", -1);
0038   prescalers_[ecaldqm::kPedestal] = _ps.getUntrackedParameter<unsigned>("pedestal", -1);
0039 
0040   // Backward compatibility
0041   prescalers_[ecaldqm::kPhysics] = std::min(
0042       prescalers_[ecaldqm::kPhysics], (unsigned int)(_ps.getUntrackedParameter<int>("occupancyPrescaleFactor", -1)));
0043   prescalers_[ecaldqm::kPhysics] = std::min(
0044       prescalers_[ecaldqm::kPhysics], (unsigned int)(_ps.getUntrackedParameter<int>("integrityPrescaleFactor", -1)));
0045   prescalers_[ecaldqm::kCosmics] = std::min(prescalers_[ecaldqm::kCosmics],
0046                                             (unsigned int)(_ps.getUntrackedParameter<int>("cosmicPrescaleFactor", -1)));
0047   prescalers_[ecaldqm::kLaser] =
0048       std::min(prescalers_[ecaldqm::kLaser], (unsigned int)(_ps.getUntrackedParameter<int>("laserPrescaleFactor", -1)));
0049   prescalers_[ecaldqm::kLed] =
0050       std::min(prescalers_[ecaldqm::kLed], (unsigned int)(_ps.getUntrackedParameter<int>("ledPrescaleFactor", -1)));
0051   prescalers_[ecaldqm::kPedestal] = std::min(
0052       prescalers_[ecaldqm::kPedestal], (unsigned int)(_ps.getUntrackedParameter<int>("pedestalPrescaleFactor", -1)));
0053   prescalers_[ecaldqm::kPedestal] =
0054       std::min(prescalers_[ecaldqm::kPedestal],
0055                (unsigned int)(_ps.getUntrackedParameter<int>("pedestalonlinePrescaleFactor", -1)));
0056   prescalers_[ecaldqm::kTestPulse] = std::min(
0057       prescalers_[ecaldqm::kTestPulse], (unsigned int)(_ps.getUntrackedParameter<int>("testpulsePrescaleFactor", -1)));
0058   prescalers_[ecaldqm::kPedestal] =
0059       std::min(prescalers_[ecaldqm::kPedestal],
0060                (unsigned int)(_ps.getUntrackedParameter<int>("pedestaloffsetPrescaleFactor", -1)));
0061   prescalers_[ecaldqm::kPhysics] = std::min(
0062       prescalers_[ecaldqm::kPhysics], (unsigned int)(_ps.getUntrackedParameter<int>("triggertowerPrescaleFactor", -1)));
0063   prescalers_[ecaldqm::kPhysics] = std::min(prescalers_[ecaldqm::kPhysics],
0064                                             (unsigned int)(_ps.getUntrackedParameter<int>("timingPrescaleFactor", -1)));
0065   prescalers_[ecaldqm::kPhysics] = std::min(
0066       prescalers_[ecaldqm::kPhysics], (unsigned int)(_ps.getUntrackedParameter<int>("physicsPrescaleFactor", -1)));
0067   prescalers_[ecaldqm::kPhysics] = std::min(
0068       prescalers_[ecaldqm::kPhysics], (unsigned int)(_ps.getUntrackedParameter<int>("clusterPrescaleFactor", -1)));
0069 }
0070 
0071 EcalMonitorPrescaler::~EcalMonitorPrescaler() {}
0072 
0073 std::shared_ptr<ecaldqm::PrescaleCounter> EcalMonitorPrescaler::globalBeginRun(edm::Run const &,
0074                                                                                edm::EventSetup const &) const {
0075   return std::make_shared<ecaldqm::PrescaleCounter>();
0076 }
0077 
0078 bool EcalMonitorPrescaler::filter(edm::StreamID, edm::Event &_event, edm::EventSetup const &) const {
0079   edm::Handle<EcalRawDataCollection> dcchs;
0080 
0081   if (!_event.getByToken(EcalRawDataCollection_, dcchs)) {
0082     edm::LogWarning("EcalMonitorPrescaler") << "EcalRawDataCollection not available";
0083     return false;
0084   }
0085 
0086   uint32_t eventBits(0);
0087   for (EcalRawDataCollection::const_iterator dcchItr(dcchs->begin()); dcchItr != dcchs->end(); ++dcchItr)
0088     eventBits |= (1 << dcchItr->getRunType());
0089 
0090   for (unsigned iP(0); iP != ecaldqm::nPrescalers; ++iP) {
0091     if ((eventBits & filterBits_[iP]) != 0 &&
0092         ++(runCache(_event.getRun().index())->counters_[iP]) % prescalers_[iP] == 0)
0093       return true;
0094   }
0095 
0096   return false;
0097 }
0098 
0099 void EcalMonitorPrescaler::globalEndRun(edm::Run const &, edm::EventSetup const &) const {}
0100 
0101 DEFINE_FWK_MODULE(EcalMonitorPrescaler);