From 2c24f44c273fa17b73d4ee40777e030eb8889f6b Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Thu, 13 Jul 2023 15:24:44 +0900 Subject: [PATCH 01/24] Add GE0 builders for pseudo triggers from the ME0 --- .../interface/GE0TriggerPseudoBuilder.h | 63 +++++++ .../plugins/GE0TriggerPseudoProducer.cc | 77 ++++++++ .../L1TGEM/src/GE0TriggerPseudoBuilder.cc | 164 ++++++++++++++++++ 3 files changed, 304 insertions(+) create mode 100644 L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h create mode 100644 L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc create mode 100644 L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc diff --git a/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h b/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h new file mode 100644 index 0000000000000..816723cbaf86a --- /dev/null +++ b/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h @@ -0,0 +1,63 @@ +#ifndef L1Trigger_L1TGEM_GE0TriggerPseudoBuilder_h +#define L1Trigger_L1TGEM_GE0TriggerPseudoBuilder_h + +/** \class GE0TriggerPseudoBuilder + * + * Builds GE0 trigger objects from GE0 segment + * + * \author Original ME0 code by Tao Huang (TAMU). Converted and updated to GE0 by Ian J. Watson (USeoul) + * + */ + +#include "DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMSegment.h" +#include "DataFormats/GEMRecHit/interface/GEMRecHit.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +class GEMGeometry; + +class GE0TriggerPseudoBuilder { +public: + /** Configure the algorithm via constructor. + * Receives ParameterSet percolated down from + * EDProducer which owns this Builder. + */ + explicit GE0TriggerPseudoBuilder(const edm::ParameterSet&); + + ~GE0TriggerPseudoBuilder(); + + /** Build Triggers from ME0 segment in each chamber and fill them into output collections. */ + void build(const GEMSegmentCollection* me0segments, ME0TriggerDigiCollection& oc_trig); + + /** set geometry for the matching needs */ + void setME0Geometry(const GEMGeometry* g) { me0_g = g; } + + /* print all ME0 segments in the event */ + void dumpAllME0Segments(const GEMSegmentCollection& segments) const; + + /** Max values of trigger labels for all ME0s; + * used to construct TMB processors. + */ + enum class trig_me0s { MAX_ENDCAPS = 2, MAX_CHAMBERS = 18 }; + +private: + static const int min_endcap; + static const int max_endcap; + static const int min_chamber; + static const int max_chamber; + static const unsigned int ME0KeyLayer; + static const int ME0TriggerCentralBX; + + const GEMGeometry* me0_g; + + int info_; + + double dphiresolution_; //unit: trigger pad + + ME0TriggerDigi segmentConversion(const GEMSegment segment); + + edm::ParameterSet config_; +}; + +#endif diff --git a/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc b/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc new file mode 100644 index 0000000000000..389557f4d0fae --- /dev/null +++ b/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc @@ -0,0 +1,77 @@ +/** \class GE0TriggerPseudoProducer + * + * Takes offline GE0 segment as input + * Produces GE0 trigger objects + * + * \author Original ME0 code by Tao Huang (TAMU). Converted and updated to GE0 by Ian J. Watson (USeoul) + * + */ + +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/InputTag.h" +#include "FWCore/Utilities/interface/ESGetToken.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h" +#include "DataFormats/GEMRecHit/interface/GEMSegmentCollection.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" + +class GE0TriggerPseudoBuilder; + +class GE0TriggerPseudoProducer : public edm::global::EDProducer<> { +public: + explicit GE0TriggerPseudoProducer(const edm::ParameterSet&); + ~GE0TriggerPseudoProducer() override; + + void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + +private: + edm::InputTag me0segmentProducer_; + edm::EDGetTokenT me0segment_token_; + edm::ESGetToken me0_geom_token_; + edm::ParameterSet config_; +}; + +GE0TriggerPseudoProducer::GE0TriggerPseudoProducer(const edm::ParameterSet& conf) { + me0segmentProducer_ = conf.getParameter("ME0SegmentProducer"); + me0segment_token_ = consumes(me0segmentProducer_); + me0_geom_token_ = esConsumes(); + config_ = conf; + + // register what this produces + produces(); +} + +GE0TriggerPseudoProducer::~GE0TriggerPseudoProducer() {} + +void GE0TriggerPseudoProducer::produce(edm::StreamID, edm::Event& ev, const edm::EventSetup& setup) const { + edm::ESHandle h_me0 = setup.getHandle(me0_geom_token_); + + edm::Handle me0Segmentcoll; + ev.getByToken(me0segment_token_, me0Segmentcoll); + const GEMSegmentCollection* me0segments = me0Segmentcoll.product(); + + // Create empty collection + auto oc_trig = std::make_unique(); + + auto trigBuilder = std::make_unique(config_); + trigBuilder->setME0Geometry(&*h_me0); + + // Fill output collections if valid input collection is available. + if (me0Segmentcoll.isValid()) { + trigBuilder->build(me0segments, *oc_trig); + } + + // Put collections in event. + ev.put(std::move(oc_trig)); +} + +DEFINE_FWK_MODULE(GE0TriggerPseudoProducer); diff --git a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc new file mode 100644 index 0000000000000..49ba433d44281 --- /dev/null +++ b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc @@ -0,0 +1,164 @@ +#include "L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" +#include "Geometry/GEMGeometry/interface/GEMGeometry.h" + +#include +#include + +const unsigned int GE0TriggerPseudoBuilder::ME0KeyLayer = 3; +const int GE0TriggerPseudoBuilder::ME0TriggerCentralBX = 8; + +GE0TriggerPseudoBuilder::GE0TriggerPseudoBuilder(const edm::ParameterSet& conf) { + config_ = conf; + info_ = config_.getUntrackedParameter("info", 0); + dphiresolution_ = config_.getUntrackedParameter("DeltaPhiResolution", 0.25); +} + +GE0TriggerPseudoBuilder::~GE0TriggerPseudoBuilder() {} + +void GE0TriggerPseudoBuilder::build(const GEMSegmentCollection* me0Segments, ME0TriggerDigiCollection& oc_trig) { + if (info_ > 2) + dumpAllME0Segments(*me0Segments); + + for (int endc = 0; endc < static_cast(trig_me0s::MAX_ENDCAPS); endc++) { + for (int cham = 0; cham < static_cast(trig_me0s::MAX_CHAMBERS); cham++) { + // 0th layer means whole chamber. + // chamber counts from 1 to 18 in ME0ID + const int region(endc == 0 ? -1 : 1); + // constexpr GEMDetId(int region, int ring, int station, int layer, int chamber, int ieta) + GEMDetId detid(region, 0, 0, 0, cham + 1, 0); + + const auto& drange = me0Segments->get(detid); + std::vector trigV; + for (auto digiIt = drange.first; digiIt != drange.second; digiIt++) { + if (info_ > 1) + LogTrace("L1ME0Trigger") << "GE0TriggerPseudoBuilder id " << detid << " ME0 segment " << *digiIt + << " to be converted into trigger digi\n"; + ME0TriggerDigi trig = segmentConversion(*digiIt); + if (trig.isValid()) + trigV.push_back(trig); + if (info_ > 1 and trig.isValid()) + LogTrace("L1ME0Trigger") << " ME0trigger " << trig << "\n"; + else if (info_ > 1) + LogTrace("L1ME0Trigger") << " ME0trigger is not valid. Conversion failed \n"; + } + + if (!trigV.empty()) { + LogTrace("L1ME0Trigger") << "GE0TriggerPseudoBuilder got results in " << detid << std::endl + << "Put " << trigV.size() << " Trigger digi" << ((trigV.size() > 1) ? "s " : " ") + << "in collection\n"; + oc_trig.put(std::make_pair(trigV.begin(), trigV.end()), detid); + } + } + } +} + +ME0TriggerDigi GE0TriggerPseudoBuilder::segmentConversion(const GEMSegment segment) { + auto detid = segment.gemDetId(); + const GEMSuperChamber* chamber = me0_g->superChamber(detid); + const GEMChamber* keylayer = chamber->chamber(GE0TriggerPseudoBuilder::ME0KeyLayer); + int chamberid = detid.superChamberId() % 2; + int totRolls = keylayer->nEtaPartitions(); + float dphi = chamber->computeDeltaPhi(segment.localPosition(), segment.localDirection()); + // !!!!TODO!!!! float time = segment.time(); + // !!!!TODO!!!! int sign_time = (time > 0) ? 1 : -1; + int nrechits = segment.nRecHits(); + std::vector rolls; + for (const auto& rechit : segment.specificRecHits()) { + if (std::find(rolls.begin(), rolls.end(), rechit.gemId().roll()) == rolls.end()) + rolls.push_back(rechit.gemId().roll()); + } + if (rolls.size() > 2 or rolls.empty()) + LogTrace("L1ME0Trigger") << " ME0 segment is crossing " << rolls.size() << " roll !!! \n"; + //assert(rolls.size() <= 2); // we did found very few ME0 segments crossing 3 rolls!!! this cut is applied offline + if (rolls.empty()) + return ME0TriggerDigi(); + if (rolls[0] < 1) + LogTrace("L1ME0Trigger") << " ME0 segment has wrong roll number " << rolls[0] << " which should be >= 1 \n !!!"; + assert(rolls[0] >= 1); + int partition = (rolls[0] - 1) << 1; //roll from detid counts from 1 + if (rolls.size() == 2 and rolls[0] > rolls[1]) + partition = partition - 1; + else if (rolls.size() == 2 and rolls[0] < rolls[1]) + partition = partition + 1; + + if (partition < 0 or partition >= 2 * totRolls) { + LogTrace("L1ME0Trigger") << " ME0 segment rolls size of all hits " << rolls.size() << " rolls[0] " << rolls[0] + << " rolls.back() " << rolls.back() << " and ME0 trigger roll is " << partition + << " max expected " << 2 * totRolls - 1 << "\n"; + return ME0TriggerDigi(); + } + + //globalpoint from ME0 segment + GlobalPoint gp = me0_g->idToDet(segment.gemDetId())->surface().toGlobal(segment.localPosition()); + const GEMEtaPartition* etapart = keylayer->etaPartition(rolls[0]); + LocalPoint segment_lp = etapart->surface().toLocal(gp); // convert segment gp into lp in etapartition coordinate + float strippitch = etapart->localPitch(segment_lp); + float strip = etapart->strip(segment_lp); + int totstrip = etapart->nstrips(); + int istrip = static_cast(strip); + int phiposition = istrip; + if (phiposition > totstrip) + LogTrace("L1ME0Trigger") << " ME0 segment strip number is " << phiposition << " larger than nstrip " << totstrip + << " !!! \n"; + float phi_resolution = 0.5; //halfstrip + int phiposition2 = (static_cast((strip - phiposition) / phi_resolution) & 1); // half-strip resolution + phiposition = (phiposition << 1) | phiposition2; + + //gloablpoint from ME0 trigger digi + float centreOfStrip = istrip + 0.25 + phiposition2 * 0.5; + GlobalPoint gp_digi = etapart->toGlobal(etapart->centreOfStrip(centreOfStrip)); + + float strippitch_rad = strippitch / gp.perp(); //unit in rad + + int idphi = static_cast(fabs(dphi) / (strippitch_rad * dphiresolution_)); + const int max_idphi = 512; + if (idphi >= max_idphi) { + LogTrace("L1ME0Trigger") << " ME0 segment dphi " << dphi << " and int type: " << idphi + << " larger than max allowed: " << max_idphi << " !!! \n"; + idphi = max_idphi - 1; + } + int quality = nrechits; // attention: not the same as discussed in meeting + // !!!!TODO!!!! int BX = (static_cast(fabs(time) / 25.0)) * sign_time + GE0TriggerPseudoBuilder::ME0TriggerCentralBX; + int BX = GE0TriggerPseudoBuilder::ME0TriggerCentralBX; + int bend = (dphi > 0.0) ? 0 : 1; + if (info_ > 2) + LogTrace("L1ME0Trigger") << " ME0trigger in conversion function:\n" + << "\t chamber(1-18) " << detid.chamber() << " chamber id " << chamberid << " \n" + << "\t rolls size of all hits " << rolls.size() << " rolls[0] " << rolls[0] + << " rolls.back() " << rolls.back() << " roll " << partition << " \n" + << "\t nRechits " << nrechits << " quality " << quality << " \n" + << "\t strip(float) " << strip << " (int) " << istrip << " phiposition " << phiposition + << " resolution (in term of strip) " << phi_resolution << " \n" + << "\t deltaphi(float) " << dphi << " (int) " << idphi << " resolution " + << strippitch_rad * dphiresolution_ << " bend " << bend << " \n" + << "\t global point eta " << gp.eta() << " phi " << gp.phi() << " trigger digi eta " + << gp_digi.eta() << " phi " << gp_digi.phi() << " \n" + // << "\t time (ns, float) " << time << " BX " << BX << " \n" + ; + + ME0TriggerDigi result = ME0TriggerDigi(chamberid, quality, phiposition, partition, idphi, bend, BX); + result.setStrip(istrip); + return result; + + return ME0TriggerDigi(); +} + +void GE0TriggerPseudoBuilder::dumpAllME0Segments(const GEMSegmentCollection& segments) const { + LogTrace("L1ME0Trigger") << "dumpt all ME0 Segments" << std::endl; + // for (auto iC = segments.id_begin(); iC != segments.id_end(); ++iC) { + // auto ch_segs = segments.get(*iC); + // for (auto iS = ch_segs.first; iS != ch_segs.second; ++iS) { + // GlobalPoint gp = me0_g->idToDet(iS->me0DetId())->surface().toGlobal(iS->localPosition()); + // LogTrace("L1ME0Trigger") << "ME0Detid " << iS->me0DetId() << " segment " << *iS << " eta " << gp.eta() << " phi " + // << gp.phi() << std::endl; + // auto recHits(iS->recHits()); + // LogTrace("L1ME0Trigger") << "\t has " << recHits.size() << " me0 rechits" << std::endl; + // for (auto& rh : recHits) { + // const ME0RecHit* me0rh(dynamic_cast(rh)); + // LogTrace("L1ME0Trigger") << "\t detid " << me0rh->me0Id() << " rechit " << *me0rh << std::endl; + // } + // } + // } +} From f6fd1556888ebdb1035e433053bd88f09ce4ed63 Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Thu, 13 Jul 2023 16:15:02 +0900 Subject: [PATCH 02/24] Update L1Trigger/L1TMuon to use the GE0 in TP and GT --- .../L1TMuon/interface/MuonTriggerPrimitive.h | 2 + L1Trigger/L1TMuon/src/GeometryTranslator.cc | 48 +++++++++++++------ L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc | 17 +++++++ 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h b/L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h index 811d3010c99ac..026e00ef65349 100644 --- a/L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h +++ b/L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h @@ -222,6 +222,8 @@ namespace L1TMuon { // Constructor from ME0 data TriggerPrimitive(const ME0DetId& detid, const ME0TriggerDigi& digi); + // Constructor from GE0 data + TriggerPrimitive(const GEMDetId& detid, const ME0TriggerDigi& digi); // Copy constructor TriggerPrimitive(const TriggerPrimitive& tp); diff --git a/L1Trigger/L1TMuon/src/GeometryTranslator.cc b/L1Trigger/L1TMuon/src/GeometryTranslator.cc index bdab164708cbe..6901cc28223fd 100644 --- a/L1Trigger/L1TMuon/src/GeometryTranslator.cc +++ b/L1Trigger/L1TMuon/src/GeometryTranslator.cc @@ -151,21 +151,39 @@ void GeometryTranslator::checkAndUpdateGeometry(const edm::EventSetup& es) { // _____________________________________________________________________________ // 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; + if (tp.detId().subdetId() == MuonSubdetId::GEM) { // GE0 + const GEMDetId id(tp.detId()); + const GEMSuperChamber* chamber = _geogem->superChamber(id); + const GEMChamber* keylayer = chamber->chamber(3); // GEM key layer is layer 3 + int partition = tp.getME0Data().partition; // 'partition' is in half-roll unit + int iroll = (partition >> 1) + 1; + const GEMEtaPartition* roll = keylayer->etaPartition(iroll); + assert(roll != nullptr); // failed to get GEM 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; + } else { // ME0 + 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 { diff --git a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc index 74eeee069ab7a..0aefee9a94d10 100644 --- a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc +++ b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc @@ -251,6 +251,23 @@ TriggerPrimitive::TriggerPrimitive(const ME0DetId& detid, const ME0TriggerDigi& _me0.bx = digi.getBX(); } +// Constructor from ME0 data +TriggerPrimitive::TriggerPrimitive(const GEMDetId& detid, const ME0TriggerDigi& digi) + : _id(detid), _subsystem(L1TMuon::kME0) { + calculateGlobalSector(detid, _globalsector, _subsector); + _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) From fb0df3cd0dbf2b89e3d2e3a73a4feea06aca664b Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Fri, 21 Jul 2023 14:28:54 +0900 Subject: [PATCH 03/24] Updates to have GE0 run with trigger debug script --- .../GEMDigi/interface/ME0TriggerDigiCollection.h | 2 ++ DataFormats/GEMDigi/src/classes_def.xml | 5 +++++ .../L1TGEM/interface/GE0TriggerPseudoBuilder.h | 2 +- .../L1TGEM/plugins/GE0TriggerPseudoProducer.cc | 4 ++-- .../python/me0TriggerConvertedPseudoDigis_cfi.py | 6 ++++++ L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py | 4 +++- .../L1TGEM/python/me0TriggerPseudoDigis_cff.py | 13 +++++++++++++ L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc | 4 ++-- L1Trigger/L1TMuon/python/simDigis_cff.py | 6 +++--- L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc | 6 +++++- 10 files changed, 42 insertions(+), 10 deletions(-) diff --git a/DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h b/DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h index de2f10186e05e..9bb32d91ecaa4 100644 --- a/DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h +++ b/DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h @@ -8,9 +8,11 @@ */ #include "DataFormats/MuonDetId/interface/ME0DetId.h" +#include "DataFormats/MuonDetId/interface/GEMDetId.h" #include "DataFormats/GEMDigi/interface/ME0TriggerDigi.h" #include "DataFormats/MuonData/interface/MuonDigiCollection.h" typedef MuonDigiCollection ME0TriggerDigiCollection; +typedef MuonDigiCollection GE0TriggerDigiCollection; #endif diff --git a/DataFormats/GEMDigi/src/classes_def.xml b/DataFormats/GEMDigi/src/classes_def.xml index 2046f2f9f66b6..348e0c72a89a2 100644 --- a/DataFormats/GEMDigi/src/classes_def.xml +++ b/DataFormats/GEMDigi/src/classes_def.xml @@ -132,4 +132,9 @@ + + + + + diff --git a/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h b/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h index 816723cbaf86a..353a69e89a92d 100644 --- a/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h +++ b/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h @@ -28,7 +28,7 @@ class GE0TriggerPseudoBuilder { ~GE0TriggerPseudoBuilder(); /** Build Triggers from ME0 segment in each chamber and fill them into output collections. */ - void build(const GEMSegmentCollection* me0segments, ME0TriggerDigiCollection& oc_trig); + void build(const GEMSegmentCollection* me0segments, GE0TriggerDigiCollection& oc_trig); /** set geometry for the matching needs */ void setME0Geometry(const GEMGeometry* g) { me0_g = g; } diff --git a/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc b/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc index 389557f4d0fae..1d05cdabdeb91 100644 --- a/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc +++ b/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc @@ -47,7 +47,7 @@ GE0TriggerPseudoProducer::GE0TriggerPseudoProducer(const edm::ParameterSet& conf config_ = conf; // register what this produces - produces(); + produces(); } GE0TriggerPseudoProducer::~GE0TriggerPseudoProducer() {} @@ -60,7 +60,7 @@ void GE0TriggerPseudoProducer::produce(edm::StreamID, edm::Event& ev, const edm: const GEMSegmentCollection* me0segments = me0Segmentcoll.product(); // Create empty collection - auto oc_trig = std::make_unique(); + auto oc_trig = std::make_unique(); auto trigBuilder = std::make_unique(config_); trigBuilder->setME0Geometry(&*h_me0); diff --git a/L1Trigger/L1TGEM/python/me0TriggerConvertedPseudoDigis_cfi.py b/L1Trigger/L1TGEM/python/me0TriggerConvertedPseudoDigis_cfi.py index 48113e3fe5121..74a941c879f2d 100644 --- a/L1Trigger/L1TGEM/python/me0TriggerConvertedPseudoDigis_cfi.py +++ b/L1Trigger/L1TGEM/python/me0TriggerConvertedPseudoDigis_cfi.py @@ -5,3 +5,9 @@ info = cms.untracked.int32(0), DeltaPhiResolution = cms.untracked.double(0.25)# in term of trigger pad ) + +ge0TriggerConvertedPseudoDigis = cms.EDProducer("GE0TriggerPseudoProducer", + ME0SegmentProducer = cms.InputTag("gemSegments"), + info = cms.untracked.int32(0), + DeltaPhiResolution = cms.untracked.double(0.25)# in term of trigger pad +) diff --git a/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py b/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py index 053cae23ea24c..d174ed2248402 100644 --- a/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py +++ b/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py @@ -7,6 +7,8 @@ me0TriggerRealDigiTask = cms.Task(simMuonME0PadDigis, me0TriggerDigis) me0TriggerAllDigiTask = cms.Task(me0TriggerRealDigiTask, me0TriggerPseudoDigiTask) +ge0TriggerAllDigiTask = cms.Task(me0TriggerRealDigiTask, ge0TriggerPseudoDigiTask) ## in scenarios with GE0, remove the pseudo digis -phase2_GE0.toReplaceWith(me0TriggerAllDigiTask, me0TriggerAllDigiTask.copyAndExclude([me0TriggerPseudoDigiTask])) +# phase2_GE0.toReplaceWith(me0TriggerAllDigiTask, me0TriggerAllDigiTask.copyAndExclude([me0TriggerPseudoDigiTask])) +phase2_GE0.toReplaceWith(me0TriggerAllDigiTask, ge0TriggerAllDigiTask) diff --git a/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py b/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py index ea60ea4d19600..b34bb154715c9 100644 --- a/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py +++ b/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py @@ -37,3 +37,16 @@ me0Segments, me0TriggerConvertedPseudoDigis ) + +from RecoLocalMuon.GEMRecHit.gemRecHits_cfi import * +from RecoLocalMuon.GEMSegment.gemSegments_cfi import * + +ge0TriggerPseudoDigiTask = cms.Task( + simMuonME0PseudoReDigisCoarse, + me0RecHitsCoarse, + me0TriggerPseudoDigis, + ## need to run the standard ME0 RECO sequence for converted triggers + gemRecHits, + gemSegments, + ge0TriggerConvertedPseudoDigis +) diff --git a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc index 49ba433d44281..8ebdb857d5d61 100644 --- a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc +++ b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc @@ -17,7 +17,7 @@ GE0TriggerPseudoBuilder::GE0TriggerPseudoBuilder(const edm::ParameterSet& conf) GE0TriggerPseudoBuilder::~GE0TriggerPseudoBuilder() {} -void GE0TriggerPseudoBuilder::build(const GEMSegmentCollection* me0Segments, ME0TriggerDigiCollection& oc_trig) { +void GE0TriggerPseudoBuilder::build(const GEMSegmentCollection* me0Segments, GE0TriggerDigiCollection& oc_trig) { if (info_ > 2) dumpAllME0Segments(*me0Segments); @@ -27,7 +27,7 @@ void GE0TriggerPseudoBuilder::build(const GEMSegmentCollection* me0Segments, ME0 // chamber counts from 1 to 18 in ME0ID const int region(endc == 0 ? -1 : 1); // constexpr GEMDetId(int region, int ring, int station, int layer, int chamber, int ieta) - GEMDetId detid(region, 0, 0, 0, cham + 1, 0); + GEMDetId detid(region, 1, 0, 0, cham + 1, 0); const auto& drange = me0Segments->get(detid); std::vector trigV; diff --git a/L1Trigger/L1TMuon/python/simDigis_cff.py b/L1Trigger/L1TMuon/python/simDigis_cff.py index 521660d4717fd..383382d542565 100644 --- a/L1Trigger/L1TMuon/python/simDigis_cff.py +++ b/L1Trigger/L1TMuon/python/simDigis_cff.py @@ -123,10 +123,10 @@ _phase2_SimL1TMuonTask = SimL1TMuonTask.copy() _phase2_SimL1TMuonTask.add(me0TriggerAllDigiTask) _phase2_SimL1TMuonTask.add(simCscTriggerPrimitiveDigisPhase2) -_phase2_GE0_SimL1TMuonTask = SimL1TMuonTask.copyAndExclude([me0TriggerAllDigiTask]) +# _phase2_GE0_SimL1TMuonTask = SimL1TMuonTask.copyAndExclude([me0TriggerAllDigiTask]) from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon (stage2L1Trigger & phase2_muon).toReplaceWith( SimL1TMuonTask, _phase2_SimL1TMuonTask ) -from Configuration.Eras.Modifier_phase2_GE0_cff import phase2_GE0 -(stage2L1Trigger & phase2_GE0).toReplaceWith( SimL1TMuonTask, _phase2_GE0_SimL1TMuonTask ) +# from Configuration.Eras.Modifier_phase2_GE0_cff import phase2_GE0 +# (stage2L1Trigger & phase2_GE0).toReplaceWith( SimL1TMuonTask, _phase2_GE0_SimL1TMuonTask ) diff --git a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc index 0aefee9a94d10..16300313a4149 100644 --- a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc +++ b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc @@ -495,7 +495,11 @@ void TriggerPrimitive::print(std::ostream& out) const { out << "Pad high : " << _gem.pad_hi << std::endl; break; case kME0: - out << detId() << std::endl; + try { + out << detId() << std::endl; + } catch (...) { + out << detId() << std::endl; + } out << "Local BX : " << _me0.bx << std::endl; out << "Chamber id : " << _me0.chamberid << std::endl; out << "Quality : " << _me0.quality << std::endl; From ee8dfb1c6ae16c5d025697c77195c006b88d8590 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Wed, 6 Dec 2023 20:33:35 +0100 Subject: [PATCH 04/24] Added EMTFpp emulator --- DataFormats/L1TMuonPhase2/BuildFile.xml | 7 +- DataFormats/L1TMuonPhase2/interface/EMTFHit.h | 268 +++++++ .../L1TMuonPhase2/interface/EMTFInput.h | 57 ++ .../L1TMuonPhase2/interface/EMTFTrack.h | 144 ++++ DataFormats/L1TMuonPhase2/src/EMTFHit.cc | 3 + DataFormats/L1TMuonPhase2/src/EMTFInput.cc | 3 + DataFormats/L1TMuonPhase2/src/EMTFTrack.cc | 3 + DataFormats/L1TMuonPhase2/src/MuonStub.cc | 1 + DataFormats/L1TMuonPhase2/src/SAMuon.cc | 1 + DataFormats/L1TMuonPhase2/src/TrackerMuon.cc | 2 +- DataFormats/L1TMuonPhase2/src/classes.h | 6 + DataFormats/L1TMuonPhase2/src/classes_def.xml | 55 +- L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml | 13 + .../interface/Algo/DuplicateRemovalLayer.h | 29 + .../interface/Algo/HitmapLayer.h | 27 + .../interface/Algo/OutputLayer.h | 49 ++ .../interface/Algo/ParameterAssignmentLayer.h | 30 + .../interface/Algo/PatternMatchingLayer.h | 32 + .../interface/Algo/RoadSortingLayer.h | 30 + .../interface/Algo/TrackBuildingLayer.h | 47 ++ .../interface/DAQ/CSCTPCollector.h | 30 + .../interface/DAQ/CSCTPConverter.h | 32 + .../interface/DAQ/CSCTPSelector.h | 46 ++ .../interface/DAQ/GE0TPCollector.h | 31 + .../interface/DAQ/GE0TPConverter.h | 32 + .../interface/DAQ/GE0TPSelector.h | 45 ++ .../interface/DAQ/GEMTPCollector.h | 30 + .../interface/DAQ/GEMTPConverter.h | 31 + .../interface/DAQ/GEMTPSelector.h | 45 ++ .../interface/DAQ/ME0TPCollector.h | 30 + .../interface/DAQ/ME0TPConverter.h | 31 + .../interface/DAQ/ME0TPSelector.h | 44 ++ .../interface/DAQ/RPCTPCollector.h | 30 + .../interface/DAQ/RPCTPConverter.h | 31 + .../interface/DAQ/RPCTPSelector.h | 47 ++ .../interface/DAQ/SubsystemTags.h | 97 +++ .../interface/DAQ/TPCollectors.h | 23 + .../interface/DAQ/TPConverters.h | 24 + .../interface/DAQ/TPSelectors.h | 24 + .../interface/DAQ/TPrimitives.h | 67 ++ .../interface/Data/ActivationLut.h | 38 + .../interface/Data/HostLut.h | 37 + .../interface/Data/SiteLut.h | 38 + .../interface/Data/TimeZoneLut.h | 37 + .../interface/Data/ZoneLut.h | 55 ++ .../interface/EMTFConfiguration.h | 53 ++ .../interface/EMTFConstants.h | 62 ++ .../interface/EMTFContext.h | 84 +++ .../interface/EMTFLogger.h | 36 + .../L1TMuonEndCapPhase2/interface/EMTFModel.h | 126 ++++ .../L1TMuonEndCapPhase2/interface/EMTFTypes.h | 178 +++++ .../L1TMuonEndCapPhase2/interface/EMTFfwd.h | 31 + .../interface/SectorProcessor.h | 72 ++ .../interface/TrackFinder.h | 41 ++ .../interface/Utils/CSCUtils.h | 44 ++ .../interface/Utils/DataUtils.h | 187 +++++ .../interface/Utils/DebugUtils.h | 19 + .../interface/Utils/IteratorUtils.h | 283 ++++++++ .../interface/Utils/RPCUtils.h | 13 + .../interface/Utils/TPUtils.h | 46 ++ .../interface/Utils/TemplateUtils.h | 25 + .../L1TMuonEndCapPhase2/plugins/BuildFile.xml | 4 + .../L1TMuonEndCapPhase2TrackProducer.cc | 59 ++ .../L1TMuonEndCapPhase2TrackProducer.h | 47 ++ .../L1TMuonEndCapPhase2/python/config.py | 57 ++ .../python/rpcRecHitsForEMTF_cfi.py | 5 + .../simCscTriggerPrimitiveDigisForEMTF_cfi.py | 30 + .../python/simEmtfDigisPhase2_cfi.py | 57 ++ .../L1TMuonEndCapPhase2/scripts/msort.py | 163 +++++ .../src/Algo/DuplicateRemovalLayer.cc | 141 ++++ .../src/Algo/HitmapLayer.cc | 207 ++++++ .../src/Algo/OutputLayer.cc | 237 +++++++ .../src/Algo/ParameterAssignmentLayer.cc | 194 +++++ .../src/Algo/PatternMatchingLayer.cc | 140 ++++ .../src/Algo/RoadSortingLayer.cc | 188 +++++ .../src/Algo/TrackBuildingLayer.cc | 602 ++++++++++++++++ .../src/DAQ/CSCTPCollector.cc | 226 ++++++ .../src/DAQ/CSCTPConverter.cc | 190 +++++ .../src/DAQ/CSCTPSelector.cc | 154 ++++ .../src/DAQ/GE0TPCollector.cc | 148 ++++ .../src/DAQ/GE0TPConverter.cc | 152 ++++ .../src/DAQ/GE0TPSelector.cc | 119 ++++ .../src/DAQ/GEMTPCollector.cc | 208 ++++++ .../src/DAQ/GEMTPConverter.cc | 157 +++++ .../src/DAQ/GEMTPSelector.cc | 132 ++++ .../src/DAQ/ME0TPCollector.cc | 147 ++++ .../src/DAQ/ME0TPConverter.cc | 152 ++++ .../src/DAQ/ME0TPSelector.cc | 119 ++++ .../src/DAQ/RPCTPCollector.cc | 174 +++++ .../src/DAQ/RPCTPConverter.cc | 189 +++++ .../src/DAQ/RPCTPSelector.cc | 141 ++++ .../src/DAQ/TPrimitives.cc | 67 ++ .../src/Data/ActivationLut.cc | 225 ++++++ .../L1TMuonEndCapPhase2/src/Data/HostLut.cc | 55 ++ .../L1TMuonEndCapPhase2/src/Data/SiteLut.cc | 55 ++ .../src/Data/TimeZoneLut.cc | 63 ++ .../L1TMuonEndCapPhase2/src/Data/ZoneLut.cc | 129 ++++ .../src/EMTFConfiguration.cc | 49 ++ .../L1TMuonEndCapPhase2/src/EMTFContext.cc | 126 ++++ .../L1TMuonEndCapPhase2/src/EMTFModel.cc | 666 ++++++++++++++++++ .../src/SectorProcessor.cc | 479 +++++++++++++ .../L1TMuonEndCapPhase2/src/TrackFinder.cc | 225 ++++++ .../L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc | 182 +++++ .../L1TMuonEndCapPhase2/src/Utils/TPUtils.cc | 124 ++++ L1Trigger/L1TMuonEndCapPhase2/test/debug.py | 182 +++++ .../L1TMuonEndCapPhase2/test/debug_disp.py | 182 +++++ .../L1TMuonEndCapPhase2/test/debug_llp.py | 181 +++++ .../test/debug_llp_flatinvdmass_d88.py | 182 +++++ 108 files changed, 10766 insertions(+), 27 deletions(-) create mode 100644 DataFormats/L1TMuonPhase2/interface/EMTFHit.h create mode 100644 DataFormats/L1TMuonPhase2/interface/EMTFInput.h create mode 100644 DataFormats/L1TMuonPhase2/interface/EMTFTrack.h create mode 100644 DataFormats/L1TMuonPhase2/src/EMTFHit.cc create mode 100644 DataFormats/L1TMuonPhase2/src/EMTFInput.cc create mode 100644 DataFormats/L1TMuonPhase2/src/EMTFTrack.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/EMTFLogger.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/plugins/BuildFile.xml create mode 100644 L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h create mode 100644 L1Trigger/L1TMuonEndCapPhase2/python/config.py create mode 100644 L1Trigger/L1TMuonEndCapPhase2/python/rpcRecHitsForEMTF_cfi.py create mode 100644 L1Trigger/L1TMuonEndCapPhase2/python/simCscTriggerPrimitiveDigisForEMTF_cfi.py create mode 100644 L1Trigger/L1TMuonEndCapPhase2/python/simEmtfDigisPhase2_cfi.py create mode 100644 L1Trigger/L1TMuonEndCapPhase2/scripts/msort.py create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/DAQ/TPrimitives.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Data/HostLut.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Data/SiteLut.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/EMTFModel.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc create mode 100644 L1Trigger/L1TMuonEndCapPhase2/test/debug.py create mode 100644 L1Trigger/L1TMuonEndCapPhase2/test/debug_disp.py create mode 100644 L1Trigger/L1TMuonEndCapPhase2/test/debug_llp.py create mode 100644 L1Trigger/L1TMuonEndCapPhase2/test/debug_llp_flatinvdmass_d88.py diff --git a/DataFormats/L1TMuonPhase2/BuildFile.xml b/DataFormats/L1TMuonPhase2/BuildFile.xml index 30d1101e0e69d..2211e3adc5bd8 100644 --- a/DataFormats/L1TMuonPhase2/BuildFile.xml +++ b/DataFormats/L1TMuonPhase2/BuildFile.xml @@ -1,9 +1,10 @@ - + - + - + + diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFHit.h b/DataFormats/L1TMuonPhase2/interface/EMTFHit.h new file mode 100644 index 0000000000000..2d26cb0d7393b --- /dev/null +++ b/DataFormats/L1TMuonPhase2/interface/EMTFHit.h @@ -0,0 +1,268 @@ +#ifndef DataFormats_L1TMuonPhase2_EMTFHit_h +#define DataFormats_L1TMuonPhase2_EMTFHit_h + +#include +#include + +#include "DataFormats/L1TMuon/interface/L1TMuonSubsystems.h" + +namespace l1t::phase2 { + + class EMTFHit { + public: + EMTFHit(): + id_(0), + + raw_det_id_(0), + subsystem_(0), + endcap_(0), + sector_(0), + subsector_(0), + station_(0), + ring_(0), + roll_(0), + layer_(0), + chamber_(0), + + csc_id_(0), + csc_fr_(0), + + strip_(0), + strip_lo_(0), + strip_hi_(0), + strip_quart_(0), // Run 3 + strip_eighth_(0), // Run 3 + strip_quart_bit_(0), // Run 3 + strip_eighth_bit_(0), // Run 3 + + wire1_(0), + wire2_(0), + + bx_(0), + subbx_(0), + + quality_(0), + pattern_(0), + + glob_phi_(0), + glob_theta_(0), + glob_perp_(0), + glob_z_(0), + glob_time_(0), + + emtf_chamber_(0), + emtf_segment_(0), + emtf_phi_(0), + emtf_bend_(0), + emtf_slope_(0), + emtf_theta1_(0), + emtf_theta2_(0), + emtf_qual1_(0), + emtf_qual2_(0), + emtf_time_(0), + emtf_site_(0), + emtf_host_(0), + emtf_zones_(0), + emtf_timezones_(0), + + flag_neighbor_(false), + flag_substitute_(false), + flag_valid_(false) + { + // Do Nothing + } + + ~EMTFHit() { + // Do Nothing + } + + // Setters + void setId(uint16_t aId) { id_ = aId; } + + void setRawDetId(uint32_t aRawDetId) { raw_det_id_ = aRawDetId; } + void setSubsystem(int16_t aSubsystem) { subsystem_ = aSubsystem; } + void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } + void setSector(int16_t aSector) { sector_ = aSector; } + void setSubsector(int16_t aSubsector) { subsector_ = aSubsector; } + void setStation(int16_t aStation) { station_ = aStation; } + void setRing(int16_t aRing) { ring_ = aRing; } + void setRoll(int16_t aRoll) { roll_ = aRoll; } + void setLayer(int16_t aLayer) { layer_ = aLayer; } + void setChamber(int16_t aChamber) { chamber_ = aChamber; } + + void setCscId(int16_t aCscid) { csc_id_ = aCscid; } + void setCscFR(int16_t aCscfr) { csc_fr_ = aCscfr; } + + void setStrip(int16_t aStrip) { strip_ = aStrip; } + void setStripLo(int16_t aStripLo) { strip_lo_ = aStripLo; } + void setStripHi(int16_t aStripHi) { strip_hi_ = aStripHi; } + void setStripQuart(int16_t aStripQuart) { strip_quart_ = aStripQuart; } // Run 3 + void setStripEighth(int16_t aStripEighth) { strip_eighth_ = aStripEighth; } // Run 3 + void setStripQuartBit(int16_t aStripQuartBit) { strip_quart_bit_ = aStripQuartBit; } // Run 3 + void setStripEighthBit(int16_t aStripEighthBit) { strip_eighth_bit_ = aStripEighthBit; } // Run 3 + + void setWire1(int16_t aWire1) { wire1_ = aWire1; } + void setWire2(int16_t aWire2) { wire2_ = aWire2; } + + void setBend(int16_t aBend) { bend_ = aBend; } + void setSlope(int16_t aSlope) { slope_ = aSlope; } + + void setBx(int16_t aBx) { bx_ = aBx; } + void setSubbx(int16_t aSubbx) { subbx_ = aSubbx; } + + void setQuality(int16_t aQuality) { quality_ = aQuality; } + void setPattern(int16_t aPattern) { pattern_ = aPattern; } + + void setGlobPhi(float aGlobPhi) { glob_phi_ = aGlobPhi; } + void setGlobTheta(float aGlobTheta) { glob_theta_ = aGlobTheta; } + void setGlobPerp(float aGlobPerp) { glob_perp_ = aGlobPerp; } + void setGlobZ(float aGlobZ) { glob_z_ = aGlobZ; } + void setGlobTime(float aGlobTime) { glob_time_ = aGlobTime; } + + void setEmtfChamber(int16_t aEmtfChamber) { emtf_chamber_ = aEmtfChamber; } + void setEmtfSegment(int16_t aEmtfSegment) { emtf_segment_ = aEmtfSegment; } + void setEmtfPhi(int16_t aEmtfPhi) { emtf_phi_ = aEmtfPhi; } + void setEmtfBend(int16_t aEmtfBend) { emtf_bend_ = aEmtfBend; } + void setEmtfTheta1(int16_t aEmtfTheta1) { emtf_theta1_ = aEmtfTheta1; } + void setEmtfTheta2(int16_t aEmtfTheta2) { emtf_theta2_ = aEmtfTheta2; } + void setEmtfQual1(int16_t aEmtfQual1) { emtf_qual1_ = aEmtfQual1; } + void setEmtfQual2(int16_t aEmtfQual2) { emtf_qual2_ = aEmtfQual2; } + void setEmtfTime(int16_t aEmtfTime) { emtf_time_ = aEmtfTime; } + void setEmtfSite(int16_t aEmtfSite) { emtf_site_ = aEmtfSite; } + void setEmtfHost(int16_t aEmtfHost) { emtf_host_ = aEmtfHost; } + void setEmtfZones(int16_t aEmtfZones) { emtf_zones_ = aEmtfZones; } + void setEmtfTimezones(int16_t aEmtfTimezones) { emtf_timezones_ = aEmtfTimezones; } + + void setFlagNeighbor(bool aNeighbor) { flag_neighbor_ = aNeighbor; } + void setFlagSubstitute(bool aSubstitute) { flag_substitute_ = aSubstitute; } + void setFlagValid(bool aValid) { flag_valid_ = aValid; } + + // Getters + uint16_t id() const { return id_; } + + uint32_t rawDetId() const { return raw_det_id_; } + int16_t subsystem() const { return subsystem_; } + int16_t endcap() const { return endcap_; } + int16_t sector() const { return sector_; } + int16_t subsector() const { return subsector_; } + int16_t station() const { return station_; } + int16_t ring() const { return ring_; } + int16_t roll() const { return roll_; } + int16_t layer() const { return layer_; } + int16_t chamber() const { return chamber_; } + + int16_t cscId() const { return csc_id_; } + int16_t cscFR() const { return csc_fr_; } + + int16_t strip() const { return strip_; } + int16_t stripLo() const { return strip_lo_; } + int16_t stripHi() const { return strip_hi_; } + int16_t stripQuart() const { return strip_quart_; } // Run 3 + int16_t stripEighth() const { return strip_eighth_; } // Run 3 + int16_t stripQuartBit() const { return strip_quart_bit_; } // Run 3 + int16_t stripEighthBit() const { return strip_eighth_bit_; } // Run 3 + + int16_t wire1() const { return wire1_; } + int16_t wire2() const { return wire2_; } + + int16_t bend() const { return bend_; } + int16_t slope() const { return slope_; } + + int16_t bx() const { return bx_; } + int16_t subbx() const { return subbx_; } + + int16_t quality() const { return quality_; } + int16_t pattern() const { return pattern_; } + + float globPhi() const { return glob_phi_; } + float globTheta() const { return glob_theta_; } + float globPerp() const { return glob_perp_; } + float globZ() const { return glob_z_; } + float globTime() const { return glob_time_; } + + int16_t emtfChamber() const { return emtf_chamber_; } + int16_t emtfSegment() const { return emtf_segment_; } + int16_t emtfPhi() const { return emtf_phi_; } + int16_t emtfBend() const { return emtf_bend_; } + int16_t emtfTheta1() const { return emtf_theta1_; } + int16_t emtfTheta2() const { return emtf_theta2_; } + int16_t emtfQual1() const { return emtf_qual1_; } + int16_t emtfQual2() const { return emtf_qual2_; } + int16_t emtfTime() const { return emtf_time_; } + int16_t emtfSite() const { return emtf_site_; } + int16_t emtfHost() const { return emtf_host_; } + int16_t emtfZones() const { return emtf_zones_; } + int16_t emtfTimezones() const { return emtf_timezones_; } + + bool flagNeighbor() const { return flag_neighbor_; } + bool flagSubstitute() const { return flag_substitute_; } + bool flagValid() const { return flag_valid_; } + + private: + uint16_t id_; + + uint32_t raw_det_id_; + int16_t subsystem_; + int16_t endcap_; + int16_t sector_; + int16_t subsector_; + int16_t station_; + int16_t ring_; + int16_t roll_; + int16_t layer_; + int16_t chamber_; + + int16_t csc_id_; + int16_t csc_fr_; // front/rear + + int16_t strip_; + int16_t strip_lo_; + int16_t strip_hi_; + int16_t strip_quart_; + int16_t strip_eighth_; + int16_t strip_quart_bit_; + int16_t strip_eighth_bit_; + + int16_t wire1_; + int16_t wire2_; + + int16_t bend_; + int16_t slope_; + + int16_t bx_; + int16_t subbx_; + + int16_t quality_; + int16_t pattern_; + + float glob_phi_; + float glob_theta_; + float glob_perp_; + float glob_z_; + float glob_time_; + + int16_t emtf_chamber_; + int16_t emtf_segment_; + int16_t emtf_phi_; + int16_t emtf_bend_; + int16_t emtf_slope_; + int16_t emtf_theta1_; + int16_t emtf_theta2_; + int16_t emtf_qual1_; + int16_t emtf_qual2_; + int16_t emtf_time_; + int16_t emtf_site_; + int16_t emtf_host_; + int16_t emtf_zones_; + int16_t emtf_timezones_; + + bool flag_neighbor_; + bool flag_substitute_; + bool flag_valid_; + }; + + typedef std::vector EMTFHitCollection; + +} // namespace l1t:phase2 + +#endif // DataFormats_L1TMuonPhase2_EMTFHit_h not defined diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFInput.h b/DataFormats/L1TMuonPhase2/interface/EMTFInput.h new file mode 100644 index 0000000000000..0dc9c46fd66ee --- /dev/null +++ b/DataFormats/L1TMuonPhase2/interface/EMTFInput.h @@ -0,0 +1,57 @@ +#ifndef DataFormats_L1TMuonPhase2_EMTFInput_h +#define DataFormats_L1TMuonPhase2_EMTFInput_h + +#include +#include + +#include "DataFormats/L1TMuon/interface/L1TMuonSubsystems.h" + +namespace l1t::phase2 { + + class EMTFInput { + public: + typedef std::vector hits_t; + typedef std::vector segs_t; + + + EMTFInput(): + endcap_(0), + sector_(0), + bx_(0), + hits_{}, + segs_{} + { + // Do Nothing + } + + ~EMTFInput() { + // Do Nothing + } + + // Setters + void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } + void setSector(int16_t aSector) { sector_ = aSector; } + void setBx(int16_t aBx) { bx_ = aBx; } + void setHits(const hits_t& aHits) { hits_ = aHits; } + void setSegs(const segs_t& aSegs) { segs_ = aSegs; } + + // Getters + int16_t endcap() const { return endcap_; } + int16_t sector() const { return sector_; } + int16_t bx() const { return bx_; } + const hits_t& hits() const { return hits_; } + const segs_t& segs() const { return segs_; } + + private: + int16_t endcap_; + int16_t sector_; + int16_t bx_; + hits_t hits_; + segs_t segs_; + }; + + typedef std::vector EMTFInputCollection; + +} // namespace l1t::phase2 + +#endif // DataFormats_L1TMuonPhase2_EMTFInput_h not defined diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h b/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h new file mode 100644 index 0000000000000..4ad5557bdad50 --- /dev/null +++ b/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h @@ -0,0 +1,144 @@ +#ifndef DataFormats_L1TMuonPhase2_EMTFTrack_h +#define DataFormats_L1TMuonPhase2_EMTFTrack_h + +#include +#include +#include + +namespace l1t::phase2 { + + class EMTFTrack { + public: + typedef std::vector features_t; + typedef std::vector site_hits_t; + typedef std::vector site_segs_t; + typedef std::vector site_mask_t; + + EMTFTrack(): + endcap_(0), + sector_(0), + bx_(0), + unconstrained_(false), + valid_(false), + model_pt_address_(0), + model_dxy_address_(0), + model_pattern_(0), + model_qual_(0), + model_phi_(0), + model_eta_(0), + model_features_{}, + emtf_q_(0), + emtf_pt_(0), + emtf_d0_(0), + emtf_z0_(0), + emtf_beta_(0), + emtf_mode_v1_(0), + emtf_mode_v2_(0), + site_hits_{}, + site_segs_{}, + site_mask_{}, + site_rm_mask_{} + { + // Do Nothing + } + + ~EMTFTrack() { + // Do Nothing + } + + // Setters + void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } + void setSector(int16_t aSector) { sector_ = aSector; } + void setBx(int16_t aBx) { bx_ = aBx; } + void setUnconstrained(bool aUnconstrained) { unconstrained_ = aUnconstrained; } + void setValid(bool aValid) { valid_ = aValid; } + + void setModelPtAddress(int16_t aAddress) { model_pt_address_ = aAddress; } + void setModelRelsAddress(int16_t aAddress) { model_rels_address_ = aAddress; } + void setModelDxyAddress(int16_t aAddress) { model_dxy_address_ = aAddress; } + void setModelPattern(int16_t aModelPattern) { model_pattern_ = aModelPattern; } + void setModelQual(int16_t aModelQual) { model_qual_ = aModelQual; } + void setModelPhi(int32_t aModelPhi) { model_phi_ = aModelPhi; } + void setModelEta(int32_t aModelEta) { model_eta_ = aModelEta; } + void setModelFeatures(const features_t& aModelFeatures) { model_features_ = aModelFeatures; } + + void setEmtfQ(int16_t aEmtfQ) { emtf_q_ = aEmtfQ; } + void setEmtfPt(int32_t aEmtfPt) { emtf_pt_ = aEmtfPt; } + void setEmtfRels(int32_t aEmtfRels) { emtf_rels_ = aEmtfRels; } + void setEmtfD0(int32_t aEmtfD0) { emtf_d0_ = aEmtfD0; } + void setEmtfZ0(int32_t aEmtfZ0) { emtf_z0_ = aEmtfZ0; } + void setEmtfBeta(int32_t aEmtfBeta) { emtf_beta_ = aEmtfBeta; } + void setEmtfModeV1(int16_t aEmtfModeV1) { emtf_mode_v1_ = aEmtfModeV1; } + void setEmtfModeV2(int16_t aEmtfModeV2) { emtf_mode_v2_ = aEmtfModeV2; } + + void setSiteHits(const site_hits_t& aSiteHits) { site_hits_ = aSiteHits; } + void setSiteSegs(const site_segs_t& aSiteSegs) { site_segs_ = aSiteSegs; } + void setSiteMask(const site_mask_t& aSiteMask) { site_mask_ = aSiteMask; } + void setSiteRMMask(const site_mask_t& aSiteMask) { site_rm_mask_ = aSiteMask; } + + // Getters + int16_t endcap() const { return endcap_; } + int16_t sector() const { return sector_; } + int16_t bx() const { return bx_; } + bool unconstrained() const { return unconstrained_; } + bool valid() const { return valid_; } + + int16_t modelPtAddress() const { return model_pt_address_; } + int16_t modelRelsAddress() const { return model_rels_address_; } + int16_t modelDxyAddress() const { return model_dxy_address_; } + int16_t modelPattern() const { return model_pattern_; } + int16_t modelQual() const { return model_qual_; } + int32_t modelPhi() const { return model_phi_; } + int32_t modelEta() const { return model_eta_; } + const features_t& modelFeatures() const { return model_features_; } + + int16_t emtfQ() const { return emtf_q_; } + int32_t emtfPt() const { return emtf_pt_; } + int32_t emtfRels() const { return emtf_rels_; } + int32_t emtfD0() const { return emtf_d0_; } + int32_t emtfZ0() const { return emtf_z0_; } + int32_t emtfBeta() const { return emtf_beta_; } + int16_t emtfModeV1() const { return emtf_mode_v1_; } + int16_t emtfModeV2() const { return emtf_mode_v2_; } + + const site_hits_t& siteHits() const { return site_hits_; } + const site_segs_t& siteSegs() const { return site_segs_; } + const site_mask_t& siteMask() const { return site_mask_; } + const site_mask_t& siteRMMask() const { return site_rm_mask_; } + + private: + int16_t endcap_; + int16_t sector_; + int16_t bx_; + bool unconstrained_; + bool valid_; + + int16_t model_pt_address_; + int16_t model_rels_address_; + int16_t model_dxy_address_; + int16_t model_pattern_; + int16_t model_qual_; + int32_t model_phi_; + int32_t model_eta_; + features_t model_features_; + + int16_t emtf_q_; + int32_t emtf_pt_; + int32_t emtf_rels_; + int32_t emtf_d0_; + int32_t emtf_z0_; + int32_t emtf_beta_; + int16_t emtf_mode_v1_; + int16_t emtf_mode_v2_; + + site_hits_t site_hits_; + site_segs_t site_segs_; + site_mask_t site_mask_; + site_mask_t site_rm_mask_; + }; + + typedef std::vector EMTFTrackCollection; + +} // namespace l1t::phase2 + +#endif // DataFormats_L1TMuonPhase2_EMTFTrack_h not defined diff --git a/DataFormats/L1TMuonPhase2/src/EMTFHit.cc b/DataFormats/L1TMuonPhase2/src/EMTFHit.cc new file mode 100644 index 0000000000000..6ffe9c26d7a19 --- /dev/null +++ b/DataFormats/L1TMuonPhase2/src/EMTFHit.cc @@ -0,0 +1,3 @@ +#include "DataFormats/L1TMuonPhase2/interface/EMTFHit.h" + +using namespace l1t::phase2; diff --git a/DataFormats/L1TMuonPhase2/src/EMTFInput.cc b/DataFormats/L1TMuonPhase2/src/EMTFInput.cc new file mode 100644 index 0000000000000..7ed9b912cb0fc --- /dev/null +++ b/DataFormats/L1TMuonPhase2/src/EMTFInput.cc @@ -0,0 +1,3 @@ +#include "DataFormats/L1TMuonPhase2/interface/EMTFInput.h" + +using namespace l1t::phase2; diff --git a/DataFormats/L1TMuonPhase2/src/EMTFTrack.cc b/DataFormats/L1TMuonPhase2/src/EMTFTrack.cc new file mode 100644 index 0000000000000..32447e69aac09 --- /dev/null +++ b/DataFormats/L1TMuonPhase2/src/EMTFTrack.cc @@ -0,0 +1,3 @@ +#include "DataFormats/L1TMuonPhase2/interface/EMTFTrack.h" + +using namespace l1t::phase2; diff --git a/DataFormats/L1TMuonPhase2/src/MuonStub.cc b/DataFormats/L1TMuonPhase2/src/MuonStub.cc index 779da226920b6..68bd8fe98775f 100644 --- a/DataFormats/L1TMuonPhase2/src/MuonStub.cc +++ b/DataFormats/L1TMuonPhase2/src/MuonStub.cc @@ -87,3 +87,4 @@ void MuonStub::print() const { << " quality=" << quality_ << " eta1=" << eta1_ << " eta2=" << eta2_ << " etaQuality=" << etaQuality_ << " type=" << type_; } + diff --git a/DataFormats/L1TMuonPhase2/src/SAMuon.cc b/DataFormats/L1TMuonPhase2/src/SAMuon.cc index b759b84ce1c45..7f91c3e7effd4 100644 --- a/DataFormats/L1TMuonPhase2/src/SAMuon.cc +++ b/DataFormats/L1TMuonPhase2/src/SAMuon.cc @@ -16,3 +16,4 @@ void SAMuon::print() const { << " z0=" << hwZ0_ << " d0=" << hwD0_ << " isolation=" << hwIso() << " beta=" << hwBeta_ << " quality=" << hwQual(); } + diff --git a/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc b/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc index 7beba2607bba5..93eea9887ba5d 100644 --- a/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc +++ b/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc @@ -1,4 +1,3 @@ - #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" using namespace l1t; @@ -26,3 +25,4 @@ void TrackerMuon::print() const { << " z0=" << hwZ0_ << " d0=" << hwD0_ << " isolation=" << hwIso() << " beta=" << hwBeta_ << " quality=" << hwQual(); } + diff --git a/DataFormats/L1TMuonPhase2/src/classes.h b/DataFormats/L1TMuonPhase2/src/classes.h index c970357cc3958..2c0dd2a390149 100644 --- a/DataFormats/L1TMuonPhase2/src/classes.h +++ b/DataFormats/L1TMuonPhase2/src/classes.h @@ -1,6 +1,12 @@ #include "DataFormats/Common/interface/Wrapper.h" #include "DataFormats/Common/interface/RefToBase.h" + #include "DataFormats/L1TMuonPhase2/interface/MuonStub.h" #include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h" #include "DataFormats/L1TMuonPhase2/interface/SAMuon.h" + +#include "DataFormats/L1TMuonPhase2/interface/EMTFHit.h" +#include "DataFormats/L1TMuonPhase2/interface/EMTFTrack.h" +#include "DataFormats/L1TMuonPhase2/interface/EMTFInput.h" + #include diff --git a/DataFormats/L1TMuonPhase2/src/classes_def.xml b/DataFormats/L1TMuonPhase2/src/classes_def.xml index b3cbf00fcf430..8a3aee143889e 100644 --- a/DataFormats/L1TMuonPhase2/src/classes_def.xml +++ b/DataFormats/L1TMuonPhase2/src/classes_def.xml @@ -1,27 +1,36 @@ - + + + + + + + - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml b/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml new file mode 100644 index 0000000000000..8bc523a4c4b2d --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h new file mode 100644 index 0000000000000..79ec8a7c559ee --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h @@ -0,0 +1,29 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_DuplicateRemovalLayer_h +#define L1Trigger_L1TMuonEndCapPhase2_DuplicateRemovalLayer_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2::algo { + + class DuplicateRemovalLayer { + public: + DuplicateRemovalLayer(const EMTFContext&); + + ~DuplicateRemovalLayer(); + + void apply( + std::vector& + ) const; + + private: + const EMTFContext& context_; + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_DuplicateRemovalLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h new file mode 100644 index 0000000000000..95c1844418209 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h @@ -0,0 +1,27 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_HitmapLayer_h +#define L1Trigger_L1TMuonEndCapPhase2_HitmapLayer_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" + +namespace emtf::phase2::algo { + + class HitmapLayer { + + public: + HitmapLayer(const EMTFContext&); + + ~HitmapLayer(); + + void apply( + const segment_collection_t&, + std::vector& + ) const; + + private: + const EMTFContext& context_; + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_HitmapLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h new file mode 100644 index 0000000000000..d28163e0fc631 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h @@ -0,0 +1,49 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_OutputLayer_h +#define L1Trigger_L1TMuonEndCapPhase2_OutputLayer_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2::algo { + + class OutputLayer { + public: + OutputLayer(const EMTFContext&); + + ~OutputLayer(); + + void apply( + const int&, const int&, const int&, + const std::map&, + const std::vector&, + const bool&, + EMTFTrackCollection& + ) const; + + private: + const EMTFContext& context_; + + std::array prompt_pt_calibration_lut_; + std::array disp_pt_calibration_lut_; + std::array disp_dxy_calibration_lut_; + + int find_prompt_emtf_pt(const int&) const; + + int find_disp_emtf_pt(const int&) const; + + int find_emtf_dxy(const int&) const; + + int find_emtf_pt_no_calib(const int&) const; + + int find_emtf_mode_v1(const track_t::site_mask_t&) const; + + int find_emtf_mode_v2(const track_t::site_mask_t&) const; + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_OutputLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h new file mode 100644 index 0000000000000..d83ec794e3ec6 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h @@ -0,0 +1,30 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_ParameterAssignment_h +#define L1Trigger_L1TMuonEndCapPhase2_ParameterAssignment_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2::algo { + + class ParameterAssignmentLayer { + public: + ParameterAssignmentLayer(const EMTFContext&); + + ~ParameterAssignmentLayer(); + + void apply( + const bool&, + std::vector& + ) const; + + private: + const EMTFContext& context_; + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_ParameterAssignment_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h new file mode 100644 index 0000000000000..864a5477ce21a --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h @@ -0,0 +1,32 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_PatternMatchingLayer_h +#define L1Trigger_L1TMuonEndCapPhase2_PatternMatchingLayer_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2::algo { + + class PatternMatchingLayer { + + public: + PatternMatchingLayer(const EMTFContext&); + + ~PatternMatchingLayer(); + + void apply( + const std::vector&, + const bool&, + std::vector& + ) const; + + private: + const EMTFContext& context_; + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_PatternMatchingLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h new file mode 100644 index 0000000000000..3ce2ac4623cf8 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h @@ -0,0 +1,30 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_RoadSortingLayer_h +#define L1Trigger_L1TMuonEndCapPhase2_RoadSortingLayer_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2::algo { + + class RoadSortingLayer { + public: + RoadSortingLayer(const EMTFContext&); + + ~RoadSortingLayer(); + + void apply( + const int&, + const std::vector&, + std::vector& + ) const; + private: + const EMTFContext& context_; + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_RoadSortingLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h new file mode 100644 index 0000000000000..3f8349957df08 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h @@ -0,0 +1,47 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TrackBuildingLayer_h +#define L1Trigger_L1TMuonEndCapPhase2_TrackBuildingLayer_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2::algo { + + class TrackBuildingLayer { + // Static + private: + static seg_theta_t calc_theta_median( + std::vector + ); + + // Members + public: + TrackBuildingLayer(const EMTFContext&); + + ~TrackBuildingLayer(); + + void apply( + const segment_collection_t&, + const std::vector&, + const bool&, + std::vector& + ) const; + + private: + const EMTFContext& context_; + + void attach_segments( + const segment_collection_t&, + const road_t&, + const bool&, + track_t& + ) const; + + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_TrackBuildingLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h new file mode 100644 index 0000000000000..4b64e7389e22c --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h @@ -0,0 +1,30 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_CSCTPCollector_h +#define L1Trigger_L1TMuonEndCapPhase2_CSCTPCollector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h" + +namespace emtf::phase2 { + + class CSCTPCollector: public TPCollector { + public: + explicit CSCTPCollector( + const EMTFContext&, + edm::ConsumesCollector&); + + ~CSCTPCollector(); + + void collect( + const edm::Event&, + BXTPCMap&) const final; + + private: + const EMTFContext& context_; + + const edm::EDGetToken input_token_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_CSCTPCollector_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h new file mode 100644 index 0000000000000..4fb31fa74c0da --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h @@ -0,0 +1,32 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_CSCTPConverter_h +#define L1Trigger_L1TMuonEndCapPhase2_CSCTPConverter_h + +#include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h" + +namespace emtf::phase2 { + + class CSCTPConverter: public TPConverter { + public: + explicit CSCTPConverter(const EMTFContext&, + const int&, const int&); + + ~CSCTPConverter(); + + void convert( + const TriggerPrimitive&, + const TPInfo&, + EMTFHit&) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + }; // namespace emtf::phase2 +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_CSCTPConverter_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h new file mode 100644 index 0000000000000..b6b6ad8d24e8e --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h @@ -0,0 +1,46 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_CSCTPSelector_h +#define L1Trigger_L1TMuonEndCapPhase2_CSCTPSelector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" + +// 18 in ME1; 9x3 in ME2,3,4; 9 from neighbor sector. +// Arranged in FW as 6 stations, 9 chambers per station. +#define NUM_CSC_CHAMBERS 6 * 9 + +namespace emtf::phase2 { + + class CSCTPSelector: public TPSelector { + public: + explicit CSCTPSelector( + const EMTFContext&, + const int&, const int& + ); + + ~CSCTPSelector(); + + void select( + const TriggerPrimitive&, + TPInfo, + ILinkTPCMap& + ) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + + int get_input_link(const TriggerPrimitive&, TPInfo&) const; + + int calculate_input_link( + const int&, const int&, + const int&, const int&, + const TPSelection& + ) const; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_CSCTPSelector_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h new file mode 100644 index 0000000000000..49b035172f177 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h @@ -0,0 +1,31 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_GE0TPCollector_h +#define L1Trigger_L1TMuonEndCapPhase2_GE0TPCollector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h" + +namespace emtf::phase2 { + + class GE0TPCollector: public TPCollector { + public: + explicit GE0TPCollector( + const EMTFContext&, + edm::ConsumesCollector&); + + ~GE0TPCollector(); + + void collect( + const edm::Event&, + BXTPCMap&) const final; + + private: + const EMTFContext& context_; + + const edm::EDGetToken input_token_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_GE0TPCollector_h + diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h new file mode 100644 index 0000000000000..c57c7b386048b --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h @@ -0,0 +1,32 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_GE0TPConverter_h +#define L1Trigger_L1TMuonEndCapPhase2_GE0TPConverter_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h" + +namespace emtf::phase2 { + + class GE0TPConverter: public TPConverter { + public: + explicit GE0TPConverter(const EMTFContext&, + const int&, const int&); + + ~GE0TPConverter(); + + void convert( + const TriggerPrimitive&, + const TPInfo&, + EMTFHit&) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_GE0TPConverter_h + diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h new file mode 100644 index 0000000000000..a8e6c0957f0fe --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h @@ -0,0 +1,45 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_GE0TPSelector_h +#define L1Trigger_L1TMuonEndCapPhase2_GE0TPSelector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" + +// 6 in GE1/1; 3 in GE2/1; 3 in GE0; 3 from neighbor sector. (unconfirmed!) +#define NUM_GEM_CHAMBERS 15 + +namespace emtf::phase2 { + + class GE0TPSelector: public TPSelector { + public: + explicit GE0TPSelector( + const EMTFContext&, + const int&, const int& + ); + + ~GE0TPSelector(); + + void select( + const TriggerPrimitive&, + TPInfo, + ILinkTPCMap& + ) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + + int get_input_link(const TriggerPrimitive&, TPInfo&) const; + + int calculate_input_link( + const int&, const int&, + const TPSelection& + ) const; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_GE0TPSelector_h + diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h new file mode 100644 index 0000000000000..e5363d5b70d04 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h @@ -0,0 +1,30 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_GEMTPCollector_h +#define L1Trigger_L1TMuonEndCapPhase2_GEMTPCollector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h" + +namespace emtf::phase2 { + + class GEMTPCollector: public TPCollector { + public: + explicit GEMTPCollector( + const EMTFContext&, + edm::ConsumesCollector&); + + ~GEMTPCollector(); + + void collect( + const edm::Event&, + BXTPCMap&) const final; + + private: + const EMTFContext& context_; + + const edm::EDGetToken input_token_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_GEMTPCollector_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h new file mode 100644 index 0000000000000..bb255c9075e6d --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h @@ -0,0 +1,31 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_GEMTPConverter_h +#define L1Trigger_L1TMuonEndCapPhase2_GEMTPConverter_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h" + +namespace emtf::phase2 { + + class GEMTPConverter: public TPConverter { + public: + explicit GEMTPConverter(const EMTFContext&, + const int&, const int&); + + ~GEMTPConverter(); + + void convert( + const TriggerPrimitive&, + const TPInfo&, + EMTFHit&) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_GEMTPConverter_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h new file mode 100644 index 0000000000000..b6f038eda20a1 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h @@ -0,0 +1,45 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_GEMTPSelector_h +#define L1Trigger_L1TMuonEndCapPhase2_GEMTPSelector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" + +// 6 in GE1/1; 3 in GE2/1; 3 in ME0; 3 from neighbor sector. (unconfirmed!) +#define NUM_GEM_CHAMBERS 15 + +namespace emtf::phase2 { + + class GEMTPSelector: public TPSelector { + public: + explicit GEMTPSelector( + const EMTFContext&, + const int&, const int& + ); + + ~GEMTPSelector(); + + void select( + const TriggerPrimitive&, + TPInfo, + ILinkTPCMap& + ) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + + int get_input_link(const TriggerPrimitive&, TPInfo&) const; + + int calculate_input_link( + const int&, const int&, + const int&, const int&, + const TPSelection& + ) const; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_GEMTPSelector_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h new file mode 100644 index 0000000000000..2603419eda751 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h @@ -0,0 +1,30 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_ME0TPCollector_h +#define L1Trigger_L1TMuonEndCapPhase2_ME0TPCollector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h" + +namespace emtf::phase2 { + + class ME0TPCollector: public TPCollector { + public: + explicit ME0TPCollector( + const EMTFContext&, + edm::ConsumesCollector&); + + ~ME0TPCollector(); + + void collect( + const edm::Event&, + BXTPCMap&) const final; + + private: + const EMTFContext& context_; + + const edm::EDGetToken input_token_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_ME0TPCollector_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h new file mode 100644 index 0000000000000..7ef59311d3f59 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h @@ -0,0 +1,31 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_ME0TPConverter_h +#define L1Trigger_L1TMuonEndCapPhase2_ME0TPConverter_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h" + +namespace emtf::phase2 { + + class ME0TPConverter: public TPConverter { + public: + explicit ME0TPConverter(const EMTFContext&, + const int&, const int&); + + ~ME0TPConverter(); + + void convert( + const TriggerPrimitive&, + const TPInfo&, + EMTFHit&) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_ME0TPConverter_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h new file mode 100644 index 0000000000000..764f81d7f75fe --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h @@ -0,0 +1,44 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_ME0TPSelector_h +#define L1Trigger_L1TMuonEndCapPhase2_ME0TPSelector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" + +// 6 in GE1/1; 3 in GE2/1; 3 in ME0; 3 from neighbor sector. (unconfirmed!) +#define NUM_GEM_CHAMBERS 15 + +namespace emtf::phase2 { + + class ME0TPSelector: public TPSelector { + public: + explicit ME0TPSelector( + const EMTFContext&, + const int&, const int& + ); + + ~ME0TPSelector(); + + void select( + const TriggerPrimitive&, + TPInfo, + ILinkTPCMap& + ) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + + int get_input_link(const TriggerPrimitive&, TPInfo&) const; + + int calculate_input_link( + const int&, const int&, + const TPSelection& + ) const; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_ME0TPSelector_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h new file mode 100644 index 0000000000000..2288d360cd63e --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h @@ -0,0 +1,30 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_RPCTPCollector_h +#define L1Trigger_L1TMuonEndCapPhase2_RPCTPCollector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h" + +namespace emtf::phase2 { + + class RPCTPCollector: public TPCollector { + public: + explicit RPCTPCollector( + const EMTFContext&, + edm::ConsumesCollector&); + + ~RPCTPCollector(); + + void collect( + const edm::Event&, + BXTPCMap&) const final; + + private: + const EMTFContext& context_; + + const edm::EDGetToken input_token_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_RPCTPCollector_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h new file mode 100644 index 0000000000000..3f9060fd10bb4 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h @@ -0,0 +1,31 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_RPCTPConverter_h +#define L1Trigger_L1TMuonEndCapPhase2_RPCTPConverter_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h" + +namespace emtf::phase2 { + + class RPCTPConverter: public TPConverter { + public: + explicit RPCTPConverter(const EMTFContext&, + const int&, const int&); + + ~RPCTPConverter(); + + void convert( + const TriggerPrimitive&, + const TPInfo&, + EMTFHit&) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_RPCTPConverter_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h new file mode 100644 index 0000000000000..33c2cbf640296 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h @@ -0,0 +1,47 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_RPCTPSelector_h +#define L1Trigger_L1TMuonEndCapPhase2_RPCTPSelector_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h" + +// 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 + +namespace emtf::phase2 { + + class RPCTPSelector: public TPSelector { + public: + explicit RPCTPSelector( + const EMTFContext&, + const int&, const int& + ); + + ~RPCTPSelector(); + + void select( + const TriggerPrimitive&, + TPInfo, + ILinkTPCMap& + ) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + + int get_input_link(const TriggerPrimitive&, TPInfo&) const; + + int calculate_input_link( + const int&, const int&, + const int&, const int&, + const TPSelection& + ) const; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_RPCTPSelector_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h new file mode 100644 index 0000000000000..580484143ab86 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h @@ -0,0 +1,97 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_SubsystemTags_h +#define L1Trigger_L1TMuonEndCapPhase2_SubsystemTags_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 "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" +#include "DataFormats/GEMDigi/interface/ME0TriggerDigi.h" +#include "DataFormats/GEMDigi/interface/ME0TriggerDigiCollection.h" + +// Forward declarations +class CSCGeometry; +class RPCGeometry; +class GEMGeometry; +class ME0Geometry; + +namespace emtf::phase2 { + + struct DTTag { + typedef L1MuDTChambPhDigi digi_type; + typedef L1MuDTChambPhContainer collection_type; + typedef L1MuDTChambThDigi theta_digi_type; + typedef L1MuDTChambThContainer theta_collection_type; + }; + + struct CSCTag { + typedef CSCDetId detid_type; + typedef CSCCorrelatedLCTDigi digi_type; + typedef CSCCorrelatedLCTDigiCollection collection_type; + typedef CSCComparatorDigi comparator_digi_type; + typedef CSCComparatorDigiCollection comparator_collection_type; + typedef CSCGeometry detgeom_type; + }; + + struct RPCTag { + typedef RPCDetId detid_type; + typedef RPCDigi digi_type; + typedef RPCDigiCollection collection_type; + typedef RPCRecHit rechit_type; + typedef RPCRecHitCollection rechit_collection_type; + typedef RPCGeometry detgeom_type; + }; + + struct IRPCTag { + typedef RPCDetId detid_type; + typedef RPCDigi digi_type; + typedef RPCDigiCollection collection_type; + typedef RPCRecHit rechit_type; + typedef RPCRecHitCollection rechit_collection_type; + typedef RPCGeometry detgeom_type; + }; + + struct CPPFTag { + typedef l1t::CPPFDigi digi_type; + typedef l1t::CPPFDigiCollection collection_type; + }; + + struct GEMTag { + typedef GEMDetId detid_type; + typedef GEMPadDigiCluster digi_type; + typedef GEMPadDigiClusterCollection collection_type; + typedef GEMGeometry detgeom_type; + }; + + struct ME0Tag { + typedef ME0DetId detid_type; + typedef ME0TriggerDigi digi_type; + typedef ME0TriggerDigiCollection collection_type; + typedef ME0Geometry detgeom_type; + }; + + struct GE0Tag { + typedef GEMDetId detid_type; + typedef ME0TriggerDigi digi_type; + typedef GE0TriggerDigiCollection collection_type; + typedef GEMGeometry detgeom_type; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_SubsystemTags_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h new file mode 100644 index 0000000000000..4da8ce0513997 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h @@ -0,0 +1,23 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TPCollectors_h +#define L1Trigger_L1TMuonEndCapPhase2_TPCollectors_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" + +namespace emtf::phase2 { + + class TPCollector { + public: + TPCollector() = default; + + virtual ~TPCollector() = default; + + // Collects all the trigger primitives in the event + virtual void collect( + const edm::Event&, + BXTPCMap&) const = 0; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_TPCollectors_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h new file mode 100644 index 0000000000000..500473bee38fe --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h @@ -0,0 +1,24 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TPConverters_h +#define L1Trigger_L1TMuonEndCapPhase2_TPConverters_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" + +namespace emtf::phase2 { + + class TPConverter { + public: + TPConverter() = default; + + virtual ~TPConverter() = default; + + virtual void convert( + const TriggerPrimitive&, + const TPInfo&, + EMTFHit&) const = 0; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_TPConverters_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h new file mode 100644 index 0000000000000..06ce817e11b52 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h @@ -0,0 +1,24 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TPSelectors_h +#define L1Trigger_L1TMuonEndCapPhase2_TPSelectors_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" + +namespace emtf::phase2 { + + class TPSelector { + public: + TPSelector() = default; + + virtual ~TPSelector() = default; + + virtual void select( + const TriggerPrimitive& tp, + TPInfo tp_info, + ILinkTPCMap& + ) const = 0; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_TPSelectors_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h new file mode 100644 index 0000000000000..013b74d2e451d --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h @@ -0,0 +1,67 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TPrimitives_h +#define L1Trigger_L1TMuonEndCapPhase2_TPrimitives_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h" + +namespace emtf::phase2 { + + enum TPSelection {kNative, kNeighbor, kNone}; + + struct TPInfo { + // Id + int hit_id = -1; + int segment_id = -1; + + // Selection + int bx = -999; + int ilink = -1; + TPSelection selection = kNone; + + // Flags + bool flag_substitute = false; + + // Detector + int endcap = 0; + int endcap_pm = 0; + int sector = 0; + int subsector = 0; + int station = 0; + int ring = 0; + int roll = 0; + int layer = 0; + int chamber = 0; + + // CSC + int csc_id = -1; + csc::Facing csc_facing = csc::Facing::kNone; + int csc_first_wire = -1; + int csc_second_wire = -1; + + // RPC + rpc::Type rpc_type = rpc::kNone; + }; + + class TPEntry { + + public: + TPEntry(const TPEntry&); + TPEntry(const TriggerPrimitive&); + TPEntry(const TriggerPrimitive&, const TPInfo&); + TPEntry(const CSCDetId&, const CSCCorrelatedLCTDigi&); + TPEntry(const RPCDetId&, const RPCRecHit&); + TPEntry(const GEMDetId&, const GEMPadDigiCluster&); + TPEntry(const ME0DetId&, const ME0TriggerDigi&); + TPEntry(const GEMDetId&, const ME0TriggerDigi&); + + ~TPEntry(); + + TriggerPrimitive tp_; + TPInfo info_; + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_TPrimitives_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h new file mode 100644 index 0000000000000..c778ca1fd4cea --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h @@ -0,0 +1,38 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_ActivationLut_h +#define L1Trigger_L1TMuonEndCapPhase2_ActivationLut_h + +#include + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" + +namespace emtf::phase2::data { + + class ActivationLut { + public: + ActivationLut(); + + ~ActivationLut(); + + void update( + const edm::Event&, + const edm::EventSetup&); + + const trk_pt_t& lookup_prompt_pt(const trk_nn_address_t&) const; + const trk_pt_t& lookup_disp_pt(const trk_nn_address_t&) const; + const trk_rels_t& lookup_rels(const trk_nn_address_t&) const; + const trk_dxy_t& lookup_dxy(const trk_nn_address_t&) const; + + private: + std::vector prompt_pt_lut_; + std::vector disp_pt_lut_; + std::vector rels_lut_; + std::vector dxy_lut_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_ActivationLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h new file mode 100644 index 0000000000000..004c953a98bc0 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h @@ -0,0 +1,37 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_HostLut_h +#define L1Trigger_L1TMuonEndCapPhase2_HostLut_h + +#include +#include + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" + +namespace emtf::phase2::data { + + class HostLut { + // Static + public: + static const int kInvalid; + + // Member + public: + HostLut(); + + ~HostLut(); + + void update( + const edm::Event&, + const edm::EventSetup&); + + const int& lookup(const std::tuple&) const; + + private: + // Key: Subsystem, Station, Ring + // Value: Host + std::map, int> lut_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_HostLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h new file mode 100644 index 0000000000000..9cbe150b57eb6 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h @@ -0,0 +1,38 @@ + +#ifndef L1Trigger_L1TMuonEndCapPhase2_SiteLut_h +#define L1Trigger_L1TMuonEndCapPhase2_SiteLut_h + +#include +#include + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" + +namespace emtf::phase2::data { + + class SiteLut { + // Static + public: + static const int kInvalid; + + // Member + public: + SiteLut(); + + ~SiteLut(); + + void update( + const edm::Event&, + const edm::EventSetup&); + + const int& lookup(const std::tuple&) const; + + private: + // Key: Subsystem, Station, Ring + // Value: Site + std::map, int> lut_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_SiteLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h new file mode 100644 index 0000000000000..c2a03e06a6f00 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h @@ -0,0 +1,37 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TimeZoneLut_h +#define L1Trigger_L1TMuonEndCapPhase2_TimeZoneLut_h + +#include +#include + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" + +namespace emtf::phase2::data { + + class TimeZoneLut { + // Static + public: + bool in_range(const std::pair&, const int&) const; + + // Member + public: + TimeZoneLut(); + + ~TimeZoneLut(); + + void update( + const edm::Event&, + const edm::EventSetup&); + + int get_timezones(const int&, const int&) const; + + private: + // Key: Host + // Value: BX Range + std::map> lut_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_TimeZoneLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h new file mode 100644 index 0000000000000..e94a611d0367e --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h @@ -0,0 +1,55 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_ZoneLut_h +#define L1Trigger_L1TMuonEndCapPhase2_ZoneLut_h + +#include +#include + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" + +namespace emtf::phase2::data { + + // Forward declarations + class Zone; + + // Classes + class ZoneLut { + + public: + ZoneLut(); + + ~ZoneLut(); + + void update( + const edm::Event&, + const edm::EventSetup&); + + int get_zones(const int&, const int&) const; + + int get_zones(const int&, const int&, const int&) const; + + private: + std::vector zones_; + }; + + class Zone { + friend ZoneLut; + + public: + Zone() = default; + + ~Zone() = default; + + bool contains(const int&, const int&) const; + + bool contains(const int&, const int&, const int&) const; + + private: + // Key: Host + // Value: Theta Range + std::map> lut_; + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_ZoneLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h new file mode 100644 index 0000000000000..1111835bb138c --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h @@ -0,0 +1,53 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFConfiguration_h +#define L1Trigger_L1TMuonEndCapPhase2_EMTFConfiguration_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" + +namespace emtf::phase2 { + + // Class + class EMTFConfiguration { + + public: + EMTFConfiguration(const edm::ParameterSet&); + + ~EMTFConfiguration(); + + // Event configuration + void update( + const edm::Event&, + const edm::EventSetup&); + + // Config + int verbosity_; + + // Validation + std::string validation_dir_; + + // Neural Network + std::string prompt_graph_path_; + std::string displ_graph_path_; + + // Trigger + int min_bx_; + int max_bx_; + int bx_window_; + + // Subsystems + bool csc_en_; + bool rpc_en_; + bool gem_en_; + bool me0_en_; + bool ge0_en_; + + int csc_bx_shift_; + int rpc_bx_shift_; + int gem_bx_shift_; + int me0_bx_shift_; + + // Primitive Selectoin + bool include_neighbor_en_; + }; +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_EMTFConfiguration_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h new file mode 100644 index 0000000000000..9a7245e4d20f7 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h @@ -0,0 +1,62 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFConstants_h +#define L1Trigger_L1TMuonEndCapPhase2_EMTFConstants_h + +namespace emtf::phase2 { + // from DataFormats/MuonDetId/interface/CSCDetId.h + constexpr int kMinEndcap = 1; + constexpr int kMaxEndcap = 2; + constexpr int kMinStation = 1; + constexpr int kMaxStation = 4; + constexpr int kMinRing = 1; + constexpr int kMaxRing = 4; + constexpr int kMinChamber = 1; + constexpr int kMaxChamber = 36; + constexpr int kMinLayer = 1; + constexpr int kMaxLayer = 6; + + // from DataFormats/MuonDetId/interface/CSCTriggerNumbering.h + constexpr int kMinCSCId = 1; + constexpr int kMaxCSCId = 9; + constexpr int kMinTrigSector = 1; + constexpr int kMaxTrigSector = 6; + constexpr int kNumTrigSector = 12; + constexpr int kMinTrigSubsector = 0; + constexpr int kMaxTrigSubsector = 2; + + // Algorithm + namespace v3 { + constexpr int kNumChambers = 115; // per sector + constexpr int kChamberSegments = 2; // per chamber + constexpr int kNumSegments = kNumChambers * kChamberSegments; + constexpr int kNumSegmentVariables = 13; // per segment + + constexpr int kNumZones = 3; // per sector + constexpr int kNumZonePatterns = 7; // per zone + + constexpr int kNumTimeZones = 3; // per sector + + constexpr int kNumTracks = 4; // per sector + constexpr int kNumTrackVariables = 54; // per track + constexpr int kNumTrackFeatures = 40; // per track + constexpr int kNumTrackPredictions = 1; // per track + constexpr int kNumTrackSites = 12; // per track + constexpr int kNumTrackSitesRM = 5; // per track + + constexpr int kChamberHitmapBW = 90; // 24 deg + constexpr int kChamberHitmapJoinedBW = 315; // 84 deg + constexpr int kHitmapNRows = 8; + constexpr int kHitmapNCols = 288; + constexpr int kHitmapNGates = 3; + constexpr int kHitmapColFactor = 16; + constexpr int kHitmapColFactorLog2 = 4; // (1 << 4) = 16 + constexpr int kHitmapCropColStart = kChamberHitmapJoinedBW - kHitmapNCols; // 27 (Inclusive) + constexpr int kHitmapCropColStop = kChamberHitmapJoinedBW; // 315 (Exclusive) + + constexpr int kPatternNCols = 110; + constexpr int kPatternMatchingPadding = 55; + constexpr int kMaxPatternActivation = 63; + constexpr int kMaxPatternActivationLog2 = 6; // (1 << 6) - 1 = 63 + } +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_EMTFConstants_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h new file mode 100644 index 0000000000000..ea55b7a1b33a5 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h @@ -0,0 +1,84 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFContext_h +#define L1Trigger_L1TMuonEndCapPhase2_EMTFContext_h + +#include "PhysicsTools/TensorFlow/interface/TensorFlow.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h" + +#define PSET this->context_.pset_ +#define CONFIG this->context_.config_ +#define GEOM this->context_.geometry_translator_ +// #define EMTF_PSET this->context_.pset_ +// #define EMTF_CONFIG this->context_.config_ +// #define EMTF_GEOM this->context_.geometry_translator_ + +namespace emtf::phase2 { + + // Class + class EMTFContext { + + public: + EMTFContext( + const edm::ParameterSet&, + edm::ConsumesCollector); + + ~EMTFContext(); + + // Event configuration + void update( + const edm::Event&, + const edm::EventSetup&); + + // Parameter Set + const edm::ParameterSet& pset_; + + // Helpers + GeometryTranslator geometry_translator_; + + // EMTF + EMTFConfiguration config_; + EMTFModel model_; + + // Prompt Neural Network + tensorflow::GraphDef* prompt_graph_ptr_; + tensorflow::Session* prompt_session_ptr_; + + // Displaced Neural Network + tensorflow::GraphDef* disp_graph_ptr_; + tensorflow::Session* disp_session_ptr_; + + // Data + data::SiteLut site_lut_; + data::HostLut host_lut_; + data::ZoneLut zone_lut_; + data::TimeZoneLut timezone_lut_; + data::ActivationLut activation_lut_; + + // Algorithm + algo::HitmapLayer hitmap_building_layer_; + algo::PatternMatchingLayer pattern_matching_layer_; + algo::RoadSortingLayer road_sorting_layer_; + algo::TrackBuildingLayer track_building_layer_; + algo::DuplicateRemovalLayer duplicate_removal_layer_; + algo::ParameterAssignmentLayer parameter_assignment_layer_; + algo::OutputLayer output_layer_; + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_EMTFContext_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFLogger.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFLogger.h new file mode 100644 index 0000000000000..eafe059c160b8 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFLogger.h @@ -0,0 +1,36 @@ + +#ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFLoggger +#define L1Trigger_L1TMuonEndCapPhase2_EMTFLoggger + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" + +namespace emtf::phase2 { + + class EMTFLoggger { + public: + EMTFLoggger(const EMTFContext&); + + ~EMTFLoggger(); + + // Sections + void print_section_header(const std:string&); + + void print_section_footer(const std:string&); + + void print_subsection_header(const std:string&); + + void print_subsection_footer(const std:string&); + + // Data + void print_segment(const int& lvl, const segment_t&); + void print_track(const int& lvl, const track_t&); + void print_track_features(const int& lvl, const track_t::features_t&); + + private: + const EMTFContext& context_; + + }; +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_EMTFLoggger diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h new file mode 100644 index 0000000000000..62607b01728b0 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h @@ -0,0 +1,126 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFModel_h +#define L1Trigger_L1TMuonEndCapPhase2_EMTFModel_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2 { + + // Forward Declarations + namespace model { + namespace zones { + namespace hitmap { + struct chamber_t; + struct site_t; + typedef std::vector row_t; + } + + namespace pattern { + struct row_t; + } + + typedef std::vector hitmap_t; + typedef std::vector pattern_t; + typedef std::vector quality_lut_t; + } + + namespace theta_medians { + struct site_t; + typedef std::vector group_t; + } + + namespace reduced_sites { + struct reduced_site_t; + } + + struct zone_t; + struct feature_t; + + typedef std::vector theta_median_t; + typedef std::vector reduced_sites_t; + } + + // Definitions + class EMTFModel { + + public: + EMTFModel(const EMTFContext&); + + ~EMTFModel(); + + std::vector zones_; + std::vector features_; + std::vector theta_medians_; + model::reduced_sites_t reduced_sites_; + + private: + const EMTFContext& context_; + + }; + + namespace model { + // Define Zone Structs + struct zone_t { + zones::hitmap_t hitmap; + + // Prompt + std::vector prompt_patterns; + zones::quality_lut_t prompt_quality_lut; + + // Displaced + std::vector disp_patterns; + zones::quality_lut_t disp_quality_lut; + }; + + namespace zones { + namespace hitmap { + struct site_t { + site_id_t id; + std::vector chambers; + }; + + struct chamber_t { + unsigned int id; + unsigned int begin; + unsigned int end; + }; + } + + namespace pattern { + struct row_t { + unsigned int begin; + unsigned int center; + unsigned int end; + }; + } + } + + // Define Feature Structs + struct feature_t { + feature_id_t id; + std::vector sites; + }; + + // Define Theta Median Structs + namespace theta_medians { + struct site_t { + site_id_t id; + theta_id_t theta_id; + }; + } + + // Define Reduced Site Structs + namespace reduced_sites { + struct reduced_site_t { + reduced_site_id_t id; + std::vector trk_sites; + }; + } + } +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_EMTFModel_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h new file mode 100644 index 0000000000000..15eb95d8730f9 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h @@ -0,0 +1,178 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFTypes_h +#define L1Trigger_L1TMuonEndCapPhase2_EMTFTypes_h + +#include +#include + +#include "ap_int.h" +#include "ap_fixed.h" +#include "DataFormats/L1TMuonPhase2/interface/EMTFHit.h" +#include "DataFormats/L1TMuonPhase2/interface/EMTFTrack.h" +#include "DataFormats/L1TMuonPhase2/interface/EMTFInput.h" +#include "L1Trigger/L1TMuon/interface/GeometryTranslator.h" +#include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2 { + + // Trigger Primitives + typedef L1TMuon::TriggerPrimitive TriggerPrimitive; + typedef std::vector TPCollection; + typedef std::map BXTPCMap; + typedef std::map ILinkTPCMap; + + // Hits + typedef l1t::phase2::EMTFHit EMTFHit; + typedef l1t::phase2::EMTFHitCollection EMTFHitCollection; + + // Tracks + typedef l1t::phase2::EMTFTrack EMTFTrack; + typedef l1t::phase2::EMTFTrackCollection EMTFTrackCollection; + + // Inputs + typedef l1t::phase2::EMTFInput EMTFInput; + typedef l1t::phase2::EMTFInputCollection EMTFInputCollection; + + // General + typedef ap_uint<1> flag_t; + + // Segments + enum class site_id_t { + kME11 = 0, kME12 = 1 , kME2 = 2 , kME3 = 3, kME4 = 4, + kRE1 = 5, kRE2 = 6 , kRE3 = 7 , kRE4 = 8, + kGE11 = 9, kGE21 = 10, kME0 = 11, + size, begin = 0, end=size + }; + + enum class feature_id_t { + kPhi = 0, kTheta = 1 , kBend = 2 , kQuality = 3, kTime = 4, + size, begin = 0, end=size + }; + + enum class theta_id_t { + kTheta1 = 0, kTheta2 = 1, + size, begin = 0, end=size + }; + + enum class reduced_site_id_t { + kME1 = 0, kME2 = 1, + kME3 = 2, kME4 = 3, + kME0 = 4, + size, begin = 0, end=size + }; + + typedef ap_uint <13> seg_phi_t ; + typedef ap_int <10> seg_bend_t ; + typedef ap_uint <8 > seg_theta_t ; + typedef ap_uint <4 > seg_qual_t ; + typedef ap_int <4 > seg_time_t ; + typedef ap_uint <3 > seg_zones_t ; + typedef ap_uint <3 > seg_tzones_t; + typedef ap_uint <1 > seg_cscfr_t ; + typedef ap_uint <1 > seg_layer_t ; + typedef ap_int <2 > seg_bx_t ; + typedef ap_uint <1 > seg_valid_t ; + + struct segment_t { + seg_phi_t phi ; + seg_bend_t bend ; + seg_theta_t theta1; + seg_theta_t theta2; + seg_qual_t qual1 ; + seg_qual_t qual2 ; + seg_time_t time ; + seg_zones_t zones ; + seg_tzones_t tzones; + seg_cscfr_t cscfr ; + seg_layer_t layer ; + seg_bx_t bx ; + seg_valid_t valid ; + }; + + typedef std::array segment_collection_t; + + // Tracks + typedef ap_uint <2 > trk_zone_t ; + typedef ap_uint <2 > trk_tzone_t ; + typedef ap_uint <9 > trk_col_t ; + typedef ap_uint <3 > trk_patt_t ; + typedef ap_uint <6 > trk_qual_t ; + typedef ap_uint <2 > trk_gate_t ; + typedef ap_uint <1 > trk_q_t ; + typedef ap_uint <13> trk_pt_t ; + typedef ap_uint <7 > trk_rels_t ; + typedef ap_int <7 > trk_dxy_t ; + typedef ap_int <5 > trk_z0_t ; + typedef ap_int <13> trk_phi_t ; + typedef ap_int <13> trk_eta_t ; + typedef ap_uint <4 > trk_beta_t ; + typedef ap_uint <1 > trk_valid_t ; + typedef ap_uint <8 > trk_site_seg_t ; + typedef ap_uint <1 > trk_site_bit_t ; + typedef ap_int <13> trk_feature_t ; + typedef ap_int <10> trk_nn_address_t; + + struct track_t { + typedef std::array site_segs_t; + typedef std::array site_mask_t; + typedef std::array features_t; + + trk_zone_t zone ; + trk_col_t col ; + trk_patt_t pattern ; + trk_qual_t quality ; + trk_q_t q ; + trk_pt_t pt ; + trk_rels_t rels ; + trk_dxy_t dxy ; + trk_z0_t z0 ; + seg_phi_t phi ; + seg_theta_t theta ; + trk_eta_t eta ; + trk_beta_t beta ; + trk_valid_t valid ; + site_segs_t site_segs ; + site_mask_t site_mask ; + site_mask_t site_rm_mask ; + features_t features ; + trk_nn_address_t pt_address ; + trk_nn_address_t rels_address; + trk_nn_address_t dxy_address ; + }; + + // Hitmaps + typedef ap_uint hitmap_row_t; + typedef std::array hitmap_t; + + // Roads + struct road_t { + trk_zone_t zone ; + trk_col_t col ; + trk_patt_t pattern; + trk_qual_t quality; + }; + + typedef std::array road_collection_t; + + // Reduced Track + struct reduced_track_t { + typedef std::array site_segs_t; + typedef std::array site_mask_t; + + trk_valid_t valid; + site_segs_t site_segs; + site_mask_t site_mask; + }; +} + +typedef L1TMuon::subsystem_type SubsystemType; +typedef L1TMuon::GeometryTranslator GeometryTranslator; + +typedef L1TMuon::TriggerPrimitive::DTData DTData; +typedef L1TMuon::TriggerPrimitive::CSCData CSCData; +typedef L1TMuon::TriggerPrimitive::RPCData RPCData; +typedef L1TMuon::TriggerPrimitive::GEMData GEMData; +typedef L1TMuon::TriggerPrimitive::ME0Data ME0Data; + +#endif // L1Trigger_L1TMuonEndCapPhase2_EMTFTypes_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h new file mode 100644 index 0000000000000..a9fbbf4647723 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h @@ -0,0 +1,31 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFfwd_h +#define L1Trigger_L1TMuonEndCapPhase2_EMTFfwd_h + +#include "FWCore/Framework/interface/Frameworkfwd.h" + +#include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h" + +namespace emtf::phase2 { + class EMTFContext; + class EMTFConfiguration; + class EMTFModel; + + struct TPInfo; + class TPEntry; + class TrackFinder; + class SectorProcessor; + class TPCollector; + class CSCTPCollector; + class RPCTPCollector; + class GEMTPCollector; + class ME0TPCollector; + class TPSelector; + class CSCTPSelector; + class RPCTPSelector; + class GEMTPSelector; + class ME0TPSelector; + class TPConverter; +} + +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_EMTFfwd_h + diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h b/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h new file mode 100644 index 0000000000000..3f449d9cdbffe --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h @@ -0,0 +1,72 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_SectorProcessor_h +#define L1Trigger_L1TMuonEndCapPhase2_SectorProcessor_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" + +namespace emtf::phase2 { + + class SectorProcessor { + public: + SectorProcessor( + const EMTFContext&, + const int&, const int&); + + ~SectorProcessor(); + + void configure_event(const edm::Event&); + + void configure_bx(const int&); + + void select( + const TriggerPrimitive&, + const TPInfo& + ); + + void process( + EMTFHitCollection&, + EMTFTrackCollection&, + EMTFInputCollection& + ); + + private: + const EMTFContext& context_; + + int endcap_, sector_; + std::map> tp_selectors_; + std::map> tp_converters_; + + // Event + const edm::Event* event_; + const int* bx_; + + // Buffers + std::vector bx_window_hits_; + std::map bx_ilink_tpc_maps_; + + // Helper functions + void copy_tp( + const ILinkTPCMap& source, + ILinkTPCMap& target) const; + + void convert_tp( + const int&, + const ILinkTPCMap&, + EMTFHitCollection&); + + void populate_segments( + const std::vector&, + std::map&, + segment_collection_t&); + + void build_tracks( + const std::map&, + const segment_collection_t&, + const bool&, + EMTFTrackCollection& + ); + }; + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_SectorProcessor_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h b/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h new file mode 100644 index 0000000000000..baf53be83d070 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h @@ -0,0 +1,41 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TrackFinder_h +#define L1Trigger_L1TMuonEndCapPhase2_TrackFinder_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" + +namespace emtf::phase2 { + + class TrackFinder { + public: + explicit TrackFinder( + const edm::ParameterSet&, + edm::ConsumesCollector&& + ); + + ~TrackFinder(); + + void process( + // Input + const edm::Event&, + const edm::EventSetup&, + // Output + EMTFHitCollection&, + EMTFTrackCollection&, + EMTFInputCollection& + ); + + void on_job_begin(); + + void on_job_end(); + + private: + EMTFContext context_; + + std::vector> tp_collectors_; + std::vector> sector_processors_; + }; +} + +#endif diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h new file mode 100644 index 0000000000000..7402e798f64ec --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h @@ -0,0 +1,44 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_CSCUtils_h +#define L1Trigger_L1TMuonEndCapPhase2_CSCUtils_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" + +namespace emtf::phase2::csc { + + // Enums + enum Facing {kFront, kRear, kNone}; + + // Chambers + int next_10deg_chamber(int chamber); + + int prev_10deg_chamber(int chamber); + + int next_20deg_chamber(int chamber); + + int prev_20deg_chamber(int chamber); + + // Functions + bool is_in_sector( + int match_endcap, int match_sector, + int tp_endcap, int tp_sector); + + bool is_in_neighbor_sector( + int match_endcap, int match_sector, + int tp_endcap, int tp_sector, int tp_subsector, + int tp_station, int tp_id); + + int get_id(int ring, int station, int chamber); + + int get_trigger_sector(int ring, int station, int chamber); + + int get_trigger_subsector(int station, int chamber); + + Facing get_face_direction(int station, int ring, int chamber); + + std::pair get_max_strip_and_wire(int station, int ring); + + std::pair get_max_pattern_and_quality(int station, int ring); + +} + +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_CSCUtils_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h new file mode 100644 index 0000000000000..c0ea0ae092c46 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h @@ -0,0 +1,187 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_DataUtils_h +#define L1Trigger_L1TMuonEndCapPhase2_DataUtils_h + +#include +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2::data { + + // Merge-Sort + template + void swap_wires( + T arr[], + const int& wire_1, const int& wire_2, + const C& comparator + ) { + + int result = comparator(arr[wire_1], arr[wire_2]); + + if (result == 1) { + auto temp = arr[wire_1]; + arr[wire_1] = arr[wire_2]; + arr[wire_2] = temp; + } + } + + template + void mergesort_block( + T arr[], + const int& offset, const int& step, + const int& block_begin, const int& block_end, + const int& first_n, + const C& comparator + ) { + int wire_offset = offset + block_begin; + int wire_cutoff = first_n + block_begin; + int wire_1 = wire_offset; + int wire_2 = wire_1 + step; + + // Loop pairs + while (wire_2 < block_end) { + // Trim results + if (first_n > 0 && wire_cutoff < block_end) { + bool wire_needed = (wire_offset <= wire_1) + && (wire_1 <= wire_cutoff); + + if (!wire_needed) { + break; + } + } + + // Swap Wires + swap_wires( + arr, + wire_1, wire_2, + comparator + ); + + // Calculate next wire_1 + if (step == 1) { + wire_1 = wire_2 + 1; + } else { + wire_1 = wire_1 + 1; + } + + // Calculate next wire_2 + wire_2 = wire_1 + step; + } + } + + template + void mergesort( + T arr[], + const int& arr_size, + const int& first_n, + const C& comparator + ) { + // Sort + int n_pairs = arr_size / 2; + + for (int i = 0; i < n_pairs; ++i) { + swap_wires(arr, 2 * i, 2 * i + 1, comparator); + } + + // Merge + int offset = 0; + int step = 2; + int block_size = step * 2; + + // Loop block sizes + while (true) { + // Loop step sizes + // If the offset is greater than the amount of wires to keep + // there's no need to continue, since (offset)-wires are known + // to not contribute to the end result + while (true) { + // Loop blocks + int block_begin = 0; + int block_end = block_size; + + while (block_begin < arr_size) { + // Constrain block_end + if (block_end > arr_size) + block_end = arr_size; + + // Merge block + mergesort_block( + arr, + offset, step, + block_begin, block_end, + first_n, + comparator + ); + + // Move to next block + block_begin = block_end; + block_end = block_end + block_size; + } + + // Decrease step + if (step > 2) { + // For each pass we are certain of the local min and max + // so skip 2 wires and reduce the step + offset = offset + 2; + step = step - 2; + } else if (step == 2) { + // For final pass we are certain of the global min and max + // so skip 1 wire and compare wires 1 to 1, the last value + // will be left without a partner; naturally since + // it's the global min + offset = 1; + step = 1; + } else { + // Short-Circuit: Done + break; + } + } + + // Short-Circuit: No more wires + if (block_size >= arr_size) + break; + + // Double the block size + offset = 0; + step = block_size; + block_size = step * 2; + } + } + + template + void mergesort( + T arr[], + const int& arr_size, + const C& comparator + ) { + mergesort( + arr, + arr_size, 0, + comparator + ); + } + + // Median Calculation + template + T median_of_sorted( + T arr[], + const int& arr_size + ) { + T mid; + + if ((arr_size % 2) == 0) { + const auto& top = arr[arr_size / 2]; + const auto& bot = arr[arr_size / 2 - 1]; + mid = (top + bot) >> 1; // Mid = (Top + Bot) / 2 + } else { + mid = arr[(arr_size - 1) / 2]; + } + + return mid; + } +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_DataUtils_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h new file mode 100644 index 0000000000000..1bb15c1a237fe --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h @@ -0,0 +1,19 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_DebugUtils_h +#define L1Trigger_L1TMuonEndCapPhase2_DebugUtils_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" + +// Uncomment the following line to use assert +#define EMTF_ALLOW_ASSERT + +#ifdef EMTF_ALLOW_ASSERT +#define emtf_assert(expr) (assert(expr)) +#else +#define emtf_assert(expr) ((void)(expr)) +#endif + +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_DebugUtils_h + diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h new file mode 100644 index 0000000000000..9d27ab3722a61 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h @@ -0,0 +1,283 @@ +#include +#include +#include +#include +#include +#include + +// Return an integer as a hex string +template +std::string to_hex(INT i) { + std::stringstream s; + s << "0x" << std::hex << i; + return s.str(); +} + +// Return an integer as a binary string +template +std::string to_binary(INT i, int n) { + std::stringstream s; + if (sizeof(i) <= 4) { + std::bitset<32> b(i); + s << "0b" << b.to_string().substr(32 - n, 32); + } else if (sizeof(i) <= 8) { + std::bitset<64> b(i); + s << "0b" << b.to_string().substr(64 - n, 64); + } + return s.str(); +} + +// Return the size of a 1D plain array +template +constexpr size_t array_size(T (&)[N]) { + return N; +} + +// Return the elements of a 1D plain array as a string (elements are separated by ' ') +template +std::string array_as_string(const T (&arr)[N]) { + std::stringstream s; + const char* sep = ""; + for (size_t i = 0; i < N; ++i) { + s << sep << arr[i]; + sep = " "; + } + return s.str(); +} + +// This function allows one to loop over a container in reversed order using C++11 for(auto ...) loop +// e.g. +// for (auto x: reversed(v)) { +// // do something +// } +// See http://stackoverflow.com/a/21510185 +namespace details { + template + struct _reversed { + T& t; + _reversed(T& _t) : t(_t) {} + decltype(t.rbegin()) begin() { return t.rbegin(); } + decltype(t.rend()) end() { return t.rend(); } + }; +} // namespace details +template +details::_reversed reversed(T& t) { + return details::_reversed(t); +} + +// Split a string by delimiters (default: ' ') into a vector of string +// See http://stackoverflow.com/a/53878 +template +std::vector split_string(const std::string& s, char c = ' ', char d = ' ') { + std::vector result; + const char* str = s.c_str(); + do { + const char* begin = str; + while (*str != c && *str != d && *str) + str++; + result.emplace_back(begin, str); + } while (0 != *str++); + return result; +} + +// Flatten a vector > into a vector +// The input type T can be different from the output type T +template +void flatten_container(const T1& input, T2& output) { + typename T1::const_iterator it; + for (it = input.begin(); it != input.end(); ++it) { + output.insert(output.end(), it->begin(), it->end()); + } +} + +// Check type for map of vector +template +struct is_map_of_vectors : public std::false_type {}; + +template +struct is_map_of_vectors > > : public std::true_type {}; + +// Merge a map of vectors (map1) into another map of vectors (map2) +template +void merge_map_into_map(const Map& map1, Map& map2) { + // This is customized for maps of containers. + typedef typename Map::iterator Iterator; + typedef typename Map::mapped_type Container; + + for (auto& kv1 : map1) { + std::pair ins = map2.insert(kv1); + if (!ins.second) { // if insertion into map2 was not successful + if (is_map_of_vectors::value) { // special case for map of vectors + const Container* container1 = &(kv1.second); + Container* container2 = &(ins.first->second); + container2->insert(container2->end(), container1->begin(), container1->end()); + } // else do nothing + } + } +} + +// A simple nearest-neighbor clustering algorithm +// It iterates through a sorted container once, whenever the 'adjacent' +// comparison between two elements evaluates to true, the 'cluster' +// operator is called to merge them. +template +ForwardIt adjacent_cluster(ForwardIt first, ForwardIt last, BinaryPredicate adjacent, BinaryOp cluster) { + if (first == last) + return last; + + ForwardIt result = first; + while (++first != last) { + if (!adjacent(*result, *first)) { + *++result = std::move(*first); + } else { + cluster(*result, *first); + } + } + return ++result; +} + +// Textbook merge sort algorithm with the same interface as std::sort() +// An internal buffer of the same size as the container is used internally. +template > +void merge_sort_merge(RandomAccessIterator first, + RandomAccessIterator middle, + RandomAccessIterator last, + Compare cmp) { + const std::ptrdiff_t len = std::distance(first, last); + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::pointer pointer; + std::pair p = std::get_temporary_buffer(len); + pointer buf = p.first; + pointer buf_end = std::next(p.first, p.second); + + RandomAccessIterator first1 = first; + RandomAccessIterator last1 = middle; + RandomAccessIterator first2 = middle; + RandomAccessIterator last2 = last; + + while (first1 != last1 && first2 != last2) { + if (cmp(*first2, *first1)) { + *buf++ = *first2++; + } else { + *buf++ = *first1++; + } + } + while (first1 != last1) { + *buf++ = *first1++; + } + while (first2 != last2) { + *buf++ = *first2++; + } + + buf = p.first; + std::copy(buf, buf_end, first); + std::return_temporary_buffer(p.first); +} + +// See above +template > +void merge_sort(RandomAccessIterator first, RandomAccessIterator last, Compare cmp) { + const std::ptrdiff_t len = std::distance(first, last); + if (len > 1) { + RandomAccessIterator middle = std::next(first, len / 2); + merge_sort(first, middle, cmp); + merge_sort(middle, last, cmp); + merge_sort_merge(first, middle, last, cmp); + } +} + +// An extended version of the merge sort algorithm to incorporate a 3-way +// comparator. It resorts back to 2-way comparator when one of the three +// lists to be merged is empty. +template +void merge_sort_merge3(RandomAccessIterator first, + RandomAccessIterator one_third, + RandomAccessIterator two_third, + RandomAccessIterator last, + Compare cmp, + Compare3 cmp3) { + const std::ptrdiff_t len = std::distance(first, last); + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::pointer pointer; + std::pair p = std::get_temporary_buffer(len); + pointer buf = p.first; + pointer buf_end = std::next(p.first, p.second); + + RandomAccessIterator first1 = first; + RandomAccessIterator last1 = one_third; + RandomAccessIterator first2 = one_third; + RandomAccessIterator last2 = two_third; + RandomAccessIterator first3 = two_third; + RandomAccessIterator last3 = last; + + while (first1 != last1 && first2 != last2 && first3 != last3) { + int rr = cmp3(*first1, *first2, *first3); + if (rr == 0) { + *buf++ = *first1++; + } else if (rr == 1) { + *buf++ = *first2++; + } else if (rr == 2) { + *buf++ = *first3++; + } + } + + if (first3 == last3) { + // do nothing + } else if (first2 == last2) { + first2 = first3; + last2 = last3; + } else if (first1 == last1) { + first1 = first2; + last1 = last2; + first2 = first3; + last2 = last3; + } + + while (first1 != last1 && first2 != last2) { + if (cmp(*first2, *first1)) { + *buf++ = *first2++; + } else { + *buf++ = *first1++; + } + } + while (first1 != last1) { + *buf++ = *first1++; + } + while (first2 != last2) { + *buf++ = *first2++; + } + + buf = p.first; + std::copy(buf, buf_end, first); + std::return_temporary_buffer(p.first); +} + +// See above +template +void merge_sort3(RandomAccessIterator first, RandomAccessIterator last, Compare cmp, Compare3 cmp3) { + const std::ptrdiff_t len = std::distance(first, last); + if (len > 1) { + RandomAccessIterator one_third = std::next(first, (len + 2) / 3); + RandomAccessIterator two_third = std::next(first, (len + 2) / 3 * 2); + merge_sort3(first, one_third, cmp, cmp3); + merge_sort3(one_third, two_third, cmp, cmp3); + merge_sort3(two_third, last, cmp, cmp3); + merge_sort_merge3(first, one_third, two_third, last, cmp, cmp3); + } +} + +// See above. 'Hint' is provided to force the very first division. This is needed to match FW. +template +void merge_sort3_with_hint( + RandomAccessIterator first, RandomAccessIterator last, Compare cmp, Compare3 cmp3, std::ptrdiff_t d) { + const std::ptrdiff_t len = std::distance(first, last); + if (len > 1) { + RandomAccessIterator one_third = std::next(first, d); + RandomAccessIterator two_third = std::next(first, d * 2); + merge_sort3(first, one_third, cmp, cmp3); + merge_sort3(one_third, two_third, cmp, cmp3); + merge_sort3(two_third, last, cmp, cmp3); + merge_sort_merge3(first, one_third, two_third, last, cmp, cmp3); + } +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h new file mode 100644 index 0000000000000..3520d8e3cdf20 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h @@ -0,0 +1,13 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_RPCUtils_h +#define L1Trigger_L1TMuonEndCapPhase2_RPCUtils_h + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" + +namespace emtf::phase2::rpc { + + // Enums + enum Type {kRPC, kiRPC, kNone}; + +} + +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_RPCUtils_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h new file mode 100644 index 0000000000000..507648ec09a57 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h @@ -0,0 +1,46 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TPUtils_h +#define L1Trigger_L1TMuonEndCapPhase2_TPUtils_h + +namespace emtf::phase2::tp { + + // _______________________________________________________________________ + // radians <-> degrees + float deg_to_rad(float deg); + + float rad_to_deg(float rad); + + // _______________________________________________________________________ + // phi range: [-180..180] or [-pi..pi] + float wrap_phi_deg(float); + + float wrap_phi_rad(float); + + // _______________________________________________________________________ + // theta + float calc_theta_rad_from_eta(float); + + float calc_theta_deg_from_eta(float); + + float calc_theta_deg_from_int(int); + + float calc_theta_rad_from_int(int); + + int calc_theta_int(int, float); + + // _______________________________________________________________________ + // phi + float calc_phi_glob_deg_from_loc(int, float); + + float calc_phi_glob_rad_from_loc(int, float); + + float calc_phi_loc_deg_from_int(int); + + float calc_phi_loc_rad_from_int(int); + + float calc_phi_loc_deg_from_glob(int, float); + + int calc_phi_int(int, float); + +} + +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_TPUtils_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h new file mode 100644 index 0000000000000..8729254506961 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h @@ -0,0 +1,25 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_TemplateUtils_h +#define L1Trigger_L1TMuonEndCapPhase2_TemplateUtils_h + +#include +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" + +namespace emtf::phase2 { + + template + T when(const bool& condition, const T& if_true, const F& if_false) { + return condition ? if_true : static_cast(if_false); + } + + template + T when(const bool& condition, const T& if_true, const T& if_false) { + return condition ? if_true : if_false; + } + +} + +#endif // L1Trigger_L1TMuonEndCapPhase2_TemplateUtils_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/BuildFile.xml b/L1Trigger/L1TMuonEndCapPhase2/plugins/BuildFile.xml new file mode 100644 index 0000000000000..bc5a448d4f1f3 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/BuildFile.xml @@ -0,0 +1,4 @@ + + + + diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc new file mode 100644 index 0000000000000..1ee2233331f19 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc @@ -0,0 +1,59 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h" + +#include "L1TMuonEndCapPhase2TrackProducer.h" + +L1TMuonEndCapPhase2TrackProducer::L1TMuonEndCapPhase2TrackProducer( + const edm::ParameterSet& pset +): + track_finder_(std::make_unique(pset, consumesCollector())) +{ + hit_token_ = produces(); + trk_token_ = produces(); + in_token_ = produces(); +} + +L1TMuonEndCapPhase2TrackProducer::~L1TMuonEndCapPhase2TrackProducer() { + // Do nothing +} + +void L1TMuonEndCapPhase2TrackProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { + edm::ParameterSetDescription desc; + desc.setUnknown(); + + descriptions.addDefault(desc); +} + +void L1TMuonEndCapPhase2TrackProducer::produce(edm::Event& event, const edm::EventSetup& event_setup) { + emtf::phase2::EMTFHitCollection out_hits; + emtf::phase2::EMTFTrackCollection out_tracks; + emtf::phase2::EMTFInputCollection out_inputs; + + // Forward event to track finder + track_finder_->process( + event, event_setup, + out_hits, out_tracks, out_inputs + ); + + // Output + event.emplace(hit_token_, std::move(out_hits)); + event.emplace(trk_token_, std::move(out_tracks)); + event.emplace(in_token_ , std::move(out_inputs)); +} + +void L1TMuonEndCapPhase2TrackProducer::beginStream(edm::StreamID stream_id) { + track_finder_->on_job_begin(); +} + +void L1TMuonEndCapPhase2TrackProducer::endStream() { + track_finder_->on_job_end(); +} + +//define this as a plug-in +DEFINE_FWK_MODULE(L1TMuonEndCapPhase2TrackProducer); diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h new file mode 100644 index 0000000000000..ccf94ef13bedb --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h @@ -0,0 +1,47 @@ +#ifndef L1Trigger_L1TMuonEndCapPhase2_L1TMuonEndCapPhase2TrackProducer_h +#define L1Trigger_L1TMuonEndCapPhase2_L1TMuonEndCapPhase2TrackProducer_h + +#include + +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/StreamID.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" + +class L1TMuonEndCapPhase2TrackProducer : public edm::stream::EDProducer<> { + public: + explicit L1TMuonEndCapPhase2TrackProducer( + const edm::ParameterSet& + ); + + ~L1TMuonEndCapPhase2TrackProducer() override; + + static void fillDescriptions( + edm::ConfigurationDescriptions& + ); + + private: + std::unique_ptr track_finder_; + + edm::EDPutTokenT hit_token_; + edm::EDPutTokenT trk_token_; + edm::EDPutTokenT in_token_; + + // Producer Functions + void produce(edm::Event&, const edm::EventSetup&) override; + void beginStream(edm::StreamID) override; + void endStream() override; + // void beginRun(edm::Run const&, edm::EventSetup const&) override; + // void endRun(edm::Run const&, edm::EventSetup const&) override; + // void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; + // void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; +}; + +#endif + diff --git a/L1Trigger/L1TMuonEndCapPhase2/python/config.py b/L1Trigger/L1TMuonEndCapPhase2/python/config.py new file mode 100644 index 0000000000000..1b6723c350bac --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/python/config.py @@ -0,0 +1,57 @@ +import FWCore.ParameterSet.Config as cms + +def customise_debug(process): + # EMTF Phase2 Emulator + process.load('L1Trigger.L1TMuonEndCapPhase2.simCscTriggerPrimitiveDigisForEMTF_cfi') + process.load('L1Trigger.L1TMuonEndCapPhase2.rpcRecHitsForEMTF_cfi') + process.load('L1Trigger.L1TMuonEndCapPhase2.simEmtfDigisPhase2_cfi') + + process.simEmtfDigisPhase2.Verbosity = cms.untracked.int32(5) + + process.L1TMuonEndCapPhase2Task = cms.Task( + process.simCscTriggerPrimitiveDigisForEMTF, + process.rpcRecHitsForEMTF, + process.simEmtfDigisPhase2 + ) + + process.L1TMuonEndCapPhase2Sequence = cms.Sequence( + process.L1TMuonEndCapPhase2Task + ) + + # Path + process.L1TMuonEndCapPhase2_step = cms.Path(process.L1TMuonEndCapPhase2Sequence) + + process.schedule.extend([process.L1TMuonEndCapPhase2_step]) + + # Remove cms.EndPath instances from schedule + paths_in_schedule = [path for path in process.schedule if not isinstance(path, cms.EndPath)] + process.schedule = cms.Schedule(*paths_in_schedule) + return process + +def customise_mc(process): + # EMTF Phase2 Emulator + process.load('L1Trigger.L1TMuonEndCapPhase2.simCscTriggerPrimitiveDigisForEMTF_cfi') + process.load('L1Trigger.L1TMuonEndCapPhase2.rpcRecHitsForEMTF_cfi') + process.load('L1Trigger.L1TMuonEndCapPhase2.simEmtfDigisPhase2_cfi') + + process.simEmtfDigisPhase2.Verbosity = cms.untracked.int32(1) + + process.L1TMuonEndCapPhase2Task = cms.Task( + process.simCscTriggerPrimitiveDigisForEMTF, + process.rpcRecHitsForEMTF, + process.simEmtfDigisPhase2 + ) + + process.L1TMuonEndCapPhase2Sequence = cms.Sequence( + process.L1TMuonEndCapPhase2Task + ) + + # Path + process.L1TMuonEndCapPhase2_step = cms.Path(process.L1TMuonEndCapPhase2Sequence) + + process.schedule.extend([process.L1TMuonEndCapPhase2_step]) + + # Remove cms.EndPath instances from schedule + paths_in_schedule = [path for path in process.schedule if not isinstance(path, cms.EndPath)] + process.schedule = cms.Schedule(*paths_in_schedule) + return process diff --git a/L1Trigger/L1TMuonEndCapPhase2/python/rpcRecHitsForEMTF_cfi.py b/L1Trigger/L1TMuonEndCapPhase2/python/rpcRecHitsForEMTF_cfi.py new file mode 100644 index 0000000000000..55bfdfead591e --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/python/rpcRecHitsForEMTF_cfi.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +from RecoLocalMuon.RPCRecHit.rpcRecHits_cfi import rpcRecHits +rpcRecHitsForEMTF = rpcRecHits.clone(rpcDigiLabel = 'simMuonRPCDigis') + diff --git a/L1Trigger/L1TMuonEndCapPhase2/python/simCscTriggerPrimitiveDigisForEMTF_cfi.py b/L1Trigger/L1TMuonEndCapPhase2/python/simCscTriggerPrimitiveDigisForEMTF_cfi.py new file mode 100644 index 0000000000000..7e57ccdaa0fdc --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/python/simCscTriggerPrimitiveDigisForEMTF_cfi.py @@ -0,0 +1,30 @@ +import FWCore.ParameterSet.Config as cms + +from L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigis_cfi import cscTriggerPrimitiveDigis + +# Taken from L1Trigger.L1TMuon.simDigis_cff +simCscTriggerPrimitiveDigisForEMTF = cscTriggerPrimitiveDigis.clone( + CSCComparatorDigiProducer = 'simMuonCSCDigis:MuonCSCComparatorDigi', + CSCWireDigiProducer = 'simMuonCSCDigis:MuonCSCWireDigi' +) + +# Taken from L1Trigger.CSCTriggerPrimitives.cscTriggerPrimitiveDigis_cfi +from Configuration.Eras.Modifier_run3_GEM_cff import run3_GEM +run3_GEM.toModify(simCscTriggerPrimitiveDigisForEMTF, + commonParam = dict(runPhase2 = cms.bool(True), + runME11Up = cms.bool(True), + runME11ILT = cms.bool(False), # was: True + GEMPadDigiClusterProducer = cms.InputTag(""), + enableAlctPhase2 = cms.bool(False))) # was: True + +from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon +phase2_muon.toModify(simCscTriggerPrimitiveDigisForEMTF, + commonParam = dict(runME21Up = cms.bool(True), + runME21ILT = cms.bool(False), # was: True + runME31Up = cms.bool(True), + runME41Up = cms.bool(True), + enableAlctPhase2 = cms.bool(False))) # was: True + +# Allow CSCs to have hits in multiple bxs - (Needs to be fixed on their end eventually) +phase2_muon.toModify(simCscTriggerPrimitiveDigisForEMTF.tmbPhase1, tmbReadoutEarliest2 = False) +phase2_muon.toModify(simCscTriggerPrimitiveDigisForEMTF.tmbPhase2, tmbReadoutEarliest2 = False) diff --git a/L1Trigger/L1TMuonEndCapPhase2/python/simEmtfDigisPhase2_cfi.py b/L1Trigger/L1TMuonEndCapPhase2/python/simEmtfDigisPhase2_cfi.py new file mode 100644 index 0000000000000..e6a9e3f97a9e7 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/python/simEmtfDigisPhase2_cfi.py @@ -0,0 +1,57 @@ +import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Modifier_phase2_GE0_cff import phase2_GE0 + +# EMTF Phase2 emulator configuration +simEmtfDigisMCPhase2 = cms.EDProducer( + "L1TMuonEndCapPhase2TrackProducer", + + # Verbosity level + Verbosity = cms.untracked.int32(3), + + # Validation + ValidationDirectory = cms.string("L1Trigger/L1TMuonEndCapPhase2/data/validation"), + + # Neural Network Models + PromptGraphPath = cms.string("L1Trigger/L1TMuonEndCapPhase2/data/prompt_model.pb"), + DisplacedGraphPath = cms.string("L1Trigger/L1TMuonEndCapPhase2/data/displaced_model.pb"), + + # Input collections + # Three options for CSCInput + # * '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('simCscTriggerPrimitiveDigisForEMTF','MPCSORTED'), + RPCInput = cms.InputTag('rpcRecHitsForEMTF'), + GEMInput = cms.InputTag('simMuonGEMPadDigiClusters'), + ME0Input = cms.InputTag('me0TriggerConvertedPseudoDigis'), + GE0Input = cms.InputTag('ge0TriggerConvertedPseudoDigis'), + + # Run with CSC, RPC, GEM + CSCEnabled = cms.bool(True), # Use CSC LCTs from the MPCs in track-building + RPCEnabled = cms.bool(True), # Use clustered RPC hits from CPPF in track-building + GEMEnabled = cms.bool(True), # Use hits from GEMs in track-building + ME0Enabled = cms.bool(True), + GE0Enabled = cms.bool(False), + + # BX + MinBX = cms.int32(-2), # Minimum BX considered + MaxBX = cms.int32(2), # Maximum BX considered + BXWindow = cms.int32(1), # Number of BX whose primitives can be included in the same track + + 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), + + IncludeNeighborEnabled = cms.bool(True), # Include primitives from neighbor chambers in track-building +) + +phase2_GE0.toModify(simEmtfDigisMCPhase2, ME0Enabled=False, GE0Enabled=True) + +simEmtfDigisDataPhase2 = simEmtfDigisMCPhase2.clone( + # Inputs + CSCInput = cms.InputTag('emtfStage2Digis'), + RPCInput = cms.InputTag('muonRPCDigis'), +) + +simEmtfDigisPhase2 = simEmtfDigisMCPhase2.clone() diff --git a/L1Trigger/L1TMuonEndCapPhase2/scripts/msort.py b/L1Trigger/L1TMuonEndCapPhase2/scripts/msort.py new file mode 100644 index 0000000000000..741b66d90776b --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/scripts/msort.py @@ -0,0 +1,163 @@ +def swap(arr, a, b): + # print('Compare (%d, %d)' % (a, b)) + + if arr[a] < arr[b]: + temp = arr[a] + arr[a] = arr[b] + arr[b] = temp + +def merge_block(arr, offset, step, block_begin, block_end, first_n=-1): + wire_offset = offset + block_begin + wire_cutoff = first_n + block_begin + wire_1 = wire_offset + wire_2 = wire_1 + step + + # Merge block + while wire_2 < block_end: + # Trim + if first_n > -1 and wire_cutoff < block_end: + if (first_n < step or step == 1): + wire_required = wire_offset <= wire_1 <= wire_cutoff + else: + wire_required = wire_offset <= wire_1 < wire_cutoff + + if not wire_required: + break + + # Swap + swap(arr, wire_1, wire_2) + + # Calculate new wire_1 + if step == 1: + wire_1 = wire_2 + 1 + else: + wire_1 = wire_1 + 1 + + # Calculate new wire_2 + wire_2 = wire_1 + step + + +def merge_sort(arr, first_n=-1): + arr_length = len(arr) + + # Sort + for i in range(int(arr_length / 2)): + swap(arr, 2 * i, 2 * i + 1) + + # Merge to mas block size + stage = 0 + offset = 0 + step = 2 + block_size = step * 2 + + # Loop block sizes + while True: + # print('Block size=%d begin' % (block_size)) + + # Loop merge steps + # if the offset surpases the amount of wires to keep, + # there's no need to continue + while True: + # Loop blocks + stage += 1 + block = 0 + block_begin = 0 + block_end = min(block_size, arr_length) + + while block_begin < arr_length: + # print('Stage %d Block %d offset=%d step=%d size=%d [%d, %d] begin' % (stage, block, offset, step, block_size, block_begin, block_end)) + + merge_block(arr, offset, step, block_begin, block_end, first_n=first_n) + + # Move to next block + block += 1 + block_begin = block_end + block_end = min(block_end + block_size, arr_length) + + # Decrease step + if step > 2: + # For each pass we are certain of the local min and max so skip 2 wires and reduce step + offset = offset + 2 + step = step - 2 + elif step == 2: + # For final pass we are certain of the global min and max so skip 1 wire and compare 1 to 1 + # the last value will be left without a partner; naturally since it's the global min + offset = 1 + step = 1 + else: + # Short-Circuit: Done + break; + + # Short-Circuit: No more wires + if block_size >= arr_length: + break + + # Double the block size + offset = 0 + step = block_size + block_size = step * 2 + +import random +import copy + +random.seed(2022) + +match_count = 0 +test_runs = 1 + +for i in range(test_runs): + random.seed(2022 + i) + original = [random.randint(0,120) for i in range(144)] + + print(original, len(original)) + + # Osvaldo Mode + osvaldo_input = copy.deepcopy(original) + osvaldo_output = copy.deepcopy(osvaldo_input) + merge_sort(osvaldo_output, first_n=4) + + # Jia Fu Mode + jf_p1_input = copy.deepcopy(original[:32]) + jf_p2_input = copy.deepcopy(original[32:]) + jf_p1_output = copy.deepcopy(jf_p1_input) + + merge_sort(jf_p1_output, first_n=16) + + for i in range(28): + part = jf_p2_input[i*4:(i+1)*4] + merge_sort(part) + #print(i, part) + jf_p2_input[i*4:(i+1)*4] = part + + jf_input = copy.deepcopy(jf_p1_output[:16] + jf_p2_input) + jf_output = copy.deepcopy(jf_input) + #print(jf_output, len(jf_output)) + merge_sort(jf_output, first_n=4) + + print('Osvaldo Mode') + print('\nInput Part 1', osvaldo_input[:32]) + print('\nInput Part 2', osvaldo_input[32:]) + print('\nInput Length', len(osvaldo_input)) + print('\nBest', osvaldo_output[:4]) + print() + print('Jia Fu Mode') + print('\nInput Part 1', jf_p1_input) + # print('\nOutput Part 1', jf_p1_output[:16]) + print('\nInput Part 2', jf_p2_input) + print('\nInput Length', len(jf_input)) + print('\nBest', jf_output[:4]) + + matches = True + + for i in range(4): + if osvaldo_output[i] != jf_output[i] or osvaldo_output[i] != jf_output[i]: + matches = False + break + + if matches: + match_count += 1 + + print('\nOutputs Match', matches) + +print('Match Count', match_count, 'Runs', test_runs) + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc new file mode 100644 index 0000000000000..d48135a8f0bc6 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc @@ -0,0 +1,141 @@ +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h" + +using namespace emtf::phase2; +using namespace emtf::phase2::algo; + +DuplicateRemovalLayer::DuplicateRemovalLayer( + const EMTFContext& context +): + context_(context) +{ + // Do Nothing +} + +DuplicateRemovalLayer::~DuplicateRemovalLayer() { + // Do Nothing +} + +void DuplicateRemovalLayer::apply( + std::vector& tracks +) const { + // =========================================================================== + // Unpack model + // --------------------------------------------------------------------------- + const auto& model = context_.model_; + const auto& model_reduced_sites = model.reduced_sites_; + + // =========================================================================== + // Build reduced tracks + // --------------------------------------------------------------------------- + std::vector reduced_tracks; + + for (const auto& track : tracks) { // Begin loop tracks + // Fetch reduced track + auto& rtrk = reduced_tracks.emplace_back(); + auto& rtrk_valid = rtrk.valid; + + // Initialize valid state + rtrk_valid = track.valid; + + // Fill reduced track with segments + for (const auto& model_rsite : model_reduced_sites) { // Begin loop reduced model sites + + // Get reduced site + int model_rsite_id = static_cast(model_rsite.id); + + auto& rsite_seg = rtrk.site_segs[model_rsite_id]; + auto& rsite_bit = rtrk.site_mask[model_rsite_id]; + + // Init reduced site + rsite_seg = 0; + rsite_bit = 0; + + // Select the first segment available for the reduced site + for (const auto& model_rs_ts : model_rsite.trk_sites) { // Begin loop reduced site track sites + int trk_site_id = static_cast(model_rs_ts); + + const auto& trk_site_seg = track.site_segs[trk_site_id]; + const auto& trk_site_bit = track.site_mask[trk_site_id]; + + if (trk_site_bit == 0) { + continue; + } + + // Attach segment + // If even one segment is attached + // the reduced track is considered valid + rtrk_valid = 1 ; + rsite_seg = trk_site_seg; + rsite_bit = 1 ; + + break; + } // End loop reduced site track sites + } // End loop reduced model sites + } // End loop tracks + + // =========================================================================== + // Find and invalidate duplicate tracks + // --------------------------------------------------------------------------- + for (unsigned int i_rtrk = 0; i_rtrk < reduced_tracks.size(); ++i_rtrk) { // Begin loop reduced tracks i + + auto& trk_i = tracks[i_rtrk]; + const auto& rtrk_i = reduced_tracks[i_rtrk]; + + if (rtrk_i.valid == 1) { + for (unsigned int j_rtrk = (i_rtrk + 1); j_rtrk < reduced_tracks.size(); ++j_rtrk) { // Begin loop reduced tracks j + + auto& rtrk_j = reduced_tracks[j_rtrk]; + + // If the reduced track is already invalid, move on + if (rtrk_j.valid == 0) + continue; + + // Compare reduced track sites + for (int k_rsite = 0; k_rsite < v3::kNumTrackSitesRM; ++k_rsite) { // Begin loop reduced sites k + const auto& rtrk_site_mask_ik = rtrk_i.site_mask[k_rsite]; + const auto& rtrk_site_mask_jk = rtrk_j.site_mask[k_rsite]; + + // If one or both of the sites are missing, move on + if (!(rtrk_site_mask_ik & rtrk_site_mask_jk)) + continue; + + // Compare segment_ids + const auto& rtrk_seg_id_ik = rtrk_i.site_segs[k_rsite]; + const auto& rtrk_seg_id_jk = rtrk_j.site_segs[k_rsite]; + + // If segment ids are differente, move on + if (rtrk_seg_id_ik != rtrk_seg_id_jk) + continue; + + // If there's even one collision, invalidate the track + rtrk_j.valid = 0; + } // End loop reduced sites k + } // End loop reduced tracks j + } + + // Propagate invalidation + trk_i.valid = rtrk_i.valid; + + // DEBUG + if (CONFIG.verbosity_ > 1) { + if (trk_i.valid) { + std::cout + << "Unique Track" + << " zone " << trk_i.zone + << " col " << trk_i.col + << " pat " << trk_i.pattern + << " qual " << trk_i.quality + << " phi " << trk_i.phi + << " theta " << trk_i.theta + << " valid " << trk_i.valid + << std::endl; + } + } + } // End loop reduced tracks i +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc new file mode 100644 index 0000000000000..2e38079902382 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc @@ -0,0 +1,207 @@ +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h" + +using namespace emtf::phase2::algo; + +HitmapLayer::HitmapLayer( + const EMTFContext& context +): + context_(context) +{ + // Do Nothing +} + +HitmapLayer::~HitmapLayer() { + // Do Nothing +} + +void HitmapLayer::apply( + const segment_collection_t& segments, + std::vector& zone_hitmaps +) const { + const hitmap_row_t padded_one = 1; + + auto& model = context_.model_; + + // Create Images + int n_zones = model.zones_.size(); + + for (int zone_id = 0; zone_id < n_zones; ++zone_id) { // Begin zones + unsigned int zone_mask = (1u << zone_id); + unsigned int tzone_mask = (1u << 0); // Only looking at BX=0 for now + + const auto& model_hm = model.zones_[zone_id].hitmap; + auto& hitmap = zone_hitmaps.emplace_back(); + bool hitmap_is_blank = true; + + int n_rows = model_hm.size(); + + for (int row_id = 0; row_id < n_rows; ++row_id) { // Begin loop rows + + const auto& model_hm_row = model_hm[row_id]; + auto& row = hitmap[row_id]; + row = 0; // Clear Row Image + + for (const auto& model_hm_site : model_hm_row) { // Begin loop sites in row + + for (const auto& model_hm_chamber : model_hm_site.chambers) { // Begin loop chambers in site + + for (int i_ch_seg = 0; i_ch_seg < v3::kChamberSegments; ++i_ch_seg) { // Begin loop segments + + const int seg_id = model_hm_chamber.id * v3::kChamberSegments + i_ch_seg; + const auto& seg = segments[seg_id]; + + // Short-Circuit: Must be valid + if (seg.valid != 1) { + continue; + } + + // Short-Circuit: Must be same zone + if ((seg.zones & zone_mask) != zone_mask) { + // Debug Info + if (CONFIG.verbosity_ > 4) { + std::cout + << "Hitmap Segment not in zone: " + << " zone " << zone_id + << " row " << row_id + << " seg_id " << seg_id + << " seg_phi " << seg.phi + << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones + << std::endl; + } + + continue; + } + + // Short-Circuit: Must be same timezone + if ((seg.tzones & tzone_mask) != tzone_mask) { + // Debug Info + if (CONFIG.verbosity_ > 4) { + std::cout + << "Hitmap Segment not in timezone: " + << " zone " << zone_id + << " row " << row_id + << " seg_id " << seg_id + << " seg_phi " << seg.phi + << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones + << std::endl; + } + + continue; + } + + // Convert emtf_phi to col: truncate the last 4 bits, hence dividing by 16 + auto col_id = static_cast(seg.phi >> v3::kHitmapColFactorLog2); + + // Debug Info + // Seg col should be in the range specified by the model chamber + if (CONFIG.verbosity_ > 4) { + std::cout + << "Hitmap Segment Before Assert" + << " zone " << zone_id + << " row " << row_id + << " col " << col_id + << " seg_id " << seg_id + << " seg_phi " << seg.phi + << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones + << " ch_col_begin " << model_hm_chamber.begin + << " ch_col_end " << model_hm_chamber.end + << std::endl; + } + + emtf_assert(model_hm_chamber.begin <= col_id && col_id < model_hm_chamber.end); + + // Short-Circuit: Joined chamber hitmap has more columns than the final image, + // so we skip the columns outside of the final hitmaps's range + // i.e. cropping the originl image + if (!(v3::kHitmapCropColStart <= col_id && col_id < v3::kHitmapCropColStop)) { + // Debug Info + if (CONFIG.verbosity_ > 4) { + std::cout + << "Hitmap Segment out of bounds: " + << " zone " << zone_id + << " row " << row_id + << " col " << col_id + << " seg_id " << seg_id + << " seg_phi " << seg.phi + << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones + << std::endl; + } + + continue; + } + + // Adjust col_id so kHitmapCropColStart is col 0 in the image + col_id -= v3::kHitmapCropColStart; + + // Calculate the 0-padded int for that column and or-it into the image + hitmap_row_t col_mask = padded_one << col_id; + row |= col_mask; + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout + << "Hitmap Segment" + << " zone " << zone_id + << " row " << row_id + << " col " << col_id + << " seg_id " << seg_id + << " seg_phi " << seg.phi + << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones + << std::endl; + } + } // End loop segments + + } // End loop chambers in site + + } // End loop sites in row + + // Check if hitmap is blank + if (hitmap_is_blank && row != 0) { + hitmap_is_blank = false; + } + } // End loop rows + + // Debug Info + if (CONFIG.verbosity_ > 3) { + // Short-Circuit: the image is blank + if (hitmap_is_blank) { + continue; + } + + // Pretty print + std::cout << std::endl; + std::cout << "Zone " << zone_id << " Image" << std::endl; + + for (int row_id = (model_hm.size() - 1); 0 <= row_id; --row_id) { // Print rows in reverse order + const auto& row = hitmap[row_id]; + + std::cout << row_id << " "; + + for (int col_id = 0; col_id < v3::kHitmapNCols; ++col_id) { + hitmap_row_t pixel_mask = 1; + pixel_mask = pixel_mask << col_id; + + bool is_present = (row & pixel_mask) == pixel_mask; + + if (is_present) { + std::cout << "X"; + } else { + std::cout << "-"; + } + } + + std::cout << std::endl; + } + + std::cout << std::endl; + } + } // End loop zones +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc new file mode 100644 index 0000000000000..80becc835e1cb --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc @@ -0,0 +1,237 @@ +#include "PhysicsTools/TensorFlow/interface/TensorFlow.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h" + +using namespace emtf::phase2; +using namespace emtf::phase2::algo; + +OutputLayer::OutputLayer( + const EMTFContext& context +): + context_(context) +{ + // Do Nothing +} + +OutputLayer::~OutputLayer() { + // Do Nothing +} + +void OutputLayer::apply( + const int& endcap, const int& sector, const int& bx, + const std::map& seg_to_hit, + const std::vector& tracks, + const bool& displaced_en, + EMTFTrackCollection& out_tracks + ) const { + const int endcap_pm = (endcap == 2) ? -1 : endcap; // 1: +endcap, -1: -endcap + + for (auto& track : tracks) { // Begin loop tracks + // Fill Site/Hit Vectors + int hit_count = 0; + + EMTFTrack::site_hits_t site_hits; + EMTFTrack::site_segs_t site_segs; + EMTFTrack::site_mask_t site_mask; + EMTFTrack::site_mask_t site_rm_mask; + + for (int i = 0; i < v3::kNumTrackSites; i++) { + // Get attached segments + const auto& site_seg_id = track.site_segs[i]; + const auto& site_bit = track.site_mask[i]; + const auto& site_rm_bit = track.site_rm_mask[i]; + + // Increase hit count + if (site_bit == 1) { + hit_count += 1; + } + + // Convert segment to hit + int hit_id = 0; + + if ((site_bit == 1) || (site_rm_bit == 1)) { + hit_id = seg_to_hit.at(site_seg_id); + } + + // Save Info + site_hits.push_back(hit_id); + site_segs.push_back(site_seg_id); + site_mask.push_back(site_bit); + site_rm_mask.push_back(site_rm_bit); + } + + // Short-Circuit: Only keep tracks with hits + if (!track.valid && hit_count == 0) { + continue; + } + + // Fill Feature Vector + EMTFTrack::features_t model_features; + + for (int i = 0; i < v3::kNumTrackFeatures; i++) { + model_features.push_back(track.features[i]); + } + + // Find EMTF/GMT variables + const int emtf_mode_v1 = find_emtf_mode_v1(track.site_mask); + const int emtf_mode_v2 = find_emtf_mode_v2(track.site_mask); + + // Init Parameters + auto& out_trk = out_tracks.emplace_back(); + + out_trk.setEndcap(endcap_pm); + out_trk.setSector(sector); + out_trk.setBx(bx); + out_trk.setUnconstrained(displaced_en ? 1 : 0); + out_trk.setValid(track.valid); + + out_trk.setModelPtAddress(track.pt_address); + out_trk.setModelRelsAddress(track.rels_address); + out_trk.setModelDxyAddress(track.dxy_address); + out_trk.setModelPattern(track.pattern); + out_trk.setModelQual(track.quality); + out_trk.setModelPhi(track.phi); + out_trk.setModelEta(track.theta); + out_trk.setModelFeatures(model_features); + + out_trk.setEmtfQ(track.q); + out_trk.setEmtfPt(track.pt); + out_trk.setEmtfRels(track.rels); + out_trk.setEmtfD0(std::abs(track.dxy)); + out_trk.setEmtfZ0(0); // not yet implemented + out_trk.setEmtfBeta(0); // not yet implemented + out_trk.setEmtfModeV1(emtf_mode_v1); + out_trk.setEmtfModeV2(emtf_mode_v2); + + out_trk.setSiteHits(site_hits); + out_trk.setSiteSegs(site_segs); + out_trk.setSiteMask(site_mask); + out_trk.setSiteRMMask(site_rm_mask); + } // End loop tracks +} + +int OutputLayer::find_emtf_mode_v1(const track_t::site_mask_t& x) const { + int mode = 0; + + if (x[0] or x[9] or x[1] or x[5] or x[11]) { // ME1/1, GE1/1, ME1/2, RE1/2, ME0 + mode |= (1 << 3); + } + + if (x[2] or x[10] or x[6]) { // ME2, GE2/1, RE2/2 + mode |= (1 << 2); + } + + if (x[3] or x[7]) { // ME3, RE3 + mode |= (1 << 1); + } + + if (x[4] or x[8]) { // ME4, RE4 + mode |= (1 << 0); + } + + return mode; +} + +// SingleMu (12) +// - at least one station-1 segment (ME1/1, GE1/1, ME1/2, RE1/2, ME0) +// with one of the following requirements on stations 2,3,4 +// a. if there is ME1/2 or RE1/2, +// i. if there is ME1/2, require 1 more CSC station +// ii. else, require 1 more CSC station + 1 more station +// b. if there is ME1/1 or GE1/1, +// i. if there is ME1/1, require 1 more CSC station + 1 more station +// ii. else, require 2 more CSC stations +// c. if there is ME0, +// i. if there is ME1/1, require 1 more station in stations 3,4 +// ii. else, require 1 more CSC station + 1 more station +// +// DoubleMu (8) +// - at least one station-1 segment (ME1/1, GE1/1, ME1/2, RE1/2, ME0) +// with one of the following requirements on stations 2,3,4 +// a. if there is ME1/1 or ME1/2, require 1 more station +// b. if there is GE1/1 or RE1/2, require 1 more CSC station +// c. if there is ME0, +// i. if there is ME1/1, require 1 more station +// ii. else, require 1 more CSC station +// +// TripleMu (4) +// - at least two stations +// a. if there is ME1/1 or ME1/2, require 1 more station +// b. if there is GE1/1 or RE1/2, require 1 more CSC station +// c. if there is ME0, +// i. if there is ME1/1, require 1 more station +// ii. else, require 1 more CSC station +// d. else, require 2 more CSC stations +// +// SingleHit (0) +// - at least one station +// +// Note that SingleMu, DoubleMu, TripleMu, SingleHit are mutually-exclusive categories. +int OutputLayer::find_emtf_mode_v2(const track_t::site_mask_t& x) const { + int mode = 0; + int cnt_ye11 = x[0] + x[9]; // ME1/1, GE1/1 + int cnt_ye12 = x[1] + x[5]; // ME1/2, RE1/2 + int cnt_ye22 = x[2] + x[10] + x[6]; // ME2, GE2/1, RE2/2 + int cnt_ye23 = x[3] + x[7]; // ME3, RE3 + int cnt_ye24 = x[4] + x[8]; // ME4, RE4 + int cnt_ye2a = (cnt_ye22 != 0) + (cnt_ye23 != 0) + (cnt_ye24 != 0); // + int cnt_ye2b = (cnt_ye23 != 0) + (cnt_ye24 != 0); // + int cnt_me11 = x[0]; // ME1/1 only + int cnt_me12 = x[1]; // ME1/2 only + int cnt_me14 = x[11]; // ME0 only + int cnt_me2a = (x[2] != 0) + (x[3] != 0) + (x[4] != 0); // + + // clang-format off + // SingleMu (12) + { + bool rule_a_i = (cnt_me12 != 0) and (cnt_me2a >= 1); + bool rule_a_ii = (cnt_ye12 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); + bool rule_b_i = (cnt_me11 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); + bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 2); + bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2b >= 1); + bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); + + if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) { + mode |= (1 << 3); + mode |= (1 << 2); + } + } + + // DoubleMu (8) + if (mode < (1 << 3)) { + bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1); + bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1); + bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1); + bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1); + bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1); + bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1); + + if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) { + mode |= (1 << 3); + } + } + + // TripleMu (4) + if (mode < (1 << 2)) { + bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1); + bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1); + bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1); + bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1); + bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1); + bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1); + bool rule_d = (cnt_me2a >= 2); + + if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii or rule_d) { + mode |= (1 << 2); + } + } + + // clang-format on + return mode; +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc new file mode 100644 index 0000000000000..25d649fd842bf --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc @@ -0,0 +1,194 @@ +#include + +#include "PhysicsTools/TensorFlow/interface/TensorFlow.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h" + +using namespace emtf::phase2; +using namespace emtf::phase2::algo; + +ParameterAssignmentLayer::ParameterAssignmentLayer( + const EMTFContext& context +): + context_(context) +{ + // Do Nothing +} + +ParameterAssignmentLayer::~ParameterAssignmentLayer() { + // Do Nothing +} + +void ParameterAssignmentLayer::apply( + const bool& displaced_en, + std::vector& tracks +) const { + std::vector feature_sites = { + 0,1,2,3,4,5,6,7,8,9,10,11, + 0,1,2,3,4,5,6,7,8,9,10,11, + 0,1,2,3,4,11, + 0,1,2,3,4,11, + -1,-1,-1,-1 + }; + + for (auto& track : tracks) { // Begin loop tracks + // Init Parameters + track.pt = 0; + track.rels = 0; + track.dxy = 0; + track.z0 = 0; + track.beta = 0; + + track.pt_address = 0; + track.rels_address = 0; + track.dxy_address = 0; + + // Short-Circuit: Skip invalid tracks + if (track.valid == 0) { + continue; + } + + // Get Features + const auto& site_mask = track.site_mask; + const auto& features = track.features; + + // Single batch of NTrackFeatures values + tensorflow::Tensor input( + tensorflow::DT_FLOAT, + {1, v3::kNumTrackFeatures} + ); + + if (CONFIG.verbosity_ > 1) { + std::cout + << "Parameter Assignment In" + << " disp " << displaced_en + << " zone " << track.zone + << " col " << track.col + << " pat " << track.pattern + << " qual " << track.quality + << " phi " << track.phi + << " theta " << track.theta + << " features " + << std::endl; + } + + // Prepare input tensor + float* input_data = input.flat().data(); + + for (int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { + const auto& feature = features[i_feature]; + const auto& feature_site = feature_sites[i_feature]; + + bool mask_value = false; + + // Debug Info + if (CONFIG.verbosity_ > 1 && i_feature > 0) { + std::cout << " "; + } + + // Mask invalid sites + if (feature_site > -1) { + mask_value = (site_mask[feature_site] == 0); + } + + if (mask_value) { + (*input_data) = 0.; + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << "0"; + } + } else { + (*input_data) = feature.to_float(); + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << feature.to_float(); + } + } + + input_data++; + } + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << std::endl; + } + + // Select TF Session + auto* session_ptr = context_.prompt_session_ptr_; + + if (displaced_en) { + session_ptr = context_.disp_session_ptr_; + } + + // Evaluate Prompt + std::vector outputs; + + tensorflow::run( + session_ptr, + {{"inputs", input}}, // Input layer name + {"Identity"}, // Output layer name + &outputs + ); + + // Assign parameters + if (displaced_en) { + // Read displaced pb outputs + auto pt_address = outputs[0].matrix()(0, 0); + auto rels_address = outputs[0].matrix()(0, 1); + auto dxy_address = outputs[0].matrix()(0, 2); + + track.pt_address = std::clamp(pt_address, -512, 511); + track.rels_address = std::clamp(rels_address, -512, 511); + track.dxy_address = std::clamp(dxy_address, -512, 511); + + track.q = (track.pt_address < 0); + track.pt = context_.activation_lut_.lookup_disp_pt(track.pt_address); + track.rels = context_.activation_lut_.lookup_rels(track.rels_address); + track.dxy = context_.activation_lut_.lookup_dxy(track.dxy_address); + } else { + // Read prompt pb outputs + auto pt_address = outputs[0].matrix()(0, 0); + auto rels_address = outputs[0].matrix()(0, 1); + + track.pt_address = std::clamp(pt_address, -512, 511); + track.rels_address = std::clamp(rels_address, -512, 511); + track.dxy_address = 0; + + track.q = (track.pt_address < 0); + track.pt = context_.activation_lut_.lookup_prompt_pt(track.pt_address); + track.rels = context_.activation_lut_.lookup_rels(track.rels_address); + track.dxy = 0; + } + + // DEBUG + if (CONFIG.verbosity_ > 1) { + std::cout + << "Parameter Assignment Out" + << " disp " << displaced_en + << " zone " << track.zone + << " col " << track.col + << " pat " << track.pattern + << " qual " << track.quality + << " q " << track.q + << " pt " << track.pt + << " rels " << track.rels + << " dxy " << track.dxy + << " z0 " << track.z0 + << " phi " << track.phi + << " theta " << track.theta + << " beta " << track.beta + << " pt_address " << track.pt_address + << " rels_address " << track.rels_address + << " dxy_address " << track.dxy_address + << " valid " << track.valid + << std::endl; + } + } // End loop tracks +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc new file mode 100644 index 0000000000000..561afe4cfb801 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc @@ -0,0 +1,140 @@ +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h" + +using namespace emtf::phase2::algo; + +PatternMatchingLayer::PatternMatchingLayer( + const EMTFContext& context +): + context_(context) +{ + // Do Nothing +} + +PatternMatchingLayer::~PatternMatchingLayer() { + // Do Nothing +} + +void PatternMatchingLayer::apply( + const std::vector& zone_hitmaps, + const bool& displaced_en, + std::vector& zone_roads +) const { + typedef ap_uint padded_row_t; + typedef ap_uint pattern_activation_t; + typedef std::array pattern_activation_collection_t; + + const padded_row_t padded_one = 1; + + auto& model = context_.model_; + + for (unsigned int i_zone = 0; i_zone < zone_hitmaps.size(); ++i_zone) { // Loop Zones + auto& hitmap = zone_hitmaps[i_zone]; + auto* model_pc = &(model.zones_[i_zone].prompt_patterns); + auto* model_ql = &(model.zones_[i_zone].prompt_quality_lut); + + if (displaced_en) { + model_pc = &(model.zones_[i_zone].disp_patterns); + model_ql = &(model.zones_[i_zone].disp_quality_lut); + } + + // Initialize roads + auto& roads = zone_roads.emplace_back(); + + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + roads[i_col].pattern = 0; + roads[i_col].quality = 0; + } + + // Apply patterns + for (unsigned int i_pattern = 0; i_pattern < model_pc->size(); ++i_pattern) { // Loop Patterns + auto& model_pat = (*model_pc)[i_pattern]; + + // Initialize activations + pattern_activation_collection_t pac; + + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + pac[i_col] = 0; + } + + // Build activations + for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { // Loop Rows + // Pad the row with zeros to cover cases where + // pattern range is out of range + auto hitmap_row = hitmap[i_row]; + auto& model_pat_row = model_pat[i_row]; + + // Pad the hitmap row on both sides using kMaxPadding + // We binary shift it to the left by kMaxPadding + // effectively padding it to the right, and since + // the bitwidth already includes both paddings + // the left is also padded + padded_row_t padded_hm_row = hitmap_row; + padded_hm_row = padded_hm_row << v3::kPatternMatchingPadding; + + // Convert the model pattern row to a padded row + padded_row_t padded_pat_row = 0; + + int offset = model_pat_row.begin; + + int bw = model_pat_row.end + - model_pat_row.begin + + 1; // Add 1 since it's an inclusive range + + for (int i_bit = 0; i_bit < bw; ++i_bit) + padded_pat_row |= (padded_one << (offset + i_bit)); + + // Slide the pattern row across the hitmap and check for 'activations' + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + // "AND" both rows together if the result is greater than 0 + // there is an activation + padded_row_t result = padded_pat_row & padded_hm_row; + + if (result > 0) + pac[i_col] = pac[i_col] | (1 << i_row); + + // Shift the pattern row to the left, i.e. slide it across + padded_pat_row = padded_pat_row << 1; + } + } // End Loop Rows + + // Compare Activations + // Update the road if the column's road has a smaller + // quality than the new activation's quality. + // Note: Since this is in a loop going from smallest pattern number + // to the largest, cases where the quality is the same, + // but the pattern number is larger the smaller one will be preferred + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + auto& activation = pac[i_col]; + auto quality = (*model_ql)[activation]; + + auto& current_road = roads[i_col]; + + if (current_road.quality < quality) { + current_road.pattern = i_pattern; + current_road.quality = quality; + } + } + } // End Loop Patterns in Zones + + // Debug Info + if (CONFIG.verbosity_ > 1) { + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + if (roads[i_col].quality == 0) { + continue; + } + + std::cout + << "Road" + << " zone " << i_zone + << " col " << i_col + << " pat " << roads[i_col].pattern + << " qual " << roads[i_col].quality + << std::endl; + } + } + } // End Loop Zones +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc new file mode 100644 index 0000000000000..750749e5116ed --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc @@ -0,0 +1,188 @@ +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h" + +using namespace emtf::phase2::algo; + +RoadSortingLayer::RoadSortingLayer( + const EMTFContext& context +): + context_(context) +{ + // Do Nothing +} + +RoadSortingLayer::~RoadSortingLayer() { + // Do Nothing +} + +void RoadSortingLayer::apply( + const int& first_n, + const std::vector& zone_roads, + std::vector& best_roads +) const { + // Find the best roads from each zone + std::vector top_roads; + + for (unsigned int i_zone = 0; i_zone < zone_roads.size(); ++i_zone) { // Loop Zones + + auto& roads = zone_roads[i_zone]; + + // Suppress qualities of non local maximum + road_collection_t suppressed_roads; + + { + const int last_col = v3::kHitmapNCols - 1; + + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + bool is_local_max = true; + bool is_last_col = i_col == last_col; + bool is_first_col = i_col == 0; + + // If this is not the last column, compare it with the next column's road + // If this column has better or equal quality than the next, this is still the local max + if (is_local_max && !is_last_col) { + is_local_max &= (roads[i_col].quality >= roads[i_col + 1].quality); + } + + // If this is not the first column, compare it with the previous column's road + // If this column has better quality than the previous, this is still the local max + if (is_local_max && !is_first_col) { + is_local_max &= (roads[i_col].quality > roads[i_col - 1].quality); + } + + // Suppress qualities + if (is_local_max) { + suppressed_roads[i_col].zone = i_zone; + suppressed_roads[i_col].col = i_col; + suppressed_roads[i_col].pattern = roads[i_col].pattern; + suppressed_roads[i_col].quality = roads[i_col].quality; + } else { + // Debug Info + if (CONFIG.verbosity_ > 2 && roads[i_col].quality > 0) { + std::cout + << "Road Suppressed" + << " zone " << i_zone + << " col " << i_col + << " pat " << roads[i_col].pattern + << " qual " << roads[i_col].quality + << std::endl; + } + + // Suppress + suppressed_roads[i_col].zone = i_zone; + suppressed_roads[i_col].col = i_col; + suppressed_roads[i_col].pattern = roads[i_col].pattern; + suppressed_roads[i_col].quality = 0; + } + } + } + + // Keep best of every pair + const int keep_n_roads = v3::kHitmapNCols / 2; + + road_t roads_kept[keep_n_roads]; + + { + for (int i_col = 0; i_col < keep_n_roads; ++i_col) { + bool is_single = (i_col * 2 + 1) >= v3::kHitmapNCols; + + if (is_single || suppressed_roads[i_col * 2].quality > 0) { + roads_kept[i_col] = suppressed_roads[i_col * 2]; + } else { + roads_kept[i_col] = suppressed_roads[i_col * 2 + 1]; + } + + if (CONFIG.verbosity_ > 2 && roads_kept[i_col].quality > 0) { + std::cout + << "Road Kept" + << " zone " << roads_kept[i_col].zone + << " col " << roads_kept[i_col].col + << " pat " << roads_kept[i_col].pattern + << " qual " << roads_kept[i_col].quality + << std::endl; + } + } + } + + // Mergesort-reduce to n best roads + // This will sort descending order (higher-value means lower-index) and keep the first n roads + + // Sort the first 32 cols since there are 144 columns and we wish to sort powers of 2, therefore 128 to keep priorities. + data::mergesort(roads_kept, 32, 16, [](const road_t& lhs, const road_t& rhs) -> int { + return lhs.quality < rhs.quality; + }); + + // Shift everything 16 cols to the left + for (int i = 16; i < keep_n_roads; ++i) { + roads_kept[i] = roads_kept[i + 16]; + } + + // Merge-sort the remaining 128 cols + data::mergesort(roads_kept, 128, first_n, [](const road_t& lhs, const road_t& rhs) -> int { + return lhs.quality < rhs.quality; + }); + + // Collect best roads + for (int i_col = 0; i_col < first_n; ++i_col) { + top_roads.push_back(roads_kept[i_col]); + } + } // End Loop Zones + + // Debug Info + if (CONFIG.verbosity_ > 2) { + for (const auto& road : top_roads) { + // Short-Circuit: Skip quality-0 roads + if (road.quality == 0) { + continue; + } + + std::cout + << "Top Road" + << " zone " << road.zone + << " col " << road.col + << " pat " << road.pattern + << " qual " << road.quality + << std::endl; + } + } + + // Mergesort-reduce to n best roads + // This will sort descending order (higher-value means lower-index) and keep the first n roads + + // Sort the first 8 cols since there are 12 cols and we wish to sort powers of 2, therefore 8 to keep priorities + data::mergesort(&top_roads[0], 8, 4, [](const road_t& lhs, const road_t& rhs) -> int { + return lhs.quality < rhs.quality; + }); + + // Shift everything 4 cols to the left + for (unsigned int i = 4; i < top_roads.size(); ++i) { + top_roads[i] = top_roads[i + 4]; + } + + // Merge-sort remaining 8 cols + data::mergesort(&top_roads[0], 8, first_n, [](const road_t& lhs, const road_t& rhs) -> int { + return lhs.quality < rhs.quality; + }); + + // Collect best roads + for (int i_road = 0; i_road < first_n; ++i_road) { + const auto& road = top_roads[i_road]; + + best_roads.push_back(road); + + // Debug Info + if (CONFIG.verbosity_ > 1 && road.quality > 0) { + std::cout + << "Best Road " << i_road + << " zone " << road.zone + << " col " << road.col + << " pat " << road.pattern + << " qual " << road.quality + << std::endl; + } + } +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc new file mode 100644 index 0000000000000..909fb1bc127c9 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc @@ -0,0 +1,602 @@ +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h" + +using namespace emtf::phase2; +using namespace emtf::phase2::algo; + +// Static +seg_theta_t TrackBuildingLayer::calc_theta_median( + std::vector thetas +) { + auto i_last = thetas.size() - 1; + + // Sort Thetas + // This will sort ascending order (lower-value means lower-index) + data::mergesort(&thetas[0], thetas.size(), [](seg_theta_t lower_index_value, seg_theta_t larger_index_value) -> int { + return when(lower_index_value > larger_index_value, 1, 0); + }); + + // Check if any model_thm_site is null + // Since the theta array has been sorted, it's enough + // to check the last index, because the invalid value will be the max + seg_theta_t invalid_theta = -1; // This maps to 255 since it underflows + + bool any_invalid = thetas[i_last] == invalid_theta; + + // Calculate median + if (any_invalid) { + // Use the min value as the median if there are any invalid thetas + return thetas[0]; + } else { + // Calculate the median if all thetas are valid + return data::median_of_sorted(&thetas[0], thetas.size()); + } +} + +// Members +TrackBuildingLayer::TrackBuildingLayer( + const EMTFContext& context +): + context_(context) +{ + // Do Nothing +} + +TrackBuildingLayer::~TrackBuildingLayer() { + // Do Nothing +} + +void TrackBuildingLayer::apply( + const segment_collection_t& segments, + const std::vector& roads, + const bool& displaced_en, + std::vector& tracks +) const { + // Apply + for (unsigned int i_road = 0; i_road < roads.size(); ++i_road) { + // Get road and track + const auto& road = roads[i_road]; + auto& track = tracks.emplace_back(); + + // Initialize track + track.phi = 0; + track.theta = 0; + track.valid = 0; + + for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + track.site_segs[site_id] = 0; + track.site_mask[site_id] = 0; + track.site_rm_mask[site_id] = 0; + } + + for (int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { + track.features[i_feature] = 0; + } + + // Short-Circuit: If the road has quality-0 skip it + if (road.quality == 0) { + continue; + } + + // Debug Info + if (CONFIG.verbosity_ > 1) { + if (i_road == 0) { + std::cout << std::endl; + std::cout << "===========================================================================" << std::endl; + std::cout << "BEGIN TRACK BUILDING" << std::endl; + std::cout << "---------------------------------------------------------------------------" << std::endl; + } + + std::cout << "***************************************************************************" << std::endl; + std::cout << "Begin building track " << i_road << std::endl; + } + + // Attach segments + attach_segments(segments, road, displaced_en, track); + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << "End building track " << i_road << std::endl; + + if (i_road == (roads.size() - 1)) { + std::cout << "---------------------------------------------------------------------------" << std::endl; + std::cout << "END TRACK BUILDING" << std::endl; + std::cout << "===========================================================================" << std::endl; + } + } + } +} + +void TrackBuildingLayer::attach_segments( + const segment_collection_t& segments, + const road_t& road, + const bool& displaced_en, + track_t& track +) const { + // =========================================================================== + // Constants + // --------------------------------------------------------------------------- + seg_theta_t invalid_theta = -1; // This will map to 255 since it underflows + + // =========================================================================== + // Unpack road + // --------------------------------------------------------------------------- + // trk_col: Recall that the hitmap is 288 cols wide, and the full chamber hitmap is 315 cols; + // the chamber hitmap doesn't fit in the hitmap, so we skipped the first 27 cols. + // In order to calculate the full hitmap col, we need to add back the 27 cols that we skipped. + // sector_col: The sector's column is the center col of the phi map adding back the 27 skipped cols. + const auto trk_zone = road.zone; + const auto trk_pattern = road.pattern; + const auto trk_quality = road.quality; + + int bit_sel_zone = (1u << trk_zone); + + const trk_col_t trk_col = road.col + v3::kHitmapCropColStart; + const trk_col_t sector_col = static_cast(v3::kHitmapNCols / 2) + v3::kHitmapCropColStart; + + // =========================================================================== + // Initialize vars + // --------------------------------------------------------------------------- + std::array trk_seg_phi_diff; + std::array trk_seg_theta; + + for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + trk_seg_phi_diff[site_id] = 0; + trk_seg_theta [site_id] = 0; + } + + // =========================================================================== + // Unpack model + // --------------------------------------------------------------------------- + const auto& model = context_.model_; + const auto& model_hm = model.zones_[trk_zone].hitmap; + const auto& model_ftc = model.features_; + + auto* model_pat = &(model.zones_[trk_zone].prompt_patterns[trk_pattern]); + + if (displaced_en) { + model_pat = &(model.zones_[trk_zone].disp_patterns[trk_pattern]); + } + + // =========================================================================== + // Convert column center to emtf_phi units + // --------------------------------------------------------------------------- + // Each column is emtf_phi=1<(trk_col) << v3::kHitmapColFactorLog2) + (1 << (v3::kHitmapColFactorLog2 - 1)); + seg_phi_t sector_abs_phi = (static_cast(sector_col) << v3::kHitmapColFactorLog2) + (1 << (v3::kHitmapColFactorLog2 - 1)); + + // Calculate track phi + // Note this is the track phi with respect to the sector center + trk_feature_t trk_rel_phi = static_cast(trk_abs_phi) - static_cast(sector_abs_phi); + + // =========================================================================== + // Get pattern info for each row + // --------------------------------------------------------------------------- + std::array trk_pat_begin; + std::array trk_pat_center; + std::array trk_pat_end; + std::array trk_pat_phi; + + for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { + // Get the model pattern + const auto& model_pat_row = (*model_pat)[i_row]; + + // Offset the pattern's begin, center, and end by the track column + trk_pat_begin[i_row] = trk_col + model_pat_row.begin; + trk_pat_center[i_row] = trk_col + model_pat_row.center; + trk_pat_end[i_row] = trk_col + model_pat_row.end; + trk_pat_phi[i_row] = 0; + + // Short-Circuit: If the pattern's center is less than the padding used + // when matching the pattern to the hitmap then the pattern center is 0. + // This is because at that point, the center is out-of-bounds. + if (trk_pat_center[i_row] <= v3::kPatternMatchingPadding) + continue; + + // When the center is beyond the padding, then the pattern + // is in-bound, therefore we subtract the padding offset. + // To get the center in terms of the non-padded row BW we need to remove padding + // since col-padding + 1 should map to 1 in the non-padded hitmap + const auto& temp_trk_pat_center = trk_pat_center[i_row] - v3::kPatternMatchingPadding; + + // Convert the pattern center to emtf_phi units + trk_pat_phi[i_row] = (static_cast(temp_trk_pat_center) << v3::kHitmapColFactorLog2) + (1 << (v3::kHitmapColFactorLog2 - 1)); + } + + // =========================================================================== + // Select segments using phi only + // --------------------------------------------------------------------------- + int n_rows = model_hm.size(); + + std::vector> site_chambers = { + { 0, 1, 2, 9, 10, 11, 45}, // ME1/1 + { 3, 4, 5, 12, 13, 14, 46}, // ME1/2 + { 18, 19, 20, 48, 21, 22, 23, 24, 25, 26, 49}, // ME2/1 + ME2/2 + { 27, 28, 29, 50, 30, 31, 32, 33, 34, 35, 51}, // ME3/1 + ME3/2 + { 36, 37, 38, 52, 39, 40, 41, 42, 43, 44, 53}, // ME4/1 + ME4/2 + { 57, 58, 59, 66, 67, 68, 100}, // RE1/2 + { 75, 76, 77, 78, 79, 80, 103}, // RE2/2 + { 81, 82, 83, 104, 84, 85, 86, 87, 88, 89, 105}, // RE3/1 + RE3/2 + { 90, 91, 92, 106, 93, 94, 95, 96, 97, 98, 107}, // RE4/1 + RE4/2 + { 54, 55, 56, 63, 64, 65, 99}, // GE1/1 + { 72, 73, 74, 102}, // GE2/1 + {108, 109, 110, 111, 112, 113, 114} // ME0 + }; + + std::vector site_chamber_orders = { + 0, 0, 2, 2, 2, 0, 0, 2, 2, 0, 1, 0 + }; + + std::vector> chamber_orders = { + {-1, -1, 6, -1, 0, 1, -1, 2, 3, -1, 4, 5}, + { 3, -1, -1, 0, -1, -1, 1, -1, -1, 2, -1, -1}, + { 3, -1, 10, 0, 4, 5, 1, 6, 7, 2, 8, 9} + }; + + for (int i_row = 0; i_row < n_rows; ++i_row) { // Begin loop rows + + const auto& model_hm_row = model_hm[i_row]; + + const auto& trk_pat_row_begin = trk_pat_begin[i_row]; + const auto& trk_pat_row_end = trk_pat_end[i_row]; + const auto& trk_pat_row_phi = trk_pat_phi[i_row]; + + if (CONFIG.verbosity_ > 2) { + std::cout + << "Pattern Row:" + << " row " << i_row + << " begin " << trk_pat_row_begin + << " end " << trk_pat_row_end + << " phi " << trk_pat_row_phi + << std::endl; + } + + for (const auto& model_hm_site : model_hm_row) { // Begin loop sites in row + + const int site_id = static_cast(model_hm_site.id); + + auto& site_seg_id = track.site_segs [site_id]; + auto& site_bit = track.site_mask [site_id]; + auto& site_min_phi_diff = trk_seg_phi_diff[site_id]; + + const auto& s_chambers = site_chambers[site_id]; + const auto& s_chamber_order_id = site_chamber_orders[site_id]; + const auto& s_chamber_order = chamber_orders[s_chamber_order_id]; + + for (const auto& chamber_idx : s_chamber_order) { // Begin loop chambers in site + + if (chamber_idx == -1) + continue; + + int chamber_id = s_chambers[chamber_idx]; + + for (int i_ch_seg = 0; i_ch_seg < v3::kChamberSegments; ++i_ch_seg) { // Begin loop segments + + const int seg_id = chamber_id * v3::kChamberSegments + i_ch_seg; + const auto& seg = segments[seg_id]; + + // Short-Circuit: If the segment is invalid move on + if (!seg.valid) { + continue; + } + + // Short-Circuit: If the segment is not in the zone move on + if ((seg.zones & bit_sel_zone) != bit_sel_zone) { + continue; + } + + // Short-Circuit: If the segment is outside of the pattern move on + const trk_col_t seg_col = (seg.phi >> 4) + v3::kPatternMatchingPadding; + + if (!(trk_pat_row_begin <= seg_col && seg_col <= trk_pat_row_end)) { + continue; + } + + // Calculate abs diff between the pattern's row phi and the segment's phi + seg_phi_t diff; + + if (trk_pat_row_phi > seg.phi) { + diff = trk_pat_row_phi - seg.phi; + } else { + diff = seg.phi - trk_pat_row_phi; + } + + if (CONFIG.verbosity_ > 2) { + std::cout + << "Site candidate:" + << " site_id " << site_id + << " seg_id " << seg_id + << " seg_phi " << seg.phi + << " seg_theta1 " << seg.theta1 + << " seg_theta2 " << seg.theta2 + << " seg_bend " << seg.bend + << std::endl; + } + + // Short-Circuit: If the difference is larger than the min diff move on + if (site_bit == 1 && site_min_phi_diff <= diff) + continue; + + // Select better segment + site_seg_id = seg_id; + site_bit = 1 ; + site_min_phi_diff = diff ; + } // End loop segments + + } // End loop chambers in site + + // Debug Info + if (CONFIG.verbosity_ > 2 && site_bit == 1) { + std::cout + << "Segment attached:" + << " site_id " << site_id + << " seg_id " << site_seg_id + << " seg_phi " << segments[site_seg_id].phi + << " seg_theta1 " << segments[site_seg_id].theta1 + << " seg_theta2 " << segments[site_seg_id].theta2 + << " seg_bend " << segments[site_seg_id].bend + << std::endl; + } + } // End loop sites in row + + } // End loop rows + + // =========================================================================== + // Calculate theta medians + // --------------------------------------------------------------------------- + const auto& model_thmc = model.theta_medians_; + + std::vector theta_medians; + + for (const auto& model_thm : model_thmc) { // Begin loop model theta medians + + std::vector group_medians; + + for (const auto& model_thm_group : model_thm) { // Begin loop theta median groups + + std::vector group; + + for (const auto& model_thm_site : model_thm_group) { // Begin loop group sites + int site_id = static_cast(model_thm_site.id); + + const auto& site_bit = track.site_mask[site_id]; + + // Initialize as invalid theta + auto& theta = group.emplace_back(invalid_theta); + + // Short-Circuit: If no segment was selected, move on. + if (site_bit == 0) + continue; + + // Get selected segment's theta value + const auto& site_seg_id = track.site_segs[site_id]; + const auto& site_seg = segments [site_seg_id]; + + if (model_thm_site.theta_id == theta_id_t::kTheta1) { + theta = site_seg.theta1; + } else if (model_thm_site.theta_id == theta_id_t::kTheta2) { + theta = site_seg.theta2; + } + + // If the segment theta is 0 this is invalid theta value + if (theta == 0) { + theta = invalid_theta; + } + } // End loop group sites + + // Calculate theta median + if (CONFIG.verbosity_ > 2) { + for (const auto& theta : group) { + std::cout + << "theta " << theta + << std::endl; + } + } + + auto group_median = calc_theta_median(group); + group_medians.push_back(group_median); + + if (CONFIG.verbosity_ > 2) { + std::cout + << "group_median " << group_median + << std::endl; + } + } // End loop theta median groups + + // Calculate model_thm_group median + auto theta_median = calc_theta_median(group_medians); + theta_medians.push_back(theta_median); + + if (CONFIG.verbosity_ > 2) { + std::cout + << "theta_median " << theta_median + << std::endl; + } + } // End loop theta medians + + // =========================================================================== + // Select track theta + // --------------------------------------------------------------------------- + seg_theta_t trk_abs_theta; + + if (trk_zone != 2) { + trk_abs_theta = theta_medians[0]; + } else { + trk_abs_theta = theta_medians[1]; + } + + // If median is invalid, try station 1 median + if (trk_abs_theta == invalid_theta) { + trk_abs_theta = theta_medians[2]; + } + + // If all medians are invalid use 0 (0 is an invalid theta) + if (trk_abs_theta == invalid_theta) { + trk_abs_theta = 0; + } + + // =========================================================================== + // Compare segment theta to track theta + // --------------------------------------------------------------------------- + + // if theta_window < diff, it is invalid + std::vector> site_theta_window = { + { 4, 0, 4, 4, 4, 0, 0, 6, 6, 6, 4, 7}, + { 5, 10, 5, 4, 4, 14, 7, 7, 7, 7, 6, 4}, + {11, 6, 5, 6, 6, 11, 8, 8, 9, 10, 8, 0} + }; + + if (displaced_en) { + site_theta_window = { + {14, 32, 5, 5, 5, 34, 0, 8, 6, 15, 7, 13}, + {16, 20, 7, 6, 6, 25, 17, 8, 9, 17, 8, 14}, + {27, 14, 8, 10, 10, 18, 11, 10, 11, 26, 20, 0} + }; + } + + for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + auto& site_bit = track.site_mask[site_id]; + auto& site_rm_bit = track.site_rm_mask[site_id]; + + // Get Theta Window + const auto& theta_window = site_theta_window[trk_zone][site_id]; + + // Short-Circuit: If no segment was selected, move on. + if (site_bit == 0) + continue; + + const auto& site_seg_id = track.site_segs[site_id]; + const auto& site_seg = segments [site_seg_id]; + + // Init differences with out-of-bounds values + seg_theta_t diff_1 = theta_window + 1; + seg_theta_t diff_2 = theta_window + 1; + + // Calculate abs theta 1 diff + if (site_seg.theta1 != 0) { + if (site_seg.theta1 < trk_abs_theta) { + diff_1 = trk_abs_theta - site_seg.theta1; + } else { + diff_1 = site_seg.theta1 - trk_abs_theta; + } + } + + // Calculate abs theta 2 diff + if (site_seg.theta2 != 0) { + if (site_seg.theta2 < trk_abs_theta) { + diff_2 = trk_abs_theta - site_seg.theta2; + } else { + diff_2 = site_seg.theta2 - trk_abs_theta; + } + } + + // Select the theta with the smallest difference + if (diff_1 <= diff_2 && diff_1 < theta_window){ + // Select theta 1 as the correct theta value + trk_seg_theta[site_id] = site_seg.theta1; + } else if (diff_2 < theta_window){ + // Select theta 2 as the correct theta value + trk_seg_theta[site_id] = site_seg.theta2; + } else { + // Invalidate site if both differences are outside of the theta window + site_bit = 0; + site_rm_bit = 1; + + // Debug Info + if (CONFIG.verbosity_ > 4) { + std::cout + << "Segment outside of theta window; detatched:" + << " site_id " << site_id + << " seg_id " << site_seg_id + << " seg_phi " << site_seg.phi + << " seg_theta1 " << site_seg.theta1 + << " seg_theta2 " << site_seg.theta2 + << std::endl; + } + } + } + + // =========================================================================== + // Assign Data + // --------------------------------------------------------------------------- + track.zone = trk_zone; + track.col = trk_col; + track.pattern = trk_pattern; + track.quality = trk_quality; + track.phi = trk_abs_phi; + track.theta = trk_abs_theta; + track.valid = 1; + + // =========================================================================== + // Fill features + // --------------------------------------------------------------------------- + int i_feature = 0; + + for (auto& model_ft : model_ftc) { + for (auto& model_ft_site : model_ft.sites) { + int site_id = static_cast(model_ft_site); + + const auto& site_seg_id = track.site_segs[site_id]; + const auto& site_bit = track.site_mask[site_id]; + const auto& site_seg = segments [site_seg_id]; + + auto& trk_feature = track.features[i_feature++]; + + // Short-Circuit: No segment attached + if (site_bit == 0) { + continue; + } + + // Fill features + if (model_ft.id == feature_id_t::kPhi) { + // Note: This is the segment's phi with respect to the track's abs phi + trk_feature = static_cast(site_seg.phi) - static_cast(trk_abs_phi); + } else if (model_ft.id == feature_id_t::kTheta) { + // Note: This is the segment's theta with respect to the track's abs theta + trk_feature = static_cast(trk_seg_theta[site_id]) - static_cast(trk_abs_theta); + } else if (model_ft.id == feature_id_t::kBend) { + trk_feature = site_seg.bend; + } else if (model_ft.id == feature_id_t::kQuality) { + trk_feature = site_seg.qual1; + } + } + } + + // Additional features + track.features[i_feature++] = when(trk_quality > 0, trk_rel_phi, 0); + track.features[i_feature++] = when(trk_quality > 0, trk_abs_theta, 0); + track.features[i_feature++] = trk_quality; + track.features[i_feature++] = 0; // unused + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout + << "Track" + << " zone " << track.zone + << " col " << track.col + << " pat " << track.pattern + << " qual " << track.quality + << " sector_abs_phi " << sector_abs_phi + << " abs_phi " << track.phi + << " rel_phi " << trk_rel_phi + << " abs_theta " << track.theta + << " features " + << std::endl; + + for (int i = 0; i < v3::kNumTrackFeatures; ++i) { + if (i > 0) { + std::cout << " "; + } + + std::cout << track.features[i]; + } + + std::cout << std::endl; + } +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc new file mode 100644 index 0000000000000..ae5c8c31aeb6e --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc @@ -0,0 +1,226 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h" + +using namespace emtf::phase2; + +CSCTPCollector::CSCTPCollector( + const EMTFContext& context, + edm::ConsumesCollector& i_consumes_collector): + context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("CSCInput"))) +{ + // Do Nothing +} + +CSCTPCollector::~CSCTPCollector() { + // Do Nothing +} + +void CSCTPCollector::collect( + const edm::Event& i_event, + BXTPCMap& bx_tpc_map +) const { + edm::Handle csc_digis; + i_event.getByToken(input_token_, csc_digis); + + // Collect + TPCollection tpc; + + auto chamber = csc_digis->begin(); + auto chend = csc_digis->end(); + + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; + + for (; digi != dend; ++digi) { + tpc.emplace_back((*chamber).first, *digi); + } + } + + // Find wires + std::map< + std::pair, + std::vector + > chamber_wires_map; + + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + + const CSCData& tp_data = tp_entry.tp_.getCSCData(); + const int tp_bx = tp_data.bx + CONFIG.csc_bx_shift_; + const int tp_wire = tp_data.keywire; + + auto key = std::make_pair(tp_det_id.rawId(), tp_bx); + auto res = chamber_wires_map.find(key); + + if (res == chamber_wires_map.end()) { + // Case: Chamber not found + chamber_wires_map[key].push_back(tp_wire); + } else { + // Case: Chamber found + // Lookup wire if found move on, otherwise add it. + bool wire_found = false; + + auto& chamber_wires = res->second; + + for (const auto& a_wire : chamber_wires) { + // Short-Circuit: If wire matches stop + if (a_wire == tp_wire) { + wire_found = true; + break; + } + } + + // Case: Wire not found, add it. + if (!wire_found) { + chamber_wires.push_back(tp_wire); + } + } + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const CSCData& tp_data = tp_entry.tp_.getCSCData(); + + const int tp_endcap = tp_det_id.endcap(); // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + const int tp_sector = tp_det_id.triggerSector(); + const int tp_station = tp_det_id.station(); + const int tp_ring = tp_det_id.ring(); + const int tp_chamber = tp_det_id.chamber(); + const int tp_layer = tp_det_id.layer(); + + const int tp_csc_id = tp_data.cscID; + + const int tp_bx = tp_data.bx + CONFIG.csc_bx_shift_; + + // Get wires + int tp_wire1 = tp_data.keywire; + int tp_wire2 = -1; + + auto tp_wire_key = std::make_pair(tp_det_id.rawId(), tp_bx); + const auto& tp_wires = chamber_wires_map.at(tp_wire_key); + + emtf_assert((1 <= tp_wires.size()) && (tp_wires.size() <= 2)); + + if (tp_wires.size() > 1) { + tp_wire1 = tp_wires.at(0); + tp_wire2 = tp_wires.at(1); + } + + // Calculate detector info + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const auto tp_face_dir = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + const auto& [max_strip, max_wire] = csc::get_max_strip_and_wire(tp_station, tp_ring); + const auto& [max_pattern, max_quality] = csc::get_max_pattern_and_quality(tp_station, tp_ring); + + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert((0 <= tp_subsector) and (tp_subsector <= 2)); + emtf_assert(1 <= tp_station && tp_station <= 4); + emtf_assert(1 <= tp_ring && tp_ring <= 4); + emtf_assert(1 <= tp_chamber && tp_chamber <= 36); + emtf_assert(1 <= tp_csc_id && tp_csc_id <= 9); + emtf_assert(tp_data.strip < max_strip); + emtf_assert(tp_data.keywire < max_wire); + emtf_assert(tp_data.pattern < max_pattern); + emtf_assert(0 < tp_data.quality && tp_data.quality < max_quality); + emtf_assert(tp_data.valid); + + // Check for corrupted LCT data. Data corruption could occur due to software + // or hardware issues, if corrupted, reject the LCT. + if (!(tp_data.strip < max_strip)) { + edm::LogWarning("L1T") << "Found error in LCT strip: " << tp_data.strip + << " (allowed range: 0-" << max_strip - 1 << ")."; + + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + + continue; + } + + if (!(tp_data.keywire < max_wire)) { + edm::LogWarning("L1T") << "Found error in LCT wire: " << tp_data.keywire + << " (allowed range: 0-" << max_wire - 1 << ")."; + + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + + continue; + } + + if (!(tp_data.valid == true)) { + edm::LogWarning("L1T") << "Found error in LCT valid: " << tp_data.valid << " (allowed value: 1)."; + + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + + continue; + } + + if (!(tp_data.pattern < max_pattern)) { + edm::LogWarning("L1T") << "Found error in LCT pattern: " << tp_data.pattern + << " (allowed range: 0-" << max_pattern - 1 << ")."; + + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + + continue; + } + + if (!(0 < tp_data.quality && tp_data.quality < max_quality)) { + edm::LogWarning("L1T") << "Found error in LCT quality: " << tp_data.quality + << " (allowed range: 1-" << max_quality - 1 << ")."; + + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + + continue; + } + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.chamber = tp_chamber; + tp_entry.info_.layer = tp_layer; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_face_dir; + tp_entry.info_.csc_first_wire = tp_wire1; + tp_entry.info_.csc_second_wire = tp_wire2; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc new file mode 100644 index 0000000000000..5636af4deece1 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc @@ -0,0 +1,190 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h" + +using namespace emtf::phase2; + +CSCTPConverter::CSCTPConverter(const EMTFContext& context, + const int& endcap, const int& sector): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +CSCTPConverter::~CSCTPConverter() { + // Do Nothing +} + +void CSCTPConverter::convert( + const TriggerPrimitive& tp, + const TPInfo& tp_info, + EMTFHit& hit +) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const auto& tp_segment_id = tp_info.segment_id; + + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getCSCData(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kCSC; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_chamber = tp_info.chamber; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_layer = tp_info.layer; + + const int tp_csc_id = tp_info.csc_id; + const auto tp_csc_facing = tp_info.csc_facing; + + // Unpack data + const int tp_strip = tp_data.strip; + const int tp_strip_quart_bit = tp_data.strip_quart_bit; + const int tp_strip_eighth_bit = tp_data.strip_eighth_bit; + const int tp_strip_quart = tp_data.strip_quart; + const int tp_strip_eighth = tp_data.strip_eighth; + + const int tp_wire1 = tp_info.csc_first_wire; + const int tp_wire2 = tp_info.csc_second_wire; + + int tp_bend; + const int tp_slope = tp_data.slope; + + const int tp_bx = tp_info.bx; + const int tp_subbx = 0; // no fine resolution timing + const float tp_time = 0; // no fine resolution timing. Note: Check with Efe, Jia Fu gets this from digi directly. + + const auto tp_selection = tp_info.selection; + + const int tp_pattern = tp_data.pattern; + const int tp_quality = 6; + + // Apply CSC Run 2 pattern -> bend conversion + // Override tp_bend + constexpr int tp_bend_lut_size = 11; + constexpr int tp_bend_lut[tp_bend_lut_size] = {-5, 5, -4, 4, -3, 3, -2, 2, -1, 1, 0}; + emtf_assert(tp_pattern < tp_bend_lut_size); + tp_bend = tp_bend_lut[tp_pattern]; + tp_bend *= tp_endcap_pm; // sign flip depending on endcap + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + const GlobalPoint& gp_w1 = GEOM.getGlobalPoint(tp); + const float glob_phi_w1 = tp::rad_to_deg(gp_w1.phi().value()); + const float glob_theta_w1 = tp::rad_to_deg(gp_w1.theta().value()); + const double glob_rho_w1 = gp_w1.perp(); + const double glob_z_w1 = gp_w1.z(); + + // Calculate EMTF Values + const int emtf_phi_w1 = tp::calc_phi_int(sector_, glob_phi_w1); + const int emtf_bend_w1 = std::clamp(tp_bend * 4, -16, 15); // 5-bit, signed + const int emtf_theta_w1 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w1); + const int emtf_qual_w1 = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned + const int emtf_site_w1 = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host_w1 = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones_w1 = context_.zone_lut_.get_zones(emtf_host_w1, emtf_theta_w1); + + // Calculated Ambiguous Info + int emtf_theta_w2 = 0; + int emtf_qual_w2 = tp_pattern; + + if (tp_wire2 > -1) { + auto tp_w2 = tp; + + tp_w2.accessCSCData().keywire = tp_wire2; + + const GlobalPoint& gp_w2 = GEOM.getGlobalPoint(tp_w2); + const double glob_theta_w2 = tp::rad_to_deg(gp_w2.theta().value()); + + emtf_theta_w2 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w2); + } + + emtf_assert((0 <= emtf_phi_w1) and (emtf_phi_w1 < 5040)); + emtf_assert((1 <= emtf_theta_w1) and (emtf_theta_w1 < 128)); + emtf_assert((0 <= emtf_theta_w2) and (emtf_theta_w2 < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = tp_data.valid; + + // Set properties + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(L1TMuon::kCSC); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_chamber); + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_strip); + hit.setStripLo(tp_strip); + hit.setStripHi(tp_strip); + hit.setStripQuart(tp_strip_quart); + hit.setStripEighth(tp_strip_eighth); + hit.setStripQuartBit(tp_strip_quart_bit); + hit.setStripEighthBit(tp_strip_eighth_bit); + + hit.setWire1(tp_wire1); + hit.setWire2(tp_wire2); + + hit.setBend(tp_bend); + hit.setSlope(tp_slope); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(tp_pattern); + + hit.setGlobPhi(glob_phi_w1); + hit.setGlobTheta(glob_theta_w1); + hit.setGlobPerp(glob_rho_w1); + hit.setGlobZ(glob_z_w1); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi_w1); + hit.setEmtfBend(emtf_bend_w1); + hit.setEmtfTheta1(emtf_theta_w1); + hit.setEmtfTheta2(emtf_theta_w2); + hit.setEmtfQual1(emtf_qual_w1); + hit.setEmtfQual2(emtf_qual_w2); + hit.setEmtfSite(emtf_site_w1); + hit.setEmtfHost(emtf_host_w1); + hit.setEmtfZones(emtf_zones_w1); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc new file mode 100644 index 0000000000000..91cd575688f5a --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc @@ -0,0 +1,154 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h" + +using namespace emtf::phase2; + +CSCTPSelector::CSCTPSelector( + const EMTFContext& context, + const int& endcap, const int& sector +): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +CSCTPSelector::~CSCTPSelector() { + // Do Nothing +} + +void CSCTPSelector::select( + const TriggerPrimitive& tp, + TPInfo tp_info, + ILinkTPCMap& ilink_tpc_map +) const { + + emtf_assert(tp.subsystem() == L1TMuon::kCSC); + + // Map CSC trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns CSC "link" index (0 - 53) + + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } + + // FIXME + if (ilink_tpc_map[ilink].size() < 2) { + ilink_tpc_map[ilink].emplace_back(tp, tp_info); + } else { + edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; + edm::LogWarning("L1T") << "Found 3 CSC trigger primitives in the same chamber"; + + for (int i_tp = 0; i_tp < 3; i_tp++) { + const auto& tp_err = ((i_tp < 2) ? ilink_tpc_map[ilink].at(i_tp).tp_ : tp); + + edm::LogWarning("L1T") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap " + << tp_err.detId().endcap() << ", sector " + << tp_err.detId().triggerSector() << ", station " + << tp_err.detId().station() << ", ring " << tp_err.detId().ring() + << ", chamber " << tp_err.detId().chamber() << ", CSC ID " + << tp_err.getCSCData().cscID << ": strip " << tp_err.getStrip() << ", wire " + << tp_err.getWire(); + } + + edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n"; + } +} + +// =========================================================================== +// Utils +// =========================================================================== +int CSCTPSelector::get_input_link( + const TriggerPrimitive& tp, + TPInfo& tp_info +) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_csc_id = tp_info.csc_id; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if ( + csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) + ) { + tp_selection = TPSelection::kNative; + } else if ( + CONFIG.include_neighbor_en_ + && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) + ) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone + return ilink; + } + + // Get chamber input link for this sector processor + ilink = calculate_input_link( + tp_subsector, tp_station, + tp_ring, tp_csc_id, + tp_selection + ); + + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; + + return ilink; +} + +// Returns CSC input "link". Index used by FW for unique chamber identification. +int CSCTPSelector::calculate_input_link( + const int& tp_subsector, const int& tp_station, + const int& tp_ring, const int& tp_csc_id, + const TPSelection& tp_selection +) const { + int ilink = -1; + + // Links + // ME1,2,3,4 : 0..17, 18..26, 27..35, 36..44 + // ME1,2,3,4 (N) : 45..47, 48..49, 50..51, 52..53 + + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 0; + + if (tp_station == 1) { + ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); + } else { + ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); + } + + emtf_assert((0 <= ilink) && (ilink < 45)); + } else { + const int ilink_offset = 45; + + if (tp_station == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + (tp_csc_id - 1) / 3; + } else if (tp_ring == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + 1; + } else { + ilink = ilink_offset + ((tp_station - 1) * 2) + 2; + } + + emtf_assert((45 <= ilink) && (ilink < 54)); + } + + return ilink; +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc new file mode 100644 index 0000000000000..d6d3c4433729f --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc @@ -0,0 +1,148 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h" + +using namespace emtf::phase2; + +GE0TPCollector::GE0TPCollector( + const EMTFContext& context, + edm::ConsumesCollector& i_consumes_collector): + context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("GE0Input"))) +{ + // Do Nothing +} + +GE0TPCollector::~GE0TPCollector() { + // Do Nothing +} + +void GE0TPCollector::collect( + const edm::Event& i_event, + BXTPCMap& bx_tpc_map) const { + // Constants + // First quarter of GE0 chamber (5 deg) and last quarter + static const int me0_max_partition = 9; + static const int me0_nstrips = 384; + static const int me0_nphipositions = me0_nstrips * 2; + static const int phiposition_q1 = me0_nphipositions / 4; + static const int phiposition_q3 = (me0_nphipositions / 4) * 3; + + // Read GE0 digis + TPCollection tpc; + + edm::Handle me0_digis; + i_event.getByToken(input_token_, me0_digis); + + auto chamber = me0_digis->begin(); + auto chend = me0_digis->end(); + + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; + + for (; digi != dend; ++digi) { + tpc.emplace_back((*chamber).first, *digi); + } + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const ME0Data& tp_data = tp_entry.tp_.getME0Data(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + const int tp_station = 1; // ME0DetId station was always 1! + const int tp_ring = 4; + const int tp_layer = tp_det_id.layer(); + const int tp_roll = tp_det_id.roll(); + const int tp_me0_chamber = tp_det_id.chamber(); + + const int tp_pad = tp_data.phiposition; + const int tp_partition = tp_data.partition; + const int tp_bx = tp_data.bx + CONFIG.me0_bx_shift_; + + // Reject if outside eta of 2.4 + if (tp_partition > me0_max_partition) { + continue; + } + + // Calculate EMTF Info + // Split 20-deg chamber into 10-deg chamber + // GE0 chamber is rotated by -5 deg relative to CSC chamber. + // GE0 chamber 1 starts at -10 deg, CSC chamber 1 starts at -5 deg. + const int tp_phiposition = tp_data.phiposition; // in half-strip unit + + int tp_chamber = (tp_me0_chamber - 1) * 2 + 1; + + if (tp_endcap == 1) { + // positive endcap + // phiposition increases counter-clockwise + if (tp_phiposition < phiposition_q1) { + tp_chamber = csc::next_10deg_chamber(tp_chamber); + } else if (tp_phiposition < phiposition_q3) { + // Do nothing + } else { + tp_chamber = csc::prev_10deg_chamber(tp_chamber); + } + } else { + // negative endcap + // phiposition increases clockwise + if (tp_phiposition < phiposition_q1) { + tp_chamber = csc::prev_10deg_chamber(tp_chamber); + } else if (tp_phiposition < phiposition_q3) { + // Do nothing + } else { + tp_chamber = csc::next_10deg_chamber(tp_chamber); + } + } + + const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert((1 <= tp_subsector) and (tp_subsector <= 2)); + emtf_assert(tp_station == 1); + emtf_assert(tp_ring == 4); + emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); + emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); + emtf_assert(0 <= tp_pad && tp_pad <= 767); + emtf_assert(0 <= tp_partition && tp_partition <= 15); + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.layer = tp_layer; + tp_entry.info_.roll = tp_roll; + tp_entry.info_.chamber = tp_chamber; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_csc_facing; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc new file mode 100644 index 0000000000000..ddef2df408bcb --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc @@ -0,0 +1,152 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h" + +using namespace emtf::phase2; + +GE0TPConverter::GE0TPConverter(const EMTFContext& context, + const int& endcap, const int& sector): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +GE0TPConverter::~GE0TPConverter() { + // Do Nothing +} + +void GE0TPConverter::convert( + const TriggerPrimitive& tp, + const TPInfo& tp_info, + EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const int tp_segment_id = tp_info.segment_id; + + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getME0Data(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kME0; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_layer = tp_info.layer; + // const int tp_chamber = tp_info.chamber; + + const int tp_csc_id = tp_info.csc_id; + const auto tp_csc_facing = tp_info.csc_facing; + + // Unpack data + const int tp_phiposition = tp_data.phiposition; // in half-strip unit + const int tp_partition = tp_data.partition; // in half-roll unit + + const int tp_bend = static_cast(tp_data.deltaphi) * (tp_data.bend == 0 ? 1 : -1); + + const int tp_bx = tp_info.bx; + const int tp_subbx = 0; // no fine resolution timing + const float tp_time = 0; // no fine resolution timing. + + const auto tp_selection = tp_info.selection; + + const int tp_quality = tp_data.quality; + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const float glob_phi = tp::rad_to_deg(gp.phi().value()); + const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const double glob_rho = gp.perp(); + const double glob_z = gp.z(); + + // Calculate EMTF Values + const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_bend = std::clamp(tp_bend / 2, -64, 63); // 7-bit, signed + const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_qual = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned + const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + + emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); + emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = true; // given by digi, not trigger_primitive :( + + // Set properties + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(L1TMuon::kME0); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_det_id.chamber()); // Save original chamber + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_phiposition); + hit.setStripLo(tp_phiposition); + hit.setStripHi(tp_phiposition); + + hit.setWire1(tp_partition); + hit.setWire2(0); + + hit.setBend(tp_bend); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(0); + + hit.setGlobPhi(glob_phi); + hit.setGlobTheta(glob_theta); + hit.setGlobPerp(glob_rho); + hit.setGlobZ(glob_z); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi); + hit.setEmtfBend(emtf_bend); + hit.setEmtfTheta1(emtf_theta); + hit.setEmtfTheta2(0); + hit.setEmtfQual1(emtf_qual); + hit.setEmtfQual2(0); + hit.setEmtfSite(emtf_site); + hit.setEmtfHost(emtf_host); + hit.setEmtfZones(emtf_zones); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc new file mode 100644 index 0000000000000..71d0cbf27527c --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc @@ -0,0 +1,119 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h" + +using namespace emtf::phase2; + +GE0TPSelector::GE0TPSelector( + const EMTFContext& context, + const int& endcap, const int& sector +): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +GE0TPSelector::~GE0TPSelector() { + // Do Nothing +} + +void GE0TPSelector::select( + const TriggerPrimitive& tp, + TPInfo tp_info, + ILinkTPCMap& ilink_tpc_map +) const { + emtf_assert(tp.subsystem() == L1TMuon::kME0); + + // Map GE0 trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns GE0 "link" index + + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } + + ilink_tpc_map[ilink].emplace_back(tp, tp_info); +} + +// =========================================================================== +// Utils +// =========================================================================== +int GE0TPSelector::get_input_link( + const TriggerPrimitive& tp, + TPInfo& tp_info +) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_csc_id = tp_info.csc_id; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if ( + csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) + ) { + tp_selection = TPSelection::kNative; + } else if ( + CONFIG.include_neighbor_en_ + && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) + ) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone + return ilink; + } + + // Get chamber input link for this sector processor + ilink = calculate_input_link( + tp_subsector, tp_csc_id, + tp_selection + ); + + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; + + return ilink; +} + +int GE0TPSelector::calculate_input_link( + const int& tp_subsector, const int& tp_csc_id, + const TPSelection& tp_selection +) const { + int ilink = -1; + + // Links + // GE0 : 108..113 + // GE0 (N) : 114 + + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 108; + + ilink = ilink_offset + ((tp_subsector - 1) * 3) + (tp_csc_id - 1); + + emtf_assert((108 <= ilink) && (ilink < 114)); + } else { + const int ilink_offset = 114; + + ilink = ilink_offset; + + emtf_assert(ilink == ilink_offset); + } + + return ilink; +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc new file mode 100644 index 0000000000000..90190bdf92e1e --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc @@ -0,0 +1,208 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" + +using namespace emtf::phase2; + +GEMTPCollector::GEMTPCollector( + const EMTFContext& context, + edm::ConsumesCollector& i_consumes_collector): + context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("GEMInput"))) +{ + // Do Nothing +} + +GEMTPCollector::~GEMTPCollector() { + // Do Nothing +} + +void GEMTPCollector::collect( + const edm::Event& i_event, + BXTPCMap& bx_tpc_map +) const { + // Constants + static const int max_delta_roll = 1; + static const int max_delta_pad_ge11 = 4; + static const int max_delta_pad_ge21 = 4; + + // Read GEM digis + TPCollection tpc; + + edm::Handle gem_digis; + i_event.getByToken(input_token_, gem_digis); + + auto chamber = gem_digis->begin(); + auto chend = gem_digis->end(); + + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; + + for (; digi != dend; ++digi) { + // Short-Circuit: Ignore invalid digis + bool tp_valid = (*digi).isValid(); + + if (!tp_valid) { + continue; + } + + // Append digi + tpc.emplace_back((*chamber).first, *digi); + } + } + + // Find Copads + std::map< + std::pair, + std::vector> + > chamber_copads_map; + + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const GEMData& tp_data = tp_entry.tp_.getGEMData(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_station = tp_det_id.station(); + const int tp_ring = tp_det_id.ring(); + const int tp_chamber = tp_det_id.chamber(); + const int tp_layer = tp_det_id.layer(); + + const uint16_t tp_roll = tp_det_id.roll(); + const uint16_t tp_pad_lo = tp_data.pad_low; + const uint16_t tp_pad_hi = tp_data.pad_hi; + + const int tp_bx = tp_data.bx + CONFIG.gem_bx_shift_; + + GEMDetId tp_mod_det_id(tp_region, tp_ring, tp_station, 0, tp_chamber, 0); + auto key = std::make_pair(tp_mod_det_id.rawId(), tp_bx); + + if (tp_layer == 1) { + // Layer 1 is incidence + // If key does not exist, insert an empty vector. If key exists, do nothing. + decltype(chamber_copads_map)::mapped_type copads; + chamber_copads_map.insert({key, copads}); + } else if (tp_layer == 2) { + // Layer 2 is coincidence + decltype(chamber_copads_map)::mapped_type::value_type copad{{ + tp_roll, + tp_pad_lo, + tp_pad_hi + }}; + chamber_copads_map[key].push_back(copad); + } + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const GEMData& tp_data = tp_entry.tp_.getGEMData(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + const int tp_station = tp_det_id.station(); + const int tp_ring = tp_det_id.ring(); + const int tp_layer = tp_det_id.layer(); + const int tp_chamber = tp_det_id.chamber(); + + const int tp_roll = tp_det_id.roll(); + const int tp_pad = (tp_data.pad_low + tp_data.pad_hi) / 2; + const int tp_pad_lo = tp_data.pad_low; + const int tp_pad_hi = tp_data.pad_hi; + + const int tp_bx = tp_data.bx + CONFIG.gem_bx_shift_; + + // Get Copad Info + GEMDetId tp_mod_det_id(tp_region, tp_ring, tp_station, 0, tp_chamber, 0); + auto tp_copads_key = std::make_pair(tp_mod_det_id.rawId(), tp_bx); + auto tp_copads = chamber_copads_map.at(tp_copads_key); + + // Check Copads + bool tp_is_substitute = false; + + if (tp_layer == 1) { + // layer 1 is used as incidence + const bool is_ge21 = (tp_station == 2); + + auto match_fn = [&tp_roll, &tp_pad_lo, &tp_pad_hi, &is_ge21](const std::array& elem) { + // Unpack entry + // Compare roll and (pad_lo, pad_hi)-range with tolerance + const auto& [c_roll_tmp, c_pad_lo_tmp, c_pad_hi_tmp] = elem; + int c_roll_lo = static_cast(c_roll_tmp) - max_delta_roll; + int c_roll_hi = static_cast(c_roll_tmp) + max_delta_roll; + int c_pad_lo = static_cast(c_pad_lo_tmp) - (is_ge21 ? max_delta_pad_ge21 : max_delta_pad_ge11); + int c_pad_hi = static_cast(c_pad_hi_tmp) + (is_ge21 ? max_delta_pad_ge21 : max_delta_pad_ge11); + + // Two ranges overlap if (range_a_lo <= range_b_hi) and (range_a_hi >= range_b_lo) + return (tp_roll <= c_roll_hi) and (tp_roll >= c_roll_lo) and (tp_pad_lo <= c_pad_hi) and (tp_pad_hi >= c_pad_lo); + }; + + auto match = std::find_if(tp_copads.begin(), tp_copads.end(), match_fn); + + if (match != tp_copads.end()) { + // Has copad + tp_is_substitute = false; + } else if (tp_copads.empty()) { + // Kinda has copad + tp_is_substitute = true; + } else { + // Short-Circuit: Didn't find coincidence + continue; + } + } else if (tp_layer == 2) { + // Short-Circuit: layer 2 is used as coincidence + continue; + } + + // Calculate EMTF Info + const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert((0 <= tp_subsector) and (tp_subsector <= 2)); + emtf_assert(1 <= tp_station && tp_station <= 2); + emtf_assert(tp_ring == 1); + emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); + emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); + emtf_assert(tp_station == 1 or (1 <= tp_roll && tp_roll <= 16)); + emtf_assert(tp_station != 1 or (1 <= tp_roll && tp_roll <= 8)); + emtf_assert(1 <= tp_layer && tp_layer <= 2); + emtf_assert((tp_station == 1 && 0 <= tp_pad && tp_pad <= 191) || (tp_station != 1)); + emtf_assert((tp_station == 2 && 0 <= tp_pad && tp_pad <= 383) || (tp_station != 2)); + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.roll = tp_roll; + tp_entry.info_.layer = tp_layer; + tp_entry.info_.chamber = tp_chamber; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_csc_facing; + + tp_entry.info_.flag_substitute = tp_is_substitute; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc new file mode 100644 index 0000000000000..942e6fcbfdec8 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc @@ -0,0 +1,157 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h" + +using namespace emtf::phase2; + +GEMTPConverter::GEMTPConverter(const EMTFContext& context, + const int& endcap, const int& sector): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +GEMTPConverter::~GEMTPConverter() { + // Do Nothing +} + +void GEMTPConverter::convert( + const TriggerPrimitive& tp, + const TPInfo& tp_info, + EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const auto& tp_segment_id = tp_info.segment_id; + + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getGEMData(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kGEM; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_roll = tp_info.roll; + const int tp_layer = tp_info.layer; + const int tp_chamber = tp_info.chamber; + + const auto tp_csc_facing = tp_info.csc_facing; + const int tp_csc_id = tp_info.csc_id; + + // Unpack data + const int tp_pad_lo = tp_data.pad_low; + const int tp_pad_hi = tp_data.pad_hi; + const int tp_pad = (tp_pad_lo + tp_pad_hi) / 2; + const int tp_clus_width = (tp_pad_hi - tp_pad_lo + 1); + + const int tp_bend = 0; // not applicable + + const int tp_bx = tp_info.bx; + const int tp_subbx = 0; // no fine resolution timing + const float tp_time = 0; // no fine resolution timing. Note: Check with Efe, Jia Fu gets this from digi directly. + + const auto tp_selection = tp_info.selection; + + // Use cluster width as quality. GE2/1 strip pitch is the same as GE1/1 strip pitch. + const int tp_quality = tp_clus_width; + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + // const GlobalPoint& gp = get_global_point(detgeom, detid, digi); + const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const float glob_phi = tp::rad_to_deg(gp.phi().value()); + const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const double glob_rho = gp.perp(); + const double glob_z = gp.z(); + + // Calculate EMTF Values + const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_bend = 0; + const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_qual = 0; + const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + + emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); + emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = true; // given by digi, not trigger_primitive + + // Set properties + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(L1TMuon::kGEM); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_chamber); + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_pad); + hit.setStripLo(tp_pad_lo); + hit.setStripHi(tp_pad_hi); + + hit.setWire1(tp_roll); + hit.setWire2(0); + + hit.setBend(tp_bend); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(0); + + hit.setGlobPhi(glob_phi); + hit.setGlobTheta(glob_theta); + hit.setGlobPerp(glob_rho); + hit.setGlobZ(glob_z); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi); + hit.setEmtfBend(emtf_bend); + hit.setEmtfTheta1(emtf_theta); + hit.setEmtfTheta2(0); + hit.setEmtfQual1(emtf_qual); + hit.setEmtfQual2(0); + hit.setEmtfSite(emtf_site); + hit.setEmtfHost(emtf_host); + hit.setEmtfZones(emtf_zones); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc new file mode 100644 index 0000000000000..99af18b2ca2f1 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc @@ -0,0 +1,132 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h" + +using namespace emtf::phase2; + +GEMTPSelector::GEMTPSelector( + const EMTFContext& context, + const int& endcap, const int& sector +): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +GEMTPSelector::~GEMTPSelector() { + // Do Nothing +} + +void GEMTPSelector::select( + const TriggerPrimitive& tp, + TPInfo tp_info, + ILinkTPCMap& ilink_tpc_map +) const { + emtf_assert(tp.subsystem() == L1TMuon::kGEM); + + // Map GEM trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns GEM "link" index + + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } + + ilink_tpc_map[ilink].emplace_back(tp, tp_info); +} + +// =========================================================================== +// Utils +// =========================================================================== +int GEMTPSelector::get_input_link( + const TriggerPrimitive& tp, + TPInfo& tp_info +) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_csc_id = tp_info.csc_id; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if ( + csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) + ) { + tp_selection = TPSelection::kNative; + } else if ( + CONFIG.include_neighbor_en_ + && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) + ) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone + return ilink; + } + + // Get chamber input link for this sector processor + ilink = calculate_input_link( + tp_subsector, tp_station, + tp_ring, tp_csc_id, + tp_selection + ); + + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; + + return ilink; +} + +int GEMTPSelector::calculate_input_link( + const int& tp_subsector, const int& tp_station, + const int& tp_ring, const int& tp_csc_id, + const TPSelection& tp_selection +) const { + int ilink = -1; + + // Links + // RE1,2,3,4 + GE1,2 : 54..71, 72..80, 81..89, 90..98 + // RE1,2,3,4 + GE1,2 (N) : 99..101, 102..103, 104..105, 106..107 + + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 54; + + if (tp_station == 1) { + ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); + } else { + ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); + } + + emtf_assert((54 <= ilink) && (ilink < 99)); + } else { + const int ilink_offset = 99; + + if (tp_station == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3); + } else if (tp_ring == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + 1; + } else { + ilink = ilink_offset + ((tp_station - 1) * 2) + 2; + } + + emtf_assert((99 <= ilink) && (ilink < 108)); + } + + return ilink; +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc new file mode 100644 index 0000000000000..50cca3e95f05d --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc @@ -0,0 +1,147 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h" + +using namespace emtf::phase2; + +ME0TPCollector::ME0TPCollector( + const EMTFContext& context, + edm::ConsumesCollector& i_consumes_collector): + context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("ME0Input"))) +{ + // Do Nothing +} + +ME0TPCollector::~ME0TPCollector() { + // Do Nothing +} + +void ME0TPCollector::collect( + const edm::Event& i_event, + BXTPCMap& bx_tpc_map) const { + // Constants + // First quarter of ME0 chamber (5 deg) and last quarter + static const int me0_max_partition = 9; + static const int me0_nstrips = 384; + static const int me0_nphipositions = me0_nstrips * 2; + static const int phiposition_q1 = me0_nphipositions / 4; + static const int phiposition_q3 = (me0_nphipositions / 4) * 3; + + // Read ME0 digis + TPCollection tpc; + + edm::Handle me0_digis; + i_event.getByToken(input_token_, me0_digis); + + auto chamber = me0_digis->begin(); + auto chend = me0_digis->end(); + + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; + + for (; digi != dend; ++digi) { + tpc.emplace_back((*chamber).first, *digi); + } + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const ME0Data& tp_data = tp_entry.tp_.getME0Data(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + const int tp_station = tp_det_id.station(); + const int tp_ring = 4; + const int tp_layer = tp_det_id.layer(); + const int tp_roll = tp_det_id.roll(); + const int tp_me0_chamber = tp_det_id.chamber(); + + const int tp_pad = tp_data.phiposition; + const int tp_partition = tp_data.partition; + const int tp_bx = tp_data.bx + CONFIG.me0_bx_shift_; + + // Reject if outside eta of 2.4 + if (tp_partition > me0_max_partition) { + continue; + } + + // Calculate EMTF Info + // Split 20-deg chamber into 10-deg chamber + // ME0 chamber is rotated by -5 deg relative to CSC chamber. + // ME0 chamber 1 starts at -10 deg, CSC chamber 1 starts at -5 deg. + const int tp_phiposition = tp_data.phiposition; // in half-strip unit + + int tp_chamber = (tp_me0_chamber - 1) * 2 + 1; + + if (tp_endcap == 1) { + // positive endcap + // phiposition increases counter-clockwise + if (tp_phiposition < phiposition_q1) { + tp_chamber = csc::next_10deg_chamber(tp_chamber); + } else if (tp_phiposition < phiposition_q3) { + // Do nothing + } else { + tp_chamber = csc::prev_10deg_chamber(tp_chamber); + } + } else { + // negative endcap + // phiposition increases clockwise + if (tp_phiposition < phiposition_q1) { + tp_chamber = csc::prev_10deg_chamber(tp_chamber); + } else if (tp_phiposition < phiposition_q3) { + // Do nothing + } else { + tp_chamber = csc::next_10deg_chamber(tp_chamber); + } + } + + const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert((1 <= tp_subsector) and (tp_subsector <= 2)); + emtf_assert(tp_station == 1); + emtf_assert(tp_ring == 4); + emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); + emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); + emtf_assert(0 <= tp_pad && tp_pad <= 767); + emtf_assert(0 <= tp_partition && tp_partition <= 15); + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.layer = tp_layer; + tp_entry.info_.roll = tp_roll; + tp_entry.info_.chamber = tp_chamber; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_csc_facing; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc new file mode 100644 index 0000000000000..a670883d091f0 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc @@ -0,0 +1,152 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h" + +using namespace emtf::phase2; + +ME0TPConverter::ME0TPConverter(const EMTFContext& context, + const int& endcap, const int& sector): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +ME0TPConverter::~ME0TPConverter() { + // Do Nothing +} + +void ME0TPConverter::convert( + const TriggerPrimitive& tp, + const TPInfo& tp_info, + EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const int tp_segment_id = tp_info.segment_id; + + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getME0Data(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kME0; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_layer = tp_info.layer; + // const int tp_chamber = tp_info.chamber; + + const int tp_csc_id = tp_info.csc_id; + const auto tp_csc_facing = tp_info.csc_facing; + + // Unpack data + const int tp_phiposition = tp_data.phiposition; // in half-strip unit + const int tp_partition = tp_data.partition; // in half-roll unit + + const int tp_bend = static_cast(tp_data.deltaphi) * (tp_data.bend == 0 ? 1 : -1); + + const int tp_bx = tp_info.bx; + const int tp_subbx = 0; // no fine resolution timing + const float tp_time = 0; // no fine resolution timing. + + const auto tp_selection = tp_info.selection; + + const int tp_quality = tp_data.quality; + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const float glob_phi = tp::rad_to_deg(gp.phi().value()); + const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const double glob_rho = gp.perp(); + const double glob_z = gp.z(); + + // Calculate EMTF Values + const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_bend = std::clamp(tp_bend / 2, -64, 63); // 7-bit, signed + const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_qual = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned + const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + + emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); + emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = true; // given by digi, not trigger_primitive :( + + // Set properties + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(L1TMuon::kME0); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_det_id.chamber()); // Save original chamber + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_phiposition); + hit.setStripLo(tp_phiposition); + hit.setStripHi(tp_phiposition); + + hit.setWire1(tp_partition); + hit.setWire2(0); + + hit.setBend(tp_bend); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(0); + + hit.setGlobPhi(glob_phi); + hit.setGlobTheta(glob_theta); + hit.setGlobPerp(glob_rho); + hit.setGlobZ(glob_z); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi); + hit.setEmtfBend(emtf_bend); + hit.setEmtfTheta1(emtf_theta); + hit.setEmtfTheta2(0); + hit.setEmtfQual1(emtf_qual); + hit.setEmtfQual2(0); + hit.setEmtfSite(emtf_site); + hit.setEmtfHost(emtf_host); + hit.setEmtfZones(emtf_zones); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc new file mode 100644 index 0000000000000..6a9cb8c3e7c88 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc @@ -0,0 +1,119 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h" + +using namespace emtf::phase2; + +ME0TPSelector::ME0TPSelector( + const EMTFContext& context, + const int& endcap, const int& sector +): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +ME0TPSelector::~ME0TPSelector() { + // Do Nothing +} + +void ME0TPSelector::select( + const TriggerPrimitive& tp, + TPInfo tp_info, + ILinkTPCMap& ilink_tpc_map +) const { + emtf_assert(tp.subsystem() == L1TMuon::kME0); + + // Map ME0 trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns ME0 "link" index + + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } + + ilink_tpc_map[ilink].emplace_back(tp, tp_info); +} + +// =========================================================================== +// Utils +// =========================================================================== +int ME0TPSelector::get_input_link( + const TriggerPrimitive& tp, + TPInfo& tp_info +) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_csc_id = tp_info.csc_id; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if ( + csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) + ) { + tp_selection = TPSelection::kNative; + } else if ( + CONFIG.include_neighbor_en_ + && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) + ) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone + return ilink; + } + + // Get chamber input link for this sector processor + ilink = calculate_input_link( + tp_subsector, tp_csc_id, + tp_selection + ); + + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; + + return ilink; +} + +int ME0TPSelector::calculate_input_link( + const int& tp_subsector, const int& tp_csc_id, + const TPSelection& tp_selection +) const { + int ilink = -1; + + // Links + // ME0 : 108..113 + // ME0 (N) : 114 + + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 108; + + ilink = ilink_offset + ((tp_subsector - 1) * 3) + (tp_csc_id - 1); + + emtf_assert((108 <= ilink) && (ilink < 114)); + } else { + const int ilink_offset = 114; + + ilink = ilink_offset; + + emtf_assert(ilink == ilink_offset); + } + + return ilink; +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc new file mode 100644 index 0000000000000..affe1ee2dc3c5 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc @@ -0,0 +1,174 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h" + +using namespace emtf::phase2; + +RPCTPCollector::RPCTPCollector( + const EMTFContext& context, + edm::ConsumesCollector& i_consumes_collector): + context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("RPCInput"))) +{ + // Do Nothing +} + +RPCTPCollector::~RPCTPCollector() { + // Do Nothing +} + +void RPCTPCollector::collect( + const edm::Event& i_event, + BXTPCMap& bx_tpc_map) const { + // Constants + static const int clus_width_cut = 4; + static const int clus_width_cut_irpc = 6; + + // Read RPC digis + TPCollection tpc; + + edm::Handle rpc_digis; + i_event.getByToken(input_token_, rpc_digis); + + auto digi = rpc_digis->begin(); + auto digi_end = rpc_digis->end(); + + for (; digi != digi_end; ++digi) { + tpc.emplace_back(digi->rpcId(), *digi); + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const RPCData& tp_data = tp_entry.tp_.getRPCData(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + + // RPC sector is rotated by -20 deg relative to CSC sector. + // RPC sector 1 starts at -5 deg, CSC sector 1 starts at 15 deg. + const int tp_rpc_sector = tp_det_id.sector(); // 1 - 6 (60 degrees in phi, sector 1 begins at -5 deg) + + // RPC subsector is defined differently than CSC subsector. + // RPC subsector is used to label the chamber within a sector. + const int tp_rpc_subsector = tp_det_id.subsector(); + + const int tp_station = tp_det_id.station(); // 1 - 4 + const int tp_ring = tp_det_id.ring(); // 2 - 3 (increasing theta) + const int tp_roll = tp_det_id.roll(); // 1 - 3 (decreasing theta; aka A - C; space between rolls is 9 - 15 in theta_fp) + const int tp_layer = tp_det_id.layer(); // Always 1 in the Endcap, 1 or 2 in the Barrel + + const int tp_strip = (tp_data.strip_low + tp_data.strip_hi) / 2; // in full-strip unit + const int tp_strip_lo = tp_data.strip_low; + const int tp_strip_hi = tp_data.strip_hi; + const int tp_clus_width = (tp_strip_hi - tp_strip_lo + 1); + + const bool tp_is_CPPF = tp_data.isCPPF; + + const int tp_bx = tp_data.bx + CONFIG.rpc_bx_shift_; + + // Check Ring + bool tp_is_substitute = (tp_ring == 3); + + // Calculate type + const bool tp_is_barrel = (tp_region == 0); + + rpc::Type tp_rpc_type; + + if ((!tp_is_barrel) && (tp_station >= 3) && (tp_ring == 1)) { + tp_rpc_type = rpc::Type::kiRPC; + } else { + tp_rpc_type = rpc::Type::kRPC; + } + + // Short-Circuit: Skip Barrel RPC (region = 0) + if (tp_region == 0) { + continue; + } + + // Short-Circuit: Skip Overlap region (RE1/3, RE2/3) + if (tp_station <= 2 && tp_ring == 3) { + continue; + } + + // Short-Circuit: Reject wide clusters + if (tp_rpc_type == rpc::Type::kiRPC) { + if (tp_clus_width > clus_width_cut_irpc) { + continue; + } + } else { + if (tp_clus_width > clus_width_cut) { + continue; + } + } + + // Calculate EMTF Info + int tp_chamber; + + if (tp_rpc_type == rpc::Type::kiRPC) { + tp_chamber = (tp_rpc_sector - 1) * 3 + tp_rpc_subsector; + } else { + tp_chamber = (tp_rpc_sector - 1) * 6 + tp_rpc_subsector; + } + + const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert(0 <= tp_subsector && tp_subsector <= 2); + emtf_assert(1 <= tp_station && tp_station <= 4); + emtf_assert(1 <= tp_chamber && tp_chamber <= 36); + emtf_assert((1 <= tp_csc_id) and (tp_csc_id <= 9)); + + if (tp_rpc_type == rpc::Type::kiRPC) { + emtf_assert(tp_ring == 1); + emtf_assert(1 <= tp_roll && tp_roll <= 5); + emtf_assert(1 <= tp_strip && tp_strip <= 96); + } else { + emtf_assert(2 <= tp_ring && tp_ring <= 3); + emtf_assert(1 <= tp_roll && tp_roll <= 3); + emtf_assert(tp_is_CPPF || (1 <= tp_strip && tp_strip <= 32)); + } + + emtf_assert(tp_data.valid); + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.roll = tp_roll; + tp_entry.info_.layer = tp_layer; + tp_entry.info_.chamber = tp_chamber; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_csc_facing; + + tp_entry.info_.rpc_type = tp_rpc_type; + + tp_entry.info_.flag_substitute = tp_is_substitute; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc new file mode 100644 index 0000000000000..84db9bca64951 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc @@ -0,0 +1,189 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "Geometry/RPCGeometry/interface/RPCGeometry.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h" + +using namespace emtf::phase2; + +RPCTPConverter::RPCTPConverter(const EMTFContext& context, + const int& endcap, const int& sector): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +RPCTPConverter::~RPCTPConverter() { + // Do Nothing +} + +void RPCTPConverter::convert( + const TriggerPrimitive& tp, + const TPInfo& tp_info, + EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const auto& tp_segment_id = tp_info.segment_id; + + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getRPCData(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kRPC; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_roll = tp_info.roll; + const int tp_layer = tp_info.layer; + const int tp_chamber = tp_info.chamber; + + const auto tp_csc_facing = tp_info.csc_facing; + const int tp_csc_id = tp_info.csc_id; + const auto tp_rpc_type = tp_info.rpc_type; + + // Unpack data + const int tp_strip = (tp_data.strip_low + tp_data.strip_hi) / 2; // in full-strip unit + const int tp_strip_lo = tp_data.strip_low; + const int tp_strip_hi = tp_data.strip_hi; + const int tp_clus_width = (tp_strip_hi - tp_strip_lo + 1); + + int tp_bend = 0; // not applicable + + const int tp_bx = tp_info.bx; + const float tp_time = tp_data.time; + float tp_subbx_f32 = tp_time - (std::round(tp_time / 25.) * 25.); // reduce range to [-12.5,12.5] ns + int tp_subbx = static_cast(std::round(tp_subbx_f32 * 16. / 25.)); + tp_subbx = std::clamp(tp_subbx, -8, 7); // 4-bit, signed + int tp_bx_check = static_cast(std::round(tp_time / 25.)); + + // Not sure why sometimes digi.time() returns 0? + emtf_assert(((not(std::abs(tp_time) < 1e-6)) and (tp_bx == tp_bx_check)) or (std::abs(tp_time) < 1e-6)); + + const auto tp_selection = tp_info.selection; + + // Use cluster width as quality. + int tp_quality; + + if (tp_rpc_type == rpc::Type::kiRPC) { + tp_quality = tp_clus_width; + } else { + tp_quality = tp_clus_width * 3 / 2; // RPC strip pitch is 1.5 times the iRPC strip pitch. + } + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + float glob_phi; + float glob_theta; + double glob_rho; + double glob_z; + + if (tp_rpc_type == rpc::Type::kiRPC) { + // Handle iRPC Coordinates + const RPCRoll* roll = dynamic_cast(GEOM.getRPCGeometry().roll(tp_det_id)); + const GlobalPoint& irpc_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0)); + + glob_phi = tp::rad_to_deg(irpc_gp.phi().value()); + glob_theta = tp::rad_to_deg(irpc_gp.theta().value()); + glob_rho = irpc_gp.perp(); + glob_z = irpc_gp.z(); + } + else{ + // Handle RPC Coordinates + const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + glob_phi = tp::rad_to_deg(gp.phi().value()); + glob_theta = tp::rad_to_deg(gp.theta().value()); + glob_rho = gp.perp(); + glob_z = gp.z(); + } + + // Calculate EMTF Values + const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_bend = 0; + const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_qual = 0; + const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + + emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); + emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = tp_data.valid; + + // Set all the variables + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(tp_subsystem); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_chamber); + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_strip); + hit.setStripLo(tp_strip_lo); + hit.setStripHi(tp_strip_hi); + + hit.setWire1(tp_roll); + hit.setWire2(0); + + hit.setBend(tp_bend); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(0); + + hit.setGlobPhi(glob_phi); + hit.setGlobTheta(glob_theta); + hit.setGlobPerp(glob_rho); + hit.setGlobZ(glob_z); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi); + hit.setEmtfBend(emtf_bend); + hit.setEmtfTheta1(emtf_theta); + hit.setEmtfTheta2(0); + hit.setEmtfQual1(emtf_qual); + hit.setEmtfQual2(0); + hit.setEmtfSite(emtf_site); + hit.setEmtfHost(emtf_host); + hit.setEmtfZones(emtf_zones); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc new file mode 100644 index 0000000000000..6e4b2f128a21e --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc @@ -0,0 +1,141 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h" + +using namespace emtf::phase2; + +RPCTPSelector::RPCTPSelector( + const EMTFContext& context, + const int& endcap, const int& sector +): + context_(context), + endcap_(endcap), + sector_(sector) +{ + // Do Nothing +} + +RPCTPSelector::~RPCTPSelector() { + // Do Nothing +} + +void RPCTPSelector::select( + const TriggerPrimitive& tp, + TPInfo tp_info, + ILinkTPCMap& ilink_tpc_map +) const { + emtf_assert(tp.subsystem() == L1TMuon::kRPC); + + // Map RPC trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns RPC "link" index + + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } + + ilink_tpc_map[ilink].emplace_back(tp, tp_info); +} + +// =========================================================================== +// Utils +// =========================================================================== +int RPCTPSelector::get_input_link( + const TriggerPrimitive& tp, + TPInfo& tp_info +) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_csc_id = tp_info.csc_id; + + const RPCData& tp_data = tp.getRPCData(); + const int tp_emtf_sect = tp_data.emtf_sector; + const bool tp_is_CPPF = tp_data.isCPPF; + + // Short-Circuit: In neighbor chambers, have two separate CPPFDigis for the two EMTF sectors + if (tp_is_CPPF && (tp_emtf_sect != sector_)) + return ilink; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if ( + csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) + ) { + tp_selection = TPSelection::kNative; + } else if ( + CONFIG.include_neighbor_en_ + && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) + ) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone + return ilink; + } + + // Get chamber input link for this sector processor + ilink = calculate_input_link( + tp_subsector, tp_station, + tp_ring, tp_csc_id, + tp_selection + ); + + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; + + return ilink; +} + +int RPCTPSelector::calculate_input_link( + const int& tp_subsector, const int& tp_station, + const int& tp_ring, const int& tp_csc_id, + const TPSelection& tp_selection +) const { + int ilink = -1; + + // Links + // RE1,2,3,4 + GE1,2 : 54..71, 72..80, 81..89, 90..98 + // RE1,2,3,4 + GE1,2 (N) : 99..101, 102..103, 104..105, 106..107 + + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 54; + + if (tp_station == 1) { + ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); + } else { + ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); + } + + emtf_assert((54 <= ilink) && (ilink < 99)); + } else { + const int ilink_offset = 99; + + if (tp_station == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3); + } else if (tp_ring == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + 1; + } else { + ilink = ilink_offset + ((tp_station - 1) * 2) + 2; + } + + emtf_assert((99 <= ilink) && (ilink < 108)); + } + + return ilink; +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/TPrimitives.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/TPrimitives.cc new file mode 100644 index 0000000000000..388f452153c50 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/TPrimitives.cc @@ -0,0 +1,67 @@ +#include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitive.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" + +using namespace emtf::phase2; + +TPEntry::TPEntry(const TPEntry& tp_entry): + tp_(tp_entry.tp_), + info_(tp_entry.info_) +{ + // Do nothing +} + +TPEntry::TPEntry(const TriggerPrimitive& tp): + tp_(tp), + info_() +{ + // Do nothing +} + +TPEntry::TPEntry(const TriggerPrimitive& tp, const TPInfo& tp_info): + tp_(tp), + info_(tp_info) +{ + // Do nothing +} + +TPEntry::TPEntry(const CSCDetId& detid, const CSCCorrelatedLCTDigi& digi): + tp_(detid, digi), + info_() +{ + // Do nothing +} + +TPEntry::TPEntry(const RPCDetId& detid, const RPCRecHit& rechit): + tp_(detid, rechit), + info_() +{ + // Do nothing +} + +TPEntry::TPEntry(const GEMDetId& detid, const GEMPadDigiCluster& digi): + tp_(detid, digi), + info_() +{ + // Do nothing +} + +TPEntry::TPEntry(const ME0DetId& detid, const ME0TriggerDigi& digi): + tp_(detid, digi), + info_() +{ + // Do nothing +} + +TPEntry::TPEntry(const GEMDetId& detid, const ME0TriggerDigi& digi): + tp_(detid, digi), + info_() +{ + // Do nothing +} + +TPEntry::~TPEntry() { + // Do nothing +} + + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc new file mode 100644 index 0000000000000..4ec2c8fb5f8c9 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc @@ -0,0 +1,225 @@ +#include + +#include "ap_int.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h" + +using namespace emtf::phase2; +using namespace emtf::phase2::data; + +ActivationLut::ActivationLut() { + prompt_pt_lut_ = {{ + 0, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8075, 7942, 7818, 7693, 7569, + 7453, 7337, 7220, 7108, 6996, 6889, 6785, 6681, 6582, 6482, 6383, 6287, 6192, 6101, 6010, 5923, 5835, 5748, 5665, + 5582, 5500, 5421, 5342, 5263, 5189, 5110, 5039, 4965, 4894, 4824, 4757, 4687, 4620, 4554, 4488, 4426, 4363, 4301, + 4239, 4181, 4123, 4061, 4007, 3949, 3891, 3837, 3783, 3729, 3675, 3625, 3576, 3522, 3472, 3422, 3376, 3327, 3281, + 3231, 3186, 3140, 3095, 3053, 3007, 2966, 2920, 2879, 2837, 2796, 2754, 2717, 2676, 2638, 2597, 2560, 2522, 2485, + 2448, 2410, 2377, 2340, 2303, 2269, 2236, 2199, 2166, 2134, 2102, 2070, 2043, 2011, 1981, 1954, 1924, 1897, 1871, + 1842, 1816, 1791, 1766, 1741, 1717, 1696, 1671, 1647, 1627, 1604, 1583, 1560, 1541, 1521, 1502, 1479, 1460, 1441, + 1422, 1404, 1388, 1370, 1352, 1334, 1319, 1301, 1283, 1269, 1254, 1237, 1223, 1209, 1192, 1178, 1164, 1150, 1136, + 1123, 1109, 1096, 1082, 1069, 1056, 1046, 1033, 1020, 1007, 997, 984, 974, 962, 952, 939, 930, 920, 908, 898, 889, + 879, 867, 858, 848, 839, 830, 821, 812, 803, 794, 785, 776, 769, 760, 751, 743, 736, 727, 719, 712, 704, 695, 689, + 681, 674, 666, 660, 652, 646, 639, 631, 625, 619, 611, 605, 599, 593, 586, 580, 574, 568, 562, 557, 551, 545, 539, + 534, 528, 523, 517, 511, 506, 500, 495, 489, 484, 480, 475, 470, 464, 461, 455, 450, 446, 441, 436, 432, 427, 422, + 419, 413, 410, 405, 402, 396, 393, 388, 385, 380, 376, 371, 368, 365, 360, 357, 353, 348, 345, 342, 337, 334, 331, + 328, 323, 320, 316, 313, 309, 305, 302, 299, 296, 293, 290, 287, 282, 279, 276, 273, 270, 267, 264, 261, 258, 255, + 252, 249, 246, 243, 240, 237, 236, 233, 230, 227, 224, 221, 218, 217, 214, 211, 208, 205, 202, 201, 198, 195, 193, + 191, 188, 185, 183, 181, 178, 176, 174, 172, 169, 167, 165, 162, 160, 158, 155, 154, 151, 150, 147, 145, 143, 140, + 139, 136, 135, 132, 131, 128, 127, 124, 123, 120, 119, 116, 115, 112, 111, 108, 107, 104, 103, 102, 99, 98, 95, 94, + 93, 90, 89, 87, 85, 84, 81, 80, 79, 76, 75, 73, 71, 70, 68, 67, 65, 63, 62, 60, 58, 57, 56, 53, 52, 51, 50, 47, 46, + 45, 43, 42, 40, 39, 37, 36, 35, 32, 31, 30, 29, 28, 26, 24, 23, 21, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 21, 23, 24, 26, 28, 29, 30, + 31, 32, 35, 36, 37, 39, 40, 42, 43, 45, 46, 47, 50, 51, 52, 53, 56, 57, 58, 60, 62, 63, 65, 67, 68, 70, 71, 73, 75, + 76, 79, 80, 81, 84, 85, 87, 89, 90, 93, 94, 95, 98, 99, 102, 103, 104, 107, 108, 111, 112, 115, 116, 119, 120, 123, + 124, 127, 128, 131, 132, 135, 136, 139, 140, 143, 145, 147, 150, 151, 154, 155, 158, 160, 162, 165, 167, 169, 172, + 174, 176, 178, 181, 183, 185, 188, 191, 193, 195, 198, 201, 202, 205, 208, 211, 214, 217, 218, 221, 224, 227, 230, + 233, 236, 237, 240, 243, 246, 249, 252, 255, 258, 261, 264, 267, 270, 273, 276, 279, 282, 287, 290, 293, 296, 299, + 302, 305, 309, 313, 316, 320, 323, 328, 331, 334, 337, 342, 345, 348, 353, 357, 360, 365, 368, 371, 376, 380, 385, + 388, 393, 396, 402, 405, 410, 413, 419, 422, 427, 432, 436, 441, 446, 450, 455, 461, 464, 470, 475, 480, 484, 489, + 495, 500, 506, 511, 517, 523, 528, 534, 539, 545, 551, 557, 562, 568, 574, 580, 586, 593, 599, 605, 611, 619, 625, + 631, 639, 646, 652, 660, 666, 674, 681, 689, 695, 704, 712, 719, 727, 736, 743, 751, 760, 769, 776, 785, 794, 803, + 812, 821, 830, 839, 848, 858, 867, 879, 889, 898, 908, 920, 930, 939, 952, 962, 974, 984, 997, 1007, 1020, 1033, + 1046, 1056, 1069, 1082, 1096, 1109, 1123, 1136, 1150, 1164, 1178, 1192, 1209, 1223, 1237, 1254, 1269, 1283, 1301, + 1319, 1334, 1352, 1370, 1388, 1404, 1422, 1441, 1460, 1479, 1502, 1521, 1541, 1560, 1583, 1604, 1627, 1647, 1671, + 1696, 1717, 1741, 1766, 1791, 1816, 1842, 1871, 1897, 1924, 1954, 1981, 2011, 2043, 2070, 2102, 2134, 2166, 2199, + 2236, 2269, 2303, 2340, 2377, 2410, 2448, 2485, 2522, 2560, 2597, 2638, 2676, 2717, 2754, 2796, 2837, 2879, 2920, + 2966, 3007, 3053, 3095, 3140, 3186, 3231, 3281, 3327, 3376, 3422, 3472, 3522, 3576, 3625, 3675, 3729, 3783, 3837, + 3891, 3949, 4007, 4061, 4123, 4181, 4239, 4301, 4363, 4426, 4488, 4554, 4620, 4687, 4757, 4824, 4894, 4965, 5039, + 5110, 5189, 5263, 5342, 5421, 5500, 5582, 5665, 5748, 5835, 5923, 6010, 6101, 6192, 6287, 6383, 6482, 6582, 6681, + 6785, 6889, 6996, 7108, 7220, 7337, 7453, 7569, 7693, 7818, 7942, 8075, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191 + }}; + + disp_pt_lut_ = {{ + 0, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 7956, 7730, + 7515, 7311, 7116, 6932, 6754, 6587, 6425, 6272, 6125, 5983, 5848, 5718, 5593, 5473, 5358, 5247, 5139, 5036, 4936, + 4840, 4747, 4657, 4569, 4485, 4404, 4325, 4249, 4174, 4103, 4032, 3964, 3899, 3834, 3772, 3712, 3652, 3595, 3539, + 3484, 3432, 3380, 3330, 3280, 3233, 3186, 3141, 3096, 3052, 3010, 2968, 2927, 2888, 2849, 2810, 2774, 2737, 2701, + 2667, 2633, 2599, 2566, 2533, 2502, 2471, 2441, 2412, 2383, 2354, 2326, 2298, 2271, 2244, 2219, 2193, 2168, 2143, + 2119, 2095, 2072, 2049, 2026, 2004, 1981, 1960, 1938, 1917, 1897, 1877, 1857, 1837, 1818, 1798, 1780, 1762, 1744, + 1726, 1709, 1692, 1673, 1658, 1641, 1624, 1608, 1592, 1576, 1560, 1546, 1531, 1515, 1501, 1486, 1473, 1458, 1445, + 1430, 1417, 1404, 1390, 1378, 1365, 1353, 1339, 1327, 1315, 1303, 1291, 1280, 1268, 1257, 1245, 1234, 1223, 1212, + 1201, 1190, 1180, 1169, 1158, 1149, 1139, 1128, 1118, 1108, 1099, 1089, 1081, 1071, 1061, 1053, 1043, 1034, 1026, + 1016, 1008, 999, 991, 982, 974, 966, 958, 949, 942, 934, 926, 918, 910, 903, 896, 887, 880, 873, 866, 858, 852, 845, + 838, 830, 824, 817, 810, 804, 798, 790, 784, 778, 771, 765, 759, 753, 747, 740, 734, 728, 722, 716, 710, 705, 699, + 693, 687, 682, 676, 671, 665, 660, 654, 649, 644, 638, 634, 629, 624, 618, 613, 608, 603, 598, 593, 589, 584, 579, + 574, 569, 566, 561, 556, 551, 547, 542, 538, 534, 529, 524, 521, 516, 512, 507, 504, 499, 495, 491, 487, 483, 479, + 474, 471, 467, 463, 459, 455, 451, 448, 444, 440, 437, 433, 429, 426, 422, 419, 415, 411, 408, 404, 400, 397, 393, + 391, 387, 383, 380, 377, 374, 370, 368, 364, 360, 358, 354, 351, 348, 344, 342, 338, 336, 332, 330, 326, 324, 320, + 318, 314, 312, 310, 306, 304, 301, 298, 295, 293, 289, 287, 285, 282, 279, 276, 274, 272, 268, 266, 263, 261, 258, + 256, 254, 251, 248, 245, 243, 241, 238, 236, 234, 231, 229, 226, 224, 222, 219, 217, 215, 212, 211, 209, 206, 204, + 202, 199, 197, 196, 193, 191, 189, 186, 184, 183, 180, 178, 175, 174, 172, 170, 167, 166, 164, 161, 160, 158, 155, + 154, 152, 149, 148, 146, 143, 142, 140, 138, 136, 135, 132, 130, 129, 126, 125, 123, 122, 119, 118, 116, 114, 112, + 111, 108, 107, 105, 104, 101, 100, 97, 96, 95, 93, 91, 89, 88, 86, 84, 83, 82, 79, 78, 75, 74, 73, 71, 69, 68, 66, + 64, 63, 62, 59, 58, 57, 55, 53, 52, 51, 48, 47, 46, 45, 42, 41, 40, 38, 37, 35, 33, 32, 31, 30, 27, 26, 25, 23, 22, + 21, 18, 17, 16, 15, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 15, 16, 17, 18, 21, 22, 23, 25, 26, 27, 30, 31, 32, 33, 35, 37, 38, 40, 41, 42, 45, + 46, 47, 48, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 66, 68, 69, 71, 73, 74, 75, 78, 79, 82, 83, 84, 86, 88, 89, 91, + 93, 95, 96, 97, 100, 101, 104, 105, 107, 108, 111, 112, 114, 116, 118, 119, 122, 123, 125, 126, 129, 130, 132, 135, + 136, 138, 140, 142, 143, 146, 148, 149, 152, 154, 155, 158, 160, 161, 164, 166, 167, 170, 172, 174, 175, 178, 180, + 183, 184, 186, 189, 191, 193, 196, 197, 199, 202, 204, 206, 209, 211, 212, 215, 217, 219, 222, 224, 226, 229, 231, + 234, 236, 238, 241, 243, 245, 248, 251, 254, 256, 258, 261, 263, 266, 268, 272, 274, 276, 279, 282, 285, 287, 289, + 293, 295, 298, 301, 304, 306, 310, 312, 314, 318, 320, 324, 326, 330, 332, 336, 338, 342, 344, 348, 351, 354, 358, + 360, 364, 368, 370, 374, 377, 380, 383, 387, 391, 393, 397, 400, 404, 408, 411, 415, 419, 422, 426, 429, 433, 437, + 440, 444, 448, 451, 455, 459, 463, 467, 471, 474, 479, 483, 487, 491, 495, 499, 504, 507, 512, 516, 521, 524, 529, + 534, 538, 542, 547, 551, 556, 561, 566, 569, 574, 579, 584, 589, 593, 598, 603, 608, 613, 618, 624, 629, 634, 638, + 644, 649, 654, 660, 665, 671, 676, 682, 687, 693, 699, 705, 710, 716, 722, 728, 734, 740, 747, 753, 759, 765, 771, + 778, 784, 790, 798, 804, 810, 817, 824, 830, 838, 845, 852, 858, 866, 873, 880, 887, 896, 903, 910, 918, 926, 934, + 942, 949, 958, 966, 974, 982, 991, 999, 1008, 1016, 1026, 1034, 1043, 1053, 1061, 1071, 1081, 1089, 1099, 1108, + 1118, 1128, 1139, 1149, 1158, 1169, 1180, 1190, 1201, 1212, 1223, 1234, 1245, 1257, 1268, 1280, 1291, 1303, 1315, + 1327, 1339, 1353, 1365, 1378, 1390, 1404, 1417, 1430, 1445, 1458, 1473, 1486, 1501, 1515, 1531, 1546, 1560, 1576, + 1592, 1608, 1624, 1641, 1658, 1673, 1692, 1709, 1726, 1744, 1762, 1780, 1798, 1818, 1837, 1857, 1877, 1897, 1917, + 1938, 1960, 1981, 2004, 2026, 2049, 2072, 2095, 2119, 2143, 2168, 2193, 2219, 2244, 2271, 2298, 2326, 2354, 2383, + 2412, 2441, 2471, 2502, 2533, 2566, 2599, 2633, 2667, 2701, 2737, 2774, 2810, 2849, 2888, 2927, 2968, 3010, 3052, + 3096, 3141, 3186, 3233, 3280, 3330, 3380, 3432, 3484, 3539, 3595, 3652, 3712, 3772, 3834, 3899, 3964, 4032, 4103, + 4174, 4249, 4325, 4404, 4485, 4569, 4657, 4747, 4840, 4936, 5036, 5139, 5247, 5358, 5473, 5593, 5718, 5848, 5983, + 6125, 6272, 6425, 6587, 6754, 6932, 7116, 7311, 7515, 7730, 7956, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191 + }}; + + rels_lut_ = {{ + 64, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 72, 72, 73, 73, 73, 74, + 74, 74, 75, 75, 75, 76, 76, 76, 77, 77, 78, 78, 78, 79, 79, 79, 80, 80, 80, 81, 81, 81, 82, 82, 82, 83, 83, 83, 84, + 84, 84, 85, 85, 85, 86, 86, 86, 87, 87, 87, 87, 88, 88, 88, 89, 89, 89, 90, 90, 90, 91, 91, 91, 91, 92, 92, 92, 93, + 93, 93, 93, 94, 94, 94, 95, 95, 95, 95, 96, 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99, 100, 100, 100, + 100, 101, 101, 101, 101, 101, 102, 102, 102, 102, 103, 103, 103, 103, 104, 104, 104, 104, 104, 105, 105, 105, 105, + 105, 106, 106, 106, 106, 106, 107, 107, 107, 107, 107, 108, 108, 108, 108, 108, 109, 109, 109, 109, 109, 109, 110, + 110, 110, 110, 110, 110, 111, 111, 111, 111, 111, 111, 112, 112, 112, 112, 112, 112, 112, 113, 113, 113, 113, 113, + 113, 113, 114, 114, 114, 114, 114, 114, 114, 115, 115, 115, 115, 115, 115, 115, 115, 116, 116, 116, 116, 116, 116, + 116, 116, 116, 117, 117, 117, 117, 117, 117, 117, 117, 117, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, + 120, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 122, 122, 122, 122, 122, 122, + 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, + 127, 127, 127, 127, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 14, 14, + 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, + 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 24, 24, 24, + 24, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 31, 31, 31, 31, + 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 36, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, + 40, 40, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, 48, 48, 49, 49, 49, + 50, 50, 51, 51, 51, 52, 52, 52, 53, 53, 53, 54, 54, 54, 55, 55, 56, 56, 56, 57, 57, 57, 58, 58, 58, 59, 59, 59, 60, + 60, 61, 61, 61, 62, 62, 62, 63, 63 + }}; + + dxy_lut_ = {{ + 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, + 11, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 21, 21, 21, 21, 22, + 22, 22, 22, 24, 24, 24, 24, 25, 25, 25, 25, 27, 27, 27, 28, 28, 28, 28, 30, 30, 30, 30, 31, 31, 31, 31, 33, 33, 33, + 33, 35, 35, 35, 35, 36, 36, 36, 36, 38, 38, 38, 40, 40, 40, 40, 41, 41, 41, 41, 43, 43, 43, 43, 45, 45, 45, 45, 47, + 47, 47, 47, 49, 49, 49, 51, 51, 51, 51, 52, 52, 52, 52, 54, 54, 54, 54, 56, 56, 56, 56, 58, 58, 58, 58, 60, 60, 60, + 60, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -62, + -62, -62, -60, -60, -60, -60, -58, -58, -58, -58, -56, -56, -56, -56, -54, -54, -54, -54, -52, -52, -52, -52, -51, + -51, -51, -51, -49, -49, -49, -47, -47, -47, -47, -45, -45, -45, -45, -43, -43, -43, -43, -41, -41, -41, -41, -40, + -40, -40, -40, -38, -38, -38, -36, -36, -36, -36, -35, -35, -35, -35, -33, -33, -33, -33, -31, -31, -31, -31, -30, + -30, -30, -30, -28, -28, -28, -28, -27, -27, -27, -25, -25, -25, -25, -24, -24, -24, -24, -22, -22, -22, -22, -21, + -21, -21, -21, -19, -19, -19, -19, -18, -18, -18, -18, -17, -17, -17, -15, -15, -15, -15, -14, -14, -14, -14, -13, + -13, -13, -13, -11, -11, -11, -11, -10, -10, -10, -10, -9, -9, -9, -8, -8, -8, -8, -7, -7, -7, -7, -6, -6, -6, -6, + -4, -4, -4, -4, -3, -3, -3, -3, -2, -2, -2, -2, 0 + }}; +} + +ActivationLut::~ActivationLut() { + // Do Nothing +} + +void ActivationLut::update( + const edm::Event&, + const edm::EventSetup& +) { + // Do Nothing +} + +const trk_pt_t& ActivationLut::lookup_prompt_pt(const trk_nn_address_t& address) const { + ap_uint<10> bin = address.to_string(AP_HEX).c_str(); + return prompt_pt_lut_[bin]; +} + +const trk_pt_t& ActivationLut::lookup_disp_pt(const trk_nn_address_t& address) const { + ap_uint<10> bin = address.to_string(AP_HEX).c_str(); + return disp_pt_lut_[bin]; +} + +const trk_rels_t& ActivationLut::lookup_rels(const trk_nn_address_t& address) const { + ap_uint<10> bin = address.to_string(AP_HEX).c_str(); + return rels_lut_[bin]; +} + +const trk_dxy_t& ActivationLut::lookup_dxy(const trk_nn_address_t& address) const { + ap_uint<10> bin = address.to_string(AP_HEX).c_str(); + return dxy_lut_[bin]; +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/HostLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/HostLut.cc new file mode 100644 index 0000000000000..806e1a27323b7 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/HostLut.cc @@ -0,0 +1,55 @@ +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h" + +using namespace emtf::phase2::data; + +// Static +const int HostLut::kInvalid = -1; + +// Member +HostLut::HostLut() { + lut_[{1, 1, 4}] = 0; // ME1/1a + lut_[{1, 1, 1}] = 0; // ME1/1b + lut_[{1, 1, 2}] = 1; // ME1/2 + lut_[{1, 1, 3}] = 2; // ME1/3 + lut_[{1, 2, 1}] = 3; // ME2/1 + lut_[{1, 2, 2}] = 4; // ME2/2 + lut_[{1, 3, 1}] = 5; // ME3/1 + lut_[{1, 3, 2}] = 6; // ME3/2 + lut_[{1, 4, 1}] = 7; // ME4/1 + lut_[{1, 4, 2}] = 8; // ME4/2 + lut_[{3, 1, 1}] = 9; // GE1/1 + lut_[{2, 1, 2}] = 10; // RE1/2 + lut_[{2, 1, 3}] = 11; // RE1/3 + lut_[{3, 2, 1}] = 12; // GE2/1 + lut_[{2, 2, 2}] = 13; // RE2/2 + lut_[{2, 2, 3}] = 13; // RE2/3 + lut_[{2, 3, 1}] = 14; // RE3/1 + lut_[{2, 3, 2}] = 15; // RE3/2 + lut_[{2, 3, 3}] = 15; // RE3/3 + lut_[{2, 4, 1}] = 16; // RE4/1 + lut_[{2, 4, 2}] = 17; // RE4/2 + lut_[{2, 4, 3}] = 17; // RE4/3 + lut_[{4, 1, 4}] = 18; // ME0 +} + +HostLut::~HostLut() { + // Do Nothing +} + + +void HostLut::update( + const edm::Event&, + const edm::EventSetup&) { + // Do Nothing +} + +const int& HostLut::lookup(const std::tuple& key) const { + auto found = lut_.find(key); + + if (found == lut_.end()) + return HostLut::kInvalid; + + return found->second; +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/SiteLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/SiteLut.cc new file mode 100644 index 0000000000000..92dd53fcb2040 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/SiteLut.cc @@ -0,0 +1,55 @@ +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h" + +using namespace emtf::phase2::data; + +// Static +const int SiteLut::kInvalid = -1; + +// Member +SiteLut::SiteLut() { + lut_[{1, 1, 4}] = 0; // ME1/1a + lut_[{1, 1, 1}] = 0; // ME1/1b + lut_[{1, 1, 2}] = 1; // ME1/2 + lut_[{1, 1, 3}] = 1; // ME1/3 + lut_[{1, 2, 1}] = 2; // ME2/1 + lut_[{1, 2, 2}] = 2; // ME2/2 + lut_[{1, 3, 1}] = 3; // ME3/1 + lut_[{1, 3, 2}] = 3; // ME3/2 + lut_[{1, 4, 1}] = 4; // ME4/1 + lut_[{1, 4, 2}] = 4; // ME4/2 + lut_[{2, 1, 2}] = 5; // RE1/2 + lut_[{2, 1, 3}] = 5; // RE1/3 + lut_[{2, 2, 2}] = 6; // RE2/2 + lut_[{2, 2, 3}] = 6; // RE2/3 + lut_[{2, 3, 1}] = 7; // RE3/1 + lut_[{2, 3, 2}] = 7; // RE3/2 + lut_[{2, 3, 3}] = 7; // RE3/3 + lut_[{2, 4, 1}] = 8; // RE4/1 + lut_[{2, 4, 2}] = 8; // RE4/2 + lut_[{2, 4, 3}] = 8; // RE4/3 + lut_[{3, 1, 1}] = 9; // GE1/1 + lut_[{3, 2, 1}] = 10; // GE2/1 + lut_[{4, 1, 4}] = 11; // ME0 +} + +SiteLut::~SiteLut() { + // Do Nothing +} + + +void SiteLut::update( + const edm::Event&, + const edm::EventSetup&) { + // Do Nothing +} + +const int& SiteLut::lookup(const std::tuple& key) const { + auto found = lut_.find(key); + + if (found == lut_.end()) + return SiteLut::kInvalid; + + return found->second; +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc new file mode 100644 index 0000000000000..29d1b63ffd304 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc @@ -0,0 +1,63 @@ +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h" + +using namespace emtf::phase2::data; + +// Static +bool TimeZoneLut::in_range(const std::pair& range, const int& bx) const { + return range.first <= bx && bx <= range.second; +} + +// Member +TimeZoneLut::TimeZoneLut() { + lut_[0] = {-1, 0}; // ME1/1 + lut_[1] = {-1, 0}; // ME1/2 + lut_[2] = {-1, 0}; // ME1/3 + lut_[3] = {-1, 0}; // ME2/1 + lut_[4] = {-1, 0}; // ME2/2 + lut_[5] = {-1, 0}; // ME3/1 + lut_[6] = {-1, 0}; // ME3/2 + lut_[7] = {-1, 0}; // ME4/1 + lut_[8] = {-1, 0}; // ME4/2 + lut_[9] = {-1, 0}; // GE1/1 + lut_[10] = {0, 0}; // RE1/2 + lut_[11] = {0, 0}; // RE1/3 + lut_[12] = {-1, 0}; // GE2/1 + lut_[13] = {0, 0}; // RE2/2 + lut_[14] = {0, 0}; // RE3/1 + lut_[15] = {0, 0}; // RE3/2 + lut_[16] = {0, 0}; // RE4/1 + lut_[17] = {0, 0}; // RE4/2 + lut_[18] = {0, 0}; // ME0 +} + +TimeZoneLut::~TimeZoneLut() { + // Do Nothing +} + + +void TimeZoneLut::update( + const edm::Event&, + const edm::EventSetup&) { + // Do Nothing +} + +int TimeZoneLut::get_timezones(const int& host, const int& bx) const { + auto found = lut_.find(host); + + // Short-Circuit: Host doesn't exist + if (found == lut_.end()) + return 0x0; + + // Build word + int word = 0x0; + + word |= in_range(found->second, bx) ? 0x01 : 0; + word |= in_range(found->second, bx + 1) ? 0x02 : 0; // +1 BX delay + word |= in_range(found->second, bx + 2) ? 0x04 : 0; // +2 BX delay + + return word; +} + + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc new file mode 100644 index 0000000000000..1564ab0bef30b --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc @@ -0,0 +1,129 @@ + +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h" + +using namespace emtf::phase2::data; + +ZoneLut::ZoneLut() { + auto& zone0 = zones_.emplace_back(); + zone0.lut_[0] = {4, 26}; // ME1/1 + zone0.lut_[3] = {4, 25}; // ME2/1 + zone0.lut_[5] = {4, 25}; // ME3/1 + zone0.lut_[7] = {4, 25}; // ME4/1 + zone0.lut_[9] = {17, 26}; // GE1/1 + zone0.lut_[12] = {7, 25}; // GE2/1 + zone0.lut_[14] = {4, 25}; // RE3/1 + zone0.lut_[16] = {4, 25}; // RE4/1 + zone0.lut_[18] = {4, 23}; // ME0 + + auto& zone1 = zones_.emplace_back(); + zone1.lut_[0] = {24, 53}; // ME1/1 + zone1.lut_[1] = {46, 54}; // ME1/2 + zone1.lut_[3] = {23, 49}; // ME2/1 + zone1.lut_[5] = {23, 41}; // ME3/1 + zone1.lut_[6] = {44, 54}; // ME3/2 + zone1.lut_[7] = {23, 35}; // ME4/1 + zone1.lut_[8] = {38, 54}; // ME4/2 + zone1.lut_[9] = {24, 52}; // GE1/1 + zone1.lut_[10] = {52, 56}; // RE1/2 + zone1.lut_[12] = {23, 46}; // GE2/1 + zone1.lut_[14] = {23, 36}; // RE3/1 + zone1.lut_[15] = {40, 52}; // RE3/2 + zone1.lut_[16] = {23, 31}; // RE4/1 + zone1.lut_[17] = {35, 54}; // RE4/2 + + auto& zone2 = zones_.emplace_back(); + zone2.lut_[1] = {52, 88}; // ME1/2 + zone2.lut_[4] = {52, 88}; // ME2/2 + zone2.lut_[6] = {50, 88}; // ME3/2 + zone2.lut_[8] = {50, 88}; // ME4/2 + zone2.lut_[10] = {52, 84}; // RE1/2 + zone2.lut_[13] = {52, 88}; // RE2/2 + zone2.lut_[15] = {48, 84}; // RE3/2 + zone2.lut_[17] = {52, 84}; // RE4/2 +} + +ZoneLut::~ZoneLut() { + // Do Nothing +} + + +void ZoneLut::update( + const edm::Event&, + const edm::EventSetup&) { + // Do Nothing +} + +int ZoneLut::get_zones(const int& host, const int& theta) const { + int i = 0; + int word = 0; + + for (const auto& zone : zones_) { + bool in_zone = zone.contains(host, theta); + + if (in_zone) { + word |= (1u << i); + } + + ++i; + } + + return word; +} + +int ZoneLut::get_zones(const int& host, const int& theta1, const int& theta2) const { + int i = 0; + int word = 0; + + for (const auto& zone : zones_) { + bool in_zone = zone.contains(host, theta1, theta2); + + if (in_zone) { + word |= (1u << i); + } + + ++i; + } + + return word; +} + +bool Zone::contains(const int& host, const int& theta) const { + // Short-Circuit: LUT not found + auto found = lut_.find(host); + + if (found == lut_.end()) + return false; + + // Short-Circuit: Must be within theta range + auto& theta_range = found->second; + + if (theta_range.first <= theta && theta <= theta_range.second) { + return true; + } + + return false; +} + +bool Zone::contains(const int& host, const int& theta1, const int& theta2) const { + // Short-Circuit: LUT not found + auto found = lut_.find(host); + + if (found == lut_.end()) + return false; + + // Short-Circuit: Must be within theta range + auto& theta_range = found->second; + + if (theta_range.first <= theta1 && theta1 <= theta_range.second) { + return true; + } + + if (theta_range.first <= theta2 && theta2 <= theta_range.second) { + return true; + } + + return false; +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc new file mode 100644 index 0000000000000..1381d53acadf5 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc @@ -0,0 +1,49 @@ +#include + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" + +using namespace emtf::phase2; + +EMTFConfiguration::EMTFConfiguration(const edm::ParameterSet& pset) { + verbosity_ = pset.getUntrackedParameter("Verbosity"); + + // Validation + validation_dir_ = pset.getParameter("ValidationDirectory"); + + // Neural Network + prompt_graph_path_ = pset.getParameter("PromptGraphPath"); + displ_graph_path_ = pset.getParameter("DisplacedGraphPath"); + + // Trigger + min_bx_ = pset.getParameter("MinBX"); + max_bx_ = pset.getParameter("MaxBX"); + bx_window_ = pset.getParameter("BXWindow"); + + // Subsystems + csc_en_ = pset.getParameter("CSCEnabled"); + rpc_en_ = pset.getParameter("RPCEnabled"); + gem_en_ = pset.getParameter("GEMEnabled"); + me0_en_ = pset.getParameter("ME0Enabled"); + ge0_en_ = pset.getParameter("GE0Enabled"); + + csc_bx_shift_ = pset.getParameter("CSCInputBXShift"); + rpc_bx_shift_ = pset.getParameter("RPCInputBXShift"); + gem_bx_shift_ = pset.getParameter("GEMInputBXShift"); + me0_bx_shift_ = pset.getParameter("ME0InputBXShift"); + + // Primitive Selection + include_neighbor_en_ = pset.getParameter("IncludeNeighborEnabled"); +} + +EMTFConfiguration::~EMTFConfiguration() {} + +void EMTFConfiguration::update( + const edm::Event& i_event, + const edm::EventSetup& i_event_setup) { + // Do Nothing +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc new file mode 100644 index 0000000000000..978d6864d7208 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc @@ -0,0 +1,126 @@ +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "L1Trigger/L1TMuon/interface/GeometryTranslator.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" + +using namespace emtf::phase2; + +EMTFContext::EMTFContext( + const edm::ParameterSet& pset, + edm::ConsumesCollector i_consumes_collector +): + // Parameter Set + pset_(pset), + + // Helpers + geometry_translator_(i_consumes_collector), + + // EMTF + config_(pset), + model_(*this), + + // Prompt Neural Network + prompt_graph_ptr_(nullptr), + prompt_session_ptr_(nullptr), + + // Displaced Neural Network + disp_graph_ptr_(nullptr), + disp_session_ptr_(nullptr), + + // Data + site_lut_(), + host_lut_(), + zone_lut_(), + timezone_lut_(), + activation_lut_(), + + // Layers + hitmap_building_layer_(*this), + pattern_matching_layer_(*this), + road_sorting_layer_(*this), + track_building_layer_(*this), + duplicate_removal_layer_(*this), + parameter_assignment_layer_(*this), + output_layer_(*this) +{ + // Do Nothing +} + +EMTFContext::~EMTFContext() { + // Delete Prompt Neural Network + if (prompt_session_ptr_ != nullptr) { + tensorflow::closeSession(prompt_session_ptr_); + delete prompt_session_ptr_; + } + + if (prompt_graph_ptr_ != nullptr) { + delete prompt_graph_ptr_; + } + + // Delete Displaced Neural Network + if (disp_session_ptr_ != nullptr) { + tensorflow::closeSession(disp_session_ptr_); + delete disp_session_ptr_; + } + + if (disp_graph_ptr_ != nullptr) { + delete disp_graph_ptr_; + } +} + +void EMTFContext::update( + const edm::Event& i_event, + const edm::EventSetup& i_event_setup) { + // Update Helpers + geometry_translator_.checkAndUpdateGeometry(i_event_setup); + + // Update Config + config_.update(i_event, i_event_setup); + + // Update Prompt Neural Network + if (prompt_session_ptr_ != nullptr) { + delete prompt_session_ptr_; + } + + if (prompt_graph_ptr_ != nullptr) { + delete prompt_graph_ptr_; + } + + prompt_graph_ptr_ = tensorflow::loadGraphDef( + edm::FileInPath(config_.prompt_graph_path_).fullPath() + ); + + prompt_session_ptr_ = tensorflow::createSession( + prompt_graph_ptr_ + ); + + // Update Displaced Neural Network + if (disp_session_ptr_ != nullptr) { + delete disp_session_ptr_; + } + + if (disp_graph_ptr_ != nullptr) { + delete disp_graph_ptr_; + } + + disp_graph_ptr_ = tensorflow::loadGraphDef( + edm::FileInPath(config_.displ_graph_path_).fullPath() + ); + + disp_session_ptr_ = tensorflow::createSession( + disp_graph_ptr_ + ); + + // Update Data + site_lut_.update(i_event, i_event_setup); + host_lut_.update(i_event, i_event_setup); + zone_lut_.update(i_event, i_event_setup); + timezone_lut_.update(i_event, i_event_setup); + activation_lut_.update(i_event, i_event_setup); +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFModel.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFModel.cc new file mode 100644 index 0000000000000..5307838214016 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFModel.cc @@ -0,0 +1,666 @@ +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h" + +using namespace emtf::phase2; +using namespace emtf::phase2::model; + +EMTFModel::EMTFModel( + const EMTFContext& context +): + context_(context) +{ + // =========================================================================== + // Zone 0 + // =========================================================================== + zones::hitmap_t&& zone0_hm = { + { // Row 0 + { + site_id_t::kME0, { + {114, 38, 90 }, + {108, 75, 127}, + {109, 113, 165}, + {110, 150, 202}, + {111, 188, 240}, + {112, 225, 277}, + {113, 263, 315} + } + } + }, + { // Row 1 + { + site_id_t::kGE11, { + {99 , 38, 90 }, + {54 , 75, 127}, + {55 , 113, 165}, + {56 , 150, 202}, + {63 , 188, 240}, + {64 , 225, 277}, + {65 , 263, 315} + } + } + }, + { // Row 2 + { + site_id_t::kME11, { + {45 , 38, 90 }, + {0 , 75, 127}, + {1 , 113, 165}, + {2 , 150, 202}, + {9 , 188, 240}, + {10 , 225, 277}, + {11 , 263, 315} + } + } + }, + { // Row 3 + { + site_id_t::kGE21, { + {102, 0 , 90 }, + {72 , 75 , 165}, + {73 , 150 , 240}, + {74 , 225 , 315} + } + } + }, + { // Row 4 + { + site_id_t::kME2, { + {48 , 0 , 90 }, + {18 , 75 , 165}, + {19 , 150 , 240}, + {20 , 225 , 315} + } + } + }, + { // Row 5 + { + site_id_t::kME3, { + {50 , 0 , 90 }, + {27 , 75 , 165}, + {28 , 150 , 240}, + {29 , 225 , 315} + } + } + }, + { // Row 6 + { + site_id_t::kRE3, { + {104, 0 , 90 }, + {81 , 75 , 165}, + {82 , 150 , 240}, + {83 , 225 , 315} + } + } + }, + { // Row 7 + { + site_id_t::kME4, { + {52 , 0 , 90 }, + {36 , 75 , 165}, + {37 , 150 , 240}, + {38 , 225 , 315} + } + }, + { + site_id_t::kRE4, { + {106, 0 , 90 }, + {90 , 75 , 165}, + {91 , 150 , 240}, + {92 , 225 , 315} + } + } + }, + }; + + std::vector zone0_prompt_pd = { + {{49, 55, 61}, {49, 55, 61}, {50, 55, 60}, {53, 55, 57}, {53, 55, 57}, {54, 55, 56}, {54, 55, 56}, {53, 55, 57}}, + {{42, 47, 52}, {42, 47, 52}, {45, 49, 53}, {53, 54, 56}, {53, 55, 57}, {55, 56, 57}, {54, 56, 58}, {54, 56, 59}}, + {{58, 63, 68}, {58, 63, 68}, {57, 61, 65}, {54, 56, 57}, {53, 55, 57}, {53, 54, 55}, {52, 54, 56}, {51, 54, 56}}, + {{35, 42, 49}, {36, 42, 48}, {39, 45, 51}, {52, 54, 56}, {54, 55, 56}, {54, 57, 59}, {54, 57, 60}, {52, 57, 61}}, + {{61, 68, 75}, {62, 68, 74}, {59, 65, 71}, {54, 56, 58}, {54, 55, 56}, {51, 53, 56}, {50, 53, 56}, {49, 53, 58}}, + {{21, 33, 45}, {22, 33, 43}, {29, 39, 49}, {51, 54, 56}, {54, 55, 56}, {52, 57, 62}, {51, 57, 63}, {46, 55, 65}}, + {{65, 77, 89}, {67, 77, 88}, {61, 71, 81}, {54, 56, 59}, {54, 55, 56}, {48, 53, 58}, {47, 53, 59}, {45, 55, 64}} + }; + + zones::quality_lut_t zone0_prompt_ql = { + 0, 3, 3, 4, 3, 5, 4, 6, 1, 6, 6, 7, 21, 26, 24, 27, 1, 21, 21, 24, 22, 26, 24, 29, + 2, 25, 25, 27, 26, 30, 28, 31, 0, 17, 17, 20, 18, 34, 20, 37, 2, 42, 28, 45, 42, 46, 45, 49, + 9, 42, 42, 45, 43, 47, 46, 49, 10, 45, 45, 48, 47, 50, 49, 51, 0, 5, 5, 6, 17, 33, 19, 36, + 2, 7, 7, 7, 29, 46, 30, 49, 3, 42, 29, 46, 43, 47, 46, 50, 4, 45, 31, 49, 47, 50, 50, 51, + 1, 20, 19, 23, 22, 38, 23, 39, 4, 45, 30, 48, 46, 49, 48, 51, 11, 46, 46, 49, 47, 50, 50, 51, + 13, 48, 49, 51, 50, 51, 51, 51, 0, 16, 16, 18, 16, 32, 18, 35, 2, 41, 27, 43, 42, 44, 44, 47, + 9, 42, 41, 44, 42, 45, 44, 48, 10, 44, 44, 47, 44, 48, 48, 50, 8, 40, 40, 41, 40, 41, 40, 43, + 11, 52, 52, 55, 53, 57, 54, 61, 12, 52, 52, 55, 53, 58, 56, 61, 14, 55, 55, 60, 58, 62, 59, 63, + 1, 40, 23, 40, 40, 41, 40, 43, 5, 52, 31, 54, 53, 57, 54, 60, 12, 52, 53, 56, 53, 58, 57, 62, + 14, 55, 56, 60, 57, 61, 60, 63, 8, 41, 41, 43, 41, 43, 43, 47, 13, 54, 54, 59, 57, 61, 58, 63, + 15, 56, 56, 59, 58, 61, 60, 63, 15, 59, 59, 62, 62, 63, 62, 63 + }; + + std::vector zone0_disp_pd = { + {{50, 55, 60}, {50, 55, 60}, {50, 55, 60}, {53, 55, 57}, {53, 55, 57}, {54, 55, 56}, {53, 55, 57}, {53, 55, 57}}, + {{53, 61, 67}, {53, 61, 65}, {53, 60, 65}, {54, 56, 57}, {54, 56, 57}, {52, 54, 56}, {52, 54, 56}, {49, 53, 56}}, + {{43, 49, 57}, {45, 49, 57}, {45, 50, 57}, {53, 54, 56}, {53, 54, 56}, {54, 56, 58}, {54, 56, 58}, {54, 57, 61}}, + {{54, 63, 72}, {54, 63, 70}, {54, 63, 71}, {54, 57, 58}, {54, 56, 56}, {49, 53, 56}, {49, 52, 56}, {45, 51, 56}}, + {{38, 47, 56}, {40, 47, 56}, {39, 47, 56}, {52, 53, 56}, {54, 54, 56}, {54, 57, 61}, {54, 58, 61}, {54, 59, 65}}, + {{54, 64, 77}, {54, 66, 74}, {54, 66, 76}, {54, 57, 59}, {54, 56, 56}, {46, 52, 56}, {45, 50, 56}, {40, 48, 56}}, + {{33, 46, 56}, {36, 44, 56}, {34, 44, 56}, {51, 53, 56}, {54, 54, 56}, {54, 58, 64}, {54, 60, 65}, {54, 62, 70}} + }; + + zones::quality_lut_t zone0_disp_ql = { + 0, 3, 3, 4, 3, 5, 4, 5, 1, 6, 6, 7, 21, 26, 26, 30, 1, 22, 21, 25, 22, 26, 24, 29, + 2, 24, 24, 27, 25, 29, 29, 31, 0, 17, 17, 20, 18, 34, 20, 38, 2, 42, 28, 47, 42, 47, 46, 50, + 9, 42, 42, 46, 43, 47, 46, 49, 10, 45, 45, 49, 46, 49, 49, 51, 0, 6, 5, 6, 17, 33, 19, 36, + 2, 7, 7, 7, 28, 46, 31, 50, 3, 42, 27, 46, 43, 47, 46, 50, 4, 45, 30, 50, 46, 50, 50, 51, + 1, 20, 19, 23, 21, 37, 23, 39, 4, 45, 30, 48, 45, 49, 48, 51, 11, 45, 45, 49, 47, 50, 49, 51, + 13, 48, 48, 51, 49, 51, 51, 51, 0, 16, 16, 18, 16, 32, 18, 35, 2, 41, 27, 44, 41, 44, 44, 48, + 9, 42, 41, 44, 42, 45, 44, 48, 10, 44, 43, 47, 44, 48, 47, 50, 8, 40, 40, 41, 40, 41, 41, 43, + 11, 52, 52, 56, 53, 57, 57, 61, 12, 53, 52, 57, 53, 58, 58, 62, 14, 56, 55, 60, 57, 62, 61, 63, + 1, 40, 23, 40, 40, 41, 40, 43, 5, 52, 31, 55, 52, 55, 56, 60, 12, 53, 52, 56, 53, 58, 57, 61, + 13, 55, 54, 60, 55, 61, 60, 63, 8, 41, 40, 43, 42, 43, 43, 47, 14, 54, 54, 59, 54, 59, 60, 62, + 15, 56, 54, 59, 58, 62, 61, 63, 15, 59, 58, 62, 59, 63, 63, 63 + }; + + zones_.push_back({ + zone0_hm, + zone0_prompt_pd, + zone0_prompt_ql, + zone0_disp_pd, + zone0_disp_ql + }); + + // =========================================================================== + // Zone 1 + // =========================================================================== + zones::hitmap_t&& zone1_hm = { + { // Row 0 + { + site_id_t::kGE11, { + {99 , 38, 90 }, + {54 , 75, 127}, + {55 , 113, 165}, + {56 , 150, 202}, + {63 , 188, 240}, + {64 , 225, 277}, + {65 , 263, 315} + } + } + }, + { // Row 1 + { + site_id_t::kME11, { + {45 , 38, 90 }, + {0 , 75, 127}, + {1 , 113, 165}, + {2 , 150, 202}, + {9 , 188, 240}, + {10 , 225, 277}, + {11 , 263, 315} + } + } + }, + { // Row 2 + { + site_id_t::kME12, { + {46 , 38, 90 }, + {3 , 75, 127}, + {4 , 113, 165}, + {5 , 150, 202}, + {12 , 188, 240}, + {13 , 225, 277}, + {14 , 263, 315} + } + }, + { + site_id_t::kRE1, { + {100, 38, 90 }, + {57 , 75, 127}, + {58 , 113, 165}, + {59 , 150, 202}, + {66 , 188, 240}, + {67 , 225, 277}, + {68 , 263, 315} + } + } + }, + { // Row 3 + { + site_id_t::kGE21, { + {102, 0 , 90 }, + {72 , 75 , 165}, + {73 , 150 , 240}, + {74 , 225 , 315} + } + } + }, + { // Row 4 + { + site_id_t::kME2, { + {48 , 0 , 90 }, + {18 , 75 , 165}, + {19 , 150 , 240}, + {20 , 225 , 315} + } + } + }, + { // Row 5 + { + site_id_t::kME3, { + // ME3/1 + {50 , 0 , 90 }, + {27 , 75 , 165}, + {28 , 150 , 240}, + {29 , 225 , 315}, + // ME3/2 + {51 , 38, 90 }, + {30 , 75, 127}, + {31 , 113, 165}, + {32 , 150, 202}, + {33 , 188, 240}, + {34 , 225, 277}, + {35 , 263, 315} + } + } + }, + { // Row 6 + { + site_id_t::kRE3, { + // RE3/1 + {104, 0 , 90 }, + {81 , 75 , 165}, + {82 , 150 , 240}, + {83 , 225 , 315}, + // RE3/2 + {105, 38, 90 }, + {84 , 75, 127}, + {85 , 113, 165}, + {86 , 150, 202}, + {87 , 188, 240}, + {88 , 225, 277}, + {89 , 263, 315} + } + } + }, + { // Row 7 + { + site_id_t::kME4, { + // ME4/1 + {52 , 0 , 90 }, + {36 , 75 , 165}, + {37 , 150 , 240}, + {38 , 225 , 315}, + // ME4/2 + {53 , 38, 90 }, + {39 , 75, 127}, + {40 , 113, 165}, + {41 , 150, 202}, + {42 , 188, 240}, + {43 , 225, 277}, + {44 , 263, 315} + } + }, + { + site_id_t::kRE4, { + // RE4/1 + {106, 0 , 90 }, + {90 , 75 , 165}, + {91 , 150 , 240}, + {92 , 225 , 315}, + // RE4/2 + {107, 38, 90 }, + {93 , 75, 127}, + {94 , 113, 165}, + {95 , 150, 202}, + {96 , 188, 240}, + {97 , 225, 277}, + {98 , 263, 315} + } + } + } + }; + + std::vector zone1_prompt_pd = { + {{47, 55, 63}, {48, 55, 62}, {51, 55, 59}, {53, 55, 57}, {53, 55, 57}, {54, 55, 56}, {53, 55, 57}, {53, 55, 57}}, + {{38, 44, 50}, {41, 46, 51}, {49, 52, 54}, {53, 54, 56}, {53, 55, 57}, {54, 56, 57}, {54, 56, 58}, {53, 56, 58}}, + {{60, 66, 72}, {59, 64, 69}, {56, 58, 61}, {54, 56, 57}, {53, 55, 57}, {53, 54, 56}, {52, 54, 56}, {52, 54, 57}}, + {{29, 37, 44}, {32, 40, 47}, {46, 50, 53}, {52, 54, 56}, {54, 55, 56}, {53, 56, 59}, {51, 55, 59}, {48, 54, 59}}, + {{66, 73, 81}, {63, 70, 78}, {57, 60, 64}, {54, 56, 58}, {54, 55, 56}, {51, 54, 57}, {51, 55, 59}, {51, 56, 62}}, + {{16, 27, 39}, {21, 32, 42}, {43, 48, 53}, {52, 55, 57}, {54, 55, 56}, {44, 52, 59}, {40, 49, 59}, {31, 44, 59}}, + {{71, 83, 94}, {68, 78, 89}, {57, 62, 67}, {53, 55, 58}, {54, 55, 56}, {51, 58, 66}, {51, 61, 70}, {51, 66, 79}} + }; + + zones::quality_lut_t zone1_prompt_ql = { + 0, 3, 4, 6, 3, 5, 5, 7, 1, 7, 21, 25, 19, 23, 25, 27, 1, 20, 22, 25, 34, 36, 37, 39, + 2, 24, 26, 28, 36, 38, 39, 39, 0, 16, 18, 21, 32, 33, 34, 37, 4, 27, 42, 46, 42, 45, 45, 49, + 9, 42, 43, 46, 43, 46, 47, 50, 10, 45, 46, 50, 45, 48, 49, 51, 0, 7, 17, 20, 17, 18, 20, 23, + 3, 7, 28, 31, 27, 29, 30, 31, 4, 29, 43, 47, 42, 45, 47, 50, 6, 30, 46, 50, 46, 48, 49, 51, + 1, 19, 22, 24, 34, 35, 37, 38, 5, 29, 46, 49, 45, 48, 49, 51, 11, 46, 47, 50, 47, 49, 50, 51, + 13, 49, 50, 51, 48, 51, 51, 51, 0, 16, 16, 18, 32, 32, 33, 35, 2, 26, 42, 44, 41, 43, 44, 48, + 9, 41, 42, 45, 42, 44, 45, 48, 10, 44, 44, 48, 44, 47, 48, 50, 8, 40, 40, 41, 40, 40, 41, 43, + 11, 52, 53, 56, 52, 54, 56, 60, 12, 52, 53, 57, 53, 56, 58, 62, 14, 55, 57, 61, 57, 59, 61, 63, + 2, 22, 40, 41, 40, 40, 41, 43, 6, 31, 52, 55, 52, 54, 55, 59, 12, 52, 53, 57, 53, 54, 58, 61, + 14, 54, 57, 61, 55, 59, 60, 63, 8, 40, 41, 43, 41, 43, 44, 47, 13, 54, 56, 60, 56, 58, 60, 62, + 15, 55, 58, 62, 58, 59, 62, 63, 15, 59, 61, 63, 60, 62, 63, 63 + }; + + std::vector zone1_disp_pd = { + {{50, 55, 60}, {50, 55, 60}, {52, 55, 58}, {53, 55, 57}, {53, 55, 57}, {54, 55, 56}, {53, 55, 57}, {53, 55, 57}}, + {{53, 60, 65}, {53, 60, 65}, {54, 58, 61}, {54, 56, 57}, {54, 56, 57}, {53, 54, 56}, {52, 54, 56}, {50, 53, 56}}, + {{45, 50, 57}, {45, 50, 57}, {49, 52, 56}, {53, 54, 56}, {53, 54, 56}, {54, 56, 57}, {54, 56, 58}, {54, 57, 60}}, + {{53, 63, 71}, {53, 62, 69}, {54, 59, 63}, {54, 57, 58}, {54, 56, 56}, {50, 54, 56}, {50, 53, 56}, {47, 51, 56}}, + {{39, 47, 57}, {41, 48, 57}, {47, 51, 56}, {52, 53, 56}, {54, 54, 56}, {54, 56, 60}, {54, 57, 60}, {54, 59, 63}}, + {{54, 65, 73}, {54, 65, 74}, {54, 61, 67}, {54, 57, 59}, {54, 56, 56}, {47, 53, 56}, {47, 51, 56}, {43, 49, 56}}, + {{37, 45, 56}, {36, 45, 56}, {43, 49, 56}, {51, 53, 56}, {54, 54, 56}, {54, 57, 63}, {54, 59, 63}, {54, 61, 67}} + }; + + zones::quality_lut_t zone1_disp_ql = { + 0, 3, 4, 6, 4, 5, 6, 7, 1, 7, 22, 26, 20, 24, 25, 29, 1, 21, 22, 25, 34, 37, 37, 39, + 2, 23, 25, 28, 36, 38, 39, 39, 0, 17, 18, 20, 32, 33, 34, 37, 3, 27, 42, 46, 42, 45, 46, 50, + 9, 42, 43, 46, 43, 46, 47, 50, 10, 45, 46, 50, 45, 48, 49, 51, 0, 7, 17, 18, 16, 19, 20, 24, + 3, 7, 27, 31, 27, 30, 29, 31, 4, 28, 43, 47, 42, 47, 47, 50, 5, 30, 46, 50, 45, 49, 49, 51, + 1, 19, 21, 23, 34, 35, 36, 38, 5, 29, 45, 49, 45, 49, 48, 51, 11, 46, 47, 50, 46, 48, 50, 51, + 13, 49, 49, 51, 48, 51, 51, 51, 0, 16, 16, 18, 32, 32, 33, 35, 2, 26, 41, 44, 41, 44, 44, 48, + 9, 42, 42, 45, 42, 44, 45, 48, 10, 44, 44, 48, 44, 48, 47, 50, 8, 40, 40, 41, 40, 41, 41, 43, + 11, 52, 52, 57, 52, 55, 56, 61, 12, 53, 53, 57, 53, 57, 58, 62, 14, 55, 56, 61, 55, 61, 60, 63, + 2, 22, 40, 40, 40, 40, 41, 43, 6, 31, 52, 57, 52, 54, 55, 60, 12, 52, 53, 58, 53, 56, 58, 62, + 14, 56, 56, 61, 54, 59, 60, 63, 8, 40, 41, 43, 41, 43, 43, 47, 13, 54, 54, 60, 54, 58, 59, 63, + 15, 55, 57, 61, 58, 60, 62, 63, 15, 59, 59, 63, 59, 62, 62, 63 + }; + + zones_.push_back({ + zone1_hm, + zone1_prompt_pd, + zone1_prompt_ql, + zone1_disp_pd, + zone1_disp_ql + }); + + // =========================================================================== + // Zone 2 + // =========================================================================== + zones::hitmap_t&& zone2_hm = { + { // Row 0 + { + site_id_t::kME12, { + {46 , 38, 90 }, + {3 , 75, 127}, + {4 , 113, 165}, + {5 , 150, 202}, + {12 , 188, 240}, + {13 , 225, 277}, + {14 , 263, 315} + } + } + }, + { // Row 1 + { + site_id_t::kRE1, { + {100, 38, 90 }, + {57 , 75, 127}, + {58 , 113, 165}, + {59 , 150, 202}, + {66 , 188, 240}, + {67 , 225, 277}, + {68 , 263, 315} + } + } + }, + { // Row 2 + { + site_id_t::kRE2, { + {103, 38, 90 }, + {75 , 75, 127}, + {76 , 113, 165}, + {77 , 150, 202}, + {78 , 188, 240}, + {79 , 225, 277}, + {80 , 263, 315} + } + } + }, + { // Row 3 + { + site_id_t::kME2, { + {49 , 38, 90 }, + {21 , 75, 127}, + {22 , 113, 165}, + {23 , 150, 202}, + {24 , 188, 240}, + {25 , 225, 277}, + {26 , 263, 315} + } + } + }, + { // Row 4 + { + site_id_t::kME3, { + {51 , 38, 90 }, + {30 , 75, 127}, + {31 , 113, 165}, + {32 , 150, 202}, + {33 , 188, 240}, + {34 , 225, 277}, + {35 , 263, 315} + } + } + }, + { // Row 5 + { + site_id_t::kRE3, { + {105, 38, 90 }, + {84 , 75, 127}, + {85 , 113, 165}, + {86 , 150, 202}, + {87 , 188, 240}, + {88 , 225, 277}, + {89 , 263, 315} + } + } + }, + { // Row 6 + { + site_id_t::kME4, { + {53 , 38, 90 }, + {39 , 75, 127}, + {40 , 113, 165}, + {41 , 150, 202}, + {42 , 188, 240}, + {43 , 225, 277}, + {44 , 263, 315} + } + } + }, + { // Row 7 + { + site_id_t::kRE4, { + {107, 38, 90 }, + {93 , 75, 127}, + {94 , 113, 165}, + {95 , 150, 202}, + {96 , 188, 240}, + {97 , 225, 277}, + {98 , 263, 315}, + } + } + } + }; + + std::vector zone2_prompt_pd = { // Pattern N: Row0..RowM + {{52, 55, 58}, {52, 55, 58}, {53, 55, 57}, {53, 55, 57}, {54, 55, 56}, {53, 55, 57}, {53, 55, 57}, {53, 55, 57}}, + {{54, 57, 61}, {53, 57, 60}, {54, 56, 58}, {54, 56, 58}, {53, 55, 56}, {53, 54, 56}, {52, 54, 56}, {52, 54, 56}}, + {{49, 53, 56}, {50, 53, 57}, {52, 54, 56}, {52, 54, 56}, {54, 55, 57}, {54, 56, 57}, {54, 56, 58}, {54, 56, 58}}, + {{54, 57, 61}, {54, 57, 61}, {54, 56, 59}, {54, 56, 59}, {53, 54, 56}, {52, 54, 56}, {51, 54, 56}, {51, 53, 56}}, + {{49, 53, 56}, {49, 53, 56}, {51, 54, 56}, {51, 54, 56}, {54, 56, 57}, {54, 56, 58}, {54, 56, 59}, {54, 57, 59}}, + {{54, 59, 65}, {54, 60, 64}, {54, 57, 59}, {54, 56, 56}, {50, 54, 56}, {49, 53, 56}, {47, 52, 56}, {46, 51, 56}}, + {{45, 51, 56}, {46, 50, 56}, {51, 53, 56}, {54, 54, 56}, {54, 56, 60}, {54, 57, 61}, {54, 58, 63}, {54, 59, 64}} + }; + + zones::quality_lut_t zone2_prompt_ql = { + 0, 3, 3, 5, 1, 23, 7, 26, 1, 36, 22, 38, 2, 39, 25, 39, 0, 32, 18, 35, 4, 44, 44, 48, + 9, 44, 44, 49, 10, 49, 48, 51, 0, 17, 6, 21, 3, 28, 7, 30, 4, 44, 43, 48, 5, 48, 48, 51, + 1, 34, 21, 37, 4, 47, 47, 50, 10, 49, 48, 51, 11, 51, 50, 51, 0, 32, 16, 33, 3, 43, 43, 47, + 8, 43, 43, 47, 9, 47, 46, 50, 8, 40, 40, 42, 11, 53, 53, 57, 11, 54, 53, 58, 13, 58, 56, 62, + 2, 40, 40, 41, 5, 52, 52, 54, 11, 53, 52, 57, 12, 58, 54, 61, 8, 42, 42, 45, 12, 56, 55, 59, + 14, 57, 56, 61, 15, 62, 59, 63, 0, 16, 5, 19, 2, 27, 7, 29, 3, 43, 42, 46, 4, 46, 45, 50, + 1, 40, 40, 41, 6, 52, 52, 54, 10, 53, 52, 58, 12, 55, 54, 60, 1, 24, 7, 26, 5, 31, 7, 31, + 6, 53, 52, 57, 6, 58, 54, 60, 2, 41, 41, 45, 7, 55, 55, 59, 13, 56, 56, 61, 14, 60, 59, 63, + 0, 34, 20, 37, 4, 46, 46, 49, 9, 47, 46, 50, 10, 50, 49, 51, 8, 42, 42, 45, 12, 57, 56, 61, + 13, 57, 55, 62, 15, 62, 59, 63, 2, 41, 41, 44, 6, 55, 54, 59, 13, 58, 56, 61, 14, 61, 59, 63, + 9, 45, 45, 49, 14, 60, 60, 62, 15, 61, 60, 63, 15, 63, 62, 63 + }; + + std::vector zone2_disp_pd = { // Pattern N: Row0..RowM + {{52, 55, 58}, {52, 55, 58}, {53, 55, 57}, {53, 55, 57}, {54, 55, 56}, {53, 55, 57}, {53, 55, 57}, {53, 55, 57}}, + {{54, 57, 61}, {54, 57, 61}, {54, 56, 59}, {54, 56, 59}, {53, 55, 56}, {53, 54, 56}, {52, 54, 56}, {51, 54, 56}}, + {{49, 53, 56}, {49, 53, 56}, {51, 54, 56}, {51, 54, 56}, {54, 55, 57}, {54, 56, 57}, {54, 56, 58}, {54, 56, 59}}, + {{54, 58, 62}, {54, 58, 62}, {54, 56, 58}, {54, 56, 57}, {51, 54, 56}, {51, 53, 56}, {49, 53, 56}, {48, 52, 56}}, + {{48, 52, 56}, {48, 52, 56}, {52, 54, 56}, {53, 54, 56}, {54, 56, 59}, {54, 57, 59}, {54, 57, 61}, {54, 58, 62}}, + {{54, 60, 66}, {54, 60, 65}, {54, 57, 59}, {54, 56, 56}, {49, 53, 56}, {48, 52, 56}, {46, 52, 56}, {45, 51, 56}}, + {{44, 50, 56}, {45, 50, 56}, {51, 53, 56}, {54, 54, 56}, {54, 57, 61}, {54, 58, 62}, {54, 58, 64}, {54, 59, 65}} + }; + + zones::quality_lut_t zone2_disp_ql = { + 0, 3, 3, 5, 1, 23, 7, 26, 1, 36, 22, 38, 2, 39, 25, 39, 0, 32, 18, 35, 4, 44, 44, 48, + 9, 44, 44, 49, 10, 49, 48, 51, 0, 17, 6, 21, 3, 28, 7, 30, 4, 44, 43, 48, 5, 48, 48, 51, + 1, 34, 21, 37, 4, 47, 48, 50, 10, 49, 47, 51, 11, 51, 50, 51, 0, 32, 16, 33, 3, 43, 43, 47, + 8, 43, 43, 47, 9, 47, 46, 50, 8, 40, 40, 42, 11, 53, 52, 57, 11, 53, 52, 58, 13, 58, 56, 61, + 2, 40, 40, 41, 5, 52, 52, 55, 11, 53, 53, 57, 12, 56, 55, 61, 8, 42, 41, 45, 12, 56, 54, 59, + 14, 58, 56, 62, 15, 61, 59, 63, 0, 16, 6, 20, 2, 27, 7, 29, 3, 43, 42, 46, 4, 46, 46, 50, + 1, 40, 40, 41, 5, 53, 52, 54, 10, 53, 52, 58, 12, 55, 54, 60, 1, 24, 7, 26, 5, 31, 7, 31, + 6, 53, 52, 57, 6, 57, 54, 61, 2, 42, 41, 45, 7, 54, 55, 59, 13, 58, 55, 60, 14, 60, 59, 63, + 0, 34, 19, 37, 4, 46, 45, 49, 9, 47, 46, 50, 10, 50, 49, 51, 8, 42, 42, 45, 12, 57, 56, 61, + 13, 57, 56, 62, 15, 62, 60, 63, 2, 41, 41, 44, 6, 56, 54, 59, 13, 58, 55, 61, 14, 61, 59, 63, + 9, 45, 45, 49, 14, 60, 59, 62, 15, 62, 60, 63, 15, 63, 62, 63 + }; + + zones_.push_back({ + zone2_hm, + zone2_prompt_pd, + zone2_prompt_ql, + zone2_disp_pd, + zone2_disp_ql + }); + + // =========================================================================== + // Features + // =========================================================================== + // feat | ME1/1 | ME1/2 | ME2 | ME3 | ME4 | RE1 | RE2 | RE3 | RE4 | GE1/1 | GE2/1 | ME0 + // -----------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|------- + // emtf_phi | * | * | * | * | * | * | * | * | * | * | * | * + // emtf_theta | * | * | * | * | * | * | * | * | * | * | * | * + // emtf_bend | * | * | * | * | * | | | | | | | * + // emtf_qual | * | * | * | * | * | | | | | | | * + // emtf_time | | | | | | | | | | | | + features_ = { + { + feature_id_t::kPhi, { + site_id_t::kME11, site_id_t::kME12, site_id_t::kME2, site_id_t::kME3, site_id_t::kME4, + site_id_t::kRE1 , site_id_t::kRE2 , site_id_t::kRE3, site_id_t::kRE4, + site_id_t::kGE11, site_id_t::kGE21, site_id_t::kME0 + } + }, + { + feature_id_t::kTheta, { + site_id_t::kME11, site_id_t::kME12, site_id_t::kME2, site_id_t::kME3, site_id_t::kME4, + site_id_t::kRE1 , site_id_t::kRE2 , site_id_t::kRE3, site_id_t::kRE4, + site_id_t::kGE11, site_id_t::kGE21, site_id_t::kME0 + } + }, + { + feature_id_t::kBend, { + site_id_t::kME11, site_id_t::kME12, site_id_t::kME2, site_id_t::kME3, site_id_t::kME4, + site_id_t::kME0 + } + }, + { + feature_id_t::kQuality, { + site_id_t::kME11, site_id_t::kME12, site_id_t::kME2, site_id_t::kME3, site_id_t::kME4, + site_id_t::kME0 + } + }, + }; + + // =========================================================================== + // Theta Options + // =========================================================================== + theta_medians_ = { + // ME2_t1, ME3_t1, ME4_t1, ME2_t2, ME3_t2, ME4_t2, GE21, RE3, RE4 + { + { + {site_id_t::kME2, theta_id_t::kTheta1}, + {site_id_t::kME3, theta_id_t::kTheta1}, + {site_id_t::kME4, theta_id_t::kTheta1} + }, + { + {site_id_t::kME2, theta_id_t::kTheta2}, + {site_id_t::kME3, theta_id_t::kTheta2}, + {site_id_t::kME4, theta_id_t::kTheta2} + }, + { + {site_id_t::kGE21, theta_id_t::kTheta1}, + {site_id_t::kRE3, theta_id_t::kTheta1}, + {site_id_t::kRE4, theta_id_t::kTheta1} + }, + }, + // ME2_t1, ME3_t1, ME4_t1, ME2_t2, ME3_t2, ME4_t2, RE2, RE3, RE4 + { + { + {site_id_t::kME2, theta_id_t::kTheta1}, + {site_id_t::kME3, theta_id_t::kTheta1}, + {site_id_t::kME4, theta_id_t::kTheta1} + }, + { + {site_id_t::kME2, theta_id_t::kTheta2}, + {site_id_t::kME3, theta_id_t::kTheta2}, + {site_id_t::kME4, theta_id_t::kTheta2} + }, + { + {site_id_t::kRE2, theta_id_t::kTheta1}, + {site_id_t::kRE3, theta_id_t::kTheta1}, + {site_id_t::kRE4, theta_id_t::kTheta1} + }, + }, + // ME12_t1, ME11_t1, ME0_t2, ME12_t2, ME11_t2, ME0_t2, RE1, GE11, ME0_t1 + { + { + {site_id_t::kME12, theta_id_t::kTheta1}, + {site_id_t::kME11, theta_id_t::kTheta1}, + {site_id_t::kME0 , theta_id_t::kTheta2} + }, + { + {site_id_t::kME12, theta_id_t::kTheta2}, + {site_id_t::kME11, theta_id_t::kTheta2}, + {site_id_t::kME0 , theta_id_t::kTheta2} + }, + { + {site_id_t::kRE1, theta_id_t::kTheta1}, + {site_id_t::kGE11, theta_id_t::kTheta1}, + {site_id_t::kME0, theta_id_t::kTheta1} + }, + }, + }; + + // =========================================================================== + // Site Reduction + // =========================================================================== + // Site (out) | Site (in) + // -----------|------------------------------------------- + // ME1 | ME1/1, GE1/1, ME1/2, RE1/2 + // ME2 | ME2, GE2/1, RE2/2 + // ME3 | ME3, RE3 + // ME4 | ME4, RE4 + // ME0 | ME0 + reduced_sites_ = { + {reduced_site_id_t::kME1, {site_id_t::kME11, site_id_t::kGE11, site_id_t::kME12, site_id_t::kRE1}}, + {reduced_site_id_t::kME2, {site_id_t::kME2, site_id_t::kGE21, site_id_t::kRE2}}, + {reduced_site_id_t::kME3, {site_id_t::kME3, site_id_t::kRE3}}, + {reduced_site_id_t::kME4, {site_id_t::kME4, site_id_t::kRE4}}, + {reduced_site_id_t::kME0, {site_id_t::kME0}}, + }; +} + +EMTFModel::~EMTFModel() { + // Do Nothing +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc new file mode 100644 index 0000000000000..efdfd8ed84f9c --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc @@ -0,0 +1,479 @@ +#include + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h" + +using namespace emtf::phase2; + +SectorProcessor::SectorProcessor( + const EMTFContext& context, + const int& endcap, const int& sector +): + context_(context), + endcap_(endcap), + sector_(sector), + event_(nullptr), + bx_(nullptr) +{ + // =========================================================================== + // Register Selectors/Converters + // =========================================================================== + if (CONFIG.csc_en_) { + tp_selectors_[L1TMuon::kCSC] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kCSC] = std::make_unique(context_, endcap_, sector_); + } + + if (CONFIG.rpc_en_) { + tp_selectors_[L1TMuon::kRPC] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kRPC] = std::make_unique(context_, endcap_, sector_); + } + + if (CONFIG.gem_en_) { + tp_selectors_[L1TMuon::kGEM] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kGEM] = std::make_unique(context_, endcap_, sector_); + } + + if (CONFIG.me0_en_) { + tp_selectors_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); + } + + if (CONFIG.ge0_en_) { + tp_selectors_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); + } + +} + +SectorProcessor::~SectorProcessor() { + // Do Nothing +} + +void SectorProcessor::configure_event(const edm::Event& event) { + // Event + event_ = &event; + bx_ = nullptr; + + // Reset Window Hits + bx_window_hits_.clear(); + bx_ilink_tpc_maps_.clear(); +} + +void SectorProcessor::configure_bx(const int& bx) { + // BX + bx_ = &bx; + + // Reset BX Maps + bx_ilink_tpc_maps_.clear(); + + // Remove BX TPCollections that aren't in the bx window + // Note that the first entry in bx_window_hits is the earliest BX + const auto min_bx = CONFIG.min_bx_; + const auto delay_bx = CONFIG.bx_window_ - 1; + const auto pop_after_bx = min_bx + delay_bx; + + if (pop_after_bx < bx) { + bx_window_hits_.erase(bx_window_hits_.begin()); + } +} + +void SectorProcessor::select( + const TriggerPrimitive& tp, + const TPInfo& tp_info +) { + // Get TPSelector + auto tp_subsystem = tp.subsystem(); + + auto tp_selectors_it = tp_selectors_.find(tp_subsystem); + + // Short-Circuit: Operation not supported + if (tp_selectors_it == tp_selectors_.end()) { + edm::LogWarning("L1T") + << "TPCollector has been implemented, " + << "but there is no TPSelector for " + << tp_subsystem; + return; + } + + // Select TP that belongs to this Sector Processor + auto& bx_ilink_tpc_map = bx_ilink_tpc_maps_[tp_subsystem]; // reference to subsystem trigger primitive collection + + tp_selectors_it->second->select( + tp, tp_info, + bx_ilink_tpc_map + ); +} + +void SectorProcessor::process( + EMTFHitCollection& out_hits, + EMTFTrackCollection& out_tracks, + EMTFInputCollection& out_inputs +) { + // =========================================================================== + // Merge subsystem selections + // =========================================================================== + ILinkTPCMap bx_ilink_tpc_map; + + for (auto& [subsystem, ilink_tpc_map] : bx_ilink_tpc_maps_) { + copy_tp(ilink_tpc_map, bx_ilink_tpc_map); + } + + // Free memory + bx_ilink_tpc_maps_.clear(); + + // =========================================================================== + // Convert trigger primitives to EMTF Hits + // =========================================================================== + + // Convert tp into hits + EMTFHitCollection bx_hits; + + convert_tp( + out_hits.size(), + bx_ilink_tpc_map, + bx_hits + ); + + // Append to bx window hits + bx_window_hits_.push_back(bx_hits); + + // Free memory + bx_ilink_tpc_map.clear(); + + // Record hits + out_hits.insert(out_hits.end(), bx_hits.begin(), bx_hits.end()); + + // =========================================================================== + // Current Algorithm only supports BX=0 + // =========================================================================== + + if ((*bx_) != 0) { + return; + } + + // =========================================================================== + // Convert EMTF Hits to Segments + // =========================================================================== + + // Init Segment to Hit Map + std::map seg_to_hit; + + // Convert bx window hits into segments + segment_collection_t segments; + + populate_segments(bx_window_hits_, seg_to_hit, segments); + + // Build Tracks + build_tracks(seg_to_hit, segments, false, out_tracks); // With prompt setup + build_tracks(seg_to_hit, segments, true, out_tracks); // With displaced setup + + // =========================================================================== + // Record segments/hits used in track building + // =========================================================================== + if (seg_to_hit.size() > 0) { + EMTFInput::hits_t hit_id_col; + EMTFInput::segs_t seg_id_col; + + for (const auto& [seg_id, hit_id] : seg_to_hit) { + seg_id_col.push_back(seg_id); + hit_id_col.push_back(hit_id); + } + + EMTFInput emtf_input; + + const int endcap_pm = (endcap_ == 2) ? -1 : endcap_; // 1: +endcap, -1: -endcap + + emtf_input.setEndcap(endcap_pm); + emtf_input.setSector(sector_); + emtf_input.setBx(*bx_); + emtf_input.setHits(hit_id_col); + emtf_input.setSegs(seg_id_col); + + out_inputs.push_back(emtf_input); + } +} + +void SectorProcessor::copy_tp( + const ILinkTPCMap& source, + ILinkTPCMap& target +) const { + typedef typename ILinkTPCMap::iterator Iterator_t; + typedef typename ILinkTPCMap::mapped_type Collection_t; + + for (auto& source_kv : source) { + std::pair ins_res = target.insert(source_kv); + + // Short-Circuit: Insertion succeeded, move on + if (ins_res.second) { + continue; + } + + // Merge into target collection + const Collection_t& source_col = source_kv.second; + Collection_t& target_col = ins_res.first->second; + + target_col.insert(target_col.end(), source_col.begin(), source_col.end()); + } +} + +void SectorProcessor::convert_tp( + const int& initial_hit_id, + const ILinkTPCMap& ilink_tpc_map, + EMTFHitCollection& hits +) { + EMTFHitCollection substitutes; + + for (const auto& [ilink, ilink_tpc] : ilink_tpc_map) { // loop input link trigger primitive collections + + unsigned int cnt_segments = 0; // Enumerates each segment in the same chamber + + for (const auto& tp_entry : ilink_tpc) { // loop trigger primitives + + // Unpack Entry + const auto& tp = tp_entry.tp_; // const reference + auto tp_info = tp_entry.info_; // copy info + + // Unpack trigger primitive + auto tp_subsystem = tp.subsystem(); + + // Get Converter + auto tp_converters_it = tp_converters_.find(tp_subsystem); + + // Short-Circuit: Operation not supported + if (tp_converters_it == tp_converters_.end()) { + edm::LogWarning("L1T") << "TPCollector & TPSelector have been implemented, " + << "but there is no TPConverter for " + << tp_subsystem; + continue; + } + + // Set Segment Id + tp_info.segment_id = cnt_segments++; // Save and increase segment count + + // Convert + EMTFHit hit; + + tp_converters_it->second->convert(tp, tp_info, hit); + + // Append to hit collections + if (tp_info.flag_substitute){ + substitutes.push_back(hit); + } else { + hits.push_back(hit); + } + } + } + + // Substitutes are placed at the end of the hit collection + hits.insert( + hits.end(), + std::make_move_iterator(substitutes.begin()), + std::make_move_iterator(substitutes.end()) + ); + + // Assign Hit Ids + unsigned int cnt_hits = initial_hit_id; + + for (auto& hit : hits) { + hit.setId(cnt_hits++); + } +} + +void SectorProcessor::populate_segments( + const std::vector& bx_window_hits, + std::map& seg_to_hit, + segment_collection_t& segments +) { + // Initialize + for (int seg_id = 0; seg_id < v3::kNumSegments; ++seg_id) { + segments[seg_id].phi = 0; + segments[seg_id].bend = 0; + segments[seg_id].theta1 = 0; + segments[seg_id].theta2 = 0; + segments[seg_id].qual1 = 0; + segments[seg_id].qual2 = 0; + segments[seg_id].time = 0; + segments[seg_id].zones = 0; + segments[seg_id].tzones = 0; + segments[seg_id].cscfr = 0; + segments[seg_id].layer = 0; + segments[seg_id].bx = 0; + segments[seg_id].valid = 0; + } + + // Populate + auto bx_window_hits_rit = bx_window_hits.rbegin(); + auto bx_window_hits_rend = bx_window_hits.rend(); + + std::map next_ch_seg; + + for (; bx_window_hits_rit != bx_window_hits_rend; ++bx_window_hits_rit) { // Begin loop from latest BX Collection to oldest BX Hit Collection + + const auto& bx_hits = *bx_window_hits_rit; + std::map bx_last_ch_seg; + + for (const auto& hit : bx_hits) { // Begin loop hits in BX + // Unpack Hit + const auto& hit_chamber = hit.emtfChamber(); + const auto& hit_segment = hit.emtfSegment(); + const auto& hit_valid = hit.flagValid(); + + emtf_assert(hit_valid); // segment must be valid + + // Get Channel Segment Count + unsigned int ch_seg = next_ch_seg[hit_chamber] + hit_segment; + + // Short-Circuit: Accept at most 2 segments + if (!(ch_seg < v3::kChamberSegments)) { + continue; + } + + // Calculate Host + const auto& hit_host = hit.emtfHost(); + + // Calculate Relative BX + // Note: Uses Hit BX relative to Sector Processor BX + const auto& hit_bx = hit.bx(); + const int hit_rel_bx = (hit_bx - *bx_); + + // Short-Circuit: Only use Relative BX=0 Segments + if (hit_rel_bx != 0) { + continue; + } + + // Calculate Timezone + const auto hit_timezones = context_.timezone_lut_.get_timezones(hit_host, hit_rel_bx); + + // Calculate algo seg + const unsigned int seg_id = hit_chamber * v3::kChamberSegments + ch_seg; + + emtf_assert(seg_id < v3::kNumSegments); + + seg_to_hit[seg_id] = hit.id(); + + // Populate segment + segments[seg_id].phi = hit.emtfPhi(); + segments[seg_id].bend = hit.emtfBend(); + segments[seg_id].theta1 = hit.emtfTheta1(); + segments[seg_id].theta2 = hit.emtfTheta2(); + segments[seg_id].qual1 = hit.emtfQual1(); + segments[seg_id].qual2 = hit.emtfQual2(); + segments[seg_id].time = hit.emtfTime(); + segments[seg_id].zones = hit.emtfZones(); + segments[seg_id].tzones = hit_timezones; + segments[seg_id].cscfr = hit.cscFR(); + segments[seg_id].layer = hit.layer(); + segments[seg_id].bx = hit.bx(); + segments[seg_id].valid = hit.flagValid(); + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout + << std::endl + << "Event: " << event_->id() + << " Endcap: " << endcap_ + << " Sector: " << sector_ + << " BX: " << (*bx_) + << " Hit iLink: " << hit_chamber + << " Hit iSeg: " << ch_seg + << " Hit Host " << hit_host + << " Hit Rel BX " << (hit_bx - *bx_) + << " Hit Timezones " << hit_timezones + << std::endl; + + std::cout + << " id " << seg_id + << " phi " << segments[seg_id].phi + << " bend " << segments[seg_id].bend + << " theta1 " << segments[seg_id].theta1 + << " theta2 " << segments[seg_id].theta2 + << " qual1 " << segments[seg_id].qual1 + << " qual2 " << segments[seg_id].qual2 + << " time " << segments[seg_id].time + << " zones " << segments[seg_id].zones + << " timezones " << segments[seg_id].tzones + << " cscfr " << segments[seg_id].cscfr + << " layer " << segments[seg_id].layer + << " bx " << segments[seg_id].bx + << " valid " << segments[seg_id].valid + << std::endl; + } + + // Update bx chamber last segment + bx_last_ch_seg[hit_chamber] = ch_seg; + } // End loop hits from BX + + for (auto& [chamber, ch_seg] : bx_last_ch_seg) { + next_ch_seg[chamber] = ch_seg + 1; + } + + bx_last_ch_seg.clear(); + } // End loop from latest BX Collection to oldest BX Hit Collection +} + +void SectorProcessor::build_tracks( + const std::map& seg_to_hit, + const segment_collection_t& segments, + const bool& displaced_en, + EMTFTrackCollection& out_tracks +) { + // Apply Hitmap Building Layer: Convert segments into hitmaps + std::vector zone_hitmaps; + + context_.hitmap_building_layer_.apply(segments, zone_hitmaps); + + // Apply Pattern Matching Layer: Match patterns to hitmaps to create roads + std::vector zone_roads; + + context_.pattern_matching_layer_.apply(zone_hitmaps, displaced_en, zone_roads); + + // Apply Road Sorting Layer: Find the best roads + std::vector best_roads; + + context_.road_sorting_layer_.apply(v3::kNumTracks, zone_roads, best_roads); + + // Apply Track Building Layer: Match segments to the best roads to create tracks + std::vector tracks; + + context_.track_building_layer_.apply(segments, best_roads, displaced_en, tracks); + + // Apply Duplicate Removal Layer: Removes tracks that share a segment, keeping the one that has the highest quality + context_.duplicate_removal_layer_.apply(tracks); + + // Apply Parameter Assigment Layer: Run NN on tracks + context_.parameter_assignment_layer_.apply(displaced_en, tracks); + + // Apply Output Layer + EMTFTrackCollection bx_tracks; + + context_.output_layer_.apply( + endcap_, sector_, *bx_, + seg_to_hit, tracks, displaced_en, + bx_tracks + ); + + // Record tracks + out_tracks.insert(out_tracks.end(), bx_tracks.begin(), bx_tracks.end()); +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc new file mode 100644 index 0000000000000..97bfdae9beb34 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc @@ -0,0 +1,225 @@ +#include +#include +#include + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h" +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h" + +using namespace emtf::phase2; + +TrackFinder::TrackFinder( + const edm::ParameterSet& i_config, + edm::ConsumesCollector&& i_consumes_collector +): + context_(i_config, i_consumes_collector), + tp_collectors_(), + sector_processors_() +{ + // =========================================================================== + // Emulation Setup + // =========================================================================== + + // Register Trigger Primitives + if (CONFIG.csc_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + if (CONFIG.rpc_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + if (CONFIG.gem_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + if (CONFIG.me0_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + if (CONFIG.ge0_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + // Register Sector Processor + for (int endcap = kMinEndcap; endcap <= kMaxEndcap; ++endcap) { + for (int sector = kMinTrigSector; sector <= kMaxTrigSector; ++sector) { + sector_processors_.push_back( + std::make_unique(context_, endcap, sector) + ); + } + } +} + +TrackFinder::~TrackFinder() { + // Do Nothing +} + +void TrackFinder::process( + // Input + const edm::Event& i_event, + const edm::EventSetup& i_event_setup, + // Output + EMTFHitCollection& out_hits, + EMTFTrackCollection& out_tracks, + EMTFInputCollection& out_inputs +) { + // =========================================================================== + // Clear output collections + // =========================================================================== + + out_hits.clear(); + out_tracks.clear(); + out_inputs.clear(); + + // =========================================================================== + // Load the event configuration + // =========================================================================== + + context_.update(i_event, i_event_setup); + + // =========================================================================== + // Collect trigger primitives + // =========================================================================== + + // Build BX Sequence + std::vector bx_sequence; + + { + auto min_bx = CONFIG.min_bx_; + auto delay_bx = CONFIG.bx_window_ - 1; + auto max_bx = CONFIG.max_bx_ + delay_bx; + + for (int bx = min_bx; bx <= max_bx; ++bx) { + bx_sequence.push_back(bx); + } + } + + // Collect TP per BX + BXTPCMap bx_tpc_map; + + for (auto& tp_collector : tp_collectors_) { + tp_collector->collect(i_event, bx_tpc_map); + } + + // Debug Info + if (CONFIG.verbosity_ > 4) { + int n_tp = 0; + + // Loop BX + for (const auto& bx : bx_sequence) { + // Get trigger primitives for this BX + auto bx_tpc_map_it = bx_tpc_map.find(bx); + auto bx_tpc_map_end = bx_tpc_map.end(); + + // Short-Circuit: Empty trigger primitive collection + if (bx_tpc_map_it == bx_tpc_map_end) { + continue; + } + + // Reference TPC + auto& bx_tpc = bx_tpc_map_it->second; + + // Short-Circuit: Empty trigger primitive collection + if (bx_tpc.size() == 0) { + continue; + } + + // Print trigger primitives + std::cout << "===========================================================================" << std::endl; + std::cout << "Begin TPC BX " << bx << " Dump" << std::endl; + std::cout << "---------------------------------------------------------------------------" << std::endl; + + n_tp += bx_tpc.size(); + + for (const auto& tp_entry : bx_tpc) { + tp_entry.tp_.print(std::cout); + + std::cout << "---------------------------------------------------------------------------" << std::endl; + } + + std::cout << "End TPC BX " << bx << " Dump" << std::endl; + std::cout << "===========================================================================" << std::endl; + } + + // Print TPrimitives Summary + if (n_tp > 0) { + std::cout << "Num of TriggerPrimitive: " << n_tp << std::endl; + std::cout << "===========================================================================" << std::endl; + } + } + + // =========================================================================== + // Run sector processors + // =========================================================================== + + // Before event + for (auto& sector_processor : sector_processors_) { + sector_processor->configure_event(i_event); + } + + // Orderly loop BX + for (const auto& bx : bx_sequence) { + // Get trigger primitives for this BX + auto bx_tpc_map_it = bx_tpc_map.find(bx); + auto bx_tpc_map_end = bx_tpc_map.end(); + + TPCollection* bx_tpc_ptr = nullptr; + + if (bx_tpc_map_it != bx_tpc_map_end) { + bx_tpc_ptr = &(bx_tpc_map_it->second); + } + + // Loop over all sector processors + for (auto& sector_processor : sector_processors_) { + // Before BX + sector_processor->configure_bx(bx); + + // Select trigger primitives in BX + if (bx_tpc_ptr != nullptr) { + for (const auto& tp_entry : *bx_tpc_ptr) { + const auto& tp = tp_entry.tp_; + const auto& tp_info = tp_entry.info_; + + sector_processor->select(tp, tp_info); + } + } + + // Process trigger primitives + sector_processor->process(out_hits, out_tracks, out_inputs); + } + + // Free memory: Removes BX TPCollections after all Sector Processors have selected their TPrimitives + if (bx_tpc_ptr != nullptr) { + bx_tpc_map.erase(bx_tpc_map_it); + } + } + + // Free memory: Drops any BX TPCollections outside of the [min bx, max bx] range + bx_tpc_map.clear(); +} + +void TrackFinder::on_job_begin() { + // Do Nothing +} + +void TrackFinder::on_job_end() { + // Do Nothing +} + diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc new file mode 100644 index 0000000000000..5251ac3142e26 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc @@ -0,0 +1,182 @@ +#include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h" + +namespace emtf::phase2::csc { + + // Chambers + int next_10deg_chamber(int chamber) { + return (chamber == 36) ? 1 : (chamber + 1); + } + + int prev_10deg_chamber(int chamber) { + return (chamber == 1) ? 36 : (chamber - 1); + } + + int next_20deg_chamber(int chamber) { + return (chamber == 18) ? 1 : (chamber + 1); + } + + int prev_20deg_chamber(int chamber) { + return (chamber == 1) ? 18 : (chamber - 1); + } + + // Sectors + bool is_in_sector( + int sp_endcap, int sp_sector, + int tp_endcap, int tp_sector + ) { + return sp_endcap == tp_endcap && sp_sector == tp_sector; + } + + bool is_in_neighbor_sector( + int sp_endcap, int sp_sector, + int tp_endcap, int tp_sector, int tp_subsector, + int tp_station, int tp_id + ) { + // Match endcap and neighbor sector + int neighbor_sector = ((sp_sector == 1) ? 6 : sp_sector - 1); + + if ((sp_endcap != tp_endcap) || (neighbor_sector != tp_sector)) + return false; + + // Match CSCID in station 1 + if (tp_station == 1) + return (tp_subsector == 2) && (tp_id == 3 || tp_id == 6 || tp_id == 9); + + + // Match CSCID in other stations + return tp_id == 3 || tp_id == 9; + } + + // Use CSC trigger "CSC ID" definitions + // Copied from DataFormats/MuonDetId/src/CSCDetId.cc + int get_id(int station, int ring, 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: + 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; + } + + // Use CSC trigger sector definitions + // Copied from DataFormats/MuonDetId/src/CSCDetId.cc + int get_trigger_sector(int station, int ring, 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) { + 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. + } + + int get_trigger_subsector(int station, int chamber) { + // station 2,3,4 --> subsector 0 + if (station != 1) { + return 0; + } + + // station 1 --> subsector 1 or 2 + if ((chamber % 6) > 2) { + return 1; + } + + return 2; + } + + // Copied from RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.cc + Facing get_face_direction(int station, int ring, int chamber) { + bool is_not_overlapping = (station == 1 && ring == 3); + + // Not overlapping means it's facing backwards + if (is_not_overlapping) + return Facing::kRear; + + // odd chambers are bolted to the iron, which faces + // forward in stations 1 and 2, backward in stations 3 and 4 + bool is_even = (chamber % 2 == 0); + + if (station < 3) + return (is_even ? Facing::kRear : Facing::kFront); + + return (is_even ? Facing::kFront : Facing::kRear); + } + + // 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 | + // +----------------------------+------------+------------+ + + std::pair get_max_strip_and_wire(int station, int ring) { + int max_strip = 0; // halfstrip + int 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 std::make_pair(max_strip, max_wire); + } + + std::pair get_max_pattern_and_quality(int station, int ring) { + int max_pattern = 11; + int max_quality = 16; + + return std::make_pair(max_pattern, max_quality); + } + +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc new file mode 100644 index 0000000000000..26852aa80e286 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc @@ -0,0 +1,124 @@ +#include + +#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h" + +namespace emtf::phase2::tp { + + // _______________________________________________________________________ + // radians <-> degrees + float deg_to_rad(float deg) { + constexpr float factor = M_PI / 180.; + return deg * factor; + } + + float rad_to_deg(float rad) { + constexpr float factor = 180. / M_PI; + + return rad * factor; + } + + // _______________________________________________________________________ + // phi range: [-180..180] or [-pi..pi] + float wrap_phi_deg(float deg) { + float twopi = 360.; + float recip = 1.0 / twopi; + + return deg - (std::round(deg * recip) * twopi); + } + + float wrap_phi_rad(float rad) { + const float twopi = M_PI * 2.; + const float recip = 1.0 / twopi; + + return rad - (std::round(rad * recip) * twopi); + } + + // _______________________________________________________________________ + // theta + float calc_theta_rad_from_eta(float eta) { + float theta = std::atan2(1.0, std::sinh(eta)); // cot(theta) = sinh(eta) + + return theta; + } + + float calc_theta_deg_from_eta(float eta) { + float theta = rad_to_deg(calc_theta_rad_from_eta(eta)); + + return theta; + } + + float calc_theta_deg_from_int(int theta_int) { + float theta = static_cast(theta_int); + + theta = theta * (45.0 - 8.5) / 128. + 8.5; + + return theta; + } + + float calc_theta_rad_from_int(int theta_int) { + float theta = deg_to_rad(calc_theta_deg_from_int(theta_int)); + + return theta; + } + + int calc_theta_int(int endcap, float theta) { // theta in deg [0..180], endcap [-1, +1] + theta = (endcap == -1) ? (180. - theta) : theta; + theta = (theta - 8.5) * 128. / (45.0 - 8.5); + + int theta_int = static_cast(std::round(theta)); + + theta_int = (theta_int <= 0) ? 1 : theta_int; // protect against invalid value + + return theta_int; + } + + // _______________________________________________________________________ + // phi + float calc_phi_glob_deg_from_loc(int sector, float loc) { // loc in deg, sector [1..6] + float glob = loc + 15. + (60. * (sector - 1)); + + glob = (glob >= 180.) ? (glob - 360.) : glob; + + return glob; + } + + float calc_phi_glob_rad_from_loc(int sector, float loc) { // loc in rad, sector [1..6] + float glob = deg_to_rad(calc_phi_glob_deg_from_loc(sector, rad_to_deg(loc))); + + return glob; + } + + float calc_phi_loc_deg_from_int(int phi_int) { + float loc = static_cast(phi_int); + + loc = (loc / 60.) - 22.; + + return loc; + } + + float calc_phi_loc_rad_from_int(int phi_int) { + float loc = deg_to_rad(calc_phi_loc_deg_from_int(phi_int)); + + return loc; + } + + float calc_phi_loc_deg_from_glob(int sector, float glob) { // glob in deg [-180..180], sector [1..6] + glob = wrap_phi_deg(glob); + + float loc = glob - 15. - (60. * (sector - 1)); + + return loc; + } + + int calc_phi_int(int sector, float glob) { // glob in deg [-180..180], sector [1..6] + float loc = calc_phi_loc_deg_from_glob(sector, glob); + + loc = ((loc + 22.) < 0.) ? (loc + 360.) : loc; + loc = (loc + 22.) * 60.; + + int phi_int = static_cast(std::round(loc)); + + return phi_int; + } + +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/test/debug.py b/L1Trigger/L1TMuonEndCapPhase2/test/debug.py new file mode 100644 index 0000000000000..bea8f03f1559f --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/test/debug.py @@ -0,0 +1,182 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 16 --conditions auto:phase2_realistic --era Phase2C9 --geometry Extended2026D49 --fileout file:SingleMuon_Endcap.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --python_filename pset_SingleMuon_PosEnd_2GeV.py --no_exec --mc +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C9_cff import Phase2C9 + +process = cms.Process('L1',Phase2C9) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(100), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + FailPath = cms.untracked.vstring(), + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + SkipEvent = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + makeTriggerResults = cms.obsolete.untracked.bool, + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py nevts:1000'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('file:SingleMuon_Endcap.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.generator = cms.EDProducer("FlatRandomPtGunProducer2", + AddAntiParticle = cms.bool(False), + PGunParameters = cms.PSet( + MaxEta = cms.double(2.5), + MaxPhi = cms.double(3.141592653589793), + MaxPt = cms.double(120.0), + MaxDxy = cms.double(120.0), + MinEta = cms.double(1.2), + MinPhi = cms.double(-3.141592653589793), + MinPt = cms.double(2.0), + MinDxy = cms.double(0.0), + PartID = cms.vint32(-13), + PtSpectrum = cms.string('flatOneOverPt'), + VertexSpectrum = cms.string('none'), + RandomCharge = cms.bool(True) + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('single muon+/- pt 2 to 120 flat in 1/pt positive endcap') +) + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.digitisation_step = cms.Path(process.pdigi) +process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) +process.L1simulation_step = cms.Path(process.SimL1Emulator) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads = 1 +process.options.numberOfStreams = 0 +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.generator) + +# customisation of the process. + +# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig +from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP + +#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig +process = higherPtTP(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging +from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 + +#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging +process = customise_aging_1000(process) + +# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 +from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 + +#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 +process = customisePhase2TTOn110(process) + +# Automatic addition of the customisation function from L1Trigger.L1TMuonEndCapPhase2.config +from L1Trigger.L1TMuonEndCapPhase2.config import customise_debug + +#call to customisation function customise_mc imported from L1Trigger.L1TMuonEndCapPhase2.config +process = customise_debug(process) + +# Automatic addition of the customisation function from EMTFTools.NtupleMaker.config +from EMTFTools.NtupleMaker.config import customise_ntuple + +#call to customisation function customise_ntuple imported from EMTFTools.NtupleMaker.config +process = customise_ntuple(process) + +# End of customisation functions + + +# Customisation from command line +process.TFileService = cms.Service('TFileService', fileName = cms.string('test.root')) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/L1Trigger/L1TMuonEndCapPhase2/test/debug_disp.py b/L1Trigger/L1TMuonEndCapPhase2/test/debug_disp.py new file mode 100644 index 0000000000000..826ac4b3a0481 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/test/debug_disp.py @@ -0,0 +1,182 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 16 --conditions auto:phase2_realistic --era Phase2C9 --geometry Extended2026D49 --fileout file:SingleMuon_Endcap.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --python_filename pset_SingleMuon_PosEnd_2GeV.py --no_exec --mc +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C9_cff import Phase2C9 + +process = cms.Process('L1',Phase2C9) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(100), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + FailPath = cms.untracked.vstring(), + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + SkipEvent = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + makeTriggerResults = cms.obsolete.untracked.bool, + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py nevts:1000'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('file:SingleMuon_Endcap.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.generator = cms.EDProducer("FlatRandomPtGunProducer2", + AddAntiParticle = cms.bool(False), + PGunParameters = cms.PSet( + MaxEta = cms.double(2.5), + MaxPhi = cms.double(3.141592653589793), + MaxPt = cms.double(120.0), + MaxDxy = cms.double(120.0), + MinEta = cms.double(1.2), + MinPhi = cms.double(-3.141592653589793), + MinPt = cms.double(2.0), + MinDxy = cms.double(0.0), + PartID = cms.vint32(-13), + PtSpectrum = cms.string('flatOneOverPt'), + VertexSpectrum = cms.string('flatD0'), + RandomCharge = cms.bool(True) + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('single muon+/- pt 2 to 120 flat in 1/pt positive endcap') +) + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.digitisation_step = cms.Path(process.pdigi) +process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) +process.L1simulation_step = cms.Path(process.SimL1Emulator) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads = 1 +process.options.numberOfStreams = 0 +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.generator) + +# customisation of the process. + +# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig +from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP + +#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig +process = higherPtTP(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging +from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 + +#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging +process = customise_aging_1000(process) + +# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 +from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 + +#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 +process = customisePhase2TTOn110(process) + +# Automatic addition of the customisation function from L1Trigger.L1TMuonEndCapPhase2.config +from L1Trigger.L1TMuonEndCapPhase2.config import customise_debug + +#call to customisation function customise_mc imported from L1Trigger.L1TMuonEndCapPhase2.config +process = customise_debug(process) + +# Automatic addition of the customisation function from EMTFTools.NtupleMaker.config +from EMTFTools.NtupleMaker.config import customise_ntuple + +#call to customisation function customise_ntuple imported from EMTFTools.NtupleMaker.config +process = customise_ntuple(process) + +# End of customisation functions + + +# Customisation from command line +process.TFileService = cms.Service('TFileService', fileName = cms.string('test.root')) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp.py b/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp.py new file mode 100644 index 0000000000000..135a05da72bf3 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp.py @@ -0,0 +1,181 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 16 --conditions auto:phase2_realistic --era Phase2C9 --geometry Extended2026D49 --fileout file:SingleMuon_Endcap.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --python_filename pset_SingleMuon_PosEnd_2GeV.py --no_exec --mc +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C9_cff import Phase2C9 + +process = cms.Process('L1',Phase2C9) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D49_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1000), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + FailPath = cms.untracked.vstring(), + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + SkipEvent = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + makeTriggerResults = cms.obsolete.untracked.bool, + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py nevts:1000'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('file:SingleMuon_Endcap.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.generator = cms.EDProducer("FlatRandomLLPGunProducer2", + AddAntiParticle = cms.bool(False), + PGunParameters = cms.PSet( + MaxMassH = cms.double(1000), + MinMassH = cms.double(20), + MaxPtH = cms.double(120), + MinPtH = cms.double(1), + MaxCTauLLP = cms.double(5000), + MinCTauLLP = cms.double(10), + MaxEta = cms.double(3.5), + MinEta = cms.double(1e-6), + MaxPhi = cms.double(3.141592653589793), + MinPhi = cms.double(-3.141592653589793), + PartID = cms.vint32(-13), + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('LLP decay positive endcap') +) + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.digitisation_step = cms.Path(process.pdigi) +process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) +process.L1simulation_step = cms.Path(process.SimL1Emulator) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads = 16 +process.options.numberOfStreams = 0 +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.generator) + +# customisation of the process. + +# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig +from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP + +#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig +process = higherPtTP(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging +from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 + +#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging +process = customise_aging_1000(process) + +# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 +from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 + +#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 +process = customisePhase2TTOn110(process) + +# Automatic addition of the customisation function from L1Trigger.L1TMuonEndCapPhase2.config +from L1Trigger.L1TMuonEndCapPhase2.config import customise_mc + +#call to customisation function customise_mc imported from L1Trigger.L1TMuonEndCapPhase2.config +process = customise_mc(process) + +# Automatic addition of the customisation function from EMTFTools.NtupleMaker.config +from EMTFTools.NtupleMaker.config import customise_ntuple + +#call to customisation function customise_ntuple imported from EMTFTools.NtupleMaker.config +process = customise_ntuple(process) + +# End of customisation functions + + +# Customisation from command line +process.TFileService = cms.Service('TFileService', fileName = cms.string('test.root')) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion diff --git a/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp_flatinvdmass_d88.py b/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp_flatinvdmass_d88.py new file mode 100644 index 0000000000000..695b9c23e1248 --- /dev/null +++ b/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp_flatinvdmass_d88.py @@ -0,0 +1,182 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 16 --conditions auto:phase2_realistic --era Phase2C9 --geometry Extended2026D49 --fileout file:SingleMuon_Endcap.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --python_filename pset_SingleMuon_PosEnd_2GeV.py --no_exec --mc +import FWCore.ParameterSet.Config as cms + +from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 + +process = cms.Process('L1',Phase2C17I13M9) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') +process.load('Configuration.Geometry.GeometryExtended2026D88_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.L1TrackTrigger_cff') +process.load('Configuration.StandardSequences.SimL1Emulator_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1000), + output = cms.optional.untracked.allowed(cms.int32,cms.PSet) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + FailPath = cms.untracked.vstring(), + IgnoreCompletely = cms.untracked.vstring(), + Rethrow = cms.untracked.vstring(), + SkipEvent = cms.untracked.vstring(), + accelerators = cms.untracked.vstring('*'), + allowUnscheduled = cms.obsolete.untracked.bool, + canDeleteEarly = cms.untracked.vstring(), + deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), + dumpOptions = cms.untracked.bool(False), + emptyRunLumiMode = cms.obsolete.untracked.string, + eventSetup = cms.untracked.PSet( + forceNumberOfConcurrentIOVs = cms.untracked.PSet( + allowAnyLabel_=cms.required.untracked.uint32 + ), + numberOfConcurrentIOVs = cms.untracked.uint32(0) + ), + fileMode = cms.untracked.string('FULLMERGE'), + forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), + makeTriggerResults = cms.obsolete.untracked.bool, + numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), + numberOfConcurrentRuns = cms.untracked.uint32(1), + numberOfStreams = cms.untracked.uint32(0), + numberOfThreads = cms.untracked.uint32(1), + printDependencies = cms.untracked.bool(False), + sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, + throwIfIllegalParameter = cms.untracked.bool(True), + wantSummary = cms.untracked.bool(False) +) + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py nevts:1000'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('file:SingleMuon_Endcap.root'), + outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, + splitLevel = cms.untracked.int32(0) +) + +# Additional output definition + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') + +process.generator = cms.EDProducer("FlatRandomLLPGunProducer2", + AddAntiParticle = cms.bool(False), + PGunParameters = cms.PSet( + MaxMassH = cms.double(1000), + MinMassH = cms.double(20), + MaxPtH = cms.double(120), + MinPtH = cms.double(1), + MaxCTauLLP = cms.double(5000), + MinCTauLLP = cms.double(10), + MaxEta = cms.double(3.5), + MinEta = cms.double(1e-6), + MaxPhi = cms.double(3.141592653589793), + MinPhi = cms.double(-3.141592653589793), + LLPMassSpectrum = cms.string('flatInvDMass'), + PartID = cms.vint32(-13), + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('LLP decay positive endcap') +) + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.digitisation_step = cms.Path(process.pdigi) +process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) +process.L1simulation_step = cms.Path(process.SimL1Emulator) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) + +#Setup FWK for multithreaded +process.options.numberOfThreads = 16 +process.options.numberOfStreams = 0 +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path).insert(0, process.generator) + +# customisation of the process. + +# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig +from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP + +#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig +process = higherPtTP(process) + +# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging +from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 + +#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging +process = customise_aging_1000(process) + +# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 +from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 + +#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 +process = customisePhase2TTOn110(process) + +# Automatic addition of the customisation function from L1Trigger.L1TMuonEndCapPhase2.config +from L1Trigger.L1TMuonEndCapPhase2.config import customise_mc + +#call to customisation function customise_mc imported from L1Trigger.L1TMuonEndCapPhase2.config +process = customise_mc(process) + +# Automatic addition of the customisation function from EMTFTools.NtupleMaker.config +from EMTFTools.NtupleMaker.config import customise_ntuple + +#call to customisation function customise_ntuple imported from EMTFTools.NtupleMaker.config +process = customise_ntuple(process) + +# End of customisation functions + + +# Customisation from command line +process.TFileService = cms.Service('TFileService', fileName = cms.string('test.root')) + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion From ccc3aab0ef7c9cf679b935a4fa725cc312ddf557 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Thu, 7 Dec 2023 22:00:17 +0100 Subject: [PATCH 05/24] Removed test psets from EMTFpp emulator --- L1Trigger/L1TMuonEndCapPhase2/test/debug.py | 182 ------------------ .../L1TMuonEndCapPhase2/test/debug_disp.py | 182 ------------------ .../L1TMuonEndCapPhase2/test/debug_llp.py | 181 ----------------- .../test/debug_llp_flatinvdmass_d88.py | 182 ------------------ 4 files changed, 727 deletions(-) delete mode 100644 L1Trigger/L1TMuonEndCapPhase2/test/debug.py delete mode 100644 L1Trigger/L1TMuonEndCapPhase2/test/debug_disp.py delete mode 100644 L1Trigger/L1TMuonEndCapPhase2/test/debug_llp.py delete mode 100644 L1Trigger/L1TMuonEndCapPhase2/test/debug_llp_flatinvdmass_d88.py diff --git a/L1Trigger/L1TMuonEndCapPhase2/test/debug.py b/L1Trigger/L1TMuonEndCapPhase2/test/debug.py deleted file mode 100644 index bea8f03f1559f..0000000000000 --- a/L1Trigger/L1TMuonEndCapPhase2/test/debug.py +++ /dev/null @@ -1,182 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 16 --conditions auto:phase2_realistic --era Phase2C9 --geometry Extended2026D49 --fileout file:SingleMuon_Endcap.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --python_filename pset_SingleMuon_PosEnd_2GeV.py --no_exec --mc -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Phase2C9_cff import Phase2C9 - -process = cms.Process('L1',Phase2C9) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D49_cff') -process.load('Configuration.StandardSequences.MagneticField_cff') -process.load('Configuration.StandardSequences.Generator_cff') -process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') -process.load('GeneratorInterface.Core.genFilterSummary_cff') -process.load('Configuration.StandardSequences.SimIdeal_cff') -process.load('Configuration.StandardSequences.Digi_cff') -process.load('Configuration.StandardSequences.L1TrackTrigger_cff') -process.load('Configuration.StandardSequences.SimL1Emulator_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(100), - output = cms.optional.untracked.allowed(cms.int32,cms.PSet) -) - -# Input source -process.source = cms.Source("EmptySource") - -process.options = cms.untracked.PSet( - FailPath = cms.untracked.vstring(), - IgnoreCompletely = cms.untracked.vstring(), - Rethrow = cms.untracked.vstring(), - SkipEvent = cms.untracked.vstring(), - accelerators = cms.untracked.vstring('*'), - allowUnscheduled = cms.obsolete.untracked.bool, - canDeleteEarly = cms.untracked.vstring(), - deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), - dumpOptions = cms.untracked.bool(False), - emptyRunLumiMode = cms.obsolete.untracked.string, - eventSetup = cms.untracked.PSet( - forceNumberOfConcurrentIOVs = cms.untracked.PSet( - allowAnyLabel_=cms.required.untracked.uint32 - ), - numberOfConcurrentIOVs = cms.untracked.uint32(0) - ), - fileMode = cms.untracked.string('FULLMERGE'), - forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), - makeTriggerResults = cms.obsolete.untracked.bool, - numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), - numberOfConcurrentRuns = cms.untracked.uint32(1), - numberOfStreams = cms.untracked.uint32(0), - numberOfThreads = cms.untracked.uint32(1), - printDependencies = cms.untracked.bool(False), - sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, - throwIfIllegalParameter = cms.untracked.bool(True), - wantSummary = cms.untracked.bool(False) -) - -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py nevts:1000'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Output definition - -process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", - SelectEvents = cms.untracked.PSet( - SelectEvents = cms.vstring('generation_step') - ), - dataset = cms.untracked.PSet( - dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), - filterName = cms.untracked.string('') - ), - fileName = cms.untracked.string('file:SingleMuon_Endcap.root'), - outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, - splitLevel = cms.untracked.int32(0) -) - -# Additional output definition - -# Other statements -process.genstepfilter.triggerConditions=cms.vstring("generation_step") -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') - -process.generator = cms.EDProducer("FlatRandomPtGunProducer2", - AddAntiParticle = cms.bool(False), - PGunParameters = cms.PSet( - MaxEta = cms.double(2.5), - MaxPhi = cms.double(3.141592653589793), - MaxPt = cms.double(120.0), - MaxDxy = cms.double(120.0), - MinEta = cms.double(1.2), - MinPhi = cms.double(-3.141592653589793), - MinPt = cms.double(2.0), - MinDxy = cms.double(0.0), - PartID = cms.vint32(-13), - PtSpectrum = cms.string('flatOneOverPt'), - VertexSpectrum = cms.string('none'), - RandomCharge = cms.bool(True) - ), - Verbosity = cms.untracked.int32(0), - firstRun = cms.untracked.uint32(1), - psethack = cms.string('single muon+/- pt 2 to 120 flat in 1/pt positive endcap') -) - -# Path and EndPath definitions -process.generation_step = cms.Path(process.pgen) -process.simulation_step = cms.Path(process.psim) -process.digitisation_step = cms.Path(process.pdigi) -process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) -process.L1simulation_step = cms.Path(process.SimL1Emulator) -process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) -process.endjob_step = cms.EndPath(process.endOfProcess) -process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) - -# Schedule definition -process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -#Setup FWK for multithreaded -process.options.numberOfThreads = 1 -process.options.numberOfStreams = 0 -# filter all path with the production filter sequence -for path in process.paths: - getattr(process,path).insert(0, process.generator) - -# customisation of the process. - -# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig -from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP - -#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig -process = higherPtTP(process) - -# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging -from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 - -#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging -process = customise_aging_1000(process) - -# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 -from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 - -#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 -process = customisePhase2TTOn110(process) - -# Automatic addition of the customisation function from L1Trigger.L1TMuonEndCapPhase2.config -from L1Trigger.L1TMuonEndCapPhase2.config import customise_debug - -#call to customisation function customise_mc imported from L1Trigger.L1TMuonEndCapPhase2.config -process = customise_debug(process) - -# Automatic addition of the customisation function from EMTFTools.NtupleMaker.config -from EMTFTools.NtupleMaker.config import customise_ntuple - -#call to customisation function customise_ntuple imported from EMTFTools.NtupleMaker.config -process = customise_ntuple(process) - -# End of customisation functions - - -# Customisation from command line -process.TFileService = cms.Service('TFileService', fileName = cms.string('test.root')) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion diff --git a/L1Trigger/L1TMuonEndCapPhase2/test/debug_disp.py b/L1Trigger/L1TMuonEndCapPhase2/test/debug_disp.py deleted file mode 100644 index 826ac4b3a0481..0000000000000 --- a/L1Trigger/L1TMuonEndCapPhase2/test/debug_disp.py +++ /dev/null @@ -1,182 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 16 --conditions auto:phase2_realistic --era Phase2C9 --geometry Extended2026D49 --fileout file:SingleMuon_Endcap.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --python_filename pset_SingleMuon_PosEnd_2GeV.py --no_exec --mc -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Phase2C9_cff import Phase2C9 - -process = cms.Process('L1',Phase2C9) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D49_cff') -process.load('Configuration.StandardSequences.MagneticField_cff') -process.load('Configuration.StandardSequences.Generator_cff') -process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') -process.load('GeneratorInterface.Core.genFilterSummary_cff') -process.load('Configuration.StandardSequences.SimIdeal_cff') -process.load('Configuration.StandardSequences.Digi_cff') -process.load('Configuration.StandardSequences.L1TrackTrigger_cff') -process.load('Configuration.StandardSequences.SimL1Emulator_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(100), - output = cms.optional.untracked.allowed(cms.int32,cms.PSet) -) - -# Input source -process.source = cms.Source("EmptySource") - -process.options = cms.untracked.PSet( - FailPath = cms.untracked.vstring(), - IgnoreCompletely = cms.untracked.vstring(), - Rethrow = cms.untracked.vstring(), - SkipEvent = cms.untracked.vstring(), - accelerators = cms.untracked.vstring('*'), - allowUnscheduled = cms.obsolete.untracked.bool, - canDeleteEarly = cms.untracked.vstring(), - deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), - dumpOptions = cms.untracked.bool(False), - emptyRunLumiMode = cms.obsolete.untracked.string, - eventSetup = cms.untracked.PSet( - forceNumberOfConcurrentIOVs = cms.untracked.PSet( - allowAnyLabel_=cms.required.untracked.uint32 - ), - numberOfConcurrentIOVs = cms.untracked.uint32(0) - ), - fileMode = cms.untracked.string('FULLMERGE'), - forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), - makeTriggerResults = cms.obsolete.untracked.bool, - numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), - numberOfConcurrentRuns = cms.untracked.uint32(1), - numberOfStreams = cms.untracked.uint32(0), - numberOfThreads = cms.untracked.uint32(1), - printDependencies = cms.untracked.bool(False), - sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, - throwIfIllegalParameter = cms.untracked.bool(True), - wantSummary = cms.untracked.bool(False) -) - -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py nevts:1000'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Output definition - -process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", - SelectEvents = cms.untracked.PSet( - SelectEvents = cms.vstring('generation_step') - ), - dataset = cms.untracked.PSet( - dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), - filterName = cms.untracked.string('') - ), - fileName = cms.untracked.string('file:SingleMuon_Endcap.root'), - outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, - splitLevel = cms.untracked.int32(0) -) - -# Additional output definition - -# Other statements -process.genstepfilter.triggerConditions=cms.vstring("generation_step") -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') - -process.generator = cms.EDProducer("FlatRandomPtGunProducer2", - AddAntiParticle = cms.bool(False), - PGunParameters = cms.PSet( - MaxEta = cms.double(2.5), - MaxPhi = cms.double(3.141592653589793), - MaxPt = cms.double(120.0), - MaxDxy = cms.double(120.0), - MinEta = cms.double(1.2), - MinPhi = cms.double(-3.141592653589793), - MinPt = cms.double(2.0), - MinDxy = cms.double(0.0), - PartID = cms.vint32(-13), - PtSpectrum = cms.string('flatOneOverPt'), - VertexSpectrum = cms.string('flatD0'), - RandomCharge = cms.bool(True) - ), - Verbosity = cms.untracked.int32(0), - firstRun = cms.untracked.uint32(1), - psethack = cms.string('single muon+/- pt 2 to 120 flat in 1/pt positive endcap') -) - -# Path and EndPath definitions -process.generation_step = cms.Path(process.pgen) -process.simulation_step = cms.Path(process.psim) -process.digitisation_step = cms.Path(process.pdigi) -process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) -process.L1simulation_step = cms.Path(process.SimL1Emulator) -process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) -process.endjob_step = cms.EndPath(process.endOfProcess) -process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) - -# Schedule definition -process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -#Setup FWK for multithreaded -process.options.numberOfThreads = 1 -process.options.numberOfStreams = 0 -# filter all path with the production filter sequence -for path in process.paths: - getattr(process,path).insert(0, process.generator) - -# customisation of the process. - -# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig -from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP - -#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig -process = higherPtTP(process) - -# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging -from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 - -#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging -process = customise_aging_1000(process) - -# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 -from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 - -#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 -process = customisePhase2TTOn110(process) - -# Automatic addition of the customisation function from L1Trigger.L1TMuonEndCapPhase2.config -from L1Trigger.L1TMuonEndCapPhase2.config import customise_debug - -#call to customisation function customise_mc imported from L1Trigger.L1TMuonEndCapPhase2.config -process = customise_debug(process) - -# Automatic addition of the customisation function from EMTFTools.NtupleMaker.config -from EMTFTools.NtupleMaker.config import customise_ntuple - -#call to customisation function customise_ntuple imported from EMTFTools.NtupleMaker.config -process = customise_ntuple(process) - -# End of customisation functions - - -# Customisation from command line -process.TFileService = cms.Service('TFileService', fileName = cms.string('test.root')) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion diff --git a/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp.py b/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp.py deleted file mode 100644 index 135a05da72bf3..0000000000000 --- a/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp.py +++ /dev/null @@ -1,181 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 16 --conditions auto:phase2_realistic --era Phase2C9 --geometry Extended2026D49 --fileout file:SingleMuon_Endcap.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --python_filename pset_SingleMuon_PosEnd_2GeV.py --no_exec --mc -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Phase2C9_cff import Phase2C9 - -process = cms.Process('L1',Phase2C9) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D49_cff') -process.load('Configuration.StandardSequences.MagneticField_cff') -process.load('Configuration.StandardSequences.Generator_cff') -process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') -process.load('GeneratorInterface.Core.genFilterSummary_cff') -process.load('Configuration.StandardSequences.SimIdeal_cff') -process.load('Configuration.StandardSequences.Digi_cff') -process.load('Configuration.StandardSequences.L1TrackTrigger_cff') -process.load('Configuration.StandardSequences.SimL1Emulator_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1000), - output = cms.optional.untracked.allowed(cms.int32,cms.PSet) -) - -# Input source -process.source = cms.Source("EmptySource") - -process.options = cms.untracked.PSet( - FailPath = cms.untracked.vstring(), - IgnoreCompletely = cms.untracked.vstring(), - Rethrow = cms.untracked.vstring(), - SkipEvent = cms.untracked.vstring(), - accelerators = cms.untracked.vstring('*'), - allowUnscheduled = cms.obsolete.untracked.bool, - canDeleteEarly = cms.untracked.vstring(), - deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), - dumpOptions = cms.untracked.bool(False), - emptyRunLumiMode = cms.obsolete.untracked.string, - eventSetup = cms.untracked.PSet( - forceNumberOfConcurrentIOVs = cms.untracked.PSet( - allowAnyLabel_=cms.required.untracked.uint32 - ), - numberOfConcurrentIOVs = cms.untracked.uint32(0) - ), - fileMode = cms.untracked.string('FULLMERGE'), - forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), - makeTriggerResults = cms.obsolete.untracked.bool, - numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), - numberOfConcurrentRuns = cms.untracked.uint32(1), - numberOfStreams = cms.untracked.uint32(0), - numberOfThreads = cms.untracked.uint32(1), - printDependencies = cms.untracked.bool(False), - sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, - throwIfIllegalParameter = cms.untracked.bool(True), - wantSummary = cms.untracked.bool(False) -) - -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py nevts:1000'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Output definition - -process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", - SelectEvents = cms.untracked.PSet( - SelectEvents = cms.vstring('generation_step') - ), - dataset = cms.untracked.PSet( - dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), - filterName = cms.untracked.string('') - ), - fileName = cms.untracked.string('file:SingleMuon_Endcap.root'), - outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, - splitLevel = cms.untracked.int32(0) -) - -# Additional output definition - -# Other statements -process.genstepfilter.triggerConditions=cms.vstring("generation_step") -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') - -process.generator = cms.EDProducer("FlatRandomLLPGunProducer2", - AddAntiParticle = cms.bool(False), - PGunParameters = cms.PSet( - MaxMassH = cms.double(1000), - MinMassH = cms.double(20), - MaxPtH = cms.double(120), - MinPtH = cms.double(1), - MaxCTauLLP = cms.double(5000), - MinCTauLLP = cms.double(10), - MaxEta = cms.double(3.5), - MinEta = cms.double(1e-6), - MaxPhi = cms.double(3.141592653589793), - MinPhi = cms.double(-3.141592653589793), - PartID = cms.vint32(-13), - ), - Verbosity = cms.untracked.int32(0), - firstRun = cms.untracked.uint32(1), - psethack = cms.string('LLP decay positive endcap') -) - -# Path and EndPath definitions -process.generation_step = cms.Path(process.pgen) -process.simulation_step = cms.Path(process.psim) -process.digitisation_step = cms.Path(process.pdigi) -process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) -process.L1simulation_step = cms.Path(process.SimL1Emulator) -process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) -process.endjob_step = cms.EndPath(process.endOfProcess) -process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) - -# Schedule definition -process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -#Setup FWK for multithreaded -process.options.numberOfThreads = 16 -process.options.numberOfStreams = 0 -# filter all path with the production filter sequence -for path in process.paths: - getattr(process,path).insert(0, process.generator) - -# customisation of the process. - -# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig -from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP - -#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig -process = higherPtTP(process) - -# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging -from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 - -#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging -process = customise_aging_1000(process) - -# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 -from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 - -#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 -process = customisePhase2TTOn110(process) - -# Automatic addition of the customisation function from L1Trigger.L1TMuonEndCapPhase2.config -from L1Trigger.L1TMuonEndCapPhase2.config import customise_mc - -#call to customisation function customise_mc imported from L1Trigger.L1TMuonEndCapPhase2.config -process = customise_mc(process) - -# Automatic addition of the customisation function from EMTFTools.NtupleMaker.config -from EMTFTools.NtupleMaker.config import customise_ntuple - -#call to customisation function customise_ntuple imported from EMTFTools.NtupleMaker.config -process = customise_ntuple(process) - -# End of customisation functions - - -# Customisation from command line -process.TFileService = cms.Service('TFileService', fileName = cms.string('test.root')) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion diff --git a/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp_flatinvdmass_d88.py b/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp_flatinvdmass_d88.py deleted file mode 100644 index 695b9c23e1248..0000000000000 --- a/L1Trigger/L1TMuonEndCapPhase2/test/debug_llp_flatinvdmass_d88.py +++ /dev/null @@ -1,182 +0,0 @@ -# Auto generated configuration file -# using: -# Revision: 1.19 -# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v -# with command line options: EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py -n 1000 -s GEN,SIM,DIGI,L1TrackTrigger,L1 --nThreads 16 --conditions auto:phase2_realistic --era Phase2C9 --geometry Extended2026D49 --fileout file:SingleMuon_Endcap.root --eventcontent FEVTDEBUGHLT --pileup NoPileUp --beamspot HLLHC14TeV --datatier GEN-SIM-DIGI-RAW --customise SimGeneral/MixingModule/customiseStoredTPConfig.higherPtTP,SLHCUpgradeSimulations/Configuration/aging.customise_aging_1000,L1Trigger/Configuration/customisePhase2TTOn110.customisePhase2TTOn110,L1Trigger/L1TMuonEndCapPhase2/config.customise_mc,EMTFTools/NtupleMaker/config.customise_ntuple --python_filename pset_SingleMuon_PosEnd_2GeV.py --no_exec --mc -import FWCore.ParameterSet.Config as cms - -from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9 - -process = cms.Process('L1',Phase2C17I13M9) - -# import of standard configurations -process.load('Configuration.StandardSequences.Services_cff') -process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') -process.load('FWCore.MessageService.MessageLogger_cfi') -process.load('Configuration.EventContent.EventContent_cff') -process.load('SimGeneral.MixingModule.mixNoPU_cfi') -process.load('Configuration.Geometry.GeometryExtended2026D88Reco_cff') -process.load('Configuration.Geometry.GeometryExtended2026D88_cff') -process.load('Configuration.StandardSequences.MagneticField_cff') -process.load('Configuration.StandardSequences.Generator_cff') -process.load('IOMC.EventVertexGenerators.VtxSmearedHLLHC14TeV_cfi') -process.load('GeneratorInterface.Core.genFilterSummary_cff') -process.load('Configuration.StandardSequences.SimIdeal_cff') -process.load('Configuration.StandardSequences.Digi_cff') -process.load('Configuration.StandardSequences.L1TrackTrigger_cff') -process.load('Configuration.StandardSequences.SimL1Emulator_cff') -process.load('Configuration.StandardSequences.EndOfProcess_cff') -process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') - -process.maxEvents = cms.untracked.PSet( - input = cms.untracked.int32(1000), - output = cms.optional.untracked.allowed(cms.int32,cms.PSet) -) - -# Input source -process.source = cms.Source("EmptySource") - -process.options = cms.untracked.PSet( - FailPath = cms.untracked.vstring(), - IgnoreCompletely = cms.untracked.vstring(), - Rethrow = cms.untracked.vstring(), - SkipEvent = cms.untracked.vstring(), - accelerators = cms.untracked.vstring('*'), - allowUnscheduled = cms.obsolete.untracked.bool, - canDeleteEarly = cms.untracked.vstring(), - deleteNonConsumedUnscheduledModules = cms.untracked.bool(True), - dumpOptions = cms.untracked.bool(False), - emptyRunLumiMode = cms.obsolete.untracked.string, - eventSetup = cms.untracked.PSet( - forceNumberOfConcurrentIOVs = cms.untracked.PSet( - allowAnyLabel_=cms.required.untracked.uint32 - ), - numberOfConcurrentIOVs = cms.untracked.uint32(0) - ), - fileMode = cms.untracked.string('FULLMERGE'), - forceEventSetupCacheClearOnNewRun = cms.untracked.bool(False), - makeTriggerResults = cms.obsolete.untracked.bool, - numberOfConcurrentLuminosityBlocks = cms.untracked.uint32(0), - numberOfConcurrentRuns = cms.untracked.uint32(1), - numberOfStreams = cms.untracked.uint32(0), - numberOfThreads = cms.untracked.uint32(1), - printDependencies = cms.untracked.bool(False), - sizeOfStackForThreadsInKB = cms.optional.untracked.uint32, - throwIfIllegalParameter = cms.untracked.bool(True), - wantSummary = cms.untracked.bool(False) -) - -# Production Info -process.configurationMetadata = cms.untracked.PSet( - annotation = cms.untracked.string('EMTFTools/ParticleGuns/python/SingleMuon_PosEnd_2GeV_cfi.py nevts:1000'), - name = cms.untracked.string('Applications'), - version = cms.untracked.string('$Revision: 1.19 $') -) - -# Output definition - -process.FEVTDEBUGHLToutput = cms.OutputModule("PoolOutputModule", - SelectEvents = cms.untracked.PSet( - SelectEvents = cms.vstring('generation_step') - ), - dataset = cms.untracked.PSet( - dataTier = cms.untracked.string('GEN-SIM-DIGI-RAW'), - filterName = cms.untracked.string('') - ), - fileName = cms.untracked.string('file:SingleMuon_Endcap.root'), - outputCommands = process.FEVTDEBUGHLTEventContent.outputCommands, - splitLevel = cms.untracked.int32(0) -) - -# Additional output definition - -# Other statements -process.genstepfilter.triggerConditions=cms.vstring("generation_step") -from Configuration.AlCa.GlobalTag import GlobalTag -process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '') - -process.generator = cms.EDProducer("FlatRandomLLPGunProducer2", - AddAntiParticle = cms.bool(False), - PGunParameters = cms.PSet( - MaxMassH = cms.double(1000), - MinMassH = cms.double(20), - MaxPtH = cms.double(120), - MinPtH = cms.double(1), - MaxCTauLLP = cms.double(5000), - MinCTauLLP = cms.double(10), - MaxEta = cms.double(3.5), - MinEta = cms.double(1e-6), - MaxPhi = cms.double(3.141592653589793), - MinPhi = cms.double(-3.141592653589793), - LLPMassSpectrum = cms.string('flatInvDMass'), - PartID = cms.vint32(-13), - ), - Verbosity = cms.untracked.int32(0), - firstRun = cms.untracked.uint32(1), - psethack = cms.string('LLP decay positive endcap') -) - -# Path and EndPath definitions -process.generation_step = cms.Path(process.pgen) -process.simulation_step = cms.Path(process.psim) -process.digitisation_step = cms.Path(process.pdigi) -process.L1TrackTrigger_step = cms.Path(process.L1TrackTrigger) -process.L1simulation_step = cms.Path(process.SimL1Emulator) -process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) -process.endjob_step = cms.EndPath(process.endOfProcess) -process.FEVTDEBUGHLToutput_step = cms.EndPath(process.FEVTDEBUGHLToutput) - -# Schedule definition -process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.L1TrackTrigger_step,process.L1simulation_step,process.endjob_step,process.FEVTDEBUGHLToutput_step) -from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask -associatePatAlgosToolsTask(process) - -#Setup FWK for multithreaded -process.options.numberOfThreads = 16 -process.options.numberOfStreams = 0 -# filter all path with the production filter sequence -for path in process.paths: - getattr(process,path).insert(0, process.generator) - -# customisation of the process. - -# Automatic addition of the customisation function from SimGeneral.MixingModule.customiseStoredTPConfig -from SimGeneral.MixingModule.customiseStoredTPConfig import higherPtTP - -#call to customisation function higherPtTP imported from SimGeneral.MixingModule.customiseStoredTPConfig -process = higherPtTP(process) - -# Automatic addition of the customisation function from SLHCUpgradeSimulations.Configuration.aging -from SLHCUpgradeSimulations.Configuration.aging import customise_aging_1000 - -#call to customisation function customise_aging_1000 imported from SLHCUpgradeSimulations.Configuration.aging -process = customise_aging_1000(process) - -# Automatic addition of the customisation function from L1Trigger.Configuration.customisePhase2TTOn110 -from L1Trigger.Configuration.customisePhase2TTOn110 import customisePhase2TTOn110 - -#call to customisation function customisePhase2TTOn110 imported from L1Trigger.Configuration.customisePhase2TTOn110 -process = customisePhase2TTOn110(process) - -# Automatic addition of the customisation function from L1Trigger.L1TMuonEndCapPhase2.config -from L1Trigger.L1TMuonEndCapPhase2.config import customise_mc - -#call to customisation function customise_mc imported from L1Trigger.L1TMuonEndCapPhase2.config -process = customise_mc(process) - -# Automatic addition of the customisation function from EMTFTools.NtupleMaker.config -from EMTFTools.NtupleMaker.config import customise_ntuple - -#call to customisation function customise_ntuple imported from EMTFTools.NtupleMaker.config -process = customise_ntuple(process) - -# End of customisation functions - - -# Customisation from command line -process.TFileService = cms.Service('TFileService', fileName = cms.string('test.root')) - -# Add early deletion of temporary data products to reduce peak memory need -from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete -process = customiseEarlyDelete(process) -# End adding early deletion From f61cb51e014772363b8fc9bdd96ce6d69a07addf Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Thu, 14 Dec 2023 18:41:34 +0100 Subject: [PATCH 06/24] Removed EMTFLogger, updated theta luts, and activation luts --- .../interface/EMTFLogger.h | 36 ---- .../src/Algo/TrackBuildingLayer.cc | 12 +- .../src/Data/ActivationLut.cc | 204 +++++++++--------- 3 files changed, 108 insertions(+), 144 deletions(-) delete mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/EMTFLogger.h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFLogger.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFLogger.h deleted file mode 100644 index eafe059c160b8..0000000000000 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFLogger.h +++ /dev/null @@ -1,36 +0,0 @@ - -#ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFLoggger -#define L1Trigger_L1TMuonEndCapPhase2_EMTFLoggger - -#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" -#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" - -namespace emtf::phase2 { - - class EMTFLoggger { - public: - EMTFLoggger(const EMTFContext&); - - ~EMTFLoggger(); - - // Sections - void print_section_header(const std:string&); - - void print_section_footer(const std:string&); - - void print_subsection_header(const std:string&); - - void print_subsection_footer(const std:string&); - - // Data - void print_segment(const int& lvl, const segment_t&); - void print_track(const int& lvl, const track_t&); - void print_track_features(const int& lvl, const track_t::features_t&); - - private: - const EMTFContext& context_; - - }; -} - -#endif // L1Trigger_L1TMuonEndCapPhase2_EMTFLoggger diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc index 909fb1bc127c9..d8b8a8bf742bf 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc @@ -446,16 +446,16 @@ void TrackBuildingLayer::attach_segments( // if theta_window < diff, it is invalid std::vector> site_theta_window = { - { 4, 0, 4, 4, 4, 0, 0, 6, 6, 6, 4, 7}, - { 5, 10, 5, 4, 4, 14, 7, 7, 7, 7, 6, 4}, - {11, 6, 5, 6, 6, 11, 8, 8, 9, 10, 8, 0} + {5, 0, 2, 2, 2, 34, 0, 3, 3, 5, 6, 5}, + {5, 9, 5, 4, 5, 14, 7, 7, 7, 7, 7, 4}, + {11, 6, 5, 6, 6, 10, 8, 8, 9, 8, 0, 0} }; if (displaced_en) { site_theta_window = { - {14, 32, 5, 5, 5, 34, 0, 8, 6, 15, 7, 13}, - {16, 20, 7, 6, 6, 25, 17, 8, 9, 17, 8, 14}, - {27, 14, 8, 10, 10, 18, 11, 10, 11, 26, 20, 0} + {14, 40, 4, 3, 3, 45, 0, 4, 4, 15, 8, 13}, + {16, 18, 7, 5, 5, 22, 7, 7, 8, 17, 9, 14}, + {26, 15, 8, 9, 9, 17, 11, 9, 10, 26, 21, 0} }; } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc index 4ec2c8fb5f8c9..a9efed9fc12bc 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc @@ -8,104 +8,104 @@ using namespace emtf::phase2::data; ActivationLut::ActivationLut() { prompt_pt_lut_ = {{ - 0, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8075, 7942, 7818, 7693, 7569, - 7453, 7337, 7220, 7108, 6996, 6889, 6785, 6681, 6582, 6482, 6383, 6287, 6192, 6101, 6010, 5923, 5835, 5748, 5665, - 5582, 5500, 5421, 5342, 5263, 5189, 5110, 5039, 4965, 4894, 4824, 4757, 4687, 4620, 4554, 4488, 4426, 4363, 4301, - 4239, 4181, 4123, 4061, 4007, 3949, 3891, 3837, 3783, 3729, 3675, 3625, 3576, 3522, 3472, 3422, 3376, 3327, 3281, - 3231, 3186, 3140, 3095, 3053, 3007, 2966, 2920, 2879, 2837, 2796, 2754, 2717, 2676, 2638, 2597, 2560, 2522, 2485, - 2448, 2410, 2377, 2340, 2303, 2269, 2236, 2199, 2166, 2134, 2102, 2070, 2043, 2011, 1981, 1954, 1924, 1897, 1871, - 1842, 1816, 1791, 1766, 1741, 1717, 1696, 1671, 1647, 1627, 1604, 1583, 1560, 1541, 1521, 1502, 1479, 1460, 1441, - 1422, 1404, 1388, 1370, 1352, 1334, 1319, 1301, 1283, 1269, 1254, 1237, 1223, 1209, 1192, 1178, 1164, 1150, 1136, - 1123, 1109, 1096, 1082, 1069, 1056, 1046, 1033, 1020, 1007, 997, 984, 974, 962, 952, 939, 930, 920, 908, 898, 889, - 879, 867, 858, 848, 839, 830, 821, 812, 803, 794, 785, 776, 769, 760, 751, 743, 736, 727, 719, 712, 704, 695, 689, - 681, 674, 666, 660, 652, 646, 639, 631, 625, 619, 611, 605, 599, 593, 586, 580, 574, 568, 562, 557, 551, 545, 539, - 534, 528, 523, 517, 511, 506, 500, 495, 489, 484, 480, 475, 470, 464, 461, 455, 450, 446, 441, 436, 432, 427, 422, - 419, 413, 410, 405, 402, 396, 393, 388, 385, 380, 376, 371, 368, 365, 360, 357, 353, 348, 345, 342, 337, 334, 331, - 328, 323, 320, 316, 313, 309, 305, 302, 299, 296, 293, 290, 287, 282, 279, 276, 273, 270, 267, 264, 261, 258, 255, - 252, 249, 246, 243, 240, 237, 236, 233, 230, 227, 224, 221, 218, 217, 214, 211, 208, 205, 202, 201, 198, 195, 193, - 191, 188, 185, 183, 181, 178, 176, 174, 172, 169, 167, 165, 162, 160, 158, 155, 154, 151, 150, 147, 145, 143, 140, - 139, 136, 135, 132, 131, 128, 127, 124, 123, 120, 119, 116, 115, 112, 111, 108, 107, 104, 103, 102, 99, 98, 95, 94, - 93, 90, 89, 87, 85, 84, 81, 80, 79, 76, 75, 73, 71, 70, 68, 67, 65, 63, 62, 60, 58, 57, 56, 53, 52, 51, 50, 47, 46, - 45, 43, 42, 40, 39, 37, 36, 35, 32, 31, 30, 29, 28, 26, 24, 23, 21, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 21, 23, 24, 26, 28, 29, 30, - 31, 32, 35, 36, 37, 39, 40, 42, 43, 45, 46, 47, 50, 51, 52, 53, 56, 57, 58, 60, 62, 63, 65, 67, 68, 70, 71, 73, 75, - 76, 79, 80, 81, 84, 85, 87, 89, 90, 93, 94, 95, 98, 99, 102, 103, 104, 107, 108, 111, 112, 115, 116, 119, 120, 123, - 124, 127, 128, 131, 132, 135, 136, 139, 140, 143, 145, 147, 150, 151, 154, 155, 158, 160, 162, 165, 167, 169, 172, - 174, 176, 178, 181, 183, 185, 188, 191, 193, 195, 198, 201, 202, 205, 208, 211, 214, 217, 218, 221, 224, 227, 230, - 233, 236, 237, 240, 243, 246, 249, 252, 255, 258, 261, 264, 267, 270, 273, 276, 279, 282, 287, 290, 293, 296, 299, - 302, 305, 309, 313, 316, 320, 323, 328, 331, 334, 337, 342, 345, 348, 353, 357, 360, 365, 368, 371, 376, 380, 385, - 388, 393, 396, 402, 405, 410, 413, 419, 422, 427, 432, 436, 441, 446, 450, 455, 461, 464, 470, 475, 480, 484, 489, - 495, 500, 506, 511, 517, 523, 528, 534, 539, 545, 551, 557, 562, 568, 574, 580, 586, 593, 599, 605, 611, 619, 625, - 631, 639, 646, 652, 660, 666, 674, 681, 689, 695, 704, 712, 719, 727, 736, 743, 751, 760, 769, 776, 785, 794, 803, - 812, 821, 830, 839, 848, 858, 867, 879, 889, 898, 908, 920, 930, 939, 952, 962, 974, 984, 997, 1007, 1020, 1033, - 1046, 1056, 1069, 1082, 1096, 1109, 1123, 1136, 1150, 1164, 1178, 1192, 1209, 1223, 1237, 1254, 1269, 1283, 1301, - 1319, 1334, 1352, 1370, 1388, 1404, 1422, 1441, 1460, 1479, 1502, 1521, 1541, 1560, 1583, 1604, 1627, 1647, 1671, - 1696, 1717, 1741, 1766, 1791, 1816, 1842, 1871, 1897, 1924, 1954, 1981, 2011, 2043, 2070, 2102, 2134, 2166, 2199, - 2236, 2269, 2303, 2340, 2377, 2410, 2448, 2485, 2522, 2560, 2597, 2638, 2676, 2717, 2754, 2796, 2837, 2879, 2920, - 2966, 3007, 3053, 3095, 3140, 3186, 3231, 3281, 3327, 3376, 3422, 3472, 3522, 3576, 3625, 3675, 3729, 3783, 3837, - 3891, 3949, 4007, 4061, 4123, 4181, 4239, 4301, 4363, 4426, 4488, 4554, 4620, 4687, 4757, 4824, 4894, 4965, 5039, - 5110, 5189, 5263, 5342, 5421, 5500, 5582, 5665, 5748, 5835, 5923, 6010, 6101, 6192, 6287, 6383, 6482, 6582, 6681, - 6785, 6889, 6996, 7108, 7220, 7337, 7453, 7569, 7693, 7818, 7942, 8075, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8116, 7991, 7867, 7743, 7623, 7503, 7387, 7276, 7165, 7058, 6952, 6845, 6743, 6640, 6543, 6445, 6352, 6258, 6165, + 6076, 5987, 5898, 5814, 5730, 5645, 5565, 5481, 5405, 5325, 5250, 5174, 5103, 5027, 4956, 4885, 4814, 4747, 4681, + 4614, 4547, 4485, 4423, 4356, 4299, 4236, 4174, 4116, 4059, 4001, 3943, 3890, 3836, 3779, 3725, 3672, 3623, 3570, + 3521, 3468, 3419, 3370, 3321, 3277, 3228, 3183, 3134, 3090, 3045, 3001, 2957, 2917, 2872, 2832, 2788, 2748, 2708, + 2668, 2628, 2588, 2552, 2512, 2472, 2437, 2401, 2361, 2326, 2291, 2257, 2223, 2193, 2160, 2127, 2098, 2065, 2037, + 2009, 1977, 1950, 1923, 1896, 1869, 1842, 1820, 1794, 1768, 1746, 1720, 1698, 1673, 1652, 1631, 1610, 1586, 1565, + 1544, 1524, 1504, 1487, 1467, 1448, 1428, 1412, 1392, 1373, 1358, 1342, 1323, 1308, 1292, 1274, 1259, 1244, 1229, + 1214, 1199, 1184, 1170, 1155, 1141, 1127, 1115, 1101, 1087, 1073, 1062, 1049, 1038, 1024, 1013, 1000, 989, 979, 966, + 955, 945, 935, 922, 912, 901, 891, 881, 871, 862, 852, 842, 832, 823, 815, 806, 796, 787, 780, 770, 761, 754, 745, + 736, 729, 720, 713, 704, 698, 689, 682, 676, 667, 660, 654, 645, 639, 633, 626, 618, 611, 605, 599, 593, 587, 581, + 574, 568, 562, 556, 550, 544, 538, 532, 527, 521, 515, 509, 505, 499, 494, 488, 484, 479, 473, 469, 464, 458, 454, + 449, 443, 440, 434, 431, 425, 422, 416, 413, 408, 404, 399, 395, 390, 387, 383, 378, 374, 371, 366, 363, 359, 354, + 351, 347, 344, 339, 336, 333, 329, 324, 321, 318, 315, 311, 308, 305, 302, 297, 294, 291, 288, 284, 281, 278, 275, + 272, 269, 266, 263, 260, 257, 254, 251, 249, 246, 243, 240, 237, 234, 231, 230, 227, 224, 221, 218, 215, 214, 211, + 208, 205, 204, 201, 198, 195, 194, 191, 188, 187, 184, 181, 180, 177, 174, 173, 170, 168, 166, 163, 162, 159, 158, + 155, 153, 151, 149, 147, 145, 143, 141, 139, 137, 135, 133, 132, 129, 128, 125, 124, 121, 120, 117, 116, 115, 112, + 111, 108, 107, 106, 103, 102, 101, 98, 97, 95, 93, 92, 90, 89, 87, 85, 84, 82, 81, 79, 78, 76, 74, 73, 72, 70, 68, + 67, 66, 64, 62, 61, 60, 58, 57, 55, 54, 53, 51, 50, 48, 47, 46, 44, 43, 42, 40, 39, 38, 36, 35, 34, 33, 32, 30, 29, + 27, 26, 25, 24, 23, 22, 21, 20, 19, 16, 15, 14, 13, 12, 11, 10, 9, 8, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 43, 44, + 46, 47, 48, 50, 51, 53, 54, 55, 57, 58, 60, 61, 62, 64, 66, 67, 68, 70, 72, 73, 74, 76, 78, 79, 81, 82, 84, 85, 87, + 89, 90, 92, 93, 95, 97, 98, 101, 102, 103, 106, 107, 108, 111, 112, 115, 116, 117, 120, 121, 124, 125, 128, 129, + 132, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 158, 159, 162, 163, 166, 168, 170, 173, 174, 177, + 180, 181, 184, 187, 188, 191, 194, 195, 198, 201, 204, 205, 208, 211, 214, 215, 218, 221, 224, 227, 230, 231, 234, + 237, 240, 243, 246, 249, 251, 254, 257, 260, 263, 266, 269, 272, 275, 278, 281, 284, 288, 291, 294, 297, 302, 305, + 308, 311, 315, 318, 321, 324, 329, 333, 336, 339, 344, 347, 351, 354, 359, 363, 366, 371, 374, 378, 383, 387, 390, + 395, 399, 404, 408, 413, 416, 422, 425, 431, 434, 440, 443, 449, 454, 458, 464, 469, 473, 479, 484, 488, 494, 499, + 505, 509, 515, 521, 527, 532, 538, 544, 550, 556, 562, 568, 574, 581, 587, 593, 599, 605, 611, 618, 626, 633, 639, + 645, 654, 660, 667, 676, 682, 689, 698, 704, 713, 720, 729, 736, 745, 754, 761, 770, 780, 787, 796, 806, 815, 823, + 832, 842, 852, 862, 871, 881, 891, 901, 912, 922, 935, 945, 955, 966, 979, 989, 1000, 1013, 1024, 1038, 1049, 1062, + 1073, 1087, 1101, 1115, 1127, 1141, 1155, 1170, 1184, 1199, 1214, 1229, 1244, 1259, 1274, 1292, 1308, 1323, 1342, + 1358, 1373, 1392, 1412, 1428, 1448, 1467, 1487, 1504, 1524, 1544, 1565, 1586, 1610, 1631, 1652, 1673, 1698, 1720, + 1746, 1768, 1794, 1820, 1842, 1869, 1896, 1923, 1950, 1977, 2009, 2037, 2065, 2098, 2127, 2160, 2193, 2223, 2257, + 2291, 2326, 2361, 2401, 2437, 2472, 2512, 2552, 2588, 2628, 2668, 2708, 2748, 2788, 2832, 2872, 2917, 2957, 3001, + 3045, 3090, 3134, 3183, 3228, 3277, 3321, 3370, 3419, 3468, 3521, 3570, 3623, 3672, 3725, 3779, 3836, 3890, 3943, + 4001, 4059, 4116, 4174, 4236, 4299, 4356, 4423, 4485, 4547, 4614, 4681, 4747, 4814, 4885, 4956, 5027, 5103, 5174, + 5250, 5325, 5405, 5481, 5565, 5645, 5730, 5814, 5898, 5987, 6076, 6165, 6258, 6352, 6445, 6543, 6640, 6743, 6845, + 6952, 7058, 7165, 7276, 7387, 7503, 7623, 7743, 7867, 7991, 8116, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191 + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191 }}; disp_pt_lut_ = {{ - 0, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 7956, 7730, - 7515, 7311, 7116, 6932, 6754, 6587, 6425, 6272, 6125, 5983, 5848, 5718, 5593, 5473, 5358, 5247, 5139, 5036, 4936, - 4840, 4747, 4657, 4569, 4485, 4404, 4325, 4249, 4174, 4103, 4032, 3964, 3899, 3834, 3772, 3712, 3652, 3595, 3539, - 3484, 3432, 3380, 3330, 3280, 3233, 3186, 3141, 3096, 3052, 3010, 2968, 2927, 2888, 2849, 2810, 2774, 2737, 2701, - 2667, 2633, 2599, 2566, 2533, 2502, 2471, 2441, 2412, 2383, 2354, 2326, 2298, 2271, 2244, 2219, 2193, 2168, 2143, - 2119, 2095, 2072, 2049, 2026, 2004, 1981, 1960, 1938, 1917, 1897, 1877, 1857, 1837, 1818, 1798, 1780, 1762, 1744, - 1726, 1709, 1692, 1673, 1658, 1641, 1624, 1608, 1592, 1576, 1560, 1546, 1531, 1515, 1501, 1486, 1473, 1458, 1445, - 1430, 1417, 1404, 1390, 1378, 1365, 1353, 1339, 1327, 1315, 1303, 1291, 1280, 1268, 1257, 1245, 1234, 1223, 1212, - 1201, 1190, 1180, 1169, 1158, 1149, 1139, 1128, 1118, 1108, 1099, 1089, 1081, 1071, 1061, 1053, 1043, 1034, 1026, - 1016, 1008, 999, 991, 982, 974, 966, 958, 949, 942, 934, 926, 918, 910, 903, 896, 887, 880, 873, 866, 858, 852, 845, - 838, 830, 824, 817, 810, 804, 798, 790, 784, 778, 771, 765, 759, 753, 747, 740, 734, 728, 722, 716, 710, 705, 699, - 693, 687, 682, 676, 671, 665, 660, 654, 649, 644, 638, 634, 629, 624, 618, 613, 608, 603, 598, 593, 589, 584, 579, - 574, 569, 566, 561, 556, 551, 547, 542, 538, 534, 529, 524, 521, 516, 512, 507, 504, 499, 495, 491, 487, 483, 479, - 474, 471, 467, 463, 459, 455, 451, 448, 444, 440, 437, 433, 429, 426, 422, 419, 415, 411, 408, 404, 400, 397, 393, - 391, 387, 383, 380, 377, 374, 370, 368, 364, 360, 358, 354, 351, 348, 344, 342, 338, 336, 332, 330, 326, 324, 320, - 318, 314, 312, 310, 306, 304, 301, 298, 295, 293, 289, 287, 285, 282, 279, 276, 274, 272, 268, 266, 263, 261, 258, - 256, 254, 251, 248, 245, 243, 241, 238, 236, 234, 231, 229, 226, 224, 222, 219, 217, 215, 212, 211, 209, 206, 204, - 202, 199, 197, 196, 193, 191, 189, 186, 184, 183, 180, 178, 175, 174, 172, 170, 167, 166, 164, 161, 160, 158, 155, - 154, 152, 149, 148, 146, 143, 142, 140, 138, 136, 135, 132, 130, 129, 126, 125, 123, 122, 119, 118, 116, 114, 112, - 111, 108, 107, 105, 104, 101, 100, 97, 96, 95, 93, 91, 89, 88, 86, 84, 83, 82, 79, 78, 75, 74, 73, 71, 69, 68, 66, - 64, 63, 62, 59, 58, 57, 55, 53, 52, 51, 48, 47, 46, 45, 42, 41, 40, 38, 37, 35, 33, 32, 31, 30, 27, 26, 25, 23, 22, - 21, 18, 17, 16, 15, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, 15, 16, 17, 18, 21, 22, 23, 25, 26, 27, 30, 31, 32, 33, 35, 37, 38, 40, 41, 42, 45, - 46, 47, 48, 51, 52, 53, 55, 57, 58, 59, 62, 63, 64, 66, 68, 69, 71, 73, 74, 75, 78, 79, 82, 83, 84, 86, 88, 89, 91, - 93, 95, 96, 97, 100, 101, 104, 105, 107, 108, 111, 112, 114, 116, 118, 119, 122, 123, 125, 126, 129, 130, 132, 135, - 136, 138, 140, 142, 143, 146, 148, 149, 152, 154, 155, 158, 160, 161, 164, 166, 167, 170, 172, 174, 175, 178, 180, - 183, 184, 186, 189, 191, 193, 196, 197, 199, 202, 204, 206, 209, 211, 212, 215, 217, 219, 222, 224, 226, 229, 231, - 234, 236, 238, 241, 243, 245, 248, 251, 254, 256, 258, 261, 263, 266, 268, 272, 274, 276, 279, 282, 285, 287, 289, - 293, 295, 298, 301, 304, 306, 310, 312, 314, 318, 320, 324, 326, 330, 332, 336, 338, 342, 344, 348, 351, 354, 358, - 360, 364, 368, 370, 374, 377, 380, 383, 387, 391, 393, 397, 400, 404, 408, 411, 415, 419, 422, 426, 429, 433, 437, - 440, 444, 448, 451, 455, 459, 463, 467, 471, 474, 479, 483, 487, 491, 495, 499, 504, 507, 512, 516, 521, 524, 529, - 534, 538, 542, 547, 551, 556, 561, 566, 569, 574, 579, 584, 589, 593, 598, 603, 608, 613, 618, 624, 629, 634, 638, - 644, 649, 654, 660, 665, 671, 676, 682, 687, 693, 699, 705, 710, 716, 722, 728, 734, 740, 747, 753, 759, 765, 771, - 778, 784, 790, 798, 804, 810, 817, 824, 830, 838, 845, 852, 858, 866, 873, 880, 887, 896, 903, 910, 918, 926, 934, - 942, 949, 958, 966, 974, 982, 991, 999, 1008, 1016, 1026, 1034, 1043, 1053, 1061, 1071, 1081, 1089, 1099, 1108, - 1118, 1128, 1139, 1149, 1158, 1169, 1180, 1190, 1201, 1212, 1223, 1234, 1245, 1257, 1268, 1280, 1291, 1303, 1315, - 1327, 1339, 1353, 1365, 1378, 1390, 1404, 1417, 1430, 1445, 1458, 1473, 1486, 1501, 1515, 1531, 1546, 1560, 1576, - 1592, 1608, 1624, 1641, 1658, 1673, 1692, 1709, 1726, 1744, 1762, 1780, 1798, 1818, 1837, 1857, 1877, 1897, 1917, - 1938, 1960, 1981, 2004, 2026, 2049, 2072, 2095, 2119, 2143, 2168, 2193, 2219, 2244, 2271, 2298, 2326, 2354, 2383, - 2412, 2441, 2471, 2502, 2533, 2566, 2599, 2633, 2667, 2701, 2737, 2774, 2810, 2849, 2888, 2927, 2968, 3010, 3052, - 3096, 3141, 3186, 3233, 3280, 3330, 3380, 3432, 3484, 3539, 3595, 3652, 3712, 3772, 3834, 3899, 3964, 4032, 4103, - 4174, 4249, 4325, 4404, 4485, 4569, 4657, 4747, 4840, 4936, 5036, 5139, 5247, 5358, 5473, 5593, 5718, 5848, 5983, - 6125, 6272, 6425, 6587, 6754, 6932, 7116, 7311, 7515, 7730, 7956, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191 + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8117, 7880, + 7657, 7444, 7243, 7050, 6868, 6692, 6527, 6367, 6216, 6070, 5930, 5796, 5668, 5544, 5425, 5311, 5202, 5095, 4993, + 4894, 4799, 4707, 4618, 4532, 4449, 4368, 4290, 4214, 4141, 4070, 4001, 3933, 3868, 3805, 3744, 3683, 3625, 3568, + 3513, 3459, 3407, 3356, 3306, 3257, 3210, 3163, 3119, 3074, 3031, 2989, 2948, 2908, 2869, 2831, 2792, 2756, 2720, + 2684, 2650, 2617, 2583, 2551, 2518, 2487, 2457, 2427, 2398, 2369, 2341, 2313, 2285, 2259, 2232, 2207, 2182, 2157, + 2133, 2109, 2085, 2062, 2039, 2016, 1995, 1972, 1951, 1930, 1909, 1889, 1870, 1849, 1830, 1811, 1792, 1774, 1756, + 1738, 1720, 1703, 1686, 1668, 1652, 1635, 1619, 1603, 1587, 1572, 1556, 1542, 1527, 1512, 1497, 1483, 1470, 1455, + 1442, 1428, 1414, 1401, 1388, 1376, 1363, 1351, 1338, 1326, 1314, 1302, 1289, 1279, 1267, 1256, 1244, 1233, 1222, + 1211, 1201, 1190, 1180, 1169, 1159, 1149, 1139, 1129, 1119, 1109, 1100, 1090, 1082, 1072, 1062, 1054, 1044, 1036, + 1028, 1018, 1010, 1001, 993, 984, 976, 969, 960, 952, 945, 936, 929, 921, 914, 906, 899, 891, 883, 876, 869, 862, + 856, 849, 841, 834, 828, 821, 814, 808, 802, 795, 789, 783, 775, 769, 763, 757, 751, 745, 739, 733, 727, 721, 715, + 711, 705, 699, 693, 688, 682, 677, 671, 666, 660, 655, 650, 644, 640, 635, 630, 624, 619, 614, 610, 605, 600, 595, + 590, 586, 581, 576, 572, 568, 563, 558, 554, 550, 545, 541, 536, 532, 528, 523, 520, 515, 511, 506, 503, 499, 494, + 491, 487, 482, 479, 475, 471, 467, 463, 459, 456, 452, 449, 445, 441, 438, 434, 431, 427, 423, 420, 416, 413, 409, + 405, 402, 399, 396, 392, 389, 386, 383, 379, 377, 373, 369, 367, 363, 360, 357, 354, 351, 348, 346, 342, 340, 336, + 334, 330, 328, 324, 322, 320, 316, 314, 312, 308, 306, 304, 300, 298, 295, 293, 290, 287, 285, 283, 279, 277, 275, + 273, 270, 268, 266, 263, 260, 258, 255, 253, 251, 249, 246, 244, 242, 240, 237, 235, 233, 231, 228, 226, 225, 223, + 220, 218, 216, 214, 211, 210, 208, 206, 204, 201, 199, 198, 196, 193, 191, 190, 188, 186, 183, 182, 180, 178, 177, + 174, 172, 171, 169, 166, 165, 163, 161, 160, 157, 156, 154, 153, 151, 148, 147, 145, 144, 142, 140, 138, 137, 135, + 134, 131, 130, 128, 127, 125, 123, 121, 120, 118, 117, 115, 113, 112, 110, 109, 107, 105, 104, 103, 101, 99, 97, 96, + 95, 92, 91, 90, 88, 87, 86, 84, 82, 81, 80, 77, 76, 75, 74, 72, 70, 69, 68, 66, 65, 63, 62, 61, 59, 58, 56, 55, 54, + 52, 50, 49, 48, 47, 46, 43, 42, 41, 40, 39, 37, 36, 35, 33, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 18, 17, 16, 15, + 13, 12, 11, 10, 9, 7, 6, 5, 4, 2, 1, 0, 1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16, 17, 18, 21, 22, 23, 24, 25, 27, + 28, 29, 30, 31, 33, 35, 36, 37, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 52, 54, 55, 56, 58, 59, 61, 62, 63, 65, 66, + 68, 69, 70, 72, 74, 75, 76, 77, 80, 81, 82, 84, 86, 87, 88, 90, 91, 92, 95, 96, 97, 99, 101, 103, 104, 105, 107, + 109, 110, 112, 113, 115, 117, 118, 120, 121, 123, 125, 127, 128, 130, 131, 134, 135, 137, 138, 140, 142, 144, 145, + 147, 148, 151, 153, 154, 156, 157, 160, 161, 163, 165, 166, 169, 171, 172, 174, 177, 178, 180, 182, 183, 186, 188, + 190, 191, 193, 196, 198, 199, 201, 204, 206, 208, 210, 211, 214, 216, 218, 220, 223, 225, 226, 228, 231, 233, 235, + 237, 240, 242, 244, 246, 249, 251, 253, 255, 258, 260, 263, 266, 268, 270, 273, 275, 277, 279, 283, 285, 287, 290, + 293, 295, 298, 300, 304, 306, 308, 312, 314, 316, 320, 322, 324, 328, 330, 334, 336, 340, 342, 346, 348, 351, 354, + 357, 360, 363, 367, 369, 373, 377, 379, 383, 386, 389, 392, 396, 399, 402, 405, 409, 413, 416, 420, 423, 427, 431, + 434, 438, 441, 445, 449, 452, 456, 459, 463, 467, 471, 475, 479, 482, 487, 491, 494, 499, 503, 506, 511, 515, 520, + 523, 528, 532, 536, 541, 545, 550, 554, 558, 563, 568, 572, 576, 581, 586, 590, 595, 600, 605, 610, 614, 619, 624, + 630, 635, 640, 644, 650, 655, 660, 666, 671, 677, 682, 688, 693, 699, 705, 711, 715, 721, 727, 733, 739, 745, 751, + 757, 763, 769, 775, 783, 789, 795, 802, 808, 814, 821, 828, 834, 841, 849, 856, 862, 869, 876, 883, 891, 899, 906, + 914, 921, 929, 936, 945, 952, 960, 969, 976, 984, 993, 1001, 1010, 1018, 1028, 1036, 1044, 1054, 1062, 1072, 1082, + 1090, 1100, 1109, 1119, 1129, 1139, 1149, 1159, 1169, 1180, 1190, 1201, 1211, 1222, 1233, 1244, 1256, 1267, 1279, + 1289, 1302, 1314, 1326, 1338, 1351, 1363, 1376, 1388, 1401, 1414, 1428, 1442, 1455, 1470, 1483, 1497, 1512, 1527, + 1542, 1556, 1572, 1587, 1603, 1619, 1635, 1652, 1668, 1686, 1703, 1720, 1738, 1756, 1774, 1792, 1811, 1830, 1849, + 1870, 1889, 1909, 1930, 1951, 1972, 1995, 2016, 2039, 2062, 2085, 2109, 2133, 2157, 2182, 2207, 2232, 2259, 2285, + 2313, 2341, 2369, 2398, 2427, 2457, 2487, 2518, 2551, 2583, 2617, 2650, 2684, 2720, 2756, 2792, 2831, 2869, 2908, + 2948, 2989, 3031, 3074, 3119, 3163, 3210, 3257, 3306, 3356, 3407, 3459, 3513, 3568, 3625, 3683, 3744, 3805, 3868, + 3933, 4001, 4070, 4141, 4214, 4290, 4368, 4449, 4532, 4618, 4707, 4799, 4894, 4993, 5095, 5202, 5311, 5425, 5544, + 5668, 5796, 5930, 6070, 6216, 6367, 6527, 6692, 6868, 7050, 7243, 7444, 7657, 7880, 8117, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191 }}; rels_lut_ = {{ @@ -149,12 +149,11 @@ ActivationLut::ActivationLut() { }}; dxy_lut_ = {{ - 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, - 11, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 21, 21, 21, 21, 22, - 22, 22, 22, 24, 24, 24, 24, 25, 25, 25, 25, 27, 27, 27, 28, 28, 28, 28, 30, 30, 30, 30, 31, 31, 31, 31, 33, 33, 33, - 33, 35, 35, 35, 35, 36, 36, 36, 36, 38, 38, 38, 40, 40, 40, 40, 41, 41, 41, 41, 43, 43, 43, 43, 45, 45, 45, 45, 47, - 47, 47, 47, 49, 49, 49, 51, 51, 51, 51, 52, 52, 52, 52, 54, 54, 54, 54, 56, 56, 56, 56, 58, 58, 58, 58, 60, 60, 60, - 60, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 6, 6, 6, 6, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, + 12, 12, 13, 13, 13, 13, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 21, 21, 21, 21, + 22, 22, 22, 22, 23, 23, 23, 23, 25, 25, 25, 25, 27, 27, 27, 28, 28, 28, 28, 30, 30, 30, 30, 32, 32, 32, 32, 35, 35, + 35, 35, 37, 37, 37, 37, 40, 40, 40, 40, 43, 43, 43, 46, 46, 46, 46, 49, 49, 49, 49, 53, 53, 53, 53, 56, 56, 56, 56, + 60, 60, 60, 60, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, @@ -166,7 +165,10 @@ ActivationLut::ActivationLut() { 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, @@ -181,14 +183,12 @@ ActivationLut::ActivationLut() { -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -62, - -62, -62, -60, -60, -60, -60, -58, -58, -58, -58, -56, -56, -56, -56, -54, -54, -54, -54, -52, -52, -52, -52, -51, - -51, -51, -51, -49, -49, -49, -47, -47, -47, -47, -45, -45, -45, -45, -43, -43, -43, -43, -41, -41, -41, -41, -40, - -40, -40, -40, -38, -38, -38, -36, -36, -36, -36, -35, -35, -35, -35, -33, -33, -33, -33, -31, -31, -31, -31, -30, - -30, -30, -30, -28, -28, -28, -28, -27, -27, -27, -25, -25, -25, -25, -24, -24, -24, -24, -22, -22, -22, -22, -21, - -21, -21, -21, -19, -19, -19, -19, -18, -18, -18, -18, -17, -17, -17, -15, -15, -15, -15, -14, -14, -14, -14, -13, - -13, -13, -13, -11, -11, -11, -11, -10, -10, -10, -10, -9, -9, -9, -8, -8, -8, -8, -7, -7, -7, -7, -6, -6, -6, -6, - -4, -4, -4, -4, -3, -3, -3, -3, -2, -2, -2, -2, 0 + -64, -64, -64, -64, -64, -64, -60, -60, -60, -60, -56, -56, -56, -56, -53, -53, -53, -53, -49, -49, -49, -49, -46, + -46, -46, -46, -43, -43, -43, -40, -40, -40, -40, -37, -37, -37, -37, -35, -35, -35, -35, -32, -32, -32, -32, -30, + -30, -30, -30, -28, -28, -28, -28, -27, -27, -27, -25, -25, -25, -25, -23, -23, -23, -23, -22, -22, -22, -22, -21, + -21, -21, -21, -19, -19, -19, -19, -18, -18, -18, -18, -17, -17, -17, -16, -16, -16, -16, -15, -15, -15, -15, -13, + -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11, -10, -10, -10, -9, -9, -9, -9, -8, -8, -8, -8, -6, -6, -6, + -6, -5, -5, -5, -5, -3, -3, -3, -3, -2, -2, -2, -2, 0 }}; } From 8d801227e6341333219e3f27f880ebd3b112b7cb Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Fri, 15 Dec 2023 18:22:57 +0100 Subject: [PATCH 07/24] Formatted code --- DataFormats/L1TMuonPhase2/interface/EMTFHit.h | 511 +++++----- .../L1TMuonPhase2/interface/EMTFInput.h | 79 +- .../L1TMuonPhase2/interface/EMTFTrack.h | 261 +++-- DataFormats/L1TMuonPhase2/src/MuonStub.cc | 1 - DataFormats/L1TMuonPhase2/src/SAMuon.cc | 1 - DataFormats/L1TMuonPhase2/src/TrackerMuon.cc | 1 - .../L1TGEM/src/GE0TriggerPseudoBuilder.cc | 4 +- L1Trigger/L1TMuon/src/GeometryTranslator.cc | 6 +- .../interface/Algo/DuplicateRemovalLayer.h | 20 +- .../interface/Algo/HitmapLayer.h | 22 +- .../interface/Algo/OutputLayer.h | 48 +- .../interface/Algo/ParameterAssignmentLayer.h | 21 +- .../interface/Algo/PatternMatchingLayer.h | 23 +- .../interface/Algo/RoadSortingLayer.h | 29 +- .../interface/Algo/TrackBuildingLayer.h | 53 +- .../interface/DAQ/CSCTPCollector.h | 22 +- .../interface/DAQ/CSCTPConverter.h | 24 +- .../interface/DAQ/CSCTPSelector.h | 45 +- .../interface/DAQ/GE0TPCollector.h | 23 +- .../interface/DAQ/GE0TPConverter.h | 23 +- .../interface/DAQ/GE0TPSelector.h | 33 +- .../interface/DAQ/GEMTPCollector.h | 22 +- .../interface/DAQ/GEMTPConverter.h | 22 +- .../interface/DAQ/GEMTPSelector.h | 45 +- .../interface/DAQ/ME0TPCollector.h | 22 +- .../interface/DAQ/ME0TPConverter.h | 22 +- .../interface/DAQ/ME0TPSelector.h | 32 +- .../interface/DAQ/RPCTPCollector.h | 22 +- .../interface/DAQ/RPCTPConverter.h | 22 +- .../interface/DAQ/RPCTPSelector.h | 45 +- .../interface/DAQ/SubsystemTags.h | 104 +- .../interface/DAQ/TPCollectors.h | 16 +- .../interface/DAQ/TPConverters.h | 15 +- .../interface/DAQ/TPSelectors.h | 16 +- .../interface/DAQ/TPrimitives.h | 89 +- .../interface/Data/ActivationLut.h | 34 +- .../interface/Data/HostLut.h | 34 +- .../interface/Data/SiteLut.h | 34 +- .../interface/Data/TimeZoneLut.h | 34 +- .../interface/Data/ZoneLut.h | 55 +- .../interface/EMTFConfiguration.h | 85 +- .../interface/EMTFConstants.h | 112 +- .../interface/EMTFContext.h | 97 +- .../L1TMuonEndCapPhase2/interface/EMTFModel.h | 194 ++-- .../L1TMuonEndCapPhase2/interface/EMTFTypes.h | 302 +++--- .../L1TMuonEndCapPhase2/interface/EMTFfwd.h | 41 +- .../interface/SectorProcessor.h | 106 +- .../interface/TrackFinder.h | 56 +- .../interface/Utils/CSCUtils.h | 42 +- .../interface/Utils/DataUtils.h | 304 +++--- .../interface/Utils/DebugUtils.h | 3 +- .../interface/Utils/IteratorUtils.h | 338 +++--- .../interface/Utils/RPCUtils.h | 8 +- .../interface/Utils/TPUtils.h | 50 +- .../interface/Utils/TemplateUtils.h | 18 +- .../L1TMuonEndCapPhase2TrackProducer.cc | 54 +- .../L1TMuonEndCapPhase2TrackProducer.h | 49 +- .../src/Algo/DuplicateRemovalLayer.cc | 234 ++--- .../src/Algo/HitmapLayer.cc | 324 +++--- .../src/Algo/OutputLayer.cc | 249 +++-- .../src/Algo/ParameterAssignmentLayer.cc | 288 +++--- .../src/Algo/PatternMatchingLayer.cc | 223 ++-- .../src/Algo/RoadSortingLayer.cc | 281 +++-- .../src/Algo/TrackBuildingLayer.cc | 965 +++++++++--------- .../src/DAQ/CSCTPCollector.cc | 335 +++--- .../src/DAQ/CSCTPConverter.cc | 325 +++--- .../src/DAQ/CSCTPSelector.cc | 209 ++-- .../src/DAQ/GE0TPCollector.cc | 240 +++-- .../src/DAQ/GE0TPConverter.cc | 250 +++-- .../src/DAQ/GE0TPSelector.cc | 140 ++- .../src/DAQ/GEMTPCollector.cc | 343 +++---- .../src/DAQ/GEMTPConverter.cc | 260 +++-- .../src/DAQ/GEMTPSelector.cc | 160 ++- .../src/DAQ/ME0TPCollector.cc | 239 +++-- .../src/DAQ/ME0TPConverter.cc | 250 +++-- .../src/DAQ/ME0TPSelector.cc | 140 ++- .../src/DAQ/RPCTPCollector.cc | 285 +++--- .../src/DAQ/RPCTPConverter.cc | 319 +++--- .../src/DAQ/RPCTPSelector.cc | 176 ++-- .../src/DAQ/TPrimitives.cc | 60 +- .../src/Data/ActivationLut.cc | 28 +- .../L1TMuonEndCapPhase2/src/Data/HostLut.cc | 65 +- .../L1TMuonEndCapPhase2/src/Data/SiteLut.cc | 65 +- .../src/Data/TimeZoneLut.cc | 71 +- .../L1TMuonEndCapPhase2/src/Data/ZoneLut.cc | 168 ++- .../src/EMTFConfiguration.cc | 63 +- .../L1TMuonEndCapPhase2/src/EMTFContext.cc | 201 ++-- .../L1TMuonEndCapPhase2/src/EMTFModel.cc | 115 +-- .../src/SectorProcessor.cc | 718 ++++++------- .../L1TMuonEndCapPhase2/src/TrackFinder.cc | 306 +++--- .../L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc | 306 +++--- .../L1TMuonEndCapPhase2/src/Utils/TPUtils.cc | 162 +-- 92 files changed, 5798 insertions(+), 6559 deletions(-) diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFHit.h b/DataFormats/L1TMuonPhase2/interface/EMTFHit.h index 2d26cb0d7393b..4ada9e1fc8e74 100644 --- a/DataFormats/L1TMuonPhase2/interface/EMTFHit.h +++ b/DataFormats/L1TMuonPhase2/interface/EMTFHit.h @@ -8,261 +8,260 @@ namespace l1t::phase2 { - class EMTFHit { - public: - EMTFHit(): - id_(0), - - raw_det_id_(0), - subsystem_(0), - endcap_(0), - sector_(0), - subsector_(0), - station_(0), - ring_(0), - roll_(0), - layer_(0), - chamber_(0), - - csc_id_(0), - csc_fr_(0), - - strip_(0), - strip_lo_(0), - strip_hi_(0), - strip_quart_(0), // Run 3 - strip_eighth_(0), // Run 3 - strip_quart_bit_(0), // Run 3 - strip_eighth_bit_(0), // Run 3 - - wire1_(0), - wire2_(0), - - bx_(0), - subbx_(0), - - quality_(0), - pattern_(0), - - glob_phi_(0), - glob_theta_(0), - glob_perp_(0), - glob_z_(0), - glob_time_(0), - - emtf_chamber_(0), - emtf_segment_(0), - emtf_phi_(0), - emtf_bend_(0), - emtf_slope_(0), - emtf_theta1_(0), - emtf_theta2_(0), - emtf_qual1_(0), - emtf_qual2_(0), - emtf_time_(0), - emtf_site_(0), - emtf_host_(0), - emtf_zones_(0), - emtf_timezones_(0), - - flag_neighbor_(false), - flag_substitute_(false), - flag_valid_(false) - { - // Do Nothing - } - - ~EMTFHit() { - // Do Nothing - } - - // Setters - void setId(uint16_t aId) { id_ = aId; } - - void setRawDetId(uint32_t aRawDetId) { raw_det_id_ = aRawDetId; } - void setSubsystem(int16_t aSubsystem) { subsystem_ = aSubsystem; } - void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } - void setSector(int16_t aSector) { sector_ = aSector; } - void setSubsector(int16_t aSubsector) { subsector_ = aSubsector; } - void setStation(int16_t aStation) { station_ = aStation; } - void setRing(int16_t aRing) { ring_ = aRing; } - void setRoll(int16_t aRoll) { roll_ = aRoll; } - void setLayer(int16_t aLayer) { layer_ = aLayer; } - void setChamber(int16_t aChamber) { chamber_ = aChamber; } - - void setCscId(int16_t aCscid) { csc_id_ = aCscid; } - void setCscFR(int16_t aCscfr) { csc_fr_ = aCscfr; } - - void setStrip(int16_t aStrip) { strip_ = aStrip; } - void setStripLo(int16_t aStripLo) { strip_lo_ = aStripLo; } - void setStripHi(int16_t aStripHi) { strip_hi_ = aStripHi; } - void setStripQuart(int16_t aStripQuart) { strip_quart_ = aStripQuart; } // Run 3 - void setStripEighth(int16_t aStripEighth) { strip_eighth_ = aStripEighth; } // Run 3 - void setStripQuartBit(int16_t aStripQuartBit) { strip_quart_bit_ = aStripQuartBit; } // Run 3 - void setStripEighthBit(int16_t aStripEighthBit) { strip_eighth_bit_ = aStripEighthBit; } // Run 3 - - void setWire1(int16_t aWire1) { wire1_ = aWire1; } - void setWire2(int16_t aWire2) { wire2_ = aWire2; } - - void setBend(int16_t aBend) { bend_ = aBend; } - void setSlope(int16_t aSlope) { slope_ = aSlope; } - - void setBx(int16_t aBx) { bx_ = aBx; } - void setSubbx(int16_t aSubbx) { subbx_ = aSubbx; } - - void setQuality(int16_t aQuality) { quality_ = aQuality; } - void setPattern(int16_t aPattern) { pattern_ = aPattern; } - - void setGlobPhi(float aGlobPhi) { glob_phi_ = aGlobPhi; } - void setGlobTheta(float aGlobTheta) { glob_theta_ = aGlobTheta; } - void setGlobPerp(float aGlobPerp) { glob_perp_ = aGlobPerp; } - void setGlobZ(float aGlobZ) { glob_z_ = aGlobZ; } - void setGlobTime(float aGlobTime) { glob_time_ = aGlobTime; } - - void setEmtfChamber(int16_t aEmtfChamber) { emtf_chamber_ = aEmtfChamber; } - void setEmtfSegment(int16_t aEmtfSegment) { emtf_segment_ = aEmtfSegment; } - void setEmtfPhi(int16_t aEmtfPhi) { emtf_phi_ = aEmtfPhi; } - void setEmtfBend(int16_t aEmtfBend) { emtf_bend_ = aEmtfBend; } - void setEmtfTheta1(int16_t aEmtfTheta1) { emtf_theta1_ = aEmtfTheta1; } - void setEmtfTheta2(int16_t aEmtfTheta2) { emtf_theta2_ = aEmtfTheta2; } - void setEmtfQual1(int16_t aEmtfQual1) { emtf_qual1_ = aEmtfQual1; } - void setEmtfQual2(int16_t aEmtfQual2) { emtf_qual2_ = aEmtfQual2; } - void setEmtfTime(int16_t aEmtfTime) { emtf_time_ = aEmtfTime; } - void setEmtfSite(int16_t aEmtfSite) { emtf_site_ = aEmtfSite; } - void setEmtfHost(int16_t aEmtfHost) { emtf_host_ = aEmtfHost; } - void setEmtfZones(int16_t aEmtfZones) { emtf_zones_ = aEmtfZones; } - void setEmtfTimezones(int16_t aEmtfTimezones) { emtf_timezones_ = aEmtfTimezones; } - - void setFlagNeighbor(bool aNeighbor) { flag_neighbor_ = aNeighbor; } - void setFlagSubstitute(bool aSubstitute) { flag_substitute_ = aSubstitute; } - void setFlagValid(bool aValid) { flag_valid_ = aValid; } - - // Getters - uint16_t id() const { return id_; } - - uint32_t rawDetId() const { return raw_det_id_; } - int16_t subsystem() const { return subsystem_; } - int16_t endcap() const { return endcap_; } - int16_t sector() const { return sector_; } - int16_t subsector() const { return subsector_; } - int16_t station() const { return station_; } - int16_t ring() const { return ring_; } - int16_t roll() const { return roll_; } - int16_t layer() const { return layer_; } - int16_t chamber() const { return chamber_; } - - int16_t cscId() const { return csc_id_; } - int16_t cscFR() const { return csc_fr_; } - - int16_t strip() const { return strip_; } - int16_t stripLo() const { return strip_lo_; } - int16_t stripHi() const { return strip_hi_; } - int16_t stripQuart() const { return strip_quart_; } // Run 3 - int16_t stripEighth() const { return strip_eighth_; } // Run 3 - int16_t stripQuartBit() const { return strip_quart_bit_; } // Run 3 - int16_t stripEighthBit() const { return strip_eighth_bit_; } // Run 3 - - int16_t wire1() const { return wire1_; } - int16_t wire2() const { return wire2_; } - - int16_t bend() const { return bend_; } - int16_t slope() const { return slope_; } - - int16_t bx() const { return bx_; } - int16_t subbx() const { return subbx_; } - - int16_t quality() const { return quality_; } - int16_t pattern() const { return pattern_; } - - float globPhi() const { return glob_phi_; } - float globTheta() const { return glob_theta_; } - float globPerp() const { return glob_perp_; } - float globZ() const { return glob_z_; } - float globTime() const { return glob_time_; } - - int16_t emtfChamber() const { return emtf_chamber_; } - int16_t emtfSegment() const { return emtf_segment_; } - int16_t emtfPhi() const { return emtf_phi_; } - int16_t emtfBend() const { return emtf_bend_; } - int16_t emtfTheta1() const { return emtf_theta1_; } - int16_t emtfTheta2() const { return emtf_theta2_; } - int16_t emtfQual1() const { return emtf_qual1_; } - int16_t emtfQual2() const { return emtf_qual2_; } - int16_t emtfTime() const { return emtf_time_; } - int16_t emtfSite() const { return emtf_site_; } - int16_t emtfHost() const { return emtf_host_; } - int16_t emtfZones() const { return emtf_zones_; } - int16_t emtfTimezones() const { return emtf_timezones_; } - - bool flagNeighbor() const { return flag_neighbor_; } - bool flagSubstitute() const { return flag_substitute_; } - bool flagValid() const { return flag_valid_; } - - private: - uint16_t id_; - - uint32_t raw_det_id_; - int16_t subsystem_; - int16_t endcap_; - int16_t sector_; - int16_t subsector_; - int16_t station_; - int16_t ring_; - int16_t roll_; - int16_t layer_; - int16_t chamber_; - - int16_t csc_id_; - int16_t csc_fr_; // front/rear - - int16_t strip_; - int16_t strip_lo_; - int16_t strip_hi_; - int16_t strip_quart_; - int16_t strip_eighth_; - int16_t strip_quart_bit_; - int16_t strip_eighth_bit_; - - int16_t wire1_; - int16_t wire2_; - - int16_t bend_; - int16_t slope_; - - int16_t bx_; - int16_t subbx_; - - int16_t quality_; - int16_t pattern_; - - float glob_phi_; - float glob_theta_; - float glob_perp_; - float glob_z_; - float glob_time_; - - int16_t emtf_chamber_; - int16_t emtf_segment_; - int16_t emtf_phi_; - int16_t emtf_bend_; - int16_t emtf_slope_; - int16_t emtf_theta1_; - int16_t emtf_theta2_; - int16_t emtf_qual1_; - int16_t emtf_qual2_; - int16_t emtf_time_; - int16_t emtf_site_; - int16_t emtf_host_; - int16_t emtf_zones_; - int16_t emtf_timezones_; - - bool flag_neighbor_; - bool flag_substitute_; - bool flag_valid_; - }; - - typedef std::vector EMTFHitCollection; - -} // namespace l1t:phase2 + class EMTFHit { + public: + EMTFHit() + : id_(0), + + raw_det_id_(0), + subsystem_(0), + endcap_(0), + sector_(0), + subsector_(0), + station_(0), + ring_(0), + roll_(0), + layer_(0), + chamber_(0), + + csc_id_(0), + csc_fr_(0), + + strip_(0), + strip_lo_(0), + strip_hi_(0), + strip_quart_(0), // Run 3 + strip_eighth_(0), // Run 3 + strip_quart_bit_(0), // Run 3 + strip_eighth_bit_(0), // Run 3 + + wire1_(0), + wire2_(0), + + bx_(0), + subbx_(0), + + quality_(0), + pattern_(0), + + glob_phi_(0), + glob_theta_(0), + glob_perp_(0), + glob_z_(0), + glob_time_(0), + + emtf_chamber_(0), + emtf_segment_(0), + emtf_phi_(0), + emtf_bend_(0), + emtf_slope_(0), + emtf_theta1_(0), + emtf_theta2_(0), + emtf_qual1_(0), + emtf_qual2_(0), + emtf_time_(0), + emtf_site_(0), + emtf_host_(0), + emtf_zones_(0), + emtf_timezones_(0), + + flag_neighbor_(false), + flag_substitute_(false), + flag_valid_(false) { + // Do Nothing + } + + ~EMTFHit() { + // Do Nothing + } + + // Setters + void setId(uint16_t aId) { id_ = aId; } + + void setRawDetId(uint32_t aRawDetId) { raw_det_id_ = aRawDetId; } + void setSubsystem(int16_t aSubsystem) { subsystem_ = aSubsystem; } + void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } + void setSector(int16_t aSector) { sector_ = aSector; } + void setSubsector(int16_t aSubsector) { subsector_ = aSubsector; } + void setStation(int16_t aStation) { station_ = aStation; } + void setRing(int16_t aRing) { ring_ = aRing; } + void setRoll(int16_t aRoll) { roll_ = aRoll; } + void setLayer(int16_t aLayer) { layer_ = aLayer; } + void setChamber(int16_t aChamber) { chamber_ = aChamber; } + + void setCscId(int16_t aCscid) { csc_id_ = aCscid; } + void setCscFR(int16_t aCscfr) { csc_fr_ = aCscfr; } + + void setStrip(int16_t aStrip) { strip_ = aStrip; } + void setStripLo(int16_t aStripLo) { strip_lo_ = aStripLo; } + void setStripHi(int16_t aStripHi) { strip_hi_ = aStripHi; } + void setStripQuart(int16_t aStripQuart) { strip_quart_ = aStripQuart; } // Run 3 + void setStripEighth(int16_t aStripEighth) { strip_eighth_ = aStripEighth; } // Run 3 + void setStripQuartBit(int16_t aStripQuartBit) { strip_quart_bit_ = aStripQuartBit; } // Run 3 + void setStripEighthBit(int16_t aStripEighthBit) { strip_eighth_bit_ = aStripEighthBit; } // Run 3 + + void setWire1(int16_t aWire1) { wire1_ = aWire1; } + void setWire2(int16_t aWire2) { wire2_ = aWire2; } + + void setBend(int16_t aBend) { bend_ = aBend; } + void setSlope(int16_t aSlope) { slope_ = aSlope; } + + void setBx(int16_t aBx) { bx_ = aBx; } + void setSubbx(int16_t aSubbx) { subbx_ = aSubbx; } + + void setQuality(int16_t aQuality) { quality_ = aQuality; } + void setPattern(int16_t aPattern) { pattern_ = aPattern; } + + void setGlobPhi(float aGlobPhi) { glob_phi_ = aGlobPhi; } + void setGlobTheta(float aGlobTheta) { glob_theta_ = aGlobTheta; } + void setGlobPerp(float aGlobPerp) { glob_perp_ = aGlobPerp; } + void setGlobZ(float aGlobZ) { glob_z_ = aGlobZ; } + void setGlobTime(float aGlobTime) { glob_time_ = aGlobTime; } + + void setEmtfChamber(int16_t aEmtfChamber) { emtf_chamber_ = aEmtfChamber; } + void setEmtfSegment(int16_t aEmtfSegment) { emtf_segment_ = aEmtfSegment; } + void setEmtfPhi(int16_t aEmtfPhi) { emtf_phi_ = aEmtfPhi; } + void setEmtfBend(int16_t aEmtfBend) { emtf_bend_ = aEmtfBend; } + void setEmtfTheta1(int16_t aEmtfTheta1) { emtf_theta1_ = aEmtfTheta1; } + void setEmtfTheta2(int16_t aEmtfTheta2) { emtf_theta2_ = aEmtfTheta2; } + void setEmtfQual1(int16_t aEmtfQual1) { emtf_qual1_ = aEmtfQual1; } + void setEmtfQual2(int16_t aEmtfQual2) { emtf_qual2_ = aEmtfQual2; } + void setEmtfTime(int16_t aEmtfTime) { emtf_time_ = aEmtfTime; } + void setEmtfSite(int16_t aEmtfSite) { emtf_site_ = aEmtfSite; } + void setEmtfHost(int16_t aEmtfHost) { emtf_host_ = aEmtfHost; } + void setEmtfZones(int16_t aEmtfZones) { emtf_zones_ = aEmtfZones; } + void setEmtfTimezones(int16_t aEmtfTimezones) { emtf_timezones_ = aEmtfTimezones; } + + void setFlagNeighbor(bool aNeighbor) { flag_neighbor_ = aNeighbor; } + void setFlagSubstitute(bool aSubstitute) { flag_substitute_ = aSubstitute; } + void setFlagValid(bool aValid) { flag_valid_ = aValid; } + + // Getters + uint16_t id() const { return id_; } + + uint32_t rawDetId() const { return raw_det_id_; } + int16_t subsystem() const { return subsystem_; } + int16_t endcap() const { return endcap_; } + int16_t sector() const { return sector_; } + int16_t subsector() const { return subsector_; } + int16_t station() const { return station_; } + int16_t ring() const { return ring_; } + int16_t roll() const { return roll_; } + int16_t layer() const { return layer_; } + int16_t chamber() const { return chamber_; } + + int16_t cscId() const { return csc_id_; } + int16_t cscFR() const { return csc_fr_; } + + int16_t strip() const { return strip_; } + int16_t stripLo() const { return strip_lo_; } + int16_t stripHi() const { return strip_hi_; } + int16_t stripQuart() const { return strip_quart_; } // Run 3 + int16_t stripEighth() const { return strip_eighth_; } // Run 3 + int16_t stripQuartBit() const { return strip_quart_bit_; } // Run 3 + int16_t stripEighthBit() const { return strip_eighth_bit_; } // Run 3 + + int16_t wire1() const { return wire1_; } + int16_t wire2() const { return wire2_; } + + int16_t bend() const { return bend_; } + int16_t slope() const { return slope_; } + + int16_t bx() const { return bx_; } + int16_t subbx() const { return subbx_; } + + int16_t quality() const { return quality_; } + int16_t pattern() const { return pattern_; } + + float globPhi() const { return glob_phi_; } + float globTheta() const { return glob_theta_; } + float globPerp() const { return glob_perp_; } + float globZ() const { return glob_z_; } + float globTime() const { return glob_time_; } + + int16_t emtfChamber() const { return emtf_chamber_; } + int16_t emtfSegment() const { return emtf_segment_; } + int16_t emtfPhi() const { return emtf_phi_; } + int16_t emtfBend() const { return emtf_bend_; } + int16_t emtfTheta1() const { return emtf_theta1_; } + int16_t emtfTheta2() const { return emtf_theta2_; } + int16_t emtfQual1() const { return emtf_qual1_; } + int16_t emtfQual2() const { return emtf_qual2_; } + int16_t emtfTime() const { return emtf_time_; } + int16_t emtfSite() const { return emtf_site_; } + int16_t emtfHost() const { return emtf_host_; } + int16_t emtfZones() const { return emtf_zones_; } + int16_t emtfTimezones() const { return emtf_timezones_; } + + bool flagNeighbor() const { return flag_neighbor_; } + bool flagSubstitute() const { return flag_substitute_; } + bool flagValid() const { return flag_valid_; } + + private: + uint16_t id_; + + uint32_t raw_det_id_; + int16_t subsystem_; + int16_t endcap_; + int16_t sector_; + int16_t subsector_; + int16_t station_; + int16_t ring_; + int16_t roll_; + int16_t layer_; + int16_t chamber_; + + int16_t csc_id_; + int16_t csc_fr_; // front/rear + + int16_t strip_; + int16_t strip_lo_; + int16_t strip_hi_; + int16_t strip_quart_; + int16_t strip_eighth_; + int16_t strip_quart_bit_; + int16_t strip_eighth_bit_; + + int16_t wire1_; + int16_t wire2_; + + int16_t bend_; + int16_t slope_; + + int16_t bx_; + int16_t subbx_; + + int16_t quality_; + int16_t pattern_; + + float glob_phi_; + float glob_theta_; + float glob_perp_; + float glob_z_; + float glob_time_; + + int16_t emtf_chamber_; + int16_t emtf_segment_; + int16_t emtf_phi_; + int16_t emtf_bend_; + int16_t emtf_slope_; + int16_t emtf_theta1_; + int16_t emtf_theta2_; + int16_t emtf_qual1_; + int16_t emtf_qual2_; + int16_t emtf_time_; + int16_t emtf_site_; + int16_t emtf_host_; + int16_t emtf_zones_; + int16_t emtf_timezones_; + + bool flag_neighbor_; + bool flag_substitute_; + bool flag_valid_; + }; + + typedef std::vector EMTFHitCollection; + +} // namespace l1t::phase2 #endif // DataFormats_L1TMuonPhase2_EMTFHit_h not defined diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFInput.h b/DataFormats/L1TMuonPhase2/interface/EMTFInput.h index 0dc9c46fd66ee..71b4aefb7aee4 100644 --- a/DataFormats/L1TMuonPhase2/interface/EMTFInput.h +++ b/DataFormats/L1TMuonPhase2/interface/EMTFInput.h @@ -8,49 +8,42 @@ namespace l1t::phase2 { - class EMTFInput { - public: - typedef std::vector hits_t; - typedef std::vector segs_t; - - - EMTFInput(): - endcap_(0), - sector_(0), - bx_(0), - hits_{}, - segs_{} - { - // Do Nothing - } - - ~EMTFInput() { - // Do Nothing - } - - // Setters - void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } - void setSector(int16_t aSector) { sector_ = aSector; } - void setBx(int16_t aBx) { bx_ = aBx; } - void setHits(const hits_t& aHits) { hits_ = aHits; } - void setSegs(const segs_t& aSegs) { segs_ = aSegs; } - - // Getters - int16_t endcap() const { return endcap_; } - int16_t sector() const { return sector_; } - int16_t bx() const { return bx_; } - const hits_t& hits() const { return hits_; } - const segs_t& segs() const { return segs_; } - - private: - int16_t endcap_; - int16_t sector_; - int16_t bx_; - hits_t hits_; - segs_t segs_; - }; - - typedef std::vector EMTFInputCollection; + class EMTFInput { + public: + typedef std::vector hits_t; + typedef std::vector segs_t; + + EMTFInput() : endcap_(0), sector_(0), bx_(0), hits_{}, segs_{} { + // Do Nothing + } + + ~EMTFInput() { + // Do Nothing + } + + // Setters + void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } + void setSector(int16_t aSector) { sector_ = aSector; } + void setBx(int16_t aBx) { bx_ = aBx; } + void setHits(const hits_t& aHits) { hits_ = aHits; } + void setSegs(const segs_t& aSegs) { segs_ = aSegs; } + + // Getters + int16_t endcap() const { return endcap_; } + int16_t sector() const { return sector_; } + int16_t bx() const { return bx_; } + const hits_t& hits() const { return hits_; } + const segs_t& segs() const { return segs_; } + + private: + int16_t endcap_; + int16_t sector_; + int16_t bx_; + hits_t hits_; + segs_t segs_; + }; + + typedef std::vector EMTFInputCollection; } // namespace l1t::phase2 diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h b/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h index 4ad5557bdad50..aff142f21c58f 100644 --- a/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h +++ b/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h @@ -7,137 +7,136 @@ namespace l1t::phase2 { - class EMTFTrack { - public: - typedef std::vector features_t; - typedef std::vector site_hits_t; - typedef std::vector site_segs_t; - typedef std::vector site_mask_t; - - EMTFTrack(): - endcap_(0), - sector_(0), - bx_(0), - unconstrained_(false), - valid_(false), - model_pt_address_(0), - model_dxy_address_(0), - model_pattern_(0), - model_qual_(0), - model_phi_(0), - model_eta_(0), - model_features_{}, - emtf_q_(0), - emtf_pt_(0), - emtf_d0_(0), - emtf_z0_(0), - emtf_beta_(0), - emtf_mode_v1_(0), - emtf_mode_v2_(0), - site_hits_{}, - site_segs_{}, - site_mask_{}, - site_rm_mask_{} - { - // Do Nothing - } - - ~EMTFTrack() { - // Do Nothing - } - - // Setters - void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } - void setSector(int16_t aSector) { sector_ = aSector; } - void setBx(int16_t aBx) { bx_ = aBx; } - void setUnconstrained(bool aUnconstrained) { unconstrained_ = aUnconstrained; } - void setValid(bool aValid) { valid_ = aValid; } - - void setModelPtAddress(int16_t aAddress) { model_pt_address_ = aAddress; } - void setModelRelsAddress(int16_t aAddress) { model_rels_address_ = aAddress; } - void setModelDxyAddress(int16_t aAddress) { model_dxy_address_ = aAddress; } - void setModelPattern(int16_t aModelPattern) { model_pattern_ = aModelPattern; } - void setModelQual(int16_t aModelQual) { model_qual_ = aModelQual; } - void setModelPhi(int32_t aModelPhi) { model_phi_ = aModelPhi; } - void setModelEta(int32_t aModelEta) { model_eta_ = aModelEta; } - void setModelFeatures(const features_t& aModelFeatures) { model_features_ = aModelFeatures; } - - void setEmtfQ(int16_t aEmtfQ) { emtf_q_ = aEmtfQ; } - void setEmtfPt(int32_t aEmtfPt) { emtf_pt_ = aEmtfPt; } - void setEmtfRels(int32_t aEmtfRels) { emtf_rels_ = aEmtfRels; } - void setEmtfD0(int32_t aEmtfD0) { emtf_d0_ = aEmtfD0; } - void setEmtfZ0(int32_t aEmtfZ0) { emtf_z0_ = aEmtfZ0; } - void setEmtfBeta(int32_t aEmtfBeta) { emtf_beta_ = aEmtfBeta; } - void setEmtfModeV1(int16_t aEmtfModeV1) { emtf_mode_v1_ = aEmtfModeV1; } - void setEmtfModeV2(int16_t aEmtfModeV2) { emtf_mode_v2_ = aEmtfModeV2; } - - void setSiteHits(const site_hits_t& aSiteHits) { site_hits_ = aSiteHits; } - void setSiteSegs(const site_segs_t& aSiteSegs) { site_segs_ = aSiteSegs; } - void setSiteMask(const site_mask_t& aSiteMask) { site_mask_ = aSiteMask; } - void setSiteRMMask(const site_mask_t& aSiteMask) { site_rm_mask_ = aSiteMask; } - - // Getters - int16_t endcap() const { return endcap_; } - int16_t sector() const { return sector_; } - int16_t bx() const { return bx_; } - bool unconstrained() const { return unconstrained_; } - bool valid() const { return valid_; } - - int16_t modelPtAddress() const { return model_pt_address_; } - int16_t modelRelsAddress() const { return model_rels_address_; } - int16_t modelDxyAddress() const { return model_dxy_address_; } - int16_t modelPattern() const { return model_pattern_; } - int16_t modelQual() const { return model_qual_; } - int32_t modelPhi() const { return model_phi_; } - int32_t modelEta() const { return model_eta_; } - const features_t& modelFeatures() const { return model_features_; } - - int16_t emtfQ() const { return emtf_q_; } - int32_t emtfPt() const { return emtf_pt_; } - int32_t emtfRels() const { return emtf_rels_; } - int32_t emtfD0() const { return emtf_d0_; } - int32_t emtfZ0() const { return emtf_z0_; } - int32_t emtfBeta() const { return emtf_beta_; } - int16_t emtfModeV1() const { return emtf_mode_v1_; } - int16_t emtfModeV2() const { return emtf_mode_v2_; } - - const site_hits_t& siteHits() const { return site_hits_; } - const site_segs_t& siteSegs() const { return site_segs_; } - const site_mask_t& siteMask() const { return site_mask_; } - const site_mask_t& siteRMMask() const { return site_rm_mask_; } - - private: - int16_t endcap_; - int16_t sector_; - int16_t bx_; - bool unconstrained_; - bool valid_; - - int16_t model_pt_address_; - int16_t model_rels_address_; - int16_t model_dxy_address_; - int16_t model_pattern_; - int16_t model_qual_; - int32_t model_phi_; - int32_t model_eta_; - features_t model_features_; - - int16_t emtf_q_; - int32_t emtf_pt_; - int32_t emtf_rels_; - int32_t emtf_d0_; - int32_t emtf_z0_; - int32_t emtf_beta_; - int16_t emtf_mode_v1_; - int16_t emtf_mode_v2_; - - site_hits_t site_hits_; - site_segs_t site_segs_; - site_mask_t site_mask_; - site_mask_t site_rm_mask_; - }; - - typedef std::vector EMTFTrackCollection; + class EMTFTrack { + public: + typedef std::vector features_t; + typedef std::vector site_hits_t; + typedef std::vector site_segs_t; + typedef std::vector site_mask_t; + + EMTFTrack() + : endcap_(0), + sector_(0), + bx_(0), + unconstrained_(false), + valid_(false), + model_pt_address_(0), + model_dxy_address_(0), + model_pattern_(0), + model_qual_(0), + model_phi_(0), + model_eta_(0), + model_features_{}, + emtf_q_(0), + emtf_pt_(0), + emtf_d0_(0), + emtf_z0_(0), + emtf_beta_(0), + emtf_mode_v1_(0), + emtf_mode_v2_(0), + site_hits_{}, + site_segs_{}, + site_mask_{}, + site_rm_mask_{} { + // Do Nothing + } + + ~EMTFTrack() { + // Do Nothing + } + + // Setters + void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } + void setSector(int16_t aSector) { sector_ = aSector; } + void setBx(int16_t aBx) { bx_ = aBx; } + void setUnconstrained(bool aUnconstrained) { unconstrained_ = aUnconstrained; } + void setValid(bool aValid) { valid_ = aValid; } + + void setModelPtAddress(int16_t aAddress) { model_pt_address_ = aAddress; } + void setModelRelsAddress(int16_t aAddress) { model_rels_address_ = aAddress; } + void setModelDxyAddress(int16_t aAddress) { model_dxy_address_ = aAddress; } + void setModelPattern(int16_t aModelPattern) { model_pattern_ = aModelPattern; } + void setModelQual(int16_t aModelQual) { model_qual_ = aModelQual; } + void setModelPhi(int32_t aModelPhi) { model_phi_ = aModelPhi; } + void setModelEta(int32_t aModelEta) { model_eta_ = aModelEta; } + void setModelFeatures(const features_t& aModelFeatures) { model_features_ = aModelFeatures; } + + void setEmtfQ(int16_t aEmtfQ) { emtf_q_ = aEmtfQ; } + void setEmtfPt(int32_t aEmtfPt) { emtf_pt_ = aEmtfPt; } + void setEmtfRels(int32_t aEmtfRels) { emtf_rels_ = aEmtfRels; } + void setEmtfD0(int32_t aEmtfD0) { emtf_d0_ = aEmtfD0; } + void setEmtfZ0(int32_t aEmtfZ0) { emtf_z0_ = aEmtfZ0; } + void setEmtfBeta(int32_t aEmtfBeta) { emtf_beta_ = aEmtfBeta; } + void setEmtfModeV1(int16_t aEmtfModeV1) { emtf_mode_v1_ = aEmtfModeV1; } + void setEmtfModeV2(int16_t aEmtfModeV2) { emtf_mode_v2_ = aEmtfModeV2; } + + void setSiteHits(const site_hits_t& aSiteHits) { site_hits_ = aSiteHits; } + void setSiteSegs(const site_segs_t& aSiteSegs) { site_segs_ = aSiteSegs; } + void setSiteMask(const site_mask_t& aSiteMask) { site_mask_ = aSiteMask; } + void setSiteRMMask(const site_mask_t& aSiteMask) { site_rm_mask_ = aSiteMask; } + + // Getters + int16_t endcap() const { return endcap_; } + int16_t sector() const { return sector_; } + int16_t bx() const { return bx_; } + bool unconstrained() const { return unconstrained_; } + bool valid() const { return valid_; } + + int16_t modelPtAddress() const { return model_pt_address_; } + int16_t modelRelsAddress() const { return model_rels_address_; } + int16_t modelDxyAddress() const { return model_dxy_address_; } + int16_t modelPattern() const { return model_pattern_; } + int16_t modelQual() const { return model_qual_; } + int32_t modelPhi() const { return model_phi_; } + int32_t modelEta() const { return model_eta_; } + const features_t& modelFeatures() const { return model_features_; } + + int16_t emtfQ() const { return emtf_q_; } + int32_t emtfPt() const { return emtf_pt_; } + int32_t emtfRels() const { return emtf_rels_; } + int32_t emtfD0() const { return emtf_d0_; } + int32_t emtfZ0() const { return emtf_z0_; } + int32_t emtfBeta() const { return emtf_beta_; } + int16_t emtfModeV1() const { return emtf_mode_v1_; } + int16_t emtfModeV2() const { return emtf_mode_v2_; } + + const site_hits_t& siteHits() const { return site_hits_; } + const site_segs_t& siteSegs() const { return site_segs_; } + const site_mask_t& siteMask() const { return site_mask_; } + const site_mask_t& siteRMMask() const { return site_rm_mask_; } + + private: + int16_t endcap_; + int16_t sector_; + int16_t bx_; + bool unconstrained_; + bool valid_; + + int16_t model_pt_address_; + int16_t model_rels_address_; + int16_t model_dxy_address_; + int16_t model_pattern_; + int16_t model_qual_; + int32_t model_phi_; + int32_t model_eta_; + features_t model_features_; + + int16_t emtf_q_; + int32_t emtf_pt_; + int32_t emtf_rels_; + int32_t emtf_d0_; + int32_t emtf_z0_; + int32_t emtf_beta_; + int16_t emtf_mode_v1_; + int16_t emtf_mode_v2_; + + site_hits_t site_hits_; + site_segs_t site_segs_; + site_mask_t site_mask_; + site_mask_t site_rm_mask_; + }; + + typedef std::vector EMTFTrackCollection; } // namespace l1t::phase2 diff --git a/DataFormats/L1TMuonPhase2/src/MuonStub.cc b/DataFormats/L1TMuonPhase2/src/MuonStub.cc index 68bd8fe98775f..779da226920b6 100644 --- a/DataFormats/L1TMuonPhase2/src/MuonStub.cc +++ b/DataFormats/L1TMuonPhase2/src/MuonStub.cc @@ -87,4 +87,3 @@ void MuonStub::print() const { << " quality=" << quality_ << " eta1=" << eta1_ << " eta2=" << eta2_ << " etaQuality=" << etaQuality_ << " type=" << type_; } - diff --git a/DataFormats/L1TMuonPhase2/src/SAMuon.cc b/DataFormats/L1TMuonPhase2/src/SAMuon.cc index 7f91c3e7effd4..b759b84ce1c45 100644 --- a/DataFormats/L1TMuonPhase2/src/SAMuon.cc +++ b/DataFormats/L1TMuonPhase2/src/SAMuon.cc @@ -16,4 +16,3 @@ void SAMuon::print() const { << " z0=" << hwZ0_ << " d0=" << hwD0_ << " isolation=" << hwIso() << " beta=" << hwBeta_ << " quality=" << hwQual(); } - diff --git a/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc b/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc index 93eea9887ba5d..916eb797b8e8e 100644 --- a/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc +++ b/DataFormats/L1TMuonPhase2/src/TrackerMuon.cc @@ -25,4 +25,3 @@ void TrackerMuon::print() const { << " z0=" << hwZ0_ << " d0=" << hwD0_ << " isolation=" << hwIso() << " beta=" << hwBeta_ << " quality=" << hwQual(); } - diff --git a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc index 8ebdb857d5d61..4bd700fb7f177 100644 --- a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc +++ b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc @@ -135,8 +135,8 @@ ME0TriggerDigi GE0TriggerPseudoBuilder::segmentConversion(const GEMSegment segme << strippitch_rad * dphiresolution_ << " bend " << bend << " \n" << "\t global point eta " << gp.eta() << " phi " << gp.phi() << " trigger digi eta " << gp_digi.eta() << " phi " << gp_digi.phi() << " \n" - // << "\t time (ns, float) " << time << " BX " << BX << " \n" - ; + // << "\t time (ns, float) " << time << " BX " << BX << " \n" + ; ME0TriggerDigi result = ME0TriggerDigi(chamberid, quality, phiposition, partition, idphi, bend, BX); result.setStrip(istrip); diff --git a/L1Trigger/L1TMuon/src/GeometryTranslator.cc b/L1Trigger/L1TMuon/src/GeometryTranslator.cc index 6901cc28223fd..657a002b28222 100644 --- a/L1Trigger/L1TMuon/src/GeometryTranslator.cc +++ b/L1Trigger/L1TMuon/src/GeometryTranslator.cc @@ -151,11 +151,11 @@ void GeometryTranslator::checkAndUpdateGeometry(const edm::EventSetup& es) { // _____________________________________________________________________________ // ME0 GlobalPoint GeometryTranslator::getME0SpecificPoint(const TriggerPrimitive& tp) const { - if (tp.detId().subdetId() == MuonSubdetId::GEM) { // GE0 + if (tp.detId().subdetId() == MuonSubdetId::GEM) { // GE0 const GEMDetId id(tp.detId()); const GEMSuperChamber* chamber = _geogem->superChamber(id); const GEMChamber* keylayer = chamber->chamber(3); // GEM key layer is layer 3 - int partition = tp.getME0Data().partition; // 'partition' is in half-roll unit + int partition = tp.getME0Data().partition; // 'partition' is in half-roll unit int iroll = (partition >> 1) + 1; const GEMEtaPartition* roll = keylayer->etaPartition(iroll); assert(roll != nullptr); // failed to get GEM roll @@ -167,7 +167,7 @@ GlobalPoint GeometryTranslator::getME0SpecificPoint(const TriggerPrimitive& tp) const LocalPoint& lp = roll->centreOfStrip(centreOfStrip); const GlobalPoint& gp = roll->surface().toGlobal(lp); return gp; - } else { // ME0 + } else { // ME0 const ME0DetId id(tp.detId()); const ME0Chamber* chamber = _geome0->chamber(id); const ME0Layer* keylayer = chamber->layer(3); // ME0 key layer is layer 3 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h index 79ec8a7c559ee..8078ae72064e9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h @@ -10,20 +10,18 @@ namespace emtf::phase2::algo { - class DuplicateRemovalLayer { - public: - DuplicateRemovalLayer(const EMTFContext&); + class DuplicateRemovalLayer { + public: + DuplicateRemovalLayer(const EMTFContext&); - ~DuplicateRemovalLayer(); + ~DuplicateRemovalLayer(); - void apply( - std::vector& - ) const; + void apply(std::vector&) const; - private: - const EMTFContext& context_; - }; + private: + const EMTFContext& context_; + }; -} +} // namespace emtf::phase2::algo #endif // L1Trigger_L1TMuonEndCapPhase2_DuplicateRemovalLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h index 95c1844418209..2663ffccfd2d6 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h @@ -6,22 +6,18 @@ namespace emtf::phase2::algo { - class HitmapLayer { + class HitmapLayer { + public: + HitmapLayer(const EMTFContext&); - public: - HitmapLayer(const EMTFContext&); + ~HitmapLayer(); - ~HitmapLayer(); + void apply(const segment_collection_t&, std::vector&) const; - void apply( - const segment_collection_t&, - std::vector& - ) const; + private: + const EMTFContext& context_; + }; - private: - const EMTFContext& context_; - }; - -} +} // namespace emtf::phase2::algo #endif // L1Trigger_L1TMuonEndCapPhase2_HitmapLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h index d28163e0fc631..fcfce93e132c8 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h @@ -10,40 +10,40 @@ namespace emtf::phase2::algo { - class OutputLayer { - public: - OutputLayer(const EMTFContext&); + class OutputLayer { + public: + OutputLayer(const EMTFContext&); - ~OutputLayer(); + ~OutputLayer(); - void apply( - const int&, const int&, const int&, - const std::map&, - const std::vector&, - const bool&, - EMTFTrackCollection& - ) const; + void apply(const int&, + const int&, + const int&, + const std::map&, + const std::vector&, + const bool&, + EMTFTrackCollection&) const; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - std::array prompt_pt_calibration_lut_; - std::array disp_pt_calibration_lut_; - std::array disp_dxy_calibration_lut_; + std::array prompt_pt_calibration_lut_; + std::array disp_pt_calibration_lut_; + std::array disp_dxy_calibration_lut_; - int find_prompt_emtf_pt(const int&) const; + int find_prompt_emtf_pt(const int&) const; - int find_disp_emtf_pt(const int&) const; + int find_disp_emtf_pt(const int&) const; - int find_emtf_dxy(const int&) const; + int find_emtf_dxy(const int&) const; - int find_emtf_pt_no_calib(const int&) const; + int find_emtf_pt_no_calib(const int&) const; - int find_emtf_mode_v1(const track_t::site_mask_t&) const; + int find_emtf_mode_v1(const track_t::site_mask_t&) const; - int find_emtf_mode_v2(const track_t::site_mask_t&) const; - }; + int find_emtf_mode_v2(const track_t::site_mask_t&) const; + }; -} +} // namespace emtf::phase2::algo #endif // L1Trigger_L1TMuonEndCapPhase2_OutputLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h index d83ec794e3ec6..65116ad0d5f2e 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h @@ -10,21 +10,18 @@ namespace emtf::phase2::algo { - class ParameterAssignmentLayer { - public: - ParameterAssignmentLayer(const EMTFContext&); + class ParameterAssignmentLayer { + public: + ParameterAssignmentLayer(const EMTFContext&); - ~ParameterAssignmentLayer(); + ~ParameterAssignmentLayer(); - void apply( - const bool&, - std::vector& - ) const; + void apply(const bool&, std::vector&) const; - private: - const EMTFContext& context_; - }; + private: + const EMTFContext& context_; + }; -} +} // namespace emtf::phase2::algo #endif // L1Trigger_L1TMuonEndCapPhase2_ParameterAssignment_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h index 864a5477ce21a..fb2663f8d1adb 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h @@ -10,23 +10,18 @@ namespace emtf::phase2::algo { - class PatternMatchingLayer { + class PatternMatchingLayer { + public: + PatternMatchingLayer(const EMTFContext&); - public: - PatternMatchingLayer(const EMTFContext&); + ~PatternMatchingLayer(); - ~PatternMatchingLayer(); + void apply(const std::vector&, const bool&, std::vector&) const; - void apply( - const std::vector&, - const bool&, - std::vector& - ) const; + private: + const EMTFContext& context_; + }; - private: - const EMTFContext& context_; - }; - -} +} // namespace emtf::phase2::algo #endif // L1Trigger_L1TMuonEndCapPhase2_PatternMatchingLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h index 3ce2ac4623cf8..358f6ef9321d9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h @@ -10,21 +10,18 @@ namespace emtf::phase2::algo { - class RoadSortingLayer { - public: - RoadSortingLayer(const EMTFContext&); - - ~RoadSortingLayer(); - - void apply( - const int&, - const std::vector&, - std::vector& - ) const; - private: - const EMTFContext& context_; - }; - -} + class RoadSortingLayer { + public: + RoadSortingLayer(const EMTFContext&); + + ~RoadSortingLayer(); + + void apply(const int&, const std::vector&, std::vector&) const; + + private: + const EMTFContext& context_; + }; + +} // namespace emtf::phase2::algo #endif // L1Trigger_L1TMuonEndCapPhase2_RoadSortingLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h index 3f8349957df08..57ad3e82e8646 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h @@ -10,38 +10,25 @@ namespace emtf::phase2::algo { - class TrackBuildingLayer { - // Static - private: - static seg_theta_t calc_theta_median( - std::vector - ); - - // Members - public: - TrackBuildingLayer(const EMTFContext&); - - ~TrackBuildingLayer(); - - void apply( - const segment_collection_t&, - const std::vector&, - const bool&, - std::vector& - ) const; - - private: - const EMTFContext& context_; - - void attach_segments( - const segment_collection_t&, - const road_t&, - const bool&, - track_t& - ) const; - - }; - -} + class TrackBuildingLayer { + // Static + private: + static seg_theta_t calc_theta_median(std::vector); + + // Members + public: + TrackBuildingLayer(const EMTFContext&); + + ~TrackBuildingLayer(); + + void apply(const segment_collection_t&, const std::vector&, const bool&, std::vector&) const; + + private: + const EMTFContext& context_; + + void attach_segments(const segment_collection_t&, const road_t&, const bool&, track_t&) const; + }; + +} // namespace emtf::phase2::algo #endif // L1Trigger_L1TMuonEndCapPhase2_TrackBuildingLayer_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h index 4b64e7389e22c..25dfcf09f6906 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h @@ -7,23 +7,19 @@ namespace emtf::phase2 { - class CSCTPCollector: public TPCollector { - public: - explicit CSCTPCollector( - const EMTFContext&, - edm::ConsumesCollector&); + class CSCTPCollector : public TPCollector { + public: + explicit CSCTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~CSCTPCollector(); + ~CSCTPCollector(); - void collect( - const edm::Event&, - BXTPCMap&) const final; + void collect(const edm::Event&, BXTPCMap&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - const edm::EDGetToken input_token_; - }; + const edm::EDGetToken input_token_; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h index 4fb31fa74c0da..aa97ef31ac013 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h @@ -10,23 +10,19 @@ namespace emtf::phase2 { - class CSCTPConverter: public TPConverter { - public: - explicit CSCTPConverter(const EMTFContext&, - const int&, const int&); + class CSCTPConverter : public TPConverter { + public: + explicit CSCTPConverter(const EMTFContext&, const int&, const int&); - ~CSCTPConverter(); + ~CSCTPConverter(); - void convert( - const TriggerPrimitive&, - const TPInfo&, - EMTFHit&) const final; + void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - int endcap_, sector_; - }; // namespace emtf::phase2 -} + int endcap_, sector_; + }; // namespace emtf::phase2 +} // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_CSCTPConverter_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h index b6b6ad8d24e8e..afb27d44cc8bc 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h @@ -12,34 +12,23 @@ namespace emtf::phase2 { - class CSCTPSelector: public TPSelector { - public: - explicit CSCTPSelector( - const EMTFContext&, - const int&, const int& - ); - - ~CSCTPSelector(); - - void select( - const TriggerPrimitive&, - TPInfo, - ILinkTPCMap& - ) const final; - - private: - const EMTFContext& context_; - - int endcap_, sector_; - - int get_input_link(const TriggerPrimitive&, TPInfo&) const; - - int calculate_input_link( - const int&, const int&, - const int&, const int&, - const TPSelection& - ) const; - }; + class CSCTPSelector : public TPSelector { + public: + explicit CSCTPSelector(const EMTFContext&, const int&, const int&); + + ~CSCTPSelector(); + + void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + + int get_input_link(const TriggerPrimitive&, TPInfo&) const; + + int calculate_input_link(const int&, const int&, const int&, const int&, const TPSelection&) const; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h index 49b035172f177..862db92ab4b3c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h @@ -7,25 +7,20 @@ namespace emtf::phase2 { - class GE0TPCollector: public TPCollector { - public: - explicit GE0TPCollector( - const EMTFContext&, - edm::ConsumesCollector&); + class GE0TPCollector : public TPCollector { + public: + explicit GE0TPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~GE0TPCollector(); + ~GE0TPCollector(); - void collect( - const edm::Event&, - BXTPCMap&) const final; + void collect(const edm::Event&, BXTPCMap&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - const edm::EDGetToken input_token_; - }; + const edm::EDGetToken input_token_; + }; } // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_GE0TPCollector_h - diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h index c57c7b386048b..1e392186e4253 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h @@ -8,25 +8,20 @@ namespace emtf::phase2 { - class GE0TPConverter: public TPConverter { - public: - explicit GE0TPConverter(const EMTFContext&, - const int&, const int&); + class GE0TPConverter : public TPConverter { + public: + explicit GE0TPConverter(const EMTFContext&, const int&, const int&); - ~GE0TPConverter(); + ~GE0TPConverter(); - void convert( - const TriggerPrimitive&, - const TPInfo&, - EMTFHit&) const final; + void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - int endcap_, sector_; - }; + int endcap_, sector_; + }; } // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_GE0TPConverter_h - diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h index a8e6c0957f0fe..cd2026907fb9b 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h @@ -11,35 +11,24 @@ namespace emtf::phase2 { - class GE0TPSelector: public TPSelector { - public: - explicit GE0TPSelector( - const EMTFContext&, - const int&, const int& - ); + class GE0TPSelector : public TPSelector { + public: + explicit GE0TPSelector(const EMTFContext&, const int&, const int&); - ~GE0TPSelector(); + ~GE0TPSelector(); - void select( - const TriggerPrimitive&, - TPInfo, - ILinkTPCMap& - ) const final; + void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - int endcap_, sector_; + int endcap_, sector_; - int get_input_link(const TriggerPrimitive&, TPInfo&) const; + int get_input_link(const TriggerPrimitive&, TPInfo&) const; - int calculate_input_link( - const int&, const int&, - const TPSelection& - ) const; - }; + int calculate_input_link(const int&, const int&, const TPSelection&) const; + }; } // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_GE0TPSelector_h - diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h index e5363d5b70d04..802e0401bb932 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h @@ -7,23 +7,19 @@ namespace emtf::phase2 { - class GEMTPCollector: public TPCollector { - public: - explicit GEMTPCollector( - const EMTFContext&, - edm::ConsumesCollector&); + class GEMTPCollector : public TPCollector { + public: + explicit GEMTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~GEMTPCollector(); + ~GEMTPCollector(); - void collect( - const edm::Event&, - BXTPCMap&) const final; + void collect(const edm::Event&, BXTPCMap&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - const edm::EDGetToken input_token_; - }; + const edm::EDGetToken input_token_; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h index bb255c9075e6d..27f3ef0c7b953 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h @@ -8,23 +8,19 @@ namespace emtf::phase2 { - class GEMTPConverter: public TPConverter { - public: - explicit GEMTPConverter(const EMTFContext&, - const int&, const int&); + class GEMTPConverter : public TPConverter { + public: + explicit GEMTPConverter(const EMTFContext&, const int&, const int&); - ~GEMTPConverter(); + ~GEMTPConverter(); - void convert( - const TriggerPrimitive&, - const TPInfo&, - EMTFHit&) const final; + void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - int endcap_, sector_; - }; + int endcap_, sector_; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h index b6f038eda20a1..cca5aff145004 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h @@ -11,34 +11,23 @@ namespace emtf::phase2 { - class GEMTPSelector: public TPSelector { - public: - explicit GEMTPSelector( - const EMTFContext&, - const int&, const int& - ); - - ~GEMTPSelector(); - - void select( - const TriggerPrimitive&, - TPInfo, - ILinkTPCMap& - ) const final; - - private: - const EMTFContext& context_; - - int endcap_, sector_; - - int get_input_link(const TriggerPrimitive&, TPInfo&) const; - - int calculate_input_link( - const int&, const int&, - const int&, const int&, - const TPSelection& - ) const; - }; + class GEMTPSelector : public TPSelector { + public: + explicit GEMTPSelector(const EMTFContext&, const int&, const int&); + + ~GEMTPSelector(); + + void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + + int get_input_link(const TriggerPrimitive&, TPInfo&) const; + + int calculate_input_link(const int&, const int&, const int&, const int&, const TPSelection&) const; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h index 2603419eda751..75008ada2499c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h @@ -7,23 +7,19 @@ namespace emtf::phase2 { - class ME0TPCollector: public TPCollector { - public: - explicit ME0TPCollector( - const EMTFContext&, - edm::ConsumesCollector&); + class ME0TPCollector : public TPCollector { + public: + explicit ME0TPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~ME0TPCollector(); + ~ME0TPCollector(); - void collect( - const edm::Event&, - BXTPCMap&) const final; + void collect(const edm::Event&, BXTPCMap&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - const edm::EDGetToken input_token_; - }; + const edm::EDGetToken input_token_; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h index 7ef59311d3f59..e8bdb4fc89e49 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h @@ -8,23 +8,19 @@ namespace emtf::phase2 { - class ME0TPConverter: public TPConverter { - public: - explicit ME0TPConverter(const EMTFContext&, - const int&, const int&); + class ME0TPConverter : public TPConverter { + public: + explicit ME0TPConverter(const EMTFContext&, const int&, const int&); - ~ME0TPConverter(); + ~ME0TPConverter(); - void convert( - const TriggerPrimitive&, - const TPInfo&, - EMTFHit&) const final; + void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - int endcap_, sector_; - }; + int endcap_, sector_; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h index 764f81d7f75fe..5001bd30f0708 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h @@ -11,33 +11,23 @@ namespace emtf::phase2 { - class ME0TPSelector: public TPSelector { - public: - explicit ME0TPSelector( - const EMTFContext&, - const int&, const int& - ); + class ME0TPSelector : public TPSelector { + public: + explicit ME0TPSelector(const EMTFContext&, const int&, const int&); - ~ME0TPSelector(); + ~ME0TPSelector(); - void select( - const TriggerPrimitive&, - TPInfo, - ILinkTPCMap& - ) const final; + void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - int endcap_, sector_; + int endcap_, sector_; - int get_input_link(const TriggerPrimitive&, TPInfo&) const; + int get_input_link(const TriggerPrimitive&, TPInfo&) const; - int calculate_input_link( - const int&, const int&, - const TPSelection& - ) const; - }; + int calculate_input_link(const int&, const int&, const TPSelection&) const; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h index 2288d360cd63e..ccb9dea502279 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h @@ -7,23 +7,19 @@ namespace emtf::phase2 { - class RPCTPCollector: public TPCollector { - public: - explicit RPCTPCollector( - const EMTFContext&, - edm::ConsumesCollector&); + class RPCTPCollector : public TPCollector { + public: + explicit RPCTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~RPCTPCollector(); + ~RPCTPCollector(); - void collect( - const edm::Event&, - BXTPCMap&) const final; + void collect(const edm::Event&, BXTPCMap&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - const edm::EDGetToken input_token_; - }; + const edm::EDGetToken input_token_; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h index 3f9060fd10bb4..c23b059752f36 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h @@ -8,23 +8,19 @@ namespace emtf::phase2 { - class RPCTPConverter: public TPConverter { - public: - explicit RPCTPConverter(const EMTFContext&, - const int&, const int&); + class RPCTPConverter : public TPConverter { + public: + explicit RPCTPConverter(const EMTFContext&, const int&, const int&); - ~RPCTPConverter(); + ~RPCTPConverter(); - void convert( - const TriggerPrimitive&, - const TPInfo&, - EMTFHit&) const final; + void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; - private: - const EMTFContext& context_; + private: + const EMTFContext& context_; - int endcap_, sector_; - }; + int endcap_, sector_; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h index 33c2cbf640296..18d4e1d3082b9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h @@ -13,34 +13,23 @@ namespace emtf::phase2 { - class RPCTPSelector: public TPSelector { - public: - explicit RPCTPSelector( - const EMTFContext&, - const int&, const int& - ); - - ~RPCTPSelector(); - - void select( - const TriggerPrimitive&, - TPInfo, - ILinkTPCMap& - ) const final; - - private: - const EMTFContext& context_; - - int endcap_, sector_; - - int get_input_link(const TriggerPrimitive&, TPInfo&) const; - - int calculate_input_link( - const int&, const int&, - const int&, const int&, - const TPSelection& - ) const; - }; + class RPCTPSelector : public TPSelector { + public: + explicit RPCTPSelector(const EMTFContext&, const int&, const int&); + + ~RPCTPSelector(); + + void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; + + private: + const EMTFContext& context_; + + int endcap_, sector_; + + int get_input_link(const TriggerPrimitive&, TPInfo&) const; + + int calculate_input_link(const int&, const int&, const int&, const int&, const TPSelection&) const; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h index 580484143ab86..691dd9c0f100c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h @@ -32,65 +32,65 @@ class ME0Geometry; namespace emtf::phase2 { - struct DTTag { - typedef L1MuDTChambPhDigi digi_type; - typedef L1MuDTChambPhContainer collection_type; - typedef L1MuDTChambThDigi theta_digi_type; - typedef L1MuDTChambThContainer theta_collection_type; - }; + struct DTTag { + typedef L1MuDTChambPhDigi digi_type; + typedef L1MuDTChambPhContainer collection_type; + typedef L1MuDTChambThDigi theta_digi_type; + typedef L1MuDTChambThContainer theta_collection_type; + }; - struct CSCTag { - typedef CSCDetId detid_type; - typedef CSCCorrelatedLCTDigi digi_type; - typedef CSCCorrelatedLCTDigiCollection collection_type; - typedef CSCComparatorDigi comparator_digi_type; - typedef CSCComparatorDigiCollection comparator_collection_type; - typedef CSCGeometry detgeom_type; - }; + struct CSCTag { + typedef CSCDetId detid_type; + typedef CSCCorrelatedLCTDigi digi_type; + typedef CSCCorrelatedLCTDigiCollection collection_type; + typedef CSCComparatorDigi comparator_digi_type; + typedef CSCComparatorDigiCollection comparator_collection_type; + typedef CSCGeometry detgeom_type; + }; - struct RPCTag { - typedef RPCDetId detid_type; - typedef RPCDigi digi_type; - typedef RPCDigiCollection collection_type; - typedef RPCRecHit rechit_type; - typedef RPCRecHitCollection rechit_collection_type; - typedef RPCGeometry detgeom_type; - }; + struct RPCTag { + typedef RPCDetId detid_type; + typedef RPCDigi digi_type; + typedef RPCDigiCollection collection_type; + typedef RPCRecHit rechit_type; + typedef RPCRecHitCollection rechit_collection_type; + typedef RPCGeometry detgeom_type; + }; - struct IRPCTag { - typedef RPCDetId detid_type; - typedef RPCDigi digi_type; - typedef RPCDigiCollection collection_type; - typedef RPCRecHit rechit_type; - typedef RPCRecHitCollection rechit_collection_type; - typedef RPCGeometry detgeom_type; - }; + struct IRPCTag { + typedef RPCDetId detid_type; + typedef RPCDigi digi_type; + typedef RPCDigiCollection collection_type; + typedef RPCRecHit rechit_type; + typedef RPCRecHitCollection rechit_collection_type; + typedef RPCGeometry detgeom_type; + }; - struct CPPFTag { - typedef l1t::CPPFDigi digi_type; - typedef l1t::CPPFDigiCollection collection_type; - }; + struct CPPFTag { + typedef l1t::CPPFDigi digi_type; + typedef l1t::CPPFDigiCollection collection_type; + }; - struct GEMTag { - typedef GEMDetId detid_type; - typedef GEMPadDigiCluster digi_type; - typedef GEMPadDigiClusterCollection collection_type; - typedef GEMGeometry detgeom_type; - }; + struct GEMTag { + typedef GEMDetId detid_type; + typedef GEMPadDigiCluster digi_type; + typedef GEMPadDigiClusterCollection collection_type; + typedef GEMGeometry detgeom_type; + }; - struct ME0Tag { - typedef ME0DetId detid_type; - typedef ME0TriggerDigi digi_type; - typedef ME0TriggerDigiCollection collection_type; - typedef ME0Geometry detgeom_type; - }; + struct ME0Tag { + typedef ME0DetId detid_type; + typedef ME0TriggerDigi digi_type; + typedef ME0TriggerDigiCollection collection_type; + typedef ME0Geometry detgeom_type; + }; - struct GE0Tag { - typedef GEMDetId detid_type; - typedef ME0TriggerDigi digi_type; - typedef GE0TriggerDigiCollection collection_type; - typedef GEMGeometry detgeom_type; - }; + struct GE0Tag { + typedef GEMDetId detid_type; + typedef ME0TriggerDigi digi_type; + typedef GE0TriggerDigiCollection collection_type; + typedef GEMGeometry detgeom_type; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h index 4da8ce0513997..e10e60df79a76 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPCollectors.h @@ -6,17 +6,15 @@ namespace emtf::phase2 { - class TPCollector { - public: - TPCollector() = default; + class TPCollector { + public: + TPCollector() = default; - virtual ~TPCollector() = default; + virtual ~TPCollector() = default; - // Collects all the trigger primitives in the event - virtual void collect( - const edm::Event&, - BXTPCMap&) const = 0; - }; + // Collects all the trigger primitives in the event + virtual void collect(const edm::Event&, BXTPCMap&) const = 0; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h index 500473bee38fe..d5a67d7b8c97d 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPConverters.h @@ -7,17 +7,14 @@ namespace emtf::phase2 { - class TPConverter { - public: - TPConverter() = default; + class TPConverter { + public: + TPConverter() = default; - virtual ~TPConverter() = default; + virtual ~TPConverter() = default; - virtual void convert( - const TriggerPrimitive&, - const TPInfo&, - EMTFHit&) const = 0; - }; + virtual void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const = 0; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h index 06ce817e11b52..488738af6231e 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h @@ -6,18 +6,14 @@ namespace emtf::phase2 { - class TPSelector { - public: - TPSelector() = default; + class TPSelector { + public: + TPSelector() = default; - virtual ~TPSelector() = default; + virtual ~TPSelector() = default; - virtual void select( - const TriggerPrimitive& tp, - TPInfo tp_info, - ILinkTPCMap& - ) const = 0; - }; + virtual void select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap&) const = 0; + }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h index 013b74d2e451d..e7c0d2ff20534 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h @@ -8,60 +8,59 @@ namespace emtf::phase2 { - enum TPSelection {kNative, kNeighbor, kNone}; + enum TPSelection { kNative, kNeighbor, kNone }; - struct TPInfo { - // Id - int hit_id = -1; - int segment_id = -1; + struct TPInfo { + // Id + int hit_id = -1; + int segment_id = -1; - // Selection - int bx = -999; - int ilink = -1; - TPSelection selection = kNone; + // Selection + int bx = -999; + int ilink = -1; + TPSelection selection = kNone; - // Flags - bool flag_substitute = false; + // Flags + bool flag_substitute = false; - // Detector - int endcap = 0; - int endcap_pm = 0; - int sector = 0; - int subsector = 0; - int station = 0; - int ring = 0; - int roll = 0; - int layer = 0; - int chamber = 0; + // Detector + int endcap = 0; + int endcap_pm = 0; + int sector = 0; + int subsector = 0; + int station = 0; + int ring = 0; + int roll = 0; + int layer = 0; + int chamber = 0; - // CSC - int csc_id = -1; - csc::Facing csc_facing = csc::Facing::kNone; - int csc_first_wire = -1; - int csc_second_wire = -1; + // CSC + int csc_id = -1; + csc::Facing csc_facing = csc::Facing::kNone; + int csc_first_wire = -1; + int csc_second_wire = -1; - // RPC - rpc::Type rpc_type = rpc::kNone; - }; + // RPC + rpc::Type rpc_type = rpc::kNone; + }; - class TPEntry { + class TPEntry { + public: + TPEntry(const TPEntry&); + TPEntry(const TriggerPrimitive&); + TPEntry(const TriggerPrimitive&, const TPInfo&); + TPEntry(const CSCDetId&, const CSCCorrelatedLCTDigi&); + TPEntry(const RPCDetId&, const RPCRecHit&); + TPEntry(const GEMDetId&, const GEMPadDigiCluster&); + TPEntry(const ME0DetId&, const ME0TriggerDigi&); + TPEntry(const GEMDetId&, const ME0TriggerDigi&); - public: - TPEntry(const TPEntry&); - TPEntry(const TriggerPrimitive&); - TPEntry(const TriggerPrimitive&, const TPInfo&); - TPEntry(const CSCDetId&, const CSCCorrelatedLCTDigi&); - TPEntry(const RPCDetId&, const RPCRecHit&); - TPEntry(const GEMDetId&, const GEMPadDigiCluster&); - TPEntry(const ME0DetId&, const ME0TriggerDigi&); - TPEntry(const GEMDetId&, const ME0TriggerDigi&); + ~TPEntry(); - ~TPEntry(); + TriggerPrimitive tp_; + TPInfo info_; + }; - TriggerPrimitive tp_; - TPInfo info_; - }; - -} +} // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_TPrimitives_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h index c778ca1fd4cea..f2b2584031b47 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h @@ -11,28 +11,26 @@ namespace emtf::phase2::data { - class ActivationLut { - public: - ActivationLut(); + class ActivationLut { + public: + ActivationLut(); - ~ActivationLut(); + ~ActivationLut(); - void update( - const edm::Event&, - const edm::EventSetup&); + void update(const edm::Event&, const edm::EventSetup&); - const trk_pt_t& lookup_prompt_pt(const trk_nn_address_t&) const; - const trk_pt_t& lookup_disp_pt(const trk_nn_address_t&) const; - const trk_rels_t& lookup_rels(const trk_nn_address_t&) const; - const trk_dxy_t& lookup_dxy(const trk_nn_address_t&) const; + const trk_pt_t& lookup_prompt_pt(const trk_nn_address_t&) const; + const trk_pt_t& lookup_disp_pt(const trk_nn_address_t&) const; + const trk_rels_t& lookup_rels(const trk_nn_address_t&) const; + const trk_dxy_t& lookup_dxy(const trk_nn_address_t&) const; - private: - std::vector prompt_pt_lut_; - std::vector disp_pt_lut_; - std::vector rels_lut_; - std::vector dxy_lut_; - }; + private: + std::vector prompt_pt_lut_; + std::vector disp_pt_lut_; + std::vector rels_lut_; + std::vector dxy_lut_; + }; -} // namespace emtf::phase2 +} // namespace emtf::phase2::data #endif // L1Trigger_L1TMuonEndCapPhase2_ActivationLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h index 004c953a98bc0..43fd857970782 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/HostLut.h @@ -9,29 +9,27 @@ namespace emtf::phase2::data { - class HostLut { - // Static - public: - static const int kInvalid; + class HostLut { + // Static + public: + static const int kInvalid; - // Member - public: - HostLut(); + // Member + public: + HostLut(); - ~HostLut(); + ~HostLut(); - void update( - const edm::Event&, - const edm::EventSetup&); + void update(const edm::Event&, const edm::EventSetup&); - const int& lookup(const std::tuple&) const; + const int& lookup(const std::tuple&) const; - private: - // Key: Subsystem, Station, Ring - // Value: Host - std::map, int> lut_; - }; + private: + // Key: Subsystem, Station, Ring + // Value: Host + std::map, int> lut_; + }; -} // namespace emtf::phase2 +} // namespace emtf::phase2::data #endif // L1Trigger_L1TMuonEndCapPhase2_HostLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h index 9cbe150b57eb6..5d5962d72254f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/SiteLut.h @@ -10,29 +10,27 @@ namespace emtf::phase2::data { - class SiteLut { - // Static - public: - static const int kInvalid; + class SiteLut { + // Static + public: + static const int kInvalid; - // Member - public: - SiteLut(); + // Member + public: + SiteLut(); - ~SiteLut(); + ~SiteLut(); - void update( - const edm::Event&, - const edm::EventSetup&); + void update(const edm::Event&, const edm::EventSetup&); - const int& lookup(const std::tuple&) const; + const int& lookup(const std::tuple&) const; - private: - // Key: Subsystem, Station, Ring - // Value: Site - std::map, int> lut_; - }; + private: + // Key: Subsystem, Station, Ring + // Value: Site + std::map, int> lut_; + }; -} // namespace emtf::phase2 +} // namespace emtf::phase2::data #endif // L1Trigger_L1TMuonEndCapPhase2_SiteLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h index c2a03e06a6f00..2a0e330e19d94 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h @@ -9,29 +9,27 @@ namespace emtf::phase2::data { - class TimeZoneLut { - // Static - public: - bool in_range(const std::pair&, const int&) const; + class TimeZoneLut { + // Static + public: + bool in_range(const std::pair&, const int&) const; - // Member - public: - TimeZoneLut(); + // Member + public: + TimeZoneLut(); - ~TimeZoneLut(); + ~TimeZoneLut(); - void update( - const edm::Event&, - const edm::EventSetup&); + void update(const edm::Event&, const edm::EventSetup&); - int get_timezones(const int&, const int&) const; + int get_timezones(const int&, const int&) const; - private: - // Key: Host - // Value: BX Range - std::map> lut_; - }; + private: + // Key: Host + // Value: BX Range + std::map> lut_; + }; -} // namespace emtf::phase2 +} // namespace emtf::phase2::data #endif // L1Trigger_L1TMuonEndCapPhase2_TimeZoneLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h index e94a611d0367e..772cc06606235 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h @@ -9,47 +9,44 @@ namespace emtf::phase2::data { - // Forward declarations - class Zone; + // Forward declarations + class Zone; - // Classes - class ZoneLut { + // Classes + class ZoneLut { + public: + ZoneLut(); - public: - ZoneLut(); + ~ZoneLut(); - ~ZoneLut(); + void update(const edm::Event&, const edm::EventSetup&); - void update( - const edm::Event&, - const edm::EventSetup&); + int get_zones(const int&, const int&) const; - int get_zones(const int&, const int&) const; + int get_zones(const int&, const int&, const int&) const; - int get_zones(const int&, const int&, const int&) const; + private: + std::vector zones_; + }; - private: - std::vector zones_; - }; + class Zone { + friend ZoneLut; - class Zone { - friend ZoneLut; + public: + Zone() = default; - public: - Zone() = default; + ~Zone() = default; - ~Zone() = default; + bool contains(const int&, const int&) const; - bool contains(const int&, const int&) const; + bool contains(const int&, const int&, const int&) const; - bool contains(const int&, const int&, const int&) const; + private: + // Key: Host + // Value: Theta Range + std::map> lut_; + }; - private: - // Key: Host - // Value: Theta Range - std::map> lut_; - }; - -} // namespace emtf::phase2 +} // namespace emtf::phase2::data #endif // L1Trigger_L1TMuonEndCapPhase2_ZoneLut_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h index 1111835bb138c..1b3fc1e65cfea 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h @@ -5,49 +5,46 @@ namespace emtf::phase2 { - // Class - class EMTFConfiguration { - - public: - EMTFConfiguration(const edm::ParameterSet&); - - ~EMTFConfiguration(); - - // Event configuration - void update( - const edm::Event&, - const edm::EventSetup&); - - // Config - int verbosity_; - - // Validation - std::string validation_dir_; - - // Neural Network - std::string prompt_graph_path_; - std::string displ_graph_path_; - - // Trigger - int min_bx_; - int max_bx_; - int bx_window_; - - // Subsystems - bool csc_en_; - bool rpc_en_; - bool gem_en_; - bool me0_en_; - bool ge0_en_; - - int csc_bx_shift_; - int rpc_bx_shift_; - int gem_bx_shift_; - int me0_bx_shift_; - - // Primitive Selectoin - bool include_neighbor_en_; - }; -} + // Class + class EMTFConfiguration { + public: + EMTFConfiguration(const edm::ParameterSet&); + + ~EMTFConfiguration(); + + // Event configuration + void update(const edm::Event&, const edm::EventSetup&); + + // Config + int verbosity_; + + // Validation + std::string validation_dir_; + + // Neural Network + std::string prompt_graph_path_; + std::string displ_graph_path_; + + // Trigger + int min_bx_; + int max_bx_; + int bx_window_; + + // Subsystems + bool csc_en_; + bool rpc_en_; + bool gem_en_; + bool me0_en_; + bool ge0_en_; + + int csc_bx_shift_; + int rpc_bx_shift_; + int gem_bx_shift_; + int me0_bx_shift_; + + // Primitive Selectoin + bool include_neighbor_en_; + }; +} // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_EMTFConfiguration_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h index 9a7245e4d20f7..d77cca5440775 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h @@ -2,61 +2,61 @@ #define L1Trigger_L1TMuonEndCapPhase2_EMTFConstants_h namespace emtf::phase2 { - // from DataFormats/MuonDetId/interface/CSCDetId.h - constexpr int kMinEndcap = 1; - constexpr int kMaxEndcap = 2; - constexpr int kMinStation = 1; - constexpr int kMaxStation = 4; - constexpr int kMinRing = 1; - constexpr int kMaxRing = 4; - constexpr int kMinChamber = 1; - constexpr int kMaxChamber = 36; - constexpr int kMinLayer = 1; - constexpr int kMaxLayer = 6; - - // from DataFormats/MuonDetId/interface/CSCTriggerNumbering.h - constexpr int kMinCSCId = 1; - constexpr int kMaxCSCId = 9; - constexpr int kMinTrigSector = 1; - constexpr int kMaxTrigSector = 6; - constexpr int kNumTrigSector = 12; - constexpr int kMinTrigSubsector = 0; - constexpr int kMaxTrigSubsector = 2; - - // Algorithm - namespace v3 { - constexpr int kNumChambers = 115; // per sector - constexpr int kChamberSegments = 2; // per chamber - constexpr int kNumSegments = kNumChambers * kChamberSegments; - constexpr int kNumSegmentVariables = 13; // per segment - - constexpr int kNumZones = 3; // per sector - constexpr int kNumZonePatterns = 7; // per zone - - constexpr int kNumTimeZones = 3; // per sector - - constexpr int kNumTracks = 4; // per sector - constexpr int kNumTrackVariables = 54; // per track - constexpr int kNumTrackFeatures = 40; // per track - constexpr int kNumTrackPredictions = 1; // per track - constexpr int kNumTrackSites = 12; // per track - constexpr int kNumTrackSitesRM = 5; // per track - - constexpr int kChamberHitmapBW = 90; // 24 deg - constexpr int kChamberHitmapJoinedBW = 315; // 84 deg - constexpr int kHitmapNRows = 8; - constexpr int kHitmapNCols = 288; - constexpr int kHitmapNGates = 3; - constexpr int kHitmapColFactor = 16; - constexpr int kHitmapColFactorLog2 = 4; // (1 << 4) = 16 - constexpr int kHitmapCropColStart = kChamberHitmapJoinedBW - kHitmapNCols; // 27 (Inclusive) - constexpr int kHitmapCropColStop = kChamberHitmapJoinedBW; // 315 (Exclusive) - - constexpr int kPatternNCols = 110; - constexpr int kPatternMatchingPadding = 55; - constexpr int kMaxPatternActivation = 63; - constexpr int kMaxPatternActivationLog2 = 6; // (1 << 6) - 1 = 63 - } -} + // from DataFormats/MuonDetId/interface/CSCDetId.h + constexpr int kMinEndcap = 1; + constexpr int kMaxEndcap = 2; + constexpr int kMinStation = 1; + constexpr int kMaxStation = 4; + constexpr int kMinRing = 1; + constexpr int kMaxRing = 4; + constexpr int kMinChamber = 1; + constexpr int kMaxChamber = 36; + constexpr int kMinLayer = 1; + constexpr int kMaxLayer = 6; + + // from DataFormats/MuonDetId/interface/CSCTriggerNumbering.h + constexpr int kMinCSCId = 1; + constexpr int kMaxCSCId = 9; + constexpr int kMinTrigSector = 1; + constexpr int kMaxTrigSector = 6; + constexpr int kNumTrigSector = 12; + constexpr int kMinTrigSubsector = 0; + constexpr int kMaxTrigSubsector = 2; + + // Algorithm + namespace v3 { + constexpr int kNumChambers = 115; // per sector + constexpr int kChamberSegments = 2; // per chamber + constexpr int kNumSegments = kNumChambers * kChamberSegments; + constexpr int kNumSegmentVariables = 13; // per segment + + constexpr int kNumZones = 3; // per sector + constexpr int kNumZonePatterns = 7; // per zone + + constexpr int kNumTimeZones = 3; // per sector + + constexpr int kNumTracks = 4; // per sector + constexpr int kNumTrackVariables = 54; // per track + constexpr int kNumTrackFeatures = 40; // per track + constexpr int kNumTrackPredictions = 1; // per track + constexpr int kNumTrackSites = 12; // per track + constexpr int kNumTrackSitesRM = 5; // per track + + constexpr int kChamberHitmapBW = 90; // 24 deg + constexpr int kChamberHitmapJoinedBW = 315; // 84 deg + constexpr int kHitmapNRows = 8; + constexpr int kHitmapNCols = 288; + constexpr int kHitmapNGates = 3; + constexpr int kHitmapColFactor = 16; + constexpr int kHitmapColFactorLog2 = 4; // (1 << 4) = 16 + constexpr int kHitmapCropColStart = kChamberHitmapJoinedBW - kHitmapNCols; // 27 (Inclusive) + constexpr int kHitmapCropColStop = kChamberHitmapJoinedBW; // 315 (Exclusive) + + constexpr int kPatternNCols = 110; + constexpr int kPatternMatchingPadding = 55; + constexpr int kMaxPatternActivation = 63; + constexpr int kMaxPatternActivationLog2 = 6; // (1 << 6) - 1 = 63 + } // namespace v3 +} // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_EMTFConstants_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h index ea55b7a1b33a5..372d6ccdd4c7b 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h @@ -29,56 +29,51 @@ namespace emtf::phase2 { - // Class - class EMTFContext { - - public: - EMTFContext( - const edm::ParameterSet&, - edm::ConsumesCollector); - - ~EMTFContext(); - - // Event configuration - void update( - const edm::Event&, - const edm::EventSetup&); - - // Parameter Set - const edm::ParameterSet& pset_; - - // Helpers - GeometryTranslator geometry_translator_; - - // EMTF - EMTFConfiguration config_; - EMTFModel model_; - - // Prompt Neural Network - tensorflow::GraphDef* prompt_graph_ptr_; - tensorflow::Session* prompt_session_ptr_; - - // Displaced Neural Network - tensorflow::GraphDef* disp_graph_ptr_; - tensorflow::Session* disp_session_ptr_; - - // Data - data::SiteLut site_lut_; - data::HostLut host_lut_; - data::ZoneLut zone_lut_; - data::TimeZoneLut timezone_lut_; - data::ActivationLut activation_lut_; - - // Algorithm - algo::HitmapLayer hitmap_building_layer_; - algo::PatternMatchingLayer pattern_matching_layer_; - algo::RoadSortingLayer road_sorting_layer_; - algo::TrackBuildingLayer track_building_layer_; - algo::DuplicateRemovalLayer duplicate_removal_layer_; - algo::ParameterAssignmentLayer parameter_assignment_layer_; - algo::OutputLayer output_layer_; - }; - -} + // Class + class EMTFContext { + public: + EMTFContext(const edm::ParameterSet&, edm::ConsumesCollector); + + ~EMTFContext(); + + // Event configuration + void update(const edm::Event&, const edm::EventSetup&); + + // Parameter Set + const edm::ParameterSet& pset_; + + // Helpers + GeometryTranslator geometry_translator_; + + // EMTF + EMTFConfiguration config_; + EMTFModel model_; + + // Prompt Neural Network + tensorflow::GraphDef* prompt_graph_ptr_; + tensorflow::Session* prompt_session_ptr_; + + // Displaced Neural Network + tensorflow::GraphDef* disp_graph_ptr_; + tensorflow::Session* disp_session_ptr_; + + // Data + data::SiteLut site_lut_; + data::HostLut host_lut_; + data::ZoneLut zone_lut_; + data::TimeZoneLut timezone_lut_; + data::ActivationLut activation_lut_; + + // Algorithm + algo::HitmapLayer hitmap_building_layer_; + algo::PatternMatchingLayer pattern_matching_layer_; + algo::RoadSortingLayer road_sorting_layer_; + algo::TrackBuildingLayer track_building_layer_; + algo::DuplicateRemovalLayer duplicate_removal_layer_; + algo::ParameterAssignmentLayer parameter_assignment_layer_; + algo::OutputLayer output_layer_; + }; + +} // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_EMTFContext_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h index 62607b01728b0..cef879daa770a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFModel.h @@ -10,117 +10,115 @@ namespace emtf::phase2 { - // Forward Declarations - namespace model { - namespace zones { - namespace hitmap { - struct chamber_t; - struct site_t; - typedef std::vector row_t; - } - - namespace pattern { - struct row_t; - } - - typedef std::vector hitmap_t; - typedef std::vector pattern_t; - typedef std::vector quality_lut_t; - } - - namespace theta_medians { - struct site_t; - typedef std::vector group_t; - } - - namespace reduced_sites { - struct reduced_site_t; - } - - struct zone_t; - struct feature_t; - - typedef std::vector theta_median_t; - typedef std::vector reduced_sites_t; + // Forward Declarations + namespace model { + namespace zones { + namespace hitmap { + struct chamber_t; + struct site_t; + typedef std::vector row_t; + } // namespace hitmap + + namespace pattern { + struct row_t; + } + + typedef std::vector hitmap_t; + typedef std::vector pattern_t; + typedef std::vector quality_lut_t; + } // namespace zones + + namespace theta_medians { + struct site_t; + typedef std::vector group_t; + } // namespace theta_medians + + namespace reduced_sites { + struct reduced_site_t; } - // Definitions - class EMTFModel { + struct zone_t; + struct feature_t; - public: - EMTFModel(const EMTFContext&); + typedef std::vector theta_median_t; + typedef std::vector reduced_sites_t; + } // namespace model - ~EMTFModel(); + // Definitions + class EMTFModel { + public: + EMTFModel(const EMTFContext&); - std::vector zones_; - std::vector features_; - std::vector theta_medians_; - model::reduced_sites_t reduced_sites_; + ~EMTFModel(); - private: - const EMTFContext& context_; + std::vector zones_; + std::vector features_; + std::vector theta_medians_; + model::reduced_sites_t reduced_sites_; - }; + private: + const EMTFContext& context_; + }; + + namespace model { + // Define Zone Structs + struct zone_t { + zones::hitmap_t hitmap; - namespace model { - // Define Zone Structs - struct zone_t { - zones::hitmap_t hitmap; + // Prompt + std::vector prompt_patterns; + zones::quality_lut_t prompt_quality_lut; - // Prompt - std::vector prompt_patterns; - zones::quality_lut_t prompt_quality_lut; + // Displaced + std::vector disp_patterns; + zones::quality_lut_t disp_quality_lut; + }; - // Displaced - std::vector disp_patterns; - zones::quality_lut_t disp_quality_lut; + namespace zones { + namespace hitmap { + struct site_t { + site_id_t id; + std::vector chambers; }; - namespace zones { - namespace hitmap { - struct site_t { - site_id_t id; - std::vector chambers; - }; - - struct chamber_t { - unsigned int id; - unsigned int begin; - unsigned int end; - }; - } - - namespace pattern { - struct row_t { - unsigned int begin; - unsigned int center; - unsigned int end; - }; - } - } - - // Define Feature Structs - struct feature_t { - feature_id_t id; - std::vector sites; + struct chamber_t { + unsigned int id; + unsigned int begin; + unsigned int end; }; + } // namespace hitmap - // Define Theta Median Structs - namespace theta_medians { - struct site_t { - site_id_t id; - theta_id_t theta_id; - }; - } - - // Define Reduced Site Structs - namespace reduced_sites { - struct reduced_site_t { - reduced_site_id_t id; - std::vector trk_sites; - }; - } - } -} + namespace pattern { + struct row_t { + unsigned int begin; + unsigned int center; + unsigned int end; + }; + } // namespace pattern + } // namespace zones + + // Define Feature Structs + struct feature_t { + feature_id_t id; + std::vector sites; + }; + + // Define Theta Median Structs + namespace theta_medians { + struct site_t { + site_id_t id; + theta_id_t theta_id; + }; + } // namespace theta_medians + + // Define Reduced Site Structs + namespace reduced_sites { + struct reduced_site_t { + reduced_site_id_t id; + std::vector trk_sites; + }; + } // namespace reduced_sites + } // namespace model +} // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_EMTFModel_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h index 15eb95d8730f9..5c562146c4f4c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h @@ -1,8 +1,8 @@ #ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFTypes_h #define L1Trigger_L1TMuonEndCapPhase2_EMTFTypes_h -#include -#include +#include +#include #include "ap_int.h" #include "ap_fixed.h" @@ -16,155 +16,155 @@ namespace emtf::phase2 { - // Trigger Primitives - typedef L1TMuon::TriggerPrimitive TriggerPrimitive; - typedef std::vector TPCollection; - typedef std::map BXTPCMap; - typedef std::map ILinkTPCMap; - - // Hits - typedef l1t::phase2::EMTFHit EMTFHit; - typedef l1t::phase2::EMTFHitCollection EMTFHitCollection; - - // Tracks - typedef l1t::phase2::EMTFTrack EMTFTrack; - typedef l1t::phase2::EMTFTrackCollection EMTFTrackCollection; - - // Inputs - typedef l1t::phase2::EMTFInput EMTFInput; - typedef l1t::phase2::EMTFInputCollection EMTFInputCollection; - - // General - typedef ap_uint<1> flag_t; - - // Segments - enum class site_id_t { - kME11 = 0, kME12 = 1 , kME2 = 2 , kME3 = 3, kME4 = 4, - kRE1 = 5, kRE2 = 6 , kRE3 = 7 , kRE4 = 8, - kGE11 = 9, kGE21 = 10, kME0 = 11, - size, begin = 0, end=size - }; - - enum class feature_id_t { - kPhi = 0, kTheta = 1 , kBend = 2 , kQuality = 3, kTime = 4, - size, begin = 0, end=size - }; - - enum class theta_id_t { - kTheta1 = 0, kTheta2 = 1, - size, begin = 0, end=size - }; - - enum class reduced_site_id_t { - kME1 = 0, kME2 = 1, - kME3 = 2, kME4 = 3, - kME0 = 4, - size, begin = 0, end=size - }; - - typedef ap_uint <13> seg_phi_t ; - typedef ap_int <10> seg_bend_t ; - typedef ap_uint <8 > seg_theta_t ; - typedef ap_uint <4 > seg_qual_t ; - typedef ap_int <4 > seg_time_t ; - typedef ap_uint <3 > seg_zones_t ; - typedef ap_uint <3 > seg_tzones_t; - typedef ap_uint <1 > seg_cscfr_t ; - typedef ap_uint <1 > seg_layer_t ; - typedef ap_int <2 > seg_bx_t ; - typedef ap_uint <1 > seg_valid_t ; - - struct segment_t { - seg_phi_t phi ; - seg_bend_t bend ; - seg_theta_t theta1; - seg_theta_t theta2; - seg_qual_t qual1 ; - seg_qual_t qual2 ; - seg_time_t time ; - seg_zones_t zones ; - seg_tzones_t tzones; - seg_cscfr_t cscfr ; - seg_layer_t layer ; - seg_bx_t bx ; - seg_valid_t valid ; - }; - - typedef std::array segment_collection_t; - - // Tracks - typedef ap_uint <2 > trk_zone_t ; - typedef ap_uint <2 > trk_tzone_t ; - typedef ap_uint <9 > trk_col_t ; - typedef ap_uint <3 > trk_patt_t ; - typedef ap_uint <6 > trk_qual_t ; - typedef ap_uint <2 > trk_gate_t ; - typedef ap_uint <1 > trk_q_t ; - typedef ap_uint <13> trk_pt_t ; - typedef ap_uint <7 > trk_rels_t ; - typedef ap_int <7 > trk_dxy_t ; - typedef ap_int <5 > trk_z0_t ; - typedef ap_int <13> trk_phi_t ; - typedef ap_int <13> trk_eta_t ; - typedef ap_uint <4 > trk_beta_t ; - typedef ap_uint <1 > trk_valid_t ; - typedef ap_uint <8 > trk_site_seg_t ; - typedef ap_uint <1 > trk_site_bit_t ; - typedef ap_int <13> trk_feature_t ; - typedef ap_int <10> trk_nn_address_t; - - struct track_t { - typedef std::array site_segs_t; - typedef std::array site_mask_t; - typedef std::array features_t; - - trk_zone_t zone ; - trk_col_t col ; - trk_patt_t pattern ; - trk_qual_t quality ; - trk_q_t q ; - trk_pt_t pt ; - trk_rels_t rels ; - trk_dxy_t dxy ; - trk_z0_t z0 ; - seg_phi_t phi ; - seg_theta_t theta ; - trk_eta_t eta ; - trk_beta_t beta ; - trk_valid_t valid ; - site_segs_t site_segs ; - site_mask_t site_mask ; - site_mask_t site_rm_mask ; - features_t features ; - trk_nn_address_t pt_address ; - trk_nn_address_t rels_address; - trk_nn_address_t dxy_address ; - }; - - // Hitmaps - typedef ap_uint hitmap_row_t; - typedef std::array hitmap_t; - - // Roads - struct road_t { - trk_zone_t zone ; - trk_col_t col ; - trk_patt_t pattern; - trk_qual_t quality; - }; - - typedef std::array road_collection_t; - - // Reduced Track - struct reduced_track_t { - typedef std::array site_segs_t; - typedef std::array site_mask_t; - - trk_valid_t valid; - site_segs_t site_segs; - site_mask_t site_mask; - }; -} + // Trigger Primitives + typedef L1TMuon::TriggerPrimitive TriggerPrimitive; + typedef std::vector TPCollection; + typedef std::map BXTPCMap; + typedef std::map ILinkTPCMap; + + // Hits + typedef l1t::phase2::EMTFHit EMTFHit; + typedef l1t::phase2::EMTFHitCollection EMTFHitCollection; + + // Tracks + typedef l1t::phase2::EMTFTrack EMTFTrack; + typedef l1t::phase2::EMTFTrackCollection EMTFTrackCollection; + + // Inputs + typedef l1t::phase2::EMTFInput EMTFInput; + typedef l1t::phase2::EMTFInputCollection EMTFInputCollection; + + // General + typedef ap_uint<1> flag_t; + + // Segments + enum class site_id_t { + kME11 = 0, + kME12 = 1, + kME2 = 2, + kME3 = 3, + kME4 = 4, + kRE1 = 5, + kRE2 = 6, + kRE3 = 7, + kRE4 = 8, + kGE11 = 9, + kGE21 = 10, + kME0 = 11, + size, + begin = 0, + end = size + }; + + enum class feature_id_t { kPhi = 0, kTheta = 1, kBend = 2, kQuality = 3, kTime = 4, size, begin = 0, end = size }; + + enum class theta_id_t { kTheta1 = 0, kTheta2 = 1, size, begin = 0, end = size }; + + enum class reduced_site_id_t { kME1 = 0, kME2 = 1, kME3 = 2, kME4 = 3, kME0 = 4, size, begin = 0, end = size }; + + typedef ap_uint<13> seg_phi_t; + typedef ap_int<10> seg_bend_t; + typedef ap_uint<8> seg_theta_t; + typedef ap_uint<4> seg_qual_t; + typedef ap_int<4> seg_time_t; + typedef ap_uint<3> seg_zones_t; + typedef ap_uint<3> seg_tzones_t; + typedef ap_uint<1> seg_cscfr_t; + typedef ap_uint<1> seg_layer_t; + typedef ap_int<2> seg_bx_t; + typedef ap_uint<1> seg_valid_t; + + struct segment_t { + seg_phi_t phi; + seg_bend_t bend; + seg_theta_t theta1; + seg_theta_t theta2; + seg_qual_t qual1; + seg_qual_t qual2; + seg_time_t time; + seg_zones_t zones; + seg_tzones_t tzones; + seg_cscfr_t cscfr; + seg_layer_t layer; + seg_bx_t bx; + seg_valid_t valid; + }; + + typedef std::array segment_collection_t; + + // Tracks + typedef ap_uint<2> trk_zone_t; + typedef ap_uint<2> trk_tzone_t; + typedef ap_uint<9> trk_col_t; + typedef ap_uint<3> trk_patt_t; + typedef ap_uint<6> trk_qual_t; + typedef ap_uint<2> trk_gate_t; + typedef ap_uint<1> trk_q_t; + typedef ap_uint<13> trk_pt_t; + typedef ap_uint<7> trk_rels_t; + typedef ap_int<7> trk_dxy_t; + typedef ap_int<5> trk_z0_t; + typedef ap_int<13> trk_phi_t; + typedef ap_int<13> trk_eta_t; + typedef ap_uint<4> trk_beta_t; + typedef ap_uint<1> trk_valid_t; + typedef ap_uint<8> trk_site_seg_t; + typedef ap_uint<1> trk_site_bit_t; + typedef ap_int<13> trk_feature_t; + typedef ap_int<10> trk_nn_address_t; + + struct track_t { + typedef std::array site_segs_t; + typedef std::array site_mask_t; + typedef std::array features_t; + + trk_zone_t zone; + trk_col_t col; + trk_patt_t pattern; + trk_qual_t quality; + trk_q_t q; + trk_pt_t pt; + trk_rels_t rels; + trk_dxy_t dxy; + trk_z0_t z0; + seg_phi_t phi; + seg_theta_t theta; + trk_eta_t eta; + trk_beta_t beta; + trk_valid_t valid; + site_segs_t site_segs; + site_mask_t site_mask; + site_mask_t site_rm_mask; + features_t features; + trk_nn_address_t pt_address; + trk_nn_address_t rels_address; + trk_nn_address_t dxy_address; + }; + + // Hitmaps + typedef ap_uint hitmap_row_t; + typedef std::array hitmap_t; + + // Roads + struct road_t { + trk_zone_t zone; + trk_col_t col; + trk_patt_t pattern; + trk_qual_t quality; + }; + + typedef std::array road_collection_t; + + // Reduced Track + struct reduced_track_t { + typedef std::array site_segs_t; + typedef std::array site_mask_t; + + trk_valid_t valid; + site_segs_t site_segs; + site_mask_t site_mask; + }; +} // namespace emtf::phase2 typedef L1TMuon::subsystem_type SubsystemType; typedef L1TMuon::GeometryTranslator GeometryTranslator; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h index a9fbbf4647723..21e0a7b02803f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h @@ -6,26 +6,25 @@ #include "L1Trigger/L1TMuon/interface/MuonTriggerPrimitiveFwd.h" namespace emtf::phase2 { - class EMTFContext; - class EMTFConfiguration; - class EMTFModel; + class EMTFContext; + class EMTFConfiguration; + class EMTFModel; - struct TPInfo; - class TPEntry; - class TrackFinder; - class SectorProcessor; - class TPCollector; - class CSCTPCollector; - class RPCTPCollector; - class GEMTPCollector; - class ME0TPCollector; - class TPSelector; - class CSCTPSelector; - class RPCTPSelector; - class GEMTPSelector; - class ME0TPSelector; - class TPConverter; -} - -#endif // namespace L1Trigger_L1TMuonEndCapPhase2_EMTFfwd_h + struct TPInfo; + class TPEntry; + class TrackFinder; + class SectorProcessor; + class TPCollector; + class CSCTPCollector; + class RPCTPCollector; + class GEMTPCollector; + class ME0TPCollector; + class TPSelector; + class CSCTPSelector; + class RPCTPSelector; + class GEMTPSelector; + class ME0TPSelector; + class TPConverter; +} // namespace emtf::phase2 +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_EMTFfwd_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h b/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h index 3f449d9cdbffe..a380192521bea 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h @@ -6,67 +6,45 @@ namespace emtf::phase2 { - class SectorProcessor { - public: - SectorProcessor( - const EMTFContext&, - const int&, const int&); - - ~SectorProcessor(); - - void configure_event(const edm::Event&); - - void configure_bx(const int&); - - void select( - const TriggerPrimitive&, - const TPInfo& - ); - - void process( - EMTFHitCollection&, - EMTFTrackCollection&, - EMTFInputCollection& - ); - - private: - const EMTFContext& context_; - - int endcap_, sector_; - std::map> tp_selectors_; - std::map> tp_converters_; - - // Event - const edm::Event* event_; - const int* bx_; - - // Buffers - std::vector bx_window_hits_; - std::map bx_ilink_tpc_maps_; - - // Helper functions - void copy_tp( - const ILinkTPCMap& source, - ILinkTPCMap& target) const; - - void convert_tp( - const int&, - const ILinkTPCMap&, - EMTFHitCollection&); - - void populate_segments( - const std::vector&, - std::map&, - segment_collection_t&); - - void build_tracks( - const std::map&, - const segment_collection_t&, - const bool&, - EMTFTrackCollection& - ); - }; - -} - -#endif // L1Trigger_L1TMuonEndCapPhase2_SectorProcessor_h + class SectorProcessor { + public: + SectorProcessor(const EMTFContext&, const int&, const int&); + + ~SectorProcessor(); + + void configure_event(const edm::Event&); + + void configure_bx(const int&); + + void select(const TriggerPrimitive&, const TPInfo&); + + void process(EMTFHitCollection&, EMTFTrackCollection&, EMTFInputCollection&); + + private: + const EMTFContext& context_; + + int endcap_, sector_; + std::map> tp_selectors_; + std::map> tp_converters_; + + // Event + const edm::Event* event_; + const int* bx_; + + // Buffers + std::vector bx_window_hits_; + std::map bx_ilink_tpc_maps_; + + // Helper functions + void copy_tp(const ILinkTPCMap& source, ILinkTPCMap& target) const; + + void convert_tp(const int&, const ILinkTPCMap&, EMTFHitCollection&); + + void populate_segments(const std::vector&, std::map&, segment_collection_t&); + + void build_tracks(const std::map&, const segment_collection_t&, const bool&, EMTFTrackCollection&); + }; + +} // namespace emtf::phase2 + +#endif // L1Trigger_L1TMuonEndCapPhase2_SectorProcessor_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h b/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h index baf53be83d070..ab8c8a3a41fbf 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h @@ -7,35 +7,31 @@ namespace emtf::phase2 { - class TrackFinder { - public: - explicit TrackFinder( - const edm::ParameterSet&, - edm::ConsumesCollector&& - ); - - ~TrackFinder(); - - void process( - // Input - const edm::Event&, - const edm::EventSetup&, - // Output - EMTFHitCollection&, - EMTFTrackCollection&, - EMTFInputCollection& - ); - - void on_job_begin(); - - void on_job_end(); - - private: - EMTFContext context_; - - std::vector> tp_collectors_; - std::vector> sector_processors_; - }; -} + class TrackFinder { + public: + explicit TrackFinder(const edm::ParameterSet&, edm::ConsumesCollector&&); + + ~TrackFinder(); + + void process( + // Input + const edm::Event&, + const edm::EventSetup&, + // Output + EMTFHitCollection&, + EMTFTrackCollection&, + EMTFInputCollection&); + + void on_job_begin(); + + void on_job_end(); + + private: + EMTFContext context_; + + std::vector> tp_collectors_; + std::vector> sector_processors_; + }; +} // namespace emtf::phase2 #endif diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h index 7402e798f64ec..4d989d5aaaaab 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h @@ -5,40 +5,36 @@ namespace emtf::phase2::csc { - // Enums - enum Facing {kFront, kRear, kNone}; + // Enums + enum Facing { kFront, kRear, kNone }; - // Chambers - int next_10deg_chamber(int chamber); + // Chambers + int next_10deg_chamber(int chamber); - int prev_10deg_chamber(int chamber); + int prev_10deg_chamber(int chamber); - int next_20deg_chamber(int chamber); + int next_20deg_chamber(int chamber); - int prev_20deg_chamber(int chamber); + int prev_20deg_chamber(int chamber); - // Functions - bool is_in_sector( - int match_endcap, int match_sector, - int tp_endcap, int tp_sector); + // Functions + bool is_in_sector(int match_endcap, int match_sector, int tp_endcap, int tp_sector); - bool is_in_neighbor_sector( - int match_endcap, int match_sector, - int tp_endcap, int tp_sector, int tp_subsector, - int tp_station, int tp_id); + bool is_in_neighbor_sector( + int match_endcap, int match_sector, int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_id); - int get_id(int ring, int station, int chamber); + int get_id(int ring, int station, int chamber); - int get_trigger_sector(int ring, int station, int chamber); + int get_trigger_sector(int ring, int station, int chamber); - int get_trigger_subsector(int station, int chamber); + int get_trigger_subsector(int station, int chamber); - Facing get_face_direction(int station, int ring, int chamber); + Facing get_face_direction(int station, int ring, int chamber); - std::pair get_max_strip_and_wire(int station, int ring); + std::pair get_max_strip_and_wire(int station, int ring); - std::pair get_max_pattern_and_quality(int station, int ring); + std::pair get_max_pattern_and_quality(int station, int ring); -} +} // namespace emtf::phase2::csc -#endif // namespace L1Trigger_L1TMuonEndCapPhase2_CSCUtils_h +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_CSCUtils_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h index c0ea0ae092c46..26bbea9f39715 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h @@ -11,177 +11,145 @@ namespace emtf::phase2::data { - // Merge-Sort - template - void swap_wires( - T arr[], - const int& wire_1, const int& wire_2, - const C& comparator - ) { - - int result = comparator(arr[wire_1], arr[wire_2]); - - if (result == 1) { - auto temp = arr[wire_1]; - arr[wire_1] = arr[wire_2]; - arr[wire_2] = temp; - } + // Merge-Sort + template + void swap_wires(T arr[], const int& wire_1, const int& wire_2, const C& comparator) { + int result = comparator(arr[wire_1], arr[wire_2]); + + if (result == 1) { + auto temp = arr[wire_1]; + arr[wire_1] = arr[wire_2]; + arr[wire_2] = temp; + } + } + + template + void mergesort_block(T arr[], + const int& offset, + const int& step, + const int& block_begin, + const int& block_end, + const int& first_n, + const C& comparator) { + int wire_offset = offset + block_begin; + int wire_cutoff = first_n + block_begin; + int wire_1 = wire_offset; + int wire_2 = wire_1 + step; + + // Loop pairs + while (wire_2 < block_end) { + // Trim results + if (first_n > 0 && wire_cutoff < block_end) { + bool wire_needed = (wire_offset <= wire_1) && (wire_1 <= wire_cutoff); + + if (!wire_needed) { + break; } - - template - void mergesort_block( - T arr[], - const int& offset, const int& step, - const int& block_begin, const int& block_end, - const int& first_n, - const C& comparator - ) { - int wire_offset = offset + block_begin; - int wire_cutoff = first_n + block_begin; - int wire_1 = wire_offset; - int wire_2 = wire_1 + step; - - // Loop pairs - while (wire_2 < block_end) { - // Trim results - if (first_n > 0 && wire_cutoff < block_end) { - bool wire_needed = (wire_offset <= wire_1) - && (wire_1 <= wire_cutoff); - - if (!wire_needed) { - break; - } - } - - // Swap Wires - swap_wires( - arr, - wire_1, wire_2, - comparator - ); - - // Calculate next wire_1 - if (step == 1) { - wire_1 = wire_2 + 1; - } else { - wire_1 = wire_1 + 1; - } - - // Calculate next wire_2 - wire_2 = wire_1 + step; - } - } - - template - void mergesort( - T arr[], - const int& arr_size, - const int& first_n, - const C& comparator - ) { - // Sort - int n_pairs = arr_size / 2; - - for (int i = 0; i < n_pairs; ++i) { - swap_wires(arr, 2 * i, 2 * i + 1, comparator); - } - - // Merge - int offset = 0; - int step = 2; - int block_size = step * 2; - - // Loop block sizes - while (true) { - // Loop step sizes - // If the offset is greater than the amount of wires to keep - // there's no need to continue, since (offset)-wires are known - // to not contribute to the end result - while (true) { - // Loop blocks - int block_begin = 0; - int block_end = block_size; - - while (block_begin < arr_size) { - // Constrain block_end - if (block_end > arr_size) - block_end = arr_size; - - // Merge block - mergesort_block( - arr, - offset, step, - block_begin, block_end, - first_n, - comparator - ); - - // Move to next block - block_begin = block_end; - block_end = block_end + block_size; - } - - // Decrease step - if (step > 2) { - // For each pass we are certain of the local min and max - // so skip 2 wires and reduce the step - offset = offset + 2; - step = step - 2; - } else if (step == 2) { - // For final pass we are certain of the global min and max - // so skip 1 wire and compare wires 1 to 1, the last value - // will be left without a partner; naturally since - // it's the global min - offset = 1; - step = 1; - } else { - // Short-Circuit: Done - break; - } - } - - // Short-Circuit: No more wires - if (block_size >= arr_size) - break; - - // Double the block size - offset = 0; - step = block_size; - block_size = step * 2; - } + } + + // Swap Wires + swap_wires(arr, wire_1, wire_2, comparator); + + // Calculate next wire_1 + if (step == 1) { + wire_1 = wire_2 + 1; + } else { + wire_1 = wire_1 + 1; + } + + // Calculate next wire_2 + wire_2 = wire_1 + step; + } + } + + template + void mergesort(T arr[], const int& arr_size, const int& first_n, const C& comparator) { + // Sort + int n_pairs = arr_size / 2; + + for (int i = 0; i < n_pairs; ++i) { + swap_wires(arr, 2 * i, 2 * i + 1, comparator); + } + + // Merge + int offset = 0; + int step = 2; + int block_size = step * 2; + + // Loop block sizes + while (true) { + // Loop step sizes + // If the offset is greater than the amount of wires to keep + // there's no need to continue, since (offset)-wires are known + // to not contribute to the end result + while (true) { + // Loop blocks + int block_begin = 0; + int block_end = block_size; + + while (block_begin < arr_size) { + // Constrain block_end + if (block_end > arr_size) + block_end = arr_size; + + // Merge block + mergesort_block(arr, offset, step, block_begin, block_end, first_n, comparator); + + // Move to next block + block_begin = block_end; + block_end = block_end + block_size; } - template - void mergesort( - T arr[], - const int& arr_size, - const C& comparator - ) { - mergesort( - arr, - arr_size, 0, - comparator - ); + // Decrease step + if (step > 2) { + // For each pass we are certain of the local min and max + // so skip 2 wires and reduce the step + offset = offset + 2; + step = step - 2; + } else if (step == 2) { + // For final pass we are certain of the global min and max + // so skip 1 wire and compare wires 1 to 1, the last value + // will be left without a partner; naturally since + // it's the global min + offset = 1; + step = 1; + } else { + // Short-Circuit: Done + break; } - - // Median Calculation - template - T median_of_sorted( - T arr[], - const int& arr_size - ) { - T mid; - - if ((arr_size % 2) == 0) { - const auto& top = arr[arr_size / 2]; - const auto& bot = arr[arr_size / 2 - 1]; - mid = (top + bot) >> 1; // Mid = (Top + Bot) / 2 - } else { - mid = arr[(arr_size - 1) / 2]; - } - - return mid; - } -} + } + + // Short-Circuit: No more wires + if (block_size >= arr_size) + break; + + // Double the block size + offset = 0; + step = block_size; + block_size = step * 2; + } + } + + template + void mergesort(T arr[], const int& arr_size, const C& comparator) { + mergesort(arr, arr_size, 0, comparator); + } + + // Median Calculation + template + T median_of_sorted(T arr[], const int& arr_size) { + T mid; + + if ((arr_size % 2) == 0) { + const auto& top = arr[arr_size / 2]; + const auto& bot = arr[arr_size / 2 - 1]; + mid = (top + bot) >> 1; // Mid = (Top + Bot) / 2 + } else { + mid = arr[(arr_size - 1) / 2]; + } + + return mid; + } +} // namespace emtf::phase2::data #endif // L1Trigger_L1TMuonEndCapPhase2_DataUtils_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h index 1bb15c1a237fe..65732819fafa9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h @@ -15,5 +15,4 @@ #define emtf_assert(expr) ((void)(expr)) #endif -#endif // namespace L1Trigger_L1TMuonEndCapPhase2_DebugUtils_h - +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_DebugUtils_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h index 9d27ab3722a61..6e779f94a913a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h @@ -8,41 +8,41 @@ // Return an integer as a hex string template std::string to_hex(INT i) { - std::stringstream s; - s << "0x" << std::hex << i; - return s.str(); + std::stringstream s; + s << "0x" << std::hex << i; + return s.str(); } // Return an integer as a binary string template std::string to_binary(INT i, int n) { - std::stringstream s; - if (sizeof(i) <= 4) { - std::bitset<32> b(i); - s << "0b" << b.to_string().substr(32 - n, 32); - } else if (sizeof(i) <= 8) { - std::bitset<64> b(i); - s << "0b" << b.to_string().substr(64 - n, 64); - } - return s.str(); + std::stringstream s; + if (sizeof(i) <= 4) { + std::bitset<32> b(i); + s << "0b" << b.to_string().substr(32 - n, 32); + } else if (sizeof(i) <= 8) { + std::bitset<64> b(i); + s << "0b" << b.to_string().substr(64 - n, 64); + } + return s.str(); } // Return the size of a 1D plain array template constexpr size_t array_size(T (&)[N]) { - return N; + return N; } // Return the elements of a 1D plain array as a string (elements are separated by ' ') template std::string array_as_string(const T (&arr)[N]) { - std::stringstream s; - const char* sep = ""; - for (size_t i = 0; i < N; ++i) { - s << sep << arr[i]; - sep = " "; - } - return s.str(); + std::stringstream s; + const char* sep = ""; + for (size_t i = 0; i < N; ++i) { + s << sep << arr[i]; + sep = " "; + } + return s.str(); } // This function allows one to loop over a container in reversed order using C++11 for(auto ...) loop @@ -52,42 +52,42 @@ std::string array_as_string(const T (&arr)[N]) { // } // See http://stackoverflow.com/a/21510185 namespace details { - template - struct _reversed { - T& t; - _reversed(T& _t) : t(_t) {} - decltype(t.rbegin()) begin() { return t.rbegin(); } - decltype(t.rend()) end() { return t.rend(); } - }; + template + struct _reversed { + T& t; + _reversed(T& _t) : t(_t) {} + decltype(t.rbegin()) begin() { return t.rbegin(); } + decltype(t.rend()) end() { return t.rend(); } + }; } // namespace details template details::_reversed reversed(T& t) { - return details::_reversed(t); + return details::_reversed(t); } // Split a string by delimiters (default: ' ') into a vector of string // See http://stackoverflow.com/a/53878 template std::vector split_string(const std::string& s, char c = ' ', char d = ' ') { - std::vector result; - const char* str = s.c_str(); - do { - const char* begin = str; - while (*str != c && *str != d && *str) - str++; - result.emplace_back(begin, str); - } while (0 != *str++); - return result; + std::vector result; + const char* str = s.c_str(); + do { + const char* begin = str; + while (*str != c && *str != d && *str) + str++; + result.emplace_back(begin, str); + } while (0 != *str++); + return result; } // Flatten a vector > into a vector // The input type T can be different from the output type T template void flatten_container(const T1& input, T2& output) { - typename T1::const_iterator it; - for (it = input.begin(); it != input.end(); ++it) { - output.insert(output.end(), it->begin(), it->end()); - } + typename T1::const_iterator it; + for (it = input.begin(); it != input.end(); ++it) { + output.insert(output.end(), it->begin(), it->end()); + } } // Check type for map of vector @@ -100,20 +100,20 @@ struct is_map_of_vectors > > : public std::true_typ // Merge a map of vectors (map1) into another map of vectors (map2) template void merge_map_into_map(const Map& map1, Map& map2) { - // This is customized for maps of containers. - typedef typename Map::iterator Iterator; - typedef typename Map::mapped_type Container; + // This is customized for maps of containers. + typedef typename Map::iterator Iterator; + typedef typename Map::mapped_type Container; - for (auto& kv1 : map1) { - std::pair ins = map2.insert(kv1); - if (!ins.second) { // if insertion into map2 was not successful - if (is_map_of_vectors::value) { // special case for map of vectors - const Container* container1 = &(kv1.second); - Container* container2 = &(ins.first->second); - container2->insert(container2->end(), container1->begin(), container1->end()); - } // else do nothing - } + for (auto& kv1 : map1) { + std::pair ins = map2.insert(kv1); + if (!ins.second) { // if insertion into map2 was not successful + if (is_map_of_vectors::value) { // special case for map of vectors + const Container* container1 = &(kv1.second); + Container* container2 = &(ins.first->second); + container2->insert(container2->end(), container1->begin(), container1->end()); + } // else do nothing } + } } // A simple nearest-neighbor clustering algorithm @@ -122,68 +122,65 @@ void merge_map_into_map(const Map& map1, Map& map2) { // operator is called to merge them. template ForwardIt adjacent_cluster(ForwardIt first, ForwardIt last, BinaryPredicate adjacent, BinaryOp cluster) { - if (first == last) - return last; + if (first == last) + return last; - ForwardIt result = first; - while (++first != last) { - if (!adjacent(*result, *first)) { - *++result = std::move(*first); - } else { - cluster(*result, *first); - } + ForwardIt result = first; + while (++first != last) { + if (!adjacent(*result, *first)) { + *++result = std::move(*first); + } else { + cluster(*result, *first); } - return ++result; + } + return ++result; } // Textbook merge sort algorithm with the same interface as std::sort() // An internal buffer of the same size as the container is used internally. template > -void merge_sort_merge(RandomAccessIterator first, - RandomAccessIterator middle, - RandomAccessIterator last, - Compare cmp) { - const std::ptrdiff_t len = std::distance(first, last); - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::pointer pointer; - std::pair p = std::get_temporary_buffer(len); - pointer buf = p.first; - pointer buf_end = std::next(p.first, p.second); +void merge_sort_merge(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare cmp) { + const std::ptrdiff_t len = std::distance(first, last); + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::pointer pointer; + std::pair p = std::get_temporary_buffer(len); + pointer buf = p.first; + pointer buf_end = std::next(p.first, p.second); - RandomAccessIterator first1 = first; - RandomAccessIterator last1 = middle; - RandomAccessIterator first2 = middle; - RandomAccessIterator last2 = last; + RandomAccessIterator first1 = first; + RandomAccessIterator last1 = middle; + RandomAccessIterator first2 = middle; + RandomAccessIterator last2 = last; - while (first1 != last1 && first2 != last2) { - if (cmp(*first2, *first1)) { - *buf++ = *first2++; - } else { - *buf++ = *first1++; - } - } - while (first1 != last1) { - *buf++ = *first1++; - } - while (first2 != last2) { - *buf++ = *first2++; + while (first1 != last1 && first2 != last2) { + if (cmp(*first2, *first1)) { + *buf++ = *first2++; + } else { + *buf++ = *first1++; } + } + while (first1 != last1) { + *buf++ = *first1++; + } + while (first2 != last2) { + *buf++ = *first2++; + } - buf = p.first; - std::copy(buf, buf_end, first); - std::return_temporary_buffer(p.first); + buf = p.first; + std::copy(buf, buf_end, first); + std::return_temporary_buffer(p.first); } // See above template > void merge_sort(RandomAccessIterator first, RandomAccessIterator last, Compare cmp) { - const std::ptrdiff_t len = std::distance(first, last); - if (len > 1) { - RandomAccessIterator middle = std::next(first, len / 2); - merge_sort(first, middle, cmp); - merge_sort(middle, last, cmp); - merge_sort_merge(first, middle, last, cmp); - } + const std::ptrdiff_t len = std::distance(first, last); + if (len > 1) { + RandomAccessIterator middle = std::next(first, len / 2); + merge_sort(first, middle, cmp); + merge_sort(middle, last, cmp); + merge_sort_merge(first, middle, last, cmp); + } } // An extended version of the merge sort algorithm to incorporate a 3-way @@ -191,93 +188,92 @@ void merge_sort(RandomAccessIterator first, RandomAccessIterator last, Compare c // lists to be merged is empty. template void merge_sort_merge3(RandomAccessIterator first, - RandomAccessIterator one_third, - RandomAccessIterator two_third, - RandomAccessIterator last, - Compare cmp, - Compare3 cmp3) { - const std::ptrdiff_t len = std::distance(first, last); - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::pointer pointer; - std::pair p = std::get_temporary_buffer(len); - pointer buf = p.first; - pointer buf_end = std::next(p.first, p.second); + RandomAccessIterator one_third, + RandomAccessIterator two_third, + RandomAccessIterator last, + Compare cmp, + Compare3 cmp3) { + const std::ptrdiff_t len = std::distance(first, last); + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::pointer pointer; + std::pair p = std::get_temporary_buffer(len); + pointer buf = p.first; + pointer buf_end = std::next(p.first, p.second); - RandomAccessIterator first1 = first; - RandomAccessIterator last1 = one_third; - RandomAccessIterator first2 = one_third; - RandomAccessIterator last2 = two_third; - RandomAccessIterator first3 = two_third; - RandomAccessIterator last3 = last; + RandomAccessIterator first1 = first; + RandomAccessIterator last1 = one_third; + RandomAccessIterator first2 = one_third; + RandomAccessIterator last2 = two_third; + RandomAccessIterator first3 = two_third; + RandomAccessIterator last3 = last; - while (first1 != last1 && first2 != last2 && first3 != last3) { - int rr = cmp3(*first1, *first2, *first3); - if (rr == 0) { - *buf++ = *first1++; - } else if (rr == 1) { - *buf++ = *first2++; - } else if (rr == 2) { - *buf++ = *first3++; - } + while (first1 != last1 && first2 != last2 && first3 != last3) { + int rr = cmp3(*first1, *first2, *first3); + if (rr == 0) { + *buf++ = *first1++; + } else if (rr == 1) { + *buf++ = *first2++; + } else if (rr == 2) { + *buf++ = *first3++; } + } - if (first3 == last3) { - // do nothing - } else if (first2 == last2) { - first2 = first3; - last2 = last3; - } else if (first1 == last1) { - first1 = first2; - last1 = last2; - first2 = first3; - last2 = last3; - } + if (first3 == last3) { + // do nothing + } else if (first2 == last2) { + first2 = first3; + last2 = last3; + } else if (first1 == last1) { + first1 = first2; + last1 = last2; + first2 = first3; + last2 = last3; + } - while (first1 != last1 && first2 != last2) { - if (cmp(*first2, *first1)) { - *buf++ = *first2++; - } else { - *buf++ = *first1++; - } - } - while (first1 != last1) { - *buf++ = *first1++; - } - while (first2 != last2) { - *buf++ = *first2++; + while (first1 != last1 && first2 != last2) { + if (cmp(*first2, *first1)) { + *buf++ = *first2++; + } else { + *buf++ = *first1++; } + } + while (first1 != last1) { + *buf++ = *first1++; + } + while (first2 != last2) { + *buf++ = *first2++; + } - buf = p.first; - std::copy(buf, buf_end, first); - std::return_temporary_buffer(p.first); + buf = p.first; + std::copy(buf, buf_end, first); + std::return_temporary_buffer(p.first); } // See above template void merge_sort3(RandomAccessIterator first, RandomAccessIterator last, Compare cmp, Compare3 cmp3) { - const std::ptrdiff_t len = std::distance(first, last); - if (len > 1) { - RandomAccessIterator one_third = std::next(first, (len + 2) / 3); - RandomAccessIterator two_third = std::next(first, (len + 2) / 3 * 2); - merge_sort3(first, one_third, cmp, cmp3); - merge_sort3(one_third, two_third, cmp, cmp3); - merge_sort3(two_third, last, cmp, cmp3); - merge_sort_merge3(first, one_third, two_third, last, cmp, cmp3); - } + const std::ptrdiff_t len = std::distance(first, last); + if (len > 1) { + RandomAccessIterator one_third = std::next(first, (len + 2) / 3); + RandomAccessIterator two_third = std::next(first, (len + 2) / 3 * 2); + merge_sort3(first, one_third, cmp, cmp3); + merge_sort3(one_third, two_third, cmp, cmp3); + merge_sort3(two_third, last, cmp, cmp3); + merge_sort_merge3(first, one_third, two_third, last, cmp, cmp3); + } } // See above. 'Hint' is provided to force the very first division. This is needed to match FW. template void merge_sort3_with_hint( - RandomAccessIterator first, RandomAccessIterator last, Compare cmp, Compare3 cmp3, std::ptrdiff_t d) { - const std::ptrdiff_t len = std::distance(first, last); - if (len > 1) { - RandomAccessIterator one_third = std::next(first, d); - RandomAccessIterator two_third = std::next(first, d * 2); - merge_sort3(first, one_third, cmp, cmp3); - merge_sort3(one_third, two_third, cmp, cmp3); - merge_sort3(two_third, last, cmp, cmp3); - merge_sort_merge3(first, one_third, two_third, last, cmp, cmp3); - } + RandomAccessIterator first, RandomAccessIterator last, Compare cmp, Compare3 cmp3, std::ptrdiff_t d) { + const std::ptrdiff_t len = std::distance(first, last); + if (len > 1) { + RandomAccessIterator one_third = std::next(first, d); + RandomAccessIterator two_third = std::next(first, d * 2); + merge_sort3(first, one_third, cmp, cmp3); + merge_sort3(one_third, two_third, cmp, cmp3); + merge_sort3(two_third, last, cmp, cmp3); + merge_sort_merge3(first, one_third, two_third, last, cmp, cmp3); + } } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h index 3520d8e3cdf20..de6903299b4d9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h @@ -5,9 +5,9 @@ namespace emtf::phase2::rpc { - // Enums - enum Type {kRPC, kiRPC, kNone}; + // Enums + enum Type { kRPC, kiRPC, kNone }; -} +} // namespace emtf::phase2::rpc -#endif // namespace L1Trigger_L1TMuonEndCapPhase2_RPCUtils_h +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_RPCUtils_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h index 507648ec09a57..86194577465d8 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h @@ -3,44 +3,44 @@ namespace emtf::phase2::tp { - // _______________________________________________________________________ - // radians <-> degrees - float deg_to_rad(float deg); + // _______________________________________________________________________ + // radians <-> degrees + float deg_to_rad(float deg); - float rad_to_deg(float rad); + float rad_to_deg(float rad); - // _______________________________________________________________________ - // phi range: [-180..180] or [-pi..pi] - float wrap_phi_deg(float); + // _______________________________________________________________________ + // phi range: [-180..180] or [-pi..pi] + float wrap_phi_deg(float); - float wrap_phi_rad(float); + float wrap_phi_rad(float); - // _______________________________________________________________________ - // theta - float calc_theta_rad_from_eta(float); + // _______________________________________________________________________ + // theta + float calc_theta_rad_from_eta(float); - float calc_theta_deg_from_eta(float); + float calc_theta_deg_from_eta(float); - float calc_theta_deg_from_int(int); + float calc_theta_deg_from_int(int); - float calc_theta_rad_from_int(int); + float calc_theta_rad_from_int(int); - int calc_theta_int(int, float); + int calc_theta_int(int, float); - // _______________________________________________________________________ - // phi - float calc_phi_glob_deg_from_loc(int, float); + // _______________________________________________________________________ + // phi + float calc_phi_glob_deg_from_loc(int, float); - float calc_phi_glob_rad_from_loc(int, float); + float calc_phi_glob_rad_from_loc(int, float); - float calc_phi_loc_deg_from_int(int); + float calc_phi_loc_deg_from_int(int); - float calc_phi_loc_rad_from_int(int); + float calc_phi_loc_rad_from_int(int); - float calc_phi_loc_deg_from_glob(int, float); + float calc_phi_loc_deg_from_glob(int, float); - int calc_phi_int(int, float); + int calc_phi_int(int, float); -} +} // namespace emtf::phase2::tp -#endif // namespace L1Trigger_L1TMuonEndCapPhase2_TPUtils_h +#endif // namespace L1Trigger_L1TMuonEndCapPhase2_TPUtils_h diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h index 8729254506961..44547b4912065 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h @@ -10,16 +10,16 @@ namespace emtf::phase2 { - template - T when(const bool& condition, const T& if_true, const F& if_false) { - return condition ? if_true : static_cast(if_false); - } + template + T when(const bool& condition, const T& if_true, const F& if_false) { + return condition ? if_true : static_cast(if_false); + } - template - T when(const bool& condition, const T& if_true, const T& if_false) { - return condition ? if_true : if_false; - } + template + T when(const bool& condition, const T& if_true, const T& if_false) { + return condition ? if_true : if_false; + } -} +} // namespace emtf::phase2 #endif // L1Trigger_L1TMuonEndCapPhase2_TemplateUtils_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc index 1ee2233331f19..e1bad5e832e73 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc @@ -9,51 +9,41 @@ #include "L1TMuonEndCapPhase2TrackProducer.h" -L1TMuonEndCapPhase2TrackProducer::L1TMuonEndCapPhase2TrackProducer( - const edm::ParameterSet& pset -): - track_finder_(std::make_unique(pset, consumesCollector())) -{ - hit_token_ = produces(); - trk_token_ = produces(); - in_token_ = produces(); +L1TMuonEndCapPhase2TrackProducer::L1TMuonEndCapPhase2TrackProducer(const edm::ParameterSet& pset) + : track_finder_(std::make_unique(pset, consumesCollector())) { + hit_token_ = produces(); + trk_token_ = produces(); + in_token_ = produces(); } L1TMuonEndCapPhase2TrackProducer::~L1TMuonEndCapPhase2TrackProducer() { - // Do nothing + // Do nothing } void L1TMuonEndCapPhase2TrackProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.setUnknown(); + edm::ParameterSetDescription desc; + desc.setUnknown(); - descriptions.addDefault(desc); + descriptions.addDefault(desc); } void L1TMuonEndCapPhase2TrackProducer::produce(edm::Event& event, const edm::EventSetup& event_setup) { - emtf::phase2::EMTFHitCollection out_hits; - emtf::phase2::EMTFTrackCollection out_tracks; - emtf::phase2::EMTFInputCollection out_inputs; - - // Forward event to track finder - track_finder_->process( - event, event_setup, - out_hits, out_tracks, out_inputs - ); - - // Output - event.emplace(hit_token_, std::move(out_hits)); - event.emplace(trk_token_, std::move(out_tracks)); - event.emplace(in_token_ , std::move(out_inputs)); -} + emtf::phase2::EMTFHitCollection out_hits; + emtf::phase2::EMTFTrackCollection out_tracks; + emtf::phase2::EMTFInputCollection out_inputs; -void L1TMuonEndCapPhase2TrackProducer::beginStream(edm::StreamID stream_id) { - track_finder_->on_job_begin(); -} + // Forward event to track finder + track_finder_->process(event, event_setup, out_hits, out_tracks, out_inputs); -void L1TMuonEndCapPhase2TrackProducer::endStream() { - track_finder_->on_job_end(); + // Output + event.emplace(hit_token_, std::move(out_hits)); + event.emplace(trk_token_, std::move(out_tracks)); + event.emplace(in_token_, std::move(out_inputs)); } +void L1TMuonEndCapPhase2TrackProducer::beginStream(edm::StreamID stream_id) { track_finder_->on_job_begin(); } + +void L1TMuonEndCapPhase2TrackProducer::endStream() { track_finder_->on_job_end(); } + //define this as a plug-in DEFINE_FWK_MODULE(L1TMuonEndCapPhase2TrackProducer); diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h index ccf94ef13bedb..65839589762d0 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h @@ -15,33 +15,28 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" class L1TMuonEndCapPhase2TrackProducer : public edm::stream::EDProducer<> { - public: - explicit L1TMuonEndCapPhase2TrackProducer( - const edm::ParameterSet& - ); - - ~L1TMuonEndCapPhase2TrackProducer() override; - - static void fillDescriptions( - edm::ConfigurationDescriptions& - ); - - private: - std::unique_ptr track_finder_; - - edm::EDPutTokenT hit_token_; - edm::EDPutTokenT trk_token_; - edm::EDPutTokenT in_token_; - - // Producer Functions - void produce(edm::Event&, const edm::EventSetup&) override; - void beginStream(edm::StreamID) override; - void endStream() override; - // void beginRun(edm::Run const&, edm::EventSetup const&) override; - // void endRun(edm::Run const&, edm::EventSetup const&) override; - // void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; - // void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; +public: + explicit L1TMuonEndCapPhase2TrackProducer(const edm::ParameterSet&); + + ~L1TMuonEndCapPhase2TrackProducer() override; + + static void fillDescriptions(edm::ConfigurationDescriptions&); + +private: + std::unique_ptr track_finder_; + + edm::EDPutTokenT hit_token_; + edm::EDPutTokenT trk_token_; + edm::EDPutTokenT in_token_; + + // Producer Functions + void produce(edm::Event&, const edm::EventSetup&) override; + void beginStream(edm::StreamID) override; + void endStream() override; + // void beginRun(edm::Run const&, edm::EventSetup const&) override; + // void endRun(edm::Run const&, edm::EventSetup const&) override; + // void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; + // void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; }; #endif - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc index d48135a8f0bc6..2687b733c9877 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc @@ -8,134 +8,122 @@ using namespace emtf::phase2; using namespace emtf::phase2::algo; -DuplicateRemovalLayer::DuplicateRemovalLayer( - const EMTFContext& context -): - context_(context) -{ - // Do Nothing +DuplicateRemovalLayer::DuplicateRemovalLayer(const EMTFContext& context) : context_(context) { + // Do Nothing } DuplicateRemovalLayer::~DuplicateRemovalLayer() { - // Do Nothing + // Do Nothing } -void DuplicateRemovalLayer::apply( - std::vector& tracks -) const { - // =========================================================================== - // Unpack model - // --------------------------------------------------------------------------- - const auto& model = context_.model_; - const auto& model_reduced_sites = model.reduced_sites_; - - // =========================================================================== - // Build reduced tracks - // --------------------------------------------------------------------------- - std::vector reduced_tracks; - - for (const auto& track : tracks) { // Begin loop tracks - // Fetch reduced track - auto& rtrk = reduced_tracks.emplace_back(); - auto& rtrk_valid = rtrk.valid; - - // Initialize valid state - rtrk_valid = track.valid; - - // Fill reduced track with segments - for (const auto& model_rsite : model_reduced_sites) { // Begin loop reduced model sites - - // Get reduced site - int model_rsite_id = static_cast(model_rsite.id); - - auto& rsite_seg = rtrk.site_segs[model_rsite_id]; - auto& rsite_bit = rtrk.site_mask[model_rsite_id]; - - // Init reduced site - rsite_seg = 0; - rsite_bit = 0; - - // Select the first segment available for the reduced site - for (const auto& model_rs_ts : model_rsite.trk_sites) { // Begin loop reduced site track sites - int trk_site_id = static_cast(model_rs_ts); - - const auto& trk_site_seg = track.site_segs[trk_site_id]; - const auto& trk_site_bit = track.site_mask[trk_site_id]; - - if (trk_site_bit == 0) { - continue; - } - - // Attach segment - // If even one segment is attached - // the reduced track is considered valid - rtrk_valid = 1 ; - rsite_seg = trk_site_seg; - rsite_bit = 1 ; - - break; - } // End loop reduced site track sites - } // End loop reduced model sites - } // End loop tracks - - // =========================================================================== - // Find and invalidate duplicate tracks - // --------------------------------------------------------------------------- - for (unsigned int i_rtrk = 0; i_rtrk < reduced_tracks.size(); ++i_rtrk) { // Begin loop reduced tracks i - - auto& trk_i = tracks[i_rtrk]; - const auto& rtrk_i = reduced_tracks[i_rtrk]; - - if (rtrk_i.valid == 1) { - for (unsigned int j_rtrk = (i_rtrk + 1); j_rtrk < reduced_tracks.size(); ++j_rtrk) { // Begin loop reduced tracks j - - auto& rtrk_j = reduced_tracks[j_rtrk]; - - // If the reduced track is already invalid, move on - if (rtrk_j.valid == 0) - continue; - - // Compare reduced track sites - for (int k_rsite = 0; k_rsite < v3::kNumTrackSitesRM; ++k_rsite) { // Begin loop reduced sites k - const auto& rtrk_site_mask_ik = rtrk_i.site_mask[k_rsite]; - const auto& rtrk_site_mask_jk = rtrk_j.site_mask[k_rsite]; - - // If one or both of the sites are missing, move on - if (!(rtrk_site_mask_ik & rtrk_site_mask_jk)) - continue; - - // Compare segment_ids - const auto& rtrk_seg_id_ik = rtrk_i.site_segs[k_rsite]; - const auto& rtrk_seg_id_jk = rtrk_j.site_segs[k_rsite]; - - // If segment ids are differente, move on - if (rtrk_seg_id_ik != rtrk_seg_id_jk) - continue; - - // If there's even one collision, invalidate the track - rtrk_j.valid = 0; - } // End loop reduced sites k - } // End loop reduced tracks j - } +void DuplicateRemovalLayer::apply(std::vector& tracks) const { + // =========================================================================== + // Unpack model + // --------------------------------------------------------------------------- + const auto& model = context_.model_; + const auto& model_reduced_sites = model.reduced_sites_; + + // =========================================================================== + // Build reduced tracks + // --------------------------------------------------------------------------- + std::vector reduced_tracks; + + for (const auto& track : tracks) { // Begin loop tracks + // Fetch reduced track + auto& rtrk = reduced_tracks.emplace_back(); + auto& rtrk_valid = rtrk.valid; + + // Initialize valid state + rtrk_valid = track.valid; + + // Fill reduced track with segments + for (const auto& model_rsite : model_reduced_sites) { // Begin loop reduced model sites + + // Get reduced site + int model_rsite_id = static_cast(model_rsite.id); - // Propagate invalidation - trk_i.valid = rtrk_i.valid; - - // DEBUG - if (CONFIG.verbosity_ > 1) { - if (trk_i.valid) { - std::cout - << "Unique Track" - << " zone " << trk_i.zone - << " col " << trk_i.col - << " pat " << trk_i.pattern - << " qual " << trk_i.quality - << " phi " << trk_i.phi - << " theta " << trk_i.theta - << " valid " << trk_i.valid - << std::endl; - } + auto& rsite_seg = rtrk.site_segs[model_rsite_id]; + auto& rsite_bit = rtrk.site_mask[model_rsite_id]; + + // Init reduced site + rsite_seg = 0; + rsite_bit = 0; + + // Select the first segment available for the reduced site + for (const auto& model_rs_ts : model_rsite.trk_sites) { // Begin loop reduced site track sites + int trk_site_id = static_cast(model_rs_ts); + + const auto& trk_site_seg = track.site_segs[trk_site_id]; + const auto& trk_site_bit = track.site_mask[trk_site_id]; + + if (trk_site_bit == 0) { + continue; } - } // End loop reduced tracks i -} + // Attach segment + // If even one segment is attached + // the reduced track is considered valid + rtrk_valid = 1; + rsite_seg = trk_site_seg; + rsite_bit = 1; + + break; + } // End loop reduced site track sites + } // End loop reduced model sites + } // End loop tracks + + // =========================================================================== + // Find and invalidate duplicate tracks + // --------------------------------------------------------------------------- + for (unsigned int i_rtrk = 0; i_rtrk < reduced_tracks.size(); ++i_rtrk) { // Begin loop reduced tracks i + + auto& trk_i = tracks[i_rtrk]; + const auto& rtrk_i = reduced_tracks[i_rtrk]; + + if (rtrk_i.valid == 1) { + for (unsigned int j_rtrk = (i_rtrk + 1); j_rtrk < reduced_tracks.size(); + ++j_rtrk) { // Begin loop reduced tracks j + + auto& rtrk_j = reduced_tracks[j_rtrk]; + + // If the reduced track is already invalid, move on + if (rtrk_j.valid == 0) + continue; + + // Compare reduced track sites + for (int k_rsite = 0; k_rsite < v3::kNumTrackSitesRM; ++k_rsite) { // Begin loop reduced sites k + const auto& rtrk_site_mask_ik = rtrk_i.site_mask[k_rsite]; + const auto& rtrk_site_mask_jk = rtrk_j.site_mask[k_rsite]; + + // If one or both of the sites are missing, move on + if (!(rtrk_site_mask_ik & rtrk_site_mask_jk)) + continue; + + // Compare segment_ids + const auto& rtrk_seg_id_ik = rtrk_i.site_segs[k_rsite]; + const auto& rtrk_seg_id_jk = rtrk_j.site_segs[k_rsite]; + + // If segment ids are differente, move on + if (rtrk_seg_id_ik != rtrk_seg_id_jk) + continue; + + // If there's even one collision, invalidate the track + rtrk_j.valid = 0; + } // End loop reduced sites k + } // End loop reduced tracks j + } + + // Propagate invalidation + trk_i.valid = rtrk_i.valid; + + // DEBUG + if (CONFIG.verbosity_ > 1) { + if (trk_i.valid) { + std::cout << "Unique Track" + << " zone " << trk_i.zone << " col " << trk_i.col << " pat " << trk_i.pattern << " qual " + << trk_i.quality << " phi " << trk_i.phi << " theta " << trk_i.theta << " valid " << trk_i.valid + << std::endl; + } + } + } // End loop reduced tracks i +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc index 2e38079902382..b44a27f46b41a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc @@ -5,203 +5,165 @@ using namespace emtf::phase2::algo; -HitmapLayer::HitmapLayer( - const EMTFContext& context -): - context_(context) -{ - // Do Nothing +HitmapLayer::HitmapLayer(const EMTFContext& context) : context_(context) { + // Do Nothing } HitmapLayer::~HitmapLayer() { - // Do Nothing + // Do Nothing } -void HitmapLayer::apply( - const segment_collection_t& segments, - std::vector& zone_hitmaps -) const { - const hitmap_row_t padded_one = 1; - - auto& model = context_.model_; - - // Create Images - int n_zones = model.zones_.size(); - - for (int zone_id = 0; zone_id < n_zones; ++zone_id) { // Begin zones - unsigned int zone_mask = (1u << zone_id); - unsigned int tzone_mask = (1u << 0); // Only looking at BX=0 for now - - const auto& model_hm = model.zones_[zone_id].hitmap; - auto& hitmap = zone_hitmaps.emplace_back(); - bool hitmap_is_blank = true; - - int n_rows = model_hm.size(); - - for (int row_id = 0; row_id < n_rows; ++row_id) { // Begin loop rows - - const auto& model_hm_row = model_hm[row_id]; - auto& row = hitmap[row_id]; - row = 0; // Clear Row Image - - for (const auto& model_hm_site : model_hm_row) { // Begin loop sites in row - - for (const auto& model_hm_chamber : model_hm_site.chambers) { // Begin loop chambers in site - - for (int i_ch_seg = 0; i_ch_seg < v3::kChamberSegments; ++i_ch_seg) { // Begin loop segments - - const int seg_id = model_hm_chamber.id * v3::kChamberSegments + i_ch_seg; - const auto& seg = segments[seg_id]; - - // Short-Circuit: Must be valid - if (seg.valid != 1) { - continue; - } - - // Short-Circuit: Must be same zone - if ((seg.zones & zone_mask) != zone_mask) { - // Debug Info - if (CONFIG.verbosity_ > 4) { - std::cout - << "Hitmap Segment not in zone: " - << " zone " << zone_id - << " row " << row_id - << " seg_id " << seg_id - << " seg_phi " << seg.phi - << " seg_zones " << seg.zones - << " seg_tzones " << seg.tzones - << std::endl; - } - - continue; - } - - // Short-Circuit: Must be same timezone - if ((seg.tzones & tzone_mask) != tzone_mask) { - // Debug Info - if (CONFIG.verbosity_ > 4) { - std::cout - << "Hitmap Segment not in timezone: " - << " zone " << zone_id - << " row " << row_id - << " seg_id " << seg_id - << " seg_phi " << seg.phi - << " seg_zones " << seg.zones - << " seg_tzones " << seg.tzones - << std::endl; - } - - continue; - } - - // Convert emtf_phi to col: truncate the last 4 bits, hence dividing by 16 - auto col_id = static_cast(seg.phi >> v3::kHitmapColFactorLog2); - - // Debug Info - // Seg col should be in the range specified by the model chamber - if (CONFIG.verbosity_ > 4) { - std::cout - << "Hitmap Segment Before Assert" - << " zone " << zone_id - << " row " << row_id - << " col " << col_id - << " seg_id " << seg_id - << " seg_phi " << seg.phi - << " seg_zones " << seg.zones - << " seg_tzones " << seg.tzones - << " ch_col_begin " << model_hm_chamber.begin - << " ch_col_end " << model_hm_chamber.end - << std::endl; - } - - emtf_assert(model_hm_chamber.begin <= col_id && col_id < model_hm_chamber.end); - - // Short-Circuit: Joined chamber hitmap has more columns than the final image, - // so we skip the columns outside of the final hitmaps's range - // i.e. cropping the originl image - if (!(v3::kHitmapCropColStart <= col_id && col_id < v3::kHitmapCropColStop)) { - // Debug Info - if (CONFIG.verbosity_ > 4) { - std::cout - << "Hitmap Segment out of bounds: " - << " zone " << zone_id - << " row " << row_id - << " col " << col_id - << " seg_id " << seg_id - << " seg_phi " << seg.phi - << " seg_zones " << seg.zones - << " seg_tzones " << seg.tzones - << std::endl; - } - - continue; - } - - // Adjust col_id so kHitmapCropColStart is col 0 in the image - col_id -= v3::kHitmapCropColStart; - - // Calculate the 0-padded int for that column and or-it into the image - hitmap_row_t col_mask = padded_one << col_id; - row |= col_mask; - - // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout - << "Hitmap Segment" - << " zone " << zone_id - << " row " << row_id - << " col " << col_id - << " seg_id " << seg_id - << " seg_phi " << seg.phi - << " seg_zones " << seg.zones - << " seg_tzones " << seg.tzones - << std::endl; - } - } // End loop segments - - } // End loop chambers in site - - } // End loop sites in row - - // Check if hitmap is blank - if (hitmap_is_blank && row != 0) { - hitmap_is_blank = false; +void HitmapLayer::apply(const segment_collection_t& segments, std::vector& zone_hitmaps) const { + const hitmap_row_t padded_one = 1; + + auto& model = context_.model_; + + // Create Images + int n_zones = model.zones_.size(); + + for (int zone_id = 0; zone_id < n_zones; ++zone_id) { // Begin zones + unsigned int zone_mask = (1u << zone_id); + unsigned int tzone_mask = (1u << 0); // Only looking at BX=0 for now + + const auto& model_hm = model.zones_[zone_id].hitmap; + auto& hitmap = zone_hitmaps.emplace_back(); + bool hitmap_is_blank = true; + + int n_rows = model_hm.size(); + + for (int row_id = 0; row_id < n_rows; ++row_id) { // Begin loop rows + + const auto& model_hm_row = model_hm[row_id]; + auto& row = hitmap[row_id]; + row = 0; // Clear Row Image + + for (const auto& model_hm_site : model_hm_row) { // Begin loop sites in row + + for (const auto& model_hm_chamber : model_hm_site.chambers) { // Begin loop chambers in site + + for (int i_ch_seg = 0; i_ch_seg < v3::kChamberSegments; ++i_ch_seg) { // Begin loop segments + + const int seg_id = model_hm_chamber.id * v3::kChamberSegments + i_ch_seg; + const auto& seg = segments[seg_id]; + + // Short-Circuit: Must be valid + if (seg.valid != 1) { + continue; } - } // End loop rows - // Debug Info - if (CONFIG.verbosity_ > 3) { - // Short-Circuit: the image is blank - if (hitmap_is_blank) { - continue; + // Short-Circuit: Must be same zone + if ((seg.zones & zone_mask) != zone_mask) { + // Debug Info + if (CONFIG.verbosity_ > 4) { + std::cout << "Hitmap Segment not in zone: " + << " zone " << zone_id << " row " << row_id << " seg_id " << seg_id << " seg_phi " << seg.phi + << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones << std::endl; + } + + continue; } - // Pretty print - std::cout << std::endl; - std::cout << "Zone " << zone_id << " Image" << std::endl; + // Short-Circuit: Must be same timezone + if ((seg.tzones & tzone_mask) != tzone_mask) { + // Debug Info + if (CONFIG.verbosity_ > 4) { + std::cout << "Hitmap Segment not in timezone: " + << " zone " << zone_id << " row " << row_id << " seg_id " << seg_id << " seg_phi " << seg.phi + << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones << std::endl; + } - for (int row_id = (model_hm.size() - 1); 0 <= row_id; --row_id) { // Print rows in reverse order - const auto& row = hitmap[row_id]; + continue; + } - std::cout << row_id << " "; + // Convert emtf_phi to col: truncate the last 4 bits, hence dividing by 16 + auto col_id = static_cast(seg.phi >> v3::kHitmapColFactorLog2); + + // Debug Info + // Seg col should be in the range specified by the model chamber + if (CONFIG.verbosity_ > 4) { + std::cout << "Hitmap Segment Before Assert" + << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " << seg_id + << " seg_phi " << seg.phi << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones + << " ch_col_begin " << model_hm_chamber.begin << " ch_col_end " << model_hm_chamber.end + << std::endl; + } - for (int col_id = 0; col_id < v3::kHitmapNCols; ++col_id) { - hitmap_row_t pixel_mask = 1; - pixel_mask = pixel_mask << col_id; + emtf_assert(model_hm_chamber.begin <= col_id && col_id < model_hm_chamber.end); + + // Short-Circuit: Joined chamber hitmap has more columns than the final image, + // so we skip the columns outside of the final hitmaps's range + // i.e. cropping the originl image + if (!(v3::kHitmapCropColStart <= col_id && col_id < v3::kHitmapCropColStop)) { + // Debug Info + if (CONFIG.verbosity_ > 4) { + std::cout << "Hitmap Segment out of bounds: " + << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " << seg_id + << " seg_phi " << seg.phi << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones + << std::endl; + } + + continue; + } - bool is_present = (row & pixel_mask) == pixel_mask; + // Adjust col_id so kHitmapCropColStart is col 0 in the image + col_id -= v3::kHitmapCropColStart; - if (is_present) { - std::cout << "X"; - } else { - std::cout << "-"; - } - } + // Calculate the 0-padded int for that column and or-it into the image + hitmap_row_t col_mask = padded_one << col_id; + row |= col_mask; - std::cout << std::endl; + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << "Hitmap Segment" + << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " << seg_id + << " seg_phi " << seg.phi << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones + << std::endl; } + } // End loop segments + + } // End loop chambers in site + + } // End loop sites in row + + // Check if hitmap is blank + if (hitmap_is_blank && row != 0) { + hitmap_is_blank = false; + } + } // End loop rows + + // Debug Info + if (CONFIG.verbosity_ > 3) { + // Short-Circuit: the image is blank + if (hitmap_is_blank) { + continue; + } + + // Pretty print + std::cout << std::endl; + std::cout << "Zone " << zone_id << " Image" << std::endl; - std::cout << std::endl; + for (int row_id = (model_hm.size() - 1); 0 <= row_id; --row_id) { // Print rows in reverse order + const auto& row = hitmap[row_id]; + + std::cout << row_id << " "; + + for (int col_id = 0; col_id < v3::kHitmapNCols; ++col_id) { + hitmap_row_t pixel_mask = 1; + pixel_mask = pixel_mask << col_id; + + bool is_present = (row & pixel_mask) == pixel_mask; + + if (is_present) { + std::cout << "X"; + } else { + std::cout << "-"; + } } - } // End loop zones + + std::cout << std::endl; + } + + std::cout << std::endl; + } + } // End loop zones } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc index 80becc835e1cb..cab14ebdf6b29 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc @@ -10,131 +10,127 @@ using namespace emtf::phase2; using namespace emtf::phase2::algo; -OutputLayer::OutputLayer( - const EMTFContext& context -): - context_(context) -{ - // Do Nothing +OutputLayer::OutputLayer(const EMTFContext& context) : context_(context) { + // Do Nothing } OutputLayer::~OutputLayer() { - // Do Nothing + // Do Nothing } -void OutputLayer::apply( - const int& endcap, const int& sector, const int& bx, - const std::map& seg_to_hit, - const std::vector& tracks, - const bool& displaced_en, - EMTFTrackCollection& out_tracks - ) const { - const int endcap_pm = (endcap == 2) ? -1 : endcap; // 1: +endcap, -1: -endcap - - for (auto& track : tracks) { // Begin loop tracks - // Fill Site/Hit Vectors - int hit_count = 0; - - EMTFTrack::site_hits_t site_hits; - EMTFTrack::site_segs_t site_segs; - EMTFTrack::site_mask_t site_mask; - EMTFTrack::site_mask_t site_rm_mask; - - for (int i = 0; i < v3::kNumTrackSites; i++) { - // Get attached segments - const auto& site_seg_id = track.site_segs[i]; - const auto& site_bit = track.site_mask[i]; - const auto& site_rm_bit = track.site_rm_mask[i]; - - // Increase hit count - if (site_bit == 1) { - hit_count += 1; - } - - // Convert segment to hit - int hit_id = 0; - - if ((site_bit == 1) || (site_rm_bit == 1)) { - hit_id = seg_to_hit.at(site_seg_id); - } - - // Save Info - site_hits.push_back(hit_id); - site_segs.push_back(site_seg_id); - site_mask.push_back(site_bit); - site_rm_mask.push_back(site_rm_bit); - } +void OutputLayer::apply(const int& endcap, + const int& sector, + const int& bx, + const std::map& seg_to_hit, + const std::vector& tracks, + const bool& displaced_en, + EMTFTrackCollection& out_tracks) const { + const int endcap_pm = (endcap == 2) ? -1 : endcap; // 1: +endcap, -1: -endcap + + for (auto& track : tracks) { // Begin loop tracks + // Fill Site/Hit Vectors + int hit_count = 0; + + EMTFTrack::site_hits_t site_hits; + EMTFTrack::site_segs_t site_segs; + EMTFTrack::site_mask_t site_mask; + EMTFTrack::site_mask_t site_rm_mask; + + for (int i = 0; i < v3::kNumTrackSites; i++) { + // Get attached segments + const auto& site_seg_id = track.site_segs[i]; + const auto& site_bit = track.site_mask[i]; + const auto& site_rm_bit = track.site_rm_mask[i]; + + // Increase hit count + if (site_bit == 1) { + hit_count += 1; + } + + // Convert segment to hit + int hit_id = 0; + + if ((site_bit == 1) || (site_rm_bit == 1)) { + hit_id = seg_to_hit.at(site_seg_id); + } + + // Save Info + site_hits.push_back(hit_id); + site_segs.push_back(site_seg_id); + site_mask.push_back(site_bit); + site_rm_mask.push_back(site_rm_bit); + } - // Short-Circuit: Only keep tracks with hits - if (!track.valid && hit_count == 0) { - continue; - } + // Short-Circuit: Only keep tracks with hits + if (!track.valid && hit_count == 0) { + continue; + } - // Fill Feature Vector - EMTFTrack::features_t model_features; + // Fill Feature Vector + EMTFTrack::features_t model_features; - for (int i = 0; i < v3::kNumTrackFeatures; i++) { - model_features.push_back(track.features[i]); - } + for (int i = 0; i < v3::kNumTrackFeatures; i++) { + model_features.push_back(track.features[i]); + } - // Find EMTF/GMT variables - const int emtf_mode_v1 = find_emtf_mode_v1(track.site_mask); - const int emtf_mode_v2 = find_emtf_mode_v2(track.site_mask); - - // Init Parameters - auto& out_trk = out_tracks.emplace_back(); - - out_trk.setEndcap(endcap_pm); - out_trk.setSector(sector); - out_trk.setBx(bx); - out_trk.setUnconstrained(displaced_en ? 1 : 0); - out_trk.setValid(track.valid); - - out_trk.setModelPtAddress(track.pt_address); - out_trk.setModelRelsAddress(track.rels_address); - out_trk.setModelDxyAddress(track.dxy_address); - out_trk.setModelPattern(track.pattern); - out_trk.setModelQual(track.quality); - out_trk.setModelPhi(track.phi); - out_trk.setModelEta(track.theta); - out_trk.setModelFeatures(model_features); - - out_trk.setEmtfQ(track.q); - out_trk.setEmtfPt(track.pt); - out_trk.setEmtfRels(track.rels); - out_trk.setEmtfD0(std::abs(track.dxy)); - out_trk.setEmtfZ0(0); // not yet implemented - out_trk.setEmtfBeta(0); // not yet implemented - out_trk.setEmtfModeV1(emtf_mode_v1); - out_trk.setEmtfModeV2(emtf_mode_v2); - - out_trk.setSiteHits(site_hits); - out_trk.setSiteSegs(site_segs); - out_trk.setSiteMask(site_mask); - out_trk.setSiteRMMask(site_rm_mask); - } // End loop tracks -} + // Find EMTF/GMT variables + const int emtf_mode_v1 = find_emtf_mode_v1(track.site_mask); + const int emtf_mode_v2 = find_emtf_mode_v2(track.site_mask); + + // Init Parameters + auto& out_trk = out_tracks.emplace_back(); + + out_trk.setEndcap(endcap_pm); + out_trk.setSector(sector); + out_trk.setBx(bx); + out_trk.setUnconstrained(displaced_en ? 1 : 0); + out_trk.setValid(track.valid); + + out_trk.setModelPtAddress(track.pt_address); + out_trk.setModelRelsAddress(track.rels_address); + out_trk.setModelDxyAddress(track.dxy_address); + out_trk.setModelPattern(track.pattern); + out_trk.setModelQual(track.quality); + out_trk.setModelPhi(track.phi); + out_trk.setModelEta(track.theta); + out_trk.setModelFeatures(model_features); + + out_trk.setEmtfQ(track.q); + out_trk.setEmtfPt(track.pt); + out_trk.setEmtfRels(track.rels); + out_trk.setEmtfD0(std::abs(track.dxy)); + out_trk.setEmtfZ0(0); // not yet implemented + out_trk.setEmtfBeta(0); // not yet implemented + out_trk.setEmtfModeV1(emtf_mode_v1); + out_trk.setEmtfModeV2(emtf_mode_v2); + + out_trk.setSiteHits(site_hits); + out_trk.setSiteSegs(site_segs); + out_trk.setSiteMask(site_mask); + out_trk.setSiteRMMask(site_rm_mask); + } // End loop tracks +} int OutputLayer::find_emtf_mode_v1(const track_t::site_mask_t& x) const { - int mode = 0; + int mode = 0; - if (x[0] or x[9] or x[1] or x[5] or x[11]) { // ME1/1, GE1/1, ME1/2, RE1/2, ME0 - mode |= (1 << 3); - } + if (x[0] or x[9] or x[1] or x[5] or x[11]) { // ME1/1, GE1/1, ME1/2, RE1/2, ME0 + mode |= (1 << 3); + } - if (x[2] or x[10] or x[6]) { // ME2, GE2/1, RE2/2 - mode |= (1 << 2); - } + if (x[2] or x[10] or x[6]) { // ME2, GE2/1, RE2/2 + mode |= (1 << 2); + } - if (x[3] or x[7]) { // ME3, RE3 - mode |= (1 << 1); - } + if (x[3] or x[7]) { // ME3, RE3 + mode |= (1 << 1); + } - if (x[4] or x[8]) { // ME4, RE4 - mode |= (1 << 0); - } + if (x[4] or x[8]) { // ME4, RE4 + mode |= (1 << 0); + } - return mode; + return mode; } // SingleMu (12) @@ -171,22 +167,22 @@ int OutputLayer::find_emtf_mode_v1(const track_t::site_mask_t& x) const { // SingleHit (0) // - at least one station // -// Note that SingleMu, DoubleMu, TripleMu, SingleHit are mutually-exclusive categories. +// Note that SingleMu, DoubleMu, TripleMu, SingleHit are mutually-exclusive categories. int OutputLayer::find_emtf_mode_v2(const track_t::site_mask_t& x) const { - int mode = 0; - int cnt_ye11 = x[0] + x[9]; // ME1/1, GE1/1 - int cnt_ye12 = x[1] + x[5]; // ME1/2, RE1/2 - int cnt_ye22 = x[2] + x[10] + x[6]; // ME2, GE2/1, RE2/2 - int cnt_ye23 = x[3] + x[7]; // ME3, RE3 - int cnt_ye24 = x[4] + x[8]; // ME4, RE4 - int cnt_ye2a = (cnt_ye22 != 0) + (cnt_ye23 != 0) + (cnt_ye24 != 0); // - int cnt_ye2b = (cnt_ye23 != 0) + (cnt_ye24 != 0); // - int cnt_me11 = x[0]; // ME1/1 only - int cnt_me12 = x[1]; // ME1/2 only - int cnt_me14 = x[11]; // ME0 only - int cnt_me2a = (x[2] != 0) + (x[3] != 0) + (x[4] != 0); // - - // clang-format off + int mode = 0; + int cnt_ye11 = x[0] + x[9]; // ME1/1, GE1/1 + int cnt_ye12 = x[1] + x[5]; // ME1/2, RE1/2 + int cnt_ye22 = x[2] + x[10] + x[6]; // ME2, GE2/1, RE2/2 + int cnt_ye23 = x[3] + x[7]; // ME3, RE3 + int cnt_ye24 = x[4] + x[8]; // ME4, RE4 + int cnt_ye2a = (cnt_ye22 != 0) + (cnt_ye23 != 0) + (cnt_ye24 != 0); // + int cnt_ye2b = (cnt_ye23 != 0) + (cnt_ye24 != 0); // + int cnt_me11 = x[0]; // ME1/1 only + int cnt_me12 = x[1]; // ME1/2 only + int cnt_me14 = x[11]; // ME0 only + int cnt_me2a = (x[2] != 0) + (x[3] != 0) + (x[4] != 0); // + + // clang-format off // SingleMu (12) { bool rule_a_i = (cnt_me12 != 0) and (cnt_me2a >= 1); @@ -231,7 +227,6 @@ int OutputLayer::find_emtf_mode_v2(const track_t::site_mask_t& x) const { } } - // clang-format on - return mode; + // clang-format on + return mode; } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc index 25d649fd842bf..ecdf85821d5be 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc @@ -12,183 +12,145 @@ using namespace emtf::phase2; using namespace emtf::phase2::algo; -ParameterAssignmentLayer::ParameterAssignmentLayer( - const EMTFContext& context -): - context_(context) -{ - // Do Nothing +ParameterAssignmentLayer::ParameterAssignmentLayer(const EMTFContext& context) : context_(context) { + // Do Nothing } ParameterAssignmentLayer::~ParameterAssignmentLayer() { - // Do Nothing + // Do Nothing } -void ParameterAssignmentLayer::apply( - const bool& displaced_en, - std::vector& tracks -) const { - std::vector feature_sites = { - 0,1,2,3,4,5,6,7,8,9,10,11, - 0,1,2,3,4,5,6,7,8,9,10,11, - 0,1,2,3,4,11, - 0,1,2,3,4,11, - -1,-1,-1,-1 - }; - - for (auto& track : tracks) { // Begin loop tracks - // Init Parameters - track.pt = 0; - track.rels = 0; - track.dxy = 0; - track.z0 = 0; - track.beta = 0; - - track.pt_address = 0; - track.rels_address = 0; - track.dxy_address = 0; - - // Short-Circuit: Skip invalid tracks - if (track.valid == 0) { - continue; - } +void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector& tracks) const { + std::vector feature_sites = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 0, 1, 2, 3, 4, 11, 0, 1, 2, 3, 4, 11, -1, -1, -1, -1}; - // Get Features - const auto& site_mask = track.site_mask; - const auto& features = track.features; + for (auto& track : tracks) { // Begin loop tracks + // Init Parameters + track.pt = 0; + track.rels = 0; + track.dxy = 0; + track.z0 = 0; + track.beta = 0; - // Single batch of NTrackFeatures values - tensorflow::Tensor input( - tensorflow::DT_FLOAT, - {1, v3::kNumTrackFeatures} - ); + track.pt_address = 0; + track.rels_address = 0; + track.dxy_address = 0; - if (CONFIG.verbosity_ > 1) { - std::cout - << "Parameter Assignment In" - << " disp " << displaced_en - << " zone " << track.zone - << " col " << track.col - << " pat " << track.pattern - << " qual " << track.quality - << " phi " << track.phi - << " theta " << track.theta - << " features " - << std::endl; - } + // Short-Circuit: Skip invalid tracks + if (track.valid == 0) { + continue; + } - // Prepare input tensor - float* input_data = input.flat().data(); - - for (int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { - const auto& feature = features[i_feature]; - const auto& feature_site = feature_sites[i_feature]; - - bool mask_value = false; - - // Debug Info - if (CONFIG.verbosity_ > 1 && i_feature > 0) { - std::cout << " "; - } - - // Mask invalid sites - if (feature_site > -1) { - mask_value = (site_mask[feature_site] == 0); - } - - if (mask_value) { - (*input_data) = 0.; - - // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout << "0"; - } - } else { - (*input_data) = feature.to_float(); - - // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout << feature.to_float(); - } - } - - input_data++; - } + // Get Features + const auto& site_mask = track.site_mask; + const auto& features = track.features; - // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout << std::endl; - } + // Single batch of NTrackFeatures values + tensorflow::Tensor input(tensorflow::DT_FLOAT, {1, v3::kNumTrackFeatures}); - // Select TF Session - auto* session_ptr = context_.prompt_session_ptr_; + if (CONFIG.verbosity_ > 1) { + std::cout << "Parameter Assignment In" + << " disp " << displaced_en << " zone " << track.zone << " col " << track.col << " pat " + << track.pattern << " qual " << track.quality << " phi " << track.phi << " theta " << track.theta + << " features " << std::endl; + } - if (displaced_en) { - session_ptr = context_.disp_session_ptr_; - } + // Prepare input tensor + float* input_data = input.flat().data(); + + for (int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { + const auto& feature = features[i_feature]; + const auto& feature_site = feature_sites[i_feature]; - // Evaluate Prompt - std::vector outputs; - - tensorflow::run( - session_ptr, - {{"inputs", input}}, // Input layer name - {"Identity"}, // Output layer name - &outputs - ); - - // Assign parameters - if (displaced_en) { - // Read displaced pb outputs - auto pt_address = outputs[0].matrix()(0, 0); - auto rels_address = outputs[0].matrix()(0, 1); - auto dxy_address = outputs[0].matrix()(0, 2); - - track.pt_address = std::clamp(pt_address, -512, 511); - track.rels_address = std::clamp(rels_address, -512, 511); - track.dxy_address = std::clamp(dxy_address, -512, 511); - - track.q = (track.pt_address < 0); - track.pt = context_.activation_lut_.lookup_disp_pt(track.pt_address); - track.rels = context_.activation_lut_.lookup_rels(track.rels_address); - track.dxy = context_.activation_lut_.lookup_dxy(track.dxy_address); - } else { - // Read prompt pb outputs - auto pt_address = outputs[0].matrix()(0, 0); - auto rels_address = outputs[0].matrix()(0, 1); - - track.pt_address = std::clamp(pt_address, -512, 511); - track.rels_address = std::clamp(rels_address, -512, 511); - track.dxy_address = 0; - - track.q = (track.pt_address < 0); - track.pt = context_.activation_lut_.lookup_prompt_pt(track.pt_address); - track.rels = context_.activation_lut_.lookup_rels(track.rels_address); - track.dxy = 0; + bool mask_value = false; + + // Debug Info + if (CONFIG.verbosity_ > 1 && i_feature > 0) { + std::cout << " "; + } + + // Mask invalid sites + if (feature_site > -1) { + mask_value = (site_mask[feature_site] == 0); + } + + if (mask_value) { + (*input_data) = 0.; + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << "0"; } + } else { + (*input_data) = feature.to_float(); - // DEBUG + // Debug Info if (CONFIG.verbosity_ > 1) { - std::cout - << "Parameter Assignment Out" - << " disp " << displaced_en - << " zone " << track.zone - << " col " << track.col - << " pat " << track.pattern - << " qual " << track.quality - << " q " << track.q - << " pt " << track.pt - << " rels " << track.rels - << " dxy " << track.dxy - << " z0 " << track.z0 - << " phi " << track.phi - << " theta " << track.theta - << " beta " << track.beta - << " pt_address " << track.pt_address - << " rels_address " << track.rels_address - << " dxy_address " << track.dxy_address - << " valid " << track.valid - << std::endl; + std::cout << feature.to_float(); } - } // End loop tracks -} + } + + input_data++; + } + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << std::endl; + } + + // Select TF Session + auto* session_ptr = context_.prompt_session_ptr_; + + if (displaced_en) { + session_ptr = context_.disp_session_ptr_; + } + + // Evaluate Prompt + std::vector outputs; + + tensorflow::run(session_ptr, + {{"inputs", input}}, // Input layer name + {"Identity"}, // Output layer name + &outputs); + + // Assign parameters + if (displaced_en) { + // Read displaced pb outputs + auto pt_address = outputs[0].matrix()(0, 0); + auto rels_address = outputs[0].matrix()(0, 1); + auto dxy_address = outputs[0].matrix()(0, 2); + + track.pt_address = std::clamp(pt_address, -512, 511); + track.rels_address = std::clamp(rels_address, -512, 511); + track.dxy_address = std::clamp(dxy_address, -512, 511); + + track.q = (track.pt_address < 0); + track.pt = context_.activation_lut_.lookup_disp_pt(track.pt_address); + track.rels = context_.activation_lut_.lookup_rels(track.rels_address); + track.dxy = context_.activation_lut_.lookup_dxy(track.dxy_address); + } else { + // Read prompt pb outputs + auto pt_address = outputs[0].matrix()(0, 0); + auto rels_address = outputs[0].matrix()(0, 1); + + track.pt_address = std::clamp(pt_address, -512, 511); + track.rels_address = std::clamp(rels_address, -512, 511); + track.dxy_address = 0; + + track.q = (track.pt_address < 0); + track.pt = context_.activation_lut_.lookup_prompt_pt(track.pt_address); + track.rels = context_.activation_lut_.lookup_rels(track.rels_address); + track.dxy = 0; + } + + // DEBUG + if (CONFIG.verbosity_ > 1) { + std::cout << "Parameter Assignment Out" + << " disp " << displaced_en << " zone " << track.zone << " col " << track.col << " pat " + << track.pattern << " qual " << track.quality << " q " << track.q << " pt " << track.pt << " rels " + << track.rels << " dxy " << track.dxy << " z0 " << track.z0 << " phi " << track.phi << " theta " + << track.theta << " beta " << track.beta << " pt_address " << track.pt_address << " rels_address " + << track.rels_address << " dxy_address " << track.dxy_address << " valid " << track.valid << std::endl; + } + } // End loop tracks +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc index 561afe4cfb801..d7dd67157e7db 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc @@ -5,136 +5,123 @@ using namespace emtf::phase2::algo; -PatternMatchingLayer::PatternMatchingLayer( - const EMTFContext& context -): - context_(context) -{ - // Do Nothing +PatternMatchingLayer::PatternMatchingLayer(const EMTFContext& context) : context_(context) { + // Do Nothing } PatternMatchingLayer::~PatternMatchingLayer() { - // Do Nothing + // Do Nothing } -void PatternMatchingLayer::apply( - const std::vector& zone_hitmaps, - const bool& displaced_en, - std::vector& zone_roads -) const { - typedef ap_uint padded_row_t; - typedef ap_uint pattern_activation_t; - typedef std::array pattern_activation_collection_t; +void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, + const bool& displaced_en, + std::vector& zone_roads) const { + typedef ap_uint padded_row_t; + typedef ap_uint pattern_activation_t; + typedef std::array pattern_activation_collection_t; - const padded_row_t padded_one = 1; + const padded_row_t padded_one = 1; - auto& model = context_.model_; + auto& model = context_.model_; - for (unsigned int i_zone = 0; i_zone < zone_hitmaps.size(); ++i_zone) { // Loop Zones - auto& hitmap = zone_hitmaps[i_zone]; - auto* model_pc = &(model.zones_[i_zone].prompt_patterns); - auto* model_ql = &(model.zones_[i_zone].prompt_quality_lut); + for (unsigned int i_zone = 0; i_zone < zone_hitmaps.size(); ++i_zone) { // Loop Zones + auto& hitmap = zone_hitmaps[i_zone]; + auto* model_pc = &(model.zones_[i_zone].prompt_patterns); + auto* model_ql = &(model.zones_[i_zone].prompt_quality_lut); - if (displaced_en) { - model_pc = &(model.zones_[i_zone].disp_patterns); - model_ql = &(model.zones_[i_zone].disp_quality_lut); - } + if (displaced_en) { + model_pc = &(model.zones_[i_zone].disp_patterns); + model_ql = &(model.zones_[i_zone].disp_quality_lut); + } + + // Initialize roads + auto& roads = zone_roads.emplace_back(); + + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + roads[i_col].pattern = 0; + roads[i_col].quality = 0; + } + + // Apply patterns + for (unsigned int i_pattern = 0; i_pattern < model_pc->size(); ++i_pattern) { // Loop Patterns + auto& model_pat = (*model_pc)[i_pattern]; + + // Initialize activations + pattern_activation_collection_t pac; + + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + pac[i_col] = 0; + } + + // Build activations + for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { // Loop Rows + // Pad the row with zeros to cover cases where + // pattern range is out of range + auto hitmap_row = hitmap[i_row]; + auto& model_pat_row = model_pat[i_row]; + + // Pad the hitmap row on both sides using kMaxPadding + // We binary shift it to the left by kMaxPadding + // effectively padding it to the right, and since + // the bitwidth already includes both paddings + // the left is also padded + padded_row_t padded_hm_row = hitmap_row; + padded_hm_row = padded_hm_row << v3::kPatternMatchingPadding; + + // Convert the model pattern row to a padded row + padded_row_t padded_pat_row = 0; - // Initialize roads - auto& roads = zone_roads.emplace_back(); + int offset = model_pat_row.begin; + int bw = model_pat_row.end - model_pat_row.begin + 1; // Add 1 since it's an inclusive range + + for (int i_bit = 0; i_bit < bw; ++i_bit) + padded_pat_row |= (padded_one << (offset + i_bit)); + + // Slide the pattern row across the hitmap and check for 'activations' for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { - roads[i_col].pattern = 0; - roads[i_col].quality = 0; - } + // "AND" both rows together if the result is greater than 0 + // there is an activation + padded_row_t result = padded_pat_row & padded_hm_row; + + if (result > 0) + pac[i_col] = pac[i_col] | (1 << i_row); - // Apply patterns - for (unsigned int i_pattern = 0; i_pattern < model_pc->size(); ++i_pattern) { // Loop Patterns - auto& model_pat = (*model_pc)[i_pattern]; - - // Initialize activations - pattern_activation_collection_t pac; - - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { - pac[i_col] = 0; - } - - // Build activations - for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { // Loop Rows - // Pad the row with zeros to cover cases where - // pattern range is out of range - auto hitmap_row = hitmap[i_row]; - auto& model_pat_row = model_pat[i_row]; - - // Pad the hitmap row on both sides using kMaxPadding - // We binary shift it to the left by kMaxPadding - // effectively padding it to the right, and since - // the bitwidth already includes both paddings - // the left is also padded - padded_row_t padded_hm_row = hitmap_row; - padded_hm_row = padded_hm_row << v3::kPatternMatchingPadding; - - // Convert the model pattern row to a padded row - padded_row_t padded_pat_row = 0; - - int offset = model_pat_row.begin; - - int bw = model_pat_row.end - - model_pat_row.begin - + 1; // Add 1 since it's an inclusive range - - for (int i_bit = 0; i_bit < bw; ++i_bit) - padded_pat_row |= (padded_one << (offset + i_bit)); - - // Slide the pattern row across the hitmap and check for 'activations' - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { - // "AND" both rows together if the result is greater than 0 - // there is an activation - padded_row_t result = padded_pat_row & padded_hm_row; - - if (result > 0) - pac[i_col] = pac[i_col] | (1 << i_row); - - // Shift the pattern row to the left, i.e. slide it across - padded_pat_row = padded_pat_row << 1; - } - } // End Loop Rows - - // Compare Activations - // Update the road if the column's road has a smaller - // quality than the new activation's quality. - // Note: Since this is in a loop going from smallest pattern number - // to the largest, cases where the quality is the same, - // but the pattern number is larger the smaller one will be preferred - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { - auto& activation = pac[i_col]; - auto quality = (*model_ql)[activation]; - - auto& current_road = roads[i_col]; - - if (current_road.quality < quality) { - current_road.pattern = i_pattern; - current_road.quality = quality; - } - } - } // End Loop Patterns in Zones - - // Debug Info - if (CONFIG.verbosity_ > 1) { - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { - if (roads[i_col].quality == 0) { - continue; - } - - std::cout - << "Road" - << " zone " << i_zone - << " col " << i_col - << " pat " << roads[i_col].pattern - << " qual " << roads[i_col].quality - << std::endl; - } + // Shift the pattern row to the left, i.e. slide it across + padded_pat_row = padded_pat_row << 1; + } + } // End Loop Rows + + // Compare Activations + // Update the road if the column's road has a smaller + // quality than the new activation's quality. + // Note: Since this is in a loop going from smallest pattern number + // to the largest, cases where the quality is the same, + // but the pattern number is larger the smaller one will be preferred + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + auto& activation = pac[i_col]; + auto quality = (*model_ql)[activation]; + + auto& current_road = roads[i_col]; + + if (current_road.quality < quality) { + current_road.pattern = i_pattern; + current_road.quality = quality; + } + } + } // End Loop Patterns in Zones + + // Debug Info + if (CONFIG.verbosity_ > 1) { + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + if (roads[i_col].quality == 0) { + continue; } - } // End Loop Zones -} + std::cout << "Road" + << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern << " qual " + << roads[i_col].quality << std::endl; + } + } + } // End Loop Zones +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc index 750749e5116ed..c756a0894d565 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc @@ -6,183 +6,156 @@ using namespace emtf::phase2::algo; -RoadSortingLayer::RoadSortingLayer( - const EMTFContext& context -): - context_(context) -{ - // Do Nothing +RoadSortingLayer::RoadSortingLayer(const EMTFContext& context) : context_(context) { + // Do Nothing } RoadSortingLayer::~RoadSortingLayer() { - // Do Nothing + // Do Nothing } -void RoadSortingLayer::apply( - const int& first_n, - const std::vector& zone_roads, - std::vector& best_roads -) const { - // Find the best roads from each zone - std::vector top_roads; - - for (unsigned int i_zone = 0; i_zone < zone_roads.size(); ++i_zone) { // Loop Zones - - auto& roads = zone_roads[i_zone]; - - // Suppress qualities of non local maximum - road_collection_t suppressed_roads; - - { - const int last_col = v3::kHitmapNCols - 1; - - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { - bool is_local_max = true; - bool is_last_col = i_col == last_col; - bool is_first_col = i_col == 0; - - // If this is not the last column, compare it with the next column's road - // If this column has better or equal quality than the next, this is still the local max - if (is_local_max && !is_last_col) { - is_local_max &= (roads[i_col].quality >= roads[i_col + 1].quality); - } - - // If this is not the first column, compare it with the previous column's road - // If this column has better quality than the previous, this is still the local max - if (is_local_max && !is_first_col) { - is_local_max &= (roads[i_col].quality > roads[i_col - 1].quality); - } - - // Suppress qualities - if (is_local_max) { - suppressed_roads[i_col].zone = i_zone; - suppressed_roads[i_col].col = i_col; - suppressed_roads[i_col].pattern = roads[i_col].pattern; - suppressed_roads[i_col].quality = roads[i_col].quality; - } else { - // Debug Info - if (CONFIG.verbosity_ > 2 && roads[i_col].quality > 0) { - std::cout - << "Road Suppressed" - << " zone " << i_zone - << " col " << i_col - << " pat " << roads[i_col].pattern - << " qual " << roads[i_col].quality - << std::endl; - } - - // Suppress - suppressed_roads[i_col].zone = i_zone; - suppressed_roads[i_col].col = i_col; - suppressed_roads[i_col].pattern = roads[i_col].pattern; - suppressed_roads[i_col].quality = 0; - } - } +void RoadSortingLayer::apply(const int& first_n, + const std::vector& zone_roads, + std::vector& best_roads) const { + // Find the best roads from each zone + std::vector top_roads; + + for (unsigned int i_zone = 0; i_zone < zone_roads.size(); ++i_zone) { // Loop Zones + + auto& roads = zone_roads[i_zone]; + + // Suppress qualities of non local maximum + road_collection_t suppressed_roads; + + { + const int last_col = v3::kHitmapNCols - 1; + + for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + bool is_local_max = true; + bool is_last_col = i_col == last_col; + bool is_first_col = i_col == 0; + + // If this is not the last column, compare it with the next column's road + // If this column has better or equal quality than the next, this is still the local max + if (is_local_max && !is_last_col) { + is_local_max &= (roads[i_col].quality >= roads[i_col + 1].quality); } - // Keep best of every pair - const int keep_n_roads = v3::kHitmapNCols / 2; - - road_t roads_kept[keep_n_roads]; - - { - for (int i_col = 0; i_col < keep_n_roads; ++i_col) { - bool is_single = (i_col * 2 + 1) >= v3::kHitmapNCols; - - if (is_single || suppressed_roads[i_col * 2].quality > 0) { - roads_kept[i_col] = suppressed_roads[i_col * 2]; - } else { - roads_kept[i_col] = suppressed_roads[i_col * 2 + 1]; - } - - if (CONFIG.verbosity_ > 2 && roads_kept[i_col].quality > 0) { - std::cout - << "Road Kept" - << " zone " << roads_kept[i_col].zone - << " col " << roads_kept[i_col].col - << " pat " << roads_kept[i_col].pattern - << " qual " << roads_kept[i_col].quality - << std::endl; - } - } + // If this is not the first column, compare it with the previous column's road + // If this column has better quality than the previous, this is still the local max + if (is_local_max && !is_first_col) { + is_local_max &= (roads[i_col].quality > roads[i_col - 1].quality); } - // Mergesort-reduce to n best roads - // This will sort descending order (higher-value means lower-index) and keep the first n roads - - // Sort the first 32 cols since there are 144 columns and we wish to sort powers of 2, therefore 128 to keep priorities. - data::mergesort(roads_kept, 32, 16, [](const road_t& lhs, const road_t& rhs) -> int { - return lhs.quality < rhs.quality; - }); - - // Shift everything 16 cols to the left - for (int i = 16; i < keep_n_roads; ++i) { - roads_kept[i] = roads_kept[i + 16]; + // Suppress qualities + if (is_local_max) { + suppressed_roads[i_col].zone = i_zone; + suppressed_roads[i_col].col = i_col; + suppressed_roads[i_col].pattern = roads[i_col].pattern; + suppressed_roads[i_col].quality = roads[i_col].quality; + } else { + // Debug Info + if (CONFIG.verbosity_ > 2 && roads[i_col].quality > 0) { + std::cout << "Road Suppressed" + << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern << " qual " + << roads[i_col].quality << std::endl; + } + + // Suppress + suppressed_roads[i_col].zone = i_zone; + suppressed_roads[i_col].col = i_col; + suppressed_roads[i_col].pattern = roads[i_col].pattern; + suppressed_roads[i_col].quality = 0; } + } + } - // Merge-sort the remaining 128 cols - data::mergesort(roads_kept, 128, first_n, [](const road_t& lhs, const road_t& rhs) -> int { - return lhs.quality < rhs.quality; - }); - - // Collect best roads - for (int i_col = 0; i_col < first_n; ++i_col) { - top_roads.push_back(roads_kept[i_col]); + // Keep best of every pair + const int keep_n_roads = v3::kHitmapNCols / 2; + + road_t roads_kept[keep_n_roads]; + + { + for (int i_col = 0; i_col < keep_n_roads; ++i_col) { + bool is_single = (i_col * 2 + 1) >= v3::kHitmapNCols; + + if (is_single || suppressed_roads[i_col * 2].quality > 0) { + roads_kept[i_col] = suppressed_roads[i_col * 2]; + } else { + roads_kept[i_col] = suppressed_roads[i_col * 2 + 1]; } - } // End Loop Zones - - // Debug Info - if (CONFIG.verbosity_ > 2) { - for (const auto& road : top_roads) { - // Short-Circuit: Skip quality-0 roads - if (road.quality == 0) { - continue; - } - - std::cout - << "Top Road" - << " zone " << road.zone - << " col " << road.col - << " pat " << road.pattern - << " qual " << road.quality - << std::endl; + + if (CONFIG.verbosity_ > 2 && roads_kept[i_col].quality > 0) { + std::cout << "Road Kept" + << " zone " << roads_kept[i_col].zone << " col " << roads_kept[i_col].col << " pat " + << roads_kept[i_col].pattern << " qual " << roads_kept[i_col].quality << std::endl; } + } } // Mergesort-reduce to n best roads // This will sort descending order (higher-value means lower-index) and keep the first n roads - - // Sort the first 8 cols since there are 12 cols and we wish to sort powers of 2, therefore 8 to keep priorities - data::mergesort(&top_roads[0], 8, 4, [](const road_t& lhs, const road_t& rhs) -> int { - return lhs.quality < rhs.quality; - }); - // Shift everything 4 cols to the left - for (unsigned int i = 4; i < top_roads.size(); ++i) { - top_roads[i] = top_roads[i + 4]; + // Sort the first 32 cols since there are 144 columns and we wish to sort powers of 2, therefore 128 to keep priorities. + data::mergesort( + roads_kept, 32, 16, [](const road_t& lhs, const road_t& rhs) -> int { return lhs.quality < rhs.quality; }); + + // Shift everything 16 cols to the left + for (int i = 16; i < keep_n_roads; ++i) { + roads_kept[i] = roads_kept[i + 16]; } - // Merge-sort remaining 8 cols - data::mergesort(&top_roads[0], 8, first_n, [](const road_t& lhs, const road_t& rhs) -> int { - return lhs.quality < rhs.quality; + // Merge-sort the remaining 128 cols + data::mergesort(roads_kept, 128, first_n, [](const road_t& lhs, const road_t& rhs) -> int { + return lhs.quality < rhs.quality; }); // Collect best roads - for (int i_road = 0; i_road < first_n; ++i_road) { - const auto& road = top_roads[i_road]; - - best_roads.push_back(road); - - // Debug Info - if (CONFIG.verbosity_ > 1 && road.quality > 0) { - std::cout - << "Best Road " << i_road - << " zone " << road.zone - << " col " << road.col - << " pat " << road.pattern - << " qual " << road.quality + for (int i_col = 0; i_col < first_n; ++i_col) { + top_roads.push_back(roads_kept[i_col]); + } + } // End Loop Zones + + // Debug Info + if (CONFIG.verbosity_ > 2) { + for (const auto& road : top_roads) { + // Short-Circuit: Skip quality-0 roads + if (road.quality == 0) { + continue; + } + + std::cout << "Top Road" + << " zone " << road.zone << " col " << road.col << " pat " << road.pattern << " qual " << road.quality << std::endl; - } } -} + } + + // Mergesort-reduce to n best roads + // This will sort descending order (higher-value means lower-index) and keep the first n roads + + // Sort the first 8 cols since there are 12 cols and we wish to sort powers of 2, therefore 8 to keep priorities + data::mergesort( + &top_roads[0], 8, 4, [](const road_t& lhs, const road_t& rhs) -> int { return lhs.quality < rhs.quality; }); + + // Shift everything 4 cols to the left + for (unsigned int i = 4; i < top_roads.size(); ++i) { + top_roads[i] = top_roads[i + 4]; + } + // Merge-sort remaining 8 cols + data::mergesort( + &top_roads[0], 8, first_n, [](const road_t& lhs, const road_t& rhs) -> int { return lhs.quality < rhs.quality; }); + + // Collect best roads + for (int i_road = 0; i_road < first_n; ++i_road) { + const auto& road = top_roads[i_road]; + + best_roads.push_back(road); + + // Debug Info + if (CONFIG.verbosity_ > 1 && road.quality > 0) { + std::cout << "Best Road " << i_road << " zone " << road.zone << " col " << road.col << " pat " << road.pattern + << " qual " << road.quality << std::endl; + } + } +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc index d8b8a8bf742bf..77435cfa9b481 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc @@ -9,210 +9,204 @@ using namespace emtf::phase2; using namespace emtf::phase2::algo; // Static -seg_theta_t TrackBuildingLayer::calc_theta_median( - std::vector thetas -) { - auto i_last = thetas.size() - 1; - - // Sort Thetas - // This will sort ascending order (lower-value means lower-index) - data::mergesort(&thetas[0], thetas.size(), [](seg_theta_t lower_index_value, seg_theta_t larger_index_value) -> int { - return when(lower_index_value > larger_index_value, 1, 0); - }); - - // Check if any model_thm_site is null - // Since the theta array has been sorted, it's enough - // to check the last index, because the invalid value will be the max - seg_theta_t invalid_theta = -1; // This maps to 255 since it underflows - - bool any_invalid = thetas[i_last] == invalid_theta; - - // Calculate median - if (any_invalid) { - // Use the min value as the median if there are any invalid thetas - return thetas[0]; - } else { - // Calculate the median if all thetas are valid - return data::median_of_sorted(&thetas[0], thetas.size()); - } +seg_theta_t TrackBuildingLayer::calc_theta_median(std::vector thetas) { + auto i_last = thetas.size() - 1; + + // Sort Thetas + // This will sort ascending order (lower-value means lower-index) + data::mergesort(&thetas[0], thetas.size(), [](seg_theta_t lower_index_value, seg_theta_t larger_index_value) -> int { + return when(lower_index_value > larger_index_value, 1, 0); + }); + + // Check if any model_thm_site is null + // Since the theta array has been sorted, it's enough + // to check the last index, because the invalid value will be the max + seg_theta_t invalid_theta = -1; // This maps to 255 since it underflows + + bool any_invalid = thetas[i_last] == invalid_theta; + + // Calculate median + if (any_invalid) { + // Use the min value as the median if there are any invalid thetas + return thetas[0]; + } else { + // Calculate the median if all thetas are valid + return data::median_of_sorted(&thetas[0], thetas.size()); + } } // Members -TrackBuildingLayer::TrackBuildingLayer( - const EMTFContext& context -): - context_(context) -{ - // Do Nothing +TrackBuildingLayer::TrackBuildingLayer(const EMTFContext& context) : context_(context) { + // Do Nothing } TrackBuildingLayer::~TrackBuildingLayer() { - // Do Nothing + // Do Nothing } -void TrackBuildingLayer::apply( - const segment_collection_t& segments, - const std::vector& roads, - const bool& displaced_en, - std::vector& tracks -) const { - // Apply - for (unsigned int i_road = 0; i_road < roads.size(); ++i_road) { - // Get road and track - const auto& road = roads[i_road]; - auto& track = tracks.emplace_back(); - - // Initialize track - track.phi = 0; - track.theta = 0; - track.valid = 0; - - for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { - track.site_segs[site_id] = 0; - track.site_mask[site_id] = 0; - track.site_rm_mask[site_id] = 0; - } - - for (int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { - track.features[i_feature] = 0; - } +void TrackBuildingLayer::apply(const segment_collection_t& segments, + const std::vector& roads, + const bool& displaced_en, + std::vector& tracks) const { + // Apply + for (unsigned int i_road = 0; i_road < roads.size(); ++i_road) { + // Get road and track + const auto& road = roads[i_road]; + auto& track = tracks.emplace_back(); + + // Initialize track + track.phi = 0; + track.theta = 0; + track.valid = 0; - // Short-Circuit: If the road has quality-0 skip it - if (road.quality == 0) { - continue; - } - - // Debug Info - if (CONFIG.verbosity_ > 1) { - if (i_road == 0) { - std::cout << std::endl; - std::cout << "===========================================================================" << std::endl; - std::cout << "BEGIN TRACK BUILDING" << std::endl; - std::cout << "---------------------------------------------------------------------------" << std::endl; - } - - std::cout << "***************************************************************************" << std::endl; - std::cout << "Begin building track " << i_road << std::endl; - } - - // Attach segments - attach_segments(segments, road, displaced_en, track); - - // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout << "End building track " << i_road << std::endl; - - if (i_road == (roads.size() - 1)) { - std::cout << "---------------------------------------------------------------------------" << std::endl; - std::cout << "END TRACK BUILDING" << std::endl; - std::cout << "===========================================================================" << std::endl; - } - } + for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + track.site_segs[site_id] = 0; + track.site_mask[site_id] = 0; + track.site_rm_mask[site_id] = 0; } -} - -void TrackBuildingLayer::attach_segments( - const segment_collection_t& segments, - const road_t& road, - const bool& displaced_en, - track_t& track -) const { - // =========================================================================== - // Constants - // --------------------------------------------------------------------------- - seg_theta_t invalid_theta = -1; // This will map to 255 since it underflows - - // =========================================================================== - // Unpack road - // --------------------------------------------------------------------------- - // trk_col: Recall that the hitmap is 288 cols wide, and the full chamber hitmap is 315 cols; - // the chamber hitmap doesn't fit in the hitmap, so we skipped the first 27 cols. - // In order to calculate the full hitmap col, we need to add back the 27 cols that we skipped. - // sector_col: The sector's column is the center col of the phi map adding back the 27 skipped cols. - const auto trk_zone = road.zone; - const auto trk_pattern = road.pattern; - const auto trk_quality = road.quality; - - int bit_sel_zone = (1u << trk_zone); - - const trk_col_t trk_col = road.col + v3::kHitmapCropColStart; - const trk_col_t sector_col = static_cast(v3::kHitmapNCols / 2) + v3::kHitmapCropColStart; - - // =========================================================================== - // Initialize vars - // --------------------------------------------------------------------------- - std::array trk_seg_phi_diff; - std::array trk_seg_theta; - for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { - trk_seg_phi_diff[site_id] = 0; - trk_seg_theta [site_id] = 0; + for (int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { + track.features[i_feature] = 0; } - // =========================================================================== - // Unpack model - // --------------------------------------------------------------------------- - const auto& model = context_.model_; - const auto& model_hm = model.zones_[trk_zone].hitmap; - const auto& model_ftc = model.features_; + // Short-Circuit: If the road has quality-0 skip it + if (road.quality == 0) { + continue; + } - auto* model_pat = &(model.zones_[trk_zone].prompt_patterns[trk_pattern]); + // Debug Info + if (CONFIG.verbosity_ > 1) { + if (i_road == 0) { + std::cout << std::endl; + std::cout << "===========================================================================" << std::endl; + std::cout << "BEGIN TRACK BUILDING" << std::endl; + std::cout << "---------------------------------------------------------------------------" << std::endl; + } - if (displaced_en) { - model_pat = &(model.zones_[trk_zone].disp_patterns[trk_pattern]); + std::cout << "***************************************************************************" << std::endl; + std::cout << "Begin building track " << i_road << std::endl; } - // =========================================================================== - // Convert column center to emtf_phi units - // --------------------------------------------------------------------------- - // Each column is emtf_phi=1<(trk_col) << v3::kHitmapColFactorLog2) + (1 << (v3::kHitmapColFactorLog2 - 1)); - seg_phi_t sector_abs_phi = (static_cast(sector_col) << v3::kHitmapColFactorLog2) + (1 << (v3::kHitmapColFactorLog2 - 1)); - - // Calculate track phi - // Note this is the track phi with respect to the sector center - trk_feature_t trk_rel_phi = static_cast(trk_abs_phi) - static_cast(sector_abs_phi); - - // =========================================================================== - // Get pattern info for each row - // --------------------------------------------------------------------------- - std::array trk_pat_begin; - std::array trk_pat_center; - std::array trk_pat_end; - std::array trk_pat_phi; - - for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { - // Get the model pattern - const auto& model_pat_row = (*model_pat)[i_row]; - - // Offset the pattern's begin, center, and end by the track column - trk_pat_begin[i_row] = trk_col + model_pat_row.begin; - trk_pat_center[i_row] = trk_col + model_pat_row.center; - trk_pat_end[i_row] = trk_col + model_pat_row.end; - trk_pat_phi[i_row] = 0; - - // Short-Circuit: If the pattern's center is less than the padding used - // when matching the pattern to the hitmap then the pattern center is 0. - // This is because at that point, the center is out-of-bounds. - if (trk_pat_center[i_row] <= v3::kPatternMatchingPadding) - continue; + // Attach segments + attach_segments(segments, road, displaced_en, track); - // When the center is beyond the padding, then the pattern - // is in-bound, therefore we subtract the padding offset. - // To get the center in terms of the non-padded row BW we need to remove padding - // since col-padding + 1 should map to 1 in the non-padded hitmap - const auto& temp_trk_pat_center = trk_pat_center[i_row] - v3::kPatternMatchingPadding; + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << "End building track " << i_road << std::endl; - // Convert the pattern center to emtf_phi units - trk_pat_phi[i_row] = (static_cast(temp_trk_pat_center) << v3::kHitmapColFactorLog2) + (1 << (v3::kHitmapColFactorLog2 - 1)); + if (i_road == (roads.size() - 1)) { + std::cout << "---------------------------------------------------------------------------" << std::endl; + std::cout << "END TRACK BUILDING" << std::endl; + std::cout << "===========================================================================" << std::endl; + } } + } +} - // =========================================================================== - // Select segments using phi only - // --------------------------------------------------------------------------- - int n_rows = model_hm.size(); - +void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, + const road_t& road, + const bool& displaced_en, + track_t& track) const { + // =========================================================================== + // Constants + // --------------------------------------------------------------------------- + seg_theta_t invalid_theta = -1; // This will map to 255 since it underflows + + // =========================================================================== + // Unpack road + // --------------------------------------------------------------------------- + // trk_col: Recall that the hitmap is 288 cols wide, and the full chamber hitmap is 315 cols; + // the chamber hitmap doesn't fit in the hitmap, so we skipped the first 27 cols. + // In order to calculate the full hitmap col, we need to add back the 27 cols that we skipped. + // sector_col: The sector's column is the center col of the phi map adding back the 27 skipped cols. + const auto trk_zone = road.zone; + const auto trk_pattern = road.pattern; + const auto trk_quality = road.quality; + + int bit_sel_zone = (1u << trk_zone); + + const trk_col_t trk_col = road.col + v3::kHitmapCropColStart; + const trk_col_t sector_col = static_cast(v3::kHitmapNCols / 2) + v3::kHitmapCropColStart; + + // =========================================================================== + // Initialize vars + // --------------------------------------------------------------------------- + std::array trk_seg_phi_diff; + std::array trk_seg_theta; + + for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + trk_seg_phi_diff[site_id] = 0; + trk_seg_theta[site_id] = 0; + } + + // =========================================================================== + // Unpack model + // --------------------------------------------------------------------------- + const auto& model = context_.model_; + const auto& model_hm = model.zones_[trk_zone].hitmap; + const auto& model_ftc = model.features_; + + auto* model_pat = &(model.zones_[trk_zone].prompt_patterns[trk_pattern]); + + if (displaced_en) { + model_pat = &(model.zones_[trk_zone].disp_patterns[trk_pattern]); + } + + // =========================================================================== + // Convert column center to emtf_phi units + // --------------------------------------------------------------------------- + // Each column is emtf_phi=1<(trk_col) << v3::kHitmapColFactorLog2) + (1 << (v3::kHitmapColFactorLog2 - 1)); + seg_phi_t sector_abs_phi = + (static_cast(sector_col) << v3::kHitmapColFactorLog2) + (1 << (v3::kHitmapColFactorLog2 - 1)); + + // Calculate track phi + // Note this is the track phi with respect to the sector center + trk_feature_t trk_rel_phi = static_cast(trk_abs_phi) - static_cast(sector_abs_phi); + + // =========================================================================== + // Get pattern info for each row + // --------------------------------------------------------------------------- + std::array trk_pat_begin; + std::array trk_pat_center; + std::array trk_pat_end; + std::array trk_pat_phi; + + for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { + // Get the model pattern + const auto& model_pat_row = (*model_pat)[i_row]; + + // Offset the pattern's begin, center, and end by the track column + trk_pat_begin[i_row] = trk_col + model_pat_row.begin; + trk_pat_center[i_row] = trk_col + model_pat_row.center; + trk_pat_end[i_row] = trk_col + model_pat_row.end; + trk_pat_phi[i_row] = 0; + + // Short-Circuit: If the pattern's center is less than the padding used + // when matching the pattern to the hitmap then the pattern center is 0. + // This is because at that point, the center is out-of-bounds. + if (trk_pat_center[i_row] <= v3::kPatternMatchingPadding) + continue; + + // When the center is beyond the padding, then the pattern + // is in-bound, therefore we subtract the padding offset. + // To get the center in terms of the non-padded row BW we need to remove padding + // since col-padding + 1 should map to 1 in the non-padded hitmap + const auto& temp_trk_pat_center = trk_pat_center[i_row] - v3::kPatternMatchingPadding; + + // Convert the pattern center to emtf_phi units + trk_pat_phi[i_row] = (static_cast(temp_trk_pat_center) << v3::kHitmapColFactorLog2) + + (1 << (v3::kHitmapColFactorLog2 - 1)); + } + + // =========================================================================== + // Select segments using phi only + // --------------------------------------------------------------------------- + int n_rows = model_hm.size(); + + // clang-format off std::vector> site_chambers = { { 0, 1, 2, 9, 10, 11, 45}, // ME1/1 { 3, 4, 5, 12, 13, 14, 46}, // ME1/2 @@ -237,366 +231,337 @@ void TrackBuildingLayer::attach_segments( { 3, -1, -1, 0, -1, -1, 1, -1, -1, 2, -1, -1}, { 3, -1, 10, 0, 4, 5, 1, 6, 7, 2, 8, 9} }; + // clang-format on - for (int i_row = 0; i_row < n_rows; ++i_row) { // Begin loop rows + for (int i_row = 0; i_row < n_rows; ++i_row) { // Begin loop rows - const auto& model_hm_row = model_hm[i_row]; + const auto& model_hm_row = model_hm[i_row]; - const auto& trk_pat_row_begin = trk_pat_begin[i_row]; - const auto& trk_pat_row_end = trk_pat_end[i_row]; - const auto& trk_pat_row_phi = trk_pat_phi[i_row]; + const auto& trk_pat_row_begin = trk_pat_begin[i_row]; + const auto& trk_pat_row_end = trk_pat_end[i_row]; + const auto& trk_pat_row_phi = trk_pat_phi[i_row]; - if (CONFIG.verbosity_ > 2) { - std::cout - << "Pattern Row:" - << " row " << i_row - << " begin " << trk_pat_row_begin - << " end " << trk_pat_row_end - << " phi " << trk_pat_row_phi - << std::endl; - } + if (CONFIG.verbosity_ > 2) { + std::cout << "Pattern Row:" + << " row " << i_row << " begin " << trk_pat_row_begin << " end " << trk_pat_row_end << " phi " + << trk_pat_row_phi << std::endl; + } - for (const auto& model_hm_site : model_hm_row) { // Begin loop sites in row + for (const auto& model_hm_site : model_hm_row) { // Begin loop sites in row - const int site_id = static_cast(model_hm_site.id); + const int site_id = static_cast(model_hm_site.id); - auto& site_seg_id = track.site_segs [site_id]; - auto& site_bit = track.site_mask [site_id]; - auto& site_min_phi_diff = trk_seg_phi_diff[site_id]; + auto& site_seg_id = track.site_segs[site_id]; + auto& site_bit = track.site_mask[site_id]; + auto& site_min_phi_diff = trk_seg_phi_diff[site_id]; - const auto& s_chambers = site_chambers[site_id]; - const auto& s_chamber_order_id = site_chamber_orders[site_id]; - const auto& s_chamber_order = chamber_orders[s_chamber_order_id]; + const auto& s_chambers = site_chambers[site_id]; + const auto& s_chamber_order_id = site_chamber_orders[site_id]; + const auto& s_chamber_order = chamber_orders[s_chamber_order_id]; - for (const auto& chamber_idx : s_chamber_order) { // Begin loop chambers in site + for (const auto& chamber_idx : s_chamber_order) { // Begin loop chambers in site - if (chamber_idx == -1) - continue; + if (chamber_idx == -1) + continue; - int chamber_id = s_chambers[chamber_idx]; + int chamber_id = s_chambers[chamber_idx]; - for (int i_ch_seg = 0; i_ch_seg < v3::kChamberSegments; ++i_ch_seg) { // Begin loop segments + for (int i_ch_seg = 0; i_ch_seg < v3::kChamberSegments; ++i_ch_seg) { // Begin loop segments - const int seg_id = chamber_id * v3::kChamberSegments + i_ch_seg; - const auto& seg = segments[seg_id]; + const int seg_id = chamber_id * v3::kChamberSegments + i_ch_seg; + const auto& seg = segments[seg_id]; - // Short-Circuit: If the segment is invalid move on - if (!seg.valid) { - continue; - } + // Short-Circuit: If the segment is invalid move on + if (!seg.valid) { + continue; + } - // Short-Circuit: If the segment is not in the zone move on - if ((seg.zones & bit_sel_zone) != bit_sel_zone) { - continue; - } + // Short-Circuit: If the segment is not in the zone move on + if ((seg.zones & bit_sel_zone) != bit_sel_zone) { + continue; + } - // Short-Circuit: If the segment is outside of the pattern move on - const trk_col_t seg_col = (seg.phi >> 4) + v3::kPatternMatchingPadding; + // Short-Circuit: If the segment is outside of the pattern move on + const trk_col_t seg_col = (seg.phi >> 4) + v3::kPatternMatchingPadding; - if (!(trk_pat_row_begin <= seg_col && seg_col <= trk_pat_row_end)) { - continue; - } + if (!(trk_pat_row_begin <= seg_col && seg_col <= trk_pat_row_end)) { + continue; + } - // Calculate abs diff between the pattern's row phi and the segment's phi - seg_phi_t diff; + // Calculate abs diff between the pattern's row phi and the segment's phi + seg_phi_t diff; - if (trk_pat_row_phi > seg.phi) { - diff = trk_pat_row_phi - seg.phi; - } else { - diff = seg.phi - trk_pat_row_phi; - } + if (trk_pat_row_phi > seg.phi) { + diff = trk_pat_row_phi - seg.phi; + } else { + diff = seg.phi - trk_pat_row_phi; + } - if (CONFIG.verbosity_ > 2) { - std::cout - << "Site candidate:" - << " site_id " << site_id - << " seg_id " << seg_id - << " seg_phi " << seg.phi - << " seg_theta1 " << seg.theta1 - << " seg_theta2 " << seg.theta2 - << " seg_bend " << seg.bend - << std::endl; - } - - // Short-Circuit: If the difference is larger than the min diff move on - if (site_bit == 1 && site_min_phi_diff <= diff) - continue; - - // Select better segment - site_seg_id = seg_id; - site_bit = 1 ; - site_min_phi_diff = diff ; - } // End loop segments - - } // End loop chambers in site - - // Debug Info - if (CONFIG.verbosity_ > 2 && site_bit == 1) { - std::cout - << "Segment attached:" - << " site_id " << site_id - << " seg_id " << site_seg_id - << " seg_phi " << segments[site_seg_id].phi - << " seg_theta1 " << segments[site_seg_id].theta1 - << " seg_theta2 " << segments[site_seg_id].theta2 - << " seg_bend " << segments[site_seg_id].bend - << std::endl; - } - } // End loop sites in row - - } // End loop rows - - // =========================================================================== - // Calculate theta medians - // --------------------------------------------------------------------------- - const auto& model_thmc = model.theta_medians_; - - std::vector theta_medians; - - for (const auto& model_thm : model_thmc) { // Begin loop model theta medians - - std::vector group_medians; - - for (const auto& model_thm_group : model_thm) { // Begin loop theta median groups - - std::vector group; - - for (const auto& model_thm_site : model_thm_group) { // Begin loop group sites - int site_id = static_cast(model_thm_site.id); - - const auto& site_bit = track.site_mask[site_id]; - - // Initialize as invalid theta - auto& theta = group.emplace_back(invalid_theta); - - // Short-Circuit: If no segment was selected, move on. - if (site_bit == 0) - continue; - - // Get selected segment's theta value - const auto& site_seg_id = track.site_segs[site_id]; - const auto& site_seg = segments [site_seg_id]; - - if (model_thm_site.theta_id == theta_id_t::kTheta1) { - theta = site_seg.theta1; - } else if (model_thm_site.theta_id == theta_id_t::kTheta2) { - theta = site_seg.theta2; - } - - // If the segment theta is 0 this is invalid theta value - if (theta == 0) { - theta = invalid_theta; - } - } // End loop group sites - - // Calculate theta median - if (CONFIG.verbosity_ > 2) { - for (const auto& theta : group) { - std::cout - << "theta " << theta - << std::endl; - } - } - - auto group_median = calc_theta_median(group); - group_medians.push_back(group_median); - - if (CONFIG.verbosity_ > 2) { - std::cout - << "group_median " << group_median - << std::endl; - } - } // End loop theta median groups - - // Calculate model_thm_group median - auto theta_median = calc_theta_median(group_medians); - theta_medians.push_back(theta_median); - - if (CONFIG.verbosity_ > 2) { - std::cout - << "theta_median " << theta_median - << std::endl; - } - } // End loop theta medians + if (CONFIG.verbosity_ > 2) { + std::cout << "Site candidate:" + << " site_id " << site_id << " seg_id " << seg_id << " seg_phi " << seg.phi << " seg_theta1 " + << seg.theta1 << " seg_theta2 " << seg.theta2 << " seg_bend " << seg.bend << std::endl; + } - // =========================================================================== - // Select track theta - // --------------------------------------------------------------------------- - seg_theta_t trk_abs_theta; + // Short-Circuit: If the difference is larger than the min diff move on + if (site_bit == 1 && site_min_phi_diff <= diff) + continue; - if (trk_zone != 2) { - trk_abs_theta = theta_medians[0]; - } else { - trk_abs_theta = theta_medians[1]; - } + // Select better segment + site_seg_id = seg_id; + site_bit = 1; + site_min_phi_diff = diff; + } // End loop segments - // If median is invalid, try station 1 median - if (trk_abs_theta == invalid_theta) { - trk_abs_theta = theta_medians[2]; - } + } // End loop chambers in site - // If all medians are invalid use 0 (0 is an invalid theta) - if (trk_abs_theta == invalid_theta) { - trk_abs_theta = 0; - } + // Debug Info + if (CONFIG.verbosity_ > 2 && site_bit == 1) { + std::cout << "Segment attached:" + << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " << segments[site_seg_id].phi + << " seg_theta1 " << segments[site_seg_id].theta1 << " seg_theta2 " << segments[site_seg_id].theta2 + << " seg_bend " << segments[site_seg_id].bend << std::endl; + } + } // End loop sites in row - // =========================================================================== - // Compare segment theta to track theta - // --------------------------------------------------------------------------- + } // End loop rows - // if theta_window < diff, it is invalid - std::vector> site_theta_window = { - {5, 0, 2, 2, 2, 34, 0, 3, 3, 5, 6, 5}, - {5, 9, 5, 4, 5, 14, 7, 7, 7, 7, 7, 4}, - {11, 6, 5, 6, 6, 10, 8, 8, 9, 8, 0, 0} - }; + // =========================================================================== + // Calculate theta medians + // --------------------------------------------------------------------------- + const auto& model_thmc = model.theta_medians_; - if (displaced_en) { - site_theta_window = { - {14, 40, 4, 3, 3, 45, 0, 4, 4, 15, 8, 13}, - {16, 18, 7, 5, 5, 22, 7, 7, 8, 17, 9, 14}, - {26, 15, 8, 9, 9, 17, 11, 9, 10, 26, 21, 0} - }; - } + std::vector theta_medians; - for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { - auto& site_bit = track.site_mask[site_id]; - auto& site_rm_bit = track.site_rm_mask[site_id]; + for (const auto& model_thm : model_thmc) { // Begin loop model theta medians + + std::vector group_medians; + + for (const auto& model_thm_group : model_thm) { // Begin loop theta median groups + + std::vector group; - // Get Theta Window - const auto& theta_window = site_theta_window[trk_zone][site_id]; + for (const auto& model_thm_site : model_thm_group) { // Begin loop group sites + int site_id = static_cast(model_thm_site.id); + + const auto& site_bit = track.site_mask[site_id]; + + // Initialize as invalid theta + auto& theta = group.emplace_back(invalid_theta); // Short-Circuit: If no segment was selected, move on. if (site_bit == 0) - continue; + continue; + // Get selected segment's theta value const auto& site_seg_id = track.site_segs[site_id]; - const auto& site_seg = segments [site_seg_id]; - - // Init differences with out-of-bounds values - seg_theta_t diff_1 = theta_window + 1; - seg_theta_t diff_2 = theta_window + 1; - - // Calculate abs theta 1 diff - if (site_seg.theta1 != 0) { - if (site_seg.theta1 < trk_abs_theta) { - diff_1 = trk_abs_theta - site_seg.theta1; - } else { - diff_1 = site_seg.theta1 - trk_abs_theta; - } - } + const auto& site_seg = segments[site_seg_id]; - // Calculate abs theta 2 diff - if (site_seg.theta2 != 0) { - if (site_seg.theta2 < trk_abs_theta) { - diff_2 = trk_abs_theta - site_seg.theta2; - } else { - diff_2 = site_seg.theta2 - trk_abs_theta; - } + if (model_thm_site.theta_id == theta_id_t::kTheta1) { + theta = site_seg.theta1; + } else if (model_thm_site.theta_id == theta_id_t::kTheta2) { + theta = site_seg.theta2; } - // Select the theta with the smallest difference - if (diff_1 <= diff_2 && diff_1 < theta_window){ - // Select theta 1 as the correct theta value - trk_seg_theta[site_id] = site_seg.theta1; - } else if (diff_2 < theta_window){ - // Select theta 2 as the correct theta value - trk_seg_theta[site_id] = site_seg.theta2; - } else { - // Invalidate site if both differences are outside of the theta window - site_bit = 0; - site_rm_bit = 1; - - // Debug Info - if (CONFIG.verbosity_ > 4) { - std::cout - << "Segment outside of theta window; detatched:" - << " site_id " << site_id - << " seg_id " << site_seg_id - << " seg_phi " << site_seg.phi - << " seg_theta1 " << site_seg.theta1 - << " seg_theta2 " << site_seg.theta2 - << std::endl; - } + // If the segment theta is 0 this is invalid theta value + if (theta == 0) { + theta = invalid_theta; } - } + } // End loop group sites - // =========================================================================== - // Assign Data - // --------------------------------------------------------------------------- - track.zone = trk_zone; - track.col = trk_col; - track.pattern = trk_pattern; - track.quality = trk_quality; - track.phi = trk_abs_phi; - track.theta = trk_abs_theta; - track.valid = 1; - - // =========================================================================== - // Fill features - // --------------------------------------------------------------------------- - int i_feature = 0; - - for (auto& model_ft : model_ftc) { - for (auto& model_ft_site : model_ft.sites) { - int site_id = static_cast(model_ft_site); - - const auto& site_seg_id = track.site_segs[site_id]; - const auto& site_bit = track.site_mask[site_id]; - const auto& site_seg = segments [site_seg_id]; - - auto& trk_feature = track.features[i_feature++]; - - // Short-Circuit: No segment attached - if (site_bit == 0) { - continue; - } - - // Fill features - if (model_ft.id == feature_id_t::kPhi) { - // Note: This is the segment's phi with respect to the track's abs phi - trk_feature = static_cast(site_seg.phi) - static_cast(trk_abs_phi); - } else if (model_ft.id == feature_id_t::kTheta) { - // Note: This is the segment's theta with respect to the track's abs theta - trk_feature = static_cast(trk_seg_theta[site_id]) - static_cast(trk_abs_theta); - } else if (model_ft.id == feature_id_t::kBend) { - trk_feature = site_seg.bend; - } else if (model_ft.id == feature_id_t::kQuality) { - trk_feature = site_seg.qual1; - } + // Calculate theta median + if (CONFIG.verbosity_ > 2) { + for (const auto& theta : group) { + std::cout << "theta " << theta << std::endl; } + } + + auto group_median = calc_theta_median(group); + group_medians.push_back(group_median); + + if (CONFIG.verbosity_ > 2) { + std::cout << "group_median " << group_median << std::endl; + } + } // End loop theta median groups + + // Calculate model_thm_group median + auto theta_median = calc_theta_median(group_medians); + theta_medians.push_back(theta_median); + + if (CONFIG.verbosity_ > 2) { + std::cout << "theta_median " << theta_median << std::endl; } + } // End loop theta medians - // Additional features - track.features[i_feature++] = when(trk_quality > 0, trk_rel_phi, 0); - track.features[i_feature++] = when(trk_quality > 0, trk_abs_theta, 0); - track.features[i_feature++] = trk_quality; - track.features[i_feature++] = 0; // unused + // =========================================================================== + // Select track theta + // --------------------------------------------------------------------------- + seg_theta_t trk_abs_theta; - // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout - << "Track" - << " zone " << track.zone - << " col " << track.col - << " pat " << track.pattern - << " qual " << track.quality - << " sector_abs_phi " << sector_abs_phi - << " abs_phi " << track.phi - << " rel_phi " << trk_rel_phi - << " abs_theta " << track.theta - << " features " - << std::endl; - - for (int i = 0; i < v3::kNumTrackFeatures; ++i) { - if (i > 0) { - std::cout << " "; - } - - std::cout << track.features[i]; - } + if (trk_zone != 2) { + trk_abs_theta = theta_medians[0]; + } else { + trk_abs_theta = theta_medians[1]; + } - std::cout << std::endl; + // If median is invalid, try station 1 median + if (trk_abs_theta == invalid_theta) { + trk_abs_theta = theta_medians[2]; + } + + // If all medians are invalid use 0 (0 is an invalid theta) + if (trk_abs_theta == invalid_theta) { + trk_abs_theta = 0; + } + + // =========================================================================== + // Compare segment theta to track theta + // --------------------------------------------------------------------------- + + // if theta_window < diff, it is invalid + + // clang-format off + std::vector> site_theta_window = { + {5, 0, 2, 2, 2, 34, 0, 3, 3, 5, 6, 5}, + {5, 9, 5, 4, 5, 14, 7, 7, 7, 7, 7, 4}, + {11, 6, 5, 6, 6, 10, 8, 8, 9, 8, 0, 0} + }; + // clang-format on + + if (displaced_en) { + // clang-format off + site_theta_window = { + {14, 40, 4, 3, 3, 45, 0, 4, 4, 15, 8, 13}, + {16, 18, 7, 5, 5, 22, 7, 7, 8, 17, 9, 14}, + {26, 15, 8, 9, 9, 17, 11, 9, 10, 26, 21, 0} + }; + // clang-format on + } + + for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + auto& site_bit = track.site_mask[site_id]; + auto& site_rm_bit = track.site_rm_mask[site_id]; + + // Get Theta Window + const auto& theta_window = site_theta_window[trk_zone][site_id]; + + // Short-Circuit: If no segment was selected, move on. + if (site_bit == 0) + continue; + + const auto& site_seg_id = track.site_segs[site_id]; + const auto& site_seg = segments[site_seg_id]; + + // Init differences with out-of-bounds values + seg_theta_t diff_1 = theta_window + 1; + seg_theta_t diff_2 = theta_window + 1; + + // Calculate abs theta 1 diff + if (site_seg.theta1 != 0) { + if (site_seg.theta1 < trk_abs_theta) { + diff_1 = trk_abs_theta - site_seg.theta1; + } else { + diff_1 = site_seg.theta1 - trk_abs_theta; + } + } + + // Calculate abs theta 2 diff + if (site_seg.theta2 != 0) { + if (site_seg.theta2 < trk_abs_theta) { + diff_2 = trk_abs_theta - site_seg.theta2; + } else { + diff_2 = site_seg.theta2 - trk_abs_theta; + } + } + + // Select the theta with the smallest difference + if (diff_1 <= diff_2 && diff_1 < theta_window) { + // Select theta 1 as the correct theta value + trk_seg_theta[site_id] = site_seg.theta1; + } else if (diff_2 < theta_window) { + // Select theta 2 as the correct theta value + trk_seg_theta[site_id] = site_seg.theta2; + } else { + // Invalidate site if both differences are outside of the theta window + site_bit = 0; + site_rm_bit = 1; + + // Debug Info + if (CONFIG.verbosity_ > 4) { + std::cout << "Segment outside of theta window; detatched:" + << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " << site_seg.phi + << " seg_theta1 " << site_seg.theta1 << " seg_theta2 " << site_seg.theta2 << std::endl; + } + } + } + + // =========================================================================== + // Assign Data + // --------------------------------------------------------------------------- + track.zone = trk_zone; + track.col = trk_col; + track.pattern = trk_pattern; + track.quality = trk_quality; + track.phi = trk_abs_phi; + track.theta = trk_abs_theta; + track.valid = 1; + + // =========================================================================== + // Fill features + // --------------------------------------------------------------------------- + int i_feature = 0; + + for (auto& model_ft : model_ftc) { + for (auto& model_ft_site : model_ft.sites) { + int site_id = static_cast(model_ft_site); + + const auto& site_seg_id = track.site_segs[site_id]; + const auto& site_bit = track.site_mask[site_id]; + const auto& site_seg = segments[site_seg_id]; + + auto& trk_feature = track.features[i_feature++]; + + // Short-Circuit: No segment attached + if (site_bit == 0) { + continue; + } + + // Fill features + if (model_ft.id == feature_id_t::kPhi) { + // Note: This is the segment's phi with respect to the track's abs phi + trk_feature = static_cast(site_seg.phi) - static_cast(trk_abs_phi); + } else if (model_ft.id == feature_id_t::kTheta) { + // Note: This is the segment's theta with respect to the track's abs theta + trk_feature = static_cast(trk_seg_theta[site_id]) - static_cast(trk_abs_theta); + } else if (model_ft.id == feature_id_t::kBend) { + trk_feature = site_seg.bend; + } else if (model_ft.id == feature_id_t::kQuality) { + trk_feature = site_seg.qual1; + } + } + } + + // Additional features + track.features[i_feature++] = when(trk_quality > 0, trk_rel_phi, 0); + track.features[i_feature++] = when(trk_quality > 0, trk_abs_theta, 0); + track.features[i_feature++] = trk_quality; + track.features[i_feature++] = 0; // unused + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << "Track" + << " zone " << track.zone << " col " << track.col << " pat " << track.pattern << " qual " << track.quality + << " sector_abs_phi " << sector_abs_phi << " abs_phi " << track.phi << " rel_phi " << trk_rel_phi + << " abs_theta " << track.theta << " features " << std::endl; + + for (int i = 0; i < v3::kNumTrackFeatures; ++i) { + if (i > 0) { + std::cout << " "; + } + + std::cout << track.features[i]; } -} + std::cout << std::endl; + } +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc index ae5c8c31aeb6e..53bc467c1705e 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc @@ -14,213 +14,204 @@ using namespace emtf::phase2; -CSCTPCollector::CSCTPCollector( - const EMTFContext& context, - edm::ConsumesCollector& i_consumes_collector): - context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("CSCInput"))) -{ - // Do Nothing +CSCTPCollector::CSCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) + : context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("CSCInput"))) { + // Do Nothing } CSCTPCollector::~CSCTPCollector() { - // Do Nothing + // Do Nothing } -void CSCTPCollector::collect( - const edm::Event& i_event, - BXTPCMap& bx_tpc_map -) const { - edm::Handle csc_digis; - i_event.getByToken(input_token_, csc_digis); +void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { + edm::Handle csc_digis; + i_event.getByToken(input_token_, csc_digis); - // Collect - TPCollection tpc; + // Collect + TPCollection tpc; - auto chamber = csc_digis->begin(); - auto chend = csc_digis->end(); + auto chamber = csc_digis->begin(); + auto chend = csc_digis->end(); - for (; chamber != chend; ++chamber) { - auto digi = (*chamber).second.first; - auto dend = (*chamber).second.second; + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; - for (; digi != dend; ++digi) { - tpc.emplace_back((*chamber).first, *digi); - } + for (; digi != dend; ++digi) { + tpc.emplace_back((*chamber).first, *digi); } + } - // Find wires - std::map< - std::pair, - std::vector - > chamber_wires_map; - - for (auto& tp_entry : tpc) { - const auto& tp_det_id = tp_entry.tp_.detId(); - - const CSCData& tp_data = tp_entry.tp_.getCSCData(); - const int tp_bx = tp_data.bx + CONFIG.csc_bx_shift_; - const int tp_wire = tp_data.keywire; - - auto key = std::make_pair(tp_det_id.rawId(), tp_bx); - auto res = chamber_wires_map.find(key); - - if (res == chamber_wires_map.end()) { - // Case: Chamber not found - chamber_wires_map[key].push_back(tp_wire); - } else { - // Case: Chamber found - // Lookup wire if found move on, otherwise add it. - bool wire_found = false; - - auto& chamber_wires = res->second; - - for (const auto& a_wire : chamber_wires) { - // Short-Circuit: If wire matches stop - if (a_wire == tp_wire) { - wire_found = true; - break; - } - } - - // Case: Wire not found, add it. - if (!wire_found) { - chamber_wires.push_back(tp_wire); - } - } - } + // Find wires + std::map, std::vector > chamber_wires_map; - // Map to BX - for (auto& tp_entry : tpc) { - const auto& tp_det_id = tp_entry.tp_.detId(); - const CSCData& tp_data = tp_entry.tp_.getCSCData(); + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); - const int tp_endcap = tp_det_id.endcap(); // 1: +endcap, 2: -endcap - const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap - const int tp_sector = tp_det_id.triggerSector(); - const int tp_station = tp_det_id.station(); - const int tp_ring = tp_det_id.ring(); - const int tp_chamber = tp_det_id.chamber(); - const int tp_layer = tp_det_id.layer(); + const CSCData& tp_data = tp_entry.tp_.getCSCData(); + const int tp_bx = tp_data.bx + CONFIG.csc_bx_shift_; + const int tp_wire = tp_data.keywire; - const int tp_csc_id = tp_data.cscID; + auto key = std::make_pair(tp_det_id.rawId(), tp_bx); + auto res = chamber_wires_map.find(key); - const int tp_bx = tp_data.bx + CONFIG.csc_bx_shift_; + if (res == chamber_wires_map.end()) { + // Case: Chamber not found + chamber_wires_map[key].push_back(tp_wire); + } else { + // Case: Chamber found + // Lookup wire if found move on, otherwise add it. + bool wire_found = false; - // Get wires - int tp_wire1 = tp_data.keywire; - int tp_wire2 = -1; + auto& chamber_wires = res->second; - auto tp_wire_key = std::make_pair(tp_det_id.rawId(), tp_bx); - const auto& tp_wires = chamber_wires_map.at(tp_wire_key); + for (const auto& a_wire : chamber_wires) { + // Short-Circuit: If wire matches stop + if (a_wire == tp_wire) { + wire_found = true; + break; + } + } - emtf_assert((1 <= tp_wires.size()) && (tp_wires.size() <= 2)); + // Case: Wire not found, add it. + if (!wire_found) { + chamber_wires.push_back(tp_wire); + } + } + } - if (tp_wires.size() > 1) { - tp_wire1 = tp_wires.at(0); - tp_wire2 = tp_wires.at(1); - } + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const CSCData& tp_data = tp_entry.tp_.getCSCData(); - // Calculate detector info - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const auto tp_face_dir = csc::get_face_direction(tp_station, tp_ring, tp_chamber); - - // Assertion checks - const auto& [max_strip, max_wire] = csc::get_max_strip_and_wire(tp_station, tp_ring); - const auto& [max_pattern, max_quality] = csc::get_max_pattern_and_quality(tp_station, tp_ring); - - emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); - emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); - emtf_assert((0 <= tp_subsector) and (tp_subsector <= 2)); - emtf_assert(1 <= tp_station && tp_station <= 4); - emtf_assert(1 <= tp_ring && tp_ring <= 4); - emtf_assert(1 <= tp_chamber && tp_chamber <= 36); - emtf_assert(1 <= tp_csc_id && tp_csc_id <= 9); - emtf_assert(tp_data.strip < max_strip); - emtf_assert(tp_data.keywire < max_wire); - emtf_assert(tp_data.pattern < max_pattern); - emtf_assert(0 < tp_data.quality && tp_data.quality < max_quality); - emtf_assert(tp_data.valid); - - // Check for corrupted LCT data. Data corruption could occur due to software - // or hardware issues, if corrupted, reject the LCT. - if (!(tp_data.strip < max_strip)) { - edm::LogWarning("L1T") << "Found error in LCT strip: " << tp_data.strip - << " (allowed range: 0-" << max_strip - 1 << ")."; - - edm::LogWarning("L1T") - << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " - << tp_ring << ", cscid " << tp_csc_id - << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; - - continue; - } + const int tp_endcap = tp_det_id.endcap(); // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + const int tp_sector = tp_det_id.triggerSector(); + const int tp_station = tp_det_id.station(); + const int tp_ring = tp_det_id.ring(); + const int tp_chamber = tp_det_id.chamber(); + const int tp_layer = tp_det_id.layer(); - if (!(tp_data.keywire < max_wire)) { - edm::LogWarning("L1T") << "Found error in LCT wire: " << tp_data.keywire - << " (allowed range: 0-" << max_wire - 1 << ")."; + const int tp_csc_id = tp_data.cscID; - edm::LogWarning("L1T") - << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " - << tp_ring << ", cscid " << tp_csc_id - << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + const int tp_bx = tp_data.bx + CONFIG.csc_bx_shift_; - continue; - } + // Get wires + int tp_wire1 = tp_data.keywire; + int tp_wire2 = -1; - if (!(tp_data.valid == true)) { - edm::LogWarning("L1T") << "Found error in LCT valid: " << tp_data.valid << " (allowed value: 1)."; + auto tp_wire_key = std::make_pair(tp_det_id.rawId(), tp_bx); + const auto& tp_wires = chamber_wires_map.at(tp_wire_key); - edm::LogWarning("L1T") - << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " - << tp_ring << ", cscid " << tp_csc_id - << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + emtf_assert((1 <= tp_wires.size()) && (tp_wires.size() <= 2)); - continue; - } + if (tp_wires.size() > 1) { + tp_wire1 = tp_wires.at(0); + tp_wire2 = tp_wires.at(1); + } - if (!(tp_data.pattern < max_pattern)) { - edm::LogWarning("L1T") << "Found error in LCT pattern: " << tp_data.pattern - << " (allowed range: 0-" << max_pattern - 1 << ")."; + // Calculate detector info + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const auto tp_face_dir = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + const auto& [max_strip, max_wire] = csc::get_max_strip_and_wire(tp_station, tp_ring); + const auto& [max_pattern, max_quality] = csc::get_max_pattern_and_quality(tp_station, tp_ring); + + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert((0 <= tp_subsector) and (tp_subsector <= 2)); + emtf_assert(1 <= tp_station && tp_station <= 4); + emtf_assert(1 <= tp_ring && tp_ring <= 4); + emtf_assert(1 <= tp_chamber && tp_chamber <= 36); + emtf_assert(1 <= tp_csc_id && tp_csc_id <= 9); + emtf_assert(tp_data.strip < max_strip); + emtf_assert(tp_data.keywire < max_wire); + emtf_assert(tp_data.pattern < max_pattern); + emtf_assert(0 < tp_data.quality && tp_data.quality < max_quality); + emtf_assert(tp_data.valid); + + // Check for corrupted LCT data. Data corruption could occur due to software + // or hardware issues, if corrupted, reject the LCT. + if (!(tp_data.strip < max_strip)) { + edm::LogWarning("L1T") << "Found error in LCT strip: " << tp_data.strip << " (allowed range: 0-" << max_strip - 1 + << ")."; + + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + + continue; + } - edm::LogWarning("L1T") - << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " - << tp_ring << ", cscid " << tp_csc_id - << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + if (!(tp_data.keywire < max_wire)) { + edm::LogWarning("L1T") << "Found error in LCT wire: " << tp_data.keywire << " (allowed range: 0-" << max_wire - 1 + << ")."; - continue; - } + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; - if (!(0 < tp_data.quality && tp_data.quality < max_quality)) { - edm::LogWarning("L1T") << "Found error in LCT quality: " << tp_data.quality - << " (allowed range: 1-" << max_quality - 1 << ")."; + continue; + } - edm::LogWarning("L1T") - << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " - << tp_ring << ", cscid " << tp_csc_id - << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + if (!(tp_data.valid == true)) { + edm::LogWarning("L1T") << "Found error in LCT valid: " << tp_data.valid << " (allowed value: 1)."; - continue; - } + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + + continue; + } + + if (!(tp_data.pattern < max_pattern)) { + edm::LogWarning("L1T") << "Found error in LCT pattern: " << tp_data.pattern << " (allowed range: 0-" + << max_pattern - 1 << ")."; - // Add info - tp_entry.info_.bx = tp_bx; + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; - tp_entry.info_.endcap = tp_endcap; - tp_entry.info_.endcap_pm = tp_endcap_pm; - tp_entry.info_.sector = tp_sector; - tp_entry.info_.subsector = tp_subsector; - tp_entry.info_.station = tp_station; - tp_entry.info_.ring = tp_ring; - tp_entry.info_.chamber = tp_chamber; - tp_entry.info_.layer = tp_layer; + continue; + } - tp_entry.info_.csc_id = tp_csc_id; - tp_entry.info_.csc_facing = tp_face_dir; - tp_entry.info_.csc_first_wire = tp_wire1; - tp_entry.info_.csc_second_wire = tp_wire2; + if (!(0 < tp_data.quality && tp_data.quality < max_quality)) { + edm::LogWarning("L1T") << "Found error in LCT quality: " << tp_data.quality << " (allowed range: 1-" + << max_quality - 1 << ")."; - bx_tpc_map[tp_bx].push_back(tp_entry); + edm::LogWarning("L1T") + << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " + << tp_ring << ", cscid " << tp_csc_id + << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; + + continue; } + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.chamber = tp_chamber; + tp_entry.info_.layer = tp_layer; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_face_dir; + tp_entry.info_.csc_first_wire = tp_wire1; + tp_entry.info_.csc_second_wire = tp_wire2; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc index 5636af4deece1..58dcedade4939 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc @@ -15,176 +15,167 @@ using namespace emtf::phase2; -CSCTPConverter::CSCTPConverter(const EMTFContext& context, - const int& endcap, const int& sector): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +CSCTPConverter::CSCTPConverter(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } CSCTPConverter::~CSCTPConverter() { - // Do Nothing + // Do Nothing } -void CSCTPConverter::convert( - const TriggerPrimitive& tp, - const TPInfo& tp_info, - EMTFHit& hit -) const { - // Unpack Id - const auto& tp_hit_id = tp_info.hit_id; - const auto& tp_segment_id = tp_info.segment_id; - - // Unpack trigger primitive - const auto& tp_det_id = tp.detId(); - const auto& tp_data = tp.getCSCData(); - - // Unpack detector info - const auto tp_subsystem = L1TMuon::kCSC; - - const int tp_raw_id = tp_det_id.rawId(); - - const int tp_endcap_pm = tp_info.endcap_pm; - const int tp_subsector = tp_info.subsector; - const int tp_chamber = tp_info.chamber; - const int tp_station = tp_info.station; - const int tp_ring = tp_info.ring; - const int tp_layer = tp_info.layer; - - const int tp_csc_id = tp_info.csc_id; - const auto tp_csc_facing = tp_info.csc_facing; - - // Unpack data - const int tp_strip = tp_data.strip; - const int tp_strip_quart_bit = tp_data.strip_quart_bit; - const int tp_strip_eighth_bit = tp_data.strip_eighth_bit; - const int tp_strip_quart = tp_data.strip_quart; - const int tp_strip_eighth = tp_data.strip_eighth; - - const int tp_wire1 = tp_info.csc_first_wire; - const int tp_wire2 = tp_info.csc_second_wire; - - int tp_bend; - const int tp_slope = tp_data.slope; - - const int tp_bx = tp_info.bx; - const int tp_subbx = 0; // no fine resolution timing - const float tp_time = 0; // no fine resolution timing. Note: Check with Efe, Jia Fu gets this from digi directly. - - const auto tp_selection = tp_info.selection; - - const int tp_pattern = tp_data.pattern; - const int tp_quality = 6; - - // Apply CSC Run 2 pattern -> bend conversion - // Override tp_bend - constexpr int tp_bend_lut_size = 11; - constexpr int tp_bend_lut[tp_bend_lut_size] = {-5, 5, -4, 4, -3, 3, -2, 2, -1, 1, 0}; - emtf_assert(tp_pattern < tp_bend_lut_size); - tp_bend = tp_bend_lut[tp_pattern]; - tp_bend *= tp_endcap_pm; // sign flip depending on endcap - - // ID scheme used in FW - const int tp_ilink = tp_info.ilink; - - // Get Global Coordinates - const GlobalPoint& gp_w1 = GEOM.getGlobalPoint(tp); - const float glob_phi_w1 = tp::rad_to_deg(gp_w1.phi().value()); - const float glob_theta_w1 = tp::rad_to_deg(gp_w1.theta().value()); - const double glob_rho_w1 = gp_w1.perp(); - const double glob_z_w1 = gp_w1.z(); - - // Calculate EMTF Values - const int emtf_phi_w1 = tp::calc_phi_int(sector_, glob_phi_w1); - const int emtf_bend_w1 = std::clamp(tp_bend * 4, -16, 15); // 5-bit, signed - const int emtf_theta_w1 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w1); - const int emtf_qual_w1 = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned - const int emtf_site_w1 = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_host_w1 = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones_w1 = context_.zone_lut_.get_zones(emtf_host_w1, emtf_theta_w1); - - // Calculated Ambiguous Info - int emtf_theta_w2 = 0; - int emtf_qual_w2 = tp_pattern; - - if (tp_wire2 > -1) { - auto tp_w2 = tp; - - tp_w2.accessCSCData().keywire = tp_wire2; - - const GlobalPoint& gp_w2 = GEOM.getGlobalPoint(tp_w2); - const double glob_theta_w2 = tp::rad_to_deg(gp_w2.theta().value()); - - emtf_theta_w2 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w2); - } - - emtf_assert((0 <= emtf_phi_w1) and (emtf_phi_w1 < 5040)); - emtf_assert((1 <= emtf_theta_w1) and (emtf_theta_w1 < 128)); - emtf_assert((0 <= emtf_theta_w2) and (emtf_theta_w2 < 128)); - - // Get flags - const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); - const bool tp_flag_substitute = tp_info.flag_substitute; - const bool tp_flag_valid = tp_data.valid; - - // Set properties - hit.setId(tp_hit_id); - - hit.setRawDetId(tp_raw_id); - hit.setSubsystem(L1TMuon::kCSC); - hit.setEndcap(tp_endcap_pm); - hit.setSector(sector_); - hit.setSubsector(tp_subsector); - hit.setStation(tp_station); - hit.setRing(tp_ring); - hit.setLayer(tp_layer); - hit.setChamber(tp_chamber); - - hit.setCscId(tp_csc_id); - hit.setCscFR(tp_csc_facing == csc::Facing::kRear); - - hit.setStrip(tp_strip); - hit.setStripLo(tp_strip); - hit.setStripHi(tp_strip); - hit.setStripQuart(tp_strip_quart); - hit.setStripEighth(tp_strip_eighth); - hit.setStripQuartBit(tp_strip_quart_bit); - hit.setStripEighthBit(tp_strip_eighth_bit); - - hit.setWire1(tp_wire1); - hit.setWire2(tp_wire2); - - hit.setBend(tp_bend); - hit.setSlope(tp_slope); - - hit.setBx(tp_bx); - hit.setSubbx(tp_subbx); - - hit.setQuality(tp_quality); - hit.setPattern(tp_pattern); - - hit.setGlobPhi(glob_phi_w1); - hit.setGlobTheta(glob_theta_w1); - hit.setGlobPerp(glob_rho_w1); - hit.setGlobZ(glob_z_w1); - hit.setGlobTime(tp_time); - - hit.setEmtfChamber(tp_ilink); - hit.setEmtfSegment(tp_segment_id); - hit.setEmtfPhi(emtf_phi_w1); - hit.setEmtfBend(emtf_bend_w1); - hit.setEmtfTheta1(emtf_theta_w1); - hit.setEmtfTheta2(emtf_theta_w2); - hit.setEmtfQual1(emtf_qual_w1); - hit.setEmtfQual2(emtf_qual_w2); - hit.setEmtfSite(emtf_site_w1); - hit.setEmtfHost(emtf_host_w1); - hit.setEmtfZones(emtf_zones_w1); - - hit.setFlagNeighbor(tp_flag_neighbor); - hit.setFlagSubstitute(tp_flag_substitute); - hit.setFlagValid(tp_flag_valid); +void CSCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const auto& tp_segment_id = tp_info.segment_id; + + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getCSCData(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kCSC; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_chamber = tp_info.chamber; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_layer = tp_info.layer; + + const int tp_csc_id = tp_info.csc_id; + const auto tp_csc_facing = tp_info.csc_facing; + + // Unpack data + const int tp_strip = tp_data.strip; + const int tp_strip_quart_bit = tp_data.strip_quart_bit; + const int tp_strip_eighth_bit = tp_data.strip_eighth_bit; + const int tp_strip_quart = tp_data.strip_quart; + const int tp_strip_eighth = tp_data.strip_eighth; + + const int tp_wire1 = tp_info.csc_first_wire; + const int tp_wire2 = tp_info.csc_second_wire; + + int tp_bend; + const int tp_slope = tp_data.slope; + + const int tp_bx = tp_info.bx; + const int tp_subbx = 0; // no fine resolution timing + const float tp_time = 0; // no fine resolution timing. Note: Check with Efe, Jia Fu gets this from digi directly. + + const auto tp_selection = tp_info.selection; + + const int tp_pattern = tp_data.pattern; + const int tp_quality = 6; + + // Apply CSC Run 2 pattern -> bend conversion + // Override tp_bend + constexpr int tp_bend_lut_size = 11; + constexpr int tp_bend_lut[tp_bend_lut_size] = {-5, 5, -4, 4, -3, 3, -2, 2, -1, 1, 0}; + emtf_assert(tp_pattern < tp_bend_lut_size); + tp_bend = tp_bend_lut[tp_pattern]; + tp_bend *= tp_endcap_pm; // sign flip depending on endcap + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + const GlobalPoint& gp_w1 = GEOM.getGlobalPoint(tp); + const float glob_phi_w1 = tp::rad_to_deg(gp_w1.phi().value()); + const float glob_theta_w1 = tp::rad_to_deg(gp_w1.theta().value()); + const double glob_rho_w1 = gp_w1.perp(); + const double glob_z_w1 = gp_w1.z(); + + // Calculate EMTF Values + const int emtf_phi_w1 = tp::calc_phi_int(sector_, glob_phi_w1); + const int emtf_bend_w1 = std::clamp(tp_bend * 4, -16, 15); // 5-bit, signed + const int emtf_theta_w1 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w1); + const int emtf_qual_w1 = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned + const int emtf_site_w1 = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host_w1 = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones_w1 = context_.zone_lut_.get_zones(emtf_host_w1, emtf_theta_w1); + + // Calculated Ambiguous Info + int emtf_theta_w2 = 0; + int emtf_qual_w2 = tp_pattern; + + if (tp_wire2 > -1) { + auto tp_w2 = tp; + + tp_w2.accessCSCData().keywire = tp_wire2; + + const GlobalPoint& gp_w2 = GEOM.getGlobalPoint(tp_w2); + const double glob_theta_w2 = tp::rad_to_deg(gp_w2.theta().value()); + + emtf_theta_w2 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w2); + } + + emtf_assert((0 <= emtf_phi_w1) and (emtf_phi_w1 < 5040)); + emtf_assert((1 <= emtf_theta_w1) and (emtf_theta_w1 < 128)); + emtf_assert((0 <= emtf_theta_w2) and (emtf_theta_w2 < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = tp_data.valid; + + // Set properties + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(L1TMuon::kCSC); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_chamber); + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_strip); + hit.setStripLo(tp_strip); + hit.setStripHi(tp_strip); + hit.setStripQuart(tp_strip_quart); + hit.setStripEighth(tp_strip_eighth); + hit.setStripQuartBit(tp_strip_quart_bit); + hit.setStripEighthBit(tp_strip_eighth_bit); + + hit.setWire1(tp_wire1); + hit.setWire2(tp_wire2); + + hit.setBend(tp_bend); + hit.setSlope(tp_slope); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(tp_pattern); + + hit.setGlobPhi(glob_phi_w1); + hit.setGlobTheta(glob_theta_w1); + hit.setGlobPerp(glob_rho_w1); + hit.setGlobZ(glob_z_w1); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi_w1); + hit.setEmtfBend(emtf_bend_w1); + hit.setEmtfTheta1(emtf_theta_w1); + hit.setEmtfTheta2(emtf_theta_w2); + hit.setEmtfQual1(emtf_qual_w1); + hit.setEmtfQual2(emtf_qual_w2); + hit.setEmtfSite(emtf_site_w1); + hit.setEmtfHost(emtf_host_w1); + hit.setEmtfZones(emtf_zones_w1); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc index 91cd575688f5a..7c614cfa57118 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc @@ -12,143 +12,120 @@ using namespace emtf::phase2; -CSCTPSelector::CSCTPSelector( - const EMTFContext& context, - const int& endcap, const int& sector -): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +CSCTPSelector::CSCTPSelector(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } CSCTPSelector::~CSCTPSelector() { - // Do Nothing + // Do Nothing } -void CSCTPSelector::select( - const TriggerPrimitive& tp, - TPInfo tp_info, - ILinkTPCMap& ilink_tpc_map -) const { - - emtf_assert(tp.subsystem() == L1TMuon::kCSC); - - // Map CSC trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns CSC "link" index (0 - 53) - - // Short-Circuit: Link not found (ilink = -1) - if (ilink < 0) { - return; +void CSCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { + emtf_assert(tp.subsystem() == L1TMuon::kCSC); + + // Map CSC trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns CSC "link" index (0 - 53) + + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } + + // FIXME + if (ilink_tpc_map[ilink].size() < 2) { + ilink_tpc_map[ilink].emplace_back(tp, tp_info); + } else { + edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; + edm::LogWarning("L1T") << "Found 3 CSC trigger primitives in the same chamber"; + + for (int i_tp = 0; i_tp < 3; i_tp++) { + const auto& tp_err = ((i_tp < 2) ? ilink_tpc_map[ilink].at(i_tp).tp_ : tp); + + edm::LogWarning("L1T") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap " + << tp_err.detId().endcap() << ", sector " + << tp_err.detId().triggerSector() << ", station " + << tp_err.detId().station() << ", ring " << tp_err.detId().ring() + << ", chamber " << tp_err.detId().chamber() << ", CSC ID " + << tp_err.getCSCData().cscID << ": strip " << tp_err.getStrip() << ", wire " + << tp_err.getWire(); } - // FIXME - if (ilink_tpc_map[ilink].size() < 2) { - ilink_tpc_map[ilink].emplace_back(tp, tp_info); - } else { - edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; - edm::LogWarning("L1T") << "Found 3 CSC trigger primitives in the same chamber"; - - for (int i_tp = 0; i_tp < 3; i_tp++) { - const auto& tp_err = ((i_tp < 2) ? ilink_tpc_map[ilink].at(i_tp).tp_ : tp); - - edm::LogWarning("L1T") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap " - << tp_err.detId().endcap() << ", sector " - << tp_err.detId().triggerSector() << ", station " - << tp_err.detId().station() << ", ring " << tp_err.detId().ring() - << ", chamber " << tp_err.detId().chamber() << ", CSC ID " - << tp_err.getCSCData().cscID << ": strip " << tp_err.getStrip() << ", wire " - << tp_err.getWire(); - } - - edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n"; - } + edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n"; + } } // =========================================================================== // Utils // =========================================================================== -int CSCTPSelector::get_input_link( - const TriggerPrimitive& tp, - TPInfo& tp_info -) const { - int ilink = -1; - - // Unpack detector info - const int tp_endcap = tp_info.endcap; - const int tp_sector = tp_info.sector; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_ring = tp_info.ring; - const int tp_csc_id = tp_info.csc_id; - - // Find selection type - auto tp_selection = TPSelection::kNone; - - if ( - csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) - ) { - tp_selection = TPSelection::kNative; - } else if ( - CONFIG.include_neighbor_en_ - && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) - ) { - tp_selection = TPSelection::kNeighbor; - } else { // Short-Circuit: tp_selection = TPSelection::kNone - return ilink; - } +int CSCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_csc_id = tp_info.csc_id; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + tp_selection = TPSelection::kNative; + } else if (CONFIG.include_neighbor_en_ && + csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone + return ilink; + } - // Get chamber input link for this sector processor - ilink = calculate_input_link( - tp_subsector, tp_station, - tp_ring, tp_csc_id, - tp_selection - ); + // Get chamber input link for this sector processor + ilink = calculate_input_link(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); - // Add selection info - tp_info.ilink = ilink; - tp_info.selection = tp_selection; + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; - return ilink; + return ilink; } // Returns CSC input "link". Index used by FW for unique chamber identification. -int CSCTPSelector::calculate_input_link( - const int& tp_subsector, const int& tp_station, - const int& tp_ring, const int& tp_csc_id, - const TPSelection& tp_selection -) const { - int ilink = -1; - - // Links - // ME1,2,3,4 : 0..17, 18..26, 27..35, 36..44 - // ME1,2,3,4 (N) : 45..47, 48..49, 50..51, 52..53 - - if (tp_selection == TPSelection::kNative) { - const int ilink_offset = 0; - - if (tp_station == 1) { - ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); - } else { - ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); - } - - emtf_assert((0 <= ilink) && (ilink < 45)); +int CSCTPSelector::calculate_input_link(const int& tp_subsector, + const int& tp_station, + const int& tp_ring, + const int& tp_csc_id, + const TPSelection& tp_selection) const { + int ilink = -1; + + // Links + // ME1,2,3,4 : 0..17, 18..26, 27..35, 36..44 + // ME1,2,3,4 (N) : 45..47, 48..49, 50..51, 52..53 + + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 0; + + if (tp_station == 1) { + ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); } else { - const int ilink_offset = 45; + ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); + } - if (tp_station == 1) { - ilink = ilink_offset + ((tp_station - 1) * 2) + (tp_csc_id - 1) / 3; - } else if (tp_ring == 1) { - ilink = ilink_offset + ((tp_station - 1) * 2) + 1; - } else { - ilink = ilink_offset + ((tp_station - 1) * 2) + 2; - } + emtf_assert((0 <= ilink) && (ilink < 45)); + } else { + const int ilink_offset = 45; - emtf_assert((45 <= ilink) && (ilink < 54)); + if (tp_station == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + (tp_csc_id - 1) / 3; + } else if (tp_ring == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + 1; + } else { + ilink = ilink_offset + ((tp_station - 1) * 2) + 2; } - return ilink; -} + emtf_assert((45 <= ilink) && (ilink < 54)); + } + return ilink; +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc index d6d3c4433729f..0bccc42e4c53d 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc @@ -14,135 +14,129 @@ using namespace emtf::phase2; -GE0TPCollector::GE0TPCollector( - const EMTFContext& context, - edm::ConsumesCollector& i_consumes_collector): - context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("GE0Input"))) -{ - // Do Nothing +GE0TPCollector::GE0TPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) + : context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("GE0Input"))) { + // Do Nothing } GE0TPCollector::~GE0TPCollector() { - // Do Nothing + // Do Nothing } -void GE0TPCollector::collect( - const edm::Event& i_event, - BXTPCMap& bx_tpc_map) const { - // Constants - // First quarter of GE0 chamber (5 deg) and last quarter - static const int me0_max_partition = 9; - static const int me0_nstrips = 384; - static const int me0_nphipositions = me0_nstrips * 2; - static const int phiposition_q1 = me0_nphipositions / 4; - static const int phiposition_q3 = (me0_nphipositions / 4) * 3; - - // Read GE0 digis - TPCollection tpc; - - edm::Handle me0_digis; - i_event.getByToken(input_token_, me0_digis); - - auto chamber = me0_digis->begin(); - auto chend = me0_digis->end(); - - for (; chamber != chend; ++chamber) { - auto digi = (*chamber).second.first; - auto dend = (*chamber).second.second; - - for (; digi != dend; ++digi) { - tpc.emplace_back((*chamber).first, *digi); - } +void GE0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { + // Constants + // First quarter of GE0 chamber (5 deg) and last quarter + static const int me0_max_partition = 9; + static const int me0_nstrips = 384; + static const int me0_nphipositions = me0_nstrips * 2; + static const int phiposition_q1 = me0_nphipositions / 4; + static const int phiposition_q3 = (me0_nphipositions / 4) * 3; + + // Read GE0 digis + TPCollection tpc; + + edm::Handle me0_digis; + i_event.getByToken(input_token_, me0_digis); + + auto chamber = me0_digis->begin(); + auto chend = me0_digis->end(); + + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; + + for (; digi != dend; ++digi) { + tpc.emplace_back((*chamber).first, *digi); + } + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const ME0Data& tp_data = tp_entry.tp_.getME0Data(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + const int tp_station = 1; // ME0DetId station was always 1! + const int tp_ring = 4; + const int tp_layer = tp_det_id.layer(); + const int tp_roll = tp_det_id.roll(); + const int tp_me0_chamber = tp_det_id.chamber(); + + const int tp_pad = tp_data.phiposition; + const int tp_partition = tp_data.partition; + const int tp_bx = tp_data.bx + CONFIG.me0_bx_shift_; + + // Reject if outside eta of 2.4 + if (tp_partition > me0_max_partition) { + continue; } - // Map to BX - for (auto& tp_entry : tpc) { - const auto& tp_det_id = tp_entry.tp_.detId(); - const ME0Data& tp_data = tp_entry.tp_.getME0Data(); - - const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap - const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap - const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap - const int tp_station = 1; // ME0DetId station was always 1! - const int tp_ring = 4; - const int tp_layer = tp_det_id.layer(); - const int tp_roll = tp_det_id.roll(); - const int tp_me0_chamber = tp_det_id.chamber(); - - const int tp_pad = tp_data.phiposition; - const int tp_partition = tp_data.partition; - const int tp_bx = tp_data.bx + CONFIG.me0_bx_shift_; - - // Reject if outside eta of 2.4 - if (tp_partition > me0_max_partition) { - continue; - } - - // Calculate EMTF Info - // Split 20-deg chamber into 10-deg chamber - // GE0 chamber is rotated by -5 deg relative to CSC chamber. - // GE0 chamber 1 starts at -10 deg, CSC chamber 1 starts at -5 deg. - const int tp_phiposition = tp_data.phiposition; // in half-strip unit - - int tp_chamber = (tp_me0_chamber - 1) * 2 + 1; - - if (tp_endcap == 1) { - // positive endcap - // phiposition increases counter-clockwise - if (tp_phiposition < phiposition_q1) { - tp_chamber = csc::next_10deg_chamber(tp_chamber); - } else if (tp_phiposition < phiposition_q3) { - // Do nothing - } else { - tp_chamber = csc::prev_10deg_chamber(tp_chamber); - } - } else { - // negative endcap - // phiposition increases clockwise - if (tp_phiposition < phiposition_q1) { - tp_chamber = csc::prev_10deg_chamber(tp_chamber); - } else if (tp_phiposition < phiposition_q3) { - // Do nothing - } else { - tp_chamber = csc::next_10deg_chamber(tp_chamber); - } - } - - const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); - const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); - - // Assertion checks - emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); - emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); - emtf_assert((1 <= tp_subsector) and (tp_subsector <= 2)); - emtf_assert(tp_station == 1); - emtf_assert(tp_ring == 4); - emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); - emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); - emtf_assert(0 <= tp_pad && tp_pad <= 767); - emtf_assert(0 <= tp_partition && tp_partition <= 15); - - // Add info - tp_entry.info_.bx = tp_bx; - - tp_entry.info_.endcap = tp_endcap; - tp_entry.info_.endcap_pm = tp_endcap_pm; - tp_entry.info_.sector = tp_sector; - tp_entry.info_.subsector = tp_subsector; - tp_entry.info_.station = tp_station; - tp_entry.info_.ring = tp_ring; - tp_entry.info_.layer = tp_layer; - tp_entry.info_.roll = tp_roll; - tp_entry.info_.chamber = tp_chamber; - - tp_entry.info_.csc_id = tp_csc_id; - tp_entry.info_.csc_facing = tp_csc_facing; - - bx_tpc_map[tp_bx].push_back(tp_entry); + // Calculate EMTF Info + // Split 20-deg chamber into 10-deg chamber + // GE0 chamber is rotated by -5 deg relative to CSC chamber. + // GE0 chamber 1 starts at -10 deg, CSC chamber 1 starts at -5 deg. + const int tp_phiposition = tp_data.phiposition; // in half-strip unit + + int tp_chamber = (tp_me0_chamber - 1) * 2 + 1; + + if (tp_endcap == 1) { + // positive endcap + // phiposition increases counter-clockwise + if (tp_phiposition < phiposition_q1) { + tp_chamber = csc::next_10deg_chamber(tp_chamber); + } else if (tp_phiposition < phiposition_q3) { + // Do nothing + } else { + tp_chamber = csc::prev_10deg_chamber(tp_chamber); + } + } else { + // negative endcap + // phiposition increases clockwise + if (tp_phiposition < phiposition_q1) { + tp_chamber = csc::prev_10deg_chamber(tp_chamber); + } else if (tp_phiposition < phiposition_q3) { + // Do nothing + } else { + tp_chamber = csc::next_10deg_chamber(tp_chamber); + } } -} + const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert((1 <= tp_subsector) and (tp_subsector <= 2)); + emtf_assert(tp_station == 1); + emtf_assert(tp_ring == 4); + emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); + emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); + emtf_assert(0 <= tp_pad && tp_pad <= 767); + emtf_assert(0 <= tp_partition && tp_partition <= 15); + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.layer = tp_layer; + tp_entry.info_.roll = tp_roll; + tp_entry.info_.chamber = tp_chamber; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_csc_facing; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc index ddef2df408bcb..a1232ec7d2988 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc @@ -15,138 +15,130 @@ using namespace emtf::phase2; -GE0TPConverter::GE0TPConverter(const EMTFContext& context, - const int& endcap, const int& sector): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +GE0TPConverter::GE0TPConverter(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } GE0TPConverter::~GE0TPConverter() { - // Do Nothing + // Do Nothing } -void GE0TPConverter::convert( - const TriggerPrimitive& tp, - const TPInfo& tp_info, - EMTFHit& hit) const { - // Unpack Id - const auto& tp_hit_id = tp_info.hit_id; - const int tp_segment_id = tp_info.segment_id; - - // Unpack trigger primitive - const auto& tp_det_id = tp.detId(); - const auto& tp_data = tp.getME0Data(); - - // Unpack detector info - const auto tp_subsystem = L1TMuon::kME0; - - const int tp_raw_id = tp_det_id.rawId(); - - const int tp_endcap_pm = tp_info.endcap_pm; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_ring = tp_info.ring; - const int tp_layer = tp_info.layer; - // const int tp_chamber = tp_info.chamber; - - const int tp_csc_id = tp_info.csc_id; - const auto tp_csc_facing = tp_info.csc_facing; - - // Unpack data - const int tp_phiposition = tp_data.phiposition; // in half-strip unit - const int tp_partition = tp_data.partition; // in half-roll unit - - const int tp_bend = static_cast(tp_data.deltaphi) * (tp_data.bend == 0 ? 1 : -1); - - const int tp_bx = tp_info.bx; - const int tp_subbx = 0; // no fine resolution timing - const float tp_time = 0; // no fine resolution timing. - - const auto tp_selection = tp_info.selection; - - const int tp_quality = tp_data.quality; - - // ID scheme used in FW - const int tp_ilink = tp_info.ilink; - - // Get Global Coordinates - const GlobalPoint& gp = GEOM.getGlobalPoint(tp); - const float glob_phi = tp::rad_to_deg(gp.phi().value()); - const float glob_theta = tp::rad_to_deg(gp.theta().value()); - const double glob_rho = gp.perp(); - const double glob_z = gp.z(); - - // Calculate EMTF Values - const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); - const int emtf_bend = std::clamp(tp_bend / 2, -64, 63); // 7-bit, signed - const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); - const int emtf_qual = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned - const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); - - emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); - emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); - - // Get flags - const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); - const bool tp_flag_substitute = tp_info.flag_substitute; - const bool tp_flag_valid = true; // given by digi, not trigger_primitive :( - - // Set properties - hit.setId(tp_hit_id); - - hit.setRawDetId(tp_raw_id); - hit.setSubsystem(L1TMuon::kME0); - hit.setEndcap(tp_endcap_pm); - hit.setSector(sector_); - hit.setSubsector(tp_subsector); - hit.setStation(tp_station); - hit.setRing(tp_ring); - hit.setLayer(tp_layer); - hit.setChamber(tp_det_id.chamber()); // Save original chamber - - hit.setCscId(tp_csc_id); - hit.setCscFR(tp_csc_facing == csc::Facing::kRear); - - hit.setStrip(tp_phiposition); - hit.setStripLo(tp_phiposition); - hit.setStripHi(tp_phiposition); - - hit.setWire1(tp_partition); - hit.setWire2(0); - - hit.setBend(tp_bend); - - hit.setBx(tp_bx); - hit.setSubbx(tp_subbx); - - hit.setQuality(tp_quality); - hit.setPattern(0); - - hit.setGlobPhi(glob_phi); - hit.setGlobTheta(glob_theta); - hit.setGlobPerp(glob_rho); - hit.setGlobZ(glob_z); - hit.setGlobTime(tp_time); - - hit.setEmtfChamber(tp_ilink); - hit.setEmtfSegment(tp_segment_id); - hit.setEmtfPhi(emtf_phi); - hit.setEmtfBend(emtf_bend); - hit.setEmtfTheta1(emtf_theta); - hit.setEmtfTheta2(0); - hit.setEmtfQual1(emtf_qual); - hit.setEmtfQual2(0); - hit.setEmtfSite(emtf_site); - hit.setEmtfHost(emtf_host); - hit.setEmtfZones(emtf_zones); - - hit.setFlagNeighbor(tp_flag_neighbor); - hit.setFlagSubstitute(tp_flag_substitute); - hit.setFlagValid(tp_flag_valid); -} +void GE0TPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const int tp_segment_id = tp_info.segment_id; + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getME0Data(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kME0; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_layer = tp_info.layer; + // const int tp_chamber = tp_info.chamber; + + const int tp_csc_id = tp_info.csc_id; + const auto tp_csc_facing = tp_info.csc_facing; + + // Unpack data + const int tp_phiposition = tp_data.phiposition; // in half-strip unit + const int tp_partition = tp_data.partition; // in half-roll unit + + const int tp_bend = static_cast(tp_data.deltaphi) * (tp_data.bend == 0 ? 1 : -1); + + const int tp_bx = tp_info.bx; + const int tp_subbx = 0; // no fine resolution timing + const float tp_time = 0; // no fine resolution timing. + + const auto tp_selection = tp_info.selection; + + const int tp_quality = tp_data.quality; + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const float glob_phi = tp::rad_to_deg(gp.phi().value()); + const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const double glob_rho = gp.perp(); + const double glob_z = gp.z(); + + // Calculate EMTF Values + const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_bend = std::clamp(tp_bend / 2, -64, 63); // 7-bit, signed + const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_qual = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned + const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + + emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); + emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = true; // given by digi, not trigger_primitive :( + + // Set properties + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(L1TMuon::kME0); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_det_id.chamber()); // Save original chamber + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_phiposition); + hit.setStripLo(tp_phiposition); + hit.setStripHi(tp_phiposition); + + hit.setWire1(tp_partition); + hit.setWire2(0); + + hit.setBend(tp_bend); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(0); + + hit.setGlobPhi(glob_phi); + hit.setGlobTheta(glob_theta); + hit.setGlobPerp(glob_rho); + hit.setGlobZ(glob_z); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi); + hit.setEmtfBend(emtf_bend); + hit.setEmtfTheta1(emtf_theta); + hit.setEmtfTheta2(0); + hit.setEmtfQual1(emtf_qual); + hit.setEmtfQual2(0); + hit.setEmtfSite(emtf_site); + hit.setEmtfHost(emtf_host); + hit.setEmtfZones(emtf_zones); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc index 71d0cbf27527c..50e9707f48023 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc @@ -12,108 +12,86 @@ using namespace emtf::phase2; -GE0TPSelector::GE0TPSelector( - const EMTFContext& context, - const int& endcap, const int& sector -): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +GE0TPSelector::GE0TPSelector(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } GE0TPSelector::~GE0TPSelector() { - // Do Nothing + // Do Nothing } -void GE0TPSelector::select( - const TriggerPrimitive& tp, - TPInfo tp_info, - ILinkTPCMap& ilink_tpc_map -) const { - emtf_assert(tp.subsystem() == L1TMuon::kME0); +void GE0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { + emtf_assert(tp.subsystem() == L1TMuon::kME0); - // Map GE0 trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns GE0 "link" index + // Map GE0 trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns GE0 "link" index - // Short-Circuit: Link not found (ilink = -1) - if (ilink < 0) { - return; - } + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } - ilink_tpc_map[ilink].emplace_back(tp, tp_info); + ilink_tpc_map[ilink].emplace_back(tp, tp_info); } // =========================================================================== // Utils // =========================================================================== -int GE0TPSelector::get_input_link( - const TriggerPrimitive& tp, - TPInfo& tp_info -) const { - int ilink = -1; - - // Unpack detector info - const int tp_endcap = tp_info.endcap; - const int tp_sector = tp_info.sector; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_csc_id = tp_info.csc_id; - - // Find selection type - auto tp_selection = TPSelection::kNone; - - if ( - csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) - ) { - tp_selection = TPSelection::kNative; - } else if ( - CONFIG.include_neighbor_en_ - && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) - ) { - tp_selection = TPSelection::kNeighbor; - } else { // Short-Circuit: tp_selection = TPSelection::kNone - return ilink; - } - - // Get chamber input link for this sector processor - ilink = calculate_input_link( - tp_subsector, tp_csc_id, - tp_selection - ); - - // Add selection info - tp_info.ilink = ilink; - tp_info.selection = tp_selection; - +int GE0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_csc_id = tp_info.csc_id; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + tp_selection = TPSelection::kNative; + } else if (CONFIG.include_neighbor_en_ && + csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone return ilink; + } + + // Get chamber input link for this sector processor + ilink = calculate_input_link(tp_subsector, tp_csc_id, tp_selection); + + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; + + return ilink; } -int GE0TPSelector::calculate_input_link( - const int& tp_subsector, const int& tp_csc_id, - const TPSelection& tp_selection -) const { - int ilink = -1; +int GE0TPSelector::calculate_input_link(const int& tp_subsector, + const int& tp_csc_id, + const TPSelection& tp_selection) const { + int ilink = -1; - // Links - // GE0 : 108..113 - // GE0 (N) : 114 + // Links + // GE0 : 108..113 + // GE0 (N) : 114 - if (tp_selection == TPSelection::kNative) { - const int ilink_offset = 108; + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 108; - ilink = ilink_offset + ((tp_subsector - 1) * 3) + (tp_csc_id - 1); + ilink = ilink_offset + ((tp_subsector - 1) * 3) + (tp_csc_id - 1); - emtf_assert((108 <= ilink) && (ilink < 114)); - } else { - const int ilink_offset = 114; + emtf_assert((108 <= ilink) && (ilink < 114)); + } else { + const int ilink_offset = 114; - ilink = ilink_offset; + ilink = ilink_offset; - emtf_assert(ilink == ilink_offset); - } + emtf_assert(ilink == ilink_offset); + } - return ilink; + return ilink; } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc index 90190bdf92e1e..b5e96db0cf121 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc @@ -12,197 +12,184 @@ using namespace emtf::phase2; -GEMTPCollector::GEMTPCollector( - const EMTFContext& context, - edm::ConsumesCollector& i_consumes_collector): - context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("GEMInput"))) -{ - // Do Nothing +GEMTPCollector::GEMTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) + : context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("GEMInput"))) { + // Do Nothing } GEMTPCollector::~GEMTPCollector() { - // Do Nothing + // Do Nothing } -void GEMTPCollector::collect( - const edm::Event& i_event, - BXTPCMap& bx_tpc_map -) const { - // Constants - static const int max_delta_roll = 1; - static const int max_delta_pad_ge11 = 4; - static const int max_delta_pad_ge21 = 4; +void GEMTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { + // Constants + static const int max_delta_roll = 1; + static const int max_delta_pad_ge11 = 4; + static const int max_delta_pad_ge21 = 4; - // Read GEM digis - TPCollection tpc; + // Read GEM digis + TPCollection tpc; - edm::Handle gem_digis; - i_event.getByToken(input_token_, gem_digis); + edm::Handle gem_digis; + i_event.getByToken(input_token_, gem_digis); - auto chamber = gem_digis->begin(); - auto chend = gem_digis->end(); + auto chamber = gem_digis->begin(); + auto chend = gem_digis->end(); - for (; chamber != chend; ++chamber) { - auto digi = (*chamber).second.first; - auto dend = (*chamber).second.second; + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; - for (; digi != dend; ++digi) { - // Short-Circuit: Ignore invalid digis - bool tp_valid = (*digi).isValid(); + for (; digi != dend; ++digi) { + // Short-Circuit: Ignore invalid digis + bool tp_valid = (*digi).isValid(); - if (!tp_valid) { - continue; - } + if (!tp_valid) { + continue; + } - // Append digi - tpc.emplace_back((*chamber).first, *digi); - } + // Append digi + tpc.emplace_back((*chamber).first, *digi); } - - // Find Copads - std::map< - std::pair, - std::vector> - > chamber_copads_map; - - for (auto& tp_entry : tpc) { - const auto& tp_det_id = tp_entry.tp_.detId(); - const GEMData& tp_data = tp_entry.tp_.getGEMData(); - - const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap - const int tp_station = tp_det_id.station(); - const int tp_ring = tp_det_id.ring(); - const int tp_chamber = tp_det_id.chamber(); - const int tp_layer = tp_det_id.layer(); - - const uint16_t tp_roll = tp_det_id.roll(); - const uint16_t tp_pad_lo = tp_data.pad_low; - const uint16_t tp_pad_hi = tp_data.pad_hi; - - const int tp_bx = tp_data.bx + CONFIG.gem_bx_shift_; - - GEMDetId tp_mod_det_id(tp_region, tp_ring, tp_station, 0, tp_chamber, 0); - auto key = std::make_pair(tp_mod_det_id.rawId(), tp_bx); - - if (tp_layer == 1) { - // Layer 1 is incidence - // If key does not exist, insert an empty vector. If key exists, do nothing. - decltype(chamber_copads_map)::mapped_type copads; - chamber_copads_map.insert({key, copads}); - } else if (tp_layer == 2) { - // Layer 2 is coincidence - decltype(chamber_copads_map)::mapped_type::value_type copad{{ - tp_roll, - tp_pad_lo, - tp_pad_hi - }}; - chamber_copads_map[key].push_back(copad); - } + } + + // Find Copads + std::map, std::vector>> chamber_copads_map; + + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const GEMData& tp_data = tp_entry.tp_.getGEMData(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_station = tp_det_id.station(); + const int tp_ring = tp_det_id.ring(); + const int tp_chamber = tp_det_id.chamber(); + const int tp_layer = tp_det_id.layer(); + + const uint16_t tp_roll = tp_det_id.roll(); + const uint16_t tp_pad_lo = tp_data.pad_low; + const uint16_t tp_pad_hi = tp_data.pad_hi; + + const int tp_bx = tp_data.bx + CONFIG.gem_bx_shift_; + + GEMDetId tp_mod_det_id(tp_region, tp_ring, tp_station, 0, tp_chamber, 0); + auto key = std::make_pair(tp_mod_det_id.rawId(), tp_bx); + + if (tp_layer == 1) { + // Layer 1 is incidence + // If key does not exist, insert an empty vector. If key exists, do nothing. + decltype(chamber_copads_map)::mapped_type copads; + chamber_copads_map.insert({key, copads}); + } else if (tp_layer == 2) { + // Layer 2 is coincidence + decltype(chamber_copads_map)::mapped_type::value_type copad{{tp_roll, tp_pad_lo, tp_pad_hi}}; + chamber_copads_map[key].push_back(copad); } - - // Map to BX - for (auto& tp_entry : tpc) { - const auto& tp_det_id = tp_entry.tp_.detId(); - const GEMData& tp_data = tp_entry.tp_.getGEMData(); - - const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap - const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap - const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap - const int tp_station = tp_det_id.station(); - const int tp_ring = tp_det_id.ring(); - const int tp_layer = tp_det_id.layer(); - const int tp_chamber = tp_det_id.chamber(); - - const int tp_roll = tp_det_id.roll(); - const int tp_pad = (tp_data.pad_low + tp_data.pad_hi) / 2; - const int tp_pad_lo = tp_data.pad_low; - const int tp_pad_hi = tp_data.pad_hi; - - const int tp_bx = tp_data.bx + CONFIG.gem_bx_shift_; - - // Get Copad Info - GEMDetId tp_mod_det_id(tp_region, tp_ring, tp_station, 0, tp_chamber, 0); - auto tp_copads_key = std::make_pair(tp_mod_det_id.rawId(), tp_bx); - auto tp_copads = chamber_copads_map.at(tp_copads_key); - - // Check Copads - bool tp_is_substitute = false; - - if (tp_layer == 1) { - // layer 1 is used as incidence - const bool is_ge21 = (tp_station == 2); - - auto match_fn = [&tp_roll, &tp_pad_lo, &tp_pad_hi, &is_ge21](const std::array& elem) { - // Unpack entry - // Compare roll and (pad_lo, pad_hi)-range with tolerance - const auto& [c_roll_tmp, c_pad_lo_tmp, c_pad_hi_tmp] = elem; - int c_roll_lo = static_cast(c_roll_tmp) - max_delta_roll; - int c_roll_hi = static_cast(c_roll_tmp) + max_delta_roll; - int c_pad_lo = static_cast(c_pad_lo_tmp) - (is_ge21 ? max_delta_pad_ge21 : max_delta_pad_ge11); - int c_pad_hi = static_cast(c_pad_hi_tmp) + (is_ge21 ? max_delta_pad_ge21 : max_delta_pad_ge11); - - // Two ranges overlap if (range_a_lo <= range_b_hi) and (range_a_hi >= range_b_lo) - return (tp_roll <= c_roll_hi) and (tp_roll >= c_roll_lo) and (tp_pad_lo <= c_pad_hi) and (tp_pad_hi >= c_pad_lo); - }; - - auto match = std::find_if(tp_copads.begin(), tp_copads.end(), match_fn); - - if (match != tp_copads.end()) { - // Has copad - tp_is_substitute = false; - } else if (tp_copads.empty()) { - // Kinda has copad - tp_is_substitute = true; - } else { - // Short-Circuit: Didn't find coincidence - continue; - } - } else if (tp_layer == 2) { - // Short-Circuit: layer 2 is used as coincidence - continue; - } - - // Calculate EMTF Info - const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); - const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); - - // Assertion checks - emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); - emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); - emtf_assert((0 <= tp_subsector) and (tp_subsector <= 2)); - emtf_assert(1 <= tp_station && tp_station <= 2); - emtf_assert(tp_ring == 1); - emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); - emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); - emtf_assert(tp_station == 1 or (1 <= tp_roll && tp_roll <= 16)); - emtf_assert(tp_station != 1 or (1 <= tp_roll && tp_roll <= 8)); - emtf_assert(1 <= tp_layer && tp_layer <= 2); - emtf_assert((tp_station == 1 && 0 <= tp_pad && tp_pad <= 191) || (tp_station != 1)); - emtf_assert((tp_station == 2 && 0 <= tp_pad && tp_pad <= 383) || (tp_station != 2)); - - // Add info - tp_entry.info_.bx = tp_bx; - - tp_entry.info_.endcap = tp_endcap; - tp_entry.info_.endcap_pm = tp_endcap_pm; - tp_entry.info_.sector = tp_sector; - tp_entry.info_.subsector = tp_subsector; - tp_entry.info_.station = tp_station; - tp_entry.info_.ring = tp_ring; - tp_entry.info_.roll = tp_roll; - tp_entry.info_.layer = tp_layer; - tp_entry.info_.chamber = tp_chamber; - - tp_entry.info_.csc_id = tp_csc_id; - tp_entry.info_.csc_facing = tp_csc_facing; - - tp_entry.info_.flag_substitute = tp_is_substitute; - - bx_tpc_map[tp_bx].push_back(tp_entry); + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const GEMData& tp_data = tp_entry.tp_.getGEMData(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + const int tp_station = tp_det_id.station(); + const int tp_ring = tp_det_id.ring(); + const int tp_layer = tp_det_id.layer(); + const int tp_chamber = tp_det_id.chamber(); + + const int tp_roll = tp_det_id.roll(); + const int tp_pad = (tp_data.pad_low + tp_data.pad_hi) / 2; + const int tp_pad_lo = tp_data.pad_low; + const int tp_pad_hi = tp_data.pad_hi; + + const int tp_bx = tp_data.bx + CONFIG.gem_bx_shift_; + + // Get Copad Info + GEMDetId tp_mod_det_id(tp_region, tp_ring, tp_station, 0, tp_chamber, 0); + auto tp_copads_key = std::make_pair(tp_mod_det_id.rawId(), tp_bx); + auto tp_copads = chamber_copads_map.at(tp_copads_key); + + // Check Copads + bool tp_is_substitute = false; + + if (tp_layer == 1) { + // layer 1 is used as incidence + const bool is_ge21 = (tp_station == 2); + + auto match_fn = [&tp_roll, &tp_pad_lo, &tp_pad_hi, &is_ge21](const std::array& elem) { + // Unpack entry + // Compare roll and (pad_lo, pad_hi)-range with tolerance + const auto& [c_roll_tmp, c_pad_lo_tmp, c_pad_hi_tmp] = elem; + int c_roll_lo = static_cast(c_roll_tmp) - max_delta_roll; + int c_roll_hi = static_cast(c_roll_tmp) + max_delta_roll; + int c_pad_lo = static_cast(c_pad_lo_tmp) - (is_ge21 ? max_delta_pad_ge21 : max_delta_pad_ge11); + int c_pad_hi = static_cast(c_pad_hi_tmp) + (is_ge21 ? max_delta_pad_ge21 : max_delta_pad_ge11); + + // Two ranges overlap if (range_a_lo <= range_b_hi) and (range_a_hi >= range_b_lo) + return (tp_roll <= c_roll_hi) and (tp_roll >= c_roll_lo) and (tp_pad_lo <= c_pad_hi) and + (tp_pad_hi >= c_pad_lo); + }; + + auto match = std::find_if(tp_copads.begin(), tp_copads.end(), match_fn); + + if (match != tp_copads.end()) { + // Has copad + tp_is_substitute = false; + } else if (tp_copads.empty()) { + // Kinda has copad + tp_is_substitute = true; + } else { + // Short-Circuit: Didn't find coincidence + continue; + } + } else if (tp_layer == 2) { + // Short-Circuit: layer 2 is used as coincidence + continue; } -} + // Calculate EMTF Info + const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert((0 <= tp_subsector) and (tp_subsector <= 2)); + emtf_assert(1 <= tp_station && tp_station <= 2); + emtf_assert(tp_ring == 1); + emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); + emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); + emtf_assert(tp_station == 1 or (1 <= tp_roll && tp_roll <= 16)); + emtf_assert(tp_station != 1 or (1 <= tp_roll && tp_roll <= 8)); + emtf_assert(1 <= tp_layer && tp_layer <= 2); + emtf_assert((tp_station == 1 && 0 <= tp_pad && tp_pad <= 191) || (tp_station != 1)); + emtf_assert((tp_station == 2 && 0 <= tp_pad && tp_pad <= 383) || (tp_station != 2)); + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.roll = tp_roll; + tp_entry.info_.layer = tp_layer; + tp_entry.info_.chamber = tp_chamber; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_csc_facing; + + tp_entry.info_.flag_substitute = tp_is_substitute; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc index 942e6fcbfdec8..889bae125bb5c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc @@ -15,143 +15,135 @@ using namespace emtf::phase2; -GEMTPConverter::GEMTPConverter(const EMTFContext& context, - const int& endcap, const int& sector): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +GEMTPConverter::GEMTPConverter(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } GEMTPConverter::~GEMTPConverter() { - // Do Nothing + // Do Nothing } -void GEMTPConverter::convert( - const TriggerPrimitive& tp, - const TPInfo& tp_info, - EMTFHit& hit) const { - // Unpack Id - const auto& tp_hit_id = tp_info.hit_id; - const auto& tp_segment_id = tp_info.segment_id; - - // Unpack trigger primitive - const auto& tp_det_id = tp.detId(); - const auto& tp_data = tp.getGEMData(); - - // Unpack detector info - const auto tp_subsystem = L1TMuon::kGEM; - - const int tp_raw_id = tp_det_id.rawId(); - - const int tp_endcap_pm = tp_info.endcap_pm; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_ring = tp_info.ring; - const int tp_roll = tp_info.roll; - const int tp_layer = tp_info.layer; - const int tp_chamber = tp_info.chamber; - - const auto tp_csc_facing = tp_info.csc_facing; - const int tp_csc_id = tp_info.csc_id; - - // Unpack data - const int tp_pad_lo = tp_data.pad_low; - const int tp_pad_hi = tp_data.pad_hi; - const int tp_pad = (tp_pad_lo + tp_pad_hi) / 2; - const int tp_clus_width = (tp_pad_hi - tp_pad_lo + 1); - - const int tp_bend = 0; // not applicable - - const int tp_bx = tp_info.bx; - const int tp_subbx = 0; // no fine resolution timing - const float tp_time = 0; // no fine resolution timing. Note: Check with Efe, Jia Fu gets this from digi directly. - - const auto tp_selection = tp_info.selection; - - // Use cluster width as quality. GE2/1 strip pitch is the same as GE1/1 strip pitch. - const int tp_quality = tp_clus_width; - - // ID scheme used in FW - const int tp_ilink = tp_info.ilink; - - // Get Global Coordinates - // const GlobalPoint& gp = get_global_point(detgeom, detid, digi); - const GlobalPoint& gp = GEOM.getGlobalPoint(tp); - const float glob_phi = tp::rad_to_deg(gp.phi().value()); - const float glob_theta = tp::rad_to_deg(gp.theta().value()); - const double glob_rho = gp.perp(); - const double glob_z = gp.z(); - - // Calculate EMTF Values - const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); - const int emtf_bend = 0; - const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); - const int emtf_qual = 0; - const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); - - emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); - emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); - - // Get flags - const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); - const bool tp_flag_substitute = tp_info.flag_substitute; - const bool tp_flag_valid = true; // given by digi, not trigger_primitive - - // Set properties - hit.setId(tp_hit_id); - - hit.setRawDetId(tp_raw_id); - hit.setSubsystem(L1TMuon::kGEM); - hit.setEndcap(tp_endcap_pm); - hit.setSector(sector_); - hit.setSubsector(tp_subsector); - hit.setStation(tp_station); - hit.setRing(tp_ring); - hit.setLayer(tp_layer); - hit.setChamber(tp_chamber); - - hit.setCscId(tp_csc_id); - hit.setCscFR(tp_csc_facing == csc::Facing::kRear); - - hit.setStrip(tp_pad); - hit.setStripLo(tp_pad_lo); - hit.setStripHi(tp_pad_hi); - - hit.setWire1(tp_roll); - hit.setWire2(0); - - hit.setBend(tp_bend); - - hit.setBx(tp_bx); - hit.setSubbx(tp_subbx); - - hit.setQuality(tp_quality); - hit.setPattern(0); - - hit.setGlobPhi(glob_phi); - hit.setGlobTheta(glob_theta); - hit.setGlobPerp(glob_rho); - hit.setGlobZ(glob_z); - hit.setGlobTime(tp_time); - - hit.setEmtfChamber(tp_ilink); - hit.setEmtfSegment(tp_segment_id); - hit.setEmtfPhi(emtf_phi); - hit.setEmtfBend(emtf_bend); - hit.setEmtfTheta1(emtf_theta); - hit.setEmtfTheta2(0); - hit.setEmtfQual1(emtf_qual); - hit.setEmtfQual2(0); - hit.setEmtfSite(emtf_site); - hit.setEmtfHost(emtf_host); - hit.setEmtfZones(emtf_zones); - - hit.setFlagNeighbor(tp_flag_neighbor); - hit.setFlagSubstitute(tp_flag_substitute); - hit.setFlagValid(tp_flag_valid); +void GEMTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const auto& tp_segment_id = tp_info.segment_id; + + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getGEMData(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kGEM; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_roll = tp_info.roll; + const int tp_layer = tp_info.layer; + const int tp_chamber = tp_info.chamber; + + const auto tp_csc_facing = tp_info.csc_facing; + const int tp_csc_id = tp_info.csc_id; + + // Unpack data + const int tp_pad_lo = tp_data.pad_low; + const int tp_pad_hi = tp_data.pad_hi; + const int tp_pad = (tp_pad_lo + tp_pad_hi) / 2; + const int tp_clus_width = (tp_pad_hi - tp_pad_lo + 1); + + const int tp_bend = 0; // not applicable + + const int tp_bx = tp_info.bx; + const int tp_subbx = 0; // no fine resolution timing + const float tp_time = 0; // no fine resolution timing. Note: Check with Efe, Jia Fu gets this from digi directly. + + const auto tp_selection = tp_info.selection; + + // Use cluster width as quality. GE2/1 strip pitch is the same as GE1/1 strip pitch. + const int tp_quality = tp_clus_width; + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + // const GlobalPoint& gp = get_global_point(detgeom, detid, digi); + const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const float glob_phi = tp::rad_to_deg(gp.phi().value()); + const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const double glob_rho = gp.perp(); + const double glob_z = gp.z(); + + // Calculate EMTF Values + const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_bend = 0; + const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_qual = 0; + const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + + emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); + emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = true; // given by digi, not trigger_primitive + + // Set properties + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(L1TMuon::kGEM); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_chamber); + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_pad); + hit.setStripLo(tp_pad_lo); + hit.setStripHi(tp_pad_hi); + + hit.setWire1(tp_roll); + hit.setWire2(0); + + hit.setBend(tp_bend); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(0); + + hit.setGlobPhi(glob_phi); + hit.setGlobTheta(glob_theta); + hit.setGlobPerp(glob_rho); + hit.setGlobZ(glob_z); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi); + hit.setEmtfBend(emtf_bend); + hit.setEmtfTheta1(emtf_theta); + hit.setEmtfTheta2(0); + hit.setEmtfQual1(emtf_qual); + hit.setEmtfQual2(0); + hit.setEmtfSite(emtf_site); + hit.setEmtfHost(emtf_host); + hit.setEmtfZones(emtf_zones); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc index 99af18b2ca2f1..21751162d462a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc @@ -12,121 +12,99 @@ using namespace emtf::phase2; -GEMTPSelector::GEMTPSelector( - const EMTFContext& context, - const int& endcap, const int& sector -): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +GEMTPSelector::GEMTPSelector(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } GEMTPSelector::~GEMTPSelector() { - // Do Nothing + // Do Nothing } -void GEMTPSelector::select( - const TriggerPrimitive& tp, - TPInfo tp_info, - ILinkTPCMap& ilink_tpc_map -) const { - emtf_assert(tp.subsystem() == L1TMuon::kGEM); +void GEMTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { + emtf_assert(tp.subsystem() == L1TMuon::kGEM); - // Map GEM trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns GEM "link" index + // Map GEM trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns GEM "link" index - // Short-Circuit: Link not found (ilink = -1) - if (ilink < 0) { - return; - } + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } - ilink_tpc_map[ilink].emplace_back(tp, tp_info); + ilink_tpc_map[ilink].emplace_back(tp, tp_info); } // =========================================================================== // Utils // =========================================================================== -int GEMTPSelector::get_input_link( - const TriggerPrimitive& tp, - TPInfo& tp_info -) const { - int ilink = -1; - - // Unpack detector info - const int tp_endcap = tp_info.endcap; - const int tp_sector = tp_info.sector; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_ring = tp_info.ring; - const int tp_csc_id = tp_info.csc_id; - - // Find selection type - auto tp_selection = TPSelection::kNone; - - if ( - csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) - ) { - tp_selection = TPSelection::kNative; - } else if ( - CONFIG.include_neighbor_en_ - && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) - ) { - tp_selection = TPSelection::kNeighbor; - } else { // Short-Circuit: tp_selection = TPSelection::kNone - return ilink; - } +int GEMTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_csc_id = tp_info.csc_id; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + tp_selection = TPSelection::kNative; + } else if (CONFIG.include_neighbor_en_ && + csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone + return ilink; + } - // Get chamber input link for this sector processor - ilink = calculate_input_link( - tp_subsector, tp_station, - tp_ring, tp_csc_id, - tp_selection - ); + // Get chamber input link for this sector processor + ilink = calculate_input_link(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); - // Add selection info - tp_info.ilink = ilink; - tp_info.selection = tp_selection; + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; - return ilink; + return ilink; } -int GEMTPSelector::calculate_input_link( - const int& tp_subsector, const int& tp_station, - const int& tp_ring, const int& tp_csc_id, - const TPSelection& tp_selection -) const { - int ilink = -1; - - // Links - // RE1,2,3,4 + GE1,2 : 54..71, 72..80, 81..89, 90..98 - // RE1,2,3,4 + GE1,2 (N) : 99..101, 102..103, 104..105, 106..107 +int GEMTPSelector::calculate_input_link(const int& tp_subsector, + const int& tp_station, + const int& tp_ring, + const int& tp_csc_id, + const TPSelection& tp_selection) const { + int ilink = -1; - if (tp_selection == TPSelection::kNative) { - const int ilink_offset = 54; + // Links + // RE1,2,3,4 + GE1,2 : 54..71, 72..80, 81..89, 90..98 + // RE1,2,3,4 + GE1,2 (N) : 99..101, 102..103, 104..105, 106..107 - if (tp_station == 1) { - ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); - } else { - ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); - } + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 54; - emtf_assert((54 <= ilink) && (ilink < 99)); + if (tp_station == 1) { + ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); } else { - const int ilink_offset = 99; + ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); + } - if (tp_station == 1) { - ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3); - } else if (tp_ring == 1) { - ilink = ilink_offset + ((tp_station - 1) * 2) + 1; - } else { - ilink = ilink_offset + ((tp_station - 1) * 2) + 2; - } + emtf_assert((54 <= ilink) && (ilink < 99)); + } else { + const int ilink_offset = 99; - emtf_assert((99 <= ilink) && (ilink < 108)); + if (tp_station == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3); + } else if (tp_ring == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + 1; + } else { + ilink = ilink_offset + ((tp_station - 1) * 2) + 2; } - return ilink; -} + emtf_assert((99 <= ilink) && (ilink < 108)); + } + return ilink; +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc index 50cca3e95f05d..96ee06b1fc952 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc @@ -14,134 +14,129 @@ using namespace emtf::phase2; -ME0TPCollector::ME0TPCollector( - const EMTFContext& context, - edm::ConsumesCollector& i_consumes_collector): - context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("ME0Input"))) -{ - // Do Nothing +ME0TPCollector::ME0TPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) + : context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("ME0Input"))) { + // Do Nothing } ME0TPCollector::~ME0TPCollector() { - // Do Nothing + // Do Nothing } -void ME0TPCollector::collect( - const edm::Event& i_event, - BXTPCMap& bx_tpc_map) const { - // Constants - // First quarter of ME0 chamber (5 deg) and last quarter - static const int me0_max_partition = 9; - static const int me0_nstrips = 384; - static const int me0_nphipositions = me0_nstrips * 2; - static const int phiposition_q1 = me0_nphipositions / 4; - static const int phiposition_q3 = (me0_nphipositions / 4) * 3; - - // Read ME0 digis - TPCollection tpc; - - edm::Handle me0_digis; - i_event.getByToken(input_token_, me0_digis); - - auto chamber = me0_digis->begin(); - auto chend = me0_digis->end(); - - for (; chamber != chend; ++chamber) { - auto digi = (*chamber).second.first; - auto dend = (*chamber).second.second; - - for (; digi != dend; ++digi) { - tpc.emplace_back((*chamber).first, *digi); - } +void ME0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { + // Constants + // First quarter of ME0 chamber (5 deg) and last quarter + static const int me0_max_partition = 9; + static const int me0_nstrips = 384; + static const int me0_nphipositions = me0_nstrips * 2; + static const int phiposition_q1 = me0_nphipositions / 4; + static const int phiposition_q3 = (me0_nphipositions / 4) * 3; + + // Read ME0 digis + TPCollection tpc; + + edm::Handle me0_digis; + i_event.getByToken(input_token_, me0_digis); + + auto chamber = me0_digis->begin(); + auto chend = me0_digis->end(); + + for (; chamber != chend; ++chamber) { + auto digi = (*chamber).second.first; + auto dend = (*chamber).second.second; + + for (; digi != dend; ++digi) { + tpc.emplace_back((*chamber).first, *digi); + } + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const ME0Data& tp_data = tp_entry.tp_.getME0Data(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + const int tp_station = tp_det_id.station(); + const int tp_ring = 4; + const int tp_layer = tp_det_id.layer(); + const int tp_roll = tp_det_id.roll(); + const int tp_me0_chamber = tp_det_id.chamber(); + + const int tp_pad = tp_data.phiposition; + const int tp_partition = tp_data.partition; + const int tp_bx = tp_data.bx + CONFIG.me0_bx_shift_; + + // Reject if outside eta of 2.4 + if (tp_partition > me0_max_partition) { + continue; } - // Map to BX - for (auto& tp_entry : tpc) { - const auto& tp_det_id = tp_entry.tp_.detId(); - const ME0Data& tp_data = tp_entry.tp_.getME0Data(); - - const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap - const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap - const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap - const int tp_station = tp_det_id.station(); - const int tp_ring = 4; - const int tp_layer = tp_det_id.layer(); - const int tp_roll = tp_det_id.roll(); - const int tp_me0_chamber = tp_det_id.chamber(); - - const int tp_pad = tp_data.phiposition; - const int tp_partition = tp_data.partition; - const int tp_bx = tp_data.bx + CONFIG.me0_bx_shift_; - - // Reject if outside eta of 2.4 - if (tp_partition > me0_max_partition) { - continue; - } - - // Calculate EMTF Info - // Split 20-deg chamber into 10-deg chamber - // ME0 chamber is rotated by -5 deg relative to CSC chamber. - // ME0 chamber 1 starts at -10 deg, CSC chamber 1 starts at -5 deg. - const int tp_phiposition = tp_data.phiposition; // in half-strip unit - - int tp_chamber = (tp_me0_chamber - 1) * 2 + 1; - - if (tp_endcap == 1) { - // positive endcap - // phiposition increases counter-clockwise - if (tp_phiposition < phiposition_q1) { - tp_chamber = csc::next_10deg_chamber(tp_chamber); - } else if (tp_phiposition < phiposition_q3) { - // Do nothing - } else { - tp_chamber = csc::prev_10deg_chamber(tp_chamber); - } - } else { - // negative endcap - // phiposition increases clockwise - if (tp_phiposition < phiposition_q1) { - tp_chamber = csc::prev_10deg_chamber(tp_chamber); - } else if (tp_phiposition < phiposition_q3) { - // Do nothing - } else { - tp_chamber = csc::next_10deg_chamber(tp_chamber); - } - } - - const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); - const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); - - // Assertion checks - emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); - emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); - emtf_assert((1 <= tp_subsector) and (tp_subsector <= 2)); - emtf_assert(tp_station == 1); - emtf_assert(tp_ring == 4); - emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); - emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); - emtf_assert(0 <= tp_pad && tp_pad <= 767); - emtf_assert(0 <= tp_partition && tp_partition <= 15); - - // Add info - tp_entry.info_.bx = tp_bx; - - tp_entry.info_.endcap = tp_endcap; - tp_entry.info_.endcap_pm = tp_endcap_pm; - tp_entry.info_.sector = tp_sector; - tp_entry.info_.subsector = tp_subsector; - tp_entry.info_.station = tp_station; - tp_entry.info_.ring = tp_ring; - tp_entry.info_.layer = tp_layer; - tp_entry.info_.roll = tp_roll; - tp_entry.info_.chamber = tp_chamber; - - tp_entry.info_.csc_id = tp_csc_id; - tp_entry.info_.csc_facing = tp_csc_facing; - - bx_tpc_map[tp_bx].push_back(tp_entry); + // Calculate EMTF Info + // Split 20-deg chamber into 10-deg chamber + // ME0 chamber is rotated by -5 deg relative to CSC chamber. + // ME0 chamber 1 starts at -10 deg, CSC chamber 1 starts at -5 deg. + const int tp_phiposition = tp_data.phiposition; // in half-strip unit + + int tp_chamber = (tp_me0_chamber - 1) * 2 + 1; + + if (tp_endcap == 1) { + // positive endcap + // phiposition increases counter-clockwise + if (tp_phiposition < phiposition_q1) { + tp_chamber = csc::next_10deg_chamber(tp_chamber); + } else if (tp_phiposition < phiposition_q3) { + // Do nothing + } else { + tp_chamber = csc::prev_10deg_chamber(tp_chamber); + } + } else { + // negative endcap + // phiposition increases clockwise + if (tp_phiposition < phiposition_q1) { + tp_chamber = csc::prev_10deg_chamber(tp_chamber); + } else if (tp_phiposition < phiposition_q3) { + // Do nothing + } else { + tp_chamber = csc::next_10deg_chamber(tp_chamber); + } } + + const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert((1 <= tp_subsector) and (tp_subsector <= 2)); + emtf_assert(tp_station == 1); + emtf_assert(tp_ring == 4); + emtf_assert((1 <= tp_chamber) and (tp_chamber <= 36)); + emtf_assert(1 <= tp_csc_id && tp_csc_id <= 3); + emtf_assert(0 <= tp_pad && tp_pad <= 767); + emtf_assert(0 <= tp_partition && tp_partition <= 15); + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.layer = tp_layer; + tp_entry.info_.roll = tp_roll; + tp_entry.info_.chamber = tp_chamber; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_csc_facing; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc index a670883d091f0..f4a3ed279ccab 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc @@ -15,138 +15,130 @@ using namespace emtf::phase2; -ME0TPConverter::ME0TPConverter(const EMTFContext& context, - const int& endcap, const int& sector): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +ME0TPConverter::ME0TPConverter(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } ME0TPConverter::~ME0TPConverter() { - // Do Nothing + // Do Nothing } -void ME0TPConverter::convert( - const TriggerPrimitive& tp, - const TPInfo& tp_info, - EMTFHit& hit) const { - // Unpack Id - const auto& tp_hit_id = tp_info.hit_id; - const int tp_segment_id = tp_info.segment_id; - - // Unpack trigger primitive - const auto& tp_det_id = tp.detId(); - const auto& tp_data = tp.getME0Data(); - - // Unpack detector info - const auto tp_subsystem = L1TMuon::kME0; - - const int tp_raw_id = tp_det_id.rawId(); - - const int tp_endcap_pm = tp_info.endcap_pm; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_ring = tp_info.ring; - const int tp_layer = tp_info.layer; - // const int tp_chamber = tp_info.chamber; - - const int tp_csc_id = tp_info.csc_id; - const auto tp_csc_facing = tp_info.csc_facing; - - // Unpack data - const int tp_phiposition = tp_data.phiposition; // in half-strip unit - const int tp_partition = tp_data.partition; // in half-roll unit - - const int tp_bend = static_cast(tp_data.deltaphi) * (tp_data.bend == 0 ? 1 : -1); - - const int tp_bx = tp_info.bx; - const int tp_subbx = 0; // no fine resolution timing - const float tp_time = 0; // no fine resolution timing. - - const auto tp_selection = tp_info.selection; - - const int tp_quality = tp_data.quality; - - // ID scheme used in FW - const int tp_ilink = tp_info.ilink; - - // Get Global Coordinates - const GlobalPoint& gp = GEOM.getGlobalPoint(tp); - const float glob_phi = tp::rad_to_deg(gp.phi().value()); - const float glob_theta = tp::rad_to_deg(gp.theta().value()); - const double glob_rho = gp.perp(); - const double glob_z = gp.z(); - - // Calculate EMTF Values - const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); - const int emtf_bend = std::clamp(tp_bend / 2, -64, 63); // 7-bit, signed - const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); - const int emtf_qual = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned - const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); - - emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); - emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); - - // Get flags - const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); - const bool tp_flag_substitute = tp_info.flag_substitute; - const bool tp_flag_valid = true; // given by digi, not trigger_primitive :( - - // Set properties - hit.setId(tp_hit_id); - - hit.setRawDetId(tp_raw_id); - hit.setSubsystem(L1TMuon::kME0); - hit.setEndcap(tp_endcap_pm); - hit.setSector(sector_); - hit.setSubsector(tp_subsector); - hit.setStation(tp_station); - hit.setRing(tp_ring); - hit.setLayer(tp_layer); - hit.setChamber(tp_det_id.chamber()); // Save original chamber - - hit.setCscId(tp_csc_id); - hit.setCscFR(tp_csc_facing == csc::Facing::kRear); - - hit.setStrip(tp_phiposition); - hit.setStripLo(tp_phiposition); - hit.setStripHi(tp_phiposition); - - hit.setWire1(tp_partition); - hit.setWire2(0); - - hit.setBend(tp_bend); - - hit.setBx(tp_bx); - hit.setSubbx(tp_subbx); - - hit.setQuality(tp_quality); - hit.setPattern(0); - - hit.setGlobPhi(glob_phi); - hit.setGlobTheta(glob_theta); - hit.setGlobPerp(glob_rho); - hit.setGlobZ(glob_z); - hit.setGlobTime(tp_time); - - hit.setEmtfChamber(tp_ilink); - hit.setEmtfSegment(tp_segment_id); - hit.setEmtfPhi(emtf_phi); - hit.setEmtfBend(emtf_bend); - hit.setEmtfTheta1(emtf_theta); - hit.setEmtfTheta2(0); - hit.setEmtfQual1(emtf_qual); - hit.setEmtfQual2(0); - hit.setEmtfSite(emtf_site); - hit.setEmtfHost(emtf_host); - hit.setEmtfZones(emtf_zones); - - hit.setFlagNeighbor(tp_flag_neighbor); - hit.setFlagSubstitute(tp_flag_substitute); - hit.setFlagValid(tp_flag_valid); -} +void ME0TPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const int tp_segment_id = tp_info.segment_id; + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getME0Data(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kME0; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_layer = tp_info.layer; + // const int tp_chamber = tp_info.chamber; + + const int tp_csc_id = tp_info.csc_id; + const auto tp_csc_facing = tp_info.csc_facing; + + // Unpack data + const int tp_phiposition = tp_data.phiposition; // in half-strip unit + const int tp_partition = tp_data.partition; // in half-roll unit + + const int tp_bend = static_cast(tp_data.deltaphi) * (tp_data.bend == 0 ? 1 : -1); + + const int tp_bx = tp_info.bx; + const int tp_subbx = 0; // no fine resolution timing + const float tp_time = 0; // no fine resolution timing. + + const auto tp_selection = tp_info.selection; + + const int tp_quality = tp_data.quality; + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const float glob_phi = tp::rad_to_deg(gp.phi().value()); + const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const double glob_rho = gp.perp(); + const double glob_z = gp.z(); + + // Calculate EMTF Values + const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_bend = std::clamp(tp_bend / 2, -64, 63); // 7-bit, signed + const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_qual = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned + const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + + emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); + emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = true; // given by digi, not trigger_primitive :( + + // Set properties + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(L1TMuon::kME0); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_det_id.chamber()); // Save original chamber + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_phiposition); + hit.setStripLo(tp_phiposition); + hit.setStripHi(tp_phiposition); + + hit.setWire1(tp_partition); + hit.setWire2(0); + + hit.setBend(tp_bend); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(0); + + hit.setGlobPhi(glob_phi); + hit.setGlobTheta(glob_theta); + hit.setGlobPerp(glob_rho); + hit.setGlobZ(glob_z); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi); + hit.setEmtfBend(emtf_bend); + hit.setEmtfTheta1(emtf_theta); + hit.setEmtfTheta2(0); + hit.setEmtfQual1(emtf_qual); + hit.setEmtfQual2(0); + hit.setEmtfSite(emtf_site); + hit.setEmtfHost(emtf_host); + hit.setEmtfZones(emtf_zones); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc index 6a9cb8c3e7c88..47b5b633b0ac3 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc @@ -12,108 +12,86 @@ using namespace emtf::phase2; -ME0TPSelector::ME0TPSelector( - const EMTFContext& context, - const int& endcap, const int& sector -): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +ME0TPSelector::ME0TPSelector(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } ME0TPSelector::~ME0TPSelector() { - // Do Nothing + // Do Nothing } -void ME0TPSelector::select( - const TriggerPrimitive& tp, - TPInfo tp_info, - ILinkTPCMap& ilink_tpc_map -) const { - emtf_assert(tp.subsystem() == L1TMuon::kME0); +void ME0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { + emtf_assert(tp.subsystem() == L1TMuon::kME0); - // Map ME0 trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns ME0 "link" index + // Map ME0 trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns ME0 "link" index - // Short-Circuit: Link not found (ilink = -1) - if (ilink < 0) { - return; - } + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } - ilink_tpc_map[ilink].emplace_back(tp, tp_info); + ilink_tpc_map[ilink].emplace_back(tp, tp_info); } // =========================================================================== // Utils // =========================================================================== -int ME0TPSelector::get_input_link( - const TriggerPrimitive& tp, - TPInfo& tp_info -) const { - int ilink = -1; - - // Unpack detector info - const int tp_endcap = tp_info.endcap; - const int tp_sector = tp_info.sector; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_csc_id = tp_info.csc_id; - - // Find selection type - auto tp_selection = TPSelection::kNone; - - if ( - csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) - ) { - tp_selection = TPSelection::kNative; - } else if ( - CONFIG.include_neighbor_en_ - && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) - ) { - tp_selection = TPSelection::kNeighbor; - } else { // Short-Circuit: tp_selection = TPSelection::kNone - return ilink; - } - - // Get chamber input link for this sector processor - ilink = calculate_input_link( - tp_subsector, tp_csc_id, - tp_selection - ); - - // Add selection info - tp_info.ilink = ilink; - tp_info.selection = tp_selection; - +int ME0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_csc_id = tp_info.csc_id; + + // Find selection type + auto tp_selection = TPSelection::kNone; + + if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + tp_selection = TPSelection::kNative; + } else if (CONFIG.include_neighbor_en_ && + csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone return ilink; + } + + // Get chamber input link for this sector processor + ilink = calculate_input_link(tp_subsector, tp_csc_id, tp_selection); + + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; + + return ilink; } -int ME0TPSelector::calculate_input_link( - const int& tp_subsector, const int& tp_csc_id, - const TPSelection& tp_selection -) const { - int ilink = -1; +int ME0TPSelector::calculate_input_link(const int& tp_subsector, + const int& tp_csc_id, + const TPSelection& tp_selection) const { + int ilink = -1; - // Links - // ME0 : 108..113 - // ME0 (N) : 114 + // Links + // ME0 : 108..113 + // ME0 (N) : 114 - if (tp_selection == TPSelection::kNative) { - const int ilink_offset = 108; + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 108; - ilink = ilink_offset + ((tp_subsector - 1) * 3) + (tp_csc_id - 1); + ilink = ilink_offset + ((tp_subsector - 1) * 3) + (tp_csc_id - 1); - emtf_assert((108 <= ilink) && (ilink < 114)); - } else { - const int ilink_offset = 114; + emtf_assert((108 <= ilink) && (ilink < 114)); + } else { + const int ilink_offset = 114; - ilink = ilink_offset; + ilink = ilink_offset; - emtf_assert(ilink == ilink_offset); - } + emtf_assert(ilink == ilink_offset); + } - return ilink; + return ilink; } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc index affe1ee2dc3c5..87012266cb2bd 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc @@ -14,161 +14,156 @@ using namespace emtf::phase2; -RPCTPCollector::RPCTPCollector( - const EMTFContext& context, - edm::ConsumesCollector& i_consumes_collector): - context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("RPCInput"))) -{ - // Do Nothing +RPCTPCollector::RPCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) + : context_(context), + input_token_(i_consumes_collector.consumes( + context.pset_.getParameter("RPCInput"))) { + // Do Nothing } RPCTPCollector::~RPCTPCollector() { - // Do Nothing + // Do Nothing } -void RPCTPCollector::collect( - const edm::Event& i_event, - BXTPCMap& bx_tpc_map) const { - // Constants - static const int clus_width_cut = 4; - static const int clus_width_cut_irpc = 6; +void RPCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { + // Constants + static const int clus_width_cut = 4; + static const int clus_width_cut_irpc = 6; - // Read RPC digis - TPCollection tpc; + // Read RPC digis + TPCollection tpc; - edm::Handle rpc_digis; - i_event.getByToken(input_token_, rpc_digis); + edm::Handle rpc_digis; + i_event.getByToken(input_token_, rpc_digis); - auto digi = rpc_digis->begin(); - auto digi_end = rpc_digis->end(); + auto digi = rpc_digis->begin(); + auto digi_end = rpc_digis->end(); - for (; digi != digi_end; ++digi) { - tpc.emplace_back(digi->rpcId(), *digi); + for (; digi != digi_end; ++digi) { + tpc.emplace_back(digi->rpcId(), *digi); + } + + // Map to BX + for (auto& tp_entry : tpc) { + const auto& tp_det_id = tp_entry.tp_.detId(); + const RPCData& tp_data = tp_entry.tp_.getRPCData(); + + const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap + const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap + const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap + + // RPC sector is rotated by -20 deg relative to CSC sector. + // RPC sector 1 starts at -5 deg, CSC sector 1 starts at 15 deg. + const int tp_rpc_sector = tp_det_id.sector(); // 1 - 6 (60 degrees in phi, sector 1 begins at -5 deg) + + // RPC subsector is defined differently than CSC subsector. + // RPC subsector is used to label the chamber within a sector. + const int tp_rpc_subsector = tp_det_id.subsector(); + + const int tp_station = tp_det_id.station(); // 1 - 4 + const int tp_ring = tp_det_id.ring(); // 2 - 3 (increasing theta) + const int tp_roll = + tp_det_id.roll(); // 1 - 3 (decreasing theta; aka A - C; space between rolls is 9 - 15 in theta_fp) + const int tp_layer = tp_det_id.layer(); // Always 1 in the Endcap, 1 or 2 in the Barrel + + const int tp_strip = (tp_data.strip_low + tp_data.strip_hi) / 2; // in full-strip unit + const int tp_strip_lo = tp_data.strip_low; + const int tp_strip_hi = tp_data.strip_hi; + const int tp_clus_width = (tp_strip_hi - tp_strip_lo + 1); + + const bool tp_is_CPPF = tp_data.isCPPF; + + const int tp_bx = tp_data.bx + CONFIG.rpc_bx_shift_; + + // Check Ring + bool tp_is_substitute = (tp_ring == 3); + + // Calculate type + const bool tp_is_barrel = (tp_region == 0); + + rpc::Type tp_rpc_type; + + if ((!tp_is_barrel) && (tp_station >= 3) && (tp_ring == 1)) { + tp_rpc_type = rpc::Type::kiRPC; + } else { + tp_rpc_type = rpc::Type::kRPC; } - // Map to BX - for (auto& tp_entry : tpc) { - const auto& tp_det_id = tp_entry.tp_.detId(); - const RPCData& tp_data = tp_entry.tp_.getRPCData(); - - const int tp_region = tp_det_id.region(); // 0: barrel, +/-1: endcap - const int tp_endcap = (tp_region == -1) ? 2 : tp_region; // 1: +endcap, 2: -endcap - const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap; // 1: +endcap, -1: -endcap - - // RPC sector is rotated by -20 deg relative to CSC sector. - // RPC sector 1 starts at -5 deg, CSC sector 1 starts at 15 deg. - const int tp_rpc_sector = tp_det_id.sector(); // 1 - 6 (60 degrees in phi, sector 1 begins at -5 deg) - - // RPC subsector is defined differently than CSC subsector. - // RPC subsector is used to label the chamber within a sector. - const int tp_rpc_subsector = tp_det_id.subsector(); - - const int tp_station = tp_det_id.station(); // 1 - 4 - const int tp_ring = tp_det_id.ring(); // 2 - 3 (increasing theta) - const int tp_roll = tp_det_id.roll(); // 1 - 3 (decreasing theta; aka A - C; space between rolls is 9 - 15 in theta_fp) - const int tp_layer = tp_det_id.layer(); // Always 1 in the Endcap, 1 or 2 in the Barrel - - const int tp_strip = (tp_data.strip_low + tp_data.strip_hi) / 2; // in full-strip unit - const int tp_strip_lo = tp_data.strip_low; - const int tp_strip_hi = tp_data.strip_hi; - const int tp_clus_width = (tp_strip_hi - tp_strip_lo + 1); - - const bool tp_is_CPPF = tp_data.isCPPF; - - const int tp_bx = tp_data.bx + CONFIG.rpc_bx_shift_; - - // Check Ring - bool tp_is_substitute = (tp_ring == 3); - - // Calculate type - const bool tp_is_barrel = (tp_region == 0); - - rpc::Type tp_rpc_type; - - if ((!tp_is_barrel) && (tp_station >= 3) && (tp_ring == 1)) { - tp_rpc_type = rpc::Type::kiRPC; - } else { - tp_rpc_type = rpc::Type::kRPC; - } - - // Short-Circuit: Skip Barrel RPC (region = 0) - if (tp_region == 0) { - continue; - } - - // Short-Circuit: Skip Overlap region (RE1/3, RE2/3) - if (tp_station <= 2 && tp_ring == 3) { - continue; - } - - // Short-Circuit: Reject wide clusters - if (tp_rpc_type == rpc::Type::kiRPC) { - if (tp_clus_width > clus_width_cut_irpc) { - continue; - } - } else { - if (tp_clus_width > clus_width_cut) { - continue; - } - } - - // Calculate EMTF Info - int tp_chamber; - - if (tp_rpc_type == rpc::Type::kiRPC) { - tp_chamber = (tp_rpc_sector - 1) * 3 + tp_rpc_subsector; - } else { - tp_chamber = (tp_rpc_sector - 1) * 6 + tp_rpc_subsector; - } - - const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); - const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); - - // Assertion checks - emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); - emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); - emtf_assert(0 <= tp_subsector && tp_subsector <= 2); - emtf_assert(1 <= tp_station && tp_station <= 4); - emtf_assert(1 <= tp_chamber && tp_chamber <= 36); - emtf_assert((1 <= tp_csc_id) and (tp_csc_id <= 9)); - - if (tp_rpc_type == rpc::Type::kiRPC) { - emtf_assert(tp_ring == 1); - emtf_assert(1 <= tp_roll && tp_roll <= 5); - emtf_assert(1 <= tp_strip && tp_strip <= 96); - } else { - emtf_assert(2 <= tp_ring && tp_ring <= 3); - emtf_assert(1 <= tp_roll && tp_roll <= 3); - emtf_assert(tp_is_CPPF || (1 <= tp_strip && tp_strip <= 32)); - } - - emtf_assert(tp_data.valid); - - // Add info - tp_entry.info_.bx = tp_bx; - - tp_entry.info_.endcap = tp_endcap; - tp_entry.info_.endcap_pm = tp_endcap_pm; - tp_entry.info_.sector = tp_sector; - tp_entry.info_.subsector = tp_subsector; - tp_entry.info_.station = tp_station; - tp_entry.info_.ring = tp_ring; - tp_entry.info_.roll = tp_roll; - tp_entry.info_.layer = tp_layer; - tp_entry.info_.chamber = tp_chamber; - - tp_entry.info_.csc_id = tp_csc_id; - tp_entry.info_.csc_facing = tp_csc_facing; - - tp_entry.info_.rpc_type = tp_rpc_type; - - tp_entry.info_.flag_substitute = tp_is_substitute; - - bx_tpc_map[tp_bx].push_back(tp_entry); + // Short-Circuit: Skip Barrel RPC (region = 0) + if (tp_region == 0) { + continue; + } + + // Short-Circuit: Skip Overlap region (RE1/3, RE2/3) + if (tp_station <= 2 && tp_ring == 3) { + continue; } -} + // Short-Circuit: Reject wide clusters + if (tp_rpc_type == rpc::Type::kiRPC) { + if (tp_clus_width > clus_width_cut_irpc) { + continue; + } + } else { + if (tp_clus_width > clus_width_cut) { + continue; + } + } + + // Calculate EMTF Info + int tp_chamber; + + if (tp_rpc_type == rpc::Type::kiRPC) { + tp_chamber = (tp_rpc_sector - 1) * 3 + tp_rpc_subsector; + } else { + tp_chamber = (tp_rpc_sector - 1) * 6 + tp_rpc_subsector; + } + + const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); + const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + + // Assertion checks + emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); + emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); + emtf_assert(0 <= tp_subsector && tp_subsector <= 2); + emtf_assert(1 <= tp_station && tp_station <= 4); + emtf_assert(1 <= tp_chamber && tp_chamber <= 36); + emtf_assert((1 <= tp_csc_id) and (tp_csc_id <= 9)); + + if (tp_rpc_type == rpc::Type::kiRPC) { + emtf_assert(tp_ring == 1); + emtf_assert(1 <= tp_roll && tp_roll <= 5); + emtf_assert(1 <= tp_strip && tp_strip <= 96); + } else { + emtf_assert(2 <= tp_ring && tp_ring <= 3); + emtf_assert(1 <= tp_roll && tp_roll <= 3); + emtf_assert(tp_is_CPPF || (1 <= tp_strip && tp_strip <= 32)); + } + + emtf_assert(tp_data.valid); + + // Add info + tp_entry.info_.bx = tp_bx; + + tp_entry.info_.endcap = tp_endcap; + tp_entry.info_.endcap_pm = tp_endcap_pm; + tp_entry.info_.sector = tp_sector; + tp_entry.info_.subsector = tp_subsector; + tp_entry.info_.station = tp_station; + tp_entry.info_.ring = tp_ring; + tp_entry.info_.roll = tp_roll; + tp_entry.info_.layer = tp_layer; + tp_entry.info_.chamber = tp_chamber; + + tp_entry.info_.csc_id = tp_csc_id; + tp_entry.info_.csc_facing = tp_csc_facing; + + tp_entry.info_.rpc_type = tp_rpc_type; + + tp_entry.info_.flag_substitute = tp_is_substitute; + + bx_tpc_map[tp_bx].push_back(tp_entry); + } +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc index 84db9bca64951..fc35902b9bf4b 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc @@ -17,173 +17,164 @@ using namespace emtf::phase2; -RPCTPConverter::RPCTPConverter(const EMTFContext& context, - const int& endcap, const int& sector): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +RPCTPConverter::RPCTPConverter(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } RPCTPConverter::~RPCTPConverter() { - // Do Nothing + // Do Nothing } -void RPCTPConverter::convert( - const TriggerPrimitive& tp, - const TPInfo& tp_info, - EMTFHit& hit) const { - // Unpack Id - const auto& tp_hit_id = tp_info.hit_id; - const auto& tp_segment_id = tp_info.segment_id; - - // Unpack trigger primitive - const auto& tp_det_id = tp.detId(); - const auto& tp_data = tp.getRPCData(); - - // Unpack detector info - const auto tp_subsystem = L1TMuon::kRPC; - - const int tp_raw_id = tp_det_id.rawId(); - - const int tp_endcap_pm = tp_info.endcap_pm; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_ring = tp_info.ring; - const int tp_roll = tp_info.roll; - const int tp_layer = tp_info.layer; - const int tp_chamber = tp_info.chamber; - - const auto tp_csc_facing = tp_info.csc_facing; - const int tp_csc_id = tp_info.csc_id; - const auto tp_rpc_type = tp_info.rpc_type; - - // Unpack data - const int tp_strip = (tp_data.strip_low + tp_data.strip_hi) / 2; // in full-strip unit - const int tp_strip_lo = tp_data.strip_low; - const int tp_strip_hi = tp_data.strip_hi; - const int tp_clus_width = (tp_strip_hi - tp_strip_lo + 1); - - int tp_bend = 0; // not applicable - - const int tp_bx = tp_info.bx; - const float tp_time = tp_data.time; - float tp_subbx_f32 = tp_time - (std::round(tp_time / 25.) * 25.); // reduce range to [-12.5,12.5] ns - int tp_subbx = static_cast(std::round(tp_subbx_f32 * 16. / 25.)); - tp_subbx = std::clamp(tp_subbx, -8, 7); // 4-bit, signed - int tp_bx_check = static_cast(std::round(tp_time / 25.)); - - // Not sure why sometimes digi.time() returns 0? - emtf_assert(((not(std::abs(tp_time) < 1e-6)) and (tp_bx == tp_bx_check)) or (std::abs(tp_time) < 1e-6)); - - const auto tp_selection = tp_info.selection; - - // Use cluster width as quality. - int tp_quality; - - if (tp_rpc_type == rpc::Type::kiRPC) { - tp_quality = tp_clus_width; - } else { - tp_quality = tp_clus_width * 3 / 2; // RPC strip pitch is 1.5 times the iRPC strip pitch. - } - - // ID scheme used in FW - const int tp_ilink = tp_info.ilink; - - // Get Global Coordinates - float glob_phi; - float glob_theta; - double glob_rho; - double glob_z; - - if (tp_rpc_type == rpc::Type::kiRPC) { - // Handle iRPC Coordinates - const RPCRoll* roll = dynamic_cast(GEOM.getRPCGeometry().roll(tp_det_id)); - const GlobalPoint& irpc_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0)); - - glob_phi = tp::rad_to_deg(irpc_gp.phi().value()); - glob_theta = tp::rad_to_deg(irpc_gp.theta().value()); - glob_rho = irpc_gp.perp(); - glob_z = irpc_gp.z(); - } - else{ - // Handle RPC Coordinates - const GlobalPoint& gp = GEOM.getGlobalPoint(tp); - glob_phi = tp::rad_to_deg(gp.phi().value()); - glob_theta = tp::rad_to_deg(gp.theta().value()); - glob_rho = gp.perp(); - glob_z = gp.z(); - } - - // Calculate EMTF Values - const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); - const int emtf_bend = 0; - const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); - const int emtf_qual = 0; - const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); - - emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); - emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); - - // Get flags - const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); - const bool tp_flag_substitute = tp_info.flag_substitute; - const bool tp_flag_valid = tp_data.valid; - - // Set all the variables - hit.setId(tp_hit_id); - - hit.setRawDetId(tp_raw_id); - hit.setSubsystem(tp_subsystem); - hit.setEndcap(tp_endcap_pm); - hit.setSector(sector_); - hit.setSubsector(tp_subsector); - hit.setStation(tp_station); - hit.setRing(tp_ring); - hit.setLayer(tp_layer); - hit.setChamber(tp_chamber); - - hit.setCscId(tp_csc_id); - hit.setCscFR(tp_csc_facing == csc::Facing::kRear); - - hit.setStrip(tp_strip); - hit.setStripLo(tp_strip_lo); - hit.setStripHi(tp_strip_hi); - - hit.setWire1(tp_roll); - hit.setWire2(0); - - hit.setBend(tp_bend); - - hit.setBx(tp_bx); - hit.setSubbx(tp_subbx); - - hit.setQuality(tp_quality); - hit.setPattern(0); - - hit.setGlobPhi(glob_phi); - hit.setGlobTheta(glob_theta); - hit.setGlobPerp(glob_rho); - hit.setGlobZ(glob_z); - hit.setGlobTime(tp_time); - - hit.setEmtfChamber(tp_ilink); - hit.setEmtfSegment(tp_segment_id); - hit.setEmtfPhi(emtf_phi); - hit.setEmtfBend(emtf_bend); - hit.setEmtfTheta1(emtf_theta); - hit.setEmtfTheta2(0); - hit.setEmtfQual1(emtf_qual); - hit.setEmtfQual2(0); - hit.setEmtfSite(emtf_site); - hit.setEmtfHost(emtf_host); - hit.setEmtfZones(emtf_zones); - - hit.setFlagNeighbor(tp_flag_neighbor); - hit.setFlagSubstitute(tp_flag_substitute); - hit.setFlagValid(tp_flag_valid); +void RPCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { + // Unpack Id + const auto& tp_hit_id = tp_info.hit_id; + const auto& tp_segment_id = tp_info.segment_id; + + // Unpack trigger primitive + const auto& tp_det_id = tp.detId(); + const auto& tp_data = tp.getRPCData(); + + // Unpack detector info + const auto tp_subsystem = L1TMuon::kRPC; + + const int tp_raw_id = tp_det_id.rawId(); + + const int tp_endcap_pm = tp_info.endcap_pm; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_roll = tp_info.roll; + const int tp_layer = tp_info.layer; + const int tp_chamber = tp_info.chamber; + + const auto tp_csc_facing = tp_info.csc_facing; + const int tp_csc_id = tp_info.csc_id; + const auto tp_rpc_type = tp_info.rpc_type; + + // Unpack data + const int tp_strip = (tp_data.strip_low + tp_data.strip_hi) / 2; // in full-strip unit + const int tp_strip_lo = tp_data.strip_low; + const int tp_strip_hi = tp_data.strip_hi; + const int tp_clus_width = (tp_strip_hi - tp_strip_lo + 1); + + int tp_bend = 0; // not applicable + + const int tp_bx = tp_info.bx; + const float tp_time = tp_data.time; + float tp_subbx_f32 = tp_time - (std::round(tp_time / 25.) * 25.); // reduce range to [-12.5,12.5] ns + int tp_subbx = static_cast(std::round(tp_subbx_f32 * 16. / 25.)); + tp_subbx = std::clamp(tp_subbx, -8, 7); // 4-bit, signed + int tp_bx_check = static_cast(std::round(tp_time / 25.)); + + // Not sure why sometimes digi.time() returns 0? + emtf_assert(((not(std::abs(tp_time) < 1e-6)) and (tp_bx == tp_bx_check)) or (std::abs(tp_time) < 1e-6)); + + const auto tp_selection = tp_info.selection; + + // Use cluster width as quality. + int tp_quality; + + if (tp_rpc_type == rpc::Type::kiRPC) { + tp_quality = tp_clus_width; + } else { + tp_quality = tp_clus_width * 3 / 2; // RPC strip pitch is 1.5 times the iRPC strip pitch. + } + + // ID scheme used in FW + const int tp_ilink = tp_info.ilink; + + // Get Global Coordinates + float glob_phi; + float glob_theta; + double glob_rho; + double glob_z; + + if (tp_rpc_type == rpc::Type::kiRPC) { + // Handle iRPC Coordinates + const RPCRoll* roll = dynamic_cast(GEOM.getRPCGeometry().roll(tp_det_id)); + const GlobalPoint& irpc_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0)); + + glob_phi = tp::rad_to_deg(irpc_gp.phi().value()); + glob_theta = tp::rad_to_deg(irpc_gp.theta().value()); + glob_rho = irpc_gp.perp(); + glob_z = irpc_gp.z(); + } else { + // Handle RPC Coordinates + const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + glob_phi = tp::rad_to_deg(gp.phi().value()); + glob_theta = tp::rad_to_deg(gp.theta().value()); + glob_rho = gp.perp(); + glob_z = gp.z(); + } + + // Calculate EMTF Values + const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_bend = 0; + const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_qual = 0; + const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); + const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + + emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); + emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); + + // Get flags + const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor); + const bool tp_flag_substitute = tp_info.flag_substitute; + const bool tp_flag_valid = tp_data.valid; + + // Set all the variables + hit.setId(tp_hit_id); + + hit.setRawDetId(tp_raw_id); + hit.setSubsystem(tp_subsystem); + hit.setEndcap(tp_endcap_pm); + hit.setSector(sector_); + hit.setSubsector(tp_subsector); + hit.setStation(tp_station); + hit.setRing(tp_ring); + hit.setLayer(tp_layer); + hit.setChamber(tp_chamber); + + hit.setCscId(tp_csc_id); + hit.setCscFR(tp_csc_facing == csc::Facing::kRear); + + hit.setStrip(tp_strip); + hit.setStripLo(tp_strip_lo); + hit.setStripHi(tp_strip_hi); + + hit.setWire1(tp_roll); + hit.setWire2(0); + + hit.setBend(tp_bend); + + hit.setBx(tp_bx); + hit.setSubbx(tp_subbx); + + hit.setQuality(tp_quality); + hit.setPattern(0); + + hit.setGlobPhi(glob_phi); + hit.setGlobTheta(glob_theta); + hit.setGlobPerp(glob_rho); + hit.setGlobZ(glob_z); + hit.setGlobTime(tp_time); + + hit.setEmtfChamber(tp_ilink); + hit.setEmtfSegment(tp_segment_id); + hit.setEmtfPhi(emtf_phi); + hit.setEmtfBend(emtf_bend); + hit.setEmtfTheta1(emtf_theta); + hit.setEmtfTheta2(0); + hit.setEmtfQual1(emtf_qual); + hit.setEmtfQual2(0); + hit.setEmtfSite(emtf_site); + hit.setEmtfHost(emtf_host); + hit.setEmtfZones(emtf_zones); + + hit.setFlagNeighbor(tp_flag_neighbor); + hit.setFlagSubstitute(tp_flag_substitute); + hit.setFlagValid(tp_flag_valid); } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc index 6e4b2f128a21e..9f3d0b68ffdbf 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc @@ -13,129 +13,107 @@ using namespace emtf::phase2; -RPCTPSelector::RPCTPSelector( - const EMTFContext& context, - const int& endcap, const int& sector -): - context_(context), - endcap_(endcap), - sector_(sector) -{ - // Do Nothing +RPCTPSelector::RPCTPSelector(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector) { + // Do Nothing } RPCTPSelector::~RPCTPSelector() { - // Do Nothing + // Do Nothing } -void RPCTPSelector::select( - const TriggerPrimitive& tp, - TPInfo tp_info, - ILinkTPCMap& ilink_tpc_map -) const { - emtf_assert(tp.subsystem() == L1TMuon::kRPC); +void RPCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { + emtf_assert(tp.subsystem() == L1TMuon::kRPC); - // Map RPC trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns RPC "link" index + // Map RPC trigger primitives to input links + int ilink = get_input_link(tp, tp_info); // Returns RPC "link" index - // Short-Circuit: Link not found (ilink = -1) - if (ilink < 0) { - return; - } + // Short-Circuit: Link not found (ilink = -1) + if (ilink < 0) { + return; + } - ilink_tpc_map[ilink].emplace_back(tp, tp_info); + ilink_tpc_map[ilink].emplace_back(tp, tp_info); } // =========================================================================== // Utils // =========================================================================== -int RPCTPSelector::get_input_link( - const TriggerPrimitive& tp, - TPInfo& tp_info -) const { - int ilink = -1; - - // Unpack detector info - const int tp_endcap = tp_info.endcap; - const int tp_sector = tp_info.sector; - const int tp_subsector = tp_info.subsector; - const int tp_station = tp_info.station; - const int tp_ring = tp_info.ring; - const int tp_csc_id = tp_info.csc_id; - - const RPCData& tp_data = tp.getRPCData(); - const int tp_emtf_sect = tp_data.emtf_sector; - const bool tp_is_CPPF = tp_data.isCPPF; - - // Short-Circuit: In neighbor chambers, have two separate CPPFDigis for the two EMTF sectors - if (tp_is_CPPF && (tp_emtf_sect != sector_)) - return ilink; - - // Find selection type - auto tp_selection = TPSelection::kNone; - - if ( - csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector) - ) { - tp_selection = TPSelection::kNative; - } else if ( - CONFIG.include_neighbor_en_ - && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id) - ) { - tp_selection = TPSelection::kNeighbor; - } else { // Short-Circuit: tp_selection = TPSelection::kNone - return ilink; - } - - // Get chamber input link for this sector processor - ilink = calculate_input_link( - tp_subsector, tp_station, - tp_ring, tp_csc_id, - tp_selection - ); +int RPCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { + int ilink = -1; + + // Unpack detector info + const int tp_endcap = tp_info.endcap; + const int tp_sector = tp_info.sector; + const int tp_subsector = tp_info.subsector; + const int tp_station = tp_info.station; + const int tp_ring = tp_info.ring; + const int tp_csc_id = tp_info.csc_id; + + const RPCData& tp_data = tp.getRPCData(); + const int tp_emtf_sect = tp_data.emtf_sector; + const bool tp_is_CPPF = tp_data.isCPPF; + + // Short-Circuit: In neighbor chambers, have two separate CPPFDigis for the two EMTF sectors + if (tp_is_CPPF && (tp_emtf_sect != sector_)) + return ilink; - // Add selection info - tp_info.ilink = ilink; - tp_info.selection = tp_selection; + // Find selection type + auto tp_selection = TPSelection::kNone; + if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + tp_selection = TPSelection::kNative; + } else if (CONFIG.include_neighbor_en_ && + csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + tp_selection = TPSelection::kNeighbor; + } else { // Short-Circuit: tp_selection = TPSelection::kNone return ilink; -} + } + + // Get chamber input link for this sector processor + ilink = calculate_input_link(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); -int RPCTPSelector::calculate_input_link( - const int& tp_subsector, const int& tp_station, - const int& tp_ring, const int& tp_csc_id, - const TPSelection& tp_selection -) const { - int ilink = -1; + // Add selection info + tp_info.ilink = ilink; + tp_info.selection = tp_selection; - // Links - // RE1,2,3,4 + GE1,2 : 54..71, 72..80, 81..89, 90..98 - // RE1,2,3,4 + GE1,2 (N) : 99..101, 102..103, 104..105, 106..107 + return ilink; +} - if (tp_selection == TPSelection::kNative) { - const int ilink_offset = 54; +int RPCTPSelector::calculate_input_link(const int& tp_subsector, + const int& tp_station, + const int& tp_ring, + const int& tp_csc_id, + const TPSelection& tp_selection) const { + int ilink = -1; - if (tp_station == 1) { - ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); - } else { - ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); - } + // Links + // RE1,2,3,4 + GE1,2 : 54..71, 72..80, 81..89, 90..98 + // RE1,2,3,4 + GE1,2 (N) : 99..101, 102..103, 104..105, 106..107 - emtf_assert((54 <= ilink) && (ilink < 99)); + if (tp_selection == TPSelection::kNative) { + const int ilink_offset = 54; + + if (tp_station == 1) { + ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1); } else { - const int ilink_offset = 99; + ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1); + } - if (tp_station == 1) { - ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3); - } else if (tp_ring == 1) { - ilink = ilink_offset + ((tp_station - 1) * 2) + 1; - } else { - ilink = ilink_offset + ((tp_station - 1) * 2) + 2; - } + emtf_assert((54 <= ilink) && (ilink < 99)); + } else { + const int ilink_offset = 99; - emtf_assert((99 <= ilink) && (ilink < 108)); + if (tp_station == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3); + } else if (tp_ring == 1) { + ilink = ilink_offset + ((tp_station - 1) * 2) + 1; + } else { + ilink = ilink_offset + ((tp_station - 1) * 2) + 2; } - return ilink; -} + emtf_assert((99 <= ilink) && (ilink < 108)); + } + return ilink; +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/TPrimitives.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/TPrimitives.cc index 388f452153c50..800cf2a01f4c9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/TPrimitives.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/TPrimitives.cc @@ -4,64 +4,38 @@ using namespace emtf::phase2; -TPEntry::TPEntry(const TPEntry& tp_entry): - tp_(tp_entry.tp_), - info_(tp_entry.info_) -{ - // Do nothing +TPEntry::TPEntry(const TPEntry& tp_entry) : tp_(tp_entry.tp_), info_(tp_entry.info_) { + // Do nothing } -TPEntry::TPEntry(const TriggerPrimitive& tp): - tp_(tp), - info_() -{ - // Do nothing +TPEntry::TPEntry(const TriggerPrimitive& tp) : tp_(tp), info_() { + // Do nothing } -TPEntry::TPEntry(const TriggerPrimitive& tp, const TPInfo& tp_info): - tp_(tp), - info_(tp_info) -{ - // Do nothing +TPEntry::TPEntry(const TriggerPrimitive& tp, const TPInfo& tp_info) : tp_(tp), info_(tp_info) { + // Do nothing } -TPEntry::TPEntry(const CSCDetId& detid, const CSCCorrelatedLCTDigi& digi): - tp_(detid, digi), - info_() -{ - // Do nothing +TPEntry::TPEntry(const CSCDetId& detid, const CSCCorrelatedLCTDigi& digi) : tp_(detid, digi), info_() { + // Do nothing } -TPEntry::TPEntry(const RPCDetId& detid, const RPCRecHit& rechit): - tp_(detid, rechit), - info_() -{ - // Do nothing +TPEntry::TPEntry(const RPCDetId& detid, const RPCRecHit& rechit) : tp_(detid, rechit), info_() { + // Do nothing } -TPEntry::TPEntry(const GEMDetId& detid, const GEMPadDigiCluster& digi): - tp_(detid, digi), - info_() -{ - // Do nothing +TPEntry::TPEntry(const GEMDetId& detid, const GEMPadDigiCluster& digi) : tp_(detid, digi), info_() { + // Do nothing } -TPEntry::TPEntry(const ME0DetId& detid, const ME0TriggerDigi& digi): - tp_(detid, digi), - info_() -{ - // Do nothing +TPEntry::TPEntry(const ME0DetId& detid, const ME0TriggerDigi& digi) : tp_(detid, digi), info_() { + // Do nothing } -TPEntry::TPEntry(const GEMDetId& detid, const ME0TriggerDigi& digi): - tp_(detid, digi), - info_() -{ - // Do nothing +TPEntry::TPEntry(const GEMDetId& detid, const ME0TriggerDigi& digi) : tp_(detid, digi), info_() { + // Do nothing } TPEntry::~TPEntry() { - // Do nothing + // Do nothing } - - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc index a9efed9fc12bc..27b168e929466 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc @@ -7,6 +7,7 @@ using namespace emtf::phase2; using namespace emtf::phase2::data; ActivationLut::ActivationLut() { + // clang-format off prompt_pt_lut_ = {{ 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, @@ -190,36 +191,33 @@ ActivationLut::ActivationLut() { -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11, -10, -10, -10, -9, -9, -9, -9, -8, -8, -8, -8, -6, -6, -6, -6, -5, -5, -5, -5, -3, -3, -3, -3, -2, -2, -2, -2, 0 }}; + // clang-format on } ActivationLut::~ActivationLut() { - // Do Nothing + // Do Nothing } -void ActivationLut::update( - const edm::Event&, - const edm::EventSetup& -) { - // Do Nothing +void ActivationLut::update(const edm::Event&, const edm::EventSetup&) { + // Do Nothing } const trk_pt_t& ActivationLut::lookup_prompt_pt(const trk_nn_address_t& address) const { - ap_uint<10> bin = address.to_string(AP_HEX).c_str(); - return prompt_pt_lut_[bin]; + ap_uint<10> bin = address.to_string(AP_HEX).c_str(); + return prompt_pt_lut_[bin]; } const trk_pt_t& ActivationLut::lookup_disp_pt(const trk_nn_address_t& address) const { - ap_uint<10> bin = address.to_string(AP_HEX).c_str(); - return disp_pt_lut_[bin]; + ap_uint<10> bin = address.to_string(AP_HEX).c_str(); + return disp_pt_lut_[bin]; } const trk_rels_t& ActivationLut::lookup_rels(const trk_nn_address_t& address) const { - ap_uint<10> bin = address.to_string(AP_HEX).c_str(); - return rels_lut_[bin]; + ap_uint<10> bin = address.to_string(AP_HEX).c_str(); + return rels_lut_[bin]; } const trk_dxy_t& ActivationLut::lookup_dxy(const trk_nn_address_t& address) const { - ap_uint<10> bin = address.to_string(AP_HEX).c_str(); - return dxy_lut_[bin]; + ap_uint<10> bin = address.to_string(AP_HEX).c_str(); + return dxy_lut_[bin]; } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/HostLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/HostLut.cc index 806e1a27323b7..d6792fc64302d 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/HostLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/HostLut.cc @@ -9,47 +9,44 @@ const int HostLut::kInvalid = -1; // Member HostLut::HostLut() { - lut_[{1, 1, 4}] = 0; // ME1/1a - lut_[{1, 1, 1}] = 0; // ME1/1b - lut_[{1, 1, 2}] = 1; // ME1/2 - lut_[{1, 1, 3}] = 2; // ME1/3 - lut_[{1, 2, 1}] = 3; // ME2/1 - lut_[{1, 2, 2}] = 4; // ME2/2 - lut_[{1, 3, 1}] = 5; // ME3/1 - lut_[{1, 3, 2}] = 6; // ME3/2 - lut_[{1, 4, 1}] = 7; // ME4/1 - lut_[{1, 4, 2}] = 8; // ME4/2 - lut_[{3, 1, 1}] = 9; // GE1/1 - lut_[{2, 1, 2}] = 10; // RE1/2 - lut_[{2, 1, 3}] = 11; // RE1/3 - lut_[{3, 2, 1}] = 12; // GE2/1 - lut_[{2, 2, 2}] = 13; // RE2/2 - lut_[{2, 2, 3}] = 13; // RE2/3 - lut_[{2, 3, 1}] = 14; // RE3/1 - lut_[{2, 3, 2}] = 15; // RE3/2 - lut_[{2, 3, 3}] = 15; // RE3/3 - lut_[{2, 4, 1}] = 16; // RE4/1 - lut_[{2, 4, 2}] = 17; // RE4/2 - lut_[{2, 4, 3}] = 17; // RE4/3 - lut_[{4, 1, 4}] = 18; // ME0 + lut_[{1, 1, 4}] = 0; // ME1/1a + lut_[{1, 1, 1}] = 0; // ME1/1b + lut_[{1, 1, 2}] = 1; // ME1/2 + lut_[{1, 1, 3}] = 2; // ME1/3 + lut_[{1, 2, 1}] = 3; // ME2/1 + lut_[{1, 2, 2}] = 4; // ME2/2 + lut_[{1, 3, 1}] = 5; // ME3/1 + lut_[{1, 3, 2}] = 6; // ME3/2 + lut_[{1, 4, 1}] = 7; // ME4/1 + lut_[{1, 4, 2}] = 8; // ME4/2 + lut_[{3, 1, 1}] = 9; // GE1/1 + lut_[{2, 1, 2}] = 10; // RE1/2 + lut_[{2, 1, 3}] = 11; // RE1/3 + lut_[{3, 2, 1}] = 12; // GE2/1 + lut_[{2, 2, 2}] = 13; // RE2/2 + lut_[{2, 2, 3}] = 13; // RE2/3 + lut_[{2, 3, 1}] = 14; // RE3/1 + lut_[{2, 3, 2}] = 15; // RE3/2 + lut_[{2, 3, 3}] = 15; // RE3/3 + lut_[{2, 4, 1}] = 16; // RE4/1 + lut_[{2, 4, 2}] = 17; // RE4/2 + lut_[{2, 4, 3}] = 17; // RE4/3 + lut_[{4, 1, 4}] = 18; // ME0 } HostLut::~HostLut() { - // Do Nothing + // Do Nothing } - -void HostLut::update( - const edm::Event&, - const edm::EventSetup&) { - // Do Nothing +void HostLut::update(const edm::Event&, const edm::EventSetup&) { + // Do Nothing } -const int& HostLut::lookup(const std::tuple& key) const { - auto found = lut_.find(key); +const int& HostLut::lookup(const std::tuple& key) const { + auto found = lut_.find(key); - if (found == lut_.end()) - return HostLut::kInvalid; + if (found == lut_.end()) + return HostLut::kInvalid; - return found->second; + return found->second; } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/SiteLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/SiteLut.cc index 92dd53fcb2040..92c75d20ba22a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/SiteLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/SiteLut.cc @@ -9,47 +9,44 @@ const int SiteLut::kInvalid = -1; // Member SiteLut::SiteLut() { - lut_[{1, 1, 4}] = 0; // ME1/1a - lut_[{1, 1, 1}] = 0; // ME1/1b - lut_[{1, 1, 2}] = 1; // ME1/2 - lut_[{1, 1, 3}] = 1; // ME1/3 - lut_[{1, 2, 1}] = 2; // ME2/1 - lut_[{1, 2, 2}] = 2; // ME2/2 - lut_[{1, 3, 1}] = 3; // ME3/1 - lut_[{1, 3, 2}] = 3; // ME3/2 - lut_[{1, 4, 1}] = 4; // ME4/1 - lut_[{1, 4, 2}] = 4; // ME4/2 - lut_[{2, 1, 2}] = 5; // RE1/2 - lut_[{2, 1, 3}] = 5; // RE1/3 - lut_[{2, 2, 2}] = 6; // RE2/2 - lut_[{2, 2, 3}] = 6; // RE2/3 - lut_[{2, 3, 1}] = 7; // RE3/1 - lut_[{2, 3, 2}] = 7; // RE3/2 - lut_[{2, 3, 3}] = 7; // RE3/3 - lut_[{2, 4, 1}] = 8; // RE4/1 - lut_[{2, 4, 2}] = 8; // RE4/2 - lut_[{2, 4, 3}] = 8; // RE4/3 - lut_[{3, 1, 1}] = 9; // GE1/1 - lut_[{3, 2, 1}] = 10; // GE2/1 - lut_[{4, 1, 4}] = 11; // ME0 + lut_[{1, 1, 4}] = 0; // ME1/1a + lut_[{1, 1, 1}] = 0; // ME1/1b + lut_[{1, 1, 2}] = 1; // ME1/2 + lut_[{1, 1, 3}] = 1; // ME1/3 + lut_[{1, 2, 1}] = 2; // ME2/1 + lut_[{1, 2, 2}] = 2; // ME2/2 + lut_[{1, 3, 1}] = 3; // ME3/1 + lut_[{1, 3, 2}] = 3; // ME3/2 + lut_[{1, 4, 1}] = 4; // ME4/1 + lut_[{1, 4, 2}] = 4; // ME4/2 + lut_[{2, 1, 2}] = 5; // RE1/2 + lut_[{2, 1, 3}] = 5; // RE1/3 + lut_[{2, 2, 2}] = 6; // RE2/2 + lut_[{2, 2, 3}] = 6; // RE2/3 + lut_[{2, 3, 1}] = 7; // RE3/1 + lut_[{2, 3, 2}] = 7; // RE3/2 + lut_[{2, 3, 3}] = 7; // RE3/3 + lut_[{2, 4, 1}] = 8; // RE4/1 + lut_[{2, 4, 2}] = 8; // RE4/2 + lut_[{2, 4, 3}] = 8; // RE4/3 + lut_[{3, 1, 1}] = 9; // GE1/1 + lut_[{3, 2, 1}] = 10; // GE2/1 + lut_[{4, 1, 4}] = 11; // ME0 } SiteLut::~SiteLut() { - // Do Nothing + // Do Nothing } - -void SiteLut::update( - const edm::Event&, - const edm::EventSetup&) { - // Do Nothing +void SiteLut::update(const edm::Event&, const edm::EventSetup&) { + // Do Nothing } -const int& SiteLut::lookup(const std::tuple& key) const { - auto found = lut_.find(key); +const int& SiteLut::lookup(const std::tuple& key) const { + auto found = lut_.find(key); - if (found == lut_.end()) - return SiteLut::kInvalid; + if (found == lut_.end()) + return SiteLut::kInvalid; - return found->second; + return found->second; } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc index 29d1b63ffd304..1149fb743be8f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc @@ -6,58 +6,53 @@ using namespace emtf::phase2::data; // Static bool TimeZoneLut::in_range(const std::pair& range, const int& bx) const { - return range.first <= bx && bx <= range.second; + return range.first <= bx && bx <= range.second; } // Member TimeZoneLut::TimeZoneLut() { - lut_[0] = {-1, 0}; // ME1/1 - lut_[1] = {-1, 0}; // ME1/2 - lut_[2] = {-1, 0}; // ME1/3 - lut_[3] = {-1, 0}; // ME2/1 - lut_[4] = {-1, 0}; // ME2/2 - lut_[5] = {-1, 0}; // ME3/1 - lut_[6] = {-1, 0}; // ME3/2 - lut_[7] = {-1, 0}; // ME4/1 - lut_[8] = {-1, 0}; // ME4/2 - lut_[9] = {-1, 0}; // GE1/1 - lut_[10] = {0, 0}; // RE1/2 - lut_[11] = {0, 0}; // RE1/3 - lut_[12] = {-1, 0}; // GE2/1 - lut_[13] = {0, 0}; // RE2/2 - lut_[14] = {0, 0}; // RE3/1 - lut_[15] = {0, 0}; // RE3/2 - lut_[16] = {0, 0}; // RE4/1 - lut_[17] = {0, 0}; // RE4/2 - lut_[18] = {0, 0}; // ME0 + lut_[0] = {-1, 0}; // ME1/1 + lut_[1] = {-1, 0}; // ME1/2 + lut_[2] = {-1, 0}; // ME1/3 + lut_[3] = {-1, 0}; // ME2/1 + lut_[4] = {-1, 0}; // ME2/2 + lut_[5] = {-1, 0}; // ME3/1 + lut_[6] = {-1, 0}; // ME3/2 + lut_[7] = {-1, 0}; // ME4/1 + lut_[8] = {-1, 0}; // ME4/2 + lut_[9] = {-1, 0}; // GE1/1 + lut_[10] = {0, 0}; // RE1/2 + lut_[11] = {0, 0}; // RE1/3 + lut_[12] = {-1, 0}; // GE2/1 + lut_[13] = {0, 0}; // RE2/2 + lut_[14] = {0, 0}; // RE3/1 + lut_[15] = {0, 0}; // RE3/2 + lut_[16] = {0, 0}; // RE4/1 + lut_[17] = {0, 0}; // RE4/2 + lut_[18] = {0, 0}; // ME0 } TimeZoneLut::~TimeZoneLut() { - // Do Nothing + // Do Nothing } - -void TimeZoneLut::update( - const edm::Event&, - const edm::EventSetup&) { - // Do Nothing +void TimeZoneLut::update(const edm::Event&, const edm::EventSetup&) { + // Do Nothing } int TimeZoneLut::get_timezones(const int& host, const int& bx) const { - auto found = lut_.find(host); + auto found = lut_.find(host); - // Short-Circuit: Host doesn't exist - if (found == lut_.end()) - return 0x0; + // Short-Circuit: Host doesn't exist + if (found == lut_.end()) + return 0x0; - // Build word - int word = 0x0; + // Build word + int word = 0x0; - word |= in_range(found->second, bx) ? 0x01 : 0; - word |= in_range(found->second, bx + 1) ? 0x02 : 0; // +1 BX delay - word |= in_range(found->second, bx + 2) ? 0x04 : 0; // +2 BX delay + word |= in_range(found->second, bx) ? 0x01 : 0; + word |= in_range(found->second, bx + 1) ? 0x02 : 0; // +1 BX delay + word |= in_range(found->second, bx + 2) ? 0x04 : 0; // +2 BX delay - return word; + return word; } - - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc index 1564ab0bef30b..77cc4ba7f58f1 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc @@ -6,124 +6,120 @@ using namespace emtf::phase2::data; ZoneLut::ZoneLut() { - auto& zone0 = zones_.emplace_back(); - zone0.lut_[0] = {4, 26}; // ME1/1 - zone0.lut_[3] = {4, 25}; // ME2/1 - zone0.lut_[5] = {4, 25}; // ME3/1 - zone0.lut_[7] = {4, 25}; // ME4/1 - zone0.lut_[9] = {17, 26}; // GE1/1 - zone0.lut_[12] = {7, 25}; // GE2/1 - zone0.lut_[14] = {4, 25}; // RE3/1 - zone0.lut_[16] = {4, 25}; // RE4/1 - zone0.lut_[18] = {4, 23}; // ME0 - - auto& zone1 = zones_.emplace_back(); - zone1.lut_[0] = {24, 53}; // ME1/1 - zone1.lut_[1] = {46, 54}; // ME1/2 - zone1.lut_[3] = {23, 49}; // ME2/1 - zone1.lut_[5] = {23, 41}; // ME3/1 - zone1.lut_[6] = {44, 54}; // ME3/2 - zone1.lut_[7] = {23, 35}; // ME4/1 - zone1.lut_[8] = {38, 54}; // ME4/2 - zone1.lut_[9] = {24, 52}; // GE1/1 - zone1.lut_[10] = {52, 56}; // RE1/2 - zone1.lut_[12] = {23, 46}; // GE2/1 - zone1.lut_[14] = {23, 36}; // RE3/1 - zone1.lut_[15] = {40, 52}; // RE3/2 - zone1.lut_[16] = {23, 31}; // RE4/1 - zone1.lut_[17] = {35, 54}; // RE4/2 - - auto& zone2 = zones_.emplace_back(); - zone2.lut_[1] = {52, 88}; // ME1/2 - zone2.lut_[4] = {52, 88}; // ME2/2 - zone2.lut_[6] = {50, 88}; // ME3/2 - zone2.lut_[8] = {50, 88}; // ME4/2 - zone2.lut_[10] = {52, 84}; // RE1/2 - zone2.lut_[13] = {52, 88}; // RE2/2 - zone2.lut_[15] = {48, 84}; // RE3/2 - zone2.lut_[17] = {52, 84}; // RE4/2 + auto& zone0 = zones_.emplace_back(); + zone0.lut_[0] = {4, 26}; // ME1/1 + zone0.lut_[3] = {4, 25}; // ME2/1 + zone0.lut_[5] = {4, 25}; // ME3/1 + zone0.lut_[7] = {4, 25}; // ME4/1 + zone0.lut_[9] = {17, 26}; // GE1/1 + zone0.lut_[12] = {7, 25}; // GE2/1 + zone0.lut_[14] = {4, 25}; // RE3/1 + zone0.lut_[16] = {4, 25}; // RE4/1 + zone0.lut_[18] = {4, 23}; // ME0 + + auto& zone1 = zones_.emplace_back(); + zone1.lut_[0] = {24, 53}; // ME1/1 + zone1.lut_[1] = {46, 54}; // ME1/2 + zone1.lut_[3] = {23, 49}; // ME2/1 + zone1.lut_[5] = {23, 41}; // ME3/1 + zone1.lut_[6] = {44, 54}; // ME3/2 + zone1.lut_[7] = {23, 35}; // ME4/1 + zone1.lut_[8] = {38, 54}; // ME4/2 + zone1.lut_[9] = {24, 52}; // GE1/1 + zone1.lut_[10] = {52, 56}; // RE1/2 + zone1.lut_[12] = {23, 46}; // GE2/1 + zone1.lut_[14] = {23, 36}; // RE3/1 + zone1.lut_[15] = {40, 52}; // RE3/2 + zone1.lut_[16] = {23, 31}; // RE4/1 + zone1.lut_[17] = {35, 54}; // RE4/2 + + auto& zone2 = zones_.emplace_back(); + zone2.lut_[1] = {52, 88}; // ME1/2 + zone2.lut_[4] = {52, 88}; // ME2/2 + zone2.lut_[6] = {50, 88}; // ME3/2 + zone2.lut_[8] = {50, 88}; // ME4/2 + zone2.lut_[10] = {52, 84}; // RE1/2 + zone2.lut_[13] = {52, 88}; // RE2/2 + zone2.lut_[15] = {48, 84}; // RE3/2 + zone2.lut_[17] = {52, 84}; // RE4/2 } ZoneLut::~ZoneLut() { - // Do Nothing + // Do Nothing } - -void ZoneLut::update( - const edm::Event&, - const edm::EventSetup&) { - // Do Nothing +void ZoneLut::update(const edm::Event&, const edm::EventSetup&) { + // Do Nothing } int ZoneLut::get_zones(const int& host, const int& theta) const { - int i = 0; - int word = 0; - - for (const auto& zone : zones_) { - bool in_zone = zone.contains(host, theta); + int i = 0; + int word = 0; - if (in_zone) { - word |= (1u << i); - } + for (const auto& zone : zones_) { + bool in_zone = zone.contains(host, theta); - ++i; + if (in_zone) { + word |= (1u << i); } - return word; + ++i; + } + + return word; } int ZoneLut::get_zones(const int& host, const int& theta1, const int& theta2) const { - int i = 0; - int word = 0; - - for (const auto& zone : zones_) { - bool in_zone = zone.contains(host, theta1, theta2); + int i = 0; + int word = 0; - if (in_zone) { - word |= (1u << i); - } + for (const auto& zone : zones_) { + bool in_zone = zone.contains(host, theta1, theta2); - ++i; + if (in_zone) { + word |= (1u << i); } - return word; + ++i; + } + + return word; } bool Zone::contains(const int& host, const int& theta) const { - // Short-Circuit: LUT not found - auto found = lut_.find(host); + // Short-Circuit: LUT not found + auto found = lut_.find(host); - if (found == lut_.end()) - return false; + if (found == lut_.end()) + return false; - // Short-Circuit: Must be within theta range - auto& theta_range = found->second; + // Short-Circuit: Must be within theta range + auto& theta_range = found->second; - if (theta_range.first <= theta && theta <= theta_range.second) { - return true; - } + if (theta_range.first <= theta && theta <= theta_range.second) { + return true; + } - return false; + return false; } bool Zone::contains(const int& host, const int& theta1, const int& theta2) const { - // Short-Circuit: LUT not found - auto found = lut_.find(host); + // Short-Circuit: LUT not found + auto found = lut_.find(host); - if (found == lut_.end()) - return false; + if (found == lut_.end()) + return false; - // Short-Circuit: Must be within theta range - auto& theta_range = found->second; + // Short-Circuit: Must be within theta range + auto& theta_range = found->second; - if (theta_range.first <= theta1 && theta1 <= theta_range.second) { - return true; - } + if (theta_range.first <= theta1 && theta1 <= theta_range.second) { + return true; + } - if (theta_range.first <= theta2 && theta2 <= theta_range.second) { - return true; - } + if (theta_range.first <= theta2 && theta2 <= theta_range.second) { + return true; + } - return false; + return false; } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc index 1381d53acadf5..5e3902a573d3f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc @@ -9,41 +9,38 @@ using namespace emtf::phase2; EMTFConfiguration::EMTFConfiguration(const edm::ParameterSet& pset) { - verbosity_ = pset.getUntrackedParameter("Verbosity"); - - // Validation - validation_dir_ = pset.getParameter("ValidationDirectory"); - - // Neural Network - prompt_graph_path_ = pset.getParameter("PromptGraphPath"); - displ_graph_path_ = pset.getParameter("DisplacedGraphPath"); - - // Trigger - min_bx_ = pset.getParameter("MinBX"); - max_bx_ = pset.getParameter("MaxBX"); - bx_window_ = pset.getParameter("BXWindow"); - - // Subsystems - csc_en_ = pset.getParameter("CSCEnabled"); - rpc_en_ = pset.getParameter("RPCEnabled"); - gem_en_ = pset.getParameter("GEMEnabled"); - me0_en_ = pset.getParameter("ME0Enabled"); - ge0_en_ = pset.getParameter("GE0Enabled"); - - csc_bx_shift_ = pset.getParameter("CSCInputBXShift"); - rpc_bx_shift_ = pset.getParameter("RPCInputBXShift"); - gem_bx_shift_ = pset.getParameter("GEMInputBXShift"); - me0_bx_shift_ = pset.getParameter("ME0InputBXShift"); - - // Primitive Selection - include_neighbor_en_ = pset.getParameter("IncludeNeighborEnabled"); + verbosity_ = pset.getUntrackedParameter("Verbosity"); + + // Validation + validation_dir_ = pset.getParameter("ValidationDirectory"); + + // Neural Network + prompt_graph_path_ = pset.getParameter("PromptGraphPath"); + displ_graph_path_ = pset.getParameter("DisplacedGraphPath"); + + // Trigger + min_bx_ = pset.getParameter("MinBX"); + max_bx_ = pset.getParameter("MaxBX"); + bx_window_ = pset.getParameter("BXWindow"); + + // Subsystems + csc_en_ = pset.getParameter("CSCEnabled"); + rpc_en_ = pset.getParameter("RPCEnabled"); + gem_en_ = pset.getParameter("GEMEnabled"); + me0_en_ = pset.getParameter("ME0Enabled"); + ge0_en_ = pset.getParameter("GE0Enabled"); + + csc_bx_shift_ = pset.getParameter("CSCInputBXShift"); + rpc_bx_shift_ = pset.getParameter("RPCInputBXShift"); + gem_bx_shift_ = pset.getParameter("GEMInputBXShift"); + me0_bx_shift_ = pset.getParameter("ME0InputBXShift"); + + // Primitive Selection + include_neighbor_en_ = pset.getParameter("IncludeNeighborEnabled"); } EMTFConfiguration::~EMTFConfiguration() {} -void EMTFConfiguration::update( - const edm::Event& i_event, - const edm::EventSetup& i_event_setup) { - // Do Nothing +void EMTFConfiguration::update(const edm::Event& i_event, const edm::EventSetup& i_event_setup) { + // Do Nothing } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc index 978d6864d7208..7bdd58f00557c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc @@ -10,117 +10,102 @@ using namespace emtf::phase2; -EMTFContext::EMTFContext( - const edm::ParameterSet& pset, - edm::ConsumesCollector i_consumes_collector -): - // Parameter Set - pset_(pset), - - // Helpers - geometry_translator_(i_consumes_collector), - - // EMTF - config_(pset), - model_(*this), - - // Prompt Neural Network - prompt_graph_ptr_(nullptr), - prompt_session_ptr_(nullptr), - - // Displaced Neural Network - disp_graph_ptr_(nullptr), - disp_session_ptr_(nullptr), - - // Data - site_lut_(), - host_lut_(), - zone_lut_(), - timezone_lut_(), - activation_lut_(), - - // Layers - hitmap_building_layer_(*this), - pattern_matching_layer_(*this), - road_sorting_layer_(*this), - track_building_layer_(*this), - duplicate_removal_layer_(*this), - parameter_assignment_layer_(*this), - output_layer_(*this) -{ - // Do Nothing +EMTFContext::EMTFContext(const edm::ParameterSet& pset, edm::ConsumesCollector i_consumes_collector) + : // Parameter Set + pset_(pset), + + // Helpers + geometry_translator_(i_consumes_collector), + + // EMTF + config_(pset), + model_(*this), + + // Prompt Neural Network + prompt_graph_ptr_(nullptr), + prompt_session_ptr_(nullptr), + + // Displaced Neural Network + disp_graph_ptr_(nullptr), + disp_session_ptr_(nullptr), + + // Data + site_lut_(), + host_lut_(), + zone_lut_(), + timezone_lut_(), + activation_lut_(), + + // Layers + hitmap_building_layer_(*this), + pattern_matching_layer_(*this), + road_sorting_layer_(*this), + track_building_layer_(*this), + duplicate_removal_layer_(*this), + parameter_assignment_layer_(*this), + output_layer_(*this) { + // Do Nothing } EMTFContext::~EMTFContext() { - // Delete Prompt Neural Network - if (prompt_session_ptr_ != nullptr) { - tensorflow::closeSession(prompt_session_ptr_); - delete prompt_session_ptr_; - } - - if (prompt_graph_ptr_ != nullptr) { - delete prompt_graph_ptr_; - } - - // Delete Displaced Neural Network - if (disp_session_ptr_ != nullptr) { - tensorflow::closeSession(disp_session_ptr_); - delete disp_session_ptr_; - } - - if (disp_graph_ptr_ != nullptr) { - delete disp_graph_ptr_; - } + // Delete Prompt Neural Network + if (prompt_session_ptr_ != nullptr) { + tensorflow::closeSession(prompt_session_ptr_); + delete prompt_session_ptr_; + } + + if (prompt_graph_ptr_ != nullptr) { + delete prompt_graph_ptr_; + } + + // Delete Displaced Neural Network + if (disp_session_ptr_ != nullptr) { + tensorflow::closeSession(disp_session_ptr_); + delete disp_session_ptr_; + } + + if (disp_graph_ptr_ != nullptr) { + delete disp_graph_ptr_; + } } -void EMTFContext::update( - const edm::Event& i_event, - const edm::EventSetup& i_event_setup) { - // Update Helpers - geometry_translator_.checkAndUpdateGeometry(i_event_setup); - - // Update Config - config_.update(i_event, i_event_setup); - - // Update Prompt Neural Network - if (prompt_session_ptr_ != nullptr) { - delete prompt_session_ptr_; - } - - if (prompt_graph_ptr_ != nullptr) { - delete prompt_graph_ptr_; - } - - prompt_graph_ptr_ = tensorflow::loadGraphDef( - edm::FileInPath(config_.prompt_graph_path_).fullPath() - ); - - prompt_session_ptr_ = tensorflow::createSession( - prompt_graph_ptr_ - ); - - // Update Displaced Neural Network - if (disp_session_ptr_ != nullptr) { - delete disp_session_ptr_; - } - - if (disp_graph_ptr_ != nullptr) { - delete disp_graph_ptr_; - } - - disp_graph_ptr_ = tensorflow::loadGraphDef( - edm::FileInPath(config_.displ_graph_path_).fullPath() - ); - - disp_session_ptr_ = tensorflow::createSession( - disp_graph_ptr_ - ); - - // Update Data - site_lut_.update(i_event, i_event_setup); - host_lut_.update(i_event, i_event_setup); - zone_lut_.update(i_event, i_event_setup); - timezone_lut_.update(i_event, i_event_setup); - activation_lut_.update(i_event, i_event_setup); -} +void EMTFContext::update(const edm::Event& i_event, const edm::EventSetup& i_event_setup) { + // Update Helpers + geometry_translator_.checkAndUpdateGeometry(i_event_setup); + + // Update Config + config_.update(i_event, i_event_setup); + + // Update Prompt Neural Network + if (prompt_session_ptr_ != nullptr) { + delete prompt_session_ptr_; + } + + if (prompt_graph_ptr_ != nullptr) { + delete prompt_graph_ptr_; + } + + prompt_graph_ptr_ = tensorflow::loadGraphDef(edm::FileInPath(config_.prompt_graph_path_).fullPath()); + + prompt_session_ptr_ = tensorflow::createSession(prompt_graph_ptr_); + // Update Displaced Neural Network + if (disp_session_ptr_ != nullptr) { + delete disp_session_ptr_; + } + + if (disp_graph_ptr_ != nullptr) { + delete disp_graph_ptr_; + } + + disp_graph_ptr_ = tensorflow::loadGraphDef(edm::FileInPath(config_.displ_graph_path_).fullPath()); + + disp_session_ptr_ = tensorflow::createSession(disp_graph_ptr_); + + // Update Data + site_lut_.update(i_event, i_event_setup); + host_lut_.update(i_event, i_event_setup); + zone_lut_.update(i_event, i_event_setup); + timezone_lut_.update(i_event, i_event_setup); + activation_lut_.update(i_event, i_event_setup); +} diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFModel.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFModel.cc index 5307838214016..6bbf95e39d387 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFModel.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFModel.cc @@ -6,14 +6,12 @@ using namespace emtf::phase2; using namespace emtf::phase2::model; -EMTFModel::EMTFModel( - const EMTFContext& context -): - context_(context) -{ - // =========================================================================== - // Zone 0 - // =========================================================================== +EMTFModel::EMTFModel(const EMTFContext& context) : context_(context) { + // =========================================================================== + // Zone 0 + // =========================================================================== + + // clang-format off zones::hitmap_t&& zone0_hm = { { // Row 0 { @@ -161,18 +159,15 @@ EMTFModel::EMTFModel( 13, 55, 54, 60, 55, 61, 60, 63, 8, 41, 40, 43, 42, 43, 43, 47, 14, 54, 54, 59, 54, 59, 60, 62, 15, 56, 54, 59, 58, 62, 61, 63, 15, 59, 58, 62, 59, 63, 63, 63 }; + // clang-format on + + zones_.push_back({zone0_hm, zone0_prompt_pd, zone0_prompt_ql, zone0_disp_pd, zone0_disp_ql}); - zones_.push_back({ - zone0_hm, - zone0_prompt_pd, - zone0_prompt_ql, - zone0_disp_pd, - zone0_disp_ql - }); + // =========================================================================== + // Zone 1 + // =========================================================================== - // =========================================================================== - // Zone 1 - // =========================================================================== + // clang-format off zones::hitmap_t&& zone1_hm = { { // Row 0 { @@ -367,18 +362,15 @@ EMTFModel::EMTFModel( 14, 56, 56, 61, 54, 59, 60, 63, 8, 40, 41, 43, 41, 43, 43, 47, 13, 54, 54, 60, 54, 58, 59, 63, 15, 55, 57, 61, 58, 60, 62, 63, 15, 59, 59, 63, 59, 62, 62, 63 }; + // clang-format on - zones_.push_back({ - zone1_hm, - zone1_prompt_pd, - zone1_prompt_ql, - zone1_disp_pd, - zone1_disp_ql - }); + zones_.push_back({zone1_hm, zone1_prompt_pd, zone1_prompt_ql, zone1_disp_pd, zone1_disp_ql}); - // =========================================================================== - // Zone 2 - // =========================================================================== + // =========================================================================== + // Zone 2 + // =========================================================================== + + // clang-format off zones::hitmap_t&& zone2_hm = { { // Row 0 { @@ -533,25 +525,22 @@ EMTFModel::EMTFModel( 13, 57, 56, 62, 15, 62, 60, 63, 2, 41, 41, 44, 6, 56, 54, 59, 13, 58, 55, 61, 14, 61, 59, 63, 9, 45, 45, 49, 14, 60, 59, 62, 15, 62, 60, 63, 15, 63, 62, 63 }; + // clang-format on + + zones_.push_back({zone2_hm, zone2_prompt_pd, zone2_prompt_ql, zone2_disp_pd, zone2_disp_ql}); - zones_.push_back({ - zone2_hm, - zone2_prompt_pd, - zone2_prompt_ql, - zone2_disp_pd, - zone2_disp_ql - }); + // =========================================================================== + // Features + // =========================================================================== + // feat | ME1/1 | ME1/2 | ME2 | ME3 | ME4 | RE1 | RE2 | RE3 | RE4 | GE1/1 | GE2/1 | ME0 + // -----------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|------- + // emtf_phi | * | * | * | * | * | * | * | * | * | * | * | * + // emtf_theta | * | * | * | * | * | * | * | * | * | * | * | * + // emtf_bend | * | * | * | * | * | | | | | | | * + // emtf_qual | * | * | * | * | * | | | | | | | * + // emtf_time | | | | | | | | | | | | - // =========================================================================== - // Features - // =========================================================================== - // feat | ME1/1 | ME1/2 | ME2 | ME3 | ME4 | RE1 | RE2 | RE3 | RE4 | GE1/1 | GE2/1 | ME0 - // -----------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|------- - // emtf_phi | * | * | * | * | * | * | * | * | * | * | * | * - // emtf_theta | * | * | * | * | * | * | * | * | * | * | * | * - // emtf_bend | * | * | * | * | * | | | | | | | * - // emtf_qual | * | * | * | * | * | | | | | | | * - // emtf_time | | | | | | | | | | | | + // clang-format off features_ = { { feature_id_t::kPhi, { @@ -580,10 +569,13 @@ EMTFModel::EMTFModel( } }, }; + // clang-format on - // =========================================================================== - // Theta Options - // =========================================================================== + // =========================================================================== + // Theta Options + // =========================================================================== + + // clang-format off theta_medians_ = { // ME2_t1, ME3_t1, ME4_t1, ME2_t2, ME3_t2, ME4_t2, GE21, RE3, RE4 { @@ -640,17 +632,20 @@ EMTFModel::EMTFModel( }, }, }; + // clang-format on + + // =========================================================================== + // Site Reduction + // =========================================================================== + // Site (out) | Site (in) + // -----------|------------------------------------------- + // ME1 | ME1/1, GE1/1, ME1/2, RE1/2 + // ME2 | ME2, GE2/1, RE2/2 + // ME3 | ME3, RE3 + // ME4 | ME4, RE4 + // ME0 | ME0 - // =========================================================================== - // Site Reduction - // =========================================================================== - // Site (out) | Site (in) - // -----------|------------------------------------------- - // ME1 | ME1/1, GE1/1, ME1/2, RE1/2 - // ME2 | ME2, GE2/1, RE2/2 - // ME3 | ME3, RE3 - // ME4 | ME4, RE4 - // ME0 | ME0 + // clang-format off reduced_sites_ = { {reduced_site_id_t::kME1, {site_id_t::kME11, site_id_t::kGE11, site_id_t::kME12, site_id_t::kRE1}}, {reduced_site_id_t::kME2, {site_id_t::kME2, site_id_t::kGE21, site_id_t::kRE2}}, @@ -658,9 +653,9 @@ EMTFModel::EMTFModel( {reduced_site_id_t::kME4, {site_id_t::kME4, site_id_t::kRE4}}, {reduced_site_id_t::kME0, {site_id_t::kME0}}, }; + // clang-format on } EMTFModel::~EMTFModel() { - // Do Nothing + // Do Nothing } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc index efdfd8ed84f9c..e61546b8ca86c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc @@ -27,453 +27,393 @@ using namespace emtf::phase2; -SectorProcessor::SectorProcessor( - const EMTFContext& context, - const int& endcap, const int& sector -): - context_(context), - endcap_(endcap), - sector_(sector), - event_(nullptr), - bx_(nullptr) -{ - // =========================================================================== - // Register Selectors/Converters - // =========================================================================== - if (CONFIG.csc_en_) { - tp_selectors_[L1TMuon::kCSC] = std::make_unique(context_, endcap_, sector_); - tp_converters_[L1TMuon::kCSC] = std::make_unique(context_, endcap_, sector_); - } - - if (CONFIG.rpc_en_) { - tp_selectors_[L1TMuon::kRPC] = std::make_unique(context_, endcap_, sector_); - tp_converters_[L1TMuon::kRPC] = std::make_unique(context_, endcap_, sector_); - } - - if (CONFIG.gem_en_) { - tp_selectors_[L1TMuon::kGEM] = std::make_unique(context_, endcap_, sector_); - tp_converters_[L1TMuon::kGEM] = std::make_unique(context_, endcap_, sector_); - } - - if (CONFIG.me0_en_) { - tp_selectors_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); - tp_converters_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); - } - - if (CONFIG.ge0_en_) { - tp_selectors_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); - tp_converters_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); - } - +SectorProcessor::SectorProcessor(const EMTFContext& context, const int& endcap, const int& sector) + : context_(context), endcap_(endcap), sector_(sector), event_(nullptr), bx_(nullptr) { + // =========================================================================== + // Register Selectors/Converters + // =========================================================================== + if (CONFIG.csc_en_) { + tp_selectors_[L1TMuon::kCSC] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kCSC] = std::make_unique(context_, endcap_, sector_); + } + + if (CONFIG.rpc_en_) { + tp_selectors_[L1TMuon::kRPC] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kRPC] = std::make_unique(context_, endcap_, sector_); + } + + if (CONFIG.gem_en_) { + tp_selectors_[L1TMuon::kGEM] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kGEM] = std::make_unique(context_, endcap_, sector_); + } + + if (CONFIG.me0_en_) { + tp_selectors_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); + } + + if (CONFIG.ge0_en_) { + tp_selectors_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); + tp_converters_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); + } } SectorProcessor::~SectorProcessor() { - // Do Nothing + // Do Nothing } void SectorProcessor::configure_event(const edm::Event& event) { - // Event - event_ = &event; - bx_ = nullptr; + // Event + event_ = &event; + bx_ = nullptr; - // Reset Window Hits - bx_window_hits_.clear(); - bx_ilink_tpc_maps_.clear(); + // Reset Window Hits + bx_window_hits_.clear(); + bx_ilink_tpc_maps_.clear(); } void SectorProcessor::configure_bx(const int& bx) { - // BX - bx_ = &bx; + // BX + bx_ = &bx; - // Reset BX Maps - bx_ilink_tpc_maps_.clear(); + // Reset BX Maps + bx_ilink_tpc_maps_.clear(); - // Remove BX TPCollections that aren't in the bx window - // Note that the first entry in bx_window_hits is the earliest BX - const auto min_bx = CONFIG.min_bx_; - const auto delay_bx = CONFIG.bx_window_ - 1; - const auto pop_after_bx = min_bx + delay_bx; + // Remove BX TPCollections that aren't in the bx window + // Note that the first entry in bx_window_hits is the earliest BX + const auto min_bx = CONFIG.min_bx_; + const auto delay_bx = CONFIG.bx_window_ - 1; + const auto pop_after_bx = min_bx + delay_bx; - if (pop_after_bx < bx) { - bx_window_hits_.erase(bx_window_hits_.begin()); - } + if (pop_after_bx < bx) { + bx_window_hits_.erase(bx_window_hits_.begin()); + } } -void SectorProcessor::select( - const TriggerPrimitive& tp, - const TPInfo& tp_info -) { - // Get TPSelector - auto tp_subsystem = tp.subsystem(); - - auto tp_selectors_it = tp_selectors_.find(tp_subsystem); - - // Short-Circuit: Operation not supported - if (tp_selectors_it == tp_selectors_.end()) { - edm::LogWarning("L1T") - << "TPCollector has been implemented, " - << "but there is no TPSelector for " - << tp_subsystem; - return; - } +void SectorProcessor::select(const TriggerPrimitive& tp, const TPInfo& tp_info) { + // Get TPSelector + auto tp_subsystem = tp.subsystem(); + + auto tp_selectors_it = tp_selectors_.find(tp_subsystem); + + // Short-Circuit: Operation not supported + if (tp_selectors_it == tp_selectors_.end()) { + edm::LogWarning("L1T") << "TPCollector has been implemented, " + << "but there is no TPSelector for " << tp_subsystem; + return; + } - // Select TP that belongs to this Sector Processor - auto& bx_ilink_tpc_map = bx_ilink_tpc_maps_[tp_subsystem]; // reference to subsystem trigger primitive collection + // Select TP that belongs to this Sector Processor + auto& bx_ilink_tpc_map = bx_ilink_tpc_maps_[tp_subsystem]; // reference to subsystem trigger primitive collection - tp_selectors_it->second->select( - tp, tp_info, - bx_ilink_tpc_map - ); + tp_selectors_it->second->select(tp, tp_info, bx_ilink_tpc_map); } -void SectorProcessor::process( - EMTFHitCollection& out_hits, - EMTFTrackCollection& out_tracks, - EMTFInputCollection& out_inputs -) { - // =========================================================================== - // Merge subsystem selections - // =========================================================================== - ILinkTPCMap bx_ilink_tpc_map; - - for (auto& [subsystem, ilink_tpc_map] : bx_ilink_tpc_maps_) { - copy_tp(ilink_tpc_map, bx_ilink_tpc_map); - } +void SectorProcessor::process(EMTFHitCollection& out_hits, + EMTFTrackCollection& out_tracks, + EMTFInputCollection& out_inputs) { + // =========================================================================== + // Merge subsystem selections + // =========================================================================== + ILinkTPCMap bx_ilink_tpc_map; - // Free memory - bx_ilink_tpc_maps_.clear(); - - // =========================================================================== - // Convert trigger primitives to EMTF Hits - // =========================================================================== - - // Convert tp into hits - EMTFHitCollection bx_hits; - - convert_tp( - out_hits.size(), - bx_ilink_tpc_map, - bx_hits - ); - - // Append to bx window hits - bx_window_hits_.push_back(bx_hits); - - // Free memory - bx_ilink_tpc_map.clear(); - - // Record hits - out_hits.insert(out_hits.end(), bx_hits.begin(), bx_hits.end()); - - // =========================================================================== - // Current Algorithm only supports BX=0 - // =========================================================================== - - if ((*bx_) != 0) { - return; - } + for (auto& [subsystem, ilink_tpc_map] : bx_ilink_tpc_maps_) { + copy_tp(ilink_tpc_map, bx_ilink_tpc_map); + } + + // Free memory + bx_ilink_tpc_maps_.clear(); + + // =========================================================================== + // Convert trigger primitives to EMTF Hits + // =========================================================================== + + // Convert tp into hits + EMTFHitCollection bx_hits; + + convert_tp(out_hits.size(), bx_ilink_tpc_map, bx_hits); + + // Append to bx window hits + bx_window_hits_.push_back(bx_hits); - // =========================================================================== - // Convert EMTF Hits to Segments - // =========================================================================== - - // Init Segment to Hit Map - std::map seg_to_hit; - - // Convert bx window hits into segments - segment_collection_t segments; - - populate_segments(bx_window_hits_, seg_to_hit, segments); - - // Build Tracks - build_tracks(seg_to_hit, segments, false, out_tracks); // With prompt setup - build_tracks(seg_to_hit, segments, true, out_tracks); // With displaced setup - - // =========================================================================== - // Record segments/hits used in track building - // =========================================================================== - if (seg_to_hit.size() > 0) { - EMTFInput::hits_t hit_id_col; - EMTFInput::segs_t seg_id_col; - - for (const auto& [seg_id, hit_id] : seg_to_hit) { - seg_id_col.push_back(seg_id); - hit_id_col.push_back(hit_id); - } - - EMTFInput emtf_input; - - const int endcap_pm = (endcap_ == 2) ? -1 : endcap_; // 1: +endcap, -1: -endcap - - emtf_input.setEndcap(endcap_pm); - emtf_input.setSector(sector_); - emtf_input.setBx(*bx_); - emtf_input.setHits(hit_id_col); - emtf_input.setSegs(seg_id_col); - - out_inputs.push_back(emtf_input); + // Free memory + bx_ilink_tpc_map.clear(); + + // Record hits + out_hits.insert(out_hits.end(), bx_hits.begin(), bx_hits.end()); + + // =========================================================================== + // Current Algorithm only supports BX=0 + // =========================================================================== + + if ((*bx_) != 0) { + return; + } + + // =========================================================================== + // Convert EMTF Hits to Segments + // =========================================================================== + + // Init Segment to Hit Map + std::map seg_to_hit; + + // Convert bx window hits into segments + segment_collection_t segments; + + populate_segments(bx_window_hits_, seg_to_hit, segments); + + // Build Tracks + build_tracks(seg_to_hit, segments, false, out_tracks); // With prompt setup + build_tracks(seg_to_hit, segments, true, out_tracks); // With displaced setup + + // =========================================================================== + // Record segments/hits used in track building + // =========================================================================== + if (seg_to_hit.size() > 0) { + EMTFInput::hits_t hit_id_col; + EMTFInput::segs_t seg_id_col; + + for (const auto& [seg_id, hit_id] : seg_to_hit) { + seg_id_col.push_back(seg_id); + hit_id_col.push_back(hit_id); } -} -void SectorProcessor::copy_tp( - const ILinkTPCMap& source, - ILinkTPCMap& target -) const { - typedef typename ILinkTPCMap::iterator Iterator_t; - typedef typename ILinkTPCMap::mapped_type Collection_t; + EMTFInput emtf_input; + + const int endcap_pm = (endcap_ == 2) ? -1 : endcap_; // 1: +endcap, -1: -endcap - for (auto& source_kv : source) { - std::pair ins_res = target.insert(source_kv); + emtf_input.setEndcap(endcap_pm); + emtf_input.setSector(sector_); + emtf_input.setBx(*bx_); + emtf_input.setHits(hit_id_col); + emtf_input.setSegs(seg_id_col); - // Short-Circuit: Insertion succeeded, move on - if (ins_res.second) { - continue; - } + out_inputs.push_back(emtf_input); + } +} - // Merge into target collection - const Collection_t& source_col = source_kv.second; - Collection_t& target_col = ins_res.first->second; +void SectorProcessor::copy_tp(const ILinkTPCMap& source, ILinkTPCMap& target) const { + typedef typename ILinkTPCMap::iterator Iterator_t; + typedef typename ILinkTPCMap::mapped_type Collection_t; - target_col.insert(target_col.end(), source_col.begin(), source_col.end()); + for (auto& source_kv : source) { + std::pair ins_res = target.insert(source_kv); + + // Short-Circuit: Insertion succeeded, move on + if (ins_res.second) { + continue; } + + // Merge into target collection + const Collection_t& source_col = source_kv.second; + Collection_t& target_col = ins_res.first->second; + + target_col.insert(target_col.end(), source_col.begin(), source_col.end()); + } } -void SectorProcessor::convert_tp( - const int& initial_hit_id, - const ILinkTPCMap& ilink_tpc_map, - EMTFHitCollection& hits -) { - EMTFHitCollection substitutes; +void SectorProcessor::convert_tp(const int& initial_hit_id, const ILinkTPCMap& ilink_tpc_map, EMTFHitCollection& hits) { + EMTFHitCollection substitutes; + + for (const auto& [ilink, ilink_tpc] : ilink_tpc_map) { // loop input link trigger primitive collections - for (const auto& [ilink, ilink_tpc] : ilink_tpc_map) { // loop input link trigger primitive collections + unsigned int cnt_segments = 0; // Enumerates each segment in the same chamber - unsigned int cnt_segments = 0; // Enumerates each segment in the same chamber + for (const auto& tp_entry : ilink_tpc) { // loop trigger primitives - for (const auto& tp_entry : ilink_tpc) { // loop trigger primitives - - // Unpack Entry - const auto& tp = tp_entry.tp_; // const reference - auto tp_info = tp_entry.info_; // copy info + // Unpack Entry + const auto& tp = tp_entry.tp_; // const reference + auto tp_info = tp_entry.info_; // copy info - // Unpack trigger primitive - auto tp_subsystem = tp.subsystem(); + // Unpack trigger primitive + auto tp_subsystem = tp.subsystem(); - // Get Converter - auto tp_converters_it = tp_converters_.find(tp_subsystem); + // Get Converter + auto tp_converters_it = tp_converters_.find(tp_subsystem); - // Short-Circuit: Operation not supported - if (tp_converters_it == tp_converters_.end()) { - edm::LogWarning("L1T") << "TPCollector & TPSelector have been implemented, " - << "but there is no TPConverter for " - << tp_subsystem; - continue; - } + // Short-Circuit: Operation not supported + if (tp_converters_it == tp_converters_.end()) { + edm::LogWarning("L1T") << "TPCollector & TPSelector have been implemented, " + << "but there is no TPConverter for " << tp_subsystem; + continue; + } - // Set Segment Id - tp_info.segment_id = cnt_segments++; // Save and increase segment count + // Set Segment Id + tp_info.segment_id = cnt_segments++; // Save and increase segment count - // Convert - EMTFHit hit; + // Convert + EMTFHit hit; - tp_converters_it->second->convert(tp, tp_info, hit); + tp_converters_it->second->convert(tp, tp_info, hit); - // Append to hit collections - if (tp_info.flag_substitute){ - substitutes.push_back(hit); - } else { - hits.push_back(hit); - } - } + // Append to hit collections + if (tp_info.flag_substitute) { + substitutes.push_back(hit); + } else { + hits.push_back(hit); + } } + } - // Substitutes are placed at the end of the hit collection - hits.insert( - hits.end(), - std::make_move_iterator(substitutes.begin()), - std::make_move_iterator(substitutes.end()) - ); + // Substitutes are placed at the end of the hit collection + hits.insert(hits.end(), std::make_move_iterator(substitutes.begin()), std::make_move_iterator(substitutes.end())); - // Assign Hit Ids - unsigned int cnt_hits = initial_hit_id; + // Assign Hit Ids + unsigned int cnt_hits = initial_hit_id; - for (auto& hit : hits) { - hit.setId(cnt_hits++); - } + for (auto& hit : hits) { + hit.setId(cnt_hits++); + } } -void SectorProcessor::populate_segments( - const std::vector& bx_window_hits, - std::map& seg_to_hit, - segment_collection_t& segments -) { - // Initialize - for (int seg_id = 0; seg_id < v3::kNumSegments; ++seg_id) { - segments[seg_id].phi = 0; - segments[seg_id].bend = 0; - segments[seg_id].theta1 = 0; - segments[seg_id].theta2 = 0; - segments[seg_id].qual1 = 0; - segments[seg_id].qual2 = 0; - segments[seg_id].time = 0; - segments[seg_id].zones = 0; - segments[seg_id].tzones = 0; - segments[seg_id].cscfr = 0; - segments[seg_id].layer = 0; - segments[seg_id].bx = 0; - segments[seg_id].valid = 0; +void SectorProcessor::populate_segments(const std::vector& bx_window_hits, + std::map& seg_to_hit, + segment_collection_t& segments) { + // Initialize + for (int seg_id = 0; seg_id < v3::kNumSegments; ++seg_id) { + segments[seg_id].phi = 0; + segments[seg_id].bend = 0; + segments[seg_id].theta1 = 0; + segments[seg_id].theta2 = 0; + segments[seg_id].qual1 = 0; + segments[seg_id].qual2 = 0; + segments[seg_id].time = 0; + segments[seg_id].zones = 0; + segments[seg_id].tzones = 0; + segments[seg_id].cscfr = 0; + segments[seg_id].layer = 0; + segments[seg_id].bx = 0; + segments[seg_id].valid = 0; + } + + // Populate + auto bx_window_hits_rit = bx_window_hits.rbegin(); + auto bx_window_hits_rend = bx_window_hits.rend(); + + std::map next_ch_seg; + + for (; bx_window_hits_rit != bx_window_hits_rend; + ++bx_window_hits_rit) { // Begin loop from latest BX Collection to oldest BX Hit Collection + + const auto& bx_hits = *bx_window_hits_rit; + std::map bx_last_ch_seg; + + for (const auto& hit : bx_hits) { // Begin loop hits in BX + // Unpack Hit + const auto& hit_chamber = hit.emtfChamber(); + const auto& hit_segment = hit.emtfSegment(); + const auto& hit_valid = hit.flagValid(); + + emtf_assert(hit_valid); // segment must be valid + + // Get Channel Segment Count + unsigned int ch_seg = next_ch_seg[hit_chamber] + hit_segment; + + // Short-Circuit: Accept at most 2 segments + if (!(ch_seg < v3::kChamberSegments)) { + continue; + } + + // Calculate Host + const auto& hit_host = hit.emtfHost(); + + // Calculate Relative BX + // Note: Uses Hit BX relative to Sector Processor BX + const auto& hit_bx = hit.bx(); + const int hit_rel_bx = (hit_bx - *bx_); + + // Short-Circuit: Only use Relative BX=0 Segments + if (hit_rel_bx != 0) { + continue; + } + + // Calculate Timezone + const auto hit_timezones = context_.timezone_lut_.get_timezones(hit_host, hit_rel_bx); + + // Calculate algo seg + const unsigned int seg_id = hit_chamber * v3::kChamberSegments + ch_seg; + + emtf_assert(seg_id < v3::kNumSegments); + + seg_to_hit[seg_id] = hit.id(); + + // Populate segment + segments[seg_id].phi = hit.emtfPhi(); + segments[seg_id].bend = hit.emtfBend(); + segments[seg_id].theta1 = hit.emtfTheta1(); + segments[seg_id].theta2 = hit.emtfTheta2(); + segments[seg_id].qual1 = hit.emtfQual1(); + segments[seg_id].qual2 = hit.emtfQual2(); + segments[seg_id].time = hit.emtfTime(); + segments[seg_id].zones = hit.emtfZones(); + segments[seg_id].tzones = hit_timezones; + segments[seg_id].cscfr = hit.cscFR(); + segments[seg_id].layer = hit.layer(); + segments[seg_id].bx = hit.bx(); + segments[seg_id].valid = hit.flagValid(); + + // Debug Info + if (CONFIG.verbosity_ > 1) { + std::cout << std::endl + << "Event: " << event_->id() << " Endcap: " << endcap_ << " Sector: " << sector_ << " BX: " << (*bx_) + << " Hit iLink: " << hit_chamber << " Hit iSeg: " << ch_seg << " Hit Host " << hit_host + << " Hit Rel BX " << (hit_bx - *bx_) << " Hit Timezones " << hit_timezones << std::endl; + + std::cout << " id " << seg_id << " phi " << segments[seg_id].phi << " bend " << segments[seg_id].bend + << " theta1 " << segments[seg_id].theta1 << " theta2 " << segments[seg_id].theta2 << " qual1 " + << segments[seg_id].qual1 << " qual2 " << segments[seg_id].qual2 << " time " << segments[seg_id].time + << " zones " << segments[seg_id].zones << " timezones " << segments[seg_id].tzones << " cscfr " + << segments[seg_id].cscfr << " layer " << segments[seg_id].layer << " bx " << segments[seg_id].bx + << " valid " << segments[seg_id].valid << std::endl; + } + + // Update bx chamber last segment + bx_last_ch_seg[hit_chamber] = ch_seg; + } // End loop hits from BX + + for (auto& [chamber, ch_seg] : bx_last_ch_seg) { + next_ch_seg[chamber] = ch_seg + 1; } - // Populate - auto bx_window_hits_rit = bx_window_hits.rbegin(); - auto bx_window_hits_rend = bx_window_hits.rend(); - - std::map next_ch_seg; - - for (; bx_window_hits_rit != bx_window_hits_rend; ++bx_window_hits_rit) { // Begin loop from latest BX Collection to oldest BX Hit Collection - - const auto& bx_hits = *bx_window_hits_rit; - std::map bx_last_ch_seg; - - for (const auto& hit : bx_hits) { // Begin loop hits in BX - // Unpack Hit - const auto& hit_chamber = hit.emtfChamber(); - const auto& hit_segment = hit.emtfSegment(); - const auto& hit_valid = hit.flagValid(); - - emtf_assert(hit_valid); // segment must be valid - - // Get Channel Segment Count - unsigned int ch_seg = next_ch_seg[hit_chamber] + hit_segment; - - // Short-Circuit: Accept at most 2 segments - if (!(ch_seg < v3::kChamberSegments)) { - continue; - } - - // Calculate Host - const auto& hit_host = hit.emtfHost(); - - // Calculate Relative BX - // Note: Uses Hit BX relative to Sector Processor BX - const auto& hit_bx = hit.bx(); - const int hit_rel_bx = (hit_bx - *bx_); - - // Short-Circuit: Only use Relative BX=0 Segments - if (hit_rel_bx != 0) { - continue; - } - - // Calculate Timezone - const auto hit_timezones = context_.timezone_lut_.get_timezones(hit_host, hit_rel_bx); - - // Calculate algo seg - const unsigned int seg_id = hit_chamber * v3::kChamberSegments + ch_seg; - - emtf_assert(seg_id < v3::kNumSegments); - - seg_to_hit[seg_id] = hit.id(); - - // Populate segment - segments[seg_id].phi = hit.emtfPhi(); - segments[seg_id].bend = hit.emtfBend(); - segments[seg_id].theta1 = hit.emtfTheta1(); - segments[seg_id].theta2 = hit.emtfTheta2(); - segments[seg_id].qual1 = hit.emtfQual1(); - segments[seg_id].qual2 = hit.emtfQual2(); - segments[seg_id].time = hit.emtfTime(); - segments[seg_id].zones = hit.emtfZones(); - segments[seg_id].tzones = hit_timezones; - segments[seg_id].cscfr = hit.cscFR(); - segments[seg_id].layer = hit.layer(); - segments[seg_id].bx = hit.bx(); - segments[seg_id].valid = hit.flagValid(); - - // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout - << std::endl - << "Event: " << event_->id() - << " Endcap: " << endcap_ - << " Sector: " << sector_ - << " BX: " << (*bx_) - << " Hit iLink: " << hit_chamber - << " Hit iSeg: " << ch_seg - << " Hit Host " << hit_host - << " Hit Rel BX " << (hit_bx - *bx_) - << " Hit Timezones " << hit_timezones - << std::endl; - - std::cout - << " id " << seg_id - << " phi " << segments[seg_id].phi - << " bend " << segments[seg_id].bend - << " theta1 " << segments[seg_id].theta1 - << " theta2 " << segments[seg_id].theta2 - << " qual1 " << segments[seg_id].qual1 - << " qual2 " << segments[seg_id].qual2 - << " time " << segments[seg_id].time - << " zones " << segments[seg_id].zones - << " timezones " << segments[seg_id].tzones - << " cscfr " << segments[seg_id].cscfr - << " layer " << segments[seg_id].layer - << " bx " << segments[seg_id].bx - << " valid " << segments[seg_id].valid - << std::endl; - } - - // Update bx chamber last segment - bx_last_ch_seg[hit_chamber] = ch_seg; - } // End loop hits from BX - - for (auto& [chamber, ch_seg] : bx_last_ch_seg) { - next_ch_seg[chamber] = ch_seg + 1; - } - - bx_last_ch_seg.clear(); - } // End loop from latest BX Collection to oldest BX Hit Collection + bx_last_ch_seg.clear(); + } // End loop from latest BX Collection to oldest BX Hit Collection } -void SectorProcessor::build_tracks( - const std::map& seg_to_hit, - const segment_collection_t& segments, - const bool& displaced_en, - EMTFTrackCollection& out_tracks -) { - // Apply Hitmap Building Layer: Convert segments into hitmaps - std::vector zone_hitmaps; +void SectorProcessor::build_tracks(const std::map& seg_to_hit, + const segment_collection_t& segments, + const bool& displaced_en, + EMTFTrackCollection& out_tracks) { + // Apply Hitmap Building Layer: Convert segments into hitmaps + std::vector zone_hitmaps; + + context_.hitmap_building_layer_.apply(segments, zone_hitmaps); + + // Apply Pattern Matching Layer: Match patterns to hitmaps to create roads + std::vector zone_roads; - context_.hitmap_building_layer_.apply(segments, zone_hitmaps); + context_.pattern_matching_layer_.apply(zone_hitmaps, displaced_en, zone_roads); - // Apply Pattern Matching Layer: Match patterns to hitmaps to create roads - std::vector zone_roads; + // Apply Road Sorting Layer: Find the best roads + std::vector best_roads; - context_.pattern_matching_layer_.apply(zone_hitmaps, displaced_en, zone_roads); + context_.road_sorting_layer_.apply(v3::kNumTracks, zone_roads, best_roads); - // Apply Road Sorting Layer: Find the best roads - std::vector best_roads; - - context_.road_sorting_layer_.apply(v3::kNumTracks, zone_roads, best_roads); + // Apply Track Building Layer: Match segments to the best roads to create tracks + std::vector tracks; - // Apply Track Building Layer: Match segments to the best roads to create tracks - std::vector tracks; + context_.track_building_layer_.apply(segments, best_roads, displaced_en, tracks); - context_.track_building_layer_.apply(segments, best_roads, displaced_en, tracks); + // Apply Duplicate Removal Layer: Removes tracks that share a segment, keeping the one that has the highest quality + context_.duplicate_removal_layer_.apply(tracks); - // Apply Duplicate Removal Layer: Removes tracks that share a segment, keeping the one that has the highest quality - context_.duplicate_removal_layer_.apply(tracks); + // Apply Parameter Assigment Layer: Run NN on tracks + context_.parameter_assignment_layer_.apply(displaced_en, tracks); - // Apply Parameter Assigment Layer: Run NN on tracks - context_.parameter_assignment_layer_.apply(displaced_en, tracks); + // Apply Output Layer + EMTFTrackCollection bx_tracks; - // Apply Output Layer - EMTFTrackCollection bx_tracks; - - context_.output_layer_.apply( - endcap_, sector_, *bx_, - seg_to_hit, tracks, displaced_en, - bx_tracks - ); + context_.output_layer_.apply(endcap_, sector_, *bx_, seg_to_hit, tracks, displaced_en, bx_tracks); - // Record tracks - out_tracks.insert(out_tracks.end(), bx_tracks.begin(), bx_tracks.end()); + // Record tracks + out_tracks.insert(out_tracks.end(), bx_tracks.begin(), bx_tracks.end()); } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc index 97bfdae9beb34..e946305a8075f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc @@ -24,202 +24,192 @@ using namespace emtf::phase2; -TrackFinder::TrackFinder( - const edm::ParameterSet& i_config, - edm::ConsumesCollector&& i_consumes_collector -): - context_(i_config, i_consumes_collector), - tp_collectors_(), - sector_processors_() -{ - // =========================================================================== - // Emulation Setup - // =========================================================================== - - // Register Trigger Primitives - if (CONFIG.csc_en_) { - tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); - } - - if (CONFIG.rpc_en_) { - tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); - } - - if (CONFIG.gem_en_) { - tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); - } - - if (CONFIG.me0_en_) { - tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); - } - - if (CONFIG.ge0_en_) { - tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); - } - - // Register Sector Processor - for (int endcap = kMinEndcap; endcap <= kMaxEndcap; ++endcap) { - for (int sector = kMinTrigSector; sector <= kMaxTrigSector; ++sector) { - sector_processors_.push_back( - std::make_unique(context_, endcap, sector) - ); - } +TrackFinder::TrackFinder(const edm::ParameterSet& i_config, edm::ConsumesCollector&& i_consumes_collector) + : context_(i_config, i_consumes_collector), tp_collectors_(), sector_processors_() { + // =========================================================================== + // Emulation Setup + // =========================================================================== + + // Register Trigger Primitives + if (CONFIG.csc_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + if (CONFIG.rpc_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + if (CONFIG.gem_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + if (CONFIG.me0_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + if (CONFIG.ge0_en_) { + tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); + } + + // Register Sector Processor + for (int endcap = kMinEndcap; endcap <= kMaxEndcap; ++endcap) { + for (int sector = kMinTrigSector; sector <= kMaxTrigSector; ++sector) { + sector_processors_.push_back(std::make_unique(context_, endcap, sector)); } + } } TrackFinder::~TrackFinder() { - // Do Nothing + // Do Nothing } void TrackFinder::process( - // Input - const edm::Event& i_event, - const edm::EventSetup& i_event_setup, - // Output - EMTFHitCollection& out_hits, - EMTFTrackCollection& out_tracks, - EMTFInputCollection& out_inputs -) { - // =========================================================================== - // Clear output collections - // =========================================================================== - - out_hits.clear(); - out_tracks.clear(); - out_inputs.clear(); - - // =========================================================================== - // Load the event configuration - // =========================================================================== - - context_.update(i_event, i_event_setup); - - // =========================================================================== - // Collect trigger primitives - // =========================================================================== - - // Build BX Sequence - std::vector bx_sequence; - - { - auto min_bx = CONFIG.min_bx_; - auto delay_bx = CONFIG.bx_window_ - 1; - auto max_bx = CONFIG.max_bx_ + delay_bx; - - for (int bx = min_bx; bx <= max_bx; ++bx) { - bx_sequence.push_back(bx); - } + // Input + const edm::Event& i_event, + const edm::EventSetup& i_event_setup, + // Output + EMTFHitCollection& out_hits, + EMTFTrackCollection& out_tracks, + EMTFInputCollection& out_inputs) { + // =========================================================================== + // Clear output collections + // =========================================================================== + + out_hits.clear(); + out_tracks.clear(); + out_inputs.clear(); + + // =========================================================================== + // Load the event configuration + // =========================================================================== + + context_.update(i_event, i_event_setup); + + // =========================================================================== + // Collect trigger primitives + // =========================================================================== + + // Build BX Sequence + std::vector bx_sequence; + + { + auto min_bx = CONFIG.min_bx_; + auto delay_bx = CONFIG.bx_window_ - 1; + auto max_bx = CONFIG.max_bx_ + delay_bx; + + for (int bx = min_bx; bx <= max_bx; ++bx) { + bx_sequence.push_back(bx); } + } - // Collect TP per BX - BXTPCMap bx_tpc_map; - - for (auto& tp_collector : tp_collectors_) { - tp_collector->collect(i_event, bx_tpc_map); - } + // Collect TP per BX + BXTPCMap bx_tpc_map; - // Debug Info - if (CONFIG.verbosity_ > 4) { - int n_tp = 0; + for (auto& tp_collector : tp_collectors_) { + tp_collector->collect(i_event, bx_tpc_map); + } - // Loop BX - for (const auto& bx : bx_sequence) { - // Get trigger primitives for this BX - auto bx_tpc_map_it = bx_tpc_map.find(bx); - auto bx_tpc_map_end = bx_tpc_map.end(); + // Debug Info + if (CONFIG.verbosity_ > 4) { + int n_tp = 0; - // Short-Circuit: Empty trigger primitive collection - if (bx_tpc_map_it == bx_tpc_map_end) { - continue; - } + // Loop BX + for (const auto& bx : bx_sequence) { + // Get trigger primitives for this BX + auto bx_tpc_map_it = bx_tpc_map.find(bx); + auto bx_tpc_map_end = bx_tpc_map.end(); - // Reference TPC - auto& bx_tpc = bx_tpc_map_it->second; + // Short-Circuit: Empty trigger primitive collection + if (bx_tpc_map_it == bx_tpc_map_end) { + continue; + } - // Short-Circuit: Empty trigger primitive collection - if (bx_tpc.size() == 0) { - continue; - } + // Reference TPC + auto& bx_tpc = bx_tpc_map_it->second; - // Print trigger primitives - std::cout << "===========================================================================" << std::endl; - std::cout << "Begin TPC BX " << bx << " Dump" << std::endl; - std::cout << "---------------------------------------------------------------------------" << std::endl; + // Short-Circuit: Empty trigger primitive collection + if (bx_tpc.size() == 0) { + continue; + } - n_tp += bx_tpc.size(); + // Print trigger primitives + std::cout << "===========================================================================" << std::endl; + std::cout << "Begin TPC BX " << bx << " Dump" << std::endl; + std::cout << "---------------------------------------------------------------------------" << std::endl; - for (const auto& tp_entry : bx_tpc) { - tp_entry.tp_.print(std::cout); + n_tp += bx_tpc.size(); - std::cout << "---------------------------------------------------------------------------" << std::endl; - } + for (const auto& tp_entry : bx_tpc) { + tp_entry.tp_.print(std::cout); - std::cout << "End TPC BX " << bx << " Dump" << std::endl; - std::cout << "===========================================================================" << std::endl; - } + std::cout << "---------------------------------------------------------------------------" << std::endl; + } - // Print TPrimitives Summary - if (n_tp > 0) { - std::cout << "Num of TriggerPrimitive: " << n_tp << std::endl; - std::cout << "===========================================================================" << std::endl; - } + std::cout << "End TPC BX " << bx << " Dump" << std::endl; + std::cout << "===========================================================================" << std::endl; } - // =========================================================================== - // Run sector processors - // =========================================================================== - - // Before event - for (auto& sector_processor : sector_processors_) { - sector_processor->configure_event(i_event); + // Print TPrimitives Summary + if (n_tp > 0) { + std::cout << "Num of TriggerPrimitive: " << n_tp << std::endl; + std::cout << "===========================================================================" << std::endl; } + } - // Orderly loop BX - for (const auto& bx : bx_sequence) { - // Get trigger primitives for this BX - auto bx_tpc_map_it = bx_tpc_map.find(bx); - auto bx_tpc_map_end = bx_tpc_map.end(); + // =========================================================================== + // Run sector processors + // =========================================================================== - TPCollection* bx_tpc_ptr = nullptr; + // Before event + for (auto& sector_processor : sector_processors_) { + sector_processor->configure_event(i_event); + } - if (bx_tpc_map_it != bx_tpc_map_end) { - bx_tpc_ptr = &(bx_tpc_map_it->second); - } + // Orderly loop BX + for (const auto& bx : bx_sequence) { + // Get trigger primitives for this BX + auto bx_tpc_map_it = bx_tpc_map.find(bx); + auto bx_tpc_map_end = bx_tpc_map.end(); + + TPCollection* bx_tpc_ptr = nullptr; - // Loop over all sector processors - for (auto& sector_processor : sector_processors_) { - // Before BX - sector_processor->configure_bx(bx); + if (bx_tpc_map_it != bx_tpc_map_end) { + bx_tpc_ptr = &(bx_tpc_map_it->second); + } - // Select trigger primitives in BX - if (bx_tpc_ptr != nullptr) { - for (const auto& tp_entry : *bx_tpc_ptr) { - const auto& tp = tp_entry.tp_; - const auto& tp_info = tp_entry.info_; + // Loop over all sector processors + for (auto& sector_processor : sector_processors_) { + // Before BX + sector_processor->configure_bx(bx); - sector_processor->select(tp, tp_info); - } - } + // Select trigger primitives in BX + if (bx_tpc_ptr != nullptr) { + for (const auto& tp_entry : *bx_tpc_ptr) { + const auto& tp = tp_entry.tp_; + const auto& tp_info = tp_entry.info_; - // Process trigger primitives - sector_processor->process(out_hits, out_tracks, out_inputs); + sector_processor->select(tp, tp_info); } + } - // Free memory: Removes BX TPCollections after all Sector Processors have selected their TPrimitives - if (bx_tpc_ptr != nullptr) { - bx_tpc_map.erase(bx_tpc_map_it); - } + // Process trigger primitives + sector_processor->process(out_hits, out_tracks, out_inputs); } - // Free memory: Drops any BX TPCollections outside of the [min bx, max bx] range - bx_tpc_map.clear(); + // Free memory: Removes BX TPCollections after all Sector Processors have selected their TPrimitives + if (bx_tpc_ptr != nullptr) { + bx_tpc_map.erase(bx_tpc_map_it); + } + } + + // Free memory: Drops any BX TPCollections outside of the [min bx, max bx] range + bx_tpc_map.clear(); } void TrackFinder::on_job_begin() { - // Do Nothing + // Do Nothing } void TrackFinder::on_job_end() { - // Do Nothing + // Do Nothing } - diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc index 5251ac3142e26..351fd503b58dd 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc @@ -4,179 +4,165 @@ namespace emtf::phase2::csc { - // Chambers - int next_10deg_chamber(int chamber) { - return (chamber == 36) ? 1 : (chamber + 1); + // Chambers + int next_10deg_chamber(int chamber) { return (chamber == 36) ? 1 : (chamber + 1); } + + int prev_10deg_chamber(int chamber) { return (chamber == 1) ? 36 : (chamber - 1); } + + int next_20deg_chamber(int chamber) { return (chamber == 18) ? 1 : (chamber + 1); } + + int prev_20deg_chamber(int chamber) { return (chamber == 1) ? 18 : (chamber - 1); } + + // Sectors + bool is_in_sector(int sp_endcap, int sp_sector, int tp_endcap, int tp_sector) { + return sp_endcap == tp_endcap && sp_sector == tp_sector; + } + + bool is_in_neighbor_sector( + int sp_endcap, int sp_sector, int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_id) { + // Match endcap and neighbor sector + int neighbor_sector = ((sp_sector == 1) ? 6 : sp_sector - 1); + + if ((sp_endcap != tp_endcap) || (neighbor_sector != tp_sector)) + return false; + + // Match CSCID in station 1 + if (tp_station == 1) + return (tp_subsector == 2) && (tp_id == 3 || tp_id == 6 || tp_id == 9); + + // Match CSCID in other stations + return tp_id == 3 || tp_id == 9; + } + + // Use CSC trigger "CSC ID" definitions + // Copied from DataFormats/MuonDetId/src/CSCDetId.cc + int get_id(int station, int ring, 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: + 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 + } } - int prev_10deg_chamber(int chamber) { - return (chamber == 1) ? 36 : (chamber - 1); - } - - int next_20deg_chamber(int chamber) { - return (chamber == 18) ? 1 : (chamber + 1); - } + return result; + } - int prev_20deg_chamber(int chamber) { - return (chamber == 1) ? 18 : (chamber - 1); - } + // Use CSC trigger sector definitions + // Copied from DataFormats/MuonDetId/src/CSCDetId.cc + int get_trigger_sector(int station, int ring, int chamber) { + int result = 0; - // Sectors - bool is_in_sector( - int sp_endcap, int sp_sector, - int tp_endcap, int tp_sector - ) { - return sp_endcap == tp_endcap && sp_sector == tp_sector; + 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) { + 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, ... } - bool is_in_neighbor_sector( - int sp_endcap, int sp_sector, - int tp_endcap, int tp_sector, int tp_subsector, - int tp_station, int tp_id - ) { - // Match endcap and neighbor sector - int neighbor_sector = ((sp_sector == 1) ? 6 : sp_sector - 1); - - if ((sp_endcap != tp_endcap) || (neighbor_sector != tp_sector)) - return false; - - // Match CSCID in station 1 - if (tp_station == 1) - return (tp_subsector == 2) && (tp_id == 3 || tp_id == 6 || tp_id == 9); + return (result <= 6) ? result + : 6; // max sector is 6, some calculations give a value greater than six but this is expected. + } - - // Match CSCID in other stations - return tp_id == 3 || tp_id == 9; + int get_trigger_subsector(int station, int chamber) { + // station 2,3,4 --> subsector 0 + if (station != 1) { + return 0; } - // Use CSC trigger "CSC ID" definitions - // Copied from DataFormats/MuonDetId/src/CSCDetId.cc - int get_id(int station, int ring, 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: - 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; + // station 1 --> subsector 1 or 2 + if ((chamber % 6) > 2) { + return 1; } - // Use CSC trigger sector definitions - // Copied from DataFormats/MuonDetId/src/CSCDetId.cc - int get_trigger_sector(int station, int ring, 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) { - 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. + return 2; + } + + // Copied from RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.cc + Facing get_face_direction(int station, int ring, int chamber) { + bool is_not_overlapping = (station == 1 && ring == 3); + + // Not overlapping means it's facing backwards + if (is_not_overlapping) + return Facing::kRear; + + // odd chambers are bolted to the iron, which faces + // forward in stations 1 and 2, backward in stations 3 and 4 + bool is_even = (chamber % 2 == 0); + + if (station < 3) + return (is_even ? Facing::kRear : Facing::kFront); + + return (is_even ? Facing::kFront : Facing::kRear); + } + + // 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 | + // +----------------------------+------------+------------+ + + std::pair get_max_strip_and_wire(int station, int ring) { + int max_strip = 0; // halfstrip + int 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; } - int get_trigger_subsector(int station, int chamber) { - // station 2,3,4 --> subsector 0 - if (station != 1) { - return 0; - } + return std::make_pair(max_strip, max_wire); + } - // station 1 --> subsector 1 or 2 - if ((chamber % 6) > 2) { - return 1; - } - - return 2; - } + std::pair get_max_pattern_and_quality(int station, int ring) { + int max_pattern = 11; + int max_quality = 16; - // Copied from RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.cc - Facing get_face_direction(int station, int ring, int chamber) { - bool is_not_overlapping = (station == 1 && ring == 3); - - // Not overlapping means it's facing backwards - if (is_not_overlapping) - return Facing::kRear; - - // odd chambers are bolted to the iron, which faces - // forward in stations 1 and 2, backward in stations 3 and 4 - bool is_even = (chamber % 2 == 0); - - if (station < 3) - return (is_even ? Facing::kRear : Facing::kFront); - - return (is_even ? Facing::kFront : Facing::kRear); - } - - // 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 | - // +----------------------------+------------+------------+ - - std::pair get_max_strip_and_wire(int station, int ring) { - int max_strip = 0; // halfstrip - int 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 std::make_pair(max_strip, max_wire); - } - - std::pair get_max_pattern_and_quality(int station, int ring) { - int max_pattern = 11; - int max_quality = 16; - - return std::make_pair(max_pattern, max_quality); - } + return std::make_pair(max_pattern, max_quality); + } -} +} // namespace emtf::phase2::csc diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc index 26852aa80e286..5830d5945df80 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc @@ -4,121 +4,121 @@ namespace emtf::phase2::tp { - // _______________________________________________________________________ - // radians <-> degrees - float deg_to_rad(float deg) { - constexpr float factor = M_PI / 180.; - return deg * factor; - } + // _______________________________________________________________________ + // radians <-> degrees + float deg_to_rad(float deg) { + constexpr float factor = M_PI / 180.; + return deg * factor; + } - float rad_to_deg(float rad) { - constexpr float factor = 180. / M_PI; + float rad_to_deg(float rad) { + constexpr float factor = 180. / M_PI; - return rad * factor; - } + return rad * factor; + } - // _______________________________________________________________________ - // phi range: [-180..180] or [-pi..pi] - float wrap_phi_deg(float deg) { - float twopi = 360.; - float recip = 1.0 / twopi; + // _______________________________________________________________________ + // phi range: [-180..180] or [-pi..pi] + float wrap_phi_deg(float deg) { + float twopi = 360.; + float recip = 1.0 / twopi; - return deg - (std::round(deg * recip) * twopi); - } + return deg - (std::round(deg * recip) * twopi); + } - float wrap_phi_rad(float rad) { - const float twopi = M_PI * 2.; - const float recip = 1.0 / twopi; + float wrap_phi_rad(float rad) { + const float twopi = M_PI * 2.; + const float recip = 1.0 / twopi; - return rad - (std::round(rad * recip) * twopi); - } + return rad - (std::round(rad * recip) * twopi); + } - // _______________________________________________________________________ - // theta - float calc_theta_rad_from_eta(float eta) { - float theta = std::atan2(1.0, std::sinh(eta)); // cot(theta) = sinh(eta) + // _______________________________________________________________________ + // theta + float calc_theta_rad_from_eta(float eta) { + float theta = std::atan2(1.0, std::sinh(eta)); // cot(theta) = sinh(eta) - return theta; - } + return theta; + } - float calc_theta_deg_from_eta(float eta) { - float theta = rad_to_deg(calc_theta_rad_from_eta(eta)); + float calc_theta_deg_from_eta(float eta) { + float theta = rad_to_deg(calc_theta_rad_from_eta(eta)); - return theta; - } + return theta; + } - float calc_theta_deg_from_int(int theta_int) { - float theta = static_cast(theta_int); + float calc_theta_deg_from_int(int theta_int) { + float theta = static_cast(theta_int); - theta = theta * (45.0 - 8.5) / 128. + 8.5; + theta = theta * (45.0 - 8.5) / 128. + 8.5; - return theta; - } + return theta; + } - float calc_theta_rad_from_int(int theta_int) { - float theta = deg_to_rad(calc_theta_deg_from_int(theta_int)); + float calc_theta_rad_from_int(int theta_int) { + float theta = deg_to_rad(calc_theta_deg_from_int(theta_int)); - return theta; - } + return theta; + } - int calc_theta_int(int endcap, float theta) { // theta in deg [0..180], endcap [-1, +1] - theta = (endcap == -1) ? (180. - theta) : theta; - theta = (theta - 8.5) * 128. / (45.0 - 8.5); + int calc_theta_int(int endcap, float theta) { // theta in deg [0..180], endcap [-1, +1] + theta = (endcap == -1) ? (180. - theta) : theta; + theta = (theta - 8.5) * 128. / (45.0 - 8.5); - int theta_int = static_cast(std::round(theta)); + int theta_int = static_cast(std::round(theta)); - theta_int = (theta_int <= 0) ? 1 : theta_int; // protect against invalid value + theta_int = (theta_int <= 0) ? 1 : theta_int; // protect against invalid value - return theta_int; - } + return theta_int; + } - // _______________________________________________________________________ - // phi - float calc_phi_glob_deg_from_loc(int sector, float loc) { // loc in deg, sector [1..6] - float glob = loc + 15. + (60. * (sector - 1)); + // _______________________________________________________________________ + // phi + float calc_phi_glob_deg_from_loc(int sector, float loc) { // loc in deg, sector [1..6] + float glob = loc + 15. + (60. * (sector - 1)); - glob = (glob >= 180.) ? (glob - 360.) : glob; + glob = (glob >= 180.) ? (glob - 360.) : glob; - return glob; - } + return glob; + } - float calc_phi_glob_rad_from_loc(int sector, float loc) { // loc in rad, sector [1..6] - float glob = deg_to_rad(calc_phi_glob_deg_from_loc(sector, rad_to_deg(loc))); + float calc_phi_glob_rad_from_loc(int sector, float loc) { // loc in rad, sector [1..6] + float glob = deg_to_rad(calc_phi_glob_deg_from_loc(sector, rad_to_deg(loc))); - return glob; - } + return glob; + } - float calc_phi_loc_deg_from_int(int phi_int) { - float loc = static_cast(phi_int); + float calc_phi_loc_deg_from_int(int phi_int) { + float loc = static_cast(phi_int); - loc = (loc / 60.) - 22.; + loc = (loc / 60.) - 22.; - return loc; - } + return loc; + } - float calc_phi_loc_rad_from_int(int phi_int) { - float loc = deg_to_rad(calc_phi_loc_deg_from_int(phi_int)); + float calc_phi_loc_rad_from_int(int phi_int) { + float loc = deg_to_rad(calc_phi_loc_deg_from_int(phi_int)); - return loc; - } + return loc; + } - float calc_phi_loc_deg_from_glob(int sector, float glob) { // glob in deg [-180..180], sector [1..6] - glob = wrap_phi_deg(glob); + float calc_phi_loc_deg_from_glob(int sector, float glob) { // glob in deg [-180..180], sector [1..6] + glob = wrap_phi_deg(glob); - float loc = glob - 15. - (60. * (sector - 1)); + float loc = glob - 15. - (60. * (sector - 1)); - return loc; - } + return loc; + } - int calc_phi_int(int sector, float glob) { // glob in deg [-180..180], sector [1..6] - float loc = calc_phi_loc_deg_from_glob(sector, glob); + int calc_phi_int(int sector, float glob) { // glob in deg [-180..180], sector [1..6] + float loc = calc_phi_loc_deg_from_glob(sector, glob); - loc = ((loc + 22.) < 0.) ? (loc + 360.) : loc; - loc = (loc + 22.) * 60.; + loc = ((loc + 22.) < 0.) ? (loc + 360.) : loc; + loc = (loc + 22.) * 60.; - int phi_int = static_cast(std::round(loc)); + int phi_int = static_cast(std::round(loc)); - return phi_int; - } + return phi_int; + } -} +} // namespace emtf::phase2::tp From 90f1f0f078669557b9cebd38609535e504e18484 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Tue, 16 Jan 2024 07:51:36 +0100 Subject: [PATCH 08/24] Implemented various changes suggested. Mainly focused on EMTF side, ME0 comments pending. --- DataFormats/L1TMuonPhase2/BuildFile.xml | 2 +- DataFormats/L1TMuonPhase2/interface/EMTFHit.h | 66 +----- .../L1TMuonPhase2/interface/EMTFInput.h | 9 +- .../L1TMuonPhase2/interface/EMTFTrack.h | 32 +-- DataFormats/L1TMuonPhase2/src/EMTFHit.cc | 61 ++++++ DataFormats/L1TMuonPhase2/src/EMTFTrack.cc | 27 +++ DataFormats/L1TMuonPhase2/src/classes_def.xml | 62 +++--- .../plugins/GE0TriggerPseudoProducer.cc | 15 +- .../L1TGEM/python/me0TriggerDigis_cff.py | 3 +- .../L1TGEM/src/GE0TriggerPseudoBuilder.cc | 2 +- L1Trigger/L1TMuon/python/simDigis_cff.py | 4 - L1Trigger/L1TMuon/src/GeometryTranslator.cc | 14 +- L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc | 2 +- .../interface/Algo/DuplicateRemovalLayer.h | 2 +- .../interface/Algo/HitmapLayer.h | 2 +- .../interface/Algo/OutputLayer.h | 2 +- .../interface/Algo/ParameterAssignmentLayer.h | 2 +- .../interface/Algo/PatternMatchingLayer.h | 2 +- .../interface/Algo/RoadSortingLayer.h | 2 +- .../interface/Algo/TrackBuildingLayer.h | 2 +- .../interface/DAQ/CSCTPCollector.h | 2 +- .../interface/DAQ/CSCTPConverter.h | 2 +- .../interface/DAQ/CSCTPSelector.h | 6 +- .../interface/DAQ/GE0TPCollector.h | 2 +- .../interface/DAQ/GE0TPConverter.h | 2 +- .../interface/DAQ/GE0TPSelector.h | 5 +- .../interface/DAQ/GEMTPCollector.h | 2 +- .../interface/DAQ/GEMTPConverter.h | 2 +- .../interface/DAQ/GEMTPSelector.h | 5 +- .../interface/DAQ/ME0TPCollector.h | 2 +- .../interface/DAQ/ME0TPConverter.h | 2 +- .../interface/DAQ/ME0TPSelector.h | 5 +- .../interface/DAQ/RPCTPCollector.h | 2 +- .../interface/DAQ/RPCTPConverter.h | 2 +- .../interface/DAQ/RPCTPSelector.h | 6 +- .../interface/EMTFContext.h | 7 - .../interface/Utils/DebugUtils.h | 2 +- .../L1TMuonEndCapPhase2TrackProducer.cc | 13 +- .../L1TMuonEndCapPhase2TrackProducer.h | 6 +- .../src/Algo/DuplicateRemovalLayer.cc | 21 +- .../src/Algo/HitmapLayer.cc | 76 ++++--- .../src/Algo/OutputLayer.cc | 87 ++++---- .../src/Algo/ParameterAssignmentLayer.cc | 51 ++--- .../src/Algo/PatternMatchingLayer.cc | 18 +- .../src/Algo/RoadSortingLayer.cc | 41 ++-- .../src/Algo/TrackBuildingLayer.cc | 112 +++++----- .../src/DAQ/CSCTPCollector.cc | 40 ++-- .../src/DAQ/CSCTPConverter.cc | 12 +- .../src/DAQ/CSCTPSelector.cc | 30 ++- .../src/DAQ/GE0TPCollector.cc | 10 +- .../src/DAQ/GE0TPConverter.cc | 10 +- .../src/DAQ/GE0TPSelector.cc | 10 +- .../src/DAQ/GEMTPCollector.cc | 12 +- .../src/DAQ/GEMTPConverter.cc | 10 +- .../src/DAQ/GEMTPSelector.cc | 10 +- .../src/DAQ/ME0TPCollector.cc | 10 +- .../src/DAQ/ME0TPConverter.cc | 10 +- .../src/DAQ/ME0TPSelector.cc | 10 +- .../src/DAQ/RPCTPCollector.cc | 11 +- .../src/DAQ/RPCTPConverter.cc | 13 +- .../src/DAQ/RPCTPSelector.cc | 10 +- .../src/Data/ActivationLut.cc | 196 +++++++++--------- .../src/Data/TimeZoneLut.cc | 6 +- .../src/SectorProcessor.cc | 48 +++-- .../L1TMuonEndCapPhase2/src/TrackFinder.cc | 40 ++-- 65 files changed, 574 insertions(+), 718 deletions(-) diff --git a/DataFormats/L1TMuonPhase2/BuildFile.xml b/DataFormats/L1TMuonPhase2/BuildFile.xml index 2211e3adc5bd8..ad2fbc6d9100e 100644 --- a/DataFormats/L1TMuonPhase2/BuildFile.xml +++ b/DataFormats/L1TMuonPhase2/BuildFile.xml @@ -1,5 +1,5 @@ - + diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFHit.h b/DataFormats/L1TMuonPhase2/interface/EMTFHit.h index 4ada9e1fc8e74..3d7703ed9be5d 100644 --- a/DataFormats/L1TMuonPhase2/interface/EMTFHit.h +++ b/DataFormats/L1TMuonPhase2/interface/EMTFHit.h @@ -10,70 +10,8 @@ namespace l1t::phase2 { class EMTFHit { public: - EMTFHit() - : id_(0), - - raw_det_id_(0), - subsystem_(0), - endcap_(0), - sector_(0), - subsector_(0), - station_(0), - ring_(0), - roll_(0), - layer_(0), - chamber_(0), - - csc_id_(0), - csc_fr_(0), - - strip_(0), - strip_lo_(0), - strip_hi_(0), - strip_quart_(0), // Run 3 - strip_eighth_(0), // Run 3 - strip_quart_bit_(0), // Run 3 - strip_eighth_bit_(0), // Run 3 - - wire1_(0), - wire2_(0), - - bx_(0), - subbx_(0), - - quality_(0), - pattern_(0), - - glob_phi_(0), - glob_theta_(0), - glob_perp_(0), - glob_z_(0), - glob_time_(0), - - emtf_chamber_(0), - emtf_segment_(0), - emtf_phi_(0), - emtf_bend_(0), - emtf_slope_(0), - emtf_theta1_(0), - emtf_theta2_(0), - emtf_qual1_(0), - emtf_qual2_(0), - emtf_time_(0), - emtf_site_(0), - emtf_host_(0), - emtf_zones_(0), - emtf_timezones_(0), - - flag_neighbor_(false), - flag_substitute_(false), - flag_valid_(false) { - // Do Nothing - } - - ~EMTFHit() { - // Do Nothing - } + EMTFHit(); + ~EMTFHit() = default; // Setters void setId(uint16_t aId) { id_ = aId; } diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFInput.h b/DataFormats/L1TMuonPhase2/interface/EMTFInput.h index 71b4aefb7aee4..f6f972c78949e 100644 --- a/DataFormats/L1TMuonPhase2/interface/EMTFInput.h +++ b/DataFormats/L1TMuonPhase2/interface/EMTFInput.h @@ -13,13 +13,8 @@ namespace l1t::phase2 { typedef std::vector hits_t; typedef std::vector segs_t; - EMTFInput() : endcap_(0), sector_(0), bx_(0), hits_{}, segs_{} { - // Do Nothing - } - - ~EMTFInput() { - // Do Nothing - } + EMTFInput() : endcap_(0), sector_(0), bx_(0), hits_{}, segs_{} {} + ~EMTFInput() = default; // Setters void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } diff --git a/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h b/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h index aff142f21c58f..76ee00fc82324 100644 --- a/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h +++ b/DataFormats/L1TMuonPhase2/interface/EMTFTrack.h @@ -14,36 +14,8 @@ namespace l1t::phase2 { typedef std::vector site_segs_t; typedef std::vector site_mask_t; - EMTFTrack() - : endcap_(0), - sector_(0), - bx_(0), - unconstrained_(false), - valid_(false), - model_pt_address_(0), - model_dxy_address_(0), - model_pattern_(0), - model_qual_(0), - model_phi_(0), - model_eta_(0), - model_features_{}, - emtf_q_(0), - emtf_pt_(0), - emtf_d0_(0), - emtf_z0_(0), - emtf_beta_(0), - emtf_mode_v1_(0), - emtf_mode_v2_(0), - site_hits_{}, - site_segs_{}, - site_mask_{}, - site_rm_mask_{} { - // Do Nothing - } - - ~EMTFTrack() { - // Do Nothing - } + EMTFTrack(); + ~EMTFTrack() = default; // Setters void setEndcap(int16_t aEndcap) { endcap_ = aEndcap; } diff --git a/DataFormats/L1TMuonPhase2/src/EMTFHit.cc b/DataFormats/L1TMuonPhase2/src/EMTFHit.cc index 6ffe9c26d7a19..966de1640a64d 100644 --- a/DataFormats/L1TMuonPhase2/src/EMTFHit.cc +++ b/DataFormats/L1TMuonPhase2/src/EMTFHit.cc @@ -1,3 +1,64 @@ #include "DataFormats/L1TMuonPhase2/interface/EMTFHit.h" using namespace l1t::phase2; + +EMTFHit::EMTFHit() + : id_(0), + + raw_det_id_(0), + subsystem_(0), + endcap_(0), + sector_(0), + subsector_(0), + station_(0), + ring_(0), + roll_(0), + layer_(0), + chamber_(0), + + csc_id_(0), + csc_fr_(0), + + strip_(0), + strip_lo_(0), + strip_hi_(0), + strip_quart_(0), // Run 3 + strip_eighth_(0), // Run 3 + strip_quart_bit_(0), // Run 3 + strip_eighth_bit_(0), // Run 3 + + wire1_(0), + wire2_(0), + + bx_(0), + subbx_(0), + + quality_(0), + pattern_(0), + + glob_phi_(0), + glob_theta_(0), + glob_perp_(0), + glob_z_(0), + glob_time_(0), + + emtf_chamber_(0), + emtf_segment_(0), + emtf_phi_(0), + emtf_bend_(0), + emtf_slope_(0), + emtf_theta1_(0), + emtf_theta2_(0), + emtf_qual1_(0), + emtf_qual2_(0), + emtf_time_(0), + emtf_site_(0), + emtf_host_(0), + emtf_zones_(0), + emtf_timezones_(0), + + flag_neighbor_(false), + flag_substitute_(false), + flag_valid_(false) { + // Do Nothing +} diff --git a/DataFormats/L1TMuonPhase2/src/EMTFTrack.cc b/DataFormats/L1TMuonPhase2/src/EMTFTrack.cc index 32447e69aac09..6cb65ec0207b0 100644 --- a/DataFormats/L1TMuonPhase2/src/EMTFTrack.cc +++ b/DataFormats/L1TMuonPhase2/src/EMTFTrack.cc @@ -1,3 +1,30 @@ #include "DataFormats/L1TMuonPhase2/interface/EMTFTrack.h" using namespace l1t::phase2; + +EMTFTrack::EMTFTrack() + : endcap_(0), + sector_(0), + bx_(0), + unconstrained_(false), + valid_(false), + model_pt_address_(0), + model_dxy_address_(0), + model_pattern_(0), + model_qual_(0), + model_phi_(0), + model_eta_(0), + model_features_{}, + emtf_q_(0), + emtf_pt_(0), + emtf_d0_(0), + emtf_z0_(0), + emtf_beta_(0), + emtf_mode_v1_(0), + emtf_mode_v2_(0), + site_hits_{}, + site_segs_{}, + site_mask_{}, + site_rm_mask_{} { + // Do Nothing +} diff --git a/DataFormats/L1TMuonPhase2/src/classes_def.xml b/DataFormats/L1TMuonPhase2/src/classes_def.xml index 8a3aee143889e..9651e92a9984b 100644 --- a/DataFormats/L1TMuonPhase2/src/classes_def.xml +++ b/DataFormats/L1TMuonPhase2/src/classes_def.xml @@ -1,36 +1,36 @@ - - - - - - - + + + + + + + - - - - - - - - + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + diff --git a/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc b/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc index 1d05cdabdeb91..30f0e76b408a5 100644 --- a/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc +++ b/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc @@ -29,7 +29,7 @@ class GE0TriggerPseudoBuilder; class GE0TriggerPseudoProducer : public edm::global::EDProducer<> { public: explicit GE0TriggerPseudoProducer(const edm::ParameterSet&); - ~GE0TriggerPseudoProducer() override; + ~GE0TriggerPseudoProducer() override = default; void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; @@ -40,18 +40,15 @@ class GE0TriggerPseudoProducer : public edm::global::EDProducer<> { edm::ParameterSet config_; }; -GE0TriggerPseudoProducer::GE0TriggerPseudoProducer(const edm::ParameterSet& conf) { - me0segmentProducer_ = conf.getParameter("ME0SegmentProducer"); - me0segment_token_ = consumes(me0segmentProducer_); - me0_geom_token_ = esConsumes(); - config_ = conf; - +GE0TriggerPseudoProducer::GE0TriggerPseudoProducer(const edm::ParameterSet& conf) + : me0segmentProducer_(conf.getParameter("ME0SegmentProducer")), + me0segment_token_(consumes(me0segmentProducer_)), + me0_geom_token_(esConsumes()), + config_(conf) { // register what this produces produces(); } -GE0TriggerPseudoProducer::~GE0TriggerPseudoProducer() {} - void GE0TriggerPseudoProducer::produce(edm::StreamID, edm::Event& ev, const edm::EventSetup& setup) const { edm::ESHandle h_me0 = setup.getHandle(me0_geom_token_); diff --git a/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py b/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py index d174ed2248402..3ed2d6397387c 100644 --- a/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py +++ b/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py @@ -9,6 +9,5 @@ me0TriggerAllDigiTask = cms.Task(me0TriggerRealDigiTask, me0TriggerPseudoDigiTask) ge0TriggerAllDigiTask = cms.Task(me0TriggerRealDigiTask, ge0TriggerPseudoDigiTask) -## in scenarios with GE0, remove the pseudo digis -# phase2_GE0.toReplaceWith(me0TriggerAllDigiTask, me0TriggerAllDigiTask.copyAndExclude([me0TriggerPseudoDigiTask])) +# in scenarios with GE0, remove the pseudo digis phase2_GE0.toReplaceWith(me0TriggerAllDigiTask, ge0TriggerAllDigiTask) diff --git a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc index 4bd700fb7f177..eb1fb8aaf080e 100644 --- a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc +++ b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc @@ -102,7 +102,7 @@ ME0TriggerDigi GE0TriggerPseudoBuilder::segmentConversion(const GEMSegment segme if (phiposition > totstrip) LogTrace("L1ME0Trigger") << " ME0 segment strip number is " << phiposition << " larger than nstrip " << totstrip << " !!! \n"; - float phi_resolution = 0.5; //halfstrip + constexpr float phi_resolution = 0.5; //halfstrip int phiposition2 = (static_cast((strip - phiposition) / phi_resolution) & 1); // half-strip resolution phiposition = (phiposition << 1) | phiposition2; diff --git a/L1Trigger/L1TMuon/python/simDigis_cff.py b/L1Trigger/L1TMuon/python/simDigis_cff.py index 383382d542565..8d06f96353b58 100644 --- a/L1Trigger/L1TMuon/python/simDigis_cff.py +++ b/L1Trigger/L1TMuon/python/simDigis_cff.py @@ -123,10 +123,6 @@ _phase2_SimL1TMuonTask = SimL1TMuonTask.copy() _phase2_SimL1TMuonTask.add(me0TriggerAllDigiTask) _phase2_SimL1TMuonTask.add(simCscTriggerPrimitiveDigisPhase2) -# _phase2_GE0_SimL1TMuonTask = SimL1TMuonTask.copyAndExclude([me0TriggerAllDigiTask]) from Configuration.Eras.Modifier_phase2_muon_cff import phase2_muon (stage2L1Trigger & phase2_muon).toReplaceWith( SimL1TMuonTask, _phase2_SimL1TMuonTask ) - -# from Configuration.Eras.Modifier_phase2_GE0_cff import phase2_GE0 -# (stage2L1Trigger & phase2_GE0).toReplaceWith( SimL1TMuonTask, _phase2_GE0_SimL1TMuonTask ) diff --git a/L1Trigger/L1TMuon/src/GeometryTranslator.cc b/L1Trigger/L1TMuon/src/GeometryTranslator.cc index 657a002b28222..ed4408d194749 100644 --- a/L1Trigger/L1TMuon/src/GeometryTranslator.cc +++ b/L1Trigger/L1TMuon/src/GeometryTranslator.cc @@ -158,7 +158,12 @@ GlobalPoint GeometryTranslator::getME0SpecificPoint(const TriggerPrimitive& tp) int partition = tp.getME0Data().partition; // 'partition' is in half-roll unit int iroll = (partition >> 1) + 1; const GEMEtaPartition* roll = keylayer->etaPartition(iroll); - assert(roll != nullptr); // failed to get GEM roll + + // failed to get ME0 roll + if (roll == nullptr) { + throw cms::Exception("Invalid GE0 Roll") << "Failed to get GEM roll for GE0" << std::endl; + } + // See L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.cc int phiposition = tp.getME0Data().phiposition; // 'phiposition' is in half-strip unit int istrip = (phiposition >> 1); @@ -174,7 +179,12 @@ GlobalPoint GeometryTranslator::getME0SpecificPoint(const TriggerPrimitive& tp) 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 + + // failed to get ME0 roll + if (roll == nullptr) { + throw cms::Exception("Invalid ME0 Roll") << "Failed to get ME0 roll" << std::endl; + } + // See L1Trigger/ME0Trigger/src/ME0TriggerPseudoBuilder.cc int phiposition = tp.getME0Data().phiposition; // 'phiposition' is in half-strip unit int istrip = (phiposition >> 1); diff --git a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc index 16300313a4149..35ea3217b1423 100644 --- a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc +++ b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc @@ -251,7 +251,7 @@ TriggerPrimitive::TriggerPrimitive(const ME0DetId& detid, const ME0TriggerDigi& _me0.bx = digi.getBX(); } -// Constructor from ME0 data +// Constructor from GE0 data TriggerPrimitive::TriggerPrimitive(const GEMDetId& detid, const ME0TriggerDigi& digi) : _id(detid), _subsystem(L1TMuon::kME0) { calculateGlobalSector(detid, _globalsector, _subsector); diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h index 8078ae72064e9..fe2da30b5d02d 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h @@ -14,7 +14,7 @@ namespace emtf::phase2::algo { public: DuplicateRemovalLayer(const EMTFContext&); - ~DuplicateRemovalLayer(); + ~DuplicateRemovalLayer() = default; void apply(std::vector&) const; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h index 2663ffccfd2d6..d28c96d2ba556 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/HitmapLayer.h @@ -10,7 +10,7 @@ namespace emtf::phase2::algo { public: HitmapLayer(const EMTFContext&); - ~HitmapLayer(); + ~HitmapLayer() = default; void apply(const segment_collection_t&, std::vector&) const; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h index fcfce93e132c8..3852f44a56bb4 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h @@ -14,7 +14,7 @@ namespace emtf::phase2::algo { public: OutputLayer(const EMTFContext&); - ~OutputLayer(); + ~OutputLayer() = default; void apply(const int&, const int&, diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h index 65116ad0d5f2e..d603484098073 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h @@ -14,7 +14,7 @@ namespace emtf::phase2::algo { public: ParameterAssignmentLayer(const EMTFContext&); - ~ParameterAssignmentLayer(); + ~ParameterAssignmentLayer() = default; void apply(const bool&, std::vector&) const; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h index fb2663f8d1adb..cfcd5f0516419 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/PatternMatchingLayer.h @@ -14,7 +14,7 @@ namespace emtf::phase2::algo { public: PatternMatchingLayer(const EMTFContext&); - ~PatternMatchingLayer(); + ~PatternMatchingLayer() = default; void apply(const std::vector&, const bool&, std::vector&) const; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h index 358f6ef9321d9..47c9c1fedbfd0 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h @@ -14,7 +14,7 @@ namespace emtf::phase2::algo { public: RoadSortingLayer(const EMTFContext&); - ~RoadSortingLayer(); + ~RoadSortingLayer() = default; void apply(const int&, const std::vector&, std::vector&) const; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h index 57ad3e82e8646..46c9b6740edca 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h @@ -19,7 +19,7 @@ namespace emtf::phase2::algo { public: TrackBuildingLayer(const EMTFContext&); - ~TrackBuildingLayer(); + ~TrackBuildingLayer() = default; void apply(const segment_collection_t&, const std::vector&, const bool&, std::vector&) const; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h index 25dfcf09f6906..ace96b51aeb5a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit CSCTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~CSCTPCollector(); + ~CSCTPCollector() = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h index aa97ef31ac013..7ee6f86da9bb2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h @@ -14,7 +14,7 @@ namespace emtf::phase2 { public: explicit CSCTPConverter(const EMTFContext&, const int&, const int&); - ~CSCTPConverter(); + ~CSCTPConverter() = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h index afb27d44cc8bc..471b7cd47af60 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h @@ -6,17 +6,13 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" -// 18 in ME1; 9x3 in ME2,3,4; 9 from neighbor sector. -// Arranged in FW as 6 stations, 9 chambers per station. -#define NUM_CSC_CHAMBERS 6 * 9 - namespace emtf::phase2 { class CSCTPSelector : public TPSelector { public: explicit CSCTPSelector(const EMTFContext&, const int&, const int&); - ~CSCTPSelector(); + ~CSCTPSelector() = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h index 862db92ab4b3c..93caf0a04802b 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit GE0TPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~GE0TPCollector(); + ~GE0TPCollector() = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h index 1e392186e4253..507094bd238f5 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit GE0TPConverter(const EMTFContext&, const int&, const int&); - ~GE0TPConverter(); + ~GE0TPConverter() = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h index cd2026907fb9b..598ac2809fb7c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h @@ -6,16 +6,13 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" -// 6 in GE1/1; 3 in GE2/1; 3 in GE0; 3 from neighbor sector. (unconfirmed!) -#define NUM_GEM_CHAMBERS 15 - namespace emtf::phase2 { class GE0TPSelector : public TPSelector { public: explicit GE0TPSelector(const EMTFContext&, const int&, const int&); - ~GE0TPSelector(); + ~GE0TPSelector() = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h index 802e0401bb932..ebbf4c4308bdd 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit GEMTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~GEMTPCollector(); + ~GEMTPCollector() = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h index 27f3ef0c7b953..e4f47386cdefe 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit GEMTPConverter(const EMTFContext&, const int&, const int&); - ~GEMTPConverter(); + ~GEMTPConverter() = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h index cca5aff145004..3b905db8dbd0f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h @@ -6,16 +6,13 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" -// 6 in GE1/1; 3 in GE2/1; 3 in ME0; 3 from neighbor sector. (unconfirmed!) -#define NUM_GEM_CHAMBERS 15 - namespace emtf::phase2 { class GEMTPSelector : public TPSelector { public: explicit GEMTPSelector(const EMTFContext&, const int&, const int&); - ~GEMTPSelector(); + ~GEMTPSelector() = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h index 75008ada2499c..cc2d73c86a7df 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit ME0TPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~ME0TPCollector(); + ~ME0TPCollector() = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h index e8bdb4fc89e49..df70b0b81e50a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit ME0TPConverter(const EMTFContext&, const int&, const int&); - ~ME0TPConverter(); + ~ME0TPConverter() = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h index 5001bd30f0708..c7529f6e03de2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h @@ -6,16 +6,13 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" -// 6 in GE1/1; 3 in GE2/1; 3 in ME0; 3 from neighbor sector. (unconfirmed!) -#define NUM_GEM_CHAMBERS 15 - namespace emtf::phase2 { class ME0TPSelector : public TPSelector { public: explicit ME0TPSelector(const EMTFContext&, const int&, const int&); - ~ME0TPSelector(); + ~ME0TPSelector() = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h index ccb9dea502279..19aadb98765b9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit RPCTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~RPCTPCollector(); + ~RPCTPCollector() = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h index c23b059752f36..200bc91ea5eeb 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit RPCTPConverter(const EMTFContext&, const int&, const int&); - ~RPCTPConverter(); + ~RPCTPConverter() = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h index 18d4e1d3082b9..646a49ec0659b 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h @@ -7,17 +7,13 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPSelectors.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h" -// 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 - namespace emtf::phase2 { class RPCTPSelector : public TPSelector { public: explicit RPCTPSelector(const EMTFContext&, const int&, const int&); - ~RPCTPSelector(); + ~RPCTPSelector() = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h index 372d6ccdd4c7b..6346e5fa66998 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h @@ -20,13 +20,6 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h" -#define PSET this->context_.pset_ -#define CONFIG this->context_.config_ -#define GEOM this->context_.geometry_translator_ -// #define EMTF_PSET this->context_.pset_ -// #define EMTF_CONFIG this->context_.config_ -// #define EMTF_GEOM this->context_.geometry_translator_ - namespace emtf::phase2 { // Class diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h index 65732819fafa9..f824837c70585 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h @@ -7,7 +7,7 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" // Uncomment the following line to use assert -#define EMTF_ALLOW_ASSERT +// #define EMTF_ALLOW_ASSERT #ifdef EMTF_ALLOW_ASSERT #define emtf_assert(expr) (assert(expr)) diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc index e1bad5e832e73..8e4a95ddfc75c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc @@ -10,15 +10,10 @@ #include "L1TMuonEndCapPhase2TrackProducer.h" L1TMuonEndCapPhase2TrackProducer::L1TMuonEndCapPhase2TrackProducer(const edm::ParameterSet& pset) - : track_finder_(std::make_unique(pset, consumesCollector())) { - hit_token_ = produces(); - trk_token_ = produces(); - in_token_ = produces(); -} - -L1TMuonEndCapPhase2TrackProducer::~L1TMuonEndCapPhase2TrackProducer() { - // Do nothing -} + : track_finder_(std::make_unique(pset, consumesCollector())), + hit_token_(produces()), + trk_token_(produces()), + in_token_(produces()) {} void L1TMuonEndCapPhase2TrackProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h index 65839589762d0..9655be15f8614 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.h @@ -18,7 +18,7 @@ class L1TMuonEndCapPhase2TrackProducer : public edm::stream::EDProducer<> { public: explicit L1TMuonEndCapPhase2TrackProducer(const edm::ParameterSet&); - ~L1TMuonEndCapPhase2TrackProducer() override; + ~L1TMuonEndCapPhase2TrackProducer() override = default; static void fillDescriptions(edm::ConfigurationDescriptions&); @@ -33,10 +33,6 @@ class L1TMuonEndCapPhase2TrackProducer : public edm::stream::EDProducer<> { void produce(edm::Event&, const edm::EventSetup&) override; void beginStream(edm::StreamID) override; void endStream() override; - // void beginRun(edm::Run const&, edm::EventSetup const&) override; - // void endRun(edm::Run const&, edm::EventSetup const&) override; - // void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; - // void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override; }; #endif diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc index 2687b733c9877..551c3f0430ec9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc @@ -1,20 +1,15 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" -#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/DuplicateRemovalLayer.h" using namespace emtf::phase2; using namespace emtf::phase2::algo; -DuplicateRemovalLayer::DuplicateRemovalLayer(const EMTFContext& context) : context_(context) { - // Do Nothing -} - -DuplicateRemovalLayer::~DuplicateRemovalLayer() { - // Do Nothing -} +DuplicateRemovalLayer::DuplicateRemovalLayer(const EMTFContext& context) : context_(context) {} void DuplicateRemovalLayer::apply(std::vector& tracks) const { // =========================================================================== @@ -117,12 +112,12 @@ void DuplicateRemovalLayer::apply(std::vector& tracks) const { trk_i.valid = rtrk_i.valid; // DEBUG - if (CONFIG.verbosity_ > 1) { + if (this->context_.config_.verbosity_ > 1) { if (trk_i.valid) { - std::cout << "Unique Track" - << " zone " << trk_i.zone << " col " << trk_i.col << " pat " << trk_i.pattern << " qual " - << trk_i.quality << " phi " << trk_i.phi << " theta " << trk_i.theta << " valid " << trk_i.valid - << std::endl; + edm::LogInfo("L1T EMTF++") << "Unique Track" + << " zone " << trk_i.zone << " col " << trk_i.col << " pat " << trk_i.pattern + << " qual " << trk_i.quality << " phi " << trk_i.phi << " theta " << trk_i.theta + << " valid " << trk_i.valid << std::endl; } } } // End loop reduced tracks i diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc index b44a27f46b41a..8f4e86020cb3a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc @@ -1,3 +1,5 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" @@ -5,13 +7,7 @@ using namespace emtf::phase2::algo; -HitmapLayer::HitmapLayer(const EMTFContext& context) : context_(context) { - // Do Nothing -} - -HitmapLayer::~HitmapLayer() { - // Do Nothing -} +HitmapLayer::HitmapLayer(const EMTFContext& context) : context_(context) {} void HitmapLayer::apply(const segment_collection_t& segments, std::vector& zone_hitmaps) const { const hitmap_row_t padded_one = 1; @@ -54,10 +50,11 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vector 4) { - std::cout << "Hitmap Segment not in zone: " - << " zone " << zone_id << " row " << row_id << " seg_id " << seg_id << " seg_phi " << seg.phi - << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones << std::endl; + if (this->context_.config_.verbosity_ > 4) { + edm::LogInfo("L1T EMTF++") + << "Hitmap Segment not in zone: " + << " zone " << zone_id << " row " << row_id << " seg_id " << seg_id << " seg_phi " << seg.phi + << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones << std::endl; } continue; @@ -66,10 +63,11 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vector 4) { - std::cout << "Hitmap Segment not in timezone: " - << " zone " << zone_id << " row " << row_id << " seg_id " << seg_id << " seg_phi " << seg.phi - << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones << std::endl; + if (this->context_.config_.verbosity_ > 4) { + edm::LogInfo("L1T EMTF++") + << "Hitmap Segment not in timezone: " + << " zone " << zone_id << " row " << row_id << " seg_id " << seg_id << " seg_phi " << seg.phi + << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones << std::endl; } continue; @@ -80,12 +78,12 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vector 4) { - std::cout << "Hitmap Segment Before Assert" - << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " << seg_id - << " seg_phi " << seg.phi << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones - << " ch_col_begin " << model_hm_chamber.begin << " ch_col_end " << model_hm_chamber.end - << std::endl; + if (this->context_.config_.verbosity_ > 4) { + edm::LogInfo("L1T EMTF++") << "Hitmap Segment Before Assert" + << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " + << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones << " ch_col_begin " << model_hm_chamber.begin + << " ch_col_end " << model_hm_chamber.end << std::endl; } emtf_assert(model_hm_chamber.begin <= col_id && col_id < model_hm_chamber.end); @@ -95,11 +93,11 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vector 4) { - std::cout << "Hitmap Segment out of bounds: " - << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " << seg_id - << " seg_phi " << seg.phi << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones - << std::endl; + if (this->context_.config_.verbosity_ > 4) { + edm::LogInfo("L1T EMTF++") << "Hitmap Segment out of bounds: " + << " zone " << zone_id << " row " << row_id << " col " << col_id + << " seg_id " << seg_id << " seg_phi " << seg.phi << " seg_zones " + << seg.zones << " seg_tzones " << seg.tzones << std::endl; } continue; @@ -113,11 +111,11 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vector 1) { - std::cout << "Hitmap Segment" - << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " << seg_id - << " seg_phi " << seg.phi << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones - << std::endl; + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << "Hitmap Segment" + << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " + << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones << std::endl; } } // End loop segments @@ -132,20 +130,20 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vector 3) { + if (this->context_.config_.verbosity_ > 3) { // Short-Circuit: the image is blank if (hitmap_is_blank) { continue; } // Pretty print - std::cout << std::endl; - std::cout << "Zone " << zone_id << " Image" << std::endl; + edm::LogInfo("L1T EMTF++") << std::endl; + edm::LogInfo("L1T EMTF++") << "Zone " << zone_id << " Image" << std::endl; for (int row_id = (model_hm.size() - 1); 0 <= row_id; --row_id) { // Print rows in reverse order const auto& row = hitmap[row_id]; - std::cout << row_id << " "; + edm::LogInfo("L1T EMTF++") << row_id << " "; for (int col_id = 0; col_id < v3::kHitmapNCols; ++col_id) { hitmap_row_t pixel_mask = 1; @@ -154,16 +152,16 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vector= 1); - bool rule_a_ii = (cnt_ye12 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); - bool rule_b_i = (cnt_me11 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); - bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 2); - bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2b >= 1); - bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); - - if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) { - mode |= (1 << 3); - mode |= (1 << 2); - } + // SingleMu (12) + { + bool rule_a_i = (cnt_me12 != 0) and (cnt_me2a >= 1); + bool rule_a_ii = (cnt_ye12 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); + bool rule_b_i = (cnt_me11 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); + bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 2); + bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2b >= 1); + bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2); + + if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) { + mode |= (1 << 3); + mode |= (1 << 2); } + } - // DoubleMu (8) - if (mode < (1 << 3)) { - bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1); - bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1); - bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1); - bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1); - bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1); - bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1); - - if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) { - mode |= (1 << 3); - } + // DoubleMu (8) + if (mode < (1 << 3)) { + bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1); + bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1); + bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1); + bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1); + bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1); + bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1); + + if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) { + mode |= (1 << 3); } + } - // TripleMu (4) - if (mode < (1 << 2)) { - bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1); - bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1); - bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1); - bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1); - bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1); - bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1); - bool rule_d = (cnt_me2a >= 2); - - if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii or rule_d) { - mode |= (1 << 2); - } + // TripleMu (4) + if (mode < (1 << 2)) { + bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1); + bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1); + bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1); + bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1); + bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1); + bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1); + bool rule_d = (cnt_me2a >= 2); + + if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii or rule_d) { + mode |= (1 << 2); } + } - // clang-format on return mode; } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc index ecdf85821d5be..762140979b4c4 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/ParameterAssignmentLayer.cc @@ -1,24 +1,18 @@ #include +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "PhysicsTools/TensorFlow/interface/TensorFlow.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" -#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/ParameterAssignmentLayer.h" using namespace emtf::phase2; using namespace emtf::phase2::algo; -ParameterAssignmentLayer::ParameterAssignmentLayer(const EMTFContext& context) : context_(context) { - // Do Nothing -} - -ParameterAssignmentLayer::~ParameterAssignmentLayer() { - // Do Nothing -} +ParameterAssignmentLayer::ParameterAssignmentLayer(const EMTFContext& context) : context_(context) {} void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector& tracks) const { std::vector feature_sites = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7, @@ -48,11 +42,11 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector 1) { - std::cout << "Parameter Assignment In" - << " disp " << displaced_en << " zone " << track.zone << " col " << track.col << " pat " - << track.pattern << " qual " << track.quality << " phi " << track.phi << " theta " << track.theta - << " features " << std::endl; + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << "Parameter Assignment In" + << " disp " << displaced_en << " zone " << track.zone << " col " << track.col + << " pat " << track.pattern << " qual " << track.quality << " phi " << track.phi + << " theta " << track.theta << " features " << std::endl; } // Prepare input tensor @@ -65,8 +59,8 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector 1 && i_feature > 0) { - std::cout << " "; + if (this->context_.config_.verbosity_ > 1 && i_feature > 0) { + edm::LogInfo("L1T EMTF++") << " "; } // Mask invalid sites @@ -78,15 +72,15 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector 1) { - std::cout << "0"; + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << "0"; } } else { (*input_data) = feature.to_float(); // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout << feature.to_float(); + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << feature.to_float(); } } @@ -94,8 +88,8 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector 1) { - std::cout << std::endl; + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << std::endl; } // Select TF Session @@ -144,13 +138,14 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector 1) { - std::cout << "Parameter Assignment Out" - << " disp " << displaced_en << " zone " << track.zone << " col " << track.col << " pat " - << track.pattern << " qual " << track.quality << " q " << track.q << " pt " << track.pt << " rels " - << track.rels << " dxy " << track.dxy << " z0 " << track.z0 << " phi " << track.phi << " theta " - << track.theta << " beta " << track.beta << " pt_address " << track.pt_address << " rels_address " - << track.rels_address << " dxy_address " << track.dxy_address << " valid " << track.valid << std::endl; + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << "Parameter Assignment Out" + << " disp " << displaced_en << " zone " << track.zone << " col " << track.col + << " pat " << track.pattern << " qual " << track.quality << " q " << track.q << " pt " + << track.pt << " rels " << track.rels << " dxy " << track.dxy << " z0 " << track.z0 + << " phi " << track.phi << " theta " << track.theta << " beta " << track.beta + << " pt_address " << track.pt_address << " rels_address " << track.rels_address + << " dxy_address " << track.dxy_address << " valid " << track.valid << std::endl; } } // End loop tracks } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc index d7dd67157e7db..dc436ee477067 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc @@ -1,3 +1,5 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" @@ -5,13 +7,7 @@ using namespace emtf::phase2::algo; -PatternMatchingLayer::PatternMatchingLayer(const EMTFContext& context) : context_(context) { - // Do Nothing -} - -PatternMatchingLayer::~PatternMatchingLayer() { - // Do Nothing -} +PatternMatchingLayer::PatternMatchingLayer(const EMTFContext& context) : context_(context) {} void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, const bool& displaced_en, @@ -112,15 +108,15 @@ void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, } // End Loop Patterns in Zones // Debug Info - if (CONFIG.verbosity_ > 1) { + if (this->context_.config_.verbosity_ > 1) { for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { if (roads[i_col].quality == 0) { continue; } - std::cout << "Road" - << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern << " qual " - << roads[i_col].quality << std::endl; + edm::LogInfo("L1T EMTF++") << "Road" + << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern + << " qual " << roads[i_col].quality << std::endl; } } } // End Loop Zones diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc index c756a0894d565..1d6cb55f1baa4 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc @@ -1,3 +1,5 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" @@ -6,13 +8,7 @@ using namespace emtf::phase2::algo; -RoadSortingLayer::RoadSortingLayer(const EMTFContext& context) : context_(context) { - // Do Nothing -} - -RoadSortingLayer::~RoadSortingLayer() { - // Do Nothing -} +RoadSortingLayer::RoadSortingLayer(const EMTFContext& context) : context_(context) {} void RoadSortingLayer::apply(const int& first_n, const std::vector& zone_roads, @@ -55,10 +51,10 @@ void RoadSortingLayer::apply(const int& first_n, suppressed_roads[i_col].quality = roads[i_col].quality; } else { // Debug Info - if (CONFIG.verbosity_ > 2 && roads[i_col].quality > 0) { - std::cout << "Road Suppressed" - << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern << " qual " - << roads[i_col].quality << std::endl; + if (this->context_.config_.verbosity_ > 2 && roads[i_col].quality > 0) { + edm::LogInfo("L1T EMTF++") << "Road Suppressed" + << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern + << " qual " << roads[i_col].quality << std::endl; } // Suppress @@ -85,10 +81,11 @@ void RoadSortingLayer::apply(const int& first_n, roads_kept[i_col] = suppressed_roads[i_col * 2 + 1]; } - if (CONFIG.verbosity_ > 2 && roads_kept[i_col].quality > 0) { - std::cout << "Road Kept" - << " zone " << roads_kept[i_col].zone << " col " << roads_kept[i_col].col << " pat " - << roads_kept[i_col].pattern << " qual " << roads_kept[i_col].quality << std::endl; + if (this->context_.config_.verbosity_ > 2 && roads_kept[i_col].quality > 0) { + edm::LogInfo("L1T EMTF++") << "Road Kept" + << " zone " << roads_kept[i_col].zone << " col " << roads_kept[i_col].col + << " pat " << roads_kept[i_col].pattern << " qual " << roads_kept[i_col].quality + << std::endl; } } } @@ -117,16 +114,16 @@ void RoadSortingLayer::apply(const int& first_n, } // End Loop Zones // Debug Info - if (CONFIG.verbosity_ > 2) { + if (this->context_.config_.verbosity_ > 2) { for (const auto& road : top_roads) { // Short-Circuit: Skip quality-0 roads if (road.quality == 0) { continue; } - std::cout << "Top Road" - << " zone " << road.zone << " col " << road.col << " pat " << road.pattern << " qual " << road.quality - << std::endl; + edm::LogInfo("L1T EMTF++") << "Top Road" + << " zone " << road.zone << " col " << road.col << " pat " << road.pattern << " qual " + << road.quality << std::endl; } } @@ -153,9 +150,9 @@ void RoadSortingLayer::apply(const int& first_n, best_roads.push_back(road); // Debug Info - if (CONFIG.verbosity_ > 1 && road.quality > 0) { - std::cout << "Best Road " << i_road << " zone " << road.zone << " col " << road.col << " pat " << road.pattern - << " qual " << road.quality << std::endl; + if (this->context_.config_.verbosity_ > 1 && road.quality > 0) { + edm::LogInfo("L1T EMTF++") << "Best Road " << i_road << " zone " << road.zone << " col " << road.col << " pat " + << road.pattern << " qual " << road.quality << std::endl; } } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc index 77435cfa9b481..5c2d76e2b37ff 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc @@ -1,7 +1,8 @@ +#include "FWCore/MessageLogger/interface/MessageLogger.h" + #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" -#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h" @@ -15,7 +16,7 @@ seg_theta_t TrackBuildingLayer::calc_theta_median(std::vector theta // Sort Thetas // This will sort ascending order (lower-value means lower-index) data::mergesort(&thetas[0], thetas.size(), [](seg_theta_t lower_index_value, seg_theta_t larger_index_value) -> int { - return when(lower_index_value > larger_index_value, 1, 0); + return lower_index_value > larger_index_value ? 1 : 0; }); // Check if any model_thm_site is null @@ -36,13 +37,7 @@ seg_theta_t TrackBuildingLayer::calc_theta_median(std::vector theta } // Members -TrackBuildingLayer::TrackBuildingLayer(const EMTFContext& context) : context_(context) { - // Do Nothing -} - -TrackBuildingLayer::~TrackBuildingLayer() { - // Do Nothing -} +TrackBuildingLayer::TrackBuildingLayer(const EMTFContext& context) : context_(context) {} void TrackBuildingLayer::apply(const segment_collection_t& segments, const std::vector& roads, @@ -75,29 +70,34 @@ void TrackBuildingLayer::apply(const segment_collection_t& segments, } // Debug Info - if (CONFIG.verbosity_ > 1) { + if (this->context_.config_.verbosity_ > 1) { if (i_road == 0) { - std::cout << std::endl; - std::cout << "===========================================================================" << std::endl; - std::cout << "BEGIN TRACK BUILDING" << std::endl; - std::cout << "---------------------------------------------------------------------------" << std::endl; + edm::LogInfo("L1T EMTF++") << std::endl; + edm::LogInfo("L1T EMTF++") << "===========================================================================" + << std::endl; + edm::LogInfo("L1T EMTF++") << "BEGIN TRACK BUILDING" << std::endl; + edm::LogInfo("L1T EMTF++") << "---------------------------------------------------------------------------" + << std::endl; } - std::cout << "***************************************************************************" << std::endl; - std::cout << "Begin building track " << i_road << std::endl; + edm::LogInfo("L1T EMTF++") << "***************************************************************************" + << std::endl; + edm::LogInfo("L1T EMTF++") << "Begin building track " << i_road << std::endl; } // Attach segments attach_segments(segments, road, displaced_en, track); // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout << "End building track " << i_road << std::endl; + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << "End building track " << i_road << std::endl; if (i_road == (roads.size() - 1)) { - std::cout << "---------------------------------------------------------------------------" << std::endl; - std::cout << "END TRACK BUILDING" << std::endl; - std::cout << "===========================================================================" << std::endl; + edm::LogInfo("L1T EMTF++") << "---------------------------------------------------------------------------" + << std::endl; + edm::LogInfo("L1T EMTF++") << "END TRACK BUILDING" << std::endl; + edm::LogInfo("L1T EMTF++") << "===========================================================================" + << std::endl; } } } @@ -241,10 +241,10 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, const auto& trk_pat_row_end = trk_pat_end[i_row]; const auto& trk_pat_row_phi = trk_pat_phi[i_row]; - if (CONFIG.verbosity_ > 2) { - std::cout << "Pattern Row:" - << " row " << i_row << " begin " << trk_pat_row_begin << " end " << trk_pat_row_end << " phi " - << trk_pat_row_phi << std::endl; + if (this->context_.config_.verbosity_ > 2) { + edm::LogInfo("L1T EMTF++") << "Pattern Row:" + << " row " << i_row << " begin " << trk_pat_row_begin << " end " << trk_pat_row_end + << " phi " << trk_pat_row_phi << std::endl; } for (const auto& model_hm_site : model_hm_row) { // Begin loop sites in row @@ -297,10 +297,11 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, diff = seg.phi - trk_pat_row_phi; } - if (CONFIG.verbosity_ > 2) { - std::cout << "Site candidate:" - << " site_id " << site_id << " seg_id " << seg_id << " seg_phi " << seg.phi << " seg_theta1 " - << seg.theta1 << " seg_theta2 " << seg.theta2 << " seg_bend " << seg.bend << std::endl; + if (this->context_.config_.verbosity_ > 2) { + edm::LogInfo("L1T EMTF++") << "Site candidate:" + << " site_id " << site_id << " seg_id " << seg_id << " seg_phi " << seg.phi + << " seg_theta1 " << seg.theta1 << " seg_theta2 " << seg.theta2 << " seg_bend " + << seg.bend << std::endl; } // Short-Circuit: If the difference is larger than the min diff move on @@ -316,11 +317,12 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, } // End loop chambers in site // Debug Info - if (CONFIG.verbosity_ > 2 && site_bit == 1) { - std::cout << "Segment attached:" - << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " << segments[site_seg_id].phi - << " seg_theta1 " << segments[site_seg_id].theta1 << " seg_theta2 " << segments[site_seg_id].theta2 - << " seg_bend " << segments[site_seg_id].bend << std::endl; + if (this->context_.config_.verbosity_ > 2 && site_bit == 1) { + edm::LogInfo("L1T EMTF++") << "Segment attached:" + << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " + << segments[site_seg_id].phi << " seg_theta1 " << segments[site_seg_id].theta1 + << " seg_theta2 " << segments[site_seg_id].theta2 << " seg_bend " + << segments[site_seg_id].bend << std::endl; } } // End loop sites in row @@ -370,17 +372,17 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, } // End loop group sites // Calculate theta median - if (CONFIG.verbosity_ > 2) { + if (this->context_.config_.verbosity_ > 2) { for (const auto& theta : group) { - std::cout << "theta " << theta << std::endl; + edm::LogInfo("L1T EMTF++") << "theta " << theta << std::endl; } } auto group_median = calc_theta_median(group); group_medians.push_back(group_median); - if (CONFIG.verbosity_ > 2) { - std::cout << "group_median " << group_median << std::endl; + if (this->context_.config_.verbosity_ > 2) { + edm::LogInfo("L1T EMTF++") << "group_median " << group_median << std::endl; } } // End loop theta median groups @@ -388,8 +390,8 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, auto theta_median = calc_theta_median(group_medians); theta_medians.push_back(theta_median); - if (CONFIG.verbosity_ > 2) { - std::cout << "theta_median " << theta_median << std::endl; + if (this->context_.config_.verbosity_ > 2) { + edm::LogInfo("L1T EMTF++") << "theta_median " << theta_median << std::endl; } } // End loop theta medians @@ -487,10 +489,11 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, site_rm_bit = 1; // Debug Info - if (CONFIG.verbosity_ > 4) { - std::cout << "Segment outside of theta window; detatched:" - << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " << site_seg.phi - << " seg_theta1 " << site_seg.theta1 << " seg_theta2 " << site_seg.theta2 << std::endl; + if (this->context_.config_.verbosity_ > 4) { + edm::LogInfo("L1T EMTF++") << "Segment outside of theta window; detatched:" + << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " << site_seg.phi + << " seg_theta1 " << site_seg.theta1 << " seg_theta2 " << site_seg.theta2 + << std::endl; } } } @@ -542,26 +545,27 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, } // Additional features - track.features[i_feature++] = when(trk_quality > 0, trk_rel_phi, 0); - track.features[i_feature++] = when(trk_quality > 0, trk_abs_theta, 0); + track.features[i_feature++] = trk_quality > 0 ? trk_rel_phi : decltype(trk_rel_phi)(0); + track.features[i_feature++] = trk_quality > 0 ? trk_abs_theta : decltype(trk_abs_theta)(0); track.features[i_feature++] = trk_quality; track.features[i_feature++] = 0; // unused // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout << "Track" - << " zone " << track.zone << " col " << track.col << " pat " << track.pattern << " qual " << track.quality - << " sector_abs_phi " << sector_abs_phi << " abs_phi " << track.phi << " rel_phi " << trk_rel_phi - << " abs_theta " << track.theta << " features " << std::endl; + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << "Track" + << " zone " << track.zone << " col " << track.col << " pat " << track.pattern << " qual " + << track.quality << " sector_abs_phi " << sector_abs_phi << " abs_phi " << track.phi + << " rel_phi " << trk_rel_phi << " abs_theta " << track.theta << " features " + << std::endl; for (int i = 0; i < v3::kNumTrackFeatures; ++i) { if (i > 0) { - std::cout << " "; + edm::LogInfo("L1T EMTF++") << " "; } - std::cout << track.features[i]; + edm::LogInfo("L1T EMTF++") << track.features[i]; } - std::cout << std::endl; + edm::LogInfo("L1T EMTF++") << std::endl; } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc index 53bc467c1705e..f78f3beb6189c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc @@ -17,13 +17,7 @@ using namespace emtf::phase2; CSCTPCollector::CSCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("CSCInput"))) { - // Do Nothing -} - -CSCTPCollector::~CSCTPCollector() { - // Do Nothing -} + context.pset_.getParameter("CSCInput"))) {} void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { edm::Handle csc_digis; @@ -51,7 +45,7 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co const auto& tp_det_id = tp_entry.tp_.detId(); const CSCData& tp_data = tp_entry.tp_.getCSCData(); - const int tp_bx = tp_data.bx + CONFIG.csc_bx_shift_; + const int tp_bx = tp_data.bx + this->context_.config_.csc_bx_shift_; const int tp_wire = tp_data.keywire; auto key = std::make_pair(tp_det_id.rawId(), tp_bx); @@ -97,7 +91,7 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co const int tp_csc_id = tp_data.cscID; - const int tp_bx = tp_data.bx + CONFIG.csc_bx_shift_; + const int tp_bx = tp_data.bx + this->context_.config_.csc_bx_shift_; // Get wires int tp_wire1 = tp_data.keywire; @@ -137,10 +131,10 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co // Check for corrupted LCT data. Data corruption could occur due to software // or hardware issues, if corrupted, reject the LCT. if (!(tp_data.strip < max_strip)) { - edm::LogWarning("L1T") << "Found error in LCT strip: " << tp_data.strip << " (allowed range: 0-" << max_strip - 1 - << ")."; + edm::LogWarning("L1T EMTF++") << "Found error in LCT strip: " << tp_data.strip << " (allowed range: 0-" + << max_strip - 1 << ")."; - edm::LogWarning("L1T") + edm::LogWarning("L1T EMTF++") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; @@ -149,10 +143,10 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } if (!(tp_data.keywire < max_wire)) { - edm::LogWarning("L1T") << "Found error in LCT wire: " << tp_data.keywire << " (allowed range: 0-" << max_wire - 1 - << ")."; + edm::LogWarning("L1T EMTF++") << "Found error in LCT wire: " << tp_data.keywire << " (allowed range: 0-" + << max_wire - 1 << ")."; - edm::LogWarning("L1T") + edm::LogWarning("L1T EMTF++") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; @@ -161,9 +155,9 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } if (!(tp_data.valid == true)) { - edm::LogWarning("L1T") << "Found error in LCT valid: " << tp_data.valid << " (allowed value: 1)."; + edm::LogWarning("L1T EMTF++") << "Found error in LCT valid: " << tp_data.valid << " (allowed value: 1)."; - edm::LogWarning("L1T") + edm::LogWarning("L1T EMTF++") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; @@ -172,10 +166,10 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } if (!(tp_data.pattern < max_pattern)) { - edm::LogWarning("L1T") << "Found error in LCT pattern: " << tp_data.pattern << " (allowed range: 0-" - << max_pattern - 1 << ")."; + edm::LogWarning("L1T EMTF++") << "Found error in LCT pattern: " << tp_data.pattern << " (allowed range: 0-" + << max_pattern - 1 << ")."; - edm::LogWarning("L1T") + edm::LogWarning("L1T EMTF++") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; @@ -184,10 +178,10 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } if (!(0 < tp_data.quality && tp_data.quality < max_quality)) { - edm::LogWarning("L1T") << "Found error in LCT quality: " << tp_data.quality << " (allowed range: 1-" - << max_quality - 1 << ")."; + edm::LogWarning("L1T EMTF++") << "Found error in LCT quality: " << tp_data.quality << " (allowed range: 1-" + << max_quality - 1 << ")."; - edm::LogWarning("L1T") + edm::LogWarning("L1T EMTF++") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc index 58dcedade4939..f46d46bf6fd2d 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc @@ -16,13 +16,7 @@ using namespace emtf::phase2; CSCTPConverter::CSCTPConverter(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -CSCTPConverter::~CSCTPConverter() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void CSCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { // Unpack Id @@ -82,7 +76,7 @@ void CSCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, const int tp_ilink = tp_info.ilink; // Get Global Coordinates - const GlobalPoint& gp_w1 = GEOM.getGlobalPoint(tp); + const GlobalPoint& gp_w1 = this->context_.geometry_translator_.getGlobalPoint(tp); const float glob_phi_w1 = tp::rad_to_deg(gp_w1.phi().value()); const float glob_theta_w1 = tp::rad_to_deg(gp_w1.theta().value()); const double glob_rho_w1 = gp_w1.perp(); @@ -106,7 +100,7 @@ void CSCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, tp_w2.accessCSCData().keywire = tp_wire2; - const GlobalPoint& gp_w2 = GEOM.getGlobalPoint(tp_w2); + const GlobalPoint& gp_w2 = this->context_.geometry_translator_.getGlobalPoint(tp_w2); const double glob_theta_w2 = tp::rad_to_deg(gp_w2.theta().value()); emtf_theta_w2 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w2); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc index 7c614cfa57118..3ba75da07d88d 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc @@ -13,13 +13,7 @@ using namespace emtf::phase2; CSCTPSelector::CSCTPSelector(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -CSCTPSelector::~CSCTPSelector() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void CSCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { emtf_assert(tp.subsystem() == L1TMuon::kCSC); @@ -36,22 +30,22 @@ void CSCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM if (ilink_tpc_map[ilink].size() < 2) { ilink_tpc_map[ilink].emplace_back(tp, tp_info); } else { - edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; - edm::LogWarning("L1T") << "Found 3 CSC trigger primitives in the same chamber"; + edm::LogWarning("L1T EMTF++") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; + edm::LogWarning("L1T EMTF++") << "Found 3 CSC trigger primitives in the same chamber"; for (int i_tp = 0; i_tp < 3; i_tp++) { const auto& tp_err = ((i_tp < 2) ? ilink_tpc_map[ilink].at(i_tp).tp_ : tp); - edm::LogWarning("L1T") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap " - << tp_err.detId().endcap() << ", sector " - << tp_err.detId().triggerSector() << ", station " - << tp_err.detId().station() << ", ring " << tp_err.detId().ring() - << ", chamber " << tp_err.detId().chamber() << ", CSC ID " - << tp_err.getCSCData().cscID << ": strip " << tp_err.getStrip() << ", wire " - << tp_err.getWire(); + edm::LogWarning("L1T EMTF++") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap " + << tp_err.detId().endcap() << ", sector " + << tp_err.detId().triggerSector() << ", station " + << tp_err.detId().station() << ", ring " + << tp_err.detId().ring() << ", chamber " + << tp_err.detId().chamber() << ", CSC ID " << tp_err.getCSCData().cscID + << ": strip " << tp_err.getStrip() << ", wire " << tp_err.getWire(); } - edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n"; + edm::LogWarning("L1T EMTF++") << "************************* ONLY KEEP FIRST TWO *************************\n\n"; } } @@ -74,7 +68,7 @@ int CSCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; - } else if (CONFIG.include_neighbor_en_ && + } else if (this->context_.config_.include_neighbor_en_ && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc index 0bccc42e4c53d..eb7c5df2c9ef1 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc @@ -17,13 +17,7 @@ using namespace emtf::phase2; GE0TPCollector::GE0TPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("GE0Input"))) { - // Do Nothing -} - -GE0TPCollector::~GE0TPCollector() { - // Do Nothing -} + context.pset_.getParameter("GE0Input"))) {} void GE0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants @@ -68,7 +62,7 @@ void GE0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co const int tp_pad = tp_data.phiposition; const int tp_partition = tp_data.partition; - const int tp_bx = tp_data.bx + CONFIG.me0_bx_shift_; + const int tp_bx = tp_data.bx + this->context_.config_.me0_bx_shift_; // Reject if outside eta of 2.4 if (tp_partition > me0_max_partition) { diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc index a1232ec7d2988..844fdff5ba751 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc @@ -16,13 +16,7 @@ using namespace emtf::phase2; GE0TPConverter::GE0TPConverter(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -GE0TPConverter::~GE0TPConverter() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void GE0TPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { // Unpack Id @@ -66,7 +60,7 @@ void GE0TPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, const int tp_ilink = tp_info.ilink; // Get Global Coordinates - const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp); const float glob_phi = tp::rad_to_deg(gp.phi().value()); const float glob_theta = tp::rad_to_deg(gp.theta().value()); const double glob_rho = gp.perp(); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc index 50e9707f48023..e9bdfb49b2865 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc @@ -13,13 +13,7 @@ using namespace emtf::phase2; GE0TPSelector::GE0TPSelector(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -GE0TPSelector::~GE0TPSelector() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void GE0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { emtf_assert(tp.subsystem() == L1TMuon::kME0); @@ -53,7 +47,7 @@ int GE0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; - } else if (CONFIG.include_neighbor_en_ && + } else if (this->context_.config_.include_neighbor_en_ && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc index b5e96db0cf121..3c4c985e8feb9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc @@ -15,13 +15,7 @@ using namespace emtf::phase2; GEMTPCollector::GEMTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("GEMInput"))) { - // Do Nothing -} - -GEMTPCollector::~GEMTPCollector() { - // Do Nothing -} + context.pset_.getParameter("GEMInput"))) {} void GEMTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants @@ -72,7 +66,7 @@ void GEMTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co const uint16_t tp_pad_lo = tp_data.pad_low; const uint16_t tp_pad_hi = tp_data.pad_hi; - const int tp_bx = tp_data.bx + CONFIG.gem_bx_shift_; + const int tp_bx = tp_data.bx + this->context_.config_.gem_bx_shift_; GEMDetId tp_mod_det_id(tp_region, tp_ring, tp_station, 0, tp_chamber, 0); auto key = std::make_pair(tp_mod_det_id.rawId(), tp_bx); @@ -107,7 +101,7 @@ void GEMTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co const int tp_pad_lo = tp_data.pad_low; const int tp_pad_hi = tp_data.pad_hi; - const int tp_bx = tp_data.bx + CONFIG.gem_bx_shift_; + const int tp_bx = tp_data.bx + this->context_.config_.gem_bx_shift_; // Get Copad Info GEMDetId tp_mod_det_id(tp_region, tp_ring, tp_station, 0, tp_chamber, 0); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc index 889bae125bb5c..41ab1b95b359b 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc @@ -16,13 +16,7 @@ using namespace emtf::phase2; GEMTPConverter::GEMTPConverter(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -GEMTPConverter::~GEMTPConverter() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void GEMTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { // Unpack Id @@ -71,7 +65,7 @@ void GEMTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, // Get Global Coordinates // const GlobalPoint& gp = get_global_point(detgeom, detid, digi); - const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp); const float glob_phi = tp::rad_to_deg(gp.phi().value()); const float glob_theta = tp::rad_to_deg(gp.theta().value()); const double glob_rho = gp.perp(); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc index 21751162d462a..44c90c57d2a4f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc @@ -13,13 +13,7 @@ using namespace emtf::phase2; GEMTPSelector::GEMTPSelector(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -GEMTPSelector::~GEMTPSelector() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void GEMTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { emtf_assert(tp.subsystem() == L1TMuon::kGEM); @@ -54,7 +48,7 @@ int GEMTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; - } else if (CONFIG.include_neighbor_en_ && + } else if (this->context_.config_.include_neighbor_en_ && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc index 96ee06b1fc952..46631c33b8774 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc @@ -17,13 +17,7 @@ using namespace emtf::phase2; ME0TPCollector::ME0TPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("ME0Input"))) { - // Do Nothing -} - -ME0TPCollector::~ME0TPCollector() { - // Do Nothing -} + context.pset_.getParameter("ME0Input"))) {} void ME0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants @@ -68,7 +62,7 @@ void ME0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co const int tp_pad = tp_data.phiposition; const int tp_partition = tp_data.partition; - const int tp_bx = tp_data.bx + CONFIG.me0_bx_shift_; + const int tp_bx = tp_data.bx + this->context_.config_.me0_bx_shift_; // Reject if outside eta of 2.4 if (tp_partition > me0_max_partition) { diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc index f4a3ed279ccab..3a694752d784b 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc @@ -16,13 +16,7 @@ using namespace emtf::phase2; ME0TPConverter::ME0TPConverter(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -ME0TPConverter::~ME0TPConverter() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void ME0TPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { // Unpack Id @@ -66,7 +60,7 @@ void ME0TPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, const int tp_ilink = tp_info.ilink; // Get Global Coordinates - const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp); const float glob_phi = tp::rad_to_deg(gp.phi().value()); const float glob_theta = tp::rad_to_deg(gp.theta().value()); const double glob_rho = gp.perp(); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc index 47b5b633b0ac3..575b3f3c32391 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc @@ -13,13 +13,7 @@ using namespace emtf::phase2; ME0TPSelector::ME0TPSelector(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -ME0TPSelector::~ME0TPSelector() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void ME0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { emtf_assert(tp.subsystem() == L1TMuon::kME0); @@ -53,7 +47,7 @@ int ME0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; - } else if (CONFIG.include_neighbor_en_ && + } else if (this->context_.config_.include_neighbor_en_ && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc index 87012266cb2bd..b6dc2fa31800f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc @@ -9,7 +9,6 @@ #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h" -#include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h" using namespace emtf::phase2; @@ -17,13 +16,7 @@ using namespace emtf::phase2; RPCTPCollector::RPCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("RPCInput"))) { - // Do Nothing -} - -RPCTPCollector::~RPCTPCollector() { - // Do Nothing -} + context.pset_.getParameter("RPCInput"))) {} void RPCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants @@ -73,7 +66,7 @@ void RPCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co const bool tp_is_CPPF = tp_data.isCPPF; - const int tp_bx = tp_data.bx + CONFIG.rpc_bx_shift_; + const int tp_bx = tp_data.bx + this->context_.config_.rpc_bx_shift_; // Check Ring bool tp_is_substitute = (tp_ring == 3); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc index fc35902b9bf4b..7b3d08fa01a8a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc @@ -18,13 +18,7 @@ using namespace emtf::phase2; RPCTPConverter::RPCTPConverter(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -RPCTPConverter::~RPCTPConverter() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void RPCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const { // Unpack Id @@ -92,7 +86,8 @@ void RPCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, if (tp_rpc_type == rpc::Type::kiRPC) { // Handle iRPC Coordinates - const RPCRoll* roll = dynamic_cast(GEOM.getRPCGeometry().roll(tp_det_id)); + const RPCRoll* roll = + dynamic_cast(this->context_.geometry_translator_.getRPCGeometry().roll(tp_det_id)); const GlobalPoint& irpc_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0)); glob_phi = tp::rad_to_deg(irpc_gp.phi().value()); @@ -101,7 +96,7 @@ void RPCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, glob_z = irpc_gp.z(); } else { // Handle RPC Coordinates - const GlobalPoint& gp = GEOM.getGlobalPoint(tp); + const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp); glob_phi = tp::rad_to_deg(gp.phi().value()); glob_theta = tp::rad_to_deg(gp.theta().value()); glob_rho = gp.perp(); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc index 9f3d0b68ffdbf..410aa73e750b5 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc @@ -14,13 +14,7 @@ using namespace emtf::phase2; RPCTPSelector::RPCTPSelector(const EMTFContext& context, const int& endcap, const int& sector) - : context_(context), endcap_(endcap), sector_(sector) { - // Do Nothing -} - -RPCTPSelector::~RPCTPSelector() { - // Do Nothing -} + : context_(context), endcap_(endcap), sector_(sector) {} void RPCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const { emtf_assert(tp.subsystem() == L1TMuon::kRPC); @@ -63,7 +57,7 @@ int RPCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; - } else if (CONFIG.include_neighbor_en_ && + } else if (this->context_.config_.include_neighbor_en_ && csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc index 27b168e929466..537114cc9ed6a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc @@ -13,100 +13,100 @@ ActivationLut::ActivationLut() { 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8101, 7970, 7842, 7719, 7595, 7479, 7362, 7246, 7137, 7028, + 6919, 6817, 6715, 6613, 6515, 6417, 6322, 6231, 6141, 6053, 5966, 5879, 5795, 5711, 5631, 5551, 5475, 5399, 5322, + 5250, 5177, 5104, 5035, 4966, 4897, 4832, 4762, 4701, 4635, 4573, 4512, 4453, 4392, 4333, 4275, 4217, 4162, 4108, + 4053, 3999, 3948, 3897, 3842, 3795, 3744, 3693, 3646, 3599, 3552, 3504, 3461, 3417, 3370, 3326, 3282, 3242, 3199, + 3159, 3115, 3075, 3035, 2995, 2959, 2919, 2882, 2842, 2806, 2770, 2733, 2697, 2664, 2628, 2595, 2559, 2526, 2493, + 2461, 2428, 2395, 2366, 2333, 2301, 2272, 2242, 2210, 2181, 2152, 2124, 2096, 2071, 2043, 2015, 1991, 1963, 1940, + 1916, 1889, 1865, 1842, 1819, 1796, 1773, 1753, 1730, 1708, 1689, 1666, 1647, 1625, 1606, 1588, 1569, 1547, 1529, + 1511, 1492, 1474, 1459, 1441, 1424, 1406, 1391, 1374, 1356, 1342, 1327, 1310, 1296, 1282, 1265, 1251, 1237, 1223, + 1209, 1195, 1181, 1168, 1154, 1141, 1127, 1117, 1103, 1090, 1077, 1066, 1053, 1043, 1030, 1020, 1007, 997, 986, 974, + 964, 954, 944, 931, 922, 912, 902, 892, 882, 873, 863, 854, 844, 835, 828, 818, 809, 799, 792, 783, 774, 767, 758, + 749, 742, 733, 726, 718, 711, 702, 695, 689, 680, 674, 667, 658, 652, 646, 639, 631, 624, 618, 612, 605, 599, 593, + 587, 581, 574, 568, 562, 556, 550, 544, 538, 532, 526, 520, 516, 510, 505, 499, 495, 489, 483, 480, 474, 468, 464, + 459, 453, 449, 444, 440, 434, 431, 425, 421, 416, 412, 407, 403, 398, 394, 391, 385, 382, 378, 373, 370, 366, 361, + 357, 354, 350, 345, 342, 338, 335, 330, 327, 323, 320, 317, 313, 310, 307, 302, 298, 295, 292, 289, 285, 282, 279, + 276, 273, 269, 266, 263, 260, 257, 254, 252, 249, 246, 243, 240, 237, 234, 232, 229, 226, 223, 220, 217, 216, 213, + 210, 207, 205, 202, 199, 196, 195, 192, 189, 188, 185, 182, 180, 178, 175, 173, 171, 168, 166, 164, 162, 159, 158, + 155, 152, 151, 148, 147, 144, 143, 140, 139, 136, 135, 132, 131, 128, 127, 124, 123, 120, 119, 116, 115, 114, 111, + 110, 107, 106, 105, 102, 101, 100, 97, 96, 93, 92, 91, 88, 87, 86, 84, 82, 81, 80, 77, 76, 75, 73, 71, 70, 69, 67, + 65, 64, 63, 61, 59, 58, 57, 56, 54, 52, 51, 50, 49, 47, 46, 44, 43, 42, 41, 39, 38, 37, 35, 34, 33, 32, 31, 29, 28, + 27, 25, 24, 23, 22, 21, 20, 19, 18, 16, 15, 14, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 13, 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 27, 28, 29, 31, 32, 33, 34, 35, 37, 38, 39, 41, 42, 43, 44, + 46, 47, 49, 50, 51, 52, 54, 56, 57, 58, 59, 61, 63, 64, 65, 67, 69, 70, 71, 73, 75, 76, 77, 80, 81, 82, 84, 86, 87, + 88, 91, 92, 93, 96, 97, 100, 101, 102, 105, 106, 107, 110, 111, 114, 115, 116, 119, 120, 123, 124, 127, 128, 131, + 132, 135, 136, 139, 140, 143, 144, 147, 148, 151, 152, 155, 158, 159, 162, 164, 166, 168, 171, 173, 175, 178, 180, + 182, 185, 188, 189, 192, 195, 196, 199, 202, 205, 207, 210, 213, 216, 217, 220, 223, 226, 229, 232, 234, 237, 240, + 243, 246, 249, 252, 254, 257, 260, 263, 266, 269, 273, 276, 279, 282, 285, 289, 292, 295, 298, 302, 307, 310, 313, + 317, 320, 323, 327, 330, 335, 338, 342, 345, 350, 354, 357, 361, 366, 370, 373, 378, 382, 385, 391, 394, 398, 403, + 407, 412, 416, 421, 425, 431, 434, 440, 444, 449, 453, 459, 464, 468, 474, 480, 483, 489, 495, 499, 505, 510, 516, + 520, 526, 532, 538, 544, 550, 556, 562, 568, 574, 581, 587, 593, 599, 605, 612, 618, 624, 631, 639, 646, 652, 658, + 667, 674, 680, 689, 695, 702, 711, 718, 726, 733, 742, 749, 758, 767, 774, 783, 792, 799, 809, 818, 828, 835, 844, + 854, 863, 873, 882, 892, 902, 912, 922, 931, 944, 954, 964, 974, 986, 997, 1007, 1020, 1030, 1043, 1053, 1066, 1077, + 1090, 1103, 1117, 1127, 1141, 1154, 1168, 1181, 1195, 1209, 1223, 1237, 1251, 1265, 1282, 1296, 1310, 1327, 1342, + 1356, 1374, 1391, 1406, 1424, 1441, 1459, 1474, 1492, 1511, 1529, 1547, 1569, 1588, 1606, 1625, 1647, 1666, 1689, + 1708, 1730, 1753, 1773, 1796, 1819, 1842, 1865, 1889, 1916, 1940, 1963, 1991, 2015, 2043, 2071, 2096, 2124, 2152, + 2181, 2210, 2242, 2272, 2301, 2333, 2366, 2395, 2428, 2461, 2493, 2526, 2559, 2595, 2628, 2664, 2697, 2733, 2770, + 2806, 2842, 2882, 2919, 2959, 2995, 3035, 3075, 3115, 3159, 3199, 3242, 3282, 3326, 3370, 3417, 3461, 3504, 3552, + 3599, 3646, 3693, 3744, 3795, 3842, 3897, 3948, 3999, 4053, 4108, 4162, 4217, 4275, 4333, 4392, 4453, 4512, 4573, + 4635, 4701, 4762, 4832, 4897, 4966, 5035, 5104, 5177, 5250, 5322, 5399, 5475, 5551, 5631, 5711, 5795, 5879, 5966, + 6053, 6141, 6231, 6322, 6417, 6515, 6613, 6715, 6817, 6919, 7028, 7137, 7246, 7362, 7479, 7595, 7719, 7842, 7970, + 8101, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8116, 7991, 7867, 7743, 7623, 7503, 7387, 7276, 7165, 7058, 6952, 6845, 6743, 6640, 6543, 6445, 6352, 6258, 6165, - 6076, 5987, 5898, 5814, 5730, 5645, 5565, 5481, 5405, 5325, 5250, 5174, 5103, 5027, 4956, 4885, 4814, 4747, 4681, - 4614, 4547, 4485, 4423, 4356, 4299, 4236, 4174, 4116, 4059, 4001, 3943, 3890, 3836, 3779, 3725, 3672, 3623, 3570, - 3521, 3468, 3419, 3370, 3321, 3277, 3228, 3183, 3134, 3090, 3045, 3001, 2957, 2917, 2872, 2832, 2788, 2748, 2708, - 2668, 2628, 2588, 2552, 2512, 2472, 2437, 2401, 2361, 2326, 2291, 2257, 2223, 2193, 2160, 2127, 2098, 2065, 2037, - 2009, 1977, 1950, 1923, 1896, 1869, 1842, 1820, 1794, 1768, 1746, 1720, 1698, 1673, 1652, 1631, 1610, 1586, 1565, - 1544, 1524, 1504, 1487, 1467, 1448, 1428, 1412, 1392, 1373, 1358, 1342, 1323, 1308, 1292, 1274, 1259, 1244, 1229, - 1214, 1199, 1184, 1170, 1155, 1141, 1127, 1115, 1101, 1087, 1073, 1062, 1049, 1038, 1024, 1013, 1000, 989, 979, 966, - 955, 945, 935, 922, 912, 901, 891, 881, 871, 862, 852, 842, 832, 823, 815, 806, 796, 787, 780, 770, 761, 754, 745, - 736, 729, 720, 713, 704, 698, 689, 682, 676, 667, 660, 654, 645, 639, 633, 626, 618, 611, 605, 599, 593, 587, 581, - 574, 568, 562, 556, 550, 544, 538, 532, 527, 521, 515, 509, 505, 499, 494, 488, 484, 479, 473, 469, 464, 458, 454, - 449, 443, 440, 434, 431, 425, 422, 416, 413, 408, 404, 399, 395, 390, 387, 383, 378, 374, 371, 366, 363, 359, 354, - 351, 347, 344, 339, 336, 333, 329, 324, 321, 318, 315, 311, 308, 305, 302, 297, 294, 291, 288, 284, 281, 278, 275, - 272, 269, 266, 263, 260, 257, 254, 251, 249, 246, 243, 240, 237, 234, 231, 230, 227, 224, 221, 218, 215, 214, 211, - 208, 205, 204, 201, 198, 195, 194, 191, 188, 187, 184, 181, 180, 177, 174, 173, 170, 168, 166, 163, 162, 159, 158, - 155, 153, 151, 149, 147, 145, 143, 141, 139, 137, 135, 133, 132, 129, 128, 125, 124, 121, 120, 117, 116, 115, 112, - 111, 108, 107, 106, 103, 102, 101, 98, 97, 95, 93, 92, 90, 89, 87, 85, 84, 82, 81, 79, 78, 76, 74, 73, 72, 70, 68, - 67, 66, 64, 62, 61, 60, 58, 57, 55, 54, 53, 51, 50, 48, 47, 46, 44, 43, 42, 40, 39, 38, 36, 35, 34, 33, 32, 30, 29, - 27, 26, 25, 24, 23, 22, 21, 20, 19, 16, 15, 14, 13, 12, 11, 10, 9, 8, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 43, 44, - 46, 47, 48, 50, 51, 53, 54, 55, 57, 58, 60, 61, 62, 64, 66, 67, 68, 70, 72, 73, 74, 76, 78, 79, 81, 82, 84, 85, 87, - 89, 90, 92, 93, 95, 97, 98, 101, 102, 103, 106, 107, 108, 111, 112, 115, 116, 117, 120, 121, 124, 125, 128, 129, - 132, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 158, 159, 162, 163, 166, 168, 170, 173, 174, 177, - 180, 181, 184, 187, 188, 191, 194, 195, 198, 201, 204, 205, 208, 211, 214, 215, 218, 221, 224, 227, 230, 231, 234, - 237, 240, 243, 246, 249, 251, 254, 257, 260, 263, 266, 269, 272, 275, 278, 281, 284, 288, 291, 294, 297, 302, 305, - 308, 311, 315, 318, 321, 324, 329, 333, 336, 339, 344, 347, 351, 354, 359, 363, 366, 371, 374, 378, 383, 387, 390, - 395, 399, 404, 408, 413, 416, 422, 425, 431, 434, 440, 443, 449, 454, 458, 464, 469, 473, 479, 484, 488, 494, 499, - 505, 509, 515, 521, 527, 532, 538, 544, 550, 556, 562, 568, 574, 581, 587, 593, 599, 605, 611, 618, 626, 633, 639, - 645, 654, 660, 667, 676, 682, 689, 698, 704, 713, 720, 729, 736, 745, 754, 761, 770, 780, 787, 796, 806, 815, 823, - 832, 842, 852, 862, 871, 881, 891, 901, 912, 922, 935, 945, 955, 966, 979, 989, 1000, 1013, 1024, 1038, 1049, 1062, - 1073, 1087, 1101, 1115, 1127, 1141, 1155, 1170, 1184, 1199, 1214, 1229, 1244, 1259, 1274, 1292, 1308, 1323, 1342, - 1358, 1373, 1392, 1412, 1428, 1448, 1467, 1487, 1504, 1524, 1544, 1565, 1586, 1610, 1631, 1652, 1673, 1698, 1720, - 1746, 1768, 1794, 1820, 1842, 1869, 1896, 1923, 1950, 1977, 2009, 2037, 2065, 2098, 2127, 2160, 2193, 2223, 2257, - 2291, 2326, 2361, 2401, 2437, 2472, 2512, 2552, 2588, 2628, 2668, 2708, 2748, 2788, 2832, 2872, 2917, 2957, 3001, - 3045, 3090, 3134, 3183, 3228, 3277, 3321, 3370, 3419, 3468, 3521, 3570, 3623, 3672, 3725, 3779, 3836, 3890, 3943, - 4001, 4059, 4116, 4174, 4236, 4299, 4356, 4423, 4485, 4547, 4614, 4681, 4747, 4814, 4885, 4956, 5027, 5103, 5174, - 5250, 5325, 5405, 5481, 5565, 5645, 5730, 5814, 5898, 5987, 6076, 6165, 6258, 6352, 6445, 6543, 6640, 6743, 6845, - 6952, 7058, 7165, 7276, 7387, 7503, 7623, 7743, 7867, 7991, 8116, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191 + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191 }}; disp_pt_lut_ = {{ 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8117, 7880, - 7657, 7444, 7243, 7050, 6868, 6692, 6527, 6367, 6216, 6070, 5930, 5796, 5668, 5544, 5425, 5311, 5202, 5095, 4993, - 4894, 4799, 4707, 4618, 4532, 4449, 4368, 4290, 4214, 4141, 4070, 4001, 3933, 3868, 3805, 3744, 3683, 3625, 3568, - 3513, 3459, 3407, 3356, 3306, 3257, 3210, 3163, 3119, 3074, 3031, 2989, 2948, 2908, 2869, 2831, 2792, 2756, 2720, - 2684, 2650, 2617, 2583, 2551, 2518, 2487, 2457, 2427, 2398, 2369, 2341, 2313, 2285, 2259, 2232, 2207, 2182, 2157, - 2133, 2109, 2085, 2062, 2039, 2016, 1995, 1972, 1951, 1930, 1909, 1889, 1870, 1849, 1830, 1811, 1792, 1774, 1756, - 1738, 1720, 1703, 1686, 1668, 1652, 1635, 1619, 1603, 1587, 1572, 1556, 1542, 1527, 1512, 1497, 1483, 1470, 1455, - 1442, 1428, 1414, 1401, 1388, 1376, 1363, 1351, 1338, 1326, 1314, 1302, 1289, 1279, 1267, 1256, 1244, 1233, 1222, - 1211, 1201, 1190, 1180, 1169, 1159, 1149, 1139, 1129, 1119, 1109, 1100, 1090, 1082, 1072, 1062, 1054, 1044, 1036, - 1028, 1018, 1010, 1001, 993, 984, 976, 969, 960, 952, 945, 936, 929, 921, 914, 906, 899, 891, 883, 876, 869, 862, - 856, 849, 841, 834, 828, 821, 814, 808, 802, 795, 789, 783, 775, 769, 763, 757, 751, 745, 739, 733, 727, 721, 715, - 711, 705, 699, 693, 688, 682, 677, 671, 666, 660, 655, 650, 644, 640, 635, 630, 624, 619, 614, 610, 605, 600, 595, - 590, 586, 581, 576, 572, 568, 563, 558, 554, 550, 545, 541, 536, 532, 528, 523, 520, 515, 511, 506, 503, 499, 494, - 491, 487, 482, 479, 475, 471, 467, 463, 459, 456, 452, 449, 445, 441, 438, 434, 431, 427, 423, 420, 416, 413, 409, - 405, 402, 399, 396, 392, 389, 386, 383, 379, 377, 373, 369, 367, 363, 360, 357, 354, 351, 348, 346, 342, 340, 336, - 334, 330, 328, 324, 322, 320, 316, 314, 312, 308, 306, 304, 300, 298, 295, 293, 290, 287, 285, 283, 279, 277, 275, - 273, 270, 268, 266, 263, 260, 258, 255, 253, 251, 249, 246, 244, 242, 240, 237, 235, 233, 231, 228, 226, 225, 223, - 220, 218, 216, 214, 211, 210, 208, 206, 204, 201, 199, 198, 196, 193, 191, 190, 188, 186, 183, 182, 180, 178, 177, - 174, 172, 171, 169, 166, 165, 163, 161, 160, 157, 156, 154, 153, 151, 148, 147, 145, 144, 142, 140, 138, 137, 135, - 134, 131, 130, 128, 127, 125, 123, 121, 120, 118, 117, 115, 113, 112, 110, 109, 107, 105, 104, 103, 101, 99, 97, 96, - 95, 92, 91, 90, 88, 87, 86, 84, 82, 81, 80, 77, 76, 75, 74, 72, 70, 69, 68, 66, 65, 63, 62, 61, 59, 58, 56, 55, 54, - 52, 50, 49, 48, 47, 46, 43, 42, 41, 40, 39, 37, 36, 35, 33, 31, 30, 29, 28, 27, 25, 24, 23, 22, 21, 18, 17, 16, 15, - 13, 12, 11, 10, 9, 7, 6, 5, 4, 2, 1, 0, 1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 16, 17, 18, 21, 22, 23, 24, 25, 27, - 28, 29, 30, 31, 33, 35, 36, 37, 39, 40, 41, 42, 43, 46, 47, 48, 49, 50, 52, 54, 55, 56, 58, 59, 61, 62, 63, 65, 66, - 68, 69, 70, 72, 74, 75, 76, 77, 80, 81, 82, 84, 86, 87, 88, 90, 91, 92, 95, 96, 97, 99, 101, 103, 104, 105, 107, - 109, 110, 112, 113, 115, 117, 118, 120, 121, 123, 125, 127, 128, 130, 131, 134, 135, 137, 138, 140, 142, 144, 145, - 147, 148, 151, 153, 154, 156, 157, 160, 161, 163, 165, 166, 169, 171, 172, 174, 177, 178, 180, 182, 183, 186, 188, - 190, 191, 193, 196, 198, 199, 201, 204, 206, 208, 210, 211, 214, 216, 218, 220, 223, 225, 226, 228, 231, 233, 235, - 237, 240, 242, 244, 246, 249, 251, 253, 255, 258, 260, 263, 266, 268, 270, 273, 275, 277, 279, 283, 285, 287, 290, - 293, 295, 298, 300, 304, 306, 308, 312, 314, 316, 320, 322, 324, 328, 330, 334, 336, 340, 342, 346, 348, 351, 354, - 357, 360, 363, 367, 369, 373, 377, 379, 383, 386, 389, 392, 396, 399, 402, 405, 409, 413, 416, 420, 423, 427, 431, - 434, 438, 441, 445, 449, 452, 456, 459, 463, 467, 471, 475, 479, 482, 487, 491, 494, 499, 503, 506, 511, 515, 520, - 523, 528, 532, 536, 541, 545, 550, 554, 558, 563, 568, 572, 576, 581, 586, 590, 595, 600, 605, 610, 614, 619, 624, - 630, 635, 640, 644, 650, 655, 660, 666, 671, 677, 682, 688, 693, 699, 705, 711, 715, 721, 727, 733, 739, 745, 751, - 757, 763, 769, 775, 783, 789, 795, 802, 808, 814, 821, 828, 834, 841, 849, 856, 862, 869, 876, 883, 891, 899, 906, - 914, 921, 929, 936, 945, 952, 960, 969, 976, 984, 993, 1001, 1010, 1018, 1028, 1036, 1044, 1054, 1062, 1072, 1082, - 1090, 1100, 1109, 1119, 1129, 1139, 1149, 1159, 1169, 1180, 1190, 1201, 1211, 1222, 1233, 1244, 1256, 1267, 1279, - 1289, 1302, 1314, 1326, 1338, 1351, 1363, 1376, 1388, 1401, 1414, 1428, 1442, 1455, 1470, 1483, 1497, 1512, 1527, - 1542, 1556, 1572, 1587, 1603, 1619, 1635, 1652, 1668, 1686, 1703, 1720, 1738, 1756, 1774, 1792, 1811, 1830, 1849, - 1870, 1889, 1909, 1930, 1951, 1972, 1995, 2016, 2039, 2062, 2085, 2109, 2133, 2157, 2182, 2207, 2232, 2259, 2285, - 2313, 2341, 2369, 2398, 2427, 2457, 2487, 2518, 2551, 2583, 2617, 2650, 2684, 2720, 2756, 2792, 2831, 2869, 2908, - 2948, 2989, 3031, 3074, 3119, 3163, 3210, 3257, 3306, 3356, 3407, 3459, 3513, 3568, 3625, 3683, 3744, 3805, 3868, - 3933, 4001, 4070, 4141, 4214, 4290, 4368, 4449, 4532, 4618, 4707, 4799, 4894, 4993, 5095, 5202, 5311, 5425, 5544, - 5668, 5796, 5930, 6070, 6216, 6367, 6527, 6692, 6868, 7050, 7243, 7444, 7657, 7880, 8117, 8191, 8191, 8191, 8191, + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8187, + 7954, 7733, 7522, 7322, 7132, 6949, 6777, 6610, 6453, 6301, 6155, 6016, 5882, 5753, 5629, 5511, 5397, 5285, 5179, + 5076, 4978, 4881, 4789, 4699, 4612, 4528, 4447, 4368, 4292, 4218, 4146, 4075, 4008, 3942, 3878, 3815, 3754, 3695, + 3638, 3581, 3527, 3474, 3422, 3371, 3322, 3274, 3227, 3181, 3136, 3092, 3050, 3007, 2967, 2927, 2887, 2849, 2812, + 2774, 2739, 2704, 2669, 2635, 2602, 2569, 2538, 2507, 2477, 2446, 2416, 2388, 2359, 2331, 2304, 2278, 2251, 2225, + 2200, 2175, 2150, 2126, 2102, 2079, 2056, 2032, 2011, 1989, 1967, 1946, 1926, 1905, 1885, 1865, 1845, 1826, 1807, + 1788, 1770, 1752, 1735, 1716, 1700, 1682, 1665, 1648, 1632, 1616, 1599, 1584, 1569, 1553, 1538, 1523, 1509, 1494, + 1481, 1466, 1452, 1438, 1424, 1412, 1398, 1386, 1372, 1359, 1347, 1334, 1322, 1310, 1298, 1287, 1274, 1263, 1252, + 1240, 1229, 1218, 1208, 1197, 1185, 1175, 1165, 1154, 1144, 1134, 1124, 1114, 1105, 1095, 1085, 1076, 1066, 1058, + 1049, 1039, 1030, 1021, 1013, 1004, 995, 988, 979, 970, 963, 954, 946, 938, 930, 923, 915, 906, 899, 891, 884, 876, + 870, 863, 855, 848, 841, 834, 826, 820, 814, 806, 800, 794, 786, 780, 774, 767, 761, 755, 749, 742, 736, 730, 724, + 719, 712, 706, 700, 695, 689, 684, 677, 672, 666, 661, 656, 650, 645, 640, 635, 629, 624, 619, 614, 609, 604, 599, + 594, 589, 584, 579, 575, 570, 565, 560, 556, 551, 546, 542, 537, 532, 528, 523, 520, 515, 511, 506, 502, 498, 493, + 490, 486, 481, 477, 473, 470, 465, 461, 457, 453, 450, 446, 442, 438, 435, 431, 427, 423, 420, 416, 412, 408, 405, + 401, 397, 395, 391, 387, 383, 381, 377, 373, 371, 367, 363, 361, 357, 353, 351, 347, 345, 341, 338, 335, 332, 329, + 326, 322, 320, 316, 314, 311, 308, 305, 303, 299, 297, 294, 291, 288, 286, 284, 280, 278, 275, 273, 269, 267, 264, + 262, 260, 257, 255, 252, 249, 247, 244, 242, 239, 237, 235, 232, 230, 228, 225, 223, 221, 218, 216, 214, 213, 210, + 208, 206, 203, 201, 199, 198, 195, 193, 191, 188, 186, 185, 183, 180, 178, 177, 175, 172, 170, 169, 167, 164, 163, + 161, 159, 158, 155, 153, 152, 150, 148, 146, 144, 143, 141, 140, 138, 135, 134, 132, 131, 129, 128, 125, 124, 122, + 121, 119, 118, 115, 114, 112, 111, 109, 108, 106, 104, 103, 101, 100, 98, 97, 96, 94, 93, 91, 89, 88, 86, 85, 84, + 82, 81, 80, 77, 76, 75, 74, 72, 71, 70, 68, 67, 66, 65, 62, 61, 60, 59, 57, 56, 55, 54, 53, 51, 50, 49, 48, 47, 45, + 43, 42, 41, 40, 39, 37, 36, 35, 34, 33, 32, 31, 30, 28, 27, 26, 25, 24, 23, 22, 21, 20, 18, 17, 15, 14, 13, 12, 11, + 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 45, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, + 61, 62, 65, 66, 67, 68, 70, 71, 72, 74, 75, 76, 77, 80, 81, 82, 84, 85, 86, 88, 89, 91, 93, 94, 96, 97, 98, 100, + 101, 103, 104, 106, 108, 109, 111, 112, 114, 115, 118, 119, 121, 122, 124, 125, 128, 129, 131, 132, 134, 135, 138, + 140, 141, 143, 144, 146, 148, 150, 152, 153, 155, 158, 159, 161, 163, 164, 167, 169, 170, 172, 175, 177, 178, 180, + 183, 185, 186, 188, 191, 193, 195, 198, 199, 201, 203, 206, 208, 210, 213, 214, 216, 218, 221, 223, 225, 228, 230, + 232, 235, 237, 239, 242, 244, 247, 249, 252, 255, 257, 260, 262, 264, 267, 269, 273, 275, 278, 280, 284, 286, 288, + 291, 294, 297, 299, 303, 305, 308, 311, 314, 316, 320, 322, 326, 329, 332, 335, 338, 341, 345, 347, 351, 353, 357, + 361, 363, 367, 371, 373, 377, 381, 383, 387, 391, 395, 397, 401, 405, 408, 412, 416, 420, 423, 427, 431, 435, 438, + 442, 446, 450, 453, 457, 461, 465, 470, 473, 477, 481, 486, 490, 493, 498, 502, 506, 511, 515, 520, 523, 528, 532, + 537, 542, 546, 551, 556, 560, 565, 570, 575, 579, 584, 589, 594, 599, 604, 609, 614, 619, 624, 629, 635, 640, 645, + 650, 656, 661, 666, 672, 677, 684, 689, 695, 700, 706, 712, 719, 724, 730, 736, 742, 749, 755, 761, 767, 774, 780, + 786, 794, 800, 806, 814, 820, 826, 834, 841, 848, 855, 863, 870, 876, 884, 891, 899, 906, 915, 923, 930, 938, 946, + 954, 963, 970, 979, 988, 995, 1004, 1013, 1021, 1030, 1039, 1049, 1058, 1066, 1076, 1085, 1095, 1105, 1114, 1124, + 1134, 1144, 1154, 1165, 1175, 1185, 1197, 1208, 1218, 1229, 1240, 1252, 1263, 1274, 1287, 1298, 1310, 1322, 1334, + 1347, 1359, 1372, 1386, 1398, 1412, 1424, 1438, 1452, 1466, 1481, 1494, 1509, 1523, 1538, 1553, 1569, 1584, 1599, + 1616, 1632, 1648, 1665, 1682, 1700, 1716, 1735, 1752, 1770, 1788, 1807, 1826, 1845, 1865, 1885, 1905, 1926, 1946, + 1967, 1989, 2011, 2032, 2056, 2079, 2102, 2126, 2150, 2175, 2200, 2225, 2251, 2278, 2304, 2331, 2359, 2388, 2416, + 2446, 2477, 2507, 2538, 2569, 2602, 2635, 2669, 2704, 2739, 2774, 2812, 2849, 2887, 2927, 2967, 3007, 3050, 3092, + 3136, 3181, 3227, 3274, 3322, 3371, 3422, 3474, 3527, 3581, 3638, 3695, 3754, 3815, 3878, 3942, 4008, 4075, 4146, + 4218, 4292, 4368, 4447, 4528, 4612, 4699, 4789, 4881, 4978, 5076, 5179, 5285, 5397, 5511, 5629, 5753, 5882, 6016, + 6155, 6301, 6453, 6610, 6777, 6949, 7132, 7322, 7522, 7733, 7954, 8187, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, - 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191 + 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191, 8191 }}; rels_lut_ = {{ @@ -150,11 +150,11 @@ ActivationLut::ActivationLut() { }}; dxy_lut_ = {{ - 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 6, 6, 6, 6, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, - 12, 12, 13, 13, 13, 13, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 21, 21, 21, 21, - 22, 22, 22, 22, 23, 23, 23, 23, 25, 25, 25, 25, 27, 27, 27, 28, 28, 28, 28, 30, 30, 30, 30, 32, 32, 32, 32, 35, 35, - 35, 35, 37, 37, 37, 37, 40, 40, 40, 40, 43, 43, 43, 46, 46, 46, 46, 49, 49, 49, 49, 53, 53, 53, 53, 56, 56, 56, 56, - 60, 60, 60, 60, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 0, 0, 2, 2, 2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 10, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, + 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 22, 22, 22, + 22, 24, 24, 24, 24, 26, 26, 26, 26, 28, 28, 28, 28, 30, 30, 30, 33, 33, 33, 33, 36, 36, 36, 36, 39, 39, 39, 39, 43, + 43, 43, 43, 47, 47, 47, 47, 51, 51, 51, 51, 56, 56, 56, 62, 62, 62, 62, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, @@ -167,7 +167,8 @@ ActivationLut::ActivationLut() { 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, + -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, @@ -184,12 +185,11 @@ ActivationLut::ActivationLut() { -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, -64, - -64, -64, -64, -64, -64, -64, -60, -60, -60, -60, -56, -56, -56, -56, -53, -53, -53, -53, -49, -49, -49, -49, -46, - -46, -46, -46, -43, -43, -43, -40, -40, -40, -40, -37, -37, -37, -37, -35, -35, -35, -35, -32, -32, -32, -32, -30, - -30, -30, -30, -28, -28, -28, -28, -27, -27, -27, -25, -25, -25, -25, -23, -23, -23, -23, -22, -22, -22, -22, -21, - -21, -21, -21, -19, -19, -19, -19, -18, -18, -18, -18, -17, -17, -17, -16, -16, -16, -16, -15, -15, -15, -15, -13, - -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11, -10, -10, -10, -9, -9, -9, -9, -8, -8, -8, -8, -6, -6, -6, - -6, -5, -5, -5, -5, -3, -3, -3, -3, -2, -2, -2, -2, 0 + -62, -62, -62, -62, -56, -56, -56, -51, -51, -51, -51, -47, -47, -47, -47, -43, -43, -43, -43, -39, -39, -39, -39, + -36, -36, -36, -36, -33, -33, -33, -33, -30, -30, -30, -28, -28, -28, -28, -26, -26, -26, -26, -24, -24, -24, -24, + -22, -22, -22, -22, -20, -20, -20, -20, -19, -19, -19, -19, -18, -18, -18, -16, -16, -16, -16, -15, -15, -15, -15, + -14, -14, -14, -14, -13, -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -10, -10, -10, -10, -8, -8, -8, -8, -7, + -7, -7, -7, -6, -6, -6, -6, -4, -4, -4, -4, -2, -2, -2, -2, 0 }}; // clang-format on } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc index 1149fb743be8f..ea4aed5d12d5f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc @@ -50,9 +50,9 @@ int TimeZoneLut::get_timezones(const int& host, const int& bx) const { // Build word int word = 0x0; - word |= in_range(found->second, bx) ? 0x01 : 0; - word |= in_range(found->second, bx + 1) ? 0x02 : 0; // +1 BX delay - word |= in_range(found->second, bx + 2) ? 0x04 : 0; // +2 BX delay + word |= in_range(found->second, bx) ? 0b001 : 0; + word |= in_range(found->second, bx + 1) ? 0b010 : 0; // +1 BX delay + word |= in_range(found->second, bx + 2) ? 0b100 : 0; // +2 BX delay return word; } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc index e61546b8ca86c..776693657eecf 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc @@ -32,27 +32,27 @@ SectorProcessor::SectorProcessor(const EMTFContext& context, const int& endcap, // =========================================================================== // Register Selectors/Converters // =========================================================================== - if (CONFIG.csc_en_) { + if (this->context_.config_.csc_en_) { tp_selectors_[L1TMuon::kCSC] = std::make_unique(context_, endcap_, sector_); tp_converters_[L1TMuon::kCSC] = std::make_unique(context_, endcap_, sector_); } - if (CONFIG.rpc_en_) { + if (this->context_.config_.rpc_en_) { tp_selectors_[L1TMuon::kRPC] = std::make_unique(context_, endcap_, sector_); tp_converters_[L1TMuon::kRPC] = std::make_unique(context_, endcap_, sector_); } - if (CONFIG.gem_en_) { + if (this->context_.config_.gem_en_) { tp_selectors_[L1TMuon::kGEM] = std::make_unique(context_, endcap_, sector_); tp_converters_[L1TMuon::kGEM] = std::make_unique(context_, endcap_, sector_); } - if (CONFIG.me0_en_) { + if (this->context_.config_.me0_en_) { tp_selectors_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); tp_converters_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); } - if (CONFIG.ge0_en_) { + if (this->context_.config_.ge0_en_) { tp_selectors_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); tp_converters_[L1TMuon::kME0] = std::make_unique(context_, endcap_, sector_); } @@ -81,8 +81,8 @@ void SectorProcessor::configure_bx(const int& bx) { // Remove BX TPCollections that aren't in the bx window // Note that the first entry in bx_window_hits is the earliest BX - const auto min_bx = CONFIG.min_bx_; - const auto delay_bx = CONFIG.bx_window_ - 1; + const auto min_bx = this->context_.config_.min_bx_; + const auto delay_bx = this->context_.config_.bx_window_ - 1; const auto pop_after_bx = min_bx + delay_bx; if (pop_after_bx < bx) { @@ -98,8 +98,8 @@ void SectorProcessor::select(const TriggerPrimitive& tp, const TPInfo& tp_info) // Short-Circuit: Operation not supported if (tp_selectors_it == tp_selectors_.end()) { - edm::LogWarning("L1T") << "TPCollector has been implemented, " - << "but there is no TPSelector for " << tp_subsystem; + edm::LogWarning("L1T EMTF++") << "TPCollector has been implemented, " + << "but there is no TPSelector for " << tp_subsystem; return; } @@ -233,8 +233,8 @@ void SectorProcessor::convert_tp(const int& initial_hit_id, const ILinkTPCMap& i // Short-Circuit: Operation not supported if (tp_converters_it == tp_converters_.end()) { - edm::LogWarning("L1T") << "TPCollector & TPSelector have been implemented, " - << "but there is no TPConverter for " << tp_subsystem; + edm::LogWarning("L1T EMTF++") << "TPCollector & TPSelector have been implemented, " + << "but there is no TPConverter for " << tp_subsystem; continue; } @@ -353,18 +353,20 @@ void SectorProcessor::populate_segments(const std::vector& bx segments[seg_id].valid = hit.flagValid(); // Debug Info - if (CONFIG.verbosity_ > 1) { - std::cout << std::endl - << "Event: " << event_->id() << " Endcap: " << endcap_ << " Sector: " << sector_ << " BX: " << (*bx_) - << " Hit iLink: " << hit_chamber << " Hit iSeg: " << ch_seg << " Hit Host " << hit_host - << " Hit Rel BX " << (hit_bx - *bx_) << " Hit Timezones " << hit_timezones << std::endl; - - std::cout << " id " << seg_id << " phi " << segments[seg_id].phi << " bend " << segments[seg_id].bend - << " theta1 " << segments[seg_id].theta1 << " theta2 " << segments[seg_id].theta2 << " qual1 " - << segments[seg_id].qual1 << " qual2 " << segments[seg_id].qual2 << " time " << segments[seg_id].time - << " zones " << segments[seg_id].zones << " timezones " << segments[seg_id].tzones << " cscfr " - << segments[seg_id].cscfr << " layer " << segments[seg_id].layer << " bx " << segments[seg_id].bx - << " valid " << segments[seg_id].valid << std::endl; + if (this->context_.config_.verbosity_ > 1) { + edm::LogInfo("L1T EMTF++") << std::endl + << "Event: " << event_->id() << " Endcap: " << endcap_ << " Sector: " << sector_ + << " BX: " << (*bx_) << " Hit iLink: " << hit_chamber << " Hit iSeg: " << ch_seg + << " Hit Host " << hit_host << " Hit Rel BX " << (hit_bx - *bx_) << " Hit Timezones " + << hit_timezones << std::endl; + + edm::LogInfo("L1T EMTF++") << " id " << seg_id << " phi " << segments[seg_id].phi << " bend " + << segments[seg_id].bend << " theta1 " << segments[seg_id].theta1 << " theta2 " + << segments[seg_id].theta2 << " qual1 " << segments[seg_id].qual1 << " qual2 " + << segments[seg_id].qual2 << " time " << segments[seg_id].time << " zones " + << segments[seg_id].zones << " timezones " << segments[seg_id].tzones << " cscfr " + << segments[seg_id].cscfr << " layer " << segments[seg_id].layer << " bx " + << segments[seg_id].bx << " valid " << segments[seg_id].valid << std::endl; } // Update bx chamber last segment diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc index e946305a8075f..3506d1ba81635 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc @@ -6,6 +6,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" @@ -31,23 +32,23 @@ TrackFinder::TrackFinder(const edm::ParameterSet& i_config, edm::ConsumesCollect // =========================================================================== // Register Trigger Primitives - if (CONFIG.csc_en_) { + if (this->context_.config_.csc_en_) { tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); } - if (CONFIG.rpc_en_) { + if (this->context_.config_.rpc_en_) { tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); } - if (CONFIG.gem_en_) { + if (this->context_.config_.gem_en_) { tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); } - if (CONFIG.me0_en_) { + if (this->context_.config_.me0_en_) { tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); } - if (CONFIG.ge0_en_) { + if (this->context_.config_.ge0_en_) { tp_collectors_.push_back(std::make_unique(context_, i_consumes_collector)); } @@ -93,9 +94,9 @@ void TrackFinder::process( std::vector bx_sequence; { - auto min_bx = CONFIG.min_bx_; - auto delay_bx = CONFIG.bx_window_ - 1; - auto max_bx = CONFIG.max_bx_ + delay_bx; + auto min_bx = this->context_.config_.min_bx_; + auto delay_bx = this->context_.config_.bx_window_ - 1; + auto max_bx = this->context_.config_.max_bx_ + delay_bx; for (int bx = min_bx; bx <= max_bx; ++bx) { bx_sequence.push_back(bx); @@ -110,7 +111,7 @@ void TrackFinder::process( } // Debug Info - if (CONFIG.verbosity_ > 4) { + if (this->context_.config_.verbosity_ > 4) { int n_tp = 0; // Loop BX @@ -133,26 +134,31 @@ void TrackFinder::process( } // Print trigger primitives - std::cout << "===========================================================================" << std::endl; - std::cout << "Begin TPC BX " << bx << " Dump" << std::endl; - std::cout << "---------------------------------------------------------------------------" << std::endl; + edm::LogInfo("L1T EMTF++") << "===========================================================================" + << std::endl; + edm::LogInfo("L1T EMTF++") << "Begin TPC BX " << bx << " Dump" << std::endl; + edm::LogInfo("L1T EMTF++") << "---------------------------------------------------------------------------" + << std::endl; n_tp += bx_tpc.size(); for (const auto& tp_entry : bx_tpc) { tp_entry.tp_.print(std::cout); - std::cout << "---------------------------------------------------------------------------" << std::endl; + edm::LogInfo("L1T EMTF++") << "---------------------------------------------------------------------------" + << std::endl; } - std::cout << "End TPC BX " << bx << " Dump" << std::endl; - std::cout << "===========================================================================" << std::endl; + edm::LogInfo("L1T EMTF++") << "End TPC BX " << bx << " Dump" << std::endl; + edm::LogInfo("L1T EMTF++") << "===========================================================================" + << std::endl; } // Print TPrimitives Summary if (n_tp > 0) { - std::cout << "Num of TriggerPrimitive: " << n_tp << std::endl; - std::cout << "===========================================================================" << std::endl; + edm::LogInfo("L1T EMTF++") << "Num of TriggerPrimitive: " << n_tp << std::endl; + edm::LogInfo("L1T EMTF++") << "===========================================================================" + << std::endl; } } From f1fcba23a441d159d9e79ce7fa27bb999de1f515 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Tue, 16 Jan 2024 07:55:01 +0100 Subject: [PATCH 09/24] Removed unnecessary files. Files are no longer being used, and are no longer needed in the emulator. --- .../interface/Utils/IteratorUtils.h | 279 ------------------ .../interface/Utils/TemplateUtils.h | 25 -- .../L1TMuonEndCapPhase2/scripts/msort.py | 163 ---------- 3 files changed, 467 deletions(-) delete mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h delete mode 100644 L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h delete mode 100644 L1Trigger/L1TMuonEndCapPhase2/scripts/msort.py diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h deleted file mode 100644 index 6e779f94a913a..0000000000000 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/IteratorUtils.h +++ /dev/null @@ -1,279 +0,0 @@ -#include -#include -#include -#include -#include -#include - -// Return an integer as a hex string -template -std::string to_hex(INT i) { - std::stringstream s; - s << "0x" << std::hex << i; - return s.str(); -} - -// Return an integer as a binary string -template -std::string to_binary(INT i, int n) { - std::stringstream s; - if (sizeof(i) <= 4) { - std::bitset<32> b(i); - s << "0b" << b.to_string().substr(32 - n, 32); - } else if (sizeof(i) <= 8) { - std::bitset<64> b(i); - s << "0b" << b.to_string().substr(64 - n, 64); - } - return s.str(); -} - -// Return the size of a 1D plain array -template -constexpr size_t array_size(T (&)[N]) { - return N; -} - -// Return the elements of a 1D plain array as a string (elements are separated by ' ') -template -std::string array_as_string(const T (&arr)[N]) { - std::stringstream s; - const char* sep = ""; - for (size_t i = 0; i < N; ++i) { - s << sep << arr[i]; - sep = " "; - } - return s.str(); -} - -// This function allows one to loop over a container in reversed order using C++11 for(auto ...) loop -// e.g. -// for (auto x: reversed(v)) { -// // do something -// } -// See http://stackoverflow.com/a/21510185 -namespace details { - template - struct _reversed { - T& t; - _reversed(T& _t) : t(_t) {} - decltype(t.rbegin()) begin() { return t.rbegin(); } - decltype(t.rend()) end() { return t.rend(); } - }; -} // namespace details -template -details::_reversed reversed(T& t) { - return details::_reversed(t); -} - -// Split a string by delimiters (default: ' ') into a vector of string -// See http://stackoverflow.com/a/53878 -template -std::vector split_string(const std::string& s, char c = ' ', char d = ' ') { - std::vector result; - const char* str = s.c_str(); - do { - const char* begin = str; - while (*str != c && *str != d && *str) - str++; - result.emplace_back(begin, str); - } while (0 != *str++); - return result; -} - -// Flatten a vector > into a vector -// The input type T can be different from the output type T -template -void flatten_container(const T1& input, T2& output) { - typename T1::const_iterator it; - for (it = input.begin(); it != input.end(); ++it) { - output.insert(output.end(), it->begin(), it->end()); - } -} - -// Check type for map of vector -template -struct is_map_of_vectors : public std::false_type {}; - -template -struct is_map_of_vectors > > : public std::true_type {}; - -// Merge a map of vectors (map1) into another map of vectors (map2) -template -void merge_map_into_map(const Map& map1, Map& map2) { - // This is customized for maps of containers. - typedef typename Map::iterator Iterator; - typedef typename Map::mapped_type Container; - - for (auto& kv1 : map1) { - std::pair ins = map2.insert(kv1); - if (!ins.second) { // if insertion into map2 was not successful - if (is_map_of_vectors::value) { // special case for map of vectors - const Container* container1 = &(kv1.second); - Container* container2 = &(ins.first->second); - container2->insert(container2->end(), container1->begin(), container1->end()); - } // else do nothing - } - } -} - -// A simple nearest-neighbor clustering algorithm -// It iterates through a sorted container once, whenever the 'adjacent' -// comparison between two elements evaluates to true, the 'cluster' -// operator is called to merge them. -template -ForwardIt adjacent_cluster(ForwardIt first, ForwardIt last, BinaryPredicate adjacent, BinaryOp cluster) { - if (first == last) - return last; - - ForwardIt result = first; - while (++first != last) { - if (!adjacent(*result, *first)) { - *++result = std::move(*first); - } else { - cluster(*result, *first); - } - } - return ++result; -} - -// Textbook merge sort algorithm with the same interface as std::sort() -// An internal buffer of the same size as the container is used internally. -template > -void merge_sort_merge(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare cmp) { - const std::ptrdiff_t len = std::distance(first, last); - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::pointer pointer; - std::pair p = std::get_temporary_buffer(len); - pointer buf = p.first; - pointer buf_end = std::next(p.first, p.second); - - RandomAccessIterator first1 = first; - RandomAccessIterator last1 = middle; - RandomAccessIterator first2 = middle; - RandomAccessIterator last2 = last; - - while (first1 != last1 && first2 != last2) { - if (cmp(*first2, *first1)) { - *buf++ = *first2++; - } else { - *buf++ = *first1++; - } - } - while (first1 != last1) { - *buf++ = *first1++; - } - while (first2 != last2) { - *buf++ = *first2++; - } - - buf = p.first; - std::copy(buf, buf_end, first); - std::return_temporary_buffer(p.first); -} - -// See above -template > -void merge_sort(RandomAccessIterator first, RandomAccessIterator last, Compare cmp) { - const std::ptrdiff_t len = std::distance(first, last); - if (len > 1) { - RandomAccessIterator middle = std::next(first, len / 2); - merge_sort(first, middle, cmp); - merge_sort(middle, last, cmp); - merge_sort_merge(first, middle, last, cmp); - } -} - -// An extended version of the merge sort algorithm to incorporate a 3-way -// comparator. It resorts back to 2-way comparator when one of the three -// lists to be merged is empty. -template -void merge_sort_merge3(RandomAccessIterator first, - RandomAccessIterator one_third, - RandomAccessIterator two_third, - RandomAccessIterator last, - Compare cmp, - Compare3 cmp3) { - const std::ptrdiff_t len = std::distance(first, last); - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::pointer pointer; - std::pair p = std::get_temporary_buffer(len); - pointer buf = p.first; - pointer buf_end = std::next(p.first, p.second); - - RandomAccessIterator first1 = first; - RandomAccessIterator last1 = one_third; - RandomAccessIterator first2 = one_third; - RandomAccessIterator last2 = two_third; - RandomAccessIterator first3 = two_third; - RandomAccessIterator last3 = last; - - while (first1 != last1 && first2 != last2 && first3 != last3) { - int rr = cmp3(*first1, *first2, *first3); - if (rr == 0) { - *buf++ = *first1++; - } else if (rr == 1) { - *buf++ = *first2++; - } else if (rr == 2) { - *buf++ = *first3++; - } - } - - if (first3 == last3) { - // do nothing - } else if (first2 == last2) { - first2 = first3; - last2 = last3; - } else if (first1 == last1) { - first1 = first2; - last1 = last2; - first2 = first3; - last2 = last3; - } - - while (first1 != last1 && first2 != last2) { - if (cmp(*first2, *first1)) { - *buf++ = *first2++; - } else { - *buf++ = *first1++; - } - } - while (first1 != last1) { - *buf++ = *first1++; - } - while (first2 != last2) { - *buf++ = *first2++; - } - - buf = p.first; - std::copy(buf, buf_end, first); - std::return_temporary_buffer(p.first); -} - -// See above -template -void merge_sort3(RandomAccessIterator first, RandomAccessIterator last, Compare cmp, Compare3 cmp3) { - const std::ptrdiff_t len = std::distance(first, last); - if (len > 1) { - RandomAccessIterator one_third = std::next(first, (len + 2) / 3); - RandomAccessIterator two_third = std::next(first, (len + 2) / 3 * 2); - merge_sort3(first, one_third, cmp, cmp3); - merge_sort3(one_third, two_third, cmp, cmp3); - merge_sort3(two_third, last, cmp, cmp3); - merge_sort_merge3(first, one_third, two_third, last, cmp, cmp3); - } -} - -// See above. 'Hint' is provided to force the very first division. This is needed to match FW. -template -void merge_sort3_with_hint( - RandomAccessIterator first, RandomAccessIterator last, Compare cmp, Compare3 cmp3, std::ptrdiff_t d) { - const std::ptrdiff_t len = std::distance(first, last); - if (len > 1) { - RandomAccessIterator one_third = std::next(first, d); - RandomAccessIterator two_third = std::next(first, d * 2); - merge_sort3(first, one_third, cmp, cmp3); - merge_sort3(one_third, two_third, cmp, cmp3); - merge_sort3(two_third, last, cmp, cmp3); - merge_sort_merge3(first, one_third, two_third, last, cmp, cmp3); - } -} diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h deleted file mode 100644 index 44547b4912065..0000000000000 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TemplateUtils.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef L1Trigger_L1TMuonEndCapPhase2_TemplateUtils_h -#define L1Trigger_L1TMuonEndCapPhase2_TemplateUtils_h - -#include -#include - -#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" -#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFTypes.h" -#include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" - -namespace emtf::phase2 { - - template - T when(const bool& condition, const T& if_true, const F& if_false) { - return condition ? if_true : static_cast(if_false); - } - - template - T when(const bool& condition, const T& if_true, const T& if_false) { - return condition ? if_true : if_false; - } - -} // namespace emtf::phase2 - -#endif // L1Trigger_L1TMuonEndCapPhase2_TemplateUtils_h not defined diff --git a/L1Trigger/L1TMuonEndCapPhase2/scripts/msort.py b/L1Trigger/L1TMuonEndCapPhase2/scripts/msort.py deleted file mode 100644 index 741b66d90776b..0000000000000 --- a/L1Trigger/L1TMuonEndCapPhase2/scripts/msort.py +++ /dev/null @@ -1,163 +0,0 @@ -def swap(arr, a, b): - # print('Compare (%d, %d)' % (a, b)) - - if arr[a] < arr[b]: - temp = arr[a] - arr[a] = arr[b] - arr[b] = temp - -def merge_block(arr, offset, step, block_begin, block_end, first_n=-1): - wire_offset = offset + block_begin - wire_cutoff = first_n + block_begin - wire_1 = wire_offset - wire_2 = wire_1 + step - - # Merge block - while wire_2 < block_end: - # Trim - if first_n > -1 and wire_cutoff < block_end: - if (first_n < step or step == 1): - wire_required = wire_offset <= wire_1 <= wire_cutoff - else: - wire_required = wire_offset <= wire_1 < wire_cutoff - - if not wire_required: - break - - # Swap - swap(arr, wire_1, wire_2) - - # Calculate new wire_1 - if step == 1: - wire_1 = wire_2 + 1 - else: - wire_1 = wire_1 + 1 - - # Calculate new wire_2 - wire_2 = wire_1 + step - - -def merge_sort(arr, first_n=-1): - arr_length = len(arr) - - # Sort - for i in range(int(arr_length / 2)): - swap(arr, 2 * i, 2 * i + 1) - - # Merge to mas block size - stage = 0 - offset = 0 - step = 2 - block_size = step * 2 - - # Loop block sizes - while True: - # print('Block size=%d begin' % (block_size)) - - # Loop merge steps - # if the offset surpases the amount of wires to keep, - # there's no need to continue - while True: - # Loop blocks - stage += 1 - block = 0 - block_begin = 0 - block_end = min(block_size, arr_length) - - while block_begin < arr_length: - # print('Stage %d Block %d offset=%d step=%d size=%d [%d, %d] begin' % (stage, block, offset, step, block_size, block_begin, block_end)) - - merge_block(arr, offset, step, block_begin, block_end, first_n=first_n) - - # Move to next block - block += 1 - block_begin = block_end - block_end = min(block_end + block_size, arr_length) - - # Decrease step - if step > 2: - # For each pass we are certain of the local min and max so skip 2 wires and reduce step - offset = offset + 2 - step = step - 2 - elif step == 2: - # For final pass we are certain of the global min and max so skip 1 wire and compare 1 to 1 - # the last value will be left without a partner; naturally since it's the global min - offset = 1 - step = 1 - else: - # Short-Circuit: Done - break; - - # Short-Circuit: No more wires - if block_size >= arr_length: - break - - # Double the block size - offset = 0 - step = block_size - block_size = step * 2 - -import random -import copy - -random.seed(2022) - -match_count = 0 -test_runs = 1 - -for i in range(test_runs): - random.seed(2022 + i) - original = [random.randint(0,120) for i in range(144)] - - print(original, len(original)) - - # Osvaldo Mode - osvaldo_input = copy.deepcopy(original) - osvaldo_output = copy.deepcopy(osvaldo_input) - merge_sort(osvaldo_output, first_n=4) - - # Jia Fu Mode - jf_p1_input = copy.deepcopy(original[:32]) - jf_p2_input = copy.deepcopy(original[32:]) - jf_p1_output = copy.deepcopy(jf_p1_input) - - merge_sort(jf_p1_output, first_n=16) - - for i in range(28): - part = jf_p2_input[i*4:(i+1)*4] - merge_sort(part) - #print(i, part) - jf_p2_input[i*4:(i+1)*4] = part - - jf_input = copy.deepcopy(jf_p1_output[:16] + jf_p2_input) - jf_output = copy.deepcopy(jf_input) - #print(jf_output, len(jf_output)) - merge_sort(jf_output, first_n=4) - - print('Osvaldo Mode') - print('\nInput Part 1', osvaldo_input[:32]) - print('\nInput Part 2', osvaldo_input[32:]) - print('\nInput Length', len(osvaldo_input)) - print('\nBest', osvaldo_output[:4]) - print() - print('Jia Fu Mode') - print('\nInput Part 1', jf_p1_input) - # print('\nOutput Part 1', jf_p1_output[:16]) - print('\nInput Part 2', jf_p2_input) - print('\nInput Length', len(jf_input)) - print('\nBest', jf_output[:4]) - - matches = True - - for i in range(4): - if osvaldo_output[i] != jf_output[i] or osvaldo_output[i] != jf_output[i]: - matches = False - break - - if matches: - match_count += 1 - - print('\nOutputs Match', matches) - -print('Match Count', match_count, 'Runs', test_runs) - From 2e2b966775ef18e8619bc1741860126a4fa14293 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Tue, 16 Jan 2024 09:11:04 +0100 Subject: [PATCH 10/24] Rename gem digis in emtf++ config to avoid missing gem digi error. --- L1Trigger/L1TMuonEndCapPhase2/python/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/L1Trigger/L1TMuonEndCapPhase2/python/config.py b/L1Trigger/L1TMuonEndCapPhase2/python/config.py index 1b6723c350bac..54453334d4b61 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/python/config.py +++ b/L1Trigger/L1TMuonEndCapPhase2/python/config.py @@ -6,6 +6,7 @@ def customise_debug(process): process.load('L1Trigger.L1TMuonEndCapPhase2.rpcRecHitsForEMTF_cfi') process.load('L1Trigger.L1TMuonEndCapPhase2.simEmtfDigisPhase2_cfi') + process.gemRecHits.gemDigiLabel = 'simMuonGEMDigis' process.simEmtfDigisPhase2.Verbosity = cms.untracked.int32(5) process.L1TMuonEndCapPhase2Task = cms.Task( @@ -34,6 +35,7 @@ def customise_mc(process): process.load('L1Trigger.L1TMuonEndCapPhase2.rpcRecHitsForEMTF_cfi') process.load('L1Trigger.L1TMuonEndCapPhase2.simEmtfDigisPhase2_cfi') + process.gemRecHits.gemDigiLabel = 'simMuonGEMDigis' process.simEmtfDigisPhase2.Verbosity = cms.untracked.int32(1) process.L1TMuonEndCapPhase2Task = cms.Task( From 5f912ec05ee29849877de95bb413fcec7aa334ef Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Thu, 18 Jan 2024 08:46:52 +0100 Subject: [PATCH 11/24] Fix comments on PR --- .../interface/GE0TriggerPseudoBuilder.h | 2 +- .../plugins/GE0TriggerPseudoProducer.cc | 2 +- .../L1TGEM/src/GE0TriggerPseudoBuilder.cc | 43 ++++++++++--------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h b/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h index 353a69e89a92d..7ad1b985982c4 100644 --- a/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h +++ b/L1Trigger/L1TGEM/interface/GE0TriggerPseudoBuilder.h @@ -28,7 +28,7 @@ class GE0TriggerPseudoBuilder { ~GE0TriggerPseudoBuilder(); /** Build Triggers from ME0 segment in each chamber and fill them into output collections. */ - void build(const GEMSegmentCollection* me0segments, GE0TriggerDigiCollection& oc_trig); + void build(const GEMSegmentCollection& me0segments, GE0TriggerDigiCollection& oc_trig); /** set geometry for the matching needs */ void setME0Geometry(const GEMGeometry* g) { me0_g = g; } diff --git a/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc b/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc index 30f0e76b408a5..56e47e4283eac 100644 --- a/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc +++ b/L1Trigger/L1TGEM/plugins/GE0TriggerPseudoProducer.cc @@ -64,7 +64,7 @@ void GE0TriggerPseudoProducer::produce(edm::StreamID, edm::Event& ev, const edm: // Fill output collections if valid input collection is available. if (me0Segmentcoll.isValid()) { - trigBuilder->build(me0segments, *oc_trig); + trigBuilder->build(*me0segments, *oc_trig); } // Put collections in event. diff --git a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc index eb1fb8aaf080e..3d7d9907e39a2 100644 --- a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc +++ b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc @@ -17,9 +17,9 @@ GE0TriggerPseudoBuilder::GE0TriggerPseudoBuilder(const edm::ParameterSet& conf) GE0TriggerPseudoBuilder::~GE0TriggerPseudoBuilder() {} -void GE0TriggerPseudoBuilder::build(const GEMSegmentCollection* me0Segments, GE0TriggerDigiCollection& oc_trig) { +void GE0TriggerPseudoBuilder::build(const GEMSegmentCollection& me0Segments, GE0TriggerDigiCollection& oc_trig) { if (info_ > 2) - dumpAllME0Segments(*me0Segments); + dumpAllME0Segments(me0Segments); for (int endc = 0; endc < static_cast(trig_me0s::MAX_ENDCAPS); endc++) { for (int cham = 0; cham < static_cast(trig_me0s::MAX_CHAMBERS); cham++) { @@ -29,7 +29,7 @@ void GE0TriggerPseudoBuilder::build(const GEMSegmentCollection* me0Segments, GE0 // constexpr GEMDetId(int region, int ring, int station, int layer, int chamber, int ieta) GEMDetId detid(region, 1, 0, 0, cham + 1, 0); - const auto& drange = me0Segments->get(detid); + const auto& drange = me0Segments.get(detid); std::vector trigV; for (auto digiIt = drange.first; digiIt != drange.second; digiIt++) { if (info_ > 1) @@ -74,9 +74,10 @@ ME0TriggerDigi GE0TriggerPseudoBuilder::segmentConversion(const GEMSegment segme //assert(rolls.size() <= 2); // we did found very few ME0 segments crossing 3 rolls!!! this cut is applied offline if (rolls.empty()) return ME0TriggerDigi(); - if (rolls[0] < 1) + if (rolls[0] < 1) { LogTrace("L1ME0Trigger") << " ME0 segment has wrong roll number " << rolls[0] << " which should be >= 1 \n !!!"; - assert(rolls[0] >= 1); + throw edm::Exception(edm::errors::LogicError, "ME0 should have at least one roll"); + } int partition = (rolls[0] - 1) << 1; //roll from detid counts from 1 if (rolls.size() == 2 and rolls[0] > rolls[1]) partition = partition - 1; @@ -146,19 +147,21 @@ ME0TriggerDigi GE0TriggerPseudoBuilder::segmentConversion(const GEMSegment segme } void GE0TriggerPseudoBuilder::dumpAllME0Segments(const GEMSegmentCollection& segments) const { - LogTrace("L1ME0Trigger") << "dumpt all ME0 Segments" << std::endl; - // for (auto iC = segments.id_begin(); iC != segments.id_end(); ++iC) { - // auto ch_segs = segments.get(*iC); - // for (auto iS = ch_segs.first; iS != ch_segs.second; ++iS) { - // GlobalPoint gp = me0_g->idToDet(iS->me0DetId())->surface().toGlobal(iS->localPosition()); - // LogTrace("L1ME0Trigger") << "ME0Detid " << iS->me0DetId() << " segment " << *iS << " eta " << gp.eta() << " phi " - // << gp.phi() << std::endl; - // auto recHits(iS->recHits()); - // LogTrace("L1ME0Trigger") << "\t has " << recHits.size() << " me0 rechits" << std::endl; - // for (auto& rh : recHits) { - // const ME0RecHit* me0rh(dynamic_cast(rh)); - // LogTrace("L1ME0Trigger") << "\t detid " << me0rh->me0Id() << " rechit " << *me0rh << std::endl; - // } - // } - // } + LogTrace("L1GE0Trigger") << "dumpt all ME0 Segments" << std::endl; + for (auto iC = segments.id_begin(); iC != segments.id_end(); ++iC) { + auto ch_segs = segments.get(*iC); + for (auto iS = ch_segs.first; iS != ch_segs.second; ++iS) { + if (iS->gemDetId().station() != 0) // only dump GE0 segments + continue; + GlobalPoint gp = me0_g->idToDet(iS->gemDetId())->surface().toGlobal(iS->localPosition()); + LogTrace("L1ME0Trigger") << "ME0Detid " << iS->gemDetId() << " segment " << *iS << " eta " << gp.eta() << " phi " + << gp.phi() << std::endl; + auto recHits(iS->recHits()); + LogTrace("L1GE0Trigger") << "\t has " << recHits.size() << " me0 rechits" << std::endl; + for (auto& rh : recHits) { + const GEMRecHit* me0rh(dynamic_cast(rh)); + LogTrace("L1GEMTrigger") << "\t detid " << me0rh->gemId() << " rechit " << *me0rh << std::endl; + } + } + } } From fc0a4f3cae4fb29cd6ca3a1b3a2716694623c597 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Thu, 18 Jan 2024 18:34:57 +0100 Subject: [PATCH 12/24] Implemented fill description for L1TMuonEndCapPhase2TrackProducer --- .../L1TMuonEndCapPhase2TrackProducer.cc | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc index 8e4a95ddfc75c..93d5d64046b1b 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc @@ -17,9 +17,44 @@ L1TMuonEndCapPhase2TrackProducer::L1TMuonEndCapPhase2TrackProducer(const edm::Pa void L1TMuonEndCapPhase2TrackProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; - desc.setUnknown(); - descriptions.addDefault(desc); + // Neural Network Models + desc.add("PromptGraphPath", "L1Trigger/L1TMuonEndCapPhase2/data/prompt_model.pb"); + desc.add("DisplacedGraphPath", "L1Trigger/L1TMuonEndCapPhase2/data/displaced_model.pb"); + + // Input Collections + desc.add("CSCInput", edm::InputTag("simCscTriggerPrimitiveDigisForEMTF")); + desc.add("RPCInput", edm::InputTag("rpcRecHitsForEMTF")); + desc.add("GEMInput", edm::InputTag("simMuonGEMPadDigiClusters")); + desc.add("ME0Input", edm::InputTag("me0TriggerConvertedPseudoDigis")); + desc.add("GE0Input", edm::InputTag("ge0TriggerConvertedPseudoDigis")); + + // Enable Subdetectors + desc.add("CSCEnabled", true); + desc.add("RPCEnabled", true); + desc.add("GEMEnabled", true); + desc.add("ME0Enabled", true); + desc.add("GE0Enabled", false); + + // Bunch-Crossing Settings + desc.add("MinBX", -2); + desc.add("MaxBX", 2); + desc.add("BXWindow", 1); + + desc.add("CSCInputBXShift", -8); + desc.add("RPCInputBXShift", 0); + desc.add("GEMInputBXShift", 0); + desc.add("ME0InputBXShift", -8); + + // Primitive Settings + desc.add("IncludeNeighborEnabled", true); + + // Debug Utils + desc.addUntracked("Verbosity", 3); + desc.add("ValidationDirectory", "L1Trigger/L1TMuonEndCapPhase2/data/validation"); + + // Register + descriptions.add("L1TMuonEndCapPhase2TrackProducer", desc); } void L1TMuonEndCapPhase2TrackProducer::produce(edm::Event& event, const edm::EventSetup& event_setup) { From 7afc4f49a0993c83513160d6e16ee9364ea2cee3 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Mon, 22 Jan 2024 15:29:25 +0100 Subject: [PATCH 13/24] Formatted GEM and EMTFpp Code --- .../L1TGEM/src/GE0TriggerPseudoBuilder.cc | 28 +++---- .../src/Algo/DuplicateRemovalLayer.cc | 8 +- .../src/Algo/HitmapLayer.cc | 44 +++++----- .../src/Algo/ParameterAssignmentLayer.cc | 30 +++---- .../src/Algo/PatternMatchingLayer.cc | 6 +- .../src/Algo/RoadSortingLayer.cc | 23 +++-- .../src/Algo/TrackBuildingLayer.cc | 84 +++++++++---------- .../src/DAQ/CSCTPCollector.cc | 28 +++---- .../src/DAQ/CSCTPSelector.cc | 20 ++--- .../src/SectorProcessor.cc | 34 ++++---- .../L1TMuonEndCapPhase2/src/TrackFinder.cc | 26 +++--- 11 files changed, 165 insertions(+), 166 deletions(-) diff --git a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc index 3d7d9907e39a2..99aac7150a0a4 100644 --- a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc +++ b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc @@ -149,19 +149,19 @@ ME0TriggerDigi GE0TriggerPseudoBuilder::segmentConversion(const GEMSegment segme void GE0TriggerPseudoBuilder::dumpAllME0Segments(const GEMSegmentCollection& segments) const { LogTrace("L1GE0Trigger") << "dumpt all ME0 Segments" << std::endl; for (auto iC = segments.id_begin(); iC != segments.id_end(); ++iC) { - auto ch_segs = segments.get(*iC); - for (auto iS = ch_segs.first; iS != ch_segs.second; ++iS) { - if (iS->gemDetId().station() != 0) // only dump GE0 segments - continue; - GlobalPoint gp = me0_g->idToDet(iS->gemDetId())->surface().toGlobal(iS->localPosition()); - LogTrace("L1ME0Trigger") << "ME0Detid " << iS->gemDetId() << " segment " << *iS << " eta " << gp.eta() << " phi " - << gp.phi() << std::endl; - auto recHits(iS->recHits()); - LogTrace("L1GE0Trigger") << "\t has " << recHits.size() << " me0 rechits" << std::endl; - for (auto& rh : recHits) { - const GEMRecHit* me0rh(dynamic_cast(rh)); - LogTrace("L1GEMTrigger") << "\t detid " << me0rh->gemId() << " rechit " << *me0rh << std::endl; - } - } + auto ch_segs = segments.get(*iC); + for (auto iS = ch_segs.first; iS != ch_segs.second; ++iS) { + if (iS->gemDetId().station() != 0) // only dump GE0 segments + continue; + GlobalPoint gp = me0_g->idToDet(iS->gemDetId())->surface().toGlobal(iS->localPosition()); + LogTrace("L1ME0Trigger") << "ME0Detid " << iS->gemDetId() << " segment " << *iS << " eta " << gp.eta() << " phi " + << gp.phi() << std::endl; + auto recHits(iS->recHits()); + LogTrace("L1GE0Trigger") << "\t has " << recHits.size() << " me0 rechits" << std::endl; + for (auto& rh : recHits) { + const GEMRecHit* me0rh(dynamic_cast(rh)); + LogTrace("L1GEMTrigger") << "\t detid " << me0rh->gemId() << " rechit " << *me0rh << std::endl; + } + } } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc index 551c3f0430ec9..3cb50bd123b75 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc @@ -114,10 +114,10 @@ void DuplicateRemovalLayer::apply(std::vector& tracks) const { // DEBUG if (this->context_.config_.verbosity_ > 1) { if (trk_i.valid) { - edm::LogInfo("L1T EMTF++") << "Unique Track" - << " zone " << trk_i.zone << " col " << trk_i.col << " pat " << trk_i.pattern - << " qual " << trk_i.quality << " phi " << trk_i.phi << " theta " << trk_i.theta - << " valid " << trk_i.valid << std::endl; + edm::LogInfo("L1TEMTFpp") << "Unique Track" + << " zone " << trk_i.zone << " col " << trk_i.col << " pat " << trk_i.pattern + << " qual " << trk_i.quality << " phi " << trk_i.phi << " theta " << trk_i.theta + << " valid " << trk_i.valid << std::endl; } } } // End loop reduced tracks i diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc index 8f4e86020cb3a..d54f576586927 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc @@ -51,7 +51,7 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vectorcontext_.config_.verbosity_ > 4) { - edm::LogInfo("L1T EMTF++") + edm::LogInfo("L1TEMTFpp") << "Hitmap Segment not in zone: " << " zone " << zone_id << " row " << row_id << " seg_id " << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones << std::endl; @@ -64,7 +64,7 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vectorcontext_.config_.verbosity_ > 4) { - edm::LogInfo("L1T EMTF++") + edm::LogInfo("L1TEMTFpp") << "Hitmap Segment not in timezone: " << " zone " << zone_id << " row " << row_id << " seg_id " << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones << " seg_tzones " << seg.tzones << std::endl; @@ -79,11 +79,11 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vectorcontext_.config_.verbosity_ > 4) { - edm::LogInfo("L1T EMTF++") << "Hitmap Segment Before Assert" - << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " - << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones - << " seg_tzones " << seg.tzones << " ch_col_begin " << model_hm_chamber.begin - << " ch_col_end " << model_hm_chamber.end << std::endl; + edm::LogInfo("L1TEMTFpp") << "Hitmap Segment Before Assert" + << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " + << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones << " ch_col_begin " << model_hm_chamber.begin + << " ch_col_end " << model_hm_chamber.end << std::endl; } emtf_assert(model_hm_chamber.begin <= col_id && col_id < model_hm_chamber.end); @@ -94,10 +94,10 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vectorcontext_.config_.verbosity_ > 4) { - edm::LogInfo("L1T EMTF++") << "Hitmap Segment out of bounds: " - << " zone " << zone_id << " row " << row_id << " col " << col_id - << " seg_id " << seg_id << " seg_phi " << seg.phi << " seg_zones " - << seg.zones << " seg_tzones " << seg.tzones << std::endl; + edm::LogInfo("L1TEMTFpp") << "Hitmap Segment out of bounds: " + << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " + << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones << std::endl; } continue; @@ -112,10 +112,10 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vectorcontext_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << "Hitmap Segment" - << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " - << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones - << " seg_tzones " << seg.tzones << std::endl; + edm::LogInfo("L1TEMTFpp") << "Hitmap Segment" + << " zone " << zone_id << " row " << row_id << " col " << col_id << " seg_id " + << seg_id << " seg_phi " << seg.phi << " seg_zones " << seg.zones + << " seg_tzones " << seg.tzones << std::endl; } } // End loop segments @@ -137,13 +137,13 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vectorcontext_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << "Parameter Assignment In" - << " disp " << displaced_en << " zone " << track.zone << " col " << track.col - << " pat " << track.pattern << " qual " << track.quality << " phi " << track.phi - << " theta " << track.theta << " features " << std::endl; + edm::LogInfo("L1TEMTFpp") << "Parameter Assignment In" + << " disp " << displaced_en << " zone " << track.zone << " col " << track.col << " pat " + << track.pattern << " qual " << track.quality << " phi " << track.phi << " theta " + << track.theta << " features " << std::endl; } // Prepare input tensor @@ -60,7 +60,7 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vectorcontext_.config_.verbosity_ > 1 && i_feature > 0) { - edm::LogInfo("L1T EMTF++") << " "; + edm::LogInfo("L1TEMTFpp") << " "; } // Mask invalid sites @@ -73,14 +73,14 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vectorcontext_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << "0"; + edm::LogInfo("L1TEMTFpp") << "0"; } } else { (*input_data) = feature.to_float(); // Debug Info if (this->context_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << feature.to_float(); + edm::LogInfo("L1TEMTFpp") << feature.to_float(); } } @@ -89,7 +89,7 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vectorcontext_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << std::endl; + edm::LogInfo("L1TEMTFpp") << std::endl; } // Select TF Session @@ -139,13 +139,13 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vectorcontext_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << "Parameter Assignment Out" - << " disp " << displaced_en << " zone " << track.zone << " col " << track.col - << " pat " << track.pattern << " qual " << track.quality << " q " << track.q << " pt " - << track.pt << " rels " << track.rels << " dxy " << track.dxy << " z0 " << track.z0 - << " phi " << track.phi << " theta " << track.theta << " beta " << track.beta - << " pt_address " << track.pt_address << " rels_address " << track.rels_address - << " dxy_address " << track.dxy_address << " valid " << track.valid << std::endl; + edm::LogInfo("L1TEMTFpp") << "Parameter Assignment Out" + << " disp " << displaced_en << " zone " << track.zone << " col " << track.col << " pat " + << track.pattern << " qual " << track.quality << " q " << track.q << " pt " << track.pt + << " rels " << track.rels << " dxy " << track.dxy << " z0 " << track.z0 << " phi " + << track.phi << " theta " << track.theta << " beta " << track.beta << " pt_address " + << track.pt_address << " rels_address " << track.rels_address << " dxy_address " + << track.dxy_address << " valid " << track.valid << std::endl; } } // End loop tracks } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc index dc436ee477067..0c1b934af06ce 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc @@ -114,9 +114,9 @@ void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, continue; } - edm::LogInfo("L1T EMTF++") << "Road" - << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern - << " qual " << roads[i_col].quality << std::endl; + edm::LogInfo("L1TEMTFpp") << "Road" + << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern + << " qual " << roads[i_col].quality << std::endl; } } } // End Loop Zones diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc index 1d6cb55f1baa4..d98adffcc72a4 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc @@ -52,9 +52,9 @@ void RoadSortingLayer::apply(const int& first_n, } else { // Debug Info if (this->context_.config_.verbosity_ > 2 && roads[i_col].quality > 0) { - edm::LogInfo("L1T EMTF++") << "Road Suppressed" - << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern - << " qual " << roads[i_col].quality << std::endl; + edm::LogInfo("L1TEMTFpp") << "Road Suppressed" + << " zone " << i_zone << " col " << i_col << " pat " << roads[i_col].pattern + << " qual " << roads[i_col].quality << std::endl; } // Suppress @@ -82,10 +82,9 @@ void RoadSortingLayer::apply(const int& first_n, } if (this->context_.config_.verbosity_ > 2 && roads_kept[i_col].quality > 0) { - edm::LogInfo("L1T EMTF++") << "Road Kept" - << " zone " << roads_kept[i_col].zone << " col " << roads_kept[i_col].col - << " pat " << roads_kept[i_col].pattern << " qual " << roads_kept[i_col].quality - << std::endl; + edm::LogInfo("L1TEMTFpp") << "Road Kept" + << " zone " << roads_kept[i_col].zone << " col " << roads_kept[i_col].col << " pat " + << roads_kept[i_col].pattern << " qual " << roads_kept[i_col].quality << std::endl; } } } @@ -121,9 +120,9 @@ void RoadSortingLayer::apply(const int& first_n, continue; } - edm::LogInfo("L1T EMTF++") << "Top Road" - << " zone " << road.zone << " col " << road.col << " pat " << road.pattern << " qual " - << road.quality << std::endl; + edm::LogInfo("L1TEMTFpp") << "Top Road" + << " zone " << road.zone << " col " << road.col << " pat " << road.pattern << " qual " + << road.quality << std::endl; } } @@ -151,8 +150,8 @@ void RoadSortingLayer::apply(const int& first_n, // Debug Info if (this->context_.config_.verbosity_ > 1 && road.quality > 0) { - edm::LogInfo("L1T EMTF++") << "Best Road " << i_road << " zone " << road.zone << " col " << road.col << " pat " - << road.pattern << " qual " << road.quality << std::endl; + edm::LogInfo("L1TEMTFpp") << "Best Road " << i_road << " zone " << road.zone << " col " << road.col << " pat " + << road.pattern << " qual " << road.quality << std::endl; } } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc index 5c2d76e2b37ff..16fdc1fd7ddca 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc @@ -72,17 +72,17 @@ void TrackBuildingLayer::apply(const segment_collection_t& segments, // Debug Info if (this->context_.config_.verbosity_ > 1) { if (i_road == 0) { - edm::LogInfo("L1T EMTF++") << std::endl; - edm::LogInfo("L1T EMTF++") << "===========================================================================" - << std::endl; - edm::LogInfo("L1T EMTF++") << "BEGIN TRACK BUILDING" << std::endl; - edm::LogInfo("L1T EMTF++") << "---------------------------------------------------------------------------" - << std::endl; + edm::LogInfo("L1TEMTFpp") << std::endl; + edm::LogInfo("L1TEMTFpp") << "===========================================================================" + << std::endl; + edm::LogInfo("L1TEMTFpp") << "BEGIN TRACK BUILDING" << std::endl; + edm::LogInfo("L1TEMTFpp") << "---------------------------------------------------------------------------" + << std::endl; } - edm::LogInfo("L1T EMTF++") << "***************************************************************************" - << std::endl; - edm::LogInfo("L1T EMTF++") << "Begin building track " << i_road << std::endl; + edm::LogInfo("L1TEMTFpp") << "***************************************************************************" + << std::endl; + edm::LogInfo("L1TEMTFpp") << "Begin building track " << i_road << std::endl; } // Attach segments @@ -90,14 +90,14 @@ void TrackBuildingLayer::apply(const segment_collection_t& segments, // Debug Info if (this->context_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << "End building track " << i_road << std::endl; + edm::LogInfo("L1TEMTFpp") << "End building track " << i_road << std::endl; if (i_road == (roads.size() - 1)) { - edm::LogInfo("L1T EMTF++") << "---------------------------------------------------------------------------" - << std::endl; - edm::LogInfo("L1T EMTF++") << "END TRACK BUILDING" << std::endl; - edm::LogInfo("L1T EMTF++") << "===========================================================================" - << std::endl; + edm::LogInfo("L1TEMTFpp") << "---------------------------------------------------------------------------" + << std::endl; + edm::LogInfo("L1TEMTFpp") << "END TRACK BUILDING" << std::endl; + edm::LogInfo("L1TEMTFpp") << "===========================================================================" + << std::endl; } } } @@ -242,9 +242,9 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, const auto& trk_pat_row_phi = trk_pat_phi[i_row]; if (this->context_.config_.verbosity_ > 2) { - edm::LogInfo("L1T EMTF++") << "Pattern Row:" - << " row " << i_row << " begin " << trk_pat_row_begin << " end " << trk_pat_row_end - << " phi " << trk_pat_row_phi << std::endl; + edm::LogInfo("L1TEMTFpp") << "Pattern Row:" + << " row " << i_row << " begin " << trk_pat_row_begin << " end " << trk_pat_row_end + << " phi " << trk_pat_row_phi << std::endl; } for (const auto& model_hm_site : model_hm_row) { // Begin loop sites in row @@ -298,10 +298,10 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, } if (this->context_.config_.verbosity_ > 2) { - edm::LogInfo("L1T EMTF++") << "Site candidate:" - << " site_id " << site_id << " seg_id " << seg_id << " seg_phi " << seg.phi - << " seg_theta1 " << seg.theta1 << " seg_theta2 " << seg.theta2 << " seg_bend " - << seg.bend << std::endl; + edm::LogInfo("L1TEMTFpp") << "Site candidate:" + << " site_id " << site_id << " seg_id " << seg_id << " seg_phi " << seg.phi + << " seg_theta1 " << seg.theta1 << " seg_theta2 " << seg.theta2 << " seg_bend " + << seg.bend << std::endl; } // Short-Circuit: If the difference is larger than the min diff move on @@ -318,11 +318,11 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, // Debug Info if (this->context_.config_.verbosity_ > 2 && site_bit == 1) { - edm::LogInfo("L1T EMTF++") << "Segment attached:" - << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " - << segments[site_seg_id].phi << " seg_theta1 " << segments[site_seg_id].theta1 - << " seg_theta2 " << segments[site_seg_id].theta2 << " seg_bend " - << segments[site_seg_id].bend << std::endl; + edm::LogInfo("L1TEMTFpp") << "Segment attached:" + << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " + << segments[site_seg_id].phi << " seg_theta1 " << segments[site_seg_id].theta1 + << " seg_theta2 " << segments[site_seg_id].theta2 << " seg_bend " + << segments[site_seg_id].bend << std::endl; } } // End loop sites in row @@ -374,7 +374,7 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, // Calculate theta median if (this->context_.config_.verbosity_ > 2) { for (const auto& theta : group) { - edm::LogInfo("L1T EMTF++") << "theta " << theta << std::endl; + edm::LogInfo("L1TEMTFpp") << "theta " << theta << std::endl; } } @@ -382,7 +382,7 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, group_medians.push_back(group_median); if (this->context_.config_.verbosity_ > 2) { - edm::LogInfo("L1T EMTF++") << "group_median " << group_median << std::endl; + edm::LogInfo("L1TEMTFpp") << "group_median " << group_median << std::endl; } } // End loop theta median groups @@ -391,7 +391,7 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, theta_medians.push_back(theta_median); if (this->context_.config_.verbosity_ > 2) { - edm::LogInfo("L1T EMTF++") << "theta_median " << theta_median << std::endl; + edm::LogInfo("L1TEMTFpp") << "theta_median " << theta_median << std::endl; } } // End loop theta medians @@ -490,10 +490,10 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, // Debug Info if (this->context_.config_.verbosity_ > 4) { - edm::LogInfo("L1T EMTF++") << "Segment outside of theta window; detatched:" - << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " << site_seg.phi - << " seg_theta1 " << site_seg.theta1 << " seg_theta2 " << site_seg.theta2 - << std::endl; + edm::LogInfo("L1TEMTFpp") << "Segment outside of theta window; detatched:" + << " site_id " << site_id << " seg_id " << site_seg_id << " seg_phi " << site_seg.phi + << " seg_theta1 " << site_seg.theta1 << " seg_theta2 " << site_seg.theta2 + << std::endl; } } } @@ -552,20 +552,20 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, // Debug Info if (this->context_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << "Track" - << " zone " << track.zone << " col " << track.col << " pat " << track.pattern << " qual " - << track.quality << " sector_abs_phi " << sector_abs_phi << " abs_phi " << track.phi - << " rel_phi " << trk_rel_phi << " abs_theta " << track.theta << " features " - << std::endl; + edm::LogInfo("L1TEMTFpp") << "Track" + << " zone " << track.zone << " col " << track.col << " pat " << track.pattern << " qual " + << track.quality << " sector_abs_phi " << sector_abs_phi << " abs_phi " << track.phi + << " rel_phi " << trk_rel_phi << " abs_theta " << track.theta << " features " + << std::endl; for (int i = 0; i < v3::kNumTrackFeatures; ++i) { if (i > 0) { - edm::LogInfo("L1T EMTF++") << " "; + edm::LogInfo("L1TEMTFpp") << " "; } - edm::LogInfo("L1T EMTF++") << track.features[i]; + edm::LogInfo("L1TEMTFpp") << track.features[i]; } - edm::LogInfo("L1T EMTF++") << std::endl; + edm::LogInfo("L1TEMTFpp") << std::endl; } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc index f78f3beb6189c..c2fdc3bf100e9 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc @@ -131,10 +131,10 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co // Check for corrupted LCT data. Data corruption could occur due to software // or hardware issues, if corrupted, reject the LCT. if (!(tp_data.strip < max_strip)) { - edm::LogWarning("L1T EMTF++") << "Found error in LCT strip: " << tp_data.strip << " (allowed range: 0-" - << max_strip - 1 << ")."; + edm::LogWarning("L1TEMTFpp") << "Found error in LCT strip: " << tp_data.strip << " (allowed range: 0-" + << max_strip - 1 << ")."; - edm::LogWarning("L1T EMTF++") + edm::LogWarning("L1TEMTFpp") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; @@ -143,10 +143,10 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } if (!(tp_data.keywire < max_wire)) { - edm::LogWarning("L1T EMTF++") << "Found error in LCT wire: " << tp_data.keywire << " (allowed range: 0-" - << max_wire - 1 << ")."; + edm::LogWarning("L1TEMTFpp") << "Found error in LCT wire: " << tp_data.keywire << " (allowed range: 0-" + << max_wire - 1 << ")."; - edm::LogWarning("L1T EMTF++") + edm::LogWarning("L1TEMTFpp") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; @@ -155,9 +155,9 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } if (!(tp_data.valid == true)) { - edm::LogWarning("L1T EMTF++") << "Found error in LCT valid: " << tp_data.valid << " (allowed value: 1)."; + edm::LogWarning("L1TEMTFpp") << "Found error in LCT valid: " << tp_data.valid << " (allowed value: 1)."; - edm::LogWarning("L1T EMTF++") + edm::LogWarning("L1TEMTFpp") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; @@ -166,10 +166,10 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } if (!(tp_data.pattern < max_pattern)) { - edm::LogWarning("L1T EMTF++") << "Found error in LCT pattern: " << tp_data.pattern << " (allowed range: 0-" - << max_pattern - 1 << ")."; + edm::LogWarning("L1TEMTFpp") << "Found error in LCT pattern: " << tp_data.pattern << " (allowed range: 0-" + << max_pattern - 1 << ")."; - edm::LogWarning("L1T EMTF++") + edm::LogWarning("L1TEMTFpp") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; @@ -178,10 +178,10 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } if (!(0 < tp_data.quality && tp_data.quality < max_quality)) { - edm::LogWarning("L1T EMTF++") << "Found error in LCT quality: " << tp_data.quality << " (allowed range: 1-" - << max_quality - 1 << ")."; + edm::LogWarning("L1TEMTFpp") << "Found error in LCT quality: " << tp_data.quality << " (allowed range: 1-" + << max_quality - 1 << ")."; - edm::LogWarning("L1T EMTF++") + edm::LogWarning("L1TEMTFpp") << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring " << tp_ring << ", cscid " << tp_csc_id << ". (Note that this LCT may be reported multiple times. See source code for explanations.)"; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc index 3ba75da07d88d..d510e097880d8 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc @@ -30,22 +30,22 @@ void CSCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM if (ilink_tpc_map[ilink].size() < 2) { ilink_tpc_map[ilink].emplace_back(tp, tp_info); } else { - edm::LogWarning("L1T EMTF++") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; - edm::LogWarning("L1T EMTF++") << "Found 3 CSC trigger primitives in the same chamber"; + edm::LogWarning("L1TEMTFpp") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; + edm::LogWarning("L1TEMTFpp") << "Found 3 CSC trigger primitives in the same chamber"; for (int i_tp = 0; i_tp < 3; i_tp++) { const auto& tp_err = ((i_tp < 2) ? ilink_tpc_map[ilink].at(i_tp).tp_ : tp); - edm::LogWarning("L1T EMTF++") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap " - << tp_err.detId().endcap() << ", sector " - << tp_err.detId().triggerSector() << ", station " - << tp_err.detId().station() << ", ring " - << tp_err.detId().ring() << ", chamber " - << tp_err.detId().chamber() << ", CSC ID " << tp_err.getCSCData().cscID - << ": strip " << tp_err.getStrip() << ", wire " << tp_err.getWire(); + edm::LogWarning("L1TEMTFpp") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap " + << tp_err.detId().endcap() << ", sector " + << tp_err.detId().triggerSector() << ", station " + << tp_err.detId().station() << ", ring " << tp_err.detId().ring() + << ", chamber " << tp_err.detId().chamber() << ", CSC ID " + << tp_err.getCSCData().cscID << ": strip " << tp_err.getStrip() << ", wire " + << tp_err.getWire(); } - edm::LogWarning("L1T EMTF++") << "************************* ONLY KEEP FIRST TWO *************************\n\n"; + edm::LogWarning("L1TEMTFpp") << "************************* ONLY KEEP FIRST TWO *************************\n\n"; } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc index 776693657eecf..93d2a3aa06ce4 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc @@ -98,8 +98,8 @@ void SectorProcessor::select(const TriggerPrimitive& tp, const TPInfo& tp_info) // Short-Circuit: Operation not supported if (tp_selectors_it == tp_selectors_.end()) { - edm::LogWarning("L1T EMTF++") << "TPCollector has been implemented, " - << "but there is no TPSelector for " << tp_subsystem; + edm::LogWarning("L1TEMTFpp") << "TPCollector has been implemented, " + << "but there is no TPSelector for " << tp_subsystem; return; } @@ -233,8 +233,8 @@ void SectorProcessor::convert_tp(const int& initial_hit_id, const ILinkTPCMap& i // Short-Circuit: Operation not supported if (tp_converters_it == tp_converters_.end()) { - edm::LogWarning("L1T EMTF++") << "TPCollector & TPSelector have been implemented, " - << "but there is no TPConverter for " << tp_subsystem; + edm::LogWarning("L1TEMTFpp") << "TPCollector & TPSelector have been implemented, " + << "but there is no TPConverter for " << tp_subsystem; continue; } @@ -354,19 +354,19 @@ void SectorProcessor::populate_segments(const std::vector& bx // Debug Info if (this->context_.config_.verbosity_ > 1) { - edm::LogInfo("L1T EMTF++") << std::endl - << "Event: " << event_->id() << " Endcap: " << endcap_ << " Sector: " << sector_ - << " BX: " << (*bx_) << " Hit iLink: " << hit_chamber << " Hit iSeg: " << ch_seg - << " Hit Host " << hit_host << " Hit Rel BX " << (hit_bx - *bx_) << " Hit Timezones " - << hit_timezones << std::endl; - - edm::LogInfo("L1T EMTF++") << " id " << seg_id << " phi " << segments[seg_id].phi << " bend " - << segments[seg_id].bend << " theta1 " << segments[seg_id].theta1 << " theta2 " - << segments[seg_id].theta2 << " qual1 " << segments[seg_id].qual1 << " qual2 " - << segments[seg_id].qual2 << " time " << segments[seg_id].time << " zones " - << segments[seg_id].zones << " timezones " << segments[seg_id].tzones << " cscfr " - << segments[seg_id].cscfr << " layer " << segments[seg_id].layer << " bx " - << segments[seg_id].bx << " valid " << segments[seg_id].valid << std::endl; + edm::LogInfo("L1TEMTFpp") << std::endl + << "Event: " << event_->id() << " Endcap: " << endcap_ << " Sector: " << sector_ + << " BX: " << (*bx_) << " Hit iLink: " << hit_chamber << " Hit iSeg: " << ch_seg + << " Hit Host " << hit_host << " Hit Rel BX " << (hit_bx - *bx_) << " Hit Timezones " + << hit_timezones << std::endl; + + edm::LogInfo("L1TEMTFpp") << " id " << seg_id << " phi " << segments[seg_id].phi << " bend " + << segments[seg_id].bend << " theta1 " << segments[seg_id].theta1 << " theta2 " + << segments[seg_id].theta2 << " qual1 " << segments[seg_id].qual1 << " qual2 " + << segments[seg_id].qual2 << " time " << segments[seg_id].time << " zones " + << segments[seg_id].zones << " timezones " << segments[seg_id].tzones << " cscfr " + << segments[seg_id].cscfr << " layer " << segments[seg_id].layer << " bx " + << segments[seg_id].bx << " valid " << segments[seg_id].valid << std::endl; } // Update bx chamber last segment diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc index 3506d1ba81635..ddde7ba06d665 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc @@ -134,31 +134,31 @@ void TrackFinder::process( } // Print trigger primitives - edm::LogInfo("L1T EMTF++") << "===========================================================================" - << std::endl; - edm::LogInfo("L1T EMTF++") << "Begin TPC BX " << bx << " Dump" << std::endl; - edm::LogInfo("L1T EMTF++") << "---------------------------------------------------------------------------" - << std::endl; + edm::LogInfo("L1TEMTFpp") << "===========================================================================" + << std::endl; + edm::LogInfo("L1TEMTFpp") << "Begin TPC BX " << bx << " Dump" << std::endl; + edm::LogInfo("L1TEMTFpp") << "---------------------------------------------------------------------------" + << std::endl; n_tp += bx_tpc.size(); for (const auto& tp_entry : bx_tpc) { tp_entry.tp_.print(std::cout); - edm::LogInfo("L1T EMTF++") << "---------------------------------------------------------------------------" - << std::endl; + edm::LogInfo("L1TEMTFpp") << "---------------------------------------------------------------------------" + << std::endl; } - edm::LogInfo("L1T EMTF++") << "End TPC BX " << bx << " Dump" << std::endl; - edm::LogInfo("L1T EMTF++") << "===========================================================================" - << std::endl; + edm::LogInfo("L1TEMTFpp") << "End TPC BX " << bx << " Dump" << std::endl; + edm::LogInfo("L1TEMTFpp") << "===========================================================================" + << std::endl; } // Print TPrimitives Summary if (n_tp > 0) { - edm::LogInfo("L1T EMTF++") << "Num of TriggerPrimitive: " << n_tp << std::endl; - edm::LogInfo("L1T EMTF++") << "===========================================================================" - << std::endl; + edm::LogInfo("L1TEMTFpp") << "Num of TriggerPrimitive: " << n_tp << std::endl; + edm::LogInfo("L1TEMTFpp") << "===========================================================================" + << std::endl; } } From eeeeeee0ff06843a7be505785255cf82d9673676 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Mon, 22 Jan 2024 16:09:48 +0100 Subject: [PATCH 14/24] Applied code-checks patch --- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h | 2 +- L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc | 2 +- L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc | 2 +- L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc | 2 +- L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc | 2 +- L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h index ace96b51aeb5a..3b13b5f3b700c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit CSCTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~CSCTPCollector() = default; + ~CSCTPCollector() override = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h index 7ee6f86da9bb2..d13448984a58a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPConverter.h @@ -14,7 +14,7 @@ namespace emtf::phase2 { public: explicit CSCTPConverter(const EMTFContext&, const int&, const int&); - ~CSCTPConverter() = default; + ~CSCTPConverter() override = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h index 471b7cd47af60..c5b3d49d8b495 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit CSCTPSelector(const EMTFContext&, const int&, const int&); - ~CSCTPSelector() = default; + ~CSCTPSelector() override = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h index 93caf0a04802b..2fddbcaa88b35 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit GE0TPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~GE0TPCollector() = default; + ~GE0TPCollector() override = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h index 507094bd238f5..843cd3687f007 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPConverter.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit GE0TPConverter(const EMTFContext&, const int&, const int&); - ~GE0TPConverter() = default; + ~GE0TPConverter() override = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h index 598ac2809fb7c..95d7004f74ff3 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit GE0TPSelector(const EMTFContext&, const int&, const int&); - ~GE0TPSelector() = default; + ~GE0TPSelector() override = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h index ebbf4c4308bdd..8715dec88a923 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit GEMTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~GEMTPCollector() = default; + ~GEMTPCollector() override = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h index e4f47386cdefe..4d2d82fce61b5 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPConverter.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit GEMTPConverter(const EMTFContext&, const int&, const int&); - ~GEMTPConverter() = default; + ~GEMTPConverter() override = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h index 3b905db8dbd0f..0990c35fb3fb2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit GEMTPSelector(const EMTFContext&, const int&, const int&); - ~GEMTPSelector() = default; + ~GEMTPSelector() override = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h index cc2d73c86a7df..40f1e444949c8 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit ME0TPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~ME0TPCollector() = default; + ~ME0TPCollector() override = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h index df70b0b81e50a..a45639b6b7740 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPConverter.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit ME0TPConverter(const EMTFContext&, const int&, const int&); - ~ME0TPConverter() = default; + ~ME0TPConverter() override = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h index c7529f6e03de2..8ba63b1575f49 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit ME0TPSelector(const EMTFContext&, const int&, const int&); - ~ME0TPSelector() = default; + ~ME0TPSelector() override = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h index 19aadb98765b9..29c0ecea79dc8 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h @@ -11,7 +11,7 @@ namespace emtf::phase2 { public: explicit RPCTPCollector(const EMTFContext&, edm::ConsumesCollector&); - ~RPCTPCollector() = default; + ~RPCTPCollector() override = default; void collect(const edm::Event&, BXTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h index 200bc91ea5eeb..8416b249e06ea 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPConverter.h @@ -12,7 +12,7 @@ namespace emtf::phase2 { public: explicit RPCTPConverter(const EMTFContext&, const int&, const int&); - ~RPCTPConverter() = default; + ~RPCTPConverter() override = default; void convert(const TriggerPrimitive&, const TPInfo&, EMTFHit&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h index 646a49ec0659b..e7b6b535f2700 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h @@ -13,7 +13,7 @@ namespace emtf::phase2 { public: explicit RPCTPSelector(const EMTFContext&, const int&, const int&); - ~RPCTPSelector() = default; + ~RPCTPSelector() override = default; void select(const TriggerPrimitive&, TPInfo, ILinkTPCMap&) const final; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc index 5f0416c9e0d37..6544445139dd6 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/OutputLayer.cc @@ -76,7 +76,7 @@ void OutputLayer::apply(const int& endcap, out_trk.setEndcap(endcap_pm); out_trk.setSector(sector); out_trk.setBx(bx); - out_trk.setUnconstrained(displaced_en ? 1 : 0); + out_trk.setUnconstrained(displaced_en ? true : false); out_trk.setValid(track.valid); out_trk.setModelPtAddress(track.pt_address); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc index 0c1b934af06ce..0925d281a2d5e 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/PatternMatchingLayer.cc @@ -53,7 +53,7 @@ void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { // Loop Rows // Pad the row with zeros to cover cases where // pattern range is out of range - auto hitmap_row = hitmap[i_row]; + const auto& hitmap_row = hitmap[i_row]; auto& model_pat_row = model_pat[i_row]; // Pad the hitmap row on both sides using kMaxPadding diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc index c2fdc3bf100e9..d1c61765fe995 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc @@ -100,7 +100,7 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co auto tp_wire_key = std::make_pair(tp_det_id.rawId(), tp_bx); const auto& tp_wires = chamber_wires_map.at(tp_wire_key); - emtf_assert((1 <= tp_wires.size()) && (tp_wires.size() <= 2)); + emtf_assert((!tp_wires.empty()) && (tp_wires.size() <= 2)); if (tp_wires.size() > 1) { tp_wire1 = tp_wires.at(0); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc index 93d2a3aa06ce4..797d656e05677 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc @@ -169,7 +169,7 @@ void SectorProcessor::process(EMTFHitCollection& out_hits, // =========================================================================== // Record segments/hits used in track building // =========================================================================== - if (seg_to_hit.size() > 0) { + if (!seg_to_hit.empty()) { EMTFInput::hits_t hit_id_col; EMTFInput::segs_t seg_id_col; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc index ddde7ba06d665..11159e778db51 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc @@ -129,7 +129,7 @@ void TrackFinder::process( auto& bx_tpc = bx_tpc_map_it->second; // Short-Circuit: Empty trigger primitive collection - if (bx_tpc.size() == 0) { + if (bx_tpc.empty()) { continue; } From e73e7f79a87ac7d8540dfb3efb21ef6193e24856 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Fri, 26 Jan 2024 20:14:32 +0100 Subject: [PATCH 15/24] Removed simMuonME0PseudoReDigisCoarse from ge0TriggerPseudoDigiTask --- L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py | 1 - 1 file changed, 1 deletion(-) diff --git a/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py b/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py index b34bb154715c9..e0c355d243d52 100644 --- a/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py +++ b/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py @@ -42,7 +42,6 @@ from RecoLocalMuon.GEMSegment.gemSegments_cfi import * ge0TriggerPseudoDigiTask = cms.Task( - simMuonME0PseudoReDigisCoarse, me0RecHitsCoarse, me0TriggerPseudoDigis, ## need to run the standard ME0 RECO sequence for converted triggers From e165badc1cbd9ce455f62ca8dd00071d673b5c25 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Sat, 27 Jan 2024 21:14:31 +0100 Subject: [PATCH 16/24] Removed me0RecHitsCoarse and me0TriggerPseudoDigis from ge0TriggerPseudoDigiTask --- L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py b/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py index e0c355d243d52..1e4e835658f66 100644 --- a/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py +++ b/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py @@ -42,9 +42,7 @@ from RecoLocalMuon.GEMSegment.gemSegments_cfi import * ge0TriggerPseudoDigiTask = cms.Task( - me0RecHitsCoarse, - me0TriggerPseudoDigis, - ## need to run the standard ME0 RECO sequence for converted triggers + ## need to run the standard GE0 RECO sequence for converted triggers gemRecHits, gemSegments, ge0TriggerConvertedPseudoDigis From 4725a29618afb26e59b8387677a4a87bbc49a40f Mon Sep 17 00:00:00 2001 From: "Ian J. Watson" Date: Mon, 29 Jan 2024 14:49:46 +0100 Subject: [PATCH 17/24] get 24034.0 running --- L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py | 4 ++-- L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py b/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py index 3ed2d6397387c..57c7be6aefc64 100644 --- a/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py +++ b/L1Trigger/L1TGEM/python/me0TriggerDigis_cff.py @@ -7,7 +7,7 @@ me0TriggerRealDigiTask = cms.Task(simMuonME0PadDigis, me0TriggerDigis) me0TriggerAllDigiTask = cms.Task(me0TriggerRealDigiTask, me0TriggerPseudoDigiTask) -ge0TriggerAllDigiTask = cms.Task(me0TriggerRealDigiTask, ge0TriggerPseudoDigiTask) +ge0TriggerAllDigiTask = cms.Task(ge0TriggerPseudoDigiTask) -# in scenarios with GE0, remove the pseudo digis +# in scenarios with GE0, remove the ME0 pseudo digis phase2_GE0.toReplaceWith(me0TriggerAllDigiTask, ge0TriggerAllDigiTask) diff --git a/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py b/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py index 1e4e835658f66..6ed3a7b3a79fa 100644 --- a/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py +++ b/L1Trigger/L1TGEM/python/me0TriggerPseudoDigis_cff.py @@ -41,6 +41,9 @@ from RecoLocalMuon.GEMRecHit.gemRecHits_cfi import * from RecoLocalMuon.GEMSegment.gemSegments_cfi import * +from Configuration.Eras.Modifier_phase2_GE0_cff import phase2_GE0 +phase2_GE0.toModify(gemRecHits, gemDigiLabel=cms.InputTag("simMuonGEMDigis")) + ge0TriggerPseudoDigiTask = cms.Task( ## need to run the standard GE0 RECO sequence for converted triggers gemRecHits, From 848c7615fea22a52eafc7a1c886248b79697c0e3 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Mon, 5 Feb 2024 20:37:28 +0100 Subject: [PATCH 18/24] Added EMTFpp Data Format Class Versions --- DataFormats/L1TMuonPhase2/src/classes_def.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/DataFormats/L1TMuonPhase2/src/classes_def.xml b/DataFormats/L1TMuonPhase2/src/classes_def.xml index 9651e92a9984b..23c286c1d736c 100644 --- a/DataFormats/L1TMuonPhase2/src/classes_def.xml +++ b/DataFormats/L1TMuonPhase2/src/classes_def.xml @@ -23,13 +23,19 @@ - + + + - + + + - + + + From 7ca90a0b4544feadcf8dc6eb2285c5617e7b67dc Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Wed, 14 Feb 2024 20:47:24 +0100 Subject: [PATCH 19/24] Removed ParameterSet reference --- .../L1TMuonEndCapPhase2/interface/EMTFConfiguration.h | 7 +++++++ L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h | 3 --- L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc | 4 +--- L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc | 4 +--- L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc | 4 +--- L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc | 4 +--- L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc | 4 +--- L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc | 6 ++++++ L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc | 5 +---- 9 files changed, 19 insertions(+), 22 deletions(-) diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h index 1b3fc1e65cfea..70504aed4faa2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h @@ -1,6 +1,7 @@ #ifndef L1Trigger_L1TMuonEndCapPhase2_EMTFConfiguration_h #define L1Trigger_L1TMuonEndCapPhase2_EMTFConfiguration_h +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFfwd.h" namespace emtf::phase2 { @@ -42,6 +43,12 @@ namespace emtf::phase2 { int gem_bx_shift_; int me0_bx_shift_; + edm::InputTag csc_input_; + edm::InputTag rpc_input_; + edm::InputTag gem_input_; + edm::InputTag me0_input_; + edm::InputTag ge0_input_; + // Primitive Selectoin bool include_neighbor_en_; }; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h index 6346e5fa66998..c45b2c528b2e7 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h @@ -32,9 +32,6 @@ namespace emtf::phase2 { // Event configuration void update(const edm::Event&, const edm::EventSetup&); - // Parameter Set - const edm::ParameterSet& pset_; - // Helpers GeometryTranslator geometry_translator_; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc index d1c61765fe995..90980efbca7ed 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" @@ -16,8 +15,7 @@ using namespace emtf::phase2; CSCTPCollector::CSCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("CSCInput"))) {} + input_token_(i_consumes_collector.consumes(context.config_.csc_input_)) {} void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { edm::Handle csc_digis; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc index eb7c5df2c9ef1..3c1754ca97da2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" @@ -16,8 +15,7 @@ using namespace emtf::phase2; GE0TPCollector::GE0TPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("GE0Input"))) {} + input_token_(i_consumes_collector.consumes(context.config_.ge0_input_)) {} void GE0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc index 3c4c985e8feb9..38b21a0589fa4 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" @@ -14,8 +13,7 @@ using namespace emtf::phase2; GEMTPCollector::GEMTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("GEMInput"))) {} + input_token_(i_consumes_collector.consumes(context.config_.gem_input_)) {} void GEMTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc index 46631c33b8774..a6bed4b686dd5 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" @@ -16,8 +15,7 @@ using namespace emtf::phase2; ME0TPCollector::ME0TPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("ME0Input"))) {} + input_token_(i_consumes_collector.consumes(context.config_.me0_input_)) {} void ME0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc index b6dc2fa31800f..c2e936be44e14 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc @@ -1,6 +1,5 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h" #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h" @@ -15,8 +14,7 @@ using namespace emtf::phase2; RPCTPCollector::RPCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector) : context_(context), - input_token_(i_consumes_collector.consumes( - context.pset_.getParameter("RPCInput"))) {} + input_token_(i_consumes_collector.consumes(context.config_.rpc_input_)) {} void RPCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const { // Constants diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc index 5e3902a573d3f..7a98785970b05 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFConfiguration.cc @@ -35,6 +35,12 @@ EMTFConfiguration::EMTFConfiguration(const edm::ParameterSet& pset) { gem_bx_shift_ = pset.getParameter("GEMInputBXShift"); me0_bx_shift_ = pset.getParameter("ME0InputBXShift"); + csc_input_ = pset.getParameter("CSCInput"); + rpc_input_ = pset.getParameter("RPCInput"); + gem_input_ = pset.getParameter("GEMInput"); + me0_input_ = pset.getParameter("ME0Input"); + ge0_input_ = pset.getParameter("GE0Input"); + // Primitive Selection include_neighbor_en_ = pset.getParameter("IncludeNeighborEnabled"); } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc index 7bdd58f00557c..c2171473846ba 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/EMTFContext.cc @@ -11,10 +11,7 @@ using namespace emtf::phase2; EMTFContext::EMTFContext(const edm::ParameterSet& pset, edm::ConsumesCollector i_consumes_collector) - : // Parameter Set - pset_(pset), - - // Helpers + : // Helpers geometry_translator_(i_consumes_collector), // EMTF From 7e021e405434de077e9394cb30e0ad0833868335 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Wed, 14 Feb 2024 20:53:08 +0100 Subject: [PATCH 20/24] Removed LDFLAGS from BuildFile.xml --- L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml b/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml index 8bc523a4c4b2d..8d0f1f91b4eab 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml +++ b/L1Trigger/L1TMuonEndCapPhase2/BuildFile.xml @@ -9,5 +9,4 @@ - From 8ad0864eb50cc6bb0f87b729782eca54a8344de1 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Mon, 26 Feb 2024 17:55:05 +0100 Subject: [PATCH 21/24] Removed trycatch for GE0 from MuonTriggerPrimitive --- L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc index 35ea3217b1423..a1b4af2a9560b 100644 --- a/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc +++ b/L1Trigger/L1TMuon/src/MuonTriggerPrimitive.cc @@ -495,11 +495,12 @@ void TriggerPrimitive::print(std::ostream& out) const { out << "Pad high : " << _gem.pad_hi << std::endl; break; case kME0: - try { + if (detId().subdetId() == MuonSubdetId::ME0) { out << detId() << std::endl; - } catch (...) { + } else { out << detId() << std::endl; } + out << "Local BX : " << _me0.bx << std::endl; out << "Chamber id : " << _me0.chamberid << std::endl; out << "Quality : " << _me0.quality << std::endl; From c955ecdd1bc85f9e0cc7f44c3b74ca844e49cd3f Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Tue, 5 Mar 2024 23:22:04 +0100 Subject: [PATCH 22/24] Switched to unsigned indexes for iteration, and applied naming conventions for L1TMuonEndcapPhase2 --- .../interface/Algo/OutputLayer.h | 12 +---- .../interface/Algo/RoadSortingLayer.h | 2 +- .../interface/Algo/TrackBuildingLayer.h | 2 +- .../interface/DAQ/CSCTPSelector.h | 4 +- .../interface/DAQ/GE0TPSelector.h | 4 +- .../interface/DAQ/GEMTPSelector.h | 4 +- .../interface/DAQ/ME0TPSelector.h | 4 +- .../interface/DAQ/RPCTPSelector.h | 4 +- .../interface/Data/ActivationLut.h | 8 +-- .../interface/Data/TimeZoneLut.h | 2 +- .../interface/Data/ZoneLut.h | 4 +- .../interface/Utils/CSCUtils.h | 24 ++++----- .../interface/Utils/DataUtils.h | 50 +++++++++---------- .../interface/Utils/TPUtils.h | 30 +++++------ .../src/Algo/DuplicateRemovalLayer.cc | 2 +- .../src/Algo/HitmapLayer.cc | 15 +++--- .../src/Algo/OutputLayer.cc | 12 ++--- .../src/Algo/ParameterAssignmentLayer.cc | 12 ++--- .../src/Algo/PatternMatchingLayer.cc | 18 +++---- .../src/Algo/RoadSortingLayer.cc | 12 ++--- .../src/Algo/TrackBuildingLayer.cc | 31 ++++++------ .../src/DAQ/CSCTPCollector.cc | 8 +-- .../src/DAQ/CSCTPConverter.cc | 14 +++--- .../src/DAQ/CSCTPSelector.cc | 24 ++++----- .../src/DAQ/GE0TPCollector.cc | 16 +++--- .../src/DAQ/GE0TPConverter.cc | 10 ++-- .../src/DAQ/GE0TPSelector.cc | 14 +++--- .../src/DAQ/GEMTPCollector.cc | 8 +-- .../src/DAQ/GEMTPConverter.cc | 10 ++-- .../src/DAQ/GEMTPSelector.cc | 20 ++++---- .../src/DAQ/ME0TPCollector.cc | 16 +++--- .../src/DAQ/ME0TPConverter.cc | 10 ++-- .../src/DAQ/ME0TPSelector.cc | 14 +++--- .../src/DAQ/RPCTPCollector.cc | 8 +-- .../src/DAQ/RPCTPConverter.cc | 14 +++--- .../src/DAQ/RPCTPSelector.cc | 20 ++++---- .../src/Data/ActivationLut.cc | 8 +-- .../src/Data/TimeZoneLut.cc | 2 +- .../L1TMuonEndCapPhase2/src/Data/ZoneLut.cc | 4 +- .../src/SectorProcessor.cc | 4 +- .../L1TMuonEndCapPhase2/src/TrackFinder.cc | 4 +- .../L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc | 24 ++++----- .../L1TMuonEndCapPhase2/src/Utils/TPUtils.cc | 48 +++++++++--------- 43 files changed, 273 insertions(+), 283 deletions(-) diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h index 3852f44a56bb4..41a025eac31eb 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/OutputLayer.h @@ -31,17 +31,9 @@ namespace emtf::phase2::algo { std::array disp_pt_calibration_lut_; std::array disp_dxy_calibration_lut_; - int find_prompt_emtf_pt(const int&) const; + int findEMTFModeV1(const track_t::site_mask_t&) const; - int find_disp_emtf_pt(const int&) const; - - int find_emtf_dxy(const int&) const; - - int find_emtf_pt_no_calib(const int&) const; - - int find_emtf_mode_v1(const track_t::site_mask_t&) const; - - int find_emtf_mode_v2(const track_t::site_mask_t&) const; + int findEMTFModeV2(const track_t::site_mask_t&) const; }; } // namespace emtf::phase2::algo diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h index 47c9c1fedbfd0..6c90677b02828 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/RoadSortingLayer.h @@ -16,7 +16,7 @@ namespace emtf::phase2::algo { ~RoadSortingLayer() = default; - void apply(const int&, const std::vector&, std::vector&) const; + void apply(const unsigned int&, const std::vector&, std::vector&) const; private: const EMTFContext& context_; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h index 46c9b6740edca..9b7a510ccf389 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Algo/TrackBuildingLayer.h @@ -26,7 +26,7 @@ namespace emtf::phase2::algo { private: const EMTFContext& context_; - void attach_segments(const segment_collection_t&, const road_t&, const bool&, track_t&) const; + void attachSegments(const segment_collection_t&, const road_t&, const bool&, track_t&) const; }; } // namespace emtf::phase2::algo diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h index c5b3d49d8b495..3f9121129bfff 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/CSCTPSelector.h @@ -21,9 +21,9 @@ namespace emtf::phase2 { int endcap_, sector_; - int get_input_link(const TriggerPrimitive&, TPInfo&) const; + int getInputLink(const TriggerPrimitive&, TPInfo&) const; - int calculate_input_link(const int&, const int&, const int&, const int&, const TPSelection&) const; + int calcInputLink(const int&, const int&, const int&, const int&, const TPSelection&) const; }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h index 95d7004f74ff3..48f2ea8963f3a 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h @@ -21,9 +21,9 @@ namespace emtf::phase2 { int endcap_, sector_; - int get_input_link(const TriggerPrimitive&, TPInfo&) const; + int getInputLink(const TriggerPrimitive&, TPInfo&) const; - int calculate_input_link(const int&, const int&, const TPSelection&) const; + int calcInputLink(const int&, const int&, const TPSelection&) const; }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h index 0990c35fb3fb2..a054e6eb4705c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h @@ -21,9 +21,9 @@ namespace emtf::phase2 { int endcap_, sector_; - int get_input_link(const TriggerPrimitive&, TPInfo&) const; + int getInputLink(const TriggerPrimitive&, TPInfo&) const; - int calculate_input_link(const int&, const int&, const int&, const int&, const TPSelection&) const; + int calcInputLink(const int&, const int&, const int&, const int&, const TPSelection&) const; }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h index 8ba63b1575f49..bd61a132c836d 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/ME0TPSelector.h @@ -21,9 +21,9 @@ namespace emtf::phase2 { int endcap_, sector_; - int get_input_link(const TriggerPrimitive&, TPInfo&) const; + int getInputLink(const TriggerPrimitive&, TPInfo&) const; - int calculate_input_link(const int&, const int&, const TPSelection&) const; + int calcInputLink(const int&, const int&, const TPSelection&) const; }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h index e7b6b535f2700..e72f3c771fe18 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h @@ -22,9 +22,9 @@ namespace emtf::phase2 { int endcap_, sector_; - int get_input_link(const TriggerPrimitive&, TPInfo&) const; + int getInputLink(const TriggerPrimitive&, TPInfo&) const; - int calculate_input_link(const int&, const int&, const int&, const int&, const TPSelection&) const; + int calcInputLink(const int&, const int&, const int&, const int&, const TPSelection&) const; }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h index f2b2584031b47..8c4dfc44846b3 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ActivationLut.h @@ -19,10 +19,10 @@ namespace emtf::phase2::data { void update(const edm::Event&, const edm::EventSetup&); - const trk_pt_t& lookup_prompt_pt(const trk_nn_address_t&) const; - const trk_pt_t& lookup_disp_pt(const trk_nn_address_t&) const; - const trk_rels_t& lookup_rels(const trk_nn_address_t&) const; - const trk_dxy_t& lookup_dxy(const trk_nn_address_t&) const; + const trk_pt_t& lookupPromptPt(const trk_nn_address_t&) const; + const trk_pt_t& lookupDispPt(const trk_nn_address_t&) const; + const trk_rels_t& lookupRels(const trk_nn_address_t&) const; + const trk_dxy_t& lookupDxy(const trk_nn_address_t&) const; private: std::vector prompt_pt_lut_; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h index 2a0e330e19d94..8a309ba053228 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/TimeZoneLut.h @@ -22,7 +22,7 @@ namespace emtf::phase2::data { void update(const edm::Event&, const edm::EventSetup&); - int get_timezones(const int&, const int&) const; + int getTimezones(const int&, const int&) const; private: // Key: Host diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h index 772cc06606235..6bbc032b09585 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Data/ZoneLut.h @@ -21,9 +21,9 @@ namespace emtf::phase2::data { void update(const edm::Event&, const edm::EventSetup&); - int get_zones(const int&, const int&) const; + int getZones(const int&, const int&) const; - int get_zones(const int&, const int&, const int&) const; + int getZones(const int&, const int&, const int&) const; private: std::vector zones_; diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h index 4d989d5aaaaab..698c508ce9e33 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h @@ -9,31 +9,31 @@ namespace emtf::phase2::csc { enum Facing { kFront, kRear, kNone }; // Chambers - int next_10deg_chamber(int chamber); + int getNext10DegChamber(int chamber); - int prev_10deg_chamber(int chamber); + int getPrev10DegChamber(int chamber); - int next_20deg_chamber(int chamber); + int getNext20DegChamber(int chamber); - int prev_20deg_chamber(int chamber); + int getPrev20DegChamber(int chamber); // Functions - bool is_in_sector(int match_endcap, int match_sector, int tp_endcap, int tp_sector); + bool isTPInSector(int match_endcap, int match_sector, int tp_endcap, int tp_sector); - bool is_in_neighbor_sector( + bool isTPInNeighborSector( int match_endcap, int match_sector, int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_id); - int get_id(int ring, int station, int chamber); + int getId(int ring, int station, int chamber); - int get_trigger_sector(int ring, int station, int chamber); + int getTriggerSector(int ring, int station, int chamber); - int get_trigger_subsector(int station, int chamber); + int getTriggerSubsector(int station, int chamber); - Facing get_face_direction(int station, int ring, int chamber); + Facing getFaceDirection(int station, int ring, int chamber); - std::pair get_max_strip_and_wire(int station, int ring); + std::pair getMaxStripAndWire(int station, int ring); - std::pair get_max_pattern_and_quality(int station, int ring); + std::pair getMaxPatternAndQuality(int station, int ring); } // namespace emtf::phase2::csc diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h index 26bbea9f39715..dec8841acf8bd 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DataUtils.h @@ -13,7 +13,7 @@ namespace emtf::phase2::data { // Merge-Sort template - void swap_wires(T arr[], const int& wire_1, const int& wire_2, const C& comparator) { + void swapWires(T arr[], const unsigned int& wire_1, const unsigned int& wire_2, const C& comparator) { int result = comparator(arr[wire_1], arr[wire_2]); if (result == 1) { @@ -24,17 +24,17 @@ namespace emtf::phase2::data { } template - void mergesort_block(T arr[], - const int& offset, - const int& step, - const int& block_begin, - const int& block_end, - const int& first_n, - const C& comparator) { - int wire_offset = offset + block_begin; - int wire_cutoff = first_n + block_begin; - int wire_1 = wire_offset; - int wire_2 = wire_1 + step; + void mergesortBlock(T arr[], + const unsigned int& offset, + const unsigned int& step, + const unsigned int& block_begin, + const unsigned int& block_end, + const unsigned int& first_n, + const C& comparator) { + auto wire_offset = offset + block_begin; + auto wire_cutoff = first_n + block_begin; + auto wire_1 = wire_offset; + auto wire_2 = wire_1 + step; // Loop pairs while (wire_2 < block_end) { @@ -48,7 +48,7 @@ namespace emtf::phase2::data { } // Swap Wires - swap_wires(arr, wire_1, wire_2, comparator); + swapWires(arr, wire_1, wire_2, comparator); // Calculate next wire_1 if (step == 1) { @@ -63,18 +63,18 @@ namespace emtf::phase2::data { } template - void mergesort(T arr[], const int& arr_size, const int& first_n, const C& comparator) { + void mergesort(T arr[], const unsigned int& arr_size, const unsigned int& first_n, const C& comparator) { // Sort - int n_pairs = arr_size / 2; + auto n_pairs = static_cast(arr_size / 2); - for (int i = 0; i < n_pairs; ++i) { - swap_wires(arr, 2 * i, 2 * i + 1, comparator); + for (unsigned int i = 0; i < n_pairs; ++i) { + swapWires(arr, 2 * i, 2 * i + 1, comparator); } // Merge - int offset = 0; - int step = 2; - int block_size = step * 2; + auto offset = 0u; + auto step = 2u; + auto block_size = step * 2; // Loop block sizes while (true) { @@ -84,8 +84,8 @@ namespace emtf::phase2::data { // to not contribute to the end result while (true) { // Loop blocks - int block_begin = 0; - int block_end = block_size; + auto block_begin = 0u; + auto block_end = block_size; while (block_begin < arr_size) { // Constrain block_end @@ -93,7 +93,7 @@ namespace emtf::phase2::data { block_end = arr_size; // Merge block - mergesort_block(arr, offset, step, block_begin, block_end, first_n, comparator); + mergesortBlock(arr, offset, step, block_begin, block_end, first_n, comparator); // Move to next block block_begin = block_end; @@ -131,13 +131,13 @@ namespace emtf::phase2::data { } template - void mergesort(T arr[], const int& arr_size, const C& comparator) { + void mergesort(T arr[], const unsigned int& arr_size, const C& comparator) { mergesort(arr, arr_size, 0, comparator); } // Median Calculation template - T median_of_sorted(T arr[], const int& arr_size) { + T getMedianOfSorted(T arr[], const unsigned int& arr_size) { T mid; if ((arr_size % 2) == 0) { diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h index 86194577465d8..a748f200bc41e 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/Utils/TPUtils.h @@ -5,41 +5,41 @@ namespace emtf::phase2::tp { // _______________________________________________________________________ // radians <-> degrees - float deg_to_rad(float deg); + float degToRad(float deg); - float rad_to_deg(float rad); + float radToDeg(float rad); // _______________________________________________________________________ // phi range: [-180..180] or [-pi..pi] - float wrap_phi_deg(float); + float wrapPhiDeg(float); - float wrap_phi_rad(float); + float wrapPhiRad(float); // _______________________________________________________________________ // theta - float calc_theta_rad_from_eta(float); + float calcThetaRadFromEta(float); - float calc_theta_deg_from_eta(float); + float calcThetaDegFromEta(float); - float calc_theta_deg_from_int(int); + float calcThetaRadFromInt(int); - float calc_theta_rad_from_int(int); + float calcThetaDegFromInt(int); - int calc_theta_int(int, float); + int calcThetaInt(int, float); // _______________________________________________________________________ // phi - float calc_phi_glob_deg_from_loc(int, float); + float calcPhiGlobDegFromLoc(int, float); - float calc_phi_glob_rad_from_loc(int, float); + float calcPhiGlobRadFromLoc(int, float); - float calc_phi_loc_deg_from_int(int); + float calcPhiLocDegFromInt(int); - float calc_phi_loc_rad_from_int(int); + float calcPhiLocRadFromInt(int); - float calc_phi_loc_deg_from_glob(int, float); + float calcPhiLocDegFromGlob(int, float); - int calc_phi_int(int, float); + int calcPhiInt(int, float); } // namespace emtf::phase2::tp diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc index 3cb50bd123b75..70f5354307131 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/DuplicateRemovalLayer.cc @@ -86,7 +86,7 @@ void DuplicateRemovalLayer::apply(std::vector& tracks) const { continue; // Compare reduced track sites - for (int k_rsite = 0; k_rsite < v3::kNumTrackSitesRM; ++k_rsite) { // Begin loop reduced sites k + for (unsigned int k_rsite = 0; k_rsite < v3::kNumTrackSitesRM; ++k_rsite) { // Begin loop reduced sites k const auto& rtrk_site_mask_ik = rtrk_i.site_mask[k_rsite]; const auto& rtrk_site_mask_jk = rtrk_j.site_mask[k_rsite]; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc index d54f576586927..bca1748d2b2e2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/HitmapLayer.cc @@ -15,9 +15,9 @@ void HitmapLayer::apply(const segment_collection_t& segments, std::vector().data(); - for (int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { + for (unsigned int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { const auto& feature = features[i_feature]; const auto& feature_site = feature_sites[i_feature]; @@ -119,9 +119,9 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector(dxy_address, -512, 511); track.q = (track.pt_address < 0); - track.pt = context_.activation_lut_.lookup_disp_pt(track.pt_address); - track.rels = context_.activation_lut_.lookup_rels(track.rels_address); - track.dxy = context_.activation_lut_.lookup_dxy(track.dxy_address); + track.pt = context_.activation_lut_.lookupDispPt(track.pt_address); + track.rels = context_.activation_lut_.lookupRels(track.rels_address); + track.dxy = context_.activation_lut_.lookupDxy(track.dxy_address); } else { // Read prompt pb outputs auto pt_address = outputs[0].matrix()(0, 0); @@ -132,8 +132,8 @@ void ParameterAssignmentLayer::apply(const bool& displaced_en, std::vector& zone_hitmaps, // Initialize roads auto& roads = zone_roads.emplace_back(); - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + for (unsigned int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { roads[i_col].pattern = 0; roads[i_col].quality = 0; } @@ -45,12 +45,12 @@ void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, // Initialize activations pattern_activation_collection_t pac; - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + for (unsigned int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { pac[i_col] = 0; } // Build activations - for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { // Loop Rows + for (unsigned int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { // Loop Rows // Pad the row with zeros to cover cases where // pattern range is out of range const auto& hitmap_row = hitmap[i_row]; @@ -67,15 +67,15 @@ void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, // Convert the model pattern row to a padded row padded_row_t padded_pat_row = 0; - int offset = model_pat_row.begin; + unsigned int offset = model_pat_row.begin; - int bw = model_pat_row.end - model_pat_row.begin + 1; // Add 1 since it's an inclusive range + unsigned int bw = model_pat_row.end - model_pat_row.begin + 1; // Add 1 since it's an inclusive range - for (int i_bit = 0; i_bit < bw; ++i_bit) + for (unsigned int i_bit = 0; i_bit < bw; ++i_bit) padded_pat_row |= (padded_one << (offset + i_bit)); // Slide the pattern row across the hitmap and check for 'activations' - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + for (unsigned int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { // "AND" both rows together if the result is greater than 0 // there is an activation padded_row_t result = padded_pat_row & padded_hm_row; @@ -94,7 +94,7 @@ void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, // Note: Since this is in a loop going from smallest pattern number // to the largest, cases where the quality is the same, // but the pattern number is larger the smaller one will be preferred - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + for (unsigned int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { auto& activation = pac[i_col]; auto quality = (*model_ql)[activation]; @@ -109,7 +109,7 @@ void PatternMatchingLayer::apply(const std::vector& zone_hitmaps, // Debug Info if (this->context_.config_.verbosity_ > 1) { - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + for (unsigned int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { if (roads[i_col].quality == 0) { continue; } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc index d98adffcc72a4..d085e9a25d2d8 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/RoadSortingLayer.cc @@ -10,7 +10,7 @@ using namespace emtf::phase2::algo; RoadSortingLayer::RoadSortingLayer(const EMTFContext& context) : context_(context) {} -void RoadSortingLayer::apply(const int& first_n, +void RoadSortingLayer::apply(const unsigned int& first_n, const std::vector& zone_roads, std::vector& best_roads) const { // Find the best roads from each zone @@ -26,7 +26,7 @@ void RoadSortingLayer::apply(const int& first_n, { const int last_col = v3::kHitmapNCols - 1; - for (int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { + for (unsigned int i_col = 0; i_col < v3::kHitmapNCols; ++i_col) { bool is_local_max = true; bool is_last_col = i_col == last_col; bool is_first_col = i_col == 0; @@ -72,7 +72,7 @@ void RoadSortingLayer::apply(const int& first_n, road_t roads_kept[keep_n_roads]; { - for (int i_col = 0; i_col < keep_n_roads; ++i_col) { + for (unsigned int i_col = 0; i_col < keep_n_roads; ++i_col) { bool is_single = (i_col * 2 + 1) >= v3::kHitmapNCols; if (is_single || suppressed_roads[i_col * 2].quality > 0) { @@ -97,7 +97,7 @@ void RoadSortingLayer::apply(const int& first_n, roads_kept, 32, 16, [](const road_t& lhs, const road_t& rhs) -> int { return lhs.quality < rhs.quality; }); // Shift everything 16 cols to the left - for (int i = 16; i < keep_n_roads; ++i) { + for (unsigned int i = 16; i < keep_n_roads; ++i) { roads_kept[i] = roads_kept[i + 16]; } @@ -107,7 +107,7 @@ void RoadSortingLayer::apply(const int& first_n, }); // Collect best roads - for (int i_col = 0; i_col < first_n; ++i_col) { + for (unsigned int i_col = 0; i_col < first_n; ++i_col) { top_roads.push_back(roads_kept[i_col]); } } // End Loop Zones @@ -143,7 +143,7 @@ void RoadSortingLayer::apply(const int& first_n, &top_roads[0], 8, first_n, [](const road_t& lhs, const road_t& rhs) -> int { return lhs.quality < rhs.quality; }); // Collect best roads - for (int i_road = 0; i_road < first_n; ++i_road) { + for (unsigned int i_road = 0; i_road < first_n; ++i_road) { const auto& road = top_roads[i_road]; best_roads.push_back(road); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc index 16fdc1fd7ddca..14fb5cb966137 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Algo/TrackBuildingLayer.cc @@ -32,7 +32,7 @@ seg_theta_t TrackBuildingLayer::calc_theta_median(std::vector theta return thetas[0]; } else { // Calculate the median if all thetas are valid - return data::median_of_sorted(&thetas[0], thetas.size()); + return data::getMedianOfSorted(&thetas[0], thetas.size()); } } @@ -54,13 +54,13 @@ void TrackBuildingLayer::apply(const segment_collection_t& segments, track.theta = 0; track.valid = 0; - for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + for (unsigned int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { track.site_segs[site_id] = 0; track.site_mask[site_id] = 0; track.site_rm_mask[site_id] = 0; } - for (int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { + for (unsigned int i_feature = 0; i_feature < v3::kNumTrackFeatures; ++i_feature) { track.features[i_feature] = 0; } @@ -86,7 +86,7 @@ void TrackBuildingLayer::apply(const segment_collection_t& segments, } // Attach segments - attach_segments(segments, road, displaced_en, track); + attachSegments(segments, road, displaced_en, track); // Debug Info if (this->context_.config_.verbosity_ > 1) { @@ -103,10 +103,10 @@ void TrackBuildingLayer::apply(const segment_collection_t& segments, } } -void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, - const road_t& road, - const bool& displaced_en, - track_t& track) const { +void TrackBuildingLayer::attachSegments(const segment_collection_t& segments, + const road_t& road, + const bool& displaced_en, + track_t& track) const { // =========================================================================== // Constants // --------------------------------------------------------------------------- @@ -134,7 +134,7 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, std::array trk_seg_phi_diff; std::array trk_seg_theta; - for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + for (unsigned int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { trk_seg_phi_diff[site_id] = 0; trk_seg_theta[site_id] = 0; } @@ -174,7 +174,7 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, std::array trk_pat_end; std::array trk_pat_phi; - for (int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { + for (unsigned int i_row = 0; i_row < v3::kHitmapNRows; ++i_row) { // Get the model pattern const auto& model_pat_row = (*model_pat)[i_row]; @@ -204,7 +204,6 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, // =========================================================================== // Select segments using phi only // --------------------------------------------------------------------------- - int n_rows = model_hm.size(); // clang-format off std::vector> site_chambers = { @@ -233,7 +232,9 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, }; // clang-format on - for (int i_row = 0; i_row < n_rows; ++i_row) { // Begin loop rows + auto n_rows = model_hm.size(); + + for (unsigned int i_row = 0; i_row < n_rows; ++i_row) { // Begin loop rows const auto& model_hm_row = model_hm[i_row]; @@ -266,7 +267,7 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, int chamber_id = s_chambers[chamber_idx]; - for (int i_ch_seg = 0; i_ch_seg < v3::kChamberSegments; ++i_ch_seg) { // Begin loop segments + for (unsigned int i_ch_seg = 0; i_ch_seg < v3::kChamberSegments; ++i_ch_seg) { // Begin loop segments const int seg_id = chamber_id * v3::kChamberSegments + i_ch_seg; const auto& seg = segments[seg_id]; @@ -440,7 +441,7 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, // clang-format on } - for (int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { + for (unsigned int site_id = 0; site_id < v3::kNumTrackSites; ++site_id) { auto& site_bit = track.site_mask[site_id]; auto& site_rm_bit = track.site_rm_mask[site_id]; @@ -558,7 +559,7 @@ void TrackBuildingLayer::attach_segments(const segment_collection_t& segments, << " rel_phi " << trk_rel_phi << " abs_theta " << track.theta << " features " << std::endl; - for (int i = 0; i < v3::kNumTrackFeatures; ++i) { + for (unsigned int i = 0; i < v3::kNumTrackFeatures; ++i) { if (i > 0) { edm::LogInfo("L1TEMTFpp") << " "; } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc index 90980efbca7ed..4d88c4c2c4bc5 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPCollector.cc @@ -106,12 +106,12 @@ void CSCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } // Calculate detector info - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const auto tp_face_dir = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::getTriggerSubsector(tp_station, tp_chamber); + const auto tp_face_dir = csc::getFaceDirection(tp_station, tp_ring, tp_chamber); // Assertion checks - const auto& [max_strip, max_wire] = csc::get_max_strip_and_wire(tp_station, tp_ring); - const auto& [max_pattern, max_quality] = csc::get_max_pattern_and_quality(tp_station, tp_ring); + const auto& [max_strip, max_wire] = csc::getMaxStripAndWire(tp_station, tp_ring); + const auto& [max_pattern, max_quality] = csc::getMaxPatternAndQuality(tp_station, tp_ring); emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc index f46d46bf6fd2d..2b014e3e0595f 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPConverter.cc @@ -77,19 +77,19 @@ void CSCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, // Get Global Coordinates const GlobalPoint& gp_w1 = this->context_.geometry_translator_.getGlobalPoint(tp); - const float glob_phi_w1 = tp::rad_to_deg(gp_w1.phi().value()); - const float glob_theta_w1 = tp::rad_to_deg(gp_w1.theta().value()); + const float glob_phi_w1 = tp::radToDeg(gp_w1.phi().value()); + const float glob_theta_w1 = tp::radToDeg(gp_w1.theta().value()); const double glob_rho_w1 = gp_w1.perp(); const double glob_z_w1 = gp_w1.z(); // Calculate EMTF Values - const int emtf_phi_w1 = tp::calc_phi_int(sector_, glob_phi_w1); + const int emtf_phi_w1 = tp::calcPhiInt(sector_, glob_phi_w1); const int emtf_bend_w1 = std::clamp(tp_bend * 4, -16, 15); // 5-bit, signed - const int emtf_theta_w1 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w1); + const int emtf_theta_w1 = tp::calcThetaInt(tp_endcap_pm, glob_theta_w1); const int emtf_qual_w1 = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned const int emtf_site_w1 = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); const int emtf_host_w1 = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones_w1 = context_.zone_lut_.get_zones(emtf_host_w1, emtf_theta_w1); + const int emtf_zones_w1 = context_.zone_lut_.getZones(emtf_host_w1, emtf_theta_w1); // Calculated Ambiguous Info int emtf_theta_w2 = 0; @@ -101,9 +101,9 @@ void CSCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, tp_w2.accessCSCData().keywire = tp_wire2; const GlobalPoint& gp_w2 = this->context_.geometry_translator_.getGlobalPoint(tp_w2); - const double glob_theta_w2 = tp::rad_to_deg(gp_w2.theta().value()); + const double glob_theta_w2 = tp::radToDeg(gp_w2.theta().value()); - emtf_theta_w2 = tp::calc_theta_int(tp_endcap_pm, glob_theta_w2); + emtf_theta_w2 = tp::calcThetaInt(tp_endcap_pm, glob_theta_w2); } emtf_assert((0 <= emtf_phi_w1) and (emtf_phi_w1 < 5040)); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc index d510e097880d8..383856addd562 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/CSCTPSelector.cc @@ -19,21 +19,21 @@ void CSCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM emtf_assert(tp.subsystem() == L1TMuon::kCSC); // Map CSC trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns CSC "link" index (0 - 53) + int ilink = getInputLink(tp, tp_info); // Returns CSC "link" index (0 - 53) // Short-Circuit: Link not found (ilink = -1) if (ilink < 0) { return; } - // FIXME + // Should have at most 2 TP if (ilink_tpc_map[ilink].size() < 2) { ilink_tpc_map[ilink].emplace_back(tp, tp_info); } else { edm::LogWarning("L1TEMTFpp") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************"; edm::LogWarning("L1TEMTFpp") << "Found 3 CSC trigger primitives in the same chamber"; - for (int i_tp = 0; i_tp < 3; i_tp++) { + for (unsigned int i_tp = 0; i_tp < 3; i_tp++) { const auto& tp_err = ((i_tp < 2) ? ilink_tpc_map[ilink].at(i_tp).tp_ : tp); edm::LogWarning("L1TEMTFpp") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap " @@ -52,7 +52,7 @@ void CSCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM // =========================================================================== // Utils // =========================================================================== -int CSCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { +int CSCTPSelector::getInputLink(const TriggerPrimitive& tp, TPInfo& tp_info) const { int ilink = -1; // Unpack detector info @@ -66,17 +66,17 @@ int CSCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c // Find selection type auto tp_selection = TPSelection::kNone; - if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; } else if (this->context_.config_.include_neighbor_en_ && - csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone return ilink; } // Get chamber input link for this sector processor - ilink = calculate_input_link(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); + ilink = calcInputLink(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); // Add selection info tp_info.ilink = ilink; @@ -86,11 +86,11 @@ int CSCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c } // Returns CSC input "link". Index used by FW for unique chamber identification. -int CSCTPSelector::calculate_input_link(const int& tp_subsector, - const int& tp_station, - const int& tp_ring, - const int& tp_csc_id, - const TPSelection& tp_selection) const { +int CSCTPSelector::calcInputLink(const int& tp_subsector, + const int& tp_station, + const int& tp_ring, + const int& tp_csc_id, + const TPSelection& tp_selection) const { int ilink = -1; // Links diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc index 3c1754ca97da2..a029372420bef 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPCollector.cc @@ -79,28 +79,28 @@ void GE0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co // positive endcap // phiposition increases counter-clockwise if (tp_phiposition < phiposition_q1) { - tp_chamber = csc::next_10deg_chamber(tp_chamber); + tp_chamber = csc::getNext10DegChamber(tp_chamber); } else if (tp_phiposition < phiposition_q3) { // Do nothing } else { - tp_chamber = csc::prev_10deg_chamber(tp_chamber); + tp_chamber = csc::getPrev10DegChamber(tp_chamber); } } else { // negative endcap // phiposition increases clockwise if (tp_phiposition < phiposition_q1) { - tp_chamber = csc::prev_10deg_chamber(tp_chamber); + tp_chamber = csc::getPrev10DegChamber(tp_chamber); } else if (tp_phiposition < phiposition_q3) { // Do nothing } else { - tp_chamber = csc::next_10deg_chamber(tp_chamber); + tp_chamber = csc::getNext10DegChamber(tp_chamber); } } - const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); - const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + const int tp_sector = csc::getTriggerSector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::getTriggerSubsector(tp_station, tp_chamber); + const int tp_csc_id = csc::getId(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::getFaceDirection(tp_station, tp_ring, tp_chamber); // Assertion checks emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc index 844fdff5ba751..b136e8db897c6 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPConverter.cc @@ -61,19 +61,19 @@ void GE0TPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, // Get Global Coordinates const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp); - const float glob_phi = tp::rad_to_deg(gp.phi().value()); - const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const float glob_phi = tp::radToDeg(gp.phi().value()); + const float glob_theta = tp::radToDeg(gp.theta().value()); const double glob_rho = gp.perp(); const double glob_z = gp.z(); // Calculate EMTF Values - const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_phi = tp::calcPhiInt(sector_, glob_phi); const int emtf_bend = std::clamp(tp_bend / 2, -64, 63); // 7-bit, signed - const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_theta = tp::calcThetaInt(tp_endcap_pm, glob_theta); const int emtf_qual = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + const int emtf_zones = context_.zone_lut_.getZones(emtf_host, emtf_theta); emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc index e9bdfb49b2865..9f3ca2f9972f2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GE0TPSelector.cc @@ -19,7 +19,7 @@ void GE0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM emtf_assert(tp.subsystem() == L1TMuon::kME0); // Map GE0 trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns GE0 "link" index + int ilink = getInputLink(tp, tp_info); // Returns GE0 "link" index // Short-Circuit: Link not found (ilink = -1) if (ilink < 0) { @@ -32,7 +32,7 @@ void GE0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM // =========================================================================== // Utils // =========================================================================== -int GE0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { +int GE0TPSelector::getInputLink(const TriggerPrimitive& tp, TPInfo& tp_info) const { int ilink = -1; // Unpack detector info @@ -45,17 +45,17 @@ int GE0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c // Find selection type auto tp_selection = TPSelection::kNone; - if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; } else if (this->context_.config_.include_neighbor_en_ && - csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone return ilink; } // Get chamber input link for this sector processor - ilink = calculate_input_link(tp_subsector, tp_csc_id, tp_selection); + ilink = calcInputLink(tp_subsector, tp_csc_id, tp_selection); // Add selection info tp_info.ilink = ilink; @@ -64,9 +64,7 @@ int GE0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c return ilink; } -int GE0TPSelector::calculate_input_link(const int& tp_subsector, - const int& tp_csc_id, - const TPSelection& tp_selection) const { +int GE0TPSelector::calcInputLink(const int& tp_subsector, const int& tp_csc_id, const TPSelection& tp_selection) const { int ilink = -1; // Links diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc index 38b21a0589fa4..b6dd63ecafaae 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPCollector.cc @@ -145,10 +145,10 @@ void GEMTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co } // Calculate EMTF Info - const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); - const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + const int tp_sector = csc::getTriggerSector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::getTriggerSubsector(tp_station, tp_chamber); + const int tp_csc_id = csc::getId(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::getFaceDirection(tp_station, tp_ring, tp_chamber); // Assertion checks emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc index 41ab1b95b359b..6765afff669d3 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPConverter.cc @@ -66,19 +66,19 @@ void GEMTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, // Get Global Coordinates // const GlobalPoint& gp = get_global_point(detgeom, detid, digi); const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp); - const float glob_phi = tp::rad_to_deg(gp.phi().value()); - const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const float glob_phi = tp::radToDeg(gp.phi().value()); + const float glob_theta = tp::radToDeg(gp.theta().value()); const double glob_rho = gp.perp(); const double glob_z = gp.z(); // Calculate EMTF Values - const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_phi = tp::calcPhiInt(sector_, glob_phi); const int emtf_bend = 0; - const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_theta = tp::calcThetaInt(tp_endcap_pm, glob_theta); const int emtf_qual = 0; const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + const int emtf_zones = context_.zone_lut_.getZones(emtf_host, emtf_theta); emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc index 44c90c57d2a4f..5a47d8020ad68 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/GEMTPSelector.cc @@ -19,7 +19,7 @@ void GEMTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM emtf_assert(tp.subsystem() == L1TMuon::kGEM); // Map GEM trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns GEM "link" index + int ilink = getInputLink(tp, tp_info); // Returns GEM "link" index // Short-Circuit: Link not found (ilink = -1) if (ilink < 0) { @@ -32,7 +32,7 @@ void GEMTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM // =========================================================================== // Utils // =========================================================================== -int GEMTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { +int GEMTPSelector::getInputLink(const TriggerPrimitive& tp, TPInfo& tp_info) const { int ilink = -1; // Unpack detector info @@ -46,17 +46,17 @@ int GEMTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c // Find selection type auto tp_selection = TPSelection::kNone; - if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; } else if (this->context_.config_.include_neighbor_en_ && - csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone return ilink; } // Get chamber input link for this sector processor - ilink = calculate_input_link(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); + ilink = calcInputLink(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); // Add selection info tp_info.ilink = ilink; @@ -65,11 +65,11 @@ int GEMTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c return ilink; } -int GEMTPSelector::calculate_input_link(const int& tp_subsector, - const int& tp_station, - const int& tp_ring, - const int& tp_csc_id, - const TPSelection& tp_selection) const { +int GEMTPSelector::calcInputLink(const int& tp_subsector, + const int& tp_station, + const int& tp_ring, + const int& tp_csc_id, + const TPSelection& tp_selection) const { int ilink = -1; // Links diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc index a6bed4b686dd5..0c10b6fa201b2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPCollector.cc @@ -79,28 +79,28 @@ void ME0TPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co // positive endcap // phiposition increases counter-clockwise if (tp_phiposition < phiposition_q1) { - tp_chamber = csc::next_10deg_chamber(tp_chamber); + tp_chamber = csc::getNext10DegChamber(tp_chamber); } else if (tp_phiposition < phiposition_q3) { // Do nothing } else { - tp_chamber = csc::prev_10deg_chamber(tp_chamber); + tp_chamber = csc::getPrev10DegChamber(tp_chamber); } } else { // negative endcap // phiposition increases clockwise if (tp_phiposition < phiposition_q1) { - tp_chamber = csc::prev_10deg_chamber(tp_chamber); + tp_chamber = csc::getPrev10DegChamber(tp_chamber); } else if (tp_phiposition < phiposition_q3) { // Do nothing } else { - tp_chamber = csc::next_10deg_chamber(tp_chamber); + tp_chamber = csc::getNext10DegChamber(tp_chamber); } } - const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); - const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + const int tp_sector = csc::getTriggerSector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::getTriggerSubsector(tp_station, tp_chamber); + const int tp_csc_id = csc::getId(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::getFaceDirection(tp_station, tp_ring, tp_chamber); // Assertion checks emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc index 3a694752d784b..7b3a5f8a1f704 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPConverter.cc @@ -61,19 +61,19 @@ void ME0TPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, // Get Global Coordinates const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp); - const float glob_phi = tp::rad_to_deg(gp.phi().value()); - const float glob_theta = tp::rad_to_deg(gp.theta().value()); + const float glob_phi = tp::radToDeg(gp.phi().value()); + const float glob_theta = tp::radToDeg(gp.theta().value()); const double glob_rho = gp.perp(); const double glob_z = gp.z(); // Calculate EMTF Values - const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_phi = tp::calcPhiInt(sector_, glob_phi); const int emtf_bend = std::clamp(tp_bend / 2, -64, 63); // 7-bit, signed - const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_theta = tp::calcThetaInt(tp_endcap_pm, glob_theta); const int emtf_qual = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + const int emtf_zones = context_.zone_lut_.getZones(emtf_host, emtf_theta); emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc index 575b3f3c32391..0cf5bdc94fe92 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/ME0TPSelector.cc @@ -19,7 +19,7 @@ void ME0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM emtf_assert(tp.subsystem() == L1TMuon::kME0); // Map ME0 trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns ME0 "link" index + int ilink = getInputLink(tp, tp_info); // Returns ME0 "link" index // Short-Circuit: Link not found (ilink = -1) if (ilink < 0) { @@ -32,7 +32,7 @@ void ME0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM // =========================================================================== // Utils // =========================================================================== -int ME0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { +int ME0TPSelector::getInputLink(const TriggerPrimitive& tp, TPInfo& tp_info) const { int ilink = -1; // Unpack detector info @@ -45,17 +45,17 @@ int ME0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c // Find selection type auto tp_selection = TPSelection::kNone; - if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; } else if (this->context_.config_.include_neighbor_en_ && - csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone return ilink; } // Get chamber input link for this sector processor - ilink = calculate_input_link(tp_subsector, tp_csc_id, tp_selection); + ilink = calcInputLink(tp_subsector, tp_csc_id, tp_selection); // Add selection info tp_info.ilink = ilink; @@ -64,9 +64,7 @@ int ME0TPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c return ilink; } -int ME0TPSelector::calculate_input_link(const int& tp_subsector, - const int& tp_csc_id, - const TPSelection& tp_selection) const { +int ME0TPSelector::calcInputLink(const int& tp_subsector, const int& tp_csc_id, const TPSelection& tp_selection) const { int ilink = -1; // Links diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc index c2e936be44e14..edb44b095a352 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPCollector.cc @@ -110,10 +110,10 @@ void RPCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) co tp_chamber = (tp_rpc_sector - 1) * 6 + tp_rpc_subsector; } - const int tp_sector = csc::get_trigger_sector(tp_station, tp_ring, tp_chamber); - const int tp_subsector = csc::get_trigger_subsector(tp_station, tp_chamber); - const int tp_csc_id = csc::get_id(tp_station, tp_ring, tp_chamber); - const auto tp_csc_facing = csc::get_face_direction(tp_station, tp_ring, tp_chamber); + const int tp_sector = csc::getTriggerSector(tp_station, tp_ring, tp_chamber); + const int tp_subsector = csc::getTriggerSubsector(tp_station, tp_chamber); + const int tp_csc_id = csc::getId(tp_station, tp_ring, tp_chamber); + const auto tp_csc_facing = csc::getFaceDirection(tp_station, tp_ring, tp_chamber); // Assertion checks emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc index 7b3d08fa01a8a..52cada1253ed0 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPConverter.cc @@ -90,27 +90,27 @@ void RPCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, dynamic_cast(this->context_.geometry_translator_.getRPCGeometry().roll(tp_det_id)); const GlobalPoint& irpc_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0)); - glob_phi = tp::rad_to_deg(irpc_gp.phi().value()); - glob_theta = tp::rad_to_deg(irpc_gp.theta().value()); + glob_phi = tp::radToDeg(irpc_gp.phi().value()); + glob_theta = tp::radToDeg(irpc_gp.theta().value()); glob_rho = irpc_gp.perp(); glob_z = irpc_gp.z(); } else { // Handle RPC Coordinates const GlobalPoint& gp = this->context_.geometry_translator_.getGlobalPoint(tp); - glob_phi = tp::rad_to_deg(gp.phi().value()); - glob_theta = tp::rad_to_deg(gp.theta().value()); + glob_phi = tp::radToDeg(gp.phi().value()); + glob_theta = tp::radToDeg(gp.theta().value()); glob_rho = gp.perp(); glob_z = gp.z(); } // Calculate EMTF Values - const int emtf_phi = tp::calc_phi_int(sector_, glob_phi); + const int emtf_phi = tp::calcPhiInt(sector_, glob_phi); const int emtf_bend = 0; - const int emtf_theta = tp::calc_theta_int(tp_endcap_pm, glob_theta); + const int emtf_theta = tp::calcThetaInt(tp_endcap_pm, glob_theta); const int emtf_qual = 0; const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring}); const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring}); - const int emtf_zones = context_.zone_lut_.get_zones(emtf_host, emtf_theta); + const int emtf_zones = context_.zone_lut_.getZones(emtf_host, emtf_theta); emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040)); emtf_assert((1 <= emtf_theta) and (emtf_theta < 128)); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc index 410aa73e750b5..628ba6a8d4804 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/DAQ/RPCTPSelector.cc @@ -20,7 +20,7 @@ void RPCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM emtf_assert(tp.subsystem() == L1TMuon::kRPC); // Map RPC trigger primitives to input links - int ilink = get_input_link(tp, tp_info); // Returns RPC "link" index + int ilink = getInputLink(tp, tp_info); // Returns RPC "link" index // Short-Circuit: Link not found (ilink = -1) if (ilink < 0) { @@ -33,7 +33,7 @@ void RPCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCM // =========================================================================== // Utils // =========================================================================== -int RPCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) const { +int RPCTPSelector::getInputLink(const TriggerPrimitive& tp, TPInfo& tp_info) const { int ilink = -1; // Unpack detector info @@ -55,17 +55,17 @@ int RPCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c // Find selection type auto tp_selection = TPSelection::kNone; - if (csc::is_in_sector(endcap_, sector_, tp_endcap, tp_sector)) { + if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) { tp_selection = TPSelection::kNative; } else if (this->context_.config_.include_neighbor_en_ && - csc::is_in_neighbor_sector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { + csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) { tp_selection = TPSelection::kNeighbor; } else { // Short-Circuit: tp_selection = TPSelection::kNone return ilink; } // Get chamber input link for this sector processor - ilink = calculate_input_link(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); + ilink = calcInputLink(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection); // Add selection info tp_info.ilink = ilink; @@ -74,11 +74,11 @@ int RPCTPSelector::get_input_link(const TriggerPrimitive& tp, TPInfo& tp_info) c return ilink; } -int RPCTPSelector::calculate_input_link(const int& tp_subsector, - const int& tp_station, - const int& tp_ring, - const int& tp_csc_id, - const TPSelection& tp_selection) const { +int RPCTPSelector::calcInputLink(const int& tp_subsector, + const int& tp_station, + const int& tp_ring, + const int& tp_csc_id, + const TPSelection& tp_selection) const { int ilink = -1; // Links diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc index 537114cc9ed6a..439983956200d 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ActivationLut.cc @@ -202,22 +202,22 @@ void ActivationLut::update(const edm::Event&, const edm::EventSetup&) { // Do Nothing } -const trk_pt_t& ActivationLut::lookup_prompt_pt(const trk_nn_address_t& address) const { +const trk_pt_t& ActivationLut::lookupPromptPt(const trk_nn_address_t& address) const { ap_uint<10> bin = address.to_string(AP_HEX).c_str(); return prompt_pt_lut_[bin]; } -const trk_pt_t& ActivationLut::lookup_disp_pt(const trk_nn_address_t& address) const { +const trk_pt_t& ActivationLut::lookupDispPt(const trk_nn_address_t& address) const { ap_uint<10> bin = address.to_string(AP_HEX).c_str(); return disp_pt_lut_[bin]; } -const trk_rels_t& ActivationLut::lookup_rels(const trk_nn_address_t& address) const { +const trk_rels_t& ActivationLut::lookupRels(const trk_nn_address_t& address) const { ap_uint<10> bin = address.to_string(AP_HEX).c_str(); return rels_lut_[bin]; } -const trk_dxy_t& ActivationLut::lookup_dxy(const trk_nn_address_t& address) const { +const trk_dxy_t& ActivationLut::lookupDxy(const trk_nn_address_t& address) const { ap_uint<10> bin = address.to_string(AP_HEX).c_str(); return dxy_lut_[bin]; } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc index ea4aed5d12d5f..09b0d170d2855 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/TimeZoneLut.cc @@ -40,7 +40,7 @@ void TimeZoneLut::update(const edm::Event&, const edm::EventSetup&) { // Do Nothing } -int TimeZoneLut::get_timezones(const int& host, const int& bx) const { +int TimeZoneLut::getTimezones(const int& host, const int& bx) const { auto found = lut_.find(host); // Short-Circuit: Host doesn't exist diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc index 77cc4ba7f58f1..9c73c5dc71bed 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Data/ZoneLut.cc @@ -52,7 +52,7 @@ void ZoneLut::update(const edm::Event&, const edm::EventSetup&) { // Do Nothing } -int ZoneLut::get_zones(const int& host, const int& theta) const { +int ZoneLut::getZones(const int& host, const int& theta) const { int i = 0; int word = 0; @@ -69,7 +69,7 @@ int ZoneLut::get_zones(const int& host, const int& theta) const { return word; } -int ZoneLut::get_zones(const int& host, const int& theta1, const int& theta2) const { +int ZoneLut::getZones(const int& host, const int& theta1, const int& theta2) const { int i = 0; int word = 0; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc index 797d656e05677..2b7abf0fb9ad2 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc @@ -270,7 +270,7 @@ void SectorProcessor::populate_segments(const std::vector& bx std::map& seg_to_hit, segment_collection_t& segments) { // Initialize - for (int seg_id = 0; seg_id < v3::kNumSegments; ++seg_id) { + for (unsigned int seg_id = 0; seg_id < v3::kNumSegments; ++seg_id) { segments[seg_id].phi = 0; segments[seg_id].bend = 0; segments[seg_id].theta1 = 0; @@ -328,7 +328,7 @@ void SectorProcessor::populate_segments(const std::vector& bx } // Calculate Timezone - const auto hit_timezones = context_.timezone_lut_.get_timezones(hit_host, hit_rel_bx); + const auto hit_timezones = context_.timezone_lut_.getTimezones(hit_host, hit_rel_bx); // Calculate algo seg const unsigned int seg_id = hit_chamber * v3::kChamberSegments + ch_seg; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc index 11159e778db51..0b3a6d42000ab 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc @@ -53,8 +53,8 @@ TrackFinder::TrackFinder(const edm::ParameterSet& i_config, edm::ConsumesCollect } // Register Sector Processor - for (int endcap = kMinEndcap; endcap <= kMaxEndcap; ++endcap) { - for (int sector = kMinTrigSector; sector <= kMaxTrigSector; ++sector) { + for (unsigned int endcap = kMinEndcap; endcap <= kMaxEndcap; ++endcap) { + for (unsigned int sector = kMinTrigSector; sector <= kMaxTrigSector; ++sector) { sector_processors_.push_back(std::make_unique(context_, endcap, sector)); } } diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc index 351fd503b58dd..30c6eabfc9982 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/CSCUtils.cc @@ -5,20 +5,20 @@ namespace emtf::phase2::csc { // Chambers - int next_10deg_chamber(int chamber) { return (chamber == 36) ? 1 : (chamber + 1); } + int getNext10DegChamber(int chamber) { return (chamber == 36) ? 1 : (chamber + 1); } - int prev_10deg_chamber(int chamber) { return (chamber == 1) ? 36 : (chamber - 1); } + int getPrev10DegChamber(int chamber) { return (chamber == 1) ? 36 : (chamber - 1); } - int next_20deg_chamber(int chamber) { return (chamber == 18) ? 1 : (chamber + 1); } + int getNext20DegChamber(int chamber) { return (chamber == 18) ? 1 : (chamber + 1); } - int prev_20deg_chamber(int chamber) { return (chamber == 1) ? 18 : (chamber - 1); } + int getPrev20DegChamber(int chamber) { return (chamber == 1) ? 18 : (chamber - 1); } // Sectors - bool is_in_sector(int sp_endcap, int sp_sector, int tp_endcap, int tp_sector) { + bool isTPInSector(int sp_endcap, int sp_sector, int tp_endcap, int tp_sector) { return sp_endcap == tp_endcap && sp_sector == tp_sector; } - bool is_in_neighbor_sector( + bool isTPInNeighborSector( int sp_endcap, int sp_sector, int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_id) { // Match endcap and neighbor sector int neighbor_sector = ((sp_sector == 1) ? 6 : sp_sector - 1); @@ -36,7 +36,7 @@ namespace emtf::phase2::csc { // Use CSC trigger "CSC ID" definitions // Copied from DataFormats/MuonDetId/src/CSCDetId.cc - int get_id(int station, int ring, int chamber) { + int getId(int station, int ring, int chamber) { int result = 0; if (station == 1) { @@ -67,7 +67,7 @@ namespace emtf::phase2::csc { // Use CSC trigger sector definitions // Copied from DataFormats/MuonDetId/src/CSCDetId.cc - int get_trigger_sector(int station, int ring, int chamber) { + int getTriggerSector(int station, int ring, int chamber) { int result = 0; if (station > 1 && ring > 1) { @@ -82,7 +82,7 @@ namespace emtf::phase2::csc { : 6; // max sector is 6, some calculations give a value greater than six but this is expected. } - int get_trigger_subsector(int station, int chamber) { + int getTriggerSubsector(int station, int chamber) { // station 2,3,4 --> subsector 0 if (station != 1) { return 0; @@ -97,7 +97,7 @@ namespace emtf::phase2::csc { } // Copied from RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.cc - Facing get_face_direction(int station, int ring, int chamber) { + Facing getFaceDirection(int station, int ring, int chamber) { bool is_not_overlapping = (station == 1 && ring == 3); // Not overlapping means it's facing backwards @@ -128,7 +128,7 @@ namespace emtf::phase2::csc { // | ME2/2, ME3/2, ME4/2 | 160 | 64 | // +----------------------------+------------+------------+ - std::pair get_max_strip_and_wire(int station, int ring) { + std::pair getMaxStripAndWire(int station, int ring) { int max_strip = 0; // halfstrip int max_wire = 0; // wiregroup @@ -158,7 +158,7 @@ namespace emtf::phase2::csc { return std::make_pair(max_strip, max_wire); } - std::pair get_max_pattern_and_quality(int station, int ring) { + std::pair getMaxPatternAndQuality(int station, int ring) { int max_pattern = 11; int max_quality = 16; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc index 5830d5945df80..dfd4d39dfc17c 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/Utils/TPUtils.cc @@ -6,12 +6,12 @@ namespace emtf::phase2::tp { // _______________________________________________________________________ // radians <-> degrees - float deg_to_rad(float deg) { + float degToRad(float deg) { constexpr float factor = M_PI / 180.; return deg * factor; } - float rad_to_deg(float rad) { + float radToDeg(float rad) { constexpr float factor = 180. / M_PI; return rad * factor; @@ -19,14 +19,14 @@ namespace emtf::phase2::tp { // _______________________________________________________________________ // phi range: [-180..180] or [-pi..pi] - float wrap_phi_deg(float deg) { + float wrapPhiDeg(float deg) { float twopi = 360.; float recip = 1.0 / twopi; return deg - (std::round(deg * recip) * twopi); } - float wrap_phi_rad(float rad) { + float wrapPhiRad(float rad) { const float twopi = M_PI * 2.; const float recip = 1.0 / twopi; @@ -35,33 +35,33 @@ namespace emtf::phase2::tp { // _______________________________________________________________________ // theta - float calc_theta_rad_from_eta(float eta) { + float calcThetaRadFromEta(float eta) { float theta = std::atan2(1.0, std::sinh(eta)); // cot(theta) = sinh(eta) return theta; } - float calc_theta_deg_from_eta(float eta) { - float theta = rad_to_deg(calc_theta_rad_from_eta(eta)); + float calcThetaDegFromEta(float eta) { + float theta = radToDeg(calcThetaRadFromEta(eta)); return theta; } - float calc_theta_deg_from_int(int theta_int) { - float theta = static_cast(theta_int); - - theta = theta * (45.0 - 8.5) / 128. + 8.5; + float calcThetaRadFromInt(int theta_int) { + float theta = degToRad(calcThetaDegFromInt(theta_int)); return theta; } - float calc_theta_rad_from_int(int theta_int) { - float theta = deg_to_rad(calc_theta_deg_from_int(theta_int)); + float calcThetaDegFromInt(int theta_int) { + float theta = static_cast(theta_int); + + theta = theta * (45.0 - 8.5) / 128. + 8.5; return theta; } - int calc_theta_int(int endcap, float theta) { // theta in deg [0..180], endcap [-1, +1] + int calcThetaInt(int endcap, float theta) { // theta in deg [0..180], endcap [-1, +1] theta = (endcap == -1) ? (180. - theta) : theta; theta = (theta - 8.5) * 128. / (45.0 - 8.5); @@ -74,7 +74,7 @@ namespace emtf::phase2::tp { // _______________________________________________________________________ // phi - float calc_phi_glob_deg_from_loc(int sector, float loc) { // loc in deg, sector [1..6] + float calcPhiGlobDegFromLoc(int sector, float loc) { // loc in deg, sector [1..6] float glob = loc + 15. + (60. * (sector - 1)); glob = (glob >= 180.) ? (glob - 360.) : glob; @@ -82,13 +82,13 @@ namespace emtf::phase2::tp { return glob; } - float calc_phi_glob_rad_from_loc(int sector, float loc) { // loc in rad, sector [1..6] - float glob = deg_to_rad(calc_phi_glob_deg_from_loc(sector, rad_to_deg(loc))); + float calcPhiGlobRadFromLoc(int sector, float loc) { // loc in rad, sector [1..6] + float glob = degToRad(calcPhiGlobDegFromLoc(sector, radToDeg(loc))); return glob; } - float calc_phi_loc_deg_from_int(int phi_int) { + float calcPhiLocDegFromInt(int phi_int) { float loc = static_cast(phi_int); loc = (loc / 60.) - 22.; @@ -96,22 +96,22 @@ namespace emtf::phase2::tp { return loc; } - float calc_phi_loc_rad_from_int(int phi_int) { - float loc = deg_to_rad(calc_phi_loc_deg_from_int(phi_int)); + float calcPhiLocRadFromInt(int phi_int) { + float loc = degToRad(calcPhiLocDegFromInt(phi_int)); return loc; } - float calc_phi_loc_deg_from_glob(int sector, float glob) { // glob in deg [-180..180], sector [1..6] - glob = wrap_phi_deg(glob); + float calcPhiLocDegFromGlob(int sector, float glob) { // glob in deg [-180..180], sector [1..6] + glob = wrapPhiDeg(glob); float loc = glob - 15. - (60. * (sector - 1)); return loc; } - int calc_phi_int(int sector, float glob) { // glob in deg [-180..180], sector [1..6] - float loc = calc_phi_loc_deg_from_glob(sector, glob); + int calcPhiInt(int sector, float glob) { // glob in deg [-180..180], sector [1..6] + float loc = calcPhiLocDegFromGlob(sector, glob); loc = ((loc + 22.) < 0.) ? (loc + 360.) : loc; loc = (loc + 22.) * 60.; From 685390350a7ab11bda1080dbf6a17e1814cddb68 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Tue, 5 Mar 2024 23:37:24 +0100 Subject: [PATCH 23/24] Switched to unsigned indexes for iteration, and applied naming conventions for L1TMuonEndcapPhase2 --- .../interface/SectorProcessor.h | 12 +++---- .../interface/TrackFinder.h | 4 +-- .../L1TMuonEndCapPhase2TrackProducer.cc | 4 +-- .../src/SectorProcessor.cc | 32 +++++++++---------- .../L1TMuonEndCapPhase2/src/TrackFinder.cc | 8 ++--- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h b/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h index a380192521bea..3054620698253 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/SectorProcessor.h @@ -12,9 +12,9 @@ namespace emtf::phase2 { ~SectorProcessor(); - void configure_event(const edm::Event&); + void configureEvent(const edm::Event&); - void configure_bx(const int&); + void configureBx(const int&); void select(const TriggerPrimitive&, const TPInfo&); @@ -36,13 +36,13 @@ namespace emtf::phase2 { std::map bx_ilink_tpc_maps_; // Helper functions - void copy_tp(const ILinkTPCMap& source, ILinkTPCMap& target) const; + void copyTP(const ILinkTPCMap& source, ILinkTPCMap& target) const; - void convert_tp(const int&, const ILinkTPCMap&, EMTFHitCollection&); + void convertTP(const int&, const ILinkTPCMap&, EMTFHitCollection&); - void populate_segments(const std::vector&, std::map&, segment_collection_t&); + void populateSegments(const std::vector&, std::map&, segment_collection_t&); - void build_tracks(const std::map&, const segment_collection_t&, const bool&, EMTFTrackCollection&); + void buildTracks(const std::map&, const segment_collection_t&, const bool&, EMTFTrackCollection&); }; } // namespace emtf::phase2 diff --git a/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h b/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h index ab8c8a3a41fbf..3a4f03e6210da 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h +++ b/L1Trigger/L1TMuonEndCapPhase2/interface/TrackFinder.h @@ -22,9 +22,9 @@ namespace emtf::phase2 { EMTFTrackCollection&, EMTFInputCollection&); - void on_job_begin(); + void onJobBegin(); - void on_job_end(); + void onJobEnd(); private: EMTFContext context_; diff --git a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc index 93d5d64046b1b..f332a9a6977f8 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/plugins/L1TMuonEndCapPhase2TrackProducer.cc @@ -71,9 +71,9 @@ void L1TMuonEndCapPhase2TrackProducer::produce(edm::Event& event, const edm::Eve event.emplace(in_token_, std::move(out_inputs)); } -void L1TMuonEndCapPhase2TrackProducer::beginStream(edm::StreamID stream_id) { track_finder_->on_job_begin(); } +void L1TMuonEndCapPhase2TrackProducer::beginStream(edm::StreamID stream_id) { track_finder_->onJobBegin(); } -void L1TMuonEndCapPhase2TrackProducer::endStream() { track_finder_->on_job_end(); } +void L1TMuonEndCapPhase2TrackProducer::endStream() { track_finder_->onJobEnd(); } //define this as a plug-in DEFINE_FWK_MODULE(L1TMuonEndCapPhase2TrackProducer); diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc index 2b7abf0fb9ad2..c64d2edecaec4 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/SectorProcessor.cc @@ -62,7 +62,7 @@ SectorProcessor::~SectorProcessor() { // Do Nothing } -void SectorProcessor::configure_event(const edm::Event& event) { +void SectorProcessor::configureEvent(const edm::Event& event) { // Event event_ = &event; bx_ = nullptr; @@ -72,7 +72,7 @@ void SectorProcessor::configure_event(const edm::Event& event) { bx_ilink_tpc_maps_.clear(); } -void SectorProcessor::configure_bx(const int& bx) { +void SectorProcessor::configureBx(const int& bx) { // BX bx_ = &bx; @@ -118,7 +118,7 @@ void SectorProcessor::process(EMTFHitCollection& out_hits, ILinkTPCMap bx_ilink_tpc_map; for (auto& [subsystem, ilink_tpc_map] : bx_ilink_tpc_maps_) { - copy_tp(ilink_tpc_map, bx_ilink_tpc_map); + copyTP(ilink_tpc_map, bx_ilink_tpc_map); } // Free memory @@ -131,7 +131,7 @@ void SectorProcessor::process(EMTFHitCollection& out_hits, // Convert tp into hits EMTFHitCollection bx_hits; - convert_tp(out_hits.size(), bx_ilink_tpc_map, bx_hits); + convertTP(out_hits.size(), bx_ilink_tpc_map, bx_hits); // Append to bx window hits bx_window_hits_.push_back(bx_hits); @@ -160,11 +160,11 @@ void SectorProcessor::process(EMTFHitCollection& out_hits, // Convert bx window hits into segments segment_collection_t segments; - populate_segments(bx_window_hits_, seg_to_hit, segments); + populateSegments(bx_window_hits_, seg_to_hit, segments); // Build Tracks - build_tracks(seg_to_hit, segments, false, out_tracks); // With prompt setup - build_tracks(seg_to_hit, segments, true, out_tracks); // With displaced setup + buildTracks(seg_to_hit, segments, false, out_tracks); // With prompt setup + buildTracks(seg_to_hit, segments, true, out_tracks); // With displaced setup // =========================================================================== // Record segments/hits used in track building @@ -192,7 +192,7 @@ void SectorProcessor::process(EMTFHitCollection& out_hits, } } -void SectorProcessor::copy_tp(const ILinkTPCMap& source, ILinkTPCMap& target) const { +void SectorProcessor::copyTP(const ILinkTPCMap& source, ILinkTPCMap& target) const { typedef typename ILinkTPCMap::iterator Iterator_t; typedef typename ILinkTPCMap::mapped_type Collection_t; @@ -212,7 +212,7 @@ void SectorProcessor::copy_tp(const ILinkTPCMap& source, ILinkTPCMap& target) co } } -void SectorProcessor::convert_tp(const int& initial_hit_id, const ILinkTPCMap& ilink_tpc_map, EMTFHitCollection& hits) { +void SectorProcessor::convertTP(const int& initial_hit_id, const ILinkTPCMap& ilink_tpc_map, EMTFHitCollection& hits) { EMTFHitCollection substitutes; for (const auto& [ilink, ilink_tpc] : ilink_tpc_map) { // loop input link trigger primitive collections @@ -266,9 +266,9 @@ void SectorProcessor::convert_tp(const int& initial_hit_id, const ILinkTPCMap& i } } -void SectorProcessor::populate_segments(const std::vector& bx_window_hits, - std::map& seg_to_hit, - segment_collection_t& segments) { +void SectorProcessor::populateSegments(const std::vector& bx_window_hits, + std::map& seg_to_hit, + segment_collection_t& segments) { // Initialize for (unsigned int seg_id = 0; seg_id < v3::kNumSegments; ++seg_id) { segments[seg_id].phi = 0; @@ -381,10 +381,10 @@ void SectorProcessor::populate_segments(const std::vector& bx } // End loop from latest BX Collection to oldest BX Hit Collection } -void SectorProcessor::build_tracks(const std::map& seg_to_hit, - const segment_collection_t& segments, - const bool& displaced_en, - EMTFTrackCollection& out_tracks) { +void SectorProcessor::buildTracks(const std::map& seg_to_hit, + const segment_collection_t& segments, + const bool& displaced_en, + EMTFTrackCollection& out_tracks) { // Apply Hitmap Building Layer: Convert segments into hitmaps std::vector zone_hitmaps; diff --git a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc index 0b3a6d42000ab..af240d0e0c8ff 100644 --- a/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc +++ b/L1Trigger/L1TMuonEndCapPhase2/src/TrackFinder.cc @@ -168,7 +168,7 @@ void TrackFinder::process( // Before event for (auto& sector_processor : sector_processors_) { - sector_processor->configure_event(i_event); + sector_processor->configureEvent(i_event); } // Orderly loop BX @@ -186,7 +186,7 @@ void TrackFinder::process( // Loop over all sector processors for (auto& sector_processor : sector_processors_) { // Before BX - sector_processor->configure_bx(bx); + sector_processor->configureBx(bx); // Select trigger primitives in BX if (bx_tpc_ptr != nullptr) { @@ -212,10 +212,10 @@ void TrackFinder::process( bx_tpc_map.clear(); } -void TrackFinder::on_job_begin() { +void TrackFinder::onJobBegin() { // Do Nothing } -void TrackFinder::on_job_end() { +void TrackFinder::onJobEnd() { // Do Nothing } From 0245ea2f0dc5602399baf5b29bb61c4afb62dff4 Mon Sep 17 00:00:00 2001 From: Osvaldo Miguel Colin Date: Tue, 5 Mar 2024 23:52:27 +0100 Subject: [PATCH 24/24] Switched to unsigned int for iteration in L1TGEM --- L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc index 99aac7150a0a4..2ffe8b658ebfd 100644 --- a/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc +++ b/L1Trigger/L1TGEM/src/GE0TriggerPseudoBuilder.cc @@ -21,8 +21,8 @@ void GE0TriggerPseudoBuilder::build(const GEMSegmentCollection& me0Segments, GE0 if (info_ > 2) dumpAllME0Segments(me0Segments); - for (int endc = 0; endc < static_cast(trig_me0s::MAX_ENDCAPS); endc++) { - for (int cham = 0; cham < static_cast(trig_me0s::MAX_CHAMBERS); cham++) { + for (unsigned int endc = 0; endc < static_cast(trig_me0s::MAX_ENDCAPS); endc++) { + for (unsigned int cham = 0; cham < static_cast(trig_me0s::MAX_CHAMBERS); cham++) { // 0th layer means whole chamber. // chamber counts from 1 to 18 in ME0ID const int region(endc == 0 ? -1 : 1); @@ -61,8 +61,7 @@ ME0TriggerDigi GE0TriggerPseudoBuilder::segmentConversion(const GEMSegment segme int chamberid = detid.superChamberId() % 2; int totRolls = keylayer->nEtaPartitions(); float dphi = chamber->computeDeltaPhi(segment.localPosition(), segment.localDirection()); - // !!!!TODO!!!! float time = segment.time(); - // !!!!TODO!!!! int sign_time = (time > 0) ? 1 : -1; + int nrechits = segment.nRecHits(); std::vector rolls; for (const auto& rechit : segment.specificRecHits()) {