Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:02

0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 
0003 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h"
0004 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h"
0005 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h"
0006 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h"
0007 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h"
0008 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h"
0009 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h"
0010 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h"
0011 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h"
0012 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h"
0013 
0014 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h"
0015 
0016 using namespace emtf::phase2;
0017 
0018 GEMTPConverter::GEMTPConverter(const EMTFContext& context, const int& endcap, const int& sector)
0019     : context_(context), endcap_(endcap), sector_(sector) {}
0020 
0021 void GEMTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const {
0022   // Unpack Id
0023   const auto& tp_hit_id = tp_info.hit_id;
0024   const auto& tp_segment_id = tp_info.segment_id;
0025 
0026   // Unpack trigger primitive
0027   const auto& tp_det_id = tp.detId<GEMDetId>();
0028   const auto& tp_data = tp.getGEMData();
0029 
0030   // Unpack detector info
0031   const auto tp_subsystem = L1TMuon::kGEM;
0032 
0033   const int tp_raw_id = tp_det_id.rawId();
0034 
0035   const int tp_endcap_pm = tp_info.endcap_pm;
0036   const int tp_subsector = tp_info.subsector;
0037   const int tp_station = tp_info.station;
0038   const int tp_ring = tp_info.ring;
0039   const int tp_roll = tp_info.roll;
0040   const int tp_layer = tp_info.layer;
0041   const int tp_chamber = tp_info.chamber;
0042 
0043   const auto tp_csc_facing = tp_info.csc_facing;
0044   const int tp_csc_id = tp_info.csc_id;
0045 
0046   // Unpack data
0047   const int tp_pad_lo = tp_data.pad_low;
0048   const int tp_pad_hi = tp_data.pad_hi;
0049   const int tp_pad = (tp_pad_lo + tp_pad_hi) / 2;
0050   const int tp_clus_width = (tp_pad_hi - tp_pad_lo + 1);
0051 
0052   const int tp_bend = 0;  // not applicable
0053 
0054   const int tp_bx = tp_info.bx;
0055   const int tp_subbx = 0;   // no fine resolution timing
0056   const float tp_time = 0;  // no fine resolution timing. Note: Check with Efe, Jia Fu gets this from digi directly.
0057 
0058   const auto tp_selection = tp_info.selection;
0059 
0060   // Use cluster width as quality. GE2/1 strip pitch is the same as GE1/1 strip pitch.
0061   const int tp_quality = tp_clus_width;
0062 
0063   // ID scheme used in FW
0064   const int tp_ilink = tp_info.ilink;
0065 
0066   // Get Global Coordinates
0067   // const GlobalPoint& gp = get_global_point(detgeom, detid, digi);
0068   const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp);
0069   const float glob_phi = tp::radToDeg(gp.phi().value());
0070   const float glob_theta = tp::radToDeg(gp.theta().value());
0071   const double glob_rho = gp.perp();
0072   const double glob_z = gp.z();
0073 
0074   // Calculate EMTF Values
0075   const int emtf_phi = tp::calcPhiInt(sector_, glob_phi);
0076   const int emtf_bend = 0;
0077   const int emtf_theta = tp::calcThetaInt(tp_endcap_pm, glob_theta);
0078   const int emtf_qual = 0;
0079   const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring});
0080   const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring});
0081   const int emtf_zones = context_.zone_lut_.getZones(emtf_host, emtf_theta);
0082 
0083   emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040));
0084   emtf_assert((1 <= emtf_theta) and (emtf_theta < 128));
0085 
0086   // Get flags
0087   const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor);
0088   const bool tp_flag_substitute = tp_info.flag_substitute;
0089   const bool tp_flag_valid = true;  // given by digi, not trigger_primitive
0090 
0091   // Set properties
0092   hit.setId(tp_hit_id);
0093 
0094   hit.setRawDetId(tp_raw_id);
0095   hit.setSubsystem(L1TMuon::kGEM);
0096   hit.setEndcap(tp_endcap_pm);
0097   hit.setSector(sector_);
0098   hit.setSubsector(tp_subsector);
0099   hit.setStation(tp_station);
0100   hit.setRing(tp_ring);
0101   hit.setLayer(tp_layer);
0102   hit.setChamber(tp_chamber);
0103 
0104   hit.setCscId(tp_csc_id);
0105   hit.setCscFR(tp_csc_facing == csc::Facing::kRear);
0106 
0107   hit.setStrip(tp_pad);
0108   hit.setStripLo(tp_pad_lo);
0109   hit.setStripHi(tp_pad_hi);
0110 
0111   hit.setWire1(tp_roll);
0112   hit.setWire2(0);
0113 
0114   hit.setBend(tp_bend);
0115 
0116   hit.setBx(tp_bx);
0117   hit.setSubbx(tp_subbx);
0118 
0119   hit.setQuality(tp_quality);
0120   hit.setPattern(0);
0121 
0122   hit.setGlobPhi(glob_phi);
0123   hit.setGlobTheta(glob_theta);
0124   hit.setGlobPerp(glob_rho);
0125   hit.setGlobZ(glob_z);
0126   hit.setGlobTime(tp_time);
0127 
0128   hit.setEmtfChamber(tp_ilink);
0129   hit.setEmtfSegment(tp_segment_id);
0130   hit.setEmtfPhi(emtf_phi);
0131   hit.setEmtfBend(emtf_bend);
0132   hit.setEmtfTheta1(emtf_theta);
0133   hit.setEmtfTheta2(0);
0134   hit.setEmtfQual1(emtf_qual);
0135   hit.setEmtfQual2(0);
0136   hit.setEmtfSite(emtf_site);
0137   hit.setEmtfHost(emtf_host);
0138   hit.setEmtfZones(emtf_zones);
0139 
0140   hit.setFlagNeighbor(tp_flag_neighbor);
0141   hit.setFlagSubstitute(tp_flag_substitute);
0142   hit.setFlagValid(tp_flag_valid);
0143 }