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