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