10 #include "CoolKernel/IFolder.h"
11 #include "CoolKernel/IDatabase.h"
12 #include "CoolKernel/FolderSpecification.h"
32 TrigConfCoolFolderSpec::readSchemaVersion(cool::IDatabasePtr
db) {
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) {
44 const IFolderPtr & hltMenuFolder =
db->getFolder(
"/TRIGGER/HLT/Menu");
45 const IRecordSpecification & hltMenuSpec = hltMenuFolder->payloadSpecification();
47 if(hltMenuSpec.exists(
"Prescale")) {
49 const IFieldSpecification& lowChNField = hltMenuSpec[
"LowerChainName"];
53 if(lowChNField.storageType() == StorageType::String4k) {
57 const IFieldSpecification& psField = hltMenuSpec[
"Prescale"];
61 if(psField.storageType() == StorageType::UInt32) {
67 if(psField.storageType() == StorageType::Float) {
73 throw runtime_error(
"Could not determine the COOL schema of the TriggerDB");
81 TrigConfCoolFolderSpec::createLvl1MenuFolderSpecification() {
82 return Lvl1MenuFolderDefinition().rspec();
86 TrigConfCoolFolderSpec::Lvl1MenuFolderDefinition() {
87 cool::RecordSpecification rspec;
88 rspec.extend(
"ItemName", StorageType::String255 );
89 rspec.extend(
"ItemVersion", StorageType::UInt32 );
91 FolderVersioning::SINGLE_VERSION, rspec);
98 TrigConfCoolFolderSpec::createLvl1ItemDefFolderSpecification() {
99 return Lvl1MenuFolderDefinition().rspec();
103 TrigConfCoolFolderSpec::Lvl1ItemDefFolderDefinition() {
104 cool::RecordSpecification rspec;
106 rspec.extend(
"Logic", StorageType::String255 );
107 rspec.extend(
"ConditionsList", StorageType::String4k );
109 FolderVersioning::SINGLE_VERSION,rspec);
116 TrigConfCoolFolderSpec::createLvl1ThresholdFolderSpecification() {
117 return Lvl1ThresholdFolderDefinition().rspec();
121 TrigConfCoolFolderSpec::Lvl1ThresholdFolderDefinition() {
122 cool::RecordSpecification rspec;
123 rspec.extend(
"Threshold", StorageType::String255 );
124 rspec.extend(
"ThresholdValue", StorageType::String4k );
125 rspec.extend(
"Cable", StorageType::String255 );
127 FolderVersioning::SINGLE_VERSION,rspec);
134 TrigConfCoolFolderSpec::createLvl1ConfigKeysFolderSpecification() {
135 return Lvl1ConfigKeysFolderDefinition().rspec();
139 TrigConfCoolFolderSpec::Lvl1ConfigKeysFolderDefinition() {
140 cool::RecordSpecification rspec;
141 rspec.extend(
"Lvl1PrescaleConfigurationKey", StorageType::UInt32 );
143 FolderVersioning::MULTI_VERSION,rspec);
150 TrigConfCoolFolderSpec::createLvl1PrescalesFolderSpecification(
int schemaVersion) {
151 return Lvl1PrescalesFolderDefinition(schemaVersion).rspec();
155 TrigConfCoolFolderSpec::Lvl1PrescalesFolderDefinition(
int schemaVersion) {
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 );
163 FolderVersioning::MULTI_VERSION,rspec);
170 TrigConfCoolFolderSpec::createLvl1InputMapFolderSpecification() {
171 return Lvl1InputMapFolderDefinition().rspec();
175 TrigConfCoolFolderSpec::Lvl1InputMapFolderDefinition() {
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 );
185 FolderVersioning::SINGLE_VERSION,rspec);
192 TrigConfCoolFolderSpec::createLvl1BGKeyFolderSpecification() {
193 return Lvl1BGKeyFolderDefinition().rspec();
197 TrigConfCoolFolderSpec::Lvl1BGKeyFolderDefinition() {
198 cool::RecordSpecification rspec;
199 rspec.extend(
"Lvl1BunchGroupConfigurationKey", StorageType::UInt32 );
201 FolderVersioning::MULTI_VERSION,rspec);
208 TrigConfCoolFolderSpec::createLvl1BGContentFolderSpecification() {
209 return Lvl1BGContentFolderDefinition().rspec();
213 TrigConfCoolFolderSpec::Lvl1BGContentFolderDefinition() {
214 cool::RecordSpecification rspec;
215 rspec.extend(
"BunchCode" , StorageType::Blob64k );
217 FolderVersioning::MULTI_VERSION,rspec);
224 TrigConfCoolFolderSpec::createLvl1BGDescFolderSpecification() {
225 return Lvl1BGDescFolderDefinition().rspec();
229 TrigConfCoolFolderSpec::Lvl1BGDescFolderDefinition() {
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 );
249 FolderVersioning::SINGLE_VERSION,rspec);
256 TrigConfCoolFolderSpec::createHltMenuFolderSpecification() {
257 return HltMenuFolderDefinition().rspec();
261 TrigConfCoolFolderSpec::HltMenuFolderDefinition() {
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 );
273 FolderVersioning::SINGLE_VERSION,rspec);
280 TrigConfCoolFolderSpec::createHltChainGroupFolderSpecification() {
281 return HltChainGroupFolderDefinition().rspec();
285 TrigConfCoolFolderSpec::HltChainGroupFolderDefinition() {
286 cool::RecordSpecification rspec;
287 rspec.extend(
"ChainCounter", StorageType::UInt32 );
288 rspec.extend(
"Groups", StorageType::String4k );
290 FolderVersioning::SINGLE_VERSION,rspec);
297 TrigConfCoolFolderSpec::createHltConfigKeysFolderSpecification() {
298 return HltConfigKeysFolderDefinition().rspec();
302 TrigConfCoolFolderSpec::HltConfigKeysFolderDefinition() {
303 cool::RecordSpecification rspec;
304 rspec.extend(
"MasterConfigurationKey", StorageType::UInt32 );
305 rspec.extend(
"HltPrescaleConfigurationKey", StorageType::UInt32 );
306 rspec.extend(
"ConfigSource", StorageType::String255 );
308 FolderVersioning::SINGLE_VERSION,rspec);
315 TrigConfCoolFolderSpec::createHltPrescalesFolderSpecification() {
316 return HltPrescalesFolderDefinition().rspec();
320 TrigConfCoolFolderSpec::HltPrescalesFolderDefinition() {
321 cool::RecordSpecification rspec;
322 rspec.extend(
"Prescale", StorageType::Float );
323 rspec.extend(
"Passthrough", StorageType::Float );
324 rspec.extend(
"RerunPrescale", StorageType::Float );
326 FolderVersioning::MULTI_VERSION,rspec);
333 TrigConfCoolFolderSpec::createHltPrescaleKeyFolderSpecification() {
334 return HltPrescaleKeyFolderDefinition().rspec();
338 TrigConfCoolFolderSpec::HltPrescaleKeyFolderDefinition() {
339 cool::RecordSpecification rspec;
340 rspec.extend(
"HltPrescaleKey", StorageType::UInt32 );
342 FolderVersioning::MULTI_VERSION,rspec);
353 TrigConfCoolFolderSpec::createLvl1MonMapFolderSpecification() {
354 return Lvl1MonMapFolderSpecification().rspec();
358 TrigConfCoolFolderSpec::Lvl1MonMapFolderSpecification() {
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 );
372 FolderVersioning::SINGLE_VERSION, rspec);
382 cool::RecordSpecification rspec;
385 return CreateFolderIfNotExist(
db,
fd, isMultiChannel);
390 TrigConfCoolFolderSpec::CreateFolderIfNotExist(IDatabasePtr
db,
FolderDefinition fd,
bool isMultiChannel) {
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>";
395 if(
db->existsFolder(
fd.folder ) )
398 const string &
description = isMultiChannel ? multiChannelDesc : singleChannelDesc;
400 bool createParents =
true;
415 TrigConfCoolFolderSpec::createFolderStructure(IDatabasePtr
db,
int schemaVersion) {
417 if(schemaVersion==0) schemaVersion = getDefaultSchemaVersion();
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>";
423 bool newFolder =
false;
425 static const bool singleChannel(
false);
426 static const bool multiChannel(
true);
428 IFolderSetPtr topFolder;
429 if( !
db->existsFolderSet(
"/TRIGGER" ) ) {
431 topFolder =
db->createFolderSet(
"/TRIGGER" );
433 if( !
db->existsFolderSet(
"/TRIGGER/LVL1" ) ) {
435 db->createFolderSet(
"/TRIGGER/LVL1" );
437 if( !
db->existsFolderSet(
"/TRIGGER/HLT" ) ) {
439 db->createFolderSet(
"/TRIGGER/HLT" );
442 newFolder |= CreateFolderIfNotExist(
db, Lvl1MenuFolderDefinition(), multiChannel);
444 newFolder |= CreateFolderIfNotExist(
db, Lvl1ItemDefFolderDefinition(), multiChannel);
446 newFolder |= CreateFolderIfNotExist(
db, Lvl1ThresholdFolderDefinition(), multiChannel);
448 newFolder |= CreateFolderIfNotExist(
db, Lvl1ConfigKeysFolderDefinition(), singleChannel);
450 newFolder |= CreateFolderIfNotExist(
db, Lvl1PrescalesFolderDefinition(schemaVersion), multiChannel);
452 newFolder |= CreateFolderIfNotExist(
db, Lvl1BGKeyFolderDefinition(), singleChannel);
454 newFolder |= CreateFolderIfNotExist(
db, Lvl1BGContentFolderDefinition(), singleChannel);
456 newFolder |= CreateFolderIfNotExist(
db, Lvl1BGDescFolderDefinition(), singleChannel);
458 newFolder |= CreateFolderIfNotExist(
db, Lvl1InputMapFolderDefinition(), multiChannel);
460 newFolder |= CreateFolderIfNotExist(
db, HltConfigKeysFolderDefinition(), singleChannel);
462 newFolder |= CreateFolderIfNotExist(
db, HltMenuFolderDefinition(), multiChannel);
464 newFolder |= CreateFolderIfNotExist(
db, HltChainGroupFolderDefinition(), multiChannel);
466 newFolder |= CreateFolderIfNotExist(
db, HltPrescalesFolderDefinition(), multiChannel);
468 newFolder |= CreateFolderIfNotExist(
db, HltPrescaleKeyFolderDefinition(), singleChannel);
470 if(newFolder) printFolderStructure(
db, cout);
476 TrigConfCoolFolderSpec::createMonFolderStructure(IDatabasePtr
db,
int ) {
478 bool multiChannel(
true);
481 bool newFolder = CreateFolderIfNotExist(
db, Lvl1MonMapFolderSpecification(), multiChannel);
483 printFolderStructure(
db, cout);
485 return db->getFolderSet(
"/TRIGGER" );
495 IFolderPtr TrigConfCoolFolderSpec::getLvl1MenuFolder(IDatabasePtr
db) {
496 return db->getFolder(
"/TRIGGER/LVL1/Menu" );
499 IFolderPtr TrigConfCoolFolderSpec::getLvl1ItemDefFolder(IDatabasePtr
db) {
500 return db->getFolder(
"/TRIGGER/LVL1/ItemDef" );
503 IFolderPtr TrigConfCoolFolderSpec::getLvl1ThresholdFolder(IDatabasePtr
db) {
504 return db->getFolder(
"/TRIGGER/LVL1/Thresholds" );
507 IFolderPtr TrigConfCoolFolderSpec::getLvl1ConfKeyFolder(IDatabasePtr
db) {
508 return db->getFolder(
"/TRIGGER/LVL1/Lvl1ConfigKey" );
511 IFolderPtr TrigConfCoolFolderSpec::getLvl1PrescalesFolder(IDatabasePtr
db) {
512 return db->getFolder(
"/TRIGGER/LVL1/Prescales" );
515 IFolderPtr TrigConfCoolFolderSpec::getLvl1BGKeyFolder(IDatabasePtr
db) {
516 return db->getFolder(
"/TRIGGER/LVL1/BunchGroupKey" );
519 IFolderPtr TrigConfCoolFolderSpec::getLvl1BGContentFolder(IDatabasePtr
db) {
520 return db->getFolder(
"/TRIGGER/LVL1/BunchGroupContent" );
523 IFolderPtr TrigConfCoolFolderSpec::getLvl1BGDescFolder(IDatabasePtr
db) {
524 return db->getFolder(
"/TRIGGER/LVL1/BunchGroupDescription" );
527 IFolderPtr TrigConfCoolFolderSpec::getLvl1InputMapFolder(IDatabasePtr
db) {
528 return db->getFolder(
"/TRIGGER/LVL1/CTPCoreInputMapping" );
531 IFolderPtr TrigConfCoolFolderSpec::getLvl1MonMapFolder(IDatabasePtr
db) {
532 return db->getFolder(
"/TRIGGER/LVL1/CTPInMonitoringMapping" );
535 IFolderPtr TrigConfCoolFolderSpec::getHltMenuFolder(IDatabasePtr
db) {
536 return db->getFolder(
"/TRIGGER/HLT/Menu" );
539 IFolderPtr TrigConfCoolFolderSpec::getHltChainGroupFolder(IDatabasePtr
db) {
540 return db->getFolder(
"/TRIGGER/HLT/Groups" );
543 IFolderPtr TrigConfCoolFolderSpec::getHltConfKeyFolder(IDatabasePtr
db) {
544 return db->getFolder(
"/TRIGGER/HLT/HltConfigKeys" );
547 IFolderPtr TrigConfCoolFolderSpec::getMonConfKeyFolder(IDatabasePtr
db) {
548 return db->getFolder(
"/TRIGGER/HLT/MenuAwareMonConfigKey" );
551 IFolderPtr TrigConfCoolFolderSpec::getHltPrescalesFolder(IDatabasePtr
db) {
552 return db->getFolder(
"/TRIGGER/HLT/Prescales" );
555 IFolderPtr TrigConfCoolFolderSpec::getHltPrescaleKeyFolder(IDatabasePtr
db) {
556 return db->getFolder(
"/TRIGGER/HLT/PrescaleKey" );
564 TrigConfCoolFolderSpec::printFolderStructure(IDatabasePtr
db, std::ostream & o)
567 for(
const string&
node :
db->listAllNodes()) {
568 bool isFolderSet =
db->existsFolderSet(
node);
574 bool isMultiVersion = (
folder->versioningMode() == FolderVersioning::MULTI_VERSION);
575 const IRecordSpecification& rspec =
folder->payloadSpecification();
576 o <<
" (" << (isMultiVersion?
"Multiversion":
"Singleversion") <<
")" << endl;
578 for(
uint i=0;
i<rspec.size();
i++) {
579 o <<
" " << setw(30) << rspec[
i].name()
580 <<
" (" << rspec[
i].storageType().name() <<
")" << endl;