ATLAS Offline Software
HLTConfigSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GaudiKernel/ServiceHandle.h"
7 
8 #include "TrigConfData/HLTMenu.h"
13 
14 #include "HLTConfigSvc.h"
15 #include "TrigConfMD5.h"
16 
17 #include <memory>
18 
19 TrigConf::HLTConfigSvc::HLTConfigSvc(const std::string& name, ISvcLocator* pSvcLocator) :
20  AthService(name, pSvcLocator)
21 {}
22 
24 {
25  std::unique_ptr<TrigConf::HLTMenu> hltmenu = std::make_unique<TrigConf::HLTMenu>();
26  std::unique_ptr<TrigConf::HLTMonitoring> monitoring;
27 
28  if (m_inputType == "DB") {
29  // db menu loader
30  TrigConf::TrigDBMenuLoader dbloader(m_dbConnection);
32 
33  ATH_CHECK( dbloader.loadHLTMenu(m_smk, *hltmenu) );
34  }
35  else if (m_inputType == "FILE") {
36  // load the json file into TrigConf::HLTMenu
37  TrigConf::JsonFileLoader fileLoader;
39 
40  ATH_CHECK( fileLoader.loadFile(m_hltFileName, *hltmenu) );
41 
42  uint32_t smk = m_smk.value();
43  if (!m_l1FileName.empty() && smk == 0u) {
44  auto l1menu = std::make_unique<TrigConf::L1Menu>();
45  const bool status = fileLoader.loadFile(m_l1FileName, *l1menu);
46  if (status) {
47  smk = TrigConf::truncatedHash(*l1menu, *hltmenu);
48  } else {
49  ATH_MSG_DEBUG("No L1 menu created, cannot compute a MC-SMK in this job");
50  }
51  }
52  ATH_MSG_INFO("Setting file-loaded HLT Menu SMK to:" << smk);
53  hltmenu->setSMK(smk); // allow assigning a specified or hashed SMK when running from FILE
54 
55  if (!m_monitoringFileName.empty()) {
56  monitoring.reset( new TrigConf::HLTMonitoring() );
57  const bool success = fileLoader.loadFile(m_monitoringFileName, *monitoring);
58  if (not success) {
59  if (m_monitoringOptional) {
60  ATH_MSG_INFO("Unable to read " << m_monitoringFileName
61  << ", but the monitoring collection is flagged as optional. Continuing.");
62  monitoring.reset(); // This smartpointer goes back from having Some to having None.
63  } else {
64  ATH_MSG_ERROR("Unable to read " << m_monitoringFileName
65  << ", the monitoring collection flagged as non-optional in this job.");
66  return StatusCode::FAILURE;
67  }
68  } else { // success
69  monitoring->setSMK(smk);
70  }
71  }
72  }
73  else {
74  ATH_MSG_ERROR("Unknown input type '" << m_inputType
75  << "'. Allowed values: " << m_inputType.documentation());
76  return StatusCode::FAILURE;
77  }
78 
79  ServiceHandle<StoreGateSvc> detStore("StoreGateSvc/DetectorStore", name());
80  ATH_CHECK( detStore.retrieve() );
81  if (detStore->record(std::move(hltmenu), "HLTTriggerMenu").isSuccess()) {
82  ATH_MSG_INFO("Recorded HLT menu as 'HLTTriggerMenu' in detector store");
83  }
84  if (monitoring and detStore->record(std::move(monitoring), "HLTMonitoringMenu").isSuccess()) {
85  ATH_MSG_INFO("Recorded HLT monitoring menu as 'HLTMonitoringMenu' in detector store");
86  }
87 
88  return StatusCode::SUCCESS;
89 }
90 
92 {
93  // Handle to JobOptionsSvc to retrieve configuration keys
94  if (auto joSvc = serviceLocator()->service<TrigConf::IJobOptionsSvc>("JobOptionsSvc")) {
95  if (joSvc->superMasterKey() > 0) {
96  m_inputType = "DB";
97  m_smk = joSvc->superMasterKey();
98  m_dbConnection = joSvc->server();
99  }
100  }
101  else {
102  ATH_MSG_DEBUG("Did not locate TrigConf::JobOptionsSvc, not running athenaHLT");
103  }
104 
105  ATH_MSG_INFO("Loading HLT trigger menu from:");
106  ATH_MSG_INFO(m_inputType);
107  if (m_inputType == "FILE") {
108  ATH_MSG_INFO(m_hltFileName);
109  ATH_MSG_INFO(m_monitoringFileName);
110  }
111  else if (m_inputType == "DB") {
112  ATH_MSG_INFO(m_dbConnection);
113  ATH_MSG_INFO(m_smk);
114  }
115  ATH_CHECK( writeConfigToDetectorStore() );
116 
117  return StatusCode::SUCCESS;
118 }
TrigConfMD5.h
TrigConf::HLTMonitoring::setSMK
void setSMK(unsigned int psk)
Definition: HLTMonitoring.cxx:99
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TrigConf::JsonFileLoader::loadFile
bool loadFile(const std::string &filename, boost::property_tree::ptree &data, const std::string &pathToChild="") const
Load content of json file into a ptree.
Definition: JsonFileLoader.cxx:45
RunEBWeightsComputation.smk
smk
Definition: RunEBWeightsComputation.py:87
TrigConf::TrigDBMenuLoader::loadHLTMenu
bool loadHLTMenu(unsigned int smk, boost::property_tree::ptree &hltmenu, const std::string &outFileName="") const
Load HLT menu content from the Trigger DB into two ptrees for a given SuperMasterKey (SMK)
Definition: TrigDBMenuLoader.cxx:123
TrigConf::HLTMenu::setSMK
void setSMK(unsigned int psk)
Definition: HLTMenu.cxx:46
TrigConf::HLTConfigSvc::writeConfigToDetectorStore
StatusCode writeConfigToDetectorStore()
Definition: HLTConfigSvc.cxx:23
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
IJobOptionsSvc.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HLTConfigSvc.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthService
Definition: AthService.h:32
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigConf::JsonFileLoader::setLevel
void setLevel(MSGTC::Level lvl)
Definition: JsonFileLoader.h:86
TrigConf::name
Definition: HLTChainList.h:35
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigConf::truncatedHash
uint32_t truncatedHash(const DataStructure &dataStructure)
Function to compute a truncated MD5 hash for a JSON file.
Definition: TrigConfMD5.cxx:23
TrigConf::HLTMonitoring
HLT monitoring configuration.
Definition: HLTMonitoring.h:27
TrigConf::HLTConfigSvc::HLTConfigSvc
HLTConfigSvc(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HLTConfigSvc.cxx:19
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
TrigConf::TrigDBLoader::setLevel
void setLevel(MSGTC::Level lvl)
Definition: TrigDBLoader.h:52
JsonFileLoader.h
Loader class for Trigger configuration from Json.
HLTMenu.h
merge.status
status
Definition: merge.py:17
TrigConf::JsonFileLoader
Loader of trigger configurations from Json files.
Definition: JsonFileLoader.h:25
TrigConf::HLTConfigSvc::initialize
virtual StatusCode initialize() override
Definition: HLTConfigSvc.cxx:91
TrigConf::TrigDBMenuLoader
Loader of trigger menu configurations from the database.
Definition: TrigDBMenuLoader.h:30
StoreGateSvc.h
TrigDBMenuLoader.h
ServiceHandle< StoreGateSvc >
TrigConf::MSGTC::WARNING
@ WARNING
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:26
HLTMonitoring.h