Skip to content

Commit 9cab997

Browse files
authored
Merge pull request #47070 from missirol/devel_cmssw46740
move per-run changes of L1-uGT emulator to `beginRun` (incl. loading of AXOL1TL model)
2 parents dcded52 + fe94271 commit 9cab997

15 files changed

+365
-510
lines changed

L1Trigger/L1TGlobal/interface/AXOL1TLCondition.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
* Description: evaluation of a CondAXOL1TL condition.
88
*/
99

10-
// system include files
1110
#include <iosfwd>
1211
#include <string>
1312

14-
// user include files
15-
// base classes
1613
#include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
1714
#include "DataFormats/L1Trigger/interface/L1Candidate.h"
1815

16+
#include "hls4ml/emulator.h"
17+
1918
// forward declarations
2019
class GlobalCondition;
2120
class AXOL1TLTemplate;
@@ -64,6 +63,10 @@ namespace l1t {
6463

6564
inline float getScore() const { return m_savedscore; }
6665

66+
void loadModel();
67+
68+
inline hls4mlEmulator::ModelLoader const& model_loader() const { return m_model_loader; }
69+
6770
private:
6871
/// copy function for copy constructor and operator=
6972
void copy(const AXOL1TLCondition& cp);
@@ -74,6 +77,11 @@ namespace l1t {
7477
/// pointer to uGt GlobalBoard, to be able to get the trigger objects
7578
const GlobalBoard* m_gtGTB;
7679

80+
static constexpr char const* kModelNamePrefix = "GTADModel_";
81+
82+
hls4mlEmulator::ModelLoader m_model_loader;
83+
std::shared_ptr<hls4mlEmulator::Model> m_model;
84+
7785
///axo score for possible score saving
7886
mutable float m_savedscore;
7987
};

L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <iostream>
2424
#include <map>
25+
#include <memory>
2526
#include <queue>
2627
#include <stack>
2728
#include <string>
@@ -55,9 +56,7 @@ namespace l1t {
5556
// virtual ~AlgorithmEvaluation();
5657

5758
//typedef std::map<std::string, ConditionEvaluation*> ConditionEvaluationMap;
58-
typedef std::unordered_map<std::string, ConditionEvaluation*> ConditionEvaluationMap;
59-
typedef ConditionEvaluationMap::const_iterator CItEvalMap;
60-
typedef ConditionEvaluationMap::iterator ItEvalMap;
59+
typedef std::unordered_map<std::string, std::unique_ptr<ConditionEvaluation>> ConditionEvaluationMap;
6160

6261
public:
6362
/// get / set the result of the algorithm

L1Trigger/L1TGlobal/interface/ConditionEvaluation.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,13 @@
2222
*
2323
*/
2424

25-
// system include files
25+
#include <cstdint>
2626
#include <iostream>
27-
2827
#include <string>
2928
#include <vector>
3029

31-
// user include files
32-
33-
// base class
34-
35-
//
3630
#include "DataFormats/L1TGlobal/interface/GlobalObjectMapFwd.h"
3731
#include "FWCore/MessageLogger/interface/MessageLogger.h"
38-
#include <cstdint>
39-
40-
// forward declarations
4132

4233
namespace l1t {
4334

L1Trigger/L1TGlobal/interface/CorrCondition.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ namespace l1t {
4242
CorrCondition();
4343

4444
/// from base template condition (from event setup usually)
45-
CorrCondition(const GlobalCondition*, const GlobalCondition*, const GlobalCondition*, const GlobalBoard*
46-
47-
);
45+
CorrCondition(const GlobalCondition*,
46+
const GlobalCondition*,
47+
const GlobalCondition*,
48+
const GlobalBoard*,
49+
const GlobalScales*);
4850

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

6567
public:
66-
/// get / set the pointer to a Condition
6768
inline const CorrelationTemplate* gtCorrelationTemplate() const { return m_gtCorrelationTemplate; }
68-
6969
void setGtCorrelationTemplate(const CorrelationTemplate*);
7070

71-
/// get / set the pointer to uGt GlobalBoard
7271
inline const GlobalBoard* getuGtB() const { return m_uGtB; }
73-
7472
void setuGtB(const GlobalBoard*);
7573

74+
inline const GlobalScales* getScales() const { return m_gtScales; }
7675
void setScales(const GlobalScales*);
7776

7877
/* //BLW Comment out for now

L1Trigger/L1TGlobal/interface/CorrThreeBodyCondition.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ namespace l1t {
4646
const GlobalCondition*,
4747
const GlobalCondition*,
4848
const GlobalCondition*,
49-
const GlobalBoard*
50-
51-
);
49+
const GlobalBoard*,
50+
const GlobalScales*);
5251

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

6968
public:
70-
/// get / set the pointer to a Condition
7169
inline const CorrelationThreeBodyTemplate* gtCorrelationThreeBodyTemplate() const {
7270
return m_gtCorrelationThreeBodyTemplate;
7371
}
74-
7572
void setGtCorrelationThreeBodyTemplate(const CorrelationThreeBodyTemplate*);
7673

77-
/// get / set the pointer to uGt GlobalBoard
7874
inline const GlobalBoard* getuGtB() const { return m_uGtB; }
79-
8075
void setuGtB(const GlobalBoard*);
8176

77+
inline const GlobalScales* getScales() const { return m_gtScales; }
8278
void setScales(const GlobalScales*);
8379

8480
private:

L1Trigger/L1TGlobal/interface/CorrWithOverlapRemovalCondition.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,8 @@ namespace l1t {
4747
const GlobalCondition*,
4848
const GlobalCondition*,
4949
const GlobalCondition*,
50-
const GlobalBoard*
51-
52-
);
50+
const GlobalBoard*,
51+
const GlobalScales*);
5352

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

7069
public:
71-
/// get / set the pointer to a Condition
7270
inline const CorrelationWithOverlapRemovalTemplate* gtCorrelationWithOverlapRemovalTemplate() const {
7371
return m_gtCorrelationWithOverlapRemovalTemplate;
7472
}
7573

7674
void setGtCorrelationWithOverlapRemovalTemplate(const CorrelationWithOverlapRemovalTemplate*);
7775

78-
/// get / set the pointer to uGt GlobalBoard
7976
inline const GlobalBoard* getuGtB() const { return m_uGtB; }
80-
8177
void setuGtB(const GlobalBoard*);
8278

79+
inline const GlobalScales* getScales() const { return m_gtScales; }
8380
void setScales(const GlobalScales*);
8481

8582
/* //BLW Comment out for now

L1Trigger/L1TGlobal/interface/GlobalBoard.h

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
#ifndef GtBoard_h
2-
#define GtBoard_h
1+
#ifndef L1Trigger_L1TGlobal_GlobalBoard_h
2+
#define L1Trigger_L1TGlobal_GlobalBoard_h
33

44
/**
55
* \class GlobalBoard
66
*
77
*
88
* Description: Global Trigger Logic board.
99
*
10-
* Implementation:
11-
* <TODO: enter implementation details>
12-
*
1310
*/
1411

1512
// system include files
@@ -18,6 +15,7 @@
1815
#include <vector>
1916
#include <cmath>
2017
#include <memory>
18+
#include <string>
2119

2220
// user include files
2321
#include "FWCore/Utilities/interface/typedefs.h"
@@ -46,11 +44,6 @@
4644

4745
// forward declarations
4846
class TriggerMenu;
49-
class L1CaloGeometry;
50-
class L1MuTriggerScales;
51-
//class L1GtEtaPhiConversions;
52-
53-
// class declaration
5447

5548
namespace l1t {
5649

@@ -107,19 +100,23 @@ namespace l1t {
107100
int bxFirst,
108101
int bxLast);
109102

110-
/// run the uGT GTL (Conditions and Algorithms)
103+
/// initialise Trigger Conditions
104+
void initTriggerConditions(const edm::EventSetup& evSetup,
105+
const TriggerMenu* m_l1GtMenu,
106+
const int nrL1Mu,
107+
const int nrL1MuShower,
108+
const int nrL1EG,
109+
const int nrL1Tau,
110+
const int nrL1Jet);
111+
112+
/// run the uGT GTL (Algorithms, per-event decisions)
111113
void runGTL(const edm::Event& iEvent,
112114
const edm::EventSetup& evSetup,
113115
const TriggerMenu* m_l1GtMenu,
114116
const bool produceL1GtObjectMapRecord,
115117
const int iBxInEvent,
116118
std::unique_ptr<GlobalObjectMapRecord>& gtObjectMapRecord, //GTO
117-
const unsigned int numberPhysTriggers,
118-
const int nrL1Mu,
119-
const int nrL1MuShower,
120-
const int nrL1EG,
121-
const int nrL1Tau,
122-
const int nrL1Jet);
119+
const unsigned int numberPhysTriggers);
123120

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

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

223-
private:
224-
// cached stuff
225-
226-
// trigger menu
227-
const TriggerMenu* m_l1GtMenu;
228-
unsigned long long m_l1GtMenuCacheID;
229-
230-
// L1 scales (phi, eta) for Mu, Calo and EnergySum objects
231-
const L1CaloGeometry* m_l1CaloGeometry;
232-
unsigned long long m_l1CaloGeometryCacheID;
233-
234-
const L1MuTriggerScales* m_l1MuTriggerScales;
235-
unsigned long long m_l1MuTriggerScalesCacheID;
236-
237-
// conversions for eta and phi
238-
// L1GtEtaPhiConversions* m_gtEtaPhiConversions;
239-
240220
private:
241221
BXVector<const l1t::Muon*>* m_candL1Mu;
242222
BXVector<std::shared_ptr<l1t::MuonShower>>* m_candL1MuShower;
@@ -264,8 +244,9 @@ namespace l1t {
264244

265245
//for optional software-only saving of axol1tl score
266246
AXOL1TLScore m_uGtAXOScore; //score dataformat
267-
float m_storedAXOScore = -999.0; //score from cond class
247+
float m_storedAXOScore = -999.f; //score from cond class
268248
bool m_saveAXOScore = false;
249+
std::string m_axoScoreConditionName;
269250

270251
// cache of maps
271252
std::vector<AlgorithmEvaluation::ConditionEvaluationMap> m_conditionResultMaps;
@@ -284,13 +265,6 @@ namespace l1t {
284265
bool m_algFinalOr;
285266
bool m_algFinalOrVeto;
286267

287-
// Counter for number of events seen by this board
288-
unsigned int m_boardEventCount;
289-
290-
// Information about board
291-
int m_uGtBoardNumber;
292-
bool m_uGtFinalBoard;
293-
294268
// whether we reset the prescales each lumi or not
295269
bool m_resetPSCountersEachLumiSec = false;
296270

0 commit comments

Comments
 (0)