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

implements UPT invariant mass triggers in uGT emulator #33708

Merged
merged 2 commits into from May 14, 2021
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
13 changes: 13 additions & 0 deletions L1Trigger/L1TGlobal/interface/GlobalScales.h
Expand Up @@ -38,6 +38,12 @@ namespace l1t {
double etStep;
std::vector<std::pair<double, double>> etBins;

// Added displaced muons
double uptMin;
double uptMax;
double uptStep;
std::vector<std::pair<double, double>> uptBins;

double phiMin;
double phiMax;
double phiStep;
Expand Down Expand Up @@ -67,6 +73,9 @@ namespace l1t {
virtual void setLUT_DeltaEta(const std::string& lutName, std::vector<long long> lut, unsigned int precision);
virtual void setLUT_DeltaPhi(const std::string& lutName, std::vector<long long> lut, unsigned int precision);
virtual void setLUT_Pt(const std::string& lutName, std::vector<long long> lut, unsigned int precision);
virtual void setLUT_Upt(const std::string& lutName,
std::vector<long long> lut,
unsigned int precision); // Added for displaced muons
virtual void setLUT_Cosh(const std::string& lutName, std::vector<long long> lut, unsigned int precision);
virtual void setLUT_Cos(const std::string& lutName, std::vector<long long> lut, unsigned int precision);
virtual void setLUT_Sin(const std::string& lutName, std::vector<long long> lut, unsigned int precision);
Expand All @@ -90,6 +99,7 @@ namespace l1t {
long long getLUT_DeltaEta(std::string lutName, int element) const;
long long getLUT_DeltaPhi(std::string lutName, int element) const;
long long getLUT_Pt(const std::string& lutName, int element) const;
long long getLUT_Upt(const std::string& lutName, int element) const; // Added for displaced muons
long long getLUT_DeltaEta_Cosh(std::string lutName, int element) const;
long long getLUT_DeltaPhi_Cos(std::string lutName, int element) const;
long long getLUT_Cos(const std::string& lutName, int element) const;
Expand All @@ -98,6 +108,7 @@ namespace l1t {
unsigned int getPrec_DeltaEta(const std::string& lutName) const;
unsigned int getPrec_DeltaPhi(const std::string& lutName) const;
unsigned int getPrec_Pt(const std::string& lutName) const;
unsigned int getPrec_Upt(const std::string& lutName) const; // Added for displaced muons
unsigned int getPrec_DeltaEta_Cosh(const std::string& lutName) const;
unsigned int getPrec_DeltaPhi_Cos(const std::string& lutName) const;
unsigned int getPrec_Cos(const std::string& lutName) const;
Expand Down Expand Up @@ -131,6 +142,7 @@ namespace l1t {
std::map<std::string, std::vector<long long>> m_lut_DeltaEta;
std::map<std::string, std::vector<long long>> m_lut_DeltaPhi;
std::map<std::string, std::vector<long long>> m_lut_Pt;
std::map<std::string, std::vector<long long>> m_lut_Upt; // Added for displaced muons
std::map<std::string, std::vector<long long>> m_lut_Cosh;
std::map<std::string, std::vector<long long>> m_lut_Cos;
std::map<std::string, std::vector<long long>> m_lut_Sin;
Expand All @@ -139,6 +151,7 @@ namespace l1t {
std::map<std::string, unsigned int> m_Prec_DeltaEta;
std::map<std::string, unsigned int> m_Prec_DeltaPhi;
std::map<std::string, unsigned int> m_Prec_Pt;
std::map<std::string, unsigned int> m_Prec_Upt; // Added for displaced muons
std::map<std::string, unsigned int> m_Prec_Cosh;
std::map<std::string, unsigned int> m_Prec_Cos;
std::map<std::string, unsigned int> m_Prec_Sin;
Expand Down
79 changes: 73 additions & 6 deletions L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc
Expand Up @@ -12,6 +12,7 @@
* \new features: Vladimir Rekovic
* - indexing
* - correlations with overlap object removal
* - displaced muons by R.Cavanaugh
*
* $Date$
* $Revision$
Expand Down Expand Up @@ -297,7 +298,8 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu)
condition.getType() == esConditionType::CaloCaloCorrelation ||
condition.getType() == esConditionType::CaloEsumCorrelation ||
condition.getType() == esConditionType::InvariantMass ||
condition.getType() == esConditionType::TransverseMass) {
condition.getType() == esConditionType::TransverseMass ||
condition.getType() == esConditionType::InvariantMassUpt) { // Added for displaced muons
parseCorrelation(condition, chipNr);

//parse Externals
Expand Down Expand Up @@ -588,6 +590,19 @@ bool l1t::TriggerMenuParser::parseScales(std::map<std::string, tmeventsetup::esS
}
}
} break;
case esScaleType::UnconstrainedPtScale: { // Added for displaced muons
scaleParam->uptMin = scale.getMinimum();
scaleParam->uptMax = scale.getMaximum();
scaleParam->uptStep = scale.getStep();

//Get bin edges
const std::vector<esBin>& binsV = scale.getBins();
for (unsigned int i = 0; i < binsV.size(); i++) {
const esBin& bin = binsV.at(i);
std::pair<double, double> binLimits(bin.minimum, bin.maximum);
scaleParam->uptBins.push_back(binLimits);
}
} break;
case esScaleType::EtaScale: {
scaleParam->etaMin = scale.getMinimum();
scaleParam->etaMax = scale.getMaximum();
Expand Down Expand Up @@ -664,6 +679,7 @@ bool l1t::TriggerMenuParser::parseScales(std::map<std::string, tmeventsetup::esS
// ---------------
parsePt_LUTS(scaleMap, "Mass", "EG", precisions["PRECISION-EG-MU-MassPt"]);
parsePt_LUTS(scaleMap, "Mass", "MU", precisions["PRECISION-EG-MU-MassPt"]);
parseUpt_LUTS(scaleMap, "Mass", "MU", precisions["PRECISION-EG-MU-MassPt"]); // Added for displaced muons
parsePt_LUTS(scaleMap, "Mass", "JET", precisions["PRECISION-EG-JET-MassPt"]);
parsePt_LUTS(scaleMap, "Mass", "TAU", precisions["PRECISION-EG-TAU-MassPt"]);
parsePt_LUTS(scaleMap, "Mass", "ETM", precisions["PRECISION-EG-ETM-MassPt"]);
Expand Down Expand Up @@ -850,6 +866,29 @@ void l1t::TriggerMenuParser::parsePt_LUTS(std::map<std::string, tmeventsetup::es
m_gtScales.setLUT_Pt(lutpfx + "_" + scLabel1, lut_pt, prec);
}

// Added for displaced muons
void l1t::TriggerMenuParser::parseUpt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
std::string lutpfx,
std::string obj1,
unsigned int prec) {
using namespace tmeventsetup;

// First Delta Eta for this set
std::string scLabel1 = obj1;
scLabel1 += "-UPT";

//This LUT does not exist in L1 Menu file, don't fill it
if (scaleMap.find(scLabel1) == scaleMap.end())
return;

const esScale* scale1 = &scaleMap.find(scLabel1)->second;

std::vector<long long> lut_pt;
getLut(lut_pt, scale1, prec);

m_gtScales.setLUT_Upt(lutpfx + "_" + scLabel1, lut_pt, prec);
}

void l1t::TriggerMenuParser::parseDeltaEta_Cosh_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
std::string obj1,
std::string obj2,
Expand Down Expand Up @@ -1300,6 +1339,11 @@ bool l1t::TriggerMenuParser::parseMuonCorr(const tmeventsetup::esObject* corrMu,
relativeBx = corrMu->getBxOffset();

// Loop over the cuts for this object
int upperUnconstrainedPtInd = -1; // Added for displaced muons
int lowerUnconstrainedPtInd = 0; // Added for displaced muons
int upperImpactParameterInd = -1; // Added for displaced muons
int lowerImpactParameterInd = 0; // Added for displaced muons
int impactParameterLUT = 0xF; // Added for displaced muons, default is to ignore unless specified
int upperThresholdInd = -1;
int lowerThresholdInd = 0;
int upperIndexInd = -1;
Expand All @@ -1317,6 +1361,17 @@ bool l1t::TriggerMenuParser::parseMuonCorr(const tmeventsetup::esObject* corrMu,
const esCut cut = cuts.at(kk);

switch (cut.getCutType()) {
case esCutType::UnconstrainedPt: // Added for displaced muons
lowerUnconstrainedPtInd = cut.getMinimum().index;
upperUnconstrainedPtInd = cut.getMaximum().index;
break;

case esCutType::ImpactParameter: // Added for displaced muons
lowerImpactParameterInd = cut.getMinimum().index;
upperImpactParameterInd = cut.getMaximum().index;
impactParameterLUT = l1tstr2int(cut.getData());
break;

case esCutType::Threshold:
lowerThresholdInd = cut.getMinimum().index;
upperThresholdInd = cut.getMaximum().index;
Expand Down Expand Up @@ -1383,6 +1438,12 @@ bool l1t::TriggerMenuParser::parseMuonCorr(const tmeventsetup::esObject* corrMu,
} //end loop over cuts

// Set the parameter cuts
objParameter[0].unconstrainedPtHigh = upperUnconstrainedPtInd; // Added for displacd muons
objParameter[0].unconstrainedPtLow = lowerUnconstrainedPtInd; // Added for displacd muons
objParameter[0].impactParameterHigh = upperImpactParameterInd; // Added for displacd muons
objParameter[0].impactParameterLow = lowerImpactParameterInd; // Added for displacd muons
objParameter[0].impactParameterLUT = impactParameterLUT; // Added for displacd muons

objParameter[0].ptHighThreshold = upperThresholdInd;
objParameter[0].ptLowThreshold = lowerThresholdInd;

Expand Down Expand Up @@ -2576,14 +2637,20 @@ bool l1t::TriggerMenuParser::parseCorrelation(tmeventsetup::esCondition corrCond
// cutType = cutType | 0x8;
if (corrCond.getType() == esConditionType::TransverseMass) {
cutType = cutType | 0x10;
//std::cout << "CCLA running Transverse mass cutType= " << cutType << std::endl;
} else {
cutType = cutType | 0x8;
//std::cout << "CCLA running Invarient mass cutType= " << cutType << std::endl;
}
}
}
}
} else if (cut.getCutType() == esCutType::MassUpt) { // Added for displaced muons
LogDebug("TriggerMenuParser") << "CutType: " << cut.getCutType() << "\tMass Cut minV = " << minV
<< " Max = " << maxV << " precMin = " << cut.getMinimum().index
<< " precMax = " << cut.getMaximum().index << std::endl;
corrParameter.minMassCutValue = (long long)(minV * pow(10., cut.getMinimum().index));
corrParameter.maxMassCutValue = (long long)(maxV * pow(10., cut.getMaximum().index));
corrParameter.precMassCut = cut.getMinimum().index;
cutType = cutType | 0x40; // Note: 0x40 (MassUpt) is next available bit after 0x20 (TwoBodyPt)
} // Careful: cutType carries same info as esCutType, but is hard coded!!
} // This seems like a historical hack, which may be error prone.
} // cutType is defined here, for use later in CorrCondition.cc
corrParameter.corrCutType = cutType;

// Get the two objects that form the legs
Expand Down
8 changes: 8 additions & 0 deletions L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h
Expand Up @@ -15,6 +15,8 @@
* \author Vladimir Rekovic
* - indexing
* - correlations with overlap object removal
* \author R. Cavanaugh
* - displaced muons
*
* $Date$
* $Revision$
Expand Down Expand Up @@ -294,6 +296,12 @@ namespace l1t {
std::string obj1,
unsigned int prec);

// Parse LUT for Upt LUT in Mass calculation for displaced muons
void parseUpt_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
std::string lutpfx,
std::string obj1,
unsigned int prec);

// Parse LUT for Delta Eta and Cosh
void parseDeltaEta_Cosh_LUTS(std::map<std::string, tmeventsetup::esScale> scaleMap,
std::string obj1,
Expand Down
44 changes: 39 additions & 5 deletions L1Trigger/L1TGlobal/src/CorrCondition.cc
Expand Up @@ -321,6 +321,13 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
int etBin1 = 0;
double et1Phy = 0.;

int uptIndex0 = 0; // Added displaced muons
int uptBin0 = 0; // Added displaced muons
double upt0Phy = 0.0; // Added displaced muons
int uptIndex1 = 0; // Added displaced muons
int uptBin1 = 0; // Added displaced muons
double upt1Phy = 0.0; // Added displaced muons

int chrg0 = -1;
int chrg1 = -1;

Expand Down Expand Up @@ -370,13 +377,14 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
phiIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPhiAtVtx(); //(*candMuVec)[obj0Index]->phiIndex();
etaIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwEtaAtVtx();
etIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPt();
uptIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPtUnconstrained(); // Added for displaced muons
chrg0 = (candMuVec->at(cond0bx, obj0Index))->hwCharge();
int etaBin0 = etaIndex0;
if (etaBin0 < 0)
etaBin0 = m_gtScales->getMUScales().etaBins.size() + etaBin0; //twos complement
// LogDebug("L1TGlobal") << "Muon phi" << phiIndex0 << " eta " << etaIndex0 << " etaBin0 = " << etaBin0 << " et " << etIndex0 << std::endl;

etBin0 = etIndex0;
uptBin0 = uptIndex0; // Added for displaced muons
int ssize = m_gtScales->getMUScales().etBins.size();
if (etBin0 >= ssize) {
etBin0 = ssize - 1;
Expand All @@ -390,7 +398,11 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
eta0Phy = 0.5 * (binEdges.second + binEdges.first);
binEdges = m_gtScales->getMUScales().etBins.at(etBin0);
et0Phy = 0.5 * (binEdges.second + binEdges.first);

if (corrPar.corrCutType & 0x40) // Added for displaced muons
{
binEdges = m_gtScales->getMUScales().uptBins.at(uptBin0);
upt0Phy = 0.5 * (binEdges.second + binEdges.first);
}
LogDebug("L1TGlobal") << "Found all quantities for the muon 0" << std::endl;
} break;

Expand Down Expand Up @@ -646,13 +658,15 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
phiIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwPhiAtVtx(); //(*candMuVec)[obj0Index]->phiIndex();
etaIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwEtaAtVtx();
etIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwPt();
uptIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwPtUnconstrained(); // Added for displaced muons
chrg1 = (candMuVec->at(cond1bx, obj1Index))->hwCharge();
etaBin1 = etaIndex1;
if (etaBin1 < 0)
etaBin1 = m_gtScales->getMUScales().etaBins.size() + etaBin1;
// LogDebug("L1TGlobal") << "Muon phi" << phiIndex1 << " eta " << etaIndex1 << " etaBin1 = " << etaBin1 << " et " << etIndex1 << std::endl;

etBin1 = etIndex1;
uptBin1 = uptIndex1; // Added for displaced muons
int ssize = m_gtScales->getMUScales().etBins.size();
if (etBin1 >= ssize) {
LogTrace("L1TGlobal") << "muon2 hw et" << etBin1 << " out of scale range. Setting to maximum.";
Expand All @@ -666,7 +680,12 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
eta1Phy = 0.5 * (binEdges.second + binEdges.first);
binEdges = m_gtScales->getMUScales().etBins.at(etBin1);
et1Phy = 0.5 * (binEdges.second + binEdges.first);

if (corrPar.corrCutType & 0x40) // Added for displaced muons
{
binEdges = m_gtScales->getMUScales().uptBins.at(uptBin1);
upt1Phy = 0.5 * (binEdges.second + binEdges.first);
}
LogDebug("L1TGlobal") << "Found all quantities for the muon 1" << std::endl;
} break;
case CondCalo: {
switch (cndObjTypeVec[1]) {
Expand Down Expand Up @@ -1149,7 +1168,8 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
}
}

if (corrPar.corrCutType & 0x8 || corrPar.corrCutType & 0x10) {
if (corrPar.corrCutType & 0x8 || corrPar.corrCutType & 0x10 ||
corrPar.corrCutType & 0x40) { // added 0x40 for massUpt
//invariant mass calculation based on
// M = sqrt(2*p1*p2(cosh(eta1-eta2) - cos(phi1 - phi2)))
// but we calculate (1/2)M^2
Expand All @@ -1159,6 +1179,8 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
if (corrPar.corrCutType & 0x10)
coshDeltaEtaPhy = 1.;
double massSqPhy = et0Phy * et1Phy * (coshDeltaEtaPhy - cosDeltaPhiPhy);
if (corrPar.corrCutType & 0x40) // Added for displaced muons
massSqPhy = upt0Phy * upt1Phy * (coshDeltaEtaPhy - cosDeltaPhiPhy);

long long cosDeltaPhiLUT = m_gtScales->getLUT_DeltaPhi_Cos(lutName, deltaPhiFW);
unsigned int precCosLUT = m_gtScales->getPrec_DeltaPhi_Cos(lutName);
Expand All @@ -1184,6 +1206,19 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
long long ptObj1 = m_gtScales->getLUT_Pt("Mass_" + lutName, etIndex1);
unsigned int precPtLUTObj1 = m_gtScales->getPrec_Pt("Mass_" + lutName);

if (corrPar.corrCutType & 0x40) // Added for displaced muons
{
lutName = lutObj0;
lutName += "-UPT";
ptObj0 = m_gtScales->getLUT_Upt("Mass_" + lutName, uptIndex0);
precPtLUTObj0 = m_gtScales->getPrec_Upt("Mass_" + lutName);

lutName = lutObj1;
lutName += "-UPT";
ptObj1 = m_gtScales->getLUT_Upt("Mass_" + lutName, uptIndex1);
precPtLUTObj1 = m_gtScales->getPrec_Upt("Mass_" + lutName);
}

// Pt and Angles are at different precission.
long long massSq = ptObj0 * ptObj1 * (coshDeltaEtaLUT - cosDeltaPhiLUT);

Expand Down Expand Up @@ -1214,7 +1249,6 @@ const bool l1t::CorrCondition::evaluateCondition(const int bxEval) const {
LogDebug("L1TGlobal") << " Passed Invariant Mass Cut ["
<< (long long)(corrPar.minMassCutValue * pow(10, preShift)) << ","
<< (long long)(corrPar.maxMassCutValue * pow(10, preShift)) << "]" << std::endl;

} else {
LogDebug("L1TGlobal") << " Failed Invariant Mass Cut ["
<< (long long)(corrPar.minMassCutValue * pow(10, preShift)) << ","
Expand Down