CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/EcalBarrelMonitorClient/src/TimingClient.cc

Go to the documentation of this file.
00001 #include "../interface/TimingClient.h"
00002 
00003 #include "DQM/EcalBarrelMonitorTasks/interface/TimingTask.h"
00004 
00005 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
00006 
00007 #include <cmath>
00008 
00009 namespace ecaldqm {
00010 
00011   TimingClient::TimingClient(const edm::ParameterSet& _params, const edm::ParameterSet& _paths) :
00012     DQWorkerClient(_params, _paths, "TimingClient"),
00013     expectedMean_(0.),
00014     meanThreshold_(0.),
00015     rmsThreshold_(0.),
00016     minChannelEntries_(0),
00017     minTowerEntries_(0),
00018     tailPopulThreshold_(0.)
00019   {
00020     edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
00021     expectedMean_ = taskParams.getUntrackedParameter<double>("expectedMean");
00022     meanThreshold_ = taskParams.getUntrackedParameter<double>("meanThreshold");
00023     rmsThreshold_ = taskParams.getUntrackedParameter<double>("rmsThreshold");
00024     minChannelEntries_ = taskParams.getUntrackedParameter<int>("minChannelEntries");
00025     minTowerEntries_ = taskParams.getUntrackedParameter<int>("minTowerEntries");
00026     tailPopulThreshold_ = taskParams.getUntrackedParameter<double>("tailPopulThreshold");
00027 
00028     edm::ParameterSet const& sources(_params.getUntrackedParameterSet("sources"));
00029     source_(sTimeAllMap, "TimingTask", TimingTask::kTimeAllMap, sources);
00030     source_(sTimeMap, "TimingTask", TimingTask::kTimeMap, sources);
00031   }
00032 
00033   void
00034   TimingClient::bookMEs()
00035   {
00036     DQWorker::bookMEs();
00037 
00038     MEs_[kQuality]->resetAll(-1.);
00039     MEs_[kRMS]->resetAll(-1.);
00040     MEs_[kQualitySummary]->resetAll(-1.);
00041   }
00042 
00043   void
00044   TimingClient::producePlots()
00045   {
00046     using namespace std;
00047 
00048     MEs_[kMeanSM]->reset();
00049     MEs_[kMeanAll]->reset();
00050     MEs_[kRMS]->reset(-1.);
00051     MEs_[kRMSAll]->reset();
00052     MEs_[kProjEta]->reset();
00053     MEs_[kProjPhi]->reset();
00054     MEs_[kFwdBkwdDiff]->reset();
00055     MEs_[kFwdvBkwd]->reset();
00056 
00057     uint32_t mask(1 << EcalDQMStatusHelper::PHYSICS_BAD_CHANNEL_WARNING);
00058 
00059     for(unsigned dccid(1); dccid <= 54; dccid++){
00060 
00061       for(unsigned tower(1); tower <= getNSuperCrystals(dccid); tower++){
00062         vector<DetId> ids(getElectronicsMap()->dccTowerConstituents(dccid, tower));
00063 
00064         if(ids.size() == 0) continue;
00065 
00066         // tower entries != sum(channel entries) because of the difference in timing cut at the source
00067         float summaryEntries(0.);
00068         if(dccid <= 9 || dccid >= 46){
00069           vector<EcalScDetId> scids(getElectronicsMap()->getEcalScDetId(dccid, tower));
00070           for(vector<EcalScDetId>::iterator scItr(scids.begin()); scItr != scids.end(); ++scItr)
00071             summaryEntries += sources_[sTimeAllMap]->getBinEntries(*scItr);
00072         }
00073         else
00074           summaryEntries = sources_[sTimeAllMap]->getBinEntries(ids[0]);
00075 
00076         float towerEntries(0.);
00077         float towerMean(0.);
00078         float towerMean2(0.);
00079 
00080         for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
00081           float entries(sources_[sTimeMap]->getBinEntries(*idItr));
00082           float mean(sources_[sTimeMap]->getBinContent(*idItr));
00083           float rms(sources_[sTimeMap]->getBinError(*idItr) * sqrt(entries));
00084 
00085           towerEntries += entries;
00086           towerMean += mean;
00087           towerMean2 += mean * mean;
00088 
00089           if(entries < minChannelEntries_){
00090             fillQuality_(kQuality, *idItr, mask, 2.);
00091             continue;
00092           }
00093 
00094           MEs_[kMeanSM]->fill(*idItr, mean);
00095           MEs_[kMeanAll]->fill(*idItr, mean);
00096           MEs_[kProjEta]->fill(*idItr, mean);
00097           MEs_[kProjPhi]->fill(*idItr, mean);
00098           MEs_[kRMS]->fill(*idItr, rms);
00099           MEs_[kRMSAll]->fill(*idItr, rms);
00100 
00101           if(dccid <= 27){
00102             DetId posId(0);
00103             if(idItr->subdetId() == EcalEndcap){
00104               posId = EEDetId::switchZSide(*idItr);
00105             }
00106             else{
00107               posId = EBDetId::switchZSide(*idItr);
00108             }
00109             float posTime(sources_[sTimeMap]->getBinContent(posId));
00110             MEs_[kFwdBkwdDiff]->fill(*idItr, posTime - mean);
00111             MEs_[kFwdvBkwd]->fill(*idItr, mean, posTime);
00112           }
00113 
00114           float quality(abs(mean - expectedMean_) > meanThreshold_ || rms > rmsThreshold_ ? 0. : 1.);
00115           fillQuality_(kQuality, *idItr, mask, quality);
00116         }
00117 
00118         float quality(1.);
00119         if(towerEntries > minTowerEntries_){
00120           if(summaryEntries < towerEntries * (1. - tailPopulThreshold_)) // large timing deviation
00121             quality = 0.;
00122 
00123           towerMean /= ids.size();
00124           towerMean2 /= ids.size();
00125 
00126           float towerRMS(0.);
00127           float variance(towerMean2 - towerMean * towerMean);
00128           if(variance > 0.) towerRMS = sqrt(variance);
00129 
00130           if(abs(towerMean - expectedMean_) > meanThreshold_ || towerRMS > rmsThreshold_)
00131             quality = 0.;
00132         }
00133         else
00134           quality = 2.;
00135 
00136         if(dccid <= 9 || dccid >= 46){
00137           vector<EcalScDetId> scs(getElectronicsMap()->getEcalScDetId(dccid, tower));
00138           for(vector<EcalScDetId>::iterator scItr(scs.begin()); scItr != scs.end(); ++scItr)
00139             fillQuality_(kQualitySummary, *scItr, mask, quality);
00140         }
00141         else
00142           fillQuality_(kQualitySummary, ids[0], mask, quality);
00143       }
00144     }
00145   }
00146 
00147   /*static*/
00148   void
00149   TimingClient::setMEData(std::vector<MEData>& _data)
00150   {
00151     BinService::AxisSpecs axis;
00152 
00153     _data[kQuality] = MEData("Quality", BinService::kSM, BinService::kCrystal, MonitorElement::DQM_KIND_TH2F);
00154 
00155     axis.nbins = 100;
00156     axis.low = -25.;
00157     axis.high = 25.;
00158     _data[kMeanSM] = MEData("MeanSM", BinService::kSM, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &axis);
00159     _data[kMeanAll] = MEData("MeanAll", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &axis);
00160 
00161     axis.nbins = 50;
00162     _data[kFwdvBkwd] = MEData("FwdvBkwd", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TH2F, &axis, &axis);
00163 
00164     axis.low = -5.;
00165     axis.high = 5.;
00166     _data[kFwdBkwdDiff] = MEData("FwdBkwdDiff", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &axis);
00167 
00168     _data[kRMS] = MEData("RMS", BinService::kSM, BinService::kCrystal, MonitorElement::DQM_KIND_TH2F);
00169 
00170     axis.nbins = 100;
00171     axis.low = 0.;
00172     axis.high = 10.;
00173     _data[kRMSAll] = MEData("RMSAll", BinService::kEcal2P, BinService::kUser, MonitorElement::DQM_KIND_TH1F, &axis);
00174     _data[kProjEta] = MEData("Projection", BinService::kEcal3P, BinService::kProjEta, MonitorElement::DQM_KIND_TPROFILE);
00175     _data[kProjPhi] = MEData("Projection", BinService::kEcal3P, BinService::kProjPhi, MonitorElement::DQM_KIND_TPROFILE);
00176     _data[kQualitySummary] = MEData("QualitySummary", BinService::kEcal2P, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TH2F);
00177   }
00178 
00179   DEFINE_ECALDQM_WORKER(TimingClient);
00180 }