From a8ebb2abdf4075dd26a999030212ebe3ed17a26d Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:32:25 -0400 Subject: [PATCH 01/18] [EMTF] Update data formats 1/3 --- DataFormats/L1TMuon/interface/EMTFHit.h | 58 ++++++++++------------- DataFormats/L1TMuon/interface/EMTFTrack.h | 12 ++--- DataFormats/L1TMuon/src/EMTFHit.cc | 2 +- 3 files changed, 31 insertions(+), 41 deletions(-) diff --git a/DataFormats/L1TMuon/interface/EMTFHit.h b/DataFormats/L1TMuon/interface/EMTFHit.h index 33ba156e53469..27a4d9e1e6685 100644 --- a/DataFormats/L1TMuon/interface/EMTFHit.h +++ b/DataFormats/L1TMuon/interface/EMTFHit.h @@ -12,10 +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/RPCDigi/interface/RPCDigi.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" @@ -25,6 +26,7 @@ namespace l1t { public: EMTFHit() : rawDetId(0), + subsystem(-99), endcap(-99), station(-99), ring(-99), @@ -58,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), @@ -77,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); @@ -114,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; } @@ -126,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; } @@ -160,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; } @@ -180,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; } @@ -218,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; } @@ -238,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; @@ -253,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. @@ -287,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) @@ -299,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. @@ -307,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 05a3233a5be276de0b0656167ffb40b675b6a071 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:35:10 -0400 Subject: [PATCH 02/18] [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 5a3b0fd4666fb0079b05380a9df02c99a1489d43 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:38:13 -0400 Subject: [PATCH 03/18] [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 858821dd401fc7577640fa95cdc4ee54bcf227c3 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:43:02 -0400 Subject: [PATCH 04/18] [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 6f7123c5eae5fe4500d97fba45fd701d342afbe1 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:44:34 -0400 Subject: [PATCH 05/18] [EMTF] Update MuonTriggerPrimitive & GeometryTranslator 2/5 --- L1Trigger/L1TMuon/BuildFile.xml | 3 --- L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h | 4 ---- L1Trigger/L1TMuon/plugins/RPCCollector.cc | 2 +- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/L1Trigger/L1TMuon/BuildFile.xml b/L1Trigger/L1TMuon/BuildFile.xml index 9d4cb7d1a0d2d..a5c1862233333 100644 --- a/L1Trigger/L1TMuon/BuildFile.xml +++ b/L1Trigger/L1TMuon/BuildFile.xml @@ -29,6 +29,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 e3a449c19e7c27987f1a45da5a65b34f02796c2e Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:45:22 -0400 Subject: [PATCH 06/18] [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 50d276a97386e6c9027e22a8c4ddccdc17533148 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:47:33 -0400 Subject: [PATCH 07/18] [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 b56bcc8fdce411d8e8d132c5cda9fedbb36ebe6e Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:48:38 -0400 Subject: [PATCH 08/18] [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 706c7d380a5f0377e17461c40c587ce3f074806a Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:55:58 -0400 Subject: [PATCH 09/18] [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 cebba8dd7930f91f3b23ccc795d264368f61f514 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:57:13 -0400 Subject: [PATCH 10/18] [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 f5e9d96bb7d5e68d7a6bb043b09ff60d1c34e01d Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:58:05 -0400 Subject: [PATCH 11/18] [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 d66b9caa368f3..6c1d5880982e7 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 52e2caadf271dbd5b21d7c6fff50e774af9879f3 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 11:59:28 -0400 Subject: [PATCH 12/18] [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 6c1d5880982e7..4f0d4de24723c 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 0f90c8ee19df708a412ff5f2565609a38f385746 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 12:00:20 -0400 Subject: [PATCH 13/18] [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 7dbd370ad90e2f859a1df325a21e4372c64b56d7 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 12:02:25 -0400 Subject: [PATCH 14/18] [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 14306897869141dd08cb22914a7b24473172cc5c Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 12:03:01 -0400 Subject: [PATCH 15/18] [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 4e48484d2817e1369441d32c228ab24450069010 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 18:13:08 -0400 Subject: [PATCH 16/18] [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 ed980ba8591ba893652e921603713157f4e16de3 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 18:39:33 -0400 Subject: [PATCH 17/18] [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 d64a3679a0e6f93e52131e998aaa69e6c2b01321 Mon Sep 17 00:00:00 2001 From: Jia Fu Low Date: Fri, 20 Mar 2020 12:03:31 -0400 Subject: [PATCH 18/18] [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 ae48f493a8fe5..c99d1de9b499c 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_2018'), @@ -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(