ATLAS Offline Software
PrescaleSetLoader.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 //
7 //NAME: PrescaleSetLoader.cpp
8 //PACKAGE: TrigConfStorage
9 //
10 //AUTHOR: J.Haller (CERN) Johannes.Haller@cern.ch
11 //CREATED: 25. Jan. 2006
12 //
13 //PURPOSE:
14 //UPDATED: 8 Dec 2008 Paul Bell for sqlite access
15 // (use of defineOutput method to set data type)
16 //
18 
19 
20 #include "CTPfragment/CTPdataformatVersion.h"
22 #include "./PrescaleSetLoader.h"
23 #include "./DBHelper.h"
24 
25 using namespace std;
26 
27 bool
28 TrigConf::PrescaleSetLoader::load( unsigned int ctpVersion, PrescaleSet& prescaleSet ) {
29 
30  TRG_MSG_INFO("loading L1 prescale set with PSK " << prescaleSet.id());
31 
32  CTPdataformatVersion ctpformat(ctpVersion);
33 
34  prescaleSet.resize(ctpformat.getMaxTrigItems());
35 
36  try {
37  startSession();
38  unique_ptr< coral::IQuery > q( m_session.nominalSchema().tableHandle( "L1_PRESCALE_SET").newQuery() );
39  q->setRowCacheSize( 5 );
40 
41  //Bind list
42  coral::AttributeList bindList;
43  bindList.extend<int>("psId");
44  std::string cond = "L1PS_ID = :psId";
45  bindList[0].data<int>() = prescaleSet.id();
46  q->setCondition( cond, bindList );
47 
48  //Output data and types
49  coral::AttributeList attList;
50  attList.extend<std::string>( "L1PS_NAME" );
51  attList.extend<int>( "L1PS_VERSION" );
52  attList.extend<std::string>( "L1PS_COMMENT" );
53  for (unsigned int ctpid = 0; ctpid < ctpformat.getMaxTrigItems(); ++ctpid) {
54  attList.extend<int64_t>( "L1PS_VAL" + std::to_string(ctpid+1) );
55  }
56  fillQuery(q.get(),attList);
57 
58  coral::ICursor& cursor = q->execute();
59 
60  if ( ! cursor.next() ) {
61  TRG_MSG_ERROR("No such prescaleset exists " << prescaleSet.id());
62  throw std::runtime_error( "PrescaleSetLoader >> PrescaleSet not available" );
63  }
64 
65  const coral::AttributeList& row = cursor.currentRow();
66  std::string name = row["L1PS_NAME"].data<std::string>();
67  int version = row["L1PS_VERSION"].data<int>();
68  std::string comment = row["L1PS_COMMENT"].data<std::string>();
69 
70  // fill the object with data
71  prescaleSet.setName( name );
72  prescaleSet.setVersion( version );
73  prescaleSet.setComment( comment );
74  for (unsigned int ctpid=0; ctpid < ctpformat.getMaxTrigItems(); ++ctpid) {
75  int64_t val = row["L1PS_VAL" +std::to_string(ctpid+1)].data<int64_t>();
76  if(isRun1()) {
77  float prescale = L1PSNumber(val).getFloatPrescale();
78  prescaleSet.setPrescale( ctpid, prescale );
79  } else {
80  prescaleSet.setCut(ctpid,val);
81  }
82  }
83 
84  commitSession();
85  return true;
86  }
87  catch( const coral::Exception& e ) {
88  TRG_MSG_ERROR("Coral::Exception: " << e.what());
89  throw;
90  }
91 
92  TRG_MSG_DEBUG("loaded L1 prescale set '" << prescaleSet.name() << "' (psk " << prescaleSet.id() << ")" );
93 
94  return true;
95 }
TrigConf::TrigConfData::setName
void setName(const std::string &name)
Definition: TrigConfData.h:30
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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::TrigConfData::name
const std::string & name() const
Definition: TrigConfData.h:22
TrigConf::L1PSNumber::getFloatPrescale
float getFloatPrescale() const
Definition: L1PSNumber.h:76
TrigConf::PrescaleSet
Definition: PrescaleSet.h:22
TrigConf::PrescaleSet::resize
void resize(size_t size)
Definition: PrescaleSet.cxx:80
DBHelper.h
TrigConf::fillQuery
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition: DBHelper.cxx:13
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
TrigConf::PrescaleSetLoader::load
virtual bool load(unsigned int ctpVersion, PrescaleSet &data) override
Definition: PrescaleSetLoader.cxx:28
L1PSNumber.h
TrigConf::PrescaleSet::setPrescale
void setPrescale(unsigned int num, int64_t prescaleValue) __attribute__((deprecated))
Set the prescale NUM from the int64 value prescaleValue.
Definition: PrescaleSet.cxx:166
PrescaleSetLoader.h
TrigConf::TrigConfData::setComment
void setComment(const std::string &c)
Definition: TrigConfData.h:32
TrigConf::L1PSNumber
Definition: L1PSNumber.h:33
TrigConf::PrescaleSet::setCut
void setCut(unsigned int num, int32_t cut)
Definition: PrescaleSet.cxx:96
TrigConf::name
Definition: HLTChainList.h:35
TRG_MSG_INFO
#define TRG_MSG_INFO(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:27
CaloCondBlobAlgs_fillNoiseFromASCII.comment
string comment
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:27
TrigConf::TrigConfData::id
unsigned int id() const
Definition: TrigConfData.h:21
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
get_generator_info.version
version
Definition: get_generator_info.py:33
query_example.cursor
cursor
Definition: query_example.py:21
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
TrigConf::TrigConfData::setVersion
void setVersion(unsigned int version)
Definition: TrigConfData.h:31
extractSporadic.q
list q
Definition: extractSporadic.py:98
TRG_MSG_DEBUG
#define TRG_MSG_DEBUG(x)
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStreamMacros.h:25