CMS 3D CMS Logo

DTLocalTriggerTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTLocalTriggerTask.cc
3  *
4  * \author M. Zanetti - INFN Padova
5  *
6 */
7 
9 
10 // Framework
12 
13 // DT trigger
15 
16 // Geometry
22 
23 //Root
24 #include "TH1.h"
25 #include "TAxis.h"
26 
27 #include <sstream>
28 #include <iostream>
29 #include <fstream>
30 
31 using namespace edm;
32 using namespace std;
33 
35  : trigGeomUtils(nullptr), isLocalRun(ps.getUntrackedParameter<bool>("localrun", true)) {
36  if (!isLocalRun) {
37  ltcDigiCollectionToken_ = consumes<LTCDigiCollection>(ps.getParameter<edm::InputTag>("ltcDigiCollectionTag"));
38  }
39 
40  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerTask") << "[DTLocalTriggerTask]: Constructor" << endl;
41 
42  tpMode = ps.getUntrackedParameter<bool>("testPulseMode", false);
43  detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis", false);
44  doTMTheta = ps.getUntrackedParameter<bool>("enableTMTheta", false);
45  tm_Token_ = consumes<L1MuDTChambPhContainer>(
46  ps.getUntrackedParameter<InputTag>("tm_label", InputTag("twinMuxStage2Digis:PhIn")));
47  tmTh_Token_ = consumes<L1MuDTChambThContainer>(
48  ps.getUntrackedParameter<edm::InputTag>("tmTh_label", InputTag("twinMuxStage2Digis:ThIn")));
49 
50  ros_Token_ =
51  consumes<DTLocalTriggerCollection>(ps.getUntrackedParameter<InputTag>("ros_label", InputTag("dtunpacker")));
52  seg_Token_ =
53  consumes<DTRecSegment4DCollection>(ps.getUntrackedParameter<InputTag>("seg_label", InputTag("dt4DSegments")));
54 
55  if (tpMode) {
56  baseFolderTM = "DT/11-LocalTriggerTP-TM/";
57  } else {
58  baseFolderTM = "DT/03-LocalTrigger-TM/";
59  }
60 
61  parameters = ps;
62 }
63 
65  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerTask")
66  << "[DTLocalTriggerTask]: analyzed " << nevents << " events" << endl;
67  if (trigGeomUtils) {
68  delete trigGeomUtils;
69  }
70 }
71 
73  nevents = 0;
74  context.get<MuonGeometryRecord>().get(muonGeom);
76 }
77 
79  edm::Run const& iRun,
80  edm::EventSetup const& context) {
81  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerTask") << "[DTLocalTriggerTask]: bookHistograms" << endl;
82 
83  if (parameters.getUntrackedParameter<bool>("staticBooking", true)) { // Static histo booking
84 
85  vector<string> trigSources;
86  if (parameters.getUntrackedParameter<bool>("localrun", true)) {
87  trigSources.push_back("");
88  } else {
89  trigSources.push_back("_DTonly");
90  trigSources.push_back("_NoDT");
91  trigSources.push_back("_DTalso");
92  }
93  vector<string>::const_iterator trigSrcIt = trigSources.begin();
94  vector<string>::const_iterator trigSrcEnd = trigSources.end();
95 
96  if (parameters.getUntrackedParameter<bool>("process_tm", true)) {
97  bookBarrelHistos(ibooker, "TM_ErrorsChamberID");
98  }
99 
100  if (tpMode) {
101  for (int stat = 1; stat < 5; ++stat) {
102  for (int wh = -2; wh < 3; ++wh) {
103  for (int sect = 1; sect < 13; ++sect) {
104  DTChamberId dtChId(wh, stat, sect);
105 
106  if (parameters.getUntrackedParameter<bool>("process_tm", true)) { // TM data
107  bookHistos(ibooker, dtChId, "LocalTriggerPhiIn", "TM_BXvsQual" + (*trigSrcIt));
108  bookHistos(ibooker, dtChId, "LocalTriggerPhiIn", "TM_QualvsPhirad" + (*trigSrcIt));
109  }
110  }
111  }
112  } // end of loop
113  } else {
114  for (; trigSrcIt != trigSrcEnd; ++trigSrcIt) {
115  for (int wh = -2; wh < 3; ++wh) {
116  for (int sect = 1; sect < 13; ++sect) {
117  for (int stat = 1; stat < 5; ++stat) {
118  DTChamberId dtChId(wh, stat, sect);
119  if (parameters.getUntrackedParameter<bool>("process_tm", true)) { // TM data
120 
121  bookHistos(ibooker, dtChId, "LocalTriggerPhiIn", "TM_BXvsQual_In" + (*trigSrcIt));
122  if (detailedAnalysis) {
123  bookHistos(ibooker, dtChId, "LocalTriggerPhiIn", "TM_QualvsPhirad_In" + (*trigSrcIt));
124  bookHistos(ibooker, dtChId, "LocalTriggerPhiIn", "TM_QualvsPhibend_In" + (*trigSrcIt));
125  }
126  bookHistos(ibooker, dtChId, "LocalTriggerPhiIn", "TM_Flag1stvsQual_In" + (*trigSrcIt));
127  bookHistos(ibooker, dtChId, "LocalTriggerPhiIn", "TM_FlagUpDownvsQual_In" + (*trigSrcIt));
128 
129  bookHistos(ibooker, dtChId, "LocalTriggerPhiIn", "TM_BestQual_In" + (*trigSrcIt));
130  if (stat != 4 && doTMTheta) {
131  bookHistos(ibooker, dtChId, "LocalTriggerTheta", "TM_PositionvsBX" + (*trigSrcIt));
132  bookHistos(ibooker, dtChId, "LocalTriggerTheta", "TM_QualityvsBX" + (*trigSrcIt));
133 
134  bookHistos(ibooker, dtChId, "LocalTriggerTheta", "TM_PositionvsQual" + (*trigSrcIt));
135 
136  bookHistos(ibooker, dtChId, "LocalTriggerTheta", "TM_ThetaBXvsQual" + (*trigSrcIt));
137  bookHistos(ibooker, dtChId, "LocalTriggerTheta", "TM_ThetaBestQual" + (*trigSrcIt));
138  }
139 
140  if (parameters.getUntrackedParameter<bool>("process_seg", true)) { // TM + Segemnt
141  bookHistos(ibooker, dtChId, "Segment", "TM_PhitkvsPhitrig" + (*trigSrcIt));
142  bookHistos(ibooker, dtChId, "Segment", "TM_PhibtkvsPhibtrig" + (*trigSrcIt));
143  bookHistos(ibooker, dtChId, "Segment", "TM_PhiResidual" + (*trigSrcIt));
144  bookHistos(ibooker, dtChId, "Segment", "TM_PhiResidualvsLUTPhi" + (*trigSrcIt));
145  bookHistos(ibooker, dtChId, "Segment", "TM_PhibResidual" + (*trigSrcIt));
146  bookHistos(ibooker, dtChId, "Segment", "TM_HitstkvsQualtrig" + (*trigSrcIt));
147  bookHistos(ibooker, dtChId, "Segment", "TM_TrackPosvsAngle" + (*trigSrcIt));
148  bookHistos(ibooker, dtChId, "Segment", "TM_TrackPosvsAngleandTrig" + (*trigSrcIt));
149  bookHistos(ibooker, dtChId, "Segment", "TM_TrackPosvsAngleandTrigHHHL" + (*trigSrcIt));
150  if (stat != 4) {
151  bookHistos(ibooker, dtChId, "Segment", "TM_TrackThetaPosvsAngle" + (*trigSrcIt)); // theta view
152  bookHistos(ibooker, dtChId, "Segment", "TM_TrackThetaPosvsAngleandTrig" + (*trigSrcIt));
153  bookHistos(ibooker,
154  dtChId,
155  "Segment",
156  "TM_TrackThetaPosvsAngleandTrigH" + (*trigSrcIt)); // TM theta quality not available!
157  }
158  }
159  }
160  }
161  }
162  for (int sect = 13; sect < 15; ++sect) {
163  DTChamberId dtChId(wh, 4, sect);
164  if (parameters.getUntrackedParameter<bool>("process_tm", true) &&
165  parameters.getUntrackedParameter<bool>("process_seg", true)) { // TM+SEG LUTs data
166  bookHistos(ibooker, dtChId, "Segment", "TM_PhitkvsPhitrig" + (*trigSrcIt));
167  bookHistos(ibooker, dtChId, "Segment", "TM_PhibtkvsPhibtrig" + (*trigSrcIt));
168  bookHistos(ibooker, dtChId, "Segment", "TM_PhiResidual" + (*trigSrcIt));
169  bookHistos(ibooker, dtChId, "Segment", "TM_PhiResidualvsLUTPhi" + (*trigSrcIt));
170  bookHistos(ibooker, dtChId, "Segment", "TM_PhibResidual" + (*trigSrcIt));
171  }
172  }
173  }
174  } // end of loop
175  }
176  }
177 }
178 
180  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerTask") << "[DTLocalTriggerTask]: Begin of LS transition" << endl;
181 
182  if (lumiSeg.id().luminosityBlock() % parameters.getUntrackedParameter<int>("ResetCycle", 3) == 0) {
183  for (map<uint32_t, map<string, MonitorElement*> >::const_iterator histo = digiHistos.begin();
184  histo != digiHistos.end();
185  histo++) {
186  for (map<string, MonitorElement*>::const_iterator ht = (*histo).second.begin(); ht != (*histo).second.end();
187  ht++) {
188  (*ht).second->Reset();
189  }
190  }
191  }
192 }
193 
195  if (!nevents) {
197  e.getByToken(tm_Token_, l1DTTPGPh);
199  e.getByToken(tmTh_Token_, l1DTTPGTh);
200 
201  useTM = (l1DTTPGPh.isValid() || l1DTTPGTh.isValid()) && parameters.getUntrackedParameter<bool>("process_tm", true);
202 
203  Handle<DTRecSegment4DCollection> all4DSegments;
204  e.getByToken(seg_Token_, all4DSegments);
205  useSEG = all4DSegments.isValid() && parameters.getUntrackedParameter<bool>("process_seg", true);
206  }
207 
208  nevents++;
209 
210  triggerSource(e);
211 
212  if (useTM) {
214  e.getByToken(tm_Token_, l1DTTPGPh);
215  vector<L1MuDTChambPhDigi> const* l1PhTrig = l1DTTPGPh->getContainer();
216 
218  e.getByToken(tmTh_Token_, l1DTTPGTh);
219 
220  vector<L1MuDTChambThDigi> const* l1ThTrig = l1DTTPGTh->getContainer();
221 
222  runTMAnalysis(l1PhTrig, l1ThTrig);
223  }
224  if (!tpMode && useSEG) {
226  e.getByToken(seg_Token_, segments4D);
227 
228  runSegmentAnalysis(segments4D);
229  }
230 }
231 
233  ibooker.setCurrentFolder(topFolder());
234  if (histoTag == "TM_ErrorsChamberID") {
235  tm_IDDataErrorPlot = ibooker.book1D(histoTag.c_str(), "TM Data ID Error", 5, -2, 3);
236  tm_IDDataErrorPlot->setAxisTitle("wheel", 1);
237  }
238 
239  return;
240 }
241 
243  const DTChamberId& dtCh,
244  string folder,
245  string histoTag) {
246  int wh = dtCh.wheel();
247  int sc = dtCh.sector();
248  stringstream wheel;
249  wheel << wh;
250  stringstream station;
251  station << dtCh.station();
252  stringstream sector;
253  sector << sc;
254 
255  double minBX = 0;
256  double maxBX = 0;
257  int rangeBX = 0;
258 
259  string histoType = histoTag.substr(3, histoTag.find('_', 3) - 3);
260 
261  ibooker.setCurrentFolder(topFolder() + "Wheel" + wheel.str() + "/Sector" + sector.str() + "/Station" + station.str() +
262  "/" + folder);
263 
264  string histoName = histoTag + "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
265 
266  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerTask")
267  << "[DTLocalTriggerTask]: booking " << topFolder() << "Wheel" << wheel.str() << "/Sector" << sector.str()
268  << "/Station" << station.str() << "/" << folder << "/" << histoName << endl;
269 
270  if (histoType.find("BX") != string::npos) {
271  if (histoTag.substr(0, 2) == "TM") {
272  minBX = parameters.getUntrackedParameter<int>("minBXTM", -2) - 0.5;
273  maxBX = parameters.getUntrackedParameter<int>("maxBXTM", 2) + 0.5;
274  }
275  rangeBX = (int)(maxBX - minBX);
276  }
277 
278  if (folder == "LocalTriggerPhiIn") {
279  if (histoType == "BXvsQual") {
280  (digiHistos[dtCh.rawId()])[histoTag] =
281  ibooker.book2D(histoName, "BX vs trigger quality", 7, -0.5, 6.5, rangeBX, minBX, maxBX);
282  setQLabels((digiHistos[dtCh.rawId()])[histoTag], 1);
283  return;
284  }
285  if (histoType == "BestQual") {
286  (digiHistos[dtCh.rawId()])[histoTag] =
287  ibooker.book1D(histoName, "Trigger quality of best primitives", 7, -0.5, 6.5);
288  setQLabels((digiHistos[dtCh.rawId()])[histoTag], 1);
289  return;
290  }
291  if (histoType == "QualvsPhirad") {
292  (digiHistos[dtCh.rawId()])[histoTag] =
293  ibooker.book2D(histoName, "Trigger quality vs local position", 100, -500., 500., 7, -0.5, 6.5);
294  setQLabels((digiHistos[dtCh.rawId()])[histoTag], 2);
295  return;
296  }
297  if (histoType == "QualvsPhibend") {
298  (digiHistos[dtCh.rawId()])[histoTag] =
299  ibooker.book2D(histoName, "Trigger quality vs local direction", 200, -40., 40., 7, -0.5, 6.5);
300  setQLabels((digiHistos[dtCh.rawId()])[histoTag], 2);
301  return;
302  }
303  if (histoType == "Flag1stvsQual") {
304  (digiHistos[dtCh.rawId()])[histoTag] =
305  ibooker.book2D(histoName, "1st/2nd trig flag vs quality", 7, -0.5, 6.5, 2, -0.5, 1.5);
306  setQLabels((digiHistos[dtCh.rawId()])[histoTag], 1);
307  return;
308  }
309  if (histoType == "FlagUpDownvsQual") {
310  (digiHistos[dtCh.rawId()])[histoTag] =
311  ibooker.book2D(histoName, "Up/Down trig flag vs quality", 7, -0.5, 6.5, 2, -0.5, 1.5);
312  setQLabels((digiHistos[dtCh.rawId()])[histoTag], 1);
313  return;
314  }
315 
316  } else if (folder == "LocalTriggerTheta") {
317  if (histoType == "PositionvsBX") {
318  (digiHistos[dtCh.rawId()])[histoTag] =
319  ibooker.book2D(histoName, "Theta trigger position vs BX", rangeBX, minBX, maxBX, 7, -0.5, 6.5);
320  return;
321  }
322  if (histoType == "PositionvsQual") {
323  (digiHistos[dtCh.rawId()])[histoTag] =
324  ibooker.book2D(histoName, "Theta trigger position vs quality", 2, 0.5, 2.5, 7, -0.5, 6.5);
325  setQLabelsTheta((digiHistos[dtCh.rawId()])[histoTag], 1);
326  return;
327  }
328  if (histoType == "ThetaBXvsQual") {
329  (digiHistos[dtCh.rawId()])[histoTag] =
330  ibooker.book2D(histoName, "BX vs trigger quality", 2, 0.5, 2.5, rangeBX, minBX, maxBX);
331  setQLabelsTheta((digiHistos[dtCh.rawId()])[histoTag], 1);
332  }
333  if (histoType == "ThetaBestQual") { //It does not make sense: 7 positions, how to define best?
334  (digiHistos[dtCh.rawId()])[histoTag] = ibooker.book1D(
335  histoName, "Trigger quality of best primitives (theta)", 2, 0.5, 2.5); // 0 = not fired, 1 = L, 2 = H
336  setQLabelsTheta((digiHistos[dtCh.rawId()])[histoTag], 1);
337  return;
338  }
339 
340  } else if (folder == "Segment") {
341  if (histoType.find("TrackThetaPosvsAngle") == 0) {
342  string histoLabel = "Position vs Angle (theta)";
343  if (histoType.find("andTrigH") != string::npos)
344  histoLabel += " for H triggers";
345  else if (histoType.find("andTrig") != string::npos)
346  histoLabel += " for triggers";
347 
348  float min, max;
349  int nbins;
351  (digiHistos[dtCh.rawId()])[histoTag] = ibooker.book2D(histoName, histoLabel, 16, -40., 40., nbins, min, max);
352  return;
353  }
354  if (histoType.find("TrackPosvsAngle") == 0) {
355  float min, max;
356  int nbins;
357  trigGeomUtils->phiRange(dtCh, min, max, nbins);
358 
359  string histoLabel = "Position vs Angle (phi)";
360  if (histoType.find("andTrigHHHL") != string::npos)
361  histoLabel += " for HH/HL triggers";
362  else if (histoType.find("andTrig") != string::npos)
363  histoLabel += " for triggers";
364 
365  (digiHistos[dtCh.rawId()])[histoTag] = ibooker.book2D(histoName, histoLabel, 16, -40., 40., nbins, min, max);
366  return;
367  }
368  if (histoType == "PhitkvsPhitrig") {
369  (digiHistos[dtCh.rawId()])[histoTag] =
370  ibooker.book2D(histoName, "Local position: segment vs trigger", 100, -500., 500., 100, -500., 500.);
371  return;
372  }
373  if (histoType == "PhibtkvsPhibtrig") {
374  (digiHistos[dtCh.rawId()])[histoTag] =
375  ibooker.book2D(histoName, "Local direction : segment vs trigger", 200, -40., 40., 200, -40., 40.);
376  return;
377  }
378  if (histoType == "PhiResidual") {
379  (digiHistos[dtCh.rawId()])[histoTag] = ibooker.book1D(
380  histoName, "Trigger local position - Segment local position (correlated triggers)", 400, -10., 10.);
381  return;
382  }
383  if (histoType == "PhibResidual") {
384  (digiHistos[dtCh.rawId()])[histoTag] = ibooker.book1D(
385  histoName, "Trigger local direction - Segment local direction (correlated triggers)", 500, -10., 10.);
386  return;
387  }
388  if (histoType == "HitstkvsQualtrig") {
389  (digiHistos[dtCh.rawId()])[histoTag] =
390  ibooker.book2D(histoName, "Segment hits (phi) vs trigger quality", 7, -0.5, 6.5, 10, 0.5, 10.5);
391  setQLabels((digiHistos[dtCh.rawId()])[histoTag], 1);
392  return;
393  }
394  }
395 }
396 
398  stringstream wheel;
399  wheel << wh;
400 
401  string histoType = histoTag.substr(3, histoTag.find('_', 3) - 3);
402 
403  ibooker.setCurrentFolder(topFolder() + "Wheel" + wheel.str() + "/");
404 
405  string histoName = histoTag + "_W" + wheel.str();
406 
407  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerTask")
408  << "[DTLocalTriggerTask]: booking " << topFolder() << "Wheel" << wheel.str() << "/" << histoName << endl;
409 }
410 
411 void DTLocalTriggerTask::runTMAnalysis(std::vector<L1MuDTChambPhDigi> const* phTrigs,
412  std::vector<L1MuDTChambThDigi> const* thTrigs) {
413  //exit(0);
414 
415  string histoType;
416  string histoTag;
417 
418  // define best quality trigger segment (phi and theta)
419  // in any station start from 1 and zero is kept empty
420  for (int i = 0; i < 5; ++i) {
421  for (int j = 0; j < 6; ++j) {
422  for (int k = 0; k < 13; ++k) {
423  phcode_best[j][i][k] = -1;
424  thcode_best[j][i][k] = -1;
425  }
426  }
427  }
428 
429  vector<L1MuDTChambPhDigi>::const_iterator iph = phTrigs->begin();
430  vector<L1MuDTChambPhDigi>::const_iterator iphe = phTrigs->end();
431  for (; iph != iphe; ++iph) {
432  int phwheel = iph->whNum();
433  int phsec = iph->scNum() + 1; // SM The track finder goes from 0 to 11. I need them from 1 to 12 !!!!!
434  int phst = iph->stNum();
435  int phbx = iph->bxNum();
436  int phcode = iph->code();
437  int phi1st = iph->Ts2Tag();
438  int updown = iph->UpDownTag();
439 
440  // FIXME: workaround for TM data with station ID
441  if (phst == 0) {
442  tm_IDDataErrorPlot->Fill(phwheel);
443  continue;
444  }
445 
446  if (phcode > phcode_best[phwheel + 3][phst][phsec] && phcode < 7) {
447  phcode_best[phwheel + 3][phst][phsec] = phcode;
448  iphbest[phwheel + 3][phst][phsec] = &(*iph);
449  }
450 
451  DTChamberId dtChId(phwheel, phst, phsec);
452 
453  float x = trigGeomUtils->trigPos(&(*iph));
454  float angle = trigGeomUtils->trigDir(&(*iph));
455  uint32_t indexCh = dtChId.rawId();
456 
457  map<string, MonitorElement*>& innerME = digiHistos[indexCh];
458 
459  if (tpMode) {
460  innerME.find("TM_BXvsQual" + trigsrc)->second->Fill(phcode, phbx - phi1st); // SM BX vs Qual Phi view (1st tracks)
461  innerME.find("TM_QualvsPhirad" + trigsrc)->second->Fill(x, phcode); // SM Qual vs radial angle Phi view
462  } else {
463  innerME.find("TM_BXvsQual_In" + trigsrc)
464  ->second->Fill(phcode, phbx - phi1st); // SM BX vs Qual Phi view (1st tracks)
465  innerME.find("TM_Flag1stvsQual_In" + trigsrc)
466  ->second->Fill(phcode, phi1st); // SM Qual 1st/2nd track flag Phi view
467  innerME.find("TM_FlagUpDownvsQual_In" + trigsrc)
468  ->second->Fill(phcode, updown); // SM Qual Up/Down track flag Phi view
469  if (detailedAnalysis) {
470  innerME.find("TM_QualvsPhirad_In" + trigsrc)->second->Fill(x, phcode); // SM Qual vs radial angle Phi view
471  innerME.find("TM_QualvsPhibend_In" + trigsrc)->second->Fill(angle, phcode); // SM Qual vs bending Phi view
472  }
473  }
474  }
475 
476  if (doTMTheta) {
477  int thcode[7];
478  vector<L1MuDTChambThDigi>::const_iterator ith = thTrigs->begin();
479  vector<L1MuDTChambThDigi>::const_iterator ithe = thTrigs->end();
480  for (; ith != ithe; ++ith) {
481  int thwheel = ith->whNum();
482  int thsec = ith->scNum() + 1; // SM The track finder goes from 0 to 11. I need them from 1 to 12 !!!!!
483  int thst = ith->stNum();
484  int thbx = ith->bxNum();
485 
486  for (int pos = 0; pos < 7; pos++) {
487  thcode[pos] = ith->code(pos);
488 
489  if (thcode[pos] > thcode_best[thwheel + 3][thst][thsec]) {
490  thcode_best[thwheel + 3][thst][thsec] = thcode[pos];
491  ithbest[thwheel + 3][thst][thsec] = &(*ith);
492  }
493  }
494 
495  DTChamberId dtChId(thwheel, thst, thsec);
496  uint32_t indexCh = dtChId.rawId();
497 
498  map<string, MonitorElement*>& innerME = digiHistos[indexCh];
499 
500  for (int pos = 0; pos < 7; pos++) { //SM fill position for non zero position bit in theta view
501  if (thcode[pos] > 0) { //Fired
502  innerME.find("TM_PositionvsBX" + trigsrc)->second->Fill(thbx, pos); // SM BX vs Position Theta view
503  innerME.find("TM_PositionvsQual" + trigsrc)
504  ->second->Fill(thcode[pos], pos); //code = pos + qual; so 0, 1, 2 for 0, L, H resp.
505  innerME.find("TM_ThetaBXvsQual" + trigsrc)
506  ->second->Fill(thcode[pos], thbx); //code = pos + qual; so 0, 1, 2 for 0, L, H resp.
507  }
508  }
509  }
510  }
511 
512  // Fill Quality plots with best TM triggers in phi & theta
513  if (!tpMode) {
514  for (int st = 1; st < 5; ++st) {
515  for (int wh = -2; wh < 3; ++wh) {
516  for (int sc = 1; sc < 13; ++sc) {
517  if (phcode_best[wh + wheelArrayShift][st][sc] > -1 && phcode_best[wh + wheelArrayShift][st][sc] < 7) {
518  DTChamberId id(wh, st, sc);
519  uint32_t indexCh = id.rawId();
520  map<string, MonitorElement*>& innerME = digiHistos[indexCh];
521 
522  innerME.find("TM_BestQual_In" + trigsrc)
523  ->second->Fill(phcode_best[wh + wheelArrayShift][st][sc]); // Best Qual Trigger Phi view
524  }
525  if (thcode_best[wh + wheelArrayShift][st][sc] > 0 && thcode_best[wh + wheelArrayShift][st][sc] < 3) {
526  DTChamberId id(wh, st, sc);
527  uint32_t indexCh = id.rawId();
528  map<string, MonitorElement*>& innerME = digiHistos[indexCh];
529 
530  innerME.find("TM_ThetaBestQual" + trigsrc)
531  ->second->Fill(thcode_best[wh + wheelArrayShift][st][sc]); // Best Qual Trigger Theta view
532  }
533  }
534  }
535  }
536  }
537 }
538 
541 
542  // Find best tracks & good tracks
543  memset(track_ok, false, 450 * sizeof(bool));
544 
546  vector<const DTRecSegment4D*> best4DSegments;
547 
548  // Preliminary loop finds best 4D Segment and high quality ones
549  for (chamberId = segments4D->id_begin(); chamberId != segments4D->id_end(); ++chamberId) {
550  DTRecSegment4DCollection::range range = segments4D->get(*chamberId);
551  const DTRecSegment4D* tmpBest = nullptr;
552  int tmpdof = 0;
553  int dof = 0;
554 
555  for (track = range.first; track != range.second; ++track) {
556  if ((*track).hasPhi()) {
557  dof = (*track).phiSegment()->degreesOfFreedom();
558  if (dof > tmpdof) {
559  tmpBest = &(*track);
560  tmpdof = dof;
561 
562  int wheel = (*track).chamberId().wheel();
563  int sector = (*track).chamberId().sector();
564  int station = (*track).chamberId().station();
565  if (sector == 13) {
566  sector = 4;
567  } else if (sector == 14) {
568  sector = 10;
569  }
570  track_ok[wheel + 3][station][sector] = (!track_ok[wheel + 3][station][sector] && dof >= 2);
571  }
572  }
573  }
574  if (tmpBest)
575  best4DSegments.push_back(tmpBest);
576  }
577 
578  vector<const DTRecSegment4D*>::const_iterator btrack;
579 
580  for (btrack = best4DSegments.begin(); btrack != best4DSegments.end(); ++btrack) {
581  if ((*btrack)->hasPhi()) { // Phi component
582 
583  int wheel = (*btrack)->chamberId().wheel();
584  int station = (*btrack)->chamberId().station();
585  int sector = (*btrack)->chamberId().sector();
586  int scsector = 0;
587  float x_track, y_track, x_angle, y_angle;
588  trigGeomUtils->computeSCCoordinates((*btrack), scsector, x_track, x_angle, y_track, y_angle);
589  int nHitsPhi = (*btrack)->phiSegment()->degreesOfFreedom() + 2;
590 
591  DTChamberId dtChId(wheel, station, sector); // get chamber for LUTs histograms (Sectors 1 to 14)
592  uint32_t indexCh = dtChId.rawId();
593  map<string, MonitorElement*>& innerMECh = digiHistos[indexCh];
594 
595  DTChamberId dtChIdSC =
596  DTChamberId(wheel, station, scsector); // get chamber for histograms SC granularity (sectors 1 to 12)
597  indexCh = dtChIdSC.rawId();
598  map<string, MonitorElement*>& innerME = digiHistos[indexCh];
599 
600  if (useTM && phcode_best[wheel + 3][station][scsector] > -1 && phcode_best[wheel + 3][station][scsector] < 7) {
601  innerME.find("TM_HitstkvsQualtrig" + trigsrc)->second->Fill(phcode_best[wheel + 3][station][scsector], nHitsPhi);
602 
603  if (phcode_best[wheel + 3][station][scsector] > 3 && nHitsPhi >= 7) {
604  float x_trigger = trigGeomUtils->trigPos(iphbest[wheel + 3][station][scsector]);
605  float angle_trigger = trigGeomUtils->trigDir(iphbest[wheel + 3][station][scsector]);
606  trigGeomUtils->trigToSeg(station, x_trigger, x_angle);
607 
608  innerMECh.find("TM_PhitkvsPhitrig" + trigsrc)->second->Fill(x_trigger, x_track);
609  innerMECh.find("TM_PhibtkvsPhibtrig" + trigsrc)->second->Fill(angle_trigger, x_angle);
610  innerMECh.find("TM_PhiResidual" + trigsrc)->second->Fill(x_trigger - x_track);
611  innerMECh.find("TM_PhibResidual" + trigsrc)->second->Fill(angle_trigger - x_angle);
612  }
613  }
614 
615  if (useTM) {
616  // check for triggers elsewhere in the sector
617  bool trigFlagTM = false;
618  for (int ist = 1; ist < 5; ist++) {
619  if (ist != station && phcode_best[wheel + 3][ist][scsector] >= 2 &&
620  phcode_best[wheel + 3][ist][scsector] < 7 && track_ok[wheel + 3][ist][scsector] == true) {
621  trigFlagTM = true;
622  break;
623  }
624  }
625 
626  if (trigFlagTM && fabs(x_angle) < 40. && nHitsPhi >= 7) {
627  // position vs angle of track for reconstruced tracks (denom. for trigger efficiency)
628  innerME.find("TM_TrackPosvsAngle" + trigsrc)->second->Fill(x_angle, x_track);
629  if (phcode_best[wheel + 3][station][scsector] >= 2 && phcode_best[wheel + 3][station][scsector] < 7) {
630  innerME.find("TM_TrackPosvsAngleandTrig" + trigsrc)->second->Fill(x_angle, x_track);
631  if (phcode_best[wheel + 3][station][scsector] > 4) { //HH & HL Triggers
632  innerME.find("TM_TrackPosvsAngleandTrigHHHL" + trigsrc)->second->Fill(x_angle, x_track);
633  }
634  }
635  }
636 
637  if ((*btrack)->hasZed() && trigFlagTM && fabs(y_angle) < 40. &&
638  (*btrack)->zSegment()->degreesOfFreedom() >= 1) {
639  // position va angle of track for reconstruced tracks (denom. for trigger efficiency) along theta direction
640  innerME.find("TM_TrackThetaPosvsAngle" + trigsrc)->second->Fill(y_angle, y_track);
641  if (thcode_best[wheel + 3][station][scsector] > 0) {
642  innerME.find("TM_TrackThetaPosvsAngleandTrig" + trigsrc)->second->Fill(y_angle, y_track);
643  if (thcode_best[wheel + 3][station][scsector] == 2) {
644  innerME.find("TM_TrackThetaPosvsAngleandTrigH" + trigsrc)->second->Fill(y_angle, y_track);
645  }
646  }
647  }
648  }
649  }
650  }
651 }
652 
654  TH1* histo = me->getTH1();
655  if (!histo)
656  return;
657 
658  TAxis* axis = nullptr;
659  if (iaxis == 1) {
660  axis = histo->GetXaxis();
661  } else if (iaxis == 2) {
662  axis = histo->GetYaxis();
663  }
664  if (!axis)
665  return;
666 
667  string labels[7] = {"LI", "LO", "HI", "HO", "LL", "HL", "HH"};
668  int istart = axis->GetXmin() < -1 ? 2 : 1;
669  for (int i = 0; i < 7; i++) {
670  axis->SetBinLabel(i + istart, labels[i].c_str());
671  }
672 }
673 
675  TH1* histo = me->getTH1();
676  if (!histo)
677  return;
678 
679  TAxis* axis = nullptr;
680  if (iaxis == 1) {
681  axis = histo->GetXaxis();
682  } else if (iaxis == 2) {
683  axis = histo->GetYaxis();
684  }
685  if (!axis)
686  return;
687 
688  string labels[2] = {"L", "H"};
689  int istart = axis->GetXmin() < -1 ? 2 : 1;
690  for (int i = 0; i < 2; i++) {
691  axis->SetBinLabel(i + istart, labels[i].c_str());
692  }
693 }
694 
696  if (!isLocalRun) {
697  Handle<LTCDigiCollection> ltcdigis;
698  e.getByToken(ltcDigiCollectionToken_, ltcdigis);
699 
700  for (std::vector<LTCDigi>::const_iterator ltc_it = ltcdigis->begin(); ltc_it != ltcdigis->end(); ltc_it++) {
701  size_t otherTriggerSum = 0;
702  for (size_t i = 1; i < 6; i++) {
703  otherTriggerSum += size_t((*ltc_it).HasTriggered(i));
704  }
705  if ((*ltc_it).HasTriggered(0) && otherTriggerSum == 0)
706  trigsrc = "_DTonly";
707  else if (!(*ltc_it).HasTriggered(0))
708  trigsrc = "_NoDT";
709  else if ((*ltc_it).HasTriggered(0) && otherTriggerSum > 0)
710  trigsrc = "_DTalso";
711  }
712  return;
713  }
714 
715  trigsrc = "";
716  return;
717 }
718 
719 // Local Variables:
720 // show-trailing-whitespace: t
721 // truncate-lines: t
722 // End:
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DTLocalTriggerTask::iphbest
DTArr3PhDigi iphbest
Definition: DTLocalTriggerTask.h:120
DTRecSegment4D
Definition: DTRecSegment4D.h:23
DTLocalTriggerTask::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
To reset the MEs.
Definition: DTLocalTriggerTask.cc:179
simKBmtfStubs_cfi.minBX
minBX
Definition: simKBmtfStubs_cfi.py:9
DTTrigGeomUtils.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
DOFs::dof
dof
Definition: AlignPCLThresholdsWriter.cc:37
mps_fire.i
i
Definition: mps_fire.py:428
DTLocalTriggerTask::tmTh_Token_
edm::EDGetTokenT< L1MuDTChambThContainer > tmTh_Token_
Definition: DTLocalTriggerTask.h:104
DTTrigGeomUtils::trigDir
float trigDir(const L1MuDTChambPhDigi *trig)
Return local direction (trigger RF) for a given trigger primitive.
Definition: DTTrigGeomUtils.cc:138
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
DTLocalTriggerTask::bookBarrelHistos
void bookBarrelHistos(DQMStore::IBooker &, std::string histoTag)
Book the histograms.
Definition: DTLocalTriggerTask.cc:232
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
DTLocalTriggerTask::muonGeom
edm::ESHandle< DTGeometry > muonGeom
Definition: DTLocalTriggerTask.h:125
edm::Run
Definition: Run.h:45
min
T min(T a, T b)
Definition: MathUtil.h:58
printsummarytable.folder
folder
Definition: printsummarytable.py:7
DTLocalTriggerTask::track_ok
bool track_ok[6][5][15]
Definition: DTLocalTriggerTask.h:122
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
DTLocalTriggerTask::~DTLocalTriggerTask
~DTLocalTriggerTask() override
Destructor.
Definition: DTLocalTriggerTask.cc:64
pos
Definition: PixelAliasList.h:18
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DTTrigGeomUtils::trigPos
float trigPos(const L1MuDTChambPhDigi *trig)
Return local position (trigger RF) for a given trigger primitive.
Definition: DTTrigGeomUtils.cc:98
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DDAxes::x
DTLocalTriggerTask::useTM
bool useTM
Definition: DTLocalTriggerTask.h:109
edm::Handle< L1MuDTChambPhContainer >
DTLocalTriggerTask::triggerSource
void triggerSource(const edm::Event &e)
Get the L1A source.
Definition: DTLocalTriggerTask.cc:695
DTLocalTriggerTask::seg_Token_
edm::EDGetTokenT< DTRecSegment4DCollection > seg_Token_
Definition: DTLocalTriggerTask.h:106
edm::RangeMap::id_iterator
identifier iterator
Definition: RangeMap.h:130
DTLocalTriggerTask::doTMTheta
bool doTMTheta
Definition: DTLocalTriggerTask.h:114
L1MuDTChambPhContainer::getContainer
Phi_Container const * getContainer() const
Definition: L1MuDTChambPhContainer.cc:41
DTLocalTriggerTask::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Book the histograms.
Definition: DTLocalTriggerTask.cc:78
DTLocalTriggerTask::parameters
edm::ParameterSet parameters
Definition: DTLocalTriggerTask.h:124
DTLocalTriggerTask::bookWheelHistos
void bookWheelHistos(DQMStore::IBooker &, int wh, std::string histoTag)
Book the histograms.
Definition: DTLocalTriggerTask.cc:397
DTLocalTriggerTask::dqmBeginRun
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Beginrun.
Definition: DTLocalTriggerTask.cc:72
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1119
DTLocalTriggerTask::topFolder
std::string & topFolder()
Get the Top folder (different between Physics and TP and TM)
Definition: DTLocalTriggerTask.h:98
DTLocalTriggerTask::DTLocalTriggerTask
DTLocalTriggerTask(const edm::ParameterSet &ps)
Constructor.
Definition: DTLocalTriggerTask.cc:34
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
DTLocalTriggerTask::detailedAnalysis
bool detailedAnalysis
Definition: DTLocalTriggerTask.h:115
DTLocalTriggerTask::isLocalRun
bool isLocalRun
Definition: DTLocalTriggerTask.h:132
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
DTLocalTriggerTask.h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DTLocalTriggerTask::bookHistos
void bookHistos(DQMStore::IBooker &, const DTChamberId &dtCh, std::string folder, std::string histoTag)
Definition: DTLocalTriggerTask.cc:242
DTLocalTriggerTask::wheelArrayShift
const int wheelArrayShift
Definition: DTLocalTriggerTask.h:100
DTLocalTriggerTask::nevents
int nevents
Definition: DTLocalTriggerTask.h:111
DTLayer.h
DTTrigGeomUtils::phiRange
void phiRange(const DTChamberId &id, float &min, float &max, int &nbins, float step=15)
Compute phi range in local chamber coordinates.
Definition: DTTrigGeomUtils.cc:67
DTGeometry.h
DTLocalTriggerTask::baseFolderTM
std::string baseFolderTM
Definition: DTLocalTriggerTask.h:113
funct::true
true
Definition: Factorize.h:173
DTLocalTriggerTask::tpMode
bool tpMode
Definition: DTLocalTriggerTask.h:112
edm::ParameterSet
Definition: ParameterSet.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
Pi.h
DTTrigGeomUtils::thetaRange
void thetaRange(const DTChamberId &id, float &min, float &max, int &nbins, float step=15)
Compute theta range in local chamber coordinates.
Definition: DTTrigGeomUtils.cc:86
DTTrigGeomUtils::trigToSeg
void trigToSeg(int st, float &x, float dir)
Compute Trigger x coordinate in chamber RF.
Definition: DTTrigGeomUtils.h:45
DTLocalTriggerTask::setQLabels
void setQLabels(MonitorElement *me, short int iaxis)
Set Quality labels.
Definition: DTLocalTriggerTask.cc:653
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
dtResolutionTest_cfi.histoTag
histoTag
Definition: dtResolutionTest_cfi.py:21
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
createfilelist.int
int
Definition: createfilelist.py:10
L1MuDTChambThContainer::getContainer
The_Container const * getContainer() const
Definition: L1MuDTChambThContainer.cc:41
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
DTTrigGeomUtils::computeSCCoordinates
void computeSCCoordinates(const DTRecSegment4D *track, int &scsec, float &x, float &xdir, float &y, float &ydir)
Compute track coordinates with SC sector numbering.
Definition: DTTrigGeomUtils.cc:52
DTLocalTriggerTask::trigsrc
std::string trigsrc
Definition: DTLocalTriggerTask.h:110
simKBmtfStubs_cfi.maxBX
maxBX
Definition: simKBmtfStubs_cfi.py:10
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
get
#define get
DTLocalTriggerTask::tm_IDDataErrorPlot
MonitorElement * tm_IDDataErrorPlot
Definition: DTLocalTriggerTask.h:130
DTLocalTriggerTask::useSEG
bool useSEG
Definition: DTLocalTriggerTask.h:109
DTLocalTriggerTask::digiHistos
std::map< uint32_t, std::map< std::string, MonitorElement * > > digiHistos
Definition: DTLocalTriggerTask.h:127
DTLocalTriggerTask::setQLabelsTheta
void setQLabelsTheta(MonitorElement *me, short int iaxis)
Definition: DTLocalTriggerTask.cc:674
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
edm::RangeMap::range
std::pair< const_iterator, const_iterator > range
iterator range
Definition: RangeMap.h:50
DTLocalTriggerTask::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
Definition: DTLocalTriggerTask.cc:194
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTLocalTriggerTask::ithbest
DTArr3ThDigi ithbest
Definition: DTLocalTriggerTask.h:121
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
DTTrigGeomUtils
Definition: DTTrigGeomUtils.h:21
DTLocalTriggerTask::thcode_best
DTArr3int thcode_best
Definition: DTLocalTriggerTask.h:118
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
DTLocalTriggerTask::ros_Token_
edm::EDGetTokenT< DTLocalTriggerCollection > ros_Token_
Definition: DTLocalTriggerTask.h:105
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
genParticles_cff.map
map
Definition: genParticles_cff.py:11
DTChamberId
Definition: DTChamberId.h:14
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
MuonGeometryRecord.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
DTLocalTriggerTask::runSegmentAnalysis
void runSegmentAnalysis(edm::Handle< DTRecSegment4DCollection > &segments4D)
Run analysis using DT 4D segments.
Definition: DTLocalTriggerTask.cc:539
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
DTTopology.h
DTLocalTriggerTask::runTMAnalysis
void runTMAnalysis(std::vector< L1MuDTChambPhDigi > const *phTrigs, std::vector< L1MuDTChambThDigi > const *thTrigs)
Run analysis on TM data.
Definition: DTLocalTriggerTask.cc:411
fftjetimagerecorder_cfi.histoLabel
histoLabel
Definition: fftjetimagerecorder_cfi.py:12
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
DTLocalTriggerTask::phcode_best
DTArr3int phcode_best
Definition: DTLocalTriggerTask.h:117
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::InputTag
Definition: InputTag.h:15
DTLocalTriggerTask::trigGeomUtils
DTTrigGeomUtils * trigGeomUtils
Definition: DTLocalTriggerTask.h:126
DTLocalTriggerTask::tm_Token_
edm::EDGetTokenT< L1MuDTChambPhContainer > tm_Token_
Definition: DTLocalTriggerTask.h:103
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
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
DTLocalTriggerTask::ltcDigiCollectionToken_
edm::EDGetTokenT< LTCDigiCollection > ltcDigiCollectionToken_
Definition: DTLocalTriggerTask.h:107
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37