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