ATLAS Offline Software
Loading...
Searching...
No Matches
CTPSimulation.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef TRIGT1CTP_CTPSIMULATION_H
5#define TRIGT1CTP_CTPSIMULATION_H
6
7
9
10#include "GaudiKernel/ServiceHandle.h"
11#include "GaudiKernel/ToolHandle.h"
12#include "Gaudi/Property.h"
14
15// monitoring from HLT
16#include "GaudiKernel/ITHistSvc.h"
17
18
19// data default location
22
23// input/output data classes
34#include "TrigT1Result/CTP_RDO.h"// TODO obsolete it in favour of xAOD::CTPResult - see line below
39
40// new configuration data
41#include "TrigConfData/L1Menu.h"
43
44// internal
45#include "./ItemMap.h"
46#include "./ThresholdMap.h"
47#include "./ResultBuilder.h"
48
49#include "GaudiKernel/LockedHandle.h"
51
52#include "TH1.h"
53#include "TH2.h"
54
55#include <map>
56#include <string>
57#include <mutex>
58
59namespace LVL1 {
60 class CPRoIDecoder;
61 class JEPRoIDecoder;
62}
63
64namespace LVL1CTP {
65
67
68 public:
69
70 CTPSimulation( const std::string& name, ISvcLocator* pSvcLocator );
72
73 virtual StatusCode initialize() override;
74
75 virtual StatusCode start() override;
76
77 virtual StatusCode execute( const EventContext& context ) const override;
78
79 virtual StatusCode stop() override;
80
81
82 private:
83 // histogramming related
84 StatusCode bookHists();
85 StatusCode setHistLabels(const TrigConf::L1Menu& l1menu);
86 StatusCode createMultiplicityHist(const std::string & type, unsigned int maxMult = 10 );
87 StatusCode setMultiplicityHistLabels(const TrigConf::L1Menu& l1menu, const std::string & type);
88 StatusCode hbook(const std::string & path, std::unique_ptr<TH1> hist);
89 StatusCode hbook(const std::string & path, std::unique_ptr<TH2> hist);
90 StatusCode storeMetadata();
91 LockedHandle<TH1> & get1DHist(const std::string & histName) const;
92 LockedHandle<TH2> & get2DHist(const std::string & histName) const;
93 std::string getBaseHistPath() const;
94
95 // execution related
96 StatusCode fillInputHistograms(const EventContext& context) const;
97
98 StatusCode extractMultiplicities(std::map<std::string, unsigned int> & thrMultiMap, const EventContext& context) const;
99
100 StatusCode simulateItems(const std::map<std::string, unsigned int> & thrMultiMap, const EventContext& context) const;
101
102 unsigned int calculateMultiplicity ( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const;
103 unsigned int calculateJetMultiplicity ( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const;
104 unsigned int calculateEMMultiplicity ( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const;
105 unsigned int calculateTauMultiplicity ( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const;
106 unsigned int calculateMETMultiplicity ( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const;
107 unsigned int calculateMuonMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const;
108 unsigned int calculateTopoMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context, bool UseLegacy ) const;
109 unsigned int calculateTopoOptMultiplicity( const TrigConf::L1Threshold & confThr, const TrigConf::L1Menu * l1menu, const EventContext& context ) const;
110
111 // Needed services and tools
112 ServiceHandle<ITHistSvc> m_histSvc { this, "THistSvc", "THistSvc/THistSvc", "Histogramming svc" };
113
114 ToolHandle<LVL1CTP::ResultBuilder> m_resultBuilder { this, "ResultBuilder", "LVL1CTP::ResultBuilder/ResultBuilder", "Builds the CTP result" };
115
116 // random engine for calculating prescales
118
119 // thread safe histogram handlers
120 std::map<std::string, LockedHandle<TH1>> m_hist1D;
121 std::map<std::string, LockedHandle<TH2>> m_hist2D;
122
123 // inputs
124 // new L1Topo
126 // legacy L1Topo
128 // MUCTPI
130 // CTPIN
131 SG::ReadHandleKey<LVL1::EmTauCTP> m_iKeyCtpinEM{ this, "CtpinEMInput", LVL1::TrigT1CaloDefs::EmTauCTPLocation, "Input from CTPIN em and tau (legacy)" };
132 SG::ReadHandleKey<LVL1::JetCTP> m_iKeyCtpinJet{ this, "CtpinJetInput", LVL1::TrigT1CaloDefs::JetCTPLocation, "Input from CTPIN jet (legacy)" };
133 SG::ReadHandleKey<LVL1::EnergyCTP> m_iKeyCtpinXE{ this, "CtpinXEInput", LVL1::TrigT1CaloDefs::EnergyCTPLocation, "Input from CTPIN energy (te,xe,xs - legacy)" };
134 // new FEX object collections (temporary until moved to L1Topo simulation)
135 // jFEX
136 SG::ReadHandleKey< xAOD::JetRoIContainer > m_iKeyJFexJets { this, "jFexJetInput", "jRoundJets", "Input list of jFEX jets" };
137 SG::ReadHandleKey< xAOD::JetRoIContainer > m_iKeyJFexLJets{ this, "jFexLJetInput", "jRoundLargeRJets", "Input list of jFEX large-R jets" };
138 // gFEX
139 SG::ReadHandleKey< xAOD::JetRoIContainer > m_iKeyGFexJets { this, "gFexJetInput", "gL1Jets", "Input list of gFEX jets" };
140 SG::ReadHandleKey< xAOD::EnergySumRoI > m_iKeyGFexMETNC { this, "gFexMETNCInput", "gXENOISECUTPerf", "Input list of gFEX MET NC" };
141 SG::ReadHandleKey< xAOD::EnergySumRoI > m_iKeyGFexMETRho { this, "gFexMETRhoInput", "gXERHOPerf", "Input list of gFEX MET Rho" };
142 SG::ReadHandleKey< xAOD::EnergySumRoI > m_iKeyGFexMETJwoJ { this, "gFexMETJwoJInput", "gXEJWOJPerf", "Input list of gFEX MET JwoJ" };
143 // eFEX
144 SG::ReadHandleKey< xAOD::TrigEMClusterContainer > m_iKeyEFexCluster{ this, "eFexClusterInput", "SClusterCl", "Input list of eFEX cluster" };
145 SG::ReadHandleKey< xAOD::EmTauRoIContainer > m_iKeyEFexTau { this, "eFexTauInput", "SClusterTau", "Input list of eFEX tau" };
146 // ZDC
148 // TRT
150
151 // outputs
152 SG::WriteHandleKey<CTP_RDO> m_oKeyRDO {this, "RDOOutput", LVL1CTP::DEFAULT_RDOOutputLocation, "Output of CTP RDO object (sim)"};
154 SG::WriteHandleKey<CTPSLink> m_oKeySLink{this, "ROIOutput", LVL1CTP::DEFAULT_CTPSLinkLocation, "Output of CTP SLink object (sim)"};
155
156
157 // properties
158 Gaudi::Property<bool> m_isData { this, "IsData", false, "emulate CTP as part of MC or rerun on data" };
159 Gaudi::Property<std::string> m_histPath { this, "HistPath", "/EXPERT/L1", "Booking path for the histogram" };
160 Gaudi::Property<bool> m_doZDC{this, "DoZDC", false, "emulate CTP with ZDC included"};
161 Gaudi::Property<bool> m_doTRT{this, "DoTRT", false, "emulate CTP with TRT included"};
162 Gaudi::Property<bool> m_forceBunchGroupPattern { this, "ForceBunchGroupPattern", true, "When true, ignore the bunchgroups and use the provided BunchGroupPattern" };
163 Gaudi::Property<unsigned int> m_bunchGroupPattern { this, "BunchGroupPattern", 0x0003, "Bunchgroup pattern applied at every event, useful for simulation. Bit x corresponds to bunchgroup x" };
164
165 Gaudi::Property<bool> m_doL1CaloLegacy { this, "DoL1CaloLegacy", false, "Use L1Calo legacy" };
166 Gaudi::Property<bool> m_doL1Topo { this, "DoL1Topo", false, "Use L1Topo" };
167 Gaudi::Property<bool> m_doL1TopoLegacy { this, "DoL1TopoLegacy", false, "Use L1Topo Legacy" };
168 Gaudi::Property<bool> m_muonRun2Format { this, "MuonMultiplicityRun2Format", false, "Interpret muon multiplicity in Run 2 format (bit 0 unused)" };
169
170 Gaudi::Property<bool> m_useEDMxAOD { this, "UseEDMxAOD", false, "Use EDM based on xAOD class" };
171
172 SG::ReadCondHandleKey<TrigConf::L1BunchGroupSet> m_bgKey{this, "L1BunchGroup", "L1BunchGroup", "L1BunchGroupSet key name"};
173 };
174
175}
176
177#endif
defines an "iterator" over instances of a given type in StoreGateSvc
A wrapper class for event-slot-local random engines.
Definition RNGWrapper.h:56
An algorithm that can be simultaneously executed in multiple threads.
unsigned int calculateJetMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
Gaudi::Property< std::string > m_histPath
SG::ReadHandleKey< xAOD::EnergySumRoI > m_iKeyGFexMETRho
SG::ReadHandleKey< xAOD::JetRoIContainer > m_iKeyJFexLJets
virtual StatusCode stop() override
StatusCode fillInputHistograms(const EventContext &context) const
Gaudi::Property< bool > m_forceBunchGroupPattern
unsigned int calculateTopoMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context, bool UseLegacy) const
Gaudi::Property< bool > m_doL1TopoLegacy
SG::ReadHandleKey< xAOD::JetRoIContainer > m_iKeyJFexJets
Gaudi::Property< bool > m_doL1Topo
unsigned int calculateTopoOptMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
unsigned int calculateTauMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
SG::ReadHandleKey< LVL1::FrontPanelCTP > m_iKeyTopo
SG::ReadHandleKey< LVL1::FrontPanelCTP > m_iKeyLegacyTopo
SG::ReadHandleKey< LVL1::EmTauCTP > m_iKeyCtpinEM
unsigned int calculateMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
SG::WriteHandleKey< xAOD::CTPResult > m_oKeyCTPResult
virtual StatusCode start() override
StatusCode setHistLabels(const TrigConf::L1Menu &l1menu)
LockedHandle< TH2 > & get2DHist(const std::string &histName) const
LockedHandle< TH1 > & get1DHist(const std::string &histName) const
StatusCode simulateItems(const std::map< std::string, unsigned int > &thrMultiMap, const EventContext &context) const
SG::ReadHandleKey< LVL1::EnergyCTP > m_iKeyCtpinXE
unsigned int calculateMETMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
unsigned int calculateEMMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
virtual StatusCode initialize() override
unsigned int calculateMuonMultiplicity(const TrigConf::L1Threshold &confThr, const TrigConf::L1Menu *l1menu, const EventContext &context) const
SG::WriteHandleKey< CTP_RDO > m_oKeyRDO
std::map< std::string, LockedHandle< TH2 > > m_hist2D
std::map< std::string, LockedHandle< TH1 > > m_hist1D
SG::ReadHandleKey< LVL1::TrtCTP > m_iKeyTRT
SG::ReadHandleKey< xAOD::EnergySumRoI > m_iKeyGFexMETNC
StatusCode setMultiplicityHistLabels(const TrigConf::L1Menu &l1menu, const std::string &type)
Gaudi::Property< bool > m_useEDMxAOD
SG::ReadHandleKey< xAOD::EmTauRoIContainer > m_iKeyEFexTau
virtual StatusCode execute(const EventContext &context) const override
SG::ReadCondHandleKey< TrigConf::L1BunchGroupSet > m_bgKey
SG::ReadHandleKey< xAOD::TrigEMClusterContainer > m_iKeyEFexCluster
ATHRNG::RNGWrapper m_RNGEngines
Gaudi::Property< bool > m_muonRun2Format
ServiceHandle< ITHistSvc > m_histSvc
Gaudi::Property< unsigned int > m_bunchGroupPattern
SG::ReadHandleKey< xAOD::JetRoIContainer > m_iKeyGFexJets
Gaudi::Property< bool > m_doL1CaloLegacy
SG::ReadHandleKey< xAOD::EnergySumRoI > m_iKeyGFexMETJwoJ
SG::WriteHandleKey< CTPSLink > m_oKeySLink
StatusCode hbook(const std::string &path, std::unique_ptr< TH1 > hist)
std::string getBaseHistPath() const
SG::ReadHandleKey< LVL1::MuCTPICTP > m_iKeyMuctpi
SG::ReadHandleKey< LVL1::ZdcCTP > m_iKeyZDC
Gaudi::Property< bool > m_doTRT
Gaudi::Property< bool > m_isData
SG::ReadHandleKey< LVL1::JetCTP > m_iKeyCtpinJet
ToolHandle< LVL1CTP::ResultBuilder > m_resultBuilder
CTPSimulation(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode createMultiplicityHist(const std::string &type, unsigned int maxMult=10)
StatusCode extractMultiplicities(std::map< std::string, unsigned int > &thrMultiMap, const EventContext &context) const
Gaudi::Property< bool > m_doZDC
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
A level 1 calorimeter trigger conversion service: returns the Coordinate represented by a RoI word.
static const std::string JetCTPLocation
static const std::string EnergyCTPLocation
static const std::string ZdcCTPLocation
static const std::string EmTauCTPLocation
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
L1 menu configuration.
Definition L1Menu.h:28
Standard L1 threshold configuration.
static const std::string DEFAULT_CTPSLinkLocation
default StoreGate location for CTPSLink
static const std::string DEFAULT_CTPResultOutputLocation
location of CTPResult output in StoreGate
static const std::string DEFAULT_RDOOutputLocation
location of CTP RDO output in StoreGate
static const std::string DEFAULT_MuonCTPLocation
default StoreGate location for MuCTPI to CTP input
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
static const std::string DEFAULT_L1TopoCTPLocation
XXX default StoreGate location for Front Panel CTP inputs.
static const std::string DEFAULT_TrtCTPLocation
default StoreGate location for TRT to CTP input
static const std::string DEFAULT_L1TopoLegacyCTPLocation
default StoreGate location for Front Panel legacy L1Topo to CTP inputs