Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,16 @@ def checkHLTfor43774(process):
print('# TSG WARNING: check value of parameter "useAbs" in',filt,'(expect True but is False)!')

return process

def customizeHLTfor44510(process):
"""
Customisation for running HLT with the updated L1 UTM and AXOL1TL condition parsing from the PR 44054
"""
for producer in producers_by_type(process, "L1TGlobalProducer"):
if hasattr(producer, 'AXOL1TLModelVersion'):
delattr(producer, 'AXOL1TLModelVersion')
return process


# CMSSW version specific customizations
def customizeHLTforCMSSW(process, menuType="GRun"):
Expand All @@ -260,4 +270,7 @@ def customizeHLTforCMSSW(process, menuType="GRun"):

process = checkHLTfor43774(process)

# customizes AXOL1TL condition in the L1 menu
process = customizeHLTfor44510(process)

return process
8 changes: 0 additions & 8 deletions L1Trigger/L1TGlobal/interface/AXOL1TLCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ namespace l1t {

void setuGtB(const GlobalBoard*);

//get / set AXOL1TL model version
inline const std::string gtModelVerion() const { return m_AXOL1TLmodelversion; }

void setModelVersion(const std::string modelversionname);

private:
/// copy function for copy constructor and operator=
void copy(const AXOL1TLCondition& cp);
Expand All @@ -73,9 +68,6 @@ namespace l1t {

/// pointer to uGt GlobalBoard, to be able to get the trigger objects
const GlobalBoard* m_gtGTB;

//to set modelversion from globalboard<-globalproducer<-config
std::string m_AXOL1TLmodelversion = "NONE";
};

} // namespace l1t
Expand Down
7 changes: 7 additions & 0 deletions L1Trigger/L1TGlobal/interface/AXOL1TLTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ class AXOL1TLTemplate : public GlobalCondition {
public:
inline const std::vector<ObjectParameter>* objectParameter() const { return &m_objectParameter; }

inline const std::string& modelVersion() const { return m_modelVersion; }

/// set functions
void setConditionParameter(const std::vector<ObjectParameter>& objParameter);

void setModelVersion(const std::string& modelversion);

/// print the condition
void print(std::ostream& myCout) const override;

Expand All @@ -67,6 +71,9 @@ class AXOL1TLTemplate : public GlobalCondition {

/// variables containing the parameters
std::vector<ObjectParameter> m_objectParameter;

/// model version
std::string m_modelVersion;
};

#endif
4 changes: 0 additions & 4 deletions L1Trigger/L1TGlobal/interface/GlobalBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ namespace l1t {
void setResetPSCountersEachLumiSec(bool val) { m_resetPSCountersEachLumiSec = val; }
void setSemiRandomInitialPSCounters(bool val) { m_semiRandomInitialPSCounters = val; }

void setAXOL1TLModelVersion(std::string axol1tlModelVersion);

public:
inline void setVerbosity(const int verbosity) { m_verbosity = verbosity; }

Expand Down Expand Up @@ -244,8 +242,6 @@ namespace l1t {
int m_bxFirst_;
int m_bxLast_;

std::string m_axol1tlModelVersion = "NULL";

std::bitset<GlobalAlgBlk::maxPhysicsTriggers> m_gtlAlgorithmOR;
std::bitset<GlobalAlgBlk::maxPhysicsTriggers> m_gtlDecisionWord;

Expand Down
8 changes: 0 additions & 8 deletions L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ void L1TGlobalProducer::fillDescriptions(edm::ConfigurationDescriptions& descrip
desc.add<bool>("AlgorithmTriggersUnmasked", false)
->setComment("not required, but recommend to specify explicitly in config");

//AXOl1TL model version:
desc.add<std::string>("AXOL1TLModelVersion", "");

// switch for muon showers in Run-3
desc.add<bool>("useMuonShowers", false);

Expand Down Expand Up @@ -133,7 +130,6 @@ L1TGlobalProducer::L1TGlobalProducer(const edm::ParameterSet& parSet)
m_algoblkInputTag(parSet.getParameter<edm::InputTag>("AlgoBlkInputTag")),
m_resetPSCountersEachLumiSec(parSet.getParameter<bool>("resetPSCountersEachLumiSec")),
m_semiRandomInitialPSCounters(parSet.getParameter<bool>("semiRandomInitialPSCounters")),
m_AXOL1TLModelVersion(parSet.getParameter<std::string>("AXOL1TLModelVersion")),
m_useMuonShowers(parSet.getParameter<bool>("useMuonShowers")) {
m_egInputToken = consumes<BXVector<EGamma>>(m_egInputTag);
m_tauInputToken = consumes<BXVector<Tau>>(m_tauInputTag);
Expand Down Expand Up @@ -625,10 +621,6 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet

m_uGtBrd->receiveMuonObjectData(iEvent, m_muInputToken, receiveMu, m_nrL1Mu);

//for getting model version to the condition class, later will come from the menu
//used in runGTL
m_uGtBrd->setAXOL1TLModelVersion(m_AXOL1TLModelVersion);

if (m_useMuonShowers)
m_uGtBrd->receiveMuonShowerObjectData(iEvent, m_muShowerInputToken, receiveMuShower, m_nrL1MuShower);

Expand Down
3 changes: 0 additions & 3 deletions L1Trigger/L1TGlobal/plugins/L1TGlobalProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,6 @@ class L1TGlobalProducer : public edm::stream::EDProducer<> {
// if false, the prescale counters are initialised to zero
bool m_semiRandomInitialPSCounters;

//string to store AXOL1TL model version
std::string m_AXOL1TLModelVersion;

// switch to load muon showers in the global board
bool m_useMuonShowers;
};
Expand Down
54 changes: 44 additions & 10 deletions L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ void l1t::TriggerMenuParser::parseCondFormats(const L1TUtmTriggerMenu* utmMenu)
parseEnergySumZdc(condition, chipNr, false);

//parse AXOL1TL
} else if (condition.getType() == esConditionType::AnomalyDetectionTrigger) {
} else if (condition.getType() == esConditionType::Axol1tlTrigger ||
condition.getType() == esConditionType::AnomalyDetectionTrigger) {
parseAXOL1TL(condition, chipNr);

//parse Muons
Expand Down Expand Up @@ -2752,19 +2753,51 @@ bool l1t::TriggerMenuParser::parseAXOL1TL(L1TUtmCondition condAXOL1TL, unsigned
int lowerThresholdInd = 0;
int upperThresholdInd = -1;

const std::vector<L1TUtmCut>& cuts = object.getCuts();
for (size_t kk = 0; kk < cuts.size(); kk++) {
const L1TUtmCut& cut = cuts.at(kk);
//save model and threshold
std::string model = "";

switch (cut.getCutType()) {
case esCutType::AnomalyScore:
// for UTM v12+
if (object.getType() == tmeventsetup::Axol1tl) {
const std::vector<L1TUtmCut>& cuts = object.getCuts();
for (size_t kk = 0; kk < cuts.size(); kk++) {
const L1TUtmCut& cut = cuts.at(kk);

//save model
if (cut.getCutType() == tmeventsetup::Model) {
model = cut.getData();
}
//save score
else if (cut.getCutType() == esCutType::Score) {
lowerThresholdInd = cut.getMinimum().value;
upperThresholdInd = cut.getMaximum().value;
} //end else if
} //end cut loop
} //end if getType
// LEGACY
// for UTM pre v12
else if (condAXOL1TL.getType() == esConditionType::AnomalyDetectionTrigger) {
// hard-code model version for legacy Menu
model = "v3";

const std::vector<L1TUtmCut>& cuts = object.getCuts();
for (size_t kk = 0; kk < cuts.size(); kk++) {
const L1TUtmCut& cut = cuts.at(kk);
if (cut.getCutType() == esCutType::AnomalyScore) {
lowerThresholdInd = cut.getMinimum().value;
upperThresholdInd = cut.getMaximum().value;
break;
default:
break;
} //end switch
} //end cut loop
}
} //end cut loop
} else {
edm::LogError("TriggerMenuParser") << " Error: not a proper AXOL1TL condition" << std::endl;
return false;
}

// check model version is not empty
if (model == "") {
edm::LogError("TriggerMenuParser") << " Error: AXOL1TL movel version is empty" << std::endl;
return false;
}

//fill object params
objParameter[0].minAXOL1TLThreshold = lowerThresholdInd;
Expand All @@ -2777,6 +2810,7 @@ bool l1t::TriggerMenuParser::parseAXOL1TL(L1TUtmCondition condAXOL1TL, unsigned
axol1tlCond.setCondChipNr(chipNr);
axol1tlCond.setCondRelativeBx(relativeBx);
axol1tlCond.setConditionParameter(objParameter);
axol1tlCond.setModelVersion(model);

if (edm::isDebugEnabled()) {
std::ostringstream myCoutStream;
Expand Down
1 change: 0 additions & 1 deletion L1Trigger/L1TGlobal/python/simGtStage2Digis_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
JetInputTag = cms.InputTag("simCaloStage2Digis"),
EtSumInputTag = cms.InputTag("simCaloStage2Digis"),
EtSumZdcInputTag = cms.InputTag("etSumZdcProducer"),
AXOL1TLModelVersion = cms.string("GTADModel_v3"),
AlgorithmTriggersUnmasked = cms.bool(True),
AlgorithmTriggersUnprescaled = cms.bool(True),
GetPrescaleColumnFromData = cms.bool(False),
Expand Down
19 changes: 12 additions & 7 deletions L1Trigger/L1TGlobal/src/AXOL1TLCondition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,20 @@ const bool l1t::AXOL1TLCondition::evaluateCondition(const int bxEval) const {
int useBx = bxEval + m_gtAXOL1TLTemplate->condRelativeBx();

//HLS4ML stuff
std::string AXOL1TLmodelversion = m_AXOL1TLmodelversion; //config loading method
std::string AXOL1TLmodelversion = "GTADModel_" + m_gtAXOL1TLTemplate->modelVersion(); //loading from menu/template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary to hardcode GTADModel_ for the AXO models ? Couldn't the L1T-menu xml specify GTADModel_vN rather than just vN ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is a question to @caruta and the uGT team @herbberg and @arnobaer
I imagine we can do it either way, but just need to have consistent name changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it might be related to this convention by the uGT team for the FW versioning vs the HLS4ML version names:
https://globaltrigger.web.cern.ch/upgrade/tme/models vs https://github.com/cms-hls4ml/AXOL1TL/tree/main/AXOL1TL_v3

fyi @quinnanm @jmduarte @thesps


//otherwise load model (if possible) and run inference
hls4mlEmulator::ModelLoader loader(AXOL1TLmodelversion);
std::shared_ptr<hls4mlEmulator::Model> model;
model = loader.load_model();

try {
model = loader.load_model();
} catch (std::runtime_error& e) {
// for stopping with exception if model version cannot be loaded
throw cms::Exception("ModelError")
<< " ERROR: failed to load AXOL1TL model version \"" << AXOL1TLmodelversion
<< "\" that was specified in menu. Model version not found in cms-hls4ml externals.";
}

// //pointers to objects
const BXVector<const l1t::Muon*>* candMuVec = m_gtGTB->getCandL1Mu();
Expand Down Expand Up @@ -249,11 +259,6 @@ const bool l1t::AXOL1TLCondition::evaluateCondition(const int bxEval) const {
return condResult;
}

//in order to set model version from config
void l1t::AXOL1TLCondition::setModelVersion(const std::string modelversionname) {
m_AXOL1TLmodelversion = modelversionname;
}

void l1t::AXOL1TLCondition::print(std::ostream& myCout) const {
myCout << "Dummy Print for AXOL1TLCondition" << std::endl;
m_gtAXOL1TLTemplate->print(myCout);
Expand Down
4 changes: 4 additions & 0 deletions L1Trigger/L1TGlobal/src/AXOL1TLTemplate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ void AXOL1TLTemplate::setConditionParameter(const std::vector<ObjectParameter>&
m_objectParameter = objParameter;
}

//setModelVersion - set the model version of the condition
void AXOL1TLTemplate::setModelVersion(const std::string& modelversion) { m_modelVersion = modelversion; }

void AXOL1TLTemplate::print(std::ostream& myCout) const {
myCout << "\n AXOL1TLTemplate print..." << std::endl;

Expand All @@ -65,6 +68,7 @@ void AXOL1TLTemplate::copy(const AXOL1TLTemplate& cp) {
m_condChipNr = cp.condChipNr();
m_condRelativeBx = cp.condRelativeBx();

m_modelVersion = cp.modelVersion(); // new for utm 0.12.0
m_objectParameter = *(cp.objectParameter());
}

Expand Down
7 changes: 0 additions & 7 deletions L1Trigger/L1TGlobal/src/GlobalBoard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ void l1t::GlobalBoard::setBxFirst(int bx) { m_bxFirst_ = bx; }

void l1t::GlobalBoard::setBxLast(int bx) { m_bxLast_ = bx; }

// temporary class for getting axol1tl version from config to condition class until it can be got from the utm menu
void l1t::GlobalBoard::setAXOL1TLModelVersion(std::string axol1tlModelVersion) {
m_axol1tlModelVersion = axol1tlModelVersion;
}

void l1t::GlobalBoard::init(const int numberPhysTriggers,
const int nrL1Mu,
const int nrL1MuShower,
Expand Down Expand Up @@ -656,8 +651,6 @@ void l1t::GlobalBoard::runGTL(const edm::Event&,

axol1tlCondition->setVerbosity(m_verbosity);

axol1tlCondition->setModelVersion(m_axol1tlModelVersion);

axol1tlCondition->evaluateConditionStoreResult(iBxInEvent);

cMapResults[itCond->first] = axol1tlCondition;
Expand Down