ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConfCoolHLTPayloadConverters.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7
8#include "CoolKernel/Record.h"
9#include "CoolKernel/IFolder.h"
10#include "CoralBase/Attribute.h"
11#include "CoralBase/AttributeList.h"
12
14
22
23using namespace std;
24using namespace cool;
25using namespace TrigConf;
26
28TrigConfCoolHLTPayloadConverters::createHltMenuPayload(cool::IFolderPtr fld, const HLTChain & ch, const string& concise ) {
29 Record payload(fld->payloadSpecification());
30 payload["ChainName"] .setValue<cool::String255>(ch.chain_name());
31 payload["ChainVersion"] .setValue<cool::UInt32>(ch.chain_version());
32 payload["ChainCounter"] .setValue<cool::UInt32>(ch.chain_counter());
33 payload["TriggerLevel"] .setValue<cool::String255>(ch.level());
34 payload["Prescale"] .setValue<cool::Float>(ch.prescale());
35 payload["PassThrough"] .setValue<cool::Float>(ch.pass_through());
36 payload["TriggerElements"].setValue<cool::String4k>(concise);
37 if(payload["LowerChainName"].storageType()==cool::StorageType::String4k) {
38 payload["LowerChainName"].setValue<cool::String4k>(ch.lower_chain_name());
39 } else {
40 payload["LowerChainName"].setValue<cool::String255>(ch.lower_chain_name());
41 }
42
43 // stream info
44 stringstream streamCat;
45 bool first(true);
46 for(HLTStreamTag* stream : ch.streams()) {
47 if(first) { first = false; } else { streamCat << ";"; }
48 streamCat << stream->stream() << "," << stream->type() << "," << stream->prescale();
49 }
50 payload["StreamInfo"].setValue<cool::String255>(streamCat.str());
51
52 return payload;
53}
54
55
58 Record payload(fld->payloadSpecification());
59 string groups(ch.level());
60 groups += ";";
61 bool start(true);
62 for(const string& group : ch.groups()) {
63 if(start) { start=false; } else { groups += ","; }
64 groups += group;
65 }
66 payload["Groups"].setValue<cool::String4k>(groups);
67 payload["ChainCounter"].setValue<cool::UInt32>(ch.chain_counter());
68 return payload;
69}
70
71
74 uint hltPrescaleKey, const string& configSource ) {
75 Record payload(fld->payloadSpecification());
76 payload["MasterConfigurationKey"].setValue<cool::UInt32>(masterKey);
77 payload["HltPrescaleConfigurationKey"].setValue<cool::UInt32>(hltPrescaleKey);
78 payload["ConfigSource"].setValue<cool::String255>(configSource);
79 return payload;
80}
81
83TrigConfCoolHLTPayloadConverters::createMonConfigKeyPayload(cool::IFolderPtr fld, uint mck, string& info ) {
84 Record payload(fld->payloadSpecification());
85 payload["MonConfigKey"].setValue<cool::UInt32>(mck);
86 payload["Info"].setValue<cool::String4k>(info);
87 return payload;
88}
89
92 float passthrough, float rerunprescale) {
93 Record payload(fld->payloadSpecification());
94 payload["Prescale"].setValue<cool::Float>(prescale);
95 payload["Passthrough"].setValue<cool::Float>(passthrough);
96 payload["RerunPrescale"].setValue<cool::Float>(rerunprescale);
97 return payload;
98}
99
100
101Record
103 Record payload(fld->payloadSpecification());
104 payload["HltPrescaleKey"].setValue<cool::UInt32>(psk);
105 return payload;
106}
107
108
109HLTChain *
110TrigConfCoolHLTPayloadConverters::createHLTChain( const coral::AttributeList & al, HLTSequenceList* sequences ) {
112
113 // this information of a chain is not in COOL:
114 // int lower_chain_counter, vector<HLTTriggerType*>& trigList
115
116 ch->set_chain_name ( al["ChainName"]. data<cool::String255>() );
117 ch->set_chain_version ( al["ChainVersion"]. data<cool::UInt32>() );
118 ch->set_chain_counter ( al["ChainCounter"]. data<cool::UInt32>() );
119 ch->set_level ( al["TriggerLevel"]. data<cool::String255>() );
120 if( typeid(cool::UInt32) == al["Prescale"].specification().type()) {
121 ch->set_prescale ( al["Prescale"]. data<cool::UInt32>() );
122 ch->set_pass_through ( al["PassThrough"]. data<cool::UInt32>() );
123 } else if( typeid(cool::Float) == al["Prescale"].specification().type()) {
124 ch->set_prescale ( al["Prescale"]. data<cool::Float>() );
125 ch->set_pass_through ( al["PassThrough"]. data<cool::Float>() );
126 }
127 if(al["LowerChainName"].specification().type()==typeid(cool::String4k)) {
128 ch->set_lower_chain_name( al["LowerChainName"].data<cool::String4k>() );
129 } else {
130 ch->set_lower_chain_name( al["LowerChainName"].data<cool::String255>() );
131 }
132 // read the trigger elements
133 string fullTeString = al["TriggerElements"].data<cool::String4k>();
134
135 if(fullTeString.find("|")==string::npos ) {
136 // old style
137 int sc(0); // signature counter
138 vector<string> singleSigStrings = split(fullTeString,";");
139 for(const string& sigdef : singleSigStrings ) {
140 if(sigdef=="") { ++sc; continue; } // empty signature (when signaturCounter is not continuious)
141 // the information available in the signature will be the signature counter and the list of TEs
142 HLTSignature * signature = new HLTSignature();
143 ch->signatureList().push_back(signature);
144 signature->set_signature_counter(++sc);
145
146 vector<string> teStrings = split(sigdef,",");
147 for( const string& te : teStrings) {
148 HLTTriggerElement * outte = new HLTTriggerElement( te );
149 signature->outputTEs().push_back( outte );
150 if(sequences && !sequences->hasTE(te) )
151 sequences->addHLTSequence(new HLTSequence( vector<HLTTriggerElement*>(), outte, vector<string>()) );
152 }
153 }
154 } else {
155
156 // new style
157 vector<string> singleSigStrings = split(fullTeString,"|");
158 if(singleSigStrings.size()==2) {
159
160 // the part in front of the '|'
161 vector< string > splitRecursive = HLTTEUtils::splitGroups( singleSigStrings[0] );
162 for( string outtename : splitRecursive ) {
163 if(outtename.find(',')!=string::npos)
164 outtename.erase(0,outtename.rfind(',')+1);
165
166 if(sequences && !sequences->hasTE(outtename)) {
167 HLTSequence* seq = HLTTEUtils::buildSequence( outtename );
168 sequences->addHLTSequence( seq );
169 }
170 }
171
172 // the part after the '|'
173 int sc(0); // signature counter
174 vector<string> signatureDesc = split(singleSigStrings[1],";");
175 for(const string& sigdef : signatureDesc) {
176 if(sigdef=="") { sc++; continue; } // empty signature (when signaturCounter is not continous)
177 // the information available in the signature will be the signature counter and the list of TEs
178 HLTSignature * signature = new HLTSignature();
179 ch->signatureList().push_back(signature);
180 signature->set_signature_counter(++sc);
181
182 vector<string> sequenceDescriptions = HLTTEUtils::splitGroups(sigdef);
183 for(string outtename : sequenceDescriptions) {
184
185 if(outtename.find(',') != string::npos)
186 outtename.erase(0,outtename.rfind(',')+1);
187
188 HLTTriggerElement * outte = new HLTTriggerElement( outtename );
189 signature->outputTEs().push_back( outte );
190 if(sequences && !sequences->hasTE(outtename)) {
191 HLTSequence* seq = HLTTEUtils::buildSequence(outtename);
192 sequences->addHLTSequence( seq );
193 }
194 }
195 }
196 }
197 } // new style
198
199 // read the stream tag info
200 string fullStreamString = al["StreamInfo"].data<cool::String255>();
201 vector<string> singleStreams = split( fullStreamString, ";" );
202
203 for( const string& stream_def : singleStreams ) {
204 HLTStreamTag * stream = new HLTStreamTag();
205 vector<string> streamInfo = split(stream_def,",");
206 if(streamInfo.size()==2) {
207 stream->set_stream(streamInfo[0]); // old version: name,prescale
208 stream->set_prescale(atoi(streamInfo[1].c_str()));
209 } else if(streamInfo.size()==3) { // new version: name,type,version
210 stream->set_stream(streamInfo[0]);
211 stream->set_type(streamInfo[1]);
212 stream->set_prescale(atoi(streamInfo[2].c_str()));
213 }
214 ch->addStream(stream);
215 }
216
217 return ch;
218}
219
220
221void
223 const HLTChainList& chl)
224{
225 int cc = al["ChainCounter"].data<cool::UInt32>();
226 vector<string> lvlGrp = split(al["Groups"].data<cool::String4k>(),";");
227 string level = lvlGrp[0];
228 if(lvlGrp.size()==2) {
229 vector<string> grV = split(lvlGrp[1],",");
230 for(HLTChain* ch : chl) {
231 if( ch->chain_counter()==cc && ch->level()==level) {
232 for(const string& gr : grV) ch->addGroup(gr);
233 break;
234 }
235 }
236 }
237}
238
239
240void
241TrigConfCoolHLTPayloadConverters::readHltConfigKeys( const coral::AttributeList & al, unsigned int & masterConfigKey,
242 unsigned int & hltPrescaleKey, string & configSource)
243{
244 masterConfigKey = al["MasterConfigurationKey"].data<cool::UInt32>();
245 hltPrescaleKey = al["HltPrescaleConfigurationKey"].data<cool::UInt32>();
246 configSource = al["ConfigSource"].data<cool::String255>();
247}
248
249
250void
252 float& ps, float& pt, float& rrps)
253{
254 ps = al["Prescale"].data<cool::Float>();
255 pt = al["Passthrough"].data<cool::Float>();
256 rrps = al["RerunPrescale"].data<cool::Float>();
257}
258
259
260int
262{
263 return al["HltPrescaleKey"].data<cool::UInt32>();
264}
265
#define gr
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
unsigned int uint
static Double_t al
static Double_t sc
list of all HLT chains in a trigger menu
HLT chain configuration information.
list of HLT sequences
bool hasTE(const std::string &name)
void addHLTSequence(HLTSequence *sequence)
adds an HLTSequence to the menu
HLT sequence configuration information.
Definition HLTSequence.h:28
HLT signature configuration information.
std::vector< HLTTriggerElement * > & outputTEs()
accessor to the list of trigger elements
void set_signature_counter(unsigned int sc)
HLT stream configuration information.
static std::vector< std::string > splitGroups(const std::string &s)
static HLTSequence * buildSequence(const std::string &desc)
HLT trigger element configuration information.
cool::Record createHltPrescaleKeyPayload(cool::IFolderPtr, int psk)
build a COOL db record from a HLT prescale value
cool::Record createHltPrescalesPayload(cool::IFolderPtr, float prescale, float passthrough, float rerunprescale)
build a COOL db record from a HLT prescale value
int readHltPrescaleKey(const coral::AttributeList &al)
build the HLT prescale key from a COOL db record
void readHltPrescale(const coral::AttributeList &al, float &ps, float &pt, float &rrps)
build the HLT prescale value from a COOL db record
cool::Record createHltChainGroupPayload(cool::IFolderPtr, const TrigConf::HLTChain &ch)
build a COOL db record from a HLT chain
cool::Record createMonConfigKeyPayload(cool::IFolderPtr fld, uint MCK, std::string &info)
build a COOL db record from a HLT monitoring configuration key
void addGroupsToHltChain(const coral::AttributeList &al, const TrigConf::HLTChainList &chl)
add the groups to and HLT chain from a AttributeList
void readHltConfigKeys(const coral::AttributeList &al, unsigned int &masterConfigKey, unsigned int &hltPrescaleKey, std::string &configSource)
read the HLT configuration keys from a coral::AttributeList
cool::Record createHltConfigKeysPayload(cool::IFolderPtr, unsigned int masterKey, unsigned int hltPrescaleKey, const std::string &configSource)
build a COOL db record from a set of HLT configuration keys
HLTChain * createHLTChain(const coral::AttributeList &al, TrigConf::HLTSequenceList *sequences=0)
build an HLT chain from a COOL db record
cool::Record createHltMenuPayload(cool::IFolderPtr, const TrigConf::HLTChain &, const std::string &concise)
build a COOL db record from a HLT chain
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
std::vector< std::string > split(const std::string &line, const std::string &del=" ")
STL namespace.