Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
321c3b6
added model version from menu changes
quinnanm Feb 22, 2024
be784a8
removed some couts
quinnanm Feb 22, 2024
3a618fa
reference instead of pointer suggestion
quinnanm Feb 22, 2024
315b978
removed config comment, added warning debug message
quinnanm Feb 22, 2024
a3bc1b9
minor typo
quinnanm Feb 22, 2024
936821f
Update L1Trigger/L1TGlobal/interface/AXOL1TLTemplate.h
quinnanm Feb 23, 2024
664e0cd
Update L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc
quinnanm Feb 23, 2024
fd70fdb
Update L1Trigger/L1TGlobal/src/AXOL1TLCondition.cc
quinnanm Feb 23, 2024
37989f6
minor code cleanup
quinnanm Feb 23, 2024
c974fa3
changed to automatic model loading, not switch
quinnanm Feb 26, 2024
0fc9b8d
fix accessing model version in AXO copy function
artlbv Feb 28, 2024
fe7f1f5
reccommended edits for PR
quinnanm Mar 12, 2024
559732f
added condition that prevents crash with menu 1_0_0
quinnanm Mar 12, 2024
560c63d
Add HLT customisation for AXOL1TL emulator
artlbv Mar 12, 2024
98cec60
Merge branch 'master' into axol1tl_emulator_modelfrommenupr
artlbv Mar 12, 2024
5c90234
Update L1 Menu to 2024_1_0_1 in TSG tests
artlbv Mar 12, 2024
26756ff
suggested minor changes
quinnanm Mar 12, 2024
e189010
requested exceptions for unsupported model versions
quinnanm Mar 12, 2024
5c92af1
update L1Menu to 2024_1_0_1 in AlCa auto conditions
artlbv Mar 13, 2024
9ce585b
Apply suggestions from code review
artlbv Mar 13, 2024
8dd61c9
updated exception behavior
quinnanm Mar 13, 2024
87a0563
code format, better error message, removed commented code
quinnanm Mar 13, 2024
69cebf8
resolve remaining comments
quinnanm Mar 13, 2024
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
6 changes: 3 additions & 3 deletions Configuration/HLT/python/autoCondHLT.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
'Fake' : ( ','.join( [ 'L1GtTriggerMenu_L1Menu_Collisions2012_v3_mc' , l1MenuRecord,connectionString, l1MenuLabel, "2015-10-26 12:00:00.000"] ), ),
'Fake1' : ( ','.join( [ 'L1Menu_Collisions2015_25nsStage1_v5' , l1MenuRecord,connectionString, l1MenuLabel, "2015-10-26 12:00:00.000"] ), ),
'Fake2' : ( ','.join( [ 'L1Menu_Collisions2016_v9_m2_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2016-10-06 19:36:53.000"] ), ),
'FULL' : ( ','.join( [ 'L1Menu_Collisions2024_v1_0_0_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2024-02-21 12:00:00.000"] ), ),
'GRun' : ( ','.join( [ 'L1Menu_Collisions2024_v1_0_0_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2024-02-21 12:00:00.000"] ), ),
'FULL' : ( ','.join( [ 'L1Menu_Collisions2024_v1_0_1_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2024-03-12 09:00:00.000"] ), ),
'GRun' : ( ','.join( [ 'L1Menu_Collisions2024_v1_0_1_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2024-03-12 09:00:00.000"] ), ),
'2023v12' : ( ','.join( [ 'L1Menu_Collisions2023_v1_2_0_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2023-06-13 14:12:00.000"] ), ),
'HIon' : ( ','.join( [ 'L1Menu_CollisionsHeavyIons2023_v1_1_5_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2023-10-24 16:59:55.000"] ), ),
'PIon' : ( ','.join( [ 'L1Menu_HeavyIons2016_v3_m2_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2016-11-22 11:11:00.000"] ), ),
'PRef' : ( ','.join( [ 'L1Menu_CollisionsPPRef2023_v1_1_2_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2023-09-21 19:00:00.000"] ), ),
'Special' : ( ','.join( [ 'L1Menu_Collisions2024_v1_0_0_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2024-02-21 12:00:00.000"] ), ),
'Special' : ( ','.join( [ 'L1Menu_Collisions2024_v1_0_1_xml' ,l1tMenuRecord,connectionString,l1tMenuLabel, "2024-03-12 09:00:00.000"] ), ),
}

hltGTs = {
Expand Down
12 changes: 12 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ def checkHLTfor43774(process):

return process

def customizeHLTfor44054(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 +269,7 @@ def customizeHLTforCMSSW(process, menuType="GRun"):

process = checkHLTfor43774(process)

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

return process
2 changes: 1 addition & 1 deletion L1Trigger/L1TGlobal/interface/AXOL1TLCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace l1t {
const GlobalBoard* m_gtGTB;

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

} // 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
19 changes: 13 additions & 6 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 @@ -224,6 +220,8 @@ L1TGlobalProducer::L1TGlobalProducer(const edm::ParameterSet& parSet)
m_l1GtParCacheID = 0ULL;
m_l1GtMenuCacheID = 0ULL;

m_AXOL1TLModelVersion = "";

m_numberPhysTriggers = 0;
m_numberDaqPartitions = 0;

Expand Down Expand Up @@ -403,6 +401,16 @@ void L1TGlobalProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSet
m_l1GtMenu->print(std::cout, printV);

m_l1GtMenuCacheID = l1GtMenuCacheID;

//for getting model version to condition class via GlobalBoard.runGTL, comes from menu rather than config
if (gtParser.gtTriggerMenuName() == "L1Menu_Collisions2024_v1_0_0") {
// m_AXOL1TLModelVersion = "GTADModel_v3"; //will run, but exception preferred
throw cms::Exception("ConditionsError")
<< " Error L1 menu version " << gtParser.gtTriggerMenuName()
<< "is unsupported due to incompatible utm grammar, please use v1_0_1 or later";
} else {
m_AXOL1TLModelVersion = gtParser.AXOL1TLModelVersion();
}
}

// get / update the board maps from the EventSetup
Expand Down Expand Up @@ -625,8 +633,7 @@ 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
//set axo model version in global board from version in menu
m_uGtBrd->setAXOL1TLModelVersion(m_AXOL1TLModelVersion);

if (m_useMuonShowers)
Expand Down
37 changes: 26 additions & 11 deletions L1Trigger/L1TGlobal/plugins/TriggerMenuParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ void l1t::TriggerMenuParser::setVecCorrelationWithOverlapRemovalTemplate(
m_vecCorrelationWithOverlapRemovalTemplate = vecCorrelationWithOverlapRemovalTempl;
}

//set the AXO model version so it can be fetched from the GlobalProducer
void l1t::TriggerMenuParser::setAXOL1TLModelVersion(const std::string& axol1tlmodelversion) {
m_axol1tlModelVersion = axol1tlmodelversion;
}

// set the vectors containing the conditions for correlation templates
//
void l1t::TriggerMenuParser::setCorMuonTemplate(const std::vector<std::vector<MuonTemplate> >& corMuonTempl) {
Expand Down Expand Up @@ -322,7 +327,7 @@ 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) {
parseAXOL1TL(condition, chipNr);

//parse Muons
Expand Down Expand Up @@ -2752,19 +2757,25 @@ 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:
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;
break;
default:
break;
} //end switch
} //end cut loop
} //end else if
} //end cut loop
} //end if getType

//fill object params
objParameter[0].minAXOL1TLThreshold = lowerThresholdInd;
Expand All @@ -2777,6 +2788,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 All @@ -2792,6 +2804,9 @@ bool l1t::TriggerMenuParser::parseAXOL1TL(L1TUtmCondition condAXOL1TL, unsigned

(m_vecAXOL1TLTemplate[chipNr]).push_back(axol1tlCond);

//fill class model version variable
l1t::TriggerMenuParser::setAXOL1TLModelVersion(model);

return true;
}

Expand Down
8 changes: 8 additions & 0 deletions L1Trigger/L1TGlobal/plugins/TriggerMenuParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ namespace l1t {
void setVecCorrelationWithOverlapRemovalTemplate(
const std::vector<std::vector<CorrelationWithOverlapRemovalTemplate> >&);

// get/set the AXO model version so it can be fetched from the GlobalProducer
inline const std::string& AXOL1TLModelVersion() const { return m_axol1tlModelVersion; }

void setAXOL1TLModelVersion(const std::string&);

// get / set the vectors containing the conditions for correlation templates
//
inline const std::vector<std::vector<MuonTemplate> >& corMuonTemplate() const { return m_corMuonTemplate; }
Expand Down Expand Up @@ -425,6 +430,9 @@ namespace l1t {
std::vector<std::vector<CaloTemplate> > m_corCaloTemplate;
std::vector<std::vector<EnergySumTemplate> > m_corEnergySumTemplate;

/// AXOL1TL Model Version
std::string m_axol1tlModelVersion = "";

/// map containing the physics algorithms (by name)
AlgorithmMap m_algorithmMap;

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
24 changes: 20 additions & 4 deletions L1Trigger/L1TGlobal/src/AXOL1TLCondition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,25 @@ 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 = m_AXOL1TLmodelversion; //loading from menu

//if model version is empty, throw exception. Should not ever happen unless not found in menu
if (AXOL1TLmodelversion == "" || AXOL1TLmodelversion == "GTADModel_") {
throw cms::Exception("ModelError") << " Error model version not found in menu!";
}

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

//model = loader.load_model();
try {
model = loader.load_model();
} catch (std::runtime_error& e) {
edm::LogWarning("AXOL1TLCondition") << "ERROR: failed to load model version " << AXOL1TLmodelversion
<< ". Not evaluating condition!" << std::endl;
return false;
}

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

//in order to set model version from config
//in order to set model version from menu->triggermenuparser->globalproducer->globalboard->here
void l1t::AXOL1TLCondition::setModelVersion(const std::string modelversionname) {
m_AXOL1TLmodelversion = modelversionname;
m_AXOL1TLmodelversion = "GTADModel_" + modelversionname;
// edm::LogWarning("AXOL1TLCondition") << "AXOL1TL model version: "<< m_AXOL1TLmodelversion << std::endl;
}

void l1t::AXOL1TLCondition::print(std::ostream& myCout) const {
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
2 changes: 1 addition & 1 deletion L1Trigger/L1TGlobal/src/GlobalBoard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ 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
// for getting axol1tl version from menu->GlobalProducer->GlobalBoard->condition class
void l1t::GlobalBoard::setAXOL1TLModelVersion(std::string axol1tlModelVersion) {
m_axol1tlModelVersion = axol1tlModelVersion;
}
Expand Down