Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-25 06:38:23

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<HBHEDigiCollection>(_tagHBHE);
0014   _tokHO = consumes<HODigiCollection>(_tagHO);
0015   _tokHF = consumes<HFDigiCollection>(_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;
0064   if (eventType == constants::EVENTTYPE_PEDESTAL) {
0065     orbitGapType = tPedestal;
0066   } else if (eventType == constants::EVENTTYPE_LED) {
0067     orbitGapType = tLED;
0068   } else if (eventType == constants::EVENTTYPE_LASER) {
0069     switch (laserType) {
0070       //case tNull : return "Null";
0071       //case tHFRaddam : return "HFRaddam";
0072       case 3:
0073         return tHBHEHPD;
0074       case 4:
0075         return tHO;
0076       case 5:
0077         return tHF;
0078       //case tZDC : return "ZDC";
0079       case 7:
0080         return tHEPMega;
0081       case 8:
0082         return tHEMMega;
0083       case 9:
0084         return tHBPMega;
0085       case 10:
0086         return tHBMMega;
0087       //case tCRF : return "CRF";
0088       //case tCalib : return "Calib";
0089       //case tSafe : return "Safe";
0090       default:
0091         return tUnknown;
0092     }
0093   }
0094   return (int)(std::find(_eventtypes.begin(), _eventtypes.end(), orbitGapType) - _eventtypes.begin());
0095 }
0096 
0097 /* virtual */ void UMNioTask::_process(edm::Event const& e, edm::EventSetup const& es) {
0098   edm::Handle<HcalUMNioDigi> cumn;
0099   if (!e.getByToken(_tokuMN, cumn))
0100     return;
0101 
0102   uint8_t eventType = cumn->eventType();
0103   uint32_t laserType = cumn->valueUserWord(0);
0104   _cEventType.fill(_currentLS, getOrbitGapIndex(eventType, laserType));
0105 
0106   //    Compute the Total Charge in the Detector...
0107   edm::Handle<HBHEDigiCollection> chbhe;
0108   edm::Handle<HODigiCollection> cho;
0109   edm::Handle<HFDigiCollection> chf;
0110 
0111   if (!e.getByToken(_tokHBHE, chbhe))
0112     _logger.dqmthrow("Collection HBHEDigiCollection isn't available " + _tagHBHE.label() + " " + _tagHBHE.instance());
0113   if (!e.getByToken(_tokHO, cho))
0114     _logger.dqmthrow("Collection HODigiCollection isn't available " + _tagHO.label() + " " + _tagHO.instance());
0115   if (!e.getByToken(_tokHF, chf))
0116     _logger.dqmthrow("Collection HFDigiCollection isn't available " + _tagHF.label() + " " + _tagHF.instance());
0117 
0118   for (HBHEDigiCollection::const_iterator it = chbhe->begin(); it != chbhe->end(); ++it) {
0119     double sumQ = hcaldqm::utilities::sumQ<HBHEDataFrame>(*it, 2.5, 0, it->size() - 1);
0120     _cTotalCharge.fill(it->id(), _currentLS, sumQ);
0121     _cTotalChargeProfile.fill(it->id(), _currentLS, sumQ);
0122   }
0123   for (HODigiCollection::const_iterator it = cho->begin(); it != cho->end(); ++it) {
0124     double sumQ = hcaldqm::utilities::sumQ<HODataFrame>(*it, 8.5, 0, it->size() - 1);
0125     _cTotalCharge.fill(it->id(), _currentLS, sumQ);
0126     _cTotalChargeProfile.fill(it->id(), _currentLS, sumQ);
0127   }
0128   for (HFDigiCollection::const_iterator it = chf->begin(); it != chf->end(); ++it) {
0129     double sumQ = hcaldqm::utilities::sumQ<HFDataFrame>(*it, 2.5, 0, it->size() - 1);
0130     _cTotalCharge.fill(it->id(), _currentLS, sumQ);
0131     _cTotalChargeProfile.fill(it->id(), _currentLS, sumQ);
0132   }
0133 }
0134 /* virtual */ void UMNioTask::globalEndLuminosityBlock(edm::LuminosityBlock const& lb, edm::EventSetup const& es) {
0135   DQTask::globalEndLuminosityBlock(lb, es);
0136 }
0137 
0138 DEFINE_FWK_MODULE(UMNioTask);