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

move per-run changes of L1-uGT emulator to beginRun (incl. loading of AXOL1TL model) #47070

Merged
merged 2 commits into from
Jan 14, 2025
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
14 changes: 11 additions & 3 deletions L1Trigger/L1TGlobal/interface/AXOL1TLCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
* Description: evaluation of a CondAXOL1TL condition.
*/

// system include files
#include <iosfwd>
#include <string>

// user include files
// base classes
#include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
#include "DataFormats/L1Trigger/interface/L1Candidate.h"

#include "hls4ml/emulator.h"

// forward declarations
class GlobalCondition;
class AXOL1TLTemplate;
Expand Down Expand Up @@ -64,6 +63,10 @@ namespace l1t {

inline float getScore() const { return m_savedscore; }

void loadModel();

inline hls4mlEmulator::ModelLoader const& model_loader() const { return m_model_loader; }

private:
/// copy function for copy constructor and operator=
void copy(const AXOL1TLCondition& cp);
Expand All @@ -74,6 +77,11 @@ namespace l1t {
/// pointer to uGt GlobalBoard, to be able to get the trigger objects
const GlobalBoard* m_gtGTB;

static constexpr char const* kModelNamePrefix = "GTADModel_";

hls4mlEmulator::ModelLoader m_model_loader;
std::shared_ptr<hls4mlEmulator::Model> m_model;

///axo score for possible score saving
mutable float m_savedscore;
};
Expand Down
5 changes: 2 additions & 3 deletions L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <stack>
#include <string>
Expand Down Expand Up @@ -55,9 +56,7 @@ namespace l1t {
// virtual ~AlgorithmEvaluation();

//typedef std::map<std::string, ConditionEvaluation*> ConditionEvaluationMap;
typedef std::unordered_map<std::string, ConditionEvaluation*> ConditionEvaluationMap;
typedef ConditionEvaluationMap::const_iterator CItEvalMap;
typedef ConditionEvaluationMap::iterator ItEvalMap;
typedef std::unordered_map<std::string, std::unique_ptr<ConditionEvaluation>> ConditionEvaluationMap;

public:
/// get / set the result of the algorithm
Expand Down
11 changes: 1 addition & 10 deletions L1Trigger/L1TGlobal/interface/ConditionEvaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,13 @@
*
*/

// system include files
#include <cstdint>
#include <iostream>

#include <string>
#include <vector>

// user include files

// base class

//
#include "DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <cstdint>

// forward declarations

namespace l1t {

Expand Down
13 changes: 6 additions & 7 deletions L1Trigger/L1TGlobal/interface/CorrCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ namespace l1t {
CorrCondition();

/// from base template condition (from event setup usually)
CorrCondition(const GlobalCondition*, const GlobalCondition*, const GlobalCondition*, const GlobalBoard*

);
CorrCondition(const GlobalCondition*,
const GlobalCondition*,
const GlobalCondition*,
const GlobalBoard*,
const GlobalScales*);

// copy constructor
CorrCondition(const CorrCondition&);
Expand All @@ -63,16 +65,13 @@ namespace l1t {
void print(std::ostream& myCout) const override;

public:
/// get / set the pointer to a Condition
inline const CorrelationTemplate* gtCorrelationTemplate() const { return m_gtCorrelationTemplate; }

void setGtCorrelationTemplate(const CorrelationTemplate*);

/// get / set the pointer to uGt GlobalBoard
inline const GlobalBoard* getuGtB() const { return m_uGtB; }

void setuGtB(const GlobalBoard*);

inline const GlobalScales* getScales() const { return m_gtScales; }
void setScales(const GlobalScales*);

/* //BLW Comment out for now
Expand Down
10 changes: 3 additions & 7 deletions L1Trigger/L1TGlobal/interface/CorrThreeBodyCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ namespace l1t {
const GlobalCondition*,
const GlobalCondition*,
const GlobalCondition*,
const GlobalBoard*

);
const GlobalBoard*,
const GlobalScales*);

// copy constructor
CorrThreeBodyCondition(const CorrThreeBodyCondition&);
Expand All @@ -67,18 +66,15 @@ namespace l1t {
void print(std::ostream& myCout) const override;

public:
/// get / set the pointer to a Condition
inline const CorrelationThreeBodyTemplate* gtCorrelationThreeBodyTemplate() const {
return m_gtCorrelationThreeBodyTemplate;
}

void setGtCorrelationThreeBodyTemplate(const CorrelationThreeBodyTemplate*);

/// get / set the pointer to uGt GlobalBoard
inline const GlobalBoard* getuGtB() const { return m_uGtB; }

void setuGtB(const GlobalBoard*);

inline const GlobalScales* getScales() const { return m_gtScales; }
void setScales(const GlobalScales*);

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ namespace l1t {
const GlobalCondition*,
const GlobalCondition*,
const GlobalCondition*,
const GlobalBoard*

);
const GlobalBoard*,
const GlobalScales*);

// copy constructor
CorrWithOverlapRemovalCondition(const CorrWithOverlapRemovalCondition&);
Expand All @@ -68,18 +67,16 @@ namespace l1t {
void print(std::ostream& myCout) const override;

public:
/// get / set the pointer to a Condition
inline const CorrelationWithOverlapRemovalTemplate* gtCorrelationWithOverlapRemovalTemplate() const {
return m_gtCorrelationWithOverlapRemovalTemplate;
}

void setGtCorrelationWithOverlapRemovalTemplate(const CorrelationWithOverlapRemovalTemplate*);

/// get / set the pointer to uGt GlobalBoard
inline const GlobalBoard* getuGtB() const { return m_uGtB; }

void setuGtB(const GlobalBoard*);

inline const GlobalScales* getScales() const { return m_gtScales; }
void setScales(const GlobalScales*);

/* //BLW Comment out for now
Expand Down
58 changes: 16 additions & 42 deletions L1Trigger/L1TGlobal/interface/GlobalBoard.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#ifndef GtBoard_h
#define GtBoard_h
#ifndef L1Trigger_L1TGlobal_GlobalBoard_h
#define L1Trigger_L1TGlobal_GlobalBoard_h

/**
* \class GlobalBoard
*
*
* Description: Global Trigger Logic board.
*
* Implementation:
* <TODO: enter implementation details>
*
*/

// system include files
Expand All @@ -18,6 +15,7 @@
#include <vector>
#include <cmath>
#include <memory>
#include <string>

// user include files
#include "FWCore/Utilities/interface/typedefs.h"
Expand Down Expand Up @@ -46,11 +44,6 @@

// forward declarations
class TriggerMenu;
class L1CaloGeometry;
class L1MuTriggerScales;
//class L1GtEtaPhiConversions;

// class declaration

namespace l1t {

Expand Down Expand Up @@ -107,19 +100,23 @@ namespace l1t {
int bxFirst,
int bxLast);

/// run the uGT GTL (Conditions and Algorithms)
/// initialise Trigger Conditions
void initTriggerConditions(const edm::EventSetup& evSetup,
const TriggerMenu* m_l1GtMenu,
const int nrL1Mu,
const int nrL1MuShower,
const int nrL1EG,
const int nrL1Tau,
const int nrL1Jet);

/// run the uGT GTL (Algorithms, per-event decisions)
void runGTL(const edm::Event& iEvent,
const edm::EventSetup& evSetup,
const TriggerMenu* m_l1GtMenu,
const bool produceL1GtObjectMapRecord,
const int iBxInEvent,
std::unique_ptr<GlobalObjectMapRecord>& gtObjectMapRecord, //GTO
const unsigned int numberPhysTriggers,
const int nrL1Mu,
const int nrL1MuShower,
const int nrL1EG,
const int nrL1Tau,
const int nrL1Jet);
const unsigned int numberPhysTriggers);

/// run the uGT FDL (Apply Prescales and Veto)
void runFDL(const edm::Event& iEvent,
Expand Down Expand Up @@ -220,23 +217,6 @@ namespace l1t {

inline void enableAXOScoreSaving(bool savescore) { m_saveAXOScore = savescore; }

private:
// cached stuff

// trigger menu
const TriggerMenu* m_l1GtMenu;
unsigned long long m_l1GtMenuCacheID;

// L1 scales (phi, eta) for Mu, Calo and EnergySum objects
const L1CaloGeometry* m_l1CaloGeometry;
unsigned long long m_l1CaloGeometryCacheID;

const L1MuTriggerScales* m_l1MuTriggerScales;
unsigned long long m_l1MuTriggerScalesCacheID;

// conversions for eta and phi
// L1GtEtaPhiConversions* m_gtEtaPhiConversions;

private:
BXVector<const l1t::Muon*>* m_candL1Mu;
BXVector<std::shared_ptr<l1t::MuonShower>>* m_candL1MuShower;
Expand Down Expand Up @@ -264,8 +244,9 @@ namespace l1t {

//for optional software-only saving of axol1tl score
AXOL1TLScore m_uGtAXOScore; //score dataformat
float m_storedAXOScore = -999.0; //score from cond class
float m_storedAXOScore = -999.f; //score from cond class
bool m_saveAXOScore = false;
std::string m_axoScoreConditionName;

// cache of maps
std::vector<AlgorithmEvaluation::ConditionEvaluationMap> m_conditionResultMaps;
Expand All @@ -284,13 +265,6 @@ namespace l1t {
bool m_algFinalOr;
bool m_algFinalOrVeto;

// Counter for number of events seen by this board
unsigned int m_boardEventCount;

// Information about board
int m_uGtBoardNumber;
bool m_uGtFinalBoard;

// whether we reset the prescales each lumi or not
bool m_resetPSCountersEachLumiSec = false;

Expand Down
Loading