Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 
0002 #include "DQM/HcalTasks/interface/UMNioTask.h"
0003 
0004 using namespace hcaldqm;
0005 using namespace hcaldqm::constants;
0006 UMNioTask::UMNioTask(edm::ParameterSet const& ps)
0007     : DQTask(ps), hcalDbServiceToken_(esConsumes<HcalDbService, HcalDbRecord, edm::Transition::BeginRun>()) {
0008   tagHBHE_ = ps.getUntrackedParameter<edm::InputTag>("tagHBHE", edm::InputTag("hcalDigis"));
0009   tagHO_ = ps.getUntrackedParameter<edm::InputTag>("tagHO", edm::InputTag("hcalDigis"));
0010   tagHF_ = ps.getUntrackedParameter<edm::InputTag>("tagHF", edm::InputTag("hcalDigis"));
0011   taguMN_ = ps.getUntrackedParameter<edm::InputTag>("taguMN", edm::InputTag("hcalDigis"));
0012 
0013   tokHBHE_ = consumes<QIE11DigiCollection>(tagHBHE_);
0014   tokHO_ = consumes<HODigiCollection>(tagHO_);
0015   tokHF_ = consumes<QIE10DigiCollection>(tagHF_);
0016   tokuMN_ = consumes<HcalUMNioDigi>(taguMN_);
0017 
0018   lowHBHE_ = ps.getUntrackedParameter<double>("lowHBHE", 20);
0019   lowHO_ = ps.getUntrackedParameter<double>("lowHO", 20);
0020   lowHF_ = ps.getUntrackedParameter<double>("lowHF", 20);
0021 
0022   //    push all the event types to monitor - whole range basically
0023   //    This corresponds to all enum values in hcaldqm::constants::OrbitGapType
0024   for (uint32_t type = constants::tNull; type < constants::nOrbitGapType; type++) {
0025     _eventtypes.push_back(type);
0026   }
0027 }
0028 
0029 /* virtual */ void UMNioTask::bookHistograms(DQMStore::IBooker& ib, edm::Run const& r, edm::EventSetup const& es) {
0030   if (_ptype == fLocal)
0031     if (r.runAuxiliary().run() == 1)
0032       return;
0033 
0034   DQTask::bookHistograms(ib, r, es);
0035 
0036   edm::ESHandle<HcalDbService> dbService = es.getHandle(hcalDbServiceToken_);
0037   _emap = dbService->getHcalMapping();
0038 
0039   _cEventType.initialize(_name,
0040                          "EventType",
0041                          new hcaldqm::quantity::LumiSection(_maxLS),
0042                          new hcaldqm::quantity::EventType(_eventtypes),
0043                          new hcaldqm::quantity::ValueQuantity(hcaldqm::quantity::fN),
0044                          0);
0045   _cTotalCharge.initialize(_name,
0046                            "TotalCharge",
0047                            new hcaldqm::quantity::LumiSection(_maxLS),
0048                            new hcaldqm::quantity::DetectorQuantity(quantity::fSubdetPM),
0049                            new hcaldqm::quantity::ValueQuantity(quantity::ffC_10000, true),
0050                            0);
0051   _cTotalChargeProfile.initialize(_name,
0052                                   "TotalChargeProfile",
0053                                   new hcaldqm::quantity::LumiSection(_maxLS),
0054                                   new hcaldqm::quantity::DetectorQuantity(quantity::fSubdetPM),
0055                                   new hcaldqm::quantity::ValueQuantity(quantity::ffC_10000, true),
0056                                   0);
0057   _cEventType.book(ib, _subsystem);
0058   _cTotalCharge.book(ib, _subsystem);
0059   _cTotalChargeProfile.book(ib, _subsystem);
0060 }
0061 
0062 int UMNioTask::getOrbitGapIndex(uint8_t eventType, uint32_t laserType) {
0063   constants::OrbitGapType orbitGapType = tNull;
0064   if (eventType == constants::EVENTTYPE_PHYSICS) {
0065     orbitGapType = tPhysics;
0066   } else if (eventType == constants::EVENTTYPE_PEDESTAL) {
0067     orbitGapType = tPedestal;
0068   } else if (eventType == constants::EVENTTYPE_LED) {
0069     orbitGapType = tLED;
0070   } else if (eventType == constants::EVENTTYPE_HFRADDAM) {
0071     orbitGapType = tHFRaddam;
0072   } else if (eventType == constants::EVENTTYPE_LASER) {
0073     switch (laserType) {
0074       //case tNull : return "Null";
0075       //case tHFRaddam : return "HFRaddam";
0076       case 3:
0077         return tHBHEHPD;
0078       case 4:
0079         return tHO;
0080       case 5:
0081         return tHF;
0082       //case tZDC : return "ZDC";
0083       case 7:
0084         return tHEPMega;
0085       case 8:
0086         return tHEMMega;
0087       case 9:
0088         return tHBPMega;
0089       case 10:
0090         return tHBMMega;
0091       //case tCRF : return "CRF";
0092       //case tCalib : return "Calib";
0093       case 14:
0094         return tSafe;
0095       case 23:
0096         return tSiPMPMT;
0097       case 24:
0098         return tMegatile;
0099       default:
0100         return tUnknown;
0101     }
0102   }
0103   return (int)(std::find(_eventtypes.begin(), _eventtypes.end(), orbitGapType) - _eventtypes.begin());
0104 }
0105 
0106 /* virtual */ void UMNioTask::_process(edm::Event const& e, edm::EventSetup const& es) {
0107   auto lumiCache = luminosityBlockCache(e.getLuminosityBlock().index());
0108   _currentLS = lumiCache->currentLS;
0109   _xQuality.reset();
0110   _xQuality = lumiCache->xQuality;
0111 
0112   auto const cumn = e.getHandle(tokuMN_);
0113   if (not(cumn.isValid())) {
0114     edm::LogWarning("UMNioTask") << "HcalUMNioDigi isn't available, calling return";
0115     return;
0116   }
0117 
0118   uint8_t eventType = cumn->eventType();
0119   uint32_t laserType = cumn->valueUserWord(0);
0120   _cEventType.fill(_currentLS, getOrbitGapIndex(eventType, laserType));
0121 
0122   //    Compute the Total Charge in the Detector...
0123   auto const chbhe = e.getHandle(tokHBHE_);
0124   if (chbhe.isValid()) {
0125     for (QIE11DigiCollection::const_iterator it = chbhe->begin(); it != chbhe->end(); ++it) {
0126       const QIE11DataFrame digi = static_cast<const QIE11DataFrame>(*it);
0127       HcalDetId const& did = digi.detid();
0128       if ((did.subdet() != HcalBarrel) && (did.subdet() != HcalEndcap))
0129         continue;
0130       if (_xQuality.exists(did)) {
0131         HcalChannelStatus cs(did.rawId(), _xQuality.get(did));
0132         if (cs.isBitSet(HcalChannelStatus::HcalCellMask) || cs.isBitSet(HcalChannelStatus::HcalCellDead))
0133           continue;
0134       }
0135       CaloSamples digi_fC = hcaldqm::utilities::loadADC2fCDB<QIE11DataFrame>(_dbService, did, digi);
0136       double sumQ = hcaldqm::utilities::sumQDB<QIE11DataFrame>(_dbService, digi_fC, did, digi, 0, digi.samples() - 1);
0137       _cTotalCharge.fill(did, _currentLS, sumQ);
0138       _cTotalChargeProfile.fill(did, _currentLS, sumQ);
0139     }
0140   }
0141   auto const cho = e.getHandle(tokHO_);
0142   if (cho.isValid()) {
0143     for (HODigiCollection::const_iterator it = cho->begin(); it != cho->end(); ++it) {
0144       const HODataFrame digi = (const HODataFrame)(*it);
0145       HcalDetId did = digi.id();
0146       if (did.subdet() != HcalOuter)
0147         continue;
0148       if (_xQuality.exists(did)) {
0149         HcalChannelStatus cs(did.rawId(), _xQuality.get(did));
0150         if (cs.isBitSet(HcalChannelStatus::HcalCellMask) || cs.isBitSet(HcalChannelStatus::HcalCellDead))
0151           continue;
0152       }
0153       CaloSamples digi_fC = hcaldqm::utilities::loadADC2fCDB<HODataFrame>(_dbService, did, digi);
0154       double sumQ = hcaldqm::utilities::sumQDB<HODataFrame>(_dbService, digi_fC, did, digi, 0, digi.size() - 1);
0155       _cTotalCharge.fill(did, _currentLS, sumQ);
0156       _cTotalChargeProfile.fill(did, _currentLS, sumQ);
0157     }
0158   }
0159   auto const chf = e.getHandle(tokHF_);
0160   if (chf.isValid()) {
0161     for (QIE10DigiCollection::const_iterator it = chf->begin(); it != chf->end(); ++it) {
0162       const QIE10DataFrame digi = static_cast<const QIE10DataFrame>(*it);
0163       HcalDetId did = digi.detid();
0164       if (did.subdet() != HcalForward)
0165         continue;
0166       if (_xQuality.exists(did)) {
0167         HcalChannelStatus cs(did.rawId(), _xQuality.get(did));
0168         if (cs.isBitSet(HcalChannelStatus::HcalCellMask) || cs.isBitSet(HcalChannelStatus::HcalCellDead))
0169           continue;
0170       }
0171       CaloSamples digi_fC = hcaldqm::utilities::loadADC2fCDB<QIE10DataFrame>(_dbService, did, digi);
0172       double sumQ = hcaldqm::utilities::sumQDB<QIE10DataFrame>(_dbService, digi_fC, did, digi, 0, digi.samples() - 1);
0173       _cTotalCharge.fill(did, _currentLS, sumQ);
0174       _cTotalChargeProfile.fill(did, _currentLS, sumQ);
0175     }
0176   }
0177 }
0178 
0179 std::shared_ptr<hcaldqm::Cache> UMNioTask::globalBeginLuminosityBlock(edm::LuminosityBlock const& lb,
0180                                                                       edm::EventSetup const& es) const {
0181   return DQTask::globalBeginLuminosityBlock(lb, es);
0182 }
0183 
0184 /* virtual */ void UMNioTask::globalEndLuminosityBlock(edm::LuminosityBlock const& lb, edm::EventSetup const& es) {
0185   DQTask::globalEndLuminosityBlock(lb, es);
0186 }
0187 
0188 DEFINE_FWK_MODULE(UMNioTask);