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  * See header file for a description of this class.
4  *
5  * $Date: 2011/06/21 10:47:53 $
6  * $Revision: 1.17 $
7  * \author G. Mila - INFN Torino
8  */
9 
10 
12 
13 // Framework
17 
18 
19 // Geometry
25 
29 
30 #include <iostream>
31 #include <sstream>
32 
33 
34 
35 using namespace edm;
36 using namespace std;
37 
38 
40  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "[DTNoiseAnalysisTest]: Constructor";
41 
42  dbe = edm::Service<DQMStore>().operator->();
43 
44  // get the cfi parameters
45  noisyCellDef = ps.getUntrackedParameter<int>("noisyCellDef",500);
46 
47  // switch on/off the summaries for the Synchronous noise
48  doSynchNoise = ps.getUntrackedParameter<bool>("doSynchNoise", false);
49  detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis",false);
50  maxSynchNoiseRate = ps.getUntrackedParameter<double>("maxSynchNoiseRate", 0.001);
51  nMinEvts = ps.getUntrackedParameter<int>("nEventsCert", 5000);
52 
53 }
54 
55 
57  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "DTNoiseAnalysisTest: analyzed " << nevents << " events";
58 }
59 
60 
62  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") <<"[DTNoiseAnalysisTest]: BeginJob";
63 
64  nevents = 0;
65 
66  // book the histos
67  bookHistos();
68 
69 }
70 
71 void DTNoiseAnalysisTest::beginRun(Run const& run, EventSetup const& context) {
72 
73  // Get the geometry
74  context.get<MuonGeometryRecord>().get(muonGeom);
75 
76 }
77 
78 
80 
81  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") <<"[DTNoiseAnalysisTest]: Begin of LS transition";
82 }
83 
84 
86 
87  nevents++;
88  if(nevents%1000 == 0) LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
89  << "[DTNoiseAnalysisTest]: "<<nevents<<" events";
90 
91 }
92 
94  LogVerbatim ("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
95  <<"[DTNoiseAnalysisTest]: End of LS transition, performing the DQM client operation";
96 
97  // Reset the summary plots
98  for(map<int, MonitorElement* >::iterator plot = noiseHistos.begin();
99  plot != noiseHistos.end(); ++plot) {
100  (*plot).second->Reset();
101  }
102 
103  for(map<int, MonitorElement* >::iterator plot = noisyCellHistos.begin();
104  plot != noisyCellHistos.end(); ++plot) {
105  (*plot).second->Reset();
106  }
107 
108  summaryNoiseHisto->Reset();
109 
110 
111 
112  vector<DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
113  vector<DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
114 
115  LogTrace ("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
116  <<"[DTNoiseAnalysisTest]: Fill the summary histos";
117 
118  for (; ch_it != ch_end; ++ch_it) { // loop over chambers
119  DTChamberId chID = (*ch_it)->id();
120 
121  MonitorElement * histo = dbe->get(getMEName(chID));
122 
123  if(histo) { // check the pointer
124 
125  TH2F * histo_root = histo->getTH2F();
126 
127  for(int sl = 1; sl != 4; ++sl) { // loop over SLs
128  // skip theta SL in MB4 chambers
129  if(chID.station() == 4 && sl == 2) continue;
130 
131  int binYlow = ((sl-1)*4)+1;
132 
133  for(int layer = 1; layer <= 4; ++layer) { // loop over layers
134 
135  // Get the layer ID
136  DTLayerId layID(chID,sl,layer);
137 
138  int nWires = muonGeom->layer(layID)->specificTopology().channels();
139  int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
140 
141  int binY = binYlow+(layer-1);
142 
143  for(int wire = firstWire; wire != (nWires+firstWire); wire++){ // loop over wires
144 
145  double noise = histo_root->GetBinContent(wire, binY);
146  // fill the histos
147  noiseHistos[chID.wheel()]->Fill(noise);
148  noiseHistos[3]->Fill(noise);
149  int sector = chID.sector();
150  if(noise>noisyCellDef) {
151  if(sector == 13) {
152  sector = 4;
153  } else if(sector == 14) {
154  sector = 10;
155  }
156  noisyCellHistos[chID.wheel()]->Fill(sector,chID.station());
157  summaryNoiseHisto->Fill(sector,chID.wheel());
158  }
159  }
160  }
161  }
162  }
163  }
164 
165  if(detailedAnalysis) {
166  threshChannelsHisto->Reset();
167  TH1F * histo = noiseHistos[3]->getTH1F();
168  for(int step = 0; step != 15; step++) {
169  int threshBin = step + 1;
170  int minBin = 26 + step*5;
171  int nNoisyCh = histo->Integral(minBin,101);
172  threshChannelsHisto->setBinContent(threshBin,nNoisyCh);
173  }
174  }
175 
176  // build the summary of synch noise
177 
178 
179  if(doSynchNoise) {
180  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
181  << "[DTNoiseAnalysisTest]: fill summaries for synch noise" << endl;
182  summarySynchNoiseHisto->Reset();
183  glbSummarySynchNoiseHisto->Reset();
184  for(int wheel = -2; wheel != 3; ++wheel) {
185  // Get the histo produced by DTDigiTask
186  MonitorElement * histoNoiseSynch = dbe->get(getSynchNoiseMEName(wheel));
187  if(histoNoiseSynch != 0) {
188  for(int sect = 1; sect != 13; ++sect) { // loop over sectors
189  TH2F * histo = histoNoiseSynch->getTH2F();
190  float maxSectRate = 0;
191  for(int sta = 1; sta != 5; ++sta) {
192  float chRate = histo->GetBinContent(sect, sta)/(float)nevents;
193  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
194  << " Wheel: " << wheel << " sect: " << sect
195  << " station: " << sta
196  << " rate is: " << chRate << endl;
197  if (chRate > maxSectRate)
198  maxSectRate = chRate;
199  }
200  summarySynchNoiseHisto->Fill(sect,wheel,
201  maxSectRate > maxSynchNoiseRate ? 1 : 0);
202  float glbBinValue = 1 - 0.15*maxSectRate/maxSynchNoiseRate;
203  glbSummarySynchNoiseHisto->Fill(sect,wheel,glbBinValue>0 ? glbBinValue : 0);
204 
205  }
206  } else {
207  LogWarning("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
208  << " Histo: " << getSynchNoiseMEName(wheel) << " not found!" << endl;
209  }
210  }
211 
212  }
213 
214  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsNoise";
215  MonitorElement * meProcEvts = dbe->get(nEvtsName);
216 
217  if (meProcEvts) {
218  int nProcEvts = meProcEvts->getFloatValue();
219  glbSummarySynchNoiseHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
220  summarySynchNoiseHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
221  } else {
222  glbSummarySynchNoiseHisto->setEntries(nMinEvts +1);
223  summarySynchNoiseHisto->setEntries(nMinEvts + 1);
224  LogVerbatim ("DTDQM|DTMonitorClient|DTnoiseAnalysisTest") << "[DTNoiseAnalysisTest] ME: "
225  << nEvtsName << " not found!" << endl;
226  }
227 
228 
229 }
230 
231 
233 
234  stringstream wheel; wheel << chID.wheel();
235  stringstream station; station << chID.station();
236  stringstream sector; sector << chID.sector();
237 
238  string folderName =
239  "DT/05-Noise/Wheel" + wheel.str() +
240  // "/Station" + station.str() +
241  "/Sector" + sector.str() + "/";
242 
243  string histoname = folderName + string("NoiseRate")
244  + "_W" + wheel.str()
245  + "_St" + station.str()
246  + "_Sec" + sector.str();
247 
248  return histoname;
249 
250 }
251 
252 
254 
255  dbe->setCurrentFolder("DT/05-Noise");
256  string histoName;
257 
258  for(int wh=-2; wh<=2; wh++){
259  stringstream wheel; wheel << wh;
260  histoName = "NoiseRateSummary_W" + wheel.str();
261  noiseHistos[wh] = dbe->book1D(histoName.c_str(),histoName.c_str(),100,0,2000);
262  noiseHistos[wh]->setAxisTitle("rate (Hz)",1);
263  noiseHistos[wh]->setAxisTitle("entries",2);
264  }
265  histoName = "NoiseRateSummary";
266  noiseHistos[3] = dbe->book1D(histoName.c_str(),histoName.c_str(),100,0,2000);
267  noiseHistos[3]->setAxisTitle("rate (Hz)",1);
268  noiseHistos[3]->setAxisTitle("entries",2);
269 
270 
271  for(int wh=-2; wh<=2; wh++){
272  stringstream wheel; wheel << wh;
273  histoName = "NoiseSummary_W" + wheel.str();
274  noisyCellHistos[wh] = dbe->book2D(histoName.c_str(),"# of noisy channels",12,1,13,4,1,5);
275  noisyCellHistos[wh]->setBinLabel(1,"MB1",2);
276  noisyCellHistos[wh]->setBinLabel(2,"MB2",2);
277  noisyCellHistos[wh]->setBinLabel(3,"MB3",2);
278  noisyCellHistos[wh]->setBinLabel(4,"MB4",2);
279  noisyCellHistos[wh]->setAxisTitle("Sector",1);
280  }
281 
282  histoName = "NoiseSummary";
283  summaryNoiseHisto = dbe->book2D(histoName.c_str(),"# of noisy channels",12,1,13,5,-2,3);
284  summaryNoiseHisto->setAxisTitle("Sector",1);
285  summaryNoiseHisto->setAxisTitle("Wheel",2);
286 
287  if(detailedAnalysis) {
288  histoName = "NoisyChannels";
289  threshChannelsHisto = dbe->book1D(histoName.c_str(),"# of noisy channels vs threshold",15,500,2000);
290  threshChannelsHisto->setAxisTitle("threshold",1);
291  threshChannelsHisto->setAxisTitle("# noisy channels",2);
292  }
293 
294  if(doSynchNoise) {
295  dbe->setCurrentFolder("DT/05-Noise/SynchNoise/");
296  histoName = "SynchNoiseSummary";
297  summarySynchNoiseHisto = dbe->book2D(histoName.c_str(),"Summary Synch. Noise",12,1,13,5,-2,3);
298  summarySynchNoiseHisto->setAxisTitle("Sector",1);
299  summarySynchNoiseHisto->setAxisTitle("Wheel",2);
300  histoName = "SynchNoiseGlbSummary";
301  glbSummarySynchNoiseHisto = dbe->book2D(histoName.c_str(),"Summary Synch. Noise",12,1,13,5,-2,3);
302  glbSummarySynchNoiseHisto->setAxisTitle("Sector",1);
303  glbSummarySynchNoiseHisto->setAxisTitle("Wheel",2);
304  }
305 
306 }
307 
308 
309 
310 string DTNoiseAnalysisTest::getSynchNoiseMEName(int wheelId) const {
311 
312  stringstream wheel; wheel << wheelId;
313  string folderName =
314  "DT/05-Noise/SynchNoise/";
315  string histoname = folderName + string("SyncNoiseEvents")
316  + "_W" + wheel.str();
317 
318  return histoname;
319 
320 }
321 
T getUntrackedParameter(std::string const &, T const &) const
void beginJob()
BeginJob.
void bookHistos()
Definition: Histogram.h:33
void bookHistos()
book the summary histograms
double getFloatValue(void) const
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:36
virtual ~DTNoiseAnalysisTest()
Destructor.