Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/HcalCommon/interface/DQClient.h"
0002 
0003 namespace hcaldqm {
0004   using namespace constants;
0005   DQClient::DQClient(std::string const &name,
0006                      std::string const &taskname,
0007                      edm::ParameterSet const &ps,
0008                      edm::ConsumesCollector &iC)
0009       : DQModule(ps),
0010         _taskname(taskname),
0011         _totalLS(0),
0012         _maxProcessedLS(0),
0013         hcalDbServiceToken_(iC.esConsumes<HcalDbService, HcalDbRecord, edm::Transition::BeginRun>()),
0014         runInfoToken_(iC.esConsumes<RunInfo, RunInfoRcd, edm::Transition::BeginRun>()),
0015         hcalChannelQualityToken_(
0016             iC.esConsumes<HcalChannelQuality, HcalChannelQualityRcd, edm::Transition::BeginLuminosityBlock>(
0017                 edm::ESInputTag("", "withTopo"))) {
0018     //  - SET THE TASK NAME YOU REFER TO
0019     //  - SET THE CLIENT'S NAME AS WELL - RUN SUMMARY PLOTS
0020     //  WILL BE GENERATED UNDER THAT FOLDER
0021     _name = name;
0022   }
0023 
0024   void DQClient::beginRun(edm::Run const &r, edm::EventSetup const &es) {
0025     //  TEMPORARY
0026     _vhashFEDs.clear();
0027     _vcdaqEids.clear();
0028     _vhashCrates.clear();
0029 
0030     //  get various FED lists
0031     edm::ESHandle<HcalDbService> dbs = es.getHandle(hcalDbServiceToken_);
0032     _emap = dbs->getHcalMapping();
0033 
0034     if (_ptype != fOffline) {  // hidefed2crate
0035       _vFEDs = utilities::getFEDList(_emap);
0036       for (std::vector<int>::const_iterator it = _vFEDs.begin(); it != _vFEDs.end(); ++it) {
0037         //
0038         //  FIXME
0039         //  until there exists a map of FED2Crate and Crate2FED,
0040         //  all the unknown Crates will be mapped to 0...
0041         //
0042         if (*it == 0) {
0043           _vhashFEDs.push_back(HcalElectronicsId(0, SLOT_uTCA_MIN, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0044           continue;
0045         }
0046 
0047         if (*it > FED_VME_MAX) {
0048           std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(*it);
0049           _vhashFEDs.push_back(
0050               HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0051         } else
0052           _vhashFEDs.push_back(HcalElectronicsId(FIBERCH_MIN, FIBER_VME_MIN, SPIGOT_MIN, (*it) - FED_VME_MIN).rawId());
0053       }
0054 
0055       //    get FEDs registered @cDAQ
0056       if (auto runInfoRec = es.tryToGet<RunInfoRcd>()) {
0057         const RunInfo &runInfo = es.getData(runInfoToken_);
0058         std::vector<int> vfeds = runInfo.m_fed_in;
0059         for (std::vector<int>::const_iterator it = vfeds.begin(); it != vfeds.end(); ++it) {
0060           if (*it >= constants::FED_VME_MIN && *it <= FED_VME_MAX)
0061             _vcdaqEids.push_back(
0062                 HcalElectronicsId(constants::FIBERCH_MIN, constants::FIBER_VME_MIN, SPIGOT_MIN, (*it) - FED_VME_MIN)
0063                     .rawId());
0064           else if (*it >= constants::FED_uTCA_MIN && *it <= FEDNumbering::MAXHCALuTCAFEDID) {
0065             std::pair<uint16_t, uint16_t> cspair = utilities::fed2crate(*it);
0066             _vcdaqEids.push_back(
0067                 HcalElectronicsId(cspair.first, cspair.second, FIBER_uTCA_MIN1, FIBERCH_MIN, false).rawId());
0068           }
0069         }
0070       }
0071     } else {
0072       _vCrates = utilities::getCrateList(_emap);
0073       std::map<int, uint32_t> crateHashMap = utilities::getCrateHashMap(_emap);
0074       for (auto &it_crate : _vCrates) {
0075         _vhashCrates.push_back(crateHashMap[it_crate]);
0076       }
0077     }
0078 
0079     // Initialize channel quality masks, but do not load (changed for 10_4_X,
0080     // moving to LS granularity)
0081     _xQuality.initialize(hashfunctions::fDChannel);
0082   }
0083 
0084   void DQClient::beginLuminosityBlock(DQMStore::IBooker &,
0085                                       DQMStore::IGetter &,
0086                                       edm::LuminosityBlock const &lb,
0087                                       edm::EventSetup const &es) {
0088     //  get the Channel Quality masks
0089     _xQuality.reset();
0090     const HcalChannelQuality *cq = &es.getData(hcalChannelQualityToken_);
0091     std::vector<DetId> detids = cq->getAllChannels();
0092     for (std::vector<DetId>::const_iterator it = detids.begin(); it != detids.end(); ++it) {
0093       if (HcalGenericDetId(*it).genericSubdet() == HcalGenericDetId::HcalGenUnknown)
0094         continue;
0095 
0096       if (HcalGenericDetId(*it).isHcalDetId()) {
0097         HcalDetId did(*it);
0098         uint32_t mask = (cq->getValues(did))->getValue();
0099         if (mask != 0)
0100           _xQuality.push(did, mask);
0101       }
0102     }
0103   }
0104 
0105   void DQClient::endLuminosityBlock(DQMStore::IBooker &,
0106                                     DQMStore::IGetter &,
0107                                     edm::LuminosityBlock const &lb,
0108                                     edm::EventSetup const &) {
0109     _currentLS = lb.luminosityBlock();
0110     _totalLS++;
0111     if (_maxProcessedLS < _currentLS)
0112       _maxProcessedLS = _currentLS;
0113   }
0114 
0115   std::vector<flag::Flag> DQClient::endJob(DQMStore::IBooker &, DQMStore::IGetter &) {
0116     return std::vector<flag::Flag>();
0117   }
0118 }  // namespace hcaldqm