00001 #include <L1Trigger/CSCTrackFinder/interface/CSCTFSectorProcessor.h>
00002 #include <L1Trigger/CSCTrackFinder/interface/CSCTrackFinderDataTypes.h>
00003 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00004
00005 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00006
00007 #include "CondFormats/L1TObjects/interface/L1MuCSCTFConfiguration.h"
00008 #include "CondFormats/DataRecord/interface/L1MuCSCTFConfigurationRcd.h"
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 #include <stdlib.h>
00011 #include <sstream>
00012 #include <strings.h>
00013
00014 const std::string CSCTFSectorProcessor::FPGAs[5] = {"F1","F2","F3","F4","F5"};
00015
00016 CSCTFSectorProcessor::CSCTFSectorProcessor(const unsigned& endcap,
00017 const unsigned& sector,
00018 const edm::ParameterSet& pset,
00019 bool tmb07,
00020 const L1MuTriggerScales* scales,
00021 const L1MuTriggerPtScale* ptScale)
00022 {
00023 m_endcap = endcap;
00024 m_sector = sector;
00025 TMB07 = tmb07;
00026
00027
00028 m_gangedME1a = pset.getUntrackedParameter<bool>("gangedME1a", true);
00029
00030
00031 m_latency = pset.getParameter<unsigned>("CoreLatency");
00032 m_minBX = pset.getParameter<int>("MinBX");
00033 m_maxBX = pset.getParameter<int>("MaxBX");
00034 initializeFromPSet = pset.getParameter<bool>("initializeFromPSet");
00035 if( m_maxBX-m_minBX >= 7 ) edm::LogWarning("CSCTFTrackBuilder::ctor")<<" BX window width >= 7BX. Resetting m_maxBX="<<(m_maxBX=m_minBX+6);
00036
00037
00038 m_bxa_depth = -1;
00039 m_allowALCTonly = -1;
00040 m_allowCLCTonly = -1;
00041 m_preTrigger = -1;
00042
00043 for(int index=0; index<7; index++) m_etawin[index] = -1;
00044 for(int index=0; index<8; index++) m_etamin[index] = -1;
00045 for(int index=0; index<8; index++) m_etamax[index] = -1;
00046
00047 m_mindphip=-1;
00048 m_mindetap=-1;
00049
00050 m_mindeta12_accp=-1;
00051 m_maxdeta12_accp=-1;
00052 m_maxdphi12_accp=-1;
00053
00054 m_mindeta13_accp=-1;
00055 m_maxdeta13_accp=-1;
00056 m_maxdphi13_accp=-1;
00057
00058 m_mindeta112_accp=-1;
00059 m_maxdeta112_accp=-1;
00060 m_maxdphi112_accp=-1;
00061
00062 m_mindeta113_accp=-1;
00063 m_maxdeta113_accp=-1;
00064 m_maxdphi113_accp=-1;
00065 m_mindphip_halo=-1;
00066 m_mindetap_halo=-1;
00067
00068 m_widePhi=-1;
00069
00070 m_straightp=-1;
00071 m_curvedp=-1;
00072
00073 m_mbaPhiOff=-1;
00074 m_mbbPhiOff=-1;
00075
00076 kill_fiber = -1;
00077 QualityEnableME1a = -1;
00078 QualityEnableME1b = -1;
00079 QualityEnableME1c = -1;
00080 QualityEnableME1d = -1;
00081 QualityEnableME1e = -1;
00082 QualityEnableME1f = -1;
00083 QualityEnableME2a = -1;
00084 QualityEnableME2b = -1;
00085 QualityEnableME2c = -1;
00086 QualityEnableME3a = -1;
00087 QualityEnableME3b = -1;
00088 QualityEnableME3c = -1;
00089 QualityEnableME4a = -1;
00090 QualityEnableME4b = -1;
00091 QualityEnableME4c = -1;
00092
00093 run_core = -1;
00094 trigger_on_ME1a = -1;
00095 trigger_on_ME1b = -1;
00096 trigger_on_ME2 = -1;
00097 trigger_on_ME3 = -1;
00098 trigger_on_ME4 = -1;
00099 trigger_on_MB1a = -1;
00100 trigger_on_MB1d = -1;
00101
00102 singlesTrackOutput = 999;
00103 rescaleSinglesPhi = -1;
00104
00105 m_firmSP = -1;
00106 m_firmFA = -1;
00107 m_firmDD = -1;
00108 m_firmVM = -1;
00109
00110 initFail_ = false;
00111
00112 isCoreVerbose = pset.getParameter<bool>("isCoreVerbose");
00113
00114 if(initializeFromPSet) readParameters(pset);
00115
00116
00117
00118 edm::ParameterSet srLUTset = pset.getParameter<edm::ParameterSet>("SRLUT");
00119 for(int i = 1; i <= 4; ++i)
00120 {
00121 if(i == 1)
00122 for(int j = 0; j < 2; j++)
00123 {
00124 srLUTs_[FPGAs[j]] = new CSCSectorReceiverLUT(endcap, sector, j+1, i, srLUTset, TMB07);
00125 }
00126 else
00127 srLUTs_[FPGAs[i]] = new CSCSectorReceiverLUT(endcap, sector, 0, i, srLUTset, TMB07);
00128 }
00129
00130 core_ = new CSCTFSPCoreLogic();
00131
00132
00133 if(initializeFromPSet){
00134 edm::ParameterSet ptLUTset = pset.getParameter<edm::ParameterSet>("PTLUT");
00135 ptLUT_ = new CSCTFPtLUT(ptLUTset, scales, ptScale);
00136 LogDebug("CSCTFSectorProcessor") << "Using stand-alone PT LUT for endcap="<<m_endcap<<", sector="<<m_sector;
00137 } else {
00138 ptLUT_=0;
00139 LogDebug("CSCTFSectorProcessor") << "Looking for PT LUT in EventSetup for endcap="<<m_endcap<<", sector="<<m_sector;
00140 }
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 firmSP_Map.insert(std::pair<int,int>(20100210,20100122));
00153 firmSP_Map.insert(std::pair<int,int>(20100617,20100122));
00154 firmSP_Map.insert(std::pair<int,int>(20100629,20100122));
00155
00156 firmSP_Map.insert(std::pair<int,int>(20100728,20100728));
00157
00158 firmSP_Map.insert(std::pair<int,int>(20100901,20100901));
00159
00160
00161 firmSP_Map.insert(std::pair<int,int>(20101011,20101011));
00162 firmSP_Map.insert(std::pair<int,int>(20101210,20101210));
00163 firmSP_Map.insert(std::pair<int,int>(20110204,20110118));
00164 firmSP_Map.insert(std::pair<int,int>(20110322,20110118));
00165
00166 firmSP_Map.insert(std::pair<int,int>(20120131,20120131));
00167 firmSP_Map.insert(std::pair<int,int>(20120227,20120131));
00168
00169 firmSP_Map.insert(std::pair<int,int>(20120313,20120313));
00170 firmSP_Map.insert(std::pair<int,int>(20120319,20120313));
00171
00172 firmSP_Map.insert(std::pair<int,int>(20120730,20120730));
00173 }
00174
00175
00176 void CSCTFSectorProcessor::initialize(const edm::EventSetup& c){
00177 initFail_ = false;
00178 if(!initializeFromPSet){
00179
00180 LogDebug("CSCTFSectorProcessor") <<"Initializing endcap: "<<m_endcap<<" sector:"<<m_sector << "SP:" << (m_endcap-1)*6+(m_sector-1);
00181 LogDebug("CSCTFSectorProcessor") << "Initializing pT LUT from EventSetup";
00182
00183 ptLUT_ = new CSCTFPtLUT(c);
00184
00185
00186 edm::ESHandle<L1MuCSCTFConfiguration> config;
00187 c.get<L1MuCSCTFConfigurationRcd>().get(config);
00188
00189 readParameters(config.product()->parameters((m_endcap-1)*6+(m_sector-1)));
00190 }
00191
00192
00193
00194
00195 LogDebug("CSCTFSectorProcessor") << "\n !!! CSCTF EMULATOR CONFIGURATION !!!"
00196 << "\n\nCORE CONFIGURATION"
00197 << "\n Coincidence Trigger? " << run_core
00198 << "\n Singles in ME1a? " << trigger_on_ME1a
00199 << "\n Singles in ME1b? " << trigger_on_ME1b
00200 << "\n Singles in ME2? " << trigger_on_ME2
00201 << "\n Singles in ME3? " << trigger_on_ME3
00202 << "\n Singles in ME4? " << trigger_on_ME4
00203 << "\n Singles in MB1a? " << trigger_on_MB1a
00204 << "\n Singles in MB1d? " << trigger_on_MB1d
00205
00206 << "\n BX Analyzer depth: assemble coinc. track with stubs in +/-" << m_bxa_depth << " Bxs"
00207 << "\n Is Wide Phi Extrapolation (DeltaPhi valid up to ~15 degrees, otherwise ~7.67 degrees)? " << m_widePhi
00208 << "\n PreTrigger=" << m_preTrigger
00209
00210 << "\n CoreLatency=" << m_latency
00211 << "\n Is Phi for singles rescaled? " << rescaleSinglesPhi
00212
00213 << "\n\nVARIOUS CONFIGURATION PARAMETERS"
00214 << "\n Allow ALCT only? " << m_allowALCTonly
00215 << "\n Allow CLCT only? " << m_allowCLCTonly
00216
00217 << "\nQualityEnableME1a (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1a
00218 << "\nQualityEnableME1b (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1b
00219 << "\nQualityEnableME1c (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1c
00220 << "\nQualityEnableME1d (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1d
00221 << "\nQualityEnableME1e (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1e
00222 << "\nQualityEnableME1f (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME1f
00223 << "\nQualityEnableME2a (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME2a
00224 << "\nQualityEnableME2b (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME2b
00225 << "\nQualityEnableME2c (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME2c
00226 << "\nQualityEnableME3a (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME3a
00227 << "\nQualityEnableME3b (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME3b
00228 << "\nQualityEnableME3c (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME3c
00229 << "\nQualityEnableME4a (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME4a
00230 << "\nQualityEnableME4b (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME4b
00231 << "\nQualityEnableME4c (in general accept all LCT qualities, i.e. 0xFFFF is expected)=" << QualityEnableME4c
00232
00233 << "\nkill_fiber=" << kill_fiber
00234 << "\nSingles Output Link=" << singlesTrackOutput
00235
00236
00237
00238
00239 << "\n\nDAT_ETA REGISTERS"
00240 << "\nMinimum eta difference for track cancellation logic=" << m_mindetap
00241 << "\nMinimum eta difference for halo track cancellation logic=" << m_mindetap_halo
00242
00243 << "\nMinimum eta for ME1-ME2 collision tracks=" << m_etamin[0]
00244 << "\nMinimum eta for ME1-ME3 collision tracks=" << m_etamin[1]
00245 << "\nMinimum eta for ME2-ME3 collision tracks=" << m_etamin[2]
00246 << "\nMinimum eta for ME2-ME4 collision tracks=" << m_etamin[3]
00247 << "\nMinimum eta for ME3-ME4 collision tracks=" << m_etamin[4]
00248 << "\nMinimum eta for ME1-ME2 collision tracks in overlap region=" << m_etamin[5]
00249 << "\nMinimum eta for ME2-MB1 collision tracks=" << m_etamin[6]
00250 << "\nMinimum eta for ME1-ME4 collision tracks=" << m_etamin[7]
00251
00252 << "\nMinimum eta difference for ME1-ME2 (except ME1/1) halo tracks=" << m_mindeta12_accp
00253 << "\nMinimum eta difference for ME1-ME3 (except ME1/1) halo tracks=" << m_mindeta13_accp
00254 << "\nMinimum eta difference for ME1/1-ME2 halo tracks=" << m_mindeta112_accp
00255 << "\nMinimum eta difference for ME1/1-ME3 halo tracks=" << m_mindeta113_accp
00256
00257 << "\nMaximum eta for ME1-ME2 collision tracks=" << m_etamax[0]
00258 << "\nMaximum eta for ME1-ME3 collision tracks=" << m_etamax[1]
00259 << "\nMaximum eta for ME2-ME3 collision tracks=" << m_etamax[2]
00260 << "\nMaximum eta for ME2-ME4 collision tracks=" << m_etamax[3]
00261 << "\nMaximum eta for ME3-ME4 collision tracks=" << m_etamax[4]
00262 << "\nMaximum eta for ME1-ME2 collision tracks in overlap region=" << m_etamax[5]
00263 << "\nMaximum eta for ME2-MB1 collision tracks=" << m_etamax[6]
00264 << "\nMaximum eta for ME1-ME4 collision tracks=" << m_etamax[7]
00265
00266 << "\nMaximum eta difference for ME1-ME2 (except ME1/1) halo tracks=" << m_maxdeta12_accp
00267 << "\nMaximum eta difference for ME1-ME3 (except ME1/1) halo tracks=" << m_maxdeta13_accp
00268 << "\nMaximum eta difference for ME1/1-ME2 halo tracks=" << m_maxdeta112_accp
00269 << "\nMaximum eta difference for ME1/1-ME3 halo tracks=" << m_maxdeta113_accp
00270
00271 << "\nEta window for ME1-ME2 collision tracks=" << m_etawin[0]
00272 << "\nEta window for ME1-ME3 collision tracks=" << m_etawin[1]
00273 << "\nEta window for ME2-ME3 collision tracks=" << m_etawin[2]
00274 << "\nEta window for ME2-ME4 collision tracks=" << m_etawin[3]
00275 << "\nEta window for ME3-ME4 collision tracks=" << m_etawin[4]
00276 << "\nEta window for ME1-ME2 collision tracks in overlap region=" << m_etawin[5]
00277 << "\nEta window for ME1-ME4 collision tracks=" << m_etawin[6]
00278
00279 << "\nMaximum phi difference for ME1-ME2 (except ME1/1) halo tracks=" << m_maxdphi12_accp
00280 << "\nMaximum phi difference for ME1-ME3 (except ME1/1) halo tracks=" << m_maxdphi13_accp
00281 << "\nMaximum phi difference for ME1/1-ME2 halo tracks=" << m_maxdphi112_accp
00282 << "\nMaximum phi difference for ME1/1-ME3 halo tracks=" << m_maxdphi113_accp
00283
00284 << "\nMinimum phi difference for track cancellation logic=" << m_mindphip
00285 << "\nMinimum phi difference for halo track cancellation logic=" << m_mindphip_halo
00286
00287 << "\nParameter for the correction of misaligned 1-2-3-4 straight tracks =" << m_straightp
00288 << "\nParameter for the correction of misaligned 1-2-3-4 curved tracks=" << m_curvedp
00289 << "\nPhi Offset for MB1A=" << m_mbaPhiOff
00290 << "\nPhi Offset for MB1D=" << m_mbbPhiOff
00291
00292 << "\nFirmware SP year+month+day:" << m_firmSP
00293 << "\nFirmware FA year+month+day:" << m_firmFA
00294 << "\nFirmware DD year+month+day:" << m_firmDD
00295 << "\nFirmware VM year+month+day:" << m_firmVM;
00296
00297
00298 printDisclaimer(m_firmSP,m_firmFA);
00299
00300
00301
00302 core_ -> SetVerbose(isCoreVerbose);
00303
00304
00305 core_ -> SetSPFirmwareVersion (m_firmSP);
00306
00307
00308 int firmVersCore = firmSP_Map.find(m_firmSP)->second;
00309 core_ -> SetCoreFirmwareVersion (firmVersCore);
00310 edm::LogInfo( "CSCTFSectorProcessor" ) << "\nCore Firmware is set to " << core_ -> GetCoreFirmwareVersion();
00311
00312
00313
00314 if(m_bxa_depth<0)
00315 {
00316 initFail_ = true;
00317 edm::LogError("CSCTFSectorProcessor")<<"BXAdepth parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00318 }
00319 if(m_allowALCTonly<0)
00320 {
00321 initFail_ = true;
00322 edm::LogError("CSCTFSectorProcessor")<<"AllowALCTonly parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00323 }
00324 if(m_allowCLCTonly<0)
00325 {
00326 initFail_ = true;
00327 edm::LogError("CSCTFSectorProcessor")<<"AllowCLCTonly parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00328 }
00329 if(m_preTrigger<0)
00330 {
00331 initFail_ = true;
00332 edm::LogError("CSCTFSectorProcessor")<<"PreTrigger parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00333 }
00334 if(m_mindphip<0)
00335 {
00336 initFail_ = true;
00337 edm::LogError("CSCTFSectorProcessor")<<"mindphip parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00338 }
00339 if(m_mindetap<0)
00340 {
00341 initFail_ = true;
00342 edm::LogError("CSCTFSectorProcessor")<<"mindeta parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00343 }
00344 if(m_straightp<0)
00345 {
00346 initFail_ = true;
00347 edm::LogError("CSCTFSectorProcessor")<<"straightp parameter left unitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00348 }
00349 if(m_curvedp<0)
00350 {
00351 initFail_ = true;
00352 edm::LogError("CSCTFSectorProcessor")<<"curvedp parameter left unitialized for endcap="<<m_endcap<<",sector="<<m_sector;
00353 }
00354 if(m_mbaPhiOff<0)
00355 {
00356 initFail_ = true;
00357 edm::LogError("CSCTFSectorProcessor")<<"mbaPhiOff parameter left unitialized for endcap="<<m_endcap<<",sector="<<m_sector;
00358 }
00359 if(m_mbbPhiOff<0)
00360 {
00361 initFail_ = true;
00362 edm::LogError("CSCTFSectorProcessor")<<"mbbPhiOff parameter left unitialized for endcap="<<m_endcap<<",sector="<<m_sector;
00363 }
00364 if(m_mindeta12_accp<0)
00365 {
00366 initFail_ = true;
00367 edm::LogError("CSCTFSectorProcessor")<<"mindeta_accp12 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00368 }
00369 if(m_maxdeta12_accp<0)
00370 {
00371 initFail_ = true;
00372 edm::LogError("CSCTFSectorProcessor")<<"maxdeta_accp12 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00373 }
00374 if(m_maxdphi12_accp<0)
00375 {
00376 initFail_ = true;
00377 edm::LogError("CSCTFSectorProcessor")<<"maxdphi_accp12 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00378 }
00379 if(m_mindeta13_accp<0)
00380 {
00381 initFail_ = true;
00382 edm::LogError("CSCTFSectorProcessor")<<"mindeta_accp13 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00383 }
00384 if(m_maxdeta13_accp<0)
00385 {
00386 initFail_ = true;
00387 edm::LogError("CSCTFSectorProcessor")<<"maxdeta_accp13 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00388 }
00389 if(m_maxdphi13_accp<0)
00390 {
00391 initFail_ = true;
00392 edm::LogError("CSCTFSectorProcessor")<<"maxdphi_accp13 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00393 }
00394 if(m_mindeta112_accp<0)
00395 {
00396 initFail_ = true;
00397 edm::LogError("CSCTFSectorProcessor")<<"mindeta_accp112 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00398 }
00399 if(m_maxdeta112_accp<0)
00400 {
00401 initFail_ = true;
00402 edm::LogError("CSCTFSectorProcessor")<<"maxdeta_accp112 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00403 }
00404 if(m_maxdphi112_accp<0)
00405 {
00406 initFail_ = true;
00407 edm::LogError("CSCTFSectorProcessor")<<"maxdphi_accp112 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00408 }
00409 if(m_mindeta113_accp<0)
00410 {
00411 initFail_ = true;
00412 edm::LogError("CSCTFSectorProcessor")<<"mindeta_accp113 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00413 }
00414 if(m_maxdeta113_accp<0)
00415 {
00416 initFail_ = true;
00417 edm::LogError("CSCTFSectorProcessor")<<"maxdeta_accp113 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00418 }
00419 if(m_maxdphi113_accp<0)
00420 {
00421 initFail_ = true;
00422 edm::LogError("CSCTFSectorProcessor")<<"maxdphi_accp113 parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00423 }
00424 if(m_mindphip_halo<0)
00425 {
00426 initFail_ = true;
00427 edm::LogError("CSCTFSectorProcessor")<<"mindphip_halo parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00428 }
00429 if(m_mindetap_halo<0)
00430 {
00431 initFail_ = true;
00432 edm::LogError("CSCTFSectorProcessor")<<"mindetep_halo parameter left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00433 }
00434
00435 if(m_widePhi<0)
00436 {
00437 initFail_ = true;
00438 edm::LogError("CSCTFSectorProcessor")<<"widePhi parameter left unitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00439 }
00440
00441 for(int index=0; index<8; index++)
00442 if(m_etamax[index]<0)
00443 {
00444 initFail_ = true;
00445 edm::LogError("CSCTFSectorProcessor")<<"Some ("<<(8-index)<<") of EtaMax parameters left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00446 }
00447 for(int index=0; index<8; index++)
00448 if(m_etamin[index]<0)
00449 {
00450 initFail_ = true;
00451 edm::LogError("CSCTFSectorProcessor")<<"Some ("<<(8-index)<<") of EtaMin parameters left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00452 }
00453 for(int index=0; index<7; index++)
00454 if(m_etawin[index]<0)
00455 {
00456 initFail_ = true;
00457 edm::LogError("CSCTFSectorProcessor")<<"Some ("<<(6-index)<<") of EtaWindows parameters left uninitialized for endcap="<<m_endcap<<", sector="<<m_sector;
00458 }
00459 if(kill_fiber<0)
00460 {
00461 initFail_ = true;
00462 edm::LogError("CSCTFTrackBuilder")<<"kill_fiber parameter left uninitialized";
00463 }
00464 if(run_core<0)
00465 {
00466 initFail_ = true;
00467 edm::LogError("CSCTFTrackBuilder")<<"run_core parameter left uninitialized";
00468 }
00469 if(trigger_on_ME1a<0)
00470 {
00471 initFail_ = true;
00472 edm::LogError("CSCTFTrackBuilder")<<"trigger_on_ME1a parameter left uninitialized";
00473 }
00474 if(trigger_on_ME1b<0)
00475 {
00476 initFail_ = true;
00477 edm::LogError("CSCTFTrackBuilder")<<"trigger_on_ME1b parameter left uninitialized";
00478 }
00479 if(trigger_on_ME2 <0)
00480 {
00481 initFail_ = true;
00482 edm::LogError("CSCTFTrackBuilder")<<"trigger_on_ME2 parameter left uninitialized";
00483 }
00484 if(trigger_on_ME3 <0)
00485 {
00486 initFail_ = true;
00487 edm::LogError("CSCTFTrackBuilder")<<"trigger_on_ME3 parameter left uninitialized";
00488 }
00489 if(trigger_on_ME4 <0)
00490 {
00491 initFail_ = true;
00492 edm::LogError("CSCTFTrackBuilder")<<"trigger_on_ME4 parameter left uninitialized";
00493 }
00494 if(trigger_on_MB1a<0)
00495 {
00496 initFail_ = true;
00497 edm::LogError("CSCTFTrackBuilder")<<"trigger_on_MB1a parameter left uninitialized";
00498 }
00499 if(trigger_on_MB1d<0)
00500 {
00501 initFail_ = true;
00502 edm::LogError("CSCTFTrackBuilder")<<"trigger_on_MB1d parameter left uninitialized";
00503 }
00504 if( trigger_on_ME1a>0 || trigger_on_ME1b>0 ||trigger_on_ME2>0 ||
00505 trigger_on_ME3>0 || trigger_on_ME4>0 ||trigger_on_MB1a>0 ||trigger_on_MB1d>0 )
00506 {
00507 if(singlesTrackOutput==999)
00508 {
00509 initFail_ = true;
00510 edm::LogError("CSCTFTrackBuilder")<<"singlesTrackOutput parameter left uninitialized";
00511 }
00512 if(rescaleSinglesPhi<0)
00513 {
00514 initFail_ = true;
00515 edm::LogError("CSCTFTrackBuilder")<<"rescaleSinglesPhi parameter left uninitialized";
00516 }
00517 }
00518 if(QualityEnableME1a<0)
00519 {
00520 initFail_ = true;
00521 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME1a parameter left uninitialized";
00522 }
00523 if(QualityEnableME1b<0)
00524 {
00525 initFail_ = true;
00526 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME1b parameter left uninitialized";
00527 }
00528 if(QualityEnableME1c<0)
00529 {
00530 initFail_ = true;
00531 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME1c parameter left uninitialized";
00532 }
00533 if(QualityEnableME1d<0)
00534 {
00535 initFail_ = true;
00536 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME1d parameter left uninitialized";
00537 }
00538 if(QualityEnableME1e<0)
00539 {
00540 initFail_ = true;
00541 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME1e parameter left uninitialized";
00542 }
00543 if(QualityEnableME1f<0)
00544 {
00545 initFail_ = true;
00546 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME1f parameter left uninitialized";
00547 }
00548 if(QualityEnableME2a<0)
00549 {
00550 initFail_ = true;
00551 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME2a parameter left uninitialized";
00552 }
00553 if(QualityEnableME2b<0)
00554 {
00555 initFail_ = true;
00556 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME2b parameter left uninitialized";
00557 }
00558 if(QualityEnableME2c<0)
00559 {
00560 initFail_ = true;
00561 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME2c parameter left uninitialized";
00562 }
00563 if(QualityEnableME3a<0)
00564 {
00565 initFail_ = true;
00566 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME3a parameter left uninitialized";
00567 }
00568 if(QualityEnableME3b<0)
00569 {
00570 initFail_ = true;
00571 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME3b parameter left uninitialized";
00572 }
00573 if(QualityEnableME3c<0)
00574 {
00575 initFail_ = true;
00576 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME3c parameter left uninitialized";
00577 }
00578 if(QualityEnableME4a<0)
00579 {
00580 initFail_ = true;
00581 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME4a parameter left uninitialized";
00582 }
00583 if(QualityEnableME4b<0)
00584 {
00585 initFail_ = true;
00586 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME4b parameter left uninitialized";
00587 }
00588 if(QualityEnableME4c<0)
00589 {
00590 initFail_ = true;
00591 edm::LogError("CSCTFTrackBuilder")<<"QualityEnableME4c parameter left uninitialized";
00592 }
00593
00594 if (m_firmSP<1)
00595 {
00596 initFail_ = true;
00597 edm::LogError("CSCTFSectorProcessor")<< " firmwareSP parameter left uninitialized!!!\n";
00598 }
00599 if (m_firmFA<1)
00600 {
00601 initFail_ = true;
00602 edm::LogError("CSCTFSectorProcessor")<< " firmwareFA parameter left uninitialized!!!\n";
00603 }
00604 if (m_firmDD<1)
00605 {
00606 initFail_ = true;
00607 edm::LogError("CSCTFSectorProcessor")<< " firmwareDD parameter left uninitialized!!!\n";
00608 }
00609 if (m_firmVM<1)
00610 {
00611 initFail_ = true;
00612 edm::LogError("CSCTFSectorProcessor")<< " firmwareVM parameter left uninitialized!!!\n";
00613 }
00614
00615 if ( (m_firmFA != m_firmDD) ||
00616 (m_firmFA != m_firmVM) ||
00617 (m_firmDD != m_firmVM) )
00618 {
00619 initFail_ = true;
00620 edm::LogError("CSCTFSectorProcessor::initialize")<< " firmwareFA (=" << m_firmFA << "), "
00621 << " firmwareDD (=" << m_firmDD << "), "
00622 << " firmwareVM (=" << m_firmVM << ") are NOT identical: it shoultd NOT happen!\n";
00623 }
00624
00625 }
00626
00627 void CSCTFSectorProcessor::readParameters(const edm::ParameterSet& pset){
00628 m_bxa_depth = pset.getParameter<unsigned>("BXAdepth");
00629 m_allowALCTonly = ( pset.getParameter<bool>("AllowALCTonly") ? 1 : 0 );
00630 m_allowCLCTonly = ( pset.getParameter<bool>("AllowCLCTonly") ? 1 : 0 );
00631 m_preTrigger = pset.getParameter<unsigned>("PreTrigger");
00632
00633 std::vector<unsigned>::const_iterator iter;
00634 int index=0;
00635 std::vector<unsigned> etawins = pset.getParameter<std::vector<unsigned> >("EtaWindows");
00636 for(iter=etawins.begin(),index=0; iter!=etawins.end()&&index<7; iter++,index++) m_etawin[index] = *iter;
00637 std::vector<unsigned> etamins = pset.getParameter<std::vector<unsigned> >("EtaMin");
00638 for(iter=etamins.begin(),index=0; iter!=etamins.end()&&index<8; iter++,index++) m_etamin[index] = *iter;
00639 std::vector<unsigned> etamaxs = pset.getParameter<std::vector<unsigned> >("EtaMax");
00640 for(iter=etamaxs.begin(),index=0; iter!=etamaxs.end()&&index<8; iter++,index++) m_etamax[index] = *iter;
00641
00642 m_mindphip = pset.getParameter<unsigned>("mindphip");
00643 m_mindetap = pset.getParameter<unsigned>("mindetap");
00644 m_straightp = pset.getParameter<unsigned>("straightp");
00645 m_curvedp = pset.getParameter<unsigned>("curvedp");
00646 m_mbaPhiOff = pset.getParameter<unsigned>("mbaPhiOff");
00647 m_mbbPhiOff = pset.getParameter<unsigned>("mbbPhiOff");
00648 m_widePhi = pset.getParameter<unsigned>("widePhi");
00649 m_mindeta12_accp = pset.getParameter<unsigned>("mindeta12_accp");
00650 m_maxdeta12_accp = pset.getParameter<unsigned>("maxdeta12_accp");
00651 m_maxdphi12_accp = pset.getParameter<unsigned>("maxdphi12_accp");
00652 m_mindeta13_accp = pset.getParameter<unsigned>("mindeta13_accp");
00653 m_maxdeta13_accp = pset.getParameter<unsigned>("maxdeta13_accp");
00654 m_maxdphi13_accp = pset.getParameter<unsigned>("maxdphi13_accp");
00655 m_mindeta112_accp = pset.getParameter<unsigned>("mindeta112_accp");
00656 m_maxdeta112_accp = pset.getParameter<unsigned>("maxdeta112_accp");
00657 m_maxdphi112_accp = pset.getParameter<unsigned>("maxdphi112_accp");
00658 m_mindeta113_accp = pset.getParameter<unsigned>("mindeta113_accp");
00659 m_maxdeta113_accp = pset.getParameter<unsigned>("maxdeta113_accp");
00660 m_maxdphi113_accp = pset.getParameter<unsigned>("maxdphi113_accp");
00661 m_mindphip_halo = pset.getParameter<unsigned>("mindphip_halo");
00662 m_mindetap_halo = pset.getParameter<unsigned>("mindetap_halo");
00663 kill_fiber = pset.getParameter<unsigned>("kill_fiber");
00664 run_core = pset.getParameter<bool>("run_core");
00665 trigger_on_ME1a = pset.getParameter<bool>("trigger_on_ME1a");
00666 trigger_on_ME1b = pset.getParameter<bool>("trigger_on_ME1b");
00667 trigger_on_ME2 = pset.getParameter<bool>("trigger_on_ME2");
00668 trigger_on_ME3 = pset.getParameter<bool>("trigger_on_ME3");
00669 trigger_on_ME4 = pset.getParameter<bool>("trigger_on_ME4");
00670 trigger_on_MB1a = pset.getParameter<bool>("trigger_on_MB1a");
00671 trigger_on_MB1d = pset.getParameter<bool>("trigger_on_MB1d");
00672
00673 singlesTrackOutput = pset.getParameter<unsigned int>("singlesTrackOutput");
00674 rescaleSinglesPhi = pset.getParameter<bool>("rescaleSinglesPhi");
00675 QualityEnableME1a = pset.getParameter<unsigned int>("QualityEnableME1a");
00676 QualityEnableME1b = pset.getParameter<unsigned int>("QualityEnableME1b");
00677 QualityEnableME1c = pset.getParameter<unsigned int>("QualityEnableME1c");
00678 QualityEnableME1d = pset.getParameter<unsigned int>("QualityEnableME1d");
00679 QualityEnableME1e = pset.getParameter<unsigned int>("QualityEnableME1e");
00680 QualityEnableME1f = pset.getParameter<unsigned int>("QualityEnableME1f");
00681 QualityEnableME2a = pset.getParameter<unsigned int>("QualityEnableME2a");
00682 QualityEnableME2b = pset.getParameter<unsigned int>("QualityEnableME2b");
00683 QualityEnableME2c = pset.getParameter<unsigned int>("QualityEnableME2c");
00684 QualityEnableME3a = pset.getParameter<unsigned int>("QualityEnableME3a");
00685 QualityEnableME3b = pset.getParameter<unsigned int>("QualityEnableME3b");
00686 QualityEnableME3c = pset.getParameter<unsigned int>("QualityEnableME3c");
00687 QualityEnableME4a = pset.getParameter<unsigned int>("QualityEnableME4a");
00688 QualityEnableME4b = pset.getParameter<unsigned int>("QualityEnableME4b");
00689 QualityEnableME4c = pset.getParameter<unsigned int>("QualityEnableME4c");
00690
00691 m_firmSP = pset.getParameter<unsigned int>("firmwareSP");
00692 m_firmFA = pset.getParameter<unsigned int>("firmwareFA");
00693 m_firmDD = pset.getParameter<unsigned int>("firmwareDD");
00694 m_firmVM = pset.getParameter<unsigned int>("firmwareVM");
00695
00696 }
00697
00698 CSCTFSectorProcessor::~CSCTFSectorProcessor()
00699 {
00700 for(int i = 0; i < 5; ++i)
00701 {
00702 if(srLUTs_[FPGAs[i]]) delete srLUTs_[FPGAs[i]];
00703 srLUTs_[FPGAs[i]] = NULL;
00704 }
00705
00706 delete core_;
00707 core_ = NULL;
00708
00709 if(ptLUT_) delete ptLUT_;
00710 ptLUT_ = NULL;
00711 }
00712
00713
00714
00715 int CSCTFSectorProcessor::run(const CSCTriggerContainer<csctf::TrackStub>& stubs)
00716 {
00717 if(initFail_)
00718 return -1;
00719
00720 if( !ptLUT_ )
00721 {
00722 edm::LogError("CSCTFSectorProcessor::run()") << "No CSCTF PTLUTs: Initialize CSC TF LUTs first (missed call to CSCTFTrackProducer::beginJob?\n";
00723 return -1;
00724 }
00725
00726
00727 l1_tracks.clear();
00728 dt_stubs.clear();
00729 stub_vec_filtered.clear();
00730
00731 std::vector<csctf::TrackStub> stub_vec = stubs.get();
00732
00736 for(std::vector<csctf::TrackStub>::const_iterator itr=stub_vec.begin(); itr!=stub_vec.end(); itr++)
00737 switch( itr->station() ){
00738 case 5: stub_vec_filtered.push_back(*itr); break;
00739 case 4:
00740 switch( itr->getMPCLink() ){
00741 case 3: if( (kill_fiber&0x4000)==0 && QualityEnableME4c&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00742 case 2: if( (kill_fiber&0x2000)==0 && QualityEnableME4b&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00743 case 1: if( (kill_fiber&0x1000)==0 && QualityEnableME4a&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00744 default: edm::LogWarning("CSCTFSectorProcessor::run()") << "No MPC sorting for LCT: link="<<itr->getMPCLink()<<"\n";
00745 }
00746 break;
00747 case 3:
00748 switch( itr->getMPCLink() ){
00749 case 3: if( (kill_fiber&0x0800)==0 && QualityEnableME3c&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00750 case 2: if( (kill_fiber&0x0400)==0 && QualityEnableME3b&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00751 case 1: if( (kill_fiber&0x0200)==0 && QualityEnableME3a&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00752 default: edm::LogWarning("CSCTFSectorProcessor::run()") << "No MPC sorting for LCT: link="<<itr->getMPCLink()<<"\n";
00753 }
00754 break;
00755 case 2:
00756 switch( itr->getMPCLink() ){
00757 case 3: if( (kill_fiber&0x0100)==0 && QualityEnableME2c&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00758 case 2: if( (kill_fiber&0x0080)==0 && QualityEnableME2b&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00759 case 1: if( (kill_fiber&0x0040)==0 && QualityEnableME2a&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00760 default: edm::LogWarning("CSCTFSectorProcessor::run()") << "No MPC sorting for LCT: link="<<itr->getMPCLink()<<"\n";
00761 }
00762 break;
00763 case 1:
00764 switch( itr->getMPCLink() + (3*(CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(itr->getDetId().rawId())) - 1)) ){
00765 case 6: if( (kill_fiber&0x0020)==0 && QualityEnableME1f&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00766 case 5: if( (kill_fiber&0x0010)==0 && QualityEnableME1e&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00767 case 4: if( (kill_fiber&0x0008)==0 && QualityEnableME1d&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00768 case 3: if( (kill_fiber&0x0004)==0 && QualityEnableME1c&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00769 case 2: if( (kill_fiber&0x0002)==0 && QualityEnableME1b&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00770 case 1: if( (kill_fiber&0x0001)==0 && QualityEnableME1a&(1<<itr->getQuality()) ) stub_vec_filtered.push_back(*itr); break;
00771 default: edm::LogWarning("CSCTFSectorProcessor::run()") << "No MPC sorting for LCT: link="<<itr->getMPCLink()<<"\n";
00772 }
00773 break;
00774 default: edm::LogWarning("CSCTFSectorProcessor::run()") << "Invalid station # encountered: "<<itr->station()<<"\n";
00775 }
00776
00785 for(std::vector<csctf::TrackStub>::iterator itr=stub_vec_filtered.begin(); itr!=stub_vec_filtered.end(); itr++)
00786 {
00787 if(itr->station() != 5)
00788 {
00789 CSCDetId id(itr->getDetId().rawId());
00790 unsigned fpga = (id.station() == 1) ? CSCTriggerNumbering::triggerSubSectorFromLabels(id) - 1 : id.station();
00791
00792 lclphidat lclPhi;
00793 try {
00794 lclPhi = srLUTs_[FPGAs[fpga]]->localPhi(itr->getStrip(), itr->getPattern(), itr->getQuality(), itr->getBend());
00795 } catch( cms::Exception &e ) {
00796 bzero(&lclPhi,sizeof(lclPhi));
00797 edm::LogWarning("CSCTFSectorProcessor:run()") << "Exception from LocalPhi LUT in " << FPGAs[fpga]
00798 << "(strip="<<itr->getStrip()<<",pattern="<<itr->getPattern()<<",quality="<<itr->getQuality()<<",bend="<<itr->getBend()<<")" <<std::endl;
00799 }
00800
00801 gblphidat gblPhi;
00802 try {
00803 unsigned csc_id = itr->cscid();
00804 if (!m_gangedME1a) csc_id = itr->cscidSeparateME1a();
00805 gblPhi = srLUTs_[FPGAs[fpga]]->globalPhiME(lclPhi.phi_local, itr->getKeyWG(), csc_id);
00806
00807 } catch( cms::Exception &e ) {
00808 bzero(&gblPhi,sizeof(gblPhi));
00809 edm::LogWarning("CSCTFSectorProcessor:run()") << "Exception from GlobalPhi LUT in " << FPGAs[fpga]
00810 << "(phi_local="<<lclPhi.phi_local<<",KeyWG="<<itr->getKeyWG()<<",csc="<<itr->cscid()<<")"<<std::endl;
00811 }
00812
00813 gbletadat gblEta;
00814 try {
00815 gblEta = srLUTs_[FPGAs[fpga]]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, itr->getKeyWG(), itr->cscid());
00816 } catch( cms::Exception &e ) {
00817 bzero(&gblEta,sizeof(gblEta));
00818 edm::LogWarning("CSCTFSectorProcessor:run()") << "Exception from GlobalEta LUT in " << FPGAs[fpga]
00819 << "(phi_bend_local="<<lclPhi.phi_bend_local<<",phi_local="<<lclPhi.phi_local<<",KeyWG="<<itr->getKeyWG()<<",csc="<<itr->cscid()<<")"<<std::endl;
00820 }
00821
00822 gblphidat gblPhiDT;
00823 try {
00824 gblPhiDT = srLUTs_[FPGAs[fpga]]->globalPhiMB(lclPhi.phi_local, itr->getKeyWG(), itr->cscid());
00825 } catch( cms::Exception &e ) {
00826 bzero(&gblPhiDT,sizeof(gblPhiDT));
00827 edm::LogWarning("CSCTFSectorProcessor:run()") << "Exception from GlobalPhi DT LUT in " << FPGAs[fpga]
00828 << "(phi_local="<<lclPhi.phi_local<<",KeyWG="<<itr->getKeyWG()<<",csc="<<itr->cscid()<<")"<<std::endl;
00829 }
00830
00831 itr->setEtaPacked(gblEta.global_eta);
00832
00833 if(itr->station() == 1 ) {
00834
00835 itr->setPhiPacked(gblPhiDT.global_phi);
00836 dt_stubs.push_back(*itr);
00837 }
00838
00839
00840
00841
00842 itr->setPhiPacked(gblPhi.global_phi);
00843
00844 LogDebug("CSCTFSectorProcessor:run()") << "LCT found, processed by FPGA: " << FPGAs[fpga] << std::endl
00845 << " LCT now has (eta, phi) of: (" << itr->etaValue() << "," << itr->phiValue() <<")\n";
00846 }
00847 }
00848
00849 CSCTriggerContainer<csctf::TrackStub> processedStubs(stub_vec_filtered);
00850
00857 std::vector<csc::L1Track> tftks;
00858
00859 if(run_core){
00860 core_->loadData(processedStubs, m_endcap, m_sector, m_minBX, m_maxBX);
00861 if( core_->run(m_endcap, m_sector, m_latency,
00862 m_etamin[0], m_etamin[1], m_etamin[2], m_etamin[3],
00863 m_etamin[4], m_etamin[5], m_etamin[6], m_etamin[7],
00864 m_etamax[0], m_etamax[1], m_etamax[2], m_etamax[3],
00865 m_etamax[4], m_etamax[5], m_etamax[6], m_etamax[7],
00866 m_etawin[0], m_etawin[1], m_etawin[2],
00867 m_etawin[3], m_etawin[4], m_etawin[5], m_etawin[6],
00868 m_mindphip, m_mindetap,
00869 m_mindeta12_accp, m_maxdeta12_accp, m_maxdphi12_accp,
00870 m_mindeta13_accp, m_maxdeta13_accp, m_maxdphi13_accp,
00871 m_mindeta112_accp, m_maxdeta112_accp, m_maxdphi112_accp,
00872 m_mindeta113_accp, m_maxdeta113_accp, m_maxdphi113_accp,
00873 m_mindphip_halo, m_mindetap_halo,
00874 m_straightp, m_curvedp,
00875 m_mbaPhiOff, m_mbbPhiOff,
00876 m_bxa_depth, m_allowALCTonly, m_allowCLCTonly, m_preTrigger, m_widePhi,
00877 m_minBX, m_maxBX) )
00878 {
00879 l1_tracks = core_->tracks();
00880 }
00881
00882 tftks = l1_tracks.get();
00883
00889 std::vector<csc::L1Track>::iterator titr = tftks.begin();
00890
00891 for(; titr != tftks.end(); titr++)
00892 {
00893 ptadd thePtAddress(titr->ptLUTAddress());
00894 ptdat thePtData = ptLUT_->Pt(thePtAddress);
00895
00896 if(thePtAddress.track_fr)
00897 {
00898 titr->setRank(thePtData.front_rank);
00899 titr->setChargeValidPacked(thePtData.charge_valid_front);
00900 }
00901 else
00902 {
00903 titr->setRank(thePtData.rear_rank);
00904 titr->setChargeValidPacked(thePtData.charge_valid_rear);
00905 }
00906
00907 if( ((titr->ptLUTAddress()>>16)&0xf)==15 )
00908 {
00909 int unmodBx = titr->bx();
00910 titr->setBx(unmodBx+2);
00911 }
00912 }
00913 }
00914
00915 l1_tracks = tftks;
00916
00917
00918
00919 CSCTriggerContainer<csctf::TrackStub> myStubContainer[7];
00920
00921 if( trigger_on_ME1a || trigger_on_ME1b || trigger_on_ME2 || trigger_on_ME3 || trigger_on_ME4 || trigger_on_MB1a || trigger_on_MB1d )
00922 for(std::vector<csctf::TrackStub>::iterator itr=stub_vec_filtered.begin(); itr!=stub_vec_filtered.end(); itr++){
00923 int station = itr->station()-1;
00924 if(station != 4){
00925 int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(itr->getDetId().rawId()));
00926 int mpc = ( subSector ? subSector-1 : station+1 );
00927 if( (mpc==0&&trigger_on_ME1a) || (mpc==1&&trigger_on_ME1b) ||
00928 (mpc==2&&trigger_on_ME2) || (mpc==3&&trigger_on_ME3) ||
00929 (mpc==4&&trigger_on_ME4) ||
00930 (mpc==5&& ( (trigger_on_MB1a&&subSector%2==1) || (trigger_on_MB1d&&subSector%2==0) ) ) ){
00931 int bx = itr->getBX() - m_minBX;
00932 if( bx<0 || bx>=7 ) edm::LogWarning("CSCTFTrackBuilder::buildTracks()") << " LCT BX is out of ["<<m_minBX<<","<<m_maxBX<<") range: "<<itr->getBX();
00933 else
00934 if( itr->isValid() ) myStubContainer[bx].push_back(*itr);
00935 }
00936 }
00937 }
00938
00939
00940
00941 int shift = (m_maxBX + m_minBX)/2 - m_minBX;
00942
00943
00944
00945 CSCTriggerContainer<csc::L1Track> tracksFromSingles;
00946 for(int bx=0; bx<7; bx++)
00947 if( myStubContainer[bx].get().size() ){
00948 bool coreTrackExists = false;
00949
00950 std::vector<csc::L1Track> tracks = l1_tracks.get();
00951 for(std::vector<csc::L1Track>::iterator trk=tracks.begin(); trk<tracks.end(); trk++)
00952 if( (trk->BX() == bx-shift && trk->outputLink() == singlesTrackOutput)
00953 || (((trk->ptLUTAddress()>>16)&0xf)==15 && trk->BX()-2 == bx-shift) ){
00954 coreTrackExists = true;
00955 break;
00956 }
00957 if( coreTrackExists == false ){
00958 csc::L1TrackId trackId(m_endcap,m_sector);
00959 csc::L1Track track(trackId);
00960 track.setBx(bx-shift);
00961 track.setOutputLink(singlesTrackOutput);
00962
00963 std::vector<csctf::TrackStub> stubs = myStubContainer[bx].get();
00964
00965 int qualityME=0, qualityMB=0, ME=100, MB=100, linkME=7;
00966 std::vector<csctf::TrackStub>::const_iterator bestStub=stubs.end();
00967 for(std::vector<csctf::TrackStub>::const_iterator st_iter=stubs.begin(); st_iter!=stubs.end(); st_iter++){
00968 int station = st_iter->station()-1;
00969 int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(st_iter->getDetId().rawId()));
00970 int mpc = ( subSector ? subSector-1 : station+1 );
00971
00972 if( mpc==5 && (st_iter->getQuality()>qualityMB || (st_iter->getQuality()==qualityMB&&subSector<MB)) ){
00973 qualityMB = st_iter->getQuality();
00974 MB = subSector;
00975 if(ME>4) bestStub = st_iter;
00976 }
00977
00978 if( mpc<5 && (st_iter->getQuality()> qualityME
00979 || (st_iter->getQuality()==qualityME && mpc< ME)
00980 || (st_iter->getQuality()==qualityME && mpc==ME && st_iter->getMPCLink()<linkME))) {
00981 qualityME = st_iter->getQuality();
00982 ME = mpc;
00983 linkME = st_iter->getMPCLink();
00984 bestStub = st_iter;
00985 }
00986 }
00987 unsigned rescaled_phi = 999;
00988 if (m_firmSP <= 20100210) {
00989
00990
00991
00992 rescaled_phi = unsigned(24*(bestStub->phiPacked()&0x7f)/128.);
00993 }
00994 else {
00995
00996 rescaled_phi = unsigned(24*(bestStub->phiPacked()>>5)/128.);
00997 }
00998
00999 unsigned unscaled_phi = bestStub->phiPacked()>>7 ;
01000 track.setLocalPhi(rescaleSinglesPhi?rescaled_phi:unscaled_phi);
01001 track.setEtaPacked((bestStub->etaPacked()>>2)&0x1f);
01002 switch( bestStub->station() ){
01003 case 1: track.setStationIds(bestStub->getMPCLink(),0,0,0,0); break;
01004 case 2: track.setStationIds(0,bestStub->getMPCLink(),0,0,0); break;
01005 case 3: track.setStationIds(0,0,bestStub->getMPCLink(),0,0); break;
01006 case 4: track.setStationIds(0,0,0,bestStub->getMPCLink(),0); break;
01007 case 5: track.setStationIds(0,0,0,0,bestStub->getMPCLink()); break;
01008 default: edm::LogError("CSCTFSectorProcessor::run()") << "Illegal LCT link="<<bestStub->station()<<"\n"; break;
01009 }
01010
01011
01012 track.setPtLUTAddress( (1<<16) | ((bestStub->etaPacked()<<9)&0xf000) );
01013 ptadd thePtAddress( track.ptLUTAddress() );
01014 ptdat thePtData = ptLUT_->Pt(thePtAddress);
01015 if( thePtAddress.track_fr ){
01016 track.setRank(thePtData.front_rank);
01017 track.setChargeValidPacked(thePtData.charge_valid_front);
01018 } else {
01019 track.setRank(thePtData.rear_rank);
01020 track.setChargeValidPacked(thePtData.charge_valid_rear);
01021 }
01022 tracksFromSingles.push_back(track);
01023 }
01024 }
01025 std::vector<csc::L1Track> single_tracks = tracksFromSingles.get();
01026 if( single_tracks.size() ) l1_tracks.push_many(single_tracks);
01027
01028
01029 return (l1_tracks.get().size() > 0);
01030 }
01031
01032
01033 void CSCTFSectorProcessor::printDisclaimer(int firmSP, int firmFA){
01034
01035 edm::LogInfo( "CSCTFSectorProcessor" ) << "\n\n"
01036 << "******************************* \n"
01037 << "*** DISCLAIMER *** \n"
01038 << "******************************* \n"
01039 << "\n Firmware SP version (year+month+day)=" << firmSP
01040 << "\n Firmware FA/VM/DD version (year+month+day)=" << firmFA;
01041 if (firmSP==20100210)
01042 edm::LogInfo( "CSCTFSectorProcessor" ) << " -> KNOWN BUGS IN THE FIRMWARE:\n"
01043 << "\t * Wrong phi assignment for singles\n"
01044 << "\t * Wrapper passes to the core only even quality DT stubs\n"
01045 << "\n -> BUGS ARE GOING TO BE EMULATED BY THE SOFTWARE\n\n";
01046
01047 else
01048 edm::LogInfo( "CSCTFSectorProcessor" ) << "\t * Correct phi assignment for singles\n";
01049
01050 if (firmSP==20100629){
01051 edm::LogInfo( "CSCTFSectorProcessor" ) << "\t * Correct MB quality masking in the wrapper\n"
01052 << "\t * Core is 20100122\n";
01053 }
01054
01055 if (firmSP==20100728)
01056 edm::LogInfo( "CSCTFSectorProcessor" ) << "\t * Inverted MB clocks\n";
01057
01058 if (firmSP==20100901)
01059 edm::LogInfo( "CSCTFSectorProcessor" ) << "\t * Inverted charge bit\n";
01060
01061 if (firmSP==20101011)
01062 edm::LogInfo( "CSCTFSectorProcessor" ) << "\t **** WARNING THIS FIRMWARE IS UNDER TEST ****\n"
01063 << "\t * Added CSC-DT assembling tracks ME1-MB2/1 \n";
01064 if (firmSP==20101210)
01065 edm::LogInfo( "CSCTFSectorProcessor" ) << "\t **** WARNING THIS FIRMWARE IS UNDER TEST ****\n"
01066 << "\t * New Ghost Busting Algorithm Removing Tracks\n"
01067 << "\t Sharing at Least One LCT\n";
01068
01069 if (firmSP==20110118)
01070 edm::LogInfo( "CSCTFSectorProcessor" ) << "\t **** WARNING THIS FIRMWARE IS UNDER TEST ****\n"
01071 << "\t * New Ghost Busting Algorithm Removing Tracks\n"
01072 << "\t Sharing at Least One LCT\n"
01073 << "\t * Passing CLCT and PhiBend for PT LUTs\n";
01074 if (firmSP==20120131)
01075 edm::LogInfo( "CSCTFSectorProcessor" ) << "\t **** WARNING THIS FIRMWARE IS UNDER TEST ****\n"
01076 << "\t * non-linear dphi12 dphi23, use deta for PTLUTs \n";
01077 }