ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConfCoolFolderSpec.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <iomanip>
8#include <stdexcept>
9
10#include "CoolKernel/IFolder.h"
11#include "CoolKernel/IDatabase.h"
12#include "CoolKernel/FolderSpecification.h"
13
14using namespace std;
15using namespace cool;
16using namespace TrigConf;
17
18// Size of BLOB used for ItemToBunchGroup map; BLOBs are cheap, in case
19// we want to add information later on like more complicated logic /
20// also OR's, we can easily increase the size here
22
23// BLOB size of BG content is the number of LHC bunches
25
27
28// ------------------------------------------------------------
29// readSchemaVersion
30// ------------------------------------------------------------
31int
33
34 // version 4:
35 // L1 prescales are Int64
36
37 const IFolderPtr & l1prescaleFolder = db->getFolder("/TRIGGER/LVL1/Prescales");
38 const IRecordSpecification & l1psSpec = l1prescaleFolder->payloadSpecification();
39 const IFieldSpecification& l1psfield = l1psSpec["Lvl1Prescale"];
40 if(l1psfield.storageType() == StorageType::Int64) {
41 return 4;
42 }
43
44 const IFolderPtr & hltMenuFolder = db->getFolder("/TRIGGER/HLT/Menu");
45 const IRecordSpecification & hltMenuSpec = hltMenuFolder->payloadSpecification();
46
47 if(hltMenuSpec.exists("Prescale")) {
48
49 const IFieldSpecification& lowChNField = hltMenuSpec["LowerChainName"];
50
51 // version 3:
52 // hlt menu has long (4000 char) lower chain name field
53 if(lowChNField.storageType() == StorageType::String4k) {
54 return 3;
55 }
56
57 const IFieldSpecification& psField = hltMenuSpec["Prescale"];
58
59 // version 1:
60 // hlt menu has integer prescale and pass_through values
61 if(psField.storageType() == StorageType::UInt32) {
62 return 1;
63 }
64
65 // version 2:
66 // hlt menu has float prescale and pass_through values
67 if(psField.storageType() == StorageType::Float) {
68 return 2;
69 }
70 }
71
72 // should never happen
73 throw runtime_error("Could not determine the COOL schema of the TriggerDB");
74
75 return -1;
76}
77
78// --------------------------------------------------------------------------------
79
80RecordSpecification
84
87 cool::RecordSpecification rspec;
88 rspec.extend( "ItemName", StorageType::String255 );
89 rspec.extend( "ItemVersion", StorageType::UInt32 );
90 FolderDefinition fd( "/TRIGGER/LVL1/Menu",
91 FolderVersioning::SINGLE_VERSION, rspec);
92 return fd;
93}
94
95// --------------------------------------------------------------------------------
96
97RecordSpecification
101
104 cool::RecordSpecification rspec;
105
106 rspec.extend( "Logic", StorageType::String255 );
107 rspec.extend( "ConditionsList", StorageType::String4k );
108 FolderDefinition fd( "/TRIGGER/LVL1/ItemDef",
109 FolderVersioning::SINGLE_VERSION,rspec);
110 return fd;
111}
112
113// --------------------------------------------------------------------------------
114
115RecordSpecification
119
122 cool::RecordSpecification rspec;
123 rspec.extend( "Threshold", StorageType::String255 );
124 rspec.extend( "ThresholdValue", StorageType::String4k );
125 rspec.extend( "Cable", StorageType::String255 );
126 FolderDefinition fd( "/TRIGGER/LVL1/Thresholds",
127 FolderVersioning::SINGLE_VERSION,rspec);
128 return fd;
129}
130
131// --------------------------------------------------------------------------------
132
133RecordSpecification
137
140 cool::RecordSpecification rspec;
141 rspec.extend( "Lvl1PrescaleConfigurationKey", StorageType::UInt32 );
142 FolderDefinition fd( "/TRIGGER/LVL1/Lvl1ConfigKey",
143 FolderVersioning::MULTI_VERSION,rspec);
144 return fd;
145}
146
147// --------------------------------------------------------------------------------
148
149RecordSpecification
153
156 cool::RecordSpecification rspec;
157 if(schemaVersion<4) {
158 rspec.extend( "Lvl1Prescale", StorageType::Int32 );
159 } else if(schemaVersion>=4) {
160 rspec.extend( "Lvl1Prescale", StorageType::Int64 );
161 }
162 FolderDefinition fd( "/TRIGGER/LVL1/Prescales",
163 FolderVersioning::MULTI_VERSION,rspec);
164 return fd;
165}
166
167// --------------------------------------------------------------------------------
168
169RecordSpecification
173
176 cool::RecordSpecification rspec;
177 rspec.extend( "ThresholdName", StorageType::String255 );
178 rspec.extend( "CtpinSlot", StorageType::UChar );
179 rspec.extend( "CtpinConnector", StorageType::UChar );
180 rspec.extend( "ThresholdBit", StorageType::UChar );
181 rspec.extend( "CableBit", StorageType::UChar );
182 rspec.extend( "ThresholdMapping", StorageType::UChar );
183 rspec.extend( "ThresholdActive", StorageType::Bool );
184 FolderDefinition fd( "/TRIGGER/LVL1/CTPCoreInputMapping",
185 FolderVersioning::SINGLE_VERSION,rspec);
186 return fd;
187}
188
189// --------------------------------------------------------------------------------
190
191RecordSpecification
195
198 cool::RecordSpecification rspec;
199 rspec.extend( "Lvl1BunchGroupConfigurationKey", StorageType::UInt32 );
200 FolderDefinition fd( "/TRIGGER/LVL1/BunchGroupKey",
201 FolderVersioning::MULTI_VERSION,rspec);
202 return fd;
203}
204
205// --------------------------------------------------------------------------------
206
207RecordSpecification
211
214 cool::RecordSpecification rspec;
215 rspec.extend( "BunchCode" , StorageType::Blob64k );
216 FolderDefinition fd( "/TRIGGER/LVL1/BunchGroupContent",
217 FolderVersioning::MULTI_VERSION,rspec);
218 return fd;
219}
220
221// --------------------------------------------------------------------------------
222
223RecordSpecification
227
230 cool::RecordSpecification rspec;
231 rspec.extend( "BunchGroup0", StorageType::String255 );
232 rspec.extend( "BunchGroup1", StorageType::String255 );
233 rspec.extend( "BunchGroup2", StorageType::String255 );
234 rspec.extend( "BunchGroup3", StorageType::String255 );
235 rspec.extend( "BunchGroup4", StorageType::String255 );
236 rspec.extend( "BunchGroup5", StorageType::String255 );
237 rspec.extend( "BunchGroup6", StorageType::String255 );
238 rspec.extend( "BunchGroup7", StorageType::String255 );
239 rspec.extend( "BunchGroup8", StorageType::String255 );
240 rspec.extend( "BunchGroup9", StorageType::String255 );
241 rspec.extend( "BunchGroup10", StorageType::String255 );
242 rspec.extend( "BunchGroup11", StorageType::String255 );
243 rspec.extend( "BunchGroup12", StorageType::String255 );
244 rspec.extend( "BunchGroup13", StorageType::String255 );
245 rspec.extend( "BunchGroup14", StorageType::String255 );
246 rspec.extend( "BunchGroup15", StorageType::String255 );
247 rspec.extend( "ItemToBunchGroupMap" ,StorageType::Blob64k );
248 FolderDefinition fd( "/TRIGGER/LVL1/BunchGroupDescription",
249 FolderVersioning::SINGLE_VERSION,rspec);
250 return fd;
251}
252
253// --------------------------------------------------------------------------------
254
255RecordSpecification
259
262 cool::RecordSpecification rspec;
263 rspec.extend( "ChainName", StorageType::String255 );
264 rspec.extend( "ChainVersion", StorageType::UInt32 );
265 rspec.extend( "ChainCounter", StorageType::UInt32 );
266 rspec.extend( "TriggerLevel", StorageType::String255 );
267 rspec.extend( "LowerChainName", StorageType::String4k );
268 rspec.extend( "Prescale", StorageType::Float );
269 rspec.extend( "PassThrough", StorageType::Float );
270 rspec.extend( "TriggerElements", StorageType::String4k );
271 rspec.extend( "StreamInfo", StorageType::String255 );
272 FolderDefinition fd( "/TRIGGER/HLT/Menu",
273 FolderVersioning::SINGLE_VERSION,rspec);
274 return fd;
275}
276
277// --------------------------------------------------------------------------------
278
279RecordSpecification
283
286 cool::RecordSpecification rspec;
287 rspec.extend( "ChainCounter", StorageType::UInt32 );
288 rspec.extend( "Groups", StorageType::String4k );
289 FolderDefinition fd( "/TRIGGER/HLT/Groups",
290 FolderVersioning::SINGLE_VERSION,rspec);
291 return fd;
292}
293
294// --------------------------------------------------------------------------------
295
296RecordSpecification
300
303 cool::RecordSpecification rspec;
304 rspec.extend( "MasterConfigurationKey", StorageType::UInt32 );
305 rspec.extend( "HltPrescaleConfigurationKey", StorageType::UInt32 );
306 rspec.extend( "ConfigSource", StorageType::String255 );
307 FolderDefinition fd( "/TRIGGER/HLT/HltConfigKeys",
308 FolderVersioning::SINGLE_VERSION,rspec);
309 return fd;
310}
311
312// --------------------------------------------------------------------------------
313
314RecordSpecification
318
321 cool::RecordSpecification rspec;
322 rspec.extend( "Prescale", StorageType::Float );
323 rspec.extend( "Passthrough", StorageType::Float );
324 rspec.extend( "RerunPrescale", StorageType::Float );
325 FolderDefinition fd( "/TRIGGER/HLT/Prescales",
326 FolderVersioning::MULTI_VERSION,rspec);
327 return fd;
328}
329
330// --------------------------------------------------------------------------------
331
332RecordSpecification
336
339 cool::RecordSpecification rspec;
340 rspec.extend( "HltPrescaleKey", StorageType::UInt32 );
341 FolderDefinition fd( "/TRIGGER/HLT/PrescaleKey",
342 FolderVersioning::MULTI_VERSION,rspec);
343 return fd;
344}
345
346// --------------------------------------------------------------------------------
347
348
349// ------------------------------------------------------------
350// createLvl1MonMapFolderSpecification()
351// ------------------------------------------------------------
352RecordSpecification
356
359 RecordSpecification rspec;
360 rspec.extend( "CounterType", StorageType::String255 );
361 rspec.extend( "BunchGroupId", StorageType::UChar );
362 rspec.extend( "ThresholdName", StorageType::String255 );
363 rspec.extend( "CtpinSlot", StorageType::String255 );
364 rspec.extend( "CtpinConnector", StorageType::String255 );
365 rspec.extend( "Multiplicity", StorageType::String255 );
366 rspec.extend( "ThresholdBitStart", StorageType::String255 );
367 rspec.extend( "ThresholdBitEnd", StorageType::String255 );
368 rspec.extend( "ThresholdActive", StorageType::String255 );
369 rspec.extend( "CounterName", StorageType::String255 );
370 rspec.extend( "CounterLogic", StorageType::String255 );
371 FolderDefinition fd("/TRIGGER/LVL1/CTPInMonitoringMapping",
372 FolderVersioning::SINGLE_VERSION, rspec);
373 return fd;
374}
375
376
377
378
379bool
380TrigConfCoolFolderSpec::CreateFolderIfNotExist(IDatabasePtr db, const string& folder, const IRecordSpecification& spec, FolderVersioning::Mode mode, bool isMultiChannel) {
381
382 cool::RecordSpecification rspec;
383 rspec.extend(spec);
384 FolderDefinition fd(folder, mode,rspec);
385 return CreateFolderIfNotExist(std::move(db), std::move(fd), isMultiChannel);
386}
387
388
389bool
390TrigConfCoolFolderSpec::CreateFolderIfNotExist(IDatabasePtr db, FolderDefinition fd, bool isMultiChannel) {
391
392 static const string singleChannelDesc = "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"40774348\" /></addrHeader><typeName>AthenaAttributeList</typeName>";
393 static const string multiChannelDesc = "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\" /></addrHeader><typeName>CondAttrListCollection</typeName>";
394
395 if( db->existsFolder( fd.folder ) )
396 return false;
397
398 const string & description = isMultiChannel ? multiChannelDesc : singleChannelDesc;
399
400 bool createParents = true;
401
402 IFolderPtr ptr = db->createFolder( fd.folder, fd.fspec, description, createParents );
403
404 return true;
405}
406
407
408
409
410
411// ------------------------------------------------------------
412// createFolderStructure()
413// ------------------------------------------------------------
414IFolderSetPtr
415TrigConfCoolFolderSpec::createFolderStructure(IDatabasePtr db, int schemaVersion) {
416
417 if(schemaVersion==0) schemaVersion = getDefaultSchemaVersion();
418
419 std::string singleChannelDesc = "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"40774348\" /></addrHeader><typeName>AthenaAttributeList</typeName>";
420 std::string multiChannelDesc = "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\" /></addrHeader><typeName>CondAttrListCollection</typeName>";
421 //std::string timeDesc = "<timeStamp>time</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"40774348\" /></addrHeader><typeName>AthenaAttributeList</typeName>";
422
423 bool newFolder = false;
424
425 static const bool singleChannel(false);
426 static const bool multiChannel(true);
427
428 IFolderSetPtr topFolder;
429 if( !db->existsFolderSet( "/TRIGGER" ) ) {
430 newFolder = true;
431 topFolder = db->createFolderSet( "/TRIGGER" );
432 }
433 if( !db->existsFolderSet( "/TRIGGER/LVL1" ) ) {
434 newFolder = true;
435 db->createFolderSet( "/TRIGGER/LVL1" );
436 }
437 if( !db->existsFolderSet( "/TRIGGER/HLT" ) ) {
438 newFolder = true;
439 db->createFolderSet( "/TRIGGER/HLT" );
440 }
441
442 newFolder |= CreateFolderIfNotExist(db, Lvl1MenuFolderDefinition(), multiChannel);
443
444 newFolder |= CreateFolderIfNotExist(db, Lvl1ItemDefFolderDefinition(), multiChannel);
445
446 newFolder |= CreateFolderIfNotExist(db, Lvl1ThresholdFolderDefinition(), multiChannel);
447
448 newFolder |= CreateFolderIfNotExist(db, Lvl1ConfigKeysFolderDefinition(), singleChannel);
449
450 newFolder |= CreateFolderIfNotExist(db, Lvl1PrescalesFolderDefinition(schemaVersion), multiChannel);
451
452 newFolder |= CreateFolderIfNotExist(db, Lvl1BGKeyFolderDefinition(), singleChannel);
453
454 newFolder |= CreateFolderIfNotExist(db, Lvl1BGContentFolderDefinition(), singleChannel);
455
456 newFolder |= CreateFolderIfNotExist(db, Lvl1BGDescFolderDefinition(), singleChannel);
457
458 newFolder |= CreateFolderIfNotExist(db, Lvl1InputMapFolderDefinition(), multiChannel);
459
460 newFolder |= CreateFolderIfNotExist(db, HltConfigKeysFolderDefinition(), singleChannel);
461
462 newFolder |= CreateFolderIfNotExist(db, HltMenuFolderDefinition(), multiChannel);
463
464 newFolder |= CreateFolderIfNotExist(db, HltChainGroupFolderDefinition(), multiChannel);
465
466 newFolder |= CreateFolderIfNotExist(db, HltPrescalesFolderDefinition(), multiChannel);
467
468 newFolder |= CreateFolderIfNotExist(db, HltPrescaleKeyFolderDefinition(), singleChannel);
469
470 if(newFolder) printFolderStructure(std::move(db), cout);
471
472 return topFolder;
473}
474
475IFolderSetPtr
476TrigConfCoolFolderSpec::createMonFolderStructure(IDatabasePtr db, int /*schemaVersion*/) {
477
478 bool multiChannel(true);
479
480
481 bool newFolder = CreateFolderIfNotExist(db, Lvl1MonMapFolderSpecification(), multiChannel);
482 if(newFolder)
483 printFolderStructure(db, cout);
484
485 return db->getFolderSet( "/TRIGGER" );
486}
487
488
489
490
491// ------------------------------------------------------------
492// folder accessors
493// ------------------------------------------------------------
494
495IFolderPtr TrigConfCoolFolderSpec::getLvl1MenuFolder(IDatabasePtr db) {
496 return db->getFolder( "/TRIGGER/LVL1/Menu" );
497}
498
500 return db->getFolder( "/TRIGGER/LVL1/ItemDef" );
501}
502
504 return db->getFolder( "/TRIGGER/LVL1/Thresholds" );
505}
506
508 return db->getFolder( "/TRIGGER/LVL1/Lvl1ConfigKey" );
509}
510
512 return db->getFolder( "/TRIGGER/LVL1/Prescales" );
513}
514
516 return db->getFolder( "/TRIGGER/LVL1/BunchGroupKey" );
517}
518
520 return db->getFolder( "/TRIGGER/LVL1/BunchGroupContent" );
521}
522
524 return db->getFolder( "/TRIGGER/LVL1/BunchGroupDescription" );
525}
526
528 return db->getFolder( "/TRIGGER/LVL1/CTPCoreInputMapping" );
529}
530
532 return db->getFolder( "/TRIGGER/LVL1/CTPInMonitoringMapping" );
533}
534
535IFolderPtr TrigConfCoolFolderSpec::getHltMenuFolder(IDatabasePtr db) {
536 return db->getFolder( "/TRIGGER/HLT/Menu" );
537}
538
540 return db->getFolder( "/TRIGGER/HLT/Groups" );
541}
542
544 return db->getFolder( "/TRIGGER/HLT/HltConfigKeys" );
545}
546
548 return db->getFolder( "/TRIGGER/HLT/MenuAwareMonConfigKey" );
549}
550
552 return db->getFolder( "/TRIGGER/HLT/Prescales" );
553}
554
556 return db->getFolder( "/TRIGGER/HLT/PrescaleKey" );
557}
558
559
560// ------------------------------------------------------------
561// printFolderStructure(IDatabasePtr db)
562// ------------------------------------------------------------
563void
564TrigConfCoolFolderSpec::printFolderStructure(IDatabasePtr db, std::ostream & o)
565{
566
567 for(const string& node : db->listAllNodes()) {
568 bool isFolderSet = db->existsFolderSet(node);
569 o << " " << node;
570 if(isFolderSet)
571 o << "/" << endl;
572 else {
573 IFolderPtr folder = db->getFolder(node);
574 bool isMultiVersion = (folder->versioningMode() == FolderVersioning::MULTI_VERSION);
575 const IRecordSpecification& rspec = folder->payloadSpecification();
576 o << " (" << (isMultiVersion?"Multiversion":"Singleversion") << ")" << endl;
577 o.setf(ios::left);
578 for(uint i=0;i<rspec.size(); i++) {
579 o << " " << setw(30) << rspec[i].name()
580 << " (" << rspec[i].storageType().name() << ")" << endl;
581 }
582 }
583 }
584 return;
585}
586
unsigned int uint
cool::RecordSpecification & rspec()
static cool::RecordSpecification createHltMenuFolderSpecification()
defines the folder structure for the HLT menu
static FolderDefinition HltPrescalesFolderDefinition()
static cool::IFolderSetPtr createMonFolderStructure(cool::IDatabasePtr db, int schemaVersion=0)
creates the folder structure in the monitoring COOL database
static cool::RecordSpecification createLvl1InputMapFolderSpecification()
defines the folder structure for the LVL1 CTP input map
static cool::RecordSpecification createLvl1MonMapFolderSpecification()
defines the folder structure for the LVL1 monitoring counter map
static cool::IFolderPtr getHltPrescaleKeyFolder(cool::IDatabasePtr db)
static void printFolderStructure(cool::IDatabasePtr db, std::ostream &o)
prints the folder structure that is in the COOL database
static cool::RecordSpecification createLvl1ThresholdFolderSpecification()
defines the folder structure for the LVL1 thresholds
static cool::RecordSpecification createLvl1MenuFolderSpecification()
defines the folder structure for the LVL1 menu
static FolderDefinition Lvl1ItemDefFolderDefinition()
static cool::IFolderPtr getHltChainGroupFolder(cool::IDatabasePtr db)
static cool::RecordSpecification createLvl1ConfigKeysFolderSpecification()
defines the folder structure for the LVL1 config key
static cool::IFolderPtr getLvl1ConfKeyFolder(cool::IDatabasePtr db)
static cool::RecordSpecification createHltPrescalesFolderSpecification()
defines the folder structure for the HLT prescales
static cool::RecordSpecification createLvl1BGKeyFolderSpecification()
defines the folder structure for the LVL1 bunch group key
static cool::IFolderPtr getHltMenuFolder(cool::IDatabasePtr db)
static FolderDefinition Lvl1BGDescFolderDefinition()
static FolderDefinition Lvl1BGKeyFolderDefinition()
static int readSchemaVersion(cool::IDatabasePtr db)
get the version of the COOL database
static cool::IFolderPtr getMonConfKeyFolder(cool::IDatabasePtr db)
static FolderDefinition HltPrescaleKeyFolderDefinition()
static cool::RecordSpecification createLvl1ItemDefFolderSpecification()
defines the folder structure for the LVL1 item def
static FolderDefinition Lvl1ConfigKeysFolderDefinition()
static cool::RecordSpecification createLvl1BGDescFolderSpecification()
defines the folder structure for the LVL1 bunch group descriptions
static cool::RecordSpecification createLvl1PrescalesFolderSpecification(int schemaVersion)
defines the folder structure for the LVL1 prescales
static cool::IFolderPtr getLvl1ItemDefFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1BGContentFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getHltConfKeyFolder(cool::IDatabasePtr db)
static FolderDefinition Lvl1MonMapFolderSpecification()
static FolderDefinition Lvl1BGContentFolderDefinition()
static FolderDefinition HltMenuFolderDefinition()
static cool::IFolderPtr getLvl1PrescalesFolder(cool::IDatabasePtr db)
static int getDefaultSchemaVersion()
access to the version
static FolderDefinition Lvl1ThresholdFolderDefinition()
static cool::IFolderSetPtr createFolderStructure(cool::IDatabasePtr db, int schemaVersion=0)
creates the folder structure in the COOL database
static cool::IFolderPtr getLvl1MonMapFolder(cool::IDatabasePtr db)
static cool::RecordSpecification createLvl1BGContentFolderSpecification()
defines the folder structure for the LVL1 bunch groups
static FolderDefinition Lvl1PrescalesFolderDefinition(int schemaVersion)
static cool::IFolderPtr getLvl1BGDescFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1BGKeyFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1ThresholdFolder(cool::IDatabasePtr db)
static cool::RecordSpecification createHltChainGroupFolderSpecification()
defines the folder structure for the HLT chain groups
static FolderDefinition HltChainGroupFolderDefinition()
static cool::IFolderPtr getLvl1InputMapFolder(cool::IDatabasePtr db)
static cool::RecordSpecification createHltPrescaleKeyFolderSpecification()
defines the folder structure for the HLT prescales
static FolderDefinition Lvl1InputMapFolderDefinition()
static cool::IFolderPtr getLvl1MenuFolder(cool::IDatabasePtr db)
static cool::RecordSpecification createHltConfigKeysFolderSpecification()
defines the folder structure for the HLT config key
static FolderDefinition Lvl1MenuFolderDefinition()
static bool CreateFolderIfNotExist(cool::IDatabasePtr db, const std::string &folder, const cool::IRecordSpecification &spec, cool::FolderVersioning::Mode mode, bool isMultiChannel)
static cool::IFolderPtr getHltPrescalesFolder(cool::IDatabasePtr db)
static FolderDefinition HltConfigKeysFolderDefinition()
Definition node.h:24
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
STL namespace.