Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/EcalMonitorTasks/interface/IntegrityTask.h"
0002 
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/Utilities/interface/Exception.h"
0005 
0006 namespace ecaldqm {
0007   IntegrityTask::IntegrityTask() : DQWorkerTask() {}
0008 
0009   void IntegrityTask::beginEvent(edm::Event const& _evt,
0010                                  edm::EventSetup const& _es,
0011                                  bool const& ByLumiResetSwitch,
0012                                  bool&) {
0013     if (ByLumiResetSwitch) {
0014       MEs_.at("MapByLumi").reset(GetElectronicsMap());
0015       MEs_.at("ByLumi").reset(GetElectronicsMap());
0016     }
0017   }
0018 
0019   template <typename IDCollection>
0020   void IntegrityTask::runOnDetIdCollection(IDCollection const& _ids, Collections _collection) {
0021     // Collection is empty if there are no errors
0022     if (_ids.empty())
0023       return;
0024 
0025     MESet* set(nullptr);
0026     switch (_collection) {
0027       case kEBGainErrors:
0028       case kEEGainErrors:
0029         set = &MEs_.at("Gain");
0030         break;
0031       case kEBChIdErrors:
0032       case kEEChIdErrors:
0033         set = &MEs_.at("ChId");
0034         break;
0035       case kEBGainSwitchErrors:
0036       case kEEGainSwitchErrors:
0037         set = &MEs_.at("GainSwitch");
0038         break;
0039       default:
0040         return;
0041     }
0042 
0043     MESet& meMapByLumi(MEs_.at("MapByLumi"));
0044     MESet& meByLumi(MEs_.at("ByLumi"));
0045     MESet& meTotal(MEs_.at("Total"));
0046     MESet& meTrendNErrors(MEs_.at("TrendNErrors"));
0047 
0048     std::for_each(_ids.begin(), _ids.end(), [&](typename IDCollection::value_type const& id) {
0049       set->fill(getEcalDQMSetupObjects(), id);
0050       int dccid(dccId(id, GetElectronicsMap()));
0051       meByLumi.fill(getEcalDQMSetupObjects(), dccid);
0052       meTotal.fill(getEcalDQMSetupObjects(), dccid);
0053       // Fill Integrity Errors Map with channel errors for this lumi
0054       meMapByLumi.fill(getEcalDQMSetupObjects(), id);
0055 
0056       meTrendNErrors.fill(getEcalDQMSetupObjects(), double(timestamp_.iLumi), 1.);
0057     });
0058   }
0059 
0060   void IntegrityTask::runOnElectronicsIdCollection(EcalElectronicsIdCollection const& _ids, Collections _collection) {
0061     // Collection is empty if there are no errors
0062     if (_ids.empty())
0063       return;
0064 
0065     MESet* set(nullptr);
0066     switch (_collection) {
0067       case kTowerIdErrors:
0068         set = &MEs_.at("TowerId");
0069         break;
0070       case kBlockSizeErrors:
0071         set = &MEs_.at("BlockSize");
0072         break;
0073       default:
0074         return;
0075     }
0076 
0077     MESet& meMapByLumi(MEs_.at("MapByLumi"));
0078     MESet& meByLumi(MEs_.at("ByLumi"));
0079     MESet& meTotal(MEs_.at("Total"));
0080     MESet& meTrendNErrors(MEs_.at("TrendNErrors"));
0081 
0082     std::for_each(_ids.begin(), _ids.end(), [&](EcalElectronicsIdCollection::value_type const& id) {
0083       set->fill(getEcalDQMSetupObjects(), id);
0084       int dccid(id.dccId());
0085       double nCrystals(0.);
0086       std::vector<DetId> chIds(GetElectronicsMap()->dccTowerConstituents(dccid, id.towerId()));
0087       if (dccid <= kEEmHigh + 1 || dccid >= kEEpLow + 1)
0088         nCrystals = chIds.size();
0089       else
0090         nCrystals = 25.;
0091       meByLumi.fill(getEcalDQMSetupObjects(), dccid, nCrystals);
0092       meTotal.fill(getEcalDQMSetupObjects(), dccid, nCrystals);
0093       // Fill Integrity Errors Map with tower errors for this lumi
0094       // Since binned by crystal for compatibility with channel errors,
0095       // fill with constituent channels of tower
0096       for (std::vector<DetId>::iterator chItr(chIds.begin()); chItr != chIds.end(); ++chItr)
0097         meMapByLumi.fill(getEcalDQMSetupObjects(), *chItr);
0098 
0099       meTrendNErrors.fill(getEcalDQMSetupObjects(), double(timestamp_.iLumi), nCrystals);
0100     });
0101   }
0102 
0103   DEFINE_ECALDQM_WORKER(IntegrityTask);
0104 }  // namespace ecaldqm