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/GE0TPConverter.h"
0015 
0016 using namespace emtf::phase2;
0017 
0018 GE0TPConverter::GE0TPConverter(const EMTFContext& context, const int& endcap, const int& sector)
0019     : context_(context), endcap_(endcap), sector_(sector) {}
0020 
0021 void GE0TPConverter::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 int 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.getME0Data();
0029 
0030   // Unpack detector info
0031   const auto tp_subsystem = L1TMuon::kME0;
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_layer = tp_info.layer;
0040   // const int tp_chamber = tp_info.chamber;
0041 
0042   const int tp_csc_id = tp_info.csc_id;
0043   const auto tp_csc_facing = tp_info.csc_facing;
0044 
0045   // Unpack data
0046   const int tp_phiposition = tp_data.phiposition;  // in half-strip unit
0047   const int tp_partition = tp_data.partition;      // in half-roll unit
0048 
0049   const int tp_bend = static_cast<int>(tp_data.deltaphi) * (tp_data.bend == 0 ? 1 : -1);
0050 
0051   const int tp_bx = tp_info.bx;
0052   const int tp_subbx = 0;   // no fine resolution timing
0053   const float tp_time = 0;  // no fine resolution timing.
0054 
0055   const auto tp_selection = tp_info.selection;
0056 
0057   const int tp_quality = tp_data.quality;
0058 
0059   // ID scheme used in FW
0060   const int tp_ilink = tp_info.ilink;
0061 
0062   // Get Global Coordinates
0063   const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp);
0064   const float glob_phi = tp::radToDeg(gp.phi().value());
0065   const float glob_theta = tp::radToDeg(gp.theta().value());
0066   const double glob_rho = gp.perp();
0067   const double glob_z = gp.z();
0068 
0069   // Calculate EMTF Values
0070   const int emtf_phi = tp::calcPhiInt(sector_, glob_phi);
0071   const int emtf_bend = std::clamp(tp_bend / 2, -64, 63);  // 7-bit, signed
0072   const int emtf_theta = tp::calcThetaInt(tp_endcap_pm, glob_theta);
0073   const int emtf_qual = std::clamp(tp_quality, 0, 15);  // 4-bit, unsigned
0074   const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring});
0075   const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring});
0076   const int emtf_zones = context_.zone_lut_.getZones(emtf_host, emtf_theta);
0077 
0078   emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040));
0079   emtf_assert((1 <= emtf_theta) and (emtf_theta < 128));
0080 
0081   // Get flags
0082   const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor);
0083   const bool tp_flag_substitute = tp_info.flag_substitute;
0084   const bool tp_flag_valid = true;  // given by digi, not trigger_primitive :(
0085 
0086   // Set properties
0087   hit.setId(tp_hit_id);
0088 
0089   hit.setRawDetId(tp_raw_id);
0090   hit.setSubsystem(L1TMuon::kME0);
0091   hit.setEndcap(tp_endcap_pm);
0092   hit.setSector(sector_);
0093   hit.setSubsector(tp_subsector);
0094   hit.setStation(tp_station);
0095   hit.setRing(tp_ring);
0096   hit.setLayer(tp_layer);
0097   hit.setChamber(tp_det_id.chamber());  // Save original chamber
0098 
0099   hit.setCscId(tp_csc_id);
0100   hit.setCscFR(tp_csc_facing == csc::Facing::kRear);
0101 
0102   hit.setStrip(tp_phiposition);
0103   hit.setStripLo(tp_phiposition);
0104   hit.setStripHi(tp_phiposition);
0105 
0106   hit.setWire1(tp_partition);
0107   hit.setWire2(0);
0108 
0109   hit.setBend(tp_bend);
0110 
0111   hit.setBx(tp_bx);
0112   hit.setSubbx(tp_subbx);
0113 
0114   hit.setQuality(tp_quality);
0115   hit.setPattern(0);
0116 
0117   hit.setGlobPhi(glob_phi);
0118   hit.setGlobTheta(glob_theta);
0119   hit.setGlobPerp(glob_rho);
0120   hit.setGlobZ(glob_z);
0121   hit.setGlobTime(tp_time);
0122 
0123   hit.setEmtfChamber(tp_ilink);
0124   hit.setEmtfSegment(tp_segment_id);
0125   hit.setEmtfPhi(emtf_phi);
0126   hit.setEmtfBend(emtf_bend);
0127   hit.setEmtfTheta1(emtf_theta);
0128   hit.setEmtfTheta2(0);
0129   hit.setEmtfQual1(emtf_qual);
0130   hit.setEmtfQual2(0);
0131   hit.setEmtfSite(emtf_site);
0132   hit.setEmtfHost(emtf_host);
0133   hit.setEmtfZones(emtf_zones);
0134 
0135   hit.setFlagNeighbor(tp_flag_neighbor);
0136   hit.setFlagSubstitute(tp_flag_substitute);
0137   hit.setFlagValid(tp_flag_valid);
0138 }