Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:59

0001 #include "L1Trigger/L1TMuonEndCap/interface/VersionControl.h"
0002 
0003 VersionControl::VersionControl(const edm::ParameterSet& iConfig) : config_(iConfig) {
0004   // All the configurables from python/simEmtfDigis_cfi.py must be visible to this class, except InputTags.
0005   verbose_ = iConfig.getUntrackedParameter<int>("verbosity");
0006   useO2O_ = iConfig.getParameter<bool>("FWConfig");
0007   era_ = iConfig.getParameter<std::string>("Era");
0008   // Run 3 CCLUT
0009   useRun3CCLUT_OTMB_ = iConfig.getParameter<bool>("UseRun3CCLUT_OTMB");
0010   useRun3CCLUT_TMB_ = iConfig.getParameter<bool>("UseRun3CCLUT_TMB");
0011 
0012   useDT_ = iConfig.getParameter<bool>("DTEnable");
0013   useCSC_ = iConfig.getParameter<bool>("CSCEnable");
0014   useRPC_ = iConfig.getParameter<bool>("RPCEnable");
0015   useIRPC_ = iConfig.getParameter<bool>("IRPCEnable");
0016   useCPPF_ = iConfig.getParameter<bool>("CPPFEnable");
0017   useGEM_ = iConfig.getParameter<bool>("GEMEnable");
0018   useME0_ = iConfig.getParameter<bool>("ME0Enable");
0019 
0020   minBX_ = iConfig.getParameter<int>("MinBX");
0021   maxBX_ = iConfig.getParameter<int>("MaxBX");
0022   bxWindow_ = iConfig.getParameter<int>("BXWindow");
0023   bxShiftCSC_ = iConfig.getParameter<int>("CSCInputBXShift");
0024   bxShiftRPC_ = iConfig.getParameter<int>("RPCInputBXShift");
0025   bxShiftGEM_ = iConfig.getParameter<int>("GEMInputBXShift");
0026   bxShiftME0_ = iConfig.getParameter<int>("ME0InputBXShift");
0027 
0028   auto spPCParams16 = iConfig.getParameter<edm::ParameterSet>("spPCParams16");
0029   zoneBoundaries_ = spPCParams16.getParameter<std::vector<int> >("ZoneBoundaries");
0030   zoneOverlap_ = spPCParams16.getParameter<int>("ZoneOverlap");
0031   includeNeighbor_ = spPCParams16.getParameter<bool>("IncludeNeighbor");
0032   duplicateTheta_ = spPCParams16.getParameter<bool>("DuplicateTheta");
0033   fixZonePhi_ = spPCParams16.getParameter<bool>("FixZonePhi");
0034   useNewZones_ = spPCParams16.getParameter<bool>("UseNewZones");
0035   fixME11Edges_ = spPCParams16.getParameter<bool>("FixME11Edges");
0036 
0037   auto spPRParams16 = iConfig.getParameter<edm::ParameterSet>("spPRParams16");
0038   pattDefinitions_ = spPRParams16.getParameter<std::vector<std::string> >("PatternDefinitions");
0039   symPattDefinitions_ = spPRParams16.getParameter<std::vector<std::string> >("SymPatternDefinitions");
0040   useSymPatterns_ = spPRParams16.getParameter<bool>("UseSymmetricalPatterns");
0041 
0042   auto spTBParams16 = iConfig.getParameter<edm::ParameterSet>("spTBParams16");
0043   thetaWindow_ = spTBParams16.getParameter<int>("ThetaWindow");
0044   thetaWindowZone0_ = spTBParams16.getParameter<int>("ThetaWindowZone0");
0045   useSingleHits_ = spTBParams16.getParameter<bool>("UseSingleHits");
0046   bugSt2PhDiff_ = spTBParams16.getParameter<bool>("BugSt2PhDiff");
0047   bugME11Dupes_ = spTBParams16.getParameter<bool>("BugME11Dupes");
0048   bugAmbigThetaWin_ = spTBParams16.getParameter<bool>("BugAmbigThetaWin");
0049   twoStationSameBX_ = spTBParams16.getParameter<bool>("TwoStationSameBX");
0050 
0051   auto spGCParams16 = iConfig.getParameter<edm::ParameterSet>("spGCParams16");
0052   maxRoadsPerZone_ = spGCParams16.getParameter<int>("MaxRoadsPerZone");
0053   maxTracks_ = spGCParams16.getParameter<int>("MaxTracks");
0054   useSecondEarliest_ = spGCParams16.getParameter<bool>("UseSecondEarliest");
0055   bugSameSectorPt0_ = spGCParams16.getParameter<bool>("BugSameSectorPt0");
0056 
0057   auto spPAParams16 = iConfig.getParameter<edm::ParameterSet>("spPAParams16");
0058   readPtLUTFile_ = spPAParams16.getParameter<bool>("ReadPtLUTFile");
0059   fixMode15HighPt_ = spPAParams16.getParameter<bool>("FixMode15HighPt");
0060   bug9BitDPhi_ = spPAParams16.getParameter<bool>("Bug9BitDPhi");
0061   bugMode7CLCT_ = spPAParams16.getParameter<bool>("BugMode7CLCT");
0062   bugNegPt_ = spPAParams16.getParameter<bool>("BugNegPt");
0063   bugGMTPhi_ = spPAParams16.getParameter<bool>("BugGMTPhi");
0064   promoteMode7_ = spPAParams16.getParameter<bool>("PromoteMode7");
0065   modeQualVer_ = spPAParams16.getParameter<int>("ModeQualVer");
0066   pbFileName_ = spPAParams16.getParameter<std::string>("ProtobufFileName");
0067 }
0068 
0069 VersionControl::~VersionControl() {}
0070 
0071 // Refer to docs/EMTF_FW_LUT_versions_2016_draft2.xlsx
0072 void VersionControl::configure_by_fw_version(unsigned fw_version) {
0073   if (fw_version == 0 || fw_version == 123456)  // fw_version '123456' is from the fake conditions
0074     return;
0075 
0076   // For now, no switches later than FW version 47864 (end-of-year 2016)
0077   // Beggining in late 2016, "fw_version" in O2O populated with timestamp, rather than FW version
0078   // tm fw_time = gmtime(fw_version);  (See https://linux.die.net/man/3/gmtime, https://www.epochconverter.com)
0079 
0080   /////////////////////////////////////////////////////////////////////////////////
0081   ///  Settings for 2018 (by default just use settings in simEmtfDigis_cfi.py)  ///
0082   /////////////////////////////////////////////////////////////////////////////////
0083   if (fw_version >= 1514764800) {  // January 1, 2018
0084 
0085     // Settings for all of 2018 (following order in simEmtfDigis_cfi.py)
0086     // BXWindow(2) and BugAmbigThetaWin(F) deployed sometime before stable beams on March 20, not quite sure when - AWB 26.04.18
0087     // TwoStationSameBX(T), ThetaWindowZone0(4), and ModeQualVer(2) to be deployed sometime between May 17 and May 31 - AWB 14.05.18
0088 
0089     // Global parameters
0090     // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2)
0091     // --------------------------------------------------------------------------------------------------------
0092     era_ = "Run2_2018";  // Era for CMSSW customization
0093     bxWindow_ = 2;       // Number of BX whose primitives can be included in the same track
0094 
0095     // spTBParams16 : Sector processor track-building parameters
0096     // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T),
0097     //            DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T)
0098     // ------------------------------------------------------------------------------
0099 
0100     // spPRParams16 : Sector processor pattern-recognition parameters
0101     // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T)
0102     // -----------------------------------------------------------------------------------------
0103 
0104     // spTBParams16 : Sector processor track-building parameters
0105     // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F),
0106     //            BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T)
0107     // ----------------------------------------------------------------------------------
0108     thetaWindow_ = 8;           // Maximum dTheta between primitives in the same track
0109     thetaWindowZone0_ = 4;      // Maximum dTheta between primitives in the same track in Zone 0 (ring 1)
0110     bugAmbigThetaWin_ = false;  // Can allow dThetas outside window when there are 2 LCTs in the same chamber
0111     twoStationSameBX_ = true;   // Requires the hits in two-station tracks to have the same BX
0112 
0113     // spGCParams16 : Sector processor ghost-cancellation parameters
0114     // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F)
0115     // --------------------------------------------------------------------------------------
0116 
0117     // spPAParams16 : Sector processor pt-assignment parameters
0118     // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F),
0119     //            BugNegPt(F), BugGMTPhi(F), PromoteMode7(F), ModeQualVer(2)
0120     // ---------------------------------------------------------------------------------
0121     modeQualVer_ = 2;       // Version 2 contains modified mode-quality mapping for 2018
0122     promoteMode7_ = false;  // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality
0123 
0124     // ___________________________________________________________________________
0125     // Versions in 2018 - no external documentation
0126     // As of the beginning of 2018 EMTF O2O was broken, not updating the database with online conditions
0127     // Firmware version reported for runs before 318841 (June 28) is 1504018578 (Aug. 29, 2017) even though
0128     //   updates occured in February and March of 2018.  May need to re-write history in the database. - AWB 30.06.18
0129 
0130     if (fw_version < 1529520380) {  // June 20, 2018
0131       thetaWindowZone0_ = 8;        // Maximum dTheta between primitives in the same track in Zone 0 (ring 1)
0132       twoStationSameBX_ = false;    // Requires the hits in two-station tracks to have the same BX
0133       modeQualVer_ = 1;             // Version 2 contains modified mode-quality mapping for 2018
0134       promoteMode7_ = true;         // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality
0135     }
0136 
0137     return;
0138   }
0139 
0140   /////////////////////////////////////////////////////////////////////////////////
0141   ///  Settings for 2017 (by default just use settings in simEmtfDigis_cfi.py)  ///
0142   /////////////////////////////////////////////////////////////////////////////////
0143   else if (fw_version >= 50000) {
0144     // Settings for all of 2017 (following order in simEmtfDigis_cfi.py)
0145 
0146     // Global parameters
0147     // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2)
0148     // --------------------------------------------------------------------------------------------------------
0149     era_ = "Run2_2017";  // Era for CMSSW customization
0150     bxWindow_ = 3;       // Number of BX whose primitives can be included in the same track
0151 
0152     // spTBParams16 : Sector processor track-building parameters
0153     // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T),
0154     //            DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T)
0155     // ------------------------------------------------------------------------------
0156 
0157     // spPRParams16 : Sector processor pattern-recognition parameters
0158     // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T)
0159     // -----------------------------------------------------------------------------------------
0160 
0161     // spTBParams16 : Sector processor track-building parameters
0162     // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F),
0163     //            BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T)
0164     // ----------------------------------------------------------------------------------
0165     thetaWindow_ = 8;           // Maximum dTheta between primitives in the same track
0166     thetaWindowZone0_ = 8;      // Maximum dTheta between primitives in the same track in Zone 0 (ring 1)
0167     bugAmbigThetaWin_ = true;   // Can allow dThetas outside window when there are 2 LCTs in the same chamber
0168     twoStationSameBX_ = false;  // Requires the hits in two-station tracks to have the same BX
0169 
0170     // spGCParams16 : Sector processor ghost-cancellation parameters
0171     // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F)
0172     // --------------------------------------------------------------------------------------
0173 
0174     // spPAParams16 : Sector processor pt-assignment parameters
0175     // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F),
0176     //            BugNegPt(F), BugGMTPhi(F), PromoteMode7(F)
0177     // ---------------------------------------------------------------------------------
0178     modeQualVer_ = 1;  // Version 2 contains modified mode-quality mapping for 2018
0179 
0180     // ___________________________________________________________________________
0181     // Versions in 2017 - no full documentation, can refer to https://twiki.cern.ch/twiki/bin/viewauth/CMS/L1KnownIssues
0182 
0183     // Before July 9th (runs < 298653), all mode 7 tracks (station 2-3-4) assigned quality 11
0184     // July 9th - 29th (runs 298653 - 300087), mode 7 tracks with |eta| > 1.6 in sector -6 assigned quality 12
0185     // After July 29th (runs >= 300088), mode 7 track promotion applied in all sectors
0186     // For some reason, the FW version in the database is 1496792995, at least for runs >= 298034 (July 4),
0187     //   which is towards the end of run 2017B (could not check earlier runs).  This corresponds to the date "June 6th",
0188     //   which is a month earlier than the first firmware update to apply this promotion.  So something's screwey.
0189     // Since July 18 is in the middle of the single-sector-fix period, would like to use a firmware version with
0190     //   roughly that date.  But this may require an intervention in the database. - AWB 04.08.17
0191     // Last firmware version in 2017 was 1504018578 (Aug. 29, 2017).
0192     if (fw_version >= 1496792995)
0193       promoteMode7_ = true;  // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality
0194 
0195     return;
0196   }
0197 
0198   ///////////////////////////////////////////////////////////////////////////
0199   ///  Settings for all of 2016 (following order in simEmtfDigis_cfi.py)  ///
0200   ///////////////////////////////////////////////////////////////////////////
0201   else {
0202     // Global parameters
0203     // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2)
0204     // --------------------------------------------------------------------------------------------------------
0205     useRPC_ = false;     // Use clustered RPC hits from CPPF in track-building
0206     era_ = "Run2_2016";  // Era for CMSSW customization
0207     // maxBX_                 // Depends on FW version, see below
0208     bxWindow_ = 3;  // Number of BX whose primitives can be included in the same track
0209 
0210     // spTBParams16 : Sector processor track-building parameters
0211     // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T),
0212     //            DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T)
0213     // ------------------------------------------------------------------------------
0214     // primConvLUT_         // Should be 0 for 2016, set using get_pc_lut_version() from ConditionsHelper.cc
0215     // fixZonePhi_          // Depends on FW version, see below
0216     fixME11Edges_ = false;  // Improved small fraction of buggy LCT coordinate transformations
0217 
0218     // spPRParams16 : Sector processor pattern-recognition parameters
0219     // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T)
0220     // -----------------------------------------------------------------------------------------
0221     // useSymPatterns_  // Depends on FW version, see below
0222 
0223     // spTBParams16 : Sector processor track-building parameters
0224     // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F),
0225     //            BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T)
0226     // ----------------------------------------------------------------------------------
0227     thetaWindow_ = 4;       // Maximum dTheta between primitives in the same track
0228     thetaWindowZone0_ = 4;  // Maximum dTheta between primitives in the same track in Zone 0 (ring 1)
0229     // bugSt2PhDiff_           // Depends on FW version, see below
0230     // bugME11Dupes_           // Depends on FW version, see below
0231     bugAmbigThetaWin_ = true;   // Can allow dThetas outside window when there are 2 LCTs in the same chamber
0232     twoStationSameBX_ = false;  // Requires the hits in two-station tracks to have the same BX
0233 
0234     // spGCParams16 : Sector processor ghost-cancellation parameters
0235     // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F)
0236     // --------------------------------------------------------------------------------------
0237     // useSecondEarliest_  // Depends on FW version, see below
0238     // bugSameSectorPt0_   // Depends on FW version, see below
0239 
0240     // spPAParams16 : Sector processor pt-assignment parameters
0241     // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F),
0242     //            BugNegPt(F), BugGMTPhi(F), PromoteMode7(F)
0243     // ---------------------------------------------------------------------------------
0244     // fixMode15HighPt_   // Depends on FW version, see below
0245     // bug9BitDPhi_       // Depends on FW version, see below
0246     // bugMode7CLCT_      // Depends on FW version, see below
0247     // bugNegPt_          // Depends on FW version, see below
0248     bugGMTPhi_ = true;  // Some drift in uGMT phi conversion, off by up to a few degrees
0249     modeQualVer_ = 1;   // Version 2 contains modified mode-quality mapping for 2018
0250 
0251   }  // End default settings for 2016
0252 
0253   // ___________________________________________________________________________
0254   // Versions in 2016 - refer to docs/EMTF_FW_LUT_versions_2016_draft2.xlsx
0255 
0256   // 1st_LCT_BX / 2nd_LCT_BX  (should also make unpacker configurable - AWB 21.07.17)
0257   // FW: Before: Earliest LCT used to assign BX, tracks only cancel within same BX
0258   //     After:  Second-earliest LCT used to assign BX, tracks cancel over 3 BX, improved LCT recovery
0259   useSecondEarliest_ = (fw_version < 46773) ? false : true;  // Changed Sept. 5
0260 
0261   // 8_BX_readout / 7_BX_readout
0262   // SW: DAQ readout changed from to [-3, +4] BX to [-3, +3] BX
0263   maxBX_ = (fw_version < 47109) ? +4 : +3;  // Changed Sept. 28
0264 
0265   // Asymm_patterns / Symm_patterns
0266   // FW: Changed from 9 asymmetric patterns to 5 symmetric patterns for track building
0267   useSymPatterns_ = (fw_version < 47214) ? false : true;  // Changed Oct. 6
0268 
0269   // HiPt_outlier
0270   // LUT: High-pT fix puts outlier LCTs in mode 15 tracks back in a straight line
0271   fixMode15HighPt_ = (fw_version < 46650) ? false : true;  // Changed July 25
0272 
0273   // Link_monitor (unpacker only)
0274   // FW: Added MPC link monitoring
0275 
0276   // ___________________________________________________________________________
0277   // Bugs
0278 
0279   // DAQ_ID (unpacker only; should make configurable - AWB 21.07.17)
0280   // FW: DAQ ME with output CSC ID range 0 - 8 instead of 1 - 9
0281   //     SP output ME2_ID, 3_ID, and 4_ID filled with 4, 5, or 6 when they should have been 7, 8, or 9.
0282 
0283   // ME_ID_FR
0284   // FW: Incorrect ME_ID fields in DAQ, wrong FR bits and some dPhi wrap-around in pT LUT address
0285   // - Unpacker only, or not worth emulating
0286 
0287   // DAQ_miss_LCT (unpacker only)
0288   // FW: LCTs only output if there was a track in the sector
0289 
0290   // Sector_pT_0
0291   // FW: Only highest-quality track in a sector assigned pT; others assigned pT = 0
0292   bugSameSectorPt0_ = (fw_version < 46650) ? true : false;  // Fixed July 22
0293 
0294   // Sector_bad_pT
0295   // FW: Tracks sometimes assigned pT of track in previous BX
0296   // - This is an ongoing (very rare) bug which occurs when 2 tracks try to access the same "bank" in the pT LUT
0297   //   It would be very difficult to emulate exactly, but the logic from Alex Madorsky is below
0298   // ## macro for detecting same bank address
0299   // ## bank and chip must match, and valid flags must be set
0300   // ## a and b are indexes 0,1,2
0301   // ## [X:Y] are bit portions from ptlut address words
0302   // `define sb(a,b) (ptlut_addr[a][29:26] == ptlut_addr[b][29:26] && ptlut_addr[a][5:2] == ptlut_addr[b][5:2] && ptlut_addr_val[a] && ptlut_addr_val[b])
0303   // ## This macro is used like this:
0304   // if (`sb(0,2) || `sb(1,2)) {disable PT readout for track 2}
0305 
0306   // DAQ_BX_3_LCT (unpacker only)
0307   // SW: LCTs in BX -3 only reported if there was a track in the sector
0308   // - not applicable
0309 
0310   // DAQ_BX_23_LCT (unpacker only)
0311   // SW: LCTs in BX -2 and -3 only reported if there was a track in the sector
0312   // - not applicable
0313 
0314   // pT_dPhi_bits
0315   // FW: dPhi wrap-around in modes 3, 5, 6, 9, 10, 12
0316   bug9BitDPhi_ = (fw_version < 47214) ? true : false;  // Fixed Oct. 6
0317 
0318   // Pattern_phi / ME1_neigh_phi
0319   // FW: Pattern phi slightly offset from true LCT phi; also ME3/4 pattern width off
0320   //     Pattern phi of neighbor hits in ME1 miscalculated
0321   fixZonePhi_ = (fw_version < 47214) ? false : true;  // Fixed Oct. 6
0322 
0323   // LCT_station_2
0324   // FW: Reduced LCT matching window in station 2, resulting in demoted tracks and inefficiency
0325   bugSt2PhDiff_ = (47109 <= fw_version && fw_version < 47249) ? true : false;  // Bug introduced Oct. 6, fixed Oct. 19
0326 
0327   // LCT_theta_dup
0328   // FW: LCTs matched to track may take theta value from other LCT in the same chamber
0329   bugME11Dupes_ = (fw_version < 47423) ? true : false;  // Fixed Nov. 1
0330 
0331   // LCT_7_10_neg_pT (E)
0332   // LUT: Written with incorrect values for mode 7 CLCT, mode 10 random offset, all modes negative (1/pT) set to 3 instead of 511
0333   bugMode7CLCT_ = (fw_version < 47864) ? true : false;  // Fixed sometime after Nov. 1
0334   bugNegPt_ = (fw_version < 47864) ? true : false;      // Fixed sometime after Nov. 1
0335 }