ATLAS Offline Software
Loading...
Searching...
No Matches
HLTPrescaleSetCollectionLoader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "./DBHelper.h"
9
12
13#include <CoralBase/Attribute.h>
14#include <CoralBase/AttributeList.h>
15
16#include "RelationalAccess/SchemaException.h"
17#include "RelationalAccess/ITransaction.h"
18#include "RelationalAccess/ITable.h"
19#include "RelationalAccess/ISchema.h"
20#include "RelationalAccess/ICursor.h"
21#include "RelationalAccess/IQuery.h"
22
23#include <algorithm>
24#include <iostream>
25#include <sstream>
26#include <stdexcept>
27
28using namespace std;
29
30bool
32 unsigned int requestcounter,
33 const std::string& partition ) {
34 TRG_MSG_INFO("started loading data");
35
36 vector< pair<unsigned int, unsigned int> > lb_psk;
37
38 //Find if old or new schema is being used:
39 try {
41
42 unique_ptr< coral::IQuery > q( m_session.nominalSchema().newQuery() );
43
44 //Set the tables that are used
45 q->addToTableList ( "HLT_PRESCALE_SET_COLL", "PSC" );
46
47 //Bind list
48 coral::AttributeList bindings;
49 bindings.extend<uint>("req");
50 bindings.extend<string>("part");
51 bindings[0].data<uint>() = requestcounter;
52 bindings[1].data<string>() = partition;
53
54 string theCondition = "HPSC_PARTITION=:part and :req>=0";
55
56 q->setCondition( theCondition, bindings );
57
58 //Output data and types
59 coral::AttributeList attList;
60 attList.extend<int>( "PSC.HPSC_LB" );
61 attList.extend<int>( "PSC.HPSC_HLTPSK" );
62 fillQuery(q.get(), attList);
63
64 // the ordering
65 q->addToOrderList( "PSC.HPSC_LB" );
66
67 // process the query
68 // query->setRowCacheSize(20);
69 q->setDistinct();
70
71 coral::ICursor& cursor = q->execute();
72
73 // fill chain info list
74 while (cursor.next()) {
75 const coral::AttributeList& row = cursor.currentRow();
76 int lb = row["PSC.HPSC_LB"].data<int>();
77 int psk = row["PSC.HPSC_HLTPSK"].data<int>();
78 lb_psk.push_back( make_pair(lb, psk) );
79 }
80
81 TRG_MSG_INFO("LB_PSK map for partition " << partition);
82 for(uint i=0; i< lb_psk.size(); i++) {
83 TRG_MSG_INFO("For LB " << lb_psk[i].first << " onwards load psk " << lb_psk[i].second);
84 }
86 }
87 catch (const std::exception& e) {
88 TRG_MSG_ERROR("HLTPrescaleSetCollectionLoader: caught exception: " << e.what());
89 throw;
90 }
91
92 pscoll.set_prescale_keys_to_load( lb_psk );
93
94 return load(pscoll);
95}
96
97
98
99bool
101
102 IHLTPrescaleSetLoader& pssloader = m_storageMgr.hltPrescaleSetLoader();
103 pssloader.setLevel(outputLevel());
104
105 bool loadsuccess = true;
106
107 for(HLTPrescaleSetCollection::cont& psinfo: psc.sets()) {
108
109 // already loaded?
110 if(psinfo.pss!=0) continue;
111
112 // create new prescale set and load it
113 psinfo.pss = new HLTPrescaleSet();
114 psinfo.pss->setId(psinfo.psk);
115 bool loadpss = pssloader.load(*psinfo.pss);
116
117 if(!loadpss) {
118 TRG_MSG_ERROR("HLTPrescaleSetCollectionLoader::load(): Could not load HLT Prescales for key " << psinfo.psk);
119 loadsuccess = false;
120 }
121 }
122
123 return loadsuccess;
124}
125
unsigned int uint
StorageMgr & m_storageMgr
reference to the storage manager
Definition DBLoader.h:67
virtual MSGTC::Level outputLevel() const override
Definition DBLoader.h:40
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
virtual bool load(HLTPrescaleSetCollection &psc)
HLT chain configuration information.
void set_prescale_keys_to_load(const std::vector< std::pair< unsigned int, unsigned int > > &)
HLT chain configuration information.
virtual bool load(HLTPrescaleSet &hltpss)=0
virtual void setLevel(MSGTC::Level lvl)=0
Load the configuration data from the configuration source.
int lb
Definition globals.cxx:23
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition DBHelper.cxx:13
Definition Config.h:26
STL namespace.
DataModel_detail::iterator< DVL > partition(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of partition for DataVector/List.