CMS 3D CMS Logo

DTChamberEfficiencyTest.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 
12 
13 // Framework
15 
16 // Geometry
19 
21 
22 #include <cstdio>
23 #include <sstream>
24 #include <cmath>
25 
26 using namespace edm;
27 using namespace std;
28 
30  edm::LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyTest") << "[DTChamberEfficiencyTest]: Constructor";
31 
32  parameters = ps;
33 
34  prescaleFactor = parameters.getUntrackedParameter<int>("diagnosticPrescale", 1);
35 
36  nevents = 0;
37 
38  bookingdone = false;
39 }
40 
42  edm::LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyTest")
43  << "DTChamberEfficiencyTest: analyzed " << nevents << " events";
44 }
45 
47  DQMStore::IGetter& igetter,
48  edm::LuminosityBlock const& lumiSeg,
49  edm::EventSetup const& context) {
50  if (!bookingdone) {
51  // Get the DT Geometry
52  context.get<MuonGeometryRecord>().get(muonGeom);
53 
54  // Loop over all the chambers
55  vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
56  vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
57  for (; ch_it != ch_end; ++ch_it) {
58  // histo booking
59  bookHistos(ibooker, (*ch_it)->id());
60  }
61 
62  //summary histo booking
63  bookHistos(ibooker);
64  }
65 
66  bookingdone = true;
67 
68  edm::LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyTest")
69  << "[DTChamberEfficiencyTest]: End of LS transition, performing the DQM client operation";
70 
71  // counts number of lumiSegs
72  nLumiSegs = lumiSeg.id().luminosityBlock();
73 
74  // prescale factor
75  if (nLumiSegs % prescaleFactor != 0)
76  return;
77 
78  edm::LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyTest")
79  << "[DTChamberEfficiencyTest]: " << nLumiSegs << " updates";
80 
81  vector<const DTChamber*>::const_iterator ch_it = muonGeom->chambers().begin();
82  vector<const DTChamber*>::const_iterator ch_end = muonGeom->chambers().end();
83 
84  edm::LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyTest")
85  << "[DTChamberEfficiencyTest]: ChamberEfficiency tests results";
86 
87  // Loop over the chambers
88  for (; ch_it != ch_end; ++ch_it) {
89  DTChamberId chID = (*ch_it)->id();
90 
91  stringstream wheel;
92  wheel << chID.wheel();
93  stringstream station;
94  station << chID.station();
95  stringstream sector;
96  sector << chID.sector();
97 
98  string HistoName = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
99 
100  // Get the ME produced by EfficiencyTask Source
101 
102  MonitorElement* GoodSegDen_histo = igetter.get(getMEName("hEffGoodSegVsPosDen", chID));
103  MonitorElement* GoodCloseSegNum_histo = igetter.get(getMEName("hEffGoodCloseSegVsPosNum", chID));
104 
105  // ME -> TH1F
106  if (GoodSegDen_histo && GoodCloseSegNum_histo) {
107  TH2F* GoodSegDen_histo_root = GoodSegDen_histo->getTH2F();
108  TH2F* GoodCloseSegNum_histo_root = GoodCloseSegNum_histo->getTH2F();
109 
110  int lastBinX = (*GoodSegDen_histo_root).GetNbinsX();
111  TH1D* proxN = GoodCloseSegNum_histo_root->ProjectionX();
112  TH1D* proxD = GoodSegDen_histo_root->ProjectionX();
113 
114  int lastBinY = (*GoodSegDen_histo_root).GetNbinsY();
115  TH1D* proyN = GoodCloseSegNum_histo_root->ProjectionY();
116  TH1D* proyD = GoodSegDen_histo_root->ProjectionY();
117 
118  for (int xBin = 1; xBin <= lastBinX; xBin++) {
119  if (proxD->GetBinContent(xBin) != 0) {
120  float Xefficiency = proxN->GetBinContent(xBin) / proxD->GetBinContent(xBin);
121  xEfficiencyHistos.find(HistoName)->second->setBinContent(xBin, Xefficiency);
122  }
123 
124  for (int yBin = 1; yBin <= lastBinY; yBin++) {
125  if (GoodSegDen_histo_root->GetBinContent(xBin, yBin) != 0) {
126  float XvsYefficiency = GoodCloseSegNum_histo_root->GetBinContent(xBin, yBin) /
127  GoodSegDen_histo_root->GetBinContent(xBin, yBin);
128  xVSyEffHistos.find(HistoName)->second->setBinContent(xBin, yBin, XvsYefficiency);
129  }
130  }
131  }
132 
133  for (int yBin = 1; yBin <= lastBinY; yBin++) {
134  if (proyD->GetBinContent(yBin) != 0) {
135  float Yefficiency = proyN->GetBinContent(yBin) / proyD->GetBinContent(yBin);
136  yEfficiencyHistos.find(HistoName)->second->setBinContent(yBin, Yefficiency);
137  }
138  }
139  }
140  } // loop on chambers
141 
142  // ChamberEfficiency test on X axis
143  string XEfficiencyCriterionName =
144  parameters.getUntrackedParameter<string>("XEfficiencyTestName", "ChEfficiencyInRangeX");
145  for (map<string, MonitorElement*>::const_iterator hXEff = xEfficiencyHistos.begin(); hXEff != xEfficiencyHistos.end();
146  hXEff++) {
147  const QReport* theXEfficiencyQReport = (*hXEff).second->getQReport(XEfficiencyCriterionName);
148  if (theXEfficiencyQReport) {
149  vector<dqm::me_util::Channel> badChannels = theXEfficiencyQReport->getBadChannels();
150  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
151  channel++) {
152  edm::LogError("DTDQM|DTMonitorClient|DTChamberEfficiencyTest")
153  << "Chamber : " << (*hXEff).first << " Bad XChamberEfficiency channels: " << (*channel).getBin()
154  << " Contents : " << (*channel).getContents();
155  }
156  }
157  }
158 
159  // ChamberEfficiency test on Y axis
160  string YEfficiencyCriterionName =
161  parameters.getUntrackedParameter<string>("YEfficiencyTestName", "ChEfficiencyInRangeY");
162  for (map<string, MonitorElement*>::const_iterator hYEff = yEfficiencyHistos.begin(); hYEff != yEfficiencyHistos.end();
163  hYEff++) {
164  const QReport* theYEfficiencyQReport = (*hYEff).second->getQReport(YEfficiencyCriterionName);
165  if (theYEfficiencyQReport) {
166  vector<dqm::me_util::Channel> badChannels = theYEfficiencyQReport->getBadChannels();
167  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
168  channel++) {
169  edm::LogError("DTDQM|DTMonitorClient|DTChamberEfficiencyTest")
170  << "Chamber : " << (*hYEff).first << " Bad YChamberEfficiency channels: " << (*channel).getBin()
171  << " Contents : " << (*channel).getContents();
172  }
173  }
174  }
175 
176  //Fill the report summary histos
177  for (int wh = -2; wh <= 2; wh++) {
178  for (int sec = 1; sec <= 12; sec++) {
179  for (int st = 1; st <= 4; st++) {
180  summaryHistos[wh]->Fill(sec, st, 1);
181  }
182  }
183  }
184 }
185 
187  edm::LogVerbatim("DTDQM|DTMonitorClient|DTChamberEfficiencyTest") << "[DTChamberEfficiencyTest] endjob called!";
188 }
189 
191  stringstream wheel;
192  wheel << chID.wheel();
193  stringstream station;
194  station << chID.station();
195  stringstream sector;
196  sector << chID.sector();
197 
198  string folderRoot = parameters.getUntrackedParameter<string>("folderRoot", "Collector/FU0/");
199  string folderName = folderRoot + "DT/01-DTChamberEfficiency/Task/Wheel" + wheel.str() + "/Sector" + sector.str() +
200  "/Station" + station.str() + "/";
201 
202  string histoname = folderName + histoTag + "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
203 
204  return histoname;
205 }
206 
208  stringstream wheel;
209  wheel << chId.wheel();
210  stringstream station;
211  station << chId.station();
212  stringstream sector;
213  sector << chId.sector();
214 
215  string HistoName = "W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str();
216  string xEfficiencyHistoName = "xEfficiency_" + HistoName;
217  string yEfficiencyHistoName = "yEfficiency_" + HistoName;
218  string xVSyEffHistoName = "xVSyEff_" + HistoName;
219 
220  ibooker.setCurrentFolder("DT/01-DTChamberEfficiency/Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" +
221  station.str());
222 
223  xEfficiencyHistos[HistoName] =
224  ibooker.book1D(xEfficiencyHistoName.c_str(), xEfficiencyHistoName.c_str(), 25, -250., 250.);
225  yEfficiencyHistos[HistoName] =
226  ibooker.book1D(yEfficiencyHistoName.c_str(), yEfficiencyHistoName.c_str(), 25, -250., 250.);
227  xVSyEffHistos[HistoName] =
228  ibooker.book2D(xVSyEffHistoName.c_str(), xVSyEffHistoName.c_str(), 25, -250., 250., 25, -250., 250.);
229 }
230 
232  for (int wh = -2; wh <= 2; wh++) {
233  stringstream wheel;
234  wheel << wh;
235  string histoName = "chEfficiencySummary_W" + wheel.str();
236 
237  ibooker.setCurrentFolder("DT/01-DTChamberEfficiency");
238  summaryHistos[wh] = ibooker.book2D(histoName.c_str(), histoName.c_str(), 12, 1, 13, 4, 1, 5);
239  summaryHistos[wh]->setAxisTitle("Sector", 1);
240  summaryHistos[wh]->setBinLabel(1, "MB1", 2);
241  summaryHistos[wh]->setBinLabel(2, "MB2", 2);
242  summaryHistos[wh]->setBinLabel(3, "MB3", 2);
243  summaryHistos[wh]->setBinLabel(4, "MB4", 2);
244  }
245 }
cmsHarvester.nevents
nevents
Definition: cmsHarvester.py:3177
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
MessageLogger.h
photonAnalyzer_cfi.xBin
xBin
Definition: photonAnalyzer_cfi.py:81
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
DTChamberEfficiencyTest::bookHistos
void bookHistos(DQMStore::IBooker &, const DTChamberId &ch)
book the new ME
Definition: DTChamberEfficiencyTest.cc:207
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
photonAnalyzer_cfi.yBin
yBin
Definition: photonAnalyzer_cfi.py:85
DTChamberEfficiencyTest::getMEName
std::string getMEName(std::string histoTag, const DTChamberId &chID)
Get the ME name.
Definition: DTChamberEfficiencyTest.cc:190
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
bookHistos
void bookHistos()
Definition: Histogram.h:33
MonitorElementData::QReport::getBadChannels
const std::vector< DQMChannel > & getBadChannels() const
Definition: MonitorElementCollection.h:116
DTGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
DTChamberEfficiencyTest::dqmEndLuminosityBlock
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
DQM Client Diagnostic.
Definition: DTChamberEfficiencyTest.cc:46
DTChamberEfficiencyTest::dqmEndJob
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Definition: DTChamberEfficiencyTest.cc:186
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
Skims_PDWG_cff.prescaleFactor
prescaleFactor
Definition: Skims_PDWG_cff.py:25
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
cscdqm::HistoName
std::string HistoName
Definition: CSCDQM_HistoDef.h:32
DTChamberEfficiencyTest::~DTChamberEfficiencyTest
~DTChamberEfficiencyTest() override
Destructor.
Definition: DTChamberEfficiencyTest.cc:41
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:94
ALCARECODTCalibSynchCosmicsDQM_cff.folderName
folderName
Definition: ALCARECODTCalibSynchCosmicsDQM_cff.py:9
DTChamberEfficiencyTest.h
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
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
DTChamberEfficiencyTest::DTChamberEfficiencyTest
DTChamberEfficiencyTest(const edm::ParameterSet &ps)
Constructor.
Definition: DTChamberEfficiencyTest.cc:29
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
dqm::implementation::IBooker
Definition: DQMStore.h:43
dtChamberEfficiencyTest_cfi.folderRoot
folderRoot
Definition: dtChamberEfficiencyTest_cfi.py:9
DTChamberId
Definition: DTChamberId.h:14
MuonGeometryRecord.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:491