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