CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTChamberEfficiencyClient.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2011/10/31 17:22:23 $
5  * $Revision: 1.9 $
6  * \author M. Pelliccioni - INFN Torino
7  */
8 
12 
15 
18 
19 #include <stdio.h>
20 #include <sstream>
21 #include <math.h>
22 
23 using namespace edm;
24 using namespace std;
25 
26 //two words about conventions: "All" histograms are those made for all segments
27 //while "Qual" histograms are those for segments with at least 12 hits
28 
30 {
31 
32  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
33  << "DTChamberEfficiencyClient: Constructor called";
34 
35  dbe = Service<DQMStore>().operator->();
36 
37  prescaleFactor = pSet.getUntrackedParameter<int>("diagnosticPrescale", 1);
38 }
39 
41 {
42  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
43  << "DTChamberEfficiencyClient: Destructor called";
44 }
45 
47 {
48  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
49  << "DTChamberEfficiencyClient: BeginJob";
50 
51  nevents = 0;
52 
53  bookHistos();
54 
55  return;
56 }
57 
59 {
60  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
61  << "[DTChamberEfficiencyClient]: Begin of LS transition";
62 
63  return;
64 }
65 
67 {
68  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
69  << "DTChamberEfficiencyClient: beginRun";
70 
71  // Get the DT Geometry
72  setup.get<MuonGeometryRecord>().get(muonGeom);
73 
74  return;
75 }
76 
78 {
79 
80  nevents++;
81  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
82  << "[DTChamberEfficiencyClient]: " << nevents << " events";
83  return;
84 }
85 
87 {
88  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
89  << "DTChamberEfficiencyClient: endluminosityBlock";
90 }
91 
92 
94 {
95  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
96  << "DTChamberEfficiencyClient: endRun";
97  // reset the global summary
98  globalEffSummary->Reset();
99 
100  //Loop over the wheels
101  for(int wheel=-2;wheel<=2;wheel++){
102  stringstream wheel_str; wheel_str << wheel;
103 
104  // Get the ME produced by EfficiencyTask Source
105  // All means no selection on segments, Qual means segments with at least 12 hits
106  MonitorElement* MECountAll = dbe->get("DT/05-ChamberEff/Task/hCountSectVsChamb_All_W" + wheel_str.str());
107  MonitorElement* MECountQual = dbe->get("DT/05-ChamberEff/Task/hCountSectVsChamb_Qual_W" + wheel_str.str());
108  MonitorElement* MEExtrap = dbe->get("DT/05-ChamberEff/Task/hExtrapSectVsChamb_W" + wheel_str.str());
109 
110  //get the TH2F
111  if(!MECountAll) cout<<"fucking ME is null"<<endl;
112  if(!(MECountAll->getTH2F())) cout<<"fucking puntator is null!"<<endl;
113  TH2F* hCountAll = MECountAll->getTH2F();
114  TH2F* hCountQual = MECountQual->getTH2F();
115  TH2F* hExtrap = MEExtrap->getTH2F();
116 
117 
118 
119  const int nBinX = summaryHistos[wheel+2][0]->getNbinsX();
120  const int nBinY = summaryHistos[wheel+2][0]->getNbinsY();
121 
122  for(int j=1;j<=nBinX;j++){
123  for(int k=1;k<=nBinY;k++){
124  summaryHistos[wheel+2][0]->setBinContent(j,k,0.);
125  summaryHistos[wheel+2][1]->setBinContent(j,k,0.);
126 
127  const float numerAll = hCountAll->GetBinContent(j,k);
128  const float numerQual = hCountQual->GetBinContent(j,k);
129  const float denom = hExtrap->GetBinContent(j,k);
130 
131  if(denom != 0.){
132  const float effAll= numerAll/denom;
133  const float eff_error_All = sqrt((effAll+effAll*effAll)/denom);
134 
135  const float effQual= numerQual/denom;
136  const float eff_error_Qual = sqrt((effQual+effQual*effQual)/denom);
137 
138  //if(wheel == 2 && k == 2 && j == 2) cout << "Eff ch " << effAll << " " << lumiSeg.id() << endl;
139 
140  summaryHistos[wheel+2][0]->setBinContent(j,k,effAll);
141  summaryHistos[wheel+2][0]->setBinError(j,k,eff_error_All);
142 
143  summaryHistos[wheel+2][1]->setBinContent(j,k,effQual);
144  summaryHistos[wheel+2][1]->setBinError(j,k,eff_error_Qual);
145 
146  // Fill 1D eff distributions
147  globalEffDistr -> Fill(effAll);
148  EffDistrPerWh[wheel+2] -> Fill(effAll);
149 
150  }
151  }
152  }
153  }
154 
155  // fill the global eff. summary
156  // problems at a granularity smaller than the chamber are ignored
157  for(int wheel=-2; wheel<=2; wheel++) { // loop over wheels
158  // retrieve the chamber efficiency summary
159  MonitorElement * segmentWheelSummary = summaryHistos[wheel+2][0];
160  if(segmentWheelSummary != 0) {
161 
162  for(int sector=1; sector<=12; sector++) { // loop over sectors
163  float nFailingChambers = 0.;
164 
165  double meaneff = 0.;
166  double errorsum = 0.;
167 
168  for(int station = 1; station != 5; ++station) { // loop over stations
169 
170  const double tmpefficiency = segmentWheelSummary->getBinContent(sector, station);
171  const double tmpvariance = pow(segmentWheelSummary->getBinError(sector, station),2);
172 
173  //if(wheel == 2 && sector == 9) cout << "ch " << station << " " << tmpefficiency << " " << tmpvariance << " " << lumiSeg.id() << endl;
174 
175  if(tmpefficiency < 0.2 || tmpvariance == 0){
176  nFailingChambers++;
177  continue;
178  }
179 
180  meaneff += tmpefficiency/tmpvariance;
181  errorsum += 1./tmpvariance;
182 
183  LogTrace("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
184  << "Wheel: " << wheel << " Stat: " << station
185  << " Sect: " << sector << " status: " << meaneff/errorsum << endl;
186  }
187 
188  if(sector == 4 || sector == 10) {
189  int whichSector = (sector == 4) ? 13 : 14;
190 
191  const double tmpefficiency = segmentWheelSummary->getBinContent(whichSector, 4);
192  const double tmpvariance = pow(segmentWheelSummary->getBinError(whichSector, 4),2);
193 
194  if(tmpefficiency > 0.2 && tmpvariance != 0) {
195  meaneff += tmpefficiency/tmpvariance;
196  errorsum += 1./tmpvariance;
197  }
198  else nFailingChambers++;
199 
200  }
201 
202  double eff_result = 0;
203  if(errorsum != 0) eff_result = meaneff/errorsum;
204 
205  if(nFailingChambers != 0) {
206  if(sector != 4 && sector != 10) eff_result = eff_result*(4.-nFailingChambers)/4.;
207  else eff_result = eff_result*(5.-nFailingChambers)/5.;
208  }
209 
210  if(eff_result > 0.7) globalEffSummary->Fill(sector,wheel,1.);
211  else if(eff_result < 0.7 && eff_result > 0.5) globalEffSummary->Fill(sector,wheel,0.6);
212  else if(eff_result < 0.5 && eff_result > 0.3) globalEffSummary->Fill(sector,wheel,0.4);
213  else if(eff_result < 0.3 && eff_result > 0.) globalEffSummary->Fill(sector,wheel,0.15);
214 
215  //if(wheel == 2 && sector == 9) cout << "eff_result " << eff_result << endl;
216  //if(wheel == 2 && sector == 9) cout << "nfail " << nFailingChambers++ << endl;
217 
218  }
219  }
220  }
221  return;
222 }
223 
225 {
226  LogVerbatim ("DTDQM|DTMonitorClient|DTChamberEfficiencyClient")
227  << "DTChamberEfficiencyClient: endJob";
228  return;
229 }
230 
232 {
233 
234  dbe->setCurrentFolder("DT/05-ChamberEff");
235  globalEffSummary = dbe->book2D("EfficiencyGlbSummary","Efficiency Summary",12,1,13,5,-2,3);
236  globalEffSummary->setAxisTitle("sector",1);
237  globalEffSummary->setAxisTitle("wheel",2);
238 
239  globalEffDistr = dbe->book1D("TotalEfficiency","Total efficiency",51,0.,1.02);
240  globalEffDistr -> setAxisTitle("Eff",1);
241 
242  for(int wh=-2; wh<=2; wh++){
243  stringstream wheel; wheel << wh;
244  string histoNameAll = "EfficiencyMap_All_W" + wheel.str();
245  string histoTitleAll = "Efficiency map for all segments for wheel " + wheel.str();
246 
247  string histoNameQual = "EfficiencyMap_Qual_W" + wheel.str();
248  string histoTitleQual = "Efficiency map for quality segments for wheel " + wheel.str();
249 
250  string histoNameEff = "Efficiency_W" + wheel.str();
251  string histoTitleEff = "Segment efficiency, wheel " + wheel.str();
252 
253  dbe->setCurrentFolder("DT/05-ChamberEff");
254 
255  summaryHistos[wh+2][0] = dbe->book2D(histoNameAll.c_str(),histoTitleAll.c_str(),14,1.,15.,4,1.,5.);
256  summaryHistos[wh+2][0]->setAxisTitle("Sector",1);
257  summaryHistos[wh+2][0]->setBinLabel(1,"MB1",2);
258  summaryHistos[wh+2][0]->setBinLabel(2,"MB2",2);
259  summaryHistos[wh+2][0]->setBinLabel(3,"MB3",2);
260  summaryHistos[wh+2][0]->setBinLabel(4,"MB4",2);
261 
262  EffDistrPerWh[wh+2] = dbe -> book1D(histoNameEff.c_str(),histoTitleEff.c_str(),51,0.,1.02);
263  EffDistrPerWh[wh+2] -> setAxisTitle("Eff",1);
264 
265  dbe->setCurrentFolder("DT/05-ChamberEff/HighQual");
266 
267  summaryHistos[wh+2][1] = dbe->book2D(histoNameQual.c_str(),histoTitleQual.c_str(),14,1.,15.,4,1.,5.);
268  summaryHistos[wh+2][1]->setAxisTitle("Sector",1);
269  summaryHistos[wh+2][1]->setBinLabel(1,"MB1",2);
270  summaryHistos[wh+2][1]->setBinLabel(2,"MB2",2);
271  summaryHistos[wh+2][1]->setBinLabel(3,"MB3",2);
272  summaryHistos[wh+2][1]->setBinLabel(4,"MB4",2);
273 
274  }
275 
276  return;
277 }
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
DQM Client Diagnostic.
void beginRun(const edm::Run &run, const edm::EventSetup &setup)
T getUntrackedParameter(std::string const &, T const &) const
void bookHistos()
Definition: Histogram.h:33
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T sqrt(T t)
Definition: SSEVec.h:46
virtual ~DTChamberEfficiencyClient()
Destructor.
int j
Definition: DBlmapReader.cc:9
int nevents
void endRun(edm::Run const &run, edm::EventSetup const &c)
#define LogTrace(id)
int k[5][pyjets_maxn]
void analyze(const edm::Event &e, const edm::EventSetup &c)
void bookHistos()
book the report summary
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
const T & get() const
Definition: EventSetup.h:55
double getBinContent(int binx) const
get content of bin (1-D)
void endLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &c)
tuple cout
Definition: gather_cfg.py:121
TH2F * getTH2F(void) const
DTChamberEfficiencyClient(const edm::ParameterSet &ps)
Constructor.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Definition: Run.h:33