CMS 3D CMS Logo

L1TCSCTF.cc
Go to the documentation of this file.
1 /*
2  * \file L1TCSCTF.cc
3  *
4  * \author J. Berryhill
5  *
6  */
7 
10 
11 // includes to fetch all reguired data products from the edm::Event
16 
19 
20 using namespace std;
21 using namespace edm;
22 
24  // if some piece of data is absent - configure corresponding source with 'null:'
25  // : csctfSource_( ps.getParameter< InputTag >("csctfSource") )
26  : gmtProducer(ps.getParameter<InputTag>("gmtProducer")),
27  lctProducer(ps.getParameter<InputTag>("lctProducer")),
28  trackProducer(ps.getParameter<InputTag>("trackProducer")),
29  statusProducer(ps.getParameter<InputTag>("statusProducer")),
30  mbProducer(ps.getParameter<InputTag>("mbProducer")),
31  l1muTscalesToken_(esConsumes()),
32  ptscalesToken_(esConsumes()) {
33  // verbosity switch
34  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
35 
36  if (verbose_)
37  edm::LogInfo("DataNotFound") << "L1TCSCTF: constructor...." << endl;
38 
39  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
40  if (!outputFile_.empty()) {
41  edm::LogInfo("DataNotFound") << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
42  }
43 
44  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
45  if (disable) {
46  outputFile_ = "";
47  }
48 
49  gangedME11a_ = ps.getUntrackedParameter<bool>("gangedME11a", false);
50 
51  // instantiate standard on-fly SR LUTs from CSC TF emulator package
52  bzero(srLUTs_, sizeof(srLUTs_));
53  //int sector=1; // assume SR LUTs are all same for every sector
54  bool TMB07 = true; // specific TMB firmware
55  // Create a pset for SR/PT LUTs: if you do not change the value in the
56  // configuration file, it will load the default minitLUTs
57  edm::ParameterSet srLUTset;
58  srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
59  srLUTset.addUntrackedParameter<bool>("Binary", false);
60  srLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
61 
62  // positive endcap
63  int endcap = 1;
64  for (int sector = 0; sector < 6; sector++) {
65  for (int station = 1, fpga = 0; station <= 4 && fpga < 5; station++) {
66  if (station == 1)
67  for (int subSector = 0; subSector < 2 && fpga < 5; subSector++)
68  srLUTs_[fpga++][1][sector] =
69  new CSCSectorReceiverLUT(endcap, sector + 1, subSector + 1, station, srLUTset, TMB07);
70  else
71  srLUTs_[fpga++][1][sector] = new CSCSectorReceiverLUT(endcap, sector + 1, 0, station, srLUTset, TMB07);
72  }
73  }
74 
75  // negative endcap
76  endcap = 2;
77  for (int sector = 0; sector < 6; sector++) {
78  for (int station = 1, fpga = 0; station <= 4 && fpga < 5; station++) {
79  if (station == 1)
80  for (int subSector = 0; subSector < 2 && fpga < 5; subSector++)
81  srLUTs_[fpga++][0][sector] =
82  new CSCSectorReceiverLUT(endcap, sector + 1, subSector + 1, station, srLUTset, TMB07);
83  else
84  srLUTs_[fpga++][0][sector] = new CSCSectorReceiverLUT(endcap, sector + 1, 0, station, srLUTset, TMB07);
85  }
86  }
87 
88  //set Token(-s)
94 
95  gmtProducerToken_ = consumes<L1MuGMTReadoutCollection>(ps.getParameter<InputTag>("gmtProducer"));
96  statusToken_ = consumes<L1CSCStatusDigiCollection>(statusTag_);
97  corrlctsToken_ = consumes<CSCCorrelatedLCTDigiCollection>(corrlctsTag_);
98  tracksToken_ = consumes<L1CSCTrackCollection>(tracksTag_);
99  dtStubsToken_ = consumes<CSCTriggerContainer<csctf::TrackStub> >(dtStubsTag_);
100  mbtracksToken_ = consumes<L1CSCTrackCollection>(mbtracksTag_);
101 }
102 
104  for (unsigned int j = 0; j < 2; j++)
105  for (unsigned int i = 0; i < 5; i++)
106  for (unsigned int s = 0; s < 6; s++)
107  delete srLUTs_[i][j][s]; //free the array of pointers
108 }
109 
111  m_scalesCacheID = -999;
112  m_ptScaleCacheID = -999;
113 
114  nev_ = 0;
115  ibooker.setCurrentFolder("L1T/L1TCSCTF");
116 
117  // Error counting histogram:
118  // 1) checks TF data integrity (error rate - first bin),
119  // 2) monitors sychronization on input links (4 errors types: SE/SM/BX/AF; ORed for all time bins, links, and SPs),
120  // 3) reports FMM status (if in any SP FMM status != "Ready" - fill the last bin)
121  csctferrors = ibooker.book1D("CSCTF_errors", "CSCTF Errors", 6, 0, 6);
122  csctferrors->setAxisTitle("Error type", 1);
123  csctferrors->setAxisTitle("Number of Errors", 2);
124  csctferrors->setBinLabel(1, "Corruptions", 1);
125  csctferrors->setBinLabel(2, "Synch. Err.", 1);
126  csctferrors->setBinLabel(3, "Synch. Mod.", 1);
127  csctferrors->setBinLabel(4, "BX mismatch", 1);
128  csctferrors->setBinLabel(5, "Time misalign.", 1);
129  csctferrors->setBinLabel(6, "FMM != Ready", 1);
130 
131  // Error with detailed MCPID
132  csctferrors_mpc = ibooker.book2D("CSCTF_errors_mpc", "CSCTF Errors", 6, 0, 6, 60, 1, 61);
133  csctferrors_mpc->setAxisTitle("Error type", 1);
134  csctferrors_mpc->setAxisTitle("MPC ID", 2);
135  csctferrors_mpc->setBinLabel(1, "Corruptions", 1);
136  csctferrors_mpc->setBinLabel(2, "Synch. Err.", 1);
137  csctferrors_mpc->setBinLabel(3, "Synch. Mod.", 1);
138  csctferrors_mpc->setBinLabel(4, "BX mismatch", 1);
139  csctferrors_mpc->setBinLabel(5, "Time misalign.", 1);
140  csctferrors_mpc->setBinLabel(6, "FMM != Ready", 1);
141  for (int ybin = 1; ybin <= 60; ybin++) {
142  if (ybin % 5)
143  continue;
144  char ytitle[50];
145  snprintf(ytitle, 50, "%d", ybin);
147  }
148 
149  // Occupancy histogram Eta x Y, where Y:
150  // 1) Phi_packed of input LCTs from 1st, 2nd, 3rd, and 4th stations
151  // 2) Phi_packed of output tracks
152  // (all 12 SPs - 360 degree coveradge)
153  csctfoccupancies = ibooker.book2D("CSCTF_occupancies", "CSCTF Occupancies", 64, -32, 31, 32, 0, 6.2);
154  csctfoccupancies->setAxisTitle("#eta", 1);
155  csctfoccupancies->setAxisTitle("#phi", 2);
156  csctfoccupancies->setBinLabel(1, "-2.5", 1);
157  csctfoccupancies->setBinLabel(8, "-2.1", 1);
158  csctfoccupancies->setBinLabel(18, "-1.6", 1);
159  csctfoccupancies->setBinLabel(26, "-1.2", 1);
160  csctfoccupancies->setBinLabel(32, "-0.9", 1);
161  csctfoccupancies->setBinLabel(33, "0.9", 1);
162  csctfoccupancies->setBinLabel(39, "1.2", 1);
163  csctfoccupancies->setBinLabel(47, "1.6", 1);
164  csctfoccupancies->setBinLabel(57, "2.1", 1);
165  csctfoccupancies->setBinLabel(64, "2.5", 1);
166 
167  // ... and for halo muons only
168  csctfoccupancies_H = ibooker.book2D("CSCTF_occupancies_H", "CSCTF Halo Occupancies", 64, -32, 31, 32, 0, 6.2);
169  csctfoccupancies_H->setAxisTitle("#eta", 1);
170  csctfoccupancies_H->setAxisTitle("#phi", 2);
171  csctfoccupancies_H->setBinLabel(1, "-2.5", 1);
172  csctfoccupancies_H->setBinLabel(8, "-2.1", 1);
173  csctfoccupancies_H->setBinLabel(18, "-1.6", 1);
174  csctfoccupancies_H->setBinLabel(26, "-1.2", 1);
175  csctfoccupancies_H->setBinLabel(32, "-0.9", 1);
176  csctfoccupancies_H->setBinLabel(33, "0.9", 1);
177  csctfoccupancies_H->setBinLabel(39, "1.2", 1);
178  csctfoccupancies_H->setBinLabel(47, "1.6", 1);
179  csctfoccupancies_H->setBinLabel(57, "2.1", 1);
180  csctfoccupancies_H->setBinLabel(64, "2.5", 1);
181 
182  //haloDelEta12 = ibooker.book1D("CSCTF_Halo_Eta12", "#Delta #eta_{12} for Halo Muons", 40, -0.20,0.30);
183  //haloDelEta112 = ibooker.book1D("CSCTF_Halo_Eta112","#Delta #eta_{112} for Halo Muons", 40, -0.20,0.30);
184  //haloDelEta13 = ibooker.book1D("CSCTF_Halo_Eta13", "#Delta #eta_{13} for Halo Muons", 40, -0.20,0.30);
185  //haloDelEta113 = ibooker.book1D("CSCTF_Halo_Eta113","#Delta #eta_{113} for Halo Muons", 40, -0.20,0.30);
186 
187  // Quality VS Mode
188  trackModeVsQ = ibooker.book2D("CSCTF_Track_ModeVsQual", "CSC Track Mode Vs Quality", 19, -0.5, 18.5, 4, 0, 4);
189  trackModeVsQ->setAxisTitle("Track Type", 1);
190  trackModeVsQ->setBinLabel(1, "No Track", 1);
191  trackModeVsQ->setBinLabel(2, "Bad Phi/Single", 1);
192  trackModeVsQ->setBinLabel(3, "ME1-2-3", 1);
193  trackModeVsQ->setBinLabel(4, "ME1-2-4", 1);
194  trackModeVsQ->setBinLabel(5, "ME1-3-4", 1);
195  trackModeVsQ->setBinLabel(6, "ME2-3-4", 1);
196  trackModeVsQ->setBinLabel(7, "ME1-2", 1);
197  trackModeVsQ->setBinLabel(8, "ME1-3", 1);
198  trackModeVsQ->setBinLabel(9, "ME2-3", 1);
199  trackModeVsQ->setBinLabel(10, "ME2-4", 1);
200  trackModeVsQ->setBinLabel(11, "ME3-4", 1);
201  trackModeVsQ->setBinLabel(12, "MB1-ME3", 1);
202  trackModeVsQ->setBinLabel(13, "MB1-ME2", 1);
203  trackModeVsQ->setBinLabel(14, "ME1-4", 1);
204  trackModeVsQ->setBinLabel(15, "MB1-ME1", 1);
205  trackModeVsQ->setBinLabel(16, "Halo Trigger", 1);
206  trackModeVsQ->setBinLabel(17, "MB1-ME1-2", 1);
207  trackModeVsQ->setBinLabel(18, "MB1-ME1-3", 1);
208  trackModeVsQ->setBinLabel(19, "MB1-ME2-3", 1);
209 
210  trackModeVsQ->setAxisTitle("Quality", 2);
211  trackModeVsQ->setBinLabel(1, "0", 2);
212  trackModeVsQ->setBinLabel(2, "1", 2);
213  trackModeVsQ->setBinLabel(3, "2", 2);
214  trackModeVsQ->setBinLabel(4, "3", 2);
215 
216  // Mode
217  csctfTrackM = ibooker.book1D("CSCTF_Track_Mode", "CSC Track Mode", 19, -0.5, 18.5);
218  csctfTrackM->setAxisTitle("Track Type", 1);
219  csctfTrackM->setBinLabel(1, "No Track", 1);
220  csctfTrackM->setBinLabel(2, "Bad Phi/Single", 1);
221  csctfTrackM->setBinLabel(3, "ME1-2-3", 1);
222  csctfTrackM->setBinLabel(4, "ME1-2-4", 1);
223  csctfTrackM->setBinLabel(5, "ME1-3-4", 1);
224  csctfTrackM->setBinLabel(6, "ME2-3-4", 1);
225  csctfTrackM->setBinLabel(7, "ME1-2", 1);
226  csctfTrackM->setBinLabel(8, "ME1-3", 1);
227  csctfTrackM->setBinLabel(9, "ME2-3", 1);
228  csctfTrackM->setBinLabel(10, "ME2-4", 1);
229  csctfTrackM->setBinLabel(11, "ME3-4", 1);
230  csctfTrackM->setBinLabel(12, "MB1-ME3", 1);
231  csctfTrackM->setBinLabel(13, "MB1-ME2", 1);
232  csctfTrackM->setBinLabel(14, "ME1-4", 1);
233  csctfTrackM->setBinLabel(15, "MB1-ME1", 1);
234  csctfTrackM->setBinLabel(16, "Halo Trigger", 1);
235  csctfTrackM->setBinLabel(17, "MB1-ME1-2", 1);
236  csctfTrackM->setBinLabel(18, "MB1-ME1-3", 1);
237  csctfTrackM->setBinLabel(19, "MB1-ME2-3", 1);
238 
239  // Chamber Occupancy
241  ibooker.book2D("CSCTF_Chamber_Occupancies", "CSCTF Chamber Occupancies", 54, -0.05, 5.35, 10, -5.5, 4.5);
242  csctfChamberOccupancies->setAxisTitle("Sector, (chambers 1-9 not labeled)", 1);
243  csctfChamberOccupancies->setBinLabel(1, "ME-4", 2);
244  csctfChamberOccupancies->setBinLabel(2, "ME-3", 2);
245  csctfChamberOccupancies->setBinLabel(3, "ME-2", 2);
246  csctfChamberOccupancies->setBinLabel(4, "ME-1b", 2);
247  csctfChamberOccupancies->setBinLabel(5, "ME-1a", 2);
248  csctfChamberOccupancies->setBinLabel(6, "ME+1a", 2);
249  csctfChamberOccupancies->setBinLabel(7, "ME+1b", 2);
250  csctfChamberOccupancies->setBinLabel(8, "ME+2", 2);
251  csctfChamberOccupancies->setBinLabel(9, "ME+3", 2);
252  csctfChamberOccupancies->setBinLabel(10, "ME+4", 2);
259 
260  // Track Phi
261  csctfTrackPhi = ibooker.book1D("CSCTF_Track_Phi", "CSCTF Track #phi", 144, 0, 2 * M_PI);
262  csctfTrackPhi->setAxisTitle("Track #phi", 1);
263 
264  // Track Eta
265  csctfTrackEta = ibooker.book1D("CSCTF_Track_Eta", "CSCTF Track #eta", 64, -32, 32);
266  csctfTrackEta->setAxisTitle("Track #eta", 1);
267  csctfTrackEta->setBinLabel(1, "-2.5", 1);
268  csctfTrackEta->setBinLabel(8, "-2.1", 1);
269  csctfTrackEta->setBinLabel(18, "-1.6", 1);
270  csctfTrackEta->setBinLabel(26, "-1.2", 1);
271  csctfTrackEta->setBinLabel(32, "-0.9", 1);
272  csctfTrackEta->setBinLabel(33, "0.9", 1);
273  csctfTrackEta->setBinLabel(39, "1.2", 1);
274  csctfTrackEta->setBinLabel(47, "1.6", 1);
275  csctfTrackEta->setBinLabel(57, "2.1", 1);
276  csctfTrackEta->setBinLabel(64, "2.5", 1);
277 
278  // Track Eta Low Quality
279  csctfTrackEtaLowQ = ibooker.book1D("CSCTF_Track_Eta_LowQ", "CSCTF Track #eta LQ", 64, -32, 32);
280  csctfTrackEtaLowQ->setAxisTitle("Track #eta", 1);
281  csctfTrackEtaLowQ->setBinLabel(1, "-2.5", 1);
282  csctfTrackEtaLowQ->setBinLabel(8, "-2.1", 1);
283  csctfTrackEtaLowQ->setBinLabel(18, "-1.6", 1);
284  csctfTrackEtaLowQ->setBinLabel(26, "-1.2", 1);
285  csctfTrackEtaLowQ->setBinLabel(32, "-0.9", 1);
286  csctfTrackEtaLowQ->setBinLabel(33, "0.9", 1);
287  csctfTrackEtaLowQ->setBinLabel(39, "1.2", 1);
288  csctfTrackEtaLowQ->setBinLabel(47, "1.6", 1);
289  csctfTrackEtaLowQ->setBinLabel(57, "2.1", 1);
290  csctfTrackEtaLowQ->setBinLabel(64, "2.5", 1);
291 
292  // Track Eta High Quality
293  csctfTrackEtaHighQ = ibooker.book1D("CSCTF_Track_Eta_HighQ", "CSCTF Track #eta HQ", 64, -32, 32);
294  csctfTrackEtaHighQ->setAxisTitle("Track #eta", 1);
295  csctfTrackEtaHighQ->setBinLabel(1, "-2.5", 1);
296  csctfTrackEtaHighQ->setBinLabel(8, "-2.1", 1);
297  csctfTrackEtaHighQ->setBinLabel(18, "-1.6", 1);
298  csctfTrackEtaHighQ->setBinLabel(26, "-1.2", 1);
299  csctfTrackEtaHighQ->setBinLabel(32, "-0.9", 1);
300  csctfTrackEtaHighQ->setBinLabel(33, "0.9", 1);
301  csctfTrackEtaHighQ->setBinLabel(39, "1.2", 1);
302  csctfTrackEtaHighQ->setBinLabel(47, "1.6", 1);
303  csctfTrackEtaHighQ->setBinLabel(57, "2.1", 1);
304  csctfTrackEtaHighQ->setBinLabel(64, "2.5", 1);
305 
306  // Halo Phi
307  csctfTrackPhi_H = ibooker.book1D("CSCTF_Track_Phi_H", "CSCTF Halo #phi", 144, 0, 2 * M_PI);
308  csctfTrackPhi_H->setAxisTitle("Track #phi", 1);
309 
310  // Halo Eta
311  csctfTrackEta_H = ibooker.book1D("CSCTF_Track_Eta_H", "CSCTF Halo #eta", 64, -32, 32);
312  csctfTrackEta_H->setAxisTitle("Track #eta", 1);
313  csctfTrackEta_H->setBinLabel(1, "-2.5", 1);
314  csctfTrackEta_H->setBinLabel(8, "-2.1", 1);
315  csctfTrackEta_H->setBinLabel(18, "-1.6", 1);
316  csctfTrackEta_H->setBinLabel(26, "-1.2", 1);
317  csctfTrackEta_H->setBinLabel(32, "-0.9", 1);
318  csctfTrackEta_H->setBinLabel(33, "0.9", 1);
319  csctfTrackEta_H->setBinLabel(39, "1.2", 1);
320  csctfTrackEta_H->setBinLabel(47, "1.6", 1);
321  csctfTrackEta_H->setBinLabel(57, "2.1", 1);
322  csctfTrackEta_H->setBinLabel(64, "2.5", 1);
323 
324  // Track Timing
325  csctfbx = ibooker.book2D("CSCTF_bx", "CSCTF BX", 12, 1, 13, 7, -3, 3);
326  csctfbx->setAxisTitle("Sector (Endcap)", 1);
327  csctfbx->setBinLabel(1, " 1 (+)", 1);
328  csctfbx->setBinLabel(2, " 2 (+)", 1);
329  csctfbx->setBinLabel(3, " 3 (+)", 1);
330  csctfbx->setBinLabel(4, " 4 (+)", 1);
331  csctfbx->setBinLabel(5, " 5 (+)", 1);
332  csctfbx->setBinLabel(6, " 6 (+)", 1);
333  csctfbx->setBinLabel(7, " 7 (-)", 1);
334  csctfbx->setBinLabel(8, " 8 (-)", 1);
335  csctfbx->setBinLabel(9, " 9 (-)", 1);
336  csctfbx->setBinLabel(10, "10 (-)", 1);
337  csctfbx->setBinLabel(11, "11 (-)", 1);
338  csctfbx->setBinLabel(12, "12 (-)", 1);
339 
340  csctfbx->setAxisTitle("CSCTF BX", 2);
341  csctfbx->setBinLabel(1, "-3", 2);
342  csctfbx->setBinLabel(2, "-2", 2);
343  csctfbx->setBinLabel(3, "-1", 2);
344  csctfbx->setBinLabel(4, "-0", 2);
345  csctfbx->setBinLabel(5, " 1", 2);
346  csctfbx->setBinLabel(6, " 2", 2);
347  csctfbx->setBinLabel(7, " 3", 2);
348 
349  // Halo Timing
350  csctfbx_H = ibooker.book2D("CSCTF_bx_H", "CSCTF HALO BX", 12, 1, 13, 7, -3, 3);
351  csctfbx_H->setAxisTitle("Sector (Endcap)", 1);
352  csctfbx_H->setBinLabel(1, " 1 (+)", 1);
353  csctfbx_H->setBinLabel(2, " 2 (+)", 1);
354  csctfbx_H->setBinLabel(3, " 3 (+)", 1);
355  csctfbx_H->setBinLabel(4, " 4 (+)", 1);
356  csctfbx_H->setBinLabel(5, " 5 (+)", 1);
357  csctfbx_H->setBinLabel(6, " 6 (+)", 1);
358  csctfbx_H->setBinLabel(7, " 7 (-)", 1);
359  csctfbx_H->setBinLabel(8, " 8 (-)", 1);
360  csctfbx_H->setBinLabel(9, " 9 (-)", 1);
361  csctfbx_H->setBinLabel(10, "10 (-)", 1);
362  csctfbx_H->setBinLabel(11, "11 (-)", 1);
363  csctfbx_H->setBinLabel(12, "12 (-)", 1);
364 
365  csctfbx_H->setAxisTitle("CSCTF BX", 2);
366  csctfbx_H->setBinLabel(1, "-3", 2);
367  csctfbx_H->setBinLabel(2, "-2", 2);
368  csctfbx_H->setBinLabel(3, "-1", 2);
369  csctfbx_H->setBinLabel(4, "-0", 2);
370  csctfbx_H->setBinLabel(5, " 1", 2);
371  csctfbx_H->setBinLabel(6, " 2", 2);
372  csctfbx_H->setBinLabel(7, " 3", 2);
373 
374  // Number of Tracks Stubs
375  cscTrackStubNumbers = ibooker.book1D("CSCTF_TrackStubs", "Number of Stubs in CSCTF Tracks", 5, 0, 5);
376  cscTrackStubNumbers->setBinLabel(1, "0", 1);
377  cscTrackStubNumbers->setBinLabel(2, "1", 1);
378  cscTrackStubNumbers->setBinLabel(3, "2", 1);
379  cscTrackStubNumbers->setBinLabel(4, "3", 1);
380  cscTrackStubNumbers->setBinLabel(5, "4", 1);
381 
382  // Number of Tracks
383  csctfntrack = ibooker.book1D("CSCTF_ntrack", "Number of CSCTracks found per event", 5, 0, 5);
384  csctfntrack->setBinLabel(1, "0", 1);
385  csctfntrack->setBinLabel(2, "1", 1);
386  csctfntrack->setBinLabel(3, "2", 1);
387  csctfntrack->setBinLabel(4, "3", 1);
388  csctfntrack->setBinLabel(5, "4", 1);
389  //}
390 
391  char hname[200];
392  char htitle[200];
393 
394  for (int i = 0; i < 12; i++) {
395  sprintf(hname, "DTstubsTimeTrackMenTimeArrival_%d", i + 1);
396  sprintf(htitle, "T_{track} - T_{DT stub} sector %d", i + 1);
397 
398  DTstubsTimeTrackMenTimeArrival[i] = ibooker.book2D(hname, htitle, 7, -3, 3, 2, 1, 3);
399  DTstubsTimeTrackMenTimeArrival[i]->getTH2F()->SetMinimum(0);
400 
401  // axis makeup
402  DTstubsTimeTrackMenTimeArrival[i]->setAxisTitle("bx_{CSC track} - bx_{DT stub}", 1);
404 
412 
415  }
416 
417  cscWireStripOverflow = ibooker.book2D("CSC_WireStripOverflow", "CSC WireStrip Overflow", 36, 1, 37, 18, 0, 18);
418 
419  // NEW: CSC EVENT LCT PLOTS
420  csctflcts = ibooker.book2D("CSCTF_LCT", "CSCTF LCTs", 12, 1, 13, 18, 0, 18);
421  csctflcts->setAxisTitle("CSCTF LCT BX", 1);
422  csctflcts->setBinLabel(1, "1", 1);
423  csctflcts->setBinLabel(2, "2", 1);
424  csctflcts->setBinLabel(3, "3", 1);
425  csctflcts->setBinLabel(4, "4", 1);
426  csctflcts->setBinLabel(5, "5", 1);
427  csctflcts->setBinLabel(6, "6", 1);
428  csctflcts->setBinLabel(7, "7", 1);
429  csctflcts->setBinLabel(8, "8", 1);
430  csctflcts->setBinLabel(9, "9", 1);
431  csctflcts->setBinLabel(10, "10", 1);
432  csctflcts->setBinLabel(11, "11", 1);
433  csctflcts->setBinLabel(12, "12", 1);
434 
435  int ihist = 0;
436  for (int iEndcap = 0; iEndcap < 2; iEndcap++) {
437  for (int iStation = 1; iStation < 5; iStation++) {
438  for (int iRing = 1; iRing < 4; iRing++) {
439  if (iStation != 1 && iRing > 2)
440  continue;
441  TString signEndcap = "+";
442  if (iEndcap == 0)
443  signEndcap = "-";
444 
445  char lcttitle[200];
446  snprintf(lcttitle, 200, "ME%s%d/%d", signEndcap.Data(), iStation, iRing);
447  if (ihist <= 8) {
448  csctflcts->setBinLabel(9 - ihist, lcttitle, 2);
449  cscWireStripOverflow->setBinLabel(9 - ihist, lcttitle, 2);
450  } else {
451  csctflcts->setBinLabel(ihist + 1, lcttitle, 2);
452  cscWireStripOverflow->setBinLabel(ihist + 1, lcttitle, 2);
453  }
454 
455  ihist++;
456  }
457  }
458  }
459 
460  // plots for ME1/1 chambers
461  me11_lctStrip = ibooker.book1D("CSC_ME11_LCT_Strip", "CSC_ME11_LCT_Strip", 223, 0, 223);
462  me11_lctStrip->setAxisTitle("Cathode HalfStrip, ME1/1", 1);
463 
464  me11_lctWire = ibooker.book1D("CSC_ME11_LCT_Wire", "CSC_ME11_LCT_Wire", 112, 0, 112);
465  me11_lctWire->setAxisTitle("Anode Wiregroup, ME1/1", 1);
466 
467  me11_lctLocalPhi = ibooker.book1D("CSC_ME11_LCT_LocalPhi", "CSC_ME11_LCT_LocalPhi", 200, 0, 1024);
468  me11_lctLocalPhi->setAxisTitle("LCT Local #it{#phi}, ME1/1", 1);
469 
470  me11_lctPackedPhi = ibooker.book1D("CSC_ME11_LCT_PackedPhi", "CSC_ME11_LCT_PackedPhi", 200, 0, 4096);
471  me11_lctPackedPhi->setAxisTitle("LCT Packed #it{#phi}, ME1/1", 1);
472 
473  me11_lctGblPhi = ibooker.book1D("CSC_ME11_LCT_GblPhi", "CSC_ME11_LCT_GblPhi", 200, 0, 2 * M_PI);
474  me11_lctGblPhi->setAxisTitle("LCT Global #it{#phi}, ME1/1", 1);
475 
476  me11_lctGblEta = ibooker.book1D("CSC_ME11_LCT_GblEta", "CSC_ME11_LCT_GblEta", 50, 0.9, 2.5);
477  me11_lctGblEta->setAxisTitle("LCT Global #eta, ME1/1", 1);
478 
479  // plots for ME4/2 chambers
480  me42_lctGblPhi = ibooker.book1D("CSC_ME42_LCT_GblPhi", "CSC_ME42_LCT_GblPhi", 200, 0, 2 * M_PI);
481  me42_lctGblPhi->setAxisTitle("LCT Global #it{#phi}, ME4/2", 1);
482 
483  me42_lctGblEta = ibooker.book1D("CSC_ME42_LCT_GblEta", "CSC_ME42_LCT_GblEta", 50, 0.9, 2.5);
484  me42_lctGblEta->setAxisTitle("LCT Global #eta, ME4/2", 1);
485 
486  //
487  csc_strip_MEplus11 = ibooker.book2D("csc_strip_MEplus11", "csc_strip_MEplus11", 36, 1, 37, 240, 0, 240);
488  csc_strip_MEplus11->setAxisTitle("Cathode HalfStrip", 2);
489  csc_strip_MEplus11->setAxisTitle("ME+1/1", 1);
490  csc_strip_MEplus12 = ibooker.book2D("csc_strip_MEplus12", "csc_strip_MEplus12", 36, 1, 37, 240, 0, 240);
491  csc_strip_MEplus12->setAxisTitle("Cathode HalfStrip", 2);
492  csc_strip_MEplus12->setAxisTitle("ME+1/2", 1);
493  csc_strip_MEplus13 = ibooker.book2D("csc_strip_MEplus13", "csc_strip_MEplus13", 36, 1, 37, 240, 0, 240);
494  csc_strip_MEplus13->setAxisTitle("Cathode HalfStrip", 2);
495  csc_strip_MEplus13->setAxisTitle("ME+1/3", 1);
496  csc_strip_MEplus21 = ibooker.book2D("csc_strip_MEplus21", "csc_strip_MEplus21", 18, 1, 19, 240, 0, 240);
497  csc_strip_MEplus21->setAxisTitle("Cathode HalfStrip", 2);
498  csc_strip_MEplus21->setAxisTitle("ME+2/1", 1);
499  csc_strip_MEplus22 = ibooker.book2D("csc_strip_MEplus22", "csc_strip_MEplus22", 36, 1, 37, 240, 0, 240);
500  csc_strip_MEplus22->setAxisTitle("Cathode HalfStrip", 2);
501  csc_strip_MEplus22->setAxisTitle("ME+2/2", 1);
502  csc_strip_MEplus31 = ibooker.book2D("csc_strip_MEplus31", "csc_strip_MEplus31", 18, 1, 19, 240, 0, 240);
503  csc_strip_MEplus31->setAxisTitle("Cathode HalfStrip", 2);
504  csc_strip_MEplus31->setAxisTitle("ME+3/1", 1);
505  csc_strip_MEplus32 = ibooker.book2D("csc_strip_MEplus32", "csc_strip_MEplus32", 36, 1, 37, 240, 0, 240);
506  csc_strip_MEplus32->setAxisTitle("Cathode HalfStrip", 2);
507  csc_strip_MEplus32->setAxisTitle("ME+3/2", 1);
508  csc_strip_MEplus41 = ibooker.book2D("csc_strip_MEplus41", "csc_strip_MEplus41", 18, 1, 19, 240, 0, 240);
509  csc_strip_MEplus41->setAxisTitle("Cathode HalfStrip", 2);
510  csc_strip_MEplus41->setAxisTitle("ME+4/1", 1);
511  csc_strip_MEplus42 = ibooker.book2D("csc_strip_MEplus42", "csc_strip_MEplus42", 36, 1, 37, 240, 0, 240);
512  csc_strip_MEplus42->setAxisTitle("Cathode HalfStrip", 2);
513  csc_strip_MEplus42->setAxisTitle("ME+4/2", 1);
514 
515  csc_strip_MEminus11 = ibooker.book2D("csc_strip_MEminus11", "csc_strip_MEminus11", 36, 1, 37, 240, 0, 240);
516  csc_strip_MEminus11->setAxisTitle("Cathode HalfStrip", 2);
517  csc_strip_MEminus11->setAxisTitle("ME-1/1", 1);
518  csc_strip_MEminus12 = ibooker.book2D("csc_strip_MEminus12", "csc_strip_MEminus12", 36, 1, 37, 240, 0, 240);
519  csc_strip_MEminus12->setAxisTitle("Cathode HalfStrip", 2);
520  csc_strip_MEminus12->setAxisTitle("ME-1/2", 1);
521  csc_strip_MEminus13 = ibooker.book2D("csc_strip_MEminus13", "csc_strip_MEminus13", 36, 1, 37, 240, 0, 240);
522  csc_strip_MEminus13->setAxisTitle("Cathode HalfStrip", 2);
523  csc_strip_MEminus13->setAxisTitle("ME-1/3", 1);
524  csc_strip_MEminus21 = ibooker.book2D("csc_strip_MEminus21", "csc_strip_MEminus21", 18, 1, 19, 240, 0, 240);
525  csc_strip_MEminus21->setAxisTitle("Cathode HalfStrip", 2);
526  csc_strip_MEminus21->setAxisTitle("ME-2/1", 1);
527  csc_strip_MEminus22 = ibooker.book2D("csc_strip_MEminus22", "csc_strip_MEminus22", 36, 1, 37, 240, 0, 240);
528  csc_strip_MEminus22->setAxisTitle("Cathode HalfStrip", 2);
529  csc_strip_MEminus22->setAxisTitle("ME-2/2", 1);
530  csc_strip_MEminus31 = ibooker.book2D("csc_strip_MEminus31", "csc_strip_MEminus31", 18, 1, 19, 240, 0, 240);
531  csc_strip_MEminus31->setAxisTitle("Cathode HalfStrip", 2);
532  csc_strip_MEminus31->setAxisTitle("ME-3/1", 1);
533  csc_strip_MEminus32 = ibooker.book2D("csc_strip_MEminus32", "csc_strip_MEminus32", 36, 1, 37, 240, 0, 240);
534  csc_strip_MEminus32->setAxisTitle("Cathode HalfStrip", 2);
535  csc_strip_MEminus32->setAxisTitle("ME-3/2", 1);
536  csc_strip_MEminus41 = ibooker.book2D("csc_strip_MEminus41", "csc_strip_MEminus41", 18, 1, 19, 240, 0, 240);
537  csc_strip_MEminus41->setAxisTitle("Cathode HalfStrip", 2);
538  csc_strip_MEminus41->setAxisTitle("ME-4/1", 1);
539  csc_strip_MEminus42 = ibooker.book2D("csc_strip_MEminus42", "csc_strip_MEminus42", 36, 1, 37, 240, 0, 240);
540  csc_strip_MEminus42->setAxisTitle("Cathode HalfStrip", 2);
541  csc_strip_MEminus42->setAxisTitle("ME-4/2", 1);
542 
543  csc_wire_MEplus11 = ibooker.book2D("csc_wire_MEplus11", "csc_wire_MEplus11", 36, 1, 37, 120, 0, 120);
544  csc_wire_MEplus11->setAxisTitle("Anode Wiregroup", 2);
545  csc_wire_MEplus11->setAxisTitle("ME+1/1", 1);
546  csc_wire_MEplus12 = ibooker.book2D("csc_wire_MEplus12", "csc_wire_MEplus12", 36, 1, 37, 120, 0, 120);
547  csc_wire_MEplus12->setAxisTitle("Anode Wiregroup", 2);
548  csc_wire_MEplus12->setAxisTitle("ME+1/2", 1);
549  csc_wire_MEplus13 = ibooker.book2D("csc_wire_MEplus13", "csc_wire_MEplus13", 36, 1, 37, 120, 0, 120);
550  csc_wire_MEplus13->setAxisTitle("Anode Wiregroup", 2);
551  csc_wire_MEplus13->setAxisTitle("ME+1/3", 1);
552  csc_wire_MEplus21 = ibooker.book2D("csc_wire_MEplus21", "csc_wire_MEplus21", 18, 1, 19, 120, 0, 120);
553  csc_wire_MEplus21->setAxisTitle("Anode Wiregroup", 2);
554  csc_wire_MEplus21->setAxisTitle("ME+2/1", 1);
555  csc_wire_MEplus22 = ibooker.book2D("csc_wire_MEplus22", "csc_wire_MEplus22", 36, 1, 37, 120, 0, 120);
556  csc_wire_MEplus22->setAxisTitle("Anode Wiregroup", 2);
557  csc_wire_MEplus22->setAxisTitle("ME+2/2", 1);
558  csc_wire_MEplus31 = ibooker.book2D("csc_wire_MEplus31", "csc_wire_MEplus31", 18, 1, 19, 120, 0, 120);
559  csc_wire_MEplus31->setAxisTitle("Anode Wiregroup", 2);
560  csc_wire_MEplus31->setAxisTitle("ME+3/1", 1);
561  csc_wire_MEplus32 = ibooker.book2D("csc_wire_MEplus32", "csc_wire_MEplus32", 36, 1, 37, 120, 0, 120);
562  csc_wire_MEplus32->setAxisTitle("Anode Wiregroup", 2);
563  csc_wire_MEplus32->setAxisTitle("ME+3/2", 1);
564  csc_wire_MEplus41 = ibooker.book2D("csc_wire_MEplus41", "csc_wire_MEplus41", 18, 1, 19, 120, 0, 120);
565  csc_wire_MEplus41->setAxisTitle("Anode Wiregroup", 2);
566  csc_wire_MEplus41->setAxisTitle("ME+4/1", 1);
567  csc_wire_MEplus42 = ibooker.book2D("csc_wire_MEplus42", "csc_wire_MEplus42", 36, 1, 37, 120, 0, 120);
568  csc_wire_MEplus42->setAxisTitle("Anode Wiregroup", 2);
569  csc_wire_MEplus42->setAxisTitle("ME+4/2", 1);
570 
571  csc_wire_MEminus11 = ibooker.book2D("csc_wire_MEminus11", "csc_wire_MEminus11", 36, 1, 37, 120, 0, 120);
572  csc_wire_MEminus11->setAxisTitle("Anode Wiregroup", 2);
573  csc_wire_MEminus11->setAxisTitle("ME-1/1", 1);
574  csc_wire_MEminus12 = ibooker.book2D("csc_wire_MEminus12", "csc_wire_MEminus12", 36, 1, 37, 120, 0, 120);
575  csc_wire_MEminus12->setAxisTitle("Anode Wiregroup", 2);
576  csc_wire_MEminus12->setAxisTitle("ME-1/2", 1);
577  csc_wire_MEminus13 = ibooker.book2D("csc_wire_MEminus13", "csc_wire_MEminus13", 36, 1, 37, 120, 0, 120);
578  csc_wire_MEminus13->setAxisTitle("Anode Wiregroup", 2);
579  csc_wire_MEminus13->setAxisTitle("ME-1/3", 1);
580  csc_wire_MEminus21 = ibooker.book2D("csc_wire_MEminus21", "csc_wire_MEminus21", 18, 1, 19, 120, 0, 120);
581  csc_wire_MEminus21->setAxisTitle("Anode Wiregroup", 2);
582  csc_wire_MEminus21->setAxisTitle("ME-2/1", 1);
583  csc_wire_MEminus22 = ibooker.book2D("csc_wire_MEminus22", "csc_wire_MEminus22", 36, 1, 37, 120, 0, 120);
584  csc_wire_MEminus22->setAxisTitle("Anode Wiregroup", 2);
585  csc_wire_MEminus22->setAxisTitle("ME-2/2", 1);
586  csc_wire_MEminus31 = ibooker.book2D("csc_wire_MEminus31", "csc_wire_MEminus31", 18, 1, 19, 120, 0, 120);
587  csc_wire_MEminus31->setAxisTitle("Anode Wiregroup", 2);
588  csc_wire_MEminus31->setAxisTitle("ME-3/1", 1);
589  csc_wire_MEminus32 = ibooker.book2D("csc_wire_MEminus32", "csc_wire_MEminus32", 36, 1, 37, 120, 0, 120);
590  csc_wire_MEminus32->setAxisTitle("Anode Wiregroup", 2);
591  csc_wire_MEminus32->setAxisTitle("ME-3/2", 1);
592  csc_wire_MEminus41 = ibooker.book2D("csc_wire_MEminus41", "csc_wire_MEminus41", 18, 1, 19, 120, 0, 120);
593  csc_wire_MEminus41->setAxisTitle("Anode Wiregroup", 2);
594  csc_wire_MEminus41->setAxisTitle("ME-4/1", 1);
595  csc_wire_MEminus42 = ibooker.book2D("csc_wire_MEminus42", "csc_wire_MEminus42", 36, 1, 37, 120, 0, 120);
596  csc_wire_MEminus42->setAxisTitle("Anode Wiregroup", 2);
597  csc_wire_MEminus42->setAxisTitle("ME-4/2", 1);
598 
599  for (int cscid = 1; cscid < 37; cscid++) {
600  char bxtitle[100];
601  sprintf(bxtitle, "%d", cscid);
602 
603  cscWireStripOverflow->setBinLabel(cscid, bxtitle, 1);
604  csc_strip_MEplus11->setBinLabel(cscid, bxtitle, 1);
605  csc_strip_MEplus12->setBinLabel(cscid, bxtitle, 1);
606  csc_strip_MEplus13->setBinLabel(cscid, bxtitle, 1);
607  csc_strip_MEplus22->setBinLabel(cscid, bxtitle, 1);
608  csc_strip_MEplus32->setBinLabel(cscid, bxtitle, 1);
609  csc_strip_MEplus42->setBinLabel(cscid, bxtitle, 1);
610 
611  csc_strip_MEminus11->setBinLabel(cscid, bxtitle, 1);
612  csc_strip_MEminus12->setBinLabel(cscid, bxtitle, 1);
613  csc_strip_MEminus13->setBinLabel(cscid, bxtitle, 1);
614  csc_strip_MEminus22->setBinLabel(cscid, bxtitle, 1);
615  csc_strip_MEminus32->setBinLabel(cscid, bxtitle, 1);
616  csc_strip_MEminus42->setBinLabel(cscid, bxtitle, 1);
617 
618  csc_wire_MEplus11->setBinLabel(cscid, bxtitle, 1);
619  csc_wire_MEplus12->setBinLabel(cscid, bxtitle, 1);
620  csc_wire_MEplus13->setBinLabel(cscid, bxtitle, 1);
621  csc_wire_MEplus22->setBinLabel(cscid, bxtitle, 1);
622  csc_wire_MEplus32->setBinLabel(cscid, bxtitle, 1);
623  csc_wire_MEplus42->setBinLabel(cscid, bxtitle, 1);
624 
625  csc_wire_MEminus11->setBinLabel(cscid, bxtitle, 1);
626  csc_wire_MEminus12->setBinLabel(cscid, bxtitle, 1);
627  csc_wire_MEminus13->setBinLabel(cscid, bxtitle, 1);
628  csc_wire_MEminus22->setBinLabel(cscid, bxtitle, 1);
629  csc_wire_MEminus32->setBinLabel(cscid, bxtitle, 1);
630  csc_wire_MEminus42->setBinLabel(cscid, bxtitle, 1);
631  }
632 
633  for (int cscid = 1; cscid < 19; cscid++) {
634  char bxtitle[100];
635  sprintf(bxtitle, "%d", cscid);
636 
637  csc_strip_MEplus21->setBinLabel(cscid, bxtitle, 1);
638  csc_strip_MEplus31->setBinLabel(cscid, bxtitle, 1);
639  csc_strip_MEplus41->setBinLabel(cscid, bxtitle, 1);
640 
641  csc_strip_MEminus21->setBinLabel(cscid, bxtitle, 1);
642  csc_strip_MEminus31->setBinLabel(cscid, bxtitle, 1);
643  csc_strip_MEminus41->setBinLabel(cscid, bxtitle, 1);
644 
645  csc_wire_MEplus21->setBinLabel(cscid, bxtitle, 1);
646  csc_wire_MEplus31->setBinLabel(cscid, bxtitle, 1);
647  csc_wire_MEplus41->setBinLabel(cscid, bxtitle, 1);
648 
649  csc_wire_MEminus21->setBinLabel(cscid, bxtitle, 1);
650  csc_wire_MEminus31->setBinLabel(cscid, bxtitle, 1);
651  csc_wire_MEminus41->setBinLabel(cscid, bxtitle, 1);
652  }
653 }
654 
655 void L1TCSCTF::analyze(const Event& e, const EventSetup& c) {
657  c.get<L1MuTriggerPtScaleRcd>().cacheIdentifier() != m_ptScaleCacheID) {
658  ts = &c.getData(l1muTscalesToken_);
659  tpts = &c.getData(ptscalesToken_);
660 
661  m_scalesCacheID = c.get<L1MuTriggerScalesRcd>().cacheIdentifier();
662  m_ptScaleCacheID = c.get<L1MuTriggerPtScaleRcd>().cacheIdentifier();
663 
664  edm::LogInfo("L1TCSCTF") << "Changing triggerscales and triggerptscales...";
665  }
666 
667  int NumCSCTfTracksRep = 0;
668  nev_++;
669  if (verbose_)
670  edm::LogInfo("DataNotFound") << "L1TCSCTF: analyze...." << endl;
671 
673  if (gmtProducer.label() != "null") { // GMT block
674  e.getByToken(gmtProducerToken_, pCollection);
675  if (!pCollection.isValid()) {
676  edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label "; // << csctfSource_.label() ;
677  return;
678  }
679 
680  L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
681  vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
682  vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
683 
684  // Look if the readout window contains one (and only one CSC cands)
685  // to make it simpler I reject events with more than a CSC cand in the
686  // same readout window
687 
688  // count non-empty candidates in this bx
689  int bxWindow = 0;
690  int nCands = 0;
691 
692  for (RRItr = gmt_records.begin(); RRItr != gmt_records.end(); RRItr++) {
693  bxWindow++;
694 
695  // get the csc candidates
696  vector<L1MuRegionalCand> INPCands = RRItr->getCSCCands();
697  vector<L1MuRegionalCand>::const_iterator INPItr;
698 
699  BxInEvent_ = 0;
700  isCSCcand_ = false;
701  int nCandsBx = 0;
702 
703  for (INPItr = INPCands.begin(); INPItr != INPCands.end(); ++INPItr) {
704  if (!INPItr->empty()) {
705  nCandsBx++;
706  nCands++;
707  BxInEvent_ = RRItr->getBxInEvent();
708  if (verbose_)
709  edm::LogInfo("DataNotFound") << "cand " << nCandsBx << " -> assigned CSCTF bx: " << INPItr->bx() << endl;
710  }
711  }
712  if (verbose_)
713  if (nCandsBx)
714  edm::LogInfo("DataNotFound") << nCandsBx << " cands in bx: " << BxInEvent_ << endl;
715  }
716 
717  if (nCands != 1)
718  return;
719  else
720  isCSCcand_ = true;
721  if (verbose_)
722  edm::LogInfo("DataNotFound") << "bxWindow: " << bxWindow << endl;
723 
724  int ncsctftrack = 0;
725  if (verbose_) {
726  edm::LogInfo("DataNotFound") << "\tCSCTFCand ntrack " << ncsctftrack << endl;
727  }
728  } // end of GMT block
729 
730  L1ABXN = -999;
731  if (statusProducer.label() != "null") {
733  e.getByToken(statusToken_, status);
734  bool integrity = status->first, se = false, sm = false, bx = false, af = false, fmm = false;
735  int nStat = 0;
736 
737  for (std::vector<L1CSCSPStatusDigi>::const_iterator stat = status->second.begin(); stat != status->second.end();
738  stat++) {
739  se |= stat->SEs() & 0xFFF;
740  sm |= stat->SMs() & 0xFFF;
741  bx |= stat->BXs() & 0xFFF;
742  af |= stat->AFs() & 0xFFF;
743  fmm |= stat->FMM() != 8;
744 
745  int ise = stat->SEs() & 0xFFF;
746  int ism = stat->SMs() & 0xFFF;
747  int ibx = stat->BXs() & 0xFFF;
748  int iaf = stat->AFs() & 0xFFF;
749  int ifmm = stat->FMM();
750  int slot = stat->slot();
751 
752  for (int j = 0; j < 15; j++) {
753  int link = j + 1;
754  int mpc_id = 0;
755  int sp_num = 0;
756  if (slot >= 6 && slot <= 11)
757  sp_num = slot - 5;
758  if (slot >= 16 && slot <= 21)
759  sp_num = slot - 9;
760 
761  if (sp_num == 1) {
762  if (link >= 1 && link <= 3)
763  mpc_id = 2;
764  else if (link >= 4 && link <= 6)
765  mpc_id = 3;
766  else if (link >= 7 && link <= 9)
767  mpc_id = 13;
768  else if (link >= 10 && link <= 12)
769  mpc_id = 19;
770  else if (link >= 13 && link <= 15)
771  mpc_id = 25;
772  } else if (sp_num == 2) {
773  if (link >= 1 && link <= 3)
774  mpc_id = 4;
775  else if (link >= 4 && link <= 6)
776  mpc_id = 5;
777  else if (link >= 7 && link <= 9)
778  mpc_id = 14;
779  else if (link >= 10 && link <= 12)
780  mpc_id = 20;
781  else if (link >= 13 && link <= 15)
782  mpc_id = 26;
783  } else if (sp_num == 3) {
784  if (link >= 1 && link <= 3)
785  mpc_id = 6;
786  else if (link >= 4 && link <= 6)
787  mpc_id = 7;
788  else if (link >= 7 && link <= 9)
789  mpc_id = 15;
790  else if (link >= 10 && link <= 12)
791  mpc_id = 21;
792  else if (link >= 13 && link <= 15)
793  mpc_id = 27;
794  } else if (sp_num == 4) {
795  if (link >= 1 && link <= 3)
796  mpc_id = 8;
797  else if (link >= 4 && link <= 6)
798  mpc_id = 9;
799  else if (link >= 7 && link <= 9)
800  mpc_id = 16;
801  else if (link >= 10 && link <= 12)
802  mpc_id = 22;
803  else if (link >= 13 && link <= 15)
804  mpc_id = 28;
805  } else if (sp_num == 5) {
806  if (link >= 1 && link <= 3)
807  mpc_id = 10;
808  else if (link >= 4 && link <= 6)
809  mpc_id = 11;
810  else if (link >= 7 && link <= 9)
811  mpc_id = 17;
812  else if (link >= 10 && link <= 12)
813  mpc_id = 23;
814  else if (link >= 13 && link <= 15)
815  mpc_id = 29;
816  } else if (sp_num == 6) {
817  if (link >= 1 && link <= 3)
818  mpc_id = 12;
819  else if (link >= 4 && link <= 6)
820  mpc_id = 1;
821  else if (link >= 7 && link <= 9)
822  mpc_id = 18;
823  else if (link >= 10 && link <= 12)
824  mpc_id = 24;
825  else if (link >= 13 && link <= 15)
826  mpc_id = 30;
827  } else if (sp_num == 7) {
828  if (link >= 1 && link <= 3)
829  mpc_id = 32;
830  else if (link >= 4 && link <= 6)
831  mpc_id = 33;
832  else if (link >= 7 && link <= 9)
833  mpc_id = 43;
834  else if (link >= 10 && link <= 12)
835  mpc_id = 49;
836  else if (link >= 13 && link <= 15)
837  mpc_id = 55;
838  } else if (sp_num == 8) {
839  if (link >= 1 && link <= 3)
840  mpc_id = 34;
841  else if (link >= 4 && link <= 6)
842  mpc_id = 35;
843  else if (link >= 7 && link <= 9)
844  mpc_id = 44;
845  else if (link >= 10 && link <= 12)
846  mpc_id = 50;
847  else if (link >= 13 && link <= 15)
848  mpc_id = 56;
849  } else if (sp_num == 9) {
850  if (link >= 1 && link <= 3)
851  mpc_id = 36;
852  else if (link >= 4 && link <= 6)
853  mpc_id = 37;
854  else if (link >= 7 && link <= 9)
855  mpc_id = 45;
856  else if (link >= 10 && link <= 12)
857  mpc_id = 51;
858  else if (link >= 13 && link <= 15)
859  mpc_id = 57;
860  } else if (sp_num == 10) {
861  if (link >= 1 && link <= 3)
862  mpc_id = 38;
863  else if (link >= 4 && link <= 6)
864  mpc_id = 39;
865  else if (link >= 7 && link <= 9)
866  mpc_id = 46;
867  else if (link >= 10 && link <= 12)
868  mpc_id = 52;
869  else if (link >= 13 && link <= 15)
870  mpc_id = 58;
871  } else if (sp_num == 11) {
872  if (link >= 1 && link <= 3)
873  mpc_id = 40;
874  else if (link >= 4 && link <= 6)
875  mpc_id = 41;
876  else if (link >= 7 && link <= 9)
877  mpc_id = 47;
878  else if (link >= 10 && link <= 12)
879  mpc_id = 53;
880  else if (link >= 13 && link <= 15)
881  mpc_id = 59;
882  } else if (sp_num == 12) {
883  if (link >= 1 && link <= 3)
884  mpc_id = 42;
885  else if (link >= 4 && link <= 6)
886  mpc_id = 31;
887  else if (link >= 7 && link <= 9)
888  mpc_id = 48;
889  else if (link >= 10 && link <= 12)
890  mpc_id = 54;
891  else if (link >= 13 && link <= 15)
892  mpc_id = 60;
893  }
894 
895  if (integrity)
896  csctferrors_mpc->Fill(0.5, mpc_id);
897  if ((ise >> j) & 0x1)
898  csctferrors_mpc->Fill(1.5, mpc_id);
899  if ((ism >> j) & 0x1)
900  csctferrors_mpc->Fill(2.5, mpc_id);
901  if ((ibx >> j) & 0x1)
902  csctferrors_mpc->Fill(3.5, mpc_id);
903  if ((iaf >> j) & 0x1)
904  csctferrors_mpc->Fill(4.5, mpc_id);
905  if (ifmm != 8)
906  csctferrors_mpc->Fill(5.5, mpc_id);
907  }
908 
909  if (stat->VPs() != 0) {
910  L1ABXN += stat->BXN();
911  nStat++;
912  }
913  }
914  // compute the average
915  if (nStat != 0)
916  L1ABXN /= nStat;
917  if (integrity)
918  csctferrors->Fill(0.5);
919  if (se)
920  csctferrors->Fill(1.5);
921  if (sm)
922  csctferrors->Fill(2.5);
923  if (bx)
924  csctferrors->Fill(3.5);
925  if (af)
926  csctferrors->Fill(4.5);
927  if (fmm)
928  csctferrors->Fill(5.5);
929  }
930 
931  if (lctProducer.label() != "null") {
932  //edm::ESHandle<CSCGeometry> pDD;
933  //c.get<MuonGeometryRecord>().get(pDD);
934 
936  e.getByToken(corrlctsToken_, corrlcts);
937 
939  csc != corrlcts.product()->end();
940  csc++) {
941  CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
942  for (CSCCorrelatedLCTDigiCollection::const_iterator lct = range1.first; lct != range1.second; lct++) {
943  int endcap = (*csc).first.endcap() - 1;
944  int station = (*csc).first.station() - 1;
945  int sector = (*csc).first.triggerSector() - 1;
946  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
947  int ring = (*csc).first.ring();
948  int cscId = (*csc).first.triggerCscId() - 1;
949  int fpga = (subSector ? subSector - 1 : station + 1);
950  int strip = lct->getStrip();
951  int keyWire = lct->getKeyWG();
952  int bx = lct->getBX();
953 
954  int endcapAssignment = 1;
955  int shift = 1;
956  float sectorArg = sector;
957  //float sectorArg = j;
958 
959  if (endcap == 1) {
960  endcapAssignment = -1;
961  shift = 2;
962  //sectorArg = sector - 6;
963  }
964 
965  int signedStation = (station + shift) * endcapAssignment;
966  if ((station == 0) && (endcap == 0))
967  signedStation = subSector - 1;
968  if ((station == 0) && (endcap == 1))
969  signedStation = (-1) * subSector;
970 
971  float chamberArg1 = cscId * 0.1 + sectorArg;
972  //float chamberArg1 = i*0.1 + sectorArg;
973  //std::cout << "First" << i << " " << sectorArg << " " << chamberArg1 << std::endl;
974 
975  float chamberArg11 = chamberArg1;
976  if (sectorArg == 1)
977  chamberArg1 = chamberArg11 - 0.1;
978  if (sectorArg == 2)
979  chamberArg1 = chamberArg11 - 0.2;
980  if (sectorArg == 3)
981  chamberArg1 = chamberArg11 - 0.3;
982  if (sectorArg == 4)
983  chamberArg1 = chamberArg11 - 0.4;
984  if (sectorArg == 5)
985  chamberArg1 = chamberArg11 - 0.5;
986 
987  //std::cout << "cscId, station, sector, endcap, sectorArg, chamber Arg: " << cscId << ", " << station << ", " <<sector << ", " << endcap << ", " << chamberArg1 << ", " << signedStation << std::endl;
988 
989  csctfChamberOccupancies->Fill(chamberArg1, signedStation);
990  //int bunchX = ( (lct->getBX()) - 6 );
991 
992  //int timingSectorArg = 3*(sector) + (lct->getMPCLink());
993  //if( endcap == 1) timingSectorArg = 3*(sector + 6) + (lct->getMPCLink());
994  //std::cout << "Sector, MPCLink, TSA, endcap: " << sector << ", " << lct->getMPCLink() << ", " << timingSectorArg << ", " << endcap << std::endl;
995 
996  //csctfbx->Fill(timingSectorArg, bunchX );
997  //std::cout << "LCT'S, encap: " << endcap << ", station: " << station << ", sector: " << sector << ", subSector: " << subSector << ", cscId: " << cscId << std:: endl;
998  //End JAG
999 
1000  // Check if Det Id is within pysical range:
1001  if (endcap < 0 || endcap > 1 || sector < 0 || sector > 6 || station < 0 || station > 3 || cscId < 0 ||
1002  cscId > 8 || fpga < 0 || fpga > 4) {
1003  edm::LogError("L1CSCTF: CSC TP are out of range: ")
1004  << " endcap: " << (endcap + 1) << " station: " << (station + 1) << " sector: " << (sector + 1)
1005  << " subSector: " << subSector << " fpga: " << fpga << " cscId: " << (cscId + 1);
1006  continue;
1007  }
1008 
1009  int EndCapLUT = 1;
1010  //if(endcap==0) EndCapLUT=1; // ME+
1011  if (endcap == 1)
1012  EndCapLUT = 0; // ME-
1013 
1014  lclphidat lclPhi;
1015  try {
1016  lclPhi = srLUTs_[fpga][EndCapLUT][sector]->localPhi(
1017  lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend(), gangedME11a_);
1018  } catch (cms::Exception&) {
1019  bzero(&lclPhi, sizeof(lclPhi));
1020  }
1021 
1022  gblphidat gblPhi;
1023  try {
1024  gblPhi =
1025  srLUTs_[fpga][EndCapLUT][sector]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId + 1, gangedME11a_);
1026  } catch (cms::Exception&) {
1027  bzero(&gblPhi, sizeof(gblPhi));
1028  }
1029 
1030  gbletadat gblEta;
1031  try {
1032  gblEta = srLUTs_[fpga][EndCapLUT][sector]->globalEtaME(
1033  lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId + 1, gangedME11a_);
1034  } catch (cms::Exception&) {
1035  bzero(&gblEta, sizeof(gblEta));
1036  }
1037 
1038  //TrackStub
1039  csctf::TrackStub theStub((*lct), (*csc).first);
1040  theStub.setPhiPacked(gblPhi.global_phi);
1041  theStub.setEtaPacked(gblEta.global_eta);
1042 
1043  float etaG = theStub.etaValue();
1044  float phiG = fmod(theStub.phiValue() + 15.0 * M_PI / 180 + (sector)*60.0 * M_PI / 180, 2. * M_PI);
1045 
1046  //BX plots
1047  // endcap==1: minus side; endcap==0: plus side
1048  // station=0,1,2,3; ring=1,2,3;
1049  if (endcap == 1) {
1050  if (station == 0) {
1051  if (ring == 1)
1052  csctflcts->Fill(bx, 8.5);
1053  else if (ring == 2)
1054  csctflcts->Fill(bx, 7.5);
1055  else
1056  csctflcts->Fill(bx, 6.5);
1057  } else if (station == 1) {
1058  if (ring == 1)
1059  csctflcts->Fill(bx, 5.5);
1060  else
1061  csctflcts->Fill(bx, 4.5);
1062  } else if (station == 2) {
1063  if (ring == 1)
1064  csctflcts->Fill(bx, 3.5);
1065  else
1066  csctflcts->Fill(bx, 2.5);
1067  } else if (station == 3) {
1068  if (ring == 1)
1069  csctflcts->Fill(bx, 1.5);
1070  else
1071  csctflcts->Fill(bx, 0.5);
1072  }
1073 
1074  } else {
1075  if (station == 0) {
1076  if (ring == 1)
1077  csctflcts->Fill(bx, 9.5);
1078  else if (ring == 2)
1079  csctflcts->Fill(bx, 10.5);
1080  else
1081  csctflcts->Fill(bx, 11.5);
1082  } else if (station == 1) {
1083  if (ring == 1)
1084  csctflcts->Fill(bx, 12.5);
1085  else
1086  csctflcts->Fill(bx, 13.5);
1087  } else if (station == 2) {
1088  if (ring == 1)
1089  csctflcts->Fill(bx, 14.5);
1090  else
1091  csctflcts->Fill(bx, 15.5);
1092  } else if (station == 3) {
1093  if (ring == 1)
1094  csctflcts->Fill(bx, 16.5);
1095  else
1096  csctflcts->Fill(bx, 17.5);
1097  }
1098  }
1099 
1100  // only for ME1/1
1101  if (station == 0 && ring == 1) {
1103  me11_lctWire->Fill(keyWire);
1104  me11_lctLocalPhi->Fill(lclPhi.phi_local);
1105  me11_lctPackedPhi->Fill(theStub.phiPacked());
1106  me11_lctGblPhi->Fill(phiG);
1107  me11_lctGblEta->Fill(etaG);
1108  }
1109 
1110  // only for ME4/2
1111  if (station == 3 && ring == 2) {
1112  me42_lctGblPhi->Fill(phiG);
1113  me42_lctGblEta->Fill(etaG);
1114  }
1115 
1116  //ME1/1
1117  if (station == 0 && ring == 1) {
1118  int realID = cscId + 6 * sector + 3 * subSector;
1119  if (realID > 36)
1120  realID -= 36;
1121  if (endcap == 0) {
1122  csc_strip_MEplus11->Fill(realID, strip);
1123  csc_wire_MEplus11->Fill(realID, keyWire);
1124  if (keyWire > 48 || strip > 224)
1125  cscWireStripOverflow->Fill(realID, 9.5, 1);
1126  }
1127  if (endcap == 1) {
1128  csc_strip_MEminus11->Fill(realID, strip);
1129  csc_wire_MEminus11->Fill(realID, keyWire);
1130  if (keyWire > 48 || strip > 224)
1131  cscWireStripOverflow->Fill(realID, 8.5, 1);
1132  }
1133  }
1134  //ME1/2
1135  if (station == 0 && ring == 2) {
1136  int realID = (cscId - 3) + 6 * sector + 3 * subSector;
1137  if (realID > 36)
1138  realID -= 36;
1139  if (endcap == 0) {
1140  csc_strip_MEplus12->Fill(realID, strip);
1141  csc_wire_MEplus12->Fill(realID, keyWire);
1142  if (keyWire > 64 || strip > 160)
1143  cscWireStripOverflow->Fill(realID, 10.5, 1);
1144  }
1145  if (endcap == 1) {
1146  csc_strip_MEminus12->Fill(realID, strip);
1147  csc_wire_MEminus12->Fill(realID, keyWire);
1148  if (keyWire > 64 || strip > 160)
1149  cscWireStripOverflow->Fill(realID, 7.5, 1);
1150  }
1151  }
1152  //ME1/3
1153  if (station == 0 && ring == 3) {
1154  int realID = (cscId - 6) + 6 * sector + 3 * subSector;
1155  if (realID > 36)
1156  realID -= 36;
1157  if (endcap == 0) {
1158  csc_strip_MEplus13->Fill(realID, strip);
1159  csc_wire_MEplus13->Fill(realID, keyWire);
1160  if (keyWire > 32 || strip > 128)
1161  cscWireStripOverflow->Fill(realID, 11.5, 1);
1162  }
1163  if (endcap == 1) {
1164  csc_strip_MEminus13->Fill(realID, strip);
1165  csc_wire_MEminus13->Fill(realID, keyWire);
1166  if (keyWire > 32 || strip > 128)
1167  cscWireStripOverflow->Fill(realID, 6.5, 1);
1168  }
1169  }
1170  //ME2/1
1171  if (station == 1 && ring == 1) {
1172  int realID = cscId + 3 * sector + 2;
1173  if (realID > 18)
1174  realID -= 18;
1175  if (endcap == 0) {
1176  csc_strip_MEplus21->Fill(realID, strip);
1177  csc_wire_MEplus21->Fill(realID, keyWire);
1178  if (keyWire > 112 || strip > 160)
1179  cscWireStripOverflow->Fill(realID, 12.5, 1);
1180  }
1181  if (endcap == 1) {
1182  csc_strip_MEminus21->Fill(realID, strip);
1183  csc_wire_MEminus21->Fill(realID, keyWire);
1184  if (keyWire > 112 || strip > 160)
1185  cscWireStripOverflow->Fill(realID, 5.5, 1);
1186  }
1187  }
1188  //ME2/2
1189  if (station == 1 && ring == 2) {
1190  int realID = (cscId - 3) + 6 * sector + 3;
1191  if (realID > 36)
1192  realID -= 36;
1193  if (endcap == 0) {
1194  csc_strip_MEplus22->Fill(realID, strip);
1195  csc_wire_MEplus22->Fill(realID, keyWire);
1196  if (keyWire > 64 || strip > 160)
1197  cscWireStripOverflow->Fill(realID, 13.5, 1);
1198  }
1199  if (endcap == 1) {
1200  csc_strip_MEminus22->Fill(realID, strip);
1201  csc_wire_MEminus22->Fill(realID, keyWire);
1202  if (keyWire > 64 || strip > 160)
1203  cscWireStripOverflow->Fill(realID, 4.5, 1);
1204  }
1205  }
1206 
1207  //ME3/1
1208  if (station == 2 && ring == 1) {
1209  int realID = cscId + 3 * sector + 2;
1210  if (realID > 18)
1211  realID -= 18;
1212  if (endcap == 0) {
1213  csc_strip_MEplus31->Fill(realID, strip);
1214  csc_wire_MEplus31->Fill(realID, keyWire);
1215  if (keyWire > 96 || strip > 160)
1216  cscWireStripOverflow->Fill(realID, 14.5, 1);
1217  }
1218  if (endcap == 1) {
1219  csc_strip_MEminus31->Fill(realID, strip);
1220  csc_wire_MEminus31->Fill(realID, keyWire);
1221  if (keyWire > 96 || strip > 160)
1222  cscWireStripOverflow->Fill(realID, 3.5, 1);
1223  }
1224  }
1225 
1226  //ME3/2
1227  if (station == 2 && ring == 2) {
1228  int realID = (cscId - 3) + 6 * sector + 3;
1229  if (realID > 36)
1230  realID -= 36;
1231  if (endcap == 0) {
1232  csc_strip_MEplus32->Fill(realID, strip);
1233  csc_wire_MEplus32->Fill(realID, keyWire);
1234  if (keyWire > 64 || strip > 160)
1235  cscWireStripOverflow->Fill(realID, 15.5, 1);
1236  }
1237  if (endcap == 1) {
1238  csc_strip_MEminus32->Fill(realID, strip);
1239  csc_wire_MEminus32->Fill(realID, keyWire);
1240  if (keyWire > 64 || strip > 160)
1241  cscWireStripOverflow->Fill(realID, 2.5, 1);
1242  }
1243  }
1244  //ME4/1
1245  if (station == 3 && ring == 1) {
1246  int realID = cscId + 3 * sector + 2;
1247  if (realID > 18)
1248  realID -= 18;
1249  if (endcap == 0) {
1250  csc_strip_MEplus41->Fill(realID, strip);
1251  csc_wire_MEplus41->Fill(realID, keyWire);
1252  if (keyWire > 96 || strip > 160)
1253  cscWireStripOverflow->Fill(realID, 16.5, 1);
1254  }
1255  if (endcap == 1) {
1256  csc_strip_MEminus41->Fill(realID, strip);
1257  csc_wire_MEminus41->Fill(realID, keyWire);
1258  if (keyWire > 96 || strip > 160)
1259  cscWireStripOverflow->Fill(realID, 1.5, 1);
1260  }
1261  }
1262  //ME4/2
1263  if (station == 3 && ring == 2) {
1264  int realID = (cscId - 3) + 6 * sector + 3;
1265  if (realID > 36)
1266  realID -= 36;
1267  if (endcap == 0) {
1268  csc_strip_MEplus42->Fill(realID, strip);
1269  csc_wire_MEplus42->Fill(realID, keyWire);
1270  if (keyWire > 64 || strip > 160)
1271  cscWireStripOverflow->Fill(realID, 17.5, 1);
1272  }
1273  if (endcap == 1) {
1274  csc_strip_MEminus42->Fill(realID, strip);
1275  csc_wire_MEminus42->Fill(realID, keyWire);
1276  if (keyWire > 64 || strip > 160)
1277  cscWireStripOverflow->Fill(realID, 0.5, 1);
1278  }
1279  }
1280 
1281  // SR LUT gives packed eta and phi values -> normilize them to 1 by scale them to 'max' and shift by 'min'
1282  //float etaP = gblEta.global_eta/127*1.5 + 0.9;
1283  //float phiP = (gblPhi.global_phi);// + ( sector )*4096 + station*4096*12) * 1./(4*4096*12);
1284  //std::cout << "LCT Eta & Phi Coordinates: " << etaP << ", " << phiP << "." << std::endl;
1285  //csctfoccupancies->Fill( gblEta.global_eta/127. * 1.5 + 0.9, (gblPhi.global_phi + ( sector + (endcap?0:6) )*4096 + station*4096*12) * 1./(4*4096*12) );
1286  } //lct != range1.scond
1287  } //csc!=corrlcts.product()->end()
1288  } // lctProducer.label() != "null"
1289 
1290  if (trackProducer.label() != "null") {
1292  e.getByToken(tracksToken_, tracks);
1293  for (L1CSCTrackCollection::const_iterator trk = tracks->begin(); trk < tracks->end(); trk++) {
1294  NumCSCTfTracksRep++;
1295  long LUTAdd = trk->first.ptLUTAddress();
1296  int trigMode = ((LUTAdd)&0xf0000) >> 16;
1297  int trEta = (trk->first.eta_packed());
1298 
1299  // trk->first.endcap() = 2 for - endcap
1300  // = 1 for + endcap
1301  //int trEndcap = (trk->first.endcap()==2 ? trk->first.endcap()-3 : trk->first.endcap());
1302  if (trk->first.endcap() != 1) {
1303  int holder = trEta;
1304  trEta = -1 * holder;
1305  trEta -= 1;
1306  }
1307 
1308  int trSector = 6 * (trk->first.endcap() - 1) + trk->first.sector();
1309  int trBX = trk->first.BX();
1310 
1311  //Here is what is done with output phi value:
1312  //output_phi = (phi / 32) * 3 /16
1313  //where:
1314  //phi is 12-bit phi, 4096 bins covering 62 degrees
1315  //output_phi is 5-bit value
1316 
1317  //Easy to see that output_phi can have values from 0 to 23, or 24 total combinations.
1318  //This gives per-bin phi value of 62/24 = 2.583333 degrees.
1319 
1320  // Sector 1 nominally starts at 15 degrees but there 1 degree overlap between sectors so 14 degrees effectively
1321  //double trPhi = trk->first.localPhi() * 62. / 24.;
1322  double trPhi = ts->getPhiScale()->getLowEdge(trk->first.localPhi());
1323  double trPhi02PI = fmod(trPhi + ((trSector - 1) * M_PI / 3) + (M_PI * 14 / 180.), 2 * M_PI);
1324 
1325  if (trigMode == 15) {
1326  csctfTrackPhi_H->Fill(trPhi02PI);
1327  csctfTrackEta_H->Fill(trEta);
1328  csctfoccupancies_H->Fill(trEta, trPhi02PI);
1329  csctfbx_H->Fill(trSector, trBX);
1330  } else {
1331  csctfTrackPhi->Fill(trPhi02PI);
1332  csctfTrackEta->Fill(trEta);
1333  csctfoccupancies->Fill(trEta, trPhi02PI);
1334  csctfbx->Fill(trSector, trBX);
1335 
1336  // Low Quality / High Quality Eta Distributions
1337  //|eta| < 2.1
1338  if (abs(trEta) < 24) {
1339  if (trigMode == 2 || trigMode == 3 || trigMode == 4 || trigMode == 5 || trigMode == 6 || trigMode == 7 ||
1340  trigMode == 11 || trigMode == 12 || trigMode == 13 || trigMode == 14)
1341  csctfTrackEtaHighQ->Fill(trEta);
1342 
1343  if (trigMode == 8 || trigMode == 9 || trigMode == 10)
1344  csctfTrackEtaLowQ->Fill(trEta);
1345  } else { //|eta| > 2.1
1346  if (trigMode == 2 || trigMode == 3 || trigMode == 4 || trigMode == 5)
1347  csctfTrackEtaHighQ->Fill(trEta);
1348  else
1349  csctfTrackEtaLowQ->Fill(trEta);
1350  }
1351  }
1352 
1353  csctfTrackM->Fill(trk->first.modeExtended());
1354 
1355  // we monitor the track quality only on the first link
1356  // so let's make sure to fill the plot if there is something that
1357  // is read from the hardware
1358  int trRank = trk->first.rank();
1359  if (trRank) {
1360  int trQuality = ((trRank >> 5) & 0x3);
1361  trackModeVsQ->Fill(trk->first.modeExtended(), trQuality);
1362  }
1363 
1364  /*
1365  OLD METHOD FOR FILLING HALO PLOTS, IMPROVED METHOD USING ASSOCIATED TRACK STUBS
1366  BELOW ~LINE 605
1367  if( trigMode == 15 )
1368  {
1369 
1370  double haloVals[4][4];
1371  for( int i = 0; i < 4; i++)
1372  {
1373  haloVals[i][0] = 0;
1374  }
1375 
1376  edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts;
1377  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++)
1378  {
1379  CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
1380  for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++)
1381  {
1382  int endcap = (*csc).first.endcap()-1;
1383  int station = (*csc).first.station()-1;
1384  int sector = (*csc).first.triggerSector()-1;
1385  int cscId = (*csc).first.triggerCscId()-1;
1386  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
1387  int fpga = ( subSector ? subSector-1 : station+1 );
1388 
1389  if(station != 4)
1390  {
1391  int modEnd = 1;
1392  if( endcap == 0 ) modEnd = -1;
1393  int indexHalo = modEnd + station;
1394  if(haloVals[indexHalo][0] == 1.0) haloVals[indexHalo][3] = 1.0;
1395  if(haloVals[indexHalo][0] == 0) haloVals[indexHalo][0] = 1.0;
1396  haloVals[indexHalo][1] = sector*1.0;
1397 
1398  lclphidat lclPhi;
1399  lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
1400  gblphidat gblPhi;
1401  gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
1402  gbletadat gblEta;
1403  gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
1404 
1405  haloVals[indexHalo][2] = gblEta.global_eta/127. * 1.5 + 0.9;
1406  } //station1 or 2
1407  } //lct first to second
1408  } //corrlcts
1409 
1410  if( (haloVals[0][0] == 1.) && (haloVals[1][0] == 1.) && (haloVals[0][3] != 1.) && (haloVals[1][3] != 1.) )
1411  {
1412  if( haloVals[0][1] == haloVals[1][1] ){
1413  double delEta23 = haloVals[1][2] - haloVals[0][2];
1414  haloDelEta23->Fill( delEta23 );
1415  }
1416  }
1417 
1418  if( (haloVals[2][0] == 1.) && (haloVals[3][0] == 1.) && (haloVals[2][3] != 1.) && (haloVals[3][3] != 1.) )
1419  {
1420  if( haloVals[2][1] == haloVals[3][1] ){
1421  double delEta23 = haloVals[3][2] - haloVals[2][2];
1422  haloDelEta23->Fill( delEta23 );
1423  }
1424  }
1425  } //halo trigger
1426  */
1427 
1428  int cscTrackStub = 0;
1429  //float haloEta[3];
1430  //for(int i=0; i<3; i++) haloEta[i]=-1.0;
1431  //bool haloME11 = false;
1432  CSCCorrelatedLCTDigiCollection lctsOfTracks = trk->second;
1433  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator trackStub = lctsOfTracks.begin();
1434  trackStub != lctsOfTracks.end();
1435  trackStub++) {
1436  CSCCorrelatedLCTDigiCollection::Range range2 = lctsOfTracks.get((*trackStub).first);
1437  for (CSCCorrelatedLCTDigiCollection::const_iterator lct = range2.first; lct != range2.second; lct++) {
1438  // int station = (*trackStub).first.station()-1;
1439  // if(station != 4)
1440  // {
1441  // // int endcap = (*trackStub).first.endcap()-1;
1442  // // int sector = (*trackStub).first.triggerSector()-1;
1443  // int cscId = (*trackStub).first.triggerCscId()-1;
1444  // int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*trackStub).first);
1445  // int fpga = ( subSector ? subSector-1 : station+1 );
1446 
1447  // lclphidat lclPhi;
1448  // lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
1449  // gblphidat gblPhi;
1450  // gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
1451  // gbletadat gblEta;
1452  // gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
1453  // haloEta[station-1] = gblEta.global_eta/127. * 1.5 + 0.9;
1454  // if(station==1 && cscId<2) haloME11 = true;
1455  // }
1456  cscTrackStub++;
1457  }
1458  }
1459  cscTrackStubNumbers->Fill(cscTrackStub);
1460 
1461  // if(trigMode == 15)
1462  // {
1463  // float dEta13 = haloEta[2]-haloEta[0];
1464  // float dEta12 = haloEta[1]-haloEta[0];
1465  // if(haloME11)
1466  // {
1467  // if(haloEta[1]!=-1.0) haloDelEta112->Fill(dEta12);
1468  // if(haloEta[2]!=-1.0) haloDelEta113->Fill(dEta13);
1469  // } else {
1470  // if(haloEta[1]!=-1.0) haloDelEta12->Fill(dEta12);
1471  // if(haloEta[2]!=-1.0) haloDelEta13->Fill(dEta13);
1472  // }
1473  // }
1474  //
1475  }
1476  }
1477  csctfntrack->Fill(NumCSCTfTracksRep);
1478 
1479  if (mbProducer.label() != "null") {
1480  // handle to needed collections
1482  e.getByToken(dtStubsToken_, dtStubs);
1484  e.getByToken(mbtracksToken_, tracks);
1485 
1486  // loop on the DT stubs
1487  std::vector<csctf::TrackStub> vstubs = dtStubs->get();
1488  for (std::vector<csctf::TrackStub>::const_iterator stub = vstubs.begin(); stub != vstubs.end(); stub++) {
1489  if (verbose_) {
1490  edm::LogInfo("DataNotFound") << "\n mbEndcap: " << stub->endcap();
1491  edm::LogInfo("DataNotFound") << "\n stub->getStrip()[FLAG]: " << stub->getStrip();
1492  edm::LogInfo("DataNotFound") << "\n stub->getKeyWG()[CAL]: " << stub->getKeyWG();
1493  edm::LogInfo("DataNotFound") << "\n stub->BX(): " << stub->BX();
1494  edm::LogInfo("DataNotFound") << "\n stub->sector(): " << stub->sector();
1495  edm::LogInfo("DataNotFound") << "\n stub->subsector(): " << stub->subsector();
1496  edm::LogInfo("DataNotFound") << "\n stub->station(): " << stub->station();
1497  edm::LogInfo("DataNotFound") << "\n stub->phiPacked(): " << stub->phiPacked();
1498  edm::LogInfo("DataNotFound") << "\n stub->getBend(): " << stub->getBend();
1499  edm::LogInfo("DataNotFound") << "\n stub->getQuality(): " << stub->getQuality();
1500  edm::LogInfo("DataNotFound") << "\n stub->cscid(): " << stub->cscid() << endl;
1501  }
1502  // define the sector ID
1503  int mbId = (stub->endcap() == 2) ? 6 : 0;
1504  mbId += stub->sector();
1505  // *** do not fill if CalMB variable is set ***
1506  // horrible! They used the same class to write up the LCT and MB info,
1507  // but given the MB does not have strip and WG they replaced this two
1508  // with the flag and cal bits... :S
1509  if (stub->getKeyWG() == 0)
1510  {
1511  // if FLAG =1, muon belong to previous BX
1512  int bxDT = stub->BX() - stub->getStrip(); // correct by the FLAG
1513  int subDT = stub->subsector();
1514 
1515  // Fill the event only if CSC had or would have triggered
1516  if (isCSCcand_) {
1517  //look for tracks in the event and compare the matching DT stubs
1518  int trkBX = 0;
1519  for (L1CSCTrackCollection::const_iterator trk = tracks->begin(); trk < tracks->end(); trk++) {
1520  trkBX = trk->first.BX();
1521  int trkId = (trk->first.endcap() == 2) ? 6 : 0;
1522  trkId += trk->first.sector();
1523  if (verbose_) {
1524  edm::LogInfo("DataNotFound")
1525  << "\n trk BX: " << trkBX << " Sector: " << trkId << " SubSector: " << trk->first.subsector()
1526  << " Endcap: " << trk->first.endcap();
1527 
1528  edm::LogInfo("DataNotFound")
1529  << "\n DT BX: " << stub->BX() << " Sector: " << mbId << " SubSector: " << stub->subsector()
1530  << " Endcap: " << stub->endcap() << endl;
1531  }
1532 
1533  if (mbId == trkId) {
1534  if (verbose_) {
1535  edm::LogInfo("DataNotFound") << " --> MATCH" << endl;
1536  edm::LogInfo("DataNotFound") << "Fill :" << trkBX + 6 - bxDT << " -- " << subDT << " -- cands" << endl;
1537  }
1538  // DT bx ranges from 3 to 9
1539  // trk bx ranges from -3 to 3
1540  DTstubsTimeTrackMenTimeArrival[mbId - 1]->Fill(bxDT - trkBX - 6, subDT); //subsec
1541  }
1542  } // loop on the tracks
1543  } //if (isCSCcand_){
1544  } //if (stub->getKeyWG() == 0) {
1545  }
1546  }
1547 }
MonitorElement * DTstubsTimeTrackMenTimeArrival[12]
Definition: L1TCSCTF.h:162
MonitorElement * csctfoccupancies
Definition: L1TCSCTF.h:78
MonitorElement * csctfTrackEtaHighQ
Definition: L1TCSCTF.h:96
MonitorElement * csctflcts
Definition: L1TCSCTF.h:105
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
unsigned phiPacked() const
Return the binned phi for this stub.
Definition: TrackStub.h:41
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
MonitorElement * csctfTrackPhi
Definition: L1TCSCTF.h:93
MonitorElement * csctferrors_mpc
Definition: L1TCSCTF.h:81
MonitorElement * csc_strip_MEminus22
Definition: L1TCSCTF.h:134
bool verbose_
Definition: L1TCSCTF.h:170
unsigned long long m_scalesCacheID
Definition: L1TCSCTF.h:180
MonitorElement * csctfTrackPhi_H
Definition: L1TCSCTF.h:97
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * csc_wire_MEplus31
Definition: L1TCSCTF.h:145
MonitorElement * csc_strip_MEplus21
Definition: L1TCSCTF.h:123
std::string const & instance() const
Definition: InputTag.h:37
edm::ESGetToken< L1MuTriggerScales, L1MuTriggerScalesRcd > l1muTscalesToken_
Definition: L1TCSCTF.h:190
MonitorElement * csc_strip_MEplus11
Definition: L1TCSCTF.h:120
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
T const * product() const
Definition: Handle.h:70
MonitorElement * csc_wire_MEminus13
Definition: L1TCSCTF.h:152
MonitorElement * csc_wire_MEminus22
Definition: L1TCSCTF.h:154
MonitorElement * me11_lctGblPhi
Definition: L1TCSCTF.h:112
MonitorElement * csc_wire_MEplus12
Definition: L1TCSCTF.h:141
MonitorElement * csc_wire_MEminus31
Definition: L1TCSCTF.h:155
double etaValue() const
return the Eta Value of this stub&#39;s position.
Definition: TrackStub.h:33
MonitorElement * csctfbx
Definition: L1TCSCTF.h:74
MonitorElement * csc_wire_MEminus32
Definition: L1TCSCTF.h:156
MonitorElement * csctfTrackEtaLowQ
Definition: L1TCSCTF.h:95
edm::InputTag mbProducer
Definition: L1TCSCTF.h:173
std::string const & label() const
Definition: InputTag.h:36
const L1MuScale * getPhiScale() const
get the phi scale
Log< level::Error, false > LogError
MonitorElement * csc_strip_MEminus12
Definition: L1TCSCTF.h:131
MonitorElement * csctfTrackEta
Definition: L1TCSCTF.h:94
MonitorElement * me11_lctWire
Definition: L1TCSCTF.h:109
MonitorElement * csc_strip_MEminus31
Definition: L1TCSCTF.h:135
unsigned long long cacheIdentifier() const
std::string outputFile_
Definition: L1TCSCTF.h:169
MonitorElement * csc_wire_MEminus21
Definition: L1TCSCTF.h:153
edm::InputTag statusProducer
Definition: L1TCSCTF.h:173
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
edm::EDGetTokenT< L1CSCStatusDigiCollection > statusToken_
Definition: L1TCSCTF.h:185
~L1TCSCTF() override
Definition: L1TCSCTF.cc:103
MonitorElement * csctfTrackEta_H
Definition: L1TCSCTF.h:98
MonitorElement * me42_lctGblPhi
Definition: L1TCSCTF.h:116
const L1MuTriggerScales * ts
Definition: L1TCSCTF.h:178
bool gangedME11a_
Definition: L1TCSCTF.h:174
MonitorElement * cscTrackStubNumbers
Definition: L1TCSCTF.h:99
MonitorElement * csc_strip_MEminus32
Definition: L1TCSCTF.h:136
int L1ABXN
Definition: L1TCSCTF.h:166
MonitorElement * me11_lctStrip
Definition: L1TCSCTF.h:108
int BxInEvent_
Definition: L1TCSCTF.h:163
edm::ESGetToken< L1MuTriggerPtScale, L1MuTriggerPtScaleRcd > ptscalesToken_
Definition: L1TCSCTF.h:191
MonitorElement * csc_strip_MEminus42
Definition: L1TCSCTF.h:138
MonitorElement * csc_wire_MEplus41
Definition: L1TCSCTF.h:147
MonitorElement * csc_strip_MEplus13
Definition: L1TCSCTF.h:122
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * csc_strip_MEplus22
Definition: L1TCSCTF.h:124
int nev_
Definition: L1TCSCTF.h:168
MonitorElement * csc_wire_MEminus41
Definition: L1TCSCTF.h:157
L1TCSCTF(const edm::ParameterSet &ps)
Definition: L1TCSCTF.cc:23
MonitorElement * csctfChamberOccupancies
Definition: L1TCSCTF.h:92
virtual 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)
MonitorElement * csc_wire_MEplus13
Definition: L1TCSCTF.h:142
edm::InputTag lctProducer
Definition: L1TCSCTF.h:173
Definition: L1Track.h:19
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: L1TCSCTF.cc:655
#define M_PI
MonitorElement * csc_wire_MEplus21
Definition: L1TCSCTF.h:143
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &, edm::EventSetup const &) override
Definition: L1TCSCTF.cc:110
edm::EDGetTokenT< L1CSCTrackCollection > tracksToken_
Definition: L1TCSCTF.h:187
MonitorElement * csc_strip_MEminus41
Definition: L1TCSCTF.h:137
Log< level::Info, false > LogInfo
MonitorElement * me42_lctGblEta
Definition: L1TCSCTF.h:117
MonitorElement * csc_strip_MEplus31
Definition: L1TCSCTF.h:125
MonitorElement * csc_wire_MEplus32
Definition: L1TCSCTF.h:146
edm::EDGetTokenT< CSCCorrelatedLCTDigiCollection > corrlctsToken_
Definition: L1TCSCTF.h:186
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
MonitorElement * csctferrors
Definition: L1TCSCTF.h:77
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:193
MonitorElement * csc_wire_MEminus42
Definition: L1TCSCTF.h:158
bool isCSCcand_
Definition: L1TCSCTF.h:164
class global_phi_data gblphidat
MonitorElement * csc_strip_MEplus41
Definition: L1TCSCTF.h:127
std::pair< const_iterator, const_iterator > Range
MonitorElement * csctfTrackM
Definition: L1TCSCTF.h:100
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
edm::EDGetTokenT< L1CSCTrackCollection > mbtracksToken_
Definition: L1TCSCTF.h:189
MonitorElement * csctfbx_H
Definition: L1TCSCTF.h:75
std::vector< DigiType >::const_iterator const_iterator
class local_phi_data lclphidat
Data Types.
static int triggerSubSectorFromLabels(int station, int chamber)
double phiValue() const
return the Phi Value of this stub&#39;s position in local coordinates.
Definition: TrackStub.h:35
gblphidat globalPhiME(int phi_local, int wire_group, int cscid, const bool gangedME1a=false) const
MonitorElement * csctfntrack
Definition: L1TCSCTF.h:73
edm::InputTag trackProducer
Definition: L1TCSCTF.h:173
edm::EDGetTokenT< L1MuGMTReadoutCollection > gmtProducerToken_
Definition: L1TCSCTF.h:184
bool isValid() const
Definition: HandleBase.h:70
MonitorElement * csc_wire_MEplus42
Definition: L1TCSCTF.h:148
MonitorElement * trackModeVsQ
Definition: L1TCSCTF.h:101
MonitorElement * me11_lctGblEta
Definition: L1TCSCTF.h:113
lclphidat localPhi(int strip, int pattern, int quality, int lr, const bool gangedME1a=false) const
Geometry Lookup Tables.
HLT enums.
MonitorElement * csc_strip_MEminus21
Definition: L1TCSCTF.h:133
MonitorElement * csctfoccupancies_H
Definition: L1TCSCTF.h:79
MonitorElement * csc_strip_MEplus32
Definition: L1TCSCTF.h:126
MonitorElement * csc_strip_MEplus12
Definition: L1TCSCTF.h:121
static unsigned int const shift
void setPhiPacked(const unsigned &phi_)
Definition: TrackStub.h:30
trackProducer
Run2: False; Run1: True.
Definition: L1TCSCTF_cfi.py:12
CSCSectorReceiverLUT * srLUTs_[5][2][6]
Definition: L1TCSCTF.h:176
gbletadat globalEtaME(int phi_bend, int phi_local, int wire_group, int cscid, const bool gangedME1a=false) const
const L1MuTriggerPtScale * tpts
Definition: L1TCSCTF.h:179
MonitorElement * me11_lctLocalPhi
Definition: L1TCSCTF.h:110
MonitorElement * csc_strip_MEminus11
Definition: L1TCSCTF.h:130
MonitorElement * csc_strip_MEminus13
Definition: L1TCSCTF.h:132
unsigned long long m_ptScaleCacheID
Definition: L1TCSCTF.h:181
MonitorElement * csc_wire_MEplus11
Definition: L1TCSCTF.h:140
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * csc_wire_MEminus12
Definition: L1TCSCTF.h:151
class global_eta_data gbletadat
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:49
MonitorElement * cscWireStripOverflow
Definition: L1TCSCTF.h:82
MonitorElement * csc_strip_MEplus42
Definition: L1TCSCTF.h:128
edm::EDGetTokenT< CSCTriggerContainer< csctf::TrackStub > > dtStubsToken_
Definition: L1TCSCTF.h:188
edm::InputTag gmtProducer
Definition: L1TCSCTF.h:173
void setEtaPacked(const unsigned &eta_)
set Eta and Phi from integer values.
Definition: TrackStub.h:29
MonitorElement * me11_lctPackedPhi
Definition: L1TCSCTF.h:111
MonitorElement * csc_wire_MEplus22
Definition: L1TCSCTF.h:144
MonitorElement * csc_wire_MEminus11
Definition: L1TCSCTF.h:150
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)