ATLAS Offline Software
Loading...
Searching...
No Matches
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
25using namespace std;
26
27bool
28TrigConf::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 {
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
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}
void commitSession()
commit session if not already done
Definition DBLoader.cxx:45
coral::ISessionProxy & m_session
CORAL interface to database session.
Definition DBLoader.h:68
void startSession()
start session if not already active
Definition DBLoader.cxx:35
float getFloatPrescale() const
Definition L1PSNumber.h:76
virtual bool load(unsigned int ctpVersion, PrescaleSet &data) override
void setPrescale(unsigned int num, int64_t prescaleValue) __attribute__((deprecated))
Set the prescale NUM from the int64 value prescaleValue.
void setCut(unsigned int num, int32_t cut)
void resize(size_t size)
unsigned int id() const
void setComment(const std::string &c)
void setName(const std::string &name)
const std::string & name() const
void setVersion(unsigned int version)
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition DBHelper.cxx:13
STL namespace.