test
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 
18 
23 
24 
26 
28 
30 
31 #include <iostream>
32 #include <iomanip>
33 #include <memory>
34 
35 
36 using namespace std;
37 using namespace edm;
38 
40  dataTrackProducer = consumes<L1CSCTrackCollection>(pset.getParameter<InputTag>("dataTrackProducer"));
41  emulTrackProducer = consumes<L1CSCTrackCollection>(pset.getParameter<InputTag>("emulTrackProducer"));
42  dataStubProducer = consumes<CSCTriggerContainer<csctf::TrackStub> >(pset.getParameter<InputTag>("dataStubProducer"));
43  emulStubProducer = consumes<L1MuDTChambPhContainer>(pset.getParameter<InputTag>("emulStubProducer"));
44 
45  m_dirName = pset.getUntrackedParameter("DQMFolder", string("L1TEMU/CSCTFexpert"));
46 
47  ts=0;
48  ptLUT_ = 0;
49 
50  ptLUTset = pset.getParameter<ParameterSet>("PTLUT");
51 
52  outFile = pset.getUntrackedParameter<string>("outFile", "");
53  if( outFile.size() != 0 )
54  {
55  LogWarning("L1TdeCSCTF")
56  << "L1T Monitoring histograms will be saved to "
57  << outFile.c_str()
58  << endl;
59  }
60 
61  bool disable = pset. getUntrackedParameter<bool>("disableROOToutput", false);
62  if(disable){
63  outFile="";
64  }
65 
66  /*bzero(srLUTs_, sizeof(srLUTs_));
67  //int endcap =1, sector =1;
68  bool TMB07=true;
69  ParameterSet srLUTset;
70  srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
71  srLUTset.addUntrackedParameter<bool>("Binary", false);
72  srLUTset.addUntrackedParameter<string>("LUTPath", "./");
73  for(int endcapItr = CSCDetId::minEndcapId(); endcapItr <= CSCDetId::maxEndcapId(); endcapItr++)
74  {
75  for(int sectorItr = CSCTriggerNumbering::minTriggerSectorId();sectorItr <= CSCTriggerNumbering::maxTriggerSectorId();sectorItr++)
76  {
77  for(int stationItr = 1; stationItr <= 4; stationItr++)
78  {
79  if(stationItr == 1)
80  {
81  for(int subsectorItr = 0; subsectorItr < 2; subsectorItr++)
82  {
83  srLUTs_[endcapItr-1][sectorItr-1][subsectorItr] = new CSCSectorReceiverLUT(endcapItr, sectorItr, subsectorItr+1, stationItr, srLUTset, TMB07);
84  }
85  } else {
86  srLUTs_[endcapItr-1][sectorItr-1][stationItr] = new CSCSectorReceiverLUT(endcapItr, sectorItr, 0, stationItr, srLUTset, TMB07);
87  } //if for station 1 or 234
88  } // stationItr loop
89  } // sectorItr loop
90  } // endcapItr loop
91  */
92  my_dtrc = new CSCTFDTReceiver();
93 }
95 }
96 
98 }
99 
101 {
102  //Histograms booking
103 
105  // DQM Directory Structure //
107 
108  ibooker.setCurrentFolder(m_dirName);
109 
111  // Define Monitor Elements //
113  //Monitor Elements for Pt Lut Address Field
114  pt1Comp = ibooker.book2D("pt1Comp","Hardware Vs. Emulator #Delta #phi_{12}",256,0,256,256,0,256);
115  pt1Comp->setAxisTitle("Hardware #Delta #phi_{12}",1);
116  pt1Comp->setAxisTitle("Emulator #Delta #phi_{12}",2);
117  pt2Comp = ibooker.book2D("pt2Comp","Hardware Vs. Emulator #Delta #phi_{23}",16,0,16,16,0,16);
118  pt2Comp->setAxisTitle("Hardware #Delta #phi_{23}",1);
119  pt2Comp->setAxisTitle("Emulator #Delta #phi_{23}",2);
120  pt3Comp = ibooker.book2D("pt3Comp","Hardware Vs. Emulator #eta",16,0,16,16,0,16);
121  pt3Comp->setAxisTitle("Hardware #eta",1);
122  pt3Comp->setAxisTitle("Emulator #eta",2);
123  pt4Comp = ibooker.book2D("pt4Comp","Hardware Vs. Emulator Mode",19,0,19,19,0,19);
124  pt4Comp->setAxisTitle("Hardware Mode",1);
125  pt4Comp->setAxisTitle("Emulator Mode",2);
126  //Hardware Bin Titles
127  pt4Comp->setBinLabel(1,"No Track",1);
128  pt4Comp->setBinLabel(2,"Bad Phi/Single",1);
129  pt4Comp->setBinLabel(3,"ME1-2-3",1);
130  pt4Comp->setBinLabel(4,"ME1-2-4",1);
131  pt4Comp->setBinLabel(5,"ME1-3-4",1);
132  pt4Comp->setBinLabel(6,"ME2-3-4",1);
133  pt4Comp->setBinLabel(7,"ME1-2",1);
134  pt4Comp->setBinLabel(8,"ME1-3",1);
135  pt4Comp->setBinLabel(9,"ME2-3",1);
136  pt4Comp->setBinLabel(10,"ME2-4",1);
137  pt4Comp->setBinLabel(11,"ME3-4",1);
138  pt4Comp->setBinLabel(12,"MB1-ME3",1);
139  pt4Comp->setBinLabel(13,"MB1-ME2",1);
140  pt4Comp->setBinLabel(14,"ME1-4",1);
141  pt4Comp->setBinLabel(15,"MB1-ME1",1);
142  pt4Comp->setBinLabel(16,"Halo Trigger",1);
143  pt4Comp->setBinLabel(17,"MB1-ME1-2",1);
144  pt4Comp->setBinLabel(18,"MB1-ME1-3",1);
145  pt4Comp->setBinLabel(19,"MB1-ME2-3",1);
146  //Emu Bin Titles
147  pt4Comp->setBinLabel(1,"No Track",2);
148  pt4Comp->setBinLabel(2,"Bad Phi/Single",2);
149  pt4Comp->setBinLabel(3,"ME1-2-3",2);
150  pt4Comp->setBinLabel(4,"ME1-2-4",2);
151  pt4Comp->setBinLabel(5,"ME1-3-4",2);
152  pt4Comp->setBinLabel(6,"ME2-3-4",2);
153  pt4Comp->setBinLabel(7,"ME1-2",2);
154  pt4Comp->setBinLabel(8,"ME1-3",2);
155  pt4Comp->setBinLabel(9,"ME2-3",2);
156  pt4Comp->setBinLabel(10,"ME2-4",2);
157  pt4Comp->setBinLabel(11,"ME3-4",2);
158  pt4Comp->setBinLabel(12,"MB1-ME3",2);
159  pt4Comp->setBinLabel(13,"MB1-ME2",2);
160  pt4Comp->setBinLabel(14,"ME1-4",2);
161  pt4Comp->setBinLabel(15,"MB1-ME1",2);
162  pt4Comp->setBinLabel(16,"Halo Trigger",2);
163  pt4Comp->setBinLabel(17,"MB1-ME1-2",2);
164  pt4Comp->setBinLabel(18,"MB1-ME1-3",2);
165  pt4Comp->setBinLabel(19,"MB1-ME2-3",2);
166 
167  pt5Comp = ibooker.book2D("pt5Comp","Hardware Vs. Emulator Sign, FR",4,0,4,4,0,4);
168  pt5Comp->setAxisTitle("Hardware Sign<<1|FR",1);
169  pt5Comp->setAxisTitle("Emulator Sign<<1|FR",2);
170 
171  //Monitor Elements for track variables
172  phiComp = ibooker.book2D("phiComp","Hardware Vs. Emulator Track #phi",32,0,32,32,0,32);
173  phiComp->setAxisTitle("Hardware #phi",1);
174  phiComp->setAxisTitle("Emulator #phi",2);
175  etaComp = ibooker.book2D("etaComp","Hardware Vs. Emulator Track #eta",32,0,32,32,0,32);
176  etaComp->setAxisTitle("Hardware #eta",1);
177  etaComp->setAxisTitle("Emulator #eta",2);
178  occComp = ibooker.book2D("occComp","Hardware Vs. Emulator Track Occupancy",5,0,5,5,0,5);
179  occComp->setAxisTitle("Hardware Occupancy",1);
180  occComp->setAxisTitle("Emulator Occupancy",2);
181  ptComp = ibooker.book2D("ptComp","Hardware Vs. Emulator Pt",32,0,32,32,0,32);
182  ptComp->setAxisTitle("Hardware P_{t}",1);
183  ptComp->setAxisTitle("Emulator P_{t}",2);
184  qualComp= ibooker.book2D("qualComp","Hardware Vs. Emulator Quality",4,0,4,4,0,4);
185  qualComp->setAxisTitle("Hardware Quality",1);
186  qualComp->setAxisTitle("Emulator Quality",2);
187 
188 
189  //Monitor Elemens for Dt Stubs
190  dtStubPhi = ibooker.book2D("dtStubPhi","Hardware Vs. Emulator DT Stub #phi",200,400,2400,200,400,2400);
191  dtStubPhi->setAxisTitle("Hardware Stub #phi",1);
192  dtStubPhi->setAxisTitle("Emulator Stub #phi",2);
193  badDtStubSector = ibooker.book2D("badDtStubSector","Dt Sector for bad Dt stub #phi",6,1,7,2,1,3);
194  badDtStubSector->setAxisTitle("Dt stub sector, subsector",1);
195  badDtStubSector->setAxisTitle("Dt Stub Endcap",2);
196 
197  //***********************************//
198  //* F O R Q U A L I T Y T E S T *//
199  //***********************************//
200  //1D plots for the quality test
201  //Monitor Elements for Pt Lut Address Field
202  pt1Comp_1d = ibooker.book1D("pt1Comp_1d","Hardware Vs. Emulator #Delta #phi_{12}",2,0,2);
203  pt1Comp_1d->setAxisTitle("#Delta #phi_{12}",1);
204  pt1Comp_1d->setBinLabel(1, "Agree", 1);
205  pt1Comp_1d->setBinLabel(2, "Disagree", 1);
206 
207  pt2Comp_1d = ibooker.book1D("pt2Comp_1d","Hardware Vs. Emulator #Delta #phi_{23}",2,0,2);
208  pt2Comp_1d->setAxisTitle("#Delta #phi_{23}",1);
209  pt2Comp_1d->setBinLabel(1, "Agree", 1);
210  pt2Comp_1d->setBinLabel(2, "Disagree", 1);
211 
212  pt3Comp_1d = ibooker.book1D("pt3Comp_1d","Hardware Vs. Emulator #eta",2,0,2);
213  pt3Comp_1d->setAxisTitle("#eta",1);
214  pt3Comp_1d->setBinLabel(1, "Agree", 1);
215  pt3Comp_1d->setBinLabel(2, "Disagree", 1);
216 
217  pt4Comp_1d = ibooker.book1D("pt4Comp_1d","Hardware Vs. Emulator Mode",2,0,2);
218  pt4Comp_1d->setAxisTitle("Mode",1);
219  pt4Comp_1d->setBinLabel(1, "Agree", 1);
220  pt4Comp_1d->setBinLabel(2, "Disagree", 1);
221 
222  pt5Comp_1d = ibooker.book1D("pt5Comp_1d","Hardware Vs. Emulator Sign, FR",2,0,2);
223  pt5Comp_1d->setAxisTitle("Sign<<1|FR",1);
224  pt5Comp_1d->setBinLabel(1, "Agree", 1);
225  pt5Comp_1d->setBinLabel(2, "Disagree", 1);
226 
227 
228  //Monitor Elements for track variables
229  phiComp_1d = ibooker.book1D("phiComp_1d","Hardware Vs. Emulator Track #phi",2,0,2);
230  phiComp_1d->setAxisTitle("#phi",1);
231  phiComp_1d->setBinLabel(1, "Agree", 1);
232  phiComp_1d->setBinLabel(2, "Disagree", 1);
233 
234  etaComp_1d = ibooker.book1D("etaComp_1d","Hardware Vs. Emulator Track #eta",2,0,2);
235  etaComp_1d->setAxisTitle("#eta",1);
236  etaComp_1d->setBinLabel(1, "Agree", 1);
237  etaComp_1d->setBinLabel(2, "Disagree", 1);
238 
239  occComp_1d = ibooker.book1D("occComp_1d","Hardware Vs. Emulator Track Occupancy",2,0,2);
240  occComp_1d->setAxisTitle("Occupancy",1);
241  occComp_1d->setBinLabel(1, "Agree", 1);
242  occComp_1d->setBinLabel(2, "Disagree", 1);
243 
244  ptComp_1d = ibooker.book1D("ptComp_1d","Hardware Vs. Emulator Pt",2,0,2);
245  ptComp_1d->setAxisTitle("P_{t}",1);
246  ptComp_1d->setBinLabel(1, "Agree", 1);
247  ptComp_1d->setBinLabel(2, "Disagree", 1);
248 
249  qualComp_1d= ibooker.book1D("qualComp_1d","Hardware Vs. Emulator Quality",2,0,2);
250  qualComp_1d->setAxisTitle("Quality",1);
251  qualComp_1d->setBinLabel(1, "Agree", 1);
252  qualComp_1d->setBinLabel(2, "Disagree", 1);
253 
254  //Monitor Elemens for Dt Stubs
255  dtStubPhi_1d = ibooker.book1D("dtStubPhi_1d","Hardware Vs. Emulator DT Stub #phi",2,0,2);
256  dtStubPhi_1d->setAxisTitle("DT Stub #phi",1);
257  dtStubPhi_1d->setBinLabel(1, "Agree", 1);
258  dtStubPhi_1d->setBinLabel(2, "Disagree", 1);
259 }
260 
261 void L1TdeCSCTF::analyze(Event const& e, EventSetup const& es){
262  // Initialize Arrays
264  unsigned int nDataMuons = 0;
265  unsigned int nEmulMuons = 0;
266  int dataMuonArray[8][10], emuMuonArray[8][10];
267  for(int muon=0; muon<8; muon++)
268  {
269  for(int par=0; par<3; par++)
270  {
271  dataMuonArray[muon][par]=0;
272  emuMuonArray[muon][par] =0;
273  }
274  emuMuonArray[muon][3] =-1;
275  dataMuonArray[muon][3]=-1;
276 
277  emuMuonArray[muon][4]=7;
278  dataMuonArray[muon][4]=7;
279 
280  for(int par2=5; par2<10; par2++)
281  {
282  emuMuonArray[muon][par2]= -1;
283  dataMuonArray[muon][par2]= -1;
284  }
285  }
286  // Get Hardware information, and check output of PtLUT
288  if( !dataTrackProducer.isUninitialized())
289  {
291  e.getByToken(dataTrackProducer,tracks);
292 
293  // check validity of input collection
294  if(!tracks.isValid()) {
295  LogWarning("L1TdeCSCTF")
296  << "\n No valid [data tracks] product found: "
297  << " L1CSCTrackCollection"
298  << endl;
299  return;
300  }
301 
302 
303  for(L1CSCTrackCollection::const_iterator trk=tracks.product()->begin(); trk!=tracks.product()->end(); trk++)
304  {
305  if (nDataMuons>=8)
306  break;
307  if ( (trk->first.BX() <2) && (trk->first.BX() > -1) )
308  {
309  //int mOdE = (trk->first.ptLUTAddress()>>16)&0xf;
310  //cout << "D->Mode: " << mOdE << ", Rank " << trk->first.rank() << endl;
311  dataMuonArray[nDataMuons][0] = trk->first.ptLUTAddress();
312  dataMuonArray[nDataMuons][1] = trk->first.sector();
313  dataMuonArray[nDataMuons][2] = trk->first.endcap();
314  dataMuonArray[nDataMuons][8] = trk->first.outputLink();
315  dataMuonArray[nDataMuons][4] = trk->first.BX();
316  dataMuonArray[nDataMuons][5] = trk->first.rank();
317  dataMuonArray[nDataMuons][6] = trk->first.localPhi();
318  dataMuonArray[nDataMuons][7] = trk->first.eta_packed();
319  dataMuonArray[nDataMuons][9] = trk->first.modeExtended();
320  nDataMuons++;
321  }
322  }
323  }
324  // Get Emulator information
326  if( !emulTrackProducer.isUninitialized() )
327  {
329  e.getByToken(emulTrackProducer,tracks);
330 
331  // check validity of input collection
332  if(!tracks.isValid()) {
333  LogWarning("L1TdeCSCTF")
334  << "\n No valid [emulator tracks] product found: "
335  << " L1CSCTrackCollection"
336  << endl;
337  return;
338  }
339 
340  for(L1CSCTrackCollection::const_iterator trk=tracks.product()->begin(); trk!=tracks.product()->end(); trk++)
341  {
342  if(nEmulMuons>=8)
343  break;
344  if((trk->first.BX() <2) && (trk->first.BX() >-1))
345  {
346  //int mOdE = (trk->first.ptLUTAddress()>>16)&0xf;
347  //cout << "E->Mode: " << mOdE << ", Rank " << trk->first.rank() << endl;
348  emuMuonArray[nEmulMuons][0] = trk->first.ptLUTAddress();
349  emuMuonArray[nEmulMuons][1] = trk->first.sector();
350  emuMuonArray[nEmulMuons][2] = trk->first.endcap();
351  emuMuonArray[nEmulMuons][4] = trk->first.BX();
352  emuMuonArray[nEmulMuons][5] = trk->first.rank();
353  emuMuonArray[nEmulMuons][6] = trk->first.localPhi();
354  emuMuonArray[nEmulMuons][7] = trk->first.eta_packed();
355  emuMuonArray[nEmulMuons][9] = trk->first.modeExtended();
356  nEmulMuons++;
357  }
358  }
359  }
360  //Fill Occupancy M.E.
361  if( (nDataMuons!=0)||(nEmulMuons!=0) ) {
362  occComp->Fill(nDataMuons,nEmulMuons);
363  (nDataMuons==nEmulMuons) ? occComp_1d->Fill(0) : occComp_1d->Fill(1);
364  }
365  // Match Tracks by sector & mode in the case of multiple tracks
367  if(nDataMuons==nEmulMuons)
368  {
369  //First, find EXACT address matches in a given sector, endcap
370  for(unsigned int mu1=0; mu1<nDataMuons; mu1++)
371  {
372  for(unsigned int mu2=0; mu2<nEmulMuons; mu2++)
373  if((emuMuonArray[mu2][1]==dataMuonArray[mu1][1])&&(emuMuonArray[mu2][2]==dataMuonArray[mu1][2]))
374  {
375  if(emuMuonArray[mu2][0]==dataMuonArray[mu1][0])
376  {
377  emuMuonArray[mu2][3]=mu1;
378  dataMuonArray[mu1][3]=1;
379  }
380  }
381  }
382  //Next, try to match unmapped
383  for(unsigned int c2a=0; c2a<nEmulMuons; c2a++)
384  {
385  if(emuMuonArray[c2a][3]==-1)
386  {
387  for(unsigned int cor_a=0; cor_a<nDataMuons; cor_a++)
388  {
389  if( (dataMuonArray[cor_a][1]==emuMuonArray[c2a][1]) && (dataMuonArray[cor_a][2]==emuMuonArray[c2a][2]))// && (dataMuonArray[cor_a][3]==-1))
390  {
391  emuMuonArray[c2a][3]=cor_a;
392  dataMuonArray[cor_a][3]=1;
393  }
394  }
395  }
396  }
397  //Check that a single emulator track is not mapped to multiple data tracks
398  bool multiMap = false;
399  if(nEmulMuons>1)
400  {
401  for(unsigned int c1a=0; c1a<(nEmulMuons-1); c1a++)
402  {
403  for(unsigned int c1b=(c1a+1); c1b<nEmulMuons; c1b++)
404  {
405  if(emuMuonArray[c1a][3]==emuMuonArray[c1b][3])
406  {
407  //cout << "Error: Multiple Emulator Muons Mapped to the same Data Muon." << endl;
408  multiMap = true;
409  break;
410  }
411  }
412  if (multiMap)
413  break;
414  }
415  }
416  //Fill histograms based on matched Tracks
417  for(unsigned int mu3=0; mu3<nEmulMuons; mu3++)
418  {
419  int mapping = emuMuonArray[mu3][3];
420  if((mapping!=-1)&&(multiMap==false))
421  {
422  //Decode LUT Address for more meaningful comparison
423  int emuPhi12 = (0x0000ff & emuMuonArray[mu3][0]);
424  int datPhi12 = (0x0000ff & dataMuonArray[mapping][0]);
425  int emuPhi23 = (0x000f00 & emuMuonArray[mu3][0])>>8;
426  int datPhi23 = (0x000f00 & dataMuonArray[mapping][0])>>8;
427  int emuEta = (0x00f000 & emuMuonArray[mu3][0])>>12;
428  int datEta = (0x00f000 & dataMuonArray[mapping][0])>>12;
429  //int emuMode = (0x0f0000 & emuMuonArray[mu3][0])>>16;
430  //int datMode = (0x0f0000 & dataMuonArray[mapping][0])>>16;
431  int emuFrSin = (0xf00000 & emuMuonArray[mu3][0])>>20;
432  int datFrSin = (0xf00000 & dataMuonArray[mapping][0])>>20;
433  //Decode Rank for more meaningful comparison
434  int emuQual = emuMuonArray[mu3][5]>>5;
435  int datQual = dataMuonArray[mapping][5]>>5;
436  int emuPt = 0x1f & emuMuonArray[mu3][5];
437  int datPt = 0x1f & dataMuonArray[mapping][5];
438  int emuModeExtended = emuMuonArray[mu3][9];
439  int datModeExtended = dataMuonArray[mapping][9];
440 
441  //Fill mode M.E., one of (the most important) PtLUT address field
442  pt4Comp->Fill(datModeExtended,emuModeExtended);
443  (datModeExtended==emuModeExtended) ? pt4Comp_1d->Fill(0) : pt4Comp_1d->Fill(1);
444  //To disentagle problems, only fill histograms if mode matches
445  if(emuModeExtended==datModeExtended)
446  {
447  //Fill Pt LUT address field M.E.
448  pt1Comp->Fill(datPhi12,emuPhi12); (datPhi12==emuPhi12) ? pt1Comp_1d->Fill(0) : pt1Comp_1d->Fill(1);
449  pt2Comp->Fill(datPhi23,emuPhi23); (datPhi23==emuPhi23) ? pt2Comp_1d->Fill(0) : pt2Comp_1d->Fill(1);
450  pt3Comp->Fill(datEta,emuEta); (datEta==emuEta) ? pt3Comp_1d->Fill(0) : pt3Comp_1d->Fill(1);
451  pt5Comp->Fill(datFrSin,emuFrSin); (datFrSin==emuFrSin) ? pt5Comp_1d->Fill(0) : pt5Comp_1d->Fill(1);
452  //Fill Track value M.E.
453  if(dataMuonArray[mapping][8]==1) //Rank Comparison available for Link 1 only due to readout limitation
454  {
455  ptComp->Fill(datPt,emuPt); (datPt==emuPt) ? ptComp_1d->Fill(0) : ptComp_1d->Fill(1);
456  qualComp->Fill(datQual,emuQual);(datQual==emuQual) ? qualComp_1d->Fill(0) : qualComp_1d->Fill(1);
457  }
458  phiComp->Fill(dataMuonArray[mapping][6],emuMuonArray[mu3][6]);
459  etaComp->Fill(dataMuonArray[mapping][7],emuMuonArray[mu3][7]);
460 
461  (dataMuonArray[mapping][6]==emuMuonArray[mu3][6]) ? phiComp_1d->Fill(0) : phiComp_1d->Fill(1);
462  (dataMuonArray[mapping][7]==emuMuonArray[mu3][7]) ? etaComp_1d->Fill(0) : etaComp_1d->Fill(1);
463  }
464  }
465  }
466  }
467 
468  //Compare DT stubs to check transmission quality
470  //Declare arrays, initialize
471  int eDtStub[7][15];
472  int dDtStub[8][15];
473  int eDtCounter = 0;
474  int dDtCounter = 0;
475  for(int dJ=0; dJ<7; dJ++)
476  {
477  for(int dK=0; dK<15; dK++)
478  {
479  eDtStub[dJ][dK] = -55;
480  dDtStub[dJ][dK] = -55;
481  dDtStub[7][dK] = -55;
482  }
483  }
484 
485  // Get Daq Recorded Stub Information
486  if( !dataStubProducer.isUninitialized() )
487  {
489  e.getByToken(dataStubProducer,dtTrig);
490  // check validity of input collection
491  if(!dtTrig.isValid()) {
492  LogWarning("L1TdeCSCTF")
493  << "\n No valid [Data Stubs] product found: "
494  << " L1CSCTrackCollection"
495  << endl;
496  return;
497  }
498  const CSCTriggerContainer<csctf::TrackStub>* dt_stubs = dtTrig.product();
500  stub_list.push_many(*dt_stubs);
501  vector<csctf::TrackStub> stuList = stub_list.get();
502  vector<csctf::TrackStub>::const_iterator stu= stuList.begin();
503  for(; stu!=stuList.end(); stu++)
504  {
505  if(dDtCounter>=15)
506  break;
507  if((stu->BX()>4) && (stu->BX()<9))
508  {
509  dDtStub[0][dDtCounter] = stu->phiPacked();
510  dDtStub[1][dDtCounter] = stu->getQuality();
511  dDtStub[2][dDtCounter] = stu->endcap();
512  dDtStub[3][dDtCounter] = stu->sector();
513  dDtStub[4][dDtCounter] = stu->subsector();
514  dDtCounter++;
515  }
516  }
517  }
518 
519  // Get Daq Recorded Stub Information
520  if( !emulStubProducer.isUninitialized() )
521  {
522  // Get Emulated Stub Information
524  e.getByToken(emulStubProducer,pCon);
525  // check validity of input collection
526  if(!pCon.isValid()) {
527  LogWarning("L1TdeCSCTF")
528  << "\n No valid [Data Stubs] product found: "
529  << " L1CSCTrackCollection"
530  << endl;
531  return;
532  }
533  CSCTriggerContainer<csctf::TrackStub> emulStub = my_dtrc->process(pCon.product());
534  vector<csctf::TrackStub> emuList = emulStub.get();
535  vector<csctf::TrackStub>::const_iterator eStu=emuList.begin();
536  for(; eStu!=emuList.end(); eStu++)
537  {
538  if (eDtCounter>=15)
539  break;
540  if((eStu->BX()>4) && (eStu->BX()<9) )
541  {
542  eDtStub[0][eDtCounter] = eStu->phiPacked();
543  eDtStub[1][eDtCounter] = eStu->getQuality();
544  eDtStub[2][eDtCounter] = eStu->endcap();
545  eDtStub[3][eDtCounter] = eStu->sector();
546  eDtStub[4][eDtCounter] = eStu->subsector();
547  eDtCounter++;
548  }
549  }
550  }
551 
552  //cout << "Num Tracks match eDtCounter: " << eDtCounter << ", dDt: " << dDtCounter << endl;
553  //First find perfect matches
554  for(int eS=0; eS<eDtCounter; eS++)
555  {
556  //cout << "es Loop" << endl;
557  for(int dS=0; dS<dDtCounter; dS++)
558  {
559  //cout << "ds Loop" << endl;
560  if(eDtStub[2][eS]==dDtStub[2][dS])
561  {
562  //cout << "end match" << endl;
563  if(eDtStub[3][eS]==dDtStub[3][dS])
564  {
565  //cout << "sec match" << endl;
566  if(eDtStub[4][eS]==dDtStub[4][dS])
567  {
568  //cout << "First match loop, eS: " << eS << ", dS" << dS << endl;
569  if( (eDtStub[0][eS]==dDtStub[0][dS]) && (eDtStub[1][eS]==dDtStub[1][dS]) && (eDtStub[6][eS]!=1) && (dDtStub[6][dS]!=1) )
570  {
571  //cout << "Passed fist matching." << endl;
572  eDtStub[5][eS] = dS;
573  eDtStub[6][eS] = 1;
574  dDtStub[5][dS] = eS;
575  dDtStub[6][dS] = 1;
576  }
577  }
578  }
579  }
580  }
581  }
582 
583  //Now find imperfect matches
584  for(int eS2=0; eS2<eDtCounter; eS2++)
585  {
586  for(int dS2=0; dS2<dDtCounter; dS2++)
587  {
588  //cout << "1: " << eDtStub[2][eS2] << ", " << dDtStub[2][dS2] << ", " << eDtStub[3][eS2] << ", " << dDtStub[3][dS2] << ", " << eDtStub[4][eS2] << ", " << dDtStub[4][dS2] << endl;
589  if( (eDtStub[2][eS2]==dDtStub[2][dS2]) && (eDtStub[3][eS2]==dDtStub[3][dS2]) && (eDtStub[4][eS2]==dDtStub[4][dS2]) )
590  {
591  //cout << "2: " << dDtStub[7][eS2] << ", " << dDtStub[7][dS2] << ", " << abs(eDtStub[0][eS2]-dDtStub[0][dS2]) << ", " << ", " << eDtStub[6][eS2] << ", " << dDtStub[6][dS2] << endl;
592  if( ((dDtStub[7][eS2]==-55) || (dDtStub[7][dS2]>(abs(eDtStub[0][eS2]-dDtStub[0][dS2]))) ) && (eDtStub[6][eS2]!=1) && (dDtStub[6][dS2]!=1) )
593  {
594  //cout << "Imperfect match found" << endl;
595  dDtStub[5][dS2] = eS2;
596  dDtStub[6][dS2] = 2;
597  eDtStub[5][eS2] = dS2;
598  eDtStub[6][eS2] = 2;
599  dDtStub[7][dS2] = abs(eDtStub[0][eS2]-dDtStub[0][dS2]);
600  }
601  }
602  }
603  }
604 
605  //Debug time!
606  bool dtSMulti = false;
607  int dtUnmap = 0;
608  if(eDtCounter>1)
609  for(int eS3a=0; eS3a<eDtCounter-1; eS3a++)
610  for(int eS3b=eS3a+1; eS3b<eDtCounter; eS3b++)
611  {
612  if( eDtStub[5][eS3a]==eDtStub[5][eS3b] ) dtSMulti=true;
613  if( eDtStub[5][eS3a]==-55 || eDtStub[5][eS3b]==-55 ) dtUnmap++;
614  }
615 
616  if(dDtCounter>1)
617  for(int dS3a=0; dS3a<dDtCounter-1; dS3a++)
618  for(int dS3b=dS3a+1; dS3b<dDtCounter; dS3b++)
619  {
620  if( dDtStub[5][dS3a]==dDtStub[5][dS3b] ) dtSMulti=true;
621  if( dDtStub[5][dS3a]==-55||dDtStub[5][dS3b]==-55 ) dtUnmap++;
622  }
623  /*if(dtSMulti==true)
624  cout << "Multiple DT stubs mapped to the same stub" << endl;
625  if(dtUnmap!=0)
626  cout << "Unmapped DT stubs:" << dtUnmap << endl;*/
627 
628  if(dtSMulti==false && dtUnmap==0)
629  {
630  for(int phil=0; phil<eDtCounter; phil++)
631  {
632  if(eDtStub[6][phil]==1 || eDtStub[6][phil]==2)
633  {
634  int indexFil = eDtStub[3][phil]*2+eDtStub[4][phil]-1;
635  dtStubPhi->Fill(eDtStub[0][phil], dDtStub[0][ eDtStub[5][phil] ]);
636  (eDtStub[0][phil] == dDtStub[0][ eDtStub[5][phil] ]) ? dtStubPhi_1d->Fill(0) : dtStubPhi_1d->Fill(1);
637  if( eDtStub[0][phil] != dDtStub[0][ eDtStub[5][phil] ])
638  badDtStubSector->Fill(indexFil,eDtStub[2][phil]);
639  }
640  }
641  }
642  if(ptLUT_) delete ptLUT_;
643 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< T > get() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
L1TdeCSCTF(edm::ParameterSet const &pset)
Definition: L1TdeCSCTF.cc:39
void analyze(edm::Event const &e, edm::EventSetup const &iSetup)
Definition: L1TdeCSCTF.cc:261
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: L1TdeCSCTF.cc:97
bool isValid() const
Definition: HandleBase.h:75
void push_many(const std::vector< T > &data)
virtual void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) override
Definition: L1TdeCSCTF.cc:100
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
tuple tracks
Definition: testEve_cfg.py:39
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: L1TdeCSCTF.cc:94
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: Run.h:43