CMS 3D CMS Logo

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 // This class header
12 
13 // Framework headers
17 // Geometry
20 
21 // Root
22 #include "TF1.h"
23 //#include "TSpectrum.h"
24 
25 //C++ headers
26 #include <iostream>
27 #include <sstream>
28 
29 using namespace edm;
30 using namespace std;
31 
33  setConfig(ps, "DTTriggerLut");
34  baseFolderTM = "DT/03-LocalTrigger-TM/";
35  thresholdWarnPhi = ps.getUntrackedParameter<double>("thresholdWarnPhi");
36  thresholdErrPhi = ps.getUntrackedParameter<double>("thresholdErrPhi");
37  thresholdWarnPhiB = ps.getUntrackedParameter<double>("thresholdWarnPhiB");
38  thresholdErrPhiB = ps.getUntrackedParameter<double>("thresholdErrPhiB");
39  validRange = ps.getUntrackedParameter<double>("validRange");
40  detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis");
41 
42  bookingdone = false;
43 }
44 
46 
48  bookingdone = true;
49 
50  vector<string>::const_iterator iTr = trigSources.begin();
51  vector<string>::const_iterator trEnd = trigSources.end();
52  vector<string>::const_iterator iHw = hwSources.begin();
53  vector<string>::const_iterator hwEnd = hwSources.end();
54 
55  //Booking
56  if (parameters.getUntrackedParameter<bool>("staticBooking")) {
57  for (; iTr != trEnd; ++iTr) {
58  trigSource = (*iTr);
59  for (; iHw != hwEnd; ++iHw) {
60  hwSource = (*iHw);
61  // Loop over the TriggerUnits
62  for (int wh = -2; wh <= 2; ++wh) {
63  if (detailedAnalysis) {
64  bookWheelHistos(ibooker, wh, "PhiResidualPercentage");
65  bookWheelHistos(ibooker, wh, "PhibResidualPercentage");
66  }
67 
68  bookWheelHistos(ibooker, wh, "PhiLutSummary", "Summaries");
69  bookWheelHistos(ibooker, wh, "PhibLutSummary", "Summaries");
70 
71  if (detailedAnalysis) {
72  bookWheelHistos(ibooker, wh, "PhiResidualMean");
73  bookWheelHistos(ibooker, wh, "PhiResidualRMS");
74  bookWheelHistos(ibooker, wh, "PhibResidualMean");
75  bookWheelHistos(ibooker, wh, "PhibResidualRMS");
76  bookWheelHistos(ibooker, wh, "CorrelationFactorPhi");
77  bookWheelHistos(ibooker, wh, "CorrelationFactorPhib");
78  bookWheelHistos(ibooker, wh, "DoublePeakFlagPhib");
79  }
80  }
81 
82  bookCmsHistos(ibooker, "TrigLutSummary", "", true);
83  bookCmsHistos(ibooker, "PhiLutSummary");
84  bookCmsHistos(ibooker, "PhibLutSummary");
85  if (detailedAnalysis) {
86  bookCmsHistos1d(ibooker, "PhiPercentageSummary");
87  bookCmsHistos1d(ibooker, "PhibPercentageSummary");
88  }
89  }
90  }
91  }
92 }
93 
95 
97  if (!bookingdone)
98  Bookings(ibooker, igetter);
99 
100  // Reset lut percentage 1D summaries
101  if (detailedAnalysis) {
102  cmsME.find(fullName("PhiPercentageSummary"))->second->Reset();
103  cmsME.find(fullName("PhibPercentageSummary"))->second->Reset();
104  }
105 
106  // Loop over Trig & Hw sources
107  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr) {
108  trigSource = (*iTr);
109  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw) {
110  hwSource = (*iHw);
111  vector<const DTChamber*>::const_iterator chIt = muonGeom->chambers().begin();
112  vector<const DTChamber*>::const_iterator chEnd = muonGeom->chambers().end();
113  for (; chIt != chEnd; ++chIt) {
114  DTChamberId chId((*chIt)->id());
115  int wh = chId.wheel();
116  int sect = chId.sector();
117  int stat = chId.station();
118 
119  std::map<std::string, MonitorElement*>& innerME = whME[wh];
120 
121  // Make Phi Residual Summary
122  TH1F* PhiResidual = getHisto<TH1F>(igetter.get(getMEName("PhiResidual", "Segment", chId)));
123  int phiSummary = 1;
124  if (PhiResidual && PhiResidual->GetEntries() > 10) {
125  if (innerME.find(fullName("PhiResidualPercentage")) == innerME.end()) {
126  bookWheelHistos(ibooker, wh, "PhiResidualPercentage");
127  }
128 
129  float rangeBin = validRange / (PhiResidual->GetBinWidth(1));
130  float center = (PhiResidual->GetNbinsX()) / 2.;
131  float perc =
132  (PhiResidual->Integral(floor(center - rangeBin), ceil(center + rangeBin))) / (PhiResidual->Integral());
133  fillWhPlot(innerME.find(fullName("PhiResidualPercentage"))->second, sect, stat, perc, false);
134  phiSummary = performLutTest(perc, thresholdWarnPhi, thresholdErrPhi);
135  if (detailedAnalysis)
136  cmsME.find(fullName("PhiPercentageSummary"))->second->Fill(perc);
137  }
138 
139  fillWhPlot(innerME.find(fullName("PhiLutSummary"))->second, sect, stat, phiSummary);
140 
141  if (detailedAnalysis) {
142  if ((phiSummary == 0) || (phiSummary == 3)) { //Information on the Peak
143 
144  if (innerME.find(fullName("PhiResidualMean")) == innerME.end()) {
145  bookWheelHistos(ibooker, wh, "PhiResidualMean");
146  bookWheelHistos(ibooker, wh, "PhiResidualRMS");
147  }
148 
149  float center = (PhiResidual->GetNbinsX()) / 2.;
150  float rangeBin = validRange / (PhiResidual->GetBinWidth(1));
151  PhiResidual->GetXaxis()->SetRange(floor(center - rangeBin), ceil(center + rangeBin));
152  float max = PhiResidual->GetMaximumBin();
153  float maxBin = PhiResidual->GetXaxis()->FindBin(max);
154  float nBinMax = 0.5 / (PhiResidual->GetBinWidth(1));
155  PhiResidual->GetXaxis()->SetRange(floor(maxBin - nBinMax), ceil(maxBin + nBinMax));
156  float Mean = PhiResidual->GetMean();
157  float rms = PhiResidual->GetRMS();
158 
159  fillWhPlot(innerME.find(fullName("PhiResidualMean"))->second, sect, stat, Mean);
160  fillWhPlot(innerME.find(fullName("PhiResidualRMS"))->second, sect, stat, rms);
161  }
162 
163  TH2F* TrackPhitkvsPhitrig = getHisto<TH2F>(igetter.get(getMEName("PhitkvsPhitrig", "Segment", chId)));
164 
165  if (TrackPhitkvsPhitrig && TrackPhitkvsPhitrig->GetEntries() > 100) {
166  float corr = TrackPhitkvsPhitrig->GetCorrelationFactor();
167  if (innerME.find(fullName("CorrelationFactorPhi")) == innerME.end()) {
168  bookWheelHistos(ibooker, wh, "CorrelationFactorPhi");
169  }
170  fillWhPlot(innerME.find(fullName("CorrelationFactorPhi"))->second, sect, stat, corr, false);
171  }
172  }
173 
174  // Make Phib Residual Summary
175  TH1F* PhibResidual = getHisto<TH1F>(igetter.get(getMEName("PhibResidual", "Segment", chId)));
176  int phibSummary = stat == 3 ? -1 : 1; // station 3 has no meaningful MB3 phi bending information
177 
178  if (stat != 3 && PhibResidual &&
179  PhibResidual->GetEntries() > 10) { // station 3 has no meaningful MB3 phi bending information
180 
181  if (innerME.find(fullName("PhibResidualPercentage")) == innerME.end()) {
182  bookWheelHistos(ibooker, wh, "PhibResidualPercentage");
183  }
184 
185  float rangeBin = validRange / (PhibResidual->GetBinWidth(1));
186  float center = (PhibResidual->GetNbinsX()) / 2.;
187  float perc =
188  (PhibResidual->Integral(floor(center - rangeBin), ceil(center + rangeBin))) / (PhibResidual->Integral());
189 
190  fillWhPlot(innerME.find(fullName("PhibResidualPercentage"))->second, sect, stat, perc, false);
191  phibSummary = performLutTest(perc, thresholdWarnPhiB, thresholdErrPhiB);
192  if (detailedAnalysis)
193  cmsME.find(fullName("PhibPercentageSummary"))->second->Fill(perc);
194  }
195 
196  fillWhPlot(innerME.find(fullName("PhibLutSummary"))->second, sect, stat, phibSummary);
197 
198  if (detailedAnalysis) {
199  if ((phibSummary == 0) || (phibSummary == 3)) {
200  if (innerME.find(fullName("PhibResidualMean")) == innerME.end()) {
201  bookWheelHistos(ibooker, wh, "PhibResidualMean");
202  bookWheelHistos(ibooker, wh, "PhibResidualRMS");
203  }
204 
205  float center = (PhibResidual->GetNbinsX()) / 2.;
206  float rangeBin = validRange / (PhibResidual->GetBinWidth(1));
207  PhibResidual->GetXaxis()->SetRange(floor(center - rangeBin), ceil(center + rangeBin));
208  float max = PhibResidual->GetMaximumBin();
209  float maxBin = PhibResidual->GetXaxis()->FindBin(max);
210  float nBinMax = 0.5 / (PhibResidual->GetBinWidth(1));
211  PhibResidual->GetXaxis()->SetRange(floor(maxBin - nBinMax), ceil(maxBin + nBinMax));
212  float Mean = PhibResidual->GetMean();
213  float rms = PhibResidual->GetRMS();
214 
215  fillWhPlot(innerME.find(fullName("PhibResidualMean"))->second, sect, stat, Mean);
216  fillWhPlot(innerME.find(fullName("PhibResidualRMS"))->second, sect, stat, rms);
217  }
218 
219  TH2F* TrackPhibtkvsPhibtrig = getHisto<TH2F>(igetter.get(getMEName("PhibtkvsPhibtrig", "Segment", chId)));
220  if (TrackPhibtkvsPhibtrig && TrackPhibtkvsPhibtrig->GetEntries() > 100) {
221  float corr = TrackPhibtkvsPhibtrig->GetCorrelationFactor();
222  if (innerME.find(fullName("CorrelationFactorPhib")) == innerME.end()) {
223  bookWheelHistos(ibooker, wh, "CorrelationFactorPhib");
224  }
225 
226  fillWhPlot(innerME.find(fullName("CorrelationFactorPhib"))->second, sect, stat, corr, false);
227  }
228  }
229  }
230  }
231  }
232 
233  // Barrel Summary Plots
234  for (vector<string>::const_iterator iTr = trigSources.begin(); iTr != trigSources.end(); ++iTr) {
235  trigSource = (*iTr);
236  for (vector<string>::const_iterator iHw = hwSources.begin(); iHw != hwSources.end(); ++iHw) {
237  hwSource = (*iHw);
238  for (int wh = -2; wh <= 2; ++wh) {
239  std::map<std::string, MonitorElement*>* innerME = &(whME[wh]);
240 
241  TH2F* phiWhSummary = getHisto<TH2F>(innerME->find(fullName("PhiLutSummary"))->second);
242  TH2F* phibWhSummary = getHisto<TH2F>(innerME->find(fullName("PhibLutSummary"))->second);
243 
244  for (int sect = 1; sect <= 12; ++sect) {
245  int phiSectorTotal = 0; // CB dai 1 occhio a questo
246  int phibSectorTotal = 0;
247  int nullphi = 0;
248  int nullphib = 0;
249  int phiStatus = 5;
250  int phibStatus = 5;
251  int glbStatus = 0;
252 
253  for (int stat = 1; stat <= 4; ++stat) {
254  if (phiWhSummary->GetBinContent(sect, stat) == 2) {
255  phiSectorTotal += 1;
256  glbStatus += 1;
257  }
258  if (phiWhSummary->GetBinContent(sect, stat) == 1)
259  nullphi += 1;
260  if (phibWhSummary->GetBinContent(sect, stat) == 2) {
261  phibSectorTotal += 1;
262  glbStatus += 1;
263  }
264  if (phibWhSummary->GetBinContent(sect, stat) == 1)
265  nullphib += 1;
266  }
267  if (nullphi != 4)
268  phiStatus = phiSectorTotal;
269  else
270  phiStatus = 5;
271  if (nullphib != 3)
272  phibStatus = phibSectorTotal;
273  else
274  phibStatus = 5;
275 
276  cmsME.find("TrigLutSummary")->second->setBinContent(sect, wh + wheelArrayShift, glbStatus);
277  cmsME.find(fullName("PhiLutSummary"))->second->setBinContent(sect, wh + wheelArrayShift, phiStatus);
278  cmsME.find(fullName("PhibLutSummary"))->second->setBinContent(sect, wh + wheelArrayShift, phibStatus);
279  }
280  }
281  }
282  }
283 }
284 
285 int DTTriggerLutTest::performLutTest(double perc, double thresholdWarn, double thresholdErr) {
286  bool isInWarn = perc < thresholdWarn;
287  bool isInErr = perc < thresholdErr;
288 
289  int result = isInErr ? 2 : isInWarn ? 3 : 0;
290 
291  return result;
292 }
293 
294 void DTTriggerLutTest::bookCmsHistos1d(DQMStore::IBooker& ibooker, string hTag, string folder) {
295  string basedir = topFolder();
296  if (!folder.empty()) {
297  basedir += folder + "/";
298  }
299  ibooker.setCurrentFolder(basedir);
300 
301  string hName = fullName(hTag);
302  LogTrace(category()) << "[" << testName << "Test]: booking " << basedir << hName;
303 
304  MonitorElement* me = ibooker.book1D(hName.c_str(), hName.c_str(), 101, -0.005, 1.005);
305  me->setAxisTitle("Percentage", 1);
306  cmsME[hName] = me;
307 }
308 
309 void DTTriggerLutTest::fillWhPlot(MonitorElement* plot, int sect, int stat, float value, bool lessIsBest) {
310  if (sect > 12) {
311  int scsect = sect == 13 ? 4 : 10;
312  if ((value > plot->getBinContent(scsect, stat)) == lessIsBest) {
313  plot->setBinContent(scsect, stat, value);
314  }
315  } else {
316  plot->setBinContent(sect, stat, value);
317  }
318 
319  return;
320 }
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:31
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
dtTriggerLutTest_cfi.validRange
validRange
Definition: dtTriggerLutTest_cfi.py:15
MessageLogger.h
DTLocalTriggerBaseTest::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &context) override
BeginRun.
Definition: DTLocalTriggerBaseTest.cc:37
edm::Run
Definition: Run.h:45
printsummarytable.folder
folder
Definition: printsummarytable.py:7
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::max
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118
dtNoiseAnalysis_cfi.detailedAnalysis
detailedAnalysis
Definition: dtNoiseAnalysis_cfi.py:7
dtTriggerLutTest_cfi.thresholdWarnPhi
thresholdWarnPhi
Definition: dtTriggerLutTest_cfi.py:17
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DTTriggerLutTest::runClientDiagnostic
void runClientDiagnostic(DQMStore::IBooker &, DQMStore::IGetter &) override
Run client analysis.
Definition: DTTriggerLutTest.cc:96
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
plotFactory.plot
plot
Definition: plotFactory.py:109
Mean
Definition: SiPixelActionExecutor.h:17
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
DTTriggerLutTest::beginRun
void beginRun(const edm::Run &r, const edm::EventSetup &c) override
BeginRun.
Definition: DTTriggerLutTest.cc:94
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
L1TBPTX_cfi.testName
testName
Definition: L1TBPTX_cfi.py:24
makeHippyCampaign.basedir
basedir
Definition: makeHippyCampaign.py:14
DTTriggerLutTest::Bookings
void Bookings(DQMStore::IBooker &, DQMStore::IGetter &)
Definition: DTTriggerLutTest.cc:47
DTTriggerLutTest::bookCmsHistos1d
void bookCmsHistos1d(DQMStore::IBooker &, std::string hTag, std::string folder="")
Definition: DTTriggerLutTest.cc:294
newFWLiteAna.fullName
fullName
Definition: newFWLiteAna.py:122
DTGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
DTTriggerLutTest::DTTriggerLutTest
DTTriggerLutTest(const edm::ParameterSet &ps)
Constructor.
Definition: DTTriggerLutTest.cc:32
DTTriggerLutTest::performLutTest
int performLutTest(double perc, double threshold1, double threshold2)
Perform Lut Test logical operations.
Definition: DTTriggerLutTest.cc:285
cms::cuda::allocator::maxBin
constexpr unsigned int maxBin
Definition: getCachingDeviceAllocator.h:20
dtFineDelayCorr_cfi.hwSource
hwSource
Definition: dtFineDelayCorr_cfi.py:26
value
Definition: value.py:1
dtFineDelayCorr_cfi.hwSources
hwSources
Definition: dtFineDelayCorr_cfi.py:9
DTTriggerLutTest::~DTTriggerLutTest
~DTTriggerLutTest() override
Destructor.
Definition: DTTriggerLutTest.cc:45
edm::EventSetup
Definition: EventSetup.h:58
alignCSCRings.r
r
Definition: alignCSCRings.py:93
DTTriggerLutTest.h
std
Definition: JetResolutionObject.h:76
DTTriggerLutTest::fillWhPlot
void fillWhPlot(MonitorElement *plot, int sect, int stat, float value, bool lessIsBest=true)
Fill summary plots managing double MB4 chambers.
Definition: DTTriggerLutTest.cc:309
dqm::implementation::IGetter
Definition: DQMStore.h:484
dtTriggerLutTest_cfi.thresholdWarnPhiB
thresholdWarnPhiB
Definition: dtTriggerLutTest_cfi.py:19
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
mps_fire.result
result
Definition: mps_fire.py:311
dtTriggerLutTest_cfi.thresholdErrPhiB
thresholdErrPhiB
Definition: dtTriggerLutTest_cfi.py:20
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
MuonGeometryRecord.h
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
dtTriggerLutTest_cfi.thresholdErrPhi
thresholdErrPhi
Definition: dtTriggerLutTest_cfi.py:18
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98