CMS 3D CMS Logo

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