CMS 3D CMS Logo

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