CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQM/RPCMonitorClient/src/RPCNoisyStripTest.cc

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