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
23 
26 
27 #include <iostream>
28 #include <sstream>
29 
30 using namespace edm;
31 using namespace std;
32 
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 
54 void DTNoiseAnalysisTest::beginRun(Run const& run, EventSetup const& context) {
55  // Get the geometry
56  context.get<MuonGeometryRecord>().get(muonGeom);
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 
83  summaryNoiseHisto->Reset();
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());
130  summaryNoiseHisto->Fill(sector, chID.wheel());
131  }
132  }
133  }
134  }
135  }
136  }
137 
138  if (detailedAnalysis) {
139  threshChannelsHisto->Reset();
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;
154  summarySynchNoiseHisto->Reset();
155  glbSummarySynchNoiseHisto->Reset();
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 {
195  glbSummarySynchNoiseHisto->setEntries(nMinEvts + 1);
196  summarySynchNoiseHisto->setEntries(nMinEvts + 1);
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);
270  summarySynchNoiseHisto->setAxisTitle("Wheel", 2);
271  histoName = "SynchNoiseGlbSummary";
272 
273  glbSummarySynchNoiseHisto = ibooker.book2D(histoName.c_str(), "Summary Synch. Noise", 12, 1, 13, 5, -2, 3);
274  glbSummarySynchNoiseHisto->setAxisTitle("Sector", 1);
275  glbSummarySynchNoiseHisto->setAxisTitle("Wheel", 2);
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 
cmsHarvester.nevents
nevents
Definition: cmsHarvester.py:3177
cms::cuda::allocator::minBin
constexpr unsigned int minBin
Definition: getCachingDeviceAllocator.h:18
DTNoiseAnalysisTest::getMEName
std::string getMEName(const DTChamberId &chID)
Get the ME name.
Definition: DTNoiseAnalysisTest.cc:202
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
DTNoiseAnalysisTest::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
Definition: DTNoiseAnalysisTest.cc:59
step
step
Definition: StallMonitor.cc:94
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
DTLayerId.h
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
dtNoiseAnalysis_cfi.detailedAnalysis
detailedAnalysis
Definition: dtNoiseAnalysis_cfi.py:7
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DTNoiseAnalysisTest::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &context) override
BeginRun.
Definition: DTNoiseAnalysisTest.cc:54
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
plotFactory.plot
plot
Definition: plotFactory.py:109
dtNoiseAnalysis_cfi.noisyCellDef
noisyCellDef
Definition: dtNoiseAnalysis_cfi.py:5
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
Service.h
DTNoiseAnalysisTest::bookHistos
void bookHistos(DQMStore::IBooker &)
book the summary histograms
Definition: DTNoiseAnalysisTest.cc:218
bookHistos
void bookHistos()
Definition: Histogram.h:33
DTLayerId
Definition: DTLayerId.h:12
dtNoiseAnalysis_cfi.maxSynchNoiseRate
maxSynchNoiseRate
Definition: dtNoiseAnalysis_cfi.py:8
DTLayer.h
DTNoiseAnalysisTest::getSynchNoiseMEName
std::string getSynchNoiseMEName(int wheelId) const
Definition: DTNoiseAnalysisTest.cc:279
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
dqm::impl::MonitorElement::getFloatValue
virtual double getFloatValue() const
Definition: MonitorElement.cc:917
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet
Definition: ParameterSet.h:36
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:669
dtNoiseAnalysis_cfi.doSynchNoise
doSynchNoise
Definition: dtNoiseAnalysis_cfi.py:6
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
dqm::impl::MonitorElement::setBinLabel
virtual 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)
Definition: MonitorElement.cc:771
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EventSetup
Definition: EventSetup.h:57
ALCARECODTCalibSynchCosmicsDQM_cff.folderName
folderName
Definition: ALCARECODTCalibSynchCosmicsDQM_cff.py:9
DTNoiseAnalysisTest::~DTNoiseAnalysisTest
~DTNoiseAnalysisTest() override
Destructor.
Definition: DTNoiseAnalysisTest.cc:50
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTNoiseAnalysisTest::DTNoiseAnalysisTest
DTNoiseAnalysisTest(const edm::ParameterSet &ps)
Constructor.
Definition: DTNoiseAnalysisTest.cc:33
dqm::implementation::IGetter
Definition: DQMStore.h:484
dqm::implementation::IBooker::book2D
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:177
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
EventSetup.h
DTNoiseAnalysisTest::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: DTNoiseAnalysisTest.cc:288
dqm::implementation::IBooker
Definition: DQMStore.h:43
DTNoiseAnalysisTest.h
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
hgchebackDigitizer_cfi.noise
noise
Definition: hgchebackDigitizer_cfi.py:42
ParameterSet.h
MuonGeometryRecord.h
DTTopology.h
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
dqm::legacy::MonitorElement::getTH2F
virtual TH2F * getTH2F() const
Definition: MonitorElement.h:490