CMS 3D CMS Logo

DTLocalTriggerBaseTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTLocalTriggerBaseTask.cc
3  *
4  * \author C. Battilana - CIEMAT
5  *
6 */
7 
9 
10 // Framework
12 
13 // DT DQM
15 
16 // DT trigger
18 
19 // Geometry
25 
26 //Root
27 #include"TH1.h"
28 #include"TAxis.h"
29 
30 #include <sstream>
31 #include <iostream>
32 #include <fstream>
33 
34 using namespace edm;
35 using namespace std;
36 
38 
39 public:
40 
41  DTTPGCompareUnit() { theQual[0]=-1 ; theQual[1]=-1; }
43 
44  void setDDU(int qual, int bx) { theQual[0] = qual; theBX[0] = bx; }
45  void setTM(int qual, int bx) { theQual[1] = qual; theBX[1] = bx; }
46 
47  bool hasOne() const { return theQual[0]!=-1 || theQual[1]!=-1; };
48  bool hasBoth() const { return theQual[0]!=-1 && theQual[1]!=-1; };
49  bool hasSameQual() const { return hasBoth() && theQual[0]==theQual[1]; };
50  int deltaBX() const { return theBX[0] - theBX[1]; }
51  int qualDDU() const { return theQual[0]; }
52  int qualTM() const { return theQual[1]; }
53 
54 private:
55 
56  int theQual[2]; // 0=DDU 1=TM
57  int theBX[2]; // 0=DDU 1=TM
58 
59 };
60 
61 
62 
64  nEvents(0), nLumis(0), theTrigGeomUtils(0) {
65 
66  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
67  << "[DTLocalTriggerBaseTask]: Constructor"<<endl;
68 
69  tpMode = ps.getUntrackedParameter<bool>("testPulseMode");
70  detailedAnalysis = ps.getUntrackedParameter<bool>("detailedAnalysis");
71 
72  targetBXTM = ps.getUntrackedParameter<int>("targetBXTM");
73  targetBXDDU = ps.getUntrackedParameter<int>("targetBXDDU");
74  bestAccRange = ps.getUntrackedParameter<int>("bestTrigAccRange");
75 
76  processTM = ps.getUntrackedParameter<bool>("processTM");
77  processDDU = ps.getUntrackedParameter<bool>("processDDU");
78 
79  tm_phiIn_Token_ = consumes<L1MuDTChambPhContainer>(
80  ps.getUntrackedParameter<InputTag>("inputTagTMphIn"));
81  tm_phiOut_Token_ = consumes<L1MuDTChambPhContainer>(
82  ps.getUntrackedParameter<InputTag>("inputTagTMphOut"));
83  tm_theta_Token_ = consumes<L1MuDTChambThContainer>(
84  ps.getUntrackedParameter<InputTag>("inputTagTMth"));
85  trig_Token_ = consumes<DTLocalTriggerCollection>(
86  ps.getUntrackedParameter<InputTag>("inputTagDDU"));
87 
88  if (processTM) theTypes.push_back("TM");
89  if (processDDU) theTypes.push_back("DDU");
90 
91 
92  if (tpMode) {
93  topFolder("TM") = "DT/11-LocalTriggerTP-TM/";
94  topFolder("DDU") = "DT/12-LocalTriggerTP-DDU/";
95  } else {
96  topFolder("TM") = "DT/03-LocalTrigger-TM/";
97  topFolder("DDU") = "DT/04-LocalTrigger-DDU/";
98  }
99 
100  theParams = ps;
101 
102 }
103 
104 
106 
107  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
108  << "[DTLocalTriggerBaseTask]: analyzed " << nEvents << " events" << endl;
109  if (theTrigGeomUtils) { delete theTrigGeomUtils; }
110 
111 }
112 
114 
115  ibooker.setCurrentFolder("DT/EventInfo/Counters");
116  nEventMonitor = ibooker.bookFloat("nProcessedEventsTrigger");
117  for (int wh=-2;wh<3;++wh){
118  for (int stat=1;stat<5;++stat){
119  for (int sect=1;sect<13;++sect){
120  bookHistos(ibooker, DTChamberId(wh,stat,sect));
121  }
122  }
123  if (processDDU) bookHistos(ibooker, wh);
124  }
125 }
126 
127 
129 
130  nEventsInLS=0;
131  nLumis++;
132  int resetCycle = theParams.getUntrackedParameter<int>("ResetCycle");
133 
134  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
135  << "[DTLocalTriggerBaseTask]: Begin of LS transition" << endl;
136 
137  if( nLumis%resetCycle == 0 ) {
138  map<uint32_t,map<string,MonitorElement*> >::const_iterator chambIt = chamberHistos.begin();
139  map<uint32_t,map<string,MonitorElement*> >::const_iterator chambEnd = chamberHistos.end();
140  for(;chambIt!=chambEnd;++chambIt) {
141  map<string,MonitorElement*>::const_iterator histoIt = chambIt->second.begin();
142  map<string,MonitorElement*>::const_iterator histoEnd = chambIt->second.end();
143  for(;histoIt!=histoEnd;++histoIt) {
144  histoIt->second->Reset();
145  }
146  }
147  }
148 
149 }
150 
152 
153  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
154  << "[DTLocalTriggerBaseTask]: End of LS transition" << endl;
155 
156  map<uint32_t,DTTimeEvolutionHisto* >::const_iterator chambIt = trendHistos.begin();
157  map<uint32_t,DTTimeEvolutionHisto* >::const_iterator chambEnd = trendHistos.end();
158  for(;chambIt!=chambEnd;++chambIt) {
159  chambIt->second->updateTimeSlot(lumiSeg.luminosityBlock(), nEventsInLS);
160  }
161 
162 }
163 
164 
166 
167  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
168  << "[DTLocalTriggerBaseTask]: BeginRun" << endl;
169 
170  ESHandle<DTGeometry> theGeom;
171  context.get<MuonGeometryRecord>().get(theGeom);
172  theTrigGeomUtils = new DTTrigGeomUtils(theGeom);
173 
174 }
175 
176 
178 
179  nEvents++;
180  nEventsInLS++;
182 
183  theCompMapIn.clear();
184  theCompMapOut.clear();
185 
186  Handle<L1MuDTChambPhContainer> phiInTrigsTM;
187  Handle<L1MuDTChambPhContainer> phiOutTrigsTM;
188  Handle<L1MuDTChambThContainer> thetaTrigsTM;
190 
191  if (processTM) {
192  InputTag inputTagTM = theParams.getUntrackedParameter<InputTag>("inputTagTM");
193 
194  e.getByToken(tm_phiIn_Token_, phiInTrigsTM);
195  e.getByToken(tm_phiOut_Token_, phiOutTrigsTM);
196  e.getByToken(tm_theta_Token_, thetaTrigsTM);
197 
198  if (phiInTrigsTM.isValid() && phiOutTrigsTM.isValid() && thetaTrigsTM.isValid()) {
199  runTMAnalysis(phiInTrigsTM->getContainer(),phiOutTrigsTM->getContainer(),thetaTrigsTM->getContainer());
200  } else {
201  LogVerbatim("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
202  << "[DTLocalTriggerBaseTask]: one or more TM handles for Input Tag "
203  << inputTagTM <<" not found!" << endl;
204  return;
205  }
206  }
207 
208  if (processDDU) {
209  InputTag inputTagDDU = theParams.getUntrackedParameter<InputTag>("inputTagDDU");
210  e.getByToken(trig_Token_, trigsDDU);
211 
212  if (trigsDDU.isValid()) {
213  runDDUAnalysis(trigsDDU);
214  } else {
215  LogVerbatim("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
216  << "[DTLocalTriggerBaseTask]: one or more DDU handles for Input Tag "
217  << inputTagDDU <<" not found!" << endl;
218  return;
219  }
220  }
221 
222  if (processTM && processDDU)
224 
225 }
226 
227 
229 
230  uint32_t rawId = dtCh.rawId();
231 
232  stringstream wheel; wheel << dtCh.wheel();
233  stringstream station; station << dtCh.station();
234  stringstream sector; sector << dtCh.sector();
235 
236  map<string,int> minBX;
237  map<string,int> maxBX;
238 
239  minBX["TM"] = theParams.getUntrackedParameter<int>("minBXTM");
240  maxBX["TM"] = theParams.getUntrackedParameter<int>("maxBXTM");
241  minBX["DDU"] = theParams.getUntrackedParameter<int>("minBXDDU");
242  maxBX["DDU"] = theParams.getUntrackedParameter<int>("maxBXDDU");
243 
244  int nTimeBins = theParams.getUntrackedParameter<int>("nTimeBins");
245  int nLSTimeBin = theParams.getUntrackedParameter<int>("nLSTimeBin");
246 
247  string chTag = "_W" + wheel.str() + "_Sec" + sector.str() + "_St" + station.str();
248  string labelInOut = "";
249 
250  vector<string>::const_iterator typeIt = theTypes.begin();
251  vector<string>::const_iterator typeEnd = theTypes.end();
252 
253  for (; typeIt!=typeEnd; ++typeIt) {
254 
255  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
256  << "[DTLocalTriggerBaseTask]: booking histos for " << topFolder((*typeIt)) << "Wheel"
257  << wheel.str() << "/Sector" << sector.str() << "/Station"<< station.str() << endl;
258 
259  for (int InOut=0; InOut<2;InOut++){
260  // Book Phi View Related Plots
261 
262  if(InOut==0)
263  {ibooker.setCurrentFolder(topFolder(*typeIt) + "Wheel" + wheel.str() + "/Sector"
264  + sector.str() + "/Station" + station.str() + "/LocalTriggerPhiIn");
265  labelInOut = "_In";}
266  else if (InOut==1){
267  ibooker.setCurrentFolder(topFolder(*typeIt) + "Wheel" + wheel.str() + "/Sector"
268  + sector.str() + "/Station" + station.str() + "/LocalTriggerPhiOut");
269  labelInOut = "_Out";}
270 
271 
272  string histoTag = (*typeIt) + "_BXvsQual" + labelInOut;
273  chamberHistos[rawId][histoTag] = ibooker.book2D(histoTag+chTag,"BX vs trigger quality",
274  7,-0.5,6.5,(int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5);
275  setQLabels((chamberHistos[rawId])[histoTag],1);
276 
277  if (!tpMode) {
278  histoTag = (*typeIt) + "_BestQual" + labelInOut;
279  chamberHistos[rawId][histoTag] = ibooker.book1D(histoTag+chTag,
280  "Trigger quality of best primitives",7,-0.5,6.5);
281  setQLabels(chamberHistos[rawId][histoTag],1);
282 
283  histoTag = (*typeIt) + "_Flag1stvsQual" + labelInOut;
284  chamberHistos[dtCh.rawId()][histoTag] = ibooker.book2D(histoTag+chTag,
285  "1st/2nd trig flag vs quality",7,-0.5,6.5,2,-0.5,1.5);
286  setQLabels(chamberHistos[rawId][histoTag],1);
287  }
288 
289  if (*typeIt=="TM") {
290  float minPh, maxPh; int nBinsPh;
291  theTrigGeomUtils->phiRange(dtCh,minPh,maxPh,nBinsPh);
292 
293  histoTag = (*typeIt) + "_QualvsPhirad" + labelInOut;
294  chamberHistos[rawId][histoTag] = ibooker.book2D(histoTag+chTag,
295  "Trigger quality vs local position",nBinsPh,minPh,maxPh,7,-0.5,6.5);
296  setQLabels(chamberHistos[rawId][histoTag],2);
297 
298  if (detailedAnalysis && !tpMode) {
299  histoTag = (*typeIt) + "_QualvsPhibend" + labelInOut;
300  chamberHistos[rawId][histoTag] = ibooker.book2D(histoTag+chTag,
301  "Trigger quality vs local direction",200,-40.,40.,7,-0.5,6.5);
302  setQLabels((chamberHistos[dtCh.rawId()])[histoTag],2);
303  }
304  }
305  } //InOut loop
306 
307  // Book Theta View Related Plots
308  ibooker.setCurrentFolder(topFolder(*typeIt) + "Wheel" + wheel.str() + "/Sector"
309  + sector.str() + "/Station" + station.str() + "/LocalTriggerTheta");
310 
311  string histoTag = "";
312  if((*typeIt)=="TM" && dtCh.station()!=4) {
313  histoTag = (*typeIt) + "_PositionvsBX";
314  chamberHistos[rawId][histoTag] = ibooker.book2D(histoTag+chTag,"Theta trigger position vs BX",
315  (int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5,7,-0.5,6.5);
316  histoTag = (*typeIt) + "_PositionvsQual";
317  chamberHistos[rawId][histoTag] = ibooker.book2D(histoTag+chTag,"Theta trigger position vs quality",
318  2,0.5,2.5,7,-0.5,6.5);
319  setQLabelsTheta(chamberHistos[rawId][histoTag],1);
320  histoTag = (*typeIt) + "_ThetaBXvsQual";
321  chamberHistos[rawId][histoTag] = ibooker.book2D(histoTag+chTag,"BX vs trigger quality",
322  2,0.5,2.5,(int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5);
323  setQLabelsTheta(chamberHistos[rawId][histoTag],1);
324 // histoTag = (*typeIt) + "_ThetaBestQual";
325 // chamberHistos[rawId][histoTag] = ibooker.book1D(histoTag+chTag,
326 // "Trigger quality of best primitives (theta)",2,0.5,2.5); // 0 = not fired, 1 = L, 2 = H
327 // setQLabelsTheta(chamberHistos[rawId][histoTag],1);
328  } else {
329  if(dtCh.station()!=4){
330  histoTag = (*typeIt) + "_ThetaBXvsQual";
331  chamberHistos[rawId][histoTag] = ibooker.book2D(histoTag+chTag,"BX vs trigger quality",7,-0.5,6.5,
332  (int)(maxBX[(*typeIt)]-minBX[*typeIt]+1),minBX[*typeIt]-.5,maxBX[*typeIt]+.5);
333  setQLabels((chamberHistos[dtCh.rawId()])[histoTag],1);
334 
335  histoTag = (*typeIt) + "_ThetaBestQual";
336  chamberHistos[rawId][histoTag] = ibooker.book1D(histoTag+chTag,
337  "Trigger quality of best primitives (theta)",7,-0.5,6.5);
338  setQLabels((chamberHistos[dtCh.rawId()])[histoTag],1);
339  }
340  }
341 
342  }
343 
344  if (processTM && processDDU) {
345  // Book TM/DDU Comparison Plots
346  // NOt needed In and Out comparison, only IN in DDU....
347  ibooker.setCurrentFolder(topFolder("DDU") + "Wheel" + wheel.str() + "/Sector"
348  + sector.str() + "/Station" + station.str() + "/LocalTriggerPhiIn");
349 
350 
351  string histoTag = "COM_QualDDUvsQualTM";
352  chamberHistos[rawId][histoTag] = ibooker.book2D(histoTag+chTag,
353  "DDU quality vs TM quality",8,-1.5,6.5,8,-1.5,6.5);
354  setQLabels((chamberHistos[rawId])[histoTag],1);
355  setQLabels((chamberHistos[rawId])[histoTag],2);
356 
357  histoTag = "COM_MatchingTrend";
358  trendHistos[rawId] = new DTTimeEvolutionHisto(ibooker,histoTag+chTag,
359  "Fraction of DDU-TM matches w.r.t. proc evts",
360  nTimeBins,nLSTimeBin,true,0);
361  }
362 
363 }
364 
366 
367  stringstream wheel; wheel << wh;
368  ibooker.setCurrentFolder(topFolder("DDU") + "Wheel" + wheel.str() + "/");
369  string whTag = "_W" + wheel.str();
370 
371  LogTrace("DTDQM|DTMonitorModule|DTLocalTriggerBaseTask")
372  << "[DTLocalTriggerBaseTask]: booking wheel histos for "
373  << topFolder("DDU") << "Wheel" << wh << endl;
374 
375  string histoTag = "COM_BXDiff";
376  MonitorElement *me = ibooker.bookProfile2D(histoTag+whTag,
377  "DDU-TM BX Difference",12,1,13,4,1,5,0.,20.);
378  me->setAxisTitle("Sector",1);
379  me->setAxisTitle("station",2);
380  wheelHistos[wh][histoTag] = me;
381 
382 }
383 
384 
385 void DTLocalTriggerBaseTask::runTMAnalysis( std::vector<L1MuDTChambPhDigi> const* phInTrigs,
386  std::vector<L1MuDTChambPhDigi> const* phOutTrigs,
387  std::vector<L1MuDTChambThDigi> const* thTrigs )
388 {
389  vector<L1MuDTChambPhDigi>::const_iterator iph = phInTrigs->begin();
390  vector<L1MuDTChambPhDigi>::const_iterator iphe = phInTrigs->end();
391 
392  for(; iph !=iphe ; ++iph) {
393 
394  int wh = iph->whNum();
395  int sec = iph->scNum() + 1; // DTTF->DT Convention
396  int st = iph->stNum();
397  int qual = iph->code();
398  int is1st = iph->Ts2Tag() ? 1 : 0;
399  int bx = iph->bxNum() - is1st;
400  if (qual <0 || qual>6) continue; // Check that quality is in a valid range
401 
402  DTChamberId dtChId(wh,st,sec);
403  uint32_t rawId = dtChId.rawId();
404 
405  float pos = theTrigGeomUtils->trigPos(&(*iph));
406  float dir = theTrigGeomUtils->trigDir(&(*iph));
407 
408  if (abs(bx-targetBXTM)<= bestAccRange &&
409  theCompMapIn[rawId].qualTM() <= qual)
410  theCompMapIn[rawId].setTM(qual,bx);
411 
412  map<string, MonitorElement*> &innerME = chamberHistos[rawId];
413  if (tpMode) {
414  innerME["TM_BXvsQual_In"]->Fill(qual,bx); // SM BX vs Qual Phi view (1st tracks)
415  innerME["TM_QualvsPhirad_In"]->Fill(pos,qual); // SM Qual vs radial angle Phi view
416  } else {
417  innerME["TM_BXvsQual_In"]->Fill(qual,bx); // SM BX vs Qual Phi view (1st tracks)
418  innerME["TM_Flag1stvsQual_In"]->Fill(qual,is1st); // SM Qual 1st/2nd track flag Phi view
419  if (!is1st) innerME["TM_QualvsPhirad_In"]->Fill(pos,qual); // SM Qual vs radial angle Phi view ONLY for 1st tracks
420  if (detailedAnalysis) {
421  innerME["TM_QualvsPhibend_In"]->Fill(dir,qual); // SM Qual vs bending Phi view
422  }
423  }
424 
425  }
426 
427  iph = phOutTrigs->begin();
428  iphe = phOutTrigs->end();
429 
430  for(; iph !=iphe ; ++iph) {
431 
432  int wh = iph->whNum();
433  int sec = iph->scNum() + 1; // DTTF->DT Convention
434  int st = iph->stNum();
435  int qual = iph->code();
436  int is1st = iph->Ts2Tag() ? 1 : 0;
437  int bx = iph->bxNum() - is1st;
438 
439  if (qual <0 || qual>6) continue; // Check that quality is in a valid range
440 
441  DTChamberId dtChId(wh,st,sec);
442  uint32_t rawId = dtChId.rawId();
443 
444  float pos = theTrigGeomUtils->trigPos(&(*iph));
445  float dir = theTrigGeomUtils->trigDir(&(*iph));
446 
447  if (abs(bx-targetBXTM)<= bestAccRange &&
448  theCompMapOut[rawId].qualTM() <= qual)
449  theCompMapOut[rawId].setTM(qual,bx);
450 
451  map<string, MonitorElement*> &innerME = chamberHistos[rawId];
452  if (tpMode) {
453  innerME["TM_BXvsQual_Out"]->Fill(qual,bx); // SM BX vs Qual Phi view (1st tracks)
454  innerME["TM_QualvsPhirad_Out"]->Fill(pos,qual); // SM Qual vs radial angle Phi view
455  } else {
456  innerME["TM_BXvsQual_Out"]->Fill(qual,bx); // SM BX vs Qual Phi view (1st tracks)
457  innerME["TM_Flag1stvsQual_Out"]->Fill(qual,is1st); // SM Qual 1st/2nd track flag Phi view
458  if (!is1st) innerME["TM_QualvsPhirad_Out"]->Fill(pos,qual); // SM Qual vs radial angle Phi view ONLY for 1st tracks
459  if (detailedAnalysis) {
460  innerME["TM_QualvsPhibend_Out"]->Fill(dir,qual); // SM Qual vs bending Phi view
461  }
462  }
463 
464  }
465 
466  vector<L1MuDTChambThDigi>::const_iterator ith = thTrigs->begin();
467  vector<L1MuDTChambThDigi>::const_iterator ithe = thTrigs->end();
468 
469  for(; ith != ithe; ++ith) {
470  int wh = ith->whNum();
471  int sec = ith->scNum() + 1; // DTTF -> DT Convention
472  int st = ith->stNum();
473  int bx = ith->bxNum();
474 
475  int thcode[7];
476 
477  for (int pos=0; pos<7; pos++)
478  thcode[pos] = ith->code(pos);
479 
480  DTChamberId dtChId(wh,st,sec);
481  uint32_t rawId = dtChId.rawId();
482 
483  map<string, MonitorElement*> &innerME = chamberHistos[rawId];
484 
485  for (int pos=0; pos<7; pos++)
486  if (thcode[pos]>0) {//Fired
487  innerME["TM_PositionvsBX"]->Fill(bx,pos); // SM BX vs Position Theta view
488  innerME["TM_PositionvsQual"]->Fill(thcode[pos],pos); //code = pos + qual; so 0, 1, 2 for 0, L, H resp.
489  innerME["TM_ThetaBXvsQual"]->Fill(thcode[pos],bx); //code = pos + qual; so 0, 1, 2 for 0, L, H resp.
490  }
491  }
492  // Fill Quality plots with best TM triggers (phi view In)
493  if (!tpMode) {
494  map<uint32_t,DTTPGCompareUnit>::const_iterator compIt = theCompMapIn.begin();
495  map<uint32_t,DTTPGCompareUnit>::const_iterator compEnd = theCompMapIn.end();
496  for (; compIt!=compEnd; ++compIt) {
497  int bestQual = compIt->second.qualTM();
498  if (bestQual > -1)
499  chamberHistos[compIt->first]["TM_BestQual_In"]->Fill(bestQual); // SM Best Qual Trigger Phi view
500  }
501  }
502 
503  // Fill Quality plots with best TM triggers (phi view Out)
504  if (!tpMode) {
505  map<uint32_t,DTTPGCompareUnit>::const_iterator compIt = theCompMapOut.begin();
506  map<uint32_t,DTTPGCompareUnit>::const_iterator compEnd = theCompMapOut.end();
507  for (; compIt!=compEnd; ++compIt) {
508  int bestQual = compIt->second.qualTM();
509  if (bestQual > -1)
510  chamberHistos[compIt->first]["TM_BestQual_Out"]->Fill(bestQual); // SM Best Qual Trigger Phi view
511  }
512  }
513 
514 }
515 
516 
518 
519  DTLocalTriggerCollection::DigiRangeIterator detUnitIt = trigsDDU->begin();
520  DTLocalTriggerCollection::DigiRangeIterator detUnitEnd = trigsDDU->end();
521 
522  for (; detUnitIt!=detUnitEnd; ++detUnitIt){
523 
524  const DTChamberId& chId = (*detUnitIt).first;
525  uint32_t rawId = chId.rawId();
526 
527  const DTLocalTriggerCollection::Range& range = (*detUnitIt).second;
528  DTLocalTriggerCollection::const_iterator trigIt = range.first;
529  map<string, MonitorElement*> &innerME = chamberHistos[rawId];
530 
531  int bestQualTheta = -1;
532 
533  for (; trigIt!=range.second; ++trigIt){
534 
535  int qualPhi = trigIt->quality();
536  int qualTheta = trigIt->trTheta();
537  int flag1st = trigIt->secondTrack() ? 1 : 0;
538  int bx = trigIt->bx();
539  int bxPhi = bx - flag1st; // phi BX assign is different for 1st & 2nd tracks
540 
541  if( qualPhi>-1 && qualPhi<7 ) { // it is a phi trigger
542  if (abs(bx-targetBXDDU) <= bestAccRange &&
543  theCompMapIn[rawId].qualDDU()<= qualPhi)
544  theCompMapIn[rawId].setDDU(qualPhi,bxPhi);
545  if(tpMode) {
546  innerME["DDU_BXvsQual"]->Fill(qualPhi,bxPhi); // SM BX vs Qual Phi view
547  } else {
548  innerME["DDU_BXvsQual"]->Fill(qualPhi,bxPhi); // SM BX vs Qual Phi view
549  innerME["DDU_Flag1stvsQual"]->Fill(qualPhi,flag1st); // SM Quality vs 1st/2nd track flag Phi view
550  }
551  }
552 
553  if( qualTheta>0 && !tpMode ){// it is a theta trigger & is not TP
554  if (qualTheta > bestQualTheta){
555  bestQualTheta = qualTheta;
556  }
557  innerME["DDU_ThetaBXvsQual"]->Fill(qualTheta,bx); // SM BX vs Qual Theta view
558  }
559  }
560 
561  // Fill Quality plots with best ddu triggers
562  if (!tpMode && theCompMapIn.find(rawId)!= theCompMapIn.end()) {
563  int bestQualPhi = theCompMapIn[rawId].qualDDU();
564  if (bestQualPhi>-1)
565  innerME["DDU_BestQual"]->Fill(bestQualPhi); // SM Best Qual Trigger Phi view
566  if(bestQualTheta>0) {
567  innerME["DDU_ThetaBestQual"]->Fill(bestQualTheta); // SM Best Qual Trigger Theta view
568  }
569  }
570  }
571 
572 }
573 
574 
576 
577  map<uint32_t,DTTPGCompareUnit>::const_iterator compIt = theCompMapIn.begin();
578  map<uint32_t,DTTPGCompareUnit>::const_iterator compEnd = theCompMapIn.end();
579 
580  for (; compIt!=compEnd; ++compIt) {
581 
582  uint32_t rawId = compIt->first;
583  DTChamberId chId(rawId);
584  map<string, MonitorElement*> &innerME = chamberHistos[rawId];
585 
586  const DTTPGCompareUnit & compUnit = compIt->second;
587  if ( compUnit.hasOne() ){
588  innerME["COM_QualDDUvsQualTM"]->Fill(compUnit.qualTM(),compUnit.qualDDU());
589  }
590  if ( compUnit.hasBoth() ){
591  wheelHistos[chId.wheel()]["COM_BXDiff"]->Fill(chId.sector(),chId.station(),compUnit.deltaBX());
592  if ( compUnit.hasSameQual() ) {
593  trendHistos[rawId]->accumulateValueTimeSlot(1);
594  }
595  }
596  }
597 
598 }
599 
600 
602 
603  TH1* histo = me->getTH1();
604  if (!histo) return;
605 
606  TAxis* axis=0;
607  if (iaxis==1) {
608  axis=histo->GetXaxis();
609  }
610  else if(iaxis==2) {
611  axis=histo->GetYaxis();
612  }
613  if (!axis) return;
614 
615  string labels[7] = {"LI","LO","HI","HO","LL","HL","HH"};
616  int istart = axis->GetXmin()<-1 ? 2 : 1;
617  for (int i=0;i<7;i++) {
618  axis->SetBinLabel(i+istart,labels[i].c_str());
619  }
620 
621 }
622 
624 
625  TH1* histo = me->getTH1();
626  if (!histo) return;
627 
628  TAxis* axis=0;
629  if (iaxis==1) {
630  axis=histo->GetXaxis();
631  }
632  else if(iaxis==2) {
633  axis=histo->GetYaxis();
634  }
635  if (!axis) return;
636 
637  string labels[2] = {"L","H"};
638  int istart = axis->GetXmin()<-1 ? 2 : 1;
639  for (int i=0;i<2;i++) {
640  axis->SetBinLabel(i+istart,labels[i].c_str());
641  }
642 
643 }
644 // Local Variables:
645 // show-trailing-whitespace: t
646 // truncate-lines: t
647 // End:
The_Container const * getContainer() const
T getUntrackedParameter(std::string const &, T const &) const
void runDDUvsTMAnalysis()
Run analysis on ROS data.
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Beginrun.
void bookHistos(DQMStore::IBooker &, const DTChamberId &chamb)
Book the histograms.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
float trigDir(const L1MuDTChambPhDigi *trig)
Return local direction (trigger RF) for a given trigger primitive.
void setDDU(int qual, int bx)
std::map< int, std::map< std::string, MonitorElement * > > wheelHistos
void setTM(int qual, int bx)
virtual ~DTLocalTriggerBaseTask()
Destructor.
std::vector< std::string > theTypes
void Fill(long long x)
LuminosityBlockNumber_t luminosityBlock() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
DTTrigGeomUtils * theTrigGeomUtils
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
Perform trend plot operations.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
MonitorElement * bookProfile2D(Args &&...args)
Definition: DQMStore.h:163
edm::EDGetTokenT< L1MuDTChambThContainer > tm_theta_Token_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TH1 * getTH1(void) const
std::map< uint32_t, DTTPGCompareUnit > theCompMapOut
edm::EDGetTokenT< DTLocalTriggerCollection > trig_Token_
void runTMAnalysis(std::vector< L1MuDTChambPhDigi > const *phInTrigs, std::vector< L1MuDTChambPhDigi > const *phOutTrigs, std::vector< L1MuDTChambThDigi > const *thTrigs)
Run analysis on TM data.
bool isValid() const
Definition: HandleBase.h:74
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context) override
To reset the MEs.
#define LogTrace(id)
void phiRange(const DTChamberId &id, float &min, float &max, int &nbins, float step=15)
Compute phi range in local chamber coordinates.
std::map< uint32_t, DTTPGCompareUnit > theCompMapIn
std::string & topFolder(std::string const &type)
Get the Top folder (different between Physics and TP and TM/DDU)
std::map< uint32_t, std::map< std::string, MonitorElement * > > chamberHistos
void setQLabelsTheta(MonitorElement *me, short int iaxis)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const T & get() const
Definition: EventSetup.h:55
std::vector< DTLocalTrigger >::const_iterator const_iterator
Phi_Container const * getContainer() const
HLT enums.
int sector() const
Definition: DTChamberId.h:61
void setQLabels(MonitorElement *me, short int iaxis)
Set Quality labels.
edm::EDGetTokenT< L1MuDTChambPhContainer > tm_phiIn_Token_
std::map< uint32_t, DTTimeEvolutionHisto * > trendHistos
std::pair< const_iterator, const_iterator > Range
MonitorElement * bookFloat(Args &&...args)
Definition: DQMStore.h:109
dbl *** dir
Definition: mlp_gen.cc:35
void runDDUAnalysis(edm::Handle< DTLocalTriggerCollection > &trigsDDU)
Run analysis on ROS data.
float trigPos(const L1MuDTChambPhDigi *trig)
Return local position (trigger RF) for a given trigger primitive.
int station() const
Return the station number.
Definition: DTChamberId.h:51
UInt_t nEvents
Definition: hcalCalib.cc:42
edm::EDGetTokenT< L1MuDTChambPhContainer > tm_phiOut_Token_
DTLocalTriggerBaseTask(const edm::ParameterSet &ps)
Constructor.
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)
Definition: Run.h:42