Skip to content

Commit

Permalink
Merge pull request cms-sw#75 from jlingema/xMTF-uGMT-TrackAddresses
Browse files Browse the repository at this point in the history
Changing handling of track addresses in RegionalMuonCand.
  • Loading branch information
jlingema committed Nov 4, 2015
2 parents 5669707 + ad2bfdc commit 74329e1
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 42 deletions.
1 change: 0 additions & 1 deletion DataFormats/L1TMuon/interface/GMTInternalMuon.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class GMTInternalMuon {
inline const int hwSign() const { return m_regional.hwSign(); };
inline const int hwSignValid() const { return m_regional.hwSignValid(); };
inline const int hwQual() const { return m_regional.hwQual(); };
inline const int hwTrackAddress() const { return m_regional.hwTrackAddress(); };
inline const int processor() const { return m_regional.processor(); };
inline const tftype trackFinderType() const { return m_regional.trackFinderType(); };
inline const int link() const { return m_regional.link(); }
Expand Down
53 changes: 41 additions & 12 deletions DataFormats/L1TMuon/interface/RegionalMuonCand.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
#ifndef __l1t_regional_muon_candidate_h__
#define __l1t_regional_muon_candidate_h__

#include <iostream>
#include "RegionalMuonCandFwd.h"
#include <map>

namespace l1t {
class RegionalMuonCand {
public:
explicit RegionalMuonCand(uint64_t dataword) : m_dataword(dataword)
{};
/// Enum to identify the individual parts of the BMTF track address
enum bmtfAddress {
kWheel=0, kStat1=1, kStat2=2, kStat3=3, kStat4=4
};
/// Enum to identify the individual parts of the EMTF track address
enum emtfAddress {
kME12=0, kME22=1
};


explicit RegionalMuonCand(uint64_t dataword);

RegionalMuonCand() :
m_hwPt(0), m_hwPhi(0), m_hwEta(0), m_hwHF(false), m_hwSign(0), m_hwSignValid(0), m_hwQuality(0),
m_hwTrackAddress(0), m_processor(0), m_trackFinder(bmtf)
m_hwPt(0), m_hwPhi(0), m_hwEta(0), m_hwHF(false), m_hwSign(0), m_hwSignValid(0), m_hwQuality(0), m_dataword(0)
{
setTFIdentifiers(m_processor, m_trackFinder);
setTFIdentifiers(0, bmtf);
};

RegionalMuonCand(int pt, int phi, int eta, int sign, int signvalid, int quality, int processor, tftype trackFinder) :
m_hwPt(pt), m_hwPhi(phi), m_hwEta(eta), m_hwHF(false), m_hwSign(sign), m_hwSignValid(signvalid), m_hwQuality(quality),
m_hwTrackAddress(0)
m_dataword(0)
{
setTFIdentifiers(processor, trackFinder);
};
Expand All @@ -40,8 +48,6 @@ class RegionalMuonCand {
void setHwQual(int bits) { m_hwQuality = bits; };
/// Set HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
void setHwHF(bool bit) { m_hwHF = bit; };
/// Set compressed track address as transmitted by hardware. Identifies trigger primitives.
void setHwTrackAddress(int bits) { m_hwTrackAddress = bits; };
/// Set the processor ID, track-finder type. From these two, the link is set
void setTFIdentifiers(int processor, tftype trackFinder);
// this is left to still be compatible with OMTF
Expand All @@ -50,6 +56,18 @@ class RegionalMuonCand {
void setDataword(int msbs, int lsbs) { m_dataword = (((uint64_t)msbs) << 32) + lsbs; };
// Set the 64 bit word coming from HW directly
void setDataword(uint64_t bits) { m_dataword = bits; };
/// Set a part of the muon candidates track address; specialised for BMTF
void setTrackSubAddress(bmtfAddress subAddress, int value) {
m_trackAddress[subAddress] = value;
}
/// Set a part of the muon candidates track address; specialised for EMTF
void setTrackSubAddress(emtfAddress subAddress, int value) {
m_trackAddress[subAddress] = value;
}
/// Set the whole track address
void setTrackAddress(const std::map<int, int>& address) {
m_trackAddress = address;
}


/// Get compressed pT (returned int * 0.5 = pT (GeV))
Expand All @@ -64,8 +82,6 @@ class RegionalMuonCand {
const int hwSignValid() const { return m_hwSignValid; };
/// Get quality code
const int hwQual() const { return m_hwQuality; };
/// Get track address identifying trigger primitives
const int hwTrackAddress() const { return m_hwTrackAddress; };
/// Get link on which the MicroGMT receives the candidate
const int link() const { return m_link; };
/// Get processor ID on which the candidate was found (1..6 for OMTF/EMTF; 1..12 for BMTF)
Expand All @@ -80,6 +96,19 @@ class RegionalMuonCand {
const int dataword32Msb() const { return (int)((m_dataword >> 32) & 0xFFFFFFFF); };
/// Get 32 LSBs of data word
const int dataword32Lsb() const { return (int)(m_dataword & 0xFFFFFFFF); };
/// Get the track address (identifies track primitives used for reconstruction)
const std::map<int, int>& trackAddress() const {
return m_trackAddress;
}
/// Get part of track address (identifies track primitives used for reconstruction)
int trackSubAddress(bmtfAddress subAddress) const {
return m_trackAddress.at(subAddress);
}
/// Get part of track address (identifies track primitives used for reconstruction)
int trackSubAddress(emtfAddress subAddress) const {
return m_trackAddress.at(subAddress);
}


private:
int m_hwPt;
Expand All @@ -89,10 +118,10 @@ class RegionalMuonCand {
int m_hwSign;
int m_hwSignValid;
int m_hwQuality;
int m_hwTrackAddress;
int m_link;
int m_processor;
tftype m_trackFinder;
std::map<int, int> m_trackAddress;

/// This is the 64 bit word as transmitted in HW
uint64_t m_dataword;
Expand Down
7 changes: 6 additions & 1 deletion DataFormats/L1TMuon/src/BMTrackCand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ BMTrackCand::BMTrackCand( int pt, int phi, int eta, int charge, int quality, int
setAdd(3);
setAdd(4);

setHwTrackAddress(TrkAdd[0]*1000000 + TrkAdd[1]*10000 + TrkAdd[2]*100 + TrkAdd[3] );
// setHwTrackAddress(TrkAdd[0]*1000000 + TrkAdd[1]*10000 + TrkAdd[2]*100 + TrkAdd[3] );

setTrackSubAddress(RegionalMuonCand::kWheel, uwh);
setTrackSubAddress(RegionalMuonCand::kStat1, adr1);
setTrackSubAddress(RegionalMuonCand::kStat2, adr2);
setTrackSubAddress(RegionalMuonCand::kStat3, adr3);
setTrackSubAddress(RegionalMuonCand::kStat4, adr4);

TClassCode = utc;
setTC();
Expand Down
7 changes: 4 additions & 3 deletions DataFormats/L1TMuon/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<class name="edm::Wrapper<L1TMuon::TriggerPrimitive>"/>
<class name="L1TMuon::TriggerPrimitiveCollection"/>
<class name="edm::Wrapper<L1TMuon::TriggerPrimitiveCollection>"/>
<class name="L1TMuon::TriggerPrimitiveRef"/>
<class name="L1TMuon::TriggerPrimitiveRef"/>
<class name="L1TMuon::TriggerPrimitivePtr"/>
<class name="L1TMuon::TriggerPrimitiveList"/>
<class name="L1TMuon::TriggerPrimitiveStationMap"/>
Expand Down Expand Up @@ -73,7 +73,8 @@
<class name="edm::reftobase::RefHolder<L1TMuon::CSCTrackRef>"/>
<class name="edm::reftobase::RefHolder<L1TMuon::InternalTrackRef>"/>

<class name="BMTrackCand" ClassVersion="20">
<class name="BMTrackCand" ClassVersion="21">
<version ClassVersion="21" checksum="1616896838"/>
<version ClassVersion="20" checksum="612222572"/>
</class>
<class name="std::vector<BMTrackCand>"/>
Expand All @@ -82,6 +83,6 @@
</class>
<class name="edm::Wrapper<BMTrackContainer>"/>


</selection>
</lcgdict>
31 changes: 24 additions & 7 deletions L1Trigger/L1TMuon/interface/RegionalMuonRawDigiTranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,38 @@ namespace l1t {
static uint64_t generate64bitDataWord(const RegionalMuonCand&);

private:
static const unsigned ptWidth_ = 0x1FF;
static const unsigned ptMask_ = 0x1FF;
static const unsigned ptShift_ = 0;
static const unsigned qualWidth_ = 0xF;
static const unsigned qualMask_ = 0xF;
static const unsigned qualShift_ = 9;
static const unsigned absEtaWidth_ = 0xFF;
static const unsigned absEtaMask_ = 0xFF;
static const unsigned absEtaShift_ = 13;
static const unsigned etaSignShift_ = 21;
static const unsigned hfWidth_ = 0x1;
static const unsigned hfMask_ = 0x1;
static const unsigned hfShift_ = 22;
static const unsigned phiWidth_ = 0xFF;
static const unsigned phiMask_ = 0xFF;
static const unsigned phiShift_ = 23;
static const unsigned signShift_ = 0;
static const unsigned signValidShift_ = 1;
static const unsigned trackAddressWidth_ = 0x1FFF;
static const unsigned trackAddressShift_ = 4;
static const unsigned trackAddressMask_ = 0x1FFFFFFF;
static const unsigned trackAddressShift_ = 2;
// relative shifts within track address
static const unsigned bmtfTrAddrDetSideShift_ = 20;
static const unsigned bmtfTrAddrWheelMask_ = 0x3;
static const unsigned bmtfTrAddrWheelShift_ = 18;
static const unsigned bmtfTrAddrStat1Mask_ = 0x3;
static const unsigned bmtfTrAddrStat1Shift_ = 2;
static const unsigned bmtfTrAddrStat2Mask_ = 0xF;
static const unsigned bmtfTrAddrStat2Shift_ = 4;
static const unsigned bmtfTrAddrStat3Mask_ = 0xF;
static const unsigned bmtfTrAddrStat3Shift_ = 8;
static const unsigned bmtfTrAddrStat4Mask_ = 0xF;
static const unsigned bmtfTrAddrStat4Shift_ = 12;
// TODO: set real widths and shifts for EMTF
static const unsigned emtfTrAddrMe12Mask_ = 0x1FFFFFFF;
static const unsigned emtfTrAddrMe12Shift_ = 0;
static const unsigned emtfTrAddrMe22Mask_ = 0x1FFFFFFF;
static const unsigned emtfTrAddrMe22Shift_ = 0;
};
}

Expand Down
65 changes: 53 additions & 12 deletions L1Trigger/L1TMuon/src/RegionalMuonRawDigiTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,49 @@ void
l1t::RegionalMuonRawDigiTranslator::fillRegionalMuonCand(RegionalMuonCand& mu, uint32_t raw_data_00_31, uint32_t raw_data_32_63, int proc, tftype tf)
{
// translations as defined in DN-15-017
mu.setHwPt((raw_data_00_31 >> ptShift_) & ptWidth_);
mu.setHwQual((raw_data_00_31 >> qualShift_) & qualWidth_);
mu.setHwPt((raw_data_00_31 >> ptShift_) & ptMask_);
mu.setHwQual((raw_data_00_31 >> qualShift_) & qualMask_);

// eta is coded as two's complement
int abs_eta = (raw_data_00_31 >> absEtaShift_) & absEtaWidth_;
int abs_eta = (raw_data_00_31 >> absEtaShift_) & absEtaMask_;
if ((raw_data_00_31 >> etaSignShift_) & 0x1) {
mu.setHwEta(abs_eta - (1 << (etaSignShift_ - absEtaShift_)));
} else {
mu.setHwEta(abs_eta);
}

mu.setHwPhi((raw_data_00_31 >> phiShift_) & phiWidth_);
mu.setHwPhi((raw_data_00_31 >> phiShift_) & phiMask_);
// sign is coded as -1^signBit
int signBit = (raw_data_32_63 >> signShift_) & 0x1;
mu.setHwSign(1 - 2*signBit);
mu.setHwSignValid((raw_data_32_63 >> signValidShift_) & 0x1);
mu.setHwHF((raw_data_00_31 >> hfShift_) & hfWidth_);
mu.setHwTrackAddress((raw_data_32_63 >> trackAddressShift_) & trackAddressWidth_);
mu.setHwHF((raw_data_00_31 >> hfShift_) & hfMask_);

// set track address with subaddresses
int rawTrackAddress = (raw_data_32_63 >> trackAddressShift_) & trackAddressMask_;
if (tf == bmtf) {
int detSide = (rawTrackAddress >> bmtfTrAddrDetSideShift_) & 0x1;
int wheel = (1 - 2*detSide) * ((rawTrackAddress >> bmtfTrAddrWheelShift_) & bmtfTrAddrWheelMask_);
int statAddr1 = (rawTrackAddress >> bmtfTrAddrStat1Shift_) & bmtfTrAddrStat1Mask_;
int statAddr2 = (rawTrackAddress >> bmtfTrAddrStat2Shift_) & bmtfTrAddrStat2Mask_;
int statAddr3 = (rawTrackAddress >> bmtfTrAddrStat3Shift_) & bmtfTrAddrStat3Mask_;
int statAddr4 = (rawTrackAddress >> bmtfTrAddrStat4Shift_) & bmtfTrAddrStat4Mask_;
mu.setTrackSubAddress(RegionalMuonCand::kWheel, wheel);
mu.setTrackSubAddress(RegionalMuonCand::kStat1, statAddr1);
mu.setTrackSubAddress(RegionalMuonCand::kStat2, statAddr2);
mu.setTrackSubAddress(RegionalMuonCand::kStat3, statAddr3);
mu.setTrackSubAddress(RegionalMuonCand::kStat4, statAddr4);
} else if (tf == emtf_neg || tf == emtf_pos) {
int me12 = (rawTrackAddress >> emtfTrAddrMe12Shift_) & emtfTrAddrMe12Mask_;
int me22 = (rawTrackAddress >> emtfTrAddrMe22Shift_) & emtfTrAddrMe22Mask_;
mu.setTrackSubAddress(RegionalMuonCand::kME12, me12);
mu.setTrackSubAddress(RegionalMuonCand::kME22, me22);
} else {
std::map<int, int> trackAddr;
trackAddr[0] = rawTrackAddress;
mu.setTrackAddress(trackAddr);
}

mu.setTFIdentifiers(proc, tf);
mu.setDataword(raw_data_32_63, raw_data_00_31);
}
Expand All @@ -39,16 +64,32 @@ l1t::RegionalMuonRawDigiTranslator::generatePackedDataWords(const RegionalMuonCa
if (abs_eta < 0) {
abs_eta += (1 << (etaSignShift_ - absEtaShift_));
}
raw_data_00_31 = (mu.hwPt() & ptWidth_) << ptShift_
| (mu.hwQual() & qualWidth_) << qualShift_
| (abs_eta & absEtaWidth_) << absEtaShift_
raw_data_00_31 = (mu.hwPt() & ptMask_) << ptShift_
| (mu.hwQual() & qualMask_) << qualShift_
| (abs_eta & absEtaMask_) << absEtaShift_
| (mu.hwEta() < 0) << etaSignShift_
| (mu.hwHF() & hfWidth_) << hfShift_
| (mu.hwPhi() & phiWidth_) << phiShift_;
| (mu.hwHF() & hfMask_) << hfShift_
| (mu.hwPhi() & phiMask_) << phiShift_;

int tf = mu.trackFinderType();
int rawTrkAddr = 0;
if (tf == bmtf) {
rawTrkAddr = (mu.trackSubAddress(RegionalMuonCand::kWheel) < 0) << bmtfTrAddrDetSideShift_
| (abs(mu.trackSubAddress(RegionalMuonCand::kWheel)) & bmtfTrAddrWheelMask_) << bmtfTrAddrWheelShift_
| (mu.trackSubAddress(RegionalMuonCand::kStat1) & bmtfTrAddrStat1Mask_) << bmtfTrAddrStat1Shift_
| (mu.trackSubAddress(RegionalMuonCand::kStat2) & bmtfTrAddrStat2Mask_) << bmtfTrAddrStat2Shift_
| (mu.trackSubAddress(RegionalMuonCand::kStat3) & bmtfTrAddrStat3Mask_) << bmtfTrAddrStat3Shift_
| (mu.trackSubAddress(RegionalMuonCand::kStat4) & bmtfTrAddrStat4Mask_) << bmtfTrAddrStat4Shift_;
} else if (tf == emtf_neg || tf == emtf_pos) {
rawTrkAddr = (mu.trackSubAddress(RegionalMuonCand::kME12) & emtfTrAddrMe12Mask_) << emtfTrAddrMe12Shift_
| (mu.trackSubAddress(RegionalMuonCand::kME22) & emtfTrAddrMe22Mask_) << emtfTrAddrMe22Shift_;
} else {
rawTrkAddr = mu.trackAddress().at(0);
}

raw_data_32_63 = (mu.hwSign() < 0) << signShift_
| mu.hwSignValid() << signValidShift_
| (mu.hwTrackAddress() & trackAddressWidth_) << trackAddressShift_;
| (rawTrkAddr & trackAddressMask_) << trackAddressShift_;
}

uint64_t
Expand Down
10 changes: 7 additions & 3 deletions L1Trigger/L1TMuonTrackFinderBarrel/src/L1MuBMTrackFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,17 @@ void L1MuBMTrackFinder::run(const edm::Event& e, const edm::EventSetup& c) {
int abs_add_3 = setAdd(3,(*iter)->address(3));
int abs_add_4 = setAdd(4,(*iter)->address(4));

int track_add = abs_add_1*1000000 + abs_add_2*10000 + abs_add_3*100 + abs_add_4;
rmc.setHwTrackAddress(track_add);
rmc.setTrackSubAddress(l1t::RegionalMuonCand::kWheel, 0); // this has to be set!
rmc.setTrackSubAddress(l1t::RegionalMuonCand::kStat1, abs_add_1);
rmc.setTrackSubAddress(l1t::RegionalMuonCand::kStat2, abs_add_2);
rmc.setTrackSubAddress(l1t::RegionalMuonCand::kStat3, abs_add_3);
rmc.setTrackSubAddress(l1t::RegionalMuonCand::kStat4, abs_add_4);


rmc.setHwPhi((*iter)->hwPhi());
if((*iter)->hwEta()>-33 || (*iter)->hwEta()<32 )
rmc.setHwEta(eta_map[(*iter)->hwEta()]);
else
else
rmc.setHwEta(-1000);
//cout<<(*iter)->hwEta()<<" "<<eta_map[(*iter)->hwEta()]<<endl;
rmc.setHwSign((*iter)->hwSign());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ l1t::RegionalMuonCand MakeRegionalCand(float pt, int phi, int theta,
Cand.setHwSign(1);
Cand.setHwSignValid(0);
Cand.setHwQual(iQual);
Cand.setHwTrackAddress(trackaddress);
// jl: FIXME this has to be adapted to the new schema of saving track addresses
Cand.setTrackSubAddress(l1t::RegionalMuonCand::kME12, trackaddress);
Cand.setTFIdentifiers(sector,TFtype);


Expand Down
8 changes: 6 additions & 2 deletions L1Trigger/L1TMuonTrackFinderOverlap/src/OMTFSorter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ l1t::RegionalMuonCand OMTFSorter::sortProcessor(const std::vector<OMTFProcessor:
candidate.setHwSign(myCand.charge);
candidate.setHwQual(myCand.hits);
///Temporary assignement
candidate.setHwTrackAddress(myCand.refLayer);
std::map<int, int> trackAddr;
trackAddr[0] = myCand.refLayer;
candidate.setTrackAddress(trackAddr);
//candidate.setLink(myCand.disc);
/////////////
return candidate;
Expand All @@ -228,7 +230,9 @@ void OMTFSorter::sortProcessor(const std::vector<OMTFProcessor::resultsMap> & pr
candidate.setHwPhi(myCand.phi);
candidate.setHwSign(myCand.charge+1*(myCand.charge<0));
candidate.setHwQual(bits.count());
candidate.setHwTrackAddress(myCand.hits);
std::map<int, int> trackAddr;
trackAddr[0] = myCand.hits;
candidate.setTrackAddress(trackAddr);
///Temporary assignement
//candidate.setHwQual(myCand.refLayer);
//candidate.setLink(myCand.disc);
Expand Down

0 comments on commit 74329e1

Please sign in to comment.