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