CMS 3D CMS Logo

DTNoiseAnalysisTest.cc

Go to the documentation of this file.
00001 
00002 
00003 /*
00004  *  See header file for a description of this class.
00005  *
00006  *  $Date: 2008/11/03 14:21:43 $
00007  *  $Revision: 1.9 $
00008  *  \author G. Mila - INFN Torino
00009  */
00010 
00011 
00012 #include <DQM/DTMonitorClient/src/DTNoiseAnalysisTest.h>
00013 
00014 // Framework
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include <FWCore/Framework/interface/EventSetup.h>
00017 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00018 
00019 
00020 // Geometry
00021 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00022 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00023 #include "Geometry/DTGeometry/interface/DTLayer.h"
00024 #include "Geometry/DTGeometry/interface/DTTopology.h"
00025 #include <DataFormats/MuonDetId/interface/DTLayerId.h>
00026 
00027 #include "DQMServices/Core/interface/DQMStore.h"
00028 #include "DQMServices/Core/interface/MonitorElement.h"
00029 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00030 
00031 #include <iostream>
00032 #include <sstream>
00033 
00034 
00035 
00036 using namespace edm;
00037 using namespace std;
00038 
00039 
00040 DTNoiseAnalysisTest::DTNoiseAnalysisTest(const edm::ParameterSet& ps){
00041   LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "[DTNoiseAnalysisTest]: Constructor";
00042 
00043   dbe = edm::Service<DQMStore>().operator->();
00044 
00045   // get the cfi parameters
00046   noisyCellDef = ps.getUntrackedParameter<int>("noisyCellDef",500);
00047 
00048   // switch on/off the summaries for the Synchronous noise
00049   doSynchNoise = ps.getUntrackedParameter<bool>("doSynchNoise", false);
00050   maxSynchNoiseRate =  ps.getUntrackedParameter<double>("maxSynchNoiseRate", 0.001);
00051 
00052 }
00053 
00054 
00055 DTNoiseAnalysisTest::~DTNoiseAnalysisTest(){
00056   LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "DTNoiseAnalysisTest: analyzed " << nevents << " events";
00057 }
00058 
00059 
00060 void DTNoiseAnalysisTest::beginJob(const edm::EventSetup& context){
00061   LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") <<"[DTNoiseAnalysisTest]: BeginJob"; 
00062 
00063   nevents = 0;
00064   // Get the geometry
00065   context.get<MuonGeometryRecord>().get(muonGeom);
00066 
00067   // book the histos
00068   bookHistos();  
00069 
00070 }
00071 
00072 
00073 void DTNoiseAnalysisTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00074 
00075   LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") <<"[DTNoiseAnalysisTest]: Begin of LS transition";
00076 }
00077 
00078 
00079 void DTNoiseAnalysisTest::analyze(const edm::Event& e, const edm::EventSetup& context){
00080 
00081   nevents++;
00082   if(nevents%1000 == 0) LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00083     << "[DTNoiseAnalysisTest]: "<<nevents<<" events";
00084 
00085 }
00086 
00087 void DTNoiseAnalysisTest::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00088   LogVerbatim ("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00089     <<"[DTNoiseAnalysisTest]: End of LS transition, performing the DQM client operation";
00090 
00091   // Reset the summary plots
00092   for(map<int, MonitorElement* >::iterator plot =  noiseHistos.begin();
00093       plot != noiseHistos.end(); ++plot) {
00094     (*plot).second->Reset();
00095   }
00096   
00097   for(map<int,  MonitorElement* >::iterator plot = noisyCellHistos.begin();
00098       plot != noisyCellHistos.end(); ++plot) {
00099     (*plot).second->Reset();
00100   }
00101 
00102   summaryNoiseHisto->Reset();
00103 
00104 
00105 
00106   vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
00107   vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
00108   
00109   LogTrace ("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00110     <<"[DTNoiseAnalysisTest]: Fill the summary histos";
00111 
00112   for (; ch_it != ch_end; ++ch_it) { // loop over chambers
00113     DTChamberId chID = (*ch_it)->id();
00114     
00115     MonitorElement * histo = dbe->get(getMEName(chID));
00116     
00117     if(histo) { // check the pointer
00118       
00119       TH2F * histo_root = histo->getTH2F();
00120       
00121       for(int sl = 1; sl != 4; ++sl) { // loop over SLs
00122         // skip theta SL in MB4 chambers
00123         if(chID.station() == 4 && sl == 2) continue;
00124 
00125         int binYlow = ((sl-1)*4)+1;
00126 
00127         for(int layer = 1; layer <= 4; ++layer) { // loop over layers
00128           
00129           // Get the layer ID
00130           DTLayerId layID(chID,sl,layer);
00131 
00132           int nWires = muonGeom->layer(layID)->specificTopology().channels();
00133           int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
00134 
00135           int binY = binYlow+(layer-1);
00136 
00137           for(int wire = firstWire; wire != (nWires+firstWire); wire++){ // loop over wires
00138 
00139             double noise = histo_root->GetBinContent(wire, binY);
00140             // fill the histos
00141             noiseHistos[chID.wheel()]->Fill(noise);
00142             noiseHistos[3]->Fill(noise);
00143             int sector = chID.sector();
00144             if(noise>noisyCellDef) {
00145               if(sector == 13) {
00146                 sector = 4;
00147               } else if(sector == 14) {
00148                 sector = 10;
00149               }
00150               noisyCellHistos[chID.wheel()]->Fill(sector,chID.station());
00151               summaryNoiseHisto->Fill(sector,chID.wheel());
00152             }
00153           }
00154         }
00155       }
00156     }
00157   }
00158 
00159 
00160   // build the summary of synch noise
00161   
00162 
00163   if(doSynchNoise) {
00164     LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00165       << "[DTNoiseAnalysisTest]: fill summaries for synch noise" << endl;
00166     summarySynchNoiseHisto->Reset();
00167     for(int wheel = -2; wheel != 3; ++wheel) {
00168       // Get the histo produced by DTDigiTask
00169       MonitorElement * histoNoiseSynch = dbe->get(getSynchNoiseMEName(wheel));
00170       if(histoNoiseSynch != 0) {
00171         for(int sect = 1; sect != 13; ++sect) { // loop over sectors
00172           TH2F * histo = histoNoiseSynch->getTH2F();
00173           for(int sta = 1; sta != 5; ++sta) {
00174             LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00175               << "   Wheel: " << wheel << " sect: " << sect
00176               << " station: " << sta
00177               << " rate is: " << histo->GetBinContent(sect, sta) << endl;
00178             if(histo->GetBinContent(sect, sta) > maxSynchNoiseRate) {
00179               summarySynchNoiseHisto->Fill(sect,wheel,1);
00180             }
00181           }
00182         }
00183       } else {
00184         LogWarning("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
00185           << "   Histo: " << getSynchNoiseMEName(wheel) << " not found!" << endl;
00186       }
00187     }
00188 
00189   }
00190 
00191 }              
00192 
00193 
00194 string DTNoiseAnalysisTest::getMEName(const DTChamberId & chID) {
00195   
00196   stringstream wheel; wheel << chID.wheel();    
00197   stringstream station; station << chID.station();      
00198   stringstream sector; sector << chID.sector(); 
00199   
00200   string folderName = 
00201     "DT/04-Noise/Wheel" +  wheel.str() +
00202 //     "/Station" + station.str() +
00203     "/Sector" + sector.str() + "/";
00204 
00205   string histoname = folderName + string("NoiseRate")  
00206     + "_W" + wheel.str() 
00207     + "_St" + station.str() 
00208     + "_Sec" + sector.str();
00209   
00210   return histoname;
00211   
00212 }
00213 
00214 
00215 void DTNoiseAnalysisTest::bookHistos() {
00216   
00217   dbe->setCurrentFolder("DT/04-Noise");
00218   string histoName;
00219 
00220   for(int wh=-2; wh<=2; wh++){
00221       stringstream wheel; wheel << wh;
00222       histoName =  "NoiseRateSummary_W" + wheel.str();
00223       noiseHistos[wh] = dbe->book1D(histoName.c_str(),histoName.c_str(),100,0,2000);
00224       noiseHistos[wh]->setAxisTitle("rate (Hz)",1);
00225       noiseHistos[wh]->setAxisTitle("entries",2);
00226   }
00227   histoName =  "NoiseRateSummary";
00228   noiseHistos[3] = dbe->book1D(histoName.c_str(),histoName.c_str(),100,0,2000);
00229   noiseHistos[3]->setAxisTitle("rate (Hz)",1);
00230   noiseHistos[3]->setAxisTitle("entries",2);
00231 
00232   
00233   for(int wh=-2; wh<=2; wh++){
00234     stringstream wheel; wheel << wh;
00235     histoName =  "NoiseSummary_W" + wheel.str();
00236     noisyCellHistos[wh] = dbe->book2D(histoName.c_str(),"# of noisy channels",12,1,13,4,1,5);
00237     noisyCellHistos[wh]->setBinLabel(1,"MB1",2);
00238     noisyCellHistos[wh]->setBinLabel(2,"MB2",2);
00239     noisyCellHistos[wh]->setBinLabel(3,"MB3",2);
00240     noisyCellHistos[wh]->setBinLabel(4,"MB4",2);  
00241     noisyCellHistos[wh]->setAxisTitle("Sector",1);
00242   }
00243 
00244   histoName =  "NoiseSummary";
00245   summaryNoiseHisto =  dbe->book2D(histoName.c_str(),"# of noisy channels",12,1,13,5,-2,3);
00246   summaryNoiseHisto->setAxisTitle("Sector",1);
00247   summaryNoiseHisto->setAxisTitle("Wheel",2);
00248 
00249 
00250   if(doSynchNoise) {
00251     dbe->setCurrentFolder("DT/04-Noise/SynchNoise/");
00252     histoName =  "SynchNoiseSummary";
00253     summarySynchNoiseHisto = dbe->book2D(histoName.c_str(),"Summary Synch. Noise",12,1,13,5,-2,3);
00254     summarySynchNoiseHisto->setAxisTitle("Sector",1);
00255     summarySynchNoiseHisto->setAxisTitle("Wheel",2);
00256   }
00257 
00258 }
00259 
00260 
00261 
00262 string DTNoiseAnalysisTest::getSynchNoiseMEName(int wheelId) const {
00263   
00264   stringstream wheel; wheel << wheelId; 
00265   string folderName = 
00266     "DT/04-Noise/SynchNoise/";
00267   string histoname = folderName + string("SyncNoiseEvents")  
00268     + "_W" + wheel.str();
00269 
00270   return histoname;
00271   
00272 }

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