CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CSCTFSectorProcessor.cc
Go to the documentation of this file.
4 #include "parameters.h"
5 
7 
8 #include <cstdlib>
9 #include <sstream>
10 #include <strings.h>
11 
12 const std::string CSCTFSectorProcessor::FPGAs[5] = {"F1", "F2", "F3", "F4", "F5"};
13 
15  Tokens tok;
16  if (not pset.getParameter<bool>("initializeFromPSet")) {
17  tok.ptLUT = CSCTFPtLUT::consumes(iC);
18  tok.config = iC.esConsumes();
19  }
20  return tok;
21 }
22 
24  const unsigned& sector,
25  const edm::ParameterSet& pset,
26  bool tmb07,
27  const L1MuTriggerScales* scales,
28  const L1MuTriggerPtScale* ptScale) {
29  m_endcap = endcap;
30  m_sector = sector;
31  TMB07 = tmb07;
32 
33  // allows a configurable option to handle unganged ME1a
34  m_gangedME1a = pset.getUntrackedParameter<bool>("gangedME1a", true);
35 
36  // Parameter below should always present in ParameterSet:
37  m_latency = pset.getParameter<unsigned>("CoreLatency");
38  m_minBX = pset.getParameter<int>("MinBX");
39  m_maxBX = pset.getParameter<int>("MaxBX");
40  initializeFromPSet = pset.getParameter<bool>("initializeFromPSet");
41  if (m_maxBX - m_minBX >= 7)
42  edm::LogWarning("CSCTFTrackBuilder::ctor")
43  << " BX window width >= 7BX. Resetting m_maxBX=" << (m_maxBX = m_minBX + 6);
44 
45  // All following parameters may appear in either ParameterSet of in EventSetup; uninitialize:
46  m_bxa_depth = -1;
47  m_allowALCTonly = -1;
48  m_allowCLCTonly = -1;
49  m_preTrigger = -1;
50 
51  for (int index = 0; index < 7; index++)
52  m_etawin[index] = -1;
53  for (int index = 0; index < 8; index++)
54  m_etamin[index] = -1;
55  for (int index = 0; index < 8; index++)
56  m_etamax[index] = -1;
57 
58  m_mindphip = -1;
59  m_mindetap = -1;
60 
61  m_mindeta12_accp = -1;
62  m_maxdeta12_accp = -1;
63  m_maxdphi12_accp = -1;
64 
65  m_mindeta13_accp = -1;
66  m_maxdeta13_accp = -1;
67  m_maxdphi13_accp = -1;
68 
69  m_mindeta112_accp = -1;
70  m_maxdeta112_accp = -1;
71  m_maxdphi112_accp = -1;
72 
73  m_mindeta113_accp = -1;
74  m_maxdeta113_accp = -1;
75  m_maxdphi113_accp = -1;
76  m_mindphip_halo = -1;
77  m_mindetap_halo = -1;
78 
79  m_widePhi = -1;
80 
81  m_straightp = -1;
82  m_curvedp = -1;
83 
84  m_mbaPhiOff = -1;
85  m_mbbPhiOff = -1;
86 
87  kill_fiber = -1;
88  QualityEnableME1a = -1;
89  QualityEnableME1b = -1;
90  QualityEnableME1c = -1;
91  QualityEnableME1d = -1;
92  QualityEnableME1e = -1;
93  QualityEnableME1f = -1;
94  QualityEnableME2a = -1;
95  QualityEnableME2b = -1;
96  QualityEnableME2c = -1;
97  QualityEnableME3a = -1;
98  QualityEnableME3b = -1;
99  QualityEnableME3c = -1;
100  QualityEnableME4a = -1;
101  QualityEnableME4b = -1;
102  QualityEnableME4c = -1;
103 
104  run_core = -1;
105  trigger_on_ME1a = -1;
106  trigger_on_ME1b = -1;
107  trigger_on_ME2 = -1;
108  trigger_on_ME3 = -1;
109  trigger_on_ME4 = -1;
110  trigger_on_MB1a = -1;
111  trigger_on_MB1d = -1;
112 
113  singlesTrackOutput = 999;
114  rescaleSinglesPhi = -1;
115 
116  m_firmSP = -1;
117  m_firmFA = -1;
118  m_firmDD = -1;
119  m_firmVM = -1;
120 
121  initFail_ = false;
122 
123  isCoreVerbose = pset.getParameter<bool>("isCoreVerbose");
124 
125  if (initializeFromPSet)
126  readParameters(pset);
127 
128  // Sector Receiver LUTs initialization
129  edm::ParameterSet srLUTset = pset.getParameter<edm::ParameterSet>("SRLUT");
130  for (int i = 1; i <= 4; ++i) {
131  if (i == 1)
132  for (int j = 0; j < 2; j++) {
133  srLUTs_[FPGAs[j]] = new CSCSectorReceiverLUT(endcap, sector, j + 1, i, srLUTset, TMB07);
134  }
135  else
136  srLUTs_[FPGAs[i]] = new CSCSectorReceiverLUT(endcap, sector, 0, i, srLUTset, TMB07);
137  }
138 
139  core_ = new CSCTFSPCoreLogic();
140 
141  // Pt LUTs initialization
142  if (initializeFromPSet) {
143  edm::ParameterSet ptLUTset = pset.getParameter<edm::ParameterSet>("PTLUT");
144  ptLUT_ = new CSCTFPtLUT(ptLUTset, scales, ptScale);
145  LogDebug("CSCTFSectorProcessor") << "Using stand-alone PT LUT for endcap=" << m_endcap << ", sector=" << m_sector;
146  } else {
147  ptLUT_ = nullptr;
148  LogDebug("CSCTFSectorProcessor") << "Looking for PT LUT in EventSetup for endcap=" << m_endcap
149  << ", sector=" << m_sector;
150  }
151 
152  // firmware map initialization
153  // all the information are based on the firmware releases
154  // documented at http://www.phys.ufl.edu/~uvarov/SP05/SP05.htm
155 
156  // map is <m_firmSP, core_version>
157  // it may happen that the same core is used for different firmware
158  // versions, e.g. change in the wrapper only
159 
160  // this mapping accounts for runs starting from 132440
161  // schema is year+month+day
162  firmSP_Map.insert(std::pair<int, int>(20100210, 20100122));
163  firmSP_Map.insert(std::pair<int, int>(20100617, 20100122));
164  firmSP_Map.insert(std::pair<int, int>(20100629, 20100122));
165 
166  firmSP_Map.insert(std::pair<int, int>(20100728, 20100728));
167 
168  firmSP_Map.insert(std::pair<int, int>(20100901, 20100901));
169 
170  //testing firmwares
171  firmSP_Map.insert(std::pair<int, int>(20101011, 20101011));
172  firmSP_Map.insert(std::pair<int, int>(20101210, 20101210));
173  firmSP_Map.insert(std::pair<int, int>(20110204, 20110118));
174  firmSP_Map.insert(std::pair<int, int>(20110322, 20110118));
175  // 2012 core with non linear dphi
176  firmSP_Map.insert(std::pair<int, int>(20120131, 20120131));
177  firmSP_Map.insert(std::pair<int, int>(20120227, 20120131));
178  //2012 core: 4 station track at |eta|>2.1 -> ME2-ME3-ME4
179  firmSP_Map.insert(std::pair<int, int>(20120313, 20120313));
180  firmSP_Map.insert(std::pair<int, int>(20120319, 20120313));
181  //2012 core: 4 station track at |eta|>2.1 -> ME1-ME2-ME3 test
182  firmSP_Map.insert(std::pair<int, int>(20120730, 20120730));
183  //2014 core: 4 station track at |eta|>2.1 -> ME1-ME2-ME3 test + correct F/R bit set
184  firmSP_Map.insert(std::pair<int, int>(20140424, 20140424));
185  //2014 core: 4 station track at |eta|>2.1 -> ME1-ME2-ME3 test + correct F/R bit set + bug fix
186  firmSP_Map.insert(std::pair<int, int>(20140515, 20140515));
187 }
188 
190  initFail_ = false;
191  if (!initializeFromPSet) {
192  // Only pT lut can be initialized from EventSetup, all front LUTs are initialized locally from their parametrizations
193  LogDebug("CSCTFSectorProcessor") << "Initializing endcap: " << m_endcap << " sector:" << m_sector
194  << "SP:" << (m_endcap - 1) * 6 + (m_sector - 1);
195  LogDebug("CSCTFSectorProcessor") << "Initializing pT LUT from EventSetup";
196 
197  ptLUT_ = new CSCTFPtLUT(c, tokens.ptLUT);
198 
199  // Extract from EventSetup alternative (to the one, used in constructor) ParameterSet
200  const L1MuCSCTFConfiguration& config = c.getData(tokens.config);
201  // And initialize only those parameters, which left uninitialized during construction
202  readParameters(parameters(config, (m_endcap - 1) * 6 + (m_sector - 1)));
203  }
204 
205  // ---------------------------------------------------------------------------
206  // This part is added per Vasile's request.
207  // It will help people understanding the emulator configuration
208  LogDebug("CSCTFSectorProcessor")
209  << "\n !!! CSCTF EMULATOR CONFIGURATION !!!"
210  << "\n\nCORE CONFIGURATION"
211  << "\n Coincidence Trigger? " << run_core << "\n Singles in ME1a? " << trigger_on_ME1a << "\n Singles in ME1b? "
212  << trigger_on_ME1b << "\n Singles in ME2? " << trigger_on_ME2 << "\n Singles in ME3? " << trigger_on_ME3
213  << "\n Singles in ME4? " << trigger_on_ME4 << "\n Singles in MB1a? " << trigger_on_MB1a << "\n Singles in MB1d? "
214  << trigger_on_MB1d
215 
216  << "\n BX Analyzer depth: assemble coinc. track with stubs in +/-" << m_bxa_depth << " Bxs"
217  << "\n Is Wide Phi Extrapolation (DeltaPhi valid up to ~15 degrees, otherwise ~7.67 degrees)? " << m_widePhi
218  << "\n PreTrigger=" << m_preTrigger
219 
220  << "\n CoreLatency=" << m_latency << "\n Is Phi for singles rescaled? " << rescaleSinglesPhi
221 
222  << "\n\nVARIOUS CONFIGURATION PARAMETERS"
223  << "\n Allow ALCT only? " << m_allowALCTonly << "\n Allow CLCT only? " << m_allowCLCTonly
224 
225  << "\nQualityEnableME1a (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1a
226  << "\nQualityEnableME1b (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1b
227  << "\nQualityEnableME1c (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1c
228  << "\nQualityEnableME1d (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1d
229  << "\nQualityEnableME1e (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1e
230  << "\nQualityEnableME1f (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1f
231  << "\nQualityEnableME2a (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME2a
232  << "\nQualityEnableME2b (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME2b
233  << "\nQualityEnableME2c (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME2c
234  << "\nQualityEnableME3a (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME3a
235  << "\nQualityEnableME3b (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME3b
236  << "\nQualityEnableME3c (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME3c
237  << "\nQualityEnableME4a (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME4a
238  << "\nQualityEnableME4b (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME4b
239  << "\nQualityEnableME4c (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME4c
240 
241  << "\nkill_fiber=" << kill_fiber << "\nSingles Output Link="
243 
244  //the DAT_ETA registers meaning are explained at Table 2 of
245  //http://www.phys.ufl.edu/~uvarov/SP05/LU-SP_ReferenceGuide_090915_Update.pdf
246 
247  << "\n\nDAT_ETA REGISTERS"
248  << "\nMinimum eta difference for track cancellation logic=" << m_mindetap
249  << "\nMinimum eta difference for halo track cancellation logic=" << m_mindetap_halo
250 
251  << "\nMinimum eta for ME1-ME2 collision tracks=" << m_etamin[0]
252  << "\nMinimum eta for ME1-ME3 collision tracks=" << m_etamin[1]
253  << "\nMinimum eta for ME2-ME3 collision tracks=" << m_etamin[2]
254  << "\nMinimum eta for ME2-ME4 collision tracks=" << m_etamin[3]
255  << "\nMinimum eta for ME3-ME4 collision tracks=" << m_etamin[4]
256  << "\nMinimum eta for ME1-ME2 collision tracks in overlap region=" << m_etamin[5]
257  << "\nMinimum eta for ME2-MB1 collision tracks=" << m_etamin[6]
258  << "\nMinimum eta for ME1-ME4 collision tracks=" << m_etamin[7]
259 
260  << "\nMinimum eta difference for ME1-ME2 (except ME1/1) halo tracks=" << m_mindeta12_accp
261  << "\nMinimum eta difference for ME1-ME3 (except ME1/1) halo tracks=" << m_mindeta13_accp
262  << "\nMinimum eta difference for ME1/1-ME2 halo tracks=" << m_mindeta112_accp
263  << "\nMinimum eta difference for ME1/1-ME3 halo tracks=" << m_mindeta113_accp
264 
265  << "\nMaximum eta for ME1-ME2 collision tracks=" << m_etamax[0]
266  << "\nMaximum eta for ME1-ME3 collision tracks=" << m_etamax[1]
267  << "\nMaximum eta for ME2-ME3 collision tracks=" << m_etamax[2]
268  << "\nMaximum eta for ME2-ME4 collision tracks=" << m_etamax[3]
269  << "\nMaximum eta for ME3-ME4 collision tracks=" << m_etamax[4]
270  << "\nMaximum eta for ME1-ME2 collision tracks in overlap region=" << m_etamax[5]
271  << "\nMaximum eta for ME2-MB1 collision tracks=" << m_etamax[6]
272  << "\nMaximum eta for ME1-ME4 collision tracks=" << m_etamax[7]
273 
274  << "\nMaximum eta difference for ME1-ME2 (except ME1/1) halo tracks=" << m_maxdeta12_accp
275  << "\nMaximum eta difference for ME1-ME3 (except ME1/1) halo tracks=" << m_maxdeta13_accp
276  << "\nMaximum eta difference for ME1/1-ME2 halo tracks=" << m_maxdeta112_accp
277  << "\nMaximum eta difference for ME1/1-ME3 halo tracks=" << m_maxdeta113_accp
278 
279  << "\nEta window for ME1-ME2 collision tracks=" << m_etawin[0]
280  << "\nEta window for ME1-ME3 collision tracks=" << m_etawin[1]
281  << "\nEta window for ME2-ME3 collision tracks=" << m_etawin[2]
282  << "\nEta window for ME2-ME4 collision tracks=" << m_etawin[3]
283  << "\nEta window for ME3-ME4 collision tracks=" << m_etawin[4]
284  << "\nEta window for ME1-ME2 collision tracks in overlap region=" << m_etawin[5]
285  << "\nEta window for ME1-ME4 collision tracks=" << m_etawin[6]
286 
287  << "\nMaximum phi difference for ME1-ME2 (except ME1/1) halo tracks=" << m_maxdphi12_accp
288  << "\nMaximum phi difference for ME1-ME3 (except ME1/1) halo tracks=" << m_maxdphi13_accp
289  << "\nMaximum phi difference for ME1/1-ME2 halo tracks=" << m_maxdphi112_accp
290  << "\nMaximum phi difference for ME1/1-ME3 halo tracks=" << m_maxdphi113_accp
291 
292  << "\nMinimum phi difference for track cancellation logic=" << m_mindphip
293  << "\nMinimum phi difference for halo track cancellation logic=" << m_mindphip_halo
294 
295  << "\nParameter for the correction of misaligned 1-2-3-4 straight tracks =" << m_straightp
296  << "\nParameter for the correction of misaligned 1-2-3-4 curved tracks=" << m_curvedp
297  << "\nPhi Offset for MB1A=" << m_mbaPhiOff << "\nPhi Offset for MB1D=" << m_mbbPhiOff
298 
299  << "\nFirmware SP year+month+day:" << m_firmSP << "\nFirmware FA year+month+day:" << m_firmFA
300  << "\nFirmware DD year+month+day:" << m_firmDD << "\nFirmware VM year+month+day:" << m_firmVM;
301 
303 
304  // set core verbosity: for debugging only purpouses
305  // in general the output is handled to Alex Madorsky
307 
308  // Set the SP firmware
310 
311  // Set the firmware for the CORE
312  int firmVersCore = firmSP_Map.find(m_firmSP)->second;
313  core_->SetCoreFirmwareVersion(firmVersCore);
314  edm::LogInfo("CSCTFSectorProcessor") << "\nCore Firmware is set to " << core_->GetCoreFirmwareVersion();
315  // ---------------------------------------------------------------------------
316 
317  // Check if parameters were not initialized in both: constuctor (from .cf? file) and initialize method (from EventSetup)
318  if (m_bxa_depth < 0) {
319  initFail_ = true;
320  edm::LogError("CSCTFSectorProcessor")
321  << "BXAdepth parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
322  }
323  if (m_allowALCTonly < 0) {
324  initFail_ = true;
325  edm::LogError("CSCTFSectorProcessor")
326  << "AllowALCTonly parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
327  }
328  if (m_allowCLCTonly < 0) {
329  initFail_ = true;
330  edm::LogError("CSCTFSectorProcessor")
331  << "AllowCLCTonly parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
332  }
333  if (m_preTrigger < 0) {
334  initFail_ = true;
335  edm::LogError("CSCTFSectorProcessor")
336  << "PreTrigger parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
337  }
338  if (m_mindphip < 0) {
339  initFail_ = true;
340  edm::LogError("CSCTFSectorProcessor")
341  << "mindphip parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
342  }
343  if (m_mindetap < 0) {
344  initFail_ = true;
345  edm::LogError("CSCTFSectorProcessor")
346  << "mindeta parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
347  }
348  if (m_straightp < 0) {
349  initFail_ = true;
350  edm::LogError("CSCTFSectorProcessor")
351  << "straightp parameter left unitialized for endcap=" << m_endcap << ", sector=" << m_sector;
352  }
353  if (m_curvedp < 0) {
354  initFail_ = true;
355  edm::LogError("CSCTFSectorProcessor")
356  << "curvedp parameter left unitialized for endcap=" << m_endcap << ",sector=" << m_sector;
357  }
358  if (m_mbaPhiOff < 0) {
359  initFail_ = true;
360  edm::LogError("CSCTFSectorProcessor")
361  << "mbaPhiOff parameter left unitialized for endcap=" << m_endcap << ",sector=" << m_sector;
362  }
363  if (m_mbbPhiOff < 0) {
364  initFail_ = true;
365  edm::LogError("CSCTFSectorProcessor")
366  << "mbbPhiOff parameter left unitialized for endcap=" << m_endcap << ",sector=" << m_sector;
367  }
368  if (m_mindeta12_accp < 0) {
369  initFail_ = true;
370  edm::LogError("CSCTFSectorProcessor")
371  << "mindeta_accp12 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
372  }
373  if (m_maxdeta12_accp < 0) {
374  initFail_ = true;
375  edm::LogError("CSCTFSectorProcessor")
376  << "maxdeta_accp12 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
377  }
378  if (m_maxdphi12_accp < 0) {
379  initFail_ = true;
380  edm::LogError("CSCTFSectorProcessor")
381  << "maxdphi_accp12 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
382  }
383  if (m_mindeta13_accp < 0) {
384  initFail_ = true;
385  edm::LogError("CSCTFSectorProcessor")
386  << "mindeta_accp13 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
387  }
388  if (m_maxdeta13_accp < 0) {
389  initFail_ = true;
390  edm::LogError("CSCTFSectorProcessor")
391  << "maxdeta_accp13 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
392  }
393  if (m_maxdphi13_accp < 0) {
394  initFail_ = true;
395  edm::LogError("CSCTFSectorProcessor")
396  << "maxdphi_accp13 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
397  }
398  if (m_mindeta112_accp < 0) {
399  initFail_ = true;
400  edm::LogError("CSCTFSectorProcessor")
401  << "mindeta_accp112 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
402  }
403  if (m_maxdeta112_accp < 0) {
404  initFail_ = true;
405  edm::LogError("CSCTFSectorProcessor")
406  << "maxdeta_accp112 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
407  }
408  if (m_maxdphi112_accp < 0) {
409  initFail_ = true;
410  edm::LogError("CSCTFSectorProcessor")
411  << "maxdphi_accp112 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
412  }
413  if (m_mindeta113_accp < 0) {
414  initFail_ = true;
415  edm::LogError("CSCTFSectorProcessor")
416  << "mindeta_accp113 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
417  }
418  if (m_maxdeta113_accp < 0) {
419  initFail_ = true;
420  edm::LogError("CSCTFSectorProcessor")
421  << "maxdeta_accp113 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
422  }
423  if (m_maxdphi113_accp < 0) {
424  initFail_ = true;
425  edm::LogError("CSCTFSectorProcessor")
426  << "maxdphi_accp113 parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
427  }
428  if (m_mindphip_halo < 0) {
429  initFail_ = true;
430  edm::LogError("CSCTFSectorProcessor")
431  << "mindphip_halo parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
432  }
433  if (m_mindetap_halo < 0) {
434  initFail_ = true;
435  edm::LogError("CSCTFSectorProcessor")
436  << "mindetep_halo parameter left uninitialized for endcap=" << m_endcap << ", sector=" << m_sector;
437  }
438 
439  if (m_widePhi < 0) {
440  initFail_ = true;
441  edm::LogError("CSCTFSectorProcessor")
442  << "widePhi parameter left unitialized for endcap=" << m_endcap << ", sector=" << m_sector;
443  }
444 
445  for (int index = 0; index < 8; index++)
446  if (m_etamax[index] < 0) {
447  initFail_ = true;
448  edm::LogError("CSCTFSectorProcessor")
449  << "Some (" << (8 - index) << ") of EtaMax parameters left uninitialized for endcap=" << m_endcap
450  << ", sector=" << m_sector;
451  }
452  for (int index = 0; index < 8; index++)
453  if (m_etamin[index] < 0) {
454  initFail_ = true;
455  edm::LogError("CSCTFSectorProcessor")
456  << "Some (" << (8 - index) << ") of EtaMin parameters left uninitialized for endcap=" << m_endcap
457  << ", sector=" << m_sector;
458  }
459  for (int index = 0; index < 7; index++)
460  if (m_etawin[index] < 0) {
461  initFail_ = true;
462  edm::LogError("CSCTFSectorProcessor")
463  << "Some (" << (6 - index) << ") of EtaWindows parameters left uninitialized for endcap=" << m_endcap
464  << ", sector=" << m_sector;
465  }
466  if (kill_fiber < 0) {
467  initFail_ = true;
468  edm::LogError("CSCTFTrackBuilder") << "kill_fiber parameter left uninitialized";
469  }
470  if (run_core < 0) {
471  initFail_ = true;
472  edm::LogError("CSCTFTrackBuilder") << "run_core parameter left uninitialized";
473  }
474  if (trigger_on_ME1a < 0) {
475  initFail_ = true;
476  edm::LogError("CSCTFTrackBuilder") << "trigger_on_ME1a parameter left uninitialized";
477  }
478  if (trigger_on_ME1b < 0) {
479  initFail_ = true;
480  edm::LogError("CSCTFTrackBuilder") << "trigger_on_ME1b parameter left uninitialized";
481  }
482  if (trigger_on_ME2 < 0) {
483  initFail_ = true;
484  edm::LogError("CSCTFTrackBuilder") << "trigger_on_ME2 parameter left uninitialized";
485  }
486  if (trigger_on_ME3 < 0) {
487  initFail_ = true;
488  edm::LogError("CSCTFTrackBuilder") << "trigger_on_ME3 parameter left uninitialized";
489  }
490  if (trigger_on_ME4 < 0) {
491  initFail_ = true;
492  edm::LogError("CSCTFTrackBuilder") << "trigger_on_ME4 parameter left uninitialized";
493  }
494  if (trigger_on_MB1a < 0) {
495  initFail_ = true;
496  edm::LogError("CSCTFTrackBuilder") << "trigger_on_MB1a parameter left uninitialized";
497  }
498  if (trigger_on_MB1d < 0) {
499  initFail_ = true;
500  edm::LogError("CSCTFTrackBuilder") << "trigger_on_MB1d parameter left uninitialized";
501  }
502  if (trigger_on_ME1a > 0 || trigger_on_ME1b > 0 || trigger_on_ME2 > 0 || trigger_on_ME3 > 0 || trigger_on_ME4 > 0 ||
503  trigger_on_MB1a > 0 || trigger_on_MB1d > 0) {
504  if (singlesTrackOutput == 999) {
505  initFail_ = true;
506  edm::LogError("CSCTFTrackBuilder") << "singlesTrackOutput parameter left uninitialized";
507  }
508  if (rescaleSinglesPhi < 0) {
509  initFail_ = true;
510  edm::LogError("CSCTFTrackBuilder") << "rescaleSinglesPhi parameter left uninitialized";
511  }
512  }
513  if (QualityEnableME1a < 0) {
514  initFail_ = true;
515  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME1a parameter left uninitialized";
516  }
517  if (QualityEnableME1b < 0) {
518  initFail_ = true;
519  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME1b parameter left uninitialized";
520  }
521  if (QualityEnableME1c < 0) {
522  initFail_ = true;
523  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME1c parameter left uninitialized";
524  }
525  if (QualityEnableME1d < 0) {
526  initFail_ = true;
527  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME1d parameter left uninitialized";
528  }
529  if (QualityEnableME1e < 0) {
530  initFail_ = true;
531  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME1e parameter left uninitialized";
532  }
533  if (QualityEnableME1f < 0) {
534  initFail_ = true;
535  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME1f parameter left uninitialized";
536  }
537  if (QualityEnableME2a < 0) {
538  initFail_ = true;
539  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME2a parameter left uninitialized";
540  }
541  if (QualityEnableME2b < 0) {
542  initFail_ = true;
543  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME2b parameter left uninitialized";
544  }
545  if (QualityEnableME2c < 0) {
546  initFail_ = true;
547  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME2c parameter left uninitialized";
548  }
549  if (QualityEnableME3a < 0) {
550  initFail_ = true;
551  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME3a parameter left uninitialized";
552  }
553  if (QualityEnableME3b < 0) {
554  initFail_ = true;
555  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME3b parameter left uninitialized";
556  }
557  if (QualityEnableME3c < 0) {
558  initFail_ = true;
559  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME3c parameter left uninitialized";
560  }
561  if (QualityEnableME4a < 0) {
562  initFail_ = true;
563  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME4a parameter left uninitialized";
564  }
565  if (QualityEnableME4b < 0) {
566  initFail_ = true;
567  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME4b parameter left uninitialized";
568  }
569  if (QualityEnableME4c < 0) {
570  initFail_ = true;
571  edm::LogError("CSCTFTrackBuilder") << "QualityEnableME4c parameter left uninitialized";
572  }
573 
574  if (m_firmSP < 1) {
575  initFail_ = true;
576  edm::LogError("CSCTFSectorProcessor") << " firmwareSP parameter left uninitialized!!!\n";
577  }
578  if (m_firmFA < 1) {
579  initFail_ = true;
580  edm::LogError("CSCTFSectorProcessor") << " firmwareFA parameter left uninitialized!!!\n";
581  }
582  if (m_firmDD < 1) {
583  initFail_ = true;
584  edm::LogError("CSCTFSectorProcessor") << " firmwareDD parameter left uninitialized!!!\n";
585  }
586  if (m_firmVM < 1) {
587  initFail_ = true;
588  edm::LogError("CSCTFSectorProcessor") << " firmwareVM parameter left uninitialized!!!\n";
589  }
590 
591  if ((m_firmFA != m_firmDD) || (m_firmFA != m_firmVM) || (m_firmDD != m_firmVM)) {
592  initFail_ = true;
593  edm::LogError("CSCTFSectorProcessor::initialize")
594  << " firmwareFA (=" << m_firmFA << "), "
595  << " firmwareDD (=" << m_firmDD << "), "
596  << " firmwareVM (=" << m_firmVM << ") are NOT identical: it shoultd NOT happen!\n";
597  }
598 }
599 
601  m_bxa_depth = pset.getParameter<unsigned>("BXAdepth");
602  m_allowALCTonly = (pset.getParameter<bool>("AllowALCTonly") ? 1 : 0);
603  m_allowCLCTonly = (pset.getParameter<bool>("AllowCLCTonly") ? 1 : 0);
604  m_preTrigger = pset.getParameter<unsigned>("PreTrigger");
605 
606  std::vector<unsigned>::const_iterator iter;
607  int index = 0;
608  std::vector<unsigned> etawins = pset.getParameter<std::vector<unsigned> >("EtaWindows");
609  for (iter = etawins.begin(), index = 0; iter != etawins.end() && index < 7; iter++, index++)
610  m_etawin[index] = *iter;
611  std::vector<unsigned> etamins = pset.getParameter<std::vector<unsigned> >("EtaMin");
612  for (iter = etamins.begin(), index = 0; iter != etamins.end() && index < 8; iter++, index++)
613  m_etamin[index] = *iter;
614  std::vector<unsigned> etamaxs = pset.getParameter<std::vector<unsigned> >("EtaMax");
615  for (iter = etamaxs.begin(), index = 0; iter != etamaxs.end() && index < 8; iter++, index++)
616  m_etamax[index] = *iter;
617 
618  m_mindphip = pset.getParameter<unsigned>("mindphip");
619  m_mindetap = pset.getParameter<unsigned>("mindetap");
620  m_straightp = pset.getParameter<unsigned>("straightp");
621  m_curvedp = pset.getParameter<unsigned>("curvedp");
622  m_mbaPhiOff = pset.getParameter<unsigned>("mbaPhiOff");
623  m_mbbPhiOff = pset.getParameter<unsigned>("mbbPhiOff");
624  m_widePhi = pset.getParameter<unsigned>("widePhi");
625  m_mindeta12_accp = pset.getParameter<unsigned>("mindeta12_accp");
626  m_maxdeta12_accp = pset.getParameter<unsigned>("maxdeta12_accp");
627  m_maxdphi12_accp = pset.getParameter<unsigned>("maxdphi12_accp");
628  m_mindeta13_accp = pset.getParameter<unsigned>("mindeta13_accp");
629  m_maxdeta13_accp = pset.getParameter<unsigned>("maxdeta13_accp");
630  m_maxdphi13_accp = pset.getParameter<unsigned>("maxdphi13_accp");
631  m_mindeta112_accp = pset.getParameter<unsigned>("mindeta112_accp");
632  m_maxdeta112_accp = pset.getParameter<unsigned>("maxdeta112_accp");
633  m_maxdphi112_accp = pset.getParameter<unsigned>("maxdphi112_accp");
634  m_mindeta113_accp = pset.getParameter<unsigned>("mindeta113_accp");
635  m_maxdeta113_accp = pset.getParameter<unsigned>("maxdeta113_accp");
636  m_maxdphi113_accp = pset.getParameter<unsigned>("maxdphi113_accp");
637  m_mindphip_halo = pset.getParameter<unsigned>("mindphip_halo");
638  m_mindetap_halo = pset.getParameter<unsigned>("mindetap_halo");
639  kill_fiber = pset.getParameter<unsigned>("kill_fiber");
640  run_core = pset.getParameter<bool>("run_core");
641  trigger_on_ME1a = pset.getParameter<bool>("trigger_on_ME1a");
642  trigger_on_ME1b = pset.getParameter<bool>("trigger_on_ME1b");
643  trigger_on_ME2 = pset.getParameter<bool>("trigger_on_ME2");
644  trigger_on_ME3 = pset.getParameter<bool>("trigger_on_ME3");
645  trigger_on_ME4 = pset.getParameter<bool>("trigger_on_ME4");
646  trigger_on_MB1a = pset.getParameter<bool>("trigger_on_MB1a");
647  trigger_on_MB1d = pset.getParameter<bool>("trigger_on_MB1d");
648 
649  singlesTrackOutput = pset.getParameter<unsigned int>("singlesTrackOutput");
650  rescaleSinglesPhi = pset.getParameter<bool>("rescaleSinglesPhi");
651  QualityEnableME1a = pset.getParameter<unsigned int>("QualityEnableME1a");
652  QualityEnableME1b = pset.getParameter<unsigned int>("QualityEnableME1b");
653  QualityEnableME1c = pset.getParameter<unsigned int>("QualityEnableME1c");
654  QualityEnableME1d = pset.getParameter<unsigned int>("QualityEnableME1d");
655  QualityEnableME1e = pset.getParameter<unsigned int>("QualityEnableME1e");
656  QualityEnableME1f = pset.getParameter<unsigned int>("QualityEnableME1f");
657  QualityEnableME2a = pset.getParameter<unsigned int>("QualityEnableME2a");
658  QualityEnableME2b = pset.getParameter<unsigned int>("QualityEnableME2b");
659  QualityEnableME2c = pset.getParameter<unsigned int>("QualityEnableME2c");
660  QualityEnableME3a = pset.getParameter<unsigned int>("QualityEnableME3a");
661  QualityEnableME3b = pset.getParameter<unsigned int>("QualityEnableME3b");
662  QualityEnableME3c = pset.getParameter<unsigned int>("QualityEnableME3c");
663  QualityEnableME4a = pset.getParameter<unsigned int>("QualityEnableME4a");
664  QualityEnableME4b = pset.getParameter<unsigned int>("QualityEnableME4b");
665  QualityEnableME4c = pset.getParameter<unsigned int>("QualityEnableME4c");
666 
667  m_firmSP = pset.getParameter<unsigned int>("firmwareSP");
668  m_firmFA = pset.getParameter<unsigned int>("firmwareFA");
669  m_firmDD = pset.getParameter<unsigned int>("firmwareDD");
670  m_firmVM = pset.getParameter<unsigned int>("firmwareVM");
671 }
672 
674  for (int i = 0; i < 5; ++i) {
675  if (srLUTs_[FPGAs[i]])
676  delete srLUTs_[FPGAs[i]]; // delete the pointer
677  srLUTs_[FPGAs[i]] = nullptr; // point it at a safe place
678  }
679 
680  delete core_;
681  core_ = nullptr;
682 
683  if (ptLUT_)
684  delete ptLUT_;
685  ptLUT_ = nullptr;
686 }
687 
688 //returns 0 for no tracks, 1 tracks found, and -1 for "exception" (what used to throw an exception)
689 // on -1, Producer should produce empty collections for event
691  if (initFail_)
692  return -1;
693 
694  if (!ptLUT_) {
695  edm::LogError("CSCTFSectorProcessor::run()")
696  << "No CSCTF PTLUTs: Initialize CSC TF LUTs first (missed call to CSCTFTrackProducer::beginJob?\n";
697  return -1;
698  }
699 
700  l1_tracks.clear();
701  dt_stubs.clear();
702  stub_vec_filtered.clear();
703 
704  std::vector<csctf::TrackStub> stub_vec = stubs.get();
705 
709  for (std::vector<csctf::TrackStub>::const_iterator itr = stub_vec.begin(); itr != stub_vec.end(); itr++)
710  switch (itr->station()) {
711  case 5:
712  stub_vec_filtered.push_back(*itr);
713  break; // DT stubs get filtered by the core controll register
714  case 4:
715  switch (itr->getMPCLink()) {
716  case 3:
717  if ((kill_fiber & 0x4000) == 0 && QualityEnableME4c & (1 << itr->getQuality()))
718  stub_vec_filtered.push_back(*itr);
719  break;
720  case 2:
721  if ((kill_fiber & 0x2000) == 0 && QualityEnableME4b & (1 << itr->getQuality()))
722  stub_vec_filtered.push_back(*itr);
723  break;
724  case 1:
725  if ((kill_fiber & 0x1000) == 0 && QualityEnableME4a & (1 << itr->getQuality()))
726  stub_vec_filtered.push_back(*itr);
727  break;
728  default:
729  edm::LogWarning("CSCTFSectorProcessor::run()")
730  << "No MPC sorting for LCT: link=" << itr->getMPCLink() << "\n";
731  }
732  break;
733  case 3:
734  switch (itr->getMPCLink()) {
735  case 3:
736  if ((kill_fiber & 0x0800) == 0 && QualityEnableME3c & (1 << itr->getQuality()))
737  stub_vec_filtered.push_back(*itr);
738  break;
739  case 2:
740  if ((kill_fiber & 0x0400) == 0 && QualityEnableME3b & (1 << itr->getQuality()))
741  stub_vec_filtered.push_back(*itr);
742  break;
743  case 1:
744  if ((kill_fiber & 0x0200) == 0 && QualityEnableME3a & (1 << itr->getQuality()))
745  stub_vec_filtered.push_back(*itr);
746  break;
747  default:
748  edm::LogWarning("CSCTFSectorProcessor::run()")
749  << "No MPC sorting for LCT: link=" << itr->getMPCLink() << "\n";
750  }
751  break;
752  case 2:
753  switch (itr->getMPCLink()) {
754  case 3:
755  if ((kill_fiber & 0x0100) == 0 && QualityEnableME2c & (1 << itr->getQuality()))
756  stub_vec_filtered.push_back(*itr);
757  break;
758  case 2:
759  if ((kill_fiber & 0x0080) == 0 && QualityEnableME2b & (1 << itr->getQuality()))
760  stub_vec_filtered.push_back(*itr);
761  break;
762  case 1:
763  if ((kill_fiber & 0x0040) == 0 && QualityEnableME2a & (1 << itr->getQuality()))
764  stub_vec_filtered.push_back(*itr);
765  break;
766  default:
767  edm::LogWarning("CSCTFSectorProcessor::run()")
768  << "No MPC sorting for LCT: link=" << itr->getMPCLink() << "\n";
769  }
770  break;
771  case 1:
772  switch (itr->getMPCLink() +
773  (3 * (CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(itr->getDetId().rawId())) - 1))) {
774  case 6:
775  if ((kill_fiber & 0x0020) == 0 && QualityEnableME1f & (1 << itr->getQuality()))
776  stub_vec_filtered.push_back(*itr);
777  break;
778  case 5:
779  if ((kill_fiber & 0x0010) == 0 && QualityEnableME1e & (1 << itr->getQuality()))
780  stub_vec_filtered.push_back(*itr);
781  break;
782  case 4:
783  if ((kill_fiber & 0x0008) == 0 && QualityEnableME1d & (1 << itr->getQuality()))
784  stub_vec_filtered.push_back(*itr);
785  break;
786  case 3:
787  if ((kill_fiber & 0x0004) == 0 && QualityEnableME1c & (1 << itr->getQuality()))
788  stub_vec_filtered.push_back(*itr);
789  break;
790  case 2:
791  if ((kill_fiber & 0x0002) == 0 && QualityEnableME1b & (1 << itr->getQuality()))
792  stub_vec_filtered.push_back(*itr);
793  break;
794  case 1:
795  if ((kill_fiber & 0x0001) == 0 && QualityEnableME1a & (1 << itr->getQuality()))
796  stub_vec_filtered.push_back(*itr);
797  break;
798  default:
799  edm::LogWarning("CSCTFSectorProcessor::run()")
800  << "No MPC sorting for LCT: link=" << itr->getMPCLink() << "\n";
801  }
802  break;
803  default:
804  edm::LogWarning("CSCTFSectorProcessor::run()") << "Invalid station # encountered: " << itr->station() << "\n";
805  }
806 
815  for (std::vector<csctf::TrackStub>::iterator itr = stub_vec_filtered.begin(); itr != stub_vec_filtered.end(); itr++) {
816  if (itr->station() != 5) {
817  CSCDetId id(itr->getDetId().rawId());
818  unsigned fpga = (id.station() == 1) ? CSCTriggerNumbering::triggerSubSectorFromLabels(id) - 1 : id.station();
819 
820  lclphidat lclPhi;
821  try {
822  lclPhi = srLUTs_[FPGAs[fpga]]->localPhi(
823  itr->getStrip(), itr->getPattern(), itr->getQuality(), itr->getBend(), m_gangedME1a);
824  } catch (cms::Exception& e) {
825  bzero(&lclPhi, sizeof(lclPhi));
826  edm::LogWarning("CSCTFSectorProcessor:run()")
827  << "Exception from LocalPhi LUT in " << FPGAs[fpga] << "(strip=" << itr->getStrip()
828  << ",pattern=" << itr->getPattern() << ",quality=" << itr->getQuality() << ",bend=" << itr->getBend() << ")"
829  << std::endl;
830  }
831 
832  gblphidat gblPhi;
833  try {
834  unsigned csc_id = itr->cscid();
835  if (!m_gangedME1a)
836  csc_id = itr->cscidSeparateME1a();
837  //std::cout << "station="<<id.station()<<" ring="<<id.ring()<<" strip="<<itr->getStrip()<<" WG="<<itr->getKeyWG()<<std::endl;
838  //std::cout << "csc_id=" << csc_id << std::endl;
839  gblPhi = srLUTs_[FPGAs[fpga]]->globalPhiME(lclPhi.phi_local, itr->getKeyWG(), csc_id, m_gangedME1a);
840 
841  } catch (cms::Exception& e) {
842  bzero(&gblPhi, sizeof(gblPhi));
843  edm::LogWarning("CSCTFSectorProcessor:run()")
844  << "Exception from GlobalPhi LUT in " << FPGAs[fpga] << "(phi_local=" << lclPhi.phi_local
845  << ",KeyWG=" << itr->getKeyWG() << ",csc=" << itr->cscid() << ")" << std::endl;
846  }
847 
848  gbletadat gblEta;
849  try {
850  unsigned csc_id = itr->cscid();
851  if (!m_gangedME1a)
852  csc_id = itr->cscidSeparateME1a();
853  gblEta = srLUTs_[FPGAs[fpga]]->globalEtaME(
854  lclPhi.phi_bend_local, lclPhi.phi_local, itr->getKeyWG(), csc_id, m_gangedME1a);
855  //gblEta = srLUTs_[FPGAs[fpga]]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, itr->getKeyWG(), itr->cscid());
856  } catch (cms::Exception& e) {
857  bzero(&gblEta, sizeof(gblEta));
858  edm::LogWarning("CSCTFSectorProcessor:run()")
859  << "Exception from GlobalEta LUT in " << FPGAs[fpga] << "(phi_bend_local=" << lclPhi.phi_bend_local
860  << ",phi_local=" << lclPhi.phi_local << ",KeyWG=" << itr->getKeyWG() << ",csc=" << itr->cscid() << ")"
861  << std::endl;
862  }
863 
864  gblphidat gblPhiDT;
865  try {
866  gblPhiDT = srLUTs_[FPGAs[fpga]]->globalPhiMB(lclPhi.phi_local, itr->getKeyWG(), itr->cscid(), m_gangedME1a);
867  } catch (cms::Exception& e) {
868  bzero(&gblPhiDT, sizeof(gblPhiDT));
869  edm::LogWarning("CSCTFSectorProcessor:run()")
870  << "Exception from GlobalPhi DT LUT in " << FPGAs[fpga] << "(phi_local=" << lclPhi.phi_local
871  << ",KeyWG=" << itr->getKeyWG() << ",csc=" << itr->cscid() << ")" << std::endl;
872  }
873 
874  itr->setEtaPacked(gblEta.global_eta);
875 
876  if (itr->station() == 1) {
877  //&& itr->cscId() > 6) { //only ring 3
878  itr->setPhiPacked(gblPhiDT.global_phi); // convert the DT to convert
879  dt_stubs.push_back(*itr); // send stubs to DT
880  }
881 
882  //reconvert the ME1 LCT to the CSCTF units.
883  //the same iterator is used to fill two containers,
884  //the CSCTF one (stub_vec_filtered) and LCTs sent to DTTF (dt_stubs)
885  itr->setPhiPacked(gblPhi.global_phi);
886 
887  LogDebug("CSCTFSectorProcessor:run()")
888  << "LCT found, processed by FPGA: " << FPGAs[fpga] << std::endl
889  << " LCT now has (eta, phi) of: (" << itr->etaValue() << "," << itr->phiValue() << ")\n";
890  }
891  }
892 
894 
901  std::vector<csc::L1Track> tftks;
902 
903  if (run_core) {
905  // core_->loadData(processedStubs, m_endcap, m_sector, m_minBX, m_maxBX, true);
906  if (core_->run(m_endcap,
907  m_sector,
908  m_latency,
909  m_etamin[0],
910  m_etamin[1],
911  m_etamin[2],
912  m_etamin[3],
913  m_etamin[4],
914  m_etamin[5],
915  m_etamin[6],
916  m_etamin[7],
917  m_etamax[0],
918  m_etamax[1],
919  m_etamax[2],
920  m_etamax[3],
921  m_etamax[4],
922  m_etamax[5],
923  m_etamax[6],
924  m_etamax[7],
925  m_etawin[0],
926  m_etawin[1],
927  m_etawin[2],
928  m_etawin[3],
929  m_etawin[4],
930  m_etawin[5],
931  m_etawin[6],
932  m_mindphip,
933  m_mindetap,
948  m_straightp,
949  m_curvedp,
950  m_mbaPhiOff,
951  m_mbbPhiOff,
952  m_bxa_depth,
955  m_preTrigger,
956  m_widePhi,
957  m_minBX,
958  m_maxBX)) {
959  l1_tracks = core_->tracks();
960  }
961 
962  tftks = l1_tracks.get();
963 
969  std::vector<csc::L1Track>::iterator titr = tftks.begin();
970 
971  for (; titr != tftks.end(); titr++) {
972  ptadd thePtAddress(titr->ptLUTAddress());
973  ptdat thePtData = ptLUT_->Pt(thePtAddress);
974  if (thePtAddress.track_fr) {
975  titr->setRank(thePtData.front_rank);
976  titr->setChargeValidPacked(thePtData.charge_valid_front);
977  } else {
978  titr->setRank(thePtData.rear_rank);
979  titr->setChargeValidPacked(thePtData.charge_valid_rear);
980  }
981 
982  if (((titr->ptLUTAddress() >> 16) & 0xf) == 15) {
983  int unmodBx = titr->bx();
984  titr->setBx(unmodBx + 2);
985  }
986  }
987  } //end of if(run_core)
988 
989  l1_tracks = tftks;
990 
991  // Add-on for singles:
992  CSCTriggerContainer<csctf::TrackStub> myStubContainer[7]; //[BX]
993  // Loop over CSC LCTs if triggering on them:
996  for (std::vector<csctf::TrackStub>::iterator itr = stub_vec_filtered.begin(); itr != stub_vec_filtered.end();
997  itr++) {
998  int station = itr->station() - 1;
999  if (station != 4) {
1000  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(itr->getDetId().rawId()));
1001  int mpc = (subSector ? subSector - 1 : station + 1);
1002  if ((mpc == 0 && trigger_on_ME1a) || (mpc == 1 && trigger_on_ME1b) || (mpc == 2 && trigger_on_ME2) ||
1003  (mpc == 3 && trigger_on_ME3) || (mpc == 4 && trigger_on_ME4) ||
1004  (mpc == 5 && ((trigger_on_MB1a && subSector % 2 == 1) || (trigger_on_MB1d && subSector % 2 == 0)))) {
1005  int bx = itr->getBX() - m_minBX;
1006  if (bx < 0 || bx >= 7)
1007  edm::LogWarning("CSCTFTrackBuilder::buildTracks()")
1008  << " LCT BX is out of [" << m_minBX << "," << m_maxBX << ") range: " << itr->getBX();
1009  else if (itr->isValid())
1010  myStubContainer[bx].push_back(*itr);
1011  }
1012  }
1013  }
1014 
1015  // Core's input was loaded in a relative time window BX=[0-7)
1016  // To relate it to time window of tracks (centred at BX=0) we introduce a shift:
1017  int shift = (m_maxBX + m_minBX) / 2 - m_minBX;
1018 
1019  // Now we put tracks from singles in a certain bx
1020  // if there were no tracks from the core in this endcap/sector/bx
1021  CSCTriggerContainer<csc::L1Track> tracksFromSingles;
1022  for (int bx = 0; bx < 7; bx++)
1023  if (!myStubContainer[bx].get().empty()) { // VP in this bx
1024  bool coreTrackExists = false;
1025  // tracks are not ordered to be accessible by bx => loop them all
1026  std::vector<csc::L1Track> tracks = l1_tracks.get();
1027  for (std::vector<csc::L1Track>::iterator trk = tracks.begin(); trk < tracks.end(); trk++)
1028  if ((trk->BX() == bx - shift && trk->outputLink() == singlesTrackOutput) ||
1029  (((trk->ptLUTAddress() >> 16) & 0xf) == 15 && trk->BX() - 2 == bx - shift)) {
1030  coreTrackExists = true;
1031  break;
1032  }
1033  if (coreTrackExists == false) {
1034  csc::L1TrackId trackId(m_endcap, m_sector);
1035  csc::L1Track track(trackId);
1036  track.setBx(bx - shift);
1038  //CSCCorrelatedLCTDigiCollection singles;
1039  std::vector<csctf::TrackStub> stubs = myStubContainer[bx].get();
1040  // Select best quality stub, and assign its eta/phi coordinates to the track
1041  int qualityME = 0, qualityMB = 0, ME = 100, MB = 100, linkME = 7;
1042  std::vector<csctf::TrackStub>::const_iterator bestStub = stubs.end();
1043  for (std::vector<csctf::TrackStub>::const_iterator st_iter = stubs.begin(); st_iter != stubs.end(); st_iter++) {
1044  int station = st_iter->station() - 1;
1045  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(st_iter->getDetId().rawId()));
1046  int mpc = (subSector ? subSector - 1 : station + 1);
1047  // Sort MB stubs first (priority: quality OR MB1a > MB1b for the same quality)
1048  if (mpc == 5 &&
1049  (st_iter->getQuality() > qualityMB || (st_iter->getQuality() == qualityMB && subSector < MB))) {
1050  qualityMB = st_iter->getQuality();
1051  MB = subSector;
1052  if (ME > 4)
1053  bestStub = st_iter; // do not select this stub if ME already had any candidate
1054  }
1055  // Sort ME stubs (priority: quality OR ME1a > ME1b > ME2 > ME3 > ME4 for the same quality)
1056  if (mpc < 5 && (st_iter->getQuality() > qualityME || (st_iter->getQuality() == qualityME && mpc < ME) ||
1057  (st_iter->getQuality() == qualityME && mpc == ME && st_iter->getMPCLink() < linkME))) {
1058  qualityME = st_iter->getQuality();
1059  ME = mpc;
1060  linkME = st_iter->getMPCLink();
1061  bestStub = st_iter;
1062  }
1063  }
1064  unsigned rescaled_phi = 999;
1065  if (m_firmSP <= 20100210) {
1066  // buggy implementation of the phi for singles in the wrapper...
1067  // at the end data/emulator have to agree: e.g. wrong in the same way
1068  // BUG: getting the lowest 7 bits instead the 7 most significant ones.
1069  rescaled_phi = unsigned(24 * (bestStub->phiPacked() & 0x7f) / 128.);
1070  } else {
1071  // correct implementation :-)
1072  rescaled_phi = unsigned(24 * (bestStub->phiPacked() >> 5) / 128.);
1073  }
1074 
1075  unsigned unscaled_phi = bestStub->phiPacked() >> 7;
1076  track.setLocalPhi(rescaleSinglesPhi ? rescaled_phi : unscaled_phi);
1077  track.setEtaPacked((bestStub->etaPacked() >> 2) & 0x1f);
1078  switch (bestStub->station()) {
1079  case 1:
1080  track.setStationIds(bestStub->getMPCLink(), 0, 0, 0, 0);
1081  break;
1082  case 2:
1083  track.setStationIds(0, bestStub->getMPCLink(), 0, 0, 0);
1084  break;
1085  case 3:
1086  track.setStationIds(0, 0, bestStub->getMPCLink(), 0, 0);
1087  break;
1088  case 4:
1089  track.setStationIds(0, 0, 0, bestStub->getMPCLink(), 0);
1090  break;
1091  case 5:
1092  track.setStationIds(0, 0, 0, 0, bestStub->getMPCLink());
1093  break;
1094  default:
1095  edm::LogError("CSCTFSectorProcessor::run()") << "Illegal LCT link=" << bestStub->station() << "\n";
1096  break;
1097  }
1098  // singles.insertDigi(CSCDetId(st_iter->getDetId().rawId()),*st_iter);
1099  //tracksFromSingles.push_back(L1CSCTrack(track,singles));
1100  track.setPtLUTAddress((1 << 16) | ((bestStub->etaPacked() << 9) & 0xf000));
1101  ptadd thePtAddress(track.ptLUTAddress());
1102  ptdat thePtData = ptLUT_->Pt(thePtAddress);
1103  if (thePtAddress.track_fr) {
1104  track.setRank(thePtData.front_rank);
1105  track.setChargeValidPacked(thePtData.charge_valid_front);
1106  } else {
1107  track.setRank(thePtData.rear_rank);
1108  track.setChargeValidPacked(thePtData.charge_valid_rear);
1109  }
1110  tracksFromSingles.push_back(track);
1111  }
1112  }
1113  std::vector<csc::L1Track> single_tracks = tracksFromSingles.get();
1114  if (!single_tracks.empty())
1115  l1_tracks.push_many(single_tracks);
1116  // End of add-on for singles
1117 
1118  return (!l1_tracks.get().empty());
1119 }
1120 
1121 // according to the firmware versions print some more information
1122 void CSCTFSectorProcessor::printDisclaimer(int firmSP, int firmFA) {
1123  edm::LogInfo("CSCTFSectorProcessor") << "\n\n"
1124  << "******************************* \n"
1125  << "*** DISCLAIMER *** \n"
1126  << "******************************* \n"
1127  << "\n Firmware SP version (year+month+day)=" << firmSP
1128  << "\n Firmware FA/VM/DD version (year+month+day)=" << firmFA;
1129  if (firmSP == 20100210)
1130  edm::LogInfo("CSCTFSectorProcessor") << " -> KNOWN BUGS IN THE FIRMWARE:\n"
1131  << "\t * Wrong phi assignment for singles\n"
1132  << "\t * Wrapper passes to the core only even quality DT stubs\n"
1133  << "\n -> BUGS ARE GOING TO BE EMULATED BY THE SOFTWARE\n\n";
1134 
1135  else
1136  edm::LogInfo("CSCTFSectorProcessor") << "\t * Correct phi assignment for singles\n";
1137 
1138  if (firmSP == 20100629) {
1139  edm::LogInfo("CSCTFSectorProcessor") << "\t * Correct MB quality masking in the wrapper\n"
1140  << "\t * Core is 20100122\n";
1141  }
1142 
1143  if (firmSP == 20100728)
1144  edm::LogInfo("CSCTFSectorProcessor") << "\t * Inverted MB clocks\n";
1145 
1146  if (firmSP == 20100901)
1147  edm::LogInfo("CSCTFSectorProcessor") << "\t * Inverted charge bit\n";
1148 
1149  if (firmSP == 20101011)
1150  edm::LogInfo("CSCTFSectorProcessor") << "\t **** WARNING THIS FIRMWARE IS UNDER TEST ****\n"
1151  << "\t * Added CSC-DT assembling tracks ME1-MB2/1 \n";
1152  if (firmSP == 20101210)
1153  edm::LogInfo("CSCTFSectorProcessor") << "\t **** WARNING THIS FIRMWARE IS UNDER TEST ****\n"
1154  << "\t * New Ghost Busting Algorithm Removing Tracks\n"
1155  << "\t Sharing at Least One LCT\n";
1156 
1157  if (firmSP == 20110118)
1158  edm::LogInfo("CSCTFSectorProcessor") << "\t **** WARNING THIS FIRMWARE IS UNDER TEST ****\n"
1159  << "\t * New Ghost Busting Algorithm Removing Tracks\n"
1160  << "\t Sharing at Least One LCT\n"
1161  << "\t * Passing CLCT and PhiBend for PT LUTs\n";
1162  if (firmSP == 20120131)
1163  edm::LogInfo("CSCTFSectorProcessor") << "\t **** WARNING THIS FIRMWARE IS UNDER TEST ****\n"
1164  << "\t * non-linear dphi12 dphi23, use deta for PTLUTs \n";
1165 }
T getUntrackedParameter(std::string const &, T const &) const
void setLocalPhi(const unsigned &lphi)
Definition: L1Track.h:38
void loadData(const CSCTriggerContainer< csctf::TrackStub > &, const unsigned &endcap, const unsigned &sector, const int &minBX, const int &maxBX, const bool gangedME1a)
std::vector< T > get() const
ptdat Pt(const ptadd &) const
Definition: CSCTFPtLUT.cc:178
const edm::EventSetup & c
CSCTriggerContainer< csctf::TrackStub > dt_stubs
uint16_t *__restrict__ id
CSCTFSPCoreLogic * core_
void readParameters(const edm::ParameterSet &pset)
std::vector< csctf::TrackStub > stub_vec_filtered
void setPtLUTAddress(const unsigned &adr)
Definition: L1Track.h:60
void printDisclaimer(int firmSP, int firmFA)
Log< level::Error, false > LogError
static const std::string FPGAs[5]
void setChargeValidPacked(unsigned valid)
Set Charge Valid.
void push_back(const T &data)
static Tokens consumes(edm::ConsumesCollector iC)
Definition: CSCTFPtLUT.cc:87
int run(const CSCTriggerContainer< csctf::TrackStub > &)
void setRank(const unsigned &rank)
Definition: L1Track.h:35
bool getData(T &iHolder) const
Definition: EventSetup.h:122
Definition: ME.h:11
static Tokens consumes(const edm::ParameterSet &pset, edm::ConsumesCollector iC)
void setBx(int bx)
Set Bunch Crossing.
bool run(const unsigned &endcap, const unsigned &sector, const unsigned &latency, const unsigned &etamin1, const unsigned &etamin2, const unsigned &etamin3, const unsigned &etamin4, const unsigned &etamin5, const unsigned &etamin6, const unsigned &etamin7, const unsigned &etamin8, const unsigned &etamax1, const unsigned &etamax2, const unsigned &etamax3, const unsigned &etamax4, const unsigned &etamax5, const unsigned &etamax6, const unsigned &etamax7, const unsigned &etamax8, const unsigned &etawin1, const unsigned &etawin2, const unsigned &etawin3, const unsigned &etawin4, const unsigned &etawin5, const unsigned &etawin6, const unsigned &etawin7, const unsigned &mindphip, const unsigned &mindetap, const unsigned &mindeta12_accp, const unsigned &maxdeta12_accp, const unsigned &maxdphi12_accp, const unsigned &mindeta13_accp, const unsigned &maxdeta13_accp, const unsigned &maxdphi13_accp, const unsigned &mindeta112_accp, const unsigned &maxdeta112_accp, const unsigned &maxdphi112_accp, const unsigned &mindeta113_accp, const unsigned &maxdeta113_accp, const unsigned &maxdphi113_accp, const unsigned &mindphip_halo, const unsigned &mindetap_halo, const unsigned &straightp, const unsigned &curvedp, const unsigned &mbaPhiOff, const unsigned &mbbPhiOff, const unsigned &m_extend_length, const unsigned &m_allowALCTonly, const unsigned &m_allowCLCTonly, const unsigned &m_preTrigger, const unsigned &m_widePhi, const int &minBX, const int &maxBX)
unsigned ptLUTAddress() const
Definition: L1Track.h:58
void SetSPFirmwareVersion(const unsigned int fwVer)
CSCTriggerContainer< csc::L1Track > l1_tracks
unsigned int GetCoreFirmwareVersion()
void push_many(const std::vector< T > &data)
edm::ESGetToken< L1MuCSCTFConfiguration, L1MuCSCTFConfigurationRcd > config
Log< level::Info, false > LogInfo
std::map< std::string, CSCSectorReceiverLUT * > srLUTs_
class pt_address ptadd
class pt_data ptdat
CSCTFSectorProcessor(const unsigned &endcap, const unsigned &sector, const edm::ParameterSet &pset, bool tmb07, const L1MuTriggerScales *scales, const L1MuTriggerPtScale *ptScale)
class global_phi_data gblphidat
void setOutputLink(unsigned oPL)
Definition: L1Track.h:64
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void SetCoreFirmwareVersion(const unsigned int fwVer)
class local_phi_data lclphidat
Data Types.
const std::vector< double > ptScale
Definition: Utilities.cc:33
static int triggerSubSectorFromLabels(int station, int chamber)
CSCTriggerContainer< csc::L1Track > tracks() const
deadvectors[0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
tuple config
parse the configuration file
void setEtaPacked(unsigned eta)
Set Eta: 6-bit code.
void SetVerbose(const bool verb)
void initialize(const edm::EventSetup &c, const Tokens &tokens)
KK.
dqm::harvesting::MonitorElement ME
static unsigned int const shift
void setStationIds(const unsigned &me1, const unsigned &me2, const unsigned &me3, const unsigned &me4, const unsigned &mb1)
Definition: L1Track.cc:102
Log< level::Warning, false > LogWarning
CSCTriggerContainer< csc::L1Track > tracks()
class global_eta_data gbletadat
std::map< int, int > firmSP_Map
#define LogDebug(id)