Skip to content

Commit

Permalink
Updates to include HTMHF triggers in GT emulator and propagation to H…
Browse files Browse the repository at this point in the history
…LTL1Seed
  • Loading branch information
elfontan committed Jul 1, 2024
1 parent a969011 commit 902a2b0
Show file tree
Hide file tree
Showing 14 changed files with 344 additions and 88 deletions.
14 changes: 8 additions & 6 deletions DataFormats/HLTReco/interface/TriggerTypeDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace trigger {

/// enum start value shifted to 81 so as to avoid clashes with PDG codes

/// L1 - using cases as defined in enum L1GtObject, file:
/// L1 - using cases as defined in enum L1GtObject, legacy and stage 1 file:
/// DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"

TriggerL1Mu = -81,
Expand Down Expand Up @@ -72,11 +72,13 @@ namespace trigger {
TriggerL1PFMHT = -122,
TriggerL1PFTrack = -123,
TriggerL1Vertex = -124,
// Phase-1: MuonShower
TriggerL1MuShower = -125, // stage2 (introduced in Run 3)
// Phase-1: ZDC+ and ZDC-
TriggerL1ZDCP = -126, // stage2 (introduced in 2023 during Run 3)
TriggerL1ZDCM = -127, // stage2 (introduced in 2023 during Run 3)
// Phase-1: MuonShower triggers (Run 3 - 2022)
TriggerL1MuShower = -125, // stage2
// Phase-1: ZDC+ and ZDC- triggers for HI (Run 3 - 2023)
TriggerL1ZDCP = -126, // stage2
TriggerL1ZDCM = -127, // stage2
// Phase-1: MHTHF triggers
TriggerL1HTMHF = -128, // stage2

/// HLT
TriggerPhoton = +81,
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/L1TGlobal/interface/GlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace l1t {
gtZDCP = 29,
gtZDCM = 30,
ObjNull = 31,
gtHTMHF = 32,
};

const std::vector<std::pair<GlobalObject, std::string>> kGlobalObjectEnumStringPairs = {
Expand Down Expand Up @@ -95,6 +96,7 @@ namespace l1t {
{gtZDCP, "ZDCP"}, // 29
{gtZDCM, "ZDCM"}, // 30
{ObjNull, "ObjNull"}, // 31
{gtHTMHF, "HTMHF"}, // 32
};

// utility functions to convert GlobalObject enum to std::string and viceversa
Expand Down
1 change: 1 addition & 0 deletions DataFormats/L1TGlobal/test/test_catch2_l1tGlobalObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ TEST_CASE("Test l1t::GlobalObject", "[l1tGlobalObject]") {
REQUIRE(isValidGlobalObject(29, l1t::gtZDCP, "ZDCP")); // 29
REQUIRE(isValidGlobalObject(30, l1t::gtZDCM, "ZDCM")); // 30
REQUIRE(isValidGlobalObject(31, l1t::ObjNull, "ObjNull")); // 31
REQUIRE(isValidGlobalObject(32, l1t::gtHTMHF, "HTMHF")); // 32
}
}
26 changes: 26 additions & 0 deletions HLTrigger/HLTfilters/plugins/HLTL1TSeed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ void HLTL1TSeed::dumpTriggerFilterObjectWithRefs(trigger::TriggerFilterObjectWit
<< "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
}

vector<l1t::EtSumRef> seedsL1EtSumHTMHF;
filterproduct.getObjects(trigger::TriggerL1HTMHF, seedsL1EtSumHTMHF);
const size_t sizeSeedsL1EtSumHTMHF = seedsL1EtSumHTMHF.size();
LogTrace("HLTL1TSeed") << "\n L1EtSum HTMHF seeds: " << sizeSeedsL1EtSumHTMHF << endl << endl;

for (size_t i = 0; i != sizeSeedsL1EtSumHTMHF; i++) {
l1t::EtSumRef obj = l1t::EtSumRef(seedsL1EtSumHTMHF[i]);

LogTrace("HLTL1TSeed") << "\tL1EtSum HTMHF"
<< "\t"
<< "pt = " << obj->pt() << "\t"
<< "eta = " << obj->eta() << "\t"
<< "phi = " << obj->phi(); //<< "\t" << "BX = " << obj->bx();
}

vector<l1t::EtSumRef> seedsL1EtSumHTM;
filterproduct.getObjects(trigger::TriggerL1HTM, seedsL1EtSumHTM);
const size_t sizeSeedsL1EtSumHTM = seedsL1EtSumHTM.size();
Expand Down Expand Up @@ -485,6 +500,7 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
std::list<int> listHTT;
std::list<int> listHTM;
std::list<int> listETMHF;
std::list<int> listHTMHF;

std::list<int> listJetCounts;

Expand Down Expand Up @@ -789,6 +805,9 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
case l1t::gtETMHF: {
listETMHF.push_back(*itObject);
} break;
case l1t::gtHTMHF: {
listHTMHF.push_back(*itObject);
} break;
case l1t::gtTowerCount: {
listTowerCount.push_back(*itObject);
} break;
Expand Down Expand Up @@ -891,6 +910,9 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
listETMHF.sort();
listETMHF.unique();

listHTMHF.sort();
listHTMHF.unique();

listJetCounts.sort();
listJetCounts.unique();

Expand Down Expand Up @@ -1112,6 +1134,10 @@ bool HLTL1TSeed::seedsL1TriggerObjectMaps(edm::Event& iEvent, trigger::TriggerFi
if (!listETMHF.empty())
filterproduct.addObject(trigger::TriggerL1ETMHF, myref);
break;
case l1t::EtSum::kMissingHtHF:
if (!listHTMHF.empty())
filterproduct.addObject(trigger::TriggerL1HTMHF, myref);
break;
case l1t::EtSum::kCentrality:
if (!listCentrality.empty())
filterproduct.addObject(trigger::TriggerL1Centrality, myref);
Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/L1TGlobal/interface/GlobalDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace l1t {
/// Type2cor : two particles, different type, with spatial correlations among them
/// Type3s : three particles, same type
/// Type4s : four particles, same type
/// TypeETM, TypeETT, TypeHTT, TypeHTM : ETM, ETT, HTT, HTM
/// TypeETM, TypeETT, TypeHTT, TypeHTM, TypeETMHF, TypeHTMHF: ETM, ETT, HTT, HTM, ETMHF, HTMHF
/// TypeExternal: external conditions (logical result only; definition in L1 GT external systems)
enum GtConditionType {
TypeNull,
Expand All @@ -59,6 +59,7 @@ namespace l1t {
TypeHTT,
TypeHTM,
TypeETMHF,
TypeHTMHF,
TypeTowerCount,
TypeMinBiasHFP0,
TypeMinBiasHFM0,
Expand Down
3 changes: 3 additions & 0 deletions L1Trigger/L1TGlobal/interface/GlobalScales.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace l1t {
inline void setHTTScales(ScaleParameters& scales) { m_httScales = scales; }
inline void setETMScales(ScaleParameters& scales) { m_etmScales = scales; }
inline void setETMHfScales(ScaleParameters& scales) { m_etmHfScales = scales; }
inline void setHTMHfScales(ScaleParameters& scales) { m_htmHfScales = scales; }
inline void setHTMScales(ScaleParameters& scales) { m_htmScales = scales; }

virtual void setLUT_CalMuEta(const std::string& lutName, std::vector<long long> lut);
Expand All @@ -91,6 +92,7 @@ namespace l1t {
inline const ScaleParameters& getETTEmScales() const { return m_ettEmScales; }
inline const ScaleParameters& getETMScales() const { return m_etmScales; }
inline const ScaleParameters& getETMHFScales() const { return m_etmHfScales; }
inline const ScaleParameters& getHTMHFScales() const { return m_htmHfScales; }
inline const ScaleParameters& getHTTScales() const { return m_httScales; }
inline const ScaleParameters& getHTMScales() const { return m_htmScales; }

Expand Down Expand Up @@ -134,6 +136,7 @@ namespace l1t {
ScaleParameters m_httScales;
ScaleParameters m_etmScales;
ScaleParameters m_etmHfScales;
ScaleParameters m_htmHfScales;
ScaleParameters m_htmScales;

//LUTs
Expand Down
128 changes: 120 additions & 8 deletions L1Trigger/L1TGlobal/plugins/GtRecordDump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include "DataFormats/L1Trigger/interface/EGamma.h"
#include "DataFormats/L1Trigger/interface/Muon.h"
#include "DataFormats/L1Trigger/interface/MuonShower.h"
#include "DataFormats/L1Trigger/interface/Tau.h"
#include "DataFormats/L1Trigger/interface/Jet.h"
#include "DataFormats/L1Trigger/interface/EtSum.h"
Expand Down Expand Up @@ -72,6 +73,7 @@ namespace l1t {
InputTag uGtExtInputTag;
EDGetToken egToken;
EDGetToken muToken;
EDGetToken muShowerToken;
EDGetToken tauToken;
EDGetToken jetToken;
EDGetToken etsumToken;
Expand All @@ -82,14 +84,16 @@ namespace l1t {
void dumpTestVectors(int bx,
std::ofstream& myCout,
Handle<BXVector<l1t::Muon>> muons,
Handle<BXVector<l1t::MuonShower>> muonShowers,
Handle<BXVector<l1t::EGamma>> egammas,
Handle<BXVector<l1t::Tau>> taus,
Handle<BXVector<l1t::Jet>> jets,
Handle<BXVector<l1t::EtSum>> etsums,
Handle<BXVector<GlobalAlgBlk>> uGtAlg,
Handle<BXVector<GlobalExtBlk>> uGtExt);

cms_uint64_t formatMuon(std::vector<l1t::Muon>::const_iterator mu);
cms_uint64_t formatMuon(std::vector<l1t::Muon>::const_iterator mu, int muShowerBit);
cms_uint64_t formatNonExistantMuon(int muShowerBit);
unsigned int formatEG(std::vector<l1t::EGamma>::const_iterator eg);
unsigned int formatTau(std::vector<l1t::Tau>::const_iterator tau);
unsigned int formatJet(std::vector<l1t::Jet>::const_iterator jet);
Expand Down Expand Up @@ -126,6 +130,7 @@ namespace l1t {
uGtExtInputTag = iConfig.getParameter<InputTag>("uGtExtInputTag");
egToken = consumes<BXVector<l1t::EGamma>>(iConfig.getParameter<InputTag>("egInputTag"));
muToken = consumes<BXVector<l1t::Muon>>(iConfig.getParameter<InputTag>("muInputTag"));
muShowerToken = consumes<BXVector<l1t::MuonShower>>(iConfig.getParameter<InputTag>("muShowerInputTag"));
tauToken = consumes<BXVector<l1t::Tau>>(iConfig.getParameter<InputTag>("tauInputTag"));
jetToken = consumes<BXVector<l1t::Jet>>(iConfig.getParameter<InputTag>("jetInputTag"));
etsumToken = consumes<BXVector<l1t::EtSum>>(iConfig.getParameter<InputTag>("etsumInputTag"));
Expand Down Expand Up @@ -169,6 +174,9 @@ namespace l1t {
Handle<BXVector<l1t::Muon>> muons;
iEvent.getByToken(muToken, muons);

Handle<BXVector<l1t::MuonShower>> muonShowers;
iEvent.getByToken(muShowerToken, muonShowers);

Handle<BXVector<l1t::Tau>> taus;
iEvent.getByToken(tauToken, taus);

Expand Down Expand Up @@ -396,6 +404,32 @@ namespace l1t {
cout << "No Muon Data in this event " << endl;
}

//Loop over Muon Showers
nObj = 0;
cout << " ------ Muons Showers --------" << endl;
if (muonShowers.isValid()) {
std::cout << "========= MuonShower BX index = " << i << "; min BX = " << m_minBx << "; max BX = " << m_maxBx
<< std::endl;
if (i >= muonShowers->getFirstBX() && i <= muonShowers->getLastBX()) {
for (std::vector<l1t::MuonShower>::const_iterator muShower = muonShowers->begin(i);
muShower != muonShowers->end(i);
++muShower) {
cout << " " << std::dec << std::setw(2) << std::setfill(' ') << nObj << std::setfill('0') << ")";
cout << " MUS0 " << std::dec << std::setw(1) << muShower->isOneNominalInTime();
cout << "; MUS1 " << std::dec << std::setw(1) << muShower->isOneTightInTime();
cout << "; MUS2 " << std::dec << std::setw(1) << muShower->isTwoLooseDiffSectorsInTime();
cout << "; MUSOOT0 " << std::dec << std::setw(1) << muShower->musOutOfTime0();
cout << "; MUSOOT1 " << std::dec << std::setw(1) << muShower->musOutOfTime1();
cout << endl;
nObj++;
}
} else {
cout << "No MuonShowers stored for this bx " << i << endl;
}
} else {
cout << "No MuonShower Data in this event " << endl;
}

//Loop over Taus
nObj = 0;
cout << " ------ Taus ----------" << endl;
Expand Down Expand Up @@ -510,7 +544,8 @@ namespace l1t {
<< std::setfill('0') << etsum->hwPt() << ")";
if (etsum->getType() == l1t::EtSum::EtSumType::kMissingEt ||
etsum->getType() == l1t::EtSum::EtSumType::kMissingHt ||
etsum->getType() == l1t::EtSum::EtSumType::kMissingEtHF)
etsum->getType() == l1t::EtSum::EtSumType::kMissingEtHF ||
etsum->getType() == l1t::EtSum::EtSumType::kMissingHtHF)
cout << " Phi " << std::dec << std::setw(3) << etsum->hwPhi() << " (0x" << std::hex << std::setw(2)
<< std::setfill('0') << etsum->hwPhi() << ")";
cout << endl;
Expand Down Expand Up @@ -566,7 +601,7 @@ namespace l1t {
// (i>=etsums->getFirstBX() && i<=etsums->getLastBX()) &&
// (i>=uGtAlg->getFirstBX() && i<=uGtAlg->getLastBX()) &&
// (i>=uGtAlg->getFirstBX() && i<=uGtAlg->getLastBX()) ) {
dumpTestVectors(i, m_testVectorFile, muons, egammas, taus, jets, etsums, uGtAlg, uGtExt);
dumpTestVectors(i, m_testVectorFile, muons, muonShowers, egammas, taus, jets, etsums, uGtAlg, uGtExt);
// } else {
// edm::LogWarning("GtRecordDump") << "WARNING: Not enough information to dump test vectors for this bx=" << i << endl;
// }
Expand Down Expand Up @@ -600,6 +635,7 @@ namespace l1t {
void GtRecordDump::dumpTestVectors(int bx,
std::ofstream& myOutFile,
Handle<BXVector<l1t::Muon>> muons,
Handle<BXVector<l1t::MuonShower>> muonShowers,
Handle<BXVector<l1t::EGamma>> egammas,
Handle<BXVector<l1t::Tau>> taus,
Handle<BXVector<l1t::Jet>> jets,
Expand All @@ -611,20 +647,73 @@ namespace l1t {
// Dump Bx (4 digits)
myOutFile << std::dec << std::setw(4) << std::setfill('0') << m_absBx;

// Dump 8 Muons (16 digits + space)
// Dump 8 Muons (16 digits + space) + Muon Showers
int nDumped = 0;
if (muons.isValid()) {

int muNumber = 0; //keeps track of which muons get which muon shower information
if (muons.isValid() && muonShowers.isValid()) {
for (std::vector<l1t::Muon>::const_iterator mu = muons->begin(bx); mu != muons->end(bx); ++mu) {
cms_uint64_t packedWd = formatMuon(mu);
// loop over valid muons in this bx (muon 0 up to max possible of muon 7)
int muShowerBit = 0; // default value for muon shower bit
if (bx >= muonShowers->getFirstBX() && bx <= muonShowers->getLastBX()) {
if (muonShowers->size(bx) > 0) {
std::vector<l1t::MuonShower>::const_iterator muShower = muonShowers->begin(bx);
if (muNumber == 0)
muShowerBit = muShower->isOneNominalInTime();
if (muNumber == 2)
muShowerBit = muShower->isOneTightInTime();
if (muNumber == 3)
muShowerBit = muShower->isTwoLooseDiffSectorsInTime();
if (muNumber == 4)
muShowerBit = muShower->musOutOfTime0();
if (muNumber == 6)
muShowerBit = muShower->musOutOfTime1();
}
}
cms_uint64_t packedWd = formatMuon(mu, muShowerBit);
if (nDumped < 8) {
myOutFile << " " << std::hex << std::setw(16) << std::setfill('0') << packedWd;
nDumped++;
}
}
++muNumber; //keeps track of how many muons have been processed
} // end loop over Muons in this bx

// Muon Shower information can exist, even if a muon object does not exist. Hence,
// now loop over non-existant muons from muNumber up to max of 7 and add the muon shower info
int start = muNumber;
for (int nonExistantMuon = start; nonExistantMuon < 8; nonExistantMuon++) {
int muShowerBit = 0; // default value for muon shower bit
if (bx >= muonShowers->getFirstBX() && bx <= muonShowers->getLastBX()) {
if (muonShowers->size(bx) > 0) {
std::vector<l1t::MuonShower>::const_iterator muShower = muonShowers->begin(bx);
if (muNumber == 0)
muShowerBit = muShower->isOneNominalInTime();
if (muNumber == 2)
muShowerBit = muShower->isOneTightInTime();
if (muNumber == 3)
muShowerBit = muShower->isTwoLooseDiffSectorsInTime();
if (muNumber == 4)
muShowerBit = muShower->musOutOfTime0();
if (muNumber == 6)
muShowerBit = muShower->musOutOfTime1();
}
}
cms_uint64_t packedWd = formatNonExistantMuon(muShowerBit);
if (nDumped < 8) {
myOutFile << " " << std::hex << std::setw(16) << std::setfill('0') << packedWd;
nDumped++;
}
++muNumber; // keep track of the number of muons processed
} // end loop over non-existant muons
}
for (int i = nDumped; i < 8; i++) {
myOutFile << " " << std::hex << std::setw(16) << std::setfill('0') << empty;
}
if (!muons.isValid())
std::cout << "========= WARNING: ALL MUONS INVALID ==========" << std::endl;
if (!muonShowers.isValid())
std::cout << "========= WARNING: ALL MUON SHOWERS INVALID ==========" << std::endl;
//===========================================

// Dump 12 EG (8 digits + space)
nDumped = 0;
Expand Down Expand Up @@ -846,7 +935,7 @@ namespace l1t {
m_absBx++;
}

cms_uint64_t GtRecordDump::formatMuon(std::vector<l1t::Muon>::const_iterator mu) {
cms_uint64_t GtRecordDump::formatMuon(std::vector<l1t::Muon>::const_iterator mu, int muShowerBit) {
cms_uint64_t packedVal = 0;

// Pack Bits
Expand All @@ -855,6 +944,7 @@ namespace l1t {
// packedVal |= ((cms_uint64_t)(mu->hwEta() & 0x1ff) << 53); // removed
packedVal |= ((cms_uint64_t)(mu->hwPtUnconstrained() & 0xff) << 53); // added
packedVal |= ((cms_uint64_t)(mu->hwDXY() & 0x3) << 62); // added
packedVal |= ((cms_uint64_t)(muShowerBit & 0x1) << 61); // added
packedVal |= ((cms_uint64_t)(mu->hwEtaAtVtx() & 0x1ff) << 23); // & 0x1ff) <<9);
packedVal |= ((cms_uint64_t)(mu->hwPt() & 0x1ff) << 10); // & 0x1ff) <<0);
packedVal |= ((cms_uint64_t)(mu->hwChargeValid() & 0x1) << 35); // & 0x1) <<28);
Expand Down Expand Up @@ -883,6 +973,8 @@ namespace l1t {
// << ((cms_uint64_t)(mu->hwPhi() & 0x3ff) << 43) << std::endl;
// std::cout << "<< 53; mu->hwPtUnconstrained() = " << std::hex << std::setw(16) << std::setfill('0')
// << ((cms_uint64_t)(mu->hwPtUnconstrained() & 0xff) << 53) << std::endl;
// std::cout << "<< 61; muShowerBit = " << std::hex << std::setw(16) << std::setfill('0')
// << ((cms_uint64_t)(muShowerBit & 0x1) << 61) << std::endl;
// std::cout << "<< 62; mu->hwDXY() = " << std::hex << std::setw(16) << std::setfill('0')
// << ((cms_uint64_t)(mu->hwDXY() & 0x3) << 62) << std::endl;
// std::cout << "packedWord = " << std::hex << std::setw(16) << std::setfill('0') << packedVal
Expand All @@ -893,6 +985,26 @@ namespace l1t {
return packedVal;
}

cms_uint64_t GtRecordDump::formatNonExistantMuon(int muShowerBit) {
cms_uint64_t packedVal = 0;

// Pack Bits
packedVal |= ((cms_uint64_t)(0 & 0x3ff) << 43);
packedVal |= ((cms_uint64_t)(0 & 0x3ff) << 0); // & 0x3ff) <<18);
// packedVal |= ((cms_uint64_t)(mu->hwEta() & 0x1ff) << 53); // removed
packedVal |= ((cms_uint64_t)(0 & 0xff) << 53); // added
packedVal |= ((cms_uint64_t)(0 & 0x3) << 62); // added
packedVal |= ((cms_uint64_t)(muShowerBit & 0x1) << 61); // added
packedVal |= ((cms_uint64_t)(0 & 0x1ff) << 23); // & 0x1ff) <<9);
packedVal |= ((cms_uint64_t)(0 & 0x1ff) << 10); // & 0x1ff) <<0);
packedVal |= ((cms_uint64_t)(0 & 0x1) << 35); // & 0x1) <<28);
packedVal |= ((cms_uint64_t)(0 & 0x1) << 34); // & 0x1) <<29);
packedVal |= ((cms_uint64_t)(0 & 0xf) << 19); // & 0xf) <<30);
packedVal |= ((cms_uint64_t)(0 & 0x3) << 32); // & 0x3) <<34);

return packedVal;
}

unsigned int GtRecordDump::formatEG(std::vector<l1t::EGamma>::const_iterator eg) {
unsigned int packedVal = 0;

Expand Down
Loading

0 comments on commit 902a2b0

Please sign in to comment.