Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:42:07

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