CMS 3D CMS Logo

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