CMS 3D CMS Logo

RPCDeadChannelTest.cc

Go to the documentation of this file.
00001 /*
00002  *  \author Anna Cimmino
00003  */
00004 #include "DQM/RPCMonitorDigi/interface/utils.h"
00005 #include <DQM/RPCMonitorClient/interface/RPCDeadChannelTest.h>
00006 #include "DQM/RPCMonitorDigi/interface/RPCBookFolderStructure.h"
00007 // Framework
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 
00010 //DataFormats
00011 #include <DataFormats/MuonDetId/interface/RPCDetId.h>
00012 #include "DataFormats/RPCDigi/interface/RPCDigi.h"
00013 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
00014 
00015 // Geometry
00016 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
00017 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00018 
00019 #include <map>
00020 #include <sstream>
00021 //#include <math.h>
00022 
00023 using namespace edm;
00024 using namespace std;
00025 
00026 RPCDeadChannelTest::RPCDeadChannelTest(const ParameterSet& ps ){
00027  
00028   LogVerbatim ("deadChannel") << "[RPCDeadChannelTest]: Constructor";
00029 
00030   globalFolder_ = ps.getUntrackedParameter<string>("GlobalFolder", "SummaryHistograms");
00031   prescaleFactor_ = ps.getUntrackedParameter<int>("diagnosticPrescale", 1);
00032   prefixDir_= ps.getUntrackedParameter<string>("GlobalFolder", "RPC/RecHits");
00033 }
00034 
00035 RPCDeadChannelTest::~RPCDeadChannelTest(){
00036   dbe_ = 0;
00037 }
00038 
00039 void RPCDeadChannelTest::beginJob(const EventSetup& iSetup){
00040 
00041  LogVerbatim ("deadChannel") << "[RPCDeadChannelTest]: Begin job";
00042  dbe_ = Service<DQMStore>().operator->();
00043  dbe_->setVerbose(0);
00044 }
00045 
00046 void RPCDeadChannelTest::beginRun(const Run& r, const EventSetup& iSetup){
00047 
00048  edm::LogVerbatim ("deadChannel") << "[RPCDeadChannelTest]: Begin run";
00049 
00050  MonitorElement* me;
00051  dbe_->setCurrentFolder( prefixDir_+"/"+globalFolder_);
00052  
00053  stringstream histoName, histoTitle;
00054 
00055  for (int i = -4; i<=4;i++ ){
00056    if (i>-3 && i<3){//wheels
00057      histoName.str("");
00058      histoName<<"DeadChannels_Wheel"<<i;
00059      histoTitle.str("");
00060      histoTitle<<"DeadChannels for Wheel "<<i;
00061      if ( me = dbe_->get(prefixDir_+"/"+globalFolder_ +"/"+ histoName.str()) ) {
00062        dbe_->removeElement(me->getName());
00063      }
00064   
00065      me = dbe_->book2D(histoName.str().c_str(), histoTitle.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
00066      for(int bin =1; bin<13;bin++) {
00067        histoName.str("");
00068        histoName<<"Sec"<<bin;
00069        me->setBinLabel(bin,histoName.str().c_str(),1);
00070      }
00071      histoName.str("");
00072      histoName<<"ClusterSize_vs_AliveStrips_Wheel"<<i;
00073      histoTitle.str("");
00074      histoTitle<<"ClusterSize vs AliveStrips Wheel "<<i;
00075      if ( me = dbe_->get(prefixDir_+"/"+globalFolder_ +"/"+ histoName.str()) ) {
00076        dbe_->removeElement(me->getName());
00077      }
00078      
00079      me = dbe_->book2D(histoName.str().c_str(), histoTitle.str().c_str(), 12, 0.5, 12.5, 21, 0.5, 21.5);
00080 
00081 
00082      for(int bin =1; bin<13;bin++) {
00083        histoName.str("");
00084        histoName<<"Sec"<<bin;
00085        me->setBinLabel(bin,histoName.str().c_str(),1);
00086      }
00087    }//end wheels
00088 
00089 
00090    histoName.str("");
00091    histoName<<"DeadChannels_Disk"<<i;
00092    histoTitle.str("");
00093    histoTitle<<"DeadChannels for Disk "<<i;
00094    if ( me = dbe_->get(prefixDir_+"/"+globalFolder_ +"/"+ histoName.str()) ) {
00095      dbe_->removeElement(me->getName());
00096    }
00097    me = dbe_->book2D(histoName.str().c_str(), histoTitle.str().c_str(), 6, 0.5, 6.5, 54, 0.5, 54.5);
00098    
00099    for(int bin =1; bin<7;bin++) {
00100      histoName.str("");
00101      histoName<<"Sec"<<bin;
00102      me->setBinLabel(bin,histoName.str().c_str(),1);
00103    }
00104 
00105    histoName.str("");
00106    histoName<<"ClusterSize_vs_AliveStrips_Disk"<<i;
00107    histoTitle.str("");
00108    histoTitle<<"ClusterSize vs AliveStrips Disk "<<i;
00109    if ( me = dbe_->get(prefixDir_+"/"+globalFolder_ +"/"+ histoName.str()) ) {
00110      dbe_->removeElement(me->getName());
00111    }
00112 
00113    me = dbe_->book2D(histoName.str().c_str(), histoTitle.str().c_str(), 6, 0.5, 6.5, 54, 0.5, 54.5);
00114  
00115    
00116    for(int bin =1; bin<7;bin++) {
00117      histoName.str("");
00118      histoName<<"Sec"<<bin;
00119      me->setBinLabel(bin,histoName.str().c_str(),1);
00120    }
00121  }
00122  
00123  histoName.str("");
00124  histoName<<"DeadChannelPercentageBarrel";
00125  if ( me = dbe_->get(prefixDir_+"/"+globalFolder_ +"/"+ histoName.str()) ) {
00126        dbe_->removeElement(me->getName());
00127  }
00128  me = dbe_->book2D(histoName.str().c_str(), "Dead Channel Fraction in Barrel", 12, 0.5, 12.5, 5, -2.5, 2.5);
00129 
00130  for(int xbin =1; xbin<13; xbin++) {
00131    histoName.str("");
00132    histoName<<"Sec"<<xbin;
00133    me->setBinLabel(xbin,histoName.str().c_str(),1);
00134  }
00135  for(int ybin =1; ybin<5; ybin++) {
00136    histoName.str("");
00137    histoName<<"Wheel"<<(ybin-3);
00138    me->setBinLabel(ybin,histoName.str().c_str(),2);
00139  }
00140  
00141  histoName.str("");
00142  histoName<<"DeadChannelPercentageEndcapPositive";
00143  if ( me = dbe_->get(prefixDir_+"/"+globalFolder_ +"/"+ histoName.str()) ) {
00144    dbe_->removeElement(me->getName());
00145  }
00146  me = dbe_->book2D(histoName.str().c_str(), "Dead Channel Fraction in Endcap+", 6, 0.5, 6.5, 4, -2, 2);
00147 
00148  for(int xbin =1; xbin<7; xbin++) {
00149    histoName.str("");
00150    histoName<<"Sec"<< xbin;
00151    me->setBinLabel( xbin,histoName.str().c_str(),1);
00152  }
00153  for(int ybin =1; ybin<5; ybin++) {
00154    histoName.str("");
00155    histoName<<"Disk"<<ybin;
00156    me->setBinLabel(ybin,histoName.str().c_str(),2);
00157  }
00158  
00159  histoName.str("");
00160  histoName<<"DeadChannelPercentageEndcapNegative";
00161  if ( me = dbe_->get(prefixDir_+"/"+globalFolder_ +"/"+ histoName.str()) ) {
00162    dbe_->removeElement(me->getName());
00163  }
00164  me = dbe_->book2D(histoName.str().c_str(), "Dead Channel Fraction in Endcap-", 6, 0.5, 6.5,4, -2, 2); 
00165 
00166  for(int xbin =1; xbin<7; xbin++) {
00167    histoName.str("");
00168    histoName<<"Sec"<< xbin;
00169    me->setBinLabel( xbin,histoName.str().c_str(),1);
00170  }
00171  for(int ybin =1; ybin<5; ybin++) {
00172    histoName.str("");
00173    histoName<<"Disk-"<<ybin;
00174    me->setBinLabel(ybin,histoName.str().c_str(),2);
00175  } 
00176 
00177 }
00178 
00179 void RPCDeadChannelTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {}
00180 
00181 //called at each event
00182 void RPCDeadChannelTest::analyze(const edm::Event& iEvent, const edm::EventSetup& c){}
00183 
00184 
00185 void RPCDeadChannelTest::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& iSetup) {
00186  
00187   edm::LogVerbatim ("deadChannel") <<"[RPCDeadChannelTest]: End of LS transition, performing the DQM client operation";
00188   
00189   // counts number of lumiSegs 
00190   int nLumiSegs = lumiSeg.id().luminosityBlock();
00191     
00192   //check some statements and prescale Factor
00193   if(nLumiSegs%prescaleFactor_ == 0) {
00194  
00195     ESHandle<RPCGeometry> rpcGeo;
00196     iSetup.get<MuonGeometryRecord>().get(rpcGeo);
00197  
00198     map<int, map< int ,  pair<float,float> > >  barrelMap, endcapMap;
00199     stringstream meName;
00200     //Loop on chambers
00201     for (TrackingGeometry::DetContainer::const_iterator it=rpcGeo->dets().begin();it<rpcGeo->dets().end();it++){
00202       if( dynamic_cast< RPCChamber* >( *it ) != 0 ){
00203         RPCChamber* ch = dynamic_cast< RPCChamber* >( *it ); 
00204        std::vector< const RPCRoll*> roles = (ch->rolls());
00205        //Loop on rolls in given chamber
00206        for(std::vector<const RPCRoll*>::const_iterator r = roles.begin();r != roles.end(); ++r){
00207          RPCDetId detId = (*r)->id();
00208          //Get Occupancy ME for roll
00209          RPCGeomServ RPCname(detId);       
00210 
00211          RPCBookFolderStructure *  folderStr = new RPCBookFolderStructure();
00212          MonitorElement * myMe = dbe_->get(prefixDir_+"/"+ folderStr->folderStructure(detId)+"/Occupancy_"+RPCname.name()); 
00213          if (!myMe)continue;
00214         
00215          MonitorElement * myGlobalMe;
00216         MonitorElement * myGlobalMe2;
00217 
00218          const QReport * theOccupancyQReport = myMe->getQReport("DeadChannel_0");  
00219          if(!theOccupancyQReport) continue;
00220 
00221          vector<dqm::me_util::Channel> badChannels = theOccupancyQReport->getBadChannels();
00222         
00223          if (detId.region()==0) {
00224            barrelMap[detId.ring()][detId.sector()].first += badChannels.size();
00225            barrelMap[detId.ring()][detId.sector()].second += (*r)->nstrips() ;
00226            meName.str("");
00227            meName<<prefixDir_+"/"+ globalFolder_+"/DeadChannels_Wheel"<<detId.ring();
00228          }else{
00229            endcapMap[detId.region()*detId.station()][detId.sector()].first +=  badChannels.size();
00230            endcapMap[detId.region()*detId.station()][detId.sector()].second+=(*r)->nstrips() ;
00231            meName.str("");
00232            meName<<prefixDir_+"/"+ globalFolder_+"/DeadChannels_Disk"<<detId.region()*detId.station();
00233          }
00234          myGlobalMe = dbe_->get(meName.str());
00235          if (!myGlobalMe)continue;
00236          rpcdqm::utils prova;
00237          int nr = prova.detId2RollNr(detId);
00238          myGlobalMe->setBinContent(detId.sector(),nr, badChannels.size()*100/(*r)->nstrips() );
00239 
00240          string Yaxis=RPCname.name();
00241          if (detId.region()==0){
00242            Yaxis.erase (1,1);
00243            Yaxis.erase(0,3);
00244            Yaxis.replace(Yaxis.find("S"),4,"");
00245            Yaxis.erase(Yaxis.find("_")+2,8);
00246          }else{
00247            Yaxis.erase(0,8);
00248          }
00249 
00250          myGlobalMe->setBinLabel(nr, Yaxis, 2);
00251          if (detId.region()==0){
00252            meName.str("");
00253            meName<<prefixDir_+"/"+ globalFolder_+"/ClusterSize_vs_AliveStrips_Wheel"<<detId.ring();
00254            myGlobalMe = dbe_->get(meName.str());
00255            meName.str("");
00256            meName<<prefixDir_+"/"+ globalFolder_+"/ClusterSize_meanValue_Wheel_"<<detId.ring();
00257            myGlobalMe2 = dbe_->get(meName.str());
00258 
00259            if(badChannels.size()!=(*r)->nstrips() )
00260              myGlobalMe->setBinContent(detId.sector(),nr, (myGlobalMe2->getBinContent(detId.sector(),nr))/((*r)->nstrips()-badChannels.size()) );
00261            else 
00262              myGlobalMe->setBinContent(detId.sector(),nr, 100 ); 
00263          }
00264 
00265          myGlobalMe->setBinLabel(nr, Yaxis, 2);
00266        }//End loop on rolls in given chambers
00267     }
00268   }//End loop on chamber
00269 
00270   this->fillDeadChannelHisto(barrelMap, 0);
00271   
00272   this->fillDeadChannelHisto(endcapMap, 1);
00273   }
00274 }
00275  
00276 void RPCDeadChannelTest::endRun(const Run& r, const EventSetup& c){}
00277 
00278 void RPCDeadChannelTest::endJob(){}
00279 
00280 //Fill report summary
00281 void  RPCDeadChannelTest::fillDeadChannelHisto(const map<int,map<int,pair<float,float> > > & sumMap, int region){
00282 
00283   MonitorElement *   regionME=NULL;
00284 
00285   map<int,map<int,pair<float,float> > >::const_iterator itr;
00286  
00287   if (sumMap.size()!=0){
00288     for (itr=sumMap.begin(); itr!=sumMap.end(); itr++){
00289       for (map< int ,  pair<float,float> >::const_iterator meItr = (*itr).second.begin(); meItr!=(*itr).second.end();meItr++){
00290           if (region==0){
00291             regionME = dbe_->get(prefixDir_+"/"+globalFolder_ +"/DeadChannelPercentageBarrel");
00292             regionME->setBinContent((*meItr).first, (*itr).first + 3,(*meItr).second.first/(*meItr).second.second );
00293           }else {
00294             regionME = dbe_->get(prefixDir_+"/"+globalFolder_ +"/DeadChannelPercentageEndcapPositive");  
00295             regionME->setBinContent((*meItr).first, (*itr).first ,(*meItr).second.first/(*meItr).second.second );
00296 
00297             regionME = dbe_->get(prefixDir_+"/"+globalFolder_ +"/DeadChannelPercentageEndcapNegative");  
00298             regionME->setBinContent((*meItr).first, (-1*(*itr).first ),(*meItr).second.first/(*meItr).second.second );
00299           }
00300       }    
00301     }
00302   }
00303 }

Generated on Tue Jun 9 17:33:17 2009 for CMSSW by  doxygen 1.5.4