ATLAS Offline Software
TrigDBL1BunchGroupSetLoader.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("TrigDBL1BunchGroupSetLoader", connection)
8 {
9  { // query for all schema versions
10  auto & q = m_queries[1];
11  // tables
12  q.addToTableList ( "L1_BUNCH_GROUP_SET" );
13  // bind vars
14  q.extendBinding<int>("key");
15  // conditions
16  q.extendCondition("L1BGS_ID = :key");
17  // attributes
18  q.extendOutput<coral::Blob>( "L1BGS_DATA" );
19  // the field with the data
20  q.setDataName("L1BGS_DATA");
21  }
22 }
23 
24 // Destructor defined here because QueryDefinition is an incomplete type in the header
26 
27 bool
30  const std::string & outFileName ) const
31 {
33  {
34  auto session = createDBSession();
35  session->transaction().start( /*bool readonly=*/ true);
36  const size_t sv = schemaVersion(session.get());
37  QueryDefinition qdef = getQueryDefinition(sv, m_queries);
38  try {
39  qdef.setBoundValue<int>("key", bgsk);
40  auto q = qdef.createQuery( session.get() );
41  auto & cursor = q->execute();
42  if ( ! cursor.next() ) {
43  TRG_MSG_ERROR("Tried reading L1 bunchgroup set, but L1 bunchgroup key " << bgsk << " is not available" );
44  throw TrigConf::NoBGSKException("TrigDBL1BunchGroupSetLoader: L1 bunchgroup key " + std::to_string(bgsk) + " not available");
45  }
46  const coral::AttributeList& row = cursor.currentRow();
47  const coral::Blob& dataBlob = row[qdef.dataName()].data<coral::Blob>();
48  writeRawFile( dataBlob, outFileName );
49  blobToPtree( dataBlob, pt );
50  }
51  catch(coral::QueryException & ex) {
52  TRG_MSG_ERROR("When reading L1 bunchgroup set for L1 bunchgroup key " << bgsk << " a coral::QueryException was caught ( " << ex.what() <<" )" );
53  throw TrigConf::QueryException("TrigDBL1BunchGroupSetLoader: " + std::string(ex.what()));
54  }
55  }
56  try {
57  bgs.setData(std::move(pt));
58  bgs.setBGSK(bgsk);
59  }
60  catch(std::exception & ex) {
61  bgs.clear();
62  TRG_MSG_ERROR("When reading L1 bunchgroup set for L1 BGSK " << bgsk << " a parsing error occured ( " << ex.what() <<" )" );
63  throw TrigConf::ParsingException("TrigDBL1BunchGroupSetLoader: parsing error " + std::string(ex.what()));
64  }
65 
66  return true;
67 }
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::L1BunchGroupSet::setBGSK
void setBGSK(unsigned int bgsk)
Definition: L1BunchGroupSet.h:96
TrigDBL1BunchGroupSetLoader.h
Loader class for Trigger configuration (L1 prescales set) from the Trigger DB.
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::NoBGSKException
Definition: Trigger/TrigConfiguration/TrigConfIO/TrigConfIO/Exceptions.h:46
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
TrigConf::TrigDBL1BunchGroupSetLoader::~TrigDBL1BunchGroupSetLoader
virtual ~TrigDBL1BunchGroupSetLoader() override
Destructor - cannot be defined here because QueryDefinition is an incomplete type.
DumpGeoConfig.outFileName
string outFileName
Definition: DumpGeoConfig.py:238
calibdata.exception
exception
Definition: calibdata.py:496
TrigConf::TrigDBL1BunchGroupSetLoader::m_queries
std::map< size_t, QueryDefinition > m_queries
Definition: TrigDBL1BunchGroupSetLoader.h:44
TrigConf::L1BunchGroupSet
L1 board configuration.
Definition: L1BunchGroupSet.h:71
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::TrigDBL1BunchGroupSetLoader::loadBunchGroupSet
bool loadBunchGroupSet(unsigned int bgsk, L1BunchGroupSet &bgs, const std::string &outFileName="") const
Load content from the Trigger DB into an L1PrescalesSet for a given L1PrescaleKey (L1PSK)
Definition: TrigDBL1BunchGroupSetLoader.cxx:28
TrigConf::L1BunchGroupSet::clear
virtual void clear() override
Clearing the configuration data.
Definition: L1BunchGroupSet.cxx:110
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
extractSporadic.q
list q
Definition: extractSporadic.py:98
TrigDBHelper.h
TrigConf::QueryDefinition::dataName
const std::string & dataName()
Definition: TrigDBHelper.h:51
TrigConf::TrigDBL1BunchGroupSetLoader::TrigDBL1BunchGroupSetLoader
TrigDBL1BunchGroupSetLoader(const std::string &connection)
Constructor.
Definition: TrigDBL1BunchGroupSetLoader.cxx:6