test
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  * \author D. Fasanella - INFN Bologna
5  *
6  * threadsafe version (//-) oct/nov 2014 - WATWanAbdullah -ncpp-um-my
7  *
8  */
9 
10 
11 // This class header
13 
14 // Framework headers
19 // Geometry
22 
23 // Root
24 #include "TF1.h"
25 //#include "TSpectrum.h"
26 
27 
28 //C++ headers
29 #include <iostream>
30 #include <sstream>
31 
32 
33 using namespace edm;
34 using namespace std;
35 
36 
38 
39  setConfig(ps,"DTTriggerLut");
40  baseFolderTM = "DT/03-LocalTrigger-TM/";
41  baseFolderDDU = "DT/04-LocalTrigger-DDU/";
42  thresholdWarnPhi = ps.getUntrackedParameter<double>("thresholdWarnPhi");
43  thresholdErrPhi = ps.getUntrackedParameter<double>("thresholdErrPhi");
44  thresholdWarnPhiB = ps.getUntrackedParameter<double>("thresholdWarnPhiB");
45  thresholdErrPhiB = ps.getUntrackedParameter<double>("thresholdErrPhiB");
46  validRange = ps.getUntrackedParameter<double>("validRange");
47  detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis");
48 
49  bookingdone = 0;
50 
51 }
52 
53 
55 
56 }
57 
58 
60 
61  bookingdone = 1;
62 
63  vector<string>::const_iterator iTr = trigSources.begin();
64  vector<string>::const_iterator trEnd = trigSources.end();
65  vector<string>::const_iterator iHw = hwSources.begin();
66  vector<string>::const_iterator hwEnd = hwSources.end();
67 
68  //Booking
69  if(parameters.getUntrackedParameter<bool>("staticBooking")){
70 
71  for (; iTr != trEnd; ++iTr){
72  trigSource = (*iTr);
73  for (; iHw != hwEnd; ++iHw){
74  hwSource = (*iHw);
75  // Loop over the TriggerUnits
76  for (int wh=-2; wh<=2; ++wh){
77  if (detailedAnalysis){
78  bookWheelHistos(ibooker,wh,"PhiResidualPercentage");
79  bookWheelHistos(ibooker,wh,"PhibResidualPercentage");
80  }
81 
82  bookWheelHistos(ibooker,wh,"PhiLutSummary","Summaries");
83  bookWheelHistos(ibooker,wh,"PhibLutSummary","Summaries");
84 
85  if (detailedAnalysis){
86  bookWheelHistos(ibooker,wh,"PhiResidualMean");
87  bookWheelHistos(ibooker,wh,"PhiResidualRMS");
88  bookWheelHistos(ibooker,wh,"PhibResidualMean");
89  bookWheelHistos(ibooker,wh,"PhibResidualRMS");
90  bookWheelHistos(ibooker,wh,"CorrelationFactorPhi");
91  bookWheelHistos(ibooker,wh,"CorrelationFactorPhib");
92  bookWheelHistos(ibooker,wh,"DoublePeakFlagPhib");
93  }
94 
95  }
96 
97  bookCmsHistos(ibooker,"TrigLutSummary","",true);
98  bookCmsHistos(ibooker,"PhiLutSummary");
99  bookCmsHistos(ibooker,"PhibLutSummary");
100  if (detailedAnalysis){
101 
102  bookCmsHistos1d(ibooker,"PhiPercentageSummary");
103  bookCmsHistos1d(ibooker,"PhibPercentageSummary");
104  }
105  }
106  }
107  }
108 }
109 
110 
112 
114 
115 }
116 
118 
119  if (!bookingdone) Bookings(ibooker,igetter);
120 
121  // Reset lut percentage 1D summaries
122  if (detailedAnalysis){
123  cmsME.find(fullName("PhiPercentageSummary"))->second->Reset();
124  cmsME.find(fullName("PhibPercentageSummary"))->second->Reset();
125  }
126 
127  // Loop over Trig & Hw sources
128  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
129  trigSource = (*iTr);
130  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
131  hwSource = (*iHw);
132  vector<const DTChamber*>::const_iterator chIt = muonGeom->chambers().begin();
133  vector<const DTChamber*>::const_iterator chEnd = muonGeom->chambers().end();
134  for (; chIt != chEnd; ++chIt) {
135 
136  DTChamberId chId((*chIt)->id());
137  int wh = chId.wheel();
138  int sect = chId.sector();
139  int stat = chId.station();
140 
141  std::map<std::string,MonitorElement*> &innerME = whME[wh];
142 
143  // Make Phi Residual Summary
144  TH1F * PhiResidual = getHisto<TH1F>(igetter.get(getMEName("PhiResidual","Segment", chId)));
145  int phiSummary = 1;
146  if (PhiResidual && PhiResidual->GetEntries()>10) {
147 
148  if( innerME.find(fullName("PhiResidualPercentage")) == innerME.end() ){
149  bookWheelHistos(ibooker,wh,"PhiResidualPercentage");
150  }
151 
152  float rangeBin = validRange/(PhiResidual->GetBinWidth(1));
153  float center = (PhiResidual->GetNbinsX())/2.;
154  float perc = (PhiResidual->Integral(floor(center-rangeBin),ceil(center+rangeBin)))/(PhiResidual->Integral());
155  fillWhPlot(innerME.find(fullName("PhiResidualPercentage"))->second,sect,stat,perc,false);
156  phiSummary = performLutTest(perc,thresholdWarnPhi,thresholdErrPhi);
157  if (detailedAnalysis) cmsME.find(fullName("PhiPercentageSummary"))->second->Fill(perc);
158 
159  }
160 
161  fillWhPlot(innerME.find(fullName("PhiLutSummary"))->second,sect,stat,phiSummary);
162 
163  if (detailedAnalysis){
164 
165  if ((phiSummary==0)||(phiSummary==3)){ //Information on the Peak
166 
167  if( innerME.find(fullName("PhiResidualMean")) == innerME.end() ){
168  bookWheelHistos(ibooker,wh,"PhiResidualMean");
169  bookWheelHistos(ibooker,wh,"PhiResidualRMS");
170  }
171 
172  float center = (PhiResidual->GetNbinsX())/2.;
173  float rangeBin = validRange/(PhiResidual->GetBinWidth(1));
174  PhiResidual->GetXaxis()->SetRange(floor(center-rangeBin),ceil(center+rangeBin));
175  float max = PhiResidual->GetMaximumBin();
176  float maxBin = PhiResidual->GetXaxis()->FindBin(max);
177  float nBinMax = 0.5/(PhiResidual->GetBinWidth(1));
178  PhiResidual->GetXaxis()->SetRange(floor(maxBin-nBinMax),ceil(maxBin+nBinMax));
179  float Mean = PhiResidual->GetMean();
180  float rms = PhiResidual->GetRMS();
181 
182  fillWhPlot(innerME.find(fullName("PhiResidualMean"))->second,sect,stat,Mean);
183  fillWhPlot(innerME.find(fullName("PhiResidualRMS"))->second,sect,stat,rms);
184 
185  }
186 
187  TH2F * TrackPhitkvsPhitrig = getHisto<TH2F>(igetter.get(getMEName("PhitkvsPhitrig","Segment", chId)));
188 
189  if (TrackPhitkvsPhitrig && TrackPhitkvsPhitrig->GetEntries()>100) {
190  float corr = TrackPhitkvsPhitrig->GetCorrelationFactor();
191  if( innerME.find(fullName("CorrelationFactorPhi")) == innerME.end() ){
192  bookWheelHistos(ibooker,wh,"CorrelationFactorPhi");
193  }
194  fillWhPlot(innerME.find(fullName("CorrelationFactorPhi"))->second,sect,stat,corr,false);
195  }
196 
197  }
198 
199 
200  // Make Phib Residual Summary
201  TH1F * PhibResidual = getHisto<TH1F>(igetter.get(getMEName("PhibResidual","Segment", chId)));
202  int phibSummary = stat==3 ? -1 : 1; // station 3 has no meaningful MB3 phi bending information
203 
204  if (stat != 3 && PhibResidual && PhibResidual->GetEntries()>10) {// station 3 has no meaningful MB3 phi bending information
205 
206  if( innerME.find(fullName("PhibResidualPercentage")) == innerME.end() ){
207  bookWheelHistos(ibooker,wh,"PhibResidualPercentage");
208  }
209 
210  float rangeBin = validRange/(PhibResidual->GetBinWidth(1));
211  float center = (PhibResidual->GetNbinsX())/2.;
212  float perc = (PhibResidual->Integral(floor(center-rangeBin),ceil(center+rangeBin)))/(PhibResidual->Integral());
213 
214  fillWhPlot(innerME.find(fullName("PhibResidualPercentage"))->second,sect,stat,perc,false);
215  phibSummary = performLutTest(perc,thresholdWarnPhiB,thresholdErrPhiB);
216  if (detailedAnalysis) cmsME.find(fullName("PhibPercentageSummary"))->second->Fill(perc);
217 
218  }
219 
220  fillWhPlot(innerME.find(fullName("PhibLutSummary"))->second,sect,stat,phibSummary);
221 
222  if (detailedAnalysis){
223 
224  if ((phibSummary==0)||(phibSummary==3)){
225 
226  if( innerME.find(fullName("PhibResidualMean")) == innerME.end() ){
227  bookWheelHistos(ibooker,wh,"PhibResidualMean");
228  bookWheelHistos(ibooker,wh,"PhibResidualRMS");
229  }
230 
231  float center = (PhibResidual->GetNbinsX())/2.;
232  float rangeBin = validRange/(PhibResidual->GetBinWidth(1));
233  PhibResidual->GetXaxis()->SetRange(floor(center-rangeBin),ceil(center+rangeBin));
234  float max = PhibResidual->GetMaximumBin();
235  float maxBin = PhibResidual->GetXaxis()->FindBin(max);
236  float nBinMax = 0.5/(PhibResidual->GetBinWidth(1));
237  PhibResidual->GetXaxis()->SetRange(floor(maxBin-nBinMax),ceil(maxBin+nBinMax));
238  float Mean = PhibResidual->GetMean();
239  float rms = PhibResidual->GetRMS();
240 
241  fillWhPlot(innerME.find(fullName("PhibResidualMean"))->second,sect,stat,Mean);
242  fillWhPlot(innerME.find(fullName("PhibResidualRMS"))->second,sect,stat,rms);
243  }
244 
245  TH2F * TrackPhibtkvsPhibtrig = getHisto<TH2F>(igetter.get(getMEName("PhibtkvsPhibtrig","Segment", chId)));
246  if (TrackPhibtkvsPhibtrig && TrackPhibtkvsPhibtrig->GetEntries()>100) {
247 
248  float corr = TrackPhibtkvsPhibtrig->GetCorrelationFactor();
249  if( innerME.find(fullName("CorrelationFactorPhib")) == innerME.end() ){
250  bookWheelHistos(ibooker,wh,"CorrelationFactorPhib");
251  }
252 
253  fillWhPlot(innerME.find(fullName("CorrelationFactorPhib"))->second,sect,stat,corr,false);
254 
255  }
256 
257  }
258  }
259  }
260  }
261 
262  // Barrel Summary Plots
263  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr){
264  trigSource = (*iTr);
265  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw){
266  hwSource = (*iHw);
267  for (int wh=-2; wh<=2; ++wh){
268 
269  std::map<std::string,MonitorElement*> *innerME = &(whME[wh]);
270 
271  TH2F* phiWhSummary = getHisto<TH2F>(innerME->find(fullName("PhiLutSummary"))->second);
272  TH2F* phibWhSummary = getHisto<TH2F>(innerME->find(fullName("PhibLutSummary"))->second);
273 
274  for (int sect=1; sect<=12; ++sect){
275 
276  int phiSectorTotal = 0; // CB dai 1 occhio a questo
277  int phibSectorTotal = 0;
278  int nullphi = 0;
279  int nullphib = 0;
280  int phiStatus = 5;
281  int phibStatus = 5;
282  int glbStatus = 0;
283 
284  for (int stat=1; stat<=4; ++stat){
285  if (phiWhSummary->GetBinContent(sect,stat)==2){
286  phiSectorTotal +=1;
287  glbStatus += 1;
288  }
289  if (phiWhSummary->GetBinContent(sect,stat)==1)
290  nullphi+=1;
291  if (phibWhSummary->GetBinContent(sect,stat)==2) {
292  phibSectorTotal+=1;
293  glbStatus += 1;
294  }
295  if (phibWhSummary->GetBinContent(sect,stat)==1)
296  nullphib+=1;
297  }
298  if (nullphi!=4)
299  phiStatus=phiSectorTotal;
300  else
301  phiStatus=5;
302  if (nullphib!=3)
303  phibStatus=phibSectorTotal;
304  else
305  phibStatus=5;
306 
307  cmsME.find("TrigLutSummary")->second->setBinContent(sect,wh+3,glbStatus);
308  cmsME.find(fullName("PhiLutSummary"))->second->setBinContent(sect,wh+3,phiStatus);
309  cmsME.find(fullName("PhibLutSummary"))->second->setBinContent(sect,wh+3,phibStatus);
310  }
311  }
312  }
313  }
314 
315 }
316 
317 int DTTriggerLutTest::performLutTest(double perc,double thresholdWarn ,double thresholdErr) {
318 
319  bool isInWarn = perc<thresholdWarn;
320  bool isInErr = perc<thresholdErr;
321 
322  int result= isInErr ? 2 : isInWarn ? 3 : 0;
323 
324  return result;
325 
326 }
327 
328 void DTTriggerLutTest::bookCmsHistos1d(DQMStore::IBooker & ibooker, string hTag, string folder) {
329 
330  string basedir = topFolder(true);
331  if (folder != "") {
332  basedir += folder +"/" ;
333  }
334  ibooker.setCurrentFolder(basedir);
335 
336  string hName = fullName(hTag);
337  LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hName;
338 
339  MonitorElement* me = ibooker.book1D(hName.c_str(),hName.c_str(),101,-0.005,1.005);
340  me->setAxisTitle("Percentage",1);
341  cmsME[hName] = me;
342 
343 }
344 
345 void DTTriggerLutTest::fillWhPlot(MonitorElement *plot, int sect, int stat, float value, bool lessIsBest) {
346 
347  if (sect>12) {
348  int scsect = sect==13 ? 4 : 10;
349  if ((value>plot->getBinContent(scsect,stat)) == lessIsBest) {
350  plot->setBinContent(scsect,stat,value);
351  }
352  }
353  else {
354  plot->setBinContent(sect,stat,value);
355  }
356 
357  return;
358 
359 }
360 
361 
void runClientDiagnostic(DQMStore::IBooker &, DQMStore::IGetter &)
Run client analysis.
T getUntrackedParameter(std::string const &, T const &) const
void bookCmsHistos1d(DQMStore::IBooker &, std::string hTag, std::string folder="")
void setBinContent(int binx, double content)
set content of bin (1-D)
DTTriggerLutTest(const edm::ParameterSet &ps)
Constructor.
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:304
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.
tuple result
Definition: mps_fire.py:83
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
#define LogTrace(id)
JetCorrectorParameters corr
Definition: classes.h:5
string fullName
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
double getBinContent(int binx) const
get content of bin (1-D)
void Bookings(DQMStore::IBooker &, DQMStore::IGetter &)
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)
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
tuple folder
Histograms Source for live online DQM in P5
Definition: Run.h:43
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:142