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 
11 
12 // Framework
16 
17 // Geometry
22 
25 
26 #include <iostream>
27 #include <sstream>
28 
29 using namespace edm;
30 using namespace std;
31 
33  : muonGeomToken_(esConsumes<edm::Transition::BeginRun>()) {
34  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "[DTNoiseAnalysisTest]: Constructor";
35 
36  // get the cfi parameters
37  noisyCellDef = ps.getUntrackedParameter<int>("noisyCellDef", 500);
38 
39  // switch on/off the summaries for the Synchronous noise
40  doSynchNoise = ps.getUntrackedParameter<bool>("doSynchNoise", false);
41  detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis", false);
42  maxSynchNoiseRate = ps.getUntrackedParameter<double>("maxSynchNoiseRate", 0.001);
43  nMinEvts = ps.getUntrackedParameter<int>("nEventsCert", 5000);
44 
45  nevents = 0;
46 
47  bookingdone = false;
48 }
49 
51  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "DTNoiseAnalysisTest: analyzed " << nevents << " events";
52 }
53 
55  // Get the geometry
56  muonGeom = &context.getData(muonGeomToken_);
57 }
58 
60  DQMStore::IGetter& igetter,
61  edm::LuminosityBlock const& lumiSeg,
62  edm::EventSetup const& context) {
63  float chRate;
64 
65  if (!bookingdone) {
66  // book the histos
67  bookHistos(ibooker);
68  }
69  bookingdone = true;
70 
71  LogVerbatim("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
72  << "[DTNoiseAnalysisTest]: End of LS transition, performing the DQM client operation";
73 
74  // Reset the summary plots
75  for (map<int, MonitorElement*>::iterator plot = noiseHistos.begin(); plot != noiseHistos.end(); ++plot) {
76  (*plot).second->Reset();
77  }
78 
79  for (map<int, MonitorElement*>::iterator plot = noisyCellHistos.begin(); plot != noisyCellHistos.end(); ++plot) {
80  (*plot).second->Reset();
81  }
82 
84 
85  vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
86  vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
87 
88  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest") << "[DTNoiseAnalysisTest]: Fill the summary histos";
89 
90  for (; ch_it != ch_end; ++ch_it) { // loop over chambers
91  DTChamberId chID = (*ch_it)->id();
92 
93  MonitorElement* histo = igetter.get(getMEName(chID));
94 
95  if (histo) { // check the pointer
96 
97  TH2F* histo_root = histo->getTH2F();
98 
99  for (int sl = 1; sl != 4; ++sl) { // loop over SLs
100  // skip theta SL in MB4 chambers
101  if (chID.station() == 4 && sl == 2)
102  continue;
103 
104  int binYlow = ((sl - 1) * 4) + 1;
105 
106  for (int layer = 1; layer <= 4; ++layer) { // loop over layers
107 
108  // Get the layer ID
109  DTLayerId layID(chID, sl, layer);
110 
111  int nWires = muonGeom->layer(layID)->specificTopology().channels();
112  int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
113 
114  int binY = binYlow + (layer - 1);
115 
116  for (int wire = firstWire; wire != (nWires + firstWire); wire++) { // loop over wires
117 
118  double noise = histo_root->GetBinContent(wire, binY);
119  // fill the histos
120  noiseHistos[chID.wheel()]->Fill(noise);
121  noiseHistos[3]->Fill(noise);
122  int sector = chID.sector();
123  if (noise > noisyCellDef) {
124  if (sector == 13) {
125  sector = 4;
126  } else if (sector == 14) {
127  sector = 10;
128  }
129  noisyCellHistos[chID.wheel()]->Fill(sector, chID.station());
131  }
132  }
133  }
134  }
135  }
136  }
137 
138  if (detailedAnalysis) {
140  TH1F* histo = noiseHistos[3]->getTH1F();
141  for (int step = 0; step != 15; step++) {
142  int threshBin = step + 1;
143  int minBin = 26 + step * 5;
144  int nNoisyCh = histo->Integral(minBin, 101);
145  threshChannelsHisto->setBinContent(threshBin, nNoisyCh);
146  }
147  }
148 
149  // build the summary of synch noise
150 
151  if (doSynchNoise) {
152  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
153  << "[DTNoiseAnalysisTest]: fill summaries for synch noise" << endl;
156  for (int wheel = -2; wheel != 3; ++wheel) {
157  // Get the histo produced by DTDigiTask
158 
159  MonitorElement* histoNoiseSynch = igetter.get(getSynchNoiseMEName(wheel));
160  if (histoNoiseSynch != nullptr) {
161  for (int sect = 1; sect != 13; ++sect) { // loop over sectors
162  TH2F* histo = histoNoiseSynch->getTH2F();
163  float maxSectRate = 0;
164  for (int sta = 1; sta != 5; ++sta) {
165  if (nevents > 0)
166  chRate = histo->GetBinContent(sect, sta) / (float)nevents;
167  else
168  chRate = -1.0;
169  // in case nevents 0 e.g. counting not done
170  LogTrace("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
171  << " Wheel: " << wheel << " sect: " << sect << " station: " << sta << " rate is: " << chRate << endl;
172  if (chRate > maxSectRate)
173  maxSectRate = chRate;
174  }
175  summarySynchNoiseHisto->Fill(sect, wheel, maxSectRate > maxSynchNoiseRate ? 1 : 0);
176  float glbBinValue = 1 - 0.15 * maxSectRate / maxSynchNoiseRate;
177  glbSummarySynchNoiseHisto->Fill(sect, wheel, glbBinValue > 0 ? glbBinValue : 0);
178  }
179  } else {
180  LogWarning("DTDQM|DTMonitorClient|DTNoiseAnalysisTest")
181  << " Histo: " << getSynchNoiseMEName(wheel) << " not found!" << endl;
182  }
183  }
184  }
185 
186  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsNoise";
187 
188  MonitorElement* meProcEvts = igetter.get(nEvtsName);
189 
190  if (meProcEvts) {
191  int nProcEvts = meProcEvts->getFloatValue();
192  glbSummarySynchNoiseHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
193  summarySynchNoiseHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
194  } else {
197  LogVerbatim("DTDQM|DTMonitorClient|DTnoiseAnalysisTest")
198  << "[DTNoiseAnalysisTest] ME: " << nEvtsName << " not found!" << endl;
199  }
200 }
201 
203  stringstream wheel;
204  wheel << chID.wheel();
205  stringstream station;
206  station << chID.station();
207  stringstream sector;
208  sector << chID.sector();
209 
210  string folderName = "DT/05-Noise/Wheel" + wheel.str() + "/Sector" + sector.str() + "/";
211 
212  string histoname =
213  folderName + string("NoiseRate") + "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
214 
215  return histoname;
216 }
217 
219  ibooker.setCurrentFolder("DT/05-Noise");
220  string histoName;
221 
222  for (int wh = -2; wh <= 2; wh++) {
223  stringstream wheel;
224  wheel << wh;
225  histoName = "NoiseRateSummary_W" + wheel.str();
226 
227  noiseHistos[wh] = ibooker.book1D(histoName.c_str(), histoName.c_str(), 100, 0, 2000);
228  noiseHistos[wh]->setAxisTitle("rate (Hz)", 1);
229  noiseHistos[wh]->setAxisTitle("entries", 2);
230  }
231  histoName = "NoiseRateSummary";
232 
233  noiseHistos[3] = ibooker.book1D(histoName.c_str(), histoName.c_str(), 100, 0, 2000);
234  noiseHistos[3]->setAxisTitle("rate (Hz)", 1);
235  noiseHistos[3]->setAxisTitle("entries", 2);
236 
237  for (int wh = -2; wh <= 2; wh++) {
238  stringstream wheel;
239  wheel << wh;
240  histoName = "NoiseSummary_W" + wheel.str();
241 
242  noisyCellHistos[wh] = ibooker.book2D(histoName.c_str(), "# of noisy channels", 12, 1, 13, 4, 1, 5);
243  noisyCellHistos[wh]->setBinLabel(1, "MB1", 2);
244  noisyCellHistos[wh]->setBinLabel(2, "MB2", 2);
245  noisyCellHistos[wh]->setBinLabel(3, "MB3", 2);
246  noisyCellHistos[wh]->setBinLabel(4, "MB4", 2);
247  noisyCellHistos[wh]->setAxisTitle("Sector", 1);
248  }
249 
250  histoName = "NoiseSummary";
251 
252  summaryNoiseHisto = ibooker.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  if (detailedAnalysis) {
257  histoName = "NoisyChannels";
258 
259  threshChannelsHisto = ibooker.book1D(histoName.c_str(), "# of noisy channels vs threshold", 15, 500, 2000);
260  threshChannelsHisto->setAxisTitle("threshold", 1);
261  threshChannelsHisto->setAxisTitle("# noisy channels", 2);
262  }
263 
264  if (doSynchNoise) {
265  ibooker.setCurrentFolder("DT/05-Noise/SynchNoise/");
266  histoName = "SynchNoiseSummary";
267 
268  summarySynchNoiseHisto = ibooker.book2D(histoName.c_str(), "Summary Synch. Noise", 12, 1, 13, 5, -2, 3);
269  summarySynchNoiseHisto->setAxisTitle("Sector", 1);
271  histoName = "SynchNoiseGlbSummary";
272 
273  glbSummarySynchNoiseHisto = ibooker.book2D(histoName.c_str(), "Summary Synch. Noise", 12, 1, 13, 5, -2, 3);
276  }
277 }
278 
279 string DTNoiseAnalysisTest::getSynchNoiseMEName(int wheelId) const {
280  stringstream wheel;
281  wheel << wheelId;
282  string folderName = "DT/05-Noise/SynchNoise/";
283  string histoname = folderName + string("SyncNoiseEvents") + "_W" + wheel.str();
284 
285  return histoname;
286 }
287 
Log< level::Info, true > LogVerbatim
int station() const
Return the station number.
Definition: DTChamberId.h:42
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
MonitorElement * threshChannelsHisto
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
constexpr unsigned int minBin
virtual void setEntries(double nentries)
set # of entries
void beginRun(edm::Run const &run, edm::EventSetup const &context) override
BeginRun.
std::map< int, MonitorElement * > noisyCellHistos
#define LogTrace(id)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
T getUntrackedParameter(std::string const &, T const &) const
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
void Fill(long long x)
std::string getSynchNoiseMEName(int wheelId) const
virtual TH2F * getTH2F() const
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
virtual double getFloatValue() const
void bookHistos(DQMStore::IBooker &)
book the summary histograms
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
Transition
Definition: Transition.h:12
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
std::string getMEName(const DTChamberId &chID)
Get the ME name.
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * summarySynchNoiseHisto
std::map< int, MonitorElement * > noiseHistos
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
const DTGeometry * muonGeom
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
MonitorElement * glbSummarySynchNoiseHisto
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
HLT enums.
int sector() const
Definition: DTChamberId.h:49
~DTNoiseAnalysisTest() override
Destructor.
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
step
Definition: StallMonitor.cc:83
Log< level::Warning, false > LogWarning
MonitorElement * summaryNoiseHisto
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
DTNoiseAnalysisTest(const edm::ParameterSet &ps)
Constructor.
int channels() const
Returns the number of wires in the layer.
Definition: DTTopology.h:76
Definition: Run.h:45
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)