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