CMS 3D CMS Logo

DTSegmentAnalysisTest.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
18 
19 // Geometry
24 
27 
29 
30 #include <iostream>
31 #include <cstdio>
32 #include <string>
33 #include <sstream>
34 #include <cmath>
35 
36 using namespace edm;
37 using namespace std;
38 
40  LogTrace("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "[DTSegmentAnalysisTest]: Constructor";
41  parameters = ps;
42 
43  // get the cfi parameters
44  detailedAnalysis = parameters.getUntrackedParameter<bool>("detailedAnalysis", false);
45  runOnline = parameters.getUntrackedParameter<bool>("runOnline", true);
46  // top folder for the histograms in DQMStore
47  topHistoFolder = ps.getUntrackedParameter<string>("topHistoFolder", "DT/02-Segments");
48  nMinEvts = ps.getUntrackedParameter<int>("nEventsCert", 5000);
49  maxPhiHit = ps.getUntrackedParameter<int>("maxPhiHit", 7);
50  maxPhiZHit = ps.getUntrackedParameter<int>("maxPhiZHit", 11);
51 
52  nLSs = 0;
53 
54  bookingdone = false;
55 }
56 
58  LogTrace("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "DTSegmentAnalysisTest: analyzed " << nLSs << " LS";
59 }
60 
61 void DTSegmentAnalysisTest::beginRun(const Run& run, const EventSetup& context) {
62  LogTrace("DTDQM|DTMonitorClient|DTSegmentAnalysisTest") << "[DTSegmentAnalysisTest]: BeginRun";
63 
64  context.get<MuonGeometryRecord>().get(muonGeom);
65 }
66 
68  nLSs++;
69  LogTrace("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
70  << "DTSegmentAnalysisTest: analyzing LS" << lumiSeg.id().luminosityBlock() << " of " << nLSs << endl;
71 }
72 
74  DQMStore::IGetter& igetter,
75  edm::LuminosityBlock const& lumiSeg,
76  edm::EventSetup const& context) {
77  // book the histos
78 
79  if (!bookingdone)
80  bookHistos(ibooker);
81  bookingdone = true;
82 
83  // counts number of lumiSegs
84  nLumiSegs = lumiSeg.id().luminosityBlock();
85 
86  if (runOnline) {
87  LogTrace("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
88  << "[DTSegmentAnalysisTest]: End of LS " << nLumiSegs
89  << ". Client called in online mode , perform DQM client operation";
90 
91  performClientDiagnostic(igetter);
92  }
93 }
94 
96  if (!runOnline) {
97  LogTrace("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
98  << "[DTSegmentAnalysisTest]: endJob. Client called in offline mode , perform DQM client operation";
99 
100  performClientDiagnostic(igetter);
101  }
102 }
103 
105  summaryHistos[3]->Reset();
106  summaryHistos[4]->Reset();
107  vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
108  vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
109 
110  for (; ch_it != ch_end; ++ch_it) {
111  DTChamberId chID = (*ch_it)->id();
112 
113  MonitorElement* hNHits = igetter.get(getMEName(chID, "h4DSegmNHits"));
114  MonitorElement* hSegmOcc = igetter.get(getMEName(chID, "numberOfSegments"));
115 
116  if (hNHits && hSegmOcc) {
117  TH1F* hNHits_root = hNHits->getTH1F();
118  TH2F* hSegmOcc_root = hSegmOcc->getTH2F();
119  TH2F* summary_histo_root = summaryHistos[3]->getTH2F();
120 
121  int sector = chID.sector();
122  if (sector == 13)
123  sector = 4;
124  if (sector == 14)
125  sector = 10;
126 
127  if ((chID.station() != 4 && hNHits_root->GetMaximumBin() < maxPhiZHit) ||
128  (chID.station() == 4 && hNHits_root->GetMaximumBin() < maxPhiHit)) {
129  summaryHistos[chID.wheel()]->setBinContent(sector, chID.station(), 1);
130  if (summary_histo_root->GetBinContent(sector, chID.wheel() + 3) < 1)
131  summaryHistos[3]->setBinContent(sector, chID.wheel() + 3, 1);
132  } else
133  summaryHistos[chID.wheel()]->setBinContent(sector, chID.station(), 0);
134 
135  if (detailedAnalysis) {
136  if (chID.station() != 4)
137  segmRecHitHistos[make_pair(chID.wheel(), chID.sector())]->Fill(chID.station(),
138  abs(12 - hNHits_root->GetMaximumBin()));
139  else
140  segmRecHitHistos[make_pair(chID.wheel(), chID.sector())]->Fill(chID.station(),
141  abs(8 - hNHits_root->GetMaximumBin()));
142  }
143 
144  TH2F* summary2_histo_root = summaryHistos[3]->getTH2F();
145  float weight = 0.001;
146  if (hSegmOcc_root->GetBinContent(sector, chID.station()) == 0) {
147  summaryHistos[chID.wheel()]->setBinContent(sector, chID.station(), 2);
148  if (summary2_histo_root->GetBinContent(sector, chID.wheel() + 3) < 2)
149  summaryHistos[3]->setBinContent(sector, chID.wheel() + 3, 2);
150  } else {
151  // Fill the percentage of segment occupancy
152  weight = 1. / 4.;
153  if ((sector == 4 || sector == 10) && chID.station() == 4)
154  weight = 1. / 8.;
155  }
156  summaryHistos[4]->Fill(sector, chID.wheel(), weight);
157  } else {
158  LogVerbatim("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
159  << "[DTSegmentAnalysisTest]: histos not found!!"; // FIXME
160  }
161 
162  if (detailedAnalysis) { // switch on detailed analysis
163 
164  //test on chi2 segment quality
165 
166  MonitorElement* chi2_histo = igetter.get(getMEName(chID, "h4DChi2"));
167  if (chi2_histo) {
168  TH1F* chi2_histo_root = chi2_histo->getTH1F();
169  double threshold = parameters.getUntrackedParameter<double>("chi2Threshold", 5);
170  double maximum = chi2_histo_root->GetXaxis()->GetXmax();
171  double minimum = chi2_histo_root->GetXaxis()->GetXmin();
172  int nbins = chi2_histo_root->GetXaxis()->GetNbins();
173  int thresholdBin = int(threshold / ((maximum - minimum) / nbins));
174 
175  double badSegments = 0;
176  for (int bin = thresholdBin; bin <= nbins; bin++) {
177  badSegments += chi2_histo_root->GetBinContent(bin);
178  }
179 
180  if (chi2_histo_root->GetEntries() != 0) {
181  double badSegmentsPercentual = badSegments / double(chi2_histo_root->GetEntries());
182  chi2Histos[make_pair(chID.wheel(), chID.sector())]->Fill(chID.station(), badSegmentsPercentual);
183  }
184  } else {
185  LogVerbatim("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
186  << "[DTSegmentAnalysisTest]: Histo: " << getMEName(chID, "h4DChi2") << " not found!" << endl;
187  }
188  } // end of switch for detailed analysis
189 
190  } //loop over all the chambers
191 
192  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsSegment";
193 
194  MonitorElement* meProcEvts = igetter.get(nEvtsName);
195 
196  if (meProcEvts) {
197  int nProcEvts = meProcEvts->getFloatValue();
198  summaryHistos[4]->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
199  } else {
200  summaryHistos[4]->setEntries(nMinEvts + 1);
201  LogVerbatim("DTDQM|DTMonitorClient|DTOccupancyTest")
202  << "[DTOccupancyTest] ME: " << nEvtsName << " not found!" << endl;
203  }
204 
205  if (detailedAnalysis) {
206  string chi2CriterionName = parameters.getUntrackedParameter<string>("chi2TestName", "chi2InRange");
207  for (map<pair<int, int>, MonitorElement*>::const_iterator histo = chi2Histos.begin(); histo != chi2Histos.end();
208  histo++) {
209  const QReport* theChi2QReport = (*histo).second->getQReport(chi2CriterionName);
210  if (theChi2QReport) {
211  vector<dqm::me_util::Channel> badChannels = theChi2QReport->getBadChannels();
212  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
213  channel++) {
214  LogError("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
215  << "Wheel: " << (*histo).first.first << " Sector: " << (*histo).first.second
216  << " Bad stations: " << (*channel).getBin() << " Contents : " << (*channel).getContents();
217  }
218  }
219  }
220 
221  string segmRecHitCriterionName =
222  parameters.getUntrackedParameter<string>("segmRecHitTestName", "segmRecHitInRange");
223  for (map<pair<int, int>, MonitorElement*>::const_iterator histo = segmRecHitHistos.begin();
224  histo != segmRecHitHistos.end();
225  histo++) {
226  const QReport* theSegmRecHitQReport = (*histo).second->getQReport(segmRecHitCriterionName);
227  if (theSegmRecHitQReport) {
228  vector<dqm::me_util::Channel> badChannels = theSegmRecHitQReport->getBadChannels();
229  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
230  channel++) {
231  LogError("DTDQM|DTMonitorClient|DTSegmentAnalysisTest")
232  << "Wheel: " << (*histo).first.first << " Sector: " << (*histo).first.second
233  << " Bad stations on recHit number: " << (*channel).getBin()
234  << " Contents : " << (*channel).getContents();
235  }
236  }
237  }
238 
239  } // end of detailedAnalysis
240 }
241 
243  stringstream wheel;
244  wheel << chID.wheel();
245  stringstream station;
246  station << chID.station();
247  stringstream sector;
248  sector << chID.sector();
249 
250  string folderName =
251  topHistoFolder + "/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str() + "/";
252 
253  string histoname = folderName + histoTag + "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
254 
255  if (histoTag == "numberOfSegments")
256  histoname = topHistoFolder + "/Wheel" + wheel.str() + "/" + histoTag + +"_W" + wheel.str();
257 
258  return histoname;
259 }
260 
262  for (int wh = -2; wh <= 2; wh++) {
263  stringstream wheel;
264  wheel << wh;
265  string histoName = "segmentSummary_W" + wheel.str();
266 
268 
269  summaryHistos[wh] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 12, 1, 13, 4, 1, 5);
270  summaryHistos[wh]->setAxisTitle("Sector", 1);
271  summaryHistos[wh]->setBinLabel(1, "MB1", 2);
272  summaryHistos[wh]->setBinLabel(2, "MB2", 2);
273  summaryHistos[wh]->setBinLabel(3, "MB3", 2);
274  summaryHistos[wh]->setBinLabel(4, "MB4", 2);
275 
276  if (detailedAnalysis) {
277  for (int sect = 1; sect <= 14; sect++) {
278  stringstream sector;
279  sector << sect;
280  string chi2HistoName = "chi2BadSegmPercentual_W" + wheel.str() + "_Sec" + sector.str();
281  ibooker.setCurrentFolder(topHistoFolder + "/Wheel" + wheel.str() + "/Tests");
282  chi2Histos[make_pair(wh, sect)] = ibooker.book1D(chi2HistoName.c_str(), chi2HistoName.c_str(), 4, 1, 5);
283  chi2Histos[make_pair(wh, sect)]->setBinLabel(1, "MB1");
284  chi2Histos[make_pair(wh, sect)]->setBinLabel(2, "MB2");
285  chi2Histos[make_pair(wh, sect)]->setBinLabel(3, "MB3");
286  chi2Histos[make_pair(wh, sect)]->setBinLabel(4, "MB4");
287 
288  string segmHistoName = "residualsOnSegmRecHitNumber_W" + wheel.str() + "_Sec" + sector.str();
289  segmRecHitHistos[make_pair(wh, sect)] = ibooker.book1D(segmHistoName.c_str(), segmHistoName.c_str(), 4, 1, 5);
290  segmRecHitHistos[make_pair(wh, sect)]->setBinLabel(1, "MB1");
291  segmRecHitHistos[make_pair(wh, sect)]->setBinLabel(2, "MB2");
292  segmRecHitHistos[make_pair(wh, sect)]->setBinLabel(3, "MB3");
293  segmRecHitHistos[make_pair(wh, sect)]->setBinLabel(4, "MB4");
294  }
295  }
296  }
297 
298  string histoName = "segmentSummary";
299 
301 
302  summaryHistos[3] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 12, 1, 13, 5, -2, 3);
303  summaryHistos[3]->setAxisTitle("Sector", 1);
304  summaryHistos[3]->setAxisTitle("Wheel", 2);
305 
306  summaryHistos[4] = ibooker.book2D("SegmentGlbSummary", histoName.c_str(), 12, 1, 13, 5, -2, 3);
307  summaryHistos[4]->setAxisTitle("Sector", 1);
308  summaryHistos[4]->setAxisTitle("Wheel", 2);
309 }
dtSegmentAnalysisTest_cfi.maxPhiHit
maxPhiHit
Definition: dtSegmentAnalysisTest_cfi.py:19
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
Handle.h
dtDQMOfflineClients_cff.runOnline
runOnline
Definition: dtDQMOfflineClients_cff.py:6
MessageLogger.h
ESHandle.h
ALCARECODTCalibSynchCosmicsDQMClient_cff.topHistoFolder
topHistoFolder
Definition: ALCARECODTCalibSynchCosmicsDQMClient_cff.py:5
dtSegmentAnalysisTest_cfi.maxPhiZHit
maxPhiZHit
Definition: dtSegmentAnalysisTest_cfi.py:20
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
mps_merge.weight
weight
Definition: mps_merge.py:88
dtNoiseAnalysis_cfi.detailedAnalysis
detailedAnalysis
Definition: dtNoiseAnalysis_cfi.py:7
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DTSegmentAnalysisTest::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: DTSegmentAnalysisTest.cc:73
DTSegmentAnalysisTest::bookHistos
void bookHistos(DQMStore::IBooker &)
Definition: DTSegmentAnalysisTest.cc:261
dqm::legacy::MonitorElement::getTH1F
virtual TH1F * getTH1F() const
Definition: MonitorElement.h:479
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
bookHistos
void bookHistos()
Definition: Histogram.h:33
MonitorElementData::QReport::getBadChannels
const std::vector< DQMChannel > & getBadChannels() const
Definition: MonitorElementCollection.h:116
DTLayer.h
DTGeometry.h
dqm::impl::MonitorElement::getFloatValue
virtual double getFloatValue() const
Definition: MonitorElement.cc:929
DTTimeEvolutionHisto.h
edm::ParameterSet
Definition: ParameterSet.h:47
DTSegmentAnalysisTest::~DTSegmentAnalysisTest
~DTSegmentAnalysisTest() override
Destructor.
Definition: DTSegmentAnalysisTest.cc:57
Event.h
dtResolutionTest_cfi.histoTag
histoTag
Definition: dtResolutionTest_cfi.py:21
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:675
MonitorElementData::QReport
Definition: MonitorElementCollection.h:55
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
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::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
ALCARECODTCalibSynchCosmicsDQM_cff.folderName
folderName
Definition: ALCARECODTCalibSynchCosmicsDQM_cff.py:9
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
DTSegmentAnalysisTest::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: DTSegmentAnalysisTest.cc:95
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTSegmentAnalysisTest.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
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
DTSegmentAnalysisTest::dqmBeginLuminosityBlock
void dqmBeginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &)
Definition: DTSegmentAnalysisTest.cc:67
DTSegmentAnalysisTest::performClientDiagnostic
void performClientDiagnostic(DQMStore::IGetter &)
Perform client diagnostic operations.
Definition: DTSegmentAnalysisTest.cc:104
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
EventSetup.h
DTSegmentAnalysisTest::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: DTSegmentAnalysisTest.cc:61
dqm::implementation::IBooker
Definition: DQMStore.h:43
DTSegmentAnalysisTest::DTSegmentAnalysisTest
DTSegmentAnalysisTest(const edm::ParameterSet &ps)
Constructor.
Definition: DTSegmentAnalysisTest.cc:39
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
genParticles_cff.map
map
Definition: genParticles_cff.py:11
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
DTSegmentAnalysisTest::getMEName
std::string getMEName(const DTChamberId &chID, std::string histoTag)
Get the ME name.
Definition: DTSegmentAnalysisTest.cc:242
MuonGeometryRecord.h
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
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
weight
Definition: weight.py:1
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