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