ATLAS Offline Software
TrigDBMonitoringLoader.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 #include "./TrigDBHelper.h"
5 
7  TrigDBLoader("TrigDBMonitoringLoader", connection)
8 {
9  /*
10  DB queries
11  */
12  { // for schema version 7
13  auto & q = m_queries[7];
14  // tables
15  q.addToTableList ( "SUPER_MASTER_TABLE", "SMT" );
16  q.addToTableList ( "HLT_MONITORING_GROUPS", "HMG" );
17  // bind vars
18  q.extendBinding<int>("smk");
19  // conditions
20  q.extendCondition("SMT.SMT_ID = :smk");
21  q.extendCondition(" AND SMT.SMT_HLT_MENU_ID = HMG.HMG_HLT_MENU_ID");
22  q.extendCondition(" AND HMG.HMG_IN_USE=1");
23  q.extendCondition(" ORDER BY HMG.HMG_ID DESC");
24  // attributes
25  q.extendOutput<int> ( "HMG.HMG_ID" );
26  q.extendOutput<coral::Blob>( "HMG.HMG_DATA" );
27  // the field with the data
28  q.setDataName("HMG.HMG_DATA");
29  }
30 }
31 
32 
33 // Destructor defined here because QueryDefinition is an incomplete type in the header
35 
36 
37 bool
39  boost::property_tree::ptree & hltmonitoring,
40  const std::string & outFileName ) const
41 {
42  auto session = createDBSession();
43  session->transaction().start( /*bool readonly=*/ true);
44  const size_t sv = schemaVersion(session.get());
45  QueryDefinition qdef = getQueryDefinition(sv, m_queries);
46  try {
47  qdef.setBoundValue<int>("smk", smk);
48  auto q = qdef.createQuery( session.get() );
49  auto & cursor = q->execute();
50  if ( ! cursor.next() ) {
51  TRG_MSG_ERROR("Tried reading HLT menu, but SuperMasterKey " << smk << " is not available" );
52  throw TrigConf::NoSMKException("TrigDBMonitoringLoader: SMK " + std::to_string(smk) + " not available");
53  }
54  const coral::AttributeList& row = cursor.currentRow();
55  const coral::Blob& dataBlob = row[qdef.dataName()].data<coral::Blob>();
56  writeRawFile( dataBlob, outFileName );
57  blobToPtree( dataBlob, hltmonitoring );
58  }
59  catch(coral::QueryException & ex) {
60  TRG_MSG_ERROR("When reading HLT menu for SMK " << smk << " a coral::QueryException was caught ( " << ex.what() <<" )" );
61  throw TrigConf::QueryException("TrigDBMonitoringLoader: " + std::string(ex.what()));
62  }
63  return true;
64 }
65 
66 bool
68  const std::string & outFileName ) const
69 {
71  loadHLTMonitoring( smk, pthlt, outFileName );
72  try {
73  hltmonitoring.setData(std::move(pthlt));
74  hltmonitoring.setSMK(smk);
75  }
76  catch(std::exception & ex) {
77  hltmonitoring.clear();
78  TRG_MSG_ERROR("When reading HLT menu for SMK " << smk << " a parsing error occured ( " << ex.what() <<" )" );
79  throw TrigConf::ParsingException("TrigDBMonitoringLoader: parsing error " + std::string(ex.what()));
80  }
81  return true;
82 }
TrigDBMonitoringLoader.h
TRG_MSG_ERROR
#define TRG_MSG_ERROR(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:29
query_example.row
row
Definition: query_example.py:24
TrigConf::HLTMonitoring::setSMK
void setSMK(unsigned int psk)
Definition: HLTMonitoring.cxx:99
RunEBWeightsComputation.smk
smk
Definition: RunEBWeightsComputation.py:87
TrigConf::NoSMKException
Definition: Trigger/TrigConfiguration/TrigConfIO/TrigConfIO/Exceptions.h:31
TrigConf::TrigDBLoader
Loader of trigger configurations from Json files.
Definition: TrigDBLoader.h:33
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::QueryDefinition
Definition: TrigDBHelper.h:28
TrigConf::DataStructure::setData
void setData(const ptree &data)
Setting the configuration data.
Definition: DataStructure.cxx:39
TrigConf::QueryDefinition::setBoundValue
void setBoundValue(const std::string &fieldName, const T &value)
Definition: TrigDBHelper.h:75
DumpGeoConfig.outFileName
string outFileName
Definition: DumpGeoConfig.py:238
TrigConf::TrigDBMonitoringLoader::~TrigDBMonitoringLoader
virtual ~TrigDBMonitoringLoader() override
Destructor - cannot be defined here because QueryDefinition is an incomplete type.
calibdata.exception
exception
Definition: calibdata.py:496
TrigConf::HLTMonitoring::clear
virtual void clear() override
Clearing the configuration data.
Definition: HLTMonitoring.cxx:87
TrigConf::QueryDefinition::createQuery
std::unique_ptr< coral::IQuery > createQuery(coral::ISessionProxy *session)
Definition: TrigDBHelper.cxx:10
TrigConf::ParsingException
Definition: Trigger/TrigConfiguration/TrigConfIO/TrigConfIO/Exceptions.h:51
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
TrigConf::QueryException
Definition: Trigger/TrigConfiguration/TrigConfIO/TrigConfIO/Exceptions.h:21
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TrigConf::HLTMonitoring
HLT monitoring configuration.
Definition: HLTMonitoring.h:27
TrigConf::TrigDBMonitoringLoader::loadHLTMonitoring
bool loadHLTMonitoring(unsigned int smk, boost::property_tree::ptree &hltmonitoring, const std::string &outFileName="") const
Load HLT menu content from the Trigger DB into two ptrees for a given SuperMasterKey (SMK)
Definition: TrigDBMonitoringLoader.cxx:38
query_example.cursor
cursor
Definition: query_example.py:21
TrigConf::blobToPtree
void blobToPtree(const coral::Blob &blob, boost::property_tree::ptree &pt)
Definition: TrigDBHelper.cxx:58
LArCellConditions.sv
bool sv
Definition: LArCellConditions.py:45
TrigConf::TrigDBMonitoringLoader::m_queries
std::map< size_t, QueryDefinition > m_queries
Definition: TrigDBMonitoringLoader.h:55
extractSporadic.q
list q
Definition: extractSporadic.py:98
TrigDBHelper.h
TrigConf::TrigDBMonitoringLoader::TrigDBMonitoringLoader
TrigDBMonitoringLoader(const std::string &connection)
Constructor.
Definition: TrigDBMonitoringLoader.cxx:6
TrigConf::QueryDefinition::dataName
const std::string & dataName()
Definition: TrigDBHelper.h:51