Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMTF unpacked muons match uGMT unpacked muons #22090

Merged
merged 6 commits into from Feb 7, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions DataFormats/L1TMuon/src/RegionalMuonCand.cc
Expand Up @@ -2,12 +2,11 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @abrinke1 I think there is no need to change this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? Don't we want the EMTF unpacker and emulator to match, wherever possible? I confirmed that L1A_BXN() in EMTFBlockSP.cc matches iEvent.bunchCrossing() in MicroGMTConverter.cc. The offset and truncation is required in both to match how the EMTF firmware fills the track address which is transmitted to the uGMT.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks as if you just changed the formatting in this file.

namespace l1t {

void
RegionalMuonCand::setTFIdentifiers(int processor, tftype trackFinder) {
m_trackFinder = trackFinder;
m_processor = processor;
void RegionalMuonCand::setTFIdentifiers(int processor, tftype trackFinder) {
m_trackFinder = trackFinder;
m_processor = processor;

switch (m_trackFinder) {
switch (m_trackFinder) {
case tftype::emtf_pos:
m_link = m_processor + 36; // range 36...41
break;
Expand All @@ -22,7 +21,7 @@ RegionalMuonCand::setTFIdentifiers(int processor, tftype trackFinder) {
break;
case tftype::emtf_neg:
m_link = m_processor + 66; // range 66...71
}
}
}

} // namespace l1t
Expand Up @@ -205,6 +205,10 @@ namespace l1t {
mu_.setHwPt ( SP_.Pt_GMT() );
mu_.setTFIdentifiers ( Track_.Sector() - 1, (Track_.Endcap() == 1) ? emtf_pos : emtf_neg );
mu_.setTrackSubAddress( RegionalMuonCand::kTrkNum, Track_.Track_num() );
// Truncated to 11 bits and offset by 25 from global event BX in EMTF firmware
int EMTF_kBX = ((res->at(iOut)).PtrEventHeader()->L1A_BXN() % 2048) - 25 + Track_.BX();
if (EMTF_kBX < 0) EMTF_kBX += 2048;
mu_.setTrackSubAddress( RegionalMuonCand::kBX, EMTF_kBX );
// mu_.set_dataword ( SP_.Dataword() );
// Track_.set_GMT(mu_);

Expand Down
Expand Up @@ -6,6 +6,10 @@ namespace l1t {
EMTFCollections::~EMTFCollections()
{
// std::cout << "Inside EMTFCollections.cc: ~EMTFCollections" << std::endl;

// Sort by processor to match uGMT unpacked order
L1TMuonEndCap::sort_uGMT_muons(*regionalMuonCands_);

event_.put(std::move(regionalMuonCands_));
event_.put(std::move(EMTFDaqOuts_));
event_.put(std::move(EMTFHits_));
Expand Down
Expand Up @@ -13,8 +13,12 @@

#include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h"

#include "L1Trigger/L1TMuonEndCap/interface/MicroGMTConverter.h"

namespace l1t {
namespace stage2 {
namespace L1TMuonEndCap = ::emtf; // use alias 'L1TMuonEndCap' for the namespace 'emtf' used in L1Trigger/L1TMuonEndCap

class EMTFCollections : public UnpackerCollections {
public:
EMTFCollections(edm::Event& e) :
Expand Down
13 changes: 12 additions & 1 deletion L1Trigger/L1TMuonEndCap/interface/MicroGMTConverter.h
@@ -1,6 +1,8 @@
#ifndef L1TMuonEndCap_MicroGMTConverter_h
#define L1TMuonEndCap_MicroGMTConverter_h

#include "FWCore/Framework/interface/Event.h"

#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"

Expand All @@ -13,16 +15,25 @@ class MicroGMTConverter {
~MicroGMTConverter();

void convert(
const int global_event_BX,
const EMTFTrack& in_track,
l1t::RegionalMuonCand& out_cand
) const;

void convert_all(
const edm::Event& iEvent,
const EMTFTrackCollection& in_tracks,
l1t::RegionalMuonCandBxCollection& out_cands
) const;

private:
};
}; // End class MicroGMTConverter

namespace emtf {
void sort_uGMT_muons(
l1t::RegionalMuonCandBxCollection& cands
);
}


#endif
Expand Up @@ -26,7 +26,7 @@ void L1TMuonEndCapTrackProducer::produce(edm::Event& iEvent, const edm::EventSet
track_finder_->process(iEvent, iSetup, *out_hits, *out_tracks);

// Convert into uGMT format
uGMT_converter_->convert_all(*out_tracks, *out_cands);
uGMT_converter_->convert_all(iEvent, *out_tracks, *out_cands);

// Fill the output products
iEvent.put(std::move(out_hits) , "");
Expand Down
46 changes: 45 additions & 1 deletion L1Trigger/L1TMuonEndCap/src/MicroGMTConverter.cc
Expand Up @@ -10,6 +10,7 @@ MicroGMTConverter::~MicroGMTConverter() {
}

void MicroGMTConverter::convert(
const int global_event_BX,
const EMTFTrack& in_track,
l1t::RegionalMuonCand& out_cand
) const {
Expand All @@ -24,6 +25,10 @@ void MicroGMTConverter::convert(
out_cand.setHwQual ( in_track.GMT_quality() );
out_cand.setHwHF ( false ); // EMTF: halo -> 1
out_cand.setTFIdentifiers ( sector, tftype );
// Truncate to 11 bits and offset by 25 from global event BX in EMTF firmware
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not belong here. Instead it should replace line 85. https://github.com/cms-sw/cmssw/pull/22090/files#diff-0098191652eebd75579da4dd04b68427R85

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not put the offset in "convert_all", because "convert" can be called stand-alone, and I would not want to have to perform the truncation and shift every time I call "convert".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 85 is not in convert_all but in this function.
out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kBX , in_track.BX()); is written there at the moment, and this should be replaced because it sets the kBX back to the old value.

int EMTF_kBX = (abs(global_event_BX) % 2048) - 25 + in_track.BX();
if (EMTF_kBX < 0) EMTF_kBX += 2048;
out_cand.setTrackSubAddress( l1t::RegionalMuonCand::kBX, EMTF_kBX );

const EMTFPtLUT& ptlut_data = in_track.PtLUT();

Expand Down Expand Up @@ -81,6 +86,7 @@ void MicroGMTConverter::convert(
}

void MicroGMTConverter::convert_all(
const edm::Event& iEvent,
const EMTFTrackCollection& in_tracks,
l1t::RegionalMuonCandBxCollection& out_cands
) const {
Expand All @@ -96,8 +102,46 @@ void MicroGMTConverter::convert_all(
if (gmtMinBX <= bx && bx <= gmtMaxBX) {
l1t::RegionalMuonCand out_cand;

convert(in_track, out_cand);
convert(iEvent.bunchCrossing(), in_track, out_cand);
out_cands.push_back(bx, out_cand);
}
}

// Sort by processor to match uGMT unpacked order
emtf::sort_uGMT_muons(out_cands);

}


namespace emtf {

void sort_uGMT_muons(
l1t::RegionalMuonCandBxCollection& cands
) {

int minBX = cands.getFirstBX();
int maxBX = cands.getLastBX();
int emtfMinProc = 0; // ME+ sector 1
int emtfMaxProc = 11; // ME- sector 6

// New collection, sorted by processor to match uGMT unpacked order
auto sortedCands = std::make_unique<l1t::RegionalMuonCandBxCollection>();
sortedCands->clear();
sortedCands->setBXRange(minBX, maxBX);
for (int iBX = minBX; iBX <= maxBX; ++iBX) {
for (int proc = emtfMinProc; proc <= emtfMaxProc; proc++) {
for (l1t::RegionalMuonCandBxCollection::const_iterator cand = cands.begin(iBX); cand != cands.end(iBX); ++cand) {
int cand_proc = cand->processor();
if (cand->trackFinderType() == l1t::tftype::emtf_neg) cand_proc += 6;
if (cand_proc != proc) continue;
sortedCands->push_back(iBX, *cand);
}
}
}

// Return sorted collection
std::swap(cands, *sortedCands);
sortedCands.reset();
}

} // End namespace emtf