Skip to content

Commit

Permalink
Merge pull request cms-sw#1044 from aperloff/phase2-l1t-integration-C…
Browse files Browse the repository at this point in the history
…MSSW_12_3_0_pre4-TrackLinkOrdering

Modify the TF to GTT Link Ordering
  • Loading branch information
cecilecaillol committed Aug 31, 2022
2 parents 3246620 + ea96862 commit 4b3e341
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 26 deletions.
4 changes: 2 additions & 2 deletions L1Trigger/DemonstratorTools/interface/codecs/tracks.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace l1t::demo::codecs {
const edm::Handle<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>&,
const edm::Handle<edm::RefVector<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>>&);

// Encodes track collection onto 18 'logical' output links (2x9 eta-phi sectors; first 9 negative eta)
// Encodes track collection onto 18 'logical' output links (2x9 eta-phi sectors; -/+ eta pairs)
std::array<std::vector<ap_uint<64>>, 18> encodeTracks(const edm::View<TTTrack<Ref_Phase2TrackerDigi_>>&,
int debug = 0);

Expand All @@ -45,7 +45,7 @@ namespace l1t::demo::codecs {
// Decodes the tracks for a single link
std::vector<TTTrack_TrackWord> decodeTracks(const std::vector<ap_uint<64>>&);

// Decodes the tracks from 18 'logical' output links (2x9 eta-phi sectors; first 9 negative eta)
// Decodes the tracks from 18 'logical' output links (2x9 eta-phi sectors; , -/+ eta pairs)
std::array<std::vector<TTTrack_TrackWord>, 18> decodeTracks(const std::array<std::vector<ap_uint<64>>, 18>&);

} // namespace l1t::demo::codecs
Expand Down
9 changes: 5 additions & 4 deletions L1Trigger/DemonstratorTools/src/codecs_tracks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace l1t::demo::codecs {
std::array<std::vector<ap_uint<96>>, 18> getTrackWords(const edm::View<TTTrack<Ref_Phase2TrackerDigi_>>& tracks) {
std::array<std::vector<ap_uint<96>>, 18> trackWords;
for (const auto& track : tracks) {
trackWords.at((track.eta() >= 0 ? 9 : 0) + track.phiSector()).push_back(encodeTrack(track));
trackWords.at((track.eta() >= 0 ? 1 : 0) + (2 * track.phiSector())).push_back(encodeTrack(track));
}
return trackWords;
}
Expand All @@ -39,10 +39,10 @@ namespace l1t::demo::codecs {
edm::Ref<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>> referenceTrackRef(referenceTracks, itrack);

if (trackInCollection(referenceTrackRef, tracks)) {
trackWords.at((referenceTrack.eta() >= 0 ? 9 : 0) + referenceTrack.phiSector())
trackWords.at((referenceTrack.eta() >= 0 ? 1 : 0) + (2 * referenceTrack.phiSector()))
.push_back(encodeTrack(referenceTrack));
} else {
trackWords.at((referenceTrack.eta() >= 0 ? 9 : 0) + referenceTrack.phiSector()).push_back(ap_uint<96>(0));
trackWords.at((referenceTrack.eta() >= 0 ? 1 : 0) + (2 * referenceTrack.phiSector())).push_back(ap_uint<96>(0));
}
}
return trackWords;
Expand All @@ -68,7 +68,7 @@ namespace l1t::demo::codecs {
return counter;
}

// Encodes track collection onto 18 output links (2x9 eta-phi sectors; first 9 negative eta)
// Encodes track collection onto 18 output links (2x9 eta-phi sectors; , -/+ eta pairs)
std::array<std::vector<ap_uint<64>>, 18> encodeTracks(const edm::View<TTTrack<Ref_Phase2TrackerDigi_>>& tracks,
int debug) {
if (debug > 0) {
Expand Down Expand Up @@ -157,6 +157,7 @@ namespace l1t::demo::codecs {
return tracks;
}

// Decodes the tracks from 18 'logical' output links (2x9 eta-phi sectors; , -/+ eta pairs)
std::array<std::vector<TTTrack_TrackWord>, 18> decodeTracks(const std::array<std::vector<ap_uint<64>>, 18>& frames) {
std::array<std::vector<TTTrack_TrackWord>, 18> tracks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
process.L1TrackSelectionProducer.l1VerticesEmulationInputTag = cms.InputTag("VertexProducer", "l1verticesEmulation")
process.L1TrackJetsEmulation.VertexInputTag = cms.InputTag("VertexProducer", "l1verticesEmulation")
process.L1TrackerEmuEtMiss.L1VertexInputTag = cms.InputTag("VertexProducer", "l1verticesEmulation")
process.L1TrackerEmuEtMiss.debug = options.debug

if options.debug:
process.MessageLogger.cerr.INFO.limit = cms.untracked.int32(1000000000)
Expand Down
55 changes: 35 additions & 20 deletions L1Trigger/L1TTrackMatch/plugins/L1TrackerEtMissEmulatorProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// system include files
#include <memory>
#include <numeric>
#include <sstream>
// user include files
#include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h"
#include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
Expand Down Expand Up @@ -154,6 +155,7 @@ void L1TrackerEtMissEmulatorProducer::produce(edm::Event& iEvent, const edm::Eve
// tracks
l1tmetemu::Et_t sumPx[l1tmetemu::kNSector * 2] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
l1tmetemu::Et_t sumPy[l1tmetemu::kNSector * 2] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int link_totals[l1tmetemu::kNSector * 2] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int sector_totals[l1tmetemu::kNSector] = {0, 0, 0, 0, 0, 0, 0, 0, 0};

// Track counters
Expand Down Expand Up @@ -263,12 +265,20 @@ void L1TrackerEtMissEmulatorProducer::produce(edm::Event& iEvent, const edm::Eve
temppx = 0;
temppy = 0;
}
if (EtTrack.EtaSector) {
sumPx[EtTrack.Sector] = sumPx[EtTrack.Sector] + temppx;
sumPy[EtTrack.Sector] = sumPy[EtTrack.Sector] + temppy;
} else {
sumPx[l1tmetemu::kNSector + EtTrack.Sector] = sumPx[l1tmetemu::kNSector + EtTrack.Sector] + temppx;
sumPy[l1tmetemu::kNSector + EtTrack.Sector] = sumPy[l1tmetemu::kNSector + EtTrack.Sector] + temppy;

int link_number = (EtTrack.Sector * 2) + ((EtTrack.EtaSector) ? 0 : 1);
link_totals[link_number] += 1;
sumPx[link_number] += temppx;
sumPy[link_number] += temppy;
if (debug_ == 4) {
edm::LogVerbatim("L1TrackerEtMissEmulatorProducer")
<< "Sector: " << EtTrack.Sector << " Eta: " << EtTrack.EtaSector << "\n"
<< "Int Track Px: " << temppx << " Int Track Py: " << temppy << "\n"
<< "Float Track Px: " << (float)temppx * l1tmetemu::kStepPt
<< " Float Track Py:" << (float)temppy * l1tmetemu::kStepPt << "\n"
<< "Int Sector Sum Px: " << sumPx[link_number] << " Int Sector Sum Py: " << sumPy[link_number] << "\n"
<< "Float Sector Sum Px: " << (float)sumPx[link_number] * l1tmetemu::kStepPt
<< " Float Sector Sum Py: " << (float)sumPy[link_number] * l1tmetemu::kStepPt << "\n";
}
}

Expand Down Expand Up @@ -306,35 +316,40 @@ void L1TrackerEtMissEmulatorProducer::produce(edm::Event& iEvent, const edm::Eve
else if ((GlobalPx < 0) && (GlobalPy >= 0))
tempPhi = EtMiss.Phi - 3 * l1tmetemu::kMETPhiBins / 2;

if (debug_ == 6) {
std::string flpxarray[l1tmetemu::kNSector * 2];
std::string flpyarray[l1tmetemu::kNSector * 2];
if (debug_ == 4 || debug_ == 6) {
std::stringstream flpxarray;
std::stringstream flpyarray;

std::string intpxarray[l1tmetemu::kNSector * 2];
std::string intpyarray[l1tmetemu::kNSector * 2];
std::stringstream intpxarray;
std::stringstream intpyarray;

std::string totalsarray[l1tmetemu::kNSector * 2];
std::stringstream totalsarray;
std::stringstream linksarray;

for (unsigned int i = 0; i < l1tmetemu::kNSector * 2; i++) {
flpxarray[i] = to_string(sumPx[i] * l1tmetemu::kStepPt) + "|";
flpyarray[i] = to_string(sumPy[i] * l1tmetemu::kStepPt) + "|";
intpxarray[i] = to_string(floor((float)sumPx[i] / (float)l1tmetemu::kGlobalPhiBins)) + "|";
intpyarray[i] = to_string(floor((float)sumPy[i] / (float)l1tmetemu::kGlobalPhiBins)) + "|";
totalsarray[i] = to_string(sector_totals[i]) + "|";
flpxarray << to_string(sumPx[i] * l1tmetemu::kStepPt) + "|";
flpyarray << to_string(sumPy[i] * l1tmetemu::kStepPt) + "|";
intpxarray << to_string(floor((float)sumPx[i] / (float)l1tmetemu::kGlobalPhiBins)) + "|";
intpyarray << to_string(floor((float)sumPy[i] / (float)l1tmetemu::kGlobalPhiBins)) + "|";
linksarray << to_string(link_totals[i]) + "|";
if (i < l1tmetemu::kNSector) {
totalsarray << to_string(sector_totals[i]) + "|";
}
}

edm::LogVerbatim("L1TrackerEtMissEmulatorProducer")
<< "====Sector Pt====\n"
<< "Float Px: " << flpxarray << "Float Py: " << flpyarray << "Integer Px: " << intpyarray
<< "Integer Px: " << intpyarray << "Sector Totals: " << totalsarray
<< "Float Px: " << flpxarray.str() << "\nFloat Py: " << flpyarray.str() << "\nInteger Px: " << intpyarray.str()
<< "\nInteger Px: " << intpyarray.str() << "\nLink Totals: " << linksarray.str()
<< "\nSector Totals: " << totalsarray.str() << "\n"

<< "====Global Pt====\n"
<< "Integer Global Px: " << GlobalPx << "| Integer Global Py: " << GlobalPy << "\n"
<< "Float Global Px: " << GlobalPx * l1tmetemu::kStepPt
<< "| Float Global Py: " << GlobalPy * l1tmetemu::kStepPt << "\n";
}

if (debug_ == 6) {
if (debug_ == 4 || debug_ == 6) {
edm::LogVerbatim("L1TrackerEtMissEmulatorProducer")
<< "====MET===\n"
<< "Integer MET: " << EtMiss.Et << "| Integer MET phi: " << EtMiss.Phi << "\n"
Expand Down

0 comments on commit 4b3e341

Please sign in to comment.