CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTNoiseAnalysisTest.cc
Go to the documentation of this file.
1 
2 
3 /*
4  * See header file for a description of this class.
5  *
6  * $Date: 2010/01/05 10:15:46 $
7  * $Revision: 1.12 $
8  * \author G. Mila - INFN Torino
9  */
10 
11 
13 
14 // Framework
18 
19 
20 // Geometry
26 
30 
31 #include <iostream>
32 #include <sstream>
33 
34 
35 
36 using namespace edm;
37 using namespace std;
38 
39 
41  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "[DTNoiseAnalysisTest]: Constructor";
42 
43  dbe = edm::Service<DQMStore>().operator->();
44 
45  // get the cfi parameters
46  noisyCellDef = ps.getUntrackedParameter<int>("noisyCellDef",500);
47 
48  // switch on/off the summaries for the Synchronous noise
49  doSynchNoise = ps.getUntrackedParameter<bool>("doSynchNoise", false);
50  maxSynchNoiseRate = ps.getUntrackedParameter<double>("maxSynchNoiseRate", 0.001);
51 
52 }
53 
54 
56  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "DTNoiseAnalysisTest: analyzed " << nevents << " events";
57 }
58 
59 
61  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") <<"[DTNoiseAnalysisTest]: BeginJob";
62 
63  nevents = 0;
64 
65  // book the histos
66  bookHistos();
67 
68 }
69 
70 void DTNoiseAnalysisTest::beginRun(Run const& run, EventSetup const& context) {
71 
72  // Get the geometry
73  context.get<MuonGeometryRecord>().get(muonGeom);
74 
75 }
76 
77 
79 
80  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") <<"[DTNoiseAnalysisTest]: Begin of LS transition";
81 }
82 
83 
85 
86  nevents++;
87  if(nevents%1000 == 0) LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
88  << "[DTNoiseAnalysisTest]: "<<nevents<<" events";
89 
90 }
91 
93  LogVerbatim ("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
94  <<"[DTNoiseAnalysisTest]: End of LS transition, performing the DQM client operation";
95 
96  // Reset the summary plots
97  for(map<int, MonitorElement* >::iterator plot = noiseHistos.begin();
98  plot != noiseHistos.end(); ++plot) {
99  (*plot).second->Reset();
100  }
101 
102  for(map<int, MonitorElement* >::iterator plot = noisyCellHistos.begin();
103  plot != noisyCellHistos.end(); ++plot) {
104  (*plot).second->Reset();
105  }
106 
107  summaryNoiseHisto->Reset();
108 
109 
110 
111  vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
112  vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
113 
114  LogTrace ("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
115  <<"[DTNoiseAnalysisTest]: Fill the summary histos";
116 
117  for (; ch_it != ch_end; ++ch_it) { // loop over chambers
118  DTChamberId chID = (*ch_it)->id();
119 
120  MonitorElement * histo = dbe->get(getMEName(chID));
121 
122  if(histo) { // check the pointer
123 
124  TH2F * histo_root = histo->getTH2F();
125 
126  for(int sl = 1; sl != 4; ++sl) { // loop over SLs
127  // skip theta SL in MB4 chambers
128  if(chID.station() == 4 && sl == 2) continue;
129 
130  int binYlow = ((sl-1)*4)+1;
131 
132  for(int layer = 1; layer <= 4; ++layer) { // loop over layers
133 
134  // Get the layer ID
135  DTLayerId layID(chID,sl,layer);
136 
137  int nWires = muonGeom->layer(layID)->specificTopology().channels();
138  int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
139 
140  int binY = binYlow+(layer-1);
141 
142  for(int wire = firstWire; wire != (nWires+firstWire); wire++){ // loop over wires
143 
144  double noise = histo_root->GetBinContent(wire, binY);
145  // fill the histos
146  noiseHistos[chID.wheel()]->Fill(noise);
147  noiseHistos[3]->Fill(noise);
148  int sector = chID.sector();
149  if(noise>noisyCellDef) {
150  if(sector == 13) {
151  sector = 4;
152  } else if(sector == 14) {
153  sector = 10;
154  }
155  noisyCellHistos[chID.wheel()]->Fill(sector,chID.station());
156  summaryNoiseHisto->Fill(sector,chID.wheel());
157  }
158  }
159  }
160  }
161  }
162  }
163 
164 
165  // build the summary of synch noise
166 
167 
168  if(doSynchNoise) {
169  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
170  << "[DTNoiseAnalysisTest]: fill summaries for synch noise" << endl;
171  summarySynchNoiseHisto->Reset();
172  for(int wheel = -2; wheel != 3; ++wheel) {
173  // Get the histo produced by DTDigiTask
174  MonitorElement * histoNoiseSynch = dbe->get(getSynchNoiseMEName(wheel));
175  if(histoNoiseSynch != 0) {
176  for(int sect = 1; sect != 13; ++sect) { // loop over sectors
177  TH2F * histo = histoNoiseSynch->getTH2F();
178  for(int sta = 1; sta != 5; ++sta) {
179  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
180  << " Wheel: " << wheel << " sect: " << sect
181  << " station: " << sta
182  << " rate is: " << histo->GetBinContent(sect, sta)/(float)nevents << endl;
183  if(histo->GetBinContent(sect, sta)/(float)nevents > maxSynchNoiseRate) {
184  summarySynchNoiseHisto->Fill(sect,wheel,1);
185  } else {
186  summarySynchNoiseHisto->Fill(sect,wheel,0);
187  }
188  }
189  }
190  } else {
191  LogWarning("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
192  << " Histo: " << getSynchNoiseMEName(wheel) << " not found!" << endl;
193  }
194  }
195 
196  }
197 
198 }
199 
200 
202 
203  stringstream wheel; wheel << chID.wheel();
204  stringstream station; station << chID.station();
205  stringstream sector; sector << chID.sector();
206 
207  string folderName =
208  "DT/05-Noise/Wheel" + wheel.str() +
209 // "/Station" + station.str() +
210  "/Sector" + sector.str() + "/";
211 
212  string histoname = folderName + string("NoiseRate")
213  + "_W" + wheel.str()
214  + "_St" + station.str()
215  + "_Sec" + sector.str();
216 
217  return histoname;
218 
219 }
220 
221 
223 
224  dbe->setCurrentFolder("DT/05-Noise");
225  string histoName;
226 
227  for(int wh=-2; wh<=2; wh++){
228  stringstream wheel; wheel << wh;
229  histoName = "NoiseRateSummary_W" + wheel.str();
230  noiseHistos[wh] = dbe->book1D(histoName.c_str(),histoName.c_str(),100,0,2000);
231  noiseHistos[wh]->setAxisTitle("rate (Hz)",1);
232  noiseHistos[wh]->setAxisTitle("entries",2);
233  }
234  histoName = "NoiseRateSummary";
235  noiseHistos[3] = dbe->book1D(histoName.c_str(),histoName.c_str(),100,0,2000);
236  noiseHistos[3]->setAxisTitle("rate (Hz)",1);
237  noiseHistos[3]->setAxisTitle("entries",2);
238 
239 
240  for(int wh=-2; wh<=2; wh++){
241  stringstream wheel; wheel << wh;
242  histoName = "NoiseSummary_W" + wheel.str();
243  noisyCellHistos[wh] = dbe->book2D(histoName.c_str(),"# of noisy channels",12,1,13,4,1,5);
244  noisyCellHistos[wh]->setBinLabel(1,"MB1",2);
245  noisyCellHistos[wh]->setBinLabel(2,"MB2",2);
246  noisyCellHistos[wh]->setBinLabel(3,"MB3",2);
247  noisyCellHistos[wh]->setBinLabel(4,"MB4",2);
248  noisyCellHistos[wh]->setAxisTitle("Sector",1);
249  }
250 
251  histoName = "NoiseSummary";
252  summaryNoiseHisto = dbe->book2D(histoName.c_str(),"# of noisy channels",12,1,13,5,-2,3);
253  summaryNoiseHisto->setAxisTitle("Sector",1);
254  summaryNoiseHisto->setAxisTitle("Wheel",2);
255 
256 
257  if(doSynchNoise) {
258  dbe->setCurrentFolder("DT/05-Noise/SynchNoise/");
259  histoName = "SynchNoiseSummary";
260  summarySynchNoiseHisto = dbe->book2D(histoName.c_str(),"Summary Synch. Noise",12,1,13,5,-2,3);
261  summarySynchNoiseHisto->setAxisTitle("Sector",1);
262  summarySynchNoiseHisto->setAxisTitle("Wheel",2);
263  }
264 
265 }
266 
267 
268 
269 string DTNoiseAnalysisTest::getSynchNoiseMEName(int wheelId) const {
270 
271  stringstream wheel; wheel << wheelId;
272  string folderName =
273  "DT/05-Noise/SynchNoise/";
274  string histoname = folderName + string("SyncNoiseEvents")
275  + "_W" + wheel.str();
276 
277  return histoname;
278 
279 }
T getUntrackedParameter(std::string const &, T const &) const
void beginJob()
BeginJob.
tuple histo
Definition: trackerHits.py:12
void bookHistos()
Definition: Histogram.h:33
void bookHistos()
book the summary histograms
int nevents
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
DQM Client Diagnostic.
std::string getMEName(const DTChamberId &chID)
Get the ME name.
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
int sector() const
Definition: DTChamberId.h:63
std::string getSynchNoiseMEName(int wheelId) const
int station() const
Return the station number.
Definition: DTChamberId.h:53
TH2F * getTH2F(void) const
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
DTNoiseAnalysisTest(const edm::ParameterSet &ps)
Constructor.
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
Definition: Run.h:32
virtual ~DTNoiseAnalysisTest()
Destructor.