ATLAS Offline Software
Loading...
Searching...
No Matches
HLTFrameLoader.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "./HLTFrameLoader.h"
6#include "./HLTChainLoader.h"
9#include "./DBHelper.h"
10
14
15
16#include <CoralBase/Attribute.h>
17#include <CoralBase/AttributeList.h>
18
19#include "RelationalAccess/ITable.h"
20#include "RelationalAccess/ISchema.h"
21#include "RelationalAccess/ICursor.h"
22#include "RelationalAccess/IQuery.h"
23
24#include <iostream>
25#include <iomanip>
26#include <sstream>
27using namespace std;
28
29bool
31
32 unsigned int smk = frame.smk();
33 if(smk==0) return false;
34
35 TRG_MSG_INFO("Loading HLT menu for SMK " << smk);
36
37 typedef pair<unsigned int, unsigned int> lbnpsk_t;
38 vector<lbnpsk_t> reqested_prescale_keys = frame.getPrescaleSetCollection().prescale_keys();
39
40 // always start a clean HLTFrame
41 frame.clear();
42
43 // set the keys
44 frame.setSMK(smk);
45
46 try {
47 set<unsigned int> connected_psk = GetConnectedPSKs(smk);
48
49 loadSMT(frame);
50
52 seqldr.setLevel(outputLevel());
53 seqldr.load(frame);
54
56 chldr.setLevel(outputLevel());
57 chldr.load(frame);
58
59 // prescale set collection
60 bool all_connected(true);
61 TRG_MSG_INFO("Requested to load prescale sets: ");
62 for( lbnpsk_t lbnpsk: reqested_prescale_keys) {
63 unsigned int psk = lbnpsk.second;
64 bool is_connected = psk!=0 && connected_psk.find(psk)!=connected_psk.end();
65 TRG_MSG_INFO("LB " << setw(3) << right << lbnpsk.first << " : " << lbnpsk.second);
66 if(!is_connected) {
67 TRG_MSG_ERROR("prescale key " << lbnpsk.second << " is not connected to SMK");
68 all_connected = false;
69 }
70 }
71
72 if(all_connected) {
73 frame.thePrescaleSetCollection().set_prescale_keys_to_load( reqested_prescale_keys );
74
76 pssldr.setLevel(outputLevel());
77 //pssldr.setLevel(MSGTC::DEBUG);
78 pssldr.load(frame.thePrescaleSetCollection());
79
80
81
82 // by default assign the single prescale set
83 if(frame.getPrescaleSetCollection().size()==1) {
84 HLTPrescaleSet* singlePrescaleSet(frame.getPrescaleSetCollection().sets().begin()->pss);
85 // for backward compatibility we first copy the unconditional chain rerun prescale to the prescale set
86 for(HLTChain* ch: frame.theHLTChainList()) {
87 pair<bool, float> rrps = ch->rerun_prescale("");
88 if(rrps.first) {
89 singlePrescaleSet->thePrescale(ch->chain_counter(), ch->level_enum()).setRerunPrescale("",rrps.second);
90 }
91 }
92 frame.theHLTChainList().applyPrescaleSet(singlePrescaleSet);
93 }
94
95 } else {
96 TRG_MSG_ERROR("Not all requested HLT prescale keys are connected to the SMK");
97 stringstream s;
98 for(int psk: connected_psk) {
99 s << psk << ", ";
100 }
101 TRG_MSG_INFO("these HLT PSK are connected to SMK " << smk << ": " << s.str());
102 throw runtime_error("HLTFrameLoader: not all requested HLT prescale keys are connected to the SMK");
103 }
104
105 //merge chainlist
106 if( frame.mergedHLT() ) {
107 bool needMerging(false);
108 for( const TrigConf::HLTChain* chain : frame.getHLTChainList() ) {
109 if(chain->level_enum() != TrigConf::HLT)
110 needMerging = true;
111 }
112
113 if(needMerging) {
114 TRG_MSG_DEBUG("Call merging of " << frame.getHLTChainList().size() << " L2 and EF chains");
116 }
117 }
118
119 //frame.print();
120 }
121 catch (const std::exception& e) {
122 TRG_MSG_ERROR("exception " << e.what());
123 throw;
124 }
125
126
127
128 return true;
129}
130
131
132// load SM name, version, and description for SMK
133void
135 startSession();
136 unique_ptr< coral::IQuery > q( m_session.nominalSchema().tableHandle( "SUPER_MASTER_TABLE").newQuery() );
137
138 std::string cond = "SMT_ID = :smId";
139 coral::AttributeList bindings;
140 bindings.extend<int>("smId");
141 bindings[0].data<int>() = frame.smk();
142 q->setCondition( cond, bindings );
143
144 coral::AttributeList attList;
145 attList.extend<std::string>( "SMT_NAME" );
146 attList.extend<int> ( "SMT_VERSION" );
147 attList.extend<std::string>( "SMT_COMMENT" );
148 fillQuery(q.get(), attList);
149
150
151 coral::ICursor& cursor = q->execute();
152 while (cursor.next()) {
153 const coral::AttributeList& row = cursor.currentRow();
154 string name = row["SMT_NAME" ].data<std::string>();
155 int version = row["SMT_VERSION"].data<int>();
156 string comment = row["SMT_COMMENT"].data<std::string>();
157
158 frame.setName( name );
159 frame.setComment( comment );
160 frame.setVersion( version );
161 }
163}
164
165
166set<unsigned int>
168 set<unsigned int> connected_psks;
169
170 startSession();
171 unique_ptr< coral::IQuery > q( m_session.nominalSchema().newQuery() );
172
173 q->addToTableList( "SUPER_MASTER_TABLE", "SMT" );
174 q->addToTableList( "HLT_MASTER_TABLE", "HMT" );
175 q->addToTableList( "HLT_TRIGGER_MENU", "HTM" );
176 q->addToTableList( "HLT_TM_TO_PS", "HM2PS" );
177
178 coral::AttributeList bindings;
179 bindings.extend<int>("smid");
180 bindings[0].data<int>() = smk;
181
182 string theCondition("");
183 theCondition += string( " SMT.SMT_ID = :smid");
184 theCondition += string( " AND SMT.SMT_HLT_MASTER_TABLE_ID = HMT.HMT_ID" );
185 theCondition += string( " AND HMT.HMT_TRIGGER_MENU_ID = HTM.HTM_ID" );
186 theCondition += string( " AND HTM.HTM_ID = HM2PS.HTM2PS_TRIGGER_MENU_ID" );
187
188
189 q->setCondition( theCondition, bindings );
190
191 //Don't really want anything back, just want to see there is one entry
192 coral::AttributeList attList;
193 attList.extend<int>( "HM2PS.HTM2PS_PRESCALE_SET_ID" );
194 fillQuery(q.get(),attList);
195
196 coral::ICursor& cursor = q->execute();
197
198 while (cursor.next()) {
199 const coral::AttributeList& row = cursor.currentRow();
200 int psk = row["HM2PS.HTM2PS_PRESCALE_SET_ID"].data<int>();
201 connected_psks.insert(psk);
202 }
203
205
206 stringstream ss;
207 for(int psk : connected_psks)
208 ss << psk << ", ";
209
210 TRG_MSG_INFO( "To SMK " << smk << " connected HLT prescale keys are " << ss.str() );
211
212 return connected_psks;
213}
214
static Double_t ss
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
virtual void setLevel(MSGTC::Level lvl) override
access to output stream
Definition DBLoader.cxx:60
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
void applyPrescaleSet(const HLTPrescaleSet *pss)
set prescales of all chains
TriggerDB loader of the HLT signatures.
virtual bool load(HLTFrame &frame)
HLT chain configuration information.
virtual bool load(HLTFrame &data) override
std::set< unsigned int > GetConnectedPSKs(unsigned int smk)
void loadSMT(HLTFrame &frame)
The HLT trigger menu,.
Definition HLTFrame.h:33
HLTPrescaleSetCollection & thePrescaleSetCollection()
Definition HLTFrame.h:46
const HLTPrescaleSetCollection & getPrescaleSetCollection() const
Definition HLTFrame.h:51
bool mergedHLT() const
Definition HLTFrame.h:53
HLTChainList & theHLTChainList()
accessor to the list of HLT chains
Definition HLTFrame.h:44
void clear()
clear chains, sequences and prescales
Definition HLTFrame.cxx:32
const HLTChainList & getHLTChainList() const
const accessor to the list of HLT chains
Definition HLTFrame.h:49
virtual bool load(HLTPrescaleSetCollection &psc)
std::vector< std::pair< unsigned int, unsigned int > > prescale_keys() const
void set_prescale_keys_to_load(const std::vector< std::pair< unsigned int, unsigned int > > &)
size_t size() const
number of prescale sets
HLT chain configuration information.
HLTPrescale & thePrescale(unsigned int chain_counter, HLTLevel level)
HLTPrescale & setRerunPrescale(const std::string &targetName, float ps)
TriggerDB loader of the HLT signatures.
virtual bool load(HLTFrame &frame)
static void mergeHLTChainList2(TrigConf::HLTFrame &frame)
void setComment(const std::string &c)
void setName(const std::string &name)
unsigned int smk() const
void setVersion(unsigned int version)
void fillQuery(coral::IQuery *q, coral::AttributeList &attList)
Definition DBHelper.cxx:13
STL namespace.