00001 #include <DQM/RPCMonitorClient/interface/RPCNoisyStripTest.h>
00002 #include "DQM/RPCMonitorDigi/interface/utils.h"
00003
00004
00005
00006
00007
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009
00010
00011
00012 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
00013
00014
00015 RPCNoisyStripTest::RPCNoisyStripTest(const edm::ParameterSet& ps ){
00016 edm::LogVerbatim ("rpcnoisetest") << "[RPCNoisyStripTest]: Constructor";
00017
00018 prescaleFactor_ = ps.getUntrackedParameter<int>("DiagnosticPrescale", 1);
00019 numberOfDisks_ = ps.getUntrackedParameter<int>("NumberOfEndcapDisks", 3);
00020 numberOfRings_ = ps.getUntrackedParameter<int>("NumberOfEndcapRings", 2);
00021 useRollInfo_ = ps.getUntrackedParameter<bool>("UseRollInfo", false);
00022 testMode_ = ps.getUntrackedParameter<bool>("testMode", false);
00023
00024 }
00025
00026 RPCNoisyStripTest::~RPCNoisyStripTest(){dbe_=0;}
00027
00028 void RPCNoisyStripTest::beginJob(DQMStore * dbe, std::string workingFolder){
00029 edm::LogVerbatim ("rpcnoisetest") << "[RPCNoisyStripTest]: Begin job ";
00030 dbe_ = dbe;
00031
00032 globalFolder_ = workingFolder;
00033 }
00034
00035 void RPCNoisyStripTest::endRun(const edm::Run& r, const edm::EventSetup& iSetup){
00036 edm::LogVerbatim ("rpcnoisetest") << "[RPCNoisyStripTest]: End run";
00037 }
00038
00039
00040 void RPCNoisyStripTest::beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& context){}
00041
00042 void RPCNoisyStripTest::analyze(const edm::Event& iEvent, const edm::EventSetup& c) {}
00043
00044 void RPCNoisyStripTest::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) {}
00045
00046 void RPCNoisyStripTest::clientOperation(edm::EventSetup const& iSetup) {
00047
00048 edm::LogVerbatim ("rpcnoisetest") <<"[RPCNoisyStripTest]: Client Operation";
00049
00050
00051 for (unsigned int i = 0 ; i<myOccupancyMe_.size();i++){
00052 this->fillGlobalME(myDetIds_[i],myOccupancyMe_[i], iSetup);
00053 }
00054
00055 }
00056
00057 void RPCNoisyStripTest::beginRun(const edm::Run& r, const edm::EventSetup& c){
00058
00059
00060 MonitorElement* me;
00061 dbe_->setCurrentFolder( globalFolder_);
00062
00063 std::stringstream histoName;
00064
00065 rpcdqm::utils rpcUtils;
00066
00067 for (int w = -2; w<= 2;w++ ){
00068
00069 if(testMode_){
00070 histoName.str("");
00071 histoName<<"RPCNoisyStrips_Distribution_Wheel"<<w;
00072 me =0;
00073 me = dbe_->get( globalFolder_ +"/"+ histoName.str());
00074 if ( 0!=me ) {
00075 dbe_->removeElement(me->getName());
00076 }
00077 NOISEDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 6, -0.5, 5.5);
00078
00079
00080 histoName.str("");
00081 histoName<<"RPCStripsDeviation_Distribution_Wheel"<<w;
00082 me =0;
00083 me = dbe_->get( globalFolder_ +"/"+ histoName.str());
00084 if ( 0!=me ) {
00085 dbe_->removeElement(me->getName());
00086 }
00087 DEVDWheel[w+2] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 101, -0.01, 10.01);
00088 }
00089
00090 histoName.str("");
00091 histoName<<"RPCNoisyStrips_Roll_vs_Sector_Wheel"<<w;
00092 me =0;
00093 me = dbe_->get( globalFolder_ +"/"+ histoName.str());
00094 if ( 0!=me ) {
00095 dbe_->removeElement(me->getName());
00096 }
00097
00098 NOISEWheel[w+2] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str() , 12, 0.5, 12.5, 21, 0.5, 21.5);
00099 rpcUtils.labelXAxisSector(NOISEWheel[w+2]);
00100 rpcUtils.labelYAxisRoll(NOISEWheel[w+2], 0, w, useRollInfo_);
00101 }
00102
00103
00104
00105 for(int d = -numberOfDisks_; d<=numberOfDisks_; d++ ){
00106
00107 if (d == 0) continue;
00108
00109 int offset = numberOfDisks_;
00110 if (d>0) offset --;
00111
00112 if (testMode_){
00113 histoName.str("");
00114 histoName<<"RPCNoisyStrips_Distribution_Disk"<<d;
00115 me =0;
00116 me = dbe_->get( globalFolder_ +"/"+ histoName.str());
00117 if ( 0!=me ) {
00118 dbe_->removeElement(me->getName());
00119 }
00120 NOISEDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 6, -0.5, 5.5);
00121
00122
00123 histoName.str("");
00124 histoName<<"RPCStripsDeviation_Distribution_Disk"<<d;
00125 me =0;
00126 me = dbe_->get( globalFolder_ +"/"+ histoName.str());
00127 if ( 0!=me ) {
00128 dbe_->removeElement(me->getName());
00129 }
00130 DEVDDisk[d+offset] = dbe_->book1D(histoName.str().c_str(), histoName.str().c_str(), 101, -0.01, 10.01);
00131 }
00132
00133 histoName.str("");
00134 histoName<<"RPCNoisyStrips_Ring_vs_Segment_Disk"<<d;
00135 me =0;
00136 me = dbe_->get( globalFolder_ +"/"+ histoName.str());
00137 if ( 0!=me ) {
00138 dbe_->removeElement(me->getName());
00139 }
00140
00141 NOISEDisk[d+offset] = dbe_->book2D(histoName.str().c_str(), histoName.str().c_str() , 36, 0.5, 36.5, 3*numberOfRings_, 0.5,3*numberOfRings_+ 0.5);
00142 rpcUtils.labelXAxisSegment(NOISEDisk[d+offset]);
00143 rpcUtils.labelYAxisRing(NOISEDisk[d+offset], numberOfRings_, useRollInfo_);
00144
00145 }
00146
00147 }
00148
00149
00150 void RPCNoisyStripTest::getMonitorElements(std::vector<MonitorElement *> & meVector, std::vector<RPCDetId> & detIdVector){
00151
00152
00153 for (unsigned int i = 0 ; i<meVector.size(); i++){
00154
00155 bool flag= false;
00156
00157 DQMNet::TagList tagList;
00158 tagList = meVector[i]->getTags();
00159 DQMNet::TagList::iterator tagItr = tagList.begin();
00160
00161 while (tagItr != tagList.end() && !flag ) {
00162 if((*tagItr) == rpcdqm::OCCUPANCY)
00163 flag= true;
00164
00165 tagItr++;
00166 }
00167
00168 if(flag){
00169 myOccupancyMe_.push_back(meVector[i]);
00170 myDetIds_.push_back(detIdVector[i]);
00171 }
00172 }
00173
00174 }
00175
00176 void RPCNoisyStripTest::endJob(){}
00177
00178 void RPCNoisyStripTest::fillGlobalME(RPCDetId & detId, MonitorElement * myMe,edm::EventSetup const& iSetup){
00179
00180
00181
00182
00183 std::stringstream meName;
00184
00185 MonitorElement * NOISE=NULL;
00186 MonitorElement * DEVD=NULL;
00187 MonitorElement * NOISED=NULL;
00188
00189 if (detId.region()==0) {
00190 NOISE = NOISEWheel[detId.ring()+2];
00191 if(testMode_) {
00192 DEVD = DEVDWheel[detId.ring()+2];
00193 NOISED= NOISEDWheel[detId.ring()+2];
00194 }
00195 }else if(detId.region()<0 && (-detId.station() + numberOfDisks_) >= 0 ){
00196 NOISE = NOISEDisk[ -detId.station() + numberOfDisks_];
00197 if(testMode_) {
00198 DEVD = DEVDDisk[ -detId.station() + numberOfDisks_];
00199 NOISED= NOISEDDisk[-detId.station() + numberOfDisks_];
00200 }
00201 }else if((-detId.station() + numberOfDisks_)>= 0 ){
00202 NOISE = NOISEDisk[detId.station() + numberOfDisks_-1];
00203 if(testMode_) {
00204 DEVD = DEVDDisk[detId.station() + numberOfDisks_-1];
00205 NOISED= NOISEDDisk[detId.station() + numberOfDisks_-1];
00206 }
00207 }
00208
00209
00210 int entries = (int) myMe -> getEntries();
00211 int bins = (int) myMe ->getNbinsX();
00212
00213 std::vector<float> myvector;
00214
00215
00216 for(int xbin =1 ; xbin <= bins ; xbin++) {
00217 float binContent = myMe->getBinContent(xbin);
00218 if (binContent > 0) myvector.push_back(binContent);
00219 }
00220
00221
00222 int noisyStrips=0;
00223
00224 if (myvector.size()>0) {
00225 float ymean = entries/myvector.size();
00226 for(unsigned int i=0; i<myvector.size(); i++) {
00227 float deviation = myvector[i]/ymean;
00228 if(deviation > 3.5) noisyStrips++;
00229 if(deviation > 5) deviation = 5;
00230 if(DEVD) DEVD-> Fill(deviation);
00231 }
00232
00233
00234 int xBin,yBin;
00235 if(detId.region()==0){
00236 xBin= detId.sector();
00237 rpcdqm::utils rollNumber;
00238 yBin = rollNumber.detId2RollNr(detId);
00239 }else{
00240
00241 RPCGeomServ RPCServ(detId);
00242 xBin = RPCServ.segment();
00243 (numberOfRings_ == 3 ? yBin= detId.ring()*3-detId.roll()+1 : yBin= (detId.ring()-1)*3-detId.roll()+1);
00244 }
00245
00246 if(NOISE) NOISE->setBinContent(xBin,yBin,noisyStrips);
00247 if(NOISED) NOISED ->Fill(noisyStrips);
00248
00249 }
00250
00251 }
00252