ATLAS Offline Software
TrigDBL1PrescalesSetLoader.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2 
3 #include "./TrigDBHelper.h"
5 
7  TrigDBLoader("TrigDBL1PrescalesSetLoader", connection)
8 {
9  { // query for all schema versions
10  auto & q = m_queries[1];
11  // tables
12  q.addToTableList ( "L1_PRESCALE_SET" );
13  // bind vars
14  q.extendBinding<int>("key");
15  // conditions
16  q.extendCondition("L1PS_ID = :key");
17  // attributes
18  q.extendOutput<coral::Blob>( "L1PS_DATA" );
19  // the field with the data
20  q.setDataName("L1PS_DATA");
21  }
22 }
23 
24 // Destructor defined here because QueryDefinition is an incomplete type in the header
26 
27 bool
29  const std::string & outFileName ) const
30 {
32  {
33  auto session = createDBSession();
34  session->transaction().start( /*bool readonly=*/ true);
35  const size_t sv = schemaVersion(session.get());
36  QueryDefinition qdef = getQueryDefinition(sv, m_queries);
37  try {
38  qdef.setBoundValue<int>("key", psk);
39  auto q = qdef.createQuery( session.get() );
40  auto & cursor = q->execute();
41  if ( ! cursor.next() ) {
42  TRG_MSG_ERROR("Tried reading L1 prescales, but L1 prescale key " << psk << " is not available" );
43  throw TrigConf::NoL1PSKException("TrigDBL1PrescalesSetLoader: L1 PSK " + std::to_string(psk) + " not available");
44  }
45  const coral::AttributeList& row = cursor.currentRow();
46  const coral::Blob& dataBlob = row[qdef.dataName()].data<coral::Blob>();
47  writeRawFile( dataBlob, outFileName );
48  blobToPtree( dataBlob, pt );
49  }
50  catch(coral::QueryException & ex) {
51  TRG_MSG_ERROR("When reading L1 prescales for L1 PSK " << psk << " a coral::QueryException was caught ( " << ex.what() <<" )" );
52  throw TrigConf::QueryException("TrigDBL1PrescalesSetLoader: " + std::string(ex.what()));
53  }
54  }
55  try {
56  pss.setData(std::move(pt));
57  pss.setPSK(psk);
58  }
59  catch(std::exception & ex) {
60  pss.clear();
61  TRG_MSG_ERROR("When reading L1 prescales for L1 PSK " << psk << " a parsing error occured ( " << ex.what() <<" )" );
62  throw TrigConf::ParsingException("TrigDBL1PrescalesSetLoader: parsing error " + std::string(ex.what()));
63  }
64 
65  return true;
66 }
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::TrigDBL1PrescalesSetLoader::TrigDBL1PrescalesSetLoader
TrigDBL1PrescalesSetLoader(const std::string &connection)
Constructor.
Definition: TrigDBL1PrescalesSetLoader.cxx:6
TrigConf::TrigDBL1PrescalesSetLoader::loadL1Prescales
bool loadL1Prescales(unsigned int l1psk, L1PrescalesSet &l1pss, const std::string &outFileName="") const
Load content from the Trigger DB into an L1PrescalesSet for a given L1PrescaleKey (L1PSK)
Definition: TrigDBL1PrescalesSetLoader.cxx:28
TrigConf::TrigDBLoader
Loader of trigger configurations from Json files.
Definition: TrigDBLoader.h:33
test_pyathena.pt
pt
Definition: test_pyathena.py:11
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::QueryDefinition
Definition: TrigDBHelper.h:28
TrigConf::L1PrescalesSet::setPSK
void setPSK(unsigned int psk)
Definition: L1PrescalesSet.cxx:49
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:252
TrigDBL1PrescalesSetLoader.h
Loader class for Trigger configuration (L1 prescales set) from the Trigger DB.
calibdata.exception
exception
Definition: calibdata.py:496
TrigConf::L1PrescalesSet::clear
virtual void clear() override
Clearing the configuration data.
Definition: L1PrescalesSet.cxx:31
TrigConf::QueryDefinition::createQuery
std::unique_ptr< coral::IQuery > createQuery(coral::ISessionProxy *session)
Definition: TrigDBHelper.cxx:10
TrigConf::L1PrescalesSet
L1 menu configuration.
Definition: L1PrescalesSet.h:19
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::TrigDBL1PrescalesSetLoader::~TrigDBL1PrescalesSetLoader
virtual ~TrigDBL1PrescalesSetLoader() override
Destructor - cannot be defined here because QueryDefinition is an incomplete type.
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::NoL1PSKException
Definition: Trigger/TrigConfiguration/TrigConfIO/TrigConfIO/Exceptions.h:36
extractSporadic.q
list q
Definition: extractSporadic.py:98
TrigDBHelper.h
TrigConf::TrigDBL1PrescalesSetLoader::m_queries
std::map< size_t, QueryDefinition > m_queries
Definition: TrigDBL1PrescalesSetLoader.h:44
TrigConf::QueryDefinition::dataName
const std::string & dataName()
Definition: TrigDBHelper.h:51