Skip to content

Commit

Permalink
Merge pull request #41313 from elfontan/EF_BA_uGT_index_etaCut_backpo…
Browse files Browse the repository at this point in the history
…rt130X

[Backport] Adding the new muon track finder index and three eta cuts features in the GT emulator
  • Loading branch information
cmsbuild authored Apr 24, 2023
2 parents a15d59b + 1792f9b commit 7741939
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 303 deletions.
17 changes: 10 additions & 7 deletions L1Trigger/L1TGlobal/interface/CaloTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
* \new features: R. Cavanaugh
* - added LUT bit for LLP displaced jets
* Note: Calo Trig considers the DISP bit part of the
* quality word, but uGT firmware considers the
* Note: Calo Trig considers the DISP bit part of the
* quality word, but uGT firmware considers the
* DISP bit to be distinct from the quality word.
*
* \new features: Bernhard Arnold, Elisa Fontanesi
* - added etaWindows for the checkRangeEta function: it allows to use up to five eta cuts in L1 algorithms
* $Date$
* $Revision$
*
Expand Down Expand Up @@ -57,6 +58,11 @@ class CaloTemplate : public GlobalCondition {
CaloTemplate& operator=(const CaloTemplate&);

public:
struct Window {
unsigned int lower;
unsigned int upper;
};

/// typedef for a single object template
struct ObjectParameter {
unsigned int etLowThreshold;
Expand All @@ -70,10 +76,7 @@ class CaloTemplate : public GlobalCondition {
unsigned int qualityLUT;
unsigned int displacedLUT; // Added for LLP Jets

unsigned int etaWindow1Lower;
unsigned int etaWindow1Upper;
unsigned int etaWindow2Lower;
unsigned int etaWindow2Upper;
std::vector<Window> etaWindows;

unsigned int phiWindow1Lower;
unsigned int phiWindow1Upper;
Expand Down
159 changes: 78 additions & 81 deletions L1Trigger/L1TGlobal/interface/ConditionEvaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
* <TODO: enter implementation details>
*
* \author: Vasile Mihai Ghete - HEPHY Vienna
* Vladimir Rekovic - extend for indexing
*
* \new features: Vladimir Rekovic
* - extend for indexing
* \new features: Bernhard Arnold, Elisa Fontanesi
* - extended for muon track finder index feature (used for Run 3 muon monitoring seeds)
* - checkRangeEta function allows to use up to five eta cuts in L1 algorithms
*
*/

Expand Down Expand Up @@ -93,7 +97,7 @@ namespace l1t {

/// check if a value is greater than a threshold or
/// greater-or-equal depending on the value of the condGEqValue flag
/// Added by Rick Cavanaugh for Displaced Muons:
/// Added for Displaced Muons:
/// Above checkThreshold fails when value overflows or threshold window is invalid
/// Below checkUnconstrainedPt allows value to overflow and only evaluates cut if threshold window is valid
template <class Type1, class Type2>
Expand All @@ -110,38 +114,41 @@ namespace l1t {
template <class Type1>
const bool checkBit(const Type1& mask, const unsigned int bitNumber) const;

/// check if a value is in a given range and outside of a veto range
/// check if a value is in a given eta range and outside of a veto range
/// Up to five eta cuts are allowed in L1 algorithms.
/// Three eta cuts are used for the DoubleMu seeds with upt requirement implemented for Run 3 (2023)
template <class Type1>
const bool checkRangeEta(const unsigned int bitNumber,
const Type1& W1beginR,
const Type1& W1endR,
const Type1& W2beginR,
const Type1& W2endR,
const std::vector<Type1>& windows,
const unsigned int nEtaBits) const;

/// check if a value is in a given range and outside of a veto range
/// check if a value is in a given phi range and outside of a veto range
template <class Type1>
const bool checkRangePhi(const unsigned int bitNumber,
const Type1& W1beginR,
const Type1& W1endR,
const Type1& W2beginR,
const Type1& W2endR) const;

/// check if a value is in a given range
/// check if a value is in a given deltaEta range
template <class Type1>
const bool checkRangeDeltaEta(const unsigned int obj1Eta,
const unsigned int obj2Eta,
const Type1& lowerR,
const Type1& upperR,
const unsigned int nEtaBits) const;

/// check if a value is in a given range
/// check if a value is in a given deltaPhi range
template <class Type1>
const bool checkRangeDeltaPhi(const unsigned int obj1Phi,
const unsigned int obj2Phi,
const Type1& lowerR,
const Type1& upperR) const;

/// check if a value is in a given muon track finder index range
template <class Type1>
const bool checkRangeTfMuonIndex(const unsigned int bitNumber, const std::vector<Type1>& windows) const;

protected:
/// maximum number of objects received for the evaluation of the condition
/// usually retrieved from event setup
Expand Down Expand Up @@ -197,7 +204,7 @@ namespace l1t {

// check if a value is greater than a threshold or
// greater-or-equal depending on the value of the condGEqValue flag
/// Added by Rick Cavanaugh for Displaced Muons:
/// Added for Displaced Muons:
/// Above checkThreshold fails when value overflows or threshold window is invalid
/// Below checkUnconstrainedPt allows value to overflow and only evaluates cut if threshold window is valid
template <class Type1, class Type2>
Expand Down Expand Up @@ -228,7 +235,7 @@ namespace l1t {
return true;
}

// check if a index in a given range
// check if a index in a given index range
template <class Type1>
const bool ConditionEvaluation::checkIndex(const Type1& indexLo,
const Type1& indexHi,
Expand All @@ -237,7 +244,7 @@ namespace l1t {
<< "\n\t indexLo = " << indexLo << "\n\t indexHi = " << indexHi << "\n\t index = " << index
<< std::endl;

// set condtion to false if indexLo > indexHi
// set condition to false if indexLo > indexHi
if (indexLo > indexHi) {
return false;
}
Expand Down Expand Up @@ -274,89 +281,60 @@ namespace l1t {
return (mask & oneBit);
}

/// check if a value is in a given range and outside of a veto range
/// check if a value is in a given eta range and outside of a veto range
/// Up to five eta cuts are allowed in L1 algorithms.
/// Three eta cuts are used for the DoubleMu seeds with upt requirement implemented for Run 3 (2023)
template <class Type1>
const bool ConditionEvaluation::checkRangeEta(const unsigned int bitNumber,
const Type1& W1beginR,
const Type1& W1endR,
const Type1& W2beginR,
const Type1& W2endR,
const std::vector<Type1>& windows,
const unsigned int nEtaBits) const {
// set condtion to true if beginR==endR = default -1
if (W1beginR == W1endR && W1beginR == (Type1)-1) {
if (windows.empty()) {
return true;
}

unsigned int W1diff1 = W1endR - W1beginR;
unsigned int W1diff2 = bitNumber - W1beginR;
unsigned int W1diff3 = W1endR - bitNumber;

bool W1cond1 = ((W1diff1 >> nEtaBits) & 1) ? false : true;
bool W1cond2 = ((W1diff2 >> nEtaBits) & 1) ? false : true;
bool W1cond3 = ((W1diff3 >> nEtaBits) & 1) ? false : true;

// check if value is in range
// for begin <= end takes [begin, end]
// for begin >= end takes [begin, end] over zero angle!
bool passWindow1 = false;
if (W1cond1 && (W1cond2 && W1cond3))
passWindow1 = true;
else if (!W1cond1 && (W1cond2 || W1cond3))
passWindow1 = true;
else {
passWindow1 = false;
}

LogDebug("l1t|Global") << "\n l1t::ConditionEvaluation"
<< "\n\t bitNumber = " << bitNumber << "\n\t W1beginR = " << W1beginR
<< "\n\t W1endR = " << W1endR << "\n\t W1diff1 = " << W1diff1
<< "\n\t W1cond1 = " << W1cond1 << "\n\t W1diff2 = " << W1diff2
<< "\n\t W1cond2 = " << W1cond2 << "\n\t W1diff3 = " << W1diff3
<< "\n\t W1cond3 = " << W1cond3 << "\n\t passWindow1 = " << passWindow1 << std::endl;

if (W2beginR == W2endR && W2beginR == (Type1)-1) {
return passWindow1;
}

unsigned int W2diff1 = W2endR - W2beginR;
unsigned int W2diff2 = bitNumber - W2beginR;
unsigned int W2diff3 = W2endR - bitNumber;

bool W2cond1 = ((W2diff1 >> nEtaBits) & 1) ? false : true;
bool W2cond2 = ((W2diff2 >> nEtaBits) & 1) ? false : true;
bool W2cond3 = ((W2diff3 >> nEtaBits) & 1) ? false : true;

bool passWindow2 = false;
if (W2cond1 && (W2cond2 && W2cond3))
passWindow2 = true;
else if (!W2cond1 && (W2cond2 || W2cond3))
passWindow2 = true;
else {
passWindow2 = false;
for (const auto& window : windows) {
const unsigned int diff1 = window.upper - window.lower;
const unsigned int diff2 = bitNumber - window.lower;
const unsigned int diff3 = window.upper - bitNumber;

const bool cond1 = ((diff1 >> nEtaBits) & 1) ? false : true;
const bool cond2 = ((diff2 >> nEtaBits) & 1) ? false : true;
const bool cond3 = ((diff3 >> nEtaBits) & 1) ? false : true;

// check if value is in range
// for begin <= end takes [begin, end]
// for begin >= end takes [begin, end] over zero angle!
bool passWindow = false;
if (cond1 && (cond2 && cond3))
passWindow = true;
else if (!cond1 && (cond2 || cond3))
passWindow = true;
else
passWindow = false;

LogDebug("l1t|Global") << "\n l1t::ConditionEvaluation"
<< "\n\t bitNumber = " << bitNumber << "\n\t window.lower = " << window.lower
<< "\n\t window.upper = " << window.upper << "\n\t diff1 = " << diff1
<< "\n\t cond1 = " << cond1 << "\n\t diff2 = " << diff2 << "\n\t cond2 = " << cond2
<< "\n\t diff3 = " << diff3 << "\n\t cond3 = " << cond3
<< "\n\t passWindow = " << passWindow << std::endl;

if (passWindow) {
return true;
}
}

LogDebug("l1t|Global") << "\n\t W2beginR = " << W2beginR << "\n\t W2endR = " << W2endR
<< "\n\t W2diff1 = " << W2diff1 << "\n\t W2cond1 = " << W2cond1
<< "\n\t W2diff2 = " << W2diff2 << "\n\t W2cond2 = " << W2cond2
<< "\n\t W2diff3 = " << W2diff3 << "\n\t W2cond3 = " << W2cond3
<< "\n\t passWindow2 = " << passWindow2
<< "\n\t pass W1 || W2 = " << (passWindow1 || passWindow2) << std::endl;

if (passWindow1 || passWindow2) {
return true;
} else {
return false;
}
return false;
}

/// check if a value is in a given range and outside of a veto range
/// check if a value is in a given phi range and outside of a veto range
template <class Type1>
const bool ConditionEvaluation::checkRangePhi(const unsigned int bitNumber,
const Type1& W1beginR,
const Type1& W1endR,
const Type1& W2beginR,
const Type1& W2endR) const {
// set condtion to true if beginR==endR = default -1
// set condition to true if beginR==endR = default -1
if (W1beginR == W1endR && W1beginR == (Type1)-1) {
return true;
}
Expand Down Expand Up @@ -425,7 +403,7 @@ namespace l1t {
const Type1& lowerR,
const Type1& upperR,
const unsigned int nEtaBits) const {
/* // set condtion to true if beginR==endR = default -1 */
/* // set condition to true if beginR==endR = default -1 */
/* if( beginR==endR && beginR==-1 ){ */
/* return true; */
/* } */
Expand Down Expand Up @@ -504,5 +482,24 @@ namespace l1t {
}
}

template <class Type1>
const bool ConditionEvaluation::checkRangeTfMuonIndex(const unsigned int value,
const std::vector<Type1>& windows) const {
if (windows.empty()) {
return true;
}

for (const auto& window : windows) {
if ((window.lower <= value) and (value <= window.upper)) {
return true;
LogDebug("l1t|Global") << "\n l1t::ConditionEvaluation"
<< "\n\t window.lower = " << window.lower << "\n\t window.upper = " << window.upper
<< "Passed TfMuonIndex window" << std::endl;
}
}

return false;
}

} // namespace l1t
#endif
20 changes: 14 additions & 6 deletions L1Trigger/L1TGlobal/interface/MuonTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
* <TODO: enter implementation details>
*
* \author: Vasile Mihai Ghete - HEPHY Vienna
* Vladimir Rekovic - extend for indexing
*
*
* \new features: Vladimir Rekovic
* - extend for indexing
* \new features: Bernhard Arnold, Elisa Fontanesi
* - added etaWindows for the checkRangeEta function: it allows to use up to five eta cuts in L1 algorithms
* - extended for muon track finder index feature (used for Run 3 muon monitoring seeds)
* $Date$
* $Revision$
*
Expand Down Expand Up @@ -51,6 +55,11 @@ class MuonTemplate : public GlobalCondition {
MuonTemplate& operator=(const MuonTemplate&);

public:
struct Window {
unsigned int lower;
unsigned int upper;
};

// typedef for a single object template
struct ObjectParameter {
unsigned int unconstrainedPtHigh;
Expand All @@ -73,15 +82,14 @@ class MuonTemplate : public GlobalCondition {

int charge;

unsigned int etaWindow1Lower;
unsigned int etaWindow1Upper;
unsigned int etaWindow2Lower;
unsigned int etaWindow2Upper;
std::vector<Window> etaWindows;

unsigned int phiWindow1Lower;
unsigned int phiWindow1Upper;
unsigned int phiWindow2Lower;
unsigned int phiWindow2Upper;

std::vector<Window> tfMuonIndexWindows;
};

// typedef for correlation parameters
Expand Down
1 change: 1 addition & 0 deletions L1Trigger/L1TGlobal/plugins/GtRecordDump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ namespace l1t {
packedVal |= ((cms_uint64_t)(mu->hwCharge() & 0x1) << 34); // & 0x1) <<29);
packedVal |= ((cms_uint64_t)(mu->hwQual() & 0xf) << 19); // & 0xf) <<30);
packedVal |= ((cms_uint64_t)(mu->hwIso() & 0x3) << 32); // & 0x3) <<34);
packedVal |= ((cms_uint64_t)(mu->tfMuonIndex() & 0x7f) << 36);

// if (false) { // for debugging purposes
// std::cout << "----------------------" << std::endl;
Expand Down
Loading

0 comments on commit 7741939

Please sign in to comment.