Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020 #include "FWCore/ServiceRegistry/interface/Service.h"
00021
00022 #include "DQMServices/Core/interface/DQMStore.h"
00023 #include "DQMServices/Core/interface/MonitorElement.h"
00024
00025 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00026 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00027 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
00028 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00029 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00030 #include "DQM/SiStripCommon/interface/SiStripHistoId.h"
00031
00032
00033 #include <FWCore/Framework/interface/EventSetup.h>
00034 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00035
00036 #include "DQM/SiStripMonitorPedestals/interface/SiStripMonitorQuality.h"
00037
00038
00039 #include <cstdlib>
00040 #include <cmath>
00041 #include <numeric>
00042 #include <algorithm>
00043
00044 SiStripMonitorQuality::SiStripMonitorQuality(edm::ParameterSet const& iConfig):
00045 dqmStore_(edm::Service<DQMStore>().operator->()),
00046 conf_(iConfig),
00047 m_cacheID_(0)
00048
00049
00050 {
00051 edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality "
00052 << " Constructing....... ";
00053 }
00054
00055
00056 SiStripMonitorQuality::~SiStripMonitorQuality()
00057 {
00058 edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality "
00059 << " Destructing....... ";
00060 }
00061
00062
00063
00064 void SiStripMonitorQuality::beginJob() {
00065 }
00066
00067
00068
00069 void SiStripMonitorQuality::beginRun(edm::Run const& run, edm::EventSetup const& eSetup){
00070 }
00071
00072
00073
00074 void SiStripMonitorQuality::analyze(edm::Event const& iEvent, edm::EventSetup const& eSetup)
00075 {
00076 unsigned long long cacheID = eSetup.get<SiStripQualityRcd>().cacheIdentifier();
00077 if (m_cacheID_ == cacheID) return;
00078
00079
00080 edm::ESHandle<TrackerTopology> tTopoHandle;
00081 eSetup.get<IdealGeometryRecord>().get(tTopoHandle);
00082 const TrackerTopology* const tTopo = tTopoHandle.product();
00083
00084 m_cacheID_ = cacheID;
00085
00086 std::string quality_label = conf_.getParameter<std::string>("StripQualityLabel");
00087 eSetup.get<SiStripQualityRcd>().get(quality_label,stripQuality_);
00088 eSetup.get<SiStripDetCablingRcd>().get( detCabling_ );
00089
00090 edm::LogInfo("SiStripMonitorQuality") << "SiStripMonitorQuality::analyze: "<<
00091 " Reading SiStripQuality "<< std::endl;
00092
00093 SiStripBadStrip::RegistryIterator rbegin = stripQuality_->getRegistryVectorBegin();
00094 SiStripBadStrip::RegistryIterator rend = stripQuality_->getRegistryVectorEnd();
00095 uint32_t detid;
00096
00097 if (rbegin==rend) return;
00098
00099 for (SiStripBadStrip::RegistryIterator rp=rbegin; rp != rend; ++rp) {
00100
00101 detid = rp->detid;
00102
00103 if (detid == 0 || detid == 0xFFFFFFFF){
00104 edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::analyze : "
00105 << "Wrong DetId !!!!!! " << detid << " Neglecting !!!!!! ";
00106 continue;
00107 }
00108
00109 if (!detCabling_->IsConnected(detid)) {
00110 edm::LogError("SiStripMonitorQuality") <<"SiStripMonitorQuality::analyze : "
00111 << " DetId " << detid << " not connected, Neglecting !!!!!! ";
00112 continue;
00113 }
00114 MonitorElement* me = getQualityME(detid, tTopo);
00115 SiStripBadStrip::Range range = SiStripBadStrip::Range( stripQuality_->getDataVectorBegin()+rp->ibegin ,
00116 stripQuality_->getDataVectorBegin()+rp->iend );
00117 SiStripBadStrip::ContainerIterator it=range.first;
00118 for(;it!=range.second;++it){
00119 unsigned int value=(*it);
00120 short str_start = stripQuality_->decode(value).firstStrip;
00121 short str_end = str_start + stripQuality_->decode(value).range;
00122 for ( short isr = str_start; isr < str_end + 1; isr++) {
00123 if (isr <= (me->getNbinsX()-1)) me->Fill(isr+1, 1.0);
00124 }
00125 }
00126 }
00127 }
00128
00129
00130
00131 void SiStripMonitorQuality::endRun(edm::Run const& run, edm::EventSetup const& eSetup) {
00132 bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
00133 std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
00134 if (outputMEsInRootFile) {
00135 dqmStore_->showDirStructure();
00136 dqmStore_->save(outputFileName);
00137 }
00138 }
00139
00140
00141
00142 void SiStripMonitorQuality::endJob(void){
00143 edm::LogInfo("SiStripMonitorQuality") <<"SiStripMonitorQuality::EndJob: "
00144 << " Finishing!! ";
00145 }
00146
00147
00148
00149 MonitorElement* SiStripMonitorQuality::getQualityME(uint32_t idet, const TrackerTopology* tTopo){
00150
00151 std::map<uint32_t, MonitorElement* >::iterator pos = QualityMEs.find(idet);
00152 MonitorElement* det_me;
00153 if (pos != QualityMEs.end()) {
00154 det_me = pos->second;
00155 det_me->Reset();
00156 } else {
00157 int nStrip = detCabling_->nApvPairs(idet) * 256;
00158
00159
00160 SiStripHistoId hidmanager;
00161
00162 SiStripFolderOrganizer folder_organizer;
00163
00164 folder_organizer.setDetectorFolder(idet, tTopo);
00165
00166 std::string hid;
00167 hid = hidmanager.createHistoId("StripQualityFromCondDB","det", idet);
00168
00169 det_me = dqmStore_->book1D(hid, hid, nStrip,0.5,nStrip+0.5);
00170 dqmStore_->tag(det_me, idet);
00171 det_me->setAxisTitle("Strip Number",1);
00172 det_me->setAxisTitle("Quality Flag from CondDB ",2);
00173 QualityMEs.insert( std::make_pair(idet, det_me));
00174 }
00175 return det_me;
00176 }
00177 DEFINE_FWK_MODULE(SiStripMonitorQuality);
00178