00001 #include <sstream>
00002 #include <DQM/RPCMonitorClient/interface/RPCChamberQuality.h>
00003 #include "DQM/RPCMonitorDigi/interface/RPCBookFolderStructure.h"
00004 #include "DQM/RPCMonitorDigi/interface/utils.h"
00005
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007
00008 #include <DataFormats/MuonDetId/interface/RPCDetId.h>
00009
00010 const std::string RPCChamberQuality::xLabels_[7] = {"Good", "OFF", "Nois.St","Nois.Ch","Part.Dead","Dead","Bad.Shape"};
00011 const std::string RPCChamberQuality::regions_[3] = {"EndcapNegative","Barrel","EndcapPositive"};
00012
00013 RPCChamberQuality::RPCChamberQuality(const edm::ParameterSet& ps ){
00014 edm::LogVerbatim ("rpceventsummary") << "[RPCChamberQuality]: Constructor";
00015
00016 prescaleFactor_ = ps.getUntrackedParameter<int>("PrescaleFactor", 5);
00017
00018 std::string subsystemFolder = ps.getUntrackedParameter<std::string>("RPCFolder", "RPC");
00019 std::string recHitTypeFolder = ps.getUntrackedParameter<std::string>("RecHitTypeFolder", "AllHits");
00020 std::string summaryFolder = ps.getUntrackedParameter<std::string>("SummaryFolder", "SummaryHistograms");
00021
00022 summaryDir_ = subsystemFolder +"/"+ recHitTypeFolder +"/"+ summaryFolder ;
00023 prefixDir_ = subsystemFolder +"/"+ recHitTypeFolder ;
00024
00025 enableDQMClients_ = ps.getUntrackedParameter<bool> ("EnableRPCDqmClient",true);
00026
00027 minEvents = ps.getUntrackedParameter<int>("MinimumRPCEvents", 10000);
00028 numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 3);
00029 useRollInfo_ = ps.getUntrackedParameter<bool> ("UseRollInfo",false);
00030 offlineDQM_ = ps.getUntrackedParameter<bool> ("OfflineDQM",true);
00031 }
00032
00033 RPCChamberQuality::~RPCChamberQuality(){
00034 edm::LogVerbatim ("rpceventsummary") << "[RPCChamberQuality]: Destructor ";
00035 if(! enableDQMClients_ ) return;
00036 dbe_=0;
00037 }
00038
00039 void RPCChamberQuality::beginJob(){
00040 edm::LogVerbatim ("rpceventsummary") << "[RPCChamberQuality]: Begin job ";
00041 if(! enableDQMClients_ ) return;
00042 dbe_ = edm::Service<DQMStore>().operator->();
00043 }
00044
00045 void RPCChamberQuality::beginRun(const edm::Run& r, const edm::EventSetup& c){
00046 edm::LogVerbatim ("rpceventsummary") << "[RPCChamberQuality]: Begin run";
00047 if(! enableDQMClients_ ) return;
00048
00049 init_ = false;
00050 lumiCounter_ = prescaleFactor_ ;
00051
00052 MonitorElement* me;
00053 dbe_->setCurrentFolder(summaryDir_);
00054
00055 std::stringstream histoName;
00056
00057 rpcdqm::utils rpcUtils;
00058
00059 for (int r = 0 ; r < 3; r++){
00060
00061 histoName.str("");
00062 histoName<<"RPCChamberQuality_"<<regions_[r];
00063 me = dbe_->get(summaryDir_+"/"+ histoName.str());
00064 if (0!=me) dbe_->removeElement(me->getName());
00065 me = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
00066
00067 for (int x = 1; x <8 ; x++) me->setBinLabel(x, xLabels_[x-1]);
00068 }
00069
00070
00071 histoName.str("");
00072 histoName<<"RPC_System_Quality_Overview";
00073 me = dbe_->get(summaryDir_+"/"+ histoName.str());
00074 if (0!=me) dbe_->removeElement(me->getName());
00075 me = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5, 3, 0.5, 3.5);
00076 me->setBinLabel(1, "E+", 2);
00077 me->setBinLabel(2, "B", 2);
00078 me->setBinLabel(3, "E-", 2);
00079
00080 for (int x = 1; x <8 ; x++) me->setBinLabel(x, xLabels_[x-1]);
00081
00082 for(int w=-2; w<3;w++){
00083
00084 histoName.str("");
00085 histoName<<"RPCChamberQuality_Roll_vs_Sector_Wheel"<<w;
00086 me = dbe_->get(summaryDir_+"/"+ histoName.str());
00087 if (0!=me) dbe_->removeElement(me->getName());
00088 me = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
00089
00090 rpcUtils.labelXAxisSector( me);
00091 rpcUtils.labelYAxisRoll(me, 0, w, useRollInfo_ );
00092
00093 histoName.str("");
00094 histoName<<"RPCChamberQuality_Distribution_Wheel"<<w;
00095 me=0;
00096 me = dbe_->get(summaryDir_+"/"+ histoName.str());
00097 if (0!=me ) dbe_->removeElement(me->getName());
00098 me = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
00099
00100 for (int x = 1; x <8; x++) me->setBinLabel(x, xLabels_[x-1]);
00101 }
00102
00103 for(int d= -numberOfDisks_; d<= numberOfDisks_ ; d++) {
00104 if(d==0) continue;
00105 histoName.str("");
00106 histoName<<"RPCChamberQuality_Ring_vs_Segment_Disk"<<d;
00107 me = 0;
00108 me = dbe_->get(summaryDir_+"/"+ histoName.str());
00109 if (0!=me) {
00110 dbe_->removeElement(me->getName());
00111 }
00112 me = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str(), 36, 0.5, 36.5, 6, 0.5, 6.5);
00113 rpcUtils.labelXAxisSegment(me);
00114 rpcUtils.labelYAxisRing(me, 2, useRollInfo_ );
00115
00116 histoName.str("");
00117 histoName<<"RPCChamberQuality_Distribution_Disk"<<d;
00118 me=0;
00119 me = dbe_->get(summaryDir_+"/"+ histoName.str());
00120 if (0!=me ) dbe_->removeElement(me->getName());
00121 me = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 7, 0.5, 7.5);
00122
00123 for (int x = 1; x <8 ; x++) me->setBinLabel(x, xLabels_[x-1]);
00124 }
00125 }
00126
00127 void RPCChamberQuality::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& context){}
00128
00129 void RPCChamberQuality::analyze(const edm::Event& iEvent, const edm::EventSetup& c) {}
00130
00131 void RPCChamberQuality::endRun(const edm::Run& r, const edm::EventSetup& c) {
00132 edm::LogVerbatim ("rpceventsummary") <<"[RPCChamberQuality]: End Job, performing DQM client operation";
00133 if(! enableDQMClients_ ) return;
00134 this->fillMonitorElements();
00135
00136 }
00137
00138 void RPCChamberQuality::fillMonitorElements() {
00139
00140 std::stringstream meName;
00141
00142 meName.str("");
00143 meName<<prefixDir_<<"/RPCEvents";
00144 int rpcEvents=minEvents;
00145 RpcEvents = dbe_->get(meName.str());
00146
00147 if(RpcEvents) rpcEvents= (int)RpcEvents->getBinContent(1);
00148
00149 if(rpcEvents >= minEvents){
00150
00151 init_ = true;
00152
00153 MonitorElement * summary[3];
00154
00155 for(int r = 0 ; r < 3 ; r++) {
00156 meName.str("");
00157 meName<<summaryDir_<<"/RPCChamberQuality_"<<RPCChamberQuality::regions_[r];
00158 summary[r] = dbe_ -> get(meName.str());
00159
00160 if( summary[r] != 0 ) summary[r]->Reset();
00161 }
00162
00163
00164 for (int wheel=-2; wheel<3; wheel++) {
00165 meName.str("");
00166 meName<<"Roll_vs_Sector_Wheel"<<wheel;
00167
00168 this->performeClientOperation(meName.str(), 0 , summary[1]);
00169 }
00170
00171
00172
00173 for(int i=-3; i<4; i++) {
00174 if(i==0) continue;
00175
00176 meName.str("");
00177 meName<<"Ring_vs_Segment_Disk"<<i;
00178
00179 if(i<0) this->performeClientOperation(meName.str(), -1 , summary[0]);
00180 else this->performeClientOperation(meName.str(), 1 , summary[2]);
00181 }
00182
00183 MonitorElement * RpcOverview = NULL;
00184 meName.str("");
00185 meName<<summaryDir_<<"/RPC_System_Quality_Overview";
00186 RpcOverview = dbe_ -> get(meName.str());
00187 RpcOverview->Reset();
00188
00189 if(RpcOverview) {
00190 for(int r = 0 ; r< 3; r++) {
00191 if (summary[r] == 0 ) continue;
00192 double entries = summary[r]->getEntries();
00193 if(entries == 0) continue;
00194 for (int x = 1; x <= 7; x++) {
00195 RpcOverview->setBinContent(x,r+1,(summary[r]->getBinContent(x)/entries));
00196 }
00197 }
00198 }
00199 }
00200 }
00201
00202 void RPCChamberQuality::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) {
00203
00204 if(!enableDQMClients_ ) return;
00205
00206 if(offlineDQM_) return;
00207
00208 if(!init_ ) {
00209 this->fillMonitorElements();
00210 return;
00211 }
00212
00213 lumiCounter_++;
00214
00215 if (lumiCounter_%prescaleFactor_ != 0) return;
00216
00217 this->fillMonitorElements();
00218
00219
00220 }
00221
00222
00223 void RPCChamberQuality::performeClientOperation(std::string MESufix, int region, MonitorElement * quality){
00224
00225
00226 MonitorElement * RCQ=NULL;
00227 MonitorElement * RCQD=NULL;
00228
00229 MonitorElement * DEAD=NULL;
00230 MonitorElement * CLS=NULL;
00231 MonitorElement * MULT=NULL;
00232 MonitorElement * NoisySt=NULL;
00233 MonitorElement * Chip=NULL;
00234 MonitorElement * HV=NULL;
00235 MonitorElement * LV=NULL;
00236 std::stringstream meName;
00237
00238 meName.str("");
00239 meName<<summaryDir_<<"/RPCChamberQuality_"<<MESufix;
00240 RCQ = dbe_ -> get(meName.str());
00241
00242
00243
00244 int pos = MESufix.find_last_of("_");
00245 meName.str("");
00246 meName<<summaryDir_<<"/RPCChamberQuality_Distribution"<<MESufix.substr(pos);
00247 RCQD = dbe_ -> get(meName.str());
00248 if (RCQD) RCQD->Reset();
00249
00250
00251 meName.str("");
00252 meName<<summaryDir_<<"/HVStatus_"<<MESufix;
00253 HV = dbe_ -> get(meName.str());
00254
00255 meName.str("");
00256 meName<<summaryDir_<<"/LVStatus_"<<MESufix;
00257 LV = dbe_ -> get(meName.str());
00258
00259 meName.str("");
00260 meName << summaryDir_<<"/DeadChannelFraction_"<<MESufix;
00261 DEAD = dbe_->get(meName.str());
00262
00263 meName.str("");
00264 meName<<summaryDir_<<"/ClusterSizeIn1Bin_"<<MESufix;
00265 CLS = dbe_ -> get(meName.str());
00266
00267 meName.str("");
00268 meName<<summaryDir_<<"/RPCNoisyStrips_"<<MESufix;
00269 NoisySt = dbe_ -> get(meName.str());
00270
00271 meName.str("");
00272 meName<<summaryDir_<<"/NumberOfDigi_Mean_"<<MESufix;
00273 MULT = dbe_ -> get(meName.str());
00274
00275 meName.str("");
00276 meName<<summaryDir_<<"/AsymmetryLeftRight_"<<MESufix;
00277 Chip = dbe_ -> get(meName.str());
00278
00279 int xBinMax, yBinMax;
00280
00281 if (region != 0) xBinMax = 37;
00282 else xBinMax = 13;
00283
00284 for(int x=1; x<xBinMax; x++) {
00285 if (region != 0 ) {
00286 yBinMax = 7;
00287 }else {
00288 if(x==4) yBinMax=22;
00289 else if(x==9 || x==11) yBinMax=16;
00290 else yBinMax=18;
00291 }
00292 for(int y=1; y<yBinMax; y++) {
00293 int hv=1;
00294 int lv=1;
00295 float dead =0;
00296 float firstbin= 0;
00297 float noisystrips = 0;
00298 float mult = 0;
00299 float asy = 0;
00300 chamberQualityState chamberState = GoodState;
00301
00302 if(HV) hv = (int)HV ->getBinContent(x,y);
00303 if(LV) lv = (int)LV ->getBinContent(x,y);
00304
00305 if( hv!=1 || lv!=1) {
00306 chamberState = OffState;
00307 }else {
00308 if(DEAD) dead= DEAD -> getBinContent(x,y);
00309 if(dead>=0.80 ) {
00310 chamberState = DeadState;
00311 }else if (0.33<=dead && dead<0.80 ){
00312 chamberState = PartiallyDeadState;
00313 }else {
00314 if(CLS ) firstbin = CLS -> getBinContent(x,y);
00315 if(firstbin >= 0.88) {
00316 chamberState = NoisyStripState;
00317 } else {
00318 if(NoisySt) noisystrips = NoisySt -> getBinContent(x,y);
00319 if (noisystrips > 0){
00320 chamberState = NoisyStripState;
00321 }else {
00322 if(MULT) mult = MULT -> getBinContent(x,y);
00323 if(mult>=6) {
00324 chamberState = NoisyRollState;
00325 }else {
00326 if (Chip) asy = Chip->getBinContent(x,y);
00327 if(asy>0.35) {
00328 chamberState = BadShapeState;
00329 }else {
00330 chamberState = GoodState;
00331 }
00332 }
00333 }
00334 }
00335 }
00336 }
00337 if (RCQ) RCQ -> setBinContent(x,y, chamberState);
00338 if (RCQD) RCQD -> Fill(chamberState);
00339 if (quality) quality->Fill(chamberState);
00340 }
00341 }
00342 return;
00343 }
00344