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