CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTTriggerLutTest.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2011/06/10 13:50:12 $
5  * $Revision: 1.1 $
6  * \author D. Fasanella - INFN Bologna
7  */
8 
9 
10 // This class header
12 
13 // Framework headers
18 // Geometry
21 
22 // Root
23 #include "TF1.h"
24 //#include "TSpectrum.h"
25 
26 
27 //C++ headers
28 #include <iostream>
29 #include <sstream>
30 
31 
32 using namespace edm;
33 using namespace std;
34 
35 
37 
38  setConfig(ps,"DTTriggerLut");
39  baseFolderDCC = "DT/03-LocalTrigger-DCC/";
40  baseFolderDDU = "DT/04-LocalTrigger-DDU/";
41  thresholdWarnPhi = ps.getUntrackedParameter<double>("thresholdWarnPhi");
42  thresholdErrPhi = ps.getUntrackedParameter<double>("thresholdErrPhi");
43  thresholdWarnPhiB = ps.getUntrackedParameter<double>("thresholdWarnPhiB");
44  thresholdErrPhiB = ps.getUntrackedParameter<double>("thresholdErrPhiB");
45  validRange = ps.getUntrackedParameter<double>("validRange");
46  detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis");
47 
48 }
49 
50 
52 
53 }
54 
55 
57 
59 
60  vector<string>::const_iterator iTr = trigSources.begin();
61  vector<string>::const_iterator trEnd = trigSources.end();
62  vector<string>::const_iterator iHw = hwSources.begin();
63  vector<string>::const_iterator hwEnd = hwSources.end();
64 
65  //Booking
66  if(parameters.getUntrackedParameter<bool>("staticBooking")){
67 
68  for (; iTr != trEnd; ++iTr){
69  trigSource = (*iTr);
70  for (; iHw != hwEnd; ++iHw){
71  hwSource = (*iHw);
72  // Loop over the TriggerUnits
73  for (int wh=-2; wh<=2; ++wh){
74  if (detailedAnalysis){
75  bookWheelHistos(wh,"PhiResidualPercentage");
76  bookWheelHistos(wh,"PhibResidualPercentage");
77  }
78 
79  bookWheelHistos(wh,"PhiLutSummary","Summaries");
80  bookWheelHistos(wh,"PhibLutSummary","Summaries");
81 
82  if (detailedAnalysis){
83  bookWheelHistos(wh,"PhiResidualMean");
84  bookWheelHistos(wh,"PhiResidualRMS");
85  bookWheelHistos(wh,"PhibResidualMean");
86  bookWheelHistos(wh,"PhibResidualRMS");
87  bookWheelHistos(wh,"CorrelationFactorPhi");
88  bookWheelHistos(wh,"CorrelationFactorPhib");
89  bookWheelHistos(wh,"DoublePeakFlagPhib");
90  }
91 
92  }
93 
94  bookCmsHistos("TrigLutSummary","",true);
95  bookCmsHistos("PhiLutSummary");
96  bookCmsHistos("PhibLutSummary");
97  if (detailedAnalysis){
98  bookCmsHistos1d("PhiPercentageSummary");
99  bookCmsHistos1d("PhibPercentageSummary");
100  }
101  }
102  }
103  }
104 
105 }
106 
107 
109 
111 
112 }
113 
114 
116 
117  // Reset lut percentage 1D summaries
118  if (detailedAnalysis){
119  cmsME.find(fullName("PhiPercentageSummary"))->second->Reset();
120  cmsME.find(fullName("PhibPercentageSummary"))->second->Reset();
121  }
122 
123  // Loop over Trig & Hw sources
124  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
125  trigSource = (*iTr);
126  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
127  hwSource = (*iHw);
128  vector<DTChamber*>::const_iterator chIt = muonGeom->chambers().begin();
129  vector<DTChamber*>::const_iterator chEnd = muonGeom->chambers().end();
130  for (; chIt != chEnd; ++chIt) {
131 
132  DTChamberId chId((*chIt)->id());
133  int wh = chId.wheel();
134  int sect = chId.sector();
135  int stat = chId.station();
136 
137  std::map<std::string,MonitorElement*> &innerME = whME[wh];
138 
139  // Make Phi Residual Summary
140  TH1F * PhiResidual = getHisto<TH1F>(dbe->get(getMEName("PhiResidual","Segment", chId)));
141  int phiSummary = 1;
142  if (PhiResidual && PhiResidual->GetEntries()>10) {
143 
144  if( innerME.find(fullName("PhiResidualPercentage")) == innerME.end() ){
145  bookWheelHistos(wh,"PhiResidualPercentage");
146  }
147 
148  float rangeBin = validRange/(PhiResidual->GetBinWidth(1));
149  float center = (PhiResidual->GetNbinsX())/2.;
150  float perc = (PhiResidual->Integral(floor(center-rangeBin),ceil(center+rangeBin)))/(PhiResidual->Integral());
151  fillWhPlot(innerME.find(fullName("PhiResidualPercentage"))->second,sect,stat,perc,false);
152  phiSummary = performLutTest(perc,thresholdWarnPhi,thresholdErrPhi);
153  if (detailedAnalysis) cmsME.find(fullName("PhiPercentageSummary"))->second->Fill(perc);
154 
155  }
156 
157  fillWhPlot(innerME.find(fullName("PhiLutSummary"))->second,sect,stat,phiSummary);
158 
159  if (detailedAnalysis){
160 
161 // if ((phiSummary ==0)&& (PhiResidual->GetEntries()>100)) { //Precision Peak test
162 
163 // Float_t *source = new float[31];
164 // Float_t *dest = new float[31];
165 // //TSpectrum *g = new TSpectrum(5);
166 // float media = PhiResidual->GetMean();
167 // int center = PhiResidual->GetXaxis()->FindBin(media);
168 // for (int i = 0; i < 30; i++) {
169 // source[i]=PhiResidual->GetBinContent(center+i-15);}
170 // int nFound = g->SearchHighRes(source, dest, 30, 1, 6, kFALSE, 5, kTRUE,2);
171 // /if (nFound>1) { // has more than 1 peak
172 // if( innerME.find(fullName("DoublePeakFlagPhi")) == innerME.end() ){
173 // bookWheelHistos(wh,"DoublePeakFlagPhi");
174 // }
175 // }
176 
177 // fillWhPlot(innerME.find(fullName("DoublePeakFlagPhi"))->second,sect,stat,1,false);
178 // }
179 
180  if ((phiSummary==0)||(phiSummary==3)){ //Information on the Peak
181 
182  if( innerME.find(fullName("PhiResidualMean")) == innerME.end() ){
183  bookWheelHistos(wh,"PhiResidualMean");
184  bookWheelHistos(wh,"PhiResidualRMS");
185  }
186 
187  float center = (PhiResidual->GetNbinsX())/2.;
188  float rangeBin = validRange/(PhiResidual->GetBinWidth(1));
189  PhiResidual->GetXaxis()->SetRange(floor(center-rangeBin),ceil(center+rangeBin));
190  float max = PhiResidual->GetMaximumBin();
191  float maxBin = PhiResidual->GetXaxis()->FindBin(max);
192  float nBinMax = 0.5/(PhiResidual->GetBinWidth(1));
193  PhiResidual->GetXaxis()->SetRange(floor(maxBin-nBinMax),ceil(maxBin+nBinMax));
194  float Mean = PhiResidual->GetMean();
195  float rms = PhiResidual->GetRMS();
196 
197  fillWhPlot(innerME.find(fullName("PhiResidualMean"))->second,sect,stat,Mean);
198  fillWhPlot(innerME.find(fullName("PhiResidualRMS"))->second,sect,stat,rms);
199 
200  }
201 
202  TH2F * TrackPhitkvsPhitrig = getHisto<TH2F>(dbe->get(getMEName("PhitkvsPhitrig","Segment", chId)));
203 
204  if (TrackPhitkvsPhitrig && TrackPhitkvsPhitrig->GetEntries()>100) {
205  float corr = TrackPhitkvsPhitrig->GetCorrelationFactor();
206  if( innerME.find(fullName("CorrelationFactorPhi")) == innerME.end() ){
207  bookWheelHistos(wh,"CorrelationFactorPhi");
208  }
209  fillWhPlot(innerME.find(fullName("CorrelationFactorPhi"))->second,sect,stat,corr,false);
210  }
211 
212  }
213 
214 
215  // Make Phib Residual Summary
216  TH1F * PhibResidual = getHisto<TH1F>(dbe->get(getMEName("PhibResidual","Segment", chId)));
217  int phibSummary = stat==3 ? -1 : 1; // station 3 has no meaningful MB3 phi bending information
218 
219  if (stat != 3 && PhibResidual && PhibResidual->GetEntries()>10) {// station 3 has no meaningful MB3 phi bending information
220 
221  if( innerME.find(fullName("PhibResidualPercentage")) == innerME.end() ){
222  bookWheelHistos(wh,"PhibResidualPercentage");
223  }
224 
225  float rangeBin = validRange/(PhibResidual->GetBinWidth(1));
226  float center = (PhibResidual->GetNbinsX())/2.;
227  float perc = (PhibResidual->Integral(floor(center-rangeBin),ceil(center+rangeBin)))/(PhibResidual->Integral());
228 
229  fillWhPlot(innerME.find(fullName("PhibResidualPercentage"))->second,sect,stat,perc,false);
230  phibSummary = performLutTest(perc,thresholdWarnPhiB,thresholdErrPhiB);
231  if (detailedAnalysis) cmsME.find(fullName("PhibPercentageSummary"))->second->Fill(perc);
232 
233  }
234 
235  fillWhPlot(innerME.find(fullName("PhibLutSummary"))->second,sect,stat,phibSummary);
236 
237  if (detailedAnalysis){
238 
239 // if ((phibSummary ==0)&& (PhibResidual->GetEntries()>100)) { //Precision Peak test
240 // Float_t * source = new float[31];
241 // Float_t * dest = new float[31];
242 // TSpectrum *spec = new TSpectrum(5);
243 // float media = PhibResidual->GetMean();
244 // int center= PhibResidual->GetXaxis()->FindBin(media);
245 // for (int i = 0; i < 30; i++) {
246 // source[i]=PhibResidual->GetBinContent(center+i-15);
247 // }
248 // int nFound = spec->SearchHighRes(source,dest,30,1,6,kFALSE,5,kTRUE,2);
249 // if (nFound>1) { // has more than 1 peak
250 // if( innerME.find(fullName("DoublePeakFlagPhib")) == innerME.end() ){
251 // bookWheelHistos(wh,"DoublePeakFlagPhib");
252 // }
253 // fillWhPlot(innerME.find(fullName("DoublePeakFlagPhib"))->second,sect,stat,1,false);
254 // }
255 // }
256 
257  if ((phibSummary==0)||(phibSummary==3)){
258 
259  if( innerME.find(fullName("PhibResidualMean")) == innerME.end() ){
260  bookWheelHistos(wh,"PhibResidualMean");
261  bookWheelHistos(wh,"PhibResidualRMS");
262  }
263 
264  float center = (PhibResidual->GetNbinsX())/2.;
265  float rangeBin = validRange/(PhibResidual->GetBinWidth(1));
266  PhibResidual->GetXaxis()->SetRange(floor(center-rangeBin),ceil(center+rangeBin));
267  float max = PhibResidual->GetMaximumBin();
268  float maxBin = PhibResidual->GetXaxis()->FindBin(max);
269  float nBinMax = 0.5/(PhibResidual->GetBinWidth(1));
270  PhibResidual->GetXaxis()->SetRange(floor(maxBin-nBinMax),ceil(maxBin+nBinMax));
271  float Mean = PhibResidual->GetMean();
272  float rms = PhibResidual->GetRMS();
273 
274  fillWhPlot(innerME.find(fullName("PhibResidualMean"))->second,sect,stat,Mean);
275  fillWhPlot(innerME.find(fullName("PhibResidualRMS"))->second,sect,stat,rms);
276  }
277 
278  TH2F * TrackPhibtkvsPhibtrig = getHisto<TH2F>(dbe->get(getMEName("PhibtkvsPhibtrig","Segment", chId)));
279  if (TrackPhibtkvsPhibtrig && TrackPhibtkvsPhibtrig->GetEntries()>100) {
280 
281  float corr = TrackPhibtkvsPhibtrig->GetCorrelationFactor();
282  if( innerME.find(fullName("CorrelationFactorPhib")) == innerME.end() ){
283  bookWheelHistos(wh,"CorrelationFactorPhib");
284  }
285 
286  fillWhPlot(innerME.find(fullName("CorrelationFactorPhib"))->second,sect,stat,corr,false);
287 
288  }
289 
290  }
291  }
292  }
293  }
294 
295  // Barrel Summary Plots
296  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
297  trigSource = (*iTr);
298  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
299  hwSource = (*iHw);
300  for (int wh=-2; wh<=2; ++wh){
301 
302  std::map<std::string,MonitorElement*> *innerME = &(whME[wh]);
303 
304  TH2F* phiWhSummary = getHisto<TH2F>(innerME->find(fullName("PhiLutSummary"))->second);
305  TH2F* phibWhSummary = getHisto<TH2F>(innerME->find(fullName("PhibLutSummary"))->second);
306 
307  for (int sect=1; sect<=12; ++sect){
308 
309  int phiSectorTotal = 0; // CB dai 1 occhio a questo
310  int phibSectorTotal = 0;
311  int nullphi = 0;
312  int nullphib = 0;
313  int phiStatus = 5;
314  int phibStatus = 5;
315  int glbStatus = 0;
316 
317  for (int stat=1; stat<=4; ++stat){
318  if (phiWhSummary->GetBinContent(sect,stat)==2){
319  phiSectorTotal +=1;
320  glbStatus += 1;
321  }
322  if (phiWhSummary->GetBinContent(sect,stat)==1)
323  nullphi+=1;
324  if (phibWhSummary->GetBinContent(sect,stat)==2) {
325  phibSectorTotal+=1;
326  glbStatus += 1;
327  }
328  if (phibWhSummary->GetBinContent(sect,stat)==1)
329  nullphib+=1;
330  }
331  if (nullphi!=4)
332  phiStatus=phiSectorTotal;
333  else
334  phiStatus=5;
335  if (nullphib!=3)
336  phibStatus=phibSectorTotal;
337  else
338  phibStatus=5;
339 
340  cmsME.find("TrigLutSummary")->second->setBinContent(sect,wh+3,glbStatus);
341  cmsME.find(fullName("PhiLutSummary"))->second->setBinContent(sect,wh+3,phiStatus);
342  cmsME.find(fullName("PhibLutSummary"))->second->setBinContent(sect,wh+3,phibStatus);
343  }
344  }
345  }
346  }
347 
348 }
349 
350 int DTTriggerLutTest::performLutTest(double perc,double thresholdWarn ,double thresholdErr) {
351 
352  bool isInWarn = perc<thresholdWarn;
353  bool isInErr = perc<thresholdErr;
354 
355  int result= isInErr ? 2 : isInWarn ? 3 : 0;
356 
357  return result;
358 
359 }
360 
361 void DTTriggerLutTest::bookCmsHistos1d(string hTag, string folder) {
362 
363  string basedir = topFolder(true);
364  if (folder != "") {
365  basedir += folder +"/" ;
366  }
367  dbe->setCurrentFolder(basedir);
368 
369  string hName = fullName(hTag);
370  LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hName;
371 
372 
373  MonitorElement* me = dbe->book1D(hName.c_str(),hName.c_str(),101,-0.005,1.005);
374  me->setAxisTitle("Percentage",1);
375  cmsME[hName] = me;
376 
377 }
378 
379 void DTTriggerLutTest::fillWhPlot(MonitorElement *plot, int sect, int stat, float value, bool lessIsBest) {
380 
381  if (sect>12) {
382  int scsect = sect==13 ? 4 : 10;
383  if ((value>plot->getBinContent(scsect,stat)) == lessIsBest) {
384  plot->setBinContent(scsect,stat,value);
385  }
386  }
387  else {
388  plot->setBinContent(sect,stat,value);
389  }
390 
391  return;
392 
393 }
394 
395 
T getUntrackedParameter(std::string const &, T const &) const
dictionary parameters
Definition: Parameters.py:2
void setBinContent(int binx, double content)
set content of bin (1-D)
void bookCmsHistos1d(std::string hTag, std::string folder="")
DTTriggerLutTest(const edm::ParameterSet &ps)
Constructor.
virtual ~DTTriggerLutTest()
Destructor.
int performLutTest(double perc, double threshold1, double threshold2)
Perform Lut Test logical operations.
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
void fillWhPlot(MonitorElement *plot, int sect, int stat, float value, bool lessIsBest=true)
Fill summary plots managing double MB4 chambers.
void beginJob()
BeginJob.
tuple result
Definition: query.py:137
#define LogTrace(id)
JetCorrectorParameters corr
Definition: classes.h:11
string fullName
void runClientDiagnostic()
Run client analysis.
double getBinContent(int binx) const
get content of bin (1-D)
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
Definition: Run.h:36
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:137