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());
130  summaryNoiseHisto->Fill(sector, chID.wheel());
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 
cms::cuda::allocator::minBin
constexpr unsigned int minBin
Definition: getCachingDeviceAllocator.h:18
DTNoiseAnalysisTest::summaryNoiseHisto
MonitorElement * summaryNoiseHisto
Definition: DTNoiseAnalysisTest.h:74
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
dqm::impl::MonitorElement::setEntries
virtual void setEntries(double nentries)
set # of entries
Definition: MonitorElement.cc:738
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
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
DTNoiseAnalysisTest::glbSummarySynchNoiseHisto
MonitorElement * glbSummarySynchNoiseHisto
Definition: DTNoiseAnalysisTest.h:77
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:278
DTTopology::channels
int channels() const
Returns the number of wires in the layer.
Definition: DTTopology.h:76
DTNoiseAnalysisTest::noiseHistos
std::map< int, MonitorElement * > noiseHistos
Definition: DTNoiseAnalysisTest.h:72
DQMStore.h
DTNoiseAnalysisTest::bookingdone
bool bookingdone
Definition: DTNoiseAnalysisTest.h:62
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DTNoiseAnalysisTest::muonGeom
const DTGeometry * muonGeom
Definition: DTNoiseAnalysisTest.h:66
plotFactory.plot
plot
Definition: plotFactory.py:109
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DTNoiseAnalysisTest::muonGeomToken_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
Definition: DTNoiseAnalysisTest.h:65
DTNoiseAnalysisTest::nMinEvts
int nMinEvts
Definition: DTNoiseAnalysisTest.h:60
visDQMUpload.context
context
Definition: visDQMUpload.py:37
DTNoiseAnalysisTest::doSynchNoise
bool doSynchNoise
Definition: DTNoiseAnalysisTest.h:79
DTNoiseAnalysisTest::noisyCellDef
int noisyCellDef
Definition: DTNoiseAnalysisTest.h:69
DTTopology::firstChannel
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:79
Service.h
DTGeometry::chambers
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
Definition: DTGeometry.cc:84
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
DTNoiseAnalysisTest::bookHistos
void bookHistos(DQMStore::IBooker &)
book the summary histograms
Definition: DTNoiseAnalysisTest.cc:218
dqm::impl::MonitorElement::Reset
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
Definition: MonitorElement.cc:354
DTLayerId
Definition: DTLayerId.h:12
DTLayer.h
DTNoiseAnalysisTest::getSynchNoiseMEName
std::string getSynchNoiseMEName(int wheelId) const
Definition: DTNoiseAnalysisTest.cc:279
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
DTGeometry.h
dqm::impl::MonitorElement::getFloatValue
virtual double getFloatValue() const
Definition: MonitorElement.cc:929
DTNoiseAnalysisTest::nevents
int nevents
Definition: DTNoiseAnalysisTest.h:59
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
DTGeometry::layer
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
DTNoiseAnalysisTest::noisyCellHistos
std::map< int, MonitorElement * > noisyCellHistos
Definition: DTNoiseAnalysisTest.h:73
DTNoiseAnalysisTest::detailedAnalysis
bool detailedAnalysis
Definition: DTNoiseAnalysisTest.h:80
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
edm::EventSetup
Definition: EventSetup.h:58
gpuVertexFinder::noise
__shared__ int noise
Definition: gpuFitVertices.h:50
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTNoiseAnalysisTest::threshChannelsHisto
MonitorElement * threshChannelsHisto
Definition: DTNoiseAnalysisTest.h:75
ALCARECODTCalibSynchCosmicsDQM_cff.folderName
folderName
Definition: ALCARECODTCalibSynchCosmicsDQM_cff.py:9
DTNoiseAnalysisTest::~DTNoiseAnalysisTest
~DTNoiseAnalysisTest() override
Destructor.
Definition: DTNoiseAnalysisTest.cc:50
DTNoiseAnalysisTest::maxSynchNoiseRate
double maxSynchNoiseRate
Definition: DTNoiseAnalysisTest.h:81
dqm::impl::MonitorElement::setBinContent
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
Definition: MonitorElement.cc:691
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTNoiseAnalysisTest::summarySynchNoiseHisto
MonitorElement * summarySynchNoiseHisto
Definition: DTNoiseAnalysisTest.h:76
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DTNoiseAnalysisTest::DTNoiseAnalysisTest
DTNoiseAnalysisTest(const edm::ParameterSet &ps)
Constructor.
Definition: DTNoiseAnalysisTest.cc:32
dqm::implementation::IGetter
Definition: DQMStore.h:484
edm::Transition::BeginRun
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:673
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
DTLayer::specificTopology
const DTTopology & specificTopology() const
Definition: DTLayer.cc:37
DTNoiseAnalysisTest.h
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
DTTopology.h
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:491