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, backport to 10_0_X #22169

Merged
merged 6 commits into from Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
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
48 changes: 46 additions & 2 deletions 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 Down Expand Up @@ -68,6 +69,10 @@ void MicroGMTConverter::convert(
return gmt_ch;
};

// Truncate kBX to 11 bits and offset by 25 from global event BX in EMTF firmware
int EMTF_kBX = (abs(global_event_BX) % 2048) - 25 + in_track.BX();
if (EMTF_kBX < 0) EMTF_kBX += 2048;

out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME1Seg, me1_seg_id);
out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME1Ch , get_gmt_chamber_me1(me1_ch_id));
out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME2Seg, me2_seg_id);
Expand All @@ -77,10 +82,11 @@ void MicroGMTConverter::convert(
out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME4Seg, me4_seg_id);
out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME4Ch , get_gmt_chamber(me4_ch_id));
out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kTrkNum, in_track.Track_num());
out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kBX , in_track.BX());
out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kBX , EMTF_kBX);
}

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