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