CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TdeCSCTF.cc
Go to the documentation of this file.
1 /*
2  * L1TdeCSCTF.cc v1.0
3  * written by J. Gartner
4  *
5  * 2011.03.11 expanded by GP Di Giovanni
6  *
7  * There is quality test allowing to check elements outside the
8  * diagonal, so I need to add the 1D plot with all elements in the diagonal
9  * in the first bin and all elements outside the diagonal in the second bin
10  *
11  * In such way we can run the ContentsXRange quality test...
12  */
13 
20 
25 
26 
28 
30 
33 
34 #include <iostream>
35 #include <iomanip>
36 #include <memory>
37 
38 
39 using namespace std;
40 using namespace edm;
41 
43  dataTrackProducer = pset.getParameter<InputTag>("dataTrackProducer");
44  emulTrackProducer = pset.getParameter<InputTag>("emulTrackProducer");
45  lctProducer = pset.getParameter<InputTag>("lctProducer");
46  dataStubProducer = pset.getParameter<InputTag>("dataStubProducer");
47  emulStubProducer = pset.getParameter<InputTag>("emulStubProducer");
48 
49  m_dirName = pset.getUntrackedParameter("DQMFolder", string("L1TEMU/CSCTFexpert"));
50 
51  ts=0;
52  ptLUT_ = 0;
53 
54  ptLUTset = pset.getParameter<ParameterSet>("PTLUT");
55 
56  dbe = NULL;
57  if(pset.getUntrackedParameter<bool>("DQMStore", false) )
58  {
59  dbe = Service<DQMStore>().operator->();
60  dbe->setVerbose(0);
61  dbe->setCurrentFolder(m_dirName);
62  }
63 
64  outFile = pset.getUntrackedParameter<string>("outFile", "");
65  if( outFile.size() != 0 )
66  {
67  LogWarning("L1TdeCSCTF")
68  << "L1T Monitoring histograms will be saved to "
69  << outFile.c_str()
70  << endl;
71  }
72 
73  bool disable = pset. getUntrackedParameter<bool>("disableROOToutput", false);
74  if(disable){
75  outFile="";
76  }
77 
78  /*bzero(srLUTs_, sizeof(srLUTs_));
79  //int endcap =1, sector =1;
80  bool TMB07=true;
81  ParameterSet srLUTset;
82  srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
83  srLUTset.addUntrackedParameter<bool>("Binary", false);
84  srLUTset.addUntrackedParameter<string>("LUTPath", "./");
85  for(int endcapItr = CSCDetId::minEndcapId(); endcapItr <= CSCDetId::maxEndcapId(); endcapItr++)
86  {
87  for(int sectorItr = CSCTriggerNumbering::minTriggerSectorId();sectorItr <= CSCTriggerNumbering::maxTriggerSectorId();sectorItr++)
88  {
89  for(int stationItr = 1; stationItr <= 4; stationItr++)
90  {
91  if(stationItr == 1)
92  {
93  for(int subsectorItr = 0; subsectorItr < 2; subsectorItr++)
94  {
95  srLUTs_[endcapItr-1][sectorItr-1][subsectorItr] = new CSCSectorReceiverLUT(endcapItr, sectorItr, subsectorItr+1, stationItr, srLUTset, TMB07);
96  }
97  } else {
98  srLUTs_[endcapItr-1][sectorItr-1][stationItr] = new CSCSectorReceiverLUT(endcapItr, sectorItr, 0, stationItr, srLUTset, TMB07);
99  } //if for station 1 or 234
100  } // stationItr loop
101  } // sectorItr loop
102  } // endcapItr loop
103  */
104  my_dtrc = new CSCTFDTReceiver();
105 }
106 
108 {
109 
110 
112  // DQM Directory Structure //
114  DQMStore * dbe = 0;
115  dbe = Service<DQMStore>().operator->();
116  if( dbe ){
119  // Define Monitor Elements //
121  //Monitor Elements for Pt Lut Address Field
122  pt1Comp = dbe->book2D("pt1Comp","Hardware Vs. Emulator #Delta #phi_{12}",256,0,256,256,0,256);
123  pt1Comp->setAxisTitle("Hardware #Delta #phi_{12}",1);
124  pt1Comp->setAxisTitle("Emulator #Delta #phi_{12}",2);
125  pt2Comp = dbe->book2D("pt2Comp","Hardware Vs. Emulator #Delta #phi_{23}",16,0,16,16,0,16);
126  pt2Comp->setAxisTitle("Hardware #Delta #phi_{23}",1);
127  pt2Comp->setAxisTitle("Emulator #Delta #phi_{23}",2);
128  pt3Comp = dbe->book2D("pt3Comp","Hardware Vs. Emulator #eta",16,0,16,16,0,16);
129  pt3Comp->setAxisTitle("Hardware #eta",1);
130  pt3Comp->setAxisTitle("Emulator #eta",2);
131  pt4Comp = dbe->book2D("pt4Comp","Hardware Vs. Emulator Mode",19,0,19,19,0,19);
132  pt4Comp->setAxisTitle("Hardware Mode",1);
133  pt4Comp->setAxisTitle("Emulator Mode",2);
134  //Hardware Bin Titles
135  pt4Comp->setBinLabel(1,"No Track",1);
136  pt4Comp->setBinLabel(2,"Bad Phi/Single",1);
137  pt4Comp->setBinLabel(3,"ME1-2-3",1);
138  pt4Comp->setBinLabel(4,"ME1-2-4",1);
139  pt4Comp->setBinLabel(5,"ME1-3-4",1);
140  pt4Comp->setBinLabel(6,"ME2-3-4",1);
141  pt4Comp->setBinLabel(7,"ME1-2",1);
142  pt4Comp->setBinLabel(8,"ME1-3",1);
143  pt4Comp->setBinLabel(9,"ME2-3",1);
144  pt4Comp->setBinLabel(10,"ME2-4",1);
145  pt4Comp->setBinLabel(11,"ME3-4",1);
146  pt4Comp->setBinLabel(12,"MB1-ME3",1);
147  pt4Comp->setBinLabel(13,"MB1-ME2",1);
148  pt4Comp->setBinLabel(14,"ME1-4",1);
149  pt4Comp->setBinLabel(15,"MB1-ME1",1);
150  pt4Comp->setBinLabel(16,"Halo Trigger",1);
151  pt4Comp->setBinLabel(17,"MB1-ME1-2",1);
152  pt4Comp->setBinLabel(18,"MB1-ME1-3",1);
153  pt4Comp->setBinLabel(19,"MB1-ME2-3",1);
154  //Emu Bin Titles
155  pt4Comp->setBinLabel(1,"No Track",2);
156  pt4Comp->setBinLabel(2,"Bad Phi/Single",2);
157  pt4Comp->setBinLabel(3,"ME1-2-3",2);
158  pt4Comp->setBinLabel(4,"ME1-2-4",2);
159  pt4Comp->setBinLabel(5,"ME1-3-4",2);
160  pt4Comp->setBinLabel(6,"ME2-3-4",2);
161  pt4Comp->setBinLabel(7,"ME1-2",2);
162  pt4Comp->setBinLabel(8,"ME1-3",2);
163  pt4Comp->setBinLabel(9,"ME2-3",2);
164  pt4Comp->setBinLabel(10,"ME2-4",2);
165  pt4Comp->setBinLabel(11,"ME3-4",2);
166  pt4Comp->setBinLabel(12,"MB1-ME3",2);
167  pt4Comp->setBinLabel(13,"MB1-ME2",2);
168  pt4Comp->setBinLabel(14,"ME1-4",2);
169  pt4Comp->setBinLabel(15,"MB1-ME1",2);
170  pt4Comp->setBinLabel(16,"Halo Trigger",2);
171  pt4Comp->setBinLabel(17,"MB1-ME1-2",2);
172  pt4Comp->setBinLabel(18,"MB1-ME1-3",2);
173  pt4Comp->setBinLabel(19,"MB1-ME2-3",2);
174 
175  pt5Comp = dbe->book2D("pt5Comp","Hardware Vs. Emulator Sign, FR",4,0,4,4,0,4);
176  pt5Comp->setAxisTitle("Hardware Sign<<1|FR",1);
177  pt5Comp->setAxisTitle("Emulator Sign<<1|FR",2);
178 
179  //Monitor Elements for track variables
180  phiComp = dbe->book2D("phiComp","Hardware Vs. Emulator Track #phi",32,0,32,32,0,32);
181  phiComp->setAxisTitle("Hardware #phi",1);
182  phiComp->setAxisTitle("Emulator #phi",2);
183  etaComp = dbe->book2D("etaComp","Hardware Vs. Emulator Track #eta",32,0,32,32,0,32);
184  etaComp->setAxisTitle("Hardware #eta",1);
185  etaComp->setAxisTitle("Emulator #eta",2);
186  occComp = dbe->book2D("occComp","Hardware Vs. Emulator Track Occupancy",5,0,5,5,0,5);
187  occComp->setAxisTitle("Hardware Occupancy",1);
188  occComp->setAxisTitle("Emulator Occupancy",2);
189  ptComp = dbe->book2D("ptComp","Hardware Vs. Emulator Pt",32,0,32,32,0,32);
190  ptComp->setAxisTitle("Hardware P_{t}",1);
191  ptComp->setAxisTitle("Emulator P_{t}",2);
192  qualComp= dbe->book2D("qualComp","Hardware Vs. Emulator Quality",4,0,4,4,0,4);
193  qualComp->setAxisTitle("Hardware Quality",1);
194  qualComp->setAxisTitle("Emulator Quality",2);
195 
196 
197  //Monitor Elemens for Dt Stubs
198  dtStubPhi = dbe->book2D("dtStubPhi","Hardware Vs. Emulator DT Stub #phi",200,400,2400,200,400,2400);
199  dtStubPhi->setAxisTitle("Hardware Stub #phi",1);
200  dtStubPhi->setAxisTitle("Emulator Stub #phi",2);
201  badDtStubSector = dbe->book2D("badDtStubSector","Dt Sector for bad Dt stub #phi",6,1,7,2,1,3);
202  badDtStubSector->setAxisTitle("Dt stub sector, subsector",1);
203  badDtStubSector->setAxisTitle("Dt Stub Endcap",2);
204 
205  //***********************************//
206  //* F O R Q U A L I T Y T E S T *//
207  //***********************************//
208  //1D plots for the quality test
209  //Monitor Elements for Pt Lut Address Field
210  pt1Comp_1d = dbe->book1D("pt1Comp_1d","Hardware Vs. Emulator #Delta #phi_{12}",2,0,2);
211  pt1Comp_1d->setAxisTitle("#Delta #phi_{12}",1);
212  pt1Comp_1d->setBinLabel(1, "Agree", 1);
213  pt1Comp_1d->setBinLabel(2, "Disagree", 1);
214 
215  pt2Comp_1d = dbe->book1D("pt2Comp_1d","Hardware Vs. Emulator #Delta #phi_{23}",2,0,2);
216  pt2Comp_1d->setAxisTitle("#Delta #phi_{23}",1);
217  pt2Comp_1d->setBinLabel(1, "Agree", 1);
218  pt2Comp_1d->setBinLabel(2, "Disagree", 1);
219 
220  pt3Comp_1d = dbe->book1D("pt3Comp_1d","Hardware Vs. Emulator #eta",2,0,2);
221  pt3Comp_1d->setAxisTitle("#eta",1);
222  pt3Comp_1d->setBinLabel(1, "Agree", 1);
223  pt3Comp_1d->setBinLabel(2, "Disagree", 1);
224 
225  pt4Comp_1d = dbe->book1D("pt4Comp_1d","Hardware Vs. Emulator Mode",2,0,2);
226  pt4Comp_1d->setAxisTitle("Mode",1);
227  pt4Comp_1d->setBinLabel(1, "Agree", 1);
228  pt4Comp_1d->setBinLabel(2, "Disagree", 1);
229 
230  pt5Comp_1d = dbe->book1D("pt5Comp_1d","Hardware Vs. Emulator Sign, FR",2,0,2);
231  pt5Comp_1d->setAxisTitle("Sign<<1|FR",1);
232  pt5Comp_1d->setBinLabel(1, "Agree", 1);
233  pt5Comp_1d->setBinLabel(2, "Disagree", 1);
234 
235 
236  //Monitor Elements for track variables
237  phiComp_1d = dbe->book1D("phiComp_1d","Hardware Vs. Emulator Track #phi",2,0,2);
238  phiComp_1d->setAxisTitle("#phi",1);
239  phiComp_1d->setBinLabel(1, "Agree", 1);
240  phiComp_1d->setBinLabel(2, "Disagree", 1);
241 
242  etaComp_1d = dbe->book1D("etaComp_1d","Hardware Vs. Emulator Track #eta",2,0,2);
243  etaComp_1d->setAxisTitle("#eta",1);
244  etaComp_1d->setBinLabel(1, "Agree", 1);
245  etaComp_1d->setBinLabel(2, "Disagree", 1);
246 
247  occComp_1d = dbe->book1D("occComp_1d","Hardware Vs. Emulator Track Occupancy",2,0,2);
248  occComp_1d->setAxisTitle("Occupancy",1);
249  occComp_1d->setBinLabel(1, "Agree", 1);
250  occComp_1d->setBinLabel(2, "Disagree", 1);
251 
252  ptComp_1d = dbe->book1D("ptComp_1d","Hardware Vs. Emulator Pt",2,0,2);
253  ptComp_1d->setAxisTitle("P_{t}",1);
254  ptComp_1d->setBinLabel(1, "Agree", 1);
255  ptComp_1d->setBinLabel(2, "Disagree", 1);
256 
257  qualComp_1d= dbe->book1D("qualComp_1d","Hardware Vs. Emulator Quality",2,0,2);
258  qualComp_1d->setAxisTitle("Quality",1);
259  qualComp_1d->setBinLabel(1, "Agree", 1);
260  qualComp_1d->setBinLabel(2, "Disagree", 1);
261 
262  //Monitor Elemens for Dt Stubs
263  dtStubPhi_1d = dbe->book1D("dtStubPhi_1d","Hardware Vs. Emulator DT Stub #phi",2,0,2);
264  dtStubPhi_1d->setAxisTitle("DT Stub #phi",1);
265  dtStubPhi_1d->setBinLabel(1, "Agree", 1);
266  dtStubPhi_1d->setBinLabel(2, "Disagree", 1);
267 
268  }
269 
270 }
271 
273 
274  if(ptLUT_) delete ptLUT_;
275 
276  if ( outFile.size() != 0 && dbe ) dbe->save(outFile);
277  return;
278 }
279 
280 void L1TdeCSCTF::analyze(Event const& e, EventSetup const& es){
281  // Get LCT information
283  /*int lctArray[20][7];
284  short nLCTs=0;
285  for(int oj=0; oj<20; oj++) lctArray[oj][0]=0;
286  if( lctProducer.label() != "null" )
287  {
288  Handle<CSCCorrelatedLCTDigiCollection> LCTs;
289  e.getByLabel(lctProducer.label(),lctProducer.instance(), LCTs);
290 
291  // check validity of input collection
292  if(!LCTs.isValid()) {
293  LogWarning("L1TdeCSCTF")
294  << "\n No valid [lct] product found: "
295  << " CSCCorrelatedLCTDigiCollection"
296  << endl;
297  return;
298  }
299 
300  ESHandle< L1MuTriggerScales > scales ;
301  es.get< L1MuTriggerScalesRcd >().get( scales ) ;
302  ESHandle< L1MuTriggerPtScale > ptScale ;
303  es.get< L1MuTriggerPtScaleRcd >().get( ptScale ) ;
304  ptLUT_ = new CSCTFPtLUT(ptLUTset, scales.product(), ptScale.product() );
305 
306  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=LCTs.product()->begin(); csc!=LCTs.product()->end(); csc++)
307  {
308  int lctId=0;
309 
310  CSCCorrelatedLCTDigiCollection::Range range1 = LCTs.product()->get((*csc).first);
311  for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++,lctId++)
312  {
313  CSCCorrelatedLCTDigiCollection::Range range1 = LCTs.product()->get((*csc).first);
314  CSCCorrelatedLCTDigiCollection::const_iterator lct;
315  for( lct = range1.first; lct!=range1.second; lct++)
316  {
317  int station = (*csc).first.station()-1;
318  int cscId = (*csc).first.triggerCscId()-1;
319  int sector = (*csc).first.triggerSector()-1;
320  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
321  int tbin = lct->getBX();
322  int fpga = ( subSector ? subSector-1 : station+1 );
323  int endcap = (*csc).first.endcap()-1;
324 
325  lclphidat lclPhi;
326  gblphidat gblPhi;
327  gbletadat gblEta;
328 
329  try{
330  lclPhi = srLUTs_[endcap][sector][fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
331  } catch ( cms::Exception &e ) {
332  bzero(&lclPhi, sizeof(lclPhi));
333  LogWarning("L1TdeCSCTF:analyze()") << "Exception from LocalPhi LUT in endCap: " << endcap << ", sector: " << sector << ", fpga: " << fpga
334  << "(strip:" << lct->getStrip() << ", pattern:"<< lct->getPattern() << ", Q:" << lct->getQuality() << ", bend:" << lct->getBend() << endl;
335  }
336 
337  try{
338  gblPhi = srLUTs_[endcap][sector][fpga]->globalPhiME( lclPhi.phi_local, lct->getKeyWG(),cscId+1);
339  } catch ( cms::Exception &e ) {
340  bzero(&gblPhi,sizeof(gblPhi));
341  LogWarning("L1TdeCSCTF:analyze()") << "Exception from GlobalPhi LUT in endCap: " << endcap << ", sector: " << sector << ", fpga: " << fpga
342  << "(local phi:" << lclPhi.phi_local << ", keyWG:" << lct->getKeyWG() << ",cscID:" << cscId+1 << endl;
343  }
344  try{
345  gblEta = srLUTs_[endcap][sector][fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local,lct->getKeyWG(),cscId+1);
346  } catch ( cms::Exception &e ) {
347  bzero(&gblEta,sizeof(gblEta));
348  LogWarning("L1TdeCSCTF:analyze()") << "Exception from GlobalEta LUT in endCap: " << endcap << ", sector: " << sector << ", fpga: " << fpga
349  << "(local phi bend:" << lclPhi.phi_bend_local << ", local phi:" << lclPhi.phi_local << ", keyWG: " << lct->getKeyWG() << ", cscID: " << cscId+1 << endl;
350  }
351 
352  allLctBx->Fill(tbin);
353 
354  if((nLCTs < 20))
355  {
356  lctArray[nLCTs][0] = 1;
357  lctArray[nLCTs][1] = sector;
358  lctArray[nLCTs][2] = tbin;
359  lctArray[nLCTs][3] = endcap;
360  lctArray[nLCTs][4] = gblPhi.global_phi;
361  lctArray[nLCTs][5] = gblEta.global_eta;
362  lctArray[nLCTs][6] = station;
363  nLCTs++;
364  }
365  }
366  }
367  }
368  }*/
369 
370  // Initialize Arrays
372  unsigned int nDataMuons = 0;
373  unsigned int nEmulMuons = 0;
374  int dataMuonArray[8][10], emuMuonArray[8][10];
375  for(int muon=0; muon<8; muon++)
376  {
377  for(int par=0; par<3; par++)
378  {
379  dataMuonArray[muon][par]=0;
380  emuMuonArray[muon][par] =0;
381  }
382  emuMuonArray[muon][3] =-1;
383  dataMuonArray[muon][3]=-1;
384 
385  emuMuonArray[muon][4]=7;
386  dataMuonArray[muon][4]=7;
387 
388  for(int par2=5; par2<10; par2++)
389  {
390  emuMuonArray[muon][par2]= -1;
391  dataMuonArray[muon][par2]= -1;
392  }
393  }
394  // Get Hardware information, and check output of PtLUT
396  if( dataTrackProducer.label() != "null" )
397  {
400 
401  // check validity of input collection
402  if(!tracks.isValid()) {
403  LogWarning("L1TdeCSCTF")
404  << "\n No valid [data tracks] product found: "
405  << " L1CSCTrackCollection"
406  << endl;
407  return;
408  }
409 
410 
411  for(L1CSCTrackCollection::const_iterator trk=tracks.product()->begin(); trk!=tracks.product()->end(); trk++)
412  {
413  if (nDataMuons>=8)
414  break;
415  if( (trk->first.BX() <2) && (trk->first.BX() > -1) )
416  {
417  //int mOdE = (trk->first.ptLUTAddress()>>16)&0xf;
418  //cout << "D->Mode: " << mOdE << ", Rank " << trk->first.rank() << endl;
419  dataMuonArray[nDataMuons][0] = trk->first.ptLUTAddress();
420  dataMuonArray[nDataMuons][1] = trk->first.sector();
421  dataMuonArray[nDataMuons][2] = trk->first.endcap();
422  dataMuonArray[nDataMuons][8] = trk->first.outputLink();
423  dataMuonArray[nDataMuons][4] = trk->first.BX();
424  dataMuonArray[nDataMuons][5] = trk->first.rank();
425  dataMuonArray[nDataMuons][6] = trk->first.localPhi();
426  dataMuonArray[nDataMuons][7] = trk->first.eta_packed();
427  dataMuonArray[nDataMuons][9] = trk->first.modeExtended();
428  nDataMuons++;
429  }
430  }
431  }
432  // Get Emulator information
434  if( emulTrackProducer.label() != "null" )
435  {
438 
439  // check validity of input collection
440  if(!tracks.isValid()) {
441  LogWarning("L1TdeCSCTF")
442  << "\n No valid [emulator tracks] product found: "
443  << " L1CSCTrackCollection"
444  << endl;
445  return;
446  }
447 
448  for(L1CSCTrackCollection::const_iterator trk=tracks.product()->begin(); trk!=tracks.product()->end(); trk++)
449  {
450  if(nEmulMuons>=8)
451  break;
452  if((trk->first.BX() <2) && (trk->first.BX() >-1))
453  {
454  //int mOdE = (trk->first.ptLUTAddress()>>16)&0xf;
455  //cout << "E->Mode: " << mOdE << ", Rank " << trk->first.rank() << endl;
456  emuMuonArray[nEmulMuons][0] = trk->first.ptLUTAddress();
457  emuMuonArray[nEmulMuons][1] = trk->first.sector();
458  emuMuonArray[nEmulMuons][2] = trk->first.endcap();
459  emuMuonArray[nEmulMuons][4] = trk->first.BX();
460  emuMuonArray[nEmulMuons][5] = trk->first.rank();
461  emuMuonArray[nEmulMuons][6] = trk->first.localPhi();
462  emuMuonArray[nEmulMuons][7] = trk->first.eta_packed();
463  emuMuonArray[nEmulMuons][9] = trk->first.modeExtended();
464  nEmulMuons++;
465  }
466  }
467  }
468  //Fill Occupancy M.E.
469  if( (nDataMuons!=0)||(nEmulMuons!=0) ) {
470  occComp->Fill(nDataMuons,nEmulMuons);
471  (nDataMuons==nEmulMuons) ? occComp_1d->Fill(0) : occComp_1d->Fill(1);
472  }
473  // Match Tracks by sector & mode in the case of multiple tracks
475  if(nDataMuons==nEmulMuons)
476  {
477  //First, find EXACT address matches in a given sector, endcap
478  for(unsigned int mu1=0; mu1<nDataMuons; mu1++)
479  {
480  for(unsigned int mu2=0; mu2<nEmulMuons; mu2++)
481  if((emuMuonArray[mu2][1]==dataMuonArray[mu1][1])&&(emuMuonArray[mu2][2]==dataMuonArray[mu1][2]))
482  {
483  if(emuMuonArray[mu2][0]==dataMuonArray[mu1][0])
484  {
485  emuMuonArray[mu2][3]=mu1;
486  dataMuonArray[mu1][3]=1;
487  }
488  }
489  }
490  //Next, try to match unmapped
491  for(unsigned int c2a=0; c2a<nEmulMuons; c2a++)
492  {
493  if(emuMuonArray[c2a][3]==-1)
494  {
495  for(unsigned int cor_a=0; cor_a<nDataMuons; cor_a++)
496  {
497  if( (dataMuonArray[cor_a][1]==emuMuonArray[c2a][1]) && (dataMuonArray[cor_a][2]==emuMuonArray[c2a][2]))// && (dataMuonArray[cor_a][3]==-1))
498  {
499  emuMuonArray[c2a][3]=cor_a;
500  dataMuonArray[cor_a][3]=1;
501  }
502  }
503  }
504  }
505  //Check that a single emulator track is not mapped to multiple data tracks
506  bool multiMap = false;
507  if(nEmulMuons>1)
508  {
509  for(unsigned int c1a=0; c1a<(nEmulMuons-1); c1a++)
510  {
511  for(unsigned int c1b=(c1a+1); c1b<nEmulMuons; c1b++)
512  {
513  if(emuMuonArray[c1a][3]==emuMuonArray[c1b][3])
514  {
515  //cout << "Error: Multiple Emulator Muons Mapped to the same Data Muon." << endl;
516  multiMap = true;
517  break;
518  }
519  }
520  if (multiMap)
521  break;
522  }
523  }
524  //Fill histograms based on matched Tracks
525  for(unsigned int mu3=0; mu3<nEmulMuons; mu3++)
526  {
527  int mapping = emuMuonArray[mu3][3];
528  if((mapping!=-1)&&(multiMap==false))
529  {
530  //Decode LUT Address for more meaningful comparison
531  int emuPhi12 = (0x0000ff & emuMuonArray[mu3][0]);
532  int datPhi12 = (0x0000ff & dataMuonArray[mapping][0]);
533  int emuPhi23 = (0x000f00 & emuMuonArray[mu3][0])>>8;
534  int datPhi23 = (0x000f00 & dataMuonArray[mapping][0])>>8;
535  int emuEta = (0x00f000 & emuMuonArray[mu3][0])>>12;
536  int datEta = (0x00f000 & dataMuonArray[mapping][0])>>12;
537  //int emuMode = (0x0f0000 & emuMuonArray[mu3][0])>>16;
538  //int datMode = (0x0f0000 & dataMuonArray[mapping][0])>>16;
539  int emuFrSin = (0xf00000 & emuMuonArray[mu3][0])>>20;
540  int datFrSin = (0xf00000 & dataMuonArray[mapping][0])>>20;
541  //Decode Rank for more meaningful comparison
542  int emuQual = emuMuonArray[mu3][5]>>5;
543  int datQual = dataMuonArray[mapping][5]>>5;
544  int emuPt = 0x1f & emuMuonArray[mu3][5];
545  int datPt = 0x1f & dataMuonArray[mapping][5];
546  int emuModeExtended = emuMuonArray[mu3][9];
547  int datModeExtended = dataMuonArray[mapping][9];
548 
549  //Fill mode M.E., one of (the most important) PtLUT address field
550  pt4Comp->Fill(datModeExtended,emuModeExtended);
551  (datModeExtended==emuModeExtended) ? pt4Comp_1d->Fill(0) : pt4Comp_1d->Fill(1);
552  //To disentagle problems, only fill histograms if mode matches
553  if(emuModeExtended==datModeExtended)
554  {
555  //Fill Pt LUT address field M.E.
556  pt1Comp->Fill(datPhi12,emuPhi12); (datPhi12==emuPhi12) ? pt1Comp_1d->Fill(0) : pt1Comp_1d->Fill(1);
557  pt2Comp->Fill(datPhi23,emuPhi23); (datPhi23==emuPhi23) ? pt2Comp_1d->Fill(0) : pt2Comp_1d->Fill(1);
558  pt3Comp->Fill(datEta,emuEta); (datEta==emuEta) ? pt3Comp_1d->Fill(0) : pt3Comp_1d->Fill(1);
559  pt5Comp->Fill(datFrSin,emuFrSin); (datFrSin==emuFrSin) ? pt5Comp_1d->Fill(0) : pt5Comp_1d->Fill(1);
560  //Fill Track value M.E.
561  if(dataMuonArray[mapping][8]==1) //Rank Comparison available for Link 1 only due to readout limitation
562  {
563  ptComp->Fill(datPt,emuPt); (datPt==emuPt) ? ptComp_1d->Fill(0) : ptComp_1d->Fill(1);
564  qualComp->Fill(datQual,emuQual);(datQual==emuQual) ? qualComp_1d->Fill(0) : qualComp_1d->Fill(1);
565  }
566  phiComp->Fill(dataMuonArray[mapping][6],emuMuonArray[mu3][6]);
567  etaComp->Fill(dataMuonArray[mapping][7],emuMuonArray[mu3][7]);
568 
569  (dataMuonArray[mapping][6]==emuMuonArray[mu3][6]) ? phiComp_1d->Fill(0) : phiComp_1d->Fill(1);
570  (dataMuonArray[mapping][7]==emuMuonArray[mu3][7]) ? etaComp_1d->Fill(0) : etaComp_1d->Fill(1);
571  }
572  }
573  }
574  }
575 
576  //Compare DT stubs to check transmission quality
578  //Declare arrays, initialize
579  int eDtStub[7][15];
580  int dDtStub[8][15];
581  int eDtCounter = 0;
582  int dDtCounter = 0;
583  for(int dJ=0; dJ<7; dJ++)
584  {
585  for(int dK=0; dK<15; dK++)
586  {
587  eDtStub[dJ][dK] = -55;
588  dDtStub[dJ][dK] = -55;
589  dDtStub[7][dK] = -55;
590  }
591  }
592 
593  // Get Daq Recorded Stub Information
594  if( dataStubProducer.label() != "null" )
595  {
598  // check validity of input collection
599  if(!dtTrig.isValid()) {
600  LogWarning("L1TdeCSCTF")
601  << "\n No valid [Data Stubs] product found: "
602  << " L1CSCTrackCollection"
603  << endl;
604  return;
605  }
606  const CSCTriggerContainer<csctf::TrackStub>* dt_stubs = dtTrig.product();
608  stub_list.push_many(*dt_stubs);
609  vector<csctf::TrackStub> stuList = stub_list.get();
610  vector<csctf::TrackStub>::const_iterator stu= stuList.begin();
611  for(; stu!=stuList.end(); stu++)
612  {
613  if(dDtCounter>=15)
614  break;
615  if((stu->BX()>4) && (stu->BX()<9))
616  {
617  dDtStub[0][dDtCounter] = stu->phiPacked();
618  dDtStub[1][dDtCounter] = stu->getQuality();
619  dDtStub[2][dDtCounter] = stu->endcap();
620  dDtStub[3][dDtCounter] = stu->sector();
621  dDtStub[4][dDtCounter] = stu->subsector();
622  dDtCounter++;
623  }
624  }
625  }
626 
627  // Get Daq Recorded Stub Information
628  if( emulStubProducer.label() != "null" )
629  {
630  // Get Emulated Stub Information
633  // check validity of input collection
634  if(!pCon.isValid()) {
635  LogWarning("L1TdeCSCTF")
636  << "\n No valid [Data Stubs] product found: "
637  << " L1CSCTrackCollection"
638  << endl;
639  return;
640  }
642  vector<csctf::TrackStub> emuList = emulStub.get();
643  vector<csctf::TrackStub>::const_iterator eStu=emuList.begin();
644  for(; eStu!=emuList.end(); eStu++)
645  {
646 
647  if (eDtCounter>=15)
648  break;
649  if((eStu->BX()>4) && (eStu->BX()<9) )
650  {
651  eDtStub[0][eDtCounter] = eStu->phiPacked();
652  eDtStub[1][eDtCounter] = eStu->getQuality();
653  eDtStub[2][eDtCounter] = eStu->endcap();
654  eDtStub[3][eDtCounter] = eStu->sector();
655  eDtStub[4][eDtCounter] = eStu->subsector();
656  eDtCounter++;
657  }
658  }
659  }
660 
661  //cout << "Num Tracks match eDtCounter: " << eDtCounter << ", dDt: " << dDtCounter << endl;
662  //First find perfect matches
663  for(int eS=0; eS<eDtCounter; eS++)
664  {
665  //cout << "es Loop" << endl;
666  for(int dS=0; dS<dDtCounter; dS++)
667  {
668  //cout << "ds Loop" << endl;
669  if(eDtStub[2][eS]==dDtStub[2][dS])
670  {
671  //cout << "end match" << endl;
672  if(eDtStub[3][eS]==dDtStub[3][dS])
673  {
674  //cout << "sec match" << endl;
675  if(eDtStub[4][eS]==dDtStub[4][dS])
676  {
677  //cout << "First match loop, eS: " << eS << ", dS" << dS << endl;
678  if( (eDtStub[0][eS]==dDtStub[0][dS]) && (eDtStub[1][eS]==dDtStub[1][dS]) && (eDtStub[6][eS]!=1) && (dDtStub[6][dS]!=1) )
679  {
680  //cout << "Passed fist matching." << endl;
681  eDtStub[5][eS] = dS;
682  eDtStub[6][eS] = 1;
683  dDtStub[5][dS] = eS;
684  dDtStub[6][dS] = 1;
685  }
686  }
687  }
688  }
689  }
690  }
691 
692  //Now find imperfect matches
693  for(int eS2=0; eS2<eDtCounter; eS2++)
694  {
695  for(int dS2=0; dS2<dDtCounter; dS2++)
696  {
697  //cout << "1: " << eDtStub[2][eS2] << ", " << dDtStub[2][dS2] << ", " << eDtStub[3][eS2] << ", " << dDtStub[3][dS2] << ", " << eDtStub[4][eS2] << ", " << dDtStub[4][dS2] << endl;
698  if( (eDtStub[2][eS2]==dDtStub[2][dS2]) && (eDtStub[3][eS2]==dDtStub[3][dS2]) && (eDtStub[4][eS2]==dDtStub[4][dS2]) )
699  {
700  //cout << "2: " << dDtStub[7][eS2] << ", " << dDtStub[7][dS2] << ", " << abs(eDtStub[0][eS2]-dDtStub[0][dS2]) << ", " << ", " << eDtStub[6][eS2] << ", " << dDtStub[6][dS2] << endl;
701  if( ((dDtStub[7][eS2]==-55) || (dDtStub[7][dS2]>(abs(eDtStub[0][eS2]-dDtStub[0][dS2]))) ) && (eDtStub[6][eS2]!=1) && (dDtStub[6][dS2]!=1) )
702  {
703  //cout << "Imperfect match found" << endl;
704  dDtStub[5][dS2] = eS2;
705  dDtStub[6][dS2] = 2;
706  eDtStub[5][eS2] = dS2;
707  eDtStub[6][eS2] = 2;
708  dDtStub[7][dS2] = abs(eDtStub[0][eS2]-dDtStub[0][dS2]);
709  }
710  }
711  }
712  }
713 
714  //Debug time!
715  bool dtSMulti = false;
716  int dtUnmap = 0;
717  if(eDtCounter>1)
718  for(int eS3a=0; eS3a<eDtCounter-1; eS3a++)
719  for(int eS3b=eS3a+1; eS3b<eDtCounter; eS3b++)
720  {
721  if( eDtStub[5][eS3a]==eDtStub[5][eS3b] ) dtSMulti=true;
722  if( eDtStub[5][eS3a]==-55 || eDtStub[5][eS3b]==-55 ) dtUnmap++;
723  }
724 
725  if(dDtCounter>1)
726  for(int dS3a=0; dS3a<dDtCounter-1; dS3a++)
727  for(int dS3b=dS3a+1; dS3b<dDtCounter; dS3b++)
728  {
729  if( dDtStub[5][dS3a]==dDtStub[5][dS3b] ) dtSMulti=true;
730  if( dDtStub[5][dS3a]==-55||dDtStub[5][dS3b]==-55 ) dtUnmap++;
731  }
732  /*if(dtSMulti==true)
733  cout << "Multiple DT stubs mapped to the same stub" << endl;
734  if(dtUnmap!=0)
735  cout << "Unmapped DT stubs:" << dtUnmap << endl;*/
736 
737  if(dtSMulti==false && dtUnmap==0)
738  {
739  for(int phil=0; phil<eDtCounter; phil++)
740  {
741  if(eDtStub[6][phil]==1 || eDtStub[6][phil]==2)
742  {
743  int indexFil = eDtStub[3][phil]*2+eDtStub[4][phil]-1;
744  dtStubPhi->Fill(eDtStub[0][phil], dDtStub[0][ eDtStub[5][phil] ]);
745  (eDtStub[0][phil] == dDtStub[0][ eDtStub[5][phil] ]) ? dtStubPhi_1d->Fill(0) : dtStubPhi_1d->Fill(1);
746  if( eDtStub[0][phil] != dDtStub[0][ eDtStub[5][phil] ])
747  badDtStubSector->Fill(indexFil,eDtStub[2][phil]);
748  }
749  }
750  }
751 
752 }
MonitorElement * ptComp
Definition: L1TdeCSCTF.h:47
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * etaComp_1d
Definition: L1TdeCSCTF.h:51
MonitorElement * qualComp
Definition: L1TdeCSCTF.h:47
std::vector< T > get() const
CSCTFPtLUT * ptLUT_
Definition: L1TdeCSCTF.h:40
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
edm::InputTag lctProducer
Definition: L1TdeCSCTF.h:37
MonitorElement * qualComp_1d
Definition: L1TdeCSCTF.h:51
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
#define abs(x)
Definition: mlp_lapack.h:159
#define NULL
Definition: scimark2.h:8
MonitorElement * dtStubPhi
Definition: L1TdeCSCTF.h:49
MonitorElement * pt5Comp
Definition: L1TdeCSCTF.h:48
edm::InputTag emulTrackProducer
Definition: L1TdeCSCTF.h:37
MonitorElement * phiComp_1d
Definition: L1TdeCSCTF.h:51
edm::InputTag dataStubProducer
Definition: L1TdeCSCTF.h:37
CSCTriggerContainer< csctf::TrackStub > process(const L1MuDTChambPhContainer *)
void Fill(long long x)
DQMStore * dbe
Definition: L1TdeCSCTF.h:46
MonitorElement * ptComp_1d
Definition: L1TdeCSCTF.h:51
MonitorElement * pt2Comp
Definition: L1TdeCSCTF.h:48
L1TdeCSCTF(edm::ParameterSet const &pset)
Definition: L1TdeCSCTF.cc:42
void analyze(edm::Event const &e, edm::EventSetup const &iSetup)
Definition: L1TdeCSCTF.cc:280
MonitorElement * pt4Comp
Definition: L1TdeCSCTF.h:48
MonitorElement * phiComp
Definition: L1TdeCSCTF.h:47
std::string outFile
Definition: L1TdeCSCTF.h:58
void endJob(void)
Definition: L1TdeCSCTF.cc:272
bool isValid() const
Definition: HandleBase.h:76
void push_many(const std::vector< T > &data)
MonitorElement * pt1Comp_1d
Definition: L1TdeCSCTF.h:52
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
MonitorElement * occComp_1d
Definition: L1TdeCSCTF.h:51
MonitorElement * dtStubPhi_1d
Definition: L1TdeCSCTF.h:53
tuple tracks
Definition: testEve_cfg.py:39
edm::InputTag emulStubProducer
Definition: L1TdeCSCTF.h:37
MonitorElement * occComp
Definition: L1TdeCSCTF.h:47
MonitorElement * pt5Comp_1d
Definition: L1TdeCSCTF.h:52
edm::InputTag dataTrackProducer
Definition: L1TdeCSCTF.h:37
T const * product() const
Definition: Handle.h:74
MonitorElement * badDtStubSector
Definition: L1TdeCSCTF.h:49
MonitorElement * pt4Comp_1d
Definition: L1TdeCSCTF.h:52
std::string const & label() const
Definition: InputTag.h:42
MonitorElement * pt2Comp_1d
Definition: L1TdeCSCTF.h:52
edm::ParameterSet ptLUTset
Definition: L1TdeCSCTF.h:41
void beginJob()
Definition: L1TdeCSCTF.cc:107
MonitorElement * pt1Comp
Definition: L1TdeCSCTF.h:48
const L1MuTriggerScales * ts
Definition: L1TdeCSCTF.h:39
MonitorElement * pt3Comp_1d
Definition: L1TdeCSCTF.h:52
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:850
MonitorElement * etaComp
Definition: L1TdeCSCTF.h:47
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
MonitorElement * pt3Comp
Definition: L1TdeCSCTF.h:48
std::string const & instance() const
Definition: InputTag.h:43
std::string m_dirName
Definition: L1TdeCSCTF.h:57
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
CSCTFDTReceiver * my_dtrc
Definition: L1TdeCSCTF.h:42