From 4f0593b2f2067b6778a012956a6b50ccbb9a4316 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:32:25 -0400 Subject: [PATCH 01/34] [EMTF] Update data formats 1/3 --- DataFormats/L1TMuon/interface/EMTFHit.h | 57 ++++++++++------------- DataFormats/L1TMuon/interface/EMTFTrack.h | 12 ++--- DataFormats/L1TMuon/src/EMTFHit.cc | 2 +- 3 files changed, 31 insertions(+), 40 deletions(-) diff --git a/DataFormats/L1TMuon/interface/EMTFHit.h b/DataFormats/L1TMuon/interface/EMTFHit.h index 2d3c2c0560b3c..27a4d9e1e6685 100644 --- a/DataFormats/L1TMuon/interface/EMTFHit.h +++ b/DataFormats/L1TMuon/interface/EMTFHit.h @@ -12,9 +12,11 @@ #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" #include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "DataFormats/MuonDetId/interface/DTChamberId.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h" -#include "DataFormats/GEMDigi/interface/GEMPadDigi.h" -#include "DataFormats/GEMDigi/interface/ME0PadDigi.h" +//#include "DataFormats/RPCDigi/interface/RPCDigi.h" +//#include "DataFormats/GEMDigi/interface/GEMPadDigi.h" +//#include "DataFormats/GEMDigi/interface/ME0PadDigi.h" #include "DataFormats/L1TMuon/interface/CPPFDigi.h" #include "DataFormats/L1TMuon/interface/EMTF/ME.h" @@ -24,6 +26,7 @@ namespace l1t { public: EMTFHit() : rawDetId(0), + subsystem(-99), endcap(-99), station(-99), ring(-99), @@ -57,8 +60,6 @@ namespace l1t { stub_num(-99), phi_fp(-99), theta_fp(-99), - phzvl(-99), - ph_hit(-99), zone_hit(-99), zone_code(-99), fs_segment(-99), @@ -76,20 +77,17 @@ namespace l1t { rho_sim(-99), z_sim(-99), alct_quality(-99), - clct_quality(-99), - is_CSC(-99), - is_RPC(-99), - is_GEM(-99), - subsystem(-99){}; + clct_quality(-99){}; virtual ~EMTFHit(){}; // void ImportCSCDetId (const CSCDetId& _detId); CSCDetId CreateCSCDetId() const; // void ImportRPCDetId (const RPCDetId& _detId); - // void ImportGEMDetId (const GEMDetId& _detId); RPCDetId CreateRPCDetId() const; + // void ImportGEMDetId (const GEMDetId& _detId); // GEMDetId CreateGEMDetId() const; + // void ImportCSCCorrelatedLCTDigi (const CSCCorrelatedLCTDigi& _digi); CSCCorrelatedLCTDigi CreateCSCCorrelatedLCTDigi() const; // void ImportRPCDigi (const RPCDigi& _digi); @@ -113,6 +111,7 @@ namespace l1t { void SetRPCDetId(const RPCDetId& id) { rawDetId = id.rawId(); } void SetGEMDetId(const GEMDetId& id) { rawDetId = id.rawId(); } void SetME0DetId(const ME0DetId& id) { rawDetId = id.rawId(); } + void SetDTDetId(const DTChamberId& id) { rawDetId = id.rawId(); } //CSCDetId CSC_DetId () const { return csc_DetId; } //RPCDetId RPC_DetId () const { return rpc_DetId; } @@ -125,7 +124,9 @@ namespace l1t { RPCDetId RPC_DetId() const { return RPCDetId(rawDetId); } GEMDetId GEM_DetId() const { return GEMDetId(rawDetId); } ME0DetId ME0_DetId() const { return ME0DetId(rawDetId); } + DTChamberId DT_DetId() const { return DTChamberId(rawDetId); } + void set_subsystem(int bits) { subsystem = bits; } void set_endcap(int bits) { endcap = bits; } void set_station(int bits) { station = bits; } void set_ring(int bits) { ring = bits; } @@ -159,8 +160,6 @@ namespace l1t { void set_stub_num(int bits) { stub_num = bits; } void set_phi_fp(int bits) { phi_fp = bits; } void set_theta_fp(int bits) { theta_fp = bits; } - void set_phzvl(int bits) { phzvl = bits; } - void set_ph_hit(int bits) { ph_hit = bits; } void set_zone_hit(int bits) { zone_hit = bits; } void set_zone_code(int bits) { zone_code = bits; } void set_fs_segment(int bits) { fs_segment = bits; } @@ -179,11 +178,8 @@ namespace l1t { void set_z_sim(float val) { z_sim = val; } void set_alct_quality(int bits) { alct_quality = bits; } void set_clct_quality(int bits) { clct_quality = bits; } - void set_is_CSC(int bits) { is_CSC = bits; } - void set_is_RPC(int bits) { is_RPC = bits; } - void set_is_GEM(int bits) { is_GEM = bits; } - void set_subsystem(int bits) { subsystem = bits; } + int Subsystem() const { return subsystem; } int Endcap() const { return endcap; } int Station() const { return station; } int Ring() const { return ring; } @@ -217,8 +213,6 @@ namespace l1t { int Stub_num() const { return stub_num; } int Phi_fp() const { return phi_fp; } int Theta_fp() const { return theta_fp; } - int Phzvl() const { return phzvl; } - int Ph_hit() const { return ph_hit; } int Zone_hit() const { return zone_hit; } int Zone_code() const { return zone_code; } int FS_segment() const { return fs_segment; } @@ -237,10 +231,13 @@ namespace l1t { float Z_sim() const { return z_sim; } int ALCT_quality() const { return alct_quality; } int CLCT_quality() const { return clct_quality; } - int Is_CSC() const { return is_CSC; } - int Is_RPC() const { return is_RPC; } - int Is_GEM() const { return is_GEM; } - int Subsystem() const { return subsystem; } + + // See L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h + bool Is_DT() const { return subsystem == 0; } + bool Is_CSC() const { return subsystem == 1; } + bool Is_RPC() const { return subsystem == 2; } + bool Is_GEM() const { return subsystem == 3; } + bool Is_ME0() const { return subsystem == 4; } private: //CSCDetId csc_DetId; @@ -252,14 +249,14 @@ namespace l1t { //GEMPadDigi gem_PadDigi; uint32_t rawDetId; // raw CMSSW DetId - - int endcap; // +/-1. For ME+ and ME-. - int station; // 1 - 4. + int subsystem; // 0 - 4. 0 for DT, 1 for CSC, 2 for RPC, 3 for GEM, 4 for ME0 + int endcap; // +/-1. For ME+ and ME-. + int station; // 1 - 4. int ring; // 1 - 4. ME1/1a is denoted as "Ring 4". Should check dependence on input CSCDetId convention. - AWB 02.03.17 int sector; // 1 - 6. CSC / EMTF sector convention: sector 1 starts at 15 degrees int sector_RPC; // 1 - 6. RPC sector convention (in CMSSW): sector 1 starts at -5 degrees int sector_idx; // 0 - 11. 0 - 5 for ME+, 6 - 11 for ME-. For neighbor hits, set by EMTF sector that received it. - int subsector; // 0 - 6. In CSCs, 1 or 2 for ME1, 0 for ME2/3/4. In RPCs, 1 - 6, where 1 is first chamber in EMTF sector. + int subsector; // 0 - 6. In CSCs, 1 or 2 for ME1, 0 for ME2/3/4. int subsector_RPC; // 0 - 6. RPC sector convention (in CMSSW): subsector 3 is the first chamber in the EMTF sector. int chamber; // 1 - 36. Chamber 1 starts at -5 degrees. int csc_ID; // 1 - 9. For CSCs only. @@ -286,8 +283,6 @@ namespace l1t { int stub_num; // 0 or 1. Only from unpacked data? - AWB 02.03.17 int phi_fp; // 0 - 4920 int theta_fp; // 0 - 127 - int phzvl; // 0 - 6. - int ph_hit; // 2 - 43. (Range? - AWB 02.03.17) int zone_hit; // 4 - 156 (Range? - AWB 02.03.17) int zone_code; // 0 - 12. (Range? - AWB 02.03.17) int fs_segment; // 0 - 13. (Range? - AWB 02.03.17) @@ -298,7 +293,7 @@ namespace l1t { float phi_glob; // +/-180. float theta; // 0 - 90. float eta; // +/-2.5. - float time; // ? - ?. RPC time information + float time; // ? - ?. RPC time information (ns) float phi_sim; // +/-180. float theta_sim; // 0 - 90. float eta_sim; // +/-2.5. @@ -306,10 +301,6 @@ namespace l1t { float z_sim; // ? - ?. int alct_quality; // 1 - 3. For emulated CSC LCTs only, maps to number of ALCT layers (4 - 6). int clct_quality; // 4 - 6. For emulated CSC LCTs only, maps to number of CLCT layers (4 - 6). - int is_CSC; // 0 or 1. - int is_RPC; // 0 or 1. - int is_GEM; // 0 or 1. - int subsystem; // 1 or ?. 1 for CSC, 2 for RPC, 3 for GEM }; // End of class EMTFHit diff --git a/DataFormats/L1TMuon/interface/EMTFTrack.h b/DataFormats/L1TMuon/interface/EMTFTrack.h index 6faca0692bd7e..ce271f80a26cd 100644 --- a/DataFormats/L1TMuon/interface/EMTFTrack.h +++ b/DataFormats/L1TMuon/interface/EMTFTrack.h @@ -107,10 +107,10 @@ namespace l1t { EMTFHitCollection Hits() const { return _Hits; } std::vector HitIdx() const { return _HitIdx; } - void set_Road(const EMTFRoad& bits) { _Road = bits; } - void set_RoadIdx(unsigned int bits) { _RoadIdx = bits; } - EMTFRoad Road() const { return _Road; } - unsigned int RoadIdx() const { return _RoadIdx; } + //void set_Road(const EMTFRoad& bits) { _Road = bits; } + //void set_RoadIdx(unsigned int bits) { _RoadIdx = bits; } + //EMTFRoad Road() const { return _Road; } + //unsigned int RoadIdx() const { return _RoadIdx; } void set_PtLUT(EMTFPtLUT bits) { _PtLUT = bits; } EMTFPtLUT PtLUT() const { return _PtLUT; } @@ -182,8 +182,8 @@ namespace l1t { EMTFHitCollection _Hits; std::vector _HitIdx; - EMTFRoad _Road; - unsigned int _RoadIdx; + //EMTFRoad _Road; + //unsigned int _RoadIdx; EMTFPtLUT _PtLUT; diff --git a/DataFormats/L1TMuon/src/EMTFHit.cc b/DataFormats/L1TMuon/src/EMTFHit.cc index 0c682b2407444..0199cae12de45 100644 --- a/DataFormats/L1TMuon/src/EMTFHit.cc +++ b/DataFormats/L1TMuon/src/EMTFHit.cc @@ -42,7 +42,7 @@ namespace l1t { } CPPFDigi EMTFHit::CreateCPPFDigi() const { - if (is_RPC != 1) + if (!Is_RPC()) return CPPFDigi(); int board_ = 1 + ((chamber % 36) / 9); // RPC chamber to CPPF board mapping From be626185fd22fe0d8c73f666250f489d820a45bb Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:35:10 -0400 Subject: [PATCH 02/34] [EMTF] Update data formats 2/3 --- .../plugins/implementations_stage2/EMTFUnpackerTools.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFUnpackerTools.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFUnpackerTools.cc index cde586009d67a..8c383fe7c221a 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFUnpackerTools.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFUnpackerTools.cc @@ -18,9 +18,7 @@ namespace l1t { _hit.set_sync_err(_ME.SE()); _hit.set_bx(_ME.TBIN() - 3); _hit.set_bc0(_ME.BC0()); - _hit.set_is_CSC(true); - _hit.set_is_RPC(false); - _hit.set_subsystem(1); + _hit.set_subsystem(1); // 1 for CSC // _hit.set_layer(); _hit.set_ring(L1TMuonEndCap::calc_ring(_hit.Station(), _hit.CSC_ID(), _hit.Strip())); @@ -45,9 +43,7 @@ namespace l1t { _hit.set_bx(_RPC.TBIN() - 3); _hit.set_valid(_RPC.VP()); _hit.set_bc0(_RPC.BC0()); - _hit.set_is_CSC(false); - _hit.set_is_RPC(true); - _hit.set_subsystem(2); + _hit.set_subsystem(2); // 2 for RPC _hit.SetRPCDetId(_hit.CreateRPCDetId()); // // Not yet implemented - AWB 15.03.17 From c9db43431065fe1763170d040a7b101ef3be6b0f Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:38:13 -0400 Subject: [PATCH 03/34] [EMTF] Update data formats 3/3 --- L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc | 5 ++--- .../L1TMuonEndCap/src/PrimitiveConversion.cc | 15 +++------------ .../L1TMuonEndCap/src/TTPrimitiveConversion.cc | 3 --- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc b/L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc index 68f138d67eb42..7eff03919e3a2 100644 --- a/L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc +++ b/L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc @@ -220,9 +220,8 @@ void PatternRecognition::process(const std::deque& extended_c for (const auto& conv_hit : conv_hits) { if (conv_hit.Subsystem() == TriggerPrimitive::kCSC) { std::cout << "CSC hit st: " << conv_hit.PC_station() << " ch: " << conv_hit.PC_chamber() - << " ph: " << conv_hit.Phi_fp() << " th: " << conv_hit.Theta_fp() - << " ph_hit: " << (1ul << conv_hit.Ph_hit()) << " phzvl: " << conv_hit.Phzvl() - << " strip: " << conv_hit.Strip() << " wire: " << conv_hit.Wire() << " cpat: " << conv_hit.Pattern() + << " ph: " << conv_hit.Phi_fp() << " th: " << conv_hit.Theta_fp() << " strip: " << conv_hit.Strip() + << " wire: " << conv_hit.Wire() << " cpat: " << conv_hit.Pattern() << " zone_hit: " << conv_hit.Zone_hit() << " zone_code: " << conv_hit.Zone_code() << " bx: " << conv_hit.BX() << std::endl; } diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc index e7ecd5195b665..d6345a02d76f7 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc @@ -154,9 +154,6 @@ void PrimitiveConversion::convert_csc(int pc_sector, conv_hit.set_bx(tp_bx + bxShiftCSC_); conv_hit.set_subsystem(TriggerPrimitive::kCSC); - conv_hit.set_is_CSC(true); - conv_hit.set_is_RPC(false); - conv_hit.set_is_GEM(false); conv_hit.set_pc_sector(pc_sector); conv_hit.set_pc_station(pc_station); @@ -436,7 +433,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { //int zone_hit = ((fph + (1<<4)) >> 5); int zone_code = get_zone_code(conv_hit, th); - int phzvl = get_phzvl(conv_hit, zone_code); + //int phzvl = get_phzvl(conv_hit, zone_code); int fs_zone_code = get_fs_zone_code(conv_hit); int fs_segment = get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment); @@ -449,8 +446,8 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { conv_hit.set_phi_fp(fph); // Full-precision integer phi conv_hit.set_theta_fp(th); // Full-precision integer theta - conv_hit.set_phzvl(phzvl); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging - conv_hit.set_ph_hit(ph_hit); // Intermediate quantity in phi calculation - used in FW debugging + //conv_hit.set_phzvl(phzvl); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging + //conv_hit.set_ph_hit(ph_hit); // Intermediate quantity in phi calculation - used in FW debugging conv_hit.set_zone_hit(zone_hit); // Phi value for building patterns (0.53333 deg precision) conv_hit.set_zone_code(zone_code); // Full zone word: 1*(zone 0) + 2*(zone 1) + 4*(zone 2) + 8*(zone 3) @@ -516,9 +513,6 @@ void PrimitiveConversion::convert_rpc(int pc_sector, conv_hit.set_bx(tp_bx + bxShiftRPC_); conv_hit.set_subsystem(TriggerPrimitive::kRPC); - conv_hit.set_is_CSC(false); - conv_hit.set_is_RPC(true); - conv_hit.set_is_GEM(false); conv_hit.set_pc_sector(pc_sector); conv_hit.set_pc_station(pc_station); @@ -814,9 +808,6 @@ void PrimitiveConversion::convert_gem(int pc_sector, conv_hit.set_bx(tp_bx + bxShiftGEM_); conv_hit.set_subsystem(TriggerPrimitive::kGEM); - conv_hit.set_is_CSC(false); - conv_hit.set_is_RPC(false); - conv_hit.set_is_GEM(true); conv_hit.set_pc_sector(pc_sector); conv_hit.set_pc_station(pc_station); diff --git a/L1Trigger/L1TMuonEndCap/src/TTPrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/TTPrimitiveConversion.cc index 50ad5707d5221..b3c90d40f0b0e 100644 --- a/L1Trigger/L1TMuonEndCap/src/TTPrimitiveConversion.cc +++ b/L1Trigger/L1TMuonEndCap/src/TTPrimitiveConversion.cc @@ -73,9 +73,6 @@ void TTPrimitiveConversion::convert_tt(const TTTriggerPrimitive& ttmuon_primitiv conv_hit.set_bx(tp_data.bx); conv_hit.set_subsystem(TTTriggerPrimitive::kTT); - conv_hit.set_is_CSC(false); - conv_hit.set_is_RPC(false); - conv_hit.set_is_GEM(false); //conv_hit.set_pc_sector ( pc_sector ); //conv_hit.set_pc_station ( pc_station ); From d08d6cefb034e8ee7cf46759d0ec3e31f9b85908 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:43:02 -0400 Subject: [PATCH 04/34] [EMTF] Update MuonTriggerPrimitive & GeometryTranslator 1/5 --- .../L1TMuon/interface/TTGeometryTranslator.h | 73 ------- .../interface/TTMuonTriggerPrimitive.h | 117 ----------- L1Trigger/L1TMuon/src/TTGeometryTranslator.cc | 183 ------------------ .../L1TMuon/src/TTMuonTriggerPrimitive.cc | 128 ------------ 4 files changed, 501 deletions(-) delete mode 100644 L1Trigger/L1TMuon/interface/TTGeometryTranslator.h delete mode 100644 L1Trigger/L1TMuon/interface/TTMuonTriggerPrimitive.h delete mode 100644 L1Trigger/L1TMuon/src/TTGeometryTranslator.cc delete mode 100644 L1Trigger/L1TMuon/src/TTMuonTriggerPrimitive.cc diff --git a/L1Trigger/L1TMuon/interface/TTGeometryTranslator.h b/L1Trigger/L1TMuon/interface/TTGeometryTranslator.h deleted file mode 100644 index 5f520c32e28d5..0000000000000 --- a/L1Trigger/L1TMuon/interface/TTGeometryTranslator.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __L1TMuon_TTGeometryTranslator_h__ -#define __L1TMuon_TTGeometryTranslator_h__ - -// -// This class implements the translations from trigger primitive to -// global CMS coordinates for the Tracker trigger primitives analogous to -// the class GeometryTranslator. -// - -#include "FWCore/Framework/interface/ESHandle.h" -#include "DataFormats/GeometryVector/interface/GlobalPoint.h" -#include - -// forwards -namespace edm { - class EventSetup; -} - -class TrackerGeometry; -class TrackerTopology; -class MagneticField; - -namespace L1TMuon { - - class TTTriggerPrimitive; - - class TTGeometryTranslator { - public: - TTGeometryTranslator(); - ~TTGeometryTranslator(); - - // Things you have to do to just get simple det id info... - bool isBarrel(const TTTriggerPrimitive&) const; - bool isPSModule(const TTTriggerPrimitive&) const; - int region(const TTTriggerPrimitive&) const; // 0 for Barrel, +/-1 for +/- Endcap - int layer(const TTTriggerPrimitive&) const; - int ring(const TTTriggerPrimitive&) const; - int module(const TTTriggerPrimitive&) const; - - // The translations - double calculateGlobalEta(const TTTriggerPrimitive&) const; - double calculateGlobalPhi(const TTTriggerPrimitive&) const; - double calculateBendAngle(const TTTriggerPrimitive&) const; - - GlobalPoint getGlobalPoint(const TTTriggerPrimitive&) const; - - // Update geometry if necessary - void checkAndUpdateGeometry(const edm::EventSetup&); - - // Retrieve the geometry records - const TrackerGeometry& getTrackerGeometry() const { return *_geom; } - const TrackerTopology& getTrackerTopology() const { return *_topo; } - const MagneticField& getMagneticField() const { return *_magfield; } - - private: - // Pointers to the current geometry records - unsigned long long _geom_cache_id; - edm::ESHandle _geom; - - unsigned long long _topo_cache_id; - edm::ESHandle _topo; - - unsigned long long _magfield_cache_id; - edm::ESHandle _magfield; - - GlobalPoint getTTSpecificPoint(const TTTriggerPrimitive&) const; - double calcTTSpecificEta(const TTTriggerPrimitive&) const; - double calcTTSpecificPhi(const TTTriggerPrimitive&) const; - double calcTTSpecificBend(const TTTriggerPrimitive&) const; - }; -} // namespace L1TMuon - -#endif diff --git a/L1Trigger/L1TMuon/interface/TTMuonTriggerPrimitive.h b/L1Trigger/L1TMuon/interface/TTMuonTriggerPrimitive.h deleted file mode 100644 index ae4085e7edf3f..0000000000000 --- a/L1Trigger/L1TMuon/interface/TTMuonTriggerPrimitive.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef __L1TMuon_TTMuonTriggerPrimitive_h__ -#define __L1TMuon_TTMuonTriggerPrimitive_h__ - -// -// This class implements a layer for Phase 2 Tracker trigger primitive -// analogous to the class MuonTriggerPrimitive. -// - -#include -#include -#include - -// DetId -#include "DataFormats/DetId/interface/DetId.h" -// Global point -#include "DataFormats/GeometryVector/interface/GlobalPoint.h" -// Track trigger data formats -#include "DataFormats/L1TrackTrigger/interface/TTTypes.h" - -namespace L1TMuon { - - class TTTriggerPrimitive { - public: - // Define the subsystems that we have available (none at the moment). - // Start at 20 for TTMuonTriggerPrimitive to avoid collision with MuonTriggerPrimitive - enum subsystem_type { kTT = 20, kNSubsystems }; - - // Rename these - typedef TTStub TTDigi; - typedef DetId TTDetId; - - // Define the raw data - struct TTData { - TTData() : row_f(0.), col_f(0.), bend(0), bx(0) {} - float row_f; // why float? - float col_f; // why float? - int bend; - int16_t bx; - }; - - // Persistency - TTTriggerPrimitive() : _subsystem(kNSubsystems) {} - - // Constructor from track trigger digi - TTTriggerPrimitive(const TTDetId& detid, const TTDigi& digi); - - // Copy constructor - TTTriggerPrimitive(const TTTriggerPrimitive&); - - // Destructor - ~TTTriggerPrimitive() {} - - // Assignment operator - TTTriggerPrimitive& operator=(const TTTriggerPrimitive& tp); - - // Equality operator - bool operator==(const TTTriggerPrimitive& tp) const; - - // Subsystem type - const subsystem_type subsystem() const { return _subsystem; } - - // Global coordinates - const double getCMSGlobalEta() const { return _eta; } - void setCMSGlobalEta(const double eta) { _eta = eta; } - const double getCMSGlobalPhi() const { return _phi; } - void setCMSGlobalPhi(const double phi) { _phi = phi; } - const double getCMSGlobalRho() const { return _rho; } - void setCMSGlobalRho(const double rho) { _rho = rho; } - - const GlobalPoint getCMSGlobalPoint() const { - double theta = 2. * atan(exp(-_eta)); - return GlobalPoint(GlobalPoint::Cylindrical(_rho, _phi, _rho / tan(theta))); - }; - - // Detector id - TTDetId detId() const { return _id; } - - TTDetId rawId() const { return detId(); } - - // Accessors to raw data - void setTTData(const TTData& data) { _data = data; } - - const TTData getTTData() const { return _data; } - - TTData& accessTTData() { return _data; } - - // Accessors to common information - const int getStrip() const; - const int getSegment() const; - const int getBend() const; - const int getBX() const; - - const unsigned getGlobalSector() const { return _globalsector; } - const unsigned getSubSector() const { return _subsector; } - - void print(std::ostream&) const; - - private: - // Translate to 'global' position information at the level of 60 - // degree sectors. Use CSC sectors as a template - void calculateTTGlobalSector(const TTDetId& detid, unsigned& globalsector, unsigned& subsector); - - TTData _data; - - TTDetId _id; - - subsystem_type _subsystem; - - unsigned _globalsector; // [1,6] in 60 degree sectors - unsigned _subsector; // [1,2] in 30 degree partitions of a sector - double _eta, _phi, _rho; // global pseudorapidity, phi, rho - double _theta; // bend angle with respect to ray from (0,0,0). // NOT USED - }; - -} // namespace L1TMuon - -#endif diff --git a/L1Trigger/L1TMuon/src/TTGeometryTranslator.cc b/L1Trigger/L1TMuon/src/TTGeometryTranslator.cc deleted file mode 100644 index b9a729854419d..0000000000000 --- a/L1Trigger/L1TMuon/src/TTGeometryTranslator.cc +++ /dev/null @@ -1,183 +0,0 @@ -#include "L1Trigger/L1TMuon/interface/TTGeometryTranslator.h" -#include "L1Trigger/L1TMuon/interface/TTMuonTriggerPrimitive.h" - -// event setup stuff / geometries -#include "FWCore/Framework/interface/EventSetup.h" -#include "DataFormats/TrackerCommon/interface/TrackerTopology.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" - -#include "Geometry/CommonTopologies/interface/PixelTopology.h" -#include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h" -#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" - -#include "MagneticField/Engine/interface/MagneticField.h" -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" - -using Phase2TrackerGeomDetUnit = PixelGeomDetUnit; -using Phase2TrackerTopology = PixelTopology; - -using namespace L1TMuon; - -TTGeometryTranslator::TTGeometryTranslator() : _geom_cache_id(0ULL), _topo_cache_id(0ULL), _magfield_cache_id(0ULL) {} - -TTGeometryTranslator::~TTGeometryTranslator() {} - -bool TTGeometryTranslator::isBarrel(const TTTriggerPrimitive& tp) const { - const DetId detId = tp.detId(); - bool isBarrel = (detId.subdetId() == StripSubdetector::TOB); - //bool isEndcap = (detId.subdetId() == StripSubdetector::TID); - return isBarrel; -} - -bool TTGeometryTranslator::isPSModule(const TTTriggerPrimitive& tp) const { - const DetId detId = tp.detId(); - const TrackerGeometry::ModuleType moduleType = _geom->getDetectorType(detId); - bool isPSModule = - (moduleType == TrackerGeometry::ModuleType::Ph2PSP) || (moduleType == TrackerGeometry::ModuleType::Ph2PSS); - //bool isSSModule = (moduleType == TrackerGeometry::ModuleType::Ph2SS); - return isPSModule; -} - -int TTGeometryTranslator::region(const TTTriggerPrimitive& tp) const { - int region = 0; - - const DetId detId = tp.detId(); - if (detId.subdetId() == StripSubdetector::TOB) { // barrel - region = 0; - } else if (detId.subdetId() == StripSubdetector::TID) { // endcap - int type = _topo->tidSide(detId); // 1=-ve 2=+ve - if (type == 1) { - region = -1; - } else if (type == 2) { - region = +1; - } - } - return region; -} - -int TTGeometryTranslator::layer(const TTTriggerPrimitive& tp) const { - int layer = 0; - - const DetId detId = tp.detId(); - if (detId.subdetId() == StripSubdetector::TOB) { // barrel - layer = static_cast(_topo->layer(detId)); - } else if (detId.subdetId() == StripSubdetector::TID) { // endcap - layer = static_cast(_topo->layer(detId)); - } - return layer; -} - -int TTGeometryTranslator::ring(const TTTriggerPrimitive& tp) const { - int ring = 0; - - const DetId detId = tp.detId(); - if (detId.subdetId() == StripSubdetector::TOB) { // barrel - ring = static_cast(_topo->tobRod(detId)); - } else if (detId.subdetId() == StripSubdetector::TID) { // endcap - ring = static_cast(_topo->tidRing(detId)); - } - return ring; -} - -int TTGeometryTranslator::module(const TTTriggerPrimitive& tp) const { - int module = 0; - - const DetId detId = tp.detId(); - if (detId.subdetId() == StripSubdetector::TOB) { // barrel - module = static_cast(_topo->module(detId)); - } else if (detId.subdetId() == StripSubdetector::TID) { // endcap - module = static_cast(_topo->module(detId)); - } - return module; -} - -double TTGeometryTranslator::calculateGlobalEta(const TTTriggerPrimitive& tp) const { - switch (tp.subsystem()) { - case TTTriggerPrimitive::kTT: - return calcTTSpecificEta(tp); - break; - default: - return std::nan("Invalid TP type!"); - break; - } -} - -double TTGeometryTranslator::calculateGlobalPhi(const TTTriggerPrimitive& tp) const { - switch (tp.subsystem()) { - case TTTriggerPrimitive::kTT: - return calcTTSpecificPhi(tp); - break; - default: - return std::nan("Invalid TP type!"); - break; - } -} - -double TTGeometryTranslator::calculateBendAngle(const TTTriggerPrimitive& tp) const { - switch (tp.subsystem()) { - case TTTriggerPrimitive::kTT: - return calcTTSpecificBend(tp); - break; - default: - return std::nan("Invalid TP type!"); - break; - } -} - -GlobalPoint TTGeometryTranslator::getGlobalPoint(const TTTriggerPrimitive& tp) const { - switch (tp.subsystem()) { - case TTTriggerPrimitive::kTT: - return getTTSpecificPoint(tp); - break; - default: - GlobalPoint ret( - GlobalPoint::Polar(std::nan("Invalid TP type!"), std::nan("Invalid TP type!"), std::nan("Invalid TP type!"))); - return ret; - break; - } -} - -void TTGeometryTranslator::checkAndUpdateGeometry(const edm::EventSetup& es) { - const TrackerDigiGeometryRecord& geom = es.get(); - unsigned long long geomid = geom.cacheIdentifier(); - if (_geom_cache_id != geomid) { - geom.get(_geom); - _geom_cache_id = geomid; - } - - const TrackerTopologyRcd& topo = es.get(); - unsigned long long topoid = topo.cacheIdentifier(); - if (_topo_cache_id != topoid) { - topo.get(_topo); - _topo_cache_id = topoid; - } - - const IdealMagneticFieldRecord& magfield = es.get(); - unsigned long long magfieldid = magfield.cacheIdentifier(); - if (_magfield_cache_id != magfieldid) { - magfield.get(_magfield); - _magfield_cache_id = magfieldid; - } -} - -GlobalPoint TTGeometryTranslator::getTTSpecificPoint(const TTTriggerPrimitive& tp) const { - // Check L1Trigger/TrackTrigger/src/TTStubAlgorithm_official.cc - const DetId detId = tp.detId(); - const GeomDetUnit* geoUnit = _geom->idToDetUnit(detId + 1); // det0 - //const GeomDetUnit* geoUnit = _geom->idToDetUnit(detId+2); // det1 - const Phase2TrackerGeomDetUnit* ph2TkGeoUnit = dynamic_cast(geoUnit); - const MeasurementPoint mp(tp.getTTData().row_f, tp.getTTData().col_f); - const GlobalPoint gp = ph2TkGeoUnit->surface().toGlobal(ph2TkGeoUnit->specificTopology().localPosition(mp)); - return gp; -} - -double TTGeometryTranslator::calcTTSpecificEta(const TTTriggerPrimitive& tp) const { - return getTTSpecificPoint(tp).eta(); -} - -double TTGeometryTranslator::calcTTSpecificPhi(const TTTriggerPrimitive& tp) const { - return getTTSpecificPoint(tp).phi(); -} - -double TTGeometryTranslator::calcTTSpecificBend(const TTTriggerPrimitive& tp) const { return tp.getTTData().bend; } diff --git a/L1Trigger/L1TMuon/src/TTMuonTriggerPrimitive.cc b/L1Trigger/L1TMuon/src/TTMuonTriggerPrimitive.cc deleted file mode 100644 index 6e9839c4db406..0000000000000 --- a/L1Trigger/L1TMuon/src/TTMuonTriggerPrimitive.cc +++ /dev/null @@ -1,128 +0,0 @@ -#include "L1Trigger/L1TMuon/interface/TTMuonTriggerPrimitive.h" - -#include - -using namespace L1TMuon; - -namespace { - const char subsystem_names[][3] = {"TT"}; -} - -// Constructor from track trigger digi -TTTriggerPrimitive::TTTriggerPrimitive(const TTDetId& detid, const TTDigi& digi) : _id(detid), _subsystem(kTT) { - calculateTTGlobalSector(detid, _globalsector, _subsector); - - const MeasurementPoint& mp = digi.clusterRef(0)->findAverageLocalCoordinatesCentered(); - _data.row_f = mp.x(); - _data.col_f = mp.y(); - _data.bend = digi.bendFE(); - _data.bx = 0; -} - -// Copy constructor -TTTriggerPrimitive::TTTriggerPrimitive(const TTTriggerPrimitive& tp) - : _data(tp._data), - _id(tp._id), - _subsystem(tp._subsystem), - _globalsector(tp._globalsector), - _subsector(tp._subsector), - _eta(tp._eta), - _phi(tp._phi), - _rho(tp._rho), - _theta(tp._theta) {} - -// Assignment operator -TTTriggerPrimitive& TTTriggerPrimitive::operator=(const TTTriggerPrimitive& tp) { - this->_data = tp._data; - this->_id = tp._id; - this->_subsystem = tp._subsystem; - this->_globalsector = tp._globalsector; - this->_subsector = tp._subsector; - this->_eta = tp._eta; - this->_phi = tp._phi; - this->_rho = tp._rho; - this->_theta = tp._theta; - return *this; -} - -// Equality operator -bool TTTriggerPrimitive::operator==(const TTTriggerPrimitive& tp) const { - return (static_cast(this->_data.row_f) == static_cast(tp._data.row_f) && - static_cast(this->_data.col_f) == static_cast(tp._data.col_f) && - this->_data.bend == tp._data.bend && this->_data.bx == tp._data.bx && this->_id == tp._id && - this->_subsystem == tp._subsystem && this->_globalsector == tp._globalsector && - this->_subsector == tp._subsector); -} - -const int TTTriggerPrimitive::getBX() const { - switch (_subsystem) { - case kTT: - return _data.bx; - default: - throw cms::Exception("Invalid Subsytem") - << "The specified subsystem for this track stub is out of range" << std::endl; - } - return -1; -} - -const int TTTriggerPrimitive::getStrip() const { - switch (_subsystem) { - case kTT: - return static_cast(_data.row_f); - default: - throw cms::Exception("Invalid Subsytem") - << "The specified subsystem for this track stub is out of range" << std::endl; - } - return -1; -} - -const int TTTriggerPrimitive::getSegment() const { - switch (_subsystem) { - case kTT: - return static_cast(_data.col_f); - default: - throw cms::Exception("Invalid Subsytem") - << "The specified subsystem for this track stub is out of range" << std::endl; - } - return -1; -} - -const int TTTriggerPrimitive::getBend() const { - switch (_subsystem) { - case kTT: - return static_cast(_data.bend); - default: - throw cms::Exception("Invalid Subsytem") - << "The specified subsystem for this track stub is out of range" << std::endl; - } - return -1; -} - -void TTTriggerPrimitive::calculateTTGlobalSector(const TTDetId& detid, unsigned& globalsector, unsigned& subsector) { - globalsector = 0; - subsector = 0; -} - -std::ostream& operator<<(std::ostream& os, const TTTriggerPrimitive::TTDetId& detid) { - // Note that there is no endl to end the output - os << " undefined"; - return os; -} - -void TTTriggerPrimitive::print(std::ostream& out) const { - unsigned idx = (unsigned)_subsystem; - out << subsystem_names[idx] << " Trigger Primitive" << std::endl; - out << "eta: " << _eta << " phi: " << _phi << " rho: " << _rho << " bend: " << _theta << std::endl; - switch (_subsystem) { - case kTT: - out << detId() << std::endl; - out << "Strip : " << static_cast(_data.row_f) << std::endl; - out << "Segment : " << static_cast(_data.col_f) << std::endl; - out << "Bend : " << _data.bend << std::endl; - out << "BX : " << _data.bx << std::endl; - break; - default: - throw cms::Exception("Invalid Subsytem") - << "The specified subsystem for this track stub is out of range" << std::endl; - } -} From 1b4a4477458cd1bb5aa178c22397262aa20ebee2 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:44:34 -0400 Subject: [PATCH 05/34] [EMTF] Update MuonTriggerPrimitive & GeometryTranslator 2/5 --- L1Trigger/L1TMuon/BuildFile.xml | 2 -- L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h | 4 ---- L1Trigger/L1TMuon/plugins/RPCCollector.cc | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/L1Trigger/L1TMuon/BuildFile.xml b/L1Trigger/L1TMuon/BuildFile.xml index 6ef9fe262da5a..3e83e81659e72 100644 --- a/L1Trigger/L1TMuon/BuildFile.xml +++ b/L1Trigger/L1TMuon/BuildFile.xml @@ -22,5 +22,3 @@ - - diff --git a/L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h b/L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h index 9a3cd9137c689..4c404f2bb634d 100644 --- a/L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h +++ b/L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h @@ -15,10 +15,6 @@ namespace L1TMuon { //typedef std::vector TriggerPrimitiveList; //typedef edm::Ptr TriggerPrimitivePtr; //typedef std::map TriggerPrimitiveStationMap; - - class TTTriggerPrimitive; // Track Trigger hits - - typedef std::vector TTTriggerPrimitiveCollection; } // namespace L1TMuon #endif diff --git a/L1Trigger/L1TMuon/plugins/RPCCollector.cc b/L1Trigger/L1TMuon/plugins/RPCCollector.cc index ba03441e75602..8354d7dcc7f20 100644 --- a/L1Trigger/L1TMuon/plugins/RPCCollector.cc +++ b/L1Trigger/L1TMuon/plugins/RPCCollector.cc @@ -23,7 +23,7 @@ void RPCCollector::extractPrimitives(const edm::Event& ev, auto digi = (*chamber).second.first; auto dend = (*chamber).second.second; for (; digi != dend; ++digi) { - out.push_back(TriggerPrimitive((*chamber).first, digi->strip(), (*chamber).first.layer(), digi->bx())); + out.push_back(TriggerPrimitive((*chamber).first, *digi)); } } } From 05df0709eb7b14d5f9c09b49a4d114a49afab586 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:45:22 -0400 Subject: [PATCH 06/34] [EMTF] Update MuonTriggerPrimitive & GeometryTranslator 3/5 --- .../L1TMuon/interface/GeometryTranslator.h | 38 ++- .../L1TMuon/interface/MuonTriggerPrimitive.h | 149 +++++---- L1Trigger/L1TMuon/src/GeometryTranslator.cc | 154 ++++++---- L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc | 283 ++++++++++++------ 4 files changed, 397 insertions(+), 227 deletions(-) diff --git a/L1Trigger/L1TMuon/interface/GeometryTranslator.h b/L1Trigger/L1TMuon/interface/GeometryTranslator.h index 055a5518f91bd..720d5c3856826 100644 --- a/L1Trigger/L1TMuon/interface/GeometryTranslator.h +++ b/L1Trigger/L1TMuon/interface/GeometryTranslator.h @@ -15,24 +15,27 @@ // Some pieces of code lifted from: Matt Carver & Bobby Scurlock (UF) // +#include + #include "FWCore/Framework/interface/ESHandle.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" -#include -// forwards +// Forward declarations namespace edm { class EventSetup; } -class ME0Geometry; -class GEMGeometry; -class RPCGeometry; +class DTGeometry; class CSCGeometry; class CSCLayer; -class DTGeometry; +class RPCGeometry; +class GEMGeometry; +class ME0Geometry; class MagneticField; namespace L1TMuon { + + // Forward declaration class TriggerPrimitive; class GeometryTranslator { @@ -48,26 +51,30 @@ namespace L1TMuon { void checkAndUpdateGeometry(const edm::EventSetup&); - const ME0Geometry& getME0Geometry() const { return *_geome0; } - const GEMGeometry& getGEMGeometry() const { return *_geogem; } - const RPCGeometry& getRPCGeometry() const { return *_georpc; } - const CSCGeometry& getCSCGeometry() const { return *_geocsc; } const DTGeometry& getDTGeometry() const { return *_geodt; } + const CSCGeometry& getCSCGeometry() const { return *_geocsc; } + const RPCGeometry& getRPCGeometry() const { return *_georpc; } + const GEMGeometry& getGEMGeometry() const { return *_geogem; } + const ME0Geometry& getME0Geometry() const { return *_geome0; } const MagneticField& getMagneticField() const { return *_magfield; } private: - // pointers to the current geometry records unsigned long long _geom_cache_id; - edm::ESHandle _geome0; - edm::ESHandle _geogem; - edm::ESHandle _georpc; - edm::ESHandle _geocsc; edm::ESHandle _geodt; + edm::ESHandle _geocsc; + edm::ESHandle _georpc; + edm::ESHandle _geogem; + edm::ESHandle _geome0; unsigned long long _magfield_cache_id; edm::ESHandle _magfield; + GlobalPoint getME0SpecificPoint(const TriggerPrimitive&) const; + double calcME0SpecificEta(const TriggerPrimitive&) const; + double calcME0SpecificPhi(const TriggerPrimitive&) const; + double calcME0SpecificBend(const TriggerPrimitive&) const; + GlobalPoint getGEMSpecificPoint(const TriggerPrimitive&) const; double calcGEMSpecificEta(const TriggerPrimitive&) const; double calcGEMSpecificPhi(const TriggerPrimitive&) const; @@ -89,6 +96,7 @@ namespace L1TMuon { double calcDTSpecificPhi(const TriggerPrimitive&) const; double calcDTSpecificBend(const TriggerPrimitive&) const; }; + } // namespace L1TMuon #endif diff --git a/L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h b/L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h index b3feb3e56a4f0..5639d15d55081 100644 --- a/L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h +++ b/L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h @@ -19,11 +19,9 @@ #include #include -#include +#include -//DetId #include "DataFormats/DetId/interface/DetId.h" -//Global point (created on the fly) #include "DataFormats/GeometryVector/interface/GlobalPoint.h" // DT digi types @@ -36,6 +34,7 @@ class CSCCorrelatedLCTDigi; class CSCDetId; // RPC digi types +class RPCRecHit; class RPCDigi; class RPCDetId; @@ -45,11 +44,11 @@ namespace l1t { } // GEM digi types -class GEMPadDigi; +class GEMPadDigiCluster; class GEMDetId; // ME0 digi types -class ME0PadDigi; +class ME0TriggerDigi; class ME0DetId; namespace L1TMuon { @@ -57,7 +56,7 @@ namespace L1TMuon { class TriggerPrimitive { public: // define the subsystems that we have available - enum subsystem_type { kDT, kCSC, kRPC, kGEM, kNSubsystems }; + enum subsystem_type { kDT, kCSC, kRPC, kGEM, kME0, kNSubsystems }; // define the data we save locally from each subsystem type // variables in these structs keep their colloquial meaning @@ -71,9 +70,11 @@ namespace L1TMuon { phi_int(0), theta_int(0), emtf_sector(0), - layer(0), + emtf_link(0), bx(0), valid(0), + x(0.), + y(0.), time(0.), isCPPF(false) {} uint16_t strip; @@ -82,10 +83,12 @@ namespace L1TMuon { uint16_t phi_int; // for CPPFDigis in EMTF uint16_t theta_int; // for CPPFDigis in EMTF uint16_t emtf_sector; // for CPPFDigis in EMTF - uint16_t layer; + uint16_t emtf_link; // for CPPFDigis in EMTF int16_t bx; - uint16_t valid; - double time; // why double? + int16_t valid; + float x; // local coordinate x (use floating-point for now) + float y; // local coordinate y (use floating-point for now) + float time; // time (use floating-point for now) bool isCPPF; }; @@ -117,10 +120,8 @@ namespace L1TMuon { uint16_t bx0; uint16_t syncErr; uint16_t cscID; - - // Extra info for ALCT (wires) and CLCT (strips) - uint16_t alct_quality; - uint16_t clct_quality; + uint16_t alct_quality; // extra info for ALCT (wires) + uint16_t clct_quality; // extra info for CLCT (strips) }; struct DTData { @@ -134,6 +135,7 @@ namespace L1TMuon { qualityCode(0), Ts2TagCode(0), BxCntCode(0), + RpcBit(-10), theta_bti_group(0), segment_number(0), theta_code(0), @@ -149,6 +151,7 @@ namespace L1TMuon { int qualityCode; // need to decode int Ts2TagCode; // ?? int BxCntCode; // ???? + int RpcBit; // 0: DT only, 1: DT segment BX corrected by RPC, 2: RPC only // from ChambThDigi (corresponds to a BTI) // we have to root out the eta manually // theta super layer == SL 1 @@ -160,63 +163,79 @@ namespace L1TMuon { int theta_quality; }; + // See documentation in DataFormats/GEMDigi/interface/GEMPadDigiCluster.h struct GEMData { - GEMData() : pad(0), pad_low(0), pad_hi(0), bx(0), bend(0), isME0(false) {} + GEMData() : pad(0), pad_low(0), pad_hi(0), bx(0) {} uint16_t pad; uint16_t pad_low; // for use in clustering uint16_t pad_hi; // for use in clustering int16_t bx; - int16_t bend; - bool isME0; }; - //Persistency - TriggerPrimitive() : _subsystem(kNSubsystems) {} + // See documentation in DataFormats/GEMDigi/interface/ME0TriggerDigi.h + struct ME0Data { + ME0Data() : chamberid(0), quality(0), phiposition(0), partition(0), deltaphi(0), bend(0), bx(0) {} + uint16_t chamberid; + uint16_t quality; + uint16_t phiposition; + uint16_t partition; + uint16_t deltaphi; + uint16_t bend; + uint16_t bx; + }; + + // Persistency + TriggerPrimitive() : _id(0), _subsystem(kNSubsystems) {} + + // Constructors from DT data + TriggerPrimitive(const DTChamberId& detid, const L1MuDTChambPhDigi& digi_phi, const int segment_number); + TriggerPrimitive(const DTChamberId& detid, const L1MuDTChambThDigi& digi_th, const int theta_bti_group); + TriggerPrimitive(const DTChamberId& detid, + const L1MuDTChambPhDigi& digi_phi, + const L1MuDTChambThDigi& digi_th, + const int theta_bti_group); - //DT - TriggerPrimitive(const DTChamberId&, const L1MuDTChambPhDigi&, const int segment_number); - TriggerPrimitive(const DTChamberId&, const L1MuDTChambThDigi&, const int segment_number); - TriggerPrimitive(const DTChamberId&, const L1MuDTChambPhDigi&, const L1MuDTChambThDigi&, const int theta_bti_group); - //CSC - TriggerPrimitive(const CSCDetId&, const CSCCorrelatedLCTDigi&); - //RPC + // Constructor from CSC data + TriggerPrimitive(const CSCDetId& detid, const CSCCorrelatedLCTDigi& digi); + + // Constructors from RPC data TriggerPrimitive(const RPCDetId& detid, const RPCDigi& digi); - TriggerPrimitive(const RPCDetId& detid, // keep this version for backward compatibility - const unsigned strip, - const unsigned layer, - const int bx); - TriggerPrimitive(const RPCDetId& detid, // constructor from CPPFDigi - const l1t::CPPFDigi& digi); + TriggerPrimitive(const RPCDetId& detid, const RPCRecHit& rechit); + + // Constructor from CPPF data + TriggerPrimitive(const RPCDetId& detid, const l1t::CPPFDigi& digi); - // GEM - TriggerPrimitive(const GEMDetId& detid, const GEMPadDigi& digi); - TriggerPrimitive(const ME0DetId& detid, const ME0PadDigi& digi); + // Constructor from GEM data + TriggerPrimitive(const GEMDetId& detid, const GEMPadDigiCluster& digi); - //copy - TriggerPrimitive(const TriggerPrimitive&); + // Constructor from ME0 data + TriggerPrimitive(const ME0DetId& detid, const ME0TriggerDigi& digi); + // Copy constructor + TriggerPrimitive(const TriggerPrimitive& tp); TriggerPrimitive& operator=(const TriggerPrimitive& tp); bool operator==(const TriggerPrimitive& tp) const; // return the subsystem we belong to - const subsystem_type subsystem() const { return _subsystem; } - - const double getCMSGlobalEta() const { return _eta; } - void setCMSGlobalEta(const double eta) { _eta = eta; } - const double getCMSGlobalPhi() const { return _phi; } - void setCMSGlobalPhi(const double phi) { _phi = phi; } - const double getCMSGlobalRho() const { return _rho; } - void setCMSGlobalRho(const double rho) { _rho = rho; } - - const GlobalPoint getCMSGlobalPoint() const { - double theta = 2. * atan(exp(-_eta)); - return GlobalPoint(GlobalPoint::Cylindrical(_rho, _phi, _rho / tan(theta))); - }; + subsystem_type subsystem() const { return _subsystem; } + + void setCMSGlobalEta(double eta) { _eta = eta; } + void setCMSGlobalPhi(double phi) { _phi = phi; } + void setCMSGlobalRho(double rho) { _rho = rho; } + + double getCMSGlobalEta() const { return _eta; } + double getCMSGlobalPhi() const { return _phi; } + double getCMSGlobalRho() const { return _rho; } + + GlobalPoint getCMSGlobalPoint() const { + double theta = 2. * std::atan(std::exp(-_eta)); + return GlobalPoint(GlobalPoint::Cylindrical(_rho, _phi, _rho / std::tan(theta))); + } // this is the relative bending angle with respect to the // current phi position. // The total angle of the track is phi + bendAngle - void setThetaBend(const double theta) { _theta = theta; } + void setThetaBend(double theta) { _theta = theta; } double getThetaBend() const { return _theta; } template @@ -229,26 +248,29 @@ namespace L1TMuon { void setCSCData(const CSCData& csc) { _csc = csc; } void setRPCData(const RPCData& rpc) { _rpc = rpc; } void setGEMData(const GEMData& gem) { _gem = gem; } + void setME0Data(const ME0Data& me0) { _me0 = me0; } - const DTData getDTData() const { return _dt; } - const CSCData getCSCData() const { return _csc; } - const RPCData getRPCData() const { return _rpc; } - const GEMData getGEMData() const { return _gem; } + DTData getDTData() const { return _dt; } + CSCData getCSCData() const { return _csc; } + RPCData getRPCData() const { return _rpc; } + GEMData getGEMData() const { return _gem; } + ME0Data getME0Data() const { return _me0; } DTData& accessDTData() { return _dt; } CSCData& accessCSCData() { return _csc; } RPCData& accessRPCData() { return _rpc; } GEMData& accessGEMData() { return _gem; } + ME0Data& accessME0Data() { return _me0; } // consistent accessors to common information - const int getBX() const; - const int getStrip() const; - const int getWire() const; - const int getPattern() const; - const DetId rawId() const { return _id; }; + int getBX() const; + int getStrip() const; + int getWire() const; + int getPattern() const; + DetId rawId() const { return _id; } - const unsigned getGlobalSector() const { return _globalsector; } - const unsigned getSubSector() const { return _subsector; } + unsigned getGlobalSector() const { return _globalsector; } + unsigned getSubSector() const { return _subsector; } void print(std::ostream&) const; @@ -256,7 +278,7 @@ namespace L1TMuon { // Translate to 'global' position information at the level of 60 // degree sectors. Use CSC sectors as a template template - void calculateGlobalSector(const IDType& chid, unsigned& globalsector, unsigned& subsector) { + void calculateGlobalSector(const IDType& chid, unsigned& globalsector, unsigned& subsector) const { // Not sure if this is ever going to get implemented globalsector = 0; subsector = 0; @@ -266,6 +288,7 @@ namespace L1TMuon { CSCData _csc; RPCData _rpc; GEMData _gem; + ME0Data _me0; DetId _id; diff --git a/L1Trigger/L1TMuon/src/GeometryTranslator.cc b/L1Trigger/L1TMuon/src/GeometryTranslator.cc index 1233798523c0c..ba6ee175fa43b 100644 --- a/L1Trigger/L1TMuon/src/GeometryTranslator.cc +++ b/L1Trigger/L1TMuon/src/GeometryTranslator.cc @@ -1,23 +1,22 @@ #include "L1Trigger/L1TMuon/interface/GeometryTranslator.h" -#include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h" -// event setup stuff / geometries #include "FWCore/Framework/interface/EventSetup.h" -#include "Geometry/Records/interface/MuonGeometryRecord.h" - -#include "Geometry/CSCGeometry/interface/CSCGeometry.h" -#include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h" -#include "L1Trigger/CSCCommonTrigger/interface/CSCPatternLUT.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "L1Trigger/DTUtilities/interface/DTTrigGeom.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" #include "Geometry/RPCGeometry/interface/RPCGeometry.h" #include "Geometry/GEMGeometry/interface/GEMGeometry.h" #include "Geometry/GEMGeometry/interface/ME0Geometry.h" - #include "MagneticField/Engine/interface/MagneticField.h" #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "L1Trigger/DTUtilities/interface/DTTrigGeom.h" +#include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h" +#include "L1Trigger/CSCCommonTrigger/interface/CSCPatternLUT.h" + +#include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h" + #include // for pi using namespace L1TMuon; @@ -40,6 +39,9 @@ double GeometryTranslator::calculateGlobalEta(const TriggerPrimitive& tp) const case TriggerPrimitive::kGEM: return calcGEMSpecificEta(tp); break; + case TriggerPrimitive::kME0: + return calcME0SpecificEta(tp); + break; default: return std::nan("Invalid TP type!"); break; @@ -60,6 +62,9 @@ double GeometryTranslator::calculateGlobalPhi(const TriggerPrimitive& tp) const case TriggerPrimitive::kGEM: return calcGEMSpecificPhi(tp); break; + case TriggerPrimitive::kME0: + return calcME0SpecificPhi(tp); + break; default: return std::nan("Invalid TP type!"); break; @@ -80,6 +85,9 @@ double GeometryTranslator::calculateBendAngle(const TriggerPrimitive& tp) const case TriggerPrimitive::kGEM: return calcGEMSpecificBend(tp); break; + case TriggerPrimitive::kME0: + return calcME0SpecificBend(tp); + break; default: return std::nan("Invalid TP type!"); break; @@ -100,6 +108,9 @@ GlobalPoint GeometryTranslator::getGlobalPoint(const TriggerPrimitive& tp) const case TriggerPrimitive::kGEM: return getGEMSpecificPoint(tp); break; + case TriggerPrimitive::kME0: + return getME0SpecificPoint(tp); + break; default: GlobalPoint ret( GlobalPoint::Polar(std::nan("Invalid TP type!"), std::nan("Invalid TP type!"), std::nan("Invalid TP type!"))); @@ -112,11 +123,11 @@ void GeometryTranslator::checkAndUpdateGeometry(const edm::EventSetup& es) { const MuonGeometryRecord& geom = es.get(); unsigned long long geomid = geom.cacheIdentifier(); if (_geom_cache_id != geomid) { - geom.get(_geome0); - geom.get(_geogem); - geom.get(_georpc); - geom.get(_geocsc); geom.get(_geodt); + geom.get(_geocsc); + geom.get(_georpc); + geom.get(_geogem); + geom.get(_geome0); _geom_cache_id = geomid; } @@ -128,35 +139,49 @@ void GeometryTranslator::checkAndUpdateGeometry(const edm::EventSetup& es) { } } -GlobalPoint GeometryTranslator::getGEMSpecificPoint(const TriggerPrimitive& tp) const { - LocalPoint lp; - GlobalPoint gp; - - if (!tp.getGEMData().isME0) { // use GEM geometry - const GEMDetId id(tp.detId()); - const GEMEtaPartition* roll = _geogem->etaPartition(id); - assert(roll); - //const uint16_t pad = tp.getGEMData().pad; - // Use half-strip precision, - 0.5 at the end to get the center of the strip - const float pad = (0.5 * static_cast(tp.getGEMData().pad_low + tp.getGEMData().pad_hi)) - 0.5; - lp = roll->centreOfPad(pad); - gp = roll->surface().toGlobal(lp); - - } else { // use ME0 geometry - const ME0DetId id(tp.detId()); - const ME0EtaPartition* roll = _geome0->etaPartition(id); - assert(roll); - //const uint16_t pad = tp.getGEMData().pad; - // Use half-strip precision, - 0.5 at the end to get the center of the strip - const float pad = (0.5 * static_cast(tp.getGEMData().pad_low + tp.getGEMData().pad_hi)) - 0.5; - //lp = roll->centreOfPad(pad); // does not work - const float strip = 2.0 * pad; - lp = roll->centreOfStrip(strip); - gp = roll->surface().toGlobal(lp); - } +// _____________________________________________________________________________ +// ME0 +GlobalPoint GeometryTranslator::getME0SpecificPoint(const TriggerPrimitive& tp) const { + const ME0DetId id(tp.detId()); + const ME0Chamber* chamber = _geome0->chamber(id); + const ME0Layer* keylayer = chamber->layer(3); // ME0 key layer is layer 3 + int partition = tp.getME0Data().partition; // 'partition' is in half-roll unit + int iroll = (partition >> 1) + 1; + const ME0EtaPartition* roll = keylayer->etaPartition(iroll); + assert(roll != nullptr); // failed to get ME0 roll + // See L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.cc + int phiposition = tp.getME0Data().phiposition; // 'phiposition' is in half-strip unit + int istrip = (phiposition >> 1); + int phiposition2 = (phiposition & 0x1); + float centreOfStrip = istrip + 0.25 + phiposition2 * 0.5; + const LocalPoint& lp = roll->centreOfStrip(centreOfStrip); + const GlobalPoint& gp = roll->surface().toGlobal(lp); + return gp; +} + +double GeometryTranslator::calcME0SpecificEta(const TriggerPrimitive& tp) const { + return getME0SpecificPoint(tp).eta(); +} - //roll.release(); +double GeometryTranslator::calcME0SpecificPhi(const TriggerPrimitive& tp) const { + return getME0SpecificPoint(tp).phi(); +} + +double GeometryTranslator::calcME0SpecificBend(const TriggerPrimitive& tp) const { + return tp.getME0Data().deltaphi * (tp.getME0Data().bend == 0 ? 1 : -1); +} +// _____________________________________________________________________________ +// GEM +GlobalPoint GeometryTranslator::getGEMSpecificPoint(const TriggerPrimitive& tp) const { + const GEMDetId id(tp.detId()); + const GEMEtaPartition* roll = _geogem->etaPartition(id); + assert(roll != nullptr); // failed to get GEM roll + //const uint16_t pad = tp.getGEMData().pad; + // Use half-pad precision, + 0.5 at the end to get the center of the pad (pad starts from 0) + const float pad = (0.5 * static_cast(tp.getGEMData().pad_low + tp.getGEMData().pad_hi)) + 0.5f; + const LocalPoint& lp = roll->centreOfPad(pad); + const GlobalPoint& gp = roll->surface().toGlobal(lp); return gp; } @@ -168,20 +193,19 @@ double GeometryTranslator::calcGEMSpecificPhi(const TriggerPrimitive& tp) const return getGEMSpecificPoint(tp).phi(); } -double GeometryTranslator::calcGEMSpecificBend(const TriggerPrimitive& tp) const { return tp.getGEMData().bend; } +double GeometryTranslator::calcGEMSpecificBend(const TriggerPrimitive& tp) const { return 0.0; } +// _____________________________________________________________________________ +// RPC GlobalPoint GeometryTranslator::getRPCSpecificPoint(const TriggerPrimitive& tp) const { const RPCDetId id(tp.detId()); const RPCRoll* roll = _georpc->roll(id); - assert(roll); + assert(roll != nullptr); // failed to get RPC roll //const int strip = static_cast(tp.getRPCData().strip); - // Use half-strip precision, - 0.5 at the end to get the center of the strip - const float strip = (0.5 * static_cast(tp.getRPCData().strip_low + tp.getRPCData().strip_hi)) - 0.5; - const LocalPoint lp = roll->centreOfStrip(strip); - const GlobalPoint gp = roll->surface().toGlobal(lp); - - //roll.release(); - + // Use half-strip precision, - 0.5 at the end to get the center of the strip (strip starts from 1) + const float strip = (0.5 * static_cast(tp.getRPCData().strip_low + tp.getRPCData().strip_hi)) - 0.5f; + const LocalPoint& lp = roll->centreOfStrip(strip); + const GlobalPoint& gp = roll->surface().toGlobal(lp); return gp; } @@ -197,6 +221,9 @@ double GeometryTranslator::calcRPCSpecificPhi(const TriggerPrimitive& tp) const // hits are point-like objects double GeometryTranslator::calcRPCSpecificBend(const TriggerPrimitive& tp) const { return 0.0; } +// _____________________________________________________________________________ +// CSC +// // alot of this is transcription and consolidation of the CSC // global phi calculation code // this works directly with the geometry @@ -206,6 +233,7 @@ GlobalPoint GeometryTranslator::getCSCSpecificPoint(const TriggerPrimitive& tp) // we should change this to weak_ptrs at some point // requires introducing std::shared_ptrs to geometry std::unique_ptr chamb(_geocsc->chamber(id)); + assert(chamb != nullptr); // failed to get CSC chamber std::unique_ptr layer_geom(chamb->layer(CSCConstants::KEY_ALCT_LAYER)->geometry()); std::unique_ptr layer(chamb->layer(CSCConstants::KEY_ALCT_LAYER)); @@ -221,13 +249,13 @@ GlobalPoint GeometryTranslator::getCSCSpecificPoint(const TriggerPrimitive& tp) case 1: offset = CSCPatternLUT::get2007Position(pattern); } - const unsigned halfstrip_offs = unsigned(0.5 + halfstrip + offset); + const unsigned halfstrip_offs = static_cast(0.5 + halfstrip + offset); const unsigned strip = halfstrip_offs / 2 + 1; // geom starts from 1 // the rough location of the hit at the ALCT key layer // we will refine this using the half strip information - const LocalPoint coarse_lp = layer_geom->stripWireGroupIntersection(strip, keyWG); - const GlobalPoint coarse_gp = layer->surface().toGlobal(coarse_lp); + const LocalPoint& coarse_lp = layer_geom->stripWireGroupIntersection(strip, keyWG); + const GlobalPoint& coarse_gp = layer->surface().toGlobal(coarse_lp); // the strip width/4.0 gives the offset of the half-strip // center with respect to the strip center @@ -265,6 +293,15 @@ double GeometryTranslator::calcCSCSpecificPhi(const TriggerPrimitive& tp) const double GeometryTranslator::calcCSCSpecificBend(const TriggerPrimitive& tp) const { return tp.getCSCData().bend; } +bool GeometryTranslator::isCSCCounterClockwise(const std::unique_ptr& layer) const { + const int nStrips = layer->geometry()->numberOfStrips(); + const double phi1 = layer->centerOfStrip(1).phi(); + const double phiN = layer->centerOfStrip(nStrips).phi(); + return ((std::abs(phi1 - phiN) < M_PI && phi1 >= phiN) || (std::abs(phi1 - phiN) >= M_PI && phi1 < phiN)); +} + +// _____________________________________________________________________________ +// DT GlobalPoint GeometryTranslator::calcDTSpecificPoint(const TriggerPrimitive& tp) const { const DTChamberId baseid(tp.detId()); // do not use this pointer for anything other than creating a trig geom @@ -288,11 +325,11 @@ GlobalPoint GeometryTranslator::calcDTSpecificPoint(const TriggerPrimitive& tp) // of the chamber thetaBTI = DTBtiId(baseid, 3, 1); } - const GlobalPoint theta_gp = trig_geom->CMSPosition(thetaBTI); + const GlobalPoint& theta_gp = trig_geom->CMSPosition(thetaBTI); // local phi in sector -> global phi - double phi = ((double)tp.getDTData().radialAngle) / 4096.0; - phi += tp.getDTData().sector * M_PI / 6.0; // add sector offset + double phi = static_cast(tp.getDTData().radialAngle) / 4096.0; // 12 bits for 1 radian + phi += tp.getDTData().sector * M_PI / 6.0; // add sector offset, sector is [0,11] return GlobalPoint(GlobalPoint::Polar(theta_gp.theta(), phi, theta_gp.mag())); } @@ -307,10 +344,3 @@ double GeometryTranslator::calcDTSpecificBend(const TriggerPrimitive& tp) const double bendf = bend / 512.0; return bendf; } - -bool GeometryTranslator::isCSCCounterClockwise(const std::unique_ptr& layer) const { - const int nStrips = layer->geometry()->numberOfStrips(); - const double phi1 = layer->centerOfStrip(1).phi(); - const double phiN = layer->centerOfStrip(nStrips).phi(); - return ((std::abs(phi1 - phiN) < M_PI && phi1 >= phiN) || (std::abs(phi1 - phiN) >= M_PI && phi1 < phiN)); -} diff --git a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc index 994ea65b39856..44f762944e1b5 100644 --- a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc +++ b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc @@ -1,33 +1,41 @@ #include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h" -// the primitive types we can use -#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h" +// Muon primitive digi types #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h" #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThDigi.h" +#include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHit.h" #include "DataFormats/RPCDigi/interface/RPCDigi.h" #include "DataFormats/L1TMuon/interface/CPPFDigi.h" -#include "DataFormats/GEMDigi/interface/GEMPadDigi.h" -#include "DataFormats/GEMDigi/interface/ME0PadDigi.h" +#include "DataFormats/GEMDigi/interface/GEMPadDigiCluster.h" +#include "DataFormats/GEMDigi/interface/ME0TriggerDigi.h" -// detector ID types +// Muon detector ID types #include "DataFormats/MuonDetId/interface/DTChamberId.h" #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" #include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include + using namespace L1TMuon; namespace { - const char subsystem_names[][4] = {"DT", "CSC", "RPC", "GEM"}; + const char subsystem_names[][4] = {"DT", "CSC", "RPC", "GEM", "ME0"}; } -//constructors from DT data +// _____________________________________________________________________________ +// Constructors from DT data TriggerPrimitive::TriggerPrimitive(const DTChamberId& detid, const L1MuDTChambPhDigi& digi_phi, const int segment_number) : _id(detid), _subsystem(TriggerPrimitive::kDT) { calculateGlobalSector(detid, _globalsector, _subsector); + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; // fill in information from theta trigger _dt.theta_bti_group = -1; _dt.segment_number = segment_number; @@ -43,6 +51,7 @@ TriggerPrimitive::TriggerPrimitive(const DTChamberId& detid, _dt.qualityCode = digi_phi.code(); _dt.Ts2TagCode = digi_phi.Ts2Tag(); _dt.BxCntCode = digi_phi.BxCnt(); + _dt.RpcBit = digi_phi.RpcBit(); } TriggerPrimitive::TriggerPrimitive(const DTChamberId& detid, @@ -50,6 +59,10 @@ TriggerPrimitive::TriggerPrimitive(const DTChamberId& detid, const int theta_bti_group) : _id(detid), _subsystem(TriggerPrimitive::kDT) { calculateGlobalSector(detid, _globalsector, _subsector); + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; // fill in information from theta trigger _dt.theta_bti_group = theta_bti_group; _dt.segment_number = digi_th.position(theta_bti_group); @@ -65,6 +78,7 @@ TriggerPrimitive::TriggerPrimitive(const DTChamberId& detid, _dt.qualityCode = -1; _dt.Ts2TagCode = -1; _dt.BxCntCode = -1; + _dt.RpcBit = -10; } TriggerPrimitive::TriggerPrimitive(const DTChamberId& detid, @@ -73,6 +87,10 @@ TriggerPrimitive::TriggerPrimitive(const DTChamberId& detid, const int theta_bti_group) : _id(detid), _subsystem(TriggerPrimitive::kDT) { calculateGlobalSector(detid, _globalsector, _subsector); + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; // fill in information from theta trigger _dt.theta_bti_group = theta_bti_group; _dt.segment_number = digi_th.position(theta_bti_group); @@ -88,12 +106,18 @@ TriggerPrimitive::TriggerPrimitive(const DTChamberId& detid, _dt.qualityCode = digi_phi.code(); _dt.Ts2TagCode = digi_phi.Ts2Tag(); _dt.BxCntCode = digi_phi.BxCnt(); + _dt.RpcBit = digi_phi.RpcBit(); } -//constructor from CSC data +// _____________________________________________________________________________ +// Constructor from CSC data TriggerPrimitive::TriggerPrimitive(const CSCDetId& detid, const CSCCorrelatedLCTDigi& digi) : _id(detid), _subsystem(TriggerPrimitive::kCSC) { calculateGlobalSector(detid, _globalsector, _subsector); + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; _csc.trknmb = digi.getTrknmb(); _csc.valid = digi.isValid(); _csc.quality = digi.getQuality(); @@ -106,96 +130,129 @@ TriggerPrimitive::TriggerPrimitive(const CSCDetId& detid, const CSCCorrelatedLCT _csc.bx0 = digi.getBX0(); _csc.syncErr = digi.getSyncErr(); _csc.cscID = digi.getCSCID(); + _csc.alct_quality = digi.getALCT().getQuality(); + _csc.clct_quality = digi.getCLCT().getQuality(); // Use ME1/1a --> ring 4 convention - if (detid.station() == 1 && detid.ring() == 1 && digi.getStrip() >= 128) { + const bool is_me11a = (detid.station() == 1 && detid.ring() == 1 && digi.getStrip() >= 128); + if (is_me11a) { _id = CSCDetId(detid.endcap(), detid.station(), 4, detid.chamber(), detid.layer()); _csc.strip = digi.getStrip() - 128; } - - CSCCorrelatedLCTDigi digi_clone = digi; // Necessary to get around const qualifier - CSCALCTDigi alct = digi_clone.getALCT(); - CSCCLCTDigi clct = digi_clone.getCLCT(); - _csc.alct_quality = alct.getQuality(); - _csc.clct_quality = clct.getQuality(); } -// constructor from RPC data +// _____________________________________________________________________________ +// Constructors from RPC data TriggerPrimitive::TriggerPrimitive(const RPCDetId& detid, const RPCDigi& digi) : _id(detid), _subsystem(TriggerPrimitive::kRPC) { calculateGlobalSector(detid, _globalsector, _subsector); + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; _rpc.strip = digi.strip(); _rpc.strip_low = digi.strip(); _rpc.strip_hi = digi.strip(); _rpc.phi_int = 0; _rpc.theta_int = 0; _rpc.emtf_sector = 0; - _rpc.layer = detid.layer(); + _rpc.emtf_link = 0; _rpc.bx = digi.bx(); _rpc.valid = 1; - _rpc.time = digi.time(); + _rpc.x = digi.hasX() ? digi.coordinateX() : -999999.; + _rpc.y = digi.hasY() ? digi.coordinateY() : -999999.; + _rpc.time = digi.hasTime() ? digi.time() : -999999.; + _rpc.isCPPF = false; } -TriggerPrimitive::TriggerPrimitive(const RPCDetId& detid, const unsigned strip, const unsigned layer, const int bx) +TriggerPrimitive::TriggerPrimitive(const RPCDetId& detid, const RPCRecHit& rechit) : _id(detid), _subsystem(TriggerPrimitive::kRPC) { calculateGlobalSector(detid, _globalsector, _subsector); - _rpc.strip = strip; - _rpc.strip_low = strip; - _rpc.strip_hi = strip; + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; + _rpc.strip = rechit.firstClusterStrip() + (rechit.clusterSize() - 1) / 2; + _rpc.strip_low = rechit.firstClusterStrip(); + _rpc.strip_hi = rechit.firstClusterStrip() + rechit.clusterSize() - 1; _rpc.phi_int = 0; _rpc.theta_int = 0; _rpc.emtf_sector = 0; - _rpc.layer = layer; - _rpc.bx = bx; + _rpc.emtf_link = 0; + _rpc.bx = rechit.BunchX(); _rpc.valid = 1; - _rpc.time = -999999.; + _rpc.x = rechit.localPosition().x(); + _rpc.y = rechit.localPosition().y(); + _rpc.time = rechit.time(); + _rpc.isCPPF = false; } -// constructor from CPPF data +// _____________________________________________________________________________ +// Constructor from CPPF data TriggerPrimitive::TriggerPrimitive(const RPCDetId& detid, const l1t::CPPFDigi& digi) : _id(detid), _subsystem(TriggerPrimitive::kRPC) { calculateGlobalSector(detid, _globalsector, _subsector); + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; // In unpacked CPPF digis, the strip number and cluster size are not available, and are set to -99 - _rpc.strip = (digi.first_strip() < 0 ? 0 : digi.first_strip() + (digi.cluster_size() / 2)); + _rpc.strip = (digi.first_strip() < 0 ? 0 : digi.first_strip() + ((digi.cluster_size() - 1) / 2)); _rpc.strip_low = (digi.first_strip() < 0 ? 0 : digi.first_strip()); _rpc.strip_hi = (digi.first_strip() < 0 ? 0 : digi.first_strip() + digi.cluster_size() - 1); _rpc.phi_int = digi.phi_int(); _rpc.theta_int = digi.theta_int(); _rpc.emtf_sector = digi.emtf_sector(); - _rpc.layer = detid.layer(); + _rpc.emtf_link = digi.emtf_link(); _rpc.bx = digi.bx(); _rpc.valid = digi.valid(); + _rpc.x = -999999.; + _rpc.y = -999999.; + _rpc.time = -999999.; _rpc.isCPPF = true; } -// constructor from GEM data -TriggerPrimitive::TriggerPrimitive(const GEMDetId& detid, const GEMPadDigi& digi) +// _____________________________________________________________________________ +// Constructor from GEM data +TriggerPrimitive::TriggerPrimitive(const GEMDetId& detid, const GEMPadDigiCluster& digi) : _id(detid), _subsystem(TriggerPrimitive::kGEM) { calculateGlobalSector(detid, _globalsector, _subsector); - _gem.pad = digi.pad(); - _gem.pad_low = digi.pad(); - _gem.pad_hi = digi.pad(); + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; + _gem.pad = digi.pads().front() + ((digi.pads().size() - 1) / 2); + _gem.pad_low = digi.pads().front(); + _gem.pad_hi = digi.pads().front() + digi.pads().size() - 1; _gem.bx = digi.bx(); - _gem.bend = 0; - _gem.isME0 = false; } -TriggerPrimitive::TriggerPrimitive(const ME0DetId& detid, const ME0PadDigi& digi) - : _id(detid), _subsystem(TriggerPrimitive::kGEM) { +// _____________________________________________________________________________ +// Constructor from ME0 data +TriggerPrimitive::TriggerPrimitive(const ME0DetId& detid, const ME0TriggerDigi& digi) + : _id(detid), _subsystem(TriggerPrimitive::kME0) { calculateGlobalSector(detid, _globalsector, _subsector); - _gem.pad = digi.pad(); - _gem.pad_low = digi.pad(); - _gem.pad_hi = digi.pad(); - _gem.bx = digi.bx(); - _gem.bend = 0; - _gem.isME0 = true; + _eta = 0.; + _phi = 0.; + _rho = 0.; + _theta = 0.; + _me0.chamberid = digi.getChamberid(); + _me0.quality = digi.getQuality(); + _me0.phiposition = digi.getPhiposition(); + _me0.partition = digi.getPartition(); + _me0.deltaphi = digi.getDeltaphi(); + _me0.bend = digi.getBend(); + _me0.bx = digi.getBX(); } +// _____________________________________________________________________________ +// Copy constructor TriggerPrimitive::TriggerPrimitive(const TriggerPrimitive& tp) : _dt(tp._dt), _csc(tp._csc), _rpc(tp._rpc), _gem(tp._gem), + _me0(tp._me0), _id(tp._id), _subsystem(tp._subsystem), _globalsector(tp._globalsector), @@ -210,6 +267,7 @@ TriggerPrimitive& TriggerPrimitive::operator=(const TriggerPrimitive& tp) { this->_csc = tp._csc; this->_rpc = tp._rpc; this->_gem = tp._gem; + this->_me0 = tp._me0; this->_id = tp._id; this->_subsystem = tp._subsystem; this->_globalsector = tp._globalsector; @@ -222,30 +280,63 @@ TriggerPrimitive& TriggerPrimitive::operator=(const TriggerPrimitive& tp) { } bool TriggerPrimitive::operator==(const TriggerPrimitive& tp) const { - return (this->_dt.bx == tp._dt.bx && this->_dt.wheel == tp._dt.wheel && this->_dt.sector == tp._dt.sector && - this->_dt.station == tp._dt.station && this->_dt.radialAngle == tp._dt.radialAngle && - this->_dt.bendingAngle == tp._dt.bendingAngle && this->_dt.qualityCode == tp._dt.qualityCode && - this->_dt.Ts2TagCode == tp._dt.Ts2TagCode && this->_dt.BxCntCode == tp._dt.BxCntCode && - this->_dt.theta_bti_group == tp._dt.theta_bti_group && this->_dt.segment_number == tp._dt.segment_number && - this->_dt.theta_code == tp._dt.theta_code && this->_dt.theta_quality == tp._dt.theta_quality && - this->_csc.trknmb == tp._csc.trknmb && this->_csc.valid == tp._csc.valid && - this->_csc.quality == tp._csc.quality && this->_csc.keywire == tp._csc.keywire && - this->_csc.strip == tp._csc.strip && this->_csc.pattern == tp._csc.pattern && - this->_csc.bend == tp._csc.bend && this->_csc.bx == tp._csc.bx && this->_csc.mpclink == tp._csc.mpclink && - this->_csc.bx0 == tp._csc.bx0 && this->_csc.syncErr == tp._csc.syncErr && this->_csc.cscID == tp._csc.cscID && - this->_rpc.strip == tp._rpc.strip && this->_rpc.strip_low == tp._rpc.strip_low && - this->_rpc.strip_hi == tp._rpc.strip_hi && this->_rpc.phi_int == tp._rpc.phi_int && - this->_rpc.theta_int == tp._rpc.theta_int && this->_rpc.emtf_sector == tp._rpc.emtf_sector && - this->_rpc.layer == tp._rpc.layer && this->_rpc.bx == tp._rpc.bx && this->_rpc.valid == tp._rpc.valid && - //this->_rpc.time == tp._rpc.time && - this->_rpc.isCPPF == tp._rpc.isCPPF && this->_gem.pad == tp._gem.pad && - this->_gem.pad_low == tp._gem.pad_low && this->_gem.pad_hi == tp._gem.pad_hi && this->_gem.bx == tp._gem.bx && - this->_gem.bend == tp._gem.bend && this->_gem.isME0 == tp._gem.isME0 && this->_id == tp._id && - this->_subsystem == tp._subsystem && this->_globalsector == tp._globalsector && - this->_subsector == tp._subsector); + // Copied from Numpy + // https://github.com/numpy/numpy/blob/v1.14.0/numpy/core/numeric.py#L2260-L2355 + auto isclose = [](float a, float b, float rtol = 1.e-5, float atol = 1.e-8) { + return std::abs(a - b) <= (atol + rtol * std::abs(b)); + }; + + switch (_subsystem) { + case kDT: + return (this->_dt.bx == tp._dt.bx && this->_dt.wheel == tp._dt.wheel && this->_dt.sector == tp._dt.sector && + this->_dt.station == tp._dt.station && this->_dt.radialAngle == tp._dt.radialAngle && + this->_dt.bendingAngle == tp._dt.bendingAngle && this->_dt.qualityCode == tp._dt.qualityCode && + this->_dt.Ts2TagCode == tp._dt.Ts2TagCode && this->_dt.BxCntCode == tp._dt.BxCntCode && + this->_dt.RpcBit == tp._dt.RpcBit && this->_dt.theta_bti_group == tp._dt.theta_bti_group && + this->_dt.segment_number == tp._dt.segment_number && this->_dt.theta_code == tp._dt.theta_code && + this->_dt.theta_quality == tp._dt.theta_quality && this->_id == tp._id && + this->_subsystem == tp._subsystem && this->_globalsector == tp._globalsector && + this->_subsector == tp._subsector); + case kCSC: + return (this->_csc.trknmb == tp._csc.trknmb && this->_csc.valid == tp._csc.valid && + this->_csc.quality == tp._csc.quality && this->_csc.keywire == tp._csc.keywire && + this->_csc.strip == tp._csc.strip && this->_csc.pattern == tp._csc.pattern && + this->_csc.bend == tp._csc.bend && this->_csc.bx == tp._csc.bx && this->_csc.mpclink == tp._csc.mpclink && + this->_csc.bx0 == tp._csc.bx0 && this->_csc.syncErr == tp._csc.syncErr && + this->_csc.cscID == tp._csc.cscID && this->_csc.alct_quality == tp._csc.alct_quality && + this->_csc.clct_quality == tp._csc.clct_quality && this->_id == tp._id && + this->_subsystem == tp._subsystem && this->_globalsector == tp._globalsector && + this->_subsector == tp._subsector); + case kRPC: + return (this->_rpc.strip == tp._rpc.strip && this->_rpc.strip_low == tp._rpc.strip_low && + this->_rpc.strip_hi == tp._rpc.strip_hi && this->_rpc.phi_int == tp._rpc.phi_int && + this->_rpc.theta_int == tp._rpc.theta_int && this->_rpc.emtf_sector == tp._rpc.emtf_sector && + this->_rpc.emtf_link == tp._rpc.emtf_link && this->_rpc.bx == tp._rpc.bx && + this->_rpc.valid == tp._rpc.valid && isclose(this->_rpc.x, tp._rpc.x) && // floating-point + isclose(this->_rpc.y, tp._rpc.y) && // floating-point + isclose(this->_rpc.time, tp._rpc.time) && // floating-point + this->_rpc.isCPPF == tp._rpc.isCPPF && this->_id == tp._id && this->_subsystem == tp._subsystem && + this->_globalsector == tp._globalsector && this->_subsector == tp._subsector); + case kGEM: + return (this->_gem.pad == tp._gem.pad && this->_gem.pad_low == tp._gem.pad_low && + this->_gem.pad_hi == tp._gem.pad_hi && this->_gem.bx == tp._gem.bx && this->_id == tp._id && + this->_subsystem == tp._subsystem && this->_globalsector == tp._globalsector && + this->_subsector == tp._subsector); + case kME0: + return (this->_me0.chamberid == tp._me0.chamberid && this->_me0.quality == tp._me0.quality && + this->_me0.phiposition == tp._me0.phiposition && this->_me0.partition == tp._me0.partition && + this->_me0.deltaphi == tp._me0.deltaphi && this->_me0.bend == tp._me0.bend && + this->_me0.bx == tp._me0.bx && this->_id == tp._id && this->_subsystem == tp._subsystem && + this->_globalsector == tp._globalsector && this->_subsector == tp._subsector); + default: + throw cms::Exception("Invalid Subsystem") + << "The specified subsystem for this track stub is out of range" << std::endl; + } + return false; } -const int TriggerPrimitive::getBX() const { +// _____________________________________________________________________________ +int TriggerPrimitive::getBX() const { switch (_subsystem) { case kDT: return _dt.bx; @@ -255,48 +346,54 @@ const int TriggerPrimitive::getBX() const { return _rpc.bx; case kGEM: return _gem.bx; + case kME0: + return _me0.bx; default: - throw cms::Exception("Invalid Subsytem") + throw cms::Exception("Invalid Subsystem") << "The specified subsystem for this track stub is out of range" << std::endl; } return -1; } -const int TriggerPrimitive::getStrip() const { +int TriggerPrimitive::getStrip() const { switch (_subsystem) { case kDT: - return -1; + return _dt.radialAngle; case kCSC: return _csc.strip; case kRPC: return _rpc.strip; case kGEM: return _gem.pad; + case kME0: + return _me0.phiposition; default: - throw cms::Exception("Invalid Subsytem") + throw cms::Exception("Invalid Subsystem") << "The specified subsystem for this track stub is out of range" << std::endl; } return -1; } -const int TriggerPrimitive::getWire() const { +int TriggerPrimitive::getWire() const { switch (_subsystem) { case kDT: - return -1; + return _dt.theta_bti_group; case kCSC: return _csc.keywire; case kRPC: return -1; case kGEM: return -1; + case kME0: + return -1; default: - throw cms::Exception("Invalid Subsytem") + throw cms::Exception("Invalid Subsystem") << "The specified subsystem for this track stub is out of range" << std::endl; } return -1; } -const int TriggerPrimitive::getPattern() const { +int TriggerPrimitive::getPattern() const { switch (_subsystem) { case kDT: return -1; @@ -306,8 +403,10 @@ const int TriggerPrimitive::getPattern() const { return -1; case kGEM: return -1; + case kME0: + return -1; default: - throw cms::Exception("Invalid Subsytem") + throw cms::Exception("Invalid Subsystem") << "The specified subsystem for this track stub is out of range" << std::endl; } return -1; @@ -326,7 +425,8 @@ void TriggerPrimitive::print(std::ostream& out) const { out << "Packed Bend : " << _dt.bendingAngle << std::endl; out << "Quality Code : " << _dt.qualityCode << std::endl; out << "Ts2Tag Code : " << _dt.Ts2TagCode << std::endl; - out << "BXCnt Code : " << _dt.BxCntCode << std::endl; + out << "BxCnt Code : " << _dt.BxCntCode << std::endl; + out << "RPC Bit : " << _dt.RpcBit << std::endl; out << "Theta BTI Grp : " << _dt.theta_bti_group << std::endl; out << "Theta Code : " << _dt.theta_code << std::endl; out << "Theta Quality : " << _dt.theta_quality << std::endl; @@ -345,35 +445,44 @@ void TriggerPrimitive::print(std::ostream& out) const { out << "BX0 : " << _csc.bx0 << std::endl; out << "Sync Error : " << _csc.syncErr << std::endl; out << "CSCID : " << _csc.cscID << std::endl; + out << "ALCT Quality : " << _csc.alct_quality << std::endl; + out << "CLCT Quality : " << _csc.clct_quality << std::endl; break; case kRPC: out << detId() << std::endl; out << "Local BX : " << _rpc.bx << std::endl; out << "Strip : " << _rpc.strip << std::endl; - out << "Strip Low : " << _rpc.strip_low << std::endl; - out << "Strip High : " << _rpc.strip_hi << std::endl; + out << "Strip low : " << _rpc.strip_low << std::endl; + out << "Strip high : " << _rpc.strip_hi << std::endl; out << "Integer phi : " << _rpc.phi_int << std::endl; out << "Integer theta : " << _rpc.theta_int << std::endl; out << "EMTF sector : " << _rpc.emtf_sector << std::endl; - out << "Layer : " << _rpc.layer << std::endl; + out << "EMTF link : " << _rpc.emtf_link << std::endl; out << "Valid : " << _rpc.valid << std::endl; + out << "Local x : " << _rpc.x << std::endl; + out << "Local y : " << _rpc.y << std::endl; out << "Time : " << _rpc.time << std::endl; out << "IsCPPF : " << _rpc.isCPPF << std::endl; break; case kGEM: - if (!_gem.isME0) - out << detId() << std::endl; - else - out << detId() << std::endl; + out << detId() << std::endl; out << "Local BX : " << _gem.bx << std::endl; out << "Pad : " << _gem.pad << std::endl; - out << "Pad Low : " << _gem.pad_low << std::endl; - out << "Pad High : " << _gem.pad_hi << std::endl; - out << "Packed Bend : " << _gem.bend << std::endl; - out << "Is ME0 : " << _gem.isME0 << std::endl; + out << "Pad low : " << _gem.pad_low << std::endl; + out << "Pad high : " << _gem.pad_hi << std::endl; + break; + case kME0: + out << detId() << std::endl; + out << "Local BX : " << _me0.bx << std::endl; + out << "Chamber id : " << _me0.chamberid << std::endl; + out << "Quality : " << _me0.quality << std::endl; + out << "Phiposition : " << _me0.phiposition << std::endl; + out << "Partition : " << _me0.partition << std::endl; + out << "Deltaphi : " << _me0.deltaphi << std::endl; + out << "Bend : " << _me0.bend << std::endl; break; default: - throw cms::Exception("Invalid Subsytem") + throw cms::Exception("Invalid Subsystem") << "The specified subsystem for this track stub is out of range" << std::endl; } } From 34d18fa2f51a426e112e15069fb4a8d27e30d4c5 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:47:33 -0400 Subject: [PATCH 07/34] [EMTF] Update MuonTriggerPrimitive & GeometryTranslator 4/5 --- .../L1TMuonEndCap/interface/EMTFGEMDetId.h | 43 ------- .../interface/EMTFGEMDetIdImpl.h | 24 ---- .../interface/TTPrimitiveConversion.h | 35 ------ L1Trigger/L1TMuonEndCap/src/EMTFGEMDetId.cc | 69 ----------- .../src/TTPrimitiveConversion.cc | 110 ------------------ 5 files changed, 281 deletions(-) delete mode 100644 L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h delete mode 100644 L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetIdImpl.h delete mode 100644 L1Trigger/L1TMuonEndCap/interface/TTPrimitiveConversion.h delete mode 100644 L1Trigger/L1TMuonEndCap/src/EMTFGEMDetId.cc delete mode 100644 L1Trigger/L1TMuonEndCap/src/TTPrimitiveConversion.cc diff --git a/L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h b/L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h deleted file mode 100644 index 00b82e8f2a57e..0000000000000 --- a/L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef L1TMuonEndCap_EMTFGEMDetId_h -#define L1TMuonEndCap_EMTFGEMDetId_h - -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "DataFormats/MuonDetId/interface/ME0DetId.h" - -#include -#include - -class GEMDetId; -class ME0DetId; - -class EMTFGEMDetId { -public: - explicit EMTFGEMDetId(const GEMDetId& id); - explicit EMTFGEMDetId(const ME0DetId& id); - - /// Sort Operator based on the raw detector id - bool operator<(const EMTFGEMDetId& r) const; - - /// The identifiers - int region() const; - int ring() const; // NOTE: use ME0 --> ring 4 convention - int station() const; // NOTE: use ME0 --> station 1 convention - int layer() const; - int chamber() const; - int roll() const; - - bool isME0() const { return isME0_; } - - GEMDetId getGEMDetId() const { return gemDetId_; } - - ME0DetId getME0DetId() const { return me0DetId_; } - -private: - GEMDetId gemDetId_; - ME0DetId me0DetId_; - bool isME0_; -}; - -std::ostream& operator<<(std::ostream& os, const EMTFGEMDetId& id); - -#endif diff --git a/L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetIdImpl.h b/L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetIdImpl.h deleted file mode 100644 index c00693f92e83c..0000000000000 --- a/L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetIdImpl.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef L1TMuonEndCap_EMTFGEMDetIdImpl_h -#define L1TMuonEndCap_EMTFGEMDetIdImpl_h - -#include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "DataFormats/MuonDetId/interface/ME0DetId.h" -#include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h" -#include "L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h" - -namespace emtf { - - template - EMTFGEMDetId construct_EMTFGEMDetId(const L1TMuon::TriggerPrimitive& tp) { - if (!tp.getGEMData().isME0) { - GEMDetId id(tp.detId()); - return EMTFGEMDetId(id); - } else { - ME0DetId id(tp.detId()); - return EMTFGEMDetId(id); - } - }; - -} // namespace emtf - -#endif diff --git a/L1Trigger/L1TMuonEndCap/interface/TTPrimitiveConversion.h b/L1Trigger/L1TMuonEndCap/interface/TTPrimitiveConversion.h deleted file mode 100644 index 10d3c6238def3..0000000000000 --- a/L1Trigger/L1TMuonEndCap/interface/TTPrimitiveConversion.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef L1TMuonEndCap_TTPrimitiveConversion_h -#define L1TMuonEndCap_TTPrimitiveConversion_h - -#include "L1Trigger/L1TMuonEndCap/interface/Common.h" - -class SectorProcessorLUT; - -class TTPrimitiveConversion { -public: - void configure(const TTGeometryTranslator* tp_ttgeom, - const SectorProcessorLUT* lut, - int verbose, - int endcap, - int sector, - int bx); - - void process(const std::map& selected_ttprim_map, - EMTFHitCollection& conv_hits) const; - - void process_no_prim_sel(const TTTriggerPrimitiveCollection& ttmuon_primitives, EMTFHitCollection& conv_hits) const; - - const SectorProcessorLUT& lut() const { return *lut_; } - - // TT functions - void convert_tt(const TTTriggerPrimitive& ttmuon_primitive, EMTFHit& conv_hit) const; - -private: - const TTGeometryTranslator* tp_ttgeom_; - - const SectorProcessorLUT* lut_; - - int verbose_, endcap_, sector_, bx_; -}; - -#endif diff --git a/L1Trigger/L1TMuonEndCap/src/EMTFGEMDetId.cc b/L1Trigger/L1TMuonEndCap/src/EMTFGEMDetId.cc deleted file mode 100644 index 8432a9c559c34..0000000000000 --- a/L1Trigger/L1TMuonEndCap/src/EMTFGEMDetId.cc +++ /dev/null @@ -1,69 +0,0 @@ -#include "L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h" - -EMTFGEMDetId::EMTFGEMDetId(const GEMDetId& id) : gemDetId_(id), me0DetId_(), isME0_(false) {} - -EMTFGEMDetId::EMTFGEMDetId(const ME0DetId& id) : gemDetId_(), me0DetId_(id), isME0_(true) {} - -/// Sort Operator based on the raw detector id -bool EMTFGEMDetId::operator<(const EMTFGEMDetId& r) const { - if (!isME0() && !r.isME0()) { - return getGEMDetId() < r.getGEMDetId(); // compare GEM with GEM - } else if (r.isME0() && r.isME0()) { - return getME0DetId() < r.getME0DetId(); // compare ME0 with ME0 - } else { - return !r.isME0(); // compare GEM with ME0 - } -} - -/// The identifiers -int EMTFGEMDetId::region() const { - if (!isME0()) - return getGEMDetId().region(); - else - return getME0DetId().region(); -} - -int EMTFGEMDetId::ring() const { - if (!isME0()) - return getGEMDetId().ring(); - else - //return getME0DetId().ring(); - return 4; // NOTE: use ME0 --> ring 4 convention -} - -int EMTFGEMDetId::station() const { - if (!isME0()) - return getGEMDetId().station(); - else - //return getME0DetId().station(); - return 1; // use ME0 --> station 1 convention -} - -int EMTFGEMDetId::layer() const { - if (!isME0()) - return getGEMDetId().layer(); - else - return getME0DetId().layer(); -} - -int EMTFGEMDetId::chamber() const { - if (!isME0()) - return getGEMDetId().chamber(); - else - return getME0DetId().chamber(); -} - -int EMTFGEMDetId::roll() const { - if (!isME0()) - return getGEMDetId().roll(); - else - return getME0DetId().roll(); -} - -std::ostream& operator<<(std::ostream& os, const EMTFGEMDetId& id) { - if (!id.isME0()) - os << id.getGEMDetId(); - else - os << id.getME0DetId(); - return os; -} diff --git a/L1Trigger/L1TMuonEndCap/src/TTPrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/TTPrimitiveConversion.cc deleted file mode 100644 index b3c90d40f0b0e..0000000000000 --- a/L1Trigger/L1TMuonEndCap/src/TTPrimitiveConversion.cc +++ /dev/null @@ -1,110 +0,0 @@ -#include "L1Trigger/L1TMuonEndCap/interface/TTPrimitiveConversion.h" - -#include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" -#include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h" - -void TTPrimitiveConversion::configure( - const TTGeometryTranslator* tp_ttgeom, const SectorProcessorLUT* lut, int verbose, int endcap, int sector, int bx) { - assert(tp_ttgeom != nullptr); - assert(lut != nullptr); - - tp_ttgeom_ = tp_ttgeom; - lut_ = lut; // not used - - verbose_ = verbose; - endcap_ = endcap; // 1 for ME+, 2 for ME- - sector_ = sector; - bx_ = bx; -} - -void TTPrimitiveConversion::process(const std::map& selected_ttprim_map, - EMTFHitCollection& conv_hits) const { - for (const auto& map_tp_it : selected_ttprim_map) { - for (const auto& tp_it : map_tp_it.second) { - EMTFHit conv_hit; - convert_tt(tp_it, conv_hit); - conv_hits.push_back(conv_hit); - } - } -} - -void TTPrimitiveConversion::process_no_prim_sel(const TTTriggerPrimitiveCollection& ttmuon_primitives, - EMTFHitCollection& conv_hits) const { - for (const auto& tp_it : ttmuon_primitives) { - if (endcap_ == 1 && sector_ == 1 && - bx_ == tp_it.getTTData().bx) { //FIXME: stupidly put everything into sector +1, to be fixed. - EMTFHit conv_hit; - convert_tt(tp_it, conv_hit); - conv_hits.push_back(conv_hit); - } - } -} - -// _____________________________________________________________________________ -// TT functions -void TTPrimitiveConversion::convert_tt(const TTTriggerPrimitive& ttmuon_primitive, EMTFHit& conv_hit) const { - //const DetId& tp_detId = ttmuon_primitive.detId(); - const TTData& tp_data = ttmuon_primitive.getTTData(); - - int tp_region = tp_ttgeom_->region(ttmuon_primitive); // 0 for Barrel, +/-1 for +/- Endcap - int tp_endcap = (tp_region == -1) ? 2 : tp_region; - int tp_station = tp_ttgeom_->layer(ttmuon_primitive); - int tp_ring = tp_ttgeom_->ring(ttmuon_primitive); - int tp_chamber = tp_ttgeom_->module(ttmuon_primitive); - int tp_sector = 1; //FIXME - int tp_subsector = 0; //FIXME - - const bool is_neighbor = false; //FIXME - - // Set properties - //conv_hit.SetTTDetId ( tp_detId ); - - conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap); - conv_hit.set_station(tp_station); - conv_hit.set_ring(tp_ring); - //conv_hit.set_roll ( tp_roll ); - conv_hit.set_chamber(tp_chamber); - conv_hit.set_sector(tp_sector); - conv_hit.set_subsector(tp_subsector); - //conv_hit.set_csc_ID ( tp_csc_ID ); - //conv_hit.set_csc_nID ( csc_nID ); - //conv_hit.set_track_num ( tp_data.trknmb ); - //conv_hit.set_sync_err ( tp_data.syncErr ); - - conv_hit.set_bx(tp_data.bx); - conv_hit.set_subsystem(TTTriggerPrimitive::kTT); - - //conv_hit.set_pc_sector ( pc_sector ); - //conv_hit.set_pc_station ( pc_station ); - //conv_hit.set_pc_chamber ( pc_chamber ); - //conv_hit.set_pc_segment ( pc_segment ); - - conv_hit.set_valid(true); - conv_hit.set_strip(static_cast(tp_data.row_f)); - //conv_hit.set_strip_low ( tp_data.strip_low ); - //conv_hit.set_strip_hi ( tp_data.strip_hi ); - conv_hit.set_wire(static_cast(tp_data.col_f)); - //conv_hit.set_quality ( tp_data.quality ); - //conv_hit.set_pattern ( tp_data.pattern ); - conv_hit.set_bend(tp_data.bend); - //conv_hit.set_time ( tp_data.time ); - - conv_hit.set_neighbor(is_neighbor); - conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5); - - // Add coordinates from fullsim - { - const GlobalPoint& gp = tp_ttgeom_->getGlobalPoint(ttmuon_primitive); - double glob_phi = emtf::rad_to_deg(gp.phi().value()); - double glob_theta = emtf::rad_to_deg(gp.theta()); - double glob_eta = gp.eta(); - double glob_rho = gp.perp(); - double glob_z = gp.z(); - - conv_hit.set_phi_sim(glob_phi); - conv_hit.set_theta_sim(glob_theta); - conv_hit.set_eta_sim(glob_eta); - conv_hit.set_rho_sim(glob_rho); - conv_hit.set_z_sim(glob_z); - } -} From 9007f86d11d7dda37f8baecf6b6160d6ef7cea67 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:48:38 -0400 Subject: [PATCH 08/34] [EMTF] Update MuonTriggerPrimitive & GeometryTranslator 5/5 --- L1Trigger/L1TMuonEndCap/interface/Common.h | 9 ----- .../interface/EMTFSubsystemTag.h | 23 +++++-------- .../src/EMTFSubsystemCollector.cc | 34 +++++++++---------- .../L1TMuonEndCap/src/PrimitiveConversion.cc | 6 ++-- .../L1TMuonEndCap/src/PrimitiveSelection.cc | 4 +-- 5 files changed, 28 insertions(+), 48 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/Common.h b/L1Trigger/L1TMuonEndCap/interface/Common.h index 86348546ed600..1e098d5b07853 100644 --- a/L1Trigger/L1TMuonEndCap/interface/Common.h +++ b/L1Trigger/L1TMuonEndCap/interface/Common.h @@ -10,9 +10,6 @@ #include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h" #include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h" -#include "L1Trigger/L1TMuon/interface/TTGeometryTranslator.h" -#include "L1Trigger/L1TMuon/interface/TTMuonTriggerPrimitive.h" - #include "L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -33,14 +30,9 @@ typedef L1TMuon::GeometryTranslator GeometryTranslator; typedef L1TMuon::TriggerPrimitive TriggerPrimitive; typedef L1TMuon::TriggerPrimitiveCollection TriggerPrimitiveCollection; -typedef L1TMuon::TTGeometryTranslator TTGeometryTranslator; -typedef L1TMuon::TTTriggerPrimitive TTTriggerPrimitive; -typedef L1TMuon::TTTriggerPrimitiveCollection TTTriggerPrimitiveCollection; - typedef TriggerPrimitive::CSCData CSCData; typedef TriggerPrimitive::RPCData RPCData; typedef TriggerPrimitive::GEMData GEMData; -typedef TTTriggerPrimitive::TTData TTData; typedef emtf::CSCTag CSCTag; typedef emtf::RPCTag RPCTag; @@ -48,7 +40,6 @@ typedef emtf::CPPFTag CPPFTag; typedef emtf::GEMTag GEMTag; typedef emtf::IRPCTag IRPCTag; typedef emtf::ME0Tag ME0Tag; -typedef emtf::TTTag TTTag; namespace emtf { diff --git a/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h b/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h index 3f0789ca081fd..b952e2e77fd0a 100644 --- a/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h +++ b/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h @@ -6,11 +6,10 @@ #include "DataFormats/RPCDigi/interface/RPCDigi.h" #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" #include "DataFormats/L1TMuon/interface/CPPFDigi.h" -#include "DataFormats/GEMDigi/interface/GEMPadDigi.h" -#include "DataFormats/GEMDigi/interface/GEMPadDigiCollection.h" -#include "DataFormats/GEMDigi/interface/ME0PadDigi.h" -#include "DataFormats/GEMDigi/interface/ME0PadDigiCollection.h" -#include "DataFormats/L1TrackTrigger/interface/TTTypes.h" +#include "DataFormats/GEMDigi/interface/GEMPadDigiCluster.h" +#include "DataFormats/GEMDigi/interface/GEMPadDigiClusterCollection.h" +#include "DataFormats/GEMDigi/interface/ME0TriggerDigi.h" +#include "DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h" namespace emtf { @@ -30,8 +29,8 @@ namespace emtf { }; struct GEMTag { - typedef GEMPadDigi digi_type; - typedef GEMPadDigiCollection digi_collection; + typedef GEMPadDigiCluster digi_type; + typedef GEMPadDigiClusterCollection digi_collection; }; struct IRPCTag { @@ -40,14 +39,8 @@ namespace emtf { }; struct ME0Tag { - typedef ME0PadDigi digi_type; - typedef ME0PadDigiCollection digi_collection; - }; - - struct TTTag { - typedef Ref_Phase2TrackerDigi_ digi_ref; - typedef TTStub digi_type; - typedef edmNew::DetSetVector digi_collection; + typedef ME0TriggerDigi digi_type; + typedef ME0TriggerDigiCollection digi_collection; }; } // namespace emtf diff --git a/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc b/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc index f727ab8e53b4b..c99a31e6e2d66 100644 --- a/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc +++ b/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc @@ -218,23 +218,23 @@ void EMTFSubsystemCollector::make_copad_gem(const TriggerPrimitiveCollection& mu in_pads_layer2[tp_detId.rawId()].push_back(muon_primitive); } - // Modified copad logic - bool modified_copad_logic = false; - if (modified_copad_logic) { - if (tp_detId.layer() == 1) { - auto id = tp_detId; - const GEMDetId co_detId(id.region(), id.ring(), id.station(), 2, id.chamber(), id.roll()); - const GEMPadDigi co_digi(muon_primitive.getGEMData().pad, muon_primitive.getGEMData().bx); - const TriggerPrimitive co_muon_primitive(co_detId, co_digi); - in_pads_layer2[co_detId.rawId()].push_back(co_muon_primitive); - } else { - auto id = tp_detId; - const GEMDetId co_detId(id.region(), id.ring(), id.station(), 1, id.chamber(), id.roll()); - const GEMPadDigi co_digi(muon_primitive.getGEMData().pad, muon_primitive.getGEMData().bx); - const TriggerPrimitive co_muon_primitive(co_detId, co_digi); - in_pads_layer1[co_detId.rawId()].push_back(co_muon_primitive); - } - } + //FIXME: Modified copad logic + //bool modified_copad_logic = false; + //if (modified_copad_logic) { + // if (tp_detId.layer() == 1) { + // auto id = tp_detId; + // const GEMDetId co_detId(id.region(), id.ring(), id.station(), 2, id.chamber(), id.roll()); + // const GEMPadDigi co_digi(muon_primitive.getGEMData().pad, muon_primitive.getGEMData().bx); + // const TriggerPrimitive co_muon_primitive(co_detId, co_digi); + // in_pads_layer2[co_detId.rawId()].push_back(co_muon_primitive); + // } else { + // auto id = tp_detId; + // const GEMDetId co_detId(id.region(), id.ring(), id.station(), 1, id.chamber(), id.roll()); + // const GEMPadDigi co_digi(muon_primitive.getGEMData().pad, muon_primitive.getGEMData().bx); + // const TriggerPrimitive co_muon_primitive(co_detId, co_digi); + // in_pads_layer1[co_detId.rawId()].push_back(co_muon_primitive); + // } + //} } } diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc index d6345a02d76f7..7541d5755c115 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc @@ -4,8 +4,6 @@ #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h" -#include "L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetIdImpl.h" #include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" #include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h" @@ -710,7 +708,7 @@ void PrimitiveConversion::convert_gem(int pc_sector, int pc_segment, const TriggerPrimitive& muon_primitive, EMTFHit& conv_hit) const { - const EMTFGEMDetId& tp_detId = emtf::construct_EMTFGEMDetId(muon_primitive); + const GEMDetId& tp_detId = muon_primitive.detId(); const GEMData& tp_data = muon_primitive.getGEMData(); int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap @@ -821,7 +819,7 @@ void PrimitiveConversion::convert_gem(int pc_sector, //conv_hit.set_wire ( tp_data.keywire ); //conv_hit.set_quality ( tp_data.quality ); conv_hit.set_pattern(1); // In firmware, this marks GEM stub (unconfirmed!) - conv_hit.set_bend(tp_data.bend); + //conv_hit.set_bend(tp_data.bend); //conv_hit.set_time ( tp_data.time ); //conv_hit.set_alct_quality ( tp_data.alct_quality ); //conv_hit.set_clct_quality ( tp_data.clct_quality ); diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc index 896ca4d778cd2..95cecef70ee15 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc @@ -4,8 +4,6 @@ #include "DataFormats/MuonDetId/interface/CSCDetId.h" #include "DataFormats/MuonDetId/interface/RPCDetId.h" #include "DataFormats/MuonDetId/interface/GEMDetId.h" -#include "L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetId.h" -#include "L1Trigger/L1TMuonEndCap/interface/EMTFGEMDetIdImpl.h" #include "helper.h" // merge_map_into_map, assert_no_abort @@ -801,7 +799,7 @@ int PrimitiveSelection::select_gem(const TriggerPrimitive& muon_primitive) const int selected = -1; if (muon_primitive.subsystem() == TriggerPrimitive::kGEM) { - const EMTFGEMDetId& tp_detId = emtf::construct_EMTFGEMDetId(muon_primitive); + const GEMDetId& tp_detId = muon_primitive.detId(); const GEMData& tp_data = muon_primitive.getGEMData(); int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap From af75a8d1fc9d41d8b58235c0760fddce4cffafb7 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:55:58 -0400 Subject: [PATCH 09/34] [EMTF] Update L1TMuonEndCapTrackProducer --- .../plugins/L1TMuonEndCapTrackProducer.cc | 41 +++++++------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapTrackProducer.cc b/L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapTrackProducer.cc index 79efd7ec58655..bf167e3d401a5 100644 --- a/L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapTrackProducer.cc +++ b/L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapTrackProducer.cc @@ -5,7 +5,6 @@ L1TMuonEndCapTrackProducer::L1TMuonEndCapTrackProducer(const edm::ParameterSet& uGMT_converter_(new MicroGMTConverter()), config_(iConfig) { // Make output products - // produces (""); // CPPF Digis emulated by EMTF using RPCDigis from Legacy RPC PAC produces(""); // All CSC LCTs and RPC clusters received by EMTF produces(""); // All output EMTF tracks, in same format as unpacked data produces("EMTF"); // EMTF tracks output to uGMT @@ -15,52 +14,40 @@ L1TMuonEndCapTrackProducer::~L1TMuonEndCapTrackProducer() {} void L1TMuonEndCapTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // Create pointers to output products - // auto out_cppfs = std::make_unique(); - auto out_hits_tmp = std::make_unique(); - auto out_hits_ZS = std::make_unique(); + auto out_hits_tmp = std::make_unique(); // before zero suppression + auto out_hits = std::make_unique(); // after zero suppression auto out_tracks = std::make_unique(); auto out_cands = std::make_unique(); // Main EMTF emulator process, produces tracks from hits in each sector in each event track_finder_->process(iEvent, iSetup, *out_hits_tmp, *out_tracks); - // Apply ZeroSuppression: Only save RPC hits if there is at least one CSC LCT in the sector - bool has_LCT[12] = {false}; - for (int iSect = 0; iSect < 12; iSect++) { - for (const auto& h : *out_hits_tmp) { - if (h.Is_CSC() && h.Sector_idx() == iSect) { - has_LCT[iSect] = true; - break; - } + // Apply zero suppression: only sectors with at least one CSC LCT are read out + // In Run 2, it means RPC hits are only saved if there is at least one CSC LCT in the sector + emtf::sector_array good_sectors; + good_sectors.fill(false); + + for (const auto& h : *out_hits_tmp) { + if (h.Is_CSC()) { + good_sectors.at(h.Sector_idx()) = true; } } + for (const auto& h : *out_hits_tmp) { - if (has_LCT[h.Sector_idx()] || h.Is_RPC() == 0) { - out_hits_ZS->push_back(h); + if (good_sectors.at(h.Sector_idx())) { + out_hits->push_back(h); } } - // // Fill collection of emulated CPPFDigis - // for (const auto& h : *out_hits_ZS) { - // if (h.Is_RPC()) out_cppfs->push_back( h.CreateCPPFDigi() ); - // } - // Convert into uGMT format uGMT_converter_->convert_all(iEvent, *out_tracks, *out_cands); // Fill the output products - // iEvent.put(std::move(out_cppfs), ""); - iEvent.put(std::move(out_hits_ZS), ""); + iEvent.put(std::move(out_hits), ""); iEvent.put(std::move(out_tracks), ""); iEvent.put(std::move(out_cands), "EMTF"); } -// void L1TMuonEndCapTrackProducer::beginJob() { -// } - -// void L1TMuonEndCapTrackProducer::endJob() { -// } - // Fill 'descriptions' with the allowed parameters void L1TMuonEndCapTrackProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { // The following says we do not know what parameters are allowed so do no validation From dc64d7e559c4508ba7c3dd536f2069b1d328114f Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:57:13 -0400 Subject: [PATCH 10/34] [EMTF] Update EMTFSubsystemTag & EMTFSubsystemCollector 1/2 --- L1Trigger/L1TMuonEndCap/interface/Common.h | 18 +- .../interface/EMTFSubsystemCollector.h | 14 +- .../interface/EMTFSubsystemTag.h | 31 +- .../src/EMTFSubsystemCollector.cc | 483 ++++++++++++------ 4 files changed, 377 insertions(+), 169 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/Common.h b/L1Trigger/L1TMuonEndCap/interface/Common.h index 1e098d5b07853..de1b388e825b8 100644 --- a/L1Trigger/L1TMuonEndCap/interface/Common.h +++ b/L1Trigger/L1TMuonEndCap/interface/Common.h @@ -1,7 +1,10 @@ #ifndef L1TMuonEndCap_Common_h #define L1TMuonEndCap_Common_h -#include "DataFormats/L1TMuon/interface/CPPFDigi.h" +#include + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + #include "DataFormats/L1TMuon/interface/EMTFHit.h" #include "DataFormats/L1TMuon/interface/EMTFRoad.h" #include "DataFormats/L1TMuon/interface/EMTFTrack.h" @@ -12,10 +15,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -#include - // Resolve namespaces typedef l1t::EMTFHit EMTFHit; @@ -30,16 +29,11 @@ typedef L1TMuon::GeometryTranslator GeometryTranslator; typedef L1TMuon::TriggerPrimitive TriggerPrimitive; typedef L1TMuon::TriggerPrimitiveCollection TriggerPrimitiveCollection; +typedef TriggerPrimitive::DTData DTData; typedef TriggerPrimitive::CSCData CSCData; typedef TriggerPrimitive::RPCData RPCData; typedef TriggerPrimitive::GEMData GEMData; - -typedef emtf::CSCTag CSCTag; -typedef emtf::RPCTag RPCTag; -typedef emtf::CPPFTag CPPFTag; -typedef emtf::GEMTag GEMTag; -typedef emtf::IRPCTag IRPCTag; -typedef emtf::ME0Tag ME0Tag; +typedef TriggerPrimitive::ME0Data ME0Data; namespace emtf { diff --git a/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemCollector.h b/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemCollector.h index 1c2b8b1ce188e..5a67a9b3fc9e5 100644 --- a/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemCollector.h +++ b/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemCollector.h @@ -12,12 +12,23 @@ namespace edm { // Class declaration class EMTFSubsystemCollector { public: + // For 1 input collection template void extractPrimitives(T tag, + const GeometryTranslator* tp_geom, const edm::Event& iEvent, const edm::EDGetToken& token, TriggerPrimitiveCollection& out) const; + // For 2 input collections + template + void extractPrimitives(T tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token1, + const edm::EDGetToken& token2, + TriggerPrimitiveCollection& out) const; + // RPC functions void cluster_rpc(const TriggerPrimitiveCollection& muon_primitives, TriggerPrimitiveCollection& clus_muon_primitives) const; @@ -25,9 +36,6 @@ class EMTFSubsystemCollector { // GEM functions void make_copad_gem(const TriggerPrimitiveCollection& muon_primitives, TriggerPrimitiveCollection& copad_muon_primitives) const; - - void cluster_gem(const TriggerPrimitiveCollection& muon_primitives, - TriggerPrimitiveCollection& clus_muon_primitives) const; }; #endif diff --git a/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h b/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h index b952e2e77fd0a..b8567ff0d2634 100644 --- a/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h +++ b/L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h @@ -1,10 +1,18 @@ #ifndef L1TMuonEndCap_EMTFSubsystemTag_h #define L1TMuonEndCap_EMTFSubsystemTag_h +#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h" +#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h" +#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThDigi.h" +#include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h" +#include "DataFormats/CSCDigi/interface/CSCComparatorDigi.h" +#include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h" #include "DataFormats/RPCDigi/interface/RPCDigi.h" #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHit.h" +#include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" #include "DataFormats/L1TMuon/interface/CPPFDigi.h" #include "DataFormats/GEMDigi/interface/GEMPadDigiCluster.h" #include "DataFormats/GEMDigi/interface/GEMPadDigiClusterCollection.h" @@ -13,14 +21,32 @@ namespace emtf { + struct DTTag { + typedef L1MuDTChambPhDigi digi_type; + typedef L1MuDTChambPhContainer digi_collection; + typedef L1MuDTChambThDigi theta_digi_type; + typedef L1MuDTChambThContainer theta_digi_collection; + }; + struct CSCTag { typedef CSCCorrelatedLCTDigi digi_type; typedef CSCCorrelatedLCTDigiCollection digi_collection; + typedef CSCComparatorDigi comparator_digi_type; + typedef CSCComparatorDigiCollection comparator_digi_collection; }; struct RPCTag { typedef RPCDigi digi_type; typedef RPCDigiCollection digi_collection; + typedef RPCRecHit rechit_type; + typedef RPCRecHitCollection rechit_collection; + }; + + struct IRPCTag { + typedef RPCDigi digi_type; + typedef RPCDigiCollection digi_collection; + typedef RPCRecHit rechit_type; + typedef RPCRecHitCollection rechit_collection; }; struct CPPFTag { @@ -33,11 +59,6 @@ namespace emtf { typedef GEMPadDigiClusterCollection digi_collection; }; - struct IRPCTag { - typedef RPCDigi digi_type; - typedef RPCDigiCollection digi_collection; - }; - struct ME0Tag { typedef ME0TriggerDigi digi_type; typedef ME0TriggerDigiCollection digi_collection; diff --git a/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc b/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc index c99a31e6e2d66..49d5b4ed711a6 100644 --- a/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc +++ b/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc @@ -3,16 +3,120 @@ #include "FWCore/Framework/interface/Event.h" #include "DataFormats/Common/interface/Handle.h" +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" // needed to handle RPCRecHit + #include "helper.h" // adjacent_cluster +// _____________________________________________________________________________ +// Specialized for DT +template <> +void EMTFSubsystemCollector::extractPrimitives(emtf::DTTag tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token1, + const edm::EDGetToken& token2, + TriggerPrimitiveCollection& out) const { + edm::Handle phiContainer; + iEvent.getByToken(token1, phiContainer); + + edm::Handle thetaContainer; + iEvent.getByToken(token2, thetaContainer); + + TriggerPrimitiveCollection muon_primitives; + + // Adapted from L1Trigger/L1TMuonBarrel/src/L1TMuonBarrelKalmanStubProcessor.cc + constexpr int minPhiQuality = 0; + constexpr int minBX = -3; + constexpr int maxBX = 3; + + for (int bx = minBX; bx <= maxBX; bx++) { + for (int wheel = -2; wheel <= 2; wheel++) { + for (int sector = 0; sector < 12; sector++) { + for (int station = 1; station < 5; station++) { + if (wheel == -1 || wheel == 0 || wheel == 1) + continue; // do not include wheels -1, 0, +1 + if (station == 4) + continue; // do not include MB4 + + // According to Michalis, in legacy BMTF, the second stub was coming as BXNUM=-1. + // This is a code convention now, but you need bx-1 to get the proper second stub. + emtf::DTTag::theta_digi_type const* theta_segm = thetaContainer->chThetaSegm(wheel, station, sector, bx); + emtf::DTTag::digi_type const* phi_segm_high = phiContainer->chPhiSegm1(wheel, station, sector, bx); + emtf::DTTag::digi_type const* phi_segm_low = phiContainer->chPhiSegm2(wheel, station, sector, bx - 1); + + // Find theta BTI group(s) + bool has_theta_segm = false; + int bti_group1 = -1; + int bti_group2 = -1; + + // Case with theta segment + if (theta_segm != nullptr) { + has_theta_segm = true; + + for (unsigned int i = 0; i < 7; ++i) { + if (theta_segm->position(i) != 0) { + if (bti_group1 < 0) { + bti_group1 = i; + bti_group2 = i; + } else { + bti_group2 = i; + } + } + } + assert(bti_group1 != -1 && bti_group2 != -1); + } + + // 1st phi segment + if (phi_segm_high != nullptr) { + if (phi_segm_high->code() >= minPhiQuality) { + DTChamberId detid(phi_segm_high->whNum(), phi_segm_high->stNum(), phi_segm_high->scNum() + 1); + if (has_theta_segm) { + muon_primitives.emplace_back(detid, *phi_segm_high, *theta_segm, bti_group1); + } else { + muon_primitives.emplace_back(detid, *phi_segm_high, 1); + } + } + } + + // 2nd phi segment + if (phi_segm_low != nullptr) { + if (phi_segm_low->code() >= minPhiQuality) { + DTChamberId detid(phi_segm_low->whNum(), phi_segm_low->stNum(), phi_segm_low->scNum() + 1); + if (has_theta_segm) { + muon_primitives.emplace_back(detid, *phi_segm_low, *theta_segm, bti_group2); + } else { + muon_primitives.emplace_back(detid, *phi_segm_low, 2); + } + } + } + + // Duplicate DT muon primitives, if more than one theta segment, but only one phi segment + if (phi_segm_high != nullptr && phi_segm_low == nullptr && bti_group1 != bti_group2) { + DTChamberId detid(phi_segm_high->whNum(), phi_segm_high->stNum(), phi_segm_high->scNum() + 1); + muon_primitives.emplace_back(detid, *phi_segm_high, *theta_segm, bti_group2); + } + + } // end loop over station + } // end loop over sector + } // end loop over wheel + } // end loop over bx + + // Remove duplicates using erase-remove idiom, + // assuming the vector is already sorted + muon_primitives.erase(std::unique(muon_primitives.begin(), muon_primitives.end()), muon_primitives.end()); + std::copy(muon_primitives.begin(), muon_primitives.end(), std::back_inserter(out)); + return; +} + +// _____________________________________________________________________________ // Specialized for CSC template <> -void EMTFSubsystemCollector::extractPrimitives( - CSCTag tag, // Defined in interface/EMTFSubsystemTag.h, maps to CSCCorrelatedLCTDigi - const edm::Event& iEvent, - const edm::EDGetToken& token, - TriggerPrimitiveCollection& out) const { - edm::Handle cscDigis; +void EMTFSubsystemCollector::extractPrimitives(emtf::CSCTag tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token, + TriggerPrimitiveCollection& out) const { + edm::Handle cscDigis; iEvent.getByToken(token, cscDigis); auto chamber = cscDigis->begin(); @@ -21,20 +125,21 @@ void EMTFSubsystemCollector::extractPrimitives( auto digi = (*chamber).second.first; auto dend = (*chamber).second.second; for (; digi != dend; ++digi) { - // emplace_back does the same thing as push_back: appends to the end of the vector out.emplace_back((*chamber).first, *digi); } } return; } +// _____________________________________________________________________________ // Specialized for RPC template <> -void EMTFSubsystemCollector::extractPrimitives(RPCTag tag, // Defined in interface/EMTFSubsystemTag.h, maps to RPCDigi +void EMTFSubsystemCollector::extractPrimitives(emtf::RPCTag tag, + const GeometryTranslator* tp_geom, const edm::Event& iEvent, const edm::EDGetToken& token, TriggerPrimitiveCollection& out) const { - edm::Handle rpcDigis; + edm::Handle rpcDigis; iEvent.getByToken(token, rpcDigis); TriggerPrimitiveCollection muon_primitives; @@ -49,7 +154,7 @@ void EMTFSubsystemCollector::extractPrimitives(RPCTag tag, // Defined in interf if ((*chamber).first.station() <= 2 && (*chamber).first.ring() == 3) continue; // do not include RE1/3, RE2/3 if ((*chamber).first.station() >= 3 && (*chamber).first.ring() == 1) - continue; // do not include RE3/1, RE4/1 + continue; // do not include RE3/1, RE4/1 (iRPC) muon_primitives.emplace_back((*chamber).first, *digi); } @@ -65,32 +170,143 @@ void EMTFSubsystemCollector::extractPrimitives(RPCTag tag, // Defined in interf return; } +// Specialized for RPC (using RecHits) +template <> +void EMTFSubsystemCollector::extractPrimitives(emtf::RPCTag tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token1, + const edm::EDGetToken& token2, + TriggerPrimitiveCollection& out) const { + constexpr int maxClusterSize = 3; + + //edm::Handle rpcDigis; + //iEvent.getByToken(token1, rpcDigis); + + edm::Handle rpcRecHits; + iEvent.getByToken(token2, rpcRecHits); + + auto rechit = rpcRecHits->begin(); + auto rhend = rpcRecHits->end(); + for (; rechit != rhend; ++rechit) { + const RPCDetId& detid = rechit->rpcId(); + const RPCRoll* roll = dynamic_cast(tp_geom->getRPCGeometry().roll(detid)); + if (roll == nullptr) + continue; + + if (detid.region() != 0) { // 0 is barrel + if (detid.station() <= 2 && detid.ring() == 3) + continue; // do not include RE1/3, RE2/3 + if (detid.station() >= 3 && detid.ring() == 1) + continue; // do not include RE3/1, RE4/1 (iRPC) + + if (rechit->clusterSize() <= maxClusterSize) { + out.emplace_back(detid, *rechit); + } + } + } + return; +} + +// _____________________________________________________________________________ +// Specialized for iRPC +template <> +void EMTFSubsystemCollector::extractPrimitives(emtf::IRPCTag tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token, + TriggerPrimitiveCollection& out) const { + edm::Handle irpcDigis; + iEvent.getByToken(token, irpcDigis); + + TriggerPrimitiveCollection muon_primitives; + + auto chamber = irpcDigis->begin(); + auto chend = irpcDigis->end(); + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; + for (; digi != dend; ++digi) { + if ((*chamber).first.region() != 0) { // 0 is barrel + if (!((*chamber).first.station() >= 3 && (*chamber).first.ring() == 1)) + continue; // only RE3/1, RE4/1 (iRPC) + + muon_primitives.emplace_back((*chamber).first, *digi); + } + } + } + + // Cluster the iRPC digis + TriggerPrimitiveCollection clus_muon_primitives; + cluster_rpc(muon_primitives, clus_muon_primitives); + + // Output + std::copy(clus_muon_primitives.begin(), clus_muon_primitives.end(), std::back_inserter(out)); + return; +} + +// Specialized for iRPC (using RecHits) +template <> +void EMTFSubsystemCollector::extractPrimitives(emtf::IRPCTag tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token1, + const edm::EDGetToken& token2, + TriggerPrimitiveCollection& out) const { + constexpr int maxClusterSize = 6; + + //edm::Handle irpcDigis; + //iEvent.getByToken(token1, irpcDigis); + + edm::Handle irpcRecHits; + iEvent.getByToken(token2, irpcRecHits); + + auto rechit = irpcRecHits->begin(); + auto rhend = irpcRecHits->end(); + for (; rechit != rhend; ++rechit) { + const RPCDetId& detid = rechit->rpcId(); + const RPCRoll* roll = dynamic_cast(tp_geom->getRPCGeometry().roll(detid)); + if (roll == nullptr) + continue; + + if (detid.region() != 0) { // 0 is barrel + if (!(detid.station() >= 3 && detid.ring() == 1)) + continue; // only RE3/1, RE4/1 (iRPC) + + if (rechit->clusterSize() <= maxClusterSize) { + out.emplace_back(detid, *rechit); + } + } + } + return; +} + +// _____________________________________________________________________________ // Specialized for CPPF template <> -void EMTFSubsystemCollector::extractPrimitives( - emtf::CPPFTag tag, // Defined in interface/EMTFSubsystemTag.h, maps to CPPFDigi - const edm::Event& iEvent, - const edm::EDGetToken& token, - TriggerPrimitiveCollection& out) const { +void EMTFSubsystemCollector::extractPrimitives(emtf::CPPFTag tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token, + TriggerPrimitiveCollection& out) const { edm::Handle cppfDigis; iEvent.getByToken(token, cppfDigis); - // Output - for (auto digi : *cppfDigis) { + for (const auto& digi : *cppfDigis) { out.emplace_back(digi.rpcId(), digi); } - return; } +// _____________________________________________________________________________ // Specialized for GEM template <> -void EMTFSubsystemCollector::extractPrimitives( - GEMTag tag, // Defined in interface/EMTFSubsystemTag.h, maps to GEMPadDigi - const edm::Event& iEvent, - const edm::EDGetToken& token, - TriggerPrimitiveCollection& out) const { - edm::Handle gemDigis; +void EMTFSubsystemCollector::extractPrimitives(emtf::GEMTag tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token, + TriggerPrimitiveCollection& out) const { + edm::Handle gemDigis; iEvent.getByToken(token, gemDigis); TriggerPrimitiveCollection muon_primitives; @@ -105,15 +321,35 @@ void EMTFSubsystemCollector::extractPrimitives( } } - // Cluster the GEM digis. + // Make GEM coincidence pads TriggerPrimitiveCollection copad_muon_primitives; make_copad_gem(muon_primitives, copad_muon_primitives); - TriggerPrimitiveCollection clus_muon_primitives; - cluster_gem(copad_muon_primitives, clus_muon_primitives); - // Output - std::copy(clus_muon_primitives.begin(), clus_muon_primitives.end(), std::back_inserter(out)); + std::copy(copad_muon_primitives.begin(), copad_muon_primitives.end(), std::back_inserter(out)); + return; +} + +// _____________________________________________________________________________ +// Specialized for ME0 +template <> +void EMTFSubsystemCollector::extractPrimitives(emtf::ME0Tag tag, + const GeometryTranslator* tp_geom, + const edm::Event& iEvent, + const edm::EDGetToken& token, + TriggerPrimitiveCollection& out) const { + edm::Handle me0Digis; + iEvent.getByToken(token, me0Digis); + + auto chamber = me0Digis->begin(); + auto chend = me0Digis->end(); + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; + for (; digi != dend; ++digi) { + out.emplace_back((*chamber).first, *digi); + } + } return; } @@ -172,6 +408,7 @@ void EMTFSubsystemCollector::cluster_rpc(const TriggerPrimitiveCollection& muon_ // Do clustering using C++ functions // 1. Select RPC digis + clus_muon_primitives.clear(); std::copy_if( muon_primitives.begin(), muon_primitives.end(), std::back_inserter(clus_muon_primitives), rpc_digi_select); @@ -194,153 +431,101 @@ void EMTFSubsystemCollector::make_copad_gem(const TriggerPrimitiveCollection& mu TriggerPrimitiveCollection& copad_muon_primitives) const { // Use the inner layer (layer 1) hit coordinates as output, and the outer // layer (layer 2) as coincidence - // Copied from: L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc - const unsigned int maxDeltaBX = 1; - const unsigned int maxDeltaPadGE11 = 2; - const unsigned int maxDeltaPadGE21 = 2; + // Adapted from L1Trigger/CSCTriggerPrimitives/src/GEMCoPadProcessor.cc + constexpr unsigned int maxDeltaBX = 1; + constexpr unsigned int maxDeltaRoll = 1; + constexpr unsigned int maxDeltaPadGE11 = 3; // it was 2 + constexpr unsigned int maxDeltaPadGE21 = 2; - std::map in_pads_layer1, in_pads_layer2; + // Make sure that the difference is calculated using signed integer, and + // output the absolute difference (as unsigned integer) + auto calculate_delta = [](int a, int b) -> unsigned int { return std::abs(a - b); }; - TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin(); - TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end(); + // Create maps of GEM pads (key = detid), split by layer + std::map in_pads_layer1, in_pads_layer2; - for (; tp_it != tp_end; ++tp_it) { - const TriggerPrimitive& muon_primitive = *tp_it; - - // Split by layer - if (muon_primitive.subsystem() == TriggerPrimitive::kGEM) { - const GEMDetId& tp_detId = muon_primitive.detId(); - assert(tp_detId.layer() == 1 || tp_detId.layer() == 2); - if (tp_detId.layer() == 1) { - in_pads_layer1[tp_detId.rawId()].push_back(muon_primitive); - } else { - in_pads_layer2[tp_detId.rawId()].push_back(muon_primitive); - } + auto tp_it = muon_primitives.begin(); + auto tp_end = muon_primitives.end(); - //FIXME: Modified copad logic - //bool modified_copad_logic = false; - //if (modified_copad_logic) { - // if (tp_detId.layer() == 1) { - // auto id = tp_detId; - // const GEMDetId co_detId(id.region(), id.ring(), id.station(), 2, id.chamber(), id.roll()); - // const GEMPadDigi co_digi(muon_primitive.getGEMData().pad, muon_primitive.getGEMData().bx); - // const TriggerPrimitive co_muon_primitive(co_detId, co_digi); - // in_pads_layer2[co_detId.rawId()].push_back(co_muon_primitive); - // } else { - // auto id = tp_detId; - // const GEMDetId co_detId(id.region(), id.ring(), id.station(), 1, id.chamber(), id.roll()); - // const GEMPadDigi co_digi(muon_primitive.getGEMData().pad, muon_primitive.getGEMData().bx); - // const TriggerPrimitive co_muon_primitive(co_detId, co_digi); - // in_pads_layer1[co_detId.rawId()].push_back(co_muon_primitive); - // } - //} + for (; tp_it != tp_end; ++tp_it) { + GEMDetId detid = tp_it->detId(); + assert(detid.layer() == 1 || detid.layer() == 2); + assert(1 <= detid.roll() && detid.roll() <= 8); + uint32_t layer = detid.layer(); + + // Remove layer number and roll number from detid + detid = GEMDetId(detid.region(), detid.ring(), detid.station(), 0, detid.chamber(), 0); + + if (layer == 1) { + in_pads_layer1[detid.rawId()].push_back(*tp_it); + } else { + in_pads_layer2[detid.rawId()].push_back(*tp_it); } } - std::map::iterator map_tp_it = in_pads_layer1.begin(); - std::map::iterator map_tp_end = in_pads_layer1.end(); + // Build coincidences + copad_muon_primitives.clear(); + + auto map_tp_it = in_pads_layer1.begin(); + auto map_tp_end = in_pads_layer1.end(); for (; map_tp_it != map_tp_end; ++map_tp_it) { - const GEMDetId& id = map_tp_it->first; + const GEMDetId& detid = map_tp_it->first; const TriggerPrimitiveCollection& pads = map_tp_it->second; - assert(id.layer() == 1); - // find the corresponding id with layer=2 and same roll number - const GEMDetId co_id(id.region(), id.ring(), id.station(), 2, id.chamber(), id.roll()); + // find all corresponding ids with layer 2 + auto found = in_pads_layer2.find(detid); // empty range = no possible coincidence pads - auto found = in_pads_layer2.find(co_id); if (found == in_pads_layer2.end()) continue; // now let's correlate the pads in two layers of this partition const TriggerPrimitiveCollection& co_pads = found->second; - for (TriggerPrimitiveCollection::const_iterator p = pads.begin(); p != pads.end(); ++p) { - for (TriggerPrimitiveCollection::const_iterator co_p = co_pads.begin(); co_p != co_pads.end(); ++co_p) { - unsigned int deltaPad = std::abs(p->getGEMData().pad - co_p->getGEMData().pad); - unsigned int deltaBX = std::abs(p->getGEMData().bx - co_p->getGEMData().bx); + for (auto p = pads.begin(); p != pads.end(); ++p) { + bool has_copad = false; + int bend = 999999; + + for (auto co_p = co_pads.begin(); co_p != co_pads.end(); ++co_p) { + unsigned int deltaPad = calculate_delta(p->getGEMData().pad, co_p->getGEMData().pad); + unsigned int deltaBX = calculate_delta(p->getGEMData().bx, co_p->getGEMData().bx); + unsigned int deltaRoll = calculate_delta(p->detId().roll(), co_p->detId().roll()); // check the match in pad - if ((id.station() == 1 && deltaPad > maxDeltaPadGE11) || (id.station() == 2 && deltaPad > maxDeltaPadGE21)) + if ((detid.station() == 1 && deltaPad > maxDeltaPadGE11) || + (detid.station() == 2 && deltaPad > maxDeltaPadGE21)) continue; // check the match in BX if (deltaBX > maxDeltaBX) continue; - // make a new coincidence pad digi - copad_muon_primitives.push_back(*p); - } - } - } -} - -void EMTFSubsystemCollector::cluster_gem(const TriggerPrimitiveCollection& muon_primitives, - TriggerPrimitiveCollection& clus_muon_primitives) const { - // Define operator to select GEM digis - struct { - typedef TriggerPrimitive value_type; - bool operator()(const value_type& x) const { return (x.subsystem() == TriggerPrimitive::kGEM); } - } gem_digi_select; - - // Define operator to sort the GEM digis prior to clustering. - // Use rawId, bx and pad as the sorting id. GEM rawId fully specifies - // endcap, station, ring, layer, roll, chamber. Pad is used as - // the least significant sorting id. - struct { - typedef TriggerPrimitive value_type; - bool operator()(const value_type& lhs, const value_type& rhs) const { - bool cmp = (std::make_pair(std::make_pair(lhs.rawId(), lhs.getGEMData().bx), lhs.getGEMData().pad) < - std::make_pair(std::make_pair(rhs.rawId(), rhs.getGEMData().bx), rhs.getGEMData().pad)); - return cmp; - } - } gem_digi_less; - - struct { - typedef TriggerPrimitive value_type; - bool operator()(const value_type& lhs, const value_type& rhs) const { - bool cmp = (std::make_pair(std::make_pair(lhs.rawId(), lhs.getGEMData().bx), lhs.getGEMData().pad) == - std::make_pair(std::make_pair(rhs.rawId(), rhs.getGEMData().bx), rhs.getGEMData().pad)); - return cmp; - } - } gem_digi_equal; - - // Define operators for the nearest-neighbor clustering algorithm. - // If two digis are next to each other (check pad_hi on the 'left', and - // pad_low on the 'right'), cluster them (increment pad_hi on the 'left') - struct { - typedef TriggerPrimitive value_type; - bool operator()(const value_type& lhs, const value_type& rhs) const { - bool cmp = ((lhs.rawId() == rhs.rawId()) && (lhs.getGEMData().bx == rhs.getGEMData().bx) && - (lhs.getGEMData().pad_hi + 1 == rhs.getGEMData().pad_low)); - return cmp; - } - } gem_digi_adjacent; - - struct { - typedef TriggerPrimitive value_type; - void operator()(value_type& lhs, value_type& rhs) { // pass by reference - lhs.accessGEMData().pad_hi += 1; - } - } gem_digi_cluster; - - // ___________________________________________________________________________ - // Do clustering using C++ functions - - // 1. Select GEM digis - std::copy_if( - muon_primitives.begin(), muon_primitives.end(), std::back_inserter(clus_muon_primitives), gem_digi_select); - - // 2. Sort - std::stable_sort(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_less); + // check the match in roll + if (deltaRoll > maxDeltaRoll) + continue; - // 3. Remove duplicates - clus_muon_primitives.erase(std::unique(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_equal), - clus_muon_primitives.end()); + has_copad = true; + + // recover the bend sign + if (static_cast(std::abs(bend)) > deltaPad) { + if (co_p->getGEMData().pad >= p->getGEMData().pad) + bend = deltaPad; + else + bend = -deltaPad; + } + } // end loop over co_pads + + // Need to flip the bend sign depending on the parity + bool isEven = (detid.chamber() % 2 == 0); + if (!isEven) { + bend = -bend; + } - // 4. Cluster adjacent digis - clus_muon_primitives.erase( - adjacent_cluster(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_adjacent, gem_digi_cluster), - clus_muon_primitives.end()); + // make a new coincidence pad digi + if (has_copad) { + copad_muon_primitives.push_back(*p); + } + } // end loop over pads + } // end loop over in_pads_layer1 } From bf1bfd96328b066c3957d5a8eea512ece382ed8f Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:58:05 -0400 Subject: [PATCH 11/34] [EMTF] Update EMTFSubsystemTag & EMTFSubsystemCollector 2/2 --- .../L1TMuonEndCap/src/PrimitiveSelection.cc | 6 +++--- L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc | 6 +++--- L1Trigger/L1TMuonEndCap/src/TrackFinder.cc | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc index 95cecef70ee15..09042d86bf61a 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc @@ -44,7 +44,7 @@ void PrimitiveSelection::configure(int verbose, // _____________________________________________________________________________ // Specialized process() for CSC template <> -void PrimitiveSelection::process(CSCTag tag, +void PrimitiveSelection::process(emtf::CSCTag tag, const TriggerPrimitiveCollection& muon_primitives, std::map& selected_csc_map) const { TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin(); @@ -175,7 +175,7 @@ void PrimitiveSelection::process(CSCTag tag, // _____________________________________________________________________________ // Specialized process() for RPC template <> -void PrimitiveSelection::process(RPCTag tag, +void PrimitiveSelection::process(emtf::RPCTag tag, const TriggerPrimitiveCollection& muon_primitives, std::map& selected_rpc_map) const { TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin(); @@ -330,7 +330,7 @@ void PrimitiveSelection::process(RPCTag tag, // _____________________________________________________________________________ // Specialized process() for GEM template <> -void PrimitiveSelection::process(GEMTag tag, +void PrimitiveSelection::process(emtf::GEMTag tag, const TriggerPrimitiveCollection& muon_primitives, std::map& selected_gem_map) const { TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin(); diff --git a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc index a8ab4695969be..d5b00a5b4f63c 100644 --- a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc @@ -556,11 +556,11 @@ void SectorProcessor::process_single_bx(int bx, // Put them into maps with an index that roughly corresponds to // each input link. // From src/PrimitiveSelection.cc - prim_sel.process(CSCTag(), muon_primitives, selected_csc_map); + prim_sel.process(emtf::CSCTag(), muon_primitives, selected_csc_map); if (useRPC_) { - prim_sel.process(RPCTag(), muon_primitives, selected_rpc_map); + prim_sel.process(emtf::RPCTag(), muon_primitives, selected_rpc_map); } - prim_sel.process(GEMTag(), muon_primitives, selected_gem_map); + prim_sel.process(emtf::GEMTag(), muon_primitives, selected_gem_map); prim_sel.merge(selected_csc_map, selected_rpc_map, selected_gem_map, selected_prim_map); // Convert trigger primitives into "converted" hits diff --git a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc index 9bde59800ac1b..8f58fe00705ae 100644 --- a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc @@ -12,10 +12,10 @@ TrackFinder::TrackFinder(const edm::ParameterSet& iConfig, edm::ConsumesCollecto pt_assign_engine_(), sector_processors_(), config_(iConfig), - tokenCSC_(iConsumes.consumes(iConfig.getParameter("CSCInput"))), - tokenRPC_(iConsumes.consumes(iConfig.getParameter("RPCInput"))), - tokenCPPF_(iConsumes.consumes(iConfig.getParameter("CPPFInput"))), - tokenGEM_(iConsumes.consumes(iConfig.getParameter("GEMInput"))), + tokenCSC_(iConsumes.consumes(iConfig.getParameter("CSCInput"))), + tokenRPC_(iConsumes.consumes(iConfig.getParameter("RPCInput"))), + tokenCPPF_(iConsumes.consumes(iConfig.getParameter("CPPFInput"))), + tokenGEM_(iConsumes.consumes(iConfig.getParameter("GEMInput"))), verbose_(iConfig.getUntrackedParameter("verbosity")), primConvLUT_(iConfig.getParameter("spPCParams16").getParameter("PrimConvLUT")), fwConfig_(iConfig.getParameter("FWConfig")), @@ -157,13 +157,13 @@ void TrackFinder::process(const edm::Event& iEvent, EMTFSubsystemCollector collector; if (useCSC_) - collector.extractPrimitives(CSCTag(), iEvent, tokenCSC_, muon_primitives); + collector.extractPrimitives(emtf::CSCTag(), &geometry_translator_, iEvent, tokenCSC_, muon_primitives); if (useRPC_ && useCPPF_) - collector.extractPrimitives(CPPFTag(), iEvent, tokenCPPF_, muon_primitives); + collector.extractPrimitives(emtf::CPPFTag(), &geometry_translator_, iEvent, tokenCPPF_, muon_primitives); else if (useRPC_) - collector.extractPrimitives(RPCTag(), iEvent, tokenRPC_, muon_primitives); + collector.extractPrimitives(emtf::RPCTag(), &geometry_translator_, iEvent, tokenRPC_, muon_primitives); if (useGEM_) - collector.extractPrimitives(GEMTag(), iEvent, tokenGEM_, muon_primitives); + collector.extractPrimitives(emtf::GEMTag(), &geometry_translator_, iEvent, tokenGEM_, muon_primitives); // Check trigger primitives if (verbose_ > 2) { // debug From 4ba8f166abcbe99190b44202dca28ea4b50796ce Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:59:28 -0400 Subject: [PATCH 12/34] [EMTF] Update TrackFinder & SectorProcessor & TrackTools 1/2 --- .../L1TMuonEndCap/interface/SectorProcessor.h | 3 +- .../L1TMuonEndCap/interface/TrackFinder.h | 5 +- .../L1TMuonEndCap/interface/TrackTools.h | 28 ++++-- .../L1TMuonEndCap/src/SectorProcessor.cc | 57 ++++++------ L1Trigger/L1TMuonEndCap/src/TrackFinder.cc | 39 +++++++-- L1Trigger/L1TMuonEndCap/src/TrackTools.cc | 86 +++++++++++++++++++ 6 files changed, 171 insertions(+), 47 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h b/L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h index c87be4fa9b406..f17477ec306d9 100644 --- a/L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h +++ b/L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h @@ -46,6 +46,7 @@ class SectorProcessor { int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, + int bxShiftME0, std::string era, const std::vector& zoneBoundaries, int zoneOverlap, @@ -111,7 +112,7 @@ class SectorProcessor { int verbose_, endcap_, sector_; - int minBX_, maxBX_, bxWindow_, bxShiftCSC_, bxShiftRPC_, bxShiftGEM_; + int minBX_, maxBX_, bxWindow_, bxShiftCSC_, bxShiftRPC_, bxShiftGEM_, bxShiftME0_; std::string era_; diff --git a/L1Trigger/L1TMuonEndCap/interface/TrackFinder.h b/L1Trigger/L1TMuonEndCap/interface/TrackFinder.h index d6dae7e99c6a6..799fc4a133c43 100644 --- a/L1Trigger/L1TMuonEndCap/interface/TrackFinder.h +++ b/L1Trigger/L1TMuonEndCap/interface/TrackFinder.h @@ -39,11 +39,12 @@ class TrackFinder { const edm::ParameterSet config_; - const edm::EDGetToken tokenCSC_, tokenRPC_, tokenCPPF_, tokenGEM_; + const edm::EDGetToken tokenDTPhi_, tokenDTTheta_, tokenCSC_, tokenCSCComparator_, tokenRPC_, tokenRPCRecHit_, + tokenCPPF_, tokenGEM_, tokenME0_; int verbose_, primConvLUT_; - bool fwConfig_, useCSC_, useRPC_, useCPPF_, useGEM_; + bool fwConfig_, useDT_, useCSC_, useRPC_, useIRPC_, useCPPF_, useGEM_, useME0_; std::string era_; }; diff --git a/L1Trigger/L1TMuonEndCap/interface/TrackTools.h b/L1Trigger/L1TMuonEndCap/interface/TrackTools.h index dddd9583cdbda..30191c62bf1b0 100644 --- a/L1Trigger/L1TMuonEndCap/interface/TrackTools.h +++ b/L1Trigger/L1TMuonEndCap/interface/TrackTools.h @@ -16,9 +16,19 @@ namespace emtf { int calc_uGMT_chamber(int csc_ID, int subsector, int neighbor, int station); + // CSC trigger sector & CSC ID + + int get_trigger_sector(int ring, int station, int chamber); + + int get_trigger_csc_ID(int ring, int station, int chamber); + + // CSC max strip & max wire + + void get_csc_max_strip_and_wire(int station, int ring, int& max_strip, int& max_wire); + // ___________________________________________________________________________ // coordinate ranges: phi[-180, 180] or [-pi, pi], theta[0, 90] or [0, pi/2] - inline double range_phi_deg(double deg) { + inline double wrap_phi_deg(double deg) { while (deg < -180.) deg += 360.; while (deg >= +180.) @@ -26,7 +36,7 @@ namespace emtf { return deg; } - inline double range_phi_rad(double rad) { + inline double wrap_phi_rad(double rad) { while (rad < -M_PI) rad += 2. * M_PI; while (rad >= +M_PI) @@ -34,8 +44,8 @@ namespace emtf { return rad; } - inline double range_theta_deg(double deg) { - deg = fabs(deg); + inline double wrap_theta_deg(double deg) { + deg = std::abs(deg); while (deg >= 180.) deg -= 180.; if (deg >= 180. / 2.) @@ -43,8 +53,8 @@ namespace emtf { return deg; } - inline double range_theta_rad(double rad) { - rad = fabs(rad); + inline double wrap_theta_rad(double rad) { + rad = std::abs(rad); while (rad >= M_PI) rad -= M_PI; if (rad >= M_PI / 2.) @@ -100,7 +110,7 @@ namespace emtf { } inline double calc_eta_from_theta_deg(double theta_deg, int endcap) { // endcap [-1,+1] - double theta_rad = deg_to_rad(range_theta_deg(theta_deg)); // put theta in [0, 90] range + double theta_rad = deg_to_rad(wrap_theta_deg(theta_deg)); // put theta in [0, 90] range double eta = calc_eta_from_theta_rad(theta_rad); eta = (endcap == -1) ? -eta : eta; return eta; @@ -182,7 +192,7 @@ namespace emtf { //} inline double calc_phi_loc_deg_from_glob(double glob, int sector) { // glob in deg, sector [1-6] - glob = range_phi_deg(glob); // put phi in [-180,180] range + glob = wrap_phi_deg(glob); // put phi in [-180,180] range double loc = glob - 15. - (60. * (sector - 1)); return loc; } @@ -216,7 +226,7 @@ namespace emtf { inline double calc_phi_GMT_rad(int bits) { return deg_to_rad(calc_phi_GMT_deg(bits)); } inline int calc_phi_GMT_int(double val) { // phi in deg - val = range_phi_deg(val); // put phi in [-180,180] range + val = wrap_phi_deg(val); // put phi in [-180,180] range val = (val - 180. / 576.) / (360. / 576.); int gmt_phi = static_cast(std::round(val)); return gmt_phi; diff --git a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc index d5b00a5b4f63c..292705fd81422 100644 --- a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc @@ -17,6 +17,7 @@ void SectorProcessor::configure(const GeometryTranslator* tp_geom, int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, + int bxShiftME0, std::string era, const std::vector& zoneBoundaries, int zoneOverlap, @@ -48,32 +49,13 @@ void SectorProcessor::configure(const GeometryTranslator* tp_geom, bool bugGMTPhi, bool promoteMode7, int modeQualVer) { - if (not(emtf::MIN_ENDCAP <= endcap && endcap <= emtf::MAX_ENDCAP)) { - edm::LogError("L1T") << "emtf::MIN_ENDCAP = " << emtf::MIN_ENDCAP << ", emtf::MAX_ENDCAP = " << emtf::MAX_ENDCAP - << ", endcap = " << endcap; - return; - } - if (not(emtf::MIN_TRIGSECTOR <= sector && sector <= emtf::MAX_TRIGSECTOR)) { - edm::LogError("L1T") << "emtf::MIN_TRIGSECTOR = " << emtf::MIN_TRIGSECTOR - << ", emtf::MAX_TRIGSECTOR = " << emtf::MAX_TRIGSECTOR << ", endcap = " << sector; - return; - } - if (not(tp_geom != nullptr)) { - edm::LogError("L1T") << "tp_geom = nullptr"; - return; - } - if (not(cond != nullptr)) { - edm::LogError("L1T") << "cond = nullptr"; - return; - } - if (not(lut != nullptr)) { - edm::LogError("L1T") << "lut = nullptr"; - return; - } - if (not(pt_assign_engine != nullptr)) { - edm::LogError("L1T") << "pt_assign_engine = nullptr"; - return; - } + assert(emtf::MIN_ENDCAP <= endcap && endcap <= emtf::MAX_ENDCAP); + assert(emtf::MIN_TRIGSECTOR <= sector && sector <= emtf::MAX_TRIGSECTOR); + + assert(tp_geom != nullptr); + assert(cond != nullptr); + assert(lut != nullptr); + assert(pt_assign_engine != nullptr); tp_geom_ = tp_geom; cond_ = cond; @@ -90,6 +72,7 @@ void SectorProcessor::configure(const GeometryTranslator* tp_geom, bxShiftCSC_ = bxShiftCSC; bxShiftRPC_ = bxShiftRPC; bxShiftGEM_ = bxShiftGEM; + bxShiftME0_ = bxShiftME0; era_ = era; @@ -405,7 +388,7 @@ void SectorProcessor::process(EventNumber_t ievent, EMTFTrackCollection& out_tracks) const { // if (endcap_ == 1 && sector_ == 1) { // std::cout << "\nConfigured with era " << era_ << ", thetaWindowZone0 = " << thetaWindowZone0_ << ", bugAmbigThetaWin = " - // << bugAmbigThetaWin_ << ", twoStationSameBX = " << twoStationSameBX_ << ", promoteMode7_ = " << promoteMode7_ << std::endl; + // << bugAmbigThetaWin_ << ", twoStationSameBX = " << twoStationSameBX_ << ", promoteMode7_ = " << promoteMode7_ << std::endl; // } // List of converted hits, extended from previous BXs @@ -463,6 +446,7 @@ void SectorProcessor::process_single_bx(int bx, bxShiftCSC_, bxShiftRPC_, bxShiftGEM_, + bxShiftME0_, includeNeighbor_, duplicateTheta_, bugME11Dupes_); @@ -477,6 +461,7 @@ void SectorProcessor::process_single_bx(int bx, bxShiftCSC_, bxShiftRPC_, bxShiftGEM_, + bxShiftME0_, zoneBoundaries_, zoneOverlap_, duplicateTheta_, @@ -534,9 +519,11 @@ void SectorProcessor::process_single_bx(int bx, promoteMode7_, modeQualVer_); + std::map selected_dt_map; std::map selected_csc_map; std::map selected_rpc_map; std::map selected_gem_map; + std::map selected_me0_map; std::map selected_prim_map; std::map inclusive_selected_prim_map; @@ -556,12 +543,15 @@ void SectorProcessor::process_single_bx(int bx, // Put them into maps with an index that roughly corresponds to // each input link. // From src/PrimitiveSelection.cc + //prim_sel.process(emtf::DTTag(), muon_primitives, selected_dt_map); //FIXME prim_sel.process(emtf::CSCTag(), muon_primitives, selected_csc_map); - if (useRPC_) { + if (useRPC_) { //FIXME prim_sel.process(emtf::RPCTag(), muon_primitives, selected_rpc_map); } prim_sel.process(emtf::GEMTag(), muon_primitives, selected_gem_map); - prim_sel.merge(selected_csc_map, selected_rpc_map, selected_gem_map, selected_prim_map); + //prim_sel.process(emtf::ME0Tag(), muon_primitives, selected_me0_map); //FIXME + prim_sel.merge( + selected_dt_map, selected_csc_map, selected_rpc_map, selected_gem_map, selected_me0_map, selected_prim_map); // Convert trigger primitives into "converted" hits // A converted hit consists of integer representations of phi, theta, and zones @@ -572,13 +562,20 @@ void SectorProcessor::process_single_bx(int bx, { // Keep all the converted hits for the use of data-emulator comparisons. // They include the extra ones that are not used in track building and the subsequent steps. - prim_sel.merge_no_truncate(selected_csc_map, selected_rpc_map, selected_gem_map, inclusive_selected_prim_map); + prim_sel.merge_no_truncate(selected_dt_map, + selected_csc_map, + selected_rpc_map, + selected_gem_map, + selected_me0_map, + inclusive_selected_prim_map); prim_conv.process(inclusive_selected_prim_map, inclusive_conv_hits); // Clear the input maps to save memory + selected_dt_map.clear(); selected_csc_map.clear(); selected_rpc_map.clear(); selected_gem_map.clear(); + selected_me0_map.clear(); } // Detect patterns in all zones, find 3 best roads in each zone diff --git a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc index 8f58fe00705ae..a3d3a7871a6b6 100644 --- a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc @@ -12,24 +12,35 @@ TrackFinder::TrackFinder(const edm::ParameterSet& iConfig, edm::ConsumesCollecto pt_assign_engine_(), sector_processors_(), config_(iConfig), + tokenDTPhi_(iConsumes.consumes(iConfig.getParameter("DTPhiInput"))), + tokenDTTheta_( + iConsumes.consumes(iConfig.getParameter("DTThetaInput"))), tokenCSC_(iConsumes.consumes(iConfig.getParameter("CSCInput"))), + tokenCSCComparator_(iConsumes.consumes( + iConfig.getParameter("CSCComparatorInput"))), tokenRPC_(iConsumes.consumes(iConfig.getParameter("RPCInput"))), + tokenRPCRecHit_( + iConsumes.consumes(iConfig.getParameter("RPCRecHitInput"))), tokenCPPF_(iConsumes.consumes(iConfig.getParameter("CPPFInput"))), tokenGEM_(iConsumes.consumes(iConfig.getParameter("GEMInput"))), + tokenME0_(iConsumes.consumes(iConfig.getParameter("ME0Input"))), verbose_(iConfig.getUntrackedParameter("verbosity")), primConvLUT_(iConfig.getParameter("spPCParams16").getParameter("PrimConvLUT")), fwConfig_(iConfig.getParameter("FWConfig")), + useDT_(iConfig.getParameter("DTEnable")), useCSC_(iConfig.getParameter("CSCEnable")), useRPC_(iConfig.getParameter("RPCEnable")), + useIRPC_(iConfig.getParameter("IRPCEnable")), useCPPF_(iConfig.getParameter("CPPFEnable")), useGEM_(iConfig.getParameter("GEMEnable")), + useME0_(iConfig.getParameter("ME0Enable")), era_(iConfig.getParameter("Era")) { if (era_ == "Run2_2016") { pt_assign_engine_.reset(new PtAssignmentEngine2016()); } else if (era_ == "Run2_2017" || era_ == "Run2_2018") { pt_assign_engine_.reset(new PtAssignmentEngine2017()); } else { - edm::LogError("L1T") << "era_ = " << era_; + edm::LogError("L1T") << "Cannot recognize the era option: " << era_; return; } @@ -39,6 +50,7 @@ TrackFinder::TrackFinder(const edm::ParameterSet& iConfig, edm::ConsumesCollecto auto bxShiftCSC = iConfig.getParameter("CSCInputBXShift"); auto bxShiftRPC = iConfig.getParameter("RPCInputBXShift"); auto bxShiftGEM = iConfig.getParameter("GEMInputBXShift"); + auto bxShiftME0 = iConfig.getParameter("ME0InputBXShift"); const auto& spPCParams16 = config_.getParameter("spPCParams16"); auto zoneBoundaries = spPCParams16.getParameter >("ZoneBoundaries"); @@ -98,6 +110,7 @@ TrackFinder::TrackFinder(const edm::ParameterSet& iConfig, edm::ConsumesCollecto bxShiftCSC, bxShiftRPC, bxShiftGEM, + bxShiftME0, era_, zoneBoundaries, zoneOverlap, @@ -156,14 +169,30 @@ void TrackFinder::process(const edm::Event& iEvent, TriggerPrimitiveCollection muon_primitives; EMTFSubsystemCollector collector; - if (useCSC_) + if (useCSC_) { collector.extractPrimitives(emtf::CSCTag(), &geometry_translator_, iEvent, tokenCSC_, muon_primitives); - if (useRPC_ && useCPPF_) + //collector.extractPrimitives(emtf::CSCTag(), &geometry_translator_, iEvent, tokenCSC_, tokenCSCComparator_, muon_primitives); + } + if (useRPC_ && useCPPF_) { collector.extractPrimitives(emtf::CPPFTag(), &geometry_translator_, iEvent, tokenCPPF_, muon_primitives); - else if (useRPC_) + } else if (useRPC_) { collector.extractPrimitives(emtf::RPCTag(), &geometry_translator_, iEvent, tokenRPC_, muon_primitives); - if (useGEM_) + //collector.extractPrimitives(emtf::RPCTag(), &geometry_translator_, iEvent, tokenRPC_, tokenRPCRecHit_, muon_primitives); + } + if (useIRPC_) { + collector.extractPrimitives(emtf::IRPCTag(), &geometry_translator_, iEvent, tokenRPC_, muon_primitives); + //collector.extractPrimitives(emtf::IRPCTag(), &geometry_translator_, iEvent, tokenRPC_, tokenRPCRecHit_, muon_primitives); + } + if (useGEM_) { collector.extractPrimitives(emtf::GEMTag(), &geometry_translator_, iEvent, tokenGEM_, muon_primitives); + } + if (useME0_) { + collector.extractPrimitives(emtf::ME0Tag(), &geometry_translator_, iEvent, tokenME0_, muon_primitives); + } + if (useDT_) { + collector.extractPrimitives( + emtf::DTTag(), &geometry_translator_, iEvent, tokenDTPhi_, tokenDTTheta_, muon_primitives); + } // Check trigger primitives if (verbose_ > 2) { // debug diff --git a/L1Trigger/L1TMuonEndCap/src/TrackTools.cc b/L1Trigger/L1TMuonEndCap/src/TrackTools.cc index d10ae5bceffab..68cf10113ef6d 100644 --- a/L1Trigger/L1TMuonEndCap/src/TrackTools.cc +++ b/L1Trigger/L1TMuonEndCap/src/TrackTools.cc @@ -80,4 +80,90 @@ namespace emtf { } } + // Use CSC trigger sector definitions + // Copied from DataFormats/MuonDetId/src/CSCDetId.cc + int get_trigger_sector(int ring, int station, int chamber) { + int result = 0; + if (station > 1 && ring > 1) { + result = ((static_cast(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6 + } else if (station == 1 && ring != 4) { + result = ((static_cast(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6 + } else { + result = ((static_cast(chamber - 2) & 0x1f) / 3) + 1; // ch 2-4-> 1, 5-7->2, ... + } + return (result <= 6) ? result + : 6; // max sector is 6, some calculations give a value greater than six but this is expected. + } + + // Use CSC trigger "CSC ID" definitions + // Copied from DataFormats/MuonDetId/src/CSCDetId.cc + int get_trigger_csc_ID(int ring, int station, int chamber) { + int result = 0; + if (station == 1) { + result = (chamber) % 3 + 1; // 1,2,3 + switch (ring) { + case 1: + break; + case 2: + result += 3; // 4,5,6 + break; + case 3: + result += 6; // 7,8,9 + break; + case 4: // ME0 + result = (chamber + 1) % 3 + 1; // 1,2,3 + break; + } + } else { + if (ring == 1) { + result = (chamber + 1) % 3 + 1; // 1,2,3 + } else { + result = (chamber + 3) % 6 + 4; // 4,5,6,7,8,9 + } + } + return result; + } + + // Number of halfstrips and wiregroups + // +----------------------------+------------+------------+ + // | Chamber type | Num of | Num of | + // | | halfstrips | wiregroups | + // +----------------------------+------------+------------+ + // | ME1/1a | 96 | 48 | + // | ME1/1b | 128 | 48 | + // | ME1/2 | 160 | 64 | + // | ME1/3 | 128 | 32 | + // | ME2/1 | 160 | 112 | + // | ME3/1, ME4/1 | 160 | 96 | + // | ME2/2, ME3/2, ME4/2 | 160 | 64 | + // +----------------------------+------------+------------+ + + void get_csc_max_strip_and_wire(int station, int ring, int& max_strip, int& max_wire) { + max_strip = 0; // halfstrip + max_wire = 0; // wiregroup + if (station == 1 && ring == 4) { // ME1/1a + max_strip = 96; + max_wire = 48; + } else if (station == 1 && ring == 1) { // ME1/1b + max_strip = 128; + max_wire = 48; + } else if (station == 1 && ring == 2) { // ME1/2 + max_strip = 160; + max_wire = 64; + } else if (station == 1 && ring == 3) { // ME1/3 + max_strip = 128; + max_wire = 32; + } else if (station == 2 && ring == 1) { // ME2/1 + max_strip = 160; + max_wire = 112; + } else if (station >= 3 && ring == 1) { // ME3/1, ME4/1 + max_strip = 160; + max_wire = 96; + } else if (station >= 2 && ring == 2) { // ME2/2, ME3/2, ME4/2 + max_strip = 160; + max_wire = 64; + } + return; + } + } // namespace emtf From 26a5496064e8f525ad2efbbed7d86fa584c52c3d Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 12:00:20 -0400 Subject: [PATCH 13/34] [EMTF] Update TrackFinder & SectorProcessor & TrackTools 2/2 --- .../L1TMuonEndCap/interface/PrimitiveConversion.h | 3 ++- .../L1TMuonEndCap/interface/PrimitiveSelection.h | 11 ++++++++--- L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc | 2 ++ L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc | 10 ++++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h b/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h index e601b720c1542..0d8f1f9793040 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h +++ b/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h @@ -16,6 +16,7 @@ class PrimitiveConversion { int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, + int bxShiftME0, const std::vector& zoneBoundaries, int zoneOverlap, bool duplicateTheta, @@ -80,7 +81,7 @@ class PrimitiveConversion { int verbose_, endcap_, sector_, bx_; - int bxShiftCSC_, bxShiftRPC_, bxShiftGEM_; + int bxShiftCSC_, bxShiftRPC_, bxShiftGEM_, bxShiftME0_; std::vector zoneBoundaries_; int zoneOverlap_; diff --git a/L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h b/L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h index c8f8e60d67830..cd7cf40c1a581 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h +++ b/L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h @@ -12,6 +12,7 @@ class PrimitiveSelection { int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, + int bxShiftME0, bool includeNeighbor, bool duplicateTheta, bool bugME11Dupes); @@ -22,15 +23,19 @@ class PrimitiveSelection { std::map& selected_prim_map) const; // Put the hits from CSC, RPC, GEM together in one collection - void merge(const std::map& selected_csc_map, + void merge(const std::map& selected_dt_map, + const std::map& selected_csc_map, const std::map& selected_rpc_map, const std::map& selected_gem_map, + const std::map& selected_me0_map, std::map& selected_prim_map) const; // Like merge(), but keep all the hits - void merge_no_truncate(const std::map& selected_csc_map, + void merge_no_truncate(const std::map& selected_dt_map, + const std::map& selected_csc_map, const std::map& selected_rpc_map, const std::map& selected_gem_map, + const std::map& selected_me0_map, std::map& selected_prim_map) const; // CSC functions @@ -73,7 +78,7 @@ class PrimitiveSelection { private: int verbose_, endcap_, sector_, bx_; - int bxShiftCSC_, bxShiftRPC_, bxShiftGEM_; + int bxShiftCSC_, bxShiftRPC_, bxShiftGEM_, bxShiftME0_; bool includeNeighbor_, duplicateTheta_; diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc index 7541d5755c115..5c8d1cb29ae71 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc @@ -17,6 +17,7 @@ void PrimitiveConversion::configure(const GeometryTranslator* tp_geom, int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, + int bxShiftME0, const std::vector& zoneBoundaries, int zoneOverlap, bool duplicateTheta, @@ -44,6 +45,7 @@ void PrimitiveConversion::configure(const GeometryTranslator* tp_geom, bxShiftCSC_ = bxShiftCSC; bxShiftRPC_ = bxShiftRPC; bxShiftGEM_ = bxShiftGEM; + bxShiftME0_ = bxShiftME0; zoneBoundaries_ = zoneBoundaries; zoneOverlap_ = zoneOverlap; diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc index 09042d86bf61a..d6b35a6ffecaf 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc @@ -24,6 +24,7 @@ void PrimitiveSelection::configure(int verbose, int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, + int bxShiftME0, bool includeNeighbor, bool duplicateTheta, bool bugME11Dupes) { @@ -35,6 +36,7 @@ void PrimitiveSelection::configure(int verbose, bxShiftCSC_ = bxShiftCSC; bxShiftRPC_ = bxShiftRPC; bxShiftGEM_ = bxShiftGEM; + bxShiftME0_ = bxShiftME0; includeNeighbor_ = includeNeighbor; duplicateTheta_ = duplicateTheta; @@ -397,9 +399,11 @@ void PrimitiveSelection::process(emtf::GEMTag tag, // or not, basically regardless of anything. RPCs are treated as a // supplemental source of stubs for CSCs. -void PrimitiveSelection::merge(const std::map& selected_csc_map, +void PrimitiveSelection::merge(const std::map& selected_dt_map, + const std::map& selected_csc_map, const std::map& selected_rpc_map, const std::map& selected_gem_map, + const std::map& selected_me0_map, std::map& selected_prim_map) const { // First, put CSC hits std::map::const_iterator map_tp_it = selected_csc_map.begin(); @@ -490,9 +494,11 @@ void PrimitiveSelection::merge(const std::map& } } -void PrimitiveSelection::merge_no_truncate(const std::map& selected_csc_map, +void PrimitiveSelection::merge_no_truncate(const std::map& selected_dt_map, + const std::map& selected_csc_map, const std::map& selected_rpc_map, const std::map& selected_gem_map, + const std::map& selected_me0_map, std::map& selected_prim_map) const { // First, put CSC hits merge_map_into_map(selected_csc_map, selected_prim_map); From 3007d04f9e34e4207935ea53fda97f1bc8d4b26a Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 12:02:25 -0400 Subject: [PATCH 14/34] [EMTF] Update PrimitiveSelection & PrimitiveConversion 1/4 --- .../interface/PrimitiveSelection.h | 47 +- .../L1TMuonEndCap/src/PrimitiveSelection.cc | 816 ++++++++++++------ .../L1TMuonEndCap/src/SectorProcessor.cc | 4 +- 3 files changed, 600 insertions(+), 267 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h b/L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h index cd7cf40c1a581..8a8fee5d74d90 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h +++ b/L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h @@ -22,7 +22,7 @@ class PrimitiveSelection { const TriggerPrimitiveCollection& muon_primitives, std::map& selected_prim_map) const; - // Put the hits from CSC, RPC, GEM together in one collection + // Put the hits from DT, CSC, RPC, GEM, ME0 together in one collection void merge(const std::map& selected_dt_map, const std::map& selected_csc_map, const std::map& selected_rpc_map, @@ -38,11 +38,12 @@ class PrimitiveSelection { const std::map& selected_me0_map, std::map& selected_prim_map) const; + // ___________________________________________________________________________ // CSC functions - // If selected, return an index 0-53, else return -1 - // The index 0-53 roughly corresponds to an input link. It maps to the - // 2D index [station][chamber] used in the firmware, with size [5:0][8:0]. - // Station 5 = neighbor sector, all stations. + // - If a chamber is selected, return an index 0-53, else return -1. + // The index 0-53 roughly corresponds to an input link. It maps to the + // 2D index [station][chamber] used in the firmware, with size [5:0][8:0]. + // Station 5 = neighbor sector, all stations. int select_csc(const TriggerPrimitive& muon_primitive) const; bool is_in_sector_csc(int tp_endcap, int tp_sector) const; @@ -51,9 +52,16 @@ class PrimitiveSelection { bool is_in_bx_csc(int tp_bx) const; - int get_index_csc(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const; + int get_index_csc(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const; // RPC functions + // - If a chamber is selected, return an index 0-41, else return -1. + // The index 0-41 corresponds to CPPF link x chamber. Each CPPF link corresponds + // to a RPC subsector (6+1 incl. neighbor), and carries data from 6 RPC chambers + // (RE1/2, RE2/2, RE3/2, RE3/3, RE4/2, RE4/3). The index maps to the 2D index + // [subsector][chamber] used in the firmware, with size [6:0][5:0]. + // For Phase 2, add RE1/3, RE2/3, RE3/1, RE4/1 -> 10 chambers, so the index + // becomes 0-69. int select_rpc(const TriggerPrimitive& muon_primitive) const; bool is_in_sector_rpc(int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const; @@ -62,7 +70,7 @@ class PrimitiveSelection { bool is_in_bx_rpc(int tp_bx) const; - int get_index_rpc(int tp_station, int tp_ring, int tp_subsector, bool is_neighbor) const; + int get_index_rpc(int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector, int tp_bx) const; // GEM functions int select_gem(const TriggerPrimitive& muon_primitive) const; @@ -73,7 +81,30 @@ class PrimitiveSelection { bool is_in_bx_gem(int tp_bx) const; - int get_index_gem(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const; + int get_index_gem(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const; + + // ME0 functions + int select_me0(const TriggerPrimitive& muon_primitive) const; + + bool is_in_sector_me0(int tp_endcap, int tp_sector, int tp_csc_ID, int tp_pad) const; + + bool is_in_neighbor_sector_me0(int tp_endcap, int tp_sector, int tp_csc_ID, int tp_pad) const; + + bool is_in_bx_me0(int tp_bx) const; + + int get_index_me0( + int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_pad, int tp_bx) const; + + // DT functions + int select_dt(const TriggerPrimitive& muon_primitive) const; + + bool is_in_sector_dt(int tp_endcap, int tp_sector) const; + + bool is_in_neighbor_sector_dt(int tp_endcap, int tp_sector, int tp_csc_ID) const; + + bool is_in_bx_dt(int tp_bx) const; + + int get_index_dt(int tp_endcap, int csc_tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const; private: int verbose_, endcap_, sector_, bx_; diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc index d6b35a6ffecaf..4a8c82b2524e8 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc @@ -1,9 +1,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h" -#include "DataFormats/MuonDetId/interface/DTChamberId.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" -#include "DataFormats/MuonDetId/interface/RPCDetId.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" +#include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h" #include "helper.h" // merge_map_into_map, assert_no_abort @@ -11,11 +8,13 @@ // Arranged in FW as 6 stations, 9 chambers per station. #define NUM_CSC_CHAMBERS 6 * 9 // 6x2 in RE1,2; 12x2 in RE3,4; 6 from neighbor sector. -// Arranged in FW as 7 stations, 6 chambers per station. (8 with iRPC) -#define NUM_RPC_CHAMBERS 7 * 8 -// 6 in GE1/1; 3 in GE2/1; 2 from neighbor sector. -// Arranged in FW as 6 stations, 9 chambers per station, mimicking CSC. (unconfirmed!) -#define NUM_GEM_CHAMBERS 6 * 9 +// Arranged in FW as 7 stations, 6 chambers per station. +// For Phase 2, add RE1/3, RE2/3, RE3/1, RE4/1 -> 10 chambers per station +#define NUM_RPC_CHAMBERS 7 * 10 +// 6 in GE1/1; 3 in GE2/1; 3 in ME0; 3 from neighbor sector. (unconfirmed!) +#define NUM_GEM_CHAMBERS 15 +// 2x4 in MB1,2,3,4; 4 from neighbor sector. (unconfirmed!) +#define NUM_DT_CHAMBERS 3 * 4 void PrimitiveSelection::configure(int verbose, int endcap, @@ -86,6 +85,7 @@ void PrimitiveSelection::process(emtf::CSCTag tag, return; } + //FIXME if (selected_csc_map[selected_csc].size() < 2) { selected_csc_map[selected_csc].push_back(new_tp); } else { @@ -184,7 +184,7 @@ void PrimitiveSelection::process(emtf::RPCTag tag, TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end(); for (; tp_it != tp_end; ++tp_it) { - int selected_rpc = select_rpc(*tp_it); // Returns RPC "link" index (0 - 41) + int selected_rpc = select_rpc(*tp_it); // Returns RPC "link" index if (selected_rpc >= 0) { if (not(selected_rpc < NUM_RPC_CHAMBERS)) { @@ -203,12 +203,24 @@ void PrimitiveSelection::process(emtf::RPCTag tag, // there are 1 large cluster and 2 small clusters, it is possible that // one of the two small clusters is discarded first, and the large cluster // then is removed by the cluster size cut, leaving only one cluster. + // Note: this needs to be modified for Phase 2 with additional iRPC chambers. bool apply_truncation = true; if (apply_truncation) { struct { typedef TriggerPrimitive value_type; bool operator()(const value_type& x) const { + // Skip cluster size cut if primitives are from CPPF emulator or EMTF unpacker (already clustered) + if (x.getRPCData().isCPPF) + return false; + int sz = x.getRPCData().strip_hi - x.getRPCData().strip_low + 1; + + const RPCDetId& tp_detId = x.detId(); + int tp_station = tp_detId.station(); + int tp_ring = tp_detId.ring(); + const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1); + if (is_irpc) + return sz > 6; // iRPC strip pitch is 1.5 times smaller than traditional RPC return sz > 3; } } cluster_size_cut; @@ -217,9 +229,10 @@ void PrimitiveSelection::process(emtf::RPCTag tag, std::map::iterator map_tp_end = selected_rpc_map.end(); for (; map_tp_it != map_tp_end; ++map_tp_it) { - //int selected = map_tp_it->first; + int selected = map_tp_it->first; TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference + //FIXME // Check to see if unpacked CPPF digis have <= 2 digis per chamber, as expected if (tmp_primitives.size() > 2 && tmp_primitives.at(0).getRPCData().isCPPF) { edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; @@ -229,13 +242,15 @@ void PrimitiveSelection::process(emtf::RPCTag tag, edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n"; } - // Keep the first two clusters - if (tmp_primitives.size() > 2) - tmp_primitives.erase(tmp_primitives.begin() + 2, tmp_primitives.end()); - - // Skip cluster size cut if primitives are from CPPF emulator or EMTF unpacker (already clustered) - if (!tmp_primitives.empty() && tmp_primitives.at(0).getRPCData().isCPPF) - break; + if ((selected % 10) == 8 || (selected % 10) == 9) { // RE3/1 or RE4/1 (iRPC) + // Keep the first 4 clusters + if (tmp_primitives.size() > 4) + tmp_primitives.erase(tmp_primitives.begin() + 4, tmp_primitives.end()); + } else { + // Keep the first 2 clusters + if (tmp_primitives.size() > 2) + tmp_primitives.erase(tmp_primitives.begin() + 2, tmp_primitives.end()); + } // Apply cluster size cut tmp_primitives.erase(std::remove_if(tmp_primitives.begin(), tmp_primitives.end(), cluster_size_cut), @@ -256,14 +271,14 @@ void PrimitiveSelection::process(emtf::RPCTag tag, int selected = map_tp_it->first; TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference - int rpc_sub = selected / 8; - int rpc_chm = selected % 8; + int rpc_sub = selected / 10; + int rpc_chm = selected % 10; int pc_station = -1; int pc_chamber = -1; if (rpc_sub != 6) { // native - if (rpc_chm == 0) { // RE1/2 + if (rpc_chm == 0) { // RE1/2: 3-5, 12-14 if (0 <= rpc_sub && rpc_sub < 3) { pc_station = 0; pc_chamber = 3 + rpc_sub; @@ -271,27 +286,47 @@ void PrimitiveSelection::process(emtf::RPCTag tag, pc_station = 1; pc_chamber = 3 + (rpc_sub - 3); } - } else if (rpc_chm == 1) { // RE2/2 + } else if (rpc_chm == 6) { // RE1/3: 6-8, 15-17 + if (0 <= rpc_sub && rpc_sub < 3) { + pc_station = 0; + pc_chamber = 6 + rpc_sub; + } else if (3 <= rpc_sub && rpc_sub < 6) { + pc_station = 1; + pc_chamber = 6 + (rpc_sub - 3); + } + } else if (rpc_chm == 1 || rpc_chm == 7) { // RE2/2, RE2/3: 21-26 pc_station = 2; pc_chamber = 3 + rpc_sub; - } else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3 + } else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3: 30-35 pc_station = 3; pc_chamber = 3 + rpc_sub; - } else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3 + } else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3: 39-44 pc_station = 4; pc_chamber = 3 + rpc_sub; + } else if (rpc_chm == 8) { // RE3/1: 27-29 + pc_station = 3; + pc_chamber = rpc_sub; + } else if (rpc_chm == 9) { // RE4/1: 36-38 + pc_station = 4; + pc_chamber = rpc_sub; } } else { // neighbor pc_station = 5; - if (rpc_chm == 0) { // RE1/2 + if (rpc_chm == 0) { // RE1/2: 46 pc_chamber = 1; - } else if (rpc_chm == 1) { // RE2/2 + } else if (rpc_chm == 6) { // RE1/3: 47 + pc_chamber = 2; + } else if (rpc_chm == 1 || rpc_chm == 7) { // RE2/2, RE2/3: 49 pc_chamber = 4; - } else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3 + } else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3: 51 pc_chamber = 6; - } else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3 + } else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3: 53 pc_chamber = 8; + } else if (rpc_chm == 8) { // RE3/1: 50 + pc_chamber = 5; + } else if (rpc_chm == 9) { // RE4/1: 52 + pc_chamber = 7; } } @@ -310,13 +345,22 @@ void PrimitiveSelection::process(emtf::RPCTag tag, ignore_this_rpc_chm = true; } + if (rpc_chm == 6 || rpc_chm == 7) { // RE1/3 and RE2/3 chambers are not part of EMTF + ignore_this_rpc_chm = true; + } + + if (rpc_chm == 8 || rpc_chm == 9) { // RE3/1 and RE4/1 chambers are not available until Phase-2 + ignore_this_rpc_chm = true; + } + if (ignore_this_rpc_chm) { - // Set RPC stubs as invalid + // Set RPC stubs as invalid, but we keep them for (auto&& tp : tmp_primitives) { tp.accessRPCData().valid = 0; } } + // Keep the stubs in the temporary map if (tmp_selected_rpc_map.find(selected) == tmp_selected_rpc_map.end()) { tmp_selected_rpc_map[selected] = tmp_primitives; } else { @@ -339,13 +383,10 @@ void PrimitiveSelection::process(emtf::GEMTag tag, TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end(); for (; tp_it != tp_end; ++tp_it) { - int selected_gem = select_gem(*tp_it); // Returns GEM "link" index (0 - 53) + int selected_gem = select_gem(*tp_it); // Returns GEM "link" index if (selected_gem >= 0) { - if (not(selected_gem < NUM_GEM_CHAMBERS)) { - edm::LogError("L1T") << "selected_gem = " << selected_gem << ", NUM_GEM_CHAMBERS = " << NUM_GEM_CHAMBERS; - return; - } + assert(selected_gem < NUM_GEM_CHAMBERS); selected_gem_map[selected_gem].push_back(*tp_it); } } @@ -380,7 +421,89 @@ void PrimitiveSelection::process(emtf::GEMTag tag, } // _____________________________________________________________________________ -// Put the hits from CSC, RPC, GEM together in one collection +// Specialized process() for ME0 +template <> +void PrimitiveSelection::process(emtf::ME0Tag tag, + const TriggerPrimitiveCollection& muon_primitives, + std::map& selected_me0_map) const { + TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin(); + TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end(); + + for (; tp_it != tp_end; ++tp_it) { + int selected_me0 = select_me0(*tp_it); // Returns ME0 "link" index + + if (selected_me0 >= 0) { + assert(selected_me0 < NUM_GEM_CHAMBERS); + selected_me0_map[selected_me0].push_back(*tp_it); + } + } + + // Apply truncation + bool apply_truncation = true; + if (apply_truncation) { + std::map::iterator map_tp_it = selected_me0_map.begin(); + std::map::iterator map_tp_end = selected_me0_map.end(); + + for (; map_tp_it != map_tp_end; ++map_tp_it) { + //int selected = map_tp_it->first; + TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference + + // Keep the first 20 clusters + if (tmp_primitives.size() > 20) + tmp_primitives.erase(tmp_primitives.begin() + 20, tmp_primitives.end()); + } + } +} + +// _____________________________________________________________________________ +// Specialized process() for DT +template <> +void PrimitiveSelection::process(emtf::DTTag tag, + const TriggerPrimitiveCollection& muon_primitives, + std::map& selected_dt_map) const { + TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin(); + TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end(); + + for (; tp_it != tp_end; ++tp_it) { + int selected_dt = select_dt(*tp_it); // Returns DT "link" index + + if (selected_dt >= 0) { + assert(selected_dt < NUM_DT_CHAMBERS); + selected_dt_map[selected_dt].push_back(*tp_it); + } + } + + // Duplicate DT muon primitives + if (duplicateTheta_) { + std::map::iterator map_tp_it = selected_dt_map.begin(); + std::map::iterator map_tp_end = selected_dt_map.end(); + + for (; map_tp_it != map_tp_end; ++map_tp_it) { + //int selected = map_tp_it->first; + TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference + + assert(tmp_primitives.size() <= 2); // at most 2 hits + + if (tmp_primitives.size() == 2) { + if ((tmp_primitives.at(0).getStrip() != tmp_primitives.at(1).getStrip()) && + (tmp_primitives.at(0).getWire() != tmp_primitives.at(1).getWire())) { + // Swap wire numbers + TriggerPrimitive tp0 = tmp_primitives.at(0); // (s1,w1) + TriggerPrimitive tp1 = tmp_primitives.at(1); // (s2,w2) + uint16_t tmp_keywire = tp0.accessDTData().theta_bti_group; + tp0.accessDTData().theta_bti_group = tp1.accessDTData().theta_bti_group; // (s1,w2) + tp1.accessDTData().theta_bti_group = tmp_keywire; // (s2,w1) + + tmp_primitives.insert(tmp_primitives.begin() + 1, tp1); // (s2,w1) at 2nd pos + tmp_primitives.insert(tmp_primitives.begin() + 2, tp0); // (s1,w2) at 3rd pos + } + } // end if tmp_primitives.size() == 2 + } // end loop over selected_dt_map + } // end if duplicate theta +} + +// _____________________________________________________________________________ +// Put the hits from DT, CSC, RPC, GEM, ME0 together in one collection // Notes from Alex (2017-03-28): // @@ -503,11 +626,17 @@ void PrimitiveSelection::merge_no_truncate(const std::map subsector 0 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2); - // Selection - if (is_in_bx_csc(tp_bx)) { - if (is_in_sector_csc(tp_endcap, tp_sector)) { - selected = get_index_csc(tp_subsector, tp_station, tp_csc_ID, false); - } else if (is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) { - selected = get_index_csc(tp_subsector, tp_station, tp_csc_ID, true); - } - } + // Check if the chamber belongs to this sector processor at this BX. + selected = get_index_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID, tp_bx); } return selected; } @@ -640,9 +724,22 @@ bool PrimitiveSelection::is_in_bx_csc(int tp_bx) const { } // Returns CSC input "link". Index used by FW for unique chamber identification. -int PrimitiveSelection::get_index_csc(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const { +int PrimitiveSelection::get_index_csc( + int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const { int selected = -1; + bool is_native = false; + bool is_neighbor = false; + if (is_in_bx_csc(tp_bx)) { + if (is_in_sector_csc(tp_endcap, tp_sector)) { + is_native = true; + } else if (is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) { + is_neighbor = true; + } + } + if (!is_native && !is_neighbor) + return selected; + if (!is_neighbor) { if (tp_station == 1) { // ME1: 0 - 8, 9 - 17 selected = (tp_subsector - 1) * 9 + (tp_csc_ID - 1); @@ -651,12 +748,13 @@ int PrimitiveSelection::get_index_csc(int tp_subsector, int tp_station, int tp_c } } else { - if (tp_station == 1) { // ME1: 45 - 47 + if (tp_station == 1) { // ME1n: 45 - 47 selected = (5) * 9 + (tp_csc_ID - 1) / 3; - } else { // ME2,3,4: 48 - 53 + } else { // ME2n,3n,4n: 48 - 53 selected = (5) * 9 + (tp_station)*2 - 1 + (tp_csc_ID - 1 < 3 ? 0 : 1); } } + assert(selected != -1); return selected; } @@ -687,75 +785,64 @@ int PrimitiveSelection::select_rpc(const TriggerPrimitive& muon_primitive) const if (tp_CPPF && (tp_emtf_sect != sector_)) return selected; - if (!(tp_region != 0)) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_region = " << tp_region; - return selected; - } - if (!(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP)) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_endcap = " << tp_endcap; - return selected; - } - if (!(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR)) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_sector = " << tp_sector; - return selected; - } - if (!(1 <= tp_subsector && tp_subsector <= 6)) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_subsector = " << tp_subsector; - return selected; - } - if (!(1 <= tp_station && tp_station <= 4)) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_station = " << tp_station; - return selected; - } - if (!(2 <= tp_ring && tp_ring <= 3)) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_ring = " << tp_ring; - return selected; - } - if (!(1 <= tp_roll && tp_roll <= 3)) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_roll = " << tp_roll; - return selected; - } - if (!(tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_data.strip = " << tp_data.strip; - return selected; - } - if (!(tp_station > 2 || tp_ring != 3)) { - edm::LogWarning("L1T") << "EMTF RPC format error: tp_station = " << tp_station << ", tp_ring = " << tp_ring; - return selected; + const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1); + + if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once + assert_no_abort(tp_region != 0); + assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + assert_no_abort(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); + assert_no_abort(1 <= tp_subsector && tp_subsector <= 6); + assert_no_abort(1 <= tp_station && tp_station <= 4); + assert_no_abort((!is_irpc && 2 <= tp_ring && tp_ring <= 3) || (is_irpc && tp_ring == 1)); + assert_no_abort((!is_irpc && 1 <= tp_roll && tp_roll <= 3) || (is_irpc && 1 <= tp_roll && tp_roll <= 5)); + //assert_no_abort((!is_irpc && (tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) || (is_irpc && 1 <= tp_strip && tp_strip <= 96)); + assert_no_abort((!is_irpc && (tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) || + (is_irpc && 1 <= tp_strip && tp_strip <= 96 * 2)); // in CMSSW, the iRPC chamber has 192 strips + //assert_no_abort(tp_station > 2 || tp_ring != 3); // stations 1 and 2 do not receive RPCs from ring 3 + assert_no_abort(tp_data.valid == true); } - // Selection - if (is_in_bx_rpc(tp_bx)) { - if (is_in_sector_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector)) { - selected = get_index_rpc(tp_station, tp_ring, tp_subsector, false); - } else if (is_in_neighbor_sector_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector)) { - selected = get_index_rpc(tp_station, tp_ring, tp_subsector, true); - } - } + // Check if the chamber belongs to this sector processor at this BX. + selected = get_index_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector, tp_bx); } return selected; } bool PrimitiveSelection::is_in_sector_rpc( int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const { - // RPC sector X, subsectors 1-2 corresponds to CSC sector X-1 - // RPC sector X, subsectors 3-6 corresponds to CSC sector X + // RPC sector X, subsectors 1-2 correspond to CSC sector X-1 + // RPC sector X, subsectors 3-6 correspond to CSC sector X + // iRPC sector X, subsectors 1 correspond to CSC sector X-1 + // iRPC sector X, subsectors 2-3 correspind to CSC sector X auto get_csc_sector = [](int tp_station, int tp_ring, int tp_sector, int tp_subsector) { - // 10 degree chamber - int corr = (tp_subsector < 3) ? (tp_sector == 1 ? +5 : -1) : 0; - return tp_sector + corr; + const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1); + if (is_irpc) { + // 20 degree chamber + int corr = (tp_subsector < 2) ? (tp_sector == 1 ? +5 : -1) : 0; + return tp_sector + corr; + } else { + // 10 degree chamber + int corr = (tp_subsector < 3) ? (tp_sector == 1 ? +5 : -1) : 0; + return tp_sector + corr; + } }; return ((endcap_ == tp_endcap) && (sector_ == get_csc_sector(tp_station, tp_ring, tp_sector, tp_subsector))); } bool PrimitiveSelection::is_in_neighbor_sector_rpc( int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const { - auto get_csc_neighbor_subsector = [](int tp_station, int tp_ring) { - // 10 degree chamber - return 2; + auto get_neighbor_subsector = [](int tp_station, int tp_ring) { + const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1); + if (is_irpc) { + // 20 degree chamber + return 1; + } else { + // 10 degree chamber + return 2; + } }; return (includeNeighbor_ && (endcap_ == tp_endcap) && (sector_ == tp_sector) && - (tp_subsector == get_csc_neighbor_subsector(tp_station, tp_ring))); + (tp_subsector == get_neighbor_subsector(tp_station, tp_ring))); } bool PrimitiveSelection::is_in_bx_rpc(int tp_bx) const { @@ -763,9 +850,22 @@ bool PrimitiveSelection::is_in_bx_rpc(int tp_bx) const { return (bx_ == tp_bx); } -int PrimitiveSelection::get_index_rpc(int tp_station, int tp_ring, int tp_subsector, bool is_neighbor) const { +int PrimitiveSelection::get_index_rpc( + int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector, int tp_bx) const { int selected = -1; + bool is_native = false; + bool is_neighbor = false; + if (is_in_bx_rpc(tp_bx)) { + if (is_in_sector_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector)) { + is_native = true; + } else if (is_in_neighbor_sector_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector)) { + is_neighbor = true; + } + } + if (!is_native && !is_neighbor) + return selected; + // CPPF RX data come in 3 frames x 64 bits, for 7 links. Each 64-bit data // carry 2 words of 32 bits. Each word carries phi (11 bits) and theta (5 bits) // of 2 segments (x2). @@ -774,33 +874,44 @@ int PrimitiveSelection::get_index_rpc(int tp_station, int tp_ring, int tp_subsec // rpc_sub [0,6] = RPC subsector 3, 4, 5, 6, 1 from neighbor, 2 from neighbor, 2. They correspond to // CSC sector phi 0-10 deg, 10-20, 20-30, 30-40, 40-50, 50-60, 50-60 from neighbor // rpc_chm [0,5] = RPC chamber RE1/2, RE2/2, RE3/2, RE3/3, RE4/2, RE4/3 + // For Phase 2, add RE1/3, RE2/3, RE3/1, RE4/1 -> rpc_chm [0,9] // int rpc_sub = -1; int rpc_chm = -1; + const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1); + if (!is_neighbor) { - rpc_sub = ((tp_subsector + 3) % 6); + if (!is_irpc) { + rpc_sub = ((tp_subsector + 3) % 6); + } else { + rpc_sub = ((tp_subsector + 1) % 3); + } } else { rpc_sub = 6; } - if (tp_station <= 2) { + if (tp_station <= 2 && tp_ring == 2) { // RE1/2, RE2/2 rpc_chm = (tp_station - 1); - } else { + } else if (tp_station >= 3 && tp_ring >= 2) { // RE3/2, RE3/3, RE4/2, RE4/3 rpc_chm = 2 + (tp_station - 3) * 2 + (tp_ring - 2); + } else if (tp_station <= 2 && tp_ring == 3) { // RE1/3, RE2/3 + rpc_chm = 6 + (tp_station - 1); + } else if (tp_station >= 3 && tp_ring == 1) { // RE3/1, RE4/1 + rpc_chm = 8 + (tp_station - 3); } - if (not(rpc_sub != -1 && rpc_chm != -1)) { - edm::LogError("L1T") << "rpc_sub = " << rpc_sub << ", rpc_chm = " << rpc_chm; - return selected; - } - - selected = (rpc_sub * 8) + rpc_chm; + selected = (rpc_sub * 10) + rpc_chm; + assert(selected != -1); return selected; } // _____________________________________________________________________________ // GEM functions +// +// According to what I know at the moment +// - GE1/1: 10 degree chamber, 8 rolls, 384 strips = 192 pads +// - GE2/1: 20 degree chamber, 8 rolls, 768 strips = 384 pads int PrimitiveSelection::select_gem(const TriggerPrimitive& muon_primitive) const { int selected = -1; @@ -817,127 +928,318 @@ int PrimitiveSelection::select_gem(const TriggerPrimitive& muon_primitive) const int tp_chamber = tp_detId.chamber(); int tp_bx = tp_data.bx; - int tp_pad = tp_data.pad; - - // Use CSC trigger sector definitions - // Code copied from DataFormats/MuonDetId/src/CSCDetId.cc - auto get_trigger_sector = [](int ring, int station, int chamber) { - int result = 0; - if (station > 1 && ring > 1) { - result = ((static_cast(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6 - } else if (station == 1 && ring != 4) { - result = ((static_cast(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6 - } else { - result = ((static_cast(chamber - 2) & 0x1f) / 3) + 1; // ch 2-4-> 1, 5-7->2, ... - } - return (result <= 6) - ? result - : 6; // max sector is 6, some calculations give a value greater than six but this is expected. - }; - - // Use CSC trigger "CSC ID" definitions - // Code copied from DataFormats/MuonDetId/src/CSCDetId.cc - auto get_trigger_csc_ID = [](int ring, int station, int chamber) { - int result = 0; - if (station == 1) { - result = (chamber) % 3 + 1; // 1,2,3 - switch (ring) { - case 1: - break; - case 2: - result += 3; // 4,5,6 - break; - case 3: - result += 6; // 7,8,9 - break; - } - } else { - if (ring == 1) { - result = (chamber + 1) % 3 + 1; // 1,2,3 - } else { - result = (chamber + 3) % 6 + 4; // 4,5,6,7,8,9 - } - } - return result; - }; + int tp_pad = ((tp_data.pad_low + tp_data.pad_hi) / 2); - int tp_sector = get_trigger_sector(tp_ring, tp_station, tp_chamber); - int tp_csc_ID = get_trigger_csc_ID(tp_ring, tp_station, tp_chamber); + int tp_sector = emtf::get_trigger_sector(tp_ring, tp_station, tp_chamber); + int tp_csc_ID = emtf::get_trigger_csc_ID(tp_ring, tp_station, tp_chamber); // station 1 --> subsector 1 or 2 // station 2,3,4 --> subsector 0 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2); - if (!(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP)) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_endcap = " << tp_endcap; - return selected; + if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once + assert_no_abort(tp_region != 0); + assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + assert_no_abort(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); + assert_no_abort(1 <= tp_station && tp_station <= 2); + assert_no_abort(tp_ring == 1); + assert_no_abort(1 <= tp_roll && tp_roll <= 8); + assert_no_abort(1 <= tp_layer && tp_layer <= 2); + assert_no_abort(1 <= tp_csc_ID && tp_csc_ID <= 3); + assert_no_abort((tp_station == 1 && 0 <= tp_pad && tp_pad <= 191) || (tp_station != 1)); + assert_no_abort((tp_station == 2 && 0 <= tp_pad && tp_pad <= 383) || (tp_station != 2)); } - if (!(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR)) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_sector = " << tp_sector; - return selected; + + // Check if the chamber belongs to this sector processor at this BX. + selected = get_index_gem(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID, tp_bx); + } + return selected; +} + +bool PrimitiveSelection::is_in_sector_gem(int tp_endcap, int tp_sector) const { + // Identical to the corresponding CSC function + return is_in_sector_csc(tp_endcap, tp_sector); +} + +bool PrimitiveSelection::is_in_neighbor_sector_gem( + int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const { + // Identical to the corresponding CSC function + return is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID); +} + +bool PrimitiveSelection::is_in_bx_gem(int tp_bx) const { + tp_bx += bxShiftGEM_; + return (bx_ == tp_bx); +} + +int PrimitiveSelection::get_index_gem( + int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const { + int selected = -1; + + bool is_native = false; + bool is_neighbor = false; + if (is_in_bx_gem(tp_bx)) { + if (is_in_sector_gem(tp_endcap, tp_sector)) { + is_native = true; + } else if (is_in_neighbor_sector_gem(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) { + is_neighbor = true; } - if (!(1 <= tp_station && tp_station <= 2)) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station; - return selected; + } + if (!is_native && !is_neighbor) + return selected; + + if (!is_neighbor) { + if (tp_station == 1) { // GE1/1: 0 - 5 + selected = (tp_subsector - 1) * 3 + (tp_csc_ID - 1); + } else { // GE2/1: 6 - 8 + selected = 6 + (tp_csc_ID - 1); } - if (!(1 <= tp_ring && tp_ring <= 1)) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_ring = " << tp_ring; - return selected; + + } else { + if (tp_station == 1) { // GE1/1n: 12 + selected = 12; + } else { // GE2/1n: 13 + selected = 13; } - if (!(1 <= tp_csc_ID && tp_csc_ID <= 9)) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_csc_ID = " << tp_csc_ID; - return selected; + } + assert(selected != -1); + return selected; +} + +// _____________________________________________________________________________ +// ME0 functions +// +// According to what I know at the moment +// - ME0: 20 degree chamber, 8 rolls, 384 strips = 192 pads +int PrimitiveSelection::select_me0(const TriggerPrimitive& muon_primitive) const { + int selected = -1; + + if (muon_primitive.subsystem() == TriggerPrimitive::kME0) { + const ME0DetId& tp_detId = muon_primitive.detId(); + const ME0Data& tp_data = muon_primitive.getME0Data(); + + int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap + int tp_endcap = (tp_region == -1) ? 2 : tp_region; + int tp_station = tp_detId.station(); + int tp_ring = 1; // tp_detId.ring() does not exist + //int tp_roll = tp_detId.roll(); + //int tp_layer = tp_detId.layer(); + int tp_chamber = tp_detId.chamber(); + + int tp_bx = tp_data.bx; + int tp_pad = tp_data.phiposition; + int tp_partition = tp_data.partition; + + // The ME0 geometry is similar to ME2/1, so I use tp_station = 2, tp_ring = 1 + // when calling get_trigger_sector() and get_trigger_csc_ID() + int tp_sector = emtf::get_trigger_sector(1, 2, tp_chamber); + int tp_csc_ID = emtf::get_trigger_csc_ID(1, 2, tp_chamber); + int tp_subsector = 0; + + if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once + assert_no_abort(tp_region != 0); + assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + assert_no_abort(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); + assert_no_abort(tp_station == 1); + assert_no_abort(tp_ring == 1); + //assert_no_abort(1 <= tp_roll && tp_roll <= 8); // not set + //assert_no_abort(1 <= tp_layer && tp_layer <= 6); // not set + assert_no_abort(1 <= tp_csc_ID && tp_csc_ID <= 3); + assert_no_abort(0 <= tp_pad && tp_pad <= 767); + assert_no_abort(0 <= tp_partition && tp_partition <= 15); } - if (!(tp_station == 1 && 1 <= tp_roll && tp_roll <= 8) || (tp_station != 1)) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station << ", tp_roll = " << tp_roll; - return selected; + + // Check if the chamber belongs to this sector processor at this BX. + selected = get_index_me0(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID, tp_pad, tp_bx); + } + return selected; +} + +bool PrimitiveSelection::is_in_sector_me0(int tp_endcap, int tp_sector, int tp_csc_ID, int tp_pad) const { + // Similar to the corresponding CSC function, but requires a 5 deg shift + // because the CSC chamber 1 starts at -5 deg, but the ME0 chamber 1 starts + // at -10 deg. + // This means that in sector 1, CSC chambers cover 15 to 75 deg, but ME0 + // chambers cover 10 to 70 deg. 5 deg (1/4 of chamber) needs to be added + // to cover 70 to 75 deg, and 5 deg needs to be subtracted from 10 to 15 deg. + auto get_other_neighbor = [](int sector) { return (sector == 6) ? 1 : sector + 1; }; + + bool add5deg = false; + bool sub5deg = false; + if (includeNeighbor_) { + if ((endcap_ == tp_endcap) && (get_other_neighbor(sector_) == tp_sector)) { + if (tp_csc_ID == 1 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber + add5deg = true; + } else if (tp_csc_ID == 1 && tp_endcap == 2 && tp_pad <= 191) { // lower 1/4 of chamber + add5deg = true; + } } - if (!(tp_station == 2 && 1 <= tp_roll && tp_roll <= 12) || (tp_station != 2)) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station << ", tp_roll = " << tp_roll; - return selected; + if ((endcap_ == tp_endcap) && (sector_ == tp_sector)) { + if (tp_csc_ID == 1 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber + sub5deg = true; + } else if (tp_csc_ID == 1 && tp_endcap == 2 && tp_pad <= 191) { // lower 1/4 of chamber + sub5deg = true; + } } - if (!(1 <= tp_layer && tp_layer <= 2)) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_layer = " << tp_layer; - return selected; + } + return (is_in_sector_csc(tp_endcap, tp_sector) && !sub5deg) || add5deg; +} + +bool PrimitiveSelection::is_in_neighbor_sector_me0(int tp_endcap, int tp_sector, int tp_csc_ID, int tp_pad) const { + // Similar to the corresponding CSC function, but requires a 5 deg shift + // because the CSC chamber 1 starts at -5 deg, but the ME0 chamber 1 starts + // at -10 deg. + // This means that in sector 1, CSC chamber from the neighbor sector + // covers -5 to 15 deg, but ME0 chamber from the neighbor sector covers + // -10 to 10 deg. 5 deg (1/4 of chamber) needs to be subtracted from + // -10 to -5 deg, and 5 deg needs to be added to cover 10 to 15 deg. + auto get_neighbor = [](int sector) { return (sector == 1) ? 6 : sector - 1; }; + + bool add5deg = false; + bool sub5deg = false; + if (includeNeighbor_) { + if ((endcap_ == tp_endcap) && (get_neighbor(sector_) == tp_sector)) { + if (tp_csc_ID == 3 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber + sub5deg = true; + } else if (tp_csc_ID == 3 && tp_endcap == 2 && tp_pad <= 191) { // lower 1/4 of chamber + sub5deg = true; + } } - if (!((tp_station == 1 && 1 <= tp_pad && tp_pad <= 192) || (tp_station != 1))) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station << ", tp_pad = " << tp_pad; - return selected; + if ((endcap_ == tp_endcap) && (sector_ == tp_sector)) { + if (tp_csc_ID == 1 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber + add5deg = true; + } else if (tp_csc_ID == 1 && tp_endcap == 2 && tp_pad <= 191) { // lower 1/4 of chamber + add5deg = true; + } } - if (!((tp_station == 2 && 1 <= tp_pad && tp_pad <= 192) || (tp_station != 2))) { - edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station << ", tp_pad = " << tp_pad; - return selected; + } + // (Note: use tp_subsector = 0, tp_station = 2) + return (is_in_neighbor_sector_csc(tp_endcap, tp_sector, 0, 2, tp_csc_ID) && !sub5deg) || add5deg; +} + +bool PrimitiveSelection::is_in_bx_me0(int tp_bx) const { + tp_bx += bxShiftME0_; + return (bx_ == tp_bx); +} + +int PrimitiveSelection::get_index_me0( + int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_pad, int tp_bx) const { + int selected = -1; + + bool is_native = false; + bool is_neighbor = false; + if (is_in_bx_me0(tp_bx)) { + if (is_in_sector_me0(tp_endcap, tp_sector, tp_csc_ID, tp_pad)) { + is_native = true; + } else if (is_in_neighbor_sector_me0(tp_endcap, tp_sector, tp_csc_ID, tp_pad)) { + is_neighbor = true; } + } + if (!is_native && !is_neighbor) + return selected; - // Selection - if (is_in_bx_gem(tp_bx)) { - if (is_in_sector_gem(tp_endcap, tp_sector)) { - selected = get_index_gem(tp_subsector, tp_station, tp_csc_ID, false); - } else if (is_in_neighbor_sector_gem(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) { - selected = get_index_gem(tp_subsector, tp_station, tp_csc_ID, true); - } + if (!is_neighbor) { // ME0: 9 - 11 + selected = 9 + (tp_csc_ID - 1); + } else { // ME0n: 14 + selected = 14; + } + assert(selected != -1); + return selected; +} + +// _____________________________________________________________________________ +// DT functions +int PrimitiveSelection::select_dt(const TriggerPrimitive& muon_primitive) const { + int selected = -1; + + if (muon_primitive.subsystem() == TriggerPrimitive::kDT) { + const DTChamberId& tp_detId = muon_primitive.detId(); + const DTData& tp_data = muon_primitive.getDTData(); + + int tp_wheel = tp_detId.wheel(); + int tp_station = tp_detId.station(); + int tp_sector = tp_detId.sector(); // sectors are 1-12, starting at phi=0 and increasing with phi + + // In station 4, where the top and bottom sectors are made of two chambers, + // two additional sector numbers are used, 13 (after sector 4, top) + // and 14 (after sector 10, bottom). + if (tp_station == 4) { + if (tp_sector == 13) + tp_sector = 4; + else if (tp_sector == 14) + tp_sector = 10; } + + int tp_bx = tp_data.bx; + int tp_phi = tp_data.radialAngle; + //int tp_phiB = tp_data.bendingAngle; + + // Mimic 10 deg CSC chamber. I use tp_station = 2, tp_ring = 2 + // when calling get_trigger_sector() and get_trigger_csc_ID() + int tp_chamber = + tp_sector * 3 - 1; // DT chambers are 30 deg. Multiply sector number by 3 to mimic 10 deg CSC chamber number + int tp_endcap = (tp_wheel > 0) ? 1 : ((tp_wheel < 0) ? 2 : 0); + int csc_tp_sector = emtf::get_trigger_sector(2, 2, tp_chamber); + int tp_csc_ID = emtf::get_trigger_csc_ID(2, 2, tp_chamber); + int tp_subsector = 0; + + if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once + //assert_no_abort(-2 <= tp_wheel && tp_wheel <= +2); + assert_no_abort(tp_wheel == -2 || tp_wheel == +2); // do not include wheels -1, 0, +1 + //assert_no_abort(1 <= tp_station && tp_station <= 4); + assert_no_abort(1 <= tp_station && tp_station <= 3); // do not include MB4 + assert_no_abort(1 <= tp_sector && tp_sector <= 12); + assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + assert_no_abort(emtf::MIN_TRIGSECTOR <= csc_tp_sector && csc_tp_sector <= emtf::MAX_TRIGSECTOR); + //assert_no_abort(4 <= tp_csc_ID && tp_csc_ID <= 9); + assert_no_abort(tp_csc_ID == 6 || tp_csc_ID == 9); + assert_no_abort(-2048 <= tp_phi && tp_phi <= 2047); // 12-bit + //assert_no_abort(-512 <= tp_phiB && tp_phiB <= 511); // 10-bit + } + + // Check if the chamber belongs to this sector processor at this BX. + selected = get_index_dt(tp_endcap, csc_tp_sector, tp_subsector, tp_station, tp_csc_ID, tp_bx); } return selected; } -bool PrimitiveSelection::is_in_sector_gem(int tp_endcap, int tp_sector) const { +bool PrimitiveSelection::is_in_sector_dt(int tp_endcap, int tp_sector) const { // Identical to the corresponding CSC function return is_in_sector_csc(tp_endcap, tp_sector); } -bool PrimitiveSelection::is_in_neighbor_sector_gem( - int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const { +bool PrimitiveSelection::is_in_neighbor_sector_dt(int tp_endcap, int tp_sector, int tp_csc_ID) const { // Identical to the corresponding CSC function - return is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID); + // (Note: use tp_subsector = 0, tp_station = 2) + return is_in_neighbor_sector_csc(tp_endcap, tp_sector, 0, 2, tp_csc_ID); } -bool PrimitiveSelection::is_in_bx_gem(int tp_bx) const { - tp_bx += bxShiftGEM_; +bool PrimitiveSelection::is_in_bx_dt(int tp_bx) const { + //tp_bx += bxShiftDT_; return (bx_ == tp_bx); } -int PrimitiveSelection::get_index_gem(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const { - // Identical to the corresponding CSC function - return get_index_csc(tp_subsector, tp_station, tp_csc_ID, is_neighbor); +int PrimitiveSelection::get_index_dt( + int tp_endcap, int csc_tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const { + int selected = -1; + + bool is_native = false; + bool is_neighbor = false; + if (is_in_bx_dt(tp_bx)) { + if (is_in_sector_dt(tp_endcap, csc_tp_sector)) { + is_native = true; + } else if (is_in_neighbor_sector_dt(tp_endcap, csc_tp_sector, tp_csc_ID)) { + is_neighbor = true; + } + } + if (!is_native && !is_neighbor) + return selected; + + if (!is_neighbor) { // MB1,2,3,4: 0-7 + selected = (tp_station - 1) * 2 + (tp_csc_ID - 6) / 3; // tp_csc_ID should be either 6 or 9 + } else { // ME1,2,3,4n: 8-11 + selected = 8 + (tp_station - 1); + } + assert(selected != -1); + return selected; } diff --git a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc index 292705fd81422..ac3c82b57c12e 100644 --- a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc @@ -543,13 +543,13 @@ void SectorProcessor::process_single_bx(int bx, // Put them into maps with an index that roughly corresponds to // each input link. // From src/PrimitiveSelection.cc - //prim_sel.process(emtf::DTTag(), muon_primitives, selected_dt_map); //FIXME + prim_sel.process(emtf::DTTag(), muon_primitives, selected_dt_map); prim_sel.process(emtf::CSCTag(), muon_primitives, selected_csc_map); if (useRPC_) { //FIXME prim_sel.process(emtf::RPCTag(), muon_primitives, selected_rpc_map); } prim_sel.process(emtf::GEMTag(), muon_primitives, selected_gem_map); - //prim_sel.process(emtf::ME0Tag(), muon_primitives, selected_me0_map); //FIXME + prim_sel.process(emtf::ME0Tag(), muon_primitives, selected_me0_map); prim_sel.merge( selected_dt_map, selected_csc_map, selected_rpc_map, selected_gem_map, selected_me0_map, selected_prim_map); From c685633df4289676d3ba8f08bcd329448de709ea Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 12:03:01 -0400 Subject: [PATCH 15/34] [EMTF] Update PrimitiveSelection & PrimitiveConversion 2/4 --- .../interface/PrimitiveConversion.h | 22 +- .../L1TMuonEndCap/src/PrimitiveConversion.cc | 594 ++++++++++++------ 2 files changed, 415 insertions(+), 201 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h b/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h index 0d8f1f9793040..04d38c5210b4d 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h +++ b/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h @@ -37,7 +37,7 @@ class PrimitiveConversion { const TriggerPrimitive& muon_primitive, EMTFHit& conv_hit) const; - void convert_csc_details(EMTFHit& conv_hit) const; + void convert_csc_details(EMTFHit& conv_hit) const; // with specific firmware impl // RPC functions void convert_rpc(int pc_sector, @@ -47,7 +47,7 @@ class PrimitiveConversion { const TriggerPrimitive& muon_primitive, EMTFHit& conv_hit) const; - void convert_rpc_details(EMTFHit& conv_hit, const bool use_cppf_lut) const; + void convert_rpc_details(EMTFHit& conv_hit, bool isCPPF) const; // with specific firmware impl // GEM functions void convert_gem(int pc_sector, @@ -57,7 +57,23 @@ class PrimitiveConversion { const TriggerPrimitive& muon_primitive, EMTFHit& conv_hit) const; - void convert_gem_details(EMTFHit& conv_hit) const; + void convert_other_details(EMTFHit& conv_hit) const; // no firmware impl + + // ME0 functions + void convert_me0(int pc_sector, + int pc_station, + int pc_chamber, + int pc_segment, + const TriggerPrimitive& muon_primitive, + EMTFHit& conv_hit) const; + + // DT functions + void convert_dt(int pc_sector, + int pc_station, + int pc_chamber, + int pc_segment, + const TriggerPrimitive& muon_primitive, + EMTFHit& conv_hit) const; // Aux functions int get_zone_code(const EMTFHit& conv_hit, int th) const; diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc index 5c8d1cb29ae71..b553edb1e61e2 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc @@ -1,12 +1,9 @@ #include "L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h" -#include "DataFormats/MuonDetId/interface/DTChamberId.h" -#include "DataFormats/MuonDetId/interface/CSCDetId.h" -#include "DataFormats/MuonDetId/interface/RPCDetId.h" -#include "DataFormats/MuonDetId/interface/GEMDetId.h" - -#include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" #include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h" +#include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" + +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" // for special treatments for iRPC void PrimitiveConversion::configure(const GeometryTranslator* tp_geom, const SectorProcessorLUT* lut, @@ -25,14 +22,8 @@ void PrimitiveConversion::configure(const GeometryTranslator* tp_geom, bool useNewZones, bool fixME11Edges, bool bugME11Dupes) { - if (not(tp_geom != nullptr)) { - edm::LogError("L1T") << "tp_geom = " << tp_geom; - return; - } - if (not(lut != nullptr)) { - edm::LogError("L1T") << "lut = " << lut; - return; - } + assert(tp_geom != nullptr); + assert(lut != nullptr); tp_geom_ = tp_geom; lut_ = lut; @@ -80,12 +71,13 @@ void PrimitiveConversion::process(const std::mapsubsystem() == TriggerPrimitive::kRPC) { convert_rpc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit); } else if (tp_it->subsystem() == TriggerPrimitive::kGEM) { - convert_gem(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit); + convert_gem(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit); // pc_station and pc_chamber are meaningless + } else if (tp_it->subsystem() == TriggerPrimitive::kME0) { + convert_me0(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit); // pc_station and pc_chamber are meaningless + } else if (tp_it->subsystem() == TriggerPrimitive::kDT) { + convert_dt(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit); // pc_station and pc_chamber are meaningless } else { - if (not(false && "Incorrect subsystem type")) { - edm::LogError("L1T") << "Incorrect subsystem type"; - return; - } + assert(false && "Incorrect subsystem type"); } conv_hits.push_back(conv_hit); pc_segment += 1; @@ -128,16 +120,15 @@ void PrimitiveConversion::convert_csc(int pc_sector, csc_nID += 1; if (tp_station == 1) { // neighbor ME1 - if (not(tp_subsector == 2)) { - edm::LogError("L1T") << "tp_subsector = " << tp_subsector; - return; - } + assert(tp_subsector == 2); } } // Set properties conv_hit.SetCSCDetId(tp_detId); + conv_hit.set_bx(tp_bx + bxShiftCSC_); + conv_hit.set_subsystem(TriggerPrimitive::kCSC); conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap); conv_hit.set_station(tp_station); conv_hit.set_ring(tp_ring); @@ -152,9 +143,6 @@ void PrimitiveConversion::convert_csc(int pc_sector, //conv_hit.set_sector_RPC ( tp_sector ); //conv_hit.set_subsector_RPC ( tp_subsector ); - conv_hit.set_bx(tp_bx + bxShiftCSC_); - conv_hit.set_subsystem(TriggerPrimitive::kCSC); - conv_hit.set_pc_sector(pc_sector); conv_hit.set_pc_station(pc_station); conv_hit.set_pc_chamber(pc_chamber); @@ -168,7 +156,7 @@ void PrimitiveConversion::convert_csc(int pc_sector, conv_hit.set_quality(tp_data.quality); conv_hit.set_pattern(tp_data.pattern); conv_hit.set_bend(tp_data.bend); - //conv_hit.set_time ( tp_data.time ); + conv_hit.set_time(0.); // No fine resolution timing conv_hit.set_alct_quality(tp_data.alct_quality); conv_hit.set_clct_quality(tp_data.clct_quality); @@ -224,7 +212,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { // Is this chamber mounted in reverse direction? // (i.e., phi vs. strip number is reversed) bool ph_reverse = false; - if ((fw_endcap == 0 && fw_station >= 3) || (fw_endcap == 1 && fw_station < 3)) + if ((fw_endcap == 0 && fw_station >= 3) || (fw_endcap == 1 && fw_station < 3)) // ME+3, ME+4, ME-1, ME-2 ph_reverse = true; // Chamber coverage if phi_reverse = true @@ -270,10 +258,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { } else if (pc_station == 5 && pc_chamber < 9) { // neighbor ME4: 59 - 60 pc_lut_id += 50 + 9 - 7; } - if (not(pc_lut_id < 61)) { - edm::LogError("L1T") << "pc_lut_id = " << pc_lut_id; - return; - } + assert(pc_lut_id < 61); if (verbose_ > 1) { // debug std::cout << "pc_station: " << pc_station << " pc_chamber: " << pc_chamber << " fw_station: " << fw_station @@ -307,13 +292,20 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { eighth_strip = fw_strip << 3; // multiply by 2, uses all 3 bits of pattern correction eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 0); } - if (not(bugStrip0BeforeFW48200 == true || eighth_strip >= 0)) { - edm::LogError("L1T") << "bugStrip0BeforeFW48200 = " << bugStrip0BeforeFW48200 - << ", eighth_strip = " << eighth_strip; - return; - } + assert(bugStrip0BeforeFW48200 == true || eighth_strip >= 0); // Multiplicative factor for eighth_strip + // +----------------------------+-------------+------------------+ + // | Chamber type | Strip angle | Mult factor | + // | | (deg) | | + // +----------------------------+-------------+------------------+ + // | ME1/2, ME2/2, ME3/2, ME4/2 | 0.1333 | 1/2 (remove LSB) | + // | ME2/1, ME3/1, ME4/1 | 0.2666 | 1 (no op) | + // | ME1/1a | 0.2222 | 0.8335 | + // | ME1/1b | 0.1695 | 0.636 | + // | ME1/3 | 0.1233 | 0.4625 | + // +----------------------------+-------------+------------------+ + int factor = 1024; if (is_me11a) factor = 1707; // ME1/1a @@ -354,14 +346,8 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { if (fixZonePhi_) zone_hit = zone_hit_fixed; - if (not(0 <= fph && fph < 5000)) { - edm::LogError("L1T") << "fph = " << fph; - return; - } - if (not(0 <= zone_hit && zone_hit < 192)) { - edm::LogError("L1T") << "zone_hit = " << zone_hit; - return; - } + assert(0 <= fph && fph < 5000); + assert(0 <= zone_hit && zone_hit < 192); // ___________________________________________________________________________ // theta conversion @@ -422,10 +408,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { int th = lut().get_th_init(fw_endcap, fw_sector, pc_lut_id); th = th + th_tmp; - if (not(0 <= th && th < 128)) { - edm::LogError("L1T") << "th = " << th; - return; - } + assert(0 <= th && th < 128); th = (th == 0) ? 1 : th; // protect against invalid value // ___________________________________________________________________________ @@ -433,7 +416,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { //int zone_hit = ((fph + (1<<4)) >> 5); int zone_code = get_zone_code(conv_hit, th); - //int phzvl = get_phzvl(conv_hit, zone_code); + //int phzvl = get_phzvl(conv_hit, zone_code); int fs_zone_code = get_fs_zone_code(conv_hit); int fs_segment = get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment); @@ -444,10 +427,10 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { // ___________________________________________________________________________ // Output - conv_hit.set_phi_fp(fph); // Full-precision integer phi - conv_hit.set_theta_fp(th); // Full-precision integer theta - //conv_hit.set_phzvl(phzvl); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging - //conv_hit.set_ph_hit(ph_hit); // Intermediate quantity in phi calculation - used in FW debugging + conv_hit.set_phi_fp(fph); // Full-precision integer phi + conv_hit.set_theta_fp(th); // Full-precision integer theta + //conv_hit.set_phzvl ( phzvl ); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging + //conv_hit.set_ph_hit ( ph_hit ); // Intermediate quantity in phi calculation - used in FW debugging conv_hit.set_zone_hit(zone_hit); // Phi value for building patterns (0.53333 deg precision) conv_hit.set_zone_code(zone_code); // Full zone word: 1*(zone 0) + 2*(zone 1) + 4*(zone 2) + 8*(zone 3) @@ -485,18 +468,43 @@ void PrimitiveConversion::convert_rpc(int pc_sector, int tp_bx = tp_data.bx; int tp_strip = ((tp_data.strip_low + tp_data.strip_hi) / 2); // in full-strip unit - int tp_valid = tp_data.valid; const bool is_neighbor = (pc_station == 5); // CSC-like sector, subsector and chamber numbers int csc_tp_chamber = (tp_sector - 1) * 6 + tp_subsector; int csc_tp_sector = (tp_subsector > 2) ? tp_sector : ((tp_sector + 4) % 6) + 1; // Rotate by 20 deg - int csc_tp_subsector = ((tp_subsector + 3) % 6) + 1; // Rotate by 2 + int csc_tp_subsector = (tp_station != 1) ? 0 : ((csc_tp_chamber % 6 > 2) ? 1 : 2); + + const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1); + if (is_irpc) { + csc_tp_chamber = (tp_sector - 1) * 3 + tp_subsector; + csc_tp_sector = (tp_subsector > 1) ? tp_sector : ((tp_sector + 4) % 6) + 1; // Rotate by 20 deg + csc_tp_subsector = (tp_station != 1) ? 0 : ((csc_tp_chamber % 6 > 2) ? 1 : 2); + } + int tp_csc_ID = emtf::get_trigger_csc_ID(tp_ring, tp_station, csc_tp_chamber); + + int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector + if (is_neighbor) { + // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3 + // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore) + // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2 + csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9); + csc_nID += 1; + } + + // Use cluster width as 'quality' + int tp_quality = (tp_data.strip_hi - tp_data.strip_low + 1); + if (!is_irpc) { + tp_quality *= 3; // old RPC strip pitch is 1.5 times the new iRPC + tp_quality /= 2; + } // Set properties conv_hit.SetRPCDetId(tp_detId); + conv_hit.set_bx(tp_bx + bxShiftRPC_); + conv_hit.set_subsystem(TriggerPrimitive::kRPC); conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap); conv_hit.set_station(tp_station); conv_hit.set_ring(tp_ring); @@ -504,27 +512,24 @@ void PrimitiveConversion::convert_rpc(int pc_sector, conv_hit.set_chamber(csc_tp_chamber); conv_hit.set_sector(csc_tp_sector); conv_hit.set_subsector(csc_tp_subsector); - //conv_hit.set_csc_ID ( tp_csc_ID ); - //conv_hit.set_csc_nID ( csc_nID ); + conv_hit.set_csc_ID(tp_csc_ID); + conv_hit.set_csc_nID(csc_nID); //conv_hit.set_track_num ( tp_data.trknmb ); //conv_hit.set_sync_err ( tp_data.syncErr ); conv_hit.set_sector_RPC(tp_sector); // In RPC convention in CMSSW (RPCDetId.h), sector 1 starts at -5 deg conv_hit.set_subsector_RPC(tp_subsector); - conv_hit.set_bx(tp_bx + bxShiftRPC_); - conv_hit.set_subsystem(TriggerPrimitive::kRPC); - conv_hit.set_pc_sector(pc_sector); conv_hit.set_pc_station(pc_station); conv_hit.set_pc_chamber(pc_chamber); conv_hit.set_pc_segment(pc_segment); - conv_hit.set_valid(tp_valid); + conv_hit.set_valid(tp_data.valid); conv_hit.set_strip(tp_strip); conv_hit.set_strip_low(tp_data.strip_low); conv_hit.set_strip_hi(tp_data.strip_hi); //conv_hit.set_wire ( tp_data.keywire ); - //conv_hit.set_quality ( tp_data.quality ); + conv_hit.set_quality(tp_quality); conv_hit.set_pattern(0); // In firmware, this marks RPC stub //conv_hit.set_bend ( tp_data.bend ); conv_hit.set_time(tp_data.time); @@ -558,23 +563,32 @@ void PrimitiveConversion::convert_rpc(int pc_sector, int fph = emtf::calc_phi_loc_int_rpc(glob_phi, conv_hit.PC_sector()); int th = emtf::calc_theta_int_rpc(glob_theta, conv_hit.Endcap()); - if (not(0 <= fph && fph < 1250)) { - edm::LogError("L1T") << "fph = " << fph; - return; - } - if (not(0 <= th && th < 32)) { - edm::LogError("L1T") << "th = " << th; - return; - } - if (not(th != 0b11111)) // RPC hit valid when data is not all ones - { - edm::LogError("L1T") << "th = " << th; - return; - } + //assert(0 <= fph && fph < 1024); + assert(0 <= fph && fph < 1250); + assert(0 <= th && th < 32); + assert(th != 0b11111); // RPC hit valid when data is not all ones fph <<= 2; // upgrade to full CSC precision by adding 2 zeros th <<= 2; // upgrade to full CSC precision by adding 2 zeros th = (th == 0) ? 1 : th; // protect against invalid value + if (is_irpc) { + const RPCRoll* roll = dynamic_cast(tp_geom_->getRPCGeometry().roll(tp_detId)); + assert(roll != nullptr); // failed to get RPC roll + const GlobalPoint& new_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0)); + glob_phi = emtf::rad_to_deg(gp.phi().value()); // using 'gp' instead of 'new_gp' for phi + glob_theta = emtf::rad_to_deg(new_gp.theta()); + glob_eta = new_gp.eta(); + glob_rho = new_gp.perp(); + glob_z = new_gp.z(); + + fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector()); + th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap()); + + assert(0 <= fph && fph < 5000); + assert(0 <= th && th < 128); + th = (th == 0) ? 1 : th; // protect against invalid value + } + // _________________________________________________________________________ // Output @@ -588,10 +602,10 @@ void PrimitiveConversion::convert_rpc(int pc_sector, conv_hit.set_theta_fp(th); // Full-precision integer theta } - convert_rpc_details(conv_hit, (tp_data.isCPPF == false)); + convert_rpc_details(conv_hit, tp_data.isCPPF); } -void PrimitiveConversion::convert_rpc_details(EMTFHit& conv_hit, const bool use_cppf_lut) const { +void PrimitiveConversion::convert_rpc_details(EMTFHit& conv_hit, bool isCPPF) const { const bool is_neighbor = conv_hit.Neighbor(); const int pc_station = conv_hit.PC_station(); @@ -601,29 +615,17 @@ void PrimitiveConversion::convert_rpc_details(EMTFHit& conv_hit, const bool use_ //const int fw_endcap = (endcap_-1); //const int fw_sector = (sector_-1); const int fw_station = (conv_hit.Station() == 1) ? (is_neighbor ? 0 : pc_station) : conv_hit.Station(); - - int fw_cscid = pc_chamber; - if (is_neighbor) { - int csc_nID = -1; - - // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3 - // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore) - // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2 - csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9); - csc_nID += 1; - - fw_cscid = csc_nID - 1; - } + const int fw_cscid = (conv_hit.CSC_nID() - 1); int fph = conv_hit.Phi_fp(); int th = conv_hit.Theta_fp(); + // Do coordinate conversion using the CPPF LUTs. Not needed if the received digis are CPPF digis. + bool use_cppf_lut = !isCPPF; + if (use_cppf_lut) { int halfstrip = (conv_hit.Strip_low() + conv_hit.Strip_hi() - 1); - if (not(1 <= halfstrip && halfstrip <= 64)) { - edm::LogError("L1T") << "halfstrip = " << halfstrip; - return; - } + assert(1 <= halfstrip && halfstrip <= 64); int fph2 = lut().get_cppf_ph_lut(conv_hit.Endcap(), conv_hit.Sector_RPC(), @@ -639,22 +641,15 @@ void PrimitiveConversion::convert_rpc_details(EMTFHit& conv_hit, const bool use_ conv_hit.Ring(), conv_hit.Subsector_RPC(), conv_hit.Roll()); + //assert(abs((fph>>2) - fph2) <= 4); // arbitrary tolerance + //assert(abs((th>>2) - th2) <= 1); // arbitrary tolerance fph = fph2; th = th2; - if (not(0 <= fph && fph < 1250)) { - edm::LogError("L1T") << "fph = " << fph; - return; - } - if (not(0 <= th && th < 32)) { - edm::LogError("L1T") << "th = " << th; - return; - } - if (not(th != 0b11111)) // RPC hit valid when data is not all ones - { - edm::LogError("L1T") << "th = " << th; - return; - } + //assert(0 <= fph && fph < 1024); + assert(0 <= fph && fph < 1250); + assert(0 <= th && th < 32); + assert(th != 0b11111); // RPC hit valid when data is not all ones fph <<= 2; // upgrade to full CSC precision by adding 2 zeros th <<= 2; // upgrade to full CSC precision by adding 2 zeros th = (th == 0) ? 1 : th; // protect against invalid value @@ -722,76 +717,37 @@ void PrimitiveConversion::convert_gem(int pc_sector, int tp_chamber = tp_detId.chamber(); int tp_bx = tp_data.bx; - int tp_strip = ((tp_data.pad_low + tp_data.pad_hi) / 2); // in full-strip unit - - // Use CSC trigger sector definitions - // Code copied from DataFormats/MuonDetId/src/CSCDetId.cc - auto get_trigger_sector = [](int ring, int station, int chamber) { - int result = 0; - if (station > 1 && ring > 1) { - result = ((static_cast(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6 - } else { - result = (station != 1) ? ((static_cast(chamber - 2) & 0x1f) / 3) + 1 : // ch 2-4-> 1, 5-7->2, ... - ((static_cast(chamber - 3) & 0x7f) / 6) + 1; - } - return (result <= 6) ? result - : 6; // max sector is 6, some calculations give a value greater than six but this is expected. - }; + int tp_pad = ((tp_data.pad_low + tp_data.pad_hi) / 2); - // Use CSC trigger "CSC ID" definitions - // Code copied from DataFormats/MuonDetId/src/CSCDetId.cc - auto get_trigger_csc_ID = [](int ring, int station, int chamber) { - int result = 0; - if (station == 1) { - result = (chamber) % 3 + 1; // 1,2,3 - switch (ring) { - case 1: - break; - case 2: - result += 3; // 4,5,6 - break; - case 3: - result += 6; // 7,8,9 - break; - } - } else { - if (ring == 1) { - result = (chamber + 1) % 3 + 1; // 1,2,3 - } else { - result = (chamber + 3) % 6 + 4; // 4,5,6,7,8,9 - } - } - return result; - }; - - int tp_sector = get_trigger_sector(tp_ring, tp_station, tp_chamber); - int tp_csc_ID = get_trigger_csc_ID(tp_ring, tp_station, tp_chamber); + int tp_sector = emtf::get_trigger_sector(tp_ring, tp_station, tp_chamber); + int tp_csc_ID = emtf::get_trigger_csc_ID(tp_ring, tp_station, tp_chamber); // station 1 --> subsector 1 or 2 // station 2,3,4 --> subsector 0 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2); - const bool is_neighbor = (pc_station == 5); + const bool is_neighbor = (pc_chamber == 12 || pc_chamber == 13); int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector if (is_neighbor) { // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3 // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore) // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2 - csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9); - csc_nID += 1; - - if (tp_station == 1) { // neighbor ME1 - if (not(tp_subsector == 2)) { - edm::LogError("L1T") << "tp_subsector = " << tp_subsector; - return; - } + if (tp_station == 1) { + csc_nID = 13; + } else { + csc_nID = 10; } } + // Use cluster width as 'quality' + int tp_quality = (tp_data.pad_hi - tp_data.pad_low + 1); + // Set properties - //conv_hit.SetGEMDetId ( tp_detId ); // Temporarily disable, caused compile error - AWB 12.04.2018 + conv_hit.SetGEMDetId(tp_detId); + conv_hit.set_bx(tp_bx + bxShiftGEM_); + conv_hit.set_subsystem(TriggerPrimitive::kGEM); conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap); conv_hit.set_station(tp_station); conv_hit.set_ring(tp_ring); @@ -806,23 +762,20 @@ void PrimitiveConversion::convert_gem(int pc_sector, //conv_hit.set_sector_RPC ( tp_sector ); //conv_hit.set_subsector_RPC ( tp_subsector ); - conv_hit.set_bx(tp_bx + bxShiftGEM_); - conv_hit.set_subsystem(TriggerPrimitive::kGEM); - conv_hit.set_pc_sector(pc_sector); conv_hit.set_pc_station(pc_station); conv_hit.set_pc_chamber(pc_chamber); conv_hit.set_pc_segment(pc_segment); conv_hit.set_valid(true); - conv_hit.set_strip(tp_strip); + conv_hit.set_strip(tp_pad); conv_hit.set_strip_low(tp_data.pad_low); conv_hit.set_strip_hi(tp_data.pad_hi); //conv_hit.set_wire ( tp_data.keywire ); - //conv_hit.set_quality ( tp_data.quality ); - conv_hit.set_pattern(1); // In firmware, this marks GEM stub (unconfirmed!) - //conv_hit.set_bend(tp_data.bend); - //conv_hit.set_time ( tp_data.time ); + conv_hit.set_quality(tp_quality); + conv_hit.set_pattern(0); // arbitrary + //conv_hit.set_bend ( tp_data.bend ); + conv_hit.set_time(0.); // No fine resolution timing //conv_hit.set_alct_quality ( tp_data.alct_quality ); //conv_hit.set_clct_quality ( tp_data.clct_quality ); @@ -843,14 +796,8 @@ void PrimitiveConversion::convert_gem(int pc_sector, int fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector()); int th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap()); - if (not(0 <= fph && fph < 5000)) { - edm::LogError("L1T") << "fph = " << fph; - return; - } - if (not(0 <= th && th < 128)) { - edm::LogError("L1T") << "th = " << th; - return; - } + assert(0 <= fph && fph < 5000); + assert(0 <= th && th < 128); th = (th == 0) ? 1 : th; // protect against invalid value // _________________________________________________________________________ @@ -866,10 +813,10 @@ void PrimitiveConversion::convert_gem(int pc_sector, conv_hit.set_theta_fp(th); // Full-precision integer theta } - convert_gem_details(conv_hit); + convert_other_details(conv_hit); } -void PrimitiveConversion::convert_gem_details(EMTFHit& conv_hit) const { +void PrimitiveConversion::convert_other_details(EMTFHit& conv_hit) const { const bool is_neighbor = conv_hit.Neighbor(); const int pc_station = conv_hit.PC_station(); @@ -927,6 +874,260 @@ void PrimitiveConversion::convert_gem_details(EMTFHit& conv_hit) const { conv_hit.set_eta(emtf::calc_eta_from_theta_deg(conv_hit.Theta(), conv_hit.Endcap())); } +// _____________________________________________________________________________ +// ME0 functions +void PrimitiveConversion::convert_me0(int pc_sector, + int pc_station, + int pc_chamber, + int pc_segment, + const TriggerPrimitive& muon_primitive, + EMTFHit& conv_hit) const { + const ME0DetId& tp_detId = muon_primitive.detId(); + const ME0Data& tp_data = muon_primitive.getME0Data(); + + int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap + int tp_endcap = (tp_region == -1) ? 2 : tp_region; + int tp_station = tp_detId.station(); + int tp_ring = 1; // tp_detId.ring() does not exist + //int tp_roll = tp_detId.roll(); + //int tp_layer = tp_detId.layer(); + int tp_chamber = tp_detId.chamber(); + + int tp_bx = tp_data.bx; + int tp_pad = tp_data.phiposition; + int tp_partition = tp_data.partition; + + // The ME0 geometry is similar to ME2/1, so I use tp_station = 2, tp_ring = 1 + // when calling get_trigger_sector() and get_trigger_csc_ID() + int tp_sector = emtf::get_trigger_sector(1, 2, tp_chamber); + int tp_csc_ID = emtf::get_trigger_csc_ID(1, 2, tp_chamber); + int tp_subsector = 0; + + const bool is_neighbor = (pc_chamber == 14); + + int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector + if (is_neighbor) { + // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3 + // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore) + // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2 + csc_nID = 10; + } + + // Set properties + conv_hit.SetME0DetId(tp_detId); + + conv_hit.set_bx(tp_bx + bxShiftME0_); + conv_hit.set_subsystem(TriggerPrimitive::kME0); + conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap); + conv_hit.set_station(tp_station); + conv_hit.set_ring(tp_ring); + conv_hit.set_roll(tp_partition); + conv_hit.set_chamber(tp_chamber); + conv_hit.set_sector(tp_sector); + conv_hit.set_subsector(tp_subsector); + conv_hit.set_csc_ID(tp_csc_ID); + conv_hit.set_csc_nID(csc_nID); + //conv_hit.set_track_num ( tp_data.trknmb ); + //conv_hit.set_sync_err ( tp_data.syncErr ); + //conv_hit.set_sector_RPC ( tp_sector ); + //conv_hit.set_subsector_RPC ( tp_subsector ); + + conv_hit.set_pc_sector(pc_sector); + conv_hit.set_pc_station(pc_station); + conv_hit.set_pc_chamber(pc_chamber); + conv_hit.set_pc_segment(pc_segment); + + conv_hit.set_valid(true); + conv_hit.set_strip(tp_pad); + //conv_hit.set_strip_low ( tp_strip ); + //conv_hit.set_strip_hi ( tp_strip ); + //conv_hit.set_wire ( tp_data.keywire ); + conv_hit.set_quality(tp_data.quality); + conv_hit.set_pattern(0); // arbitrary + conv_hit.set_bend(tp_data.deltaphi * (tp_data.bend == 0 ? 1 : -1)); + conv_hit.set_time(0.); // No fine resolution timing + //conv_hit.set_alct_quality ( tp_data.alct_quality ); + //conv_hit.set_clct_quality ( tp_data.clct_quality ); + + conv_hit.set_neighbor(is_neighbor); + conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5); + + // Get coordinates from fullsim since LUTs do not exist yet + bool use_fullsim_coords = true; + if (use_fullsim_coords) { + const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive); + double glob_phi = emtf::rad_to_deg(gp.phi().value()); + double glob_theta = emtf::rad_to_deg(gp.theta()); + double glob_eta = gp.eta(); + double glob_rho = gp.perp(); + double glob_z = gp.z(); + + // Use the CSC precision (unconfirmed!) + int fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector()); + int th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap()); + + bool fix_me0_theta_edge = true; + if (fix_me0_theta_edge) { + // The ME0 extends to eta of 2.8 or theta of 7.0 deg. But integer theta + // only starts at theta of 8.5 deg. + if (th < 0) + th = 0; + } + + assert(0 <= fph && fph < 5000); + assert(0 <= th && th < 128); + th = (th == 0) ? 1 : th; // protect against invalid value + + // _________________________________________________________________________ + // Output + + conv_hit.set_phi_sim(glob_phi); + conv_hit.set_theta_sim(glob_theta); + conv_hit.set_eta_sim(glob_eta); + conv_hit.set_rho_sim(glob_rho); + conv_hit.set_z_sim(glob_z); + + conv_hit.set_phi_fp(fph); // Full-precision integer phi + conv_hit.set_theta_fp(th); // Full-precision integer theta + } + + convert_other_details(conv_hit); +} + +// _____________________________________________________________________________ +// DT functions +void PrimitiveConversion::convert_dt(int pc_sector, + int pc_station, + int pc_chamber, + int pc_segment, + const TriggerPrimitive& muon_primitive, + EMTFHit& conv_hit) const { + const DTChamberId& tp_detId = muon_primitive.detId(); + const DTData& tp_data = muon_primitive.getDTData(); + + int tp_wheel = tp_detId.wheel(); + int tp_station = tp_detId.station(); + int tp_sector = tp_detId.sector(); // sectors are 1-12, starting at phi=0 and increasing with phi + + // In station 4, where the top and bottom setcors are made of two chambers, + // two additional sector numbers are used, 13 (after sector 4, top) + // and 14 (after sector 10, bottom). + if (tp_station == 4) { + if (tp_sector == 13) + tp_sector = 4; + else if (tp_sector == 14) + tp_sector = 10; + } + + int tp_bx = tp_data.bx; + int tp_phi = tp_data.radialAngle; + int tp_phiB = tp_data.bendingAngle; + + // Mimic 10 deg CSC chamber. I use tp_station = 2, tp_ring = 2 + // when calling get_trigger_sector() and get_trigger_csc_ID() + int tp_chamber = + tp_sector * 3 - 1; // DT chambers are 30 deg. Multiply sector number by 3 to mimic 10 deg CSC chamber number + int tp_endcap = (tp_wheel > 0) ? +1 : ((tp_wheel < 0) ? 2 : 0); + int csc_tp_sector = emtf::get_trigger_sector(2, 2, tp_chamber); + int tp_csc_ID = emtf::get_trigger_csc_ID(2, 2, tp_chamber); + int tp_subsector = 0; + + const bool is_neighbor = (pc_chamber >= 8); + + int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector + if (is_neighbor) { + // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3 + // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore) + // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2 + csc_nID = 10; + } + + // Set properties + conv_hit.SetDTDetId(tp_detId); + + conv_hit.set_bx(tp_bx); + conv_hit.set_subsystem(TriggerPrimitive::kDT); + conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap); + conv_hit.set_station(tp_station); + conv_hit.set_ring(1); // set to ring 1? + conv_hit.set_roll(tp_wheel); // used as wheel + conv_hit.set_chamber(tp_chamber); + conv_hit.set_sector(csc_tp_sector); + conv_hit.set_subsector(tp_subsector); + conv_hit.set_csc_ID(tp_csc_ID); + conv_hit.set_csc_nID(csc_nID); + conv_hit.set_track_num(tp_data.segment_number); + conv_hit.set_sync_err(tp_data.RpcBit); // hacked to store rpc bit + //conv_hit.set_sector_RPC ( tp_sector ); + //conv_hit.set_subsector_RPC ( tp_subsector ); + + conv_hit.set_pc_sector(pc_sector); + conv_hit.set_pc_station(pc_station); + conv_hit.set_pc_chamber(pc_chamber); + conv_hit.set_pc_segment(pc_segment); + + conv_hit.set_valid(true); + conv_hit.set_strip(tp_phi); + //conv_hit.set_strip_low ( tp_data.strip_low ); + //conv_hit.set_strip_hi ( tp_data.strip_hi ); + conv_hit.set_wire(tp_data.theta_bti_group); + conv_hit.set_quality(tp_data.qualityCode); + conv_hit.set_pattern(0); // arbitrary + conv_hit.set_bend(tp_phiB); + conv_hit.set_time(0.); // No fine resolution timing + //conv_hit.set_alct_quality ( tp_data.alct_quality ); + //conv_hit.set_clct_quality ( tp_data.clct_quality ); + + conv_hit.set_neighbor(is_neighbor); + conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5); + + // Get coordinates from fullsim since LUTs do not exist yet + bool use_fullsim_coords = true; + if (use_fullsim_coords) { + const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive); + double glob_phi = emtf::rad_to_deg(gp.phi().value()); + double glob_theta = emtf::rad_to_deg(gp.theta()); + double glob_eta = gp.eta(); + double glob_rho = gp.perp(); + double glob_z = gp.z(); + + // Use the CSC precision (unconfirmed!) + int fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector()); + int th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap()); + + bool fix_dt_phi_edge = true; + if (fix_dt_phi_edge) { + // The DT chamber edges are not always aligned at 0,30,60,etc. The local + // phi 0 is set to the CSC chamber edge minus 22 deg. But it is possible + // for the DT neighbor chamber to go as far as the CSC chamber edge minus + // 32 deg. + double loc = emtf::calc_phi_loc_deg_from_glob(glob_phi, conv_hit.PC_sector()); + if ((loc + 22.) < 0. && (loc + 32.) > 0.) + fph = 0; + else if ((loc + 360. + 22.) < 0. && (loc + 360. + 32.) > 0.) + fph = 0; + } + + assert(0 <= fph && fph < 5400); + assert(0 <= th && th < 180); // Note: eta = 0.73 -> theta_int = 150 + th = (th == 0) ? 1 : th; // protect against invalid value + + // _________________________________________________________________________ + // Output + + conv_hit.set_phi_sim(glob_phi); + conv_hit.set_theta_sim(glob_theta); + conv_hit.set_eta_sim(glob_eta); + conv_hit.set_rho_sim(glob_rho); + conv_hit.set_z_sim(glob_z); + + conv_hit.set_phi_fp(fph); // Full-precision integer phi + conv_hit.set_theta_fp(th); // Full-precision integer theta + } + + convert_other_details(conv_hit); +} + // _____________________________________________________________________________ // Aux functions int PrimitiveConversion::get_zone_code(const EMTFHit& conv_hit, int th) const { @@ -937,6 +1138,9 @@ int PrimitiveConversion::get_zone_code(const EMTFHit& conv_hit, int th) const { bool is_csc = (conv_hit.Subsystem() == TriggerPrimitive::kCSC); bool is_me13 = (is_csc && conv_hit.Station() == 1 && conv_hit.Ring() == 3); + if (th >= 127) + th = 127; + for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) { int zone_code_tmp = get_fs_zone_code(conv_hit); if (zone_code_tmp & (1 << izone)) { @@ -952,10 +1156,7 @@ int PrimitiveConversion::get_zone_code(const EMTFHit& conv_hit, int th) const { } } } - if (not(zone_code > 0)) { - edm::LogError("L1T") << "zone_code = " << zone_code; - return 0; - } + assert(zone_code > 0); return zone_code; } @@ -997,10 +1198,7 @@ int PrimitiveConversion::get_fs_zone_code(const EMTFHit& conv_hit) const { unsigned int istation = (conv_hit.Station() - 1); unsigned int iring = (conv_hit.Ring() == 4) ? 0 : (conv_hit.Ring() - 1); - if (not(istation < 4 && iring < 3)) { - edm::LogError("L1T") << "istation = " << istation << ", iring = " << iring; - return 0; - } + assert(istation < 4 && iring < 3); unsigned int zone_code = useNewZones_ ? zone_code_table_new[istation][iring] : zone_code_table[istation][iring]; return zone_code; } @@ -1028,11 +1226,7 @@ int PrimitiveConversion::get_fs_segment(const EMTFHit& conv_hit, int fw_station, fs_chamber = is_neighbor ? 0 : 1 + n; } - if (not(fs_history == 0 && (0 <= fs_chamber && fs_chamber < 7) && (0 <= fs_segment && fs_segment < 2))) { - edm::LogError("L1T") << "fs_history = " << fs_history << ", fs_chamber = " << fs_chamber - << ", fs_segment = " << fs_segment; - return 0; - } + assert(fs_history == 0 && (0 <= fs_chamber && fs_chamber < 7) && (0 <= fs_segment && fs_segment < 2)); // fs_segment is a 6-bit word, HHCCCS, encoding the segment number S in the chamber (1 or 2), // the chamber number CCC ("j" above: uniquely identifies chamber within station and ring), // and the history HH (0 for current BX, 1 for previous BX, 2 for BX before that) @@ -1064,15 +1258,19 @@ int PrimitiveConversion::get_bt_segment(const EMTFHit& conv_hit, int fw_station, if (fw_station == 0 && bt_chamber >= 13) // ME1 neighbor chambers 13,14,15 -> 10,11,12 bt_chamber -= 3; - if (not(bt_history == 0 && (0 <= bt_chamber && bt_chamber < 13) && (0 <= bt_segment && bt_segment < 2))) { - edm::LogError("L1T") << "bt_history = " << bt_history << ", bt_chamber = " << bt_chamber - << ", bt_segment = " << bt_segment; - return 0; - } - + assert(bt_history == 0 && (0 <= bt_chamber && bt_chamber < 13) && (0 <= bt_segment && bt_segment < 2)); // bt_segment is a 7-bit word, HHCCCCS, encoding the segment number S in the chamber (1 or 2), // the chamber number CCCC ("j" above: uniquely identifies chamber within station and ring), // and the history HH (0 for current BX, 1 for previous BX, 2 for BX before that) bt_segment = ((bt_history & 0x3) << 5) | ((bt_chamber & 0xf) << 1) | (bt_segment & 0x1); return bt_segment; } + +bool PrimitiveConversion::is_valid_for_run2(const EMTFHit& conv_hit) const { + bool is_csc = conv_hit.Is_CSC(); + bool is_rpc = conv_hit.Is_RPC(); + bool is_irpc = conv_hit.Is_RPC() && ((conv_hit.Station() == 3 || conv_hit.Station() == 4) && (conv_hit.Ring() == 1)); + bool is_omtf = conv_hit.Is_RPC() && ((conv_hit.Station() == 1 || conv_hit.Station() == 2) && + (conv_hit.Ring() == 3)); // RPC in the overlap region + return (is_csc || (is_rpc && !is_irpc && !is_omtf)); +} From 569d85d7cbe105660f926376f0d3633d7e93463a Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 18:13:08 -0400 Subject: [PATCH 16/34] [EMTF] Update PrimitiveSelection & PrimitiveConversion 3/4 --- .../implementations_stage2/EMTFBlockRPC.cc | 19 +++++++++++++------ .../implementations_stage2/EMTFBlockSP.cc | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFBlockRPC.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFBlockRPC.cc index 8d0d63c68e1c6..629750837393d 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFBlockRPC.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFBlockRPC.cc @@ -177,15 +177,22 @@ namespace l1t { RPC_.Word(), RPC_.Link()); + // Rotate by 20 deg to match RPC convention in CMSSW + int _sector_rpc = (_subsector < 5) ? _sector : (_sector % 6) + 1; + // Rotate by 2 to match RPC convention in CMSSW (RPCDetId.h) + int _subsector_rpc = ((_subsector + 1) % 6) + 1; + // Define chamber number + int _chamber = (_sector_rpc - 1) * 6 + _subsector_rpc; + // Define CSC-like subsector + int _subsector_csc = (_station != 1) ? 0 : ((_chamber % 6 > 2) ? 1 : 2); + Hit_.set_station(_station); Hit_.set_ring(_ring); Hit_.set_sector(_sector); - Hit_.set_subsector(_subsector); - Hit_.set_sector_RPC(_subsector < 5 ? _sector - : (_sector % 6) + 1); // Rotate by 20 deg to match RPC convention in CMSSW - Hit_.set_subsector_RPC(((_subsector + 1) % 6) + - 1); // Rotate by 2 to match RPC convention in CMSSW (RPCDetId.h) - Hit_.set_chamber((Hit_.Sector_RPC() - 1) * 6 + Hit_.Subsector_RPC()); + Hit_.set_subsector(_subsector_csc); + Hit_.set_sector_RPC(_sector_rpc); + Hit_.set_subsector_RPC(_subsector_rpc); + Hit_.set_chamber(_chamber); Hit_.set_neighbor(_neighbor); Hit_.set_pc_segment(_segment); Hit_.set_fs_segment(_segment); diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFBlockSP.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFBlockSP.cc index c7354badd8d76..ca6d1ba9d1a46 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFBlockSP.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/EMTFBlockSP.cc @@ -310,6 +310,9 @@ namespace l1t { // else if (nDelay[2] + nDelay[1] >= 1) trk_delay = 1; // else if (nDelay[2] + nDelay[1] + nDelay[0] >= 1) trk_delay = 0; + // Reverse 'rotate by 2' to get CPPF subsector number + auto get_subsector_rpc_cppf = [](int subsector_rpc) { return ((subsector_rpc + 3) % 6) + 1; }; + std::array St_hits{{0, 0, 0, 0}}; // Number of matched hits in each station for (auto const& Hit : *res_hit) { @@ -341,8 +344,9 @@ namespace l1t { if (Hit.Is_CSC() == 1 && (Hit.CSC_ID() != conv_vals_SP.at(0) || Hit.Subsector() != conv_vals_SP.at(2))) continue; - int RPC_subsector = ((Hit.Subsector() - 1) / 3) + 1; // Map RPC subsector to equivalent CSC subsector - int RPC_CSC_ID = ((Hit.Subsector() - 1) % 3) + 4; // Map RPC subsector and ring to equivalent CSC ID + int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC()); + int RPC_subsector = ((tmp_subsector - 1) / 3) + 1; // Map RPC subsector to equivalent CSC subsector + int RPC_CSC_ID = ((tmp_subsector - 1) % 3) + 4; // Map RPC subsector and ring to equivalent CSC ID if (Hit.Is_RPC() == 1 && (RPC_CSC_ID != conv_vals_SP.at(0) || RPC_subsector != conv_vals_SP.at(2))) continue; @@ -365,7 +369,8 @@ namespace l1t { if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0)) continue; - if (Hit.Is_RPC() == 1 && Hit.Subsector() + 3 != conv_vals_SP.at(0)) + int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC()); + if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0)) continue; if (St_hits.at(1) == 0) { @@ -386,7 +391,8 @@ namespace l1t { if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0)) continue; - if (Hit.Is_RPC() == 1 && Hit.Subsector() + 3 != conv_vals_SP.at(0)) + int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC()); + if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0)) continue; if (St_hits.at(2) == 0) { @@ -407,7 +413,8 @@ namespace l1t { if (Hit.Is_CSC() == 1 && Hit.CSC_ID() != conv_vals_SP.at(0)) continue; - if (Hit.Is_RPC() == 1 && Hit.Subsector() + 3 != conv_vals_SP.at(0)) + int tmp_subsector = get_subsector_rpc_cppf(Hit.Subsector_RPC()); + if (Hit.Is_RPC() == 1 && tmp_subsector + 3 != conv_vals_SP.at(0)) continue; if (St_hits.at(3) == 0) { From 69d89db07b442cc549e3de6cb588873ccc8b936b Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 18:39:33 -0400 Subject: [PATCH 17/34] [EMTF] Update PrimitiveSelection & PrimitiveConversion 4/4 --- DQM/L1TMonitor/src/L1TStage2EMTF.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/DQM/L1TMonitor/src/L1TStage2EMTF.cc b/DQM/L1TMonitor/src/L1TStage2EMTF.cc index cb3104bf2cb50..92b0f3324c80a 100644 --- a/DQM/L1TMonitor/src/L1TStage2EMTF.cc +++ b/DQM/L1TMonitor/src/L1TStage2EMTF.cc @@ -592,6 +592,9 @@ void L1TStage2EMTF::analyze(const edm::Event& e, const edm::EventSetup& c) { const std::map, int> histIndexRPC = { {{4, 3}, 0}, {{4, 2}, 1}, {{3, 3}, 2}, {{3, 2}, 3}, {{2, 2}, 4}, {{1, 2}, 5}}; + // Reverse 'rotate by 2' for RPC subsector + auto get_subsector_rpc_cppf = [](int subsector_rpc) { return ((subsector_rpc + 3) % 6) + 1; }; + for (auto Hit = HitCollection->begin(); Hit != HitCollection->end(); ++Hit) { int endcap = Hit->Endcap(); int sector = Hit->Sector(); @@ -650,7 +653,8 @@ void L1TStage2EMTF::analyze(const edm::Event& e, const edm::EventSetup& c) { rpcHitTheta[hist_index]->Fill(Hit->Theta_fp() / 4); rpcChamberPhi[hist_index]->Fill(chamber, Hit->Phi_fp() / 4); rpcChamberTheta[hist_index]->Fill(chamber, Hit->Theta_fp() / 4); - rpcHitOccupancy->Fill((Hit->Sector_RPC() - 1) * 7 + Hit->Subsector(), hist_index + 0.5); + rpcHitOccupancy->Fill((Hit->Sector_RPC() - 1) * 7 + get_subsector_rpc_cppf(Hit->Subsector_RPC()), + hist_index + 0.5); } else if (Hit->Neighbor() == true) { rpcHitOccupancy->Fill((Hit->Sector_RPC() - 1) * 7 + 7, hist_index + 0.5); } @@ -742,7 +746,7 @@ void L1TStage2EMTF::analyze(const edm::Event& e, const edm::EventSetup& c) { int ring = TrkHit.Ring(); int station = TrkHit.Station(); int sector = TrkHit.Sector(); - int subsector = TrkHit.Subsector(); + //int subsector = TrkHit.Subsector(); //int cscid_offset = (sector - 1) * 9;//no longer needed after new time plots (maybe useful for future plots) int neighbor = TrkHit.Neighbor(); int endcap = TrkHit.Endcap(); @@ -790,9 +794,10 @@ void L1TStage2EMTF::analyze(const edm::Event& e, const edm::EventSetup& c) { if (Hit->Endcap() > 0) hist_index = 11 - hist_index; rpcHitTimingInTrack->Fill(Hit->BX(), hist_index + 0.5); - rpcHitTiming[histIndexBX.at(Hit->BX())]->Fill((Hit->Sector_RPC() - 1) * 7 + Hit->Subsector(), - hist_index + 0.5); - rpcHitTimingTot->Fill((Hit->Sector_RPC() - 1) * 7 + Hit->Subsector(), hist_index + 0.5); + rpcHitTiming[histIndexBX.at(Hit->BX())]->Fill( + (Hit->Sector_RPC() - 1) * 7 + get_subsector_rpc_cppf(Hit->Subsector_RPC()), hist_index + 0.5); + rpcHitTimingTot->Fill((Hit->Sector_RPC() - 1) * 7 + get_subsector_rpc_cppf(Hit->Subsector_RPC()), + hist_index + 0.5); } // End loop: for (auto Hit = HitCollection->begin(); Hit != HitCollection->end(); ++Hit) } // End conditional: if (trackHitBX == 0 && ring == 2) } // End conditional: if (TrkHit.Is_CSC() == true) @@ -807,8 +812,10 @@ void L1TStage2EMTF::analyze(const edm::Event& e, const edm::EventSetup& c) { hist_index = 11 - hist_index; rpcHitTimingInTrack->Fill(trackHitBX, hist_index + 0.5); - rpcHitTiming[histIndexBX.at(trackHitBX)]->Fill((TrkHit.Sector_RPC() - 1) * 7 + subsector, hist_index + 0.5); - rpcHitTimingTot->Fill((TrkHit.Sector_RPC() - 1) * 7 + subsector, hist_index + 0.5); + rpcHitTiming[histIndexBX.at(trackHitBX)]->Fill( + (TrkHit.Sector_RPC() - 1) * 7 + get_subsector_rpc_cppf(TrkHit.Subsector_RPC()), hist_index + 0.5); + rpcHitTimingTot->Fill((TrkHit.Sector_RPC() - 1) * 7 + get_subsector_rpc_cppf(TrkHit.Subsector_RPC()), + hist_index + 0.5); } // End conditional: if (TrkHit.Is_RPC() == true && neighbor == false) if (TrkHit.Is_RPC() == true && neighbor == true) { hist_index = histIndexRPC.at({station, ring}); From 569312ee625ee500fcc99742f063bb855549c095 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 12:03:31 -0400 Subject: [PATCH 18/34] [EMTF] Update simEmtfDigis_cfi.py --- .../python/customise_Phase2C2.py | 37 ------------------- .../L1TMuonEndCap/python/simEmtfDigis_cfi.py | 15 ++++++-- 2 files changed, 12 insertions(+), 40 deletions(-) delete mode 100644 L1Trigger/L1TMuonEndCap/python/customise_Phase2C2.py diff --git a/L1Trigger/L1TMuonEndCap/python/customise_Phase2C2.py b/L1Trigger/L1TMuonEndCap/python/customise_Phase2C2.py deleted file mode 100644 index 51f27e76bd700..0000000000000 --- a/L1Trigger/L1TMuonEndCap/python/customise_Phase2C2.py +++ /dev/null @@ -1,37 +0,0 @@ -import FWCore.ParameterSet.Config as cms - -def customise(process): - - # From python/simEmtfDigis_cfi.py - if hasattr(process, 'simEmtfDigis'): - process.simEmtfDigis.spPCParams16.ZoneBoundaries = [0,36,54,96,127] - process.simEmtfDigis.spPCParams16.UseNewZones = True - process.simEmtfDigis.RPCEnable = True - process.simEmtfDigis.GEMEnable = True - process.simEmtfDigis.IRPCEnable = True - process.simEmtfDigis.ME0Enable = True - process.simEmtfDigis.TTEnable = False - process.simEmtfDigis.ME0Input = cms.InputTag('fakeSimMuonME0PadDigis') - process.simEmtfDigis.Era = cms.string('Phase2C2') - process.simEmtfDigis.spPAParams16.PtLUTVersion = cms.int32(7) - - # From python/fakeEmtfParams_cff.py - if hasattr(process, 'emtfParams'): - process.emtfParams.PtAssignVersion = cms.int32(7) - - if hasattr(process, 'emtfForestsDB'): - process.emtfForestsDB = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonEndCapForestRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) - ) - - process.emtfForests = cms.ESProducer( - "L1TMuonEndCapForestESProducer", - PtAssignVersion = cms.int32(7), - bdtXMLDir = cms.string("2017_v7") - ) - - return process - diff --git a/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py b/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py index 5c582ffb703b9..d6e78131b3a64 100644 --- a/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py +++ b/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py @@ -21,16 +21,24 @@ # * 'simCscTriggerPrimitiveDigis','MPCSORTED' : simulated trigger primitives (LCTs) from re-emulating CSC digis # * 'csctfDigis' : real trigger primitives as received by CSCTF (legacy trigger), available only in 2016 data # * 'emtfStage2Digis' : real trigger primitives as received by EMTF, unpacked in EventFilter/L1TRawToDigi/ - CSCInput = cms.InputTag('simCscTriggerPrimitiveDigis','MPCSORTED'), - RPCInput = cms.InputTag('simMuonRPCDigis'), + DTPhiInput = cms.InputTag('simTwinMuxDigis'), + DTThetaInput = cms.InputTag('simDtTriggerPrimitiveDigis'), + CSCInput = cms.InputTag('simCscTriggerPrimitiveDigis','MPCSORTED'), + CSCComparatorInput = cms.InputTag('simMuonCSCDigis','MuonCSCComparatorDigi'), + RPCInput = cms.InputTag('simMuonRPCDigis'), + RPCRecHitInput = cms.InputTag('rpcRecHits'), CPPFInput = cms.InputTag('simCPPFDigis'), ## Cannot use in MC workflow, does not exist yet. CPPFEnable set to False - AWB 01.06.18 - GEMInput = cms.InputTag('simMuonGEMPadDigis'), + GEMInput = cms.InputTag('simMuonGEMPadDigiClusters'), + ME0Input = cms.InputTag('me0TriggerPseudoDigis105X'), # Run with CSC, RPC, GEM + DTEnable = cms.bool(False), CSCEnable = cms.bool(True), # Use CSC LCTs from the MPCs in track-building RPCEnable = cms.bool(True), # Use clustered RPC hits from CPPF in track-building CPPFEnable = cms.bool(False), # Use CPPF-emulated clustered RPC hits from CPPF as the RPC hits GEMEnable = cms.bool(False), # Use hits from GEMs in track-building + IRPCEnable = cms.bool(False), + ME0Enable = cms.bool(False), # Era (options: 'Run2_2016', 'Run2_2017', 'Run2_2018') Era = cms.string('Run2_2016'), @@ -44,6 +52,7 @@ CSCInputBXShift = cms.int32(-8), # Shift applied to input CSC LCT primitives, to center at BX = 0 RPCInputBXShift = cms.int32(0), GEMInputBXShift = cms.int32(0), + ME0InputBXShift = cms.int32(-8), # Sector processor primitive-conversion parameters spPCParams16 = cms.PSet( From d31a9a535b547d0e5cc2282050b0d82798c600bf Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 21 Apr 2020 10:42:06 -0400 Subject: [PATCH 19/34] [EMTF] Add DebugTools 1/4 --- .../L1TMuonEndCap/interface/DebugTools.h | 17 +++++++++++ L1Trigger/L1TMuonEndCap/src/DebugTools.cc | 1 + L1Trigger/L1TMuonEndCap/test/BuildFile.xml | 5 ++++ .../test/unittests/TestDebugTools.cpp | 28 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 L1Trigger/L1TMuonEndCap/interface/DebugTools.h create mode 100644 L1Trigger/L1TMuonEndCap/src/DebugTools.cc create mode 100644 L1Trigger/L1TMuonEndCap/test/unittests/TestDebugTools.cpp diff --git a/L1Trigger/L1TMuonEndCap/interface/DebugTools.h b/L1Trigger/L1TMuonEndCap/interface/DebugTools.h new file mode 100644 index 0000000000000..178367e80bc59 --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/interface/DebugTools.h @@ -0,0 +1,17 @@ +#ifndef L1TMuonEndCap_DebugTools_h +#define L1TMuonEndCap_DebugTools_h + +#include + +// Uncomment the following line to use assert +#define EMTF_ALLOW_ASSERT + +#ifdef EMTF_ALLOW_ASSERT +#define emtf_assert(expr) (assert(expr)) +#else +#define emtf_assert(expr) ((void)(expr)) +#endif + +namespace emtf {} // namespace emtf + +#endif diff --git a/L1Trigger/L1TMuonEndCap/src/DebugTools.cc b/L1Trigger/L1TMuonEndCap/src/DebugTools.cc new file mode 100644 index 0000000000000..9f18d2723ffbd --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/src/DebugTools.cc @@ -0,0 +1 @@ +#include "L1Trigger/L1TMuonEndCap/interface/DebugTools.h" diff --git a/L1Trigger/L1TMuonEndCap/test/BuildFile.xml b/L1Trigger/L1TMuonEndCap/test/BuildFile.xml index 97868c9e80869..9f6c15e989d7e 100644 --- a/L1Trigger/L1TMuonEndCap/test/BuildFile.xml +++ b/L1Trigger/L1TMuonEndCap/test/BuildFile.xml @@ -9,6 +9,11 @@ + + + + + diff --git a/L1Trigger/L1TMuonEndCap/test/unittests/TestDebugTools.cpp b/L1Trigger/L1TMuonEndCap/test/unittests/TestDebugTools.cpp new file mode 100644 index 0000000000000..07961219991be --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/test/unittests/TestDebugTools.cpp @@ -0,0 +1,28 @@ +#include "Utilities/Testing/interface/CppUnit_testdriver.icpp" +#include "cppunit/extensions/HelperMacros.h" + +#include "L1Trigger/L1TMuonEndCap/interface/DebugTools.h" + +class TestDebugTools : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(TestDebugTools); + CPPUNIT_TEST(test_assert); + CPPUNIT_TEST_SUITE_END(); + +public: + TestDebugTools() {} + ~TestDebugTools() {} + void setUp() {} + void tearDown() {} + + void test_assert(); +}; + +///registration of the test so that the runner can find it +CPPUNIT_TEST_SUITE_REGISTRATION(TestDebugTools); + +using namespace emtf; + +void TestDebugTools::test_assert() { + // emtf_assert should not cause an assertion failure in CMSSW production + CPPUNIT_ASSERT_ASSERTION_PASS(emtf_assert(1 == 2)); +} From 298b2f14491eb154cf17abdcc7c9199dd176128f Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 21 Apr 2020 10:43:37 -0400 Subject: [PATCH 20/34] [EMTF] Add DebugTools 2/4 --- L1Trigger/L1TMuonEndCap/interface/Common.h | 2 ++ L1Trigger/L1TMuonEndCap/interface/TrackTools.h | 3 --- L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc | 1 - L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc | 1 - L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc | 2 -- L1Trigger/L1TMuonEndCap/src/TrackTools.cc | 2 +- 6 files changed, 3 insertions(+), 8 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/Common.h b/L1Trigger/L1TMuonEndCap/interface/Common.h index de1b388e825b8..94c5795bab458 100644 --- a/L1Trigger/L1TMuonEndCap/interface/Common.h +++ b/L1Trigger/L1TMuonEndCap/interface/Common.h @@ -14,6 +14,8 @@ #include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h" #include "L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemTag.h" +#include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h" +#include "L1Trigger/L1TMuonEndCap/interface/DebugTools.h" // Resolve namespaces diff --git a/L1Trigger/L1TMuonEndCap/interface/TrackTools.h b/L1Trigger/L1TMuonEndCap/interface/TrackTools.h index 30191c62bf1b0..bb45c120a4544 100644 --- a/L1Trigger/L1TMuonEndCap/interface/TrackTools.h +++ b/L1Trigger/L1TMuonEndCap/interface/TrackTools.h @@ -3,9 +3,6 @@ #include -#include "DataFormats/L1TMuon/interface/EMTFTrack.h" -#include "DataFormats/L1TMuon/interface/EMTFTrack.h" - namespace emtf { // Please refers to DN-2015/017 for uGMT conventions diff --git a/L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc b/L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc index 11d46a1f198ac..0b569dbe4e7bb 100644 --- a/L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc +++ b/L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc @@ -1,6 +1,5 @@ #include "L1Trigger/L1TMuonEndCap/interface/AngleCalculation.h" -#include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h" #include "helper.h" // to_hex, to_binary namespace { diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc index b553edb1e61e2..1f0e7ab432886 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc @@ -1,6 +1,5 @@ #include "L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h" -#include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h" #include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" #include "Geometry/RPCGeometry/interface/RPCGeometry.h" // for special treatments for iRPC diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc index 4a8c82b2524e8..2a6e316d7e6bb 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc @@ -1,7 +1,5 @@ #include "L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h" -#include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h" - #include "helper.h" // merge_map_into_map, assert_no_abort // 18 in ME1; 9x3 in ME2,3,4; 9 from neighbor sector. diff --git a/L1Trigger/L1TMuonEndCap/src/TrackTools.cc b/L1Trigger/L1TMuonEndCap/src/TrackTools.cc index 68cf10113ef6d..4f315c98bc801 100644 --- a/L1Trigger/L1TMuonEndCap/src/TrackTools.cc +++ b/L1Trigger/L1TMuonEndCap/src/TrackTools.cc @@ -86,7 +86,7 @@ namespace emtf { int result = 0; if (station > 1 && ring > 1) { result = ((static_cast(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6 - } else if (station == 1 && ring != 4) { + } else if (station == 1) { result = ((static_cast(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6 } else { result = ((static_cast(chamber - 2) & 0x1f) / 3) + 1; // ch 2-4-> 1, 5-7->2, ... From 51e148d468fd4f698d951a289a21468bb7148c95 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 21 Apr 2020 12:21:04 -0400 Subject: [PATCH 21/34] [EMTF] Add DebugTools 3/4 --- .../interface/PtAssignmentEngineAux.h | 5 +- .../interface/PtAssignmentEngineAux2016.h | 7 +- .../interface/PtAssignmentEngineAux2017.h | 4 +- .../L1TMuonEndCap/src/AngleCalculation.cc | 66 ++----- .../L1TMuonEndCap/src/BestTrackSelection.cc | 30 +-- .../src/EMTFSubsystemCollector.cc | 6 +- .../L1TMuonEndCap/src/PatternRecognition.cc | 62 ++---- L1Trigger/L1TMuonEndCap/src/PhiMemoryImage.cc | 5 +- .../L1TMuonEndCap/src/PrimitiveConversion.cc | 80 ++++---- .../L1TMuonEndCap/src/PrimitiveMatching.cc | 41 +--- .../L1TMuonEndCap/src/PrimitiveSelection.cc | 176 +++++++----------- L1Trigger/L1TMuonEndCap/src/PtAssignment.cc | 13 +- .../L1TMuonEndCap/src/PtAssignmentEngine.cc | 10 +- .../src/PtAssignmentEngine2016.cc | 10 +- .../src/PtAssignmentEngine2017.cc | 94 +++------- .../src/PtAssignmentEngineAux2017.cc | 157 ++++------------ L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc | 20 +- L1Trigger/L1TMuonEndCap/src/PtLUTWriter.cc | 1 - .../L1TMuonEndCap/src/SectorProcessor.cc | 12 +- .../L1TMuonEndCap/src/SectorProcessorLUT.cc | 3 +- L1Trigger/L1TMuonEndCap/src/SingleHitTrack.cc | 3 +- L1Trigger/L1TMuonEndCap/src/helper.h | 14 -- 22 files changed, 240 insertions(+), 579 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h index 1c3d772bbbadc..feeb826ade0c1 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h +++ b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h @@ -1,12 +1,15 @@ #ifndef L1TMuonEndCap_PtAssignmentEngineAux_h #define L1TMuonEndCap_PtAssignmentEngineAux_h -#include #include #include #include #include +#include "L1Trigger/L1TMuonEndCap/interface/Common.h" + +// This class (and its daughters) should never own any data members. It should have only functions. + class PtAssignmentEngineAux { public: // Functions for GMT quantities diff --git a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2016.h b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2016.h index d5a1df175878d..2dd14920adf0b 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2016.h +++ b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2016.h @@ -1,12 +1,9 @@ #ifndef L1TMuonEndCap_PtAssignmentEngineAux2016_h #define L1TMuonEndCap_PtAssignmentEngineAux2016_h -#include -#include -#include -#include +#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h" -class PtAssignmentEngineAux2016 { +class PtAssignmentEngineAux2016 : public PtAssignmentEngineAux { public: // Functions for pT assignment const int (*getModeVariables() const)[6]; diff --git a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h index 22437e63d9f3e..79bcda49dfe92 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h +++ b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h @@ -1,7 +1,9 @@ #ifndef L1TMuonEndCap_PtAssignmentEngineAux2017_h #define L1TMuonEndCap_PtAssignmentEngineAux2017_h -class PtAssignmentEngineAux2017 { +#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux.h" + +class PtAssignmentEngineAux2017 : public PtAssignmentEngineAux { public: int getNLBdPhi(int dPhi, int bits = 7, int max = 512) const; diff --git a/L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc b/L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc index 0b569dbe4e7bb..dff65be4b85d4 100644 --- a/L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc +++ b/L1Trigger/L1TMuonEndCap/src/AngleCalculation.cc @@ -88,24 +88,12 @@ void AngleCalculation::calculate_angles(EMTFTrack& track, const int izone) const } if (bugME11Dupes_) { - if (not(st_conv_hits.at(istation).size() <= 4)) // ambiguity in theta is max 4 - { - edm::LogError("L1T") << "st_conv_hits.at(istation).size() = " << st_conv_hits.at(istation).size(); - return; - } + emtf_assert(st_conv_hits.at(istation).size() <= 4); // ambiguity in theta is max 4 } else { - if (not(st_conv_hits.at(istation).size() <= 2)) // ambiguity in theta is max 2 - { - edm::LogError("L1T") << "st_conv_hits.at(istation).size() = " << st_conv_hits.at(istation).size(); - return; - } + emtf_assert(st_conv_hits.at(istation).size() <= 2); // ambiguity in theta is max 2 } } - if (not(st_conv_hits.size() == emtf::NUM_STATIONS)) { - edm::LogError("L1T") << "st_conv_hits.size() = " << st_conv_hits.size() - << ", emtf::NUM_STATIONS = " << emtf::NUM_STATIONS; - return; - } + emtf_assert(st_conv_hits.size() == emtf::NUM_STATIONS); // Best theta deltas and phi deltas // from 0 to 5: dtheta12, dtheta13, dtheta14, dtheta23, dtheta24, dtheta34 @@ -156,14 +144,8 @@ void AngleCalculation::calculate_angles(EMTFTrack& track, const int izone) const int thB = conv_hitB.Theta_fp(); int dth = abs_diff(thA, thB); int dth_sign = (thA <= thB); // sign - if (not(thA != 0 && thB != 0)) { - edm::LogError("L1T") << "thA = " << thA << ", thB = " << thB; - return; - } - if (not(dth < invalid_dtheta)) { - edm::LogError("L1T") << "dth = " << dth << ", invalid_dtheta = " << invalid_dtheta; - return; - } + emtf_assert(thA != 0 && thB != 0); + emtf_assert(dth < invalid_dtheta); if (best_dtheta_arr.at(ipair) >= dth) { best_dtheta_arr.at(ipair) = dth; @@ -196,10 +178,7 @@ void AngleCalculation::calculate_angles(EMTFTrack& track, const int izone) const ++ipair; } // end loop over station B } // end loop over station A - if (not(ipair == emtf::NUM_STATION_PAIRS)) { - edm::LogError("L1T") << "ipair = " << ipair << ", emtf::NUM_STATION_PAIRS = " << emtf::NUM_STATION_PAIRS; - return; - } + emtf_assert(ipair == emtf::NUM_STATION_PAIRS); // Apply cuts on dtheta @@ -286,7 +265,7 @@ void AngleCalculation::calculate_angles(EMTFTrack& track, const int izone) const if (best_dtheta_valid_arr_1.at(5)) { dth_bad &= (~(1 << 3)); // 34 } - assert(dth_bad < 64); + emtf_assert(dth_bad < 64); // extract station mask from LUT vstat = trk_bld[dth_bad]; @@ -352,10 +331,7 @@ void AngleCalculation::calculate_angles(EMTFTrack& track, const int izone) const if (best_pair != -1) { phi_fp = best_phi_arr.at(best_pair); theta_fp = best_theta_arr.at(best_pair); - if (not(theta_fp != 0)) { - edm::LogError("L1T") << "theta_fp = " << theta_fp; - return; - } + emtf_assert(theta_fp != 0); // In firmware, the track is associated to LCTs by the segment number, which // identifies the best strip, but does not resolve the ambiguity in theta. @@ -455,10 +431,7 @@ void AngleCalculation::calculate_angles(EMTFTrack& track, const int izone) const const auto& v = st_conv_hits.at(i); if (!v.empty()) { int bt_station = v.front().BT_station(); - if (not(0 <= bt_station && bt_station <= 4)) { - edm::LogError("L1T") << "bt_station = " << bt_station; - return; - } + emtf_assert(0 <= bt_station && bt_station <= 4); int bt_segment = v.front().BT_segment(); ptlut_data.bt_vi[bt_station] = 1; @@ -493,10 +466,7 @@ void AngleCalculation::calculate_angles(EMTFTrack& track, const int izone) const void AngleCalculation::calculate_bx(EMTFTrack& track) const { const int delayBX = bxWindow_ - 1; - if (not(delayBX >= 0)) { - edm::LogError("L1T") << "delayBX = " << delayBX; - return; - } + emtf_assert(delayBX >= 0); std::vector counter(delayBX + 1, 0); for (const auto& conv_hit : track.Hits()) { @@ -514,10 +484,7 @@ void AngleCalculation::calculate_bx(EMTFTrack& track) const { break; } } - if (not(second_bx != 99)) { - edm::LogError("L1T") << "second_bx = " << second_bx; - return; - } + emtf_assert(second_bx != 99); // ___________________________________________________________________________ // Output @@ -549,14 +516,7 @@ void AngleCalculation::erase_tracks(EMTFTrackCollection& tracks) const { } for (const auto& track : tracks) { - if (not(!track.Hits().empty())) { - edm::LogError("L1T") << "track.Hits().empty() = " << track.Hits().empty(); - return; - } - if (not(track.Hits().size() <= emtf::NUM_STATIONS)) { - edm::LogError("L1T") << "track.Hits().size() = " << track.Hits().size() - << ", emtf::NUM_STATIONS= " << emtf::NUM_STATIONS; - return; - } + emtf_assert(!track.Hits().empty()); + emtf_assert(track.Hits().size() <= emtf::NUM_STATIONS); } } diff --git a/L1Trigger/L1TMuonEndCap/src/BestTrackSelection.cc b/L1Trigger/L1TMuonEndCap/src/BestTrackSelection.cc index a947021dab2f6..131bd6f1ed05e 100644 --- a/L1Trigger/L1TMuonEndCap/src/BestTrackSelection.cc +++ b/L1Trigger/L1TMuonEndCap/src/BestTrackSelection.cc @@ -66,10 +66,7 @@ void BestTrackSelection::cancel_one_bx(const std::deque& ex const int max_z = emtf::NUM_ZONES; // = 4 zones const int max_n = maxRoadsPerZone_; // = 3 candidates per zone const int max_zn = max_z * max_n; // = 12 total candidates - if (not(maxTracks_ <= max_zn)) { - edm::LogError("L1T") << "maxTracks_ = " << maxTracks_ << ", max_zn = " << max_zn; - return; - } + emtf_assert(maxTracks_ <= max_zn); // Emulate the arrays used in firmware typedef std::array segment_ref_t; @@ -88,10 +85,7 @@ void BestTrackSelection::cancel_one_bx(const std::deque& ex for (int z = 0; z < max_z; ++z) { const EMTFTrackCollection& tracks = extended_best_track_cands.at(z); const int ntracks = tracks.size(); - if (not(ntracks <= max_n)) { - edm::LogError("L1T") << "ntracks = " << ntracks << ", max_n = " << max_n; - return; - } + emtf_assert(ntracks <= max_n); for (int n = 0; n < ntracks; ++n) { const int zn = (n * max_z) + z; // for (i = 0; i < 12; i = i+1) rank[i%4][i/4] @@ -100,10 +94,7 @@ void BestTrackSelection::cancel_one_bx(const std::deque& ex rank.at(zn) = track.Rank(); for (const auto& conv_hit : track.Hits()) { - if (not(conv_hit.Valid())) { - edm::LogError("L1T") << "conv_hit.Valid() = " << conv_hit.Valid(); - return; - } + emtf_assert(conv_hit.Valid()); // A segment identifier (chamber, strip, bx) const segment_ref_t segment = {{conv_hit.PC_station() * 9 + conv_hit.PC_chamber(), @@ -261,10 +252,7 @@ void BestTrackSelection::cancel_multi_bx(const std::deque& const int max_n = maxRoadsPerZone_; // = 3 candidates per zone const int max_zn = max_z * max_n; // = 12 total candidates const int max_hzn = max_h * max_zn; // = 36 total candidates - if (not(maxTracks_ <= max_hzn)) { - edm::LogError("L1T") << "maxTracks_ = " << maxTracks_ << ", max_hzn = " << max_hzn; - return; - } + emtf_assert(maxTracks_ <= max_hzn); const int delayBX = bxWindow_ - 1; const int num_h = extended_best_track_cands.size() / max_z; // num of bx history so far @@ -291,10 +279,7 @@ void BestTrackSelection::cancel_multi_bx(const std::deque& for (int z = 0; z < max_z; ++z) { const EMTFTrackCollection& tracks = extended_best_track_cands.at(h * max_z + z); const int ntracks = tracks.size(); - if (not(ntracks <= max_n)) { - edm::LogError("L1T") << "ntracks = " << ntracks << ", max_n = " << max_n; - return; - } + emtf_assert(ntracks <= max_n); for (int n = 0; n < ntracks; ++n) { const int hzn = (h * max_z * max_n) + (n * max_z) + z; // for (i = 0; i < 12; i = i+1) rank[i%4][i/4] @@ -307,10 +292,7 @@ void BestTrackSelection::cancel_multi_bx(const std::deque& good_bx.at(hzn) = 1; // kill this rank if it's not the right BX for (const auto& conv_hit : track.Hits()) { - if (not(conv_hit.Valid())) { - edm::LogError("L1T") << "conv_hit.Valid() = " << conv_hit.Valid(); - return; - } + emtf_assert(conv_hit.Valid()); // Notes from Alex (2017-03-16): // diff --git a/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc b/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc index 49d5b4ed711a6..866740f96cbf1 100644 --- a/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc +++ b/L1Trigger/L1TMuonEndCap/src/EMTFSubsystemCollector.cc @@ -63,7 +63,7 @@ void EMTFSubsystemCollector::extractPrimitives(emtf::DTTag tag, } } } - assert(bti_group1 != -1 && bti_group2 != -1); + emtf_assert(bti_group1 != -1 && bti_group2 != -1); } // 1st phi segment @@ -450,8 +450,8 @@ void EMTFSubsystemCollector::make_copad_gem(const TriggerPrimitiveCollection& mu for (; tp_it != tp_end; ++tp_it) { GEMDetId detid = tp_it->detId(); - assert(detid.layer() == 1 || detid.layer() == 2); - assert(1 <= detid.roll() && detid.roll() <= 8); + emtf_assert(detid.layer() == 1 || detid.layer() == 2); + emtf_assert(1 <= detid.roll() && detid.roll() <= 8); uint32_t layer = detid.layer(); // Remove layer number and roll number from detid diff --git a/L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc b/L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc index 7eff03919e3a2..f0195a950d42f 100644 --- a/L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc +++ b/L1Trigger/L1TMuonEndCap/src/PatternRecognition.cc @@ -34,6 +34,8 @@ void PatternRecognition::configure(int verbose, } void PatternRecognition::configure_details() { + emtf_assert(1 <= bxWindow_ && bxWindow_ <= 3); // only work for BX windows <= 3 + patterns_.clear(); // Parse pattern definitions @@ -41,11 +43,7 @@ void PatternRecognition::configure_details() { // Normal patterns for (const auto& s : pattDefinitions_) { const std::vector& tokens = split_string(s, ',', ':'); // split by comma or colon - if (not(tokens.size() == 9)) // want to find 9 numbers - { - edm::LogError("L1T") << "tokens.size() = " << tokens.size(); - return; - } + emtf_assert(tokens.size() == 9); // want to find 9 numbers std::vector::const_iterator tokens_it = tokens.begin(); @@ -63,11 +61,7 @@ void PatternRecognition::configure_details() { // There can only be one zone hit in the key station in the pattern // and it has to be this magic number - if (not(st2_max == padding_w_st3 && st2_min == padding_w_st3)) { - edm::LogError("L1T") << "st2_max = " << st2_max << ", padding_w_st3 = " << padding_w_st3 - << ", st2_min = " << st2_min << ", padding_w_st3 = " << padding_w_st3; - return; - } + emtf_assert(st2_max == padding_w_st3 && st2_min == padding_w_st3); // There is extra "padding" in st1 w.r.t st2,3,4 // Add the extra padding to st2,3,4 @@ -96,21 +90,13 @@ void PatternRecognition::configure_details() { pattern.rotr(padding_extra_w_st1); patterns_.push_back(pattern); } - if (not(patterns_.size() == pattDefinitions_.size())) { - edm::LogError("L1T") << "patterns_.size() = " << patterns_.size() - << ", pattDefinitions_.size() = " << pattDefinitions_.size(); - return; - } + emtf_assert(patterns_.size() == pattDefinitions_.size()); } else { // Symmetrical patterns for (const auto& s : symPattDefinitions_) { const std::vector& tokens = split_string(s, ',', ':'); // split by comma or colon - if (not(tokens.size() == 17)) // want to find 17 numbers - { - edm::LogError("L1T") << "tokens.size() = " << tokens.size(); - return; - } + emtf_assert(tokens.size() == 17); // want to find 17 numbers std::vector::const_iterator tokens_it = tokens.begin(); @@ -136,16 +122,8 @@ void PatternRecognition::configure_details() { // There can only be one zone hit in the key station in the pattern // and it has to be this magic number - if (not(st2_max1 == padding_w_st3 && st2_min1 == padding_w_st3)) { - edm::LogError("L1T") << "st2_max1 = " << st2_max1 << ", padding_w_st3 = " << padding_w_st3 - << ", st2_min1 = " << st2_min1 << ", padding_w_st3 = " << padding_w_st3; - return; - } - if (not(st2_max2 == padding_w_st3 && st2_min2 == padding_w_st3)) { - edm::LogError("L1T") << "st2_max2 = " << st2_max2 << ", padding_w_st3 = " << padding_w_st3 - << ", st2_min2 = " << st2_min2 << ", padding_w_st3 = " << padding_w_st3; - return; - } + emtf_assert(st2_max1 == padding_w_st3 && st2_min1 == padding_w_st3); + emtf_assert(st2_max2 == padding_w_st3 && st2_min2 == padding_w_st3); // There is extra "padding" in st1 w.r.t st2,3,4 // Add the extra padding to st2,3,4 @@ -188,11 +166,7 @@ void PatternRecognition::configure_details() { pattern.rotr(padding_extra_w_st1); patterns_.push_back(pattern); } - if (not(patterns_.size() == symPattDefinitions_.size())) { - edm::LogError("L1T") << "patterns_.size() = " << patterns_.size() - << ", symPattDefinitions_.size() = " << symPattDefinitions_.size(); - return; - } + emtf_assert(patterns_.size() == symPattDefinitions_.size()); } if (verbose_ > 2) { // debug @@ -307,11 +281,8 @@ bool PatternRecognition::is_zone_empty(int zone, EMTFHitCollection::const_iterator conv_hits_end = ext_conv_hits_it->end(); for (; conv_hits_it != conv_hits_end; ++conv_hits_it) { - if (not(conv_hits_it->PC_segment() <= 4)) // With 2 unique LCTs per chamber, 4 possible strip/wire combinations - { - edm::LogError("L1T") << "conv_hits_it->PC_segment() = " << conv_hits_it->PC_segment(); - return true; - } + emtf_assert(conv_hits_it->PC_segment() <= + 4); // With 2 unique LCTs per chamber, 4 possible strip/wire combinations if (conv_hits_it->Subsystem() == TriggerPrimitive::kRPC) continue; // Don't use RPC hits for pattern formation @@ -430,12 +401,6 @@ void PatternRecognition::process_single_zone(int zone, is_lifetime_up = true; } else if (drift_time == 0) { is_lifetime_up = true; - } else { - // The bx_shifter keeps track of a number of booleans from BX 0, 1, ..., drift_time. - if (not(drift_time == 2 || drift_time == 1 || drift_time == 0)) { - edm::LogError("L1T") << "drift_time = " << drift_time << ", not 0 or 1 or 2"; - return; - } } bx2 = bx1; @@ -559,10 +524,7 @@ void PatternRecognition::sort_single_zone(EMTFRoadCollection& roads) const { if (roads.size() > n) { roads.erase(roads.begin() + n, roads.end()); } - if (not(roads.size() <= n)) { - edm::LogError("L1T") << "roads.size() = " << roads.size() << ", n = " << n; - return; - } + emtf_assert(roads.size() <= n); // Assign the winner variable for (unsigned iroad = 0; iroad < roads.size(); ++iroad) { diff --git a/L1Trigger/L1TMuonEndCap/src/PhiMemoryImage.cc b/L1Trigger/L1TMuonEndCap/src/PhiMemoryImage.cc index 15108ab666770..a2dea3fd728e1 100644 --- a/L1Trigger/L1TMuonEndCap/src/PhiMemoryImage.cc +++ b/L1Trigger/L1TMuonEndCap/src/PhiMemoryImage.cc @@ -142,10 +142,7 @@ void PhiMemoryImage::rotr(unsigned int n) { } unsigned int PhiMemoryImage::op_and(const PhiMemoryImage& other) const { - if (not(_layers == 4 && _units == 3)) { - edm::LogError("L1T") << "_layers = " << _layers << ", _units = " << _units; - return 0; - } + static_assert((_layers == 4 && _units == 3), "This function assumes (_layers == 4 && _units == 3)"); // Unroll bool b_st1 = (_buffer[0][0] & other._buffer[0][0]) || (_buffer[0][1] & other._buffer[0][1]) || diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc index 1f0e7ab432886..4f541767f2d09 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc @@ -21,8 +21,8 @@ void PrimitiveConversion::configure(const GeometryTranslator* tp_geom, bool useNewZones, bool fixME11Edges, bool bugME11Dupes) { - assert(tp_geom != nullptr); - assert(lut != nullptr); + emtf_assert(tp_geom != nullptr); + emtf_assert(lut != nullptr); tp_geom_ = tp_geom; lut_ = lut; @@ -76,7 +76,7 @@ void PrimitiveConversion::process(const std::mapsubsystem() == TriggerPrimitive::kDT) { convert_dt(pc_sector, 0, selected, pc_segment, *tp_it, conv_hit); // pc_station and pc_chamber are meaningless } else { - assert(false && "Incorrect subsystem type"); + emtf_assert(false && "Incorrect subsystem type"); } conv_hits.push_back(conv_hit); pc_segment += 1; @@ -119,7 +119,7 @@ void PrimitiveConversion::convert_csc(int pc_sector, csc_nID += 1; if (tp_station == 1) { // neighbor ME1 - assert(tp_subsector == 2); + emtf_assert(tp_subsector == 2); } } @@ -257,7 +257,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { } else if (pc_station == 5 && pc_chamber < 9) { // neighbor ME4: 59 - 60 pc_lut_id += 50 + 9 - 7; } - assert(pc_lut_id < 61); + emtf_assert(pc_lut_id < 61); if (verbose_ > 1) { // debug std::cout << "pc_station: " << pc_station << " pc_chamber: " << pc_chamber << " fw_station: " << fw_station @@ -291,7 +291,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { eighth_strip = fw_strip << 3; // multiply by 2, uses all 3 bits of pattern correction eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 0); } - assert(bugStrip0BeforeFW48200 == true || eighth_strip >= 0); + emtf_assert(bugStrip0BeforeFW48200 == true || eighth_strip >= 0); // Multiplicative factor for eighth_strip // +----------------------------+-------------+------------------+ @@ -345,8 +345,8 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { if (fixZonePhi_) zone_hit = zone_hit_fixed; - assert(0 <= fph && fph < 5000); - assert(0 <= zone_hit && zone_hit < 192); + emtf_assert(0 <= fph && fph < 5000); + emtf_assert(0 <= zone_hit && zone_hit < 192); // ___________________________________________________________________________ // theta conversion @@ -407,7 +407,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { int th = lut().get_th_init(fw_endcap, fw_sector, pc_lut_id); th = th + th_tmp; - assert(0 <= th && th < 128); + emtf_assert(0 <= th && th < 128); th = (th == 0) ? 1 : th; // protect against invalid value // ___________________________________________________________________________ @@ -562,17 +562,17 @@ void PrimitiveConversion::convert_rpc(int pc_sector, int fph = emtf::calc_phi_loc_int_rpc(glob_phi, conv_hit.PC_sector()); int th = emtf::calc_theta_int_rpc(glob_theta, conv_hit.Endcap()); - //assert(0 <= fph && fph < 1024); - assert(0 <= fph && fph < 1250); - assert(0 <= th && th < 32); - assert(th != 0b11111); // RPC hit valid when data is not all ones - fph <<= 2; // upgrade to full CSC precision by adding 2 zeros - th <<= 2; // upgrade to full CSC precision by adding 2 zeros - th = (th == 0) ? 1 : th; // protect against invalid value + //emtf_assert(0 <= fph && fph < 1024); + emtf_assert(0 <= fph && fph < 1250); + emtf_assert(0 <= th && th < 32); + emtf_assert(th != 0b11111); // RPC hit valid when data is not all ones + fph <<= 2; // upgrade to full CSC precision by adding 2 zeros + th <<= 2; // upgrade to full CSC precision by adding 2 zeros + th = (th == 0) ? 1 : th; // protect against invalid value if (is_irpc) { const RPCRoll* roll = dynamic_cast(tp_geom_->getRPCGeometry().roll(tp_detId)); - assert(roll != nullptr); // failed to get RPC roll + emtf_assert(roll != nullptr); // failed to get RPC roll const GlobalPoint& new_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0)); glob_phi = emtf::rad_to_deg(gp.phi().value()); // using 'gp' instead of 'new_gp' for phi glob_theta = emtf::rad_to_deg(new_gp.theta()); @@ -583,8 +583,8 @@ void PrimitiveConversion::convert_rpc(int pc_sector, fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector()); th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap()); - assert(0 <= fph && fph < 5000); - assert(0 <= th && th < 128); + emtf_assert(0 <= fph && fph < 5000); + emtf_assert(0 <= th && th < 128); th = (th == 0) ? 1 : th; // protect against invalid value } @@ -624,7 +624,7 @@ void PrimitiveConversion::convert_rpc_details(EMTFHit& conv_hit, bool isCPPF) co if (use_cppf_lut) { int halfstrip = (conv_hit.Strip_low() + conv_hit.Strip_hi() - 1); - assert(1 <= halfstrip && halfstrip <= 64); + emtf_assert(1 <= halfstrip && halfstrip <= 64); int fph2 = lut().get_cppf_ph_lut(conv_hit.Endcap(), conv_hit.Sector_RPC(), @@ -640,18 +640,18 @@ void PrimitiveConversion::convert_rpc_details(EMTFHit& conv_hit, bool isCPPF) co conv_hit.Ring(), conv_hit.Subsector_RPC(), conv_hit.Roll()); - //assert(abs((fph>>2) - fph2) <= 4); // arbitrary tolerance - //assert(abs((th>>2) - th2) <= 1); // arbitrary tolerance + //emtf_assert(abs((fph>>2) - fph2) <= 4); // arbitrary tolerance + //emtf_assert(abs((th>>2) - th2) <= 1); // arbitrary tolerance fph = fph2; th = th2; - //assert(0 <= fph && fph < 1024); - assert(0 <= fph && fph < 1250); - assert(0 <= th && th < 32); - assert(th != 0b11111); // RPC hit valid when data is not all ones - fph <<= 2; // upgrade to full CSC precision by adding 2 zeros - th <<= 2; // upgrade to full CSC precision by adding 2 zeros - th = (th == 0) ? 1 : th; // protect against invalid value + //emtf_assert(0 <= fph && fph < 1024); + emtf_assert(0 <= fph && fph < 1250); + emtf_assert(0 <= th && th < 32); + emtf_assert(th != 0b11111); // RPC hit valid when data is not all ones + fph <<= 2; // upgrade to full CSC precision by adding 2 zeros + th <<= 2; // upgrade to full CSC precision by adding 2 zeros + th = (th == 0) ? 1 : th; // protect against invalid value } if (verbose_ > 1) { // debug @@ -795,8 +795,8 @@ void PrimitiveConversion::convert_gem(int pc_sector, int fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector()); int th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap()); - assert(0 <= fph && fph < 5000); - assert(0 <= th && th < 128); + emtf_assert(0 <= fph && fph < 5000); + emtf_assert(0 <= th && th < 128); th = (th == 0) ? 1 : th; // protect against invalid value // _________________________________________________________________________ @@ -973,8 +973,8 @@ void PrimitiveConversion::convert_me0(int pc_sector, th = 0; } - assert(0 <= fph && fph < 5000); - assert(0 <= th && th < 128); + emtf_assert(0 <= fph && fph < 5000); + emtf_assert(0 <= th && th < 128); th = (th == 0) ? 1 : th; // protect against invalid value // _________________________________________________________________________ @@ -1107,9 +1107,9 @@ void PrimitiveConversion::convert_dt(int pc_sector, fph = 0; } - assert(0 <= fph && fph < 5400); - assert(0 <= th && th < 180); // Note: eta = 0.73 -> theta_int = 150 - th = (th == 0) ? 1 : th; // protect against invalid value + emtf_assert(0 <= fph && fph < 5400); + emtf_assert(0 <= th && th < 180); // Note: eta = 0.73 -> theta_int = 150 + th = (th == 0) ? 1 : th; // protect against invalid value // _________________________________________________________________________ // Output @@ -1155,7 +1155,7 @@ int PrimitiveConversion::get_zone_code(const EMTFHit& conv_hit, int th) const { } } } - assert(zone_code > 0); + emtf_assert(zone_code > 0); return zone_code; } @@ -1197,7 +1197,7 @@ int PrimitiveConversion::get_fs_zone_code(const EMTFHit& conv_hit) const { unsigned int istation = (conv_hit.Station() - 1); unsigned int iring = (conv_hit.Ring() == 4) ? 0 : (conv_hit.Ring() - 1); - assert(istation < 4 && iring < 3); + emtf_assert(istation < 4 && iring < 3); unsigned int zone_code = useNewZones_ ? zone_code_table_new[istation][iring] : zone_code_table[istation][iring]; return zone_code; } @@ -1225,7 +1225,7 @@ int PrimitiveConversion::get_fs_segment(const EMTFHit& conv_hit, int fw_station, fs_chamber = is_neighbor ? 0 : 1 + n; } - assert(fs_history == 0 && (0 <= fs_chamber && fs_chamber < 7) && (0 <= fs_segment && fs_segment < 2)); + emtf_assert(fs_history == 0 && (0 <= fs_chamber && fs_chamber < 7) && (0 <= fs_segment && fs_segment < 2)); // fs_segment is a 6-bit word, HHCCCS, encoding the segment number S in the chamber (1 or 2), // the chamber number CCC ("j" above: uniquely identifies chamber within station and ring), // and the history HH (0 for current BX, 1 for previous BX, 2 for BX before that) @@ -1257,7 +1257,7 @@ int PrimitiveConversion::get_bt_segment(const EMTFHit& conv_hit, int fw_station, if (fw_station == 0 && bt_chamber >= 13) // ME1 neighbor chambers 13,14,15 -> 10,11,12 bt_chamber -= 3; - assert(bt_history == 0 && (0 <= bt_chamber && bt_chamber < 13) && (0 <= bt_segment && bt_segment < 2)); + emtf_assert(bt_history == 0 && (0 <= bt_chamber && bt_chamber < 13) && (0 <= bt_segment && bt_segment < 2)); // bt_segment is a 7-bit word, HHCCCCS, encoding the segment number S in the chamber (1 or 2), // the chamber number CCCC ("j" above: uniquely identifies chamber within station and ring), // and the history HH (0 for current BX, 1 for previous BX, 2 for BX before that) diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveMatching.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveMatching.cc index 2c14e4c1b4d21..e1f6225dbc43a 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveMatching.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveMatching.cc @@ -136,12 +136,7 @@ void PrimitiveMatching::process(const std::deque& extended_co // conv_hit with the lowest phi_diff from the pattern in this station and zone process_single_zone_station( izone + 1, istation + 1, zone_roads.at(izone), zs_conv_hits.at(zs), zs_phi_differences.at(zs)); - - if (not(zone_roads.at(izone).size() == zs_phi_differences.at(zs).size())) { - edm::LogError("L1T") << "zone_roads.at(izone).size() = " << zone_roads.at(izone).size() - << ", zs_phi_differences.at(zs).size() = " << zs_phi_differences.at(zs).size(); - return; - } + emtf_assert(zone_roads.at(izone).size() == zs_phi_differences.at(zs).size()); } // end loop over stations } // end loop over zones @@ -197,10 +192,7 @@ void PrimitiveMatching::process(const std::deque& extended_co } if (fixZonePhi_) { - if (not(!track.Hits().empty())) { - edm::LogError("L1T") << "track.Hits().empty() = " << track.Hits().empty(); - return; - } + emtf_assert(!track.Hits().empty()); } // Output track @@ -311,10 +303,7 @@ void PrimitiveMatching::process_single_zone_station(int zone, for (; roads_it != roads_end; ++roads_it) { int ph_pat = roads_it->Key_zhit(); // pattern key phi value int ph_q = roads_it->Quality_code(); // pattern quality code - if (not(ph_pat >= 0 && ph_q > 0)) { - edm::LogError("L1T") << "ph_pat = " << ph_pat << ", ph_q = " << ph_q; - return; - } + emtf_assert(ph_pat >= 0 && ph_q > 0); if (fixZonePhi_) { ph_pat <<= 5; // add missing 5 lower bits to pattern phi @@ -328,10 +317,7 @@ void PrimitiveMatching::process_single_zone_station(int zone, for (; conv_hits_it != conv_hits_end; ++conv_hits_it) { int ph_seg = conv_hits_it->Phi_fp(); // ph from segments int ph_seg_red = ph_seg >> (bw_fph - bpow - 1); // remove unused low bits - if (not(ph_seg >= 0)) { - edm::LogError("L1T") << "ph_seg = " << ph_seg; - return; - } + emtf_assert(ph_seg >= 0); if (fixZonePhi_) { ph_seg_red = ph_seg; // use full-precision phi @@ -383,17 +369,8 @@ void PrimitiveMatching::process_single_zone_station(int zone, fs_segment = (fs_segment & 0x1); unsigned fw_sort_array_index = (fs_history * zone_cham * seg_ch) + (fs_chamber * seg_ch) + fs_segment; - if (not(fs_history < max_drift && fs_chamber < zone_cham && fs_segment < seg_ch)) { - edm::LogError("L1T") << "fs_history = " << fs_history << ", max_drift = " << max_drift - << ", fs_chamber = " << fs_chamber << ", zone_cham = " << zone_cham - << ", fs_segment = " << fs_segment << ", seg_ch = " << seg_ch; - return; - } - if (not(fw_sort_array_index < fw_sort_array.size())) { - edm::LogError("L1T") << "fw_sort_array_index = " << fw_sort_array_index - << ", fw_sort_array.size() = " << fw_sort_array.size(); - return; - } + emtf_assert(fs_history < max_drift && fs_chamber < zone_cham && fs_segment < seg_ch); + emtf_assert(fw_sort_array_index < fw_sort_array.size()); fw_sort_array.at(fw_sort_array_index) = *phdiffs_it; } @@ -480,11 +457,7 @@ void PrimitiveMatching::insert_hits(hit_ptr_t conv_hit_ptr, (conv_hit_i.Theta_fp() == conv_hit_j.Theta_fp()))) && true) { // All duplicates with the same strip but different wire must have same phi_fp - if (not(conv_hit_i.Phi_fp() == conv_hit_j.Phi_fp())) { - edm::LogError("L1T") << "conv_hit_i.Phi_fp() = " << conv_hit_i.Phi_fp() - << ", conv_hit_j.Phi_fp() = " << conv_hit_j.Phi_fp(); - return; - } + emtf_assert(conv_hit_i.Phi_fp() == conv_hit_j.Phi_fp()); track.push_Hit(conv_hit_i); diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc index 2a6e316d7e6bb..4ccc7258fb8a6 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveSelection.cc @@ -1,6 +1,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h" -#include "helper.h" // merge_map_into_map, assert_no_abort +#include "helper.h" // merge_map_into_map // 18 in ME1; 9x3 in ME2,3,4; 9 from neighbor sector. // Arranged in FW as 6 stations, 9 chambers per station. @@ -78,10 +78,7 @@ void PrimitiveSelection::process(emtf::CSCTag tag, int selected_csc = select_csc(new_tp); // Returns CSC "link" index (0 - 53) if (selected_csc >= 0) { - if (not(selected_csc < NUM_CSC_CHAMBERS)) { - edm::LogError("L1T") << "selected_csc = " << selected_csc << ", NUM_CSC_CHAMBERS = " << NUM_CSC_CHAMBERS; - return; - } + emtf_assert(selected_csc < NUM_CSC_CHAMBERS); //FIXME if (selected_csc_map[selected_csc].size() < 2) { @@ -125,11 +122,7 @@ void PrimitiveSelection::process(emtf::CSCTag tag, edm::LogWarning("L1T") << "EMTF found 3 CSC LCTs in one chamber: keeping only two"; tmp_primitives.erase(tmp_primitives.begin() + 2); // erase 3rd element } - if (not(tmp_primitives.size() <= 2)) // at most 2 hits - { - edm::LogError("L1T") << "tmp_primitives.size() = " << tmp_primitives.size(); - return; - } + emtf_assert(tmp_primitives.size() <= 2); // at most 2 hits if (tmp_primitives.size() == 2) { if ((tmp_primitives.at(0).getStrip() != tmp_primitives.at(1).getStrip()) && @@ -161,10 +154,7 @@ void PrimitiveSelection::process(emtf::CSCTag tag, tmp_primitives.insert(tmp_primitives.begin() + 1, tp1); // (s2,w1) at 2nd pos tmp_primitives.insert(tmp_primitives.begin() + 2, tp0); // (s1,w2) at 3rd pos } - if (not(tmp_primitives.size() == 1 || tmp_primitives.size() == 4)) { - edm::LogError("L1T") << "tmp_primitives.size() = " << tmp_primitives.size(); - return; - } + emtf_assert(tmp_primitives.size() == 1 || tmp_primitives.size() == 4); } } // end if tmp_primitives.size() == 2 @@ -185,10 +175,7 @@ void PrimitiveSelection::process(emtf::RPCTag tag, int selected_rpc = select_rpc(*tp_it); // Returns RPC "link" index if (selected_rpc >= 0) { - if (not(selected_rpc < NUM_RPC_CHAMBERS)) { - edm::LogError("L1T") << "selected_rpc = " << selected_rpc << ", NUM_RPC_CHAMBERS = " << NUM_RPC_CHAMBERS; - return; - } + emtf_assert(selected_rpc < NUM_RPC_CHAMBERS); selected_rpc_map[selected_rpc].push_back(*tp_it); } } @@ -327,11 +314,8 @@ void PrimitiveSelection::process(emtf::RPCTag tag, pc_chamber = 7; } } - - if (not(pc_station != -1 && pc_chamber != -1)) { - edm::LogError("L1T") << "pc_station = " << pc_station << ", pc_chamber = " << pc_chamber; - return; - } + emtf_assert(pc_station != -1 && pc_chamber != -1); + emtf_assert(pc_station < 6 && pc_chamber < 9); selected = (pc_station * 9) + pc_chamber; @@ -384,7 +368,7 @@ void PrimitiveSelection::process(emtf::GEMTag tag, int selected_gem = select_gem(*tp_it); // Returns GEM "link" index if (selected_gem >= 0) { - assert(selected_gem < NUM_GEM_CHAMBERS); + emtf_assert(selected_gem < NUM_GEM_CHAMBERS); selected_gem_map[selected_gem].push_back(*tp_it); } } @@ -431,7 +415,7 @@ void PrimitiveSelection::process(emtf::ME0Tag tag, int selected_me0 = select_me0(*tp_it); // Returns ME0 "link" index if (selected_me0 >= 0) { - assert(selected_me0 < NUM_GEM_CHAMBERS); + emtf_assert(selected_me0 < NUM_GEM_CHAMBERS); selected_me0_map[selected_me0].push_back(*tp_it); } } @@ -466,7 +450,7 @@ void PrimitiveSelection::process(emtf::DTTag tag, int selected_dt = select_dt(*tp_it); // Returns DT "link" index if (selected_dt >= 0) { - assert(selected_dt < NUM_DT_CHAMBERS); + emtf_assert(selected_dt < NUM_DT_CHAMBERS); selected_dt_map[selected_dt].push_back(*tp_it); } } @@ -480,7 +464,7 @@ void PrimitiveSelection::process(emtf::DTTag tag, //int selected = map_tp_it->first; TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference - assert(tmp_primitives.size() <= 2); // at most 2 hits + emtf_assert(tmp_primitives.size() <= 2); // at most 2 hits if (tmp_primitives.size() == 2) { if ((tmp_primitives.at(0).getStrip() != tmp_primitives.at(1).getStrip()) && @@ -533,11 +517,7 @@ void PrimitiveSelection::merge(const std::map& for (; map_tp_it != map_tp_end; ++map_tp_it) { int selected_csc = map_tp_it->first; const TriggerPrimitiveCollection& csc_primitives = map_tp_it->second; - if (not(csc_primitives.size() <= 4)) // at most 4 hits, including duplicated hits - { - edm::LogError("L1T") << "csc_primitives.size() = " << csc_primitives.size(); - return; - } + emtf_assert(csc_primitives.size() <= 4); // at most 4 hits, including duplicated hits // Insert all CSC hits selected_prim_map[selected_csc] = csc_primitives; @@ -552,11 +532,7 @@ void PrimitiveSelection::merge(const std::map& const TriggerPrimitiveCollection& gem_primitives = map_tp_it->second; if (gem_primitives.empty()) continue; - if (not(gem_primitives.size() <= 8)) // at most 8 hits - { - edm::LogError("L1T") << "gem_primitives.size() = " << gem_primitives.size(); - return; - } + emtf_assert(gem_primitives.size() <= 8); // at most 8 hits bool found = (selected_prim_map.find(selected_gem) != selected_prim_map.end()); if (!found) { @@ -577,11 +553,7 @@ void PrimitiveSelection::merge(const std::map& const TriggerPrimitiveCollection& rpc_primitives = map_tp_it->second; if (rpc_primitives.empty()) continue; - if (not(rpc_primitives.size() <= 4)) // at most 4 hits - { - edm::LogError("L1T") << "rpc_primitives.size() = " << rpc_primitives.size(); - return; - } + emtf_assert(rpc_primitives.size() <= 4); // at most 4 hits bool found = (selected_prim_map.find(selected_rpc) != selected_prim_map.end()); if (!found) { @@ -595,11 +567,7 @@ void PrimitiveSelection::merge(const std::map& tmp_rpc_primitives.push_back(tp); } } - if (not(tmp_rpc_primitives.size() <= 2)) // at most 2 hits - { - edm::LogError("L1T") << "tmp_rpc_primitives.size() = " << tmp_rpc_primitives.size(); - return; - } + emtf_assert(tmp_rpc_primitives.size() <= 2); // at most 2 hits selected_prim_map[selected_rpc] = tmp_rpc_primitives; @@ -660,15 +628,15 @@ int PrimitiveSelection::select_csc(const TriggerPrimitive& muon_primitive) const emtf::get_csc_max_strip_and_wire(tp_station, tp_ring, max_strip, max_wire); if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once - assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); - assert_no_abort(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); - assert_no_abort(1 <= tp_station && tp_station <= 4); - assert_no_abort(1 <= tp_csc_ID && tp_csc_ID <= 9); - assert_no_abort(tp_data.strip < max_strip); - assert_no_abort(tp_data.keywire < max_wire); - assert_no_abort(tp_data.valid == true); - assert_no_abort(tp_data.pattern <= 10); - //assert_no_abort(tp_data.quality > 0); + emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + emtf_assert(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); + emtf_assert(1 <= tp_station && tp_station <= 4); + emtf_assert(1 <= tp_csc_ID && tp_csc_ID <= 9); + emtf_assert(tp_data.strip < max_strip); + emtf_assert(tp_data.keywire < max_wire); + emtf_assert(tp_data.valid == true); + emtf_assert(tp_data.pattern <= 10); + //emtf_assert(tp_data.quality > 0); } // LogWarning @@ -752,7 +720,7 @@ int PrimitiveSelection::get_index_csc( selected = (5) * 9 + (tp_station)*2 - 1 + (tp_csc_ID - 1 < 3 ? 0 : 1); } } - assert(selected != -1); + emtf_assert(selected != -1); return selected; } @@ -786,18 +754,18 @@ int PrimitiveSelection::select_rpc(const TriggerPrimitive& muon_primitive) const const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1); if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once - assert_no_abort(tp_region != 0); - assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); - assert_no_abort(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); - assert_no_abort(1 <= tp_subsector && tp_subsector <= 6); - assert_no_abort(1 <= tp_station && tp_station <= 4); - assert_no_abort((!is_irpc && 2 <= tp_ring && tp_ring <= 3) || (is_irpc && tp_ring == 1)); - assert_no_abort((!is_irpc && 1 <= tp_roll && tp_roll <= 3) || (is_irpc && 1 <= tp_roll && tp_roll <= 5)); - //assert_no_abort((!is_irpc && (tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) || (is_irpc && 1 <= tp_strip && tp_strip <= 96)); - assert_no_abort((!is_irpc && (tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) || - (is_irpc && 1 <= tp_strip && tp_strip <= 96 * 2)); // in CMSSW, the iRPC chamber has 192 strips - //assert_no_abort(tp_station > 2 || tp_ring != 3); // stations 1 and 2 do not receive RPCs from ring 3 - assert_no_abort(tp_data.valid == true); + emtf_assert(tp_region != 0); + emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + emtf_assert(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); + emtf_assert(1 <= tp_subsector && tp_subsector <= 6); + emtf_assert(1 <= tp_station && tp_station <= 4); + emtf_assert((!is_irpc && 2 <= tp_ring && tp_ring <= 3) || (is_irpc && tp_ring == 1)); + emtf_assert((!is_irpc && 1 <= tp_roll && tp_roll <= 3) || (is_irpc && 1 <= tp_roll && tp_roll <= 5)); + //emtf_assert((!is_irpc && (tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) || (is_irpc && 1 <= tp_strip && tp_strip <= 96)); + emtf_assert((!is_irpc && (tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) || + (is_irpc && 1 <= tp_strip && tp_strip <= 96 * 2)); // in CMSSW, the iRPC chamber has 192 strips + //emtf_assert(tp_station > 2 || tp_ring != 3); // stations 1 and 2 do not receive RPCs from ring 3 + emtf_assert(tp_data.valid == true); } // Check if the chamber belongs to this sector processor at this BX. @@ -900,7 +868,7 @@ int PrimitiveSelection::get_index_rpc( } selected = (rpc_sub * 10) + rpc_chm; - assert(selected != -1); + emtf_assert(selected != -1); return selected; } @@ -936,16 +904,16 @@ int PrimitiveSelection::select_gem(const TriggerPrimitive& muon_primitive) const int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2); if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once - assert_no_abort(tp_region != 0); - assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); - assert_no_abort(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); - assert_no_abort(1 <= tp_station && tp_station <= 2); - assert_no_abort(tp_ring == 1); - assert_no_abort(1 <= tp_roll && tp_roll <= 8); - assert_no_abort(1 <= tp_layer && tp_layer <= 2); - assert_no_abort(1 <= tp_csc_ID && tp_csc_ID <= 3); - assert_no_abort((tp_station == 1 && 0 <= tp_pad && tp_pad <= 191) || (tp_station != 1)); - assert_no_abort((tp_station == 2 && 0 <= tp_pad && tp_pad <= 383) || (tp_station != 2)); + emtf_assert(tp_region != 0); + emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + emtf_assert(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); + emtf_assert(1 <= tp_station && tp_station <= 2); + emtf_assert(tp_ring == 1); + emtf_assert(1 <= tp_roll && tp_roll <= 8); + emtf_assert(1 <= tp_layer && tp_layer <= 2); + emtf_assert(1 <= tp_csc_ID && tp_csc_ID <= 3); + emtf_assert((tp_station == 1 && 0 <= tp_pad && tp_pad <= 191) || (tp_station != 1)); + emtf_assert((tp_station == 2 && 0 <= tp_pad && tp_pad <= 383) || (tp_station != 2)); } // Check if the chamber belongs to this sector processor at this BX. @@ -1000,7 +968,7 @@ int PrimitiveSelection::get_index_gem( selected = 13; } } - assert(selected != -1); + emtf_assert(selected != -1); return selected; } @@ -1035,16 +1003,16 @@ int PrimitiveSelection::select_me0(const TriggerPrimitive& muon_primitive) const int tp_subsector = 0; if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once - assert_no_abort(tp_region != 0); - assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); - assert_no_abort(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); - assert_no_abort(tp_station == 1); - assert_no_abort(tp_ring == 1); - //assert_no_abort(1 <= tp_roll && tp_roll <= 8); // not set - //assert_no_abort(1 <= tp_layer && tp_layer <= 6); // not set - assert_no_abort(1 <= tp_csc_ID && tp_csc_ID <= 3); - assert_no_abort(0 <= tp_pad && tp_pad <= 767); - assert_no_abort(0 <= tp_partition && tp_partition <= 15); + emtf_assert(tp_region != 0); + emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + emtf_assert(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR); + emtf_assert(tp_station == 1); + emtf_assert(tp_ring == 1); + //emtf_assert(1 <= tp_roll && tp_roll <= 8); // not set + //emtf_assert(1 <= tp_layer && tp_layer <= 6); // not set + emtf_assert(1 <= tp_csc_ID && tp_csc_ID <= 3); + emtf_assert(0 <= tp_pad && tp_pad <= 767); + emtf_assert(0 <= tp_partition && tp_partition <= 15); } // Check if the chamber belongs to this sector processor at this BX. @@ -1141,7 +1109,7 @@ int PrimitiveSelection::get_index_me0( } else { // ME0n: 14 selected = 14; } - assert(selected != -1); + emtf_assert(selected != -1); return selected; } @@ -1182,17 +1150,17 @@ int PrimitiveSelection::select_dt(const TriggerPrimitive& muon_primitive) const int tp_subsector = 0; if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once - //assert_no_abort(-2 <= tp_wheel && tp_wheel <= +2); - assert_no_abort(tp_wheel == -2 || tp_wheel == +2); // do not include wheels -1, 0, +1 - //assert_no_abort(1 <= tp_station && tp_station <= 4); - assert_no_abort(1 <= tp_station && tp_station <= 3); // do not include MB4 - assert_no_abort(1 <= tp_sector && tp_sector <= 12); - assert_no_abort(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); - assert_no_abort(emtf::MIN_TRIGSECTOR <= csc_tp_sector && csc_tp_sector <= emtf::MAX_TRIGSECTOR); - //assert_no_abort(4 <= tp_csc_ID && tp_csc_ID <= 9); - assert_no_abort(tp_csc_ID == 6 || tp_csc_ID == 9); - assert_no_abort(-2048 <= tp_phi && tp_phi <= 2047); // 12-bit - //assert_no_abort(-512 <= tp_phiB && tp_phiB <= 511); // 10-bit + //emtf_assert(-2 <= tp_wheel && tp_wheel <= +2); + emtf_assert(tp_wheel == -2 || tp_wheel == +2); // do not include wheels -1, 0, +1 + //emtf_assert(1 <= tp_station && tp_station <= 4); + emtf_assert(1 <= tp_station && tp_station <= 3); // do not include MB4 + emtf_assert(1 <= tp_sector && tp_sector <= 12); + emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP); + emtf_assert(emtf::MIN_TRIGSECTOR <= csc_tp_sector && csc_tp_sector <= emtf::MAX_TRIGSECTOR); + //emtf_assert(4 <= tp_csc_ID && tp_csc_ID <= 9); + emtf_assert(tp_csc_ID == 6 || tp_csc_ID == 9); + emtf_assert(-2048 <= tp_phi && tp_phi <= 2047); // 12-bit + //emtf_assert(-512 <= tp_phiB && tp_phiB <= 511); // 10-bit } // Check if the chamber belongs to this sector processor at this BX. @@ -1238,6 +1206,6 @@ int PrimitiveSelection::get_index_dt( } else { // ME1,2,3,4n: 8-11 selected = 8 + (tp_station - 1); } - assert(selected != -1); + emtf_assert(selected != -1); return selected; } diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignment.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignment.cc index bcba8f67b7ab4..ae38ae9d55365 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignment.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignment.cc @@ -15,10 +15,7 @@ void PtAssignment::configure(PtAssignmentEngine* pt_assign_engine, bool bugGMTPhi, bool promoteMode7, int modeQualVer) { - if (not(pt_assign_engine != nullptr)) { - edm::LogError("L1T") << "pt_assign_engine == nullptr "; - return; - } + emtf_assert(pt_assign_engine != nullptr); pt_assign_engine_ = pt_assign_engine; @@ -76,9 +73,9 @@ void PtAssignment::process(EMTFTrackCollection& best_tracks) { // Check address packing / unpacking using PtAssignmentEngine2017::calculate_pt_xml(const EMTFTrack& track) if (pt_assign_engine_->get_pt_lut_version() > 5 && not(fabs(xmlpt - pt_assign_engine_->calculate_pt(track)) < 0.001)) { - edm::LogWarning("L1T") << "EMTF pT assignment mismatch: xmlpt = " << xmlpt - << ", pt_assign_engine_->calculate_pt(track)) = " - << pt_assign_engine_->calculate_pt(track); + edm::LogError("L1T") << "EMTF pT assignment mismatch: xmlpt = " << xmlpt + << ", pt_assign_engine_->calculate_pt(track)) = " + << pt_assign_engine_->calculate_pt(track); } pt = (xmlpt < 0.) ? 1. : xmlpt; // Matt used fabs(-1) when mode is invalid @@ -154,7 +151,7 @@ void PtAssignment::process(EMTFTrackCollection& best_tracks) { return (lhs_addr_1 == rhs_addr_1) && (lhs_addr_2 == rhs_addr_2); }; - assert(best_tracks.size() <= 3); + emtf_assert(best_tracks.size() <= 3); if (best_tracks.size() == 3) { bool same_bank = is_in_same_bank(best_tracks.at(0), best_tracks.at(2)) || is_in_same_bank(best_tracks.at(1), best_tracks.at(2)); diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine.cc index c78bda63bc883..b536a7756036b 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine.cc @@ -1,11 +1,8 @@ #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine.h" -#include #include #include -#include "helper.h" // assert_no_abort - PtAssignmentEngine::PtAssignmentEngine() : allowedModes_({3, 5, 9, 6, 10, 12, 7, 11, 13, 14, 15}), forests_(), ptlut_reader_(), ptLUTVersion_(0xFFFFFFFF) {} @@ -56,11 +53,8 @@ void PtAssignmentEngine::load(int pt_lut_version, const L1TMuonEndCapForest* pay // std::cout << " * ptLUTVersion_ = " << ptLUTVersion_ << std::endl; forests_.at(mode).getTree(0)->setBoostWeight(boostWeight_); - if (not(boostWeight_ == 0 || ptLUTVersion_ >= 6)) // Check that XMLs and pT LUT version are consistent - { - edm::LogError("L1T") << "boostWeight_ = " << boostWeight_ << ", ptLUTVersion_ = " << ptLUTVersion_; - return; - } + emtf_assert(boostWeight_ == 0 || ptLUTVersion_ >= 6); // Check that XMLs and pT LUT version are consistent + // Will catch user trying to run with Global Tag settings on 2017 data, rather than fakeEmtfParams. - AWB 08.06.17 // // Code below can be used to save out trees in XML format diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2016.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2016.cc index e2291a07c17c2..5a9f82ab5ce21 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2016.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2016.cc @@ -1,7 +1,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine2016.h" #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2016.h" -#include #include #include @@ -13,9 +12,7 @@ const PtAssignmentEngineAux2016& PtAssignmentEngine2016::aux() const { float PtAssignmentEngine2016::scale_pt(const float pt, const int mode) const { // Scaling to achieve 90% efficency at any given L1 pT threshold // For 2016, was a flat scaling factor of 1.4 - float pt_scale = 1.4; - return pt_scale; } @@ -641,10 +638,7 @@ float PtAssignmentEngine2016::calculate_pt_xml(const address_t& address) const { if (mv != -999) { int v = variables.at(mv); if (!(mode_inv == 13 && i == 3)) { // somehow this uses CSCID1 - if (not(v != -999)) { - edm::LogError("L1T") << "v = " << v; - return -1; - } + emtf_assert(v != -999); } tree_data.push_back(v); } else { @@ -694,7 +688,7 @@ float PtAssignmentEngine2016::calculate_pt_xml(const address_t& address) const { pt = (tmp_pt == 0) ? tmp_pt : 1.0 / tmp_pt; } - assert(pt > 0); + emtf_assert(pt > 0); return pt; } diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2017.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2017.cc index ff2ac4f16e196..1834a27a327ea 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2017.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2017.cc @@ -2,7 +2,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h" #include "L1Trigger/L1TMuonEndCap/interface/PtLUTVarCalc.h" -#include #include #include @@ -13,10 +12,7 @@ const PtAssignmentEngineAux2017& PtAssignmentEngine2017::aux() const { } float PtAssignmentEngine2017::scale_pt(const float pt, const int mode) const { - if (not(ptLUTVersion_ >= 6)) { - edm::LogError("L1T") << "ptLUTVersion_ = " << ptLUTVersion_; - return 0; - } + emtf_assert(ptLUTVersion_ >= 6); float pt_xml = -99; float pt_scale = -99; @@ -39,10 +35,7 @@ float PtAssignmentEngine2017::scale_pt(const float pt, const int mode) const { } float PtAssignmentEngine2017::unscale_pt(const float pt, const int mode) const { - if (not(ptLUTVersion_ >= 6)) { - edm::LogError("L1T") << "ptLUTVersion_ = " << ptLUTVersion_; - return 0; - } + emtf_assert(ptLUTVersion_ >= 6); float pt_unscale = -99; @@ -64,10 +57,7 @@ PtAssignmentEngine::address_t PtAssignmentEngine2017::calculate_address(const EM int theta = track.Theta_fp(); int endcap = track.Endcap(); int nHits = (mode / 8) + ((mode % 8) / 4) + ((mode % 4) / 2) + ((mode % 2) / 1); - if (not(nHits > 1 && nHits < 5)) { - edm::LogError("L1T") << "nHits = " << nHits; - return 0; - } + emtf_assert(nHits > 1 && nHits < 5); // 'A' is first station in the track, 'B' the second, etc. int mode_ID = -1; @@ -179,11 +169,7 @@ PtAssignmentEngine::address_t PtAssignmentEngine2017::calculate_address(const EM address |= (frA & ((1 << 1) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2); address |= (mode15_8b & ((1 << 8) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1); address |= (mode_ID & ((1 << 1) - 1)) << (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1 + 8); - if (not(address < pow(2, 30) && address >= pow(2, 29))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } - + emtf_assert(address < pow(2, 30) && address >= pow(2, 29)); } else if (nHits == 3) { int dPhiAB = data.delta_ph[iAB]; int dPhiBC = data.delta_ph[iBC]; @@ -221,16 +207,10 @@ PtAssignmentEngine::address_t PtAssignmentEngine2017::calculate_address(const EM address |= (theta & ((1 << 5) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2); if (mode != 7) { address |= (mode_ID & ((1 << 2) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5); - if (not(address < pow(2, 29) && address >= pow(2, 27))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } + emtf_assert(address < pow(2, 29) && address >= pow(2, 27)); } else { address |= (mode_ID & ((1 << 1) - 1)) << (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5); - if (not(address < pow(2, 27) && address >= pow(2, 26))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } + emtf_assert(address < pow(2, 27) && address >= pow(2, 26)); } } else if (nHits == 2) { @@ -258,10 +238,7 @@ PtAssignmentEngine::address_t PtAssignmentEngine2017::calculate_address(const EM address |= (clctB & ((1 << 3) - 1)) << (0 + 7 + 3 + 1 + 1 + 3); address |= (theta & ((1 << 5) - 1)) << (0 + 7 + 3 + 1 + 1 + 3 + 3); address |= (mode_ID & ((1 << 3) - 1)) << (0 + 7 + 3 + 1 + 1 + 3 + 3 + 5); - if (not(address < pow(2, 26) && address >= pow(2, 24))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } + emtf_assert(address < pow(2, 26) && address >= pow(2, 24)); } return address; } // End function: PtAssignmentEngine2017::calculate_address() @@ -278,10 +255,7 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { float pt_xml = 0.; int nHits = -1, mode = -1; - if (not(address < pow(2, 30))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } + emtf_assert(address < pow(2, 30)); if (address >= pow(2, 29)) { nHits = 4; mode = 15; @@ -318,10 +292,7 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { frA = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2) & ((1 << 1) - 1)); mode15_8b = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1) & ((1 << 8) - 1)); mode_ID = (address >> (0 + 7 + 5 + 4 + 1 + 1 + 2 + 1 + 8) & ((1 << 1) - 1)); - if (not(address < pow(2, 30))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } + emtf_assert(address < pow(2, 30)); } else if (nHits == 3) { dPhiAB = (address >> (0) & ((1 << 7) - 1)); dPhiBC = (address >> (0 + 7) & ((1 << 5) - 1)); @@ -338,16 +309,10 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { theta = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2) & ((1 << 5) - 1)); if (mode != 7) { mode_ID = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5) & ((1 << 2) - 1)); - if (not(address < pow(2, 29))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } + emtf_assert(address < pow(2, 29)); } else { mode_ID = (address >> (0 + 7 + 5 + 1 + 3 + 1 + bit + 2 + 2 + 5) & ((1 << 1) - 1)); - if (not(address < pow(2, 27))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } + emtf_assert(address < pow(2, 27)); } } else if (nHits == 2) { dPhiAB = (address >> (0) & ((1 << 7) - 1)); @@ -358,10 +323,7 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { clctB = (address >> (0 + 7 + 3 + 1 + 1 + 3) & ((1 << 3) - 1)); theta = (address >> (0 + 7 + 3 + 1 + 1 + 3 + 3) & ((1 << 5) - 1)); mode_ID = (address >> (0 + 7 + 3 + 1 + 1 + 3 + 3 + 5) & ((1 << 3) - 1)); - if (not(address < pow(2, 26))) { - edm::LogError("L1T") << "address = " << address; - return 0; - } + emtf_assert(address < pow(2, 26)); } // Infer track mode (and stations with hits) from mode_ID @@ -404,10 +366,7 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { } } - if (not(mode > 0)) { - edm::LogError("L1T") << "mode = " << mode; - return 0; - } + emtf_assert(mode > 0); // Un-compress words from address // For most variables (e.g. theta, dTheta, CLCT) don't need to unpack, since compressed version was used in training @@ -419,8 +378,7 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { aux().unpack8bMode15(mode15_8b, theta, St1_ring2, endcap, (sPhiAB == 1 ? 1 : -1), clctA, rpcA, rpcB, rpcC, rpcD); // // Check bit-wise compression / de-compression - // if (not( dTheta == aux().getdTheta( aux().unpackdTheta( dTheta, 2), 2) ); - // { edm::LogError("L1T") << " = " << ; return; } + // emtf_assert( dTheta == aux().getdTheta( aux().unpackdTheta( dTheta, 2), 2) ); } else if (nHits == 3) { dPhiAB = aux().getdPhiFromBin(dPhiAB, 7, 512); dPhiBC = aux().getdPhiFromBin(dPhiBC, 5, 256) * (sPhiBC == 1 ? 1 : -1); @@ -428,32 +386,25 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { aux().unpack2bRPC(rpc_2b, rpcA, rpcB, rpcC); // // Check bit-wise compression / de-compression - // if (not( dTheta == aux().getdTheta( aux().unpackdTheta( dTheta, 3), 3) ); - // { edm::LogError("L1T") << " = " << ; return; } - // if (not( clctA == aux().getCLCT( aux().unpackCLCT( clctA, endcap, (sPhiAB == 1 ? 1 : -1), 2), + // emtf_assert( dTheta == aux().getdTheta( aux().unpackdTheta( dTheta, 3), 3) ); + // emtf_assert( clctA == aux().getCLCT( aux().unpackCLCT( clctA, endcap, (sPhiAB == 1 ? 1 : -1), 2), // endcap, (sPhiAB == 1 ? 1 : -1), 2) ); - // { edm::LogError("L1T") << " = " << ; return; } // int theta_unp = theta; // aux().unpackTheta( theta_unp, St1_ring2, 5 ); - // if (not( theta == aux().getTheta(theta_unp, St1_ring2, 5) ); - // { edm::LogError("L1T") << " = " << ; return; } + // emtf_assert( theta == aux().getTheta(theta_unp, St1_ring2, 5) ); } else if (nHits == 2) { dPhiAB = aux().getdPhiFromBin(dPhiAB, 7, 512); St1_ring2 = aux().unpackSt1Ring2(theta, 5); // // Check bit-wise compression / de-compression - // if (not( dTheta == aux().getdTheta( aux().unpackdTheta( dTheta, 3), 3) ); - // { edm::LogError("L1T") << " = " << ; return; } - // if (not( clctA == aux().getCLCT( aux().unpackCLCT( clctA, endcap, (sPhiAB == 1 ? 1 : -1), 3), + // emtf_assert( dTheta == aux().getdTheta( aux().unpackdTheta( dTheta, 3), 3) ); + // emtf_assert( clctA == aux().getCLCT( aux().unpackCLCT( clctA, endcap, (sPhiAB == 1 ? 1 : -1), 3), // endcap, (sPhiAB == 1 ? 1 : -1), 3) ); - // { edm::LogError("L1T") << " = " << ; return; } - // if (not( clctB == aux().getCLCT( aux().unpackCLCT( clctB, endcap, (sPhiAB == 1 ? 1 : -1), 3), + // emtf_assert( clctB == aux().getCLCT( aux().unpackCLCT( clctB, endcap, (sPhiAB == 1 ? 1 : -1), 3), // endcap, (sPhiAB == 1 ? 1 : -1), 3) ); - // { edm::LogError("L1T") << " = " << ; return; } // int theta_unp = theta; // aux().unpackTheta( theta_unp, St1_ring2, 5 ); - // if (not( theta == aux().getTheta(theta_unp, St1_ring2, 5) ); - // { edm::LogError("L1T") << " = " << ; return; } + // emtf_assert( theta == aux().getTheta(theta_unp, St1_ring2, 5) ); } // Fill vectors of variables for XMLs @@ -496,8 +447,7 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { } else if (nHits == 2 && mode < 8) { predictors = {theta, dPhiAB, frA, frB, clctA, clctB, dTheta, (clctA == 0), (clctB == 0)}; } else { - edm::LogError("L1T") << "nHits = " << nHits << ", mode = " << mode; - return 0; + emtf_assert(false && "Incorrect nHits or mode"); } // Retreive pT from XMLs diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux2017.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux2017.cc index 662929cde5c2b..a0ff1e3e0776e 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux2017.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux2017.cc @@ -1,8 +1,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" + #include -#include -#include // From here down, exact copy of code used for training BDT: EMTFPtAssign2017/src/PtLUTVarCalc.cc @@ -26,10 +24,7 @@ static const int dPhiNLBMap_7bit_512Max[128] = { 174, 181, 188, 196, 204, 214, 224, 235, 247, 261, 276, 294, 313, 336, 361, 391, 427, 470}; int PtAssignmentEngineAux2017::getNLBdPhi(int dPhi, int bits, int max) const { - if (not((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512))) { - edm::LogError("L1T") << "bits = " << bits << ", max = " << max; - return 0; - } + emtf_assert((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512)); int dPhi_ = max; int sign_ = 1; @@ -70,18 +65,12 @@ int PtAssignmentEngineAux2017::getNLBdPhi(int dPhi, int bits, int max) const { } // End conditional: if (bits == 7) } // End conditional: else if (max == 512) - if (not(abs(sign_) == 1 && dPhi_ >= 0 && dPhi_ < max)) { - edm::LogError("L1T") << "sign_ = " << sign_ << ", dPhi_ = " << dPhi_ << ", max = " << max; - return 0; - } + emtf_assert(abs(sign_) == 1 && dPhi_ >= 0 && dPhi_ < max); return (sign_ * dPhi_); } // End function: nt PtAssignmentEngineAux2017::getNLBdPhi() int PtAssignmentEngineAux2017::getNLBdPhiBin(int dPhi, int bits, int max) const { - if (not((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512))) { - edm::LogError("L1T") << "bits = " << bits << ", max = " << max; - return 0; - } + emtf_assert((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512)); int dPhiBin_ = (1 << bits) - 1; int sign_ = 1; @@ -119,18 +108,12 @@ int PtAssignmentEngineAux2017::getNLBdPhiBin(int dPhi, int bits, int max) const } // End conditional: if (bits == 7) } // End conditional: else if (max == 512) - if (not(dPhiBin_ >= 0 && dPhiBin_ < pow(2, bits))) { - edm::LogError("L1T") << "dPhiBin_ = " << dPhiBin_ << ", bits = " << bits; - return 0; - } + emtf_assert(dPhiBin_ >= 0 && dPhiBin_ < pow(2, bits)); return (dPhiBin_); } // End function: int PtAssignmentEngineAux2017::getNLBdPhiBin() int PtAssignmentEngineAux2017::getdPhiFromBin(int dPhiBin, int bits, int max) const { - if (not((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512))) { - edm::LogError("L1T") << "bits = " << bits << ", max = " << max; - return 0; - } + emtf_assert((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512)); int dPhi_ = (1 << bits) - 1; @@ -149,10 +132,7 @@ int PtAssignmentEngineAux2017::getdPhiFromBin(int dPhiBin, int bits, int max) co dPhi_ = dPhiNLBMap_7bit_512Max[dPhiBin]; } // End conditional: else if (max == 512) - if (not(dPhi_ >= 0 && dPhi_ < max)) { - edm::LogError("L1T") << "dPhi_ = " << dPhi_ << ", max = " << max; - return 0; - } + emtf_assert(dPhi_ >= 0 && dPhi_ < max); return (dPhi_); } // End function: int PtAssignmentEngineAux2017::getdPhiFromBin() @@ -160,11 +140,7 @@ int PtAssignmentEngineAux2017::getCLCT(int clct, int endcap, int dPhiSign, int b // std::cout << "Inside getCLCT: clct = " << clct << ", endcap = " << endcap // << ", dPhiSign = " << dPhiSign << ", bits = " << bits << std::endl; - if (not(clct >= 0 && clct <= 10 && abs(endcap) == 1 && abs(dPhiSign) == 1 && (bits == 2 || bits == 3))) { - edm::LogError("L1T") << "clct = " << clct << ", endcap = " << endcap << ", dPhiSign = " << dPhiSign - << ", bits = " << bits; - return 0; - } + emtf_assert(clct >= 0 && clct <= 10 && abs(endcap) == 1 && abs(dPhiSign) == 1 && (bits == 2 || bits == 3)); // Convention here: endcap == +/-1, dPhiSign = +/-1. int clct_ = 0; @@ -264,10 +240,7 @@ int PtAssignmentEngineAux2017::getCLCT(int clct, int endcap, int dPhiSign, int b // std::cout << " * Output clct_ = " << clct_ << std::endl; - if (not(clct_ >= 0 && clct_ < pow(2, bits))) { - edm::LogError("L1T") << "clct_ = " << clct_ << ", bits = " << bits; - return 0; - } + emtf_assert(clct_ >= 0 && clct_ < pow(2, bits)); return clct_; } // End function: int PtAssignmentEngineAux2017::getCLCT() @@ -275,18 +248,9 @@ int PtAssignmentEngineAux2017::unpackCLCT(int clct, int endcap, int dPhiSign, in // std::cout << "Inside unpackCLCT: clct = " << clct << ", endcap = " << endcap // << ", dPhiSign = " << dPhiSign << ", bits = " << bits << std::endl; - if (not(bits == 2 || bits == 3)) { - edm::LogError("L1T") << "bits = " << bits; - return 0; - } - if (not(clct >= 0 && clct < pow(2, bits))) { - edm::LogError("L1T") << "bits = " << bits << ", clct = " << clct; - return 0; - } - if (not(abs(dPhiSign) == 1)) { - edm::LogError("L1T") << "dPhiSign = " << dPhiSign; - return 0; - } + emtf_assert(bits == 2 || bits == 3); + emtf_assert(clct >= 0 && clct < pow(2, bits)); + emtf_assert(abs(dPhiSign) == 1); // Convention here: endcap == +/-1, dPhiSign = +/-1. int clct_ = -1; @@ -342,18 +306,12 @@ int PtAssignmentEngineAux2017::unpackCLCT(int clct, int endcap, int dPhiSign, in // std::cout << " * Output clct_ = " << clct_ << std::endl; - if (not(clct_ >= 0 && clct_ <= 10)) { - edm::LogError("L1T") << "clct_ = " << clct_; - return 0; - } + emtf_assert(clct_ >= 0 && clct_ <= 10); return clct_; } // End function: int PtAssignmentEngineAux2017::unpackCLCT() int PtAssignmentEngineAux2017::getdTheta(int dTheta, int bits) const { - if (not(bits == 2 || bits == 3)) { - edm::LogError("L1T") << "bits = " << bits; - return 0; - } + emtf_assert(bits == 2 || bits == 3); int dTheta_ = -99; @@ -389,18 +347,13 @@ int PtAssignmentEngineAux2017::getdTheta(int dTheta, int bits) const { dTheta_ = 7; } // End conditional: if (bits == 3) - if (not(dTheta_ >= 0 && dTheta_ < pow(2, bits))) { - edm::LogError("L1T") << "dTheta_ = " << dTheta_ << ", bits = " << bits; - return 0; - } + emtf_assert(dTheta_ >= 0 && dTheta_ < pow(2, bits)); return (dTheta_); } // End function: int PtAssignmentEngineAux2017::getdTheta() int PtAssignmentEngineAux2017::unpackdTheta(int dTheta, int bits) const { - if (not(bits == 2 || bits == 3)) { - edm::LogError("L1T") << "bits = " << bits; - return 0; - } + emtf_assert(bits == 2 || bits == 3); + int dTheta_ = -99; if (bits == 2) { // For use in mode 15 @@ -451,18 +404,12 @@ int PtAssignmentEngineAux2017::unpackdTheta(int dTheta, int bits) const { } } - if (not(dTheta_ >= -4 && dTheta_ <= 3)) { - edm::LogError("L1T") << "dTheta_ = " << dTheta_; - return 0; - } + emtf_assert(dTheta_ >= -4 && dTheta_ <= 3); return (dTheta_); } // End function: int PtAssignmentEngineAux2017::unpackdTheta(int dTheta, int bits) int PtAssignmentEngineAux2017::getTheta(int theta, int st1_ring2, int bits) const { - if (not(theta >= 5 && theta < 128 && (st1_ring2 == 0 || st1_ring2 == 1) && (bits == 4 || bits == 5))) { - edm::LogError("L1T") << "theta = " << theta << ", st1_ring2 = " << st1_ring2 << ", bits = " << bits; - return 0; - } + emtf_assert(theta >= 5 && theta < 128 && (st1_ring2 == 0 || st1_ring2 == 1) && (bits == 4 || bits == 5)); int theta_ = -99; @@ -492,22 +439,13 @@ int PtAssignmentEngineAux2017::getTheta(int theta, int st1_ring2, int bits) cons } } // End conditional: else if (bits == 5) - if (not(theta_ >= 0 && ((bits == 4 && theta_ <= 13) || (bits == 5 && theta_ < pow(2, bits))))) { - edm::LogError("L1T") << "theta_ = " << theta_ << ", bits = " << bits; - return 0; - } + emtf_assert(theta_ >= 0 && ((bits == 4 && theta_ <= 13) || (bits == 5 && theta_ < pow(2, bits)))); return (theta_); } // End function: int PtAssignmentEngineAux2017::getTheta() void PtAssignmentEngineAux2017::unpackTheta(int& theta, int& st1_ring2, int bits) const { - if (not(bits == 4 || bits == 5)) { - edm::LogError("L1T") << "bits = " << bits; - return; - } - if (not(theta >= 0 && theta < pow(2, bits))) { - edm::LogError("L1T") << "theta = " << theta << ", bits = " << bits; - return; - } + emtf_assert(bits == 4 || bits == 5); + emtf_assert(theta >= 0 && theta < pow(2, bits)); // For use in mode 15 if (bits == 4) { @@ -528,22 +466,13 @@ void PtAssignmentEngineAux2017::unpackTheta(int& theta, int& st1_ring2, int bits } } - if (not(theta >= 5 && theta <= 104)) { - edm::LogError("L1T") << "theta = " << theta; - return; - } + emtf_assert(theta >= 5 && theta <= 104); } // End function: void PtAssignmentEngineAux2017::unpackTheta() int PtAssignmentEngineAux2017::unpackSt1Ring2(int theta, int bits) const { - if (not(bits == 4 || bits == 5)) { - edm::LogError("L1T") << "bits = " << bits; - return 0; - } - if (not(theta >= 0 && theta < pow(2, bits))) { - edm::LogError("L1T") << "theta = " << theta << ", bits = " << bits; - return 0; - } + emtf_assert(bits == 4 || bits == 5); + emtf_assert(theta >= 0 && theta < pow(2, bits)); // For use in mode 15 if (bits == 4) { @@ -572,18 +501,12 @@ int PtAssignmentEngineAux2017::get2bRPC(int clctA, int clctB, int clctC) const { else rpc_2b = 3; - if (not(rpc_2b >= 0 && rpc_2b < 4)) { - edm::LogError("L1T") << "rpc_2b = " << rpc_2b; - return 0; - } + emtf_assert(rpc_2b >= 0 && rpc_2b < 4); return (rpc_2b); } // End function: int PtAssignmentEngineAux2017::get2bRPC() void PtAssignmentEngineAux2017::unpack2bRPC(int rpc_2b, int& rpcA, int& rpcB, int& rpcC) const { - if (not(rpc_2b >= 0 && rpc_2b < 4)) { - edm::LogError("L1T") << "rpc_2b = " << rpc_2b; - return; - } + emtf_assert(rpc_2b >= 0 && rpc_2b < 4); rpcA = 0; rpcB = 0; @@ -607,10 +530,8 @@ int PtAssignmentEngineAux2017::get8bMode15( theta = (std::min(std::max(theta, 46), 87) - 46) / 7; else theta = (std::min(std::max(theta, 5), 52) - 5) / 6; - if (not(theta >= 0 && theta < 10)) { - edm::LogError("L1T") << "theta = " << theta; - return 0; - } + + emtf_assert(theta >= 0 && theta < 10); int clctA_2b = getCLCT(clctA, endcap, sPhiAB, 2); @@ -657,10 +578,7 @@ int PtAssignmentEngineAux2017::get8bMode15( // std::cout << " * Output mode15_8b = " << mode15_8b << std::endl; - if (not(mode15_8b >= 0 && mode15_8b < pow(2, 8))) { - edm::LogError("L1T") << "mode15_8b = " << mode15_8b; - return 0; - } + emtf_assert(mode15_8b >= 0 && mode15_8b < pow(2, 8)); return (mode15_8b); } // End function: int PtAssignmentEngineAux2017::get8bMode15() @@ -679,14 +597,8 @@ void PtAssignmentEngineAux2017::unpack8bMode15(int mode15_8b, // << ", st1_ring2 = " << st1_ring2 << ", endcap = " << endcap << ", sPhiAB = " << sPhiAB << ", clctA = " << clctA // << ", rpcA = " << rpcA << ", rpcB = " << rpcB << ", rpcC = " << rpcC << ", rpcD = " << rpcD << std::endl; - if (not(mode15_8b >= 0 && mode15_8b < pow(2, 8))) { - edm::LogError("L1T") << "mode15_8b = " << mode15_8b; - return; - } - if (not(abs(endcap) == 1 && abs(sPhiAB) == 1)) { - edm::LogError("L1T") << "endcap = " << endcap << ", sPhiAB = " << sPhiAB; - return; - } + emtf_assert(mode15_8b >= 0 && mode15_8b < pow(2, 8)); + emtf_assert(abs(endcap) == 1 && abs(sPhiAB) == 1); rpcA = 0; rpcB = 0; @@ -803,9 +715,6 @@ void PtAssignmentEngineAux2017::unpack8bMode15(int mode15_8b, // std::cout << " * Output theta = " << theta << ", st1_ring2 = " << st1_ring2 << ", clctA = " << clctA // << ", rpcA = " << rpcA << ", rpcB = " << rpcB << ", rpcC = " << rpcC << ", rpcD = " << rpcD << std::endl; - if (not(nRPC >= 0)) { - edm::LogError("L1T") << "nRPC = " << nRPC; - return; - } + emtf_assert(nRPC >= 0); } // End function: void PtAssignmentEngineAux2017::unpack8bMode15() diff --git a/L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc b/L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc index 22d1d8ec8acf9..5c5a3e6ef1ba4 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc @@ -1,8 +1,7 @@ -#include -#include #include "L1Trigger/L1TMuonEndCap/interface/PtLUTVarCalc.h" #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include // From here down, exact copy of code used for training BDT: EMTFPtAssign2017/src/PtLUTVarCalc.cc @@ -24,10 +23,7 @@ int CalcTrackTheta(const int th1, else if ((mode % 2) > 0) // Has station 4 hit theta = th4; - if (not(theta > 0)) { - edm::LogError("L1T") << "theta = " << theta; - return 0; - } + emtf_assert(theta > 0); if (BIT_COMP) { int nBits = (mode == 15 ? 4 : 5); @@ -80,10 +76,7 @@ void CalcDeltaPhis(int& dPh12, dPhSign = (dPh34 >= 0 ? +1 : -1); } - if (not(dPhSign != 0)) { - edm::LogError("L1T") << "dPhSign = " << dPhSign; - return; - } + emtf_assert(dPhSign != 0); dPh12 *= dPhSign; dPh13 *= dPhSign; @@ -304,10 +297,7 @@ int CalcBendFromPattern(const int pattern, const int endcap) { if (endcap == 1) bend *= -1; - if (not(bend != -99)) { - edm::LogError("L1T") << "bend = " << bend; - return 0; - } + emtf_assert(bend != -99); return bend; } diff --git a/L1Trigger/L1TMuonEndCap/src/PtLUTWriter.cc b/L1Trigger/L1TMuonEndCap/src/PtLUTWriter.cc index 16ad88598d7e8..708d8c4cb7dd3 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtLUTWriter.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtLUTWriter.cc @@ -4,7 +4,6 @@ #include #include #include -#include #define PTLUT_SIZE (1 << 30) diff --git a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc index ac3c82b57c12e..d8559eae3c25e 100644 --- a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc @@ -49,13 +49,13 @@ void SectorProcessor::configure(const GeometryTranslator* tp_geom, bool bugGMTPhi, bool promoteMode7, int modeQualVer) { - assert(emtf::MIN_ENDCAP <= endcap && endcap <= emtf::MAX_ENDCAP); - assert(emtf::MIN_TRIGSECTOR <= sector && sector <= emtf::MAX_TRIGSECTOR); + emtf_assert(emtf::MIN_ENDCAP <= endcap && endcap <= emtf::MAX_ENDCAP); + emtf_assert(emtf::MIN_TRIGSECTOR <= sector && sector <= emtf::MAX_TRIGSECTOR); - assert(tp_geom != nullptr); - assert(cond != nullptr); - assert(lut != nullptr); - assert(pt_assign_engine != nullptr); + emtf_assert(tp_geom != nullptr); + emtf_assert(cond != nullptr); + emtf_assert(lut != nullptr); + emtf_assert(pt_assign_engine != nullptr); tp_geom_ = tp_geom; cond_ = cond; diff --git a/L1Trigger/L1TMuonEndCap/src/SectorProcessorLUT.cc b/L1Trigger/L1TMuonEndCap/src/SectorProcessorLUT.cc index ea9c70b1e0398..05ee91ce85327 100644 --- a/L1Trigger/L1TMuonEndCap/src/SectorProcessorLUT.cc +++ b/L1Trigger/L1TMuonEndCap/src/SectorProcessorLUT.cc @@ -1,6 +1,5 @@ #include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" -#include #include #include @@ -356,7 +355,7 @@ void SectorProcessorLUT::read_cppf_file(const std::string& filename, size_t ph_index = (th_index * 64) + (halfstrip - 1); // std::cout << id << " " << rpc_region << " " << rpc_sector << " " << rpc_station << " " << rpc_ring << " " - // << rpc_subsector << " " << rpc_roll << " " << halfstrip << " " << th_index << " " << ph_index << std::endl; + // << rpc_subsector << " " << rpc_roll << " " << halfstrip << " " << th_index << " " << ph_index << std::endl; vec1.at(ph_index) = ph; if (halfstrip == 1) diff --git a/L1Trigger/L1TMuonEndCap/src/SingleHitTrack.cc b/L1Trigger/L1TMuonEndCap/src/SingleHitTrack.cc index ea42050078d19..dad0e51241799 100644 --- a/L1Trigger/L1TMuonEndCap/src/SingleHitTrack.cc +++ b/L1Trigger/L1TMuonEndCap/src/SingleHitTrack.cc @@ -88,8 +88,7 @@ void SingleHitTrack::process(const EMTFHitCollection& conv_hits, EMTFTrackCollec else if (zone_code & 0b0001) zone = 1; else { - edm::LogError("L1T") << "EMTF SingleHitTrack.cc - bizzare case where zone_code = " << zone_code; - return; + emtf_assert(false && "Incorrect zone_code"); } EMTFTrack new_trk; diff --git a/L1Trigger/L1TMuonEndCap/src/helper.h b/L1Trigger/L1TMuonEndCap/src/helper.h index 45d774d06f07f..9dc44b3248691 100644 --- a/L1Trigger/L1TMuonEndCap/src/helper.h +++ b/L1Trigger/L1TMuonEndCap/src/helper.h @@ -4,20 +4,6 @@ #include #include #include -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -// Need a safe assertion function -#ifdef NDEBUG -#define assert_no_abort(expr) ((void)0) -#else -#define assert_no_abort(expr) ((void)((expr) || (__assert_no_abort(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__), 0))) -template -void __assert_no_abort(const char* assertion, const char* file, unsigned int line, const char* function) { - //std::cout << file << ":" << line << ": " << function << ": Assertion `" << assertion << "' failed. (no abort)" << std::endl; - edm::LogWarning("L1T") << file << ":" << line << ": " << function << ": Assertion `" << assertion - << "' failed. (no abort)"; -} -#endif namespace { From 1ed373b4cb1281a3d58d3efb2a97b622585ea4be Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Sat, 2 May 2020 03:03:09 -0400 Subject: [PATCH 22/34] [EMTF] Add DebugTools 4/4 --- .../L1TMuonEndCap/interface/DebugTools.h | 12 +- L1Trigger/L1TMuonEndCap/src/DebugTools.cc | 105 +++++++++++++++++ L1Trigger/L1TMuonEndCap/src/TrackFinder.cc | 108 ++---------------- 3 files changed, 125 insertions(+), 100 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/DebugTools.h b/L1Trigger/L1TMuonEndCap/interface/DebugTools.h index 178367e80bc59..7aabb4fdf77c1 100644 --- a/L1Trigger/L1TMuonEndCap/interface/DebugTools.h +++ b/L1Trigger/L1TMuonEndCap/interface/DebugTools.h @@ -3,6 +3,12 @@ #include +#include "DataFormats/L1TMuon/interface/EMTFHit.h" +#include "DataFormats/L1TMuon/interface/EMTFRoad.h" +#include "DataFormats/L1TMuon/interface/EMTFTrack.h" +#include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h" +#include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h" + // Uncomment the following line to use assert #define EMTF_ALLOW_ASSERT @@ -12,6 +18,10 @@ #define emtf_assert(expr) ((void)(expr)) #endif -namespace emtf {} // namespace emtf +namespace emtf { + + void dump_fw_raw_input(const l1t::EMTFHitCollection& out_hits, const l1t::EMTFTrackCollection& out_tracks); + +} // namespace emtf #endif diff --git a/L1Trigger/L1TMuonEndCap/src/DebugTools.cc b/L1Trigger/L1TMuonEndCap/src/DebugTools.cc index 9f18d2723ffbd..5252bba54f874 100644 --- a/L1Trigger/L1TMuonEndCap/src/DebugTools.cc +++ b/L1Trigger/L1TMuonEndCap/src/DebugTools.cc @@ -1 +1,106 @@ #include "L1Trigger/L1TMuonEndCap/interface/DebugTools.h" + +namespace emtf { + + void dump_fw_raw_input(const l1t::EMTFHitCollection& out_hits, const l1t::EMTFTrackCollection& out_tracks) { + // from interface/Common.h + typedef L1TMuon::TriggerPrimitive TriggerPrimitive; + constexpr int MIN_ENDCAP = 1; + constexpr int MAX_ENDCAP = 2; + constexpr int MIN_TRIGSECTOR = 1; + constexpr int MAX_TRIGSECTOR = 6; + + for (int endcap = MIN_ENDCAP; endcap <= MAX_ENDCAP; ++endcap) { + for (int sector = MIN_TRIGSECTOR; sector <= MAX_TRIGSECTOR; ++sector) { + const int es = (endcap - MIN_ENDCAP) * (MAX_TRIGSECTOR - MIN_TRIGSECTOR + 1) + (sector - MIN_TRIGSECTOR); + + // _____________________________________________________________________ + // This prints the hits as raw text input to the firmware simulator + // "12345" is the BX separator + + std::cout << "==== Endcap " << endcap << " Sector " << sector << " Hits ====" << std::endl; + std::cout << "bx e s ss st vf ql cp wg id bd hs" << std::endl; + + bool empty_sector = true; + for (const auto& h : out_hits) { + if (h.Sector_idx() != es) + continue; + empty_sector = false; + } + + for (int ibx = -3 - 5; (ibx < +3 + 5 + 5) && !empty_sector; ++ibx) { + for (const auto& h : out_hits) { + if (h.Subsystem() == TriggerPrimitive::kCSC) { + if (h.Sector_idx() != es) + continue; + if (h.BX() != ibx) + continue; + + int bx = 1; + int endcap = (h.Endcap() == 1) ? 1 : 2; + int sector = h.PC_sector(); + int station = (h.PC_station() == 0 && h.Subsector() == 1) ? 1 : h.PC_station(); + int chamber = h.PC_chamber() + 1; + int strip = (h.Station() == 1 && h.Ring() == 4) ? h.Strip() + 128 : h.Strip(); // ME1/1a + int wire = h.Wire(); + int valid = 1; + std::cout << bx << " " << endcap << " " << sector << " " << h.Subsector() << " " << station << " " + << valid << " " << h.Quality() << " " << h.Pattern() << " " << wire << " " << chamber << " " + << h.Bend() << " " << strip << std::endl; + + } else if (h.Subsystem() == TriggerPrimitive::kRPC) { + if (h.Sector_idx() != es) + continue; + if (h.BX() + 6 != ibx) + continue; // RPC hits should be supplied 6 BX later relative to CSC hits + + // Assign RPC link index. Code taken from src/PrimitiveSelection.cc + int rpc_sub = -1; + int rpc_chm = -1; + if (!h.Neighbor()) { + rpc_sub = ((h.Subsector_RPC() + 3) % 6); + } else { + rpc_sub = 6; + } + if (h.Station() <= 2) { + rpc_chm = (h.Station() - 1); + } else { + rpc_chm = 2 + (h.Station() - 3) * 2 + (h.Ring() - 2); + } + + int bx = 1; + int endcap = (h.Endcap() == 1) ? 1 : 2; + int sector = h.PC_sector(); + int station = rpc_sub; + int chamber = rpc_chm + 1; + int strip = (h.Phi_fp() >> 2); + int wire = (h.Theta_fp() >> 2); + int valid = 2; // this marks RPC stub + std::cout << bx << " " << endcap << " " << sector << " " << 0 << " " << station << " " << valid << " " + << 0 << " " << 0 << " " << wire << " " << chamber << " " << 0 << " " << strip << std::endl; + } + } // end loop over hits + + std::cout << "12345" << std::endl; + } // end loop over bx + + // _____________________________________________________________________ + // This prints the tracks as raw text output from the firmware simulator + + std::cout << "==== Endcap " << endcap << " Sector " << sector << " Tracks ====" << std::endl; + std::cout << "bx e s a mo et ph cr q pt" << std::endl; + + for (const auto& t : out_tracks) { + if (t.Sector_idx() != es) + continue; + + std::cout << t.BX() << " " << (t.Endcap() == 1 ? 1 : 2) << " " << t.Sector() << " " << t.PtLUT().address + << " " << t.Mode() << " " << (t.GMT_eta() >= 0 ? t.GMT_eta() : t.GMT_eta() + 512) << " " + << t.GMT_phi() << " " << t.GMT_charge() << " " << t.GMT_quality() << " " << t.Pt() << std::endl; + } // end loop over tracks + + } // end loop over sector + } // end loop over endcap + } + +} // namespace emtf diff --git a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc index a3d3a7871a6b6..cd72216f768ce 100644 --- a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc @@ -228,108 +228,18 @@ void TrackFinder::process(const edm::Event& iEvent, } // ___________________________________________________________________________ - // Check emulator input and output. They are printed in a way that is friendly - // for comparison with the firmware simulator. - if (verbose_ > 0) { // debug std::cout << "Run number: " << iEvent.id().run() << " pc_lut_ver: " << condition_helper_.get_pc_lut_version() - << " pt_lut_ver: " << condition_helper_.get_pt_lut_version() << ", " - << pt_assign_engine_->get_pt_lut_version() << " fw_ver: " << condition_helper_.get_fw_version() - << std::endl; - - for (int endcap = emtf::MIN_ENDCAP; endcap <= emtf::MAX_ENDCAP; ++endcap) { - for (int sector = emtf::MIN_TRIGSECTOR; sector <= emtf::MAX_TRIGSECTOR; ++sector) { - const int es = (endcap - emtf::MIN_ENDCAP) * (emtf::MAX_TRIGSECTOR - emtf::MIN_TRIGSECTOR + 1) + - (sector - emtf::MIN_TRIGSECTOR); - - // _____________________________________________________________________ - // This prints the hits as raw text input to the firmware simulator - // "12345" is the BX separator - - std::cout << "==== Endcap " << endcap << " Sector " << sector << " Hits ====" << std::endl; - std::cout << "bx e s ss st vf ql cp wg id bd hs" << std::endl; - - bool empty_sector = true; - for (const auto& h : out_hits) { - if (h.Sector_idx() != es) - continue; - empty_sector = false; - } - - for (int ibx = -3 - 5; (ibx < +3 + 5 + 5) && !empty_sector; ++ibx) { - for (const auto& h : out_hits) { - if (h.Subsystem() == TriggerPrimitive::kCSC) { - if (h.Sector_idx() != es) - continue; - if (h.BX() != ibx) - continue; - - int bx = 1; - int endcap = (h.Endcap() == 1) ? 1 : 2; - int sector = h.PC_sector(); - int station = (h.PC_station() == 0 && h.Subsector() == 1) ? 1 : h.PC_station(); - int chamber = h.PC_chamber() + 1; - int strip = (h.Station() == 1 && h.Ring() == 4) ? h.Strip() + 128 : h.Strip(); // ME1/1a - int wire = h.Wire(); - int valid = 1; - std::cout << bx << " " << endcap << " " << sector << " " << h.Subsector() << " " << station << " " - << valid << " " << h.Quality() << " " << h.Pattern() << " " << wire << " " << chamber << " " - << h.Bend() << " " << strip << std::endl; - - } else if (h.Subsystem() == TriggerPrimitive::kRPC) { - if (h.Sector_idx() != es) - continue; - if (h.BX() + 6 != ibx) - continue; // RPC hits should be supplied 6 BX later relative to CSC hits - - // Assign RPC link index. Code taken from src/PrimitiveSelection.cc - int rpc_sub = -1; - int rpc_chm = -1; - if (!h.Neighbor()) { - rpc_sub = h.Subsector() - 1; - } else { - rpc_sub = 6; - } - if (h.Station() <= 2) { - rpc_chm = (h.Station() - 1); - } else { - rpc_chm = 2 + (h.Station() - 3) * 2 + (h.Ring() - 2); - } - - int bx = 1; - int endcap = (h.Endcap() == 1) ? 1 : 2; - int sector = h.PC_sector(); - int station = rpc_sub; - int chamber = rpc_chm + 1; - int strip = (h.Phi_fp() >> 2); - int wire = (h.Theta_fp() >> 2); - int valid = 2; // this marks RPC stub - std::cout << bx << " " << endcap << " " << sector << " " << 0 << " " << station << " " << valid << " " - << 0 << " " << 0 << " " << wire << " " << chamber << " " << 0 << " " << strip << std::endl; - } - } // end loop over hits - - std::cout << "12345" << std::endl; - } // end loop over bx - - // _____________________________________________________________________ - // This prints the tracks as raw text output from the firmware simulator - - std::cout << "==== Endcap " << endcap << " Sector " << sector << " Tracks ====" << std::endl; - std::cout << "bx e s a mo et ph cr q pt" << std::endl; - - for (const auto& t : out_tracks) { - if (t.Sector_idx() != es) - continue; - - std::cout << t.BX() << " " << (t.Endcap() == 1 ? 1 : 2) << " " << t.Sector() << " " << t.PtLUT().address - << " " << t.Mode() << " " << (t.GMT_eta() >= 0 ? t.GMT_eta() : t.GMT_eta() + 512) << " " - << t.GMT_phi() << " " << t.GMT_charge() << " " << t.GMT_quality() << " " << t.Pt() << std::endl; - } // end loop over tracks + << " pt_lut_ver: " << condition_helper_.get_pt_lut_version() + << " pt_lut_ver in engine: " << pt_assign_engine_->get_pt_lut_version() + << " fw_ver: " << condition_helper_.get_fw_version() << std::endl; + } - } // end loop over sector - } // end loop over endcap - } // end debug + if (verbose_ > 1) { // debug + // Check emulator input and output. They are printed as raw text that is + // used by the firmware simulator to do comparisons. + emtf::dump_fw_raw_input(out_hits, out_tracks); + } return; } From 225e727009a8f2872751f0ca341bbc621b75e576 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Thu, 7 May 2020 09:51:57 -0400 Subject: [PATCH 23/34] [EMTF] Add EMTFSetup & VersionControl 1/6 --- .../L1TMuonEndCap/interface/VersionControl.h | 61 ++++ L1Trigger/L1TMuonEndCap/src/VersionControl.cc | 331 ++++++++++++++++++ 2 files changed, 392 insertions(+) create mode 100644 L1Trigger/L1TMuonEndCap/interface/VersionControl.h create mode 100644 L1Trigger/L1TMuonEndCap/src/VersionControl.cc diff --git a/L1Trigger/L1TMuonEndCap/interface/VersionControl.h b/L1Trigger/L1TMuonEndCap/interface/VersionControl.h new file mode 100644 index 0000000000000..468a5865c636a --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/interface/VersionControl.h @@ -0,0 +1,61 @@ +#ifndef L1TMuonEndCap_VersionControl_h +#define L1TMuonEndCap_VersionControl_h + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class SectorProcessor; + +class VersionControl { +public: + explicit VersionControl(const edm::ParameterSet& iConfig); + ~VersionControl(); + + // Modify the configurables based on FW version + void configure_by_fw_version(unsigned fw_version); + + // Getters + const edm::ParameterSet& getConfig() const { return config_; } + int verbose() const { return verbose_; } + bool useO2O() const { return useO2O_; } + std::string era() const { return era_; } + + friend class SectorProcessor; // allow access to private memebers + +private: + // All the configurables from python/simEmtfDigis_cfi.py must be visible to this class, except InputTags. + const edm::ParameterSet config_; + + int verbose_; + bool useO2O_; + std::string era_; + + // Trigger primitives & BX settings + bool useDT_, useCSC_, useRPC_, useIRPC_, useCPPF_, useGEM_, useME0_; + int minBX_, maxBX_, bxWindow_, bxShiftCSC_, bxShiftRPC_, bxShiftGEM_, bxShiftME0_; + + // For primitive conversion + std::vector zoneBoundaries_; + int zoneOverlap_; + bool includeNeighbor_, duplicateTheta_, fixZonePhi_, useNewZones_, fixME11Edges_; + + // For pattern recognition + std::vector pattDefinitions_, symPattDefinitions_; + bool useSymPatterns_; + + // For track building + int thetaWindow_, thetaWindowZone0_; + bool useSingleHits_; + bool bugSt2PhDiff_, bugME11Dupes_, bugAmbigThetaWin_, twoStationSameBX_; + + // For ghost cancellation + int maxRoadsPerZone_, maxTracks_; + bool useSecondEarliest_; + bool bugSameSectorPt0_; + + // For pt assignment + bool readPtLUTFile_, fixMode15HighPt_; + bool bug9BitDPhi_, bugMode7CLCT_, bugNegPt_, bugGMTPhi_, promoteMode7_; + int modeQualVer_; +}; + +#endif diff --git a/L1Trigger/L1TMuonEndCap/src/VersionControl.cc b/L1Trigger/L1TMuonEndCap/src/VersionControl.cc new file mode 100644 index 0000000000000..a518296cbd1ad --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/src/VersionControl.cc @@ -0,0 +1,331 @@ +#include "L1Trigger/L1TMuonEndCap/interface/VersionControl.h" + +VersionControl::VersionControl(const edm::ParameterSet& iConfig) : config_(iConfig) { + // All the configurables from python/simEmtfDigis_cfi.py must be visible to this class, except InputTags. + verbose_ = iConfig.getUntrackedParameter("verbosity"); + useO2O_ = iConfig.getParameter("FWConfig"); + era_ = iConfig.getParameter("Era"); + + useDT_ = iConfig.getParameter("DTEnable"); + useCSC_ = iConfig.getParameter("CSCEnable"); + useRPC_ = iConfig.getParameter("RPCEnable"); + useIRPC_ = iConfig.getParameter("IRPCEnable"); + useCPPF_ = iConfig.getParameter("CPPFEnable"); + useGEM_ = iConfig.getParameter("GEMEnable"); + useME0_ = iConfig.getParameter("ME0Enable"); + + minBX_ = iConfig.getParameter("MinBX"); + maxBX_ = iConfig.getParameter("MaxBX"); + bxWindow_ = iConfig.getParameter("BXWindow"); + bxShiftCSC_ = iConfig.getParameter("CSCInputBXShift"); + bxShiftRPC_ = iConfig.getParameter("RPCInputBXShift"); + bxShiftGEM_ = iConfig.getParameter("GEMInputBXShift"); + bxShiftME0_ = iConfig.getParameter("ME0InputBXShift"); + + auto spPCParams16 = iConfig.getParameter("spPCParams16"); + zoneBoundaries_ = spPCParams16.getParameter >("ZoneBoundaries"); + zoneOverlap_ = spPCParams16.getParameter("ZoneOverlap"); + includeNeighbor_ = spPCParams16.getParameter("IncludeNeighbor"); + duplicateTheta_ = spPCParams16.getParameter("DuplicateTheta"); + fixZonePhi_ = spPCParams16.getParameter("FixZonePhi"); + useNewZones_ = spPCParams16.getParameter("UseNewZones"); + fixME11Edges_ = spPCParams16.getParameter("FixME11Edges"); + + auto spPRParams16 = iConfig.getParameter("spPRParams16"); + pattDefinitions_ = spPRParams16.getParameter >("PatternDefinitions"); + symPattDefinitions_ = spPRParams16.getParameter >("SymPatternDefinitions"); + useSymPatterns_ = spPRParams16.getParameter("UseSymmetricalPatterns"); + + auto spTBParams16 = iConfig.getParameter("spTBParams16"); + thetaWindow_ = spTBParams16.getParameter("ThetaWindow"); + thetaWindowZone0_ = spTBParams16.getParameter("ThetaWindowZone0"); + useSingleHits_ = spTBParams16.getParameter("UseSingleHits"); + bugSt2PhDiff_ = spTBParams16.getParameter("BugSt2PhDiff"); + bugME11Dupes_ = spTBParams16.getParameter("BugME11Dupes"); + bugAmbigThetaWin_ = spTBParams16.getParameter("BugAmbigThetaWin"); + twoStationSameBX_ = spTBParams16.getParameter("TwoStationSameBX"); + + auto spGCParams16 = iConfig.getParameter("spGCParams16"); + maxRoadsPerZone_ = spGCParams16.getParameter("MaxRoadsPerZone"); + maxTracks_ = spGCParams16.getParameter("MaxTracks"); + useSecondEarliest_ = spGCParams16.getParameter("UseSecondEarliest"); + bugSameSectorPt0_ = spGCParams16.getParameter("BugSameSectorPt0"); + + auto spPAParams16 = iConfig.getParameter("spPAParams16"); + readPtLUTFile_ = spPAParams16.getParameter("ReadPtLUTFile"); + fixMode15HighPt_ = spPAParams16.getParameter("FixMode15HighPt"); + bug9BitDPhi_ = spPAParams16.getParameter("Bug9BitDPhi"); + bugMode7CLCT_ = spPAParams16.getParameter("BugMode7CLCT"); + bugNegPt_ = spPAParams16.getParameter("BugNegPt"); + bugGMTPhi_ = spPAParams16.getParameter("BugGMTPhi"); + promoteMode7_ = spPAParams16.getParameter("PromoteMode7"); + modeQualVer_ = spPAParams16.getParameter("ModeQualVer"); +} + +VersionControl::~VersionControl() {} + +// Refer to docs/EMTF_FW_LUT_versions_2016_draft2.xlsx +void VersionControl::configure_by_fw_version(unsigned fw_version) { + if (fw_version == 0 || fw_version == 123456) // fw_version '123456' is from the fake conditions + return; + + // For now, no switches later than FW version 47864 (end-of-year 2016) + // Beggining in late 2016, "fw_version" in O2O populated with timestamp, rather than FW version + // tm fw_time = gmtime(fw_version); (See https://linux.die.net/man/3/gmtime, https://www.epochconverter.com) + + ///////////////////////////////////////////////////////////////////////////////// + /// Settings for 2018 (by default just use settings in simEmtfDigis_cfi.py) /// + ///////////////////////////////////////////////////////////////////////////////// + if (fw_version >= 1514764800) { // January 1, 2018 + + // Settings for all of 2018 (following order in simEmtfDigis_cfi.py) + // BXWindow(2) and BugAmbigThetaWin(F) deployed sometime before stable beams on March 20, not quite sure when - AWB 26.04.18 + // TwoStationSameBX(T), ThetaWindowZone0(4), and ModeQualVer(2) to be deployed sometime between May 17 and May 31 - AWB 14.05.18 + + // Global parameters + // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2) + // -------------------------------------------------------------------------------------------------------- + era_ = "Run2_2018"; // Era for CMSSW customization + bxWindow_ = 2; // Number of BX whose primitives can be included in the same track + + // spTBParams16 : Sector processor track-building parameters + // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T), + // DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T) + // ------------------------------------------------------------------------------ + + // spPRParams16 : Sector processor pattern-recognition parameters + // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T) + // ----------------------------------------------------------------------------------------- + + // spTBParams16 : Sector processor track-building parameters + // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F), + // BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T) + // ---------------------------------------------------------------------------------- + thetaWindow_ = 8; // Maximum dTheta between primitives in the same track + thetaWindowZone0_ = 4; // Maximum dTheta between primitives in the same track in Zone 0 (ring 1) + bugAmbigThetaWin_ = false; // Can allow dThetas outside window when there are 2 LCTs in the same chamber + twoStationSameBX_ = true; // Requires the hits in two-station tracks to have the same BX + + // spGCParams16 : Sector processor ghost-cancellation parameters + // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F) + // -------------------------------------------------------------------------------------- + + // spPAParams16 : Sector processor pt-assignment parameters + // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F), + // BugNegPt(F), BugGMTPhi(F), PromoteMode7(F), ModeQualVer(2) + // --------------------------------------------------------------------------------- + modeQualVer_ = 2; // Version 2 contains modified mode-quality mapping for 2018 + promoteMode7_ = false; // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality + + // ___________________________________________________________________________ + // Versions in 2018 - no external documentation + // As of the beginning of 2018 EMTF O2O was broken, not updating the database with online conditions + // Firmware version reported for runs before 318841 (June 28) is 1504018578 (Aug. 29, 2017) even though + // updates occured in February and March of 2018. May need to re-write history in the database. - AWB 30.06.18 + + if (fw_version < 1529520380) { // June 20, 2018 + thetaWindowZone0_ = 8; // Maximum dTheta between primitives in the same track in Zone 0 (ring 1) + twoStationSameBX_ = false; // Requires the hits in two-station tracks to have the same BX + modeQualVer_ = 1; // Version 2 contains modified mode-quality mapping for 2018 + promoteMode7_ = true; // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality + } + + return; + } + + ///////////////////////////////////////////////////////////////////////////////// + /// Settings for 2017 (by default just use settings in simEmtfDigis_cfi.py) /// + ///////////////////////////////////////////////////////////////////////////////// + else if (fw_version >= 50000) { + // Settings for all of 2017 (following order in simEmtfDigis_cfi.py) + + // Global parameters + // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2) + // -------------------------------------------------------------------------------------------------------- + era_ = "Run2_2017"; // Era for CMSSW customization + bxWindow_ = 3; // Number of BX whose primitives can be included in the same track + + // spTBParams16 : Sector processor track-building parameters + // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T), + // DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T) + // ------------------------------------------------------------------------------ + + // spPRParams16 : Sector processor pattern-recognition parameters + // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T) + // ----------------------------------------------------------------------------------------- + + // spTBParams16 : Sector processor track-building parameters + // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F), + // BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T) + // ---------------------------------------------------------------------------------- + thetaWindow_ = 8; // Maximum dTheta between primitives in the same track + thetaWindowZone0_ = 8; // Maximum dTheta between primitives in the same track in Zone 0 (ring 1) + bugAmbigThetaWin_ = true; // Can allow dThetas outside window when there are 2 LCTs in the same chamber + twoStationSameBX_ = false; // Requires the hits in two-station tracks to have the same BX + + // spGCParams16 : Sector processor ghost-cancellation parameters + // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F) + // -------------------------------------------------------------------------------------- + + // spPAParams16 : Sector processor pt-assignment parameters + // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F), + // BugNegPt(F), BugGMTPhi(F), PromoteMode7(F) + // --------------------------------------------------------------------------------- + modeQualVer_ = 1; // Version 2 contains modified mode-quality mapping for 2018 + + // ___________________________________________________________________________ + // Versions in 2017 - no full documentation, can refer to https://twiki.cern.ch/twiki/bin/viewauth/CMS/L1KnownIssues + + // Before July 9th (runs < 298653), all mode 7 tracks (station 2-3-4) assigned quality 11 + // July 9th - 29th (runs 298653 - 300087), mode 7 tracks with |eta| > 1.6 in sector -6 assigned quality 12 + // After July 29th (runs >= 300088), mode 7 track promotion applied in all sectors + // For some reason, the FW version in the database is 1496792995, at least for runs >= 298034 (July 4), + // which is towards the end of run 2017B (could not check earlier runs). This corresponds to the date "June 6th", + // which is a month earlier than the first firmware update to apply this promotion. So something's screwey. + // Since July 18 is in the middle of the single-sector-fix period, would like to use a firmware version with + // roughly that date. But this may require an intervention in the database. - AWB 04.08.17 + // Last firmware version in 2017 was 1504018578 (Aug. 29, 2017). + if (fw_version >= 1496792995) + promoteMode7_ = true; // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality + + return; + } + + /////////////////////////////////////////////////////////////////////////// + /// Settings for all of 2016 (following order in simEmtfDigis_cfi.py) /// + /////////////////////////////////////////////////////////////////////////// + else { + // Global parameters + // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2) + // -------------------------------------------------------------------------------------------------------- + useRPC_ = false; // Use clustered RPC hits from CPPF in track-building + era_ = "Run2_2016"; // Era for CMSSW customization + // maxBX_ // Depends on FW version, see below + bxWindow_ = 3; // Number of BX whose primitives can be included in the same track + + // spTBParams16 : Sector processor track-building parameters + // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T), + // DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T) + // ------------------------------------------------------------------------------ + // primConvLUT_ // Should be 0 for 2016, set using get_pc_lut_version() from ConditionsHelper.cc + // fixZonePhi_ // Depends on FW version, see below + fixME11Edges_ = false; // Improved small fraction of buggy LCT coordinate transformations + + // spPRParams16 : Sector processor pattern-recognition parameters + // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T) + // ----------------------------------------------------------------------------------------- + // useSymPatterns_ // Depends on FW version, see below + + // spTBParams16 : Sector processor track-building parameters + // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F), + // BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T) + // ---------------------------------------------------------------------------------- + thetaWindow_ = 4; // Maximum dTheta between primitives in the same track + thetaWindowZone0_ = 4; // Maximum dTheta between primitives in the same track in Zone 0 (ring 1) + // bugSt2PhDiff_ // Depends on FW version, see below + // bugME11Dupes_ // Depends on FW version, see below + bugAmbigThetaWin_ = true; // Can allow dThetas outside window when there are 2 LCTs in the same chamber + twoStationSameBX_ = false; // Requires the hits in two-station tracks to have the same BX + + // spGCParams16 : Sector processor ghost-cancellation parameters + // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F) + // -------------------------------------------------------------------------------------- + // useSecondEarliest_ // Depends on FW version, see below + // bugSameSectorPt0_ // Depends on FW version, see below + + // spPAParams16 : Sector processor pt-assignment parameters + // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F), + // BugNegPt(F), BugGMTPhi(F), PromoteMode7(F) + // --------------------------------------------------------------------------------- + // fixMode15HighPt_ // Depends on FW version, see below + // bug9BitDPhi_ // Depends on FW version, see below + // bugMode7CLCT_ // Depends on FW version, see below + // bugNegPt_ // Depends on FW version, see below + bugGMTPhi_ = true; // Some drift in uGMT phi conversion, off by up to a few degrees + modeQualVer_ = 1; // Version 2 contains modified mode-quality mapping for 2018 + + } // End default settings for 2016 + + // ___________________________________________________________________________ + // Versions in 2016 - refer to docs/EMTF_FW_LUT_versions_2016_draft2.xlsx + + // 1st_LCT_BX / 2nd_LCT_BX (should also make unpacker configurable - AWB 21.07.17) + // FW: Before: Earliest LCT used to assign BX, tracks only cancel within same BX + // After: Second-earliest LCT used to assign BX, tracks cancel over 3 BX, improved LCT recovery + useSecondEarliest_ = (fw_version < 46773) ? false : true; // Changed Sept. 5 + + // 8_BX_readout / 7_BX_readout + // SW: DAQ readout changed from to [-3, +4] BX to [-3, +3] BX + maxBX_ = (fw_version < 47109) ? +4 : +3; // Changed Sept. 28 + + // Asymm_patterns / Symm_patterns + // FW: Changed from 9 asymmetric patterns to 5 symmetric patterns for track building + useSymPatterns_ = (fw_version < 47214) ? false : true; // Changed Oct. 6 + + // HiPt_outlier + // LUT: High-pT fix puts outlier LCTs in mode 15 tracks back in a straight line + fixMode15HighPt_ = (fw_version < 46650) ? false : true; // Changed July 25 + + // Link_monitor (unpacker only) + // FW: Added MPC link monitoring + + // ___________________________________________________________________________ + // Bugs + + // DAQ_ID (unpacker only; should make configurable - AWB 21.07.17) + // FW: DAQ ME with output CSC ID range 0 - 8 instead of 1 - 9 + // SP output ME2_ID, 3_ID, and 4_ID filled with 4, 5, or 6 when they should have been 7, 8, or 9. + + // ME_ID_FR + // FW: Incorrect ME_ID fields in DAQ, wrong FR bits and some dPhi wrap-around in pT LUT address + // - Unpacker only, or not worth emulating + + // DAQ_miss_LCT (unpacker only) + // FW: LCTs only output if there was a track in the sector + + // Sector_pT_0 + // FW: Only highest-quality track in a sector assigned pT; others assigned pT = 0 + bugSameSectorPt0_ = (fw_version < 46650) ? true : false; // Fixed July 22 + + // Sector_bad_pT + // FW: Tracks sometimes assigned pT of track in previous BX + // - This is an ongoing (very rare) bug which occurs when 2 tracks try to access the same "bank" in the pT LUT + // It would be very difficult to emulate exactly, but the logic from Alex Madorsky is below + // ## macro for detecting same bank address + // ## bank and chip must match, and valid flags must be set + // ## a and b are indexes 0,1,2 + // ## [X:Y] are bit portions from ptlut address words + // `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]) + // ## This macro is used like this: + // if (`sb(0,2) || `sb(1,2)) {disable PT readout for track 2} + + // DAQ_BX_3_LCT (unpacker only) + // SW: LCTs in BX -3 only reported if there was a track in the sector + // - not applicable + + // DAQ_BX_23_LCT (unpacker only) + // SW: LCTs in BX -2 and -3 only reported if there was a track in the sector + // - not applicable + + // pT_dPhi_bits + // FW: dPhi wrap-around in modes 3, 5, 6, 9, 10, 12 + bug9BitDPhi_ = (fw_version < 47214) ? true : false; // Fixed Oct. 6 + + // Pattern_phi / ME1_neigh_phi + // FW: Pattern phi slightly offset from true LCT phi; also ME3/4 pattern width off + // Pattern phi of neighbor hits in ME1 miscalculated + fixZonePhi_ = (fw_version < 47214) ? false : true; // Fixed Oct. 6 + + // LCT_station_2 + // FW: Reduced LCT matching window in station 2, resulting in demoted tracks and inefficiency + bugSt2PhDiff_ = (47109 <= fw_version && fw_version < 47249) ? true : false; // Bug introduced Oct. 6, fixed Oct. 19 + + // LCT_theta_dup + // FW: LCTs matched to track may take theta value from other LCT in the same chamber + bugME11Dupes_ = (fw_version < 47423) ? true : false; // Fixed Nov. 1 + + // LCT_7_10_neg_pT (E) + // LUT: Written with incorrect values for mode 7 CLCT, mode 10 random offset, all modes negative (1/pT) set to 3 instead of 511 + bugMode7CLCT_ = (fw_version < 47864) ? true : false; // Fixed sometime after Nov. 1 + bugNegPt_ = (fw_version < 47864) ? true : false; // Fixed sometime after Nov. 1 +} From 94d6ad0386791fb5755f403fe89aacf87edcf54f Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Thu, 7 May 2020 09:52:42 -0400 Subject: [PATCH 24/34] [EMTF] Add EMTFSetup & VersionControl 2/6 --- L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h | 57 +++++++++++++++++++ L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc | 51 +++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h create mode 100644 L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc diff --git a/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h b/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h new file mode 100644 index 0000000000000..c28fa8b9f418b --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h @@ -0,0 +1,57 @@ +#ifndef L1TMuonEndCap_EMTFSetup_h +#define L1TMuonEndCap_EMTFSetup_h + +#include +#include + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "L1Trigger/L1TMuon/interface/GeometryTranslator.h" +#include "L1Trigger/L1TMuonEndCap/interface/ConditionHelper.h" +#include "L1Trigger/L1TMuonEndCap/interface/VersionControl.h" +#include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" +#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine.h" + +class EMTFSetup { +public: + explicit EMTFSetup(const edm::ParameterSet& iConfig); + ~EMTFSetup(); + + // Check and update geometry, conditions, versions, sp LUTs, and pt assignment engine + void reload(const edm::Event& iEvent, const edm::EventSetup& iSetup); + + // Getters + const GeometryTranslator& getGeometryTranslator() const { return geometry_translator_; } + + const ConditionHelper& getConditionHelper() const { return condition_helper_; } + + const VersionControl& getVersionControl() const { return version_control_; } + + const SectorProcessorLUT& getSectorProcessorLUT() const { return sector_processor_lut_; } + + PtAssignmentEngine* getPtAssignmentEngine() const { return pt_assign_engine_.get(); } + + // VersionControl getters + const edm::ParameterSet& getConfig() const { return version_control_.getConfig(); } + int verbose() const { return version_control_.verbose(); } + bool useO2O() const { return version_control_.useO2O(); } + std::string era() const { return version_control_.era(); } + +private: + GeometryTranslator geometry_translator_; + + ConditionHelper condition_helper_; + + VersionControl version_control_; + + SectorProcessorLUT sector_processor_lut_; + + // Polymorphic class + std::unique_ptr pt_assign_engine_; +}; + +#endif diff --git a/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc b/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc new file mode 100644 index 0000000000000..cb675eeca6263 --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc @@ -0,0 +1,51 @@ +#include "L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h" + +#include "FWCore/Utilities/interface/Exception.h" + +#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine2016.h" +#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine2017.h" + +EMTFSetup::EMTFSetup(const edm::ParameterSet& iConfig) + : geometry_translator_(), + condition_helper_(), + version_control_(iConfig), + sector_processor_lut_(), + pt_assign_engine_(nullptr) { + // Set pt assignment engine according to Era + if (era() == "Run2_2016") { + pt_assign_engine_.reset(new PtAssignmentEngine2016()); + } else if (era() == "Run2_2017" || era() == "Run2_2018") { + pt_assign_engine_.reset(new PtAssignmentEngine2017()); + } else if (era() == "Run3_2021") { + pt_assign_engine_.reset(new PtAssignmentEngine2017()); //TODO - implement ver 2021 + } else { + throw cms::Exception("L1TMuonEndCap") << "Cannot recognize the era option: " << era(); + } + + emtf_assert(pt_assign_engine_ != nullptr); +} + +EMTFSetup::~EMTFSetup() {} + +void EMTFSetup::reload(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + // Get the geometry for TP conversions + geometry_translator_.checkAndUpdateGeometry(iSetup); + + // Get the conditions, primarily the firmware version and the BDT forests + condition_helper_.checkAndUpdateConditions(iEvent, iSetup); + + // Do run-dependent configuration. This may overwrite the configurables passed by the python config file + version_control_.configure_by_fw_version(condition_helper_.get_fw_version()); + + // Decide the best pc_lut_ver & pt_lut_ver + unsigned pc_lut_ver = condition_helper_.get_pc_lut_version(); //TODO - check this + unsigned pt_lut_ver = condition_helper_.get_pt_lut_version(); //TODO - check this + + // Reload primitive conversion LUTs if necessary + sector_processor_lut_.read(iEvent.isRealData(), pc_lut_ver); + + // Reload pT LUT if necessary + pt_assign_engine_->load(pt_lut_ver, &(condition_helper_.getForest())); + + return; +} From 57589dfc5c22709078529f3a33a4fedc1bf86eac Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 5 May 2020 00:56:26 -0400 Subject: [PATCH 25/34] [EMTF] Add EMTFSetup & VersionControl 3/6 --- .../L1TMuonEndCap/interface/TrackFinder.h | 36 ++- L1Trigger/L1TMuonEndCap/src/TrackFinder.cc | 223 ++++-------------- 2 files changed, 63 insertions(+), 196 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/TrackFinder.h b/L1Trigger/L1TMuonEndCap/interface/TrackFinder.h index 799fc4a133c43..935cbd3884ecb 100644 --- a/L1Trigger/L1TMuonEndCap/interface/TrackFinder.h +++ b/L1Trigger/L1TMuonEndCap/interface/TrackFinder.h @@ -1,9 +1,6 @@ #ifndef L1TMuonEndCap_TrackFinder_h #define L1TMuonEndCap_TrackFinder_h -#include -#include -#include #include #include "FWCore/Framework/interface/Event.h" @@ -11,6 +8,9 @@ #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "L1Trigger/L1TMuonEndCap/interface/Common.h" +#include "L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h" +#include "L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemCollector.h" #include "L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h" class TrackFinder { @@ -27,26 +27,22 @@ class TrackFinder { EMTFTrackCollection& out_tracks); private: - GeometryTranslator geometry_translator_; - - ConditionHelper condition_helper_; - - SectorProcessorLUT sector_processor_lut_; - - std::unique_ptr pt_assign_engine_; + EMTFSetup setup_; emtf::sector_array sector_processors_; - const edm::ParameterSet config_; - - const edm::EDGetToken tokenDTPhi_, tokenDTTheta_, tokenCSC_, tokenCSCComparator_, tokenRPC_, tokenRPCRecHit_, - tokenCPPF_, tokenGEM_, tokenME0_; - - int verbose_, primConvLUT_; - - bool fwConfig_, useDT_, useCSC_, useRPC_, useIRPC_, useCPPF_, useGEM_, useME0_; - - std::string era_; + // Various tokens + const edm::EDGetToken tokenDTPhi_; + const edm::EDGetToken tokenDTTheta_; + const edm::EDGetToken tokenCSC_; + const edm::EDGetToken tokenCSCComparator_; + const edm::EDGetToken tokenRPC_; + const edm::EDGetToken tokenRPCRecHit_; + const edm::EDGetToken tokenCPPF_; + const edm::EDGetToken tokenGEM_; + const edm::EDGetToken tokenME0_; + + int verbose_; }; #endif diff --git a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc index cd72216f768ce..aea42016fd290 100644 --- a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc @@ -3,15 +3,9 @@ #include #include -#include "L1Trigger/L1TMuonEndCap/interface/EMTFSubsystemCollector.h" - TrackFinder::TrackFinder(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iConsumes) - : geometry_translator_(), - condition_helper_(), - sector_processor_lut_(), - pt_assign_engine_(), + : setup_(iConfig), sector_processors_(), - config_(iConfig), tokenDTPhi_(iConsumes.consumes(iConfig.getParameter("DTPhiInput"))), tokenDTTheta_( iConsumes.consumes(iConfig.getParameter("DTThetaInput"))), @@ -24,128 +18,7 @@ TrackFinder::TrackFinder(const edm::ParameterSet& iConfig, edm::ConsumesCollecto tokenCPPF_(iConsumes.consumes(iConfig.getParameter("CPPFInput"))), tokenGEM_(iConsumes.consumes(iConfig.getParameter("GEMInput"))), tokenME0_(iConsumes.consumes(iConfig.getParameter("ME0Input"))), - verbose_(iConfig.getUntrackedParameter("verbosity")), - primConvLUT_(iConfig.getParameter("spPCParams16").getParameter("PrimConvLUT")), - fwConfig_(iConfig.getParameter("FWConfig")), - useDT_(iConfig.getParameter("DTEnable")), - useCSC_(iConfig.getParameter("CSCEnable")), - useRPC_(iConfig.getParameter("RPCEnable")), - useIRPC_(iConfig.getParameter("IRPCEnable")), - useCPPF_(iConfig.getParameter("CPPFEnable")), - useGEM_(iConfig.getParameter("GEMEnable")), - useME0_(iConfig.getParameter("ME0Enable")), - era_(iConfig.getParameter("Era")) { - if (era_ == "Run2_2016") { - pt_assign_engine_.reset(new PtAssignmentEngine2016()); - } else if (era_ == "Run2_2017" || era_ == "Run2_2018") { - pt_assign_engine_.reset(new PtAssignmentEngine2017()); - } else { - edm::LogError("L1T") << "Cannot recognize the era option: " << era_; - return; - } - - auto minBX = iConfig.getParameter("MinBX"); - auto maxBX = iConfig.getParameter("MaxBX"); - auto bxWindow = iConfig.getParameter("BXWindow"); - auto bxShiftCSC = iConfig.getParameter("CSCInputBXShift"); - auto bxShiftRPC = iConfig.getParameter("RPCInputBXShift"); - auto bxShiftGEM = iConfig.getParameter("GEMInputBXShift"); - auto bxShiftME0 = iConfig.getParameter("ME0InputBXShift"); - - const auto& spPCParams16 = config_.getParameter("spPCParams16"); - auto zoneBoundaries = spPCParams16.getParameter >("ZoneBoundaries"); - auto zoneOverlap = spPCParams16.getParameter("ZoneOverlap"); - auto includeNeighbor = spPCParams16.getParameter("IncludeNeighbor"); - auto duplicateTheta = spPCParams16.getParameter("DuplicateTheta"); - auto fixZonePhi = spPCParams16.getParameter("FixZonePhi"); - auto useNewZones = spPCParams16.getParameter("UseNewZones"); - auto fixME11Edges = spPCParams16.getParameter("FixME11Edges"); - - const auto& spPRParams16 = config_.getParameter("spPRParams16"); - auto pattDefinitions = spPRParams16.getParameter >("PatternDefinitions"); - auto symPattDefinitions = spPRParams16.getParameter >("SymPatternDefinitions"); - auto useSymPatterns = spPRParams16.getParameter("UseSymmetricalPatterns"); - - const auto& spTBParams16 = config_.getParameter("spTBParams16"); - auto thetaWindow = spTBParams16.getParameter("ThetaWindow"); - auto thetaWindowZone0 = spTBParams16.getParameter("ThetaWindowZone0"); - auto useSingleHits = spTBParams16.getParameter("UseSingleHits"); - auto bugSt2PhDiff = spTBParams16.getParameter("BugSt2PhDiff"); - auto bugME11Dupes = spTBParams16.getParameter("BugME11Dupes"); - auto bugAmbigThetaWin = spTBParams16.getParameter("BugAmbigThetaWin"); - auto twoStationSameBX = spTBParams16.getParameter("TwoStationSameBX"); - - const auto& spGCParams16 = config_.getParameter("spGCParams16"); - auto maxRoadsPerZone = spGCParams16.getParameter("MaxRoadsPerZone"); - auto maxTracks = spGCParams16.getParameter("MaxTracks"); - auto useSecondEarliest = spGCParams16.getParameter("UseSecondEarliest"); - auto bugSameSectorPt0 = spGCParams16.getParameter("BugSameSectorPt0"); - - const auto& spPAParams16 = config_.getParameter("spPAParams16"); - auto readPtLUTFile = spPAParams16.getParameter("ReadPtLUTFile"); - auto fixMode15HighPt = spPAParams16.getParameter("FixMode15HighPt"); - auto bug9BitDPhi = spPAParams16.getParameter("Bug9BitDPhi"); - auto bugMode7CLCT = spPAParams16.getParameter("BugMode7CLCT"); - auto bugNegPt = spPAParams16.getParameter("BugNegPt"); - auto bugGMTPhi = spPAParams16.getParameter("BugGMTPhi"); - auto promoteMode7 = spPAParams16.getParameter("PromoteMode7"); - auto modeQualVer = spPAParams16.getParameter("ModeQualVer"); - - // Configure sector processors - for (int endcap = emtf::MIN_ENDCAP; endcap <= emtf::MAX_ENDCAP; ++endcap) { - for (int sector = emtf::MIN_TRIGSECTOR; sector <= emtf::MAX_TRIGSECTOR; ++sector) { - const int es = (endcap - emtf::MIN_ENDCAP) * (emtf::MAX_TRIGSECTOR - emtf::MIN_TRIGSECTOR + 1) + - (sector - emtf::MIN_TRIGSECTOR); - - sector_processors_.at(es).configure(&geometry_translator_, - &condition_helper_, - §or_processor_lut_, - pt_assign_engine_.get(), - verbose_, - endcap, - sector, - minBX, - maxBX, - bxWindow, - bxShiftCSC, - bxShiftRPC, - bxShiftGEM, - bxShiftME0, - era_, - zoneBoundaries, - zoneOverlap, - includeNeighbor, - duplicateTheta, - fixZonePhi, - useNewZones, - fixME11Edges, - pattDefinitions, - symPattDefinitions, - useSymPatterns, - thetaWindow, - thetaWindowZone0, - useRPC_, - useSingleHits, - bugSt2PhDiff, - bugME11Dupes, - bugAmbigThetaWin, - twoStationSameBX, - maxRoadsPerZone, - maxTracks, - useSecondEarliest, - bugSameSectorPt0, - readPtLUTFile, - fixMode15HighPt, - bug9BitDPhi, - bugMode7CLCT, - bugNegPt, - bugGMTPhi, - promoteMode7, - modeQualVer); - } - } - -} // End constructor: TrackFinder::TrackFinder() + verbose_(iConfig.getUntrackedParameter("verbosity")) {} TrackFinder::~TrackFinder() {} @@ -157,11 +30,19 @@ void TrackFinder::process(const edm::Event& iEvent, out_hits.clear(); out_tracks.clear(); - // Get the geometry for TP conversions - geometry_translator_.checkAndUpdateGeometry(iSetup); + // Check and update geometry, conditions, versions, sp LUTs, and pt assignment engine + setup_.reload(iEvent, iSetup); + + auto tp_geom_ = &(setup_.getGeometryTranslator()); - // Get the conditions, primarily the firmware version and the BDT forests - condition_helper_.checkAndUpdateConditions(iEvent, iSetup); + // Check versions + if (verbose_ > 0) { // debug + std::cout << "Event: " << iEvent.id() //TODO - check this + << " pc_lut_ver: " << setup_.getConditionHelper().get_pc_lut_version() + << " pt_lut_ver: " << setup_.getConditionHelper().get_pt_lut_version() + << " pt_lut_ver in engine: " << setup_.getPtAssignmentEngine()->get_pt_lut_version() + << " fw_ver: " << setup_.getConditionHelper().get_fw_version() << std::endl; + } // ___________________________________________________________________________ // Extract all trigger primitives @@ -169,32 +50,41 @@ void TrackFinder::process(const edm::Event& iEvent, TriggerPrimitiveCollection muon_primitives; EMTFSubsystemCollector collector; - if (useCSC_) { - collector.extractPrimitives(emtf::CSCTag(), &geometry_translator_, iEvent, tokenCSC_, muon_primitives); - //collector.extractPrimitives(emtf::CSCTag(), &geometry_translator_, iEvent, tokenCSC_, tokenCSCComparator_, muon_primitives); + + auto iConfig = setup_.getConfig(); + auto useDT = iConfig.getParameter("DTEnable"); + auto useCSC = iConfig.getParameter("CSCEnable"); + auto useRPC = iConfig.getParameter("RPCEnable"); + auto useIRPC = iConfig.getParameter("IRPCEnable"); + auto useCPPF = iConfig.getParameter("CPPFEnable"); + auto useGEM = iConfig.getParameter("GEMEnable"); + auto useME0 = iConfig.getParameter("ME0Enable"); + + if (useCSC) { + collector.extractPrimitives(emtf::CSCTag(), tp_geom_, iEvent, tokenCSC_, muon_primitives); + //collector.extractPrimitives(emtf::CSCTag(), tp_geom_, iEvent, tokenCSC_, tokenCSCComparator_, muon_primitives); } - if (useRPC_ && useCPPF_) { - collector.extractPrimitives(emtf::CPPFTag(), &geometry_translator_, iEvent, tokenCPPF_, muon_primitives); - } else if (useRPC_) { - collector.extractPrimitives(emtf::RPCTag(), &geometry_translator_, iEvent, tokenRPC_, muon_primitives); - //collector.extractPrimitives(emtf::RPCTag(), &geometry_translator_, iEvent, tokenRPC_, tokenRPCRecHit_, muon_primitives); + if (useRPC && useCPPF) { + collector.extractPrimitives(emtf::CPPFTag(), tp_geom_, iEvent, tokenCPPF_, muon_primitives); + } else if (useRPC) { + collector.extractPrimitives(emtf::RPCTag(), tp_geom_, iEvent, tokenRPC_, muon_primitives); + //collector.extractPrimitives(emtf::RPCTag(), tp_geom_, iEvent, tokenRPC_, tokenRPCRecHit_, muon_primitives); } - if (useIRPC_) { - collector.extractPrimitives(emtf::IRPCTag(), &geometry_translator_, iEvent, tokenRPC_, muon_primitives); - //collector.extractPrimitives(emtf::IRPCTag(), &geometry_translator_, iEvent, tokenRPC_, tokenRPCRecHit_, muon_primitives); + if (useIRPC) { + collector.extractPrimitives(emtf::IRPCTag(), tp_geom_, iEvent, tokenRPC_, muon_primitives); + //collector.extractPrimitives(emtf::IRPCTag(), tp_geom_, iEvent, tokenRPC_, tokenRPCRecHit_, muon_primitives); } - if (useGEM_) { - collector.extractPrimitives(emtf::GEMTag(), &geometry_translator_, iEvent, tokenGEM_, muon_primitives); + if (useGEM) { + collector.extractPrimitives(emtf::GEMTag(), tp_geom_, iEvent, tokenGEM_, muon_primitives); } - if (useME0_) { - collector.extractPrimitives(emtf::ME0Tag(), &geometry_translator_, iEvent, tokenME0_, muon_primitives); + if (useME0) { + collector.extractPrimitives(emtf::ME0Tag(), tp_geom_, iEvent, tokenME0_, muon_primitives); } - if (useDT_) { - collector.extractPrimitives( - emtf::DTTag(), &geometry_translator_, iEvent, tokenDTPhi_, tokenDTTheta_, muon_primitives); + if (useDT) { + collector.extractPrimitives(emtf::DTTag(), tp_geom_, iEvent, tokenDTPhi_, tokenDTTheta_, muon_primitives); } - // Check trigger primitives + // Check trigger primitives. The printout is really verbose. if (verbose_ > 2) { // debug std::cout << "Num of TriggerPrimitive: " << muon_primitives.size() << std::endl; for (const auto& p : muon_primitives) { @@ -203,41 +93,22 @@ void TrackFinder::process(const edm::Event& iEvent, } // ___________________________________________________________________________ - // Run each sector processor - - // Reload primitive conversion LUTs if necessary - sector_processor_lut_.read(iEvent.isRealData(), fwConfig_ ? condition_helper_.get_pc_lut_version() : primConvLUT_); + // Run the sector processors - // Reload pT LUT if necessary - pt_assign_engine_->load(condition_helper_.get_pt_lut_version(), &(condition_helper_.getForest())); - - // MIN/MAX ENDCAP and TRIGSECTOR set in interface/Common.h for (int endcap = emtf::MIN_ENDCAP; endcap <= emtf::MAX_ENDCAP; ++endcap) { for (int sector = emtf::MIN_TRIGSECTOR; sector <= emtf::MAX_TRIGSECTOR; ++sector) { const int es = (endcap - emtf::MIN_ENDCAP) * (emtf::MAX_TRIGSECTOR - emtf::MIN_TRIGSECTOR + 1) + (sector - emtf::MIN_TRIGSECTOR); - // Run-dependent configure. This overwrites many of the configurables passed by the python config file. - if (fwConfig_) { - sector_processors_.at(es).configure_by_fw_version(condition_helper_.get_fw_version()); - } - - // Process - sector_processors_.at(es).process(iEvent.id().event(), muon_primitives, out_hits, out_tracks); + sector_processors_.at(es).configure(&setup_, verbose_, endcap, sector); + sector_processors_.at(es).process(iEvent.id(), muon_primitives, out_hits, out_tracks); } } // ___________________________________________________________________________ - if (verbose_ > 0) { // debug - std::cout << "Run number: " << iEvent.id().run() << " pc_lut_ver: " << condition_helper_.get_pc_lut_version() - << " pt_lut_ver: " << condition_helper_.get_pt_lut_version() - << " pt_lut_ver in engine: " << pt_assign_engine_->get_pt_lut_version() - << " fw_ver: " << condition_helper_.get_fw_version() << std::endl; - } - + // Check emulator input and output. They are printed as raw text that is + // used by the firmware simulator to do comparisons. if (verbose_ > 1) { // debug - // Check emulator input and output. They are printed as raw text that is - // used by the firmware simulator to do comparisons. emtf::dump_fw_raw_input(out_hits, out_tracks); } From 3343bb657d948739837c9df2fb25e817dcdc503a Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 5 May 2020 01:02:10 -0400 Subject: [PATCH 26/34] [EMTF] Add EMTFSetup & VersionControl 4/6 --- .../L1TMuonEndCap/interface/SectorProcessor.h | 98 +--- .../L1TMuonEndCap/src/SectorProcessor.cc | 492 +++--------------- 2 files changed, 73 insertions(+), 517 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h b/L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h index f17477ec306d9..542a776859b5e 100644 --- a/L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h +++ b/L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h @@ -6,15 +6,10 @@ #include #include -#include "L1Trigger/L1TMuonEndCap/interface/Common.h" - -//#include "L1Trigger/L1TMuonEndCap/interface/GeometryTranslator.h" -#include "L1Trigger/L1TMuonEndCap/interface/ConditionHelper.h" +#include "DataFormats/Provenance/interface/EventID.h" -#include "L1Trigger/L1TMuonEndCap/interface/SectorProcessorLUT.h" -#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine.h" -#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine2016.h" -#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine2017.h" +#include "L1Trigger/L1TMuonEndCap/interface/Common.h" +#include "L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h" #include "L1Trigger/L1TMuonEndCap/interface/PrimitiveSelection.h" #include "L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h" @@ -30,60 +25,13 @@ class SectorProcessor { explicit SectorProcessor(); ~SectorProcessor(); - typedef unsigned long long EventNumber_t; typedef PatternRecognition::pattern_ref_t pattern_ref_t; - void configure(const GeometryTranslator* tp_geom, - const ConditionHelper* cond, - const SectorProcessorLUT* lut, - PtAssignmentEngine* pt_assign_engine, - int verbose, - int endcap, - int sector, - int minBX, - int maxBX, - int bxWindow, - int bxShiftCSC, - int bxShiftRPC, - int bxShiftGEM, - int bxShiftME0, - std::string era, - const std::vector& zoneBoundaries, - int zoneOverlap, - bool includeNeighbor, - bool duplicateTheta, - bool fixZonePhi, - bool useNewZones, - bool fixME11Edges, - const std::vector& pattDefinitions, - const std::vector& symPattDefinitions, - bool useSymPatterns, - int thetaWindow, - int thetaWindowZone0, - bool useRPC, - bool useSingleHits, - bool bugSt2PhDiff, - bool bugME11Dupes, - bool bugAmbigThetaWin, - bool twoStationSameBX, - int maxRoadsPerZone, - int maxTracks, - bool useSecondEarliest, - bool bugSameSectorPt0, - bool readPtLUTFile, - bool fixMode15HighPt, - bool bug9BitDPhi, - bool bugMode7CLCT, - bool bugNegPt, - bool bugGMTPhi, - bool promoteMode7, - int modeQualVer); - - void configure_by_fw_version(unsigned fw_version); + void configure(const EMTFSetup* setup, int verbose, int endcap, int sector); void process( // Input - EventNumber_t ievent, + const edm::EventID& event_id, const TriggerPrimitiveCollection& muon_primitives, // Output EMTFHitCollection& out_hits, @@ -102,43 +50,9 @@ class SectorProcessor { std::map& patt_lifetime_map) const; private: - const GeometryTranslator* tp_geom_; - - const ConditionHelper* cond_; - - const SectorProcessorLUT* lut_; - - PtAssignmentEngine* pt_assign_engine_; + const EMTFSetup* setup_; int verbose_, endcap_, sector_; - - int minBX_, maxBX_, bxWindow_, bxShiftCSC_, bxShiftRPC_, bxShiftGEM_, bxShiftME0_; - - std::string era_; - - // For primitive conversion - std::vector zoneBoundaries_; - int zoneOverlap_; - bool includeNeighbor_, duplicateTheta_, fixZonePhi_, useNewZones_, fixME11Edges_; - - // For pattern recognition - std::vector pattDefinitions_, symPattDefinitions_; - bool useSymPatterns_; - - // For track building - int thetaWindow_, thetaWindowZone0_; - bool useRPC_, useCPPF_, useSingleHits_; - bool bugSt2PhDiff_, bugME11Dupes_, bugAmbigThetaWin_, twoStationSameBX_; - - // For ghost cancellation - int maxRoadsPerZone_, maxTracks_; - bool useSecondEarliest_; - bool bugSameSectorPt0_; - - // For pt assignment - bool readPtLUTFile_, fixMode15HighPt_; - bool bug9BitDPhi_, bugMode7CLCT_, bugNegPt_, bugGMTPhi_, promoteMode7_; - int modeQualVer_; }; #endif diff --git a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc index d8559eae3c25e..ba9159d808150 100644 --- a/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCap/src/SectorProcessor.cc @@ -4,392 +4,22 @@ SectorProcessor::SectorProcessor() {} SectorProcessor::~SectorProcessor() {} -void SectorProcessor::configure(const GeometryTranslator* tp_geom, - const ConditionHelper* cond, - const SectorProcessorLUT* lut, - PtAssignmentEngine* pt_assign_engine, - int verbose, - int endcap, - int sector, - int minBX, - int maxBX, - int bxWindow, - int bxShiftCSC, - int bxShiftRPC, - int bxShiftGEM, - int bxShiftME0, - std::string era, - const std::vector& zoneBoundaries, - int zoneOverlap, - bool includeNeighbor, - bool duplicateTheta, - bool fixZonePhi, - bool useNewZones, - bool fixME11Edges, - const std::vector& pattDefinitions, - const std::vector& symPattDefinitions, - bool useSymPatterns, - int thetaWindow, - int thetaWindowZone0, - bool useRPC, - bool useSingleHits, - bool bugSt2PhDiff, - bool bugME11Dupes, - bool bugAmbigThetaWin, - bool twoStationSameBX, - int maxRoadsPerZone, - int maxTracks, - bool useSecondEarliest, - bool bugSameSectorPt0, - bool readPtLUTFile, - bool fixMode15HighPt, - bool bug9BitDPhi, - bool bugMode7CLCT, - bool bugNegPt, - bool bugGMTPhi, - bool promoteMode7, - int modeQualVer) { +void SectorProcessor::configure(const EMTFSetup* setup, int verbose, int endcap, int sector) { + emtf_assert(setup != nullptr); emtf_assert(emtf::MIN_ENDCAP <= endcap && endcap <= emtf::MAX_ENDCAP); emtf_assert(emtf::MIN_TRIGSECTOR <= sector && sector <= emtf::MAX_TRIGSECTOR); - emtf_assert(tp_geom != nullptr); - emtf_assert(cond != nullptr); - emtf_assert(lut != nullptr); - emtf_assert(pt_assign_engine != nullptr); - - tp_geom_ = tp_geom; - cond_ = cond; - lut_ = lut; - pt_assign_engine_ = pt_assign_engine; - + setup_ = setup; verbose_ = verbose; endcap_ = endcap; sector_ = sector; - - minBX_ = minBX; - maxBX_ = maxBX; - bxWindow_ = bxWindow; - bxShiftCSC_ = bxShiftCSC; - bxShiftRPC_ = bxShiftRPC; - bxShiftGEM_ = bxShiftGEM; - bxShiftME0_ = bxShiftME0; - - era_ = era; - - zoneBoundaries_ = zoneBoundaries; - zoneOverlap_ = zoneOverlap; - includeNeighbor_ = includeNeighbor; - duplicateTheta_ = duplicateTheta; - fixZonePhi_ = fixZonePhi; - useNewZones_ = useNewZones; - fixME11Edges_ = fixME11Edges; - - pattDefinitions_ = pattDefinitions; - symPattDefinitions_ = symPattDefinitions; - useSymPatterns_ = useSymPatterns; - - thetaWindow_ = thetaWindow; - thetaWindowZone0_ = thetaWindowZone0; - useRPC_ = useRPC; - useSingleHits_ = useSingleHits; - bugSt2PhDiff_ = bugSt2PhDiff; - bugME11Dupes_ = bugME11Dupes; - bugAmbigThetaWin_ = bugAmbigThetaWin; - twoStationSameBX_ = twoStationSameBX; - - maxRoadsPerZone_ = maxRoadsPerZone; - maxTracks_ = maxTracks; - useSecondEarliest_ = useSecondEarliest; - bugSameSectorPt0_ = bugSameSectorPt0; - - readPtLUTFile_ = readPtLUTFile; - fixMode15HighPt_ = fixMode15HighPt; - bug9BitDPhi_ = bug9BitDPhi; - bugMode7CLCT_ = bugMode7CLCT; - bugNegPt_ = bugNegPt; - bugGMTPhi_ = bugGMTPhi; - promoteMode7_ = promoteMode7; - modeQualVer_ = modeQualVer; -} - -// Refer to docs/EMTF_FW_LUT_versions_2016_draft2.xlsx -void SectorProcessor::configure_by_fw_version(unsigned fw_version) { - if (verbose_ > 0) { - std::cout << "Configure SectorProcessor with fw_version: " << fw_version << std::endl; - } - - if (fw_version == 0 || fw_version == 123456) // fw_version '123456' is from the fake conditions - return; - - // For now, no switches later than FW version 47864 (end-of-year 2016) - // Beggining in late 2016, "fw_version" in O2O populated with timestamp, rather than FW version - // tm fw_time = gmtime(fw_version); (See https://linux.die.net/man/3/gmtime, https://www.epochconverter.com) - - ///////////////////////////////////////////////////////////////////////////////// - /// Settings for 2018 (by default just use settings in simEmtfDigis_cfi.py) /// - ///////////////////////////////////////////////////////////////////////////////// - if (fw_version >= 1514764800) { // January 1, 2018 - - // Settings for all of 2018 (following order in simEmtfDigis_cfi.py) - // BXWindow(2) and BugAmbigThetaWin(F) deployed sometime before stable beams on March 20, not quite sure when - AWB 26.04.18 - // TwoStationSameBX(T), ThetaWindowZone0(4), and ModeQualVer(2) to be deployed sometime between May 17 and May 31 - AWB 14.05.18 - - // Global parameters - // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2) - // -------------------------------------------------------------------------------------------------------- - era_ = "Run2_2018"; // Era for CMSSW customization - bxWindow_ = 2; // Number of BX whose primitives can be included in the same track - - // spTBParams16 : Sector processor track-building parameters - // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T), - // DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T) - // ------------------------------------------------------------------------------ - - // spPRParams16 : Sector processor pattern-recognition parameters - // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T) - // ----------------------------------------------------------------------------------------- - - // spTBParams16 : Sector processor track-building parameters - // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F), - // BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T) - // ---------------------------------------------------------------------------------- - thetaWindow_ = 8; // Maximum dTheta between primitives in the same track - thetaWindowZone0_ = 4; // Maximum dTheta between primitives in the same track in Zone 0 (ring 1) - bugAmbigThetaWin_ = false; // Can allow dThetas outside window when there are 2 LCTs in the same chamber - twoStationSameBX_ = true; // Requires the hits in two-station tracks to have the same BX - - // spGCParams16 : Sector processor ghost-cancellation parameters - // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F) - // -------------------------------------------------------------------------------------- - - // spPAParams16 : Sector processor pt-assignment parameters - // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F), - // BugNegPt(F), BugGMTPhi(F), PromoteMode7(F), ModeQualVer(2) - // --------------------------------------------------------------------------------- - modeQualVer_ = 2; // Version 2 contains modified mode-quality mapping for 2018 - promoteMode7_ = false; // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality - - // ___________________________________________________________________________ - // Versions in 2018 - no external documentation - // As of the beginning of 2018 EMTF O2O was broken, not updating the database with online conditions - // Firmware version reported for runs before 318841 (June 28) is 1504018578 (Aug. 29, 2017) even though - // updates occured in February and March of 2018. May need to re-write history in the database. - AWB 30.06.18 - - if (fw_version < 1529520380) { // June 20, 2018 - thetaWindowZone0_ = 8; // Maximum dTheta between primitives in the same track in Zone 0 (ring 1) - twoStationSameBX_ = false; // Requires the hits in two-station tracks to have the same BX - modeQualVer_ = 1; // Version 2 contains modified mode-quality mapping for 2018 - promoteMode7_ = true; // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality - } - - return; - } - - ///////////////////////////////////////////////////////////////////////////////// - /// Settings for 2017 (by default just use settings in simEmtfDigis_cfi.py) /// - ///////////////////////////////////////////////////////////////////////////////// - else if (fw_version >= 50000) { - // Settings for all of 2017 (following order in simEmtfDigis_cfi.py) - - // Global parameters - // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2) - // -------------------------------------------------------------------------------------------------------- - era_ = "Run2_2017"; // Era for CMSSW customization - bxWindow_ = 3; // Number of BX whose primitives can be included in the same track - - // spTBParams16 : Sector processor track-building parameters - // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T), - // DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T) - // ------------------------------------------------------------------------------ - - // spPRParams16 : Sector processor pattern-recognition parameters - // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T) - // ----------------------------------------------------------------------------------------- - - // spTBParams16 : Sector processor track-building parameters - // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F), - // BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T) - // ---------------------------------------------------------------------------------- - thetaWindow_ = 8; // Maximum dTheta between primitives in the same track - thetaWindowZone0_ = 8; // Maximum dTheta between primitives in the same track in Zone 0 (ring 1) - bugAmbigThetaWin_ = true; // Can allow dThetas outside window when there are 2 LCTs in the same chamber - twoStationSameBX_ = false; // Requires the hits in two-station tracks to have the same BX - - // spGCParams16 : Sector processor ghost-cancellation parameters - // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F) - // -------------------------------------------------------------------------------------- - - // spPAParams16 : Sector processor pt-assignment parameters - // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F), - // BugNegPt(F), BugGMTPhi(F), PromoteMode7(F) - // --------------------------------------------------------------------------------- - modeQualVer_ = 1; // Version 2 contains modified mode-quality mapping for 2018 - - // ___________________________________________________________________________ - // Versions in 2017 - no full documentation, can refer to https://twiki.cern.ch/twiki/bin/viewauth/CMS/L1KnownIssues - - // Before July 9th (runs < 298653), all mode 7 tracks (station 2-3-4) assigned quality 11 - // July 9th - 29th (runs 298653 - 300087), mode 7 tracks with |eta| > 1.6 in sector -6 assigned quality 12 - // After July 29th (runs >= 300088), mode 7 track promotion applied in all sectors - // For some reason, the FW version in the database is 1496792995, at least for runs >= 298034 (July 4), - // which is towards the end of run 2017B (could not check earlier runs). This corresponds to the date "June 6th", - // which is a month earlier than the first firmware update to apply this promotion. So something's screwey. - // Since July 18 is in the middle of the single-sector-fix period, would like to use a firmware version with - // roughly that date. But this may require an intervention in the database. - AWB 04.08.17 - // Last firmware version in 2017 was 1504018578 (Aug. 29, 2017). - if (fw_version >= 1496792995) - promoteMode7_ = true; // Assign station 2-3-4 tracks with |eta| > 1.6 SingleMu quality - - return; - } - - /////////////////////////////////////////////////////////////////////////// - /// Settings for all of 2016 (following order in simEmtfDigis_cfi.py) /// - /////////////////////////////////////////////////////////////////////////// - else { - // Global parameters - // Defaults : CSCEnable(T), RPCEnable(T), GEMEnable(F), Era("Run2_2018"), MinBX(-3), MaxBX(+3), BXWindow(2) - // -------------------------------------------------------------------------------------------------------- - useRPC_ = false; // Use clustered RPC hits from CPPF in track-building - era_ = "Run2_2016"; // Era for CMSSW customization - // maxBX_ // Depends on FW version, see below - bxWindow_ = 3; // Number of BX whose primitives can be included in the same track - - // spTBParams16 : Sector processor track-building parameters - // Defaults : PrimConvLUT(1), ZoneBoundaries(0,41,49,87,127), ZoneOverlap(2), IncludeNeighbor(T), - // DuplicateThteta(T), FixZonePhi(T), UseNewZones(F), FixME11Edges(T) - // ------------------------------------------------------------------------------ - // primConvLUT_ // Should be 0 for 2016, set using get_pc_lut_version() from ConditionsHelper.cc - // fixZonePhi_ // Depends on FW version, see below - fixME11Edges_ = false; // Improved small fraction of buggy LCT coordinate transformations - - // spPRParams16 : Sector processor pattern-recognition parameters - // Defaults : PatternDefinitions(...), SymPatternDefinitions(...), UseSymmetricalPatterns(T) - // ----------------------------------------------------------------------------------------- - // useSymPatterns_ // Depends on FW version, see below - - // spTBParams16 : Sector processor track-building parameters - // Defaults : ThetaWindow(8), ThetaWindowZone0(4), UseSingleHits(F), BugSt2PhDiff(F), - // BugME11Dupes(F), BugAmbigThetaWin(F), TwoStationSameBX(T) - // ---------------------------------------------------------------------------------- - thetaWindow_ = 4; // Maximum dTheta between primitives in the same track - thetaWindowZone0_ = 4; // Maximum dTheta between primitives in the same track in Zone 0 (ring 1) - // bugSt2PhDiff_ // Depends on FW version, see below - // bugME11Dupes_ // Depends on FW version, see below - bugAmbigThetaWin_ = true; // Can allow dThetas outside window when there are 2 LCTs in the same chamber - twoStationSameBX_ = false; // Requires the hits in two-station tracks to have the same BX - - // spGCParams16 : Sector processor ghost-cancellation parameters - // Defaults : MaxRoadsPerZone(3), MaxTracks(3), UseSecondEarliest(T), BugSameSectorPt0(F) - // -------------------------------------------------------------------------------------- - // useSecondEarliest_ // Depends on FW version, see below - // bugSameSectorPt0_ // Depends on FW version, see below - - // spPAParams16 : Sector processor pt-assignment parameters - // Defaults : ReadPtLUTFile(F), FixMode15HighPt(T), Bug9BitDPhi(F), BugMode7CLCT(F), - // BugNegPt(F), BugGMTPhi(F), PromoteMode7(F) - // --------------------------------------------------------------------------------- - // fixMode15HighPt_ // Depends on FW version, see below - // bug9BitDPhi_ // Depends on FW version, see below - // bugMode7CLCT_ // Depends on FW version, see below - // bugNegPt_ // Depends on FW version, see below - bugGMTPhi_ = true; // Some drift in uGMT phi conversion, off by up to a few degrees - modeQualVer_ = 1; // Version 2 contains modified mode-quality mapping for 2018 - - } // End default settings for 2016 - - // ___________________________________________________________________________ - // Versions in 2016 - refer to docs/EMTF_FW_LUT_versions_2016_draft2.xlsx - - // 1st_LCT_BX / 2nd_LCT_BX (should also make unpacker configurable - AWB 21.07.17) - // FW: Before: Earliest LCT used to assign BX, tracks only cancel within same BX - // After: Second-earliest LCT used to assign BX, tracks cancel over 3 BX, improved LCT recovery - useSecondEarliest_ = (fw_version < 46773) ? false : true; // Changed Sept. 5 - - // 8_BX_readout / 7_BX_readout - // SW: DAQ readout changed from to [-3, +4] BX to [-3, +3] BX - maxBX_ = (fw_version < 47109) ? +4 : +3; // Changed Sept. 28 - - // Asymm_patterns / Symm_patterns - // FW: Changed from 9 asymmetric patterns to 5 symmetric patterns for track building - useSymPatterns_ = (fw_version < 47214) ? false : true; // Changed Oct. 6 - - // HiPt_outlier - // LUT: High-pT fix puts outlier LCTs in mode 15 tracks back in a straight line - fixMode15HighPt_ = (fw_version < 46650) ? false : true; // Changed July 25 - - // Link_monitor (unpacker only) - // FW: Added MPC link monitoring - - // ___________________________________________________________________________ - // Bugs - - // DAQ_ID (unpacker only; should make configurable - AWB 21.07.17) - // FW: DAQ ME with output CSC ID range 0 - 8 instead of 1 - 9 - // SP output ME2_ID, 3_ID, and 4_ID filled with 4, 5, or 6 when they should have been 7, 8, or 9. - - // ME_ID_FR - // FW: Incorrect ME_ID fields in DAQ, wrong FR bits and some dPhi wrap-around in pT LUT address - // - Unpacker only, or not worth emulating - - // DAQ_miss_LCT (unpacker only) - // FW: LCTs only output if there was a track in the sector - - // Sector_pT_0 - // FW: Only highest-quality track in a sector assigned pT; others assigned pT = 0 - bugSameSectorPt0_ = (fw_version < 46650) ? true : false; // Fixed July 22 - - // Sector_bad_pT - // FW: Tracks sometimes assigned pT of track in previous BX - // - This is an ongoing (very rare) bug which occurs when 2 tracks try to access the same "bank" in the pT LUT - // It would be very difficult to emulate exactly, but the logic from Alex Madorsky is below - // ## macro for detecting same bank address - // ## bank and chip must match, and valid flags must be set - // ## a and b are indexes 0,1,2 - // ## [X:Y] are bit portions from ptlut address words - // `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]) - // ## This macro is used like this: - // if (`sb(0,2) || `sb(1,2)) {disable PT readout for track 2} - - // DAQ_BX_3_LCT (unpacker only) - // SW: LCTs in BX -3 only reported if there was a track in the sector - // - not applicable - - // DAQ_BX_23_LCT (unpacker only) - // SW: LCTs in BX -2 and -3 only reported if there was a track in the sector - // - not applicable - - // pT_dPhi_bits - // FW: dPhi wrap-around in modes 3, 5, 6, 9, 10, 12 - bug9BitDPhi_ = (fw_version < 47214) ? true : false; // Fixed Oct. 6 - - // Pattern_phi / ME1_neigh_phi - // FW: Pattern phi slightly offset from true LCT phi; also ME3/4 pattern width off - // Pattern phi of neighbor hits in ME1 miscalculated - fixZonePhi_ = (fw_version < 47214) ? false : true; // Fixed Oct. 6 - - // LCT_station_2 - // FW: Reduced LCT matching window in station 2, resulting in demoted tracks and inefficiency - bugSt2PhDiff_ = (47109 <= fw_version && fw_version < 47249) ? true : false; // Bug introduced Oct. 6, fixed Oct. 19 - - // LCT_theta_dup - // FW: LCTs matched to track may take theta value from other LCT in the same chamber - bugME11Dupes_ = (fw_version < 47423) ? true : false; // Fixed Nov. 1 - - // LCT_7_10_neg_pT (E) - // LUT: Written with incorrect values for mode 7 CLCT, mode 10 random offset, all modes negative (1/pT) set to 3 instead of 511 - bugMode7CLCT_ = (fw_version < 47864) ? true : false; // Fixed sometime after Nov. 1 - bugNegPt_ = (fw_version < 47864) ? true : false; // Fixed sometime after Nov. 1 } -void SectorProcessor::process(EventNumber_t ievent, +void SectorProcessor::process(const edm::EventID& event_id, const TriggerPrimitiveCollection& muon_primitives, EMTFHitCollection& out_hits, EMTFTrackCollection& out_tracks) const { - // if (endcap_ == 1 && sector_ == 1) { - // std::cout << "\nConfigured with era " << era_ << ", thetaWindowZone0 = " << thetaWindowZone0_ << ", bugAmbigThetaWin = " - // << bugAmbigThetaWin_ << ", twoStationSameBX = " << twoStationSameBX_ << ", promoteMode7_ = " << promoteMode7_ << std::endl; - // } + auto cfg = setup_->getVersionControl(); // List of converted hits, extended from previous BXs // deque (double-ended queue) is similar to a vector, but allows insertion or deletion of elements at both beginning and end @@ -404,11 +34,11 @@ void SectorProcessor::process(EventNumber_t ievent, // ___________________________________________________________________________ // Run each sector processor for every BX, taking into account the BX window - int delayBX = bxWindow_ - 1; + int delayBX = cfg.bxWindow_ - 1; - for (int bx = minBX_; bx <= maxBX_ + delayBX; ++bx) { + for (int bx = cfg.minBX_; bx <= cfg.maxBX_ + delayBX; ++bx) { if (verbose_ > 0) { // debug - std::cout << "Endcap: " << endcap_ << " Sector: " << sector_ << " Event: " << ievent << " BX: " << bx + std::cout << "Event: " << event_id << " Endcap: " << endcap_ << " Sector: " << sector_ << " BX: " << bx << std::endl; } @@ -416,7 +46,7 @@ void SectorProcessor::process(EventNumber_t ievent, bx, muon_primitives, out_hits, out_tracks, extended_conv_hits, extended_best_track_cands, patt_lifetime_map); // Drop earliest BX outside of BX window - if (bx >= minBX_ + delayBX) { + if (bx >= cfg.minBX_ + delayBX) { extended_conv_hits.pop_front(); int n = emtf::zone_array().size(); @@ -435,6 +65,12 @@ void SectorProcessor::process_single_bx(int bx, std::deque& extended_conv_hits, std::deque& extended_best_track_cands, std::map& patt_lifetime_map) const { + auto cfg = setup_->getVersionControl(); + + auto tp_geom_ = &(setup_->getGeometryTranslator()); + auto pc_lut_ = &(setup_->getSectorProcessorLUT()); + auto pt_assign_engine_ = setup_->getPtAssignmentEngine(); + // ___________________________________________________________________________ // Configure @@ -443,66 +79,74 @@ void SectorProcessor::process_single_bx(int bx, endcap_, sector_, bx, - bxShiftCSC_, - bxShiftRPC_, - bxShiftGEM_, - bxShiftME0_, - includeNeighbor_, - duplicateTheta_, - bugME11Dupes_); + cfg.bxShiftCSC_, + cfg.bxShiftRPC_, + cfg.bxShiftGEM_, + cfg.bxShiftME0_, + cfg.includeNeighbor_, + cfg.duplicateTheta_, + cfg.bugME11Dupes_); PrimitiveConversion prim_conv; prim_conv.configure(tp_geom_, - lut_, + pc_lut_, verbose_, endcap_, sector_, bx, - bxShiftCSC_, - bxShiftRPC_, - bxShiftGEM_, - bxShiftME0_, - zoneBoundaries_, - zoneOverlap_, - duplicateTheta_, - fixZonePhi_, - useNewZones_, - fixME11Edges_, - bugME11Dupes_); + cfg.bxShiftCSC_, + cfg.bxShiftRPC_, + cfg.bxShiftGEM_, + cfg.bxShiftME0_, + cfg.zoneBoundaries_, + cfg.zoneOverlap_, + cfg.duplicateTheta_, + cfg.fixZonePhi_, + cfg.useNewZones_, + cfg.fixME11Edges_, + cfg.bugME11Dupes_); PatternRecognition patt_recog; patt_recog.configure(verbose_, endcap_, sector_, bx, - bxWindow_, - pattDefinitions_, - symPattDefinitions_, - useSymPatterns_, - maxRoadsPerZone_, - useSecondEarliest_); + cfg.bxWindow_, + cfg.pattDefinitions_, + cfg.symPattDefinitions_, + cfg.useSymPatterns_, + cfg.maxRoadsPerZone_, + cfg.useSecondEarliest_); PrimitiveMatching prim_match; - prim_match.configure(verbose_, endcap_, sector_, bx, fixZonePhi_, useNewZones_, bugSt2PhDiff_, bugME11Dupes_); + prim_match.configure( + verbose_, endcap_, sector_, bx, cfg.fixZonePhi_, cfg.useNewZones_, cfg.bugSt2PhDiff_, cfg.bugME11Dupes_); AngleCalculation angle_calc; angle_calc.configure(verbose_, endcap_, sector_, bx, - bxWindow_, - thetaWindow_, - thetaWindowZone0_, - bugME11Dupes_, - bugAmbigThetaWin_, - twoStationSameBX_); + cfg.bxWindow_, + cfg.thetaWindow_, + cfg.thetaWindowZone0_, + cfg.bugME11Dupes_, + cfg.bugAmbigThetaWin_, + cfg.twoStationSameBX_); BestTrackSelection btrack_sel; - btrack_sel.configure( - verbose_, endcap_, sector_, bx, bxWindow_, maxRoadsPerZone_, maxTracks_, useSecondEarliest_, bugSameSectorPt0_); + btrack_sel.configure(verbose_, + endcap_, + sector_, + bx, + cfg.bxWindow_, + cfg.maxRoadsPerZone_, + cfg.maxTracks_, + cfg.useSecondEarliest_, + cfg.bugSameSectorPt0_); SingleHitTrack single_hit; - single_hit.configure(verbose_, endcap_, sector_, bx, maxTracks_, useSingleHits_); + single_hit.configure(verbose_, endcap_, sector_, bx, cfg.maxTracks_, cfg.useSingleHits_); PtAssignment pt_assign; pt_assign.configure(pt_assign_engine_, @@ -510,14 +154,14 @@ void SectorProcessor::process_single_bx(int bx, endcap_, sector_, bx, - readPtLUTFile_, - fixMode15HighPt_, - bug9BitDPhi_, - bugMode7CLCT_, - bugNegPt_, - bugGMTPhi_, - promoteMode7_, - modeQualVer_); + cfg.readPtLUTFile_, + cfg.fixMode15HighPt_, + cfg.bug9BitDPhi_, + cfg.bugMode7CLCT_, + cfg.bugNegPt_, + cfg.bugGMTPhi_, + cfg.promoteMode7_, + cfg.modeQualVer_); std::map selected_dt_map; std::map selected_csc_map; @@ -545,9 +189,7 @@ void SectorProcessor::process_single_bx(int bx, // From src/PrimitiveSelection.cc prim_sel.process(emtf::DTTag(), muon_primitives, selected_dt_map); prim_sel.process(emtf::CSCTag(), muon_primitives, selected_csc_map); - if (useRPC_) { //FIXME - prim_sel.process(emtf::RPCTag(), muon_primitives, selected_rpc_map); - } + prim_sel.process(emtf::RPCTag(), muon_primitives, selected_rpc_map); prim_sel.process(emtf::GEMTag(), muon_primitives, selected_gem_map); prim_sel.process(emtf::ME0Tag(), muon_primitives, selected_me0_map); prim_sel.merge( From 18844bfd21fca5c9979033358cc5a1f6fd5f74ca Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 5 May 2020 14:52:07 -0400 Subject: [PATCH 27/34] [EMTF] Add EMTFSetup & VersionControl 5/6 --- .../L1TMuonEndCap/interface/ConditionHelper.h | 8 +++--- L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h | 15 +++++++++++ .../L1TMuonEndCap/src/ConditionHelper.cc | 9 +++++-- L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc | 25 +++++++++++++------ L1Trigger/L1TMuonEndCap/src/TrackFinder.cc | 13 ++++++---- 5 files changed, 51 insertions(+), 19 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/ConditionHelper.h b/L1Trigger/L1TMuonEndCap/interface/ConditionHelper.h index 72783d41a52f8..a36ce6af7c1fe 100644 --- a/L1Trigger/L1TMuonEndCap/interface/ConditionHelper.h +++ b/L1Trigger/L1TMuonEndCap/interface/ConditionHelper.h @@ -11,7 +11,6 @@ namespace edm { class L1TMuonEndCapParams; class L1TMuonEndCapForest; -class PtAssignmentEngine; // class declaration class ConditionHelper { @@ -21,16 +20,17 @@ class ConditionHelper { void checkAndUpdateConditions(const edm::Event& iEvent, const edm::EventSetup& iSetup); - const L1TMuonEndCapParams& getParams() const { return *params_; } - const L1TMuonEndCapForest& getForest() const { return *forest_; } + const L1TMuonEndCapParams* getParams() const { return params_.product(); } + const L1TMuonEndCapForest* getForest() const { return forest_.product(); } // EMTF firmware is defined by three numbers: // 1. FW version for the core logic // 2. pT assignment LUT - // 3. coordinate conversion LUT + // 3. primitive conversion (PC) LUT unsigned int get_fw_version() const; unsigned int get_pt_lut_version() const; unsigned int get_pc_lut_version() const; + unsigned int get_pc_lut_version_unchecked() const; private: unsigned long long params_cache_id_; diff --git a/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h b/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h index c28fa8b9f418b..086d89ccf46e4 100644 --- a/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h +++ b/L1Trigger/L1TMuonEndCap/interface/EMTFSetup.h @@ -35,6 +35,16 @@ class EMTFSetup { PtAssignmentEngine* getPtAssignmentEngine() const { return pt_assign_engine_.get(); } + // Setters + //void set_fw_version(unsigned version) { fw_ver_ = version; } + //void set_pt_lut_version(unsigned version) { pt_lut_ver_ = version; } + //void set_pc_lut_version(unsigned version) { pc_lut_ver_ = version; } + + // Getters + unsigned get_fw_version() const { return fw_ver_; } + unsigned get_pt_lut_version() const { return pt_lut_ver_; } + unsigned get_pc_lut_version() const { return pc_lut_ver_; } + // VersionControl getters const edm::ParameterSet& getConfig() const { return version_control_.getConfig(); } int verbose() const { return version_control_.verbose(); } @@ -52,6 +62,11 @@ class EMTFSetup { // Polymorphic class std::unique_ptr pt_assign_engine_; + + // Version numbers. Note: may be different from those in ConditionHelper + unsigned fw_ver_; + unsigned pt_lut_ver_; + unsigned pc_lut_ver_; }; #endif diff --git a/L1Trigger/L1TMuonEndCap/src/ConditionHelper.cc b/L1Trigger/L1TMuonEndCap/src/ConditionHelper.cc index ddb40b51ee62f..ecb03b4ccc44b 100644 --- a/L1Trigger/L1TMuonEndCap/src/ConditionHelper.cc +++ b/L1Trigger/L1TMuonEndCap/src/ConditionHelper.cc @@ -1,5 +1,7 @@ #include "L1Trigger/L1TMuonEndCap/interface/ConditionHelper.h" +#include "FWCore/Framework/interface/EventSetup.h" + #include "CondFormats/L1TObjects/interface/L1TMuonEndCapParams.h" #include "CondFormats/DataRecord/interface/L1TMuonEndCapParamsRcd.h" @@ -8,8 +10,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine.h" -#include "FWCore/Framework/interface/EventSetup.h" - ConditionHelper::ConditionHelper() : params_cache_id_(0ULL), forest_cache_id_(0ULL) {} ConditionHelper::~ConditionHelper() {} @@ -84,3 +84,8 @@ unsigned int ConditionHelper::get_pc_lut_version() const { return 2; // Starting September 26, 2018 with run 323556 (data only, not in MC) } } + +unsigned int ConditionHelper::get_pc_lut_version_unchecked() const { + // See comment in get_pc_lut_version() + return params_->PhiMatchWindowSt1_; +} diff --git a/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc b/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc index cb675eeca6263..c42c2d0dbbcdd 100644 --- a/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc +++ b/L1Trigger/L1TMuonEndCap/src/EMTFSetup.cc @@ -10,7 +10,10 @@ EMTFSetup::EMTFSetup(const edm::ParameterSet& iConfig) condition_helper_(), version_control_(iConfig), sector_processor_lut_(), - pt_assign_engine_(nullptr) { + pt_assign_engine_(nullptr), + fw_ver_(0), + pt_lut_ver_(0), + pc_lut_ver_(0) { // Set pt assignment engine according to Era if (era() == "Run2_2016") { pt_assign_engine_.reset(new PtAssignmentEngine2016()); @@ -34,18 +37,24 @@ void EMTFSetup::reload(const edm::Event& iEvent, const edm::EventSetup& iSetup) // Get the conditions, primarily the firmware version and the BDT forests condition_helper_.checkAndUpdateConditions(iEvent, iSetup); - // Do run-dependent configuration. This may overwrite the configurables passed by the python config file - version_control_.configure_by_fw_version(condition_helper_.get_fw_version()); + // Set version numbers + fw_ver_ = condition_helper_.get_fw_version(); + pt_lut_ver_ = condition_helper_.get_pt_lut_version(); + pc_lut_ver_ = condition_helper_.get_pc_lut_version(); + + if (!useO2O()) { + // Currently, do not modify fw_ver_ and pt_lut_ver_ + pc_lut_ver_ = condition_helper_.get_pc_lut_version_unchecked(); + } - // Decide the best pc_lut_ver & pt_lut_ver - unsigned pc_lut_ver = condition_helper_.get_pc_lut_version(); //TODO - check this - unsigned pt_lut_ver = condition_helper_.get_pt_lut_version(); //TODO - check this + // Do run-dependent configuration. This may overwrite the configurables passed by the python config file + version_control_.configure_by_fw_version(get_fw_version()); // Reload primitive conversion LUTs if necessary - sector_processor_lut_.read(iEvent.isRealData(), pc_lut_ver); + sector_processor_lut_.read(iEvent.isRealData(), get_pc_lut_version()); // Reload pT LUT if necessary - pt_assign_engine_->load(pt_lut_ver, &(condition_helper_.getForest())); + pt_assign_engine_->load(get_pt_lut_version(), condition_helper_.getForest()); return; } diff --git a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc index aea42016fd290..33c3cdb5cba86 100644 --- a/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCap/src/TrackFinder.cc @@ -36,12 +36,15 @@ void TrackFinder::process(const edm::Event& iEvent, auto tp_geom_ = &(setup_.getGeometryTranslator()); // Check versions - if (verbose_ > 0) { // debug - std::cout << "Event: " << iEvent.id() //TODO - check this - << " pc_lut_ver: " << setup_.getConditionHelper().get_pc_lut_version() - << " pt_lut_ver: " << setup_.getConditionHelper().get_pt_lut_version() + if (verbose_ > 0) { // debug + std::cout << "Event: " << iEvent.id() << " isData: " << iEvent.isRealData() << " useO2O: " << setup_.useO2O() + << " era: " << setup_.era() << " fw_ver: " << setup_.get_fw_version() + << " pt_lut_ver: " << setup_.get_pt_lut_version() << " pt_lut_ver in engine: " << setup_.getPtAssignmentEngine()->get_pt_lut_version() - << " fw_ver: " << setup_.getConditionHelper().get_fw_version() << std::endl; + << " pc_lut_ver: " << setup_.get_pc_lut_version() + << " pc_lut_ver in cond (i): " << setup_.getConditionHelper().get_pc_lut_version() + << " pc_lut_ver in cond (ii): " << setup_.getConditionHelper().get_pc_lut_version_unchecked() + << std::endl; } // ___________________________________________________________________________ From 3698d8daee237cdbdf6fc66a9854b2120a039b42 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 5 May 2020 01:03:53 -0400 Subject: [PATCH 28/34] [EMTF] Add EMTFSetup & VersionControl 6/6 --- .../interface/EndCapParamsHelper.h | 2 - .../interface/PrimitiveConversion.h | 6 +- .../plugins/L1TMuonEndCapParamsESProducer.cc | 1 - .../L1TMuonEndCap/src/PrimitiveConversion.cc | 68 +++++++++---------- .../L1TMuonEndCap/src/SectorProcessorLUT.cc | 59 ++++++++-------- 5 files changed, 65 insertions(+), 71 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/EndCapParamsHelper.h b/L1Trigger/L1TMuonEndCap/interface/EndCapParamsHelper.h index fc4df8746a549..8dc4064558ff4 100644 --- a/L1Trigger/L1TMuonEndCap/interface/EndCapParamsHelper.h +++ b/L1Trigger/L1TMuonEndCap/interface/EndCapParamsHelper.h @@ -31,8 +31,6 @@ // initialized with. That is responsibility of the calling code. // -#include "TXMLEngine.h" - namespace l1t { class EndCapParamsHelper { diff --git a/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h b/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h index 04d38c5210b4d..3d573a992e4f4 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h +++ b/L1Trigger/L1TMuonEndCap/interface/PrimitiveConversion.h @@ -8,7 +8,7 @@ class SectorProcessorLUT; class PrimitiveConversion { public: void configure(const GeometryTranslator* tp_geom, - const SectorProcessorLUT* lut, + const SectorProcessorLUT* pc_lut, int verbose, int endcap, int sector, @@ -27,7 +27,7 @@ class PrimitiveConversion { void process(const std::map& selected_prim_map, EMTFHitCollection& conv_hits) const; - const SectorProcessorLUT& lut() const { return *lut_; } + const SectorProcessorLUT& pc_lut() const { return *pc_lut_; } // CSC functions void convert_csc(int pc_sector, @@ -93,7 +93,7 @@ class PrimitiveConversion { private: const GeometryTranslator* tp_geom_; - const SectorProcessorLUT* lut_; + const SectorProcessorLUT* pc_lut_; int verbose_, endcap_, sector_, bx_; diff --git a/L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapParamsESProducer.cc b/L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapParamsESProducer.cc index 61291cd5cedad..b87fff411548d 100644 --- a/L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapParamsESProducer.cc +++ b/L1Trigger/L1TMuonEndCap/plugins/L1TMuonEndCapParamsESProducer.cc @@ -12,7 +12,6 @@ #include "L1Trigger/L1TMuonEndCap/interface/EndCapParamsHelper.h" #include "FWCore/ParameterSet/interface/FileInPath.h" -#include "TXMLEngine.h" using namespace std; diff --git a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc index 4f541767f2d09..89c7b45930ce9 100644 --- a/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc +++ b/L1Trigger/L1TMuonEndCap/src/PrimitiveConversion.cc @@ -5,7 +5,7 @@ #include "Geometry/RPCGeometry/interface/RPCGeometry.h" // for special treatments for iRPC void PrimitiveConversion::configure(const GeometryTranslator* tp_geom, - const SectorProcessorLUT* lut, + const SectorProcessorLUT* pc_lut, int verbose, int endcap, int sector, @@ -22,10 +22,10 @@ void PrimitiveConversion::configure(const GeometryTranslator* tp_geom, bool fixME11Edges, bool bugME11Dupes) { emtf_assert(tp_geom != nullptr); - emtf_assert(lut != nullptr); + emtf_assert(pc_lut != nullptr); tp_geom_ = tp_geom; - lut_ = lut; + pc_lut_ = pc_lut; verbose_ = verbose; endcap_ = endcap; // 1 for ME+, 2 for ME- @@ -262,11 +262,11 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { if (verbose_ > 1) { // debug std::cout << "pc_station: " << pc_station << " pc_chamber: " << pc_chamber << " fw_station: " << fw_station << " fw_cscid: " << fw_cscid << " lut_id: " << pc_lut_id - << " ph_init: " << lut().get_ph_init(fw_endcap, fw_sector, pc_lut_id) - << " ph_disp: " << lut().get_ph_disp(fw_endcap, fw_sector, pc_lut_id) - << " th_init: " << lut().get_th_init(fw_endcap, fw_sector, pc_lut_id) - << " th_disp: " << lut().get_th_disp(fw_endcap, fw_sector, pc_lut_id) - << " ph_init_hard: " << lut().get_ph_init_hard(fw_station, fw_cscid) << std::endl; + << " ph_init: " << pc_lut().get_ph_init(fw_endcap, fw_sector, pc_lut_id) + << " ph_disp: " << pc_lut().get_ph_disp(fw_endcap, fw_sector, pc_lut_id) + << " th_init: " << pc_lut().get_th_init(fw_endcap, fw_sector, pc_lut_id) + << " th_disp: " << pc_lut().get_th_disp(fw_endcap, fw_sector, pc_lut_id) + << " ph_init_hard: " << pc_lut().get_ph_init_hard(fw_station, fw_cscid) << std::endl; } // ___________________________________________________________________________ @@ -276,8 +276,8 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { int eighth_strip = 0; // Apply phi correction from CLCT pattern number (from src/SectorProcessorLUT.cc) - int clct_pat_corr = lut().get_ph_patt_corr(conv_hit.Pattern()); - int clct_pat_corr_sign = (lut().get_ph_patt_corr_sign(conv_hit.Pattern()) == 0) ? 1 : -1; + int clct_pat_corr = pc_lut().get_ph_patt_corr(conv_hit.Pattern()); + int clct_pat_corr_sign = (pc_lut().get_ph_patt_corr_sign(conv_hit.Pattern()) == 0) ? 1 : -1; // At strip number 0, protect against negative correction bool bugStrip0BeforeFW48200 = false; @@ -319,27 +319,27 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { int ph_tmp = (eighth_strip * factor) >> 10; int ph_tmp_sign = (ph_reverse == 0) ? 1 : -1; - int fph = lut().get_ph_init(fw_endcap, fw_sector, pc_lut_id); + int fph = pc_lut().get_ph_init(fw_endcap, fw_sector, pc_lut_id); fph = fph + ph_tmp_sign * ph_tmp; - int ph_hit = lut().get_ph_disp(fw_endcap, fw_sector, pc_lut_id); + int ph_hit = pc_lut().get_ph_disp(fw_endcap, fw_sector, pc_lut_id); ph_hit = (ph_hit >> 1) + ph_tmp_sign * (ph_tmp >> 5) + ph_coverage; // Full phi +16 to put the rounded value into the middle of error range // Divide full phi by 32, subtract chamber start - int ph_hit_fixed = -1 * lut().get_ph_init_hard(fw_station, fw_cscid); + int ph_hit_fixed = -1 * pc_lut().get_ph_init_hard(fw_station, fw_cscid); ph_hit_fixed = ph_hit_fixed + ((fph + (1 << 4)) >> 5); if (fixZonePhi_) ph_hit = ph_hit_fixed; // Zone phi - int zone_hit = lut().get_ph_zone_offset(pc_station, pc_chamber); + int zone_hit = pc_lut().get_ph_zone_offset(pc_station, pc_chamber); zone_hit += ph_hit; - int zone_hit_fixed = lut().get_ph_init_hard(fw_station, fw_cscid); + int zone_hit_fixed = pc_lut().get_ph_init_hard(fw_station, fw_cscid); zone_hit_fixed += ph_hit_fixed; - // Since ph_hit_fixed = ((fph + (1<<4)) >> 5) - lut().get_ph_init_hard(), the following is equivalent: + // Since ph_hit_fixed = ((fph + (1<<4)) >> 5) - pc_lut().get_ph_init_hard(), the following is equivalent: //zone_hit_fixed = ((fph + (1<<4)) >> 5); if (fixZonePhi_) @@ -353,7 +353,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { // th_tmp is theta local to chamber int pc_wire_id = (fw_wire & 0x7f); // 7-bit - int th_tmp = lut().get_th_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_id); + int th_tmp = pc_lut().get_th_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_id); // For ME1/1 with tilted wires, add theta correction as a function of (wire,strip) index if (!fixME11Edges_ && (is_me11a || is_me11b)) { @@ -371,7 +371,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { } } - int th_corr = lut().get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id); + int th_corr = pc_lut().get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id); int th_corr_sign = (ph_reverse == 0) ? 1 : -1; th_tmp = th_tmp + th_corr_sign * th_corr; @@ -390,7 +390,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { if (is_me11a) pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | ((((eighth_strip * 341) >> 8) >> 4) & 0x1f); // correct for ME1/1a strip number (341/256 =~ 1.333) - int th_corr = lut().get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id); + int th_corr = pc_lut().get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id); th_tmp = th_tmp + th_corr; @@ -404,7 +404,7 @@ void PrimitiveConversion::convert_csc_details(EMTFHit& conv_hit) const { // theta precision: (36.5/128) deg // theta starts at 8.5 deg: {1, 127} <--> {8.785, 44.715} - int th = lut().get_th_init(fw_endcap, fw_sector, pc_lut_id); + int th = pc_lut().get_th_init(fw_endcap, fw_sector, pc_lut_id); th = th + th_tmp; emtf_assert(0 <= th && th < 128); @@ -626,20 +626,20 @@ void PrimitiveConversion::convert_rpc_details(EMTFHit& conv_hit, bool isCPPF) co int halfstrip = (conv_hit.Strip_low() + conv_hit.Strip_hi() - 1); emtf_assert(1 <= halfstrip && halfstrip <= 64); - int fph2 = lut().get_cppf_ph_lut(conv_hit.Endcap(), - conv_hit.Sector_RPC(), - conv_hit.Station(), - conv_hit.Ring(), - conv_hit.Subsector_RPC(), - conv_hit.Roll(), - halfstrip, - is_neighbor); - int th2 = lut().get_cppf_th_lut(conv_hit.Endcap(), - conv_hit.Sector_RPC(), - conv_hit.Station(), - conv_hit.Ring(), - conv_hit.Subsector_RPC(), - conv_hit.Roll()); + int fph2 = pc_lut().get_cppf_ph_lut(conv_hit.Endcap(), + conv_hit.Sector_RPC(), + conv_hit.Station(), + conv_hit.Ring(), + conv_hit.Subsector_RPC(), + conv_hit.Roll(), + halfstrip, + is_neighbor); + int th2 = pc_lut().get_cppf_th_lut(conv_hit.Endcap(), + conv_hit.Sector_RPC(), + conv_hit.Station(), + conv_hit.Ring(), + conv_hit.Subsector_RPC(), + conv_hit.Roll()); //emtf_assert(abs((fph>>2) - fph2) <= 4); // arbitrary tolerance //emtf_assert(abs((th>>2) - th2) <= 1); // arbitrary tolerance fph = fph2; diff --git a/L1Trigger/L1TMuonEndCap/src/SectorProcessorLUT.cc b/L1Trigger/L1TMuonEndCap/src/SectorProcessorLUT.cc index 05ee91ce85327..7491c3c49fa98 100644 --- a/L1Trigger/L1TMuonEndCap/src/SectorProcessorLUT.cc +++ b/L1Trigger/L1TMuonEndCap/src/SectorProcessorLUT.cc @@ -32,7 +32,7 @@ void SectorProcessorLUT::read(bool pc_lut_data, int pc_lut_version) { else if (pc_lut_version == -1) coord_lut_dir = "ph_lut_v2"; // MC using ideal CMS LCT alignment, but use local CPPF LUTs for RPC else - throw cms::Exception("SectorProcessorLUT") + throw cms::Exception("L1TMuonEndCap") << "Trying to use EMTF pc_lut_version = " << pc_lut_version << ", does not exist!"; // Will catch user trying to run with Global Tag settings on 2016 data, rather than fakeEmtfParams. - AWB 08.06.17 @@ -57,48 +57,46 @@ void SectorProcessorLUT::read(bool pc_lut_data, int pc_lut_version) { use_local_cppf_files); // cppf filenames are hardcoded in the function if (ph_init_neighbor_.size() != 2 * 6 * 61) { // [endcap_2][sector_6][chamber_61] - throw cms::Exception("SectorProcessorLUT") << "Expected ph_init_neighbor_ to get " << 2 * 6 * 61 << " values, " - << "got " << ph_init_neighbor_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected ph_init_neighbor_ to get " << 2 * 6 * 61 << " values, " + << "got " << ph_init_neighbor_.size() << " values."; } if (ph_disp_neighbor_.size() != 2 * 6 * 61) { // [endcap_2][sector_6][chamber_61] - throw cms::Exception("SectorProcessorLUT") << "Expected ph_disp_neighbor_ to get " << 2 * 6 * 61 << " values, " - << "got " << ph_disp_neighbor_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected ph_disp_neighbor_ to get " << 2 * 6 * 61 << " values, " + << "got " << ph_disp_neighbor_.size() << " values."; } if (th_init_neighbor_.size() != 2 * 6 * 61) { // [endcap_2][sector_6][chamber_61] - throw cms::Exception("SectorProcessorLUT") << "Expected th_init_neighbor_ to get " << 2 * 6 * 61 << " values, " - << "got " << th_init_neighbor_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected th_init_neighbor_ to get " << 2 * 6 * 61 << " values, " + << "got " << th_init_neighbor_.size() << " values."; } if (th_disp_neighbor_.size() != 2 * 6 * 61) { // [endcap_2][sector_6][chamber_61] - throw cms::Exception("SectorProcessorLUT") << "Expected th_disp_neighbor_ to get " << 2 * 6 * 61 << " values, " - << "got " << th_disp_neighbor_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected th_disp_neighbor_ to get " << 2 * 6 * 61 << " values, " + << "got " << th_disp_neighbor_.size() << " values."; } if (th_lut_neighbor_.size() != 2 * 6 * 61 * 128) { // [endcap_2][sector_6][chamber_61][wire_128] - throw cms::Exception("SectorProcessorLUT") << "Expected th_lut_neighbor_ to get " << 2 * 6 * 61 * 128 << " values, " - << "got " << th_lut_neighbor_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected th_lut_neighbor_ to get " << 2 * 6 * 61 * 128 << " values, " + << "got " << th_lut_neighbor_.size() << " values."; } if (th_corr_lut_neighbor_.size() != 2 * 6 * 7 * 128) { // [endcap_2][sector_6][chamber_61][strip_wire_128] - throw cms::Exception("SectorProcessorLUT") - << "Expected th_corr_lut_neighbor_ to get " << 2 * 6 * 7 * 128 << " values, " - << "got " << th_corr_lut_neighbor_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected th_corr_lut_neighbor_ to get " << 2 * 6 * 7 * 128 << " values, " + << "got " << th_corr_lut_neighbor_.size() << " values."; } if (cppf_ph_lut_.size() != 2 * 6 * 6 * 6 * 3 * 64) { // [endcap_2][rpc_sector_6][rpc_station_ring_6][rpc_subsector_6][rpc_roll_3][rpc_halfstrip_64] - throw cms::Exception("SectorProcessorLUT") - << "Expected cppf_ph_lut_ to get " << 2 * 6 * 6 * 6 * 3 * 64 << " values, " - << "got " << cppf_ph_lut_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected cppf_ph_lut_ to get " << 2 * 6 * 6 * 6 * 3 * 64 << " values, " + << "got " << cppf_ph_lut_.size() << " values."; } if (cppf_th_lut_.size() != 2 * 6 * 6 * 6 * 3) { // [endcap_2][rpc_sector_6][rpc_station_ring_6][rpc_subsector_6][rpc_roll_3] - throw cms::Exception("SectorProcessorLUT") << "Expected cppf_th_lut_ to get " << 2 * 6 * 6 * 6 * 3 << " values, " - << "got " << cppf_th_lut_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected cppf_th_lut_ to get " << 2 * 6 * 6 * 6 * 3 << " values, " + << "got " << cppf_th_lut_.size() << " values."; } // clct pattern convertion array from CMSSW @@ -106,22 +104,22 @@ void SectorProcessorLUT::read(bool pc_lut_data, int pc_lut_version) { // 0 0 -5 +5 -5 +5 -2 +2 -2 +2 0 ph_patt_corr_ = {0, 0, 5, 5, 5, 5, 2, 2, 2, 2, 0}; if (ph_patt_corr_.size() != 11) { - throw cms::Exception("SectorProcessorLUT") << "Expected ph_patt_corr_ to get " << 11 << " values, " - << "got " << ph_patt_corr_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected ph_patt_corr_ to get " << 11 << " values, " + << "got " << ph_patt_corr_.size() << " values."; } ph_patt_corr_sign_ = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0}; if (ph_patt_corr_sign_.size() != 11) { - throw cms::Exception("SectorProcessorLUT") << "Expected ph_patt_corr_sign_ to get " << 11 << " values, " - << "got " << ph_patt_corr_sign_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected ph_patt_corr_sign_ to get " << 11 << " values, " + << "got " << ph_patt_corr_sign_.size() << " values."; } ph_zone_offset_ = {39, 57, 76, 39, 58, 76, 41, 60, 79, 95, 114, 132, 95, 114, 133, 98, 116, 135, 38, 76, 113, 39, 58, 76, 95, 114, 132, 38, 76, 113, 39, 58, 76, 95, 114, 132, 38, 76, 113, 38, 57, 76, 95, 113, 132, 21, 21, 23, 1, 21, 1, 21, 1, 20}; if (ph_zone_offset_.size() != 6 * 9) { - throw cms::Exception("SectorProcessorLUT") << "Expected ph_zone_offset_ to get " << 6 * 9 << " values, " - << "got " << ph_zone_offset_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected ph_zone_offset_ to get " << 6 * 9 << " values, " + << "got " << ph_zone_offset_.size() << " values."; } // start phi of each chamber in reduced precision, for zone hits, @@ -131,8 +129,8 @@ void SectorProcessorLUT::read(bool pc_lut_data, int pc_lut_version) { 132, 1, 21, 0, 0, 0, 0, 0, 38, 76, 113, 39, 58, 76, 95, 114, 132, 1, 21, 0, 0, 0, 0, 0, 38, 76, 113, 38, 57, 76, 95, 113, 132, 1, 20, 0, 0, 0, 0, 0}; if (ph_init_hard_.size() != 5 * 16) { - throw cms::Exception("SectorProcessorLUT") << "Expected ph_init_hard_ to get " << 5 * 16 << " values, " - << "got " << ph_init_hard_.size() << " values."; + throw cms::Exception("L1TMuonEndCap") << "Expected ph_init_hard_ to get " << 5 * 16 << " values, " + << "got " << ph_init_hard_.size() << " values."; } version_ = pc_lut_version; @@ -190,7 +188,7 @@ uint32_t SectorProcessorLUT::get_th_corr_lut(int fw_endcap, int fw_sector, int p } else if (16 <= pc_lut_id2 && pc_lut_id2 < 19) { pc_lut_id2 -= 12; } else { - throw cms::Exception("SectorProcessorLUT") << "get_th_corr_lut(): out of range pc_lut_id: " << pc_lut_id; + throw cms::Exception("L1TMuonEndCap") << "get_th_corr_lut(): out of range pc_lut_id: " << pc_lut_id; } size_t index = ((fw_endcap * 6 + fw_sector) * 7 + pc_lut_id2) * 128 + pc_wire_strip_id; @@ -310,11 +308,10 @@ void SectorProcessorLUT::read_cppf_file(const std::string& filename, } if (local && (buf1 == 0 || buf2 == 0)) { - throw cms::Exception("SectorProcessorLUT") - << "Expected non-0 values, got buf1 = " << buf1 << ", buf2 = " << buf2; + throw cms::Exception("L1TMuonEndCap") << "Expected non-0 values, got buf1 = " << buf1 << ", buf2 = " << buf2; } if (!local && (buf1_prev == 0 || buf2_prev == 0)) { - throw cms::Exception("SectorProcessorLUT") + throw cms::Exception("L1TMuonEndCap") << "Expected non-0 values, got buf1_prev = " << buf1_prev << ", buf2_prev = " << buf2_prev; } From 4763d71682e52dee773521886969155f5ab84abf Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 5 May 2020 14:27:52 -0400 Subject: [PATCH 29/34] [EMTF] Remove PtLUTVarCalc 1/2 --- .../L1TMuonEndCap/interface/PtLUTVarCalc.h | 80 ---- L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc | 347 ------------------ 2 files changed, 427 deletions(-) delete mode 100644 L1Trigger/L1TMuonEndCap/interface/PtLUTVarCalc.h delete mode 100644 L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc diff --git a/L1Trigger/L1TMuonEndCap/interface/PtLUTVarCalc.h b/L1Trigger/L1TMuonEndCap/interface/PtLUTVarCalc.h deleted file mode 100644 index c5cff26303249..0000000000000 --- a/L1Trigger/L1TMuonEndCap/interface/PtLUTVarCalc.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef L1TMuonEndCap_PtLUTVarCalc_h -#define L1TMuonEndCap_PtLUTVarCalc_h - -int CalcTrackTheta(const int th1, - const int th2, - const int th3, - const int th4, - const int ring1, - const int mode, - const bool BIT_COMP = false); - -void CalcDeltaPhis(int& dPh12, - int& dPh13, - int& dPh14, - int& dPh23, - int& dPh24, - int& dPh34, - int& dPhSign, - int& dPhSum4, - int& dPhSum4A, - int& dPhSum3, - int& dPhSum3A, - int& outStPh, - const int ph1, - const int ph2, - const int ph3, - const int ph4, - const int mode, - const bool BIT_COMP = false); - -void CalcDeltaThetas(int& dTh12, - int& dTh13, - int& dTh14, - int& dTh23, - int& dTh24, - int& dTh34, - const int th1, - const int th2, - const int th3, - const int th4, - const int mode, - const bool BIT_COMP = false); - -void CalcBends(int& bend1, - int& bend2, - int& bend3, - int& bend4, - const int pat1, - const int pat2, - const int pat3, - const int pat4, - const int dPhSign, - const int endcap, - const int mode, - const bool BIT_COMP = false); - -void CalcRPCs(int& RPC1, - int& RPC2, - int& RPC3, - int& RPC4, - const int mode, - const int st1_ring2, - const int theta, - const bool BIT_COMP = false); - -int CalcBendFromPattern(const int pattern, const int endcap); - -void CalcDeltaPhiSums(int& dPhSum4, - int& dPhSum4A, - int& dPhSum3, - int& dPhSum3A, - int& outStPh, - const int dPh12, - const int dPh13, - const int dPh14, - const int dPh23, - const int dPh24, - const int dPh34); - -#endif diff --git a/L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc b/L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc deleted file mode 100644 index 5c5a3e6ef1ba4..0000000000000 --- a/L1Trigger/L1TMuonEndCap/src/PtLUTVarCalc.cc +++ /dev/null @@ -1,347 +0,0 @@ -#include "L1Trigger/L1TMuonEndCap/interface/PtLUTVarCalc.h" -#include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h" - -#include - -// From here down, exact copy of code used for training BDT: EMTFPtAssign2017/src/PtLUTVarCalc.cc - -PtAssignmentEngineAux2017 ENG; - -int CalcTrackTheta(const int th1, - const int th2, - const int th3, - const int th4, - const int st1_ring2, - const int mode, - const bool BIT_COMP) { - int theta = -99; - - if ((mode % 8) / 4 > 0) // Has station 2 hit - theta = th2; - else if ((mode % 4) / 2 > 0) // Has station 3 hit - theta = th3; - else if ((mode % 2) > 0) // Has station 4 hit - theta = th4; - - emtf_assert(theta > 0); - - if (BIT_COMP) { - int nBits = (mode == 15 ? 4 : 5); - theta = ENG.getTheta(theta, st1_ring2, nBits); - } - - return theta; -} - -void CalcDeltaPhis(int& dPh12, - int& dPh13, - int& dPh14, - int& dPh23, - int& dPh24, - int& dPh34, - int& dPhSign, - int& dPhSum4, - int& dPhSum4A, - int& dPhSum3, - int& dPhSum3A, - int& outStPh, - const int ph1, - const int ph2, - const int ph3, - const int ph4, - const int mode, - const bool BIT_COMP) { - dPh12 = ph2 - ph1; - dPh13 = ph3 - ph1; - dPh14 = ph4 - ph1; - dPh23 = ph3 - ph2; - dPh24 = ph4 - ph2; - dPh34 = ph4 - ph3; - dPhSign = 0; - - if (mode >= 8) { // First hit is station 1 - if ((mode % 8) / 4 > 0) // Has station 2 hit - dPhSign = (dPh12 >= 0 ? +1 : -1); - else if ((mode % 4) / 2 > 0) // Has station 3 hit - dPhSign = (dPh13 >= 0 ? +1 : -1); - else if ((mode % 2) > 0) // Has station 4 hit - dPhSign = (dPh14 >= 0 ? +1 : -1); - } else if ((mode % 8) / 4 > 0) { // First hit is station 2 - if ((mode % 4) / 2 > 0) // Has station 3 hit - dPhSign = (dPh23 >= 0 ? +1 : -1); - else if ((mode % 2) > 0) // Has station 4 hit - dPhSign = (dPh24 >= 0 ? +1 : -1); - } else if ((mode % 4) / 2 > 0) { // First hit is station 3 - if ((mode % 2) > 0) // Has station 4 hit - dPhSign = (dPh34 >= 0 ? +1 : -1); - } - - emtf_assert(dPhSign != 0); - - dPh12 *= dPhSign; - dPh13 *= dPhSign; - dPh14 *= dPhSign; - dPh23 *= dPhSign; - dPh24 *= dPhSign; - dPh34 *= dPhSign; - - if (BIT_COMP) { - int nBitsA = 7; - int nBitsB = 7; - int nBitsC = 7; - int maxA = 512; - int maxB = 512; - int maxC = 512; - - if (mode == 7 || mode == 11 || mode > 12) { - nBitsB = 5; - maxB = 256; - nBitsC = 5; - maxC = 256; - } - if (mode == 15) { - nBitsC = 4; - maxC = 256; - } - - dPh12 = ENG.getNLBdPhi(dPh12, nBitsA, maxA); - dPh13 = ENG.getNLBdPhi(dPh13, nBitsA, maxA); - dPh14 = ENG.getNLBdPhi(dPh14, nBitsA, maxA); - if (mode == 7) - dPh23 = ENG.getNLBdPhi(dPh23, nBitsA, maxA); - else - dPh23 = ENG.getNLBdPhi(dPh23, nBitsB, maxB); - dPh24 = ENG.getNLBdPhi(dPh24, nBitsB, maxB); - dPh34 = ENG.getNLBdPhi(dPh34, nBitsC, maxC); - - // Some delta phi values must be computed from others - switch (mode) { - case 15: - dPh13 = dPh12 + dPh23; - dPh14 = dPh13 + dPh34; - dPh24 = dPh23 + dPh34; - break; - case 14: - dPh13 = dPh12 + dPh23; - break; - case 13: - dPh14 = dPh12 + dPh24; - break; - case 11: - dPh14 = dPh13 + dPh34; - break; - case 7: - dPh24 = dPh23 + dPh34; - break; - default: - break; - } - - } // End conditional: if (BIT_COMP) - - // Compute summed quantities - if (mode == 15) - CalcDeltaPhiSums(dPhSum4, dPhSum4A, dPhSum3, dPhSum3A, outStPh, dPh12, dPh13, dPh14, dPh23, dPh24, dPh34); - -} // End function: CalcDeltaPhis() - -void CalcDeltaThetas(int& dTh12, - int& dTh13, - int& dTh14, - int& dTh23, - int& dTh24, - int& dTh34, - const int th1, - const int th2, - const int th3, - const int th4, - const int mode, - const bool BIT_COMP) { - dTh12 = th2 - th1; - dTh13 = th3 - th1; - dTh14 = th4 - th1; - dTh23 = th3 - th2; - dTh24 = th4 - th2; - dTh34 = th4 - th3; - - if (BIT_COMP) { - int nBits = (mode == 15 ? 2 : 3); - - dTh12 = ENG.getdTheta(dTh12, nBits); - dTh13 = ENG.getdTheta(dTh13, nBits); - dTh14 = ENG.getdTheta(dTh14, nBits); - dTh23 = ENG.getdTheta(dTh23, nBits); - dTh24 = ENG.getdTheta(dTh24, nBits); - dTh34 = ENG.getdTheta(dTh34, nBits); - } // End conditional: if (BIT_COMP) - -} // CalcDeltaThetas() - -void CalcBends(int& bend1, - int& bend2, - int& bend3, - int& bend4, - const int pat1, - const int pat2, - const int pat3, - const int pat4, - const int dPhSign, - const int endcap, - const int mode, - const bool BIT_COMP) { - bend1 = CalcBendFromPattern(pat1, endcap); - bend2 = CalcBendFromPattern(pat2, endcap); - bend3 = CalcBendFromPattern(pat3, endcap); - bend4 = CalcBendFromPattern(pat4, endcap); - - if (BIT_COMP) { - int nBits = 3; - if (mode == 7 || mode == 11 || mode > 12) - nBits = 2; - - if (mode / 8 > 0) // Has station 1 hit - bend1 = ENG.getCLCT(pat1, endcap, dPhSign, nBits); - if ((mode % 8) / 4 > 0) // Has station 2 hit - bend2 = ENG.getCLCT(pat2, endcap, dPhSign, nBits); - if ((mode % 4) / 2 > 0) // Has station 3 hit - bend3 = ENG.getCLCT(pat3, endcap, dPhSign, nBits); - if ((mode % 2) > 0) // Has station 4 hit - bend4 = ENG.getCLCT(pat4, endcap, dPhSign, nBits); - } // End conditional: if (BIT_COMP) - -} // End function: CalcBends() - -void CalcRPCs(int& RPC1, - int& RPC2, - int& RPC3, - int& RPC4, - const int mode, - const int st1_ring2, - const int theta, - const bool BIT_COMP) { - if (BIT_COMP) { - // Mask some invalid locations for RPC hits - // theta is assumed to be the compressed, mode 15 version - if (mode == 15 && !st1_ring2) { - RPC1 = 0; - RPC2 = 0; - if (theta < 4) { - RPC3 = 0; - RPC4 = 0; - } - } - - int nRPC = (RPC1 == 1) + (RPC2 == 1) + (RPC3 == 1) + (RPC4 == 1); - - // In 3- and 4-station modes, only specify some combinations of RPCs - if (nRPC >= 2) { - if (mode == 15) { - if (RPC1 == 1 && RPC2 == 1) { - RPC3 = 0; - RPC4 = 0; - } else if (RPC1 == 1 && RPC3 == 1) { - RPC4 = 0; - } else if (RPC4 == 1 && RPC2 == 1) { - RPC3 = 0; - } else if (RPC3 == 1 && RPC4 == 1 && !st1_ring2) { - RPC3 = 0; - } - } else if (mode == 14) { - if (RPC1 == 1) { - RPC2 = 0; - RPC3 = 0; - } else if (RPC3 == 1) { - RPC2 = 0; - } - } else if (mode == 13) { - if (RPC1 == 1) { - RPC2 = 0; - RPC4 = 0; - } else if (RPC4 == 1) { - RPC2 = 0; - } - } else if (mode == 11) { - if (RPC1 == 1) { - RPC3 = 0; - RPC4 = 0; - } else if (RPC4 == 1) { - RPC3 = 0; - } - } else if (mode == 7) { - if (RPC2 == 1) { - RPC3 = 0; - RPC4 = 0; - } else if (RPC4 == 1) { - RPC3 = 0; - } - } - - } // End conditional: if (nRPC >= 2) - } // End conditional: if (BIT_COMP) - -} // End function: void CalcRPCs() - -int CalcBendFromPattern(const int pattern, const int endcap) { - int bend = -99; - if (pattern < 0) - return bend; - - if (pattern == 10) - bend = 0; - else if ((pattern % 2) == 0) - bend = (10 - pattern) / 2; - else if ((pattern % 2) == 1) - bend = -1 * (11 - pattern) / 2; - - // Reverse to match dPhi convention - if (endcap == 1) - bend *= -1; - - emtf_assert(bend != -99); - return bend; -} - -void CalcDeltaPhiSums(int& dPhSum4, - int& dPhSum4A, - int& dPhSum3, - int& dPhSum3A, - int& outStPh, - const int dPh12, - const int dPh13, - const int dPh14, - const int dPh23, - const int dPh24, - const int dPh34) { - dPhSum4 = dPh12 + dPh13 + dPh14 + dPh23 + dPh24 + dPh34; - dPhSum4A = abs(dPh12) + abs(dPh13) + abs(dPh14) + abs(dPh23) + abs(dPh24) + abs(dPh34); - int devSt1 = abs(dPh12) + abs(dPh13) + abs(dPh14); - int devSt2 = abs(dPh12) + abs(dPh23) + abs(dPh24); - int devSt3 = abs(dPh13) + abs(dPh23) + abs(dPh34); - int devSt4 = abs(dPh14) + abs(dPh24) + abs(dPh34); - - if (devSt4 > devSt3 && devSt4 > devSt2 && devSt4 > devSt1) - outStPh = 4; - else if (devSt3 > devSt4 && devSt3 > devSt2 && devSt3 > devSt1) - outStPh = 3; - else if (devSt2 > devSt4 && devSt2 > devSt3 && devSt2 > devSt1) - outStPh = 2; - else if (devSt1 > devSt4 && devSt1 > devSt3 && devSt1 > devSt2) - outStPh = 1; - else - outStPh = 0; - - if (outStPh == 4) { - dPhSum3 = dPh12 + dPh13 + dPh23; - dPhSum3A = abs(dPh12) + abs(dPh13) + abs(dPh23); - } else if (outStPh == 3) { - dPhSum3 = dPh12 + dPh14 + dPh24; - dPhSum3A = abs(dPh12) + abs(dPh14) + abs(dPh24); - } else if (outStPh == 2) { - dPhSum3 = dPh13 + dPh14 + dPh34; - dPhSum3A = abs(dPh13) + abs(dPh14) + abs(dPh34); - } else { - dPhSum3 = dPh23 + dPh24 + dPh34; - dPhSum3A = abs(dPh23) + abs(dPh24) + abs(dPh34); - } - -} // End function: void CalcDeltaPhiSums() From 320aa9d0ac8e1758daf92d8685a323926f049ad4 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 5 May 2020 14:33:26 -0400 Subject: [PATCH 30/34] [EMTF] Remove PtLUTVarCalc 2/2 --- .../interface/PtAssignmentEngineAux2017.h | 79 ++++ .../src/PtAssignmentEngine2017.cc | 71 ++-- .../src/PtAssignmentEngineAux2017.cc | 344 +++++++++++++++++- 3 files changed, 457 insertions(+), 37 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h index 79bcda49dfe92..5adaa997939ef 100644 --- a/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h +++ b/L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h @@ -44,6 +44,85 @@ class PtAssignmentEngineAux2017 : public PtAssignmentEngineAux { // Need to re-check / verify this - AWB 17.03.17 // int getFRLUT(int sector, int station, int chamber) const; + + // ___________________________________________________________________________ + // From here down, code was originally in PtLUTVarCalc.h + + int calcTrackTheta(const int th1, + const int th2, + const int th3, + const int th4, + const int ring1, + const int mode, + const bool BIT_COMP = false) const; + + void calcDeltaPhis(int& dPh12, + int& dPh13, + int& dPh14, + int& dPh23, + int& dPh24, + int& dPh34, + int& dPhSign, + int& dPhSum4, + int& dPhSum4A, + int& dPhSum3, + int& dPhSum3A, + int& outStPh, + const int ph1, + const int ph2, + const int ph3, + const int ph4, + const int mode, + const bool BIT_COMP = false) const; + + void calcDeltaThetas(int& dTh12, + int& dTh13, + int& dTh14, + int& dTh23, + int& dTh24, + int& dTh34, + const int th1, + const int th2, + const int th3, + const int th4, + const int mode, + const bool BIT_COMP = false) const; + + void calcBends(int& bend1, + int& bend2, + int& bend3, + int& bend4, + const int pat1, + const int pat2, + const int pat3, + const int pat4, + const int dPhSign, + const int endcap, + const int mode, + const bool BIT_COMP = false) const; + + void calcRPCs(int& RPC1, + int& RPC2, + int& RPC3, + int& RPC4, + const int mode, + const int st1_ring2, + const int theta, + const bool BIT_COMP = false) const; + + int calcBendFromPattern(const int pattern, const int endcap) const; + + void calcDeltaPhiSums(int& dPhSum4, + int& dPhSum4A, + int& dPhSum3, + int& dPhSum3A, + int& outStPh, + const int dPh12, + const int dPh13, + const int dPh14, + const int dPh23, + const int dPh24, + const int dPh34) const; }; #endif diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2017.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2017.cc index 1834a27a327ea..10c3d480c8584 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2017.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngine2017.cc @@ -1,6 +1,5 @@ #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngine2017.h" #include "L1Trigger/L1TMuonEndCap/interface/PtAssignmentEngineAux2017.h" -#include "L1Trigger/L1TMuonEndCap/interface/PtLUTVarCalc.h" #include #include @@ -419,17 +418,17 @@ float PtAssignmentEngine2017::calculate_pt_xml(const address_t& address) const { predictors = { theta, St1_ring2, dPhiAB, dPhiBC, dPhiCD, dPhiAB + dPhiBC, dPhiAB + dPhiBC + dPhiCD, dPhiBC + dPhiCD, frA, clctA}; - CalcDeltaPhiSums(dPhiSum4, - dPhiSum4A, - dPhiSum3, - dPhiSum3A, - outStPhi, - dPhiAB, - dPhiAB + dPhiBC, - dPhiAB + dPhiBC + dPhiCD, - dPhiBC, - dPhiBC + dPhiCD, - dPhiCD); + aux().calcDeltaPhiSums(dPhiSum4, + dPhiSum4A, + dPhiSum3, + dPhiSum3A, + outStPhi, + dPhiAB, + dPhiAB + dPhiBC, + dPhiAB + dPhiBC + dPhiCD, + dPhiBC, + dPhiBC + dPhiCD, + dPhiCD); int tmp[10] = {dPhiSum4, dPhiSum4A, dPhiSum3, dPhiSum3A, outStPhi, dTheta, rpcA, rpcB, rpcC, rpcD}; predictors.insert(predictors.end(), tmp, tmp + 10); @@ -567,42 +566,42 @@ float PtAssignmentEngine2017::calculate_pt_xml(const EMTFTrack& track) const { // BEGIN: Identical (almost) to BDT training code in EMTFPtAssign2017/PtRegression_Apr_2017.C - theta = CalcTrackTheta(th1, th2, th3, th4, St1_ring2, mode, true); - - CalcDeltaPhis(dPhi_12, - dPhi_13, - dPhi_14, - dPhi_23, - dPhi_24, - dPhi_34, - dPhiSign, - dPhiSum4, - dPhiSum4A, - dPhiSum3, - dPhiSum3A, - outStPhi, - ph1, - ph2, - ph3, - ph4, - mode, - true); - - CalcDeltaThetas(dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34, th1, th2, th3, th4, mode, true); + theta = aux().calcTrackTheta(th1, th2, th3, th4, St1_ring2, mode, true); + + aux().calcDeltaPhis(dPhi_12, + dPhi_13, + dPhi_14, + dPhi_23, + dPhi_24, + dPhi_34, + dPhiSign, + dPhiSum4, + dPhiSum4A, + dPhiSum3, + dPhiSum3A, + outStPhi, + ph1, + ph2, + ph3, + ph4, + mode, + true); + + aux().calcDeltaThetas(dTh_12, dTh_13, dTh_14, dTh_23, dTh_24, dTh_34, th1, th2, th3, th4, mode, true); FR_1 = (st1 ? data.fr[0] : -99); FR_2 = (st2 ? data.fr[1] : -99); FR_3 = (st3 ? data.fr[2] : -99); FR_4 = (st4 ? data.fr[3] : -99); - CalcBends(bend_1, bend_2, bend_3, bend_4, pat1, pat2, pat3, pat4, dPhiSign, endcap, mode, true); + aux().calcBends(bend_1, bend_2, bend_3, bend_4, pat1, pat2, pat3, pat4, dPhiSign, endcap, mode, true); RPC_1 = (st1 ? (pat1 == 0) : -99); RPC_2 = (st2 ? (pat2 == 0) : -99); RPC_3 = (st3 ? (pat3 == 0) : -99); RPC_4 = (st4 ? (pat4 == 0) : -99); - CalcRPCs(RPC_1, RPC_2, RPC_3, RPC_4, mode, St1_ring2, theta, true); + aux().calcRPCs(RPC_1, RPC_2, RPC_3, RPC_4, mode, St1_ring2, theta, true); // END: Identical (almost) to BDT training code in EMTFPtAssign2017/PtRegression_Apr_2017.C diff --git a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux2017.cc b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux2017.cc index a0ff1e3e0776e..a7a7e510c448d 100644 --- a/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux2017.cc +++ b/L1Trigger/L1TMuonEndCap/src/PtAssignmentEngineAux2017.cc @@ -67,7 +67,7 @@ int PtAssignmentEngineAux2017::getNLBdPhi(int dPhi, int bits, int max) const { emtf_assert(abs(sign_) == 1 && dPhi_ >= 0 && dPhi_ < max); return (sign_ * dPhi_); -} // End function: nt PtAssignmentEngineAux2017::getNLBdPhi() +} // End function: int PtAssignmentEngineAux2017::getNLBdPhi() int PtAssignmentEngineAux2017::getNLBdPhiBin(int dPhi, int bits, int max) const { emtf_assert((bits == 4 && max == 256) || (bits == 5 && max == 256) || (bits == 7 && max == 512)); @@ -718,3 +718,345 @@ void PtAssignmentEngineAux2017::unpack8bMode15(int mode15_8b, emtf_assert(nRPC >= 0); } // End function: void PtAssignmentEngineAux2017::unpack8bMode15() + +// _____________________________________________________________________________ +// From here down, code was originally in PtLUTVarCalc.cc + +int PtAssignmentEngineAux2017::calcTrackTheta(const int th1, + const int th2, + const int th3, + const int th4, + const int st1_ring2, + const int mode, + const bool BIT_COMP) const { + int theta = -99; + + if ((mode % 8) / 4 > 0) // Has station 2 hit + theta = th2; + else if ((mode % 4) / 2 > 0) // Has station 3 hit + theta = th3; + else if ((mode % 2) > 0) // Has station 4 hit + theta = th4; + + emtf_assert(theta > 0); + + if (BIT_COMP) { + int nBits = (mode == 15 ? 4 : 5); + theta = getTheta(theta, st1_ring2, nBits); + } + + return theta; +} + +void PtAssignmentEngineAux2017::calcDeltaPhis(int& dPh12, + int& dPh13, + int& dPh14, + int& dPh23, + int& dPh24, + int& dPh34, + int& dPhSign, + int& dPhSum4, + int& dPhSum4A, + int& dPhSum3, + int& dPhSum3A, + int& outStPh, + const int ph1, + const int ph2, + const int ph3, + const int ph4, + const int mode, + const bool BIT_COMP) const { + dPh12 = ph2 - ph1; + dPh13 = ph3 - ph1; + dPh14 = ph4 - ph1; + dPh23 = ph3 - ph2; + dPh24 = ph4 - ph2; + dPh34 = ph4 - ph3; + dPhSign = 0; + + if (mode >= 8) { // First hit is station 1 + if ((mode % 8) / 4 > 0) // Has station 2 hit + dPhSign = (dPh12 >= 0 ? +1 : -1); + else if ((mode % 4) / 2 > 0) // Has station 3 hit + dPhSign = (dPh13 >= 0 ? +1 : -1); + else if ((mode % 2) > 0) // Has station 4 hit + dPhSign = (dPh14 >= 0 ? +1 : -1); + } else if ((mode % 8) / 4 > 0) { // First hit is station 2 + if ((mode % 4) / 2 > 0) // Has station 3 hit + dPhSign = (dPh23 >= 0 ? +1 : -1); + else if ((mode % 2) > 0) // Has station 4 hit + dPhSign = (dPh24 >= 0 ? +1 : -1); + } else if ((mode % 4) / 2 > 0) { // First hit is station 3 + if ((mode % 2) > 0) // Has station 4 hit + dPhSign = (dPh34 >= 0 ? +1 : -1); + } + + emtf_assert(dPhSign != 0); + + dPh12 *= dPhSign; + dPh13 *= dPhSign; + dPh14 *= dPhSign; + dPh23 *= dPhSign; + dPh24 *= dPhSign; + dPh34 *= dPhSign; + + if (BIT_COMP) { + int nBitsA = 7; + int nBitsB = 7; + int nBitsC = 7; + int maxA = 512; + int maxB = 512; + int maxC = 512; + + if (mode == 7 || mode == 11 || mode > 12) { + nBitsB = 5; + maxB = 256; + nBitsC = 5; + maxC = 256; + } + if (mode == 15) { + nBitsC = 4; + maxC = 256; + } + + dPh12 = getNLBdPhi(dPh12, nBitsA, maxA); + dPh13 = getNLBdPhi(dPh13, nBitsA, maxA); + dPh14 = getNLBdPhi(dPh14, nBitsA, maxA); + if (mode == 7) + dPh23 = getNLBdPhi(dPh23, nBitsA, maxA); + else + dPh23 = getNLBdPhi(dPh23, nBitsB, maxB); + dPh24 = getNLBdPhi(dPh24, nBitsB, maxB); + dPh34 = getNLBdPhi(dPh34, nBitsC, maxC); + + // Some delta phi values must be computed from others + switch (mode) { + case 15: + dPh13 = dPh12 + dPh23; + dPh14 = dPh13 + dPh34; + dPh24 = dPh23 + dPh34; + break; + case 14: + dPh13 = dPh12 + dPh23; + break; + case 13: + dPh14 = dPh12 + dPh24; + break; + case 11: + dPh14 = dPh13 + dPh34; + break; + case 7: + dPh24 = dPh23 + dPh34; + break; + default: + break; + } + + } // End conditional: if (BIT_COMP) + + // Compute summed quantities + if (mode == 15) + calcDeltaPhiSums(dPhSum4, dPhSum4A, dPhSum3, dPhSum3A, outStPh, dPh12, dPh13, dPh14, dPh23, dPh24, dPh34); + +} // End function: void PtAssignmentEngineAux2017::calcDeltaPhis() + +void PtAssignmentEngineAux2017::calcDeltaThetas(int& dTh12, + int& dTh13, + int& dTh14, + int& dTh23, + int& dTh24, + int& dTh34, + const int th1, + const int th2, + const int th3, + const int th4, + const int mode, + const bool BIT_COMP) const { + dTh12 = th2 - th1; + dTh13 = th3 - th1; + dTh14 = th4 - th1; + dTh23 = th3 - th2; + dTh24 = th4 - th2; + dTh34 = th4 - th3; + + if (BIT_COMP) { + int nBits = (mode == 15 ? 2 : 3); + + dTh12 = getdTheta(dTh12, nBits); + dTh13 = getdTheta(dTh13, nBits); + dTh14 = getdTheta(dTh14, nBits); + dTh23 = getdTheta(dTh23, nBits); + dTh24 = getdTheta(dTh24, nBits); + dTh34 = getdTheta(dTh34, nBits); + } // End conditional: if (BIT_COMP) + +} // Enf function: void PtAssignmentEngineAux2017::calcDeltaThetas() + +void PtAssignmentEngineAux2017::calcBends(int& bend1, + int& bend2, + int& bend3, + int& bend4, + const int pat1, + const int pat2, + const int pat3, + const int pat4, + const int dPhSign, + const int endcap, + const int mode, + const bool BIT_COMP) const { + bend1 = calcBendFromPattern(pat1, endcap); + bend2 = calcBendFromPattern(pat2, endcap); + bend3 = calcBendFromPattern(pat3, endcap); + bend4 = calcBendFromPattern(pat4, endcap); + + if (BIT_COMP) { + int nBits = 3; + if (mode == 7 || mode == 11 || mode > 12) + nBits = 2; + + if (mode / 8 > 0) // Has station 1 hit + bend1 = getCLCT(pat1, endcap, dPhSign, nBits); + if ((mode % 8) / 4 > 0) // Has station 2 hit + bend2 = getCLCT(pat2, endcap, dPhSign, nBits); + if ((mode % 4) / 2 > 0) // Has station 3 hit + bend3 = getCLCT(pat3, endcap, dPhSign, nBits); + if ((mode % 2) > 0) // Has station 4 hit + bend4 = getCLCT(pat4, endcap, dPhSign, nBits); + } // End conditional: if (BIT_COMP) + +} // End function: void PtAssignmentEngineAux2017::calcBends() + +void PtAssignmentEngineAux2017::calcRPCs(int& RPC1, + int& RPC2, + int& RPC3, + int& RPC4, + const int mode, + const int st1_ring2, + const int theta, + const bool BIT_COMP) const { + if (BIT_COMP) { + // Mask some invalid locations for RPC hits + // theta is assumed to be the compressed, mode 15 version + if (mode == 15 && !st1_ring2) { + RPC1 = 0; + RPC2 = 0; + if (theta < 4) { + RPC3 = 0; + RPC4 = 0; + } + } + + int nRPC = (RPC1 == 1) + (RPC2 == 1) + (RPC3 == 1) + (RPC4 == 1); + + // In 3- and 4-station modes, only specify some combinations of RPCs + if (nRPC >= 2) { + if (mode == 15) { + if (RPC1 == 1 && RPC2 == 1) { + RPC3 = 0; + RPC4 = 0; + } else if (RPC1 == 1 && RPC3 == 1) { + RPC4 = 0; + } else if (RPC4 == 1 && RPC2 == 1) { + RPC3 = 0; + } else if (RPC3 == 1 && RPC4 == 1 && !st1_ring2) { + RPC3 = 0; + } + } else if (mode == 14) { + if (RPC1 == 1) { + RPC2 = 0; + RPC3 = 0; + } else if (RPC3 == 1) { + RPC2 = 0; + } + } else if (mode == 13) { + if (RPC1 == 1) { + RPC2 = 0; + RPC4 = 0; + } else if (RPC4 == 1) { + RPC2 = 0; + } + } else if (mode == 11) { + if (RPC1 == 1) { + RPC3 = 0; + RPC4 = 0; + } else if (RPC4 == 1) { + RPC3 = 0; + } + } else if (mode == 7) { + if (RPC2 == 1) { + RPC3 = 0; + RPC4 = 0; + } else if (RPC4 == 1) { + RPC3 = 0; + } + } + + } // End conditional: if (nRPC >= 2) + } // End conditional: if (BIT_COMP) + +} // End function: void PtAssignmentEngineAux2017::calcRPCs() + +int PtAssignmentEngineAux2017::calcBendFromPattern(const int pattern, const int endcap) const { + int bend = -99; + if (pattern < 0) + return bend; + + if (pattern == 10) + bend = 0; + else if ((pattern % 2) == 0) + bend = (10 - pattern) / 2; + else if ((pattern % 2) == 1) + bend = -1 * (11 - pattern) / 2; + + // Reverse to match dPhi convention + if (endcap == 1) + bend *= -1; + + emtf_assert(bend != -99); + return bend; +} + +void PtAssignmentEngineAux2017::calcDeltaPhiSums(int& dPhSum4, + int& dPhSum4A, + int& dPhSum3, + int& dPhSum3A, + int& outStPh, + const int dPh12, + const int dPh13, + const int dPh14, + const int dPh23, + const int dPh24, + const int dPh34) const { + dPhSum4 = dPh12 + dPh13 + dPh14 + dPh23 + dPh24 + dPh34; + dPhSum4A = abs(dPh12) + abs(dPh13) + abs(dPh14) + abs(dPh23) + abs(dPh24) + abs(dPh34); + int devSt1 = abs(dPh12) + abs(dPh13) + abs(dPh14); + int devSt2 = abs(dPh12) + abs(dPh23) + abs(dPh24); + int devSt3 = abs(dPh13) + abs(dPh23) + abs(dPh34); + int devSt4 = abs(dPh14) + abs(dPh24) + abs(dPh34); + + if (devSt4 > devSt3 && devSt4 > devSt2 && devSt4 > devSt1) + outStPh = 4; + else if (devSt3 > devSt4 && devSt3 > devSt2 && devSt3 > devSt1) + outStPh = 3; + else if (devSt2 > devSt4 && devSt2 > devSt3 && devSt2 > devSt1) + outStPh = 2; + else if (devSt1 > devSt4 && devSt1 > devSt3 && devSt1 > devSt2) + outStPh = 1; + else + outStPh = 0; + + if (outStPh == 4) { + dPhSum3 = dPh12 + dPh13 + dPh23; + dPhSum3A = abs(dPh12) + abs(dPh13) + abs(dPh23); + } else if (outStPh == 3) { + dPhSum3 = dPh12 + dPh14 + dPh24; + dPhSum3A = abs(dPh12) + abs(dPh14) + abs(dPh24); + } else if (outStPh == 2) { + dPhSum3 = dPh13 + dPh14 + dPh34; + dPhSum3A = abs(dPh13) + abs(dPh14) + abs(dPh34); + } else { + dPhSum3 = dPh23 + dPh24 + dPh34; + dPhSum3A = abs(dPh23) + abs(dPh24) + abs(dPh34); + } + +} // End function: void PtAssignmentEngineAux2017::calcDeltaPhiSums() From e848c488844a7b41f819d4a021edb5442886d0ab Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Thu, 7 May 2020 09:53:05 -0400 Subject: [PATCH 31/34] [EMTF] Add test/globaltags.md --- L1Trigger/L1TMuonEndCap/test/globaltags.md | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 L1Trigger/L1TMuonEndCap/test/globaltags.md diff --git a/L1Trigger/L1TMuonEndCap/test/globaltags.md b/L1Trigger/L1TMuonEndCap/test/globaltags.md new file mode 100644 index 0000000000000..c2da4eeff05ab --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/test/globaltags.md @@ -0,0 +1,38 @@ +For the **L1TMuonEndCapParams** tags, here are the appropriate params tags for each year: +- 2016 + - **L1TMuonEndCapParams_static_2016_mc** + - PtAssignVersion = 5, firmwareVersion = 49999, PhiMatchWindowSt1 = 0 +- 2017 + - **L1TMuonEndCapParams_Stage2v1** + - PtAssignVersion = 7, firmwareVersion = 1497518612, PhiMatchWindowSt1 = 1 + - It's not clear to me why the firmwareVersion for this tag should be 1497518612 and not 1496792995 or 1504018578 + - In the current emulator, makes no difference; but for full consistency 1504018578 might be the best choice for any future "UL" tag for 2017. +- 2018 + - **L1TMuonEndCapParams_Stage2v3_2018_HI_mc** + - PtAssignVersion = 7, firmwareVersion = 1539271335 (October 11, 2018), PhiMatchWindowSt1 = 1 + - Note that this should be used for *all* 2018 MC, not just Heavy Ion - tag L1TMuonEndCapParams_Stage2v1_2018_mc is WRONG! + +For the **L1TMuonEndCapForest** tags, here are the appropriate forest tags for each year: +- 2016 + - **L1TMuonEndCapForest_static_2016_mc** + - Payload 1d58582f55ae84cf5ec5ea91ebcb8b4a23b1af23, 5.2 MB, loaded 2017-05-24 15:45:10 (UTC) + - This payload is also included in data tags L1TMuonEndCapForest_Stage2v1_hlt and L1TMuonEndCapForest_Stage2v2_hlt +- 2017 and 2018 + - **L1TMuonEndCapForest_static_Sq_20170613_v7_mc** + - **L1TMuonEndCapForest_Stage2v1_2018_HI_mc** + - Payload 821067bddc9f3e5e4e6dd627ecf0c5e453853ccc, 52 MB, loaded 2017-06-13 10:36:43 (UTC) + - This payload is also included in data tags L1TMuonEndCapForest_Stage2v1_hlt and L1TMuonEndCapForest_Stage2v2_hlt + - Corresponds to /afs/cern.ch/work/a/abrinke1/public/EMTF/PtAssign2017/XMLs/2017_v7/, which is the latest 2017/2018 XMLs + + +How to extract tag and payload information + +1. Enter a CMSSW environment and run: cmsenv +2. To see the lists of existing EMTF O2O tags, type: + - conddb listTags | grep L1TMuonEndCapParams + - conddb listTags | grep L1TMuonEndCapForest +3. To see the payloads for each tag, do either of the following: + - Go to: + - In CMSSW, type: conddb list YourTagName +4. Using "Payload" from #3 above, run: conddb dump PayloadHash + From 633baac4f8c7afa4e75eb987df44216a2b0efe80 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Thu, 7 May 2020 06:37:19 -0400 Subject: [PATCH 32/34] [EMTF] Update python/fakeEmtfParams_*_cff.py --- .../python/fakeEmtfParams_2016_MC_cff.py | 33 ++++++----------- .../python/fakeEmtfParams_2016_data_cff.py | 10 +----- .../python/fakeEmtfParams_2017_MC_cff.py | 33 ++++++----------- .../python/fakeEmtfParams_2017_data_cff.py | 10 +----- .../python/fakeEmtfParams_2018_MC_cff.py | 36 +++++++++++++++++++ .../python/fakeEmtfParams_2018_data_cff.py | 33 +++++++++++++++++ ...ams_cff.py => fakeEmtfParams_empty_cff.py} | 32 ++++------------- 7 files changed, 100 insertions(+), 87 deletions(-) create mode 100644 L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2018_MC_cff.py create mode 100644 L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2018_data_cff.py rename L1Trigger/L1TMuonEndCap/python/{fakeEmtfParams_cff.py => fakeEmtfParams_empty_cff.py} (57%) diff --git a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2016_MC_cff.py b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2016_MC_cff.py index 54f75936bc943..1cea9a154f30c 100644 --- a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2016_MC_cff.py +++ b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2016_MC_cff.py @@ -5,33 +5,22 @@ CondDB.connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS") -## Fills firmware, pT LUT, and PC LUT versions manually +## Fills firmware, pT LUT, and PC LUT versions from the database emtfParamsSource = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonEndCapParamsRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) - ) - -emtfParams = cms.ESProducer( - "L1TMuonEndCapParamsESProducer", - ## Version 5 was used for all of 2016 - PtAssignVersion = cms.int32(5), - ## Latest version in 2016 - FirmwareVersion = cms.int32(49999), - ## v0 corresponds to data/emtf_luts/ph_lut_v1, used for all of 2016 - PrimConvVersion = cms.int32(0) + "PoolDBESSource", + CondDB, + toGet = cms.VPSet( + cms.PSet( + record = cms.string("L1TMuonEndCapParamsRcd"), + ## This payload contains + ## PtAssignVersion=5, firmwareVersion=49999, PhiMatchWindowSt1=0 + tag = cms.string("L1TMuonEndCapParams_static_2016_mc") + ) + ) ) ## Fills pT LUT XMLs ("forests") from the database -emtfForestsSource = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonEndCapForestRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) - ) - emtfForestsDB = cms.ESSource( "PoolDBESSource", CondDB, diff --git a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2016_data_cff.py b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2016_data_cff.py index 7a17380f55504..da508a54e46ea 100644 --- a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2016_data_cff.py +++ b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2016_data_cff.py @@ -12,20 +12,13 @@ toGet = cms.VPSet( cms.PSet( record = cms.string("L1TMuonEndCapParamsRcd"), - tag = cms.string("L1TMuonEndCapParams_Stage2v1_hlt") + tag = cms.string("L1TMuonEndCapParams_Stage2v3_hlt") ) ) ) ## Fills pT LUT XMLs ("forests") from the database -emtfForestsSource = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonEndCapForestRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) - ) - emtfForestsDB = cms.ESSource( "PoolDBESSource", CondDB, @@ -38,4 +31,3 @@ ) ) ) - diff --git a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2017_MC_cff.py b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2017_MC_cff.py index 6d3ec9cbbaf87..567bc7a857d1d 100644 --- a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2017_MC_cff.py +++ b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2017_MC_cff.py @@ -5,33 +5,22 @@ CondDB.connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS") -## Fills firmware, pT LUT, and PC LUT versions manually +## Fills firmware, pT LUT, and PC LUT versions from the database emtfParamsSource = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonEndCapParamsRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) - ) - -emtfParams = cms.ESProducer( - "L1TMuonEndCapParamsESProducer", - ## Version 7 was deployed June 8, 2017 - PtAssignVersion = cms.int32(7), - ## 123456 is default (most up-to-date) firmware version - FirmwareVersion = cms.int32(123456), - ## v1 corresponds to data/emtf_luts/ph_lut_v2, used at the beginning of 2017 - PrimConvVersion = cms.int32(1) + "PoolDBESSource", + CondDB, + toGet = cms.VPSet( + cms.PSet( + record = cms.string("L1TMuonEndCapParamsRcd"), + ## This payload contains + ## PtAssignVersion=7, firmwareVersion=1497518612, PhiMatchWindowSt1=1 + tag = cms.string("L1TMuonEndCapParams_Stage2v1") + ) + ) ) ## Fills pT LUT XMLs ("forests") from the database -emtfForestsSource = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonEndCapForestRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) - ) - emtfForestsDB = cms.ESSource( "PoolDBESSource", CondDB, diff --git a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2017_data_cff.py b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2017_data_cff.py index 563c438f60955..088036bfd624f 100644 --- a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2017_data_cff.py +++ b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2017_data_cff.py @@ -12,20 +12,13 @@ toGet = cms.VPSet( cms.PSet( record = cms.string("L1TMuonEndCapParamsRcd"), - tag = cms.string("L1TMuonEndCapParams_Stage2v1_hlt") + tag = cms.string("L1TMuonEndCapParams_Stage2v3_hlt") ) ) ) ## Fills pT LUT XMLs ("forests") from the database -emtfForestsSource = cms.ESSource( - "EmptyESSource", - recordName = cms.string('L1TMuonEndCapForestRcd'), - iovIsRunNotTime = cms.bool(True), - firstValid = cms.vuint32(1) - ) - emtfForestsDB = cms.ESSource( "PoolDBESSource", CondDB, @@ -38,4 +31,3 @@ ) ) ) - diff --git a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2018_MC_cff.py b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2018_MC_cff.py new file mode 100644 index 0000000000000..3bc50cb5c6315 --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2018_MC_cff.py @@ -0,0 +1,36 @@ +import FWCore.ParameterSet.Config as cms + +## Fills CondFormats from the database +from CondCore.CondDB.CondDB_cfi import CondDB +CondDB.connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS") + + +## Fills firmware, pT LUT, and PC LUT versions from the database +emtfParamsSource = cms.ESSource( + "PoolDBESSource", + CondDB, + toGet = cms.VPSet( + cms.PSet( + record = cms.string("L1TMuonEndCapParamsRcd"), + ## This payload contains + ## PtAssignVersion=7, firmwareVersion=1539271335, PhiMatchWindowSt1=1 + ## Note: "L1TMuonEndCapParams_Stage2v1_2018_mc" is wrong + tag = cms.string("L1TMuonEndCapParams_Stage2v3_2018_HI_mc") + ) + ) + ) + + +## Fills pT LUT XMLs ("forests") from the database +emtfForestsDB = cms.ESSource( + "PoolDBESSource", + CondDB, + toGet = cms.VPSet( + cms.PSet( + ## https://cms-conddb.cern.ch/cmsDbBrowser/search/Prod/L1TMuonEndCapForest + record = cms.string("L1TMuonEndCapForestRcd"), + ## v7 EMTF pT LUTs from June 8, 2017 + tag = cms.string("L1TMuonEndCapForest_Stage2v1_2018_HI_mc") + ) + ) + ) diff --git a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2018_data_cff.py b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2018_data_cff.py new file mode 100644 index 0000000000000..b8223ebbd12c5 --- /dev/null +++ b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_2018_data_cff.py @@ -0,0 +1,33 @@ +import FWCore.ParameterSet.Config as cms + +## Fills CondFormats from the database +from CondCore.CondDB.CondDB_cfi import CondDB +CondDB.connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS") + + +## Fills firmware, pT LUT, and PC LUT versions from the database +emtfParamsSource = cms.ESSource( + "PoolDBESSource", + CondDB, + toGet = cms.VPSet( + cms.PSet( + record = cms.string("L1TMuonEndCapParamsRcd"), + tag = cms.string("L1TMuonEndCapParams_Stage2v3_hlt") + ) + ) + ) + + +## Fills pT LUT XMLs ("forests") from the database +emtfForestsDB = cms.ESSource( + "PoolDBESSource", + CondDB, + toGet = cms.VPSet( + cms.PSet( + ## https://cms-conddb.cern.ch/cmsDbBrowser/search/Prod/L1TMuonEndCapForest + record = cms.string("L1TMuonEndCapForestRcd"), + ## v7 EMTF pT LUTs from June 8, 2017 + tag = cms.string("L1TMuonEndCapForest_Stage2v1_2018_HI_mc") + ) + ) + ) diff --git a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_cff.py b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_empty_cff.py similarity index 57% rename from L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_cff.py rename to L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_empty_cff.py index f349816d5feb0..498a2c53318cc 100644 --- a/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_cff.py +++ b/L1Trigger/L1TMuonEndCap/python/fakeEmtfParams_empty_cff.py @@ -29,7 +29,7 @@ ) -## Fills pT LUT XMLs ("forests") from the database +## Fills pT LUT XMLs ("forests") manually emtfForestsSource = cms.ESSource( "EmptyESSource", recordName = cms.string('L1TMuonEndCapForestRcd'), @@ -37,27 +37,9 @@ firstValid = cms.vuint32(1) ) -#emtfForestsDB = cms.ESSource( -# "PoolDBESSource", -# CondDB, -# toGet = cms.VPSet( -# cms.PSet( -# ## https://cms-conddb.cern.ch/cmsDbBrowser/search/Prod/L1TMuonEndCapForest -# record = cms.string("L1TMuonEndCapForestRcd"), -# -# # ## v5 EMTF pT LUTs from ~August 2016 -# # tag = cms.string("L1TMuonEndCapForest_static_2016_mc") -# # ## v6 EMTF pT LUTs from May 24, 2017 -# # tag = cms.string("L1TMuonEndCapForest_static_Sq_20170523_mc") -# ## v7 EMTF pT LUTs from June 7, 2017 - AWB 07.06.17 -# tag = cms.string("L1TMuonEndCapForest_static_Sq_20170613_v7_mc") -# ) -# ) -# ) - -# ## EMTF ESProducer. Fills CondFormats from local XML files instead of database. -# emtfForests = cms.ESProducer( -# "L1TMuonEndCapForestESProducer", -# PtAssignVersion = cms.int32(7), -# bdtXMLDir = cms.string("2017_v7") -# ) +## Fills CondFormats from local XML files instead of database. +emtfForests = cms.ESProducer( + "L1TMuonEndCapForestESProducer", + PtAssignVersion = cms.int32(7), + bdtXMLDir = cms.string("2017_v7") + ) From 632f8dd7b2af2d7bc65d2e2dad19422d64968169 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Tue, 21 Apr 2020 10:45:47 -0400 Subject: [PATCH 33/34] [EMTF] Update python/simEmtfDigis_cfi.py --- .../L1TMuonEndCap/python/simEmtfDigis_cfi.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py b/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py index d6e78131b3a64..3b354cd3428c2 100644 --- a/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py +++ b/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py @@ -16,6 +16,9 @@ # Configure by firmware version, which may be different than the default parameters in this file FWConfig = cms.bool(True), + # Era (options: 'Run2_2016', 'Run2_2017', 'Run2_2018') + Era = cms.string('Run2_2018'), + # Input collections # Three options for CSCInput # * 'simCscTriggerPrimitiveDigis','MPCSORTED' : simulated trigger primitives (LCTs) from re-emulating CSC digis @@ -29,20 +32,17 @@ RPCRecHitInput = cms.InputTag('rpcRecHits'), CPPFInput = cms.InputTag('simCPPFDigis'), ## Cannot use in MC workflow, does not exist yet. CPPFEnable set to False - AWB 01.06.18 GEMInput = cms.InputTag('simMuonGEMPadDigiClusters'), - ME0Input = cms.InputTag('me0TriggerPseudoDigis105X'), + ME0Input = cms.InputTag('me0TriggerConvertedPseudoDigis'), # Run with CSC, RPC, GEM DTEnable = cms.bool(False), CSCEnable = cms.bool(True), # Use CSC LCTs from the MPCs in track-building RPCEnable = cms.bool(True), # Use clustered RPC hits from CPPF in track-building + IRPCEnable = cms.bool(False), CPPFEnable = cms.bool(False), # Use CPPF-emulated clustered RPC hits from CPPF as the RPC hits GEMEnable = cms.bool(False), # Use hits from GEMs in track-building - IRPCEnable = cms.bool(False), ME0Enable = cms.bool(False), - # Era (options: 'Run2_2016', 'Run2_2017', 'Run2_2018') - Era = cms.string('Run2_2016'), - # BX MinBX = cms.int32(-3), # Minimum BX considered MaxBX = cms.int32(+3), # Maximum BX considered @@ -56,7 +56,6 @@ # Sector processor primitive-conversion parameters spPCParams16 = cms.PSet( - PrimConvLUT = cms.int32(2), # v0, v1, and v2 LUTs used at different times, "-1" for local CPPF files (only works if FWConfig = False) ZoneBoundaries = cms.vint32(0,41,49,87,127), # Vertical boundaries of track-building zones, in integer theta (5 for 4 zones) # ZoneBoundaries = cms.vint32(0,36,54,96,127), # New proposed zone boundaries ZoneOverlap = cms.int32(2), # Overlap between zones @@ -128,10 +127,15 @@ ) simEmtfDigisData = simEmtfDigisMC.clone( - CSCInput = cms.InputTag('emtfStage2Digis'), - RPCInput = cms.InputTag('muonRPCDigis'), + DTPhiInput = cms.InputTag('bmtfDigis'), + DTThetaInput = cms.InputTag('bmtfDigis'), + CSCInput = cms.InputTag('emtfStage2Digis'), + CSCComparatorInput = cms.InputTag('muonCSCDigis','MuonCSCComparatorDigi'), + RPCInput = cms.InputTag('muonRPCDigis'), + #RPCRecHitInput = cms.InputTag('rpcRecHits'), # no unpacker CPPFInput = cms.InputTag('emtfStage2Digis'), - GEMInput = cms.InputTag('muonGEMPadDigis'), + #GEMInput = cms.InputTag('muonGEMPadDigis'), # no unpacker + #ME0Input = cms.InputTag('me0TriggerConvertedPseudoDigis'), # no unpacker CPPFEnable = cms.bool(True), # Use CPPF-emulated clustered RPC hits from CPPF as the RPC hits @@ -152,6 +156,6 @@ from Configuration.Eras.Modifier_stage2L1Trigger_2017_cff import stage2L1Trigger_2017 stage2L1Trigger_2017.toModify(simEmtfDigis, RPCEnable = cms.bool(True), Era = cms.string('Run2_2017')) -### Era: Run2_2018 +## Era: Run2_2018 from Configuration.Eras.Modifier_stage2L1Trigger_2018_cff import stage2L1Trigger_2018 stage2L1Trigger_2018.toModify(simEmtfDigis, RPCEnable = cms.bool(True), Era = cms.string('Run2_2018')) From 7745bb89b118109fcc1bec2d99df3e3c4e4a9874 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Thu, 7 May 2020 10:06:01 -0400 Subject: [PATCH 34/34] [EMTF] Apply cmssw hook --- DQM/L1TMonitor/src/L1TStage2EMTF.cc | 1 - DataFormats/L1TMuon/interface/EMTFHit.h | 6 ------ DataFormats/L1TMuon/interface/EMTFTrack.h | 8 -------- L1Trigger/L1TMuonEndCap/interface/DebugTools.h | 2 +- L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py | 3 --- 5 files changed, 1 insertion(+), 19 deletions(-) diff --git a/DQM/L1TMonitor/src/L1TStage2EMTF.cc b/DQM/L1TMonitor/src/L1TStage2EMTF.cc index 92b0f3324c80a..ca12e2b7639a6 100644 --- a/DQM/L1TMonitor/src/L1TStage2EMTF.cc +++ b/DQM/L1TMonitor/src/L1TStage2EMTF.cc @@ -746,7 +746,6 @@ void L1TStage2EMTF::analyze(const edm::Event& e, const edm::EventSetup& c) { int ring = TrkHit.Ring(); int station = TrkHit.Station(); int sector = TrkHit.Sector(); - //int subsector = TrkHit.Subsector(); //int cscid_offset = (sector - 1) * 9;//no longer needed after new time plots (maybe useful for future plots) int neighbor = TrkHit.Neighbor(); int endcap = TrkHit.Endcap(); diff --git a/DataFormats/L1TMuon/interface/EMTFHit.h b/DataFormats/L1TMuon/interface/EMTFHit.h index 27a4d9e1e6685..031b780ec9aa0 100644 --- a/DataFormats/L1TMuon/interface/EMTFHit.h +++ b/DataFormats/L1TMuon/interface/EMTFHit.h @@ -14,9 +14,6 @@ #include "DataFormats/MuonDetId/interface/ME0DetId.h" #include "DataFormats/MuonDetId/interface/DTChamberId.h" #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h" -//#include "DataFormats/RPCDigi/interface/RPCDigi.h" -//#include "DataFormats/GEMDigi/interface/GEMPadDigi.h" -//#include "DataFormats/GEMDigi/interface/ME0PadDigi.h" #include "DataFormats/L1TMuon/interface/CPPFDigi.h" #include "DataFormats/L1TMuon/interface/EMTF/ME.h" @@ -81,11 +78,8 @@ namespace l1t { virtual ~EMTFHit(){}; - // void ImportCSCDetId (const CSCDetId& _detId); CSCDetId CreateCSCDetId() const; - // void ImportRPCDetId (const RPCDetId& _detId); RPCDetId CreateRPCDetId() const; - // void ImportGEMDetId (const GEMDetId& _detId); // GEMDetId CreateGEMDetId() const; // void ImportCSCCorrelatedLCTDigi (const CSCCorrelatedLCTDigi& _digi); diff --git a/DataFormats/L1TMuon/interface/EMTFTrack.h b/DataFormats/L1TMuon/interface/EMTFTrack.h index ce271f80a26cd..c1bc3637ed2c0 100644 --- a/DataFormats/L1TMuon/interface/EMTFTrack.h +++ b/DataFormats/L1TMuon/interface/EMTFTrack.h @@ -107,11 +107,6 @@ namespace l1t { EMTFHitCollection Hits() const { return _Hits; } std::vector HitIdx() const { return _HitIdx; } - //void set_Road(const EMTFRoad& bits) { _Road = bits; } - //void set_RoadIdx(unsigned int bits) { _RoadIdx = bits; } - //EMTFRoad Road() const { return _Road; } - //unsigned int RoadIdx() const { return _RoadIdx; } - void set_PtLUT(EMTFPtLUT bits) { _PtLUT = bits; } EMTFPtLUT PtLUT() const { return _PtLUT; } @@ -182,9 +177,6 @@ namespace l1t { EMTFHitCollection _Hits; std::vector _HitIdx; - //EMTFRoad _Road; - //unsigned int _RoadIdx; - EMTFPtLUT _PtLUT; int endcap; // +/-1. For ME+ and ME-. diff --git a/L1Trigger/L1TMuonEndCap/interface/DebugTools.h b/L1Trigger/L1TMuonEndCap/interface/DebugTools.h index 7aabb4fdf77c1..441fd69963422 100644 --- a/L1Trigger/L1TMuonEndCap/interface/DebugTools.h +++ b/L1Trigger/L1TMuonEndCap/interface/DebugTools.h @@ -10,7 +10,7 @@ #include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h" // Uncomment the following line to use assert -#define EMTF_ALLOW_ASSERT +//#define EMTF_ALLOW_ASSERT #ifdef EMTF_ALLOW_ASSERT #define emtf_assert(expr) (assert(expr)) diff --git a/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py b/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py index 3b354cd3428c2..30d84d4c807a4 100644 --- a/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py +++ b/L1Trigger/L1TMuonEndCap/python/simEmtfDigis_cfi.py @@ -132,10 +132,7 @@ CSCInput = cms.InputTag('emtfStage2Digis'), CSCComparatorInput = cms.InputTag('muonCSCDigis','MuonCSCComparatorDigi'), RPCInput = cms.InputTag('muonRPCDigis'), - #RPCRecHitInput = cms.InputTag('rpcRecHits'), # no unpacker CPPFInput = cms.InputTag('emtfStage2Digis'), - #GEMInput = cms.InputTag('muonGEMPadDigis'), # no unpacker - #ME0Input = cms.InputTag('me0TriggerConvertedPseudoDigis'), # no unpacker CPPFEnable = cms.bool(True), # Use CPPF-emulated clustered RPC hits from CPPF as the RPC hits