From ae20cb1d329f859b4b641d9dd4b9283b83fe057a Mon Sep 17 00:00:00 2001 From: elfontan Date: Tue, 22 Nov 2022 15:21:05 +0100 Subject: [PATCH] Fix to include the possibility to read the OS requirement for TripleMu seeds with the three-muon invariant mass requirement (final) --- .../interface/CorrelationThreeBodyTemplate.h | 3 + .../L1TGlobal/plugins/TriggerMenuParser.cc | 17 +- .../L1TGlobal/src/CorrThreeBodyCondition.cc | 178 +++++----- .../L1TGlobal/test/testVectorCode_data.py | 318 ++++++++++++++++++ 4 files changed, 420 insertions(+), 96 deletions(-) create mode 100644 L1Trigger/L1TGlobal/test/testVectorCode_data.py diff --git a/L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h b/L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h index dd3be14cd8e73..9d469660e5e9c 100644 --- a/L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h +++ b/L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h @@ -77,6 +77,9 @@ class CorrelationThreeBodyTemplate : public GlobalCondition { unsigned int precMassCut; int corrCutType; + + //Requirement on charge of the three muon legs + unsigned int chargeCorrelation; }; public: diff --git a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc index ec7e2e0cf4e44..42e2972f319b6 100644 --- a/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc +++ b/L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc @@ -2988,19 +2988,30 @@ bool l1t::TriggerMenuParser::parseCorrelationThreeBody(tmeventsetup::esCondition // Storage of the correlation selection CorrelationThreeBodyTemplate::CorrelationThreeBodyParameter corrThreeBodyParameter; + // Set charge correlation parameter + //corrThreeBodyParameter.chargeCorrelation = chargeCorrelation; //tmpValues[0]; + //corrThreeBodyParameter.chargeCorrelation = 1; //ignore charge correlation for corr-legs // Get the correlation cuts on the legs int cutType = 0; const std::vector& cuts = corrCond.getCuts(); - for (size_t lll = 0; lll < cuts.size(); lll++) { + for (size_t lll = 0; lll < cuts.size(); lll++) { // START esCut lll const esCut cut = cuts.at(lll); + if (cut.getCutType() == esCutType::ChargeCorrelation) { + if (cut.getData() == "ls") + corrThreeBodyParameter.chargeCorrelation = 2; + else if (cut.getData() == "os") + corrThreeBodyParameter.chargeCorrelation = 4; + else + corrThreeBodyParameter.chargeCorrelation = 1; //ignore charge correlation + } + // // Until utm has method to calculate these, do the integer value calculation with precision. // double minV = cut.getMinimum().value; double maxV = cut.getMaximum().value; - //Scale down very large numbers out of xml if (maxV > 1.0e8) maxV = 1.0e8; @@ -3019,7 +3030,7 @@ bool l1t::TriggerMenuParser::parseCorrelationThreeBody(tmeventsetup::esCondition corrThreeBodyParameter.precMassCut = cut.getMinimum().index; cutType = cutType | 0x80; } - } + } // END esCut lll corrThreeBodyParameter.corrCutType = cutType; // Get the three objects that form the legs diff --git a/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc b/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc index fcfc5037477a0..ec34597390a83 100644 --- a/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc +++ b/L1Trigger/L1TGlobal/src/CorrThreeBodyCondition.cc @@ -94,7 +94,6 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons } bool condResult = false; - bool reqObjResult = false; // number of objects in the condition (three) and their type int nObjInCond = 3; @@ -116,6 +115,8 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons int cond2bx(0); // FIRST OBJECT + bool reqObjResult = false; + if (cond0Categ == CondMuon) { LogDebug("L1TGlobal") << "\n --------------------- First muon checks ---------------------" << std::endl; corrMuon = static_cast(m_gtCond0); @@ -209,7 +210,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons return false; } - // return if third subcondition is false + // Return if third subcondition is false if (!reqObjResult) { return false; } else { @@ -219,22 +220,22 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons << std::endl; } - // since we have three good legs get the correlation parameters + // Since we have three good legs get the correlation parameters CorrelationThreeBodyTemplate::CorrelationThreeBodyParameter corrPar = *(m_gtCorrelationThreeBodyTemplate->correlationThreeBodyParameter()); - // vector to store the indices of the objects involved in the condition evaluation + // Vector to store the indices of the objects involved in the condition evaluation SingleCombInCond objectsInComb; objectsInComb.reserve(nObjInCond); - // clear the m_combinationsInCond vector: + // Clear the m_combinationsInCond vector: // it will store the set of objects satisfying the condition evaluated as true (combinationsInCond()).clear(); - // pointers to objects + // Pointers to objects const BXVector* candMuVec = nullptr; - // make the conversions of the indices, depending on the combination of objects involved + // Make the conversions of the indices, depending on the combination of objects involved int phiIndex0 = 0; double phi0Phy = 0.; int phiIndex1 = 0; @@ -262,6 +263,11 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons int etBin2 = 0; double et2Phy = 0.; + // Charges to take into account the charge correlation + int chrg0 = -1; + int chrg1 = -1; + int chrg2 = -1; + // Determine the number of phi bins to get cutoff at pi int phiBound = 0; if (cond0Categ == CondMuon || cond1Categ == CondMuon || cond2Categ == CondMuon) { @@ -307,13 +313,14 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons if (cond0Categ == CondMuon) { lutObj0 = "MU"; candMuVec = m_uGtB->getCandL1Mu(); - phiIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPhiAtVtx(); //(*candMuVec)[obj0Index]->phiIndex(); + phiIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPhiAtVtx(); etaIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwEtaAtVtx(); etIndex0 = (candMuVec->at(cond0bx, obj0Index))->hwPt(); + chrg0 = (candMuVec->at(cond0bx, obj0Index))->hwCharge(); + 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; + etaBin0 = m_gtScales->getMUScales().etaBins.size() + etaBin0; etBin0 = etIndex0; int ssize = m_gtScales->getMUScales().etBins.size(); @@ -322,7 +329,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons LogTrace("L1TGlobal") << "MU0 hw et" << etBin0 << " out of scale range. Setting to maximum."; } - // Determine Floating Pt numbers for floating point caluclation + // Determine Floating Pt numbers for floating point calculation std::pair binEdges = m_gtScales->getMUScales().phiBins.at(phiIndex0); phi0Phy = 0.5 * (binEdges.second + binEdges.first); binEdges = m_gtScales->getMUScales().etaBins.at(etaBin0); @@ -339,7 +346,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons // SECOND OBJECT: Now loop over the second leg to get its information for (std::vector::const_iterator it1Comb = cond1Comb.begin(); it1Comb != cond1Comb.end(); it1Comb++) { - LogDebug("L1TGlobal") << "Looking at second subdondition" << std::endl; + LogDebug("L1TGlobal") << "Looking at second subcondition" << std::endl; int obj1Index = -1; if (!(*it1Comb).empty()) { @@ -349,8 +356,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons return false; } - //If we are dealing with the same object type avoid the two legs - // either being the same object + // If we are dealing with the same object type avoid the two legs either being the same object if (cndObjTypeVec[0] == cndObjTypeVec[1] && obj0Index == obj1Index && cond0bx == cond1bx) { LogDebug("L1TGlobal") << "Corr Condition looking at same leg...skip" << std::endl; continue; @@ -359,13 +365,14 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons if (cond1Categ == CondMuon) { lutObj1 = "MU"; candMuVec = m_uGtB->getCandL1Mu(); - phiIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwPhiAtVtx(); //(*candMuVec)[obj0Index]->phiIndex(); + phiIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwPhiAtVtx(); etaIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwEtaAtVtx(); etIndex1 = (candMuVec->at(cond1bx, obj1Index))->hwPt(); + 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; int ssize = m_gtScales->getMUScales().etBins.size(); @@ -401,7 +408,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons return false; } - //If we are dealing with the same object type avoid the two legs + // If we are dealing with the same object type avoid the two legs // either being the same object if ((cndObjTypeVec[0] == cndObjTypeVec[2] && obj0Index == obj2Index && cond0bx == cond2bx) || (cndObjTypeVec[1] == cndObjTypeVec[2] && obj1Index == obj2Index && cond1bx == cond2bx)) { @@ -412,9 +419,11 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons if (cond2Categ == CondMuon) { lutObj2 = "MU"; candMuVec = m_uGtB->getCandL1Mu(); - phiIndex2 = (candMuVec->at(cond2bx, obj2Index))->hwPhiAtVtx(); //(*candMuVec)[obj0Index]->phiIndex(); + phiIndex2 = (candMuVec->at(cond2bx, obj2Index))->hwPhiAtVtx(); etaIndex2 = (candMuVec->at(cond2bx, obj2Index))->hwEtaAtVtx(); etIndex2 = (candMuVec->at(cond2bx, obj2Index))->hwPt(); + chrg2 = (candMuVec->at(cond2bx, obj2Index))->hwCharge(); + etaBin2 = etaIndex2; if (etaBin2 < 0) etaBin2 = m_gtScales->getMUScales().etaBins.size() + etaBin2; @@ -455,12 +464,31 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons << "]\n" << " eta indices = [" << etaIndex0 << ", " << etaIndex1 << ", " << etaIndex2 << "]\n" + << " charge values = [" << chrg0 << ", " << chrg1 << ", " << chrg2 << "]\n" << std::endl; } // Now perform the desired correlation on these three objects: - //reqResult will be set true in case all checks were successful for a given combination of three muons + // reqResult will be set true in case all checks were successful for a given combination of three muons bool reqResult = false; + bool chrgCorrel = true; + + // Check the three-muon charge correlation, if requested. + // NOTE that the charge can be 1 (positive) or 0 (negative), so [SS] SUM(chrg) == 3 OR 0, [OS] SUM(chrg) == 1 OR 2 + if (cond0Categ == CondMuon && cond1Categ == CondMuon && cond2Categ == CondMuon) { + // Check for opp-sign requirement: + if (corrPar.chargeCorrelation == 4 && ((chrg0 + chrg1 + chrg2) == 3 || (chrg0 + chrg1 + chrg2) == 0)) { + chrgCorrel = false; + } + // Check for same-sign + if (corrPar.chargeCorrelation == 2 && ((chrg0 + chrg1 + chrg2) == 1 || (chrg0 + chrg1 + chrg2) == 2)) { + chrgCorrel = false; + } + // Ignore the charge correlation requirement + if (corrPar.chargeCorrelation == 1) { + chrgCorrel = true; + } + } // Clear the vector containing indices of the objects of the combination involved in the condition evaluation objectsInComb.clear(); @@ -548,10 +576,10 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons << " DeltaEtaLUT_12 = " << deltaEtaLUT_12 << std::endl; if (corrPar.corrCutType & 0x9) { - //invariant mass calculation based for each pair on + // Invariant mass calculation based for each pair on // M = sqrt(2*p1*p2(cosh(eta1-eta2) - cos(phi1 - phi2))) - // but we calculate (1/2)M^2 - // + // NOTE: we calculate (1/2)M^2 + /// double cosDeltaPhiPhy_01 = cos(deltaPhiPhy_01); double coshDeltaEtaPhy_01 = cosh(deltaEtaPhy_01); double massSqPhy_01 = et0Phy * et1Phy * (coshDeltaEtaPhy_01 - cosDeltaPhiPhy_01); @@ -563,7 +591,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons coshDeltaEtaLUT_01 = m_gtScales->getLUT_DeltaEta_Cosh(lutName_01, deltaEtaFW_01); unsigned int precCoshLUT_01 = m_gtScales->getPrec_DeltaEta_Cosh(lutName_01); if (precCoshLUT_01 - precCosLUT_01 != 0) - LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision" << std::endl; double cosDeltaPhiPhy_02 = cos(deltaPhiPhy_02); double coshDeltaEtaPhy_02 = cosh(deltaEtaPhy_02); @@ -579,7 +607,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons coshDeltaEtaLUT_02 = m_gtScales->getLUT_DeltaEta_Cosh(lutName_02, deltaEtaFW_02); unsigned int precCoshLUT_02 = m_gtScales->getPrec_DeltaEta_Cosh(lutName_02); if (precCoshLUT_02 - precCosLUT_02 != 0) - LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision" << std::endl; } double cosDeltaPhiPhy_12 = cos(deltaPhiPhy_12); @@ -596,7 +624,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons coshDeltaEtaLUT_12 = m_gtScales->getLUT_DeltaEta_Cosh(lutName_12, deltaEtaFW_12); unsigned int precCoshLUT_12 = m_gtScales->getPrec_DeltaEta_Cosh(lutName_12); if (precCoshLUT_12 - precCosLUT_12 != 0) - LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different Precision" << std::endl; + LogDebug("L1TGlobal") << "Warning: Cos and Cosh LUTs on different precision" << std::endl; } std::string lutName = lutObj0; @@ -614,82 +642,46 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons long long ptObj2 = m_gtScales->getLUT_Pt("Mass_" + lutName, etIndex2); unsigned int precPtLUTObj2 = m_gtScales->getPrec_Pt("Mass_" + lutName); - // Pt and Angles are at different precission. + // Pt and Angles are at different precision long long massSq_01 = ptObj0 * ptObj1 * (coshDeltaEtaLUT_01 - cosDeltaPhiLUT_01); long long massSq_02 = ptObj0 * ptObj2 * (coshDeltaEtaLUT_02 - cosDeltaPhiLUT_02); long long massSq_12 = ptObj1 * ptObj2 * (coshDeltaEtaLUT_12 - cosDeltaPhiLUT_12); - //Note: There is an assumption here that Cos and Cosh have the same precission - //unsigned int preShift_01 = precPtLUTObj0 + precPtLUTObj1 + precCosLUT - corrPar.precMassCut; + // Note: There is an assumption here that Cos and Cosh have the same precision + // unsigned int preShift_01 = precPtLUTObj0 + precPtLUTObj1 + precCosLUT - corrPar.precMassCut; unsigned int preShift_01 = precPtLUTObj0 + precPtLUTObj1 + precCosLUT_01 - corrPar.precMassCut; unsigned int preShift_02 = precPtLUTObj0 + precPtLUTObj2 + precCosLUT_02 - corrPar.precMassCut; unsigned int preShift_12 = precPtLUTObj1 + precPtLUTObj2 + precCosLUT_12 - corrPar.precMassCut; LogDebug("L1TGlobal") << "####################################\n"; - LogDebug("L1TGlobal") - << " Testing the dimuon invariant mass between the FIRST PAIR 0-1 (" << lutObj0 << "," << lutObj1 - << ") \n" - //<< (long long)(corrPar.minMassCutValue * pow(10, preShift_01)) << "," - //<< (long long)(corrPar.maxMassCutValue * pow(10, preShift_01)) - //<< "] with precision = " << corrPar.precMassCut << "\n" - //<< " deltaPhiLUT = " << deltaPhiLUT_01 << " cosLUT = " << cosDeltaPhiLUT_01 << "\n" - //<< " deltaEtaLUT = " << deltaEtaLUT_01 << " coshLUT = " << coshDeltaEtaLUT_01 << "\n" - //<< " etIndex0 = " << etIndex0 << " pt0LUT = " << ptObj0 - //<< " PhyEt0 = " << et0Phy << "\n" - //<< " etIndex1 = " << etIndex1 << " pt1LUT = " << ptObj1 - //<< " PhyEt1 = " << et1Phy << "\n" - << " massSq/2 = " << massSq_01 << "\n" - << " Precision Shift = " << preShift_01 << "\n" - << " massSq (shift)= " << (massSq_01 / pow(10, preShift_01 + corrPar.precMassCut)) - << "\n" - //<< " deltaPhiPhy = " << deltaPhiPhy_01 << " cos() = " << cosDeltaPhiPhy_01 << "\n" - //<< " deltaEtaPhy = " << deltaEtaPhy_01 << " cosh()= " << coshDeltaEtaPhy_01 << "\n" - << " massSqPhy/2 = " << massSqPhy_01 << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_01)) - << std::endl; + LogDebug("L1TGlobal") << " Testing the dimuon invariant mass between the FIRST PAIR 0-1 (" << lutObj0 + << "," << lutObj1 << ") \n" + << " massSq/2 = " << massSq_01 << "\n" + << " Precision Shift = " << preShift_01 << "\n" + << " massSq (shift)= " << (massSq_01 / pow(10, preShift_01 + corrPar.precMassCut)) + << "\n" + << " massSqPhy/2 = " << massSqPhy_01 + << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_01)) << std::endl; LogDebug("L1TGlobal") << "####################################\n"; - LogDebug("L1TGlobal") - << " Testing the dimuon invariant mass between the SECOND PAIR 0-2 (" << lutObj0 << "," << lutObj2 - << ") \n" - //<< (long long)(corrPar.minMassCutValue * pow(10, preShift_02)) << "," - //<< (long long)(corrPar.maxMassCutValue * pow(10, preShift_02)) - //<< "] with precision = " << corrPar.precMassCut << "\n" - //<< " deltaPhiLUT = " << deltaPhiLUT_02 << " cosLUT = " << cosDeltaPhiLUT_02 << "\n" - //<< " deltaEtaLUT = " << deltaEtaLUT_02 << " coshLUT = " << coshDeltaEtaLUT_02 << "\n" - //<< " etIndex0 = " << etIndex0 << " pt0LUT = " << ptObj0 - //<< " PhyEt0 = " << et0Phy << "\n" - //<< " etIndex2 = " << etIndex2 << " pt2LUT = " << ptObj2 - //<< " PhyEt2 = " << et2Phy << "\n" - << " massSq/2 = " << massSq_02 << "\n" - << " Precision Shift = " << preShift_02 << "\n" - << " massSq (shift)= " << (massSq_02 / pow(10, preShift_02 + corrPar.precMassCut)) - << "\n" - //<< " deltaPhiPhy = " << deltaPhiPhy_02 << " cos() = " << cosDeltaPhiPhy_02 << "\n" - //<< " deltaEtaPhy = " << deltaEtaPhy_02 << " cosh()= " << coshDeltaEtaPhy_02 << "\n" - << " massSqPhy/2 = " << massSqPhy_02 << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_02)) - << std::endl; + LogDebug("L1TGlobal") << " Testing the dimuon invariant mass between the SECOND PAIR 0-2 (" << lutObj0 + << "," << lutObj2 << ") \n" + << " massSq/2 = " << massSq_02 << "\n" + << " Precision Shift = " << preShift_02 << "\n" + << " massSq (shift)= " << (massSq_02 / pow(10, preShift_02 + corrPar.precMassCut)) + << "\n" + << " massSqPhy/2 = " << massSqPhy_02 + << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_02)) << std::endl; LogDebug("L1TGlobal") << "####################################\n"; - LogDebug("L1TGlobal") - << " Testing the dimuon invariant mass between the THIRD PAIR 1-2 (" << lutObj1 << "," << lutObj2 - << ") \n" - //<< (long long)(corrPar.minMassCutValue * pow(10, preShift_12)) << "," - //<< (long long)(corrPar.maxMassCutValue * pow(10, preShift_12)) - //<< "] with precision = " << corrPar.precMassCut << "\n" - //<< " deltaPhiLUT = " << deltaPhiLUT_12 << " cosLUT = " << cosDeltaPhiLUT_12 << "\n" - //<< " deltaEtaLUT = " << deltaEtaLUT_12 << " coshLUT = " << coshDeltaEtaLUT_12 << "\n" - //<< " etIndex1 = " << etIndex1 << " pt1LUT = " << ptObj1 - //<< " PhyEt1 = " << et0Phy << "\n" - //<< " etIndex2 = " << etIndex2 << " pt2LUT = " << ptObj2 - //<< " PhyEt2 = " << et2Phy << "\n" - << " massSq/2 = " << massSq_12 << "\n" - << " Precision Shift = " << preShift_12 << "\n" - << " massSq (shift)= " << (massSq_12 / pow(10, preShift_12 + corrPar.precMassCut)) - << "\n" - //<< " deltaPhiPhy = " << deltaPhiPhy_12 << " cos() = " << cosDeltaPhiPhy_12 << "\n" - //<< " deltaEtaPhy = " << deltaEtaPhy_12 << " cosh()= " << coshDeltaEtaPhy_12 << "\n" - << " massSqPhy/2 = " << massSqPhy_12 << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_12)) - << std::endl; + LogDebug("L1TGlobal") << " Testing the dimuon invariant mass between the THIRD PAIR 1-2 (" << lutObj1 + << "," << lutObj2 << ") \n" + << " massSq/2 = " << massSq_12 << "\n" + << " Precision Shift = " << preShift_12 << "\n" + << " massSq (shift)= " << (massSq_12 / pow(10, preShift_12 + corrPar.precMassCut)) + << "\n" + << " massSqPhy/2 = " << massSqPhy_12 + << " sqrt(|massSq|) = " << sqrt(fabs(2. * massSqPhy_12)) << std::endl; LogDebug("L1TGlobal") << "\n ########### THREE-BODY INVARIANT MASS #########################\n"; long long massSq = 0; @@ -725,7 +717,7 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons } } - if (reqResult) { + if (reqResult && chrgCorrel) { condResult = true; (combinationsInCond()).push_back(objectsInComb); } @@ -741,12 +733,12 @@ const bool l1t::CorrThreeBodyCondition::evaluateCondition(const int bxEval) cons } /** - * checkObjectParameter - Compare a single particle with a numbered condition. + * checkObjectParameter - Compare a single particle with a numbered condition * - * @param iCondition The number of the condition. - * @param cand The candidate to compare. + * @param iCondition: The number of the condition. + * @param cand: The candidate to compare. * - * @return The result of the comparison (false if a condition does not exist). + * @return: The result of the comparison (false if a condition does not exist) */ const bool l1t::CorrThreeBodyCondition::checkObjectParameter(const int iCondition, const l1t::L1Candidate& cand) const { diff --git a/L1Trigger/L1TGlobal/test/testVectorCode_data.py b/L1Trigger/L1TGlobal/test/testVectorCode_data.py new file mode 100644 index 0000000000000..102245a3447b0 --- /dev/null +++ b/L1Trigger/L1TGlobal/test/testVectorCode_data.py @@ -0,0 +1,318 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys + +""" +The parameters can be changed by adding command line arguments of the form: + testVectorCode_data.py nevents=-1 +The latter can be used to change parameters in crab. +""" + +job = 0 #job number +njob = 1 #number of jobs +nevents = 3564 #number of events +rootout = False #whether to produce root file +dump = False #dump python +newXML = False #whether running with the new Grammar + +# ---------------- +# Argument parsing +# ---------------- +if len(sys.argv) > 1 and sys.argv[1].endswith('.py'): + sys.argv.pop(0) +if len(sys.argv) == 2 and ':' in sys.argv[1]: + argv = sys.argv[1].split(':') +else: + argv = sys.argv[1:] + +for arg in argv: + (k, v) = map(str.strip, arg.split('=')) + if k not in globals(): + raise "Unknown argument '%s'!" % (k,) + if isinstance(globals()[k], bool): + globals()[k] = v.lower() in ('y', 'yes', 'true', 't', '1') + elif isinstance(globals()[k], int): + globals()[k] = int(v) + else: + globals()[k] = v + +neventsPerJob = int(nevents/njob) +skip = job * neventsPerJob + +if skip>4: + skip = skip-4 + neventsPerJob = neventsPerJob+4 + +# ------------------------------------------------------------ +# Set up Run 3 conditions to get the proper emulation sequence +# ------------------------------------------------------------ +import FWCore.ParameterSet.Config as cms +from Configuration.Eras.Era_Run3_cff import Run3 +process = cms.Process('L1TEMULATION', Run3) + +process.load('Configuration.StandardSequences.Services_cff') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff') + +# --------------------- +# Message Logger output +# --------------------- +process.load('FWCore.MessageService.MessageLogger_cfi') +#process.load('L1Trigger/L1TYellow/l1t_debug_messages_cfi') +#process.load('L1Trigger/L1TYellow/l1t_info_messages_cfi') + +process.load('L1Trigger/L1TGlobal/debug_messages_cfi') +process.MessageLogger.l1t_debug.l1t.limit = cms.untracked.int32(100000) + +process.MessageLogger.categories.append('l1t|Global') + +# DEBUG +#process.MessageLogger.debugModules = cms.untracked.vstring('simGtStage2Digis') +#process.MessageLogger.cerr.threshold = cms.untracked.string('DEBUG') + +# ------------ +# Input source +# ------------ +# Set the number of events +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(neventsPerJob) + ) + +# Set file: it needs to be a RAW format +process.source = cms.Source("PoolSource", + secondaryFileNames = cms.untracked.vstring(), + fileNames = cms.untracked.vstring( + "/store/data/Run2022E/EphemeralHLTPhysics0/RAW/v1/000/359/661/00000/355c33ec-6253-4590-bc11-94e0ce1b45be.root" + ), + skipEvents = cms.untracked.uint32(skip) + ) + +process.output =cms.OutputModule("PoolOutputModule", + outputCommands = cms.untracked.vstring('keep *'), + fileName = cms.untracked.string('testGlobalMCInputProducer_'+repr(job)+'.root') + ) + +process.options = cms.untracked.PSet( + wantSummary = cms.bool(True) +) + +# ----------------------------------------------- +# Additional output definition: TTree output file +# ----------------------------------------------- +process.load("CommonTools.UtilAlgos.TFileService_cfi") +process.TFileService.fileName = cms.string('l1t_histos.root') + +# ---------- +# Global Tag +# ---------- +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, '124X_dataRun3_Prompt_v4', '') + +# ---------------- +# Load the L1 menu +# ---------------- +process.load('L1Trigger.L1TGlobal.GlobalParameters_cff') +process.load("L1Trigger.L1TGlobal.TriggerMenu_cff") +xmlMenu="L1Menu_Collisions2022_v1_3_0.xml" +process.TriggerMenu.L1TriggerMenuFile = cms.string(xmlMenu) +process.ESPreferL1TXML = cms.ESPrefer("L1TUtmTriggerMenuESProducer","TriggerMenu") + +process.dumpMenu = cms.EDAnalyzer("L1MenuViewer") +# DEBUG: Information about names and types of algos parsed by the emulator from the menu +#process.menuDumper = cms.EDAnalyzer("L1TUtmTriggerMenuDumper") + +# ----------------------------------------- +# Load the GT inputs from the unpacker step +# ----------------------------------------- +process.load('Configuration.StandardSequences.RawToDigi_cff') +process.raw2digi_step = cms.Path(process.RawToDigi) + +process.dumpGT = cms.EDAnalyzer("l1t::GtInputDump", + egInputTag = cms.InputTag("gtInput"), + muInputTag = cms.InputTag("gtInput"), + tauInputTag = cms.InputTag("gtInput"), + jetInputTag = cms.InputTag("gtInput"), + etsumInputTag = cms.InputTag("gtInput"), + minBx = cms.int32(0), + maxBx = cms.int32(0) + ) +process.dumpED = cms.EDAnalyzer("EventContentAnalyzer") +process.dumpES = cms.EDAnalyzer("PrintEventSetupContent") + +# ------------------------ +# Fill External conditions +# ------------------------ +process.load('L1Trigger.L1TGlobal.simGtExtFakeProd_cfi') +process.simGtExtFakeProd.bxFirst = cms.int32(-2) +process.simGtExtFakeProd.bxLast = cms.int32(2) +process.simGtExtFakeProd.setBptxAND = cms.bool(True) +process.simGtExtFakeProd.setBptxPlus = cms.bool(True) +process.simGtExtFakeProd.setBptxMinus = cms.bool(True) +process.simGtExtFakeProd.setBptxOR = cms.bool(True) + +# ---------------------------- +# Run the Stage 2 uGT emulator +# ---------------------------- +process.load('L1Trigger.L1TGlobal.simGtStage2Digis_cfi') +process.simGtStage2Digis.PrescaleSet = cms.uint32(1) +process.simGtStage2Digis.ExtInputTag = cms.InputTag("simGtExtFakeProd") +process.simGtStage2Digis.MuonInputTag = cms.InputTag("gtStage2Digis", "Muon") +process.simGtStage2Digis.EGammaInputTag = cms.InputTag("gtStage2Digis", "EGamma") +process.simGtStage2Digis.TauInputTag = cms.InputTag("gtStage2Digis", "Tau") +process.simGtStage2Digis.JetInputTag = cms.InputTag("gtStage2Digis", "Jet") +process.simGtStage2Digis.EtSumInputTag = cms.InputTag("gtStage2Digis", "ETSum") +process.simGtStage2Digis.EmulateBxInEvent = cms.int32(1) + +process.dumpGTRecord = cms.EDAnalyzer("l1t::GtRecordDump", + egInputTag = cms.InputTag("gtStage2Digis", "EGamma"), + muInputTag = cms.InputTag("gtStage2Digis", "Muon"), + tauInputTag = cms.InputTag("gtStage2Digis", "Tau"), + jetInputTag = cms.InputTag("gtStage2Digis", "Jet"), + etsumInputTag = cms.InputTag("gtStage2Digis", "ETSum"), + uGtAlgInputTag = cms.InputTag("simGtStage2Digis"), + uGtExtInputTag = cms.InputTag("simGtExtFakeProd"), + uGtObjectMapInputTag = cms.InputTag("simGtStage2Digis"), + bxOffset = cms.int32(skip), + minBx = cms.int32(-2), + maxBx = cms.int32(2), + minBxVec = cms.int32(0), + maxBxVec = cms.int32(0), + dumpGTRecord = cms.bool(True), + dumpGTObjectMap= cms.bool(False), + dumpTrigResults= cms.bool(False), + dumpVectors = cms.bool(True), + tvFileName = cms.string( ("TestVector_%03d.txt") % job ), + tvVersion = cms.int32(3), + ReadPrescalesFromFile = cms.bool(True), + psFileName = cms.string( "prescale_L1TGlobal.csv" ), + psColumn = cms.int32(1), + unprescaleL1Algos = cms.bool(False), + unmaskL1Algos = cms.bool(False) + ) + +process.load("L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi") +process.l1GtTrigReport.L1GtRecordInputTag = "simGtStage2Digis" +process.l1GtTrigReport.PrintVerbosity = 2 +process.report = cms.Path(process.l1GtTrigReport) + +process.MessageLogger.categories.append("MuConditon") + +# ------------------------- +# Setup Digi to Raw to Digi +# ------------------------- +process.load('EventFilter.L1TRawToDigi.gtStage2Raw_cfi') +process.gtStage2Raw.GtInputTag = cms.InputTag("simGtStage2Digis") +process.gtStage2Raw.ExtInputTag = cms.InputTag("simGtExtFakeProd") +process.gtStage2Raw.EGammaInputTag = cms.InputTag("gtInput") +process.gtStage2Raw.TauInputTag = cms.InputTag("gtInput") +process.gtStage2Raw.JetInputTag = cms.InputTag("gtInput") +process.gtStage2Raw.EtSumInputTag = cms.InputTag("gtInput") +process.gtStage2Raw.MuonInputTag = cms.InputTag("gtInput") + +process.load('EventFilter.L1TRawToDigi.gtStage2Digis_cfi') +process.newGtStage2Digis = process.gtStage2Digis.clone() +process.newGtStage2Digis.InputLabel = cms.InputTag('gtStage2Raw') +# DEBUG +#process.newGtStage2Digis.debug = cms.untracked.bool(True) + +process.dumpRaw = cms.EDAnalyzer( + "DumpFEDRawDataProduct", + label = cms.untracked.string("gtStage2Raw"), + feds = cms.untracked.vint32 ( 1404 ), + dumpPayload = cms.untracked.bool ( True ) +) + +process.newDumpGTRecord = cms.EDAnalyzer("l1t::GtRecordDump", + egInputTag = cms.InputTag("newGtStage2Digis","EGamma"), + muInputTag = cms.InputTag("newGtStage2Digis","Muon"), + tauInputTag = cms.InputTag("newGtStage2Digis","Tau"), + jetInputTag = cms.InputTag("newGtStage2Digis","Jet"), + etsumInputTag = cms.InputTag("newGtStage2Digis","EtSum"), + uGtAlgInputTag = cms.InputTag("newGtStage2Digis"), + uGtExtInputTag = cms.InputTag("newGtStage2Digis"), + uGtObjectMapInputTag = cms.InputTag("simGtStage2Digis"), + bxOffset = cms.int32(skip), + minBx = cms.int32(0), + maxBx = cms.int32(0), + minBxVec = cms.int32(0), + maxBxVec = cms.int32(0), + dumpGTRecord = cms.bool(True), + dumpGTObjectMap= cms.bool(True), + dumpTrigResults= cms.bool(False), + dumpVectors = cms.bool(False), + tvFileName = cms.string( ("TestVector_%03d.txt") % job ), + ReadPrescalesFromFile = cms.bool(False), + psFileName = cms.string( "prescale_L1TGlobal.csv" ), + psColumn = cms.int32(1) + ) + +# ----------- +# GT analyzer +# ----------- +process.l1tGlobalAnalyzer = cms.EDAnalyzer('L1TGlobalAnalyzer', + doText = cms.untracked.bool(False), + gmuToken = cms.InputTag("None"), + dmxEGToken = cms.InputTag("None"), + dmxTauToken = cms.InputTag("None"), + dmxJetToken = cms.InputTag("None"), + dmxEtSumToken = cms.InputTag("None"), + muToken = cms.InputTag("gtStage2Digis", "Muon"), + egToken = cms.InputTag("gtStage2Digis", "EGamma"), + tauToken = cms.InputTag("gtStage2Digis", "Tau"), + jetToken = cms.InputTag("gtStage2Digis", "Jet"), + etSumToken = cms.InputTag("gtStage2Digis", "EtSum"), + gtAlgToken = cms.InputTag("simGtStage2Digis"), + emulDxAlgToken = cms.InputTag("None"), + emulGtAlgToken = cms.InputTag("simGtStage2Digis") +) + +# ------------------ +# Process definition +# ------------------ +process.p1 = cms.Path( + ## Input, emulation, dump of the results + process.dumpMenu + *process.RawToDigi + #*process.gtInput + #*process.dumpGT + *process.simGtExtFakeProd + *process.simGtStage2Digis + *process.dumpGTRecord + + ## Sequence for packing and unpacking uGT data + #+process.gtStage2Raw + #+process.dumpRaw + #+process.newGtStage2Digis + #+process.newDumpGTRecord + + ## Analysis/Dumping + *process.l1tGlobalAnalyzer + #*process.menuDumper # DEBUG -> to activate the menuDumper + #*process.debug + #*process.dumpED + #*process.dumpES + ) + +# ------------------- +# Schedule definition +# ------------------- +process.schedule = cms.Schedule( + process.p1 +) +#process.schedule.append(process.report) + +if rootout: + process.outpath = cms.EndPath(process.output) + process.schedule.append(process.outpath) + +# Spit out filter efficiency at the end +process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(True)) + +# Options for multithreading +#process.options.numberOfThreads = cms.untracked.uint32( 2 ) +#process.options.numberOfStreams = cms.untracked.uint32( 0 ) + +if dump: + outfile = open('dump_runGlobalFakeInputProducer_'+repr(job)+'.py','w') + print(process.dumpPython(), file=outfile) + outfile.close()