00001 #include "../interface/PresampleClient.h"
00002
00003 #include "DQM/EcalBarrelMonitorTasks/interface/PresampleTask.h"
00004
00005 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
00006
00007 #include <cmath>
00008
00009 namespace ecaldqm {
00010
00011 PresampleClient::PresampleClient(const edm::ParameterSet& _params, const edm::ParameterSet& _paths) :
00012 DQWorkerClient(_params, _paths, "PresampleClient"),
00013 minChannelEntries_(0),
00014 minTowerEntries_(0),
00015 expectedMean_(0.),
00016 meanThreshold_(0.),
00017 rmsThreshold_(0.),
00018 rmsThresholdHighEta_(0.),
00019 noisyFracThreshold_(0.)
00020 {
00021 edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
00022 minChannelEntries_ = taskParams.getUntrackedParameter<int>("minChannelEntries");
00023 minTowerEntries_ = taskParams.getUntrackedParameter<int>("minTowerEntries");
00024 expectedMean_ = taskParams.getUntrackedParameter<double>("expectedMean");
00025 meanThreshold_ = taskParams.getUntrackedParameter<double>("meanThreshold");
00026 rmsThreshold_ = taskParams.getUntrackedParameter<double>("rmsThreshold");
00027 rmsThresholdHighEta_ = taskParams.getUntrackedParameter<double>("rmsThresholdHighEta");
00028 noisyFracThreshold_ = taskParams.getUntrackedParameter<double>("noisyFracThreshold");
00029
00030 edm::ParameterSet const& sources(_params.getUntrackedParameterSet("sources"));
00031 source_(sPedestal, "PresampleTask", PresampleTask::kPedestal, sources);
00032 }
00033
00034 void
00035 PresampleClient::bookMEs()
00036 {
00037 DQWorker::bookMEs();
00038
00039 MEs_[kQuality]->resetAll(-1.);
00040 MEs_[kRMSMap]->resetAll(-1.);
00041 MEs_[kRMSMapSummary]->resetAll(-1.);
00042 MEs_[kQualitySummary]->resetAll(-1.);
00043 }
00044
00045 void
00046 PresampleClient::producePlots()
00047 {
00048 MEs_[kMean]->reset();
00049 MEs_[kMeanDCC]->reset();
00050 MEs_[kRMS]->reset();
00051 MEs_[kRMSMap]->reset(-1.);
00052 MEs_[kRMSMapSummary]->reset(-1.);
00053
00054 uint32_t mask(1 << EcalDQMStatusHelper::PEDESTAL_ONLINE_HIGH_GAIN_MEAN_ERROR |
00055 1 << EcalDQMStatusHelper::PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR);
00056
00057 for(unsigned dccid(1); dccid <= 54; dccid++){
00058
00059 for(unsigned tower(1); tower <= getNSuperCrystals(dccid); tower++){
00060 std::vector<DetId> ids(getElectronicsMap()->dccTowerConstituents(dccid, tower));
00061
00062 if(ids.size() == 0) continue;
00063
00064 unsigned iSM(dccid - 1);
00065 float rmsThresh(rmsThreshold_);
00066 if(iSM <= kEEmHigh || iSM >= kEEpLow || tower > 48) rmsThresh = rmsThresholdHighEta_;
00067
00068 float nNoisy(0.);
00069 float towerEntries(0.);
00070 float towerMean(0.);
00071 float towerRMS(0.);
00072
00073 for(std::vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
00074 float entries(sources_[sPedestal]->getBinEntries(*idItr));
00075 float mean(sources_[sPedestal]->getBinContent(*idItr));
00076 float rms(sources_[sPedestal]->getBinError(*idItr) * std::sqrt(entries));
00077 towerEntries += entries;
00078 towerMean += mean * entries;
00079 towerRMS += (rms * rms + mean * mean) * entries;
00080
00081 if(entries < minChannelEntries_){
00082 fillQuality_(kQuality, *idItr, mask, 2.);
00083 continue;
00084 }
00085
00086 MEs_[kMean]->fill(*idItr, mean);
00087 MEs_[kMeanDCC]->fill(*idItr, mean);
00088 MEs_[kRMS]->fill(*idItr, rms);
00089 MEs_[kRMSMap]->fill(*idItr, rms);
00090
00091 if(std::abs(mean - expectedMean_) > meanThreshold_ || rms > rmsThresh){
00092 fillQuality_(kQuality, *idItr, mask, 0.);
00093 nNoisy += 1.;
00094 }
00095 else
00096 fillQuality_(kQuality, *idItr, mask, 1.);
00097 }
00098
00099 towerMean /= towerEntries;
00100 towerRMS = std::sqrt(towerRMS / towerEntries - towerMean * towerMean);
00101
00102 float quality(-1.);
00103
00104 if(towerEntries > minTowerEntries_)
00105 quality = nNoisy / ids.size() > noisyFracThreshold_ ? 0. : 1.;
00106 else
00107 quality = 2.;
00108
00109 if(dccid <= 9 || dccid >= 46){
00110 std::vector<EcalScDetId> scs(getElectronicsMap()->getEcalScDetId(dccid, tower));
00111 for(std::vector<EcalScDetId>::iterator scItr(scs.begin()); scItr != scs.end(); ++scItr){
00112 fillQuality_(kQualitySummary, *scItr, mask, quality);
00113 MEs_[kRMSMapSummary]->setBinContent(*scItr, towerRMS);
00114 }
00115 }
00116 else{
00117 fillQuality_(kQualitySummary, ids[0], mask, quality);
00118 MEs_[kRMSMapSummary]->setBinContent(ids[0], towerRMS);
00119 }
00120 }
00121 }
00122 }
00123
00124
00125 void
00126 PresampleClient::setMEData(std::vector<MEData>& _data)
00127 {
00128 BinService::AxisSpecs axis;
00129
00130 _data[kQuality] = MEData("Quality", BinService::kSM, BinService::kCrystal, MonitorElement::DQM_KIND_TH2F);
00131
00132 axis.nbins = 120;
00133 axis.low = 170.;
00134 axis.high = 230.;
00135 _data[kMean] = MEData("Mean", BinService::kSM, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &axis);
00136 _data[kMeanDCC] = MEData("MeanDCC", BinService::kEcal2P, BinService::kDCC, MonitorElement::DQM_KIND_TPROFILE, 0, &axis);
00137
00138 axis.nbins = 100;
00139 axis.low = 0.;
00140 axis.high = 10.;
00141 _data[kRMS] = MEData("RMS", BinService::kSM, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &axis);
00142 _data[kRMSMap] = MEData("RMSMap", BinService::kSM, BinService::kCrystal, MonitorElement::DQM_KIND_TH2F, 0, 0, &axis);
00143 _data[kRMSMapSummary] = MEData("RMSMap", BinService::kEcal2P, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TH2F, 0, 0, &axis);
00144
00145 _data[kQualitySummary] = MEData("QualitySummary", BinService::kEcal2P, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TH2F);
00146 }
00147
00148 DEFINE_ECALDQM_WORKER(PresampleClient);
00149 }
00150