ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConfCoolWriter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
10
14#include "TrigConfL1Data/Menu.h"
16#include "TrigConfL1Data/PIT.h"
24
25#include "CoolKernel/ValidityKey.h"
26#include "CoolKernel/IFolder.h"
27#include "CoolKernel/Exception.h"
28#include "CoolKernel/IObject.h"
29#include "CoolKernel/IObjectIterator.h"
30#include "CoolKernel/Record.h"
31#include "CoolKernel/IDatabaseSvc.h"
32#include "CoralKernel/Context.h"
33#include "RelationalAccess/ConnectionService.h"
34#include "RelationalAccess/IConnectionService.h"
35#include "RelationalAccess/IConnectionServiceConfiguration.h"
36#include "RelationalAccess/ILookupService.h"
37#include "RelationalAccess/IAuthenticationService.h"
38#include "RelationalAccess/IAuthenticationCredentials.h"
39#include "RelationalAccess/IDatabaseServiceDescription.h"
40#include "RelationalAccess/IDatabaseServiceSet.h"
41
42#include <iomanip>
43#include <stdexcept>
44#include <sstream>
45#include <set>
46#include <iterator>
47
48using namespace std;
49using namespace cool;
50using namespace TrigConf;
53
54
55#define READ_ONLY true
56#define READ_WRITE false
57
58
59
62 m_neededToOpen(false),
63 m_ro(readOnly)
64{
65 if(m_writer->dbIsOpen()) {
66 m_neededToOpen = false;
67 } else {
68 m_writer->openDb(m_ro);
69 m_neededToOpen = true;
70 }
71}
72
75 m_writer->closeDb();
76}
77
78
79cool::IDatabaseSvc&
81{
82 return m_coolApp.databaseService();
83}
84
85
86bool
88 if(dbIsOpen()) return true;
89 openDb( readOnly );
90 closeDb();
91 return true;
92}
93
94
95bool
97 return m_dbPtr.use_count()>0 && m_dbPtr->isOpen();
98}
99
100
101// ------------------------------------------------------------
102// openDb(bool readOnly)
103// ------------------------------------------------------------
104cool::IDatabasePtr
106 if(dbIsOpen()) return m_dbPtr;
107 cool::IDatabaseSvc& dbSvc = databaseService();
108 try {
109 m_ostream << "Opening database '" << m_dbId << "' in " << (readOnly?"read-only":"read-write") << " mode" << endl;
110 m_dbPtr = dbSvc.openDatabase( m_dbId, readOnly ); // If the database does not exist, an exception is thrown
111 // int schemaVersion = TrigConfCoolFolderSpec::readSchemaVersion(m_dbPtr);
112 // m_ostream << "Found schema with version " << schemaVersion << endl;
113 return m_dbPtr;
114 } catch(cool::DatabaseDoesNotExist& e) {
115 if(readOnly) {
116 m_ostream << "Database '" << m_dbId << "' does not exist. Can't create it since connection is read-only." << endl;
117 throw;
118 } else {
119 m_ostream << "Database '" << m_dbId << "' does not exist, will create it" << endl;
120 m_dbPtr = dbSvc.createDatabase( m_dbId );
121 m_ostream << "Created DB" << endl;
122 return m_dbPtr;
123 }
124 } catch(Exception& e) {
125 m_ostream << "*** COOL exception caught: " << e.what() << endl;
126 m_ostream << "Couldn't open database " << m_dbId << endl;
127 throw;
128 }
129}
130
131
132// ------------------------------------------------------------
133// closeDb()
134// ------------------------------------------------------------
135void
137 try {
138 if(db.use_count()>0 && db->isOpen()) {
139 m_ostream << "Closing database (old way) '" << m_dbId << "'" << endl;
140 db->closeDatabase( );
141 }
142 } catch(std::exception& e) {
143 m_ostream << "*** COOL exception caught: " << e.what() << endl
144 << "Couldn't close conditions database: " << m_dbId << endl;
145 }
146 return;
147}
148
149
150// ------------------------------------------------------------
151// closeDb()
152// ------------------------------------------------------------
153void
155 try {
156 if(dbIsOpen()) {
157 m_ostream << "Closing database '" << m_dbId << "'" << endl;
158 m_dbPtr->closeDatabase();
159 }
160 } catch(std::exception& e) {
161 m_ostream << "*** COOL exception caught: " << e.what() << endl
162 << "Couldn't close conditions database: " << m_dbId << endl;
163 }
164}
165
166
167// ------------------------------------------------------------
168// createSchema()
169// ------------------------------------------------------------
170void
172 bool needToOpen = !dbIsOpen();
173 if(needToOpen) {
174 try {
175 openDb(false);
176 }
177 catch(cool::DatabaseDoesNotExist& e) {
178 m_ostream << "*** : " << e.what() << endl;
179 m_ostream << "Will create a new database: " << m_dbId << endl;
180 createDb();
181 openDb(false);
182 }
183 catch(cool::Exception& e) {
184 m_ostream << "*** COOL exception caught: " << e.what() << endl;
185 m_ostream << "Coudn't create a new schema: " << m_dbId << endl;
186 throw;
187 }
188 }
189
190 try {
191 if(schemaVersion==0) schemaVersion=TrigConfCoolFolderSpec::getDefaultSchemaVersion();
192 m_ostream << "Creating schema '" << m_dbId << "' with version " << schemaVersion
193 << (schemaVersion==TrigConfCoolFolderSpec::getDefaultSchemaVersion()?" (=default)":"") << endl;
195 }
196 catch(cool::Exception& e) {
197 m_ostream << "*** COOL exception caught: " << e.what() << endl;
198 m_ostream << "Coudn't create a new schema: " << m_dbId << endl;
199 throw;
200 }
201 if(needToOpen) closeDb();
202 return;
203}
204
205
206// ------------------------------------------------------------
207// printSchema(ostream &)
208// ------------------------------------------------------------
209void
214
215
216// ------------------------------------------------------------
217// printSchemaVersion(ostream &)
218// ------------------------------------------------------------
219void
221 AutoDBOpen db(this, READ_ONLY);
223 o << "Schema version is " << schemaVersion
224 << (schemaVersion==TrigConfCoolFolderSpec::getDefaultSchemaVersion()?" (=default)":"") << endl;
225}
226
227
228// ------------------------------------------------------------
229// recreateSchema()
230// ------------------------------------------------------------
232
233
234// ------------------------------------------------------------
235// dropDb()
236// ------------------------------------------------------------
238
239
240// ------------------------------------------------------------
241// createDb()
242// ------------------------------------------------------------
243cool::IDatabasePtr
245 m_ostream << "Creating database '" << m_dbId << "'" << endl;
246 try {
247 cool::IDatabaseSvc& dbSvc = databaseService();
248 m_dbPtr = dbSvc.createDatabase( m_dbId );
249 }
250 catch(std::exception& e) {
251 m_ostream << "*** COOL exception caught: " << e.what() << endl;
252 m_ostream << "Coudn't create a new conditions database: " << m_dbId << endl;
253 throw;
254 }
255
256 return m_dbPtr;
257}
258
259
260void
261TrigConfCoolWriter::rangeInfo(const std::string& content,
262 cool::ValidityKey since,
263 cool::ValidityKey until) {
264
265
266 if(since==ValidityKeyMin && until==ValidityKeyMax) {
267 m_ostream << "Writing " << content << " for infinite range [0,oo]" << endl;
268 return;
269 }
270
271 unsigned long long run[2];
272 unsigned long long lb[2];
273 lb[0] = since & 0xFFFFFFFF;
274 lb[1] = until & 0xFFFFFFFF;
275 run[0] = since>>32;
276 run[0] &= 0x7FFFFFFF;
277 run[1] = until>>32;
278 run[1] &= 0x7FFFFFFF;
279
280 if(lb[0]==0 && lb[1]==0) {
281 unsigned int first = run[0];
282 unsigned int last = run[1]-1;
283 if(first==last) {
284 m_ostream << "IOV Info: writing " << content << " for run " << first << endl;
285 } else {
286 m_ostream << "IOV Info: writing " << content << " for run range [" << first << "," << last << "]" << endl;
287 }
288 } else {
289 if(run[0]==run[1]) {
290 if(lb[0]==lb[1]-1)
291 m_ostream << "IOV Info: writing " << content << " for run " << run[0] << " and LB " << lb[0] << endl;
292 else
293 m_ostream << "IOV Info: writing " << content << " for run " << run[0] << " and LB range [" << lb[0] << "," << lb[1]-1 << "]" << endl;
294 } else {
295 m_ostream << "IOV Info: writing " << content << " for range [" << run[0] << "/" << lb[0] << "," << run[1] << "/" << lb[1] << "[" << endl;
296 }
297 }
298}
299
300
301
302void
304{
305 AutoDBOpen db(this, READ_WRITE);
307 try {
308 writeL1MenuPayload (vr, ctpConfig.menu());
309 writeL1BunchGroupRunPayload(vr, ctpConfig.menu(), ctpConfig.bunchGroupSet() ); // writes bunchgroup description folder
310 writeL1BunchGroupLBPayload (vr, ctpConfig.bunchGroupSet().id(), ctpConfig.bunchGroupSet()); // writes bunchgroup content and key folders
311 writeL1PrescalePayload(vr.since(), vr.until(), ctpConfig.prescaleSet().id(), ctpConfig.prescaleSet());
312 }
313 catch(exception & e) {
314 m_ostream << "<writeL1Payload> caught and re-throw exception: " << e.what() << endl;
315 throw;
316 }
317}
318
319
320
321void
323 const HLTFrame& hltFrame,
324 const string& configSource)
325{
326 AutoDBOpen db(this, READ_WRITE);
328
329 // writing configuration keys
330 if( shouldFolderBeUpdated("/TRIGGER/HLT/HltConfigKeys") ) {
331 rangeInfo("HLT configuration keys", vr.since(), vr.until());
332 try {
333 IFolderPtr confkeyFolder = TrigConfCoolFolderSpec::getHltConfKeyFolder(m_dbPtr);
334 Record payload = createHltConfigKeysPayload(confkeyFolder, hltFrame.smk(), 0, configSource);
335 confkeyFolder->storeObject(vr.since(), vr.until(), payload, 0);
336 }
337 catch(exception & e) {
338 m_ostream << "<writeHLTPayload> caught and re-throw exception: " << e.what() << endl
339 << "WARNING: Failed to write configuration keys to COOL" << endl;
340 throw;
341 }
342 }
343
344 if(!hltFrame.getPrescaleSetCollection().sets().empty()) {
345 // we only support one prescale set at a time here
346 const HLTPrescaleSet& pss = *hltFrame.getPrescaleSetCollection().sets().front().pss;
347 writeHltPrescalePayload(vr.since(), vr.until(), pss);
348 }
349
350 if( shouldFolderBeUpdated("/TRIGGER/HLT/Menu") ||
351 shouldFolderBeUpdated("/TRIGGER/HLT/Groups") ) {
352 if( hltFrame.getHLTChainList().size() > 0 ) {
353
354 rangeInfo("HLT menu", vr.since(), vr.until());
355
356 // this call is needed to set the level of each sequence
358
359 // writing the chains of the HLT menu
360 try {
361
362 ChannelId menuChannel(0);
363 IFolderPtr hltMenuFolder = TrigConfCoolFolderSpec::getHltMenuFolder(m_dbPtr);
364 IFolderPtr hltGroupFolder = TrigConfCoolFolderSpec::getHltChainGroupFolder(m_dbPtr);
365 // use buffer to speed up COOL writing
366 hltMenuFolder->setupStorageBuffer();
367 hltGroupFolder->setupStorageBuffer();
368
369 for ( const HLTChain* chain : hltFrame.getHLTChainList() ) {
370 menuChannel++;
371 string concise = HLTTEUtils::ChainCondenseDisplay( *chain, hltFrame);
372 Record payload = createHltMenuPayload( hltMenuFolder, *chain, concise );
373 hltMenuFolder->storeObject(vr.since(), vr.until(), payload, menuChannel);
374
375 Record payloadGroups = TrigConfCoolHLTPayloadConverters::createHltChainGroupPayload(hltGroupFolder, *chain );
376 hltGroupFolder->storeObject(vr.since(), vr.until(), payloadGroups, menuChannel);
377 m_ostream << "Writing (to buffer) HLT chain " << chain->chain_name()
378 << "(id " << chain->chain_counter()
379 << " level "<< chain->level()
380 << ") to COOL channel " << menuChannel
381 << " [belongs to groups " << payloadGroups["Groups"].data<cool::String4k>() << "]" << endl;
382 }
383 if( shouldFolderBeUpdated("/TRIGGER/HLT/Menu") ) {
384 m_ostream << "Flushing HLT menu buffer to /TRIGGER/HLT/Menu" << endl;
385 try {
386 hltMenuFolder->flushStorageBuffer();
387 }
388 catch ( cool::Exception & e) {
389 m_ostream << "WARNING: Flushing buffer to DB failed: " << e.what() << endl
390 << "warning will be ignored, job will continue" << endl;
391 }
392 }
393 if( shouldFolderBeUpdated("/TRIGGER/HLT/Groups") ) {
394 m_ostream << "Flushing HLT group buffer to /TRIGGER/HLT/Groups" << endl;
395 try {
396 hltGroupFolder->flushStorageBuffer();
397 }
398 catch ( cool::Exception & e) {
399 m_ostream << "WARNING: Flushing buffer to DB failed: " << e.what() << endl
400 << "warning will be ignored, job will continue" << endl;
401 }
402 }
403 }
404 catch( cool::Exception & e) {
405 m_ostream << "Caught cool::Exception: " << e.what() << endl;
406 m_ostream << "Failed to write HLT menu to COOL" << endl;
407 throw;
408 }
409 catch(std::exception & e) {
410 m_ostream << "<writeHLTPayload> Caught std::exception: " << e.what() << endl;
411 throw;
412 }
413 } else {
414 m_ostream << "List of HLT Chains is empty, nothing is written to COOL" << endl;
415 }
416 }
417}
418
419
420// ------------------------------------------------------------
421// writeMCKPayload()
422// ------------------------------------------------------------
423void
425 unsigned int mck,
426 std::string & release,
427 std::string & info)
428{
429 AutoDBOpen db(this, READ_WRITE);
431
432 // writing monitoring configuration key
433 if( shouldFolderBeUpdated("/TRIGGER/HLT/MenuAwareMonConfigKey") ) {
434 rangeInfo("Monitoring configuration key", vr.since(), vr.until());
435 try {
436 IFolderPtr monconfkeyFolder = TrigConfCoolFolderSpec::getMonConfKeyFolder(m_dbPtr);
437 Record payload = createMonConfigKeyPayload(monconfkeyFolder, mck, info);
438 monconfkeyFolder->storeObject(vr.since(), vr.until(), payload, 0, "MenuAwareMonConfigKey-"+release); //tag
439 }
440 catch(exception & e) {
441 m_ostream << "<writeMCKPayload> caught and re-throw exception: " << e.what() << endl
442 << "WARNING: Failed to write monitoring configuration key (MCK) to COOL" << endl;
443 throw;
444 }
445 }
446
447}
448
449
450// ------------------------------------------------------------
451// writeRunPayload()
452// ------------------------------------------------------------
453void
455 unsigned int masterConfigKey,
456 unsigned int hltPrescaleKey,
457 const TrigConf::ThresholdConfig & lvl1Thr,
458 const TrigConf::CTPConfig & ctpConfig,
459 const TrigConf::CaloInfo & caloInfo,
460 const TrigConf::HLTFrame & hltFrame,
461 const std::string & configSource)
462{
463 RunRangeVec runRanges;
464 runRanges.push_back(std::pair<unsigned int,unsigned int>(runNumber,runNumber));
465 writeRunPayload( runRanges, masterConfigKey, hltPrescaleKey, lvl1Thr, ctpConfig, caloInfo, hltFrame, configSource);
466}
467
468
469void
471 unsigned int /*masterConfigKey*/,
472 unsigned int /*hltPrescaleKey*/,
473 const TrigConf::ThresholdConfig & /*lvl1Thr*/,
474 const TrigConf::CTPConfig & ctpConfig,
475 const TrigConf::CaloInfo & /*caloInfo*/,
476 const TrigConf::HLTFrame & hltFrame,
477 const std::string & configSource)
478{
479 AutoDBOpen db(this, READ_WRITE);
481
482 for ( RunRange rr : runRanges) {
483 writeL1Payload(rr, ctpConfig);
484 }
485
486 // loop over the run ranges
487 for ( RunRange rr : runRanges) {
488 writeHLTPayload( ValidityRange(rr), hltFrame, configSource);
489 }
490}
491
492
493
494
495void
497 const TrigConf::Menu * lvl1Menu) {
498 RunRangeVec runRanges;
499 runRanges.push_back(std::pair<unsigned int,unsigned int>(runNumber,runNumber));
500 writeL1MonPayload( runRanges, lvl1Menu);
501}
502
503void
505 const TrigConf::Menu * lvl1Menu)
506{
507 if(lvl1Menu == 0) throw std::runtime_error("L1 trigger menu ptr is NULL");
508
509 AutoDBOpen db(this, READ_WRITE);
510 // just in case
512
513 // loop over the run ranges
514 for ( RunRange rr : runRanges) {
515
516 ValidityRange vr(rr);
517 rangeInfo("LVL1 monitoring", vr.since(), vr.until());
518
519 if( shouldFolderBeUpdated("/TRIGGER/LVL1/CTPInMonitoringMapping") ) {
520
521 try {
522 // maps to store exact description of mon counters; channel id is
523 // internal mon counter id. Different entries in the mon vector
524 // belong to the same counter, the strings are concatenated,
525 // separated by ':'
526 std::map<cool::ChannelId,std::string> monNames;
527 std::map<cool::ChannelId,std::string> thrNames;
528 std::map<cool::ChannelId,std::string> slots;
529 std::map<cool::ChannelId,std::string> cons;
530 std::map<cool::ChannelId,std::string> mults;
531 std::map<cool::ChannelId,std::string> starts;
532 std::map<cool::ChannelId,std::string> ends;
533 std::map<cool::ChannelId,std::string> actives;
534 // not possible yet std::map<cool::ChannelId,std::string> counterlogic;
535 // the next 2 must be unique
536 std::map<cool::ChannelId,std::string> counterType;
537 std::map<cool::ChannelId,uint16_t> bgId;
538 const std::vector<TrigConf::ThresholdMonitor*>& monCounter = lvl1Menu->moncountVector();
539 std::vector<TrigConf::ThresholdMonitor*>::const_iterator mc = monCounter.begin();
540 for(;mc != monCounter.end(); ++mc) {
541 cool::ChannelId index = static_cast<cool::ChannelId>((*mc)->internalCounter());
542 // the CTPMON goes into the same table, the configuration
543 // of the 160 counters is written with internal counter
544 // as MONCOUNTER + 768, i.e. is added at the end
545 if((*mc)->counterType().find("CTPMON") != std::string::npos) {
546 index += 768;
547 }
548
549 //prepare strings
550 std::stringstream strSlot; strSlot << (*mc)->ctpinSlot();
551 std::stringstream strCon; strCon << (*mc)->ctpinConnector();
552 std::stringstream strMult; strMult << (*mc)->multiplicity();
553 std::stringstream strStart; strStart << (*mc)->thresholdStartBit();
554 std::stringstream strEnd; strEnd << (*mc)->thresholdEndBit();
555 std::string active;
556 if((*mc)->thresholdActive()) active = "ENABLED";
557 else active = "DISABLED";
558
559
560 int flag=0;//0: not write, 1: write new entry, 2: concatenate
561 if( monNames.find(index) == monNames.end() ){
562 //no entries for this counter
563 flag=1;
564 }else{
565 flag=2;
566
567 //check if all parameters exist for the index
568 if( thrNames.find(index) == thrNames.end() ){
569 flag=1;
570 m_ostream << "PROBLEM counter " << index << " : no thrNames in previous entries, overwrite all with new one" << endl;
571 }else if( slots.find(index) == slots.end() ){
572 flag=1;
573 m_ostream << "PROBLEM counter " << index << " : no slots in previous entries, overwrite all with new one" << endl;
574 }else if( cons.find(index) == cons.end() ){
575 flag=1;
576 m_ostream << "PROBLEM counter " << index << " : no cons in previous entries, overwrite all with new one" << endl;
577 }else if( mults.find(index) == mults.end() ){
578 flag=1;
579 m_ostream << "PROBLEM counter " << index << " : no mults in previous entries, overwrite all with new one" << endl;
580 }else if( starts.find(index) == starts.end() ){
581 flag=1;
582 m_ostream << "PROBLEM counter " << index << " : no starts in previous entries, overwrite all with new one" << endl;
583 }else if( ends.find(index) == ends.end() ){
584 flag=1;
585 m_ostream << "PROBLEM counter " << index << " : no ends in previous entries, overwrite all with new one" << endl;
586 }else if( actives.find(index) == actives.end() ){
587 flag=1;
588 m_ostream << "PROBLEM counter " << index << " : no actives in previous entries, overwrite all with new one" << endl;
589 }else if( counterType.find(index) == counterType.end() ){
590 flag=1;
591 m_ostream << "PROBLEM counter " << index << " : no counterType in previous entries, overwrite all with new one" << endl;
592 }else if( bgId.find(index) == bgId.end() ){
593 flag=1;
594 m_ostream << "PROBLEM counter " << index << " : no bgId in previous entries, overwrite all with new one" << endl;
595 }else{
596
597 //check if previous entries for same name have same parameters
598 std::vector<std::string> thrNamesCheck = split(thrNames[index],":");
599 std::vector<std::string> slotsCheck = split(slots[index],":");
600 std::vector<std::string> consCheck = split(cons[index],":");
601 std::vector<std::string> multsCheck = split(mults[index],":");
602 std::vector<std::string> startsCheck = split(starts[index],":");
603 std::vector<std::string> endsCheck = split(ends[index],":");
604 std::vector<std::string> activesCheck = split(actives[index],":");
605 if (thrNamesCheck.size() != slotsCheck.size()||
606 thrNamesCheck.size() != consCheck.size()||
607 thrNamesCheck.size() != multsCheck.size()||
608 thrNamesCheck.size() != startsCheck.size()||
609 thrNamesCheck.size() != endsCheck.size()||
610 thrNamesCheck.size() != activesCheck.size()){
611 flag=1;
612 m_ostream << "PROBLEM counter " << index << " : numbers of entries are different, overwrite all with new one" << endl;
613 }else{
614 for (unsigned int i = 0; i < thrNamesCheck.size();i++){
615 if(thrNamesCheck[i]==(*mc)->thresholdName()&&
616 slotsCheck[i]==strSlot.str()&&
617 consCheck[i]==strCon.str()&&
618 multsCheck[i]==strMult.str()&&
619 startsCheck[i]==strStart.str()&&
620 endsCheck[i]==strEnd.str()&&
621 activesCheck[i]==active){
622
623 flag=0;
624 break;
625 }
626 }
627 }
628 }
629 }
630
631 if(flag==0)continue;
632
633
634 if(flag==1){
635 monNames[index]=(*mc)->name();
636 thrNames[index]=(*mc)->thresholdName();
637 slots[index]=strSlot.str();
638 cons[index]=strCon.str();
639 mults[index]=strMult.str();
640 starts[index]=strStart.str();
641 ends[index]=strEnd.str();
642 actives[index]=std::move(active);
643 counterType[index]=(*mc)->counterType();
644 bgId[index]=(*mc)->bunchGroupId();
645 // not possible yet
646 // monNames[index]=(*mc)->counterLogic();
647 }else if(flag==2){
648 if (monNames[index]!=(*mc)->name()){
649 std::stringstream str;
650 str << "PROBLEM counter " << index;
651 str << " : previous monitor name" << monNames[index];
652 str << ", current monitor name " << (*mc)->name() << endl;
653 m_ostream << str.str() << endl;
654 }
655 if(counterType[index] != (*mc)->counterType()) {
656 std::stringstream str;
657 str << "PROBLEM counter " << index;
658 str << " : previous type " << counterType[index];
659 str << ", current type " << (*mc)->counterType() << endl;
660 m_ostream << str.str() << endl;
661 }
662 if(bgId[index] != (*mc)->bunchGroupId()) {
663 std::stringstream str;
664 str << "PROBLEM counter " << index;
665 str << " : previous bunch-group id " << bgId[index];
666 str << ", current id " << (*mc)->bunchGroupId() << endl;
667 m_ostream << str.str() << endl;
668 }
669 monNames[index]=(*mc)->name();
670 counterType[index]=(*mc)->counterType();
671 bgId[index]=(*mc)->bunchGroupId();
672
673 thrNames[index]+=":";thrNames[index]+=(*mc)->thresholdName();
674 slots[index]+=":";slots[index]+=strSlot.str();
675 cons[index]+=":";cons[index]+=strCon.str();
676 mults[index]+=":";mults[index]+=strMult.str();
677 starts[index]+=":";starts[index]+=strStart.str();
678 ends[index]+=":";ends[index]+=strEnd.str();
679 actives[index]+=":";actives[index]+=active;
680 }else{
681 m_ostream << "PROBLEM counter " << index << " : unknown flag = " << flag << endl;
682 continue;
683 }
684 }
685
686 cool::ChannelId channel(0);
687 cool::IFolderPtr monFolder = TrigConfCoolFolderSpec::getLvl1MonMapFolder(m_dbPtr);
688 // use buffer to speed up COOL writing
689 monFolder->setupStorageBuffer();
690 for(std::map<cool::ChannelId,std::string>::iterator it = thrNames.begin();
691 it != thrNames.end();++it) {
692 channel = it->first;
693 cool::Record payload =
695 counterType[channel],
696 bgId[channel],
697 it->second,
698 slots[channel],
699 cons[channel],
700 mults[channel],
701 starts[channel],
702 ends[channel],
703 actives[channel],
704 monNames[channel]);
705 // add counterlogic above and below when implemented in trigger db
706
707 m_ostream << "Write monitoring counter (channel " << channel << ") :: "
708 << " monname '" << monNames[channel] << "'"
709 << " type '" << counterType[channel] << "'"
710 << " bgid '" << bgId[channel] << "'"
711 << " thnames '" << it->second << "'"
712 << " slots '" << slots[channel] << "'"
713 << " connectors '" << cons[channel] << "'"
714 << " multiplicities '" << mults[channel] << "'"
715 << " start bits '" << starts[channel] << "'"
716 << " end bits '" << ends[channel] << "'"
717 << " thresholds active '" << actives[channel] << "'"
718 << endl;
719 monFolder->storeObject(vr.since(), vr.until(), payload, channel);
720 }
721 monFolder->flushStorageBuffer();
722 } catch( cool::Exception & e) {
723 m_ostream << "Caught cool::Exception: " << e.what() << endl;
724 m_ostream << "Failed to write LVL1 monitoring mapping to COOL" << endl;
725 //throw;
726 } catch(std::exception & e) {
727 m_ostream << "<writeLVL1MonPayload> Caught std::exception: " << e.what() << endl;
728 }
729 }
730 }
731}
732
733
734// ------------------------------------------------------------
735// writeL1MenuPayload()
736// ------------------------------------------------------------
737void
739 const Menu& lvl1Menu)
740{
741 AutoDBOpen db(this, READ_WRITE);
743
744 // writing the Lvl1 menu
745 try {
746 if( shouldFolderBeUpdated("/TRIGGER/LVL1/Thresholds") &&
747 lvl1Menu.thresholdConfig().thresholdVector().size()>0 ) { // if there are no thresholds we don't want to write anything (METsig, JETWeights)
748 // get the folders for the menu, itemDef, and thresholds
749 cool::IFolderPtr lvl1ThresholdFolder = TrigConfCoolFolderSpec::getLvl1ThresholdFolder(m_dbPtr);
750
751 rangeInfo("LVL1 thresholds", vr.since(), vr.until());
752 // first, parse the threshold list and write to threshold folder
753 const std::vector<TrigConf::TriggerThreshold*> & lvl1Thrs = lvl1Menu.thresholdConfig().thresholdVector();
754 // use buffer to speed up COOL writing
755
756 lvl1ThresholdFolder->setupStorageBuffer();
757
758 // go through the thresholds, channels assigned in the order (0..#thr-1)
759 cool::ChannelId thrChannel = 0;
760 for (TrigConf::TriggerThreshold* thr : lvl1Thrs) {
761 Record payloadThr = TrigConfCoolL1PayloadConverters::createLvl1ThresholdPayload( lvl1ThresholdFolder, *thr );
762 m_ostream << "Writing (to buffer) LVL1 threshold " << thr->name()
763 << " (version " << thr->version() << ") to channel "
764 << thrChannel << endl;
765 lvl1ThresholdFolder->storeObject(vr.since(), vr.until(), payloadThr, thrChannel++);
766 }
767
768
769 // TODO
770 if( lvl1Menu.thresholdConfig().l1Version() == 0 ) {
771 m_ostream << "Writing (to buffer) LVL1 threshold 'JetWeights':";
772 const std::vector<int>& jetweights = lvl1Menu.caloInfo().jetWeights();
773 std::copy(jetweights.begin(), jetweights.end(), std::ostream_iterator<int>(m_ostream, ", "));
774 m_ostream << endl;
775 Record payloadJW = TrigConfCoolL1PayloadConverters::createLvl1JetWeightPayload( lvl1ThresholdFolder, lvl1Menu.caloInfo().jetWeights() );
776 lvl1ThresholdFolder->storeObject(vr.since(), vr.until(), payloadJW, thrChannel++);
777 }
778
779 m_ostream << "Writing (to buffer) LVL1 threshold 'MET Significance parameters':";
780 lvl1Menu.caloInfo().metSigParam().print();
781 cool::Record payloadMETSigParams = TrigConfCoolL1PayloadConverters::createLvl1METSigPayload( lvl1ThresholdFolder, lvl1Menu.caloInfo().metSigParam() );
782 lvl1ThresholdFolder->storeObject(vr.since(), vr.until(), payloadMETSigParams, thrChannel++);
783
784 // write
785 m_ostream << "Flushing LVL1 thresholds buffer to /TRIGGER/LVL1/Thresholds" << endl;
786 try {
787 lvl1ThresholdFolder->flushStorageBuffer();
788 }
789 catch ( cool::Exception & e) {
790 m_ostream << "WARNING: Flushing buffer to DB failed: " << e.what() << endl
791 << "warning will be ignored, job will continue" << endl;
792 }
793 }
794 } catch( cool::Exception & e) {
795 m_ostream << "Caught cool::Exception: " << e.what() << endl;
796 m_ostream << "Failed to write LVL1 menu to COOL" << endl;
797 throw;
798 } catch(std::exception & e) {
799 m_ostream << "<writeLVL1RunPayload> Caught std::exception: " << e.what() << endl;
800 throw;
801 }
802
803
804 try {
805
806 // second, parse the items and write to menu and itemDef folders
807 if( shouldFolderBeUpdated("/TRIGGER/LVL1/Menu") ||
808 shouldFolderBeUpdated("/TRIGGER/LVL1/ItemDef") ) {
809
810 rangeInfo("LVL1 menu", vr.since(), vr.until());
811
812 cool::IFolderPtr lvl1MenuFolder = TrigConfCoolFolderSpec::getLvl1MenuFolder(m_dbPtr);
813 cool::IFolderPtr lvl1ItemDefFolder = TrigConfCoolFolderSpec::getLvl1ItemDefFolder(m_dbPtr);
814
815 // use buffer to speed up COOL writing
816 lvl1MenuFolder->setupStorageBuffer();
817 lvl1ItemDefFolder->setupStorageBuffer();
818 // go through the items
819 for ( TriggerItem* item : lvl1Menu.items()) {
820 cool::Record payloadMenu = TrigConfCoolL1PayloadConverters::createLvl1MenuPayload( lvl1MenuFolder, *item );
821 cool::Record payloadItemDef = TrigConfCoolL1PayloadConverters::createLvl1ItemDefPayload( lvl1ItemDefFolder, *item );
822 cool::ChannelId menuChannel = static_cast<cool::ChannelId>(item->ctpId()); // int -> uint32
823 m_ostream << "Writing (to buffer) LVL1 item " << item->name()
824 << " (logic " << payloadItemDef["Logic"].data<cool::String255>()
825 << ": [" << payloadItemDef["ConditionsList"].data<cool::String4k>() << "]) to channel "
826 << menuChannel << endl;
827 if( shouldFolderBeUpdated("/TRIGGER/LVL1/Menu") )
828 lvl1MenuFolder->storeObject(vr.since(), vr.until(), payloadMenu, menuChannel);
829
830 if( shouldFolderBeUpdated("/TRIGGER/LVL1/ItemDef") )
831 lvl1ItemDefFolder->storeObject(vr.since(), vr.until(), payloadItemDef, menuChannel);
832 }
833 // write
834 if( shouldFolderBeUpdated("/TRIGGER/LVL1/Menu") ) {
835 m_ostream << "Flushing LVL1 menu buffer to /TRIGGER/LVL1/Menu" << endl;
836 try {
837 lvl1MenuFolder->flushStorageBuffer();
838 }
839 catch ( cool::Exception & e) {
840 m_ostream << "WARNING: Flushing buffer to DB failed: " << e.what() << endl
841 << "warning will be ignored, job will continue" << endl;
842 }
843 }
844 if( shouldFolderBeUpdated("/TRIGGER/LVL1/ItemDef") ) {
845 m_ostream << "Flushing LVL1 item buffer to /TRIGGER/LVL1/ItemDef" << endl;
846 try {
847 lvl1ItemDefFolder->flushStorageBuffer();
848 }
849 catch ( cool::Exception & e) {
850 m_ostream << "WARNING: Flushing buffer to DB failed: " << e.what() << endl
851 << "warning will be ignored, job will continue" << endl;
852 }
853 }
854 }
855 } catch( cool::Exception & e) {
856 m_ostream << "Caught cool::Exception: " << e.what() << endl;
857 m_ostream << "Failed to write LVL1 menu to COOL" << endl;
858 throw;
859 } catch(std::exception & e) {
860 m_ostream << "<writeLVL1RunPayload> Caught std::exception: " << e.what() << endl;
861 throw;
862 }
863
864 writeL1CTPCoreInputMapping( vr, lvl1Menu );
865
866}
867
868
869
870void
872 const TrigConf::Menu& lvl1Menu)
873{
874 AutoDBOpen db(this, READ_WRITE);
875 for ( RunRange rr : runRanges)
876 writeL1MenuPayload( rr, lvl1Menu );
877}
878
879
880
881
882
883
884
885void
887 const Menu& lvl1Menu)
888{
889 if( ! shouldFolderBeUpdated("/TRIGGER/LVL1/CTPCoreInputMapping") )
890 return;
891
892 AutoDBOpen db(this, READ_WRITE);
893
894 // now write PIT mapping
895 try {
896
897 cool::IFolderPtr tipFolder = TrigConfCoolFolderSpec::getLvl1InputMapFolder(m_dbPtr);
898 tipFolder->setupStorageBuffer();
899
900 for ( const TIP * tip : lvl1Menu.tipVector() ) {
901
902 cool::ChannelId tipNum = static_cast<cool::ChannelId>(tip->tipNumber());
903
904 stringstream tipName;
905 tipName << "name:" << tip->thresholdName();
906 tipName << "|thresh bit:" << tip->thresholdBit();
907 tipName << "|pos:" << tip->thresholdMapping();
908 tipName << "|active:" << tip->thresholdActive();
909 tipName << "|ctpin slot:" << tip->slot();
910 tipName << "|con:" << tip->connector();
911 tipName << "|cable bit:" << tip->cableBit();
912 m_ostream << "Write TIP / channel " << tipNum << " : " << tipName.str() << endl;
913
914 Record payload = TrigConfCoolL1PayloadConverters::createLvl1InputMapPayload( tipFolder, *tip );
915 tipFolder->storeObject(vr.since(), vr.until(), payload, tipNum);
916 }
917 m_ostream << "Flushing LVL1 CTPInputMap buffer to /TRIGGER/LVL1/CTPCoreInputMapping" << endl;
918 tipFolder->flushStorageBuffer();
919 } catch( cool::Exception & e) {
920 m_ostream << "Caught cool::Exception: " << e.what() << endl;
921 m_ostream << "Failed to write LVL1 TIP mapping to COOL" << endl;
922 throw;
923 } catch( exception & e) {
924 m_ostream << "<writeLVL1RunPayload> Caught std::exception: " << e.what() << endl;
925 throw;
926 }
927}
928
929
930
931
932// ------------------------------------------------------------
933// writeLVL1BunchGroups()
934// ------------------------------------------------------------
935
936void
938 const Menu& lvl1Menu,
939 const BunchGroupSet& bgs)
940{
941 if( !shouldFolderBeUpdated("/TRIGGER/LVL1/BunchGroupDescription") ) return;
942 AutoDBOpen db(this, READ_WRITE);
944 rangeInfo("LVL1 bunch group descriptions", vr.since(), vr.until());
945 try {
946 IFolderPtr bgDescFolder = TrigConfCoolFolderSpec::getLvl1BGDescFolder(m_dbPtr);
947 Record payload = createLvl1BGDescPayload(bgDescFolder, bgs,lvl1Menu);
948 m_ostream << "Store LVL1 BG description buffer to /TRIGGER/LVL1/BunchGroupDescription" << endl;
949 bgDescFolder->storeObject(vr.since(), vr.until(), payload, 0);
950 }
951 catch(exception & e) {
952 m_ostream << "<writeL1BunchGroupRunPayload> caught and re-throw exception: " << e.what() << endl;
953 throw;
954 }
955}
956
957
958void
968
969
970void
972 unsigned int bgKey,
973 const TrigConf::BunchGroupSet& bgs)
974{
975 AutoDBOpen db(this, READ_WRITE);
976 for ( RunRange rr : runRanges) {
977 ValidityRange vr(rr);
978 writeL1BunchGroupLBPayload( rr, bgKey, bgs);
979 }
980}
981
982void
984 unsigned int bgKey,
985 const BunchGroupSet& bgs)
986{
987 AutoDBOpen db(this, READ_WRITE);
989 try {
990 if( shouldFolderBeUpdated("/TRIGGER/LVL1/BunchGroupKey") ) {
991 rangeInfo("LVL1 bunchgroup key", vr.since(), vr.until());
992 IFolderPtr lvl1BGKFolder = TrigConfCoolFolderSpec::getLvl1BGKeyFolder(m_dbPtr);
993 Record payload = createLvl1BGKeyPayload(lvl1BGKFolder, bgKey);
994 m_ostream << "Store LVL1 BG key to /TRIGGER/LVL1/BunchGroupKey" << endl;
995 lvl1BGKFolder->storeObject(vr.since(), vr.until(), payload, 0);
996 }
997
998 if( shouldFolderBeUpdated("/TRIGGER/LVL1/BunchGroupContent") ) {
999 rangeInfo("LVL1 bunchgroups", vr.since(), vr.until());
1000 IFolderPtr lvl1BGContentFolder = TrigConfCoolFolderSpec::getLvl1BGContentFolder(m_dbPtr);
1001 Record payload = createLvl1BGContentPayload(lvl1BGContentFolder, bgs);
1002 m_ostream << "Store LVL1 BG content to /TRIGGER/LVL1/BunchGroupContent" << endl;
1003 lvl1BGContentFolder->storeObject(vr.since(), vr.until(), payload, 0);
1004 }
1005 }
1006 catch(exception & e) {
1007 m_ostream << "<writeLVL1BGPayload> caugh and re-throw exception: " << e.what() << endl;
1008 throw;
1009 }
1010}
1011
1012
1013
1014
1015// ------------------------------------------------------------
1016// writeLbPayload()
1017// ------------------------------------------------------------
1018void
1020 const HLTPrescaleSet& pss)
1021{
1022 AutoDBOpen db(this, READ_WRITE);
1024 for ( RunRange rr : runRanges) {
1025 ValidityRange vr(rr);
1026 writeHltPrescalePayload( vr.since(), vr.until(), pss);
1027 }
1028}
1029
1030
1031void
1033 const HLTPrescaleSet& pss)
1034{
1035 AutoDBOpen db(this, READ_WRITE);
1037 ValidityRange vr(run, lb);
1038 writeHltPrescalePayload( vr.since(), vr.until(), pss);
1039}
1040
1041void
1043 ValidityKey until,
1044 const HLTPrescaleSet& pss)
1045{
1046
1047 AutoDBOpen db(this, READ_WRITE);
1048 // writing configuration keys and prescales
1049 try {
1050 if( shouldFolderBeUpdated("/TRIGGER/HLT/PrescaleKey") ) {
1051 cool::IFolderPtr hltpskFolder = TrigConfCoolFolderSpec::getHltPrescaleKeyFolder(m_dbPtr);
1052 rangeInfo("HLT prescale key", since, until);
1053 cool::Record payload = TrigConfCoolHLTPayloadConverters::createHltPrescaleKeyPayload(hltpskFolder, pss.id());
1054 m_ostream << "Store HLT prescale key " << pss.id() << " to /TRIGGER/HLT/PrescaleKey" << endl;
1055 hltpskFolder->storeObject(since, until, payload, 0);
1056 }
1057
1058 if( shouldFolderBeUpdated("/TRIGGER/HLT/Prescales") ) {
1059 rangeInfo("HLT prescale set", since, until);
1060 cool::IFolderPtr hltpssFolder = TrigConfCoolFolderSpec::getHltPrescalesFolder(m_dbPtr);
1061 // use buffer to speed up COOL writing
1062 hltpssFolder->setupStorageBuffer();
1063 m_ostream << "Writing (to buffer) HLT prescales [(value/channel)]:" << endl;
1064 // L2
1065 const uint ccmax = 8192; //pss.maxChainCounter(TrigConf::L2);
1066 uint printcount=0;
1067 for(uint cc=0; cc<ccmax; cc++) {
1068 if(!pss.hasPrescale( cc, TrigConf::L2 )) continue;
1069 const HLTPrescale& sc = pss.getPrescale( cc, L2 );
1070 cool::Record payload = TrigConfCoolHLTPayloadConverters::createHltPrescalesPayload(hltpssFolder, sc.prescale(), sc.pass_through(), sc.getRerunPrescale("").first);
1071 hltpssFolder->storeObject(since, until, payload, 2*cc);
1072 m_ostream << "(L2:" << sc.prescale() << "/" << cc << ") ";
1073 if((++printcount)%10==0) m_ostream << endl;
1074 }
1075 // EF
1076 m_ostream << endl;
1077 //ccmax = pss.maxChainCounter(TrigConf::EF);
1078 printcount=0;
1079 for(uint cc=0; cc<ccmax; cc++) {
1080 if(!pss.hasPrescale( cc, TrigConf::EF )) continue;
1081 const HLTPrescale& sc = pss.getPrescale( cc, EF );
1082 cool::Record payload = TrigConfCoolHLTPayloadConverters::createHltPrescalesPayload(hltpssFolder, sc.prescale(), sc.pass_through(), sc.getRerunPrescale("").first);
1083 hltpssFolder->storeObject(since, until, payload, 2*cc+1);
1084 m_ostream << "(EF:" << sc.prescale() << "/" << cc << ") ";
1085 if((++printcount)%10==0) m_ostream << endl;
1086 }
1087
1088 // merged HLT
1089 for(uint cc=0; cc<ccmax; cc++) {
1090 if(!pss.hasPrescale( cc, TrigConf::HLT )) continue;
1091 const HLTPrescale& sc = pss.getPrescale( cc, HLT );
1092 cool::Record payload = TrigConfCoolHLTPayloadConverters::createHltPrescalesPayload(hltpssFolder, sc.prescale(), sc.pass_through(), sc.getRerunPrescale("").first);
1093 hltpssFolder->storeObject(since, until, payload, 20000+cc); //shift block by 20 thousands
1094 m_ostream << "(HLT:" << sc.prescale() << "/" << 20000+cc << ") ";
1095 if((++printcount)%10==0) m_ostream << endl;
1096 }
1097
1098 m_ostream << "]" << endl;
1099 m_ostream << "Flushing HLT prescales buffer to /TRIGGER/HLT/Prescales" << endl;
1100 hltpssFolder->flushStorageBuffer();
1101 }
1102 }
1103 catch(exception & e) {
1104 m_ostream << "<writeHltPrescalePayload> caught and re-throw exception: " << e.what() << endl;
1105 throw;
1106 }
1107}
1108
1109void
1111 HLTPrescaleSet& pss) {
1112
1113 AutoDBOpen db(this, READ_ONLY);
1114 ValidityRange vr(run, lb);
1115 pss.reset();
1116
1117 // read the prescale key
1118 {
1120 IObjectIteratorPtr objects = hltpskFolder->browseObjects( vr.since(), vr.since()+1, 0 );
1121 if (not objects->goToNext()){
1122 throw std::runtime_error("'objects' is empty");
1123 }
1124 const IObject& obj = objects->currentRef();
1125 const IRecord & payload = obj.payload();
1126 unsigned int hltpsk = readHltPrescaleKey( payload.attributeList() );
1127 pss.setId(hltpsk);
1128
1129 }
1130
1131 // read the prescale set
1132 {
1133 float ps, pt, rrps;
1134 HLTLevel level;
1135 cool::IFolderPtr hltpssFolder = TrigConfCoolFolderSpec::getHltPrescalesFolder(m_dbPtr);
1136 cool::IObjectIteratorPtr objects = hltpssFolder->browseObjects( vr.since(), vr.since()+1, cool::ChannelSelection());
1137 bool iovset=false;
1138 while(objects->goToNext()) {
1139 const cool::IObject& obj = objects->currentRef();
1140 if(!iovset) {
1141 pss.setIOV(obj.since(), obj.until()); // assume the IOV of the first channel is like all the others
1142 iovset=true;
1143 }
1144 const ChannelId& ch = obj.channelId();
1145 const IRecord& payload = obj.payload();
1146 readHltPrescale( payload.attributeList(), ps, pt, rrps);
1147 unsigned int counter = ch/2;
1148
1149 if (ch >=20000 ) {
1150 level=HLT;
1151 counter = ch - 20000;
1152 } else
1153 level = (ch%2==0)?L2:EF;
1154
1155 pss.thePrescale( counter, level )
1156 .setPrescale(ps)
1157 .setPassThrough(pt)
1158 .setRerunPrescale("",rrps);
1159 }
1160 }
1161}
1162
1163
1164
1165
1166
1167void
1169 unsigned int lvl1PrescaleKey,
1170 const PrescaleSet & prescale)
1171{
1172 AutoDBOpen db(this, READ_WRITE);
1174 for ( RunRange rr : runRanges) {
1175 ValidityRange vr(rr);
1176 writeL1PrescalePayload( vr.since(), vr.until(), lvl1PrescaleKey, prescale);
1177 }
1178}
1179
1180
1181void
1183 unsigned int lvl1PrescaleKey,
1184 const PrescaleSet& prescaleSet)
1185{
1186 AutoDBOpen db(this, READ_WRITE);
1188 ValidityRange vr(run, lb);
1189 writeL1PrescalePayload( vr.since(), vr.until(), lvl1PrescaleKey, prescaleSet);
1190}
1191
1192void
1194 cool::ValidityKey until,
1195 unsigned int lvl1PrescaleKey,
1196 const TrigConf::PrescaleSet & prescaleSet)
1197{
1198 prescaleSet.print("",5);
1199 AutoDBOpen db(this, READ_WRITE);
1200 // writing configuration keys and prescales
1201 try {
1202 IFolderPtr lvl1CkConfFolder = TrigConfCoolFolderSpec::getLvl1ConfKeyFolder(m_dbPtr);
1203 if( shouldFolderBeUpdated("/TRIGGER/LVL1/Lvl1ConfigKey") ) {
1204 rangeInfo("LVL1 prescale key", since, until);
1205 cool::Record payload =
1206 TrigConfCoolL1PayloadConverters::createLvl1ConfigKeyPayload(lvl1CkConfFolder, lvl1PrescaleKey);
1207 m_ostream << "Store LVL1 prescale key " << lvl1PrescaleKey << " to /TRIGGER/LVL1/Lvl1ConfigKey" << endl;
1208 lvl1CkConfFolder->storeObject(since, until, payload, 0);
1209 }
1210
1211 if( shouldFolderBeUpdated("/TRIGGER/LVL1/Prescales") ) {
1212 rangeInfo("LVL1 prescale set", since, until);
1213 IFolderPtr lvl1PsConfFolder = TrigConfCoolFolderSpec::getLvl1PrescalesFolder(m_dbPtr);
1214 vector<int32_t> prescaleV = prescaleSet.cuts();
1215
1216 vector<int32_t>::const_iterator psIt = prescaleV.begin();
1217
1218 // use buffer to speed up COOL writing
1219 lvl1PsConfFolder->setupStorageBuffer();
1220
1221 m_ostream << "Writing (to buffer) LVL1 prescales [(value/channel)]:" << endl;
1222 for(int channel=0; psIt != prescaleV.end(); channel++, ++psIt) {
1223 Record payload =
1225 lvl1PsConfFolder->storeObject(since, until, payload, channel);
1226 m_ostream << "(" << *psIt << "/" << channel << ") ";
1227 if((channel+1)%10==0) m_ostream << endl;
1228 }
1229 m_ostream << "]" << endl;
1230 m_ostream << "Flushing LVL1 prescales buffer to /TRIGGER/LVL1/Prescales" << endl;
1231 lvl1PsConfFolder->flushStorageBuffer();
1232 }
1233 }
1234 catch(std::exception & e) {
1235 m_ostream << "<writeL1PrescalePayload> caught and re-throw exception: " << e.what() << endl;
1236 throw;
1237 }
1238
1239}
1240
1241
1242
1243
1244
1245
1246void
1248 HLTFrame & hltFrame)
1249{
1250 AutoDBOpen db(this, READ_ONLY);
1251 ValidityKey pointInTime( (ValidityKey(run)<<32) + 1);
1252
1253 // read the general chain info
1254 IFolderPtr hltMenuFolder = TrigConfCoolFolderSpec::getHltMenuFolder(m_dbPtr);
1255 IObjectIteratorPtr objects = hltMenuFolder->findObjects( pointInTime, ChannelSelection() );
1256 while ( objects->goToNext() ) {
1257 const IObject& obj = objects->currentRef();
1258 const IRecord & payload = obj.payload();
1259 HLTChain* ch = createHLTChain( payload.attributeList(), &hltFrame.theHLTSequenceList() );
1260 hltFrame.theHLTChainList().addHLTChain(ch);
1261 }
1262
1263 // read the chain groups (they are in a separate folder)
1264 IFolderPtr hltGroupFolder = TrigConfCoolFolderSpec::getHltChainGroupFolder(m_dbPtr);
1265 objects = hltGroupFolder->findObjects( pointInTime, ChannelSelection() );
1266 while ( objects->goToNext() ) {
1267 const IObject& obj = objects->currentRef();
1268 const IRecord & payload = obj.payload();
1269 addGroupsToHltChain( payload.attributeList(), hltFrame.theHLTChainList());
1270 }
1271
1272 IFolderPtr hltConfigKeyFolder = TrigConfCoolFolderSpec::getHltConfKeyFolder(m_dbPtr);
1273 try {
1274 IObjectPtr object = hltConfigKeyFolder->findObject( pointInTime, (ChannelId) 0 );
1275 const IRecord & payload = object->payload();
1276 unsigned int smk, hltPrescaleKey;
1277 string configSource;
1278 readHltConfigKeys( payload.attributeList(), smk, hltPrescaleKey, configSource ); // the hltPrescaleKey here is not useable (it is superseeded by the multiversion one)
1279 hltFrame.setSMK(smk);
1280 hltFrame.setConfigSource(configSource);
1281 }
1282 catch(const cool::ObjectNotFound& o) {
1283 m_ostream << "<readHLTPayload> No entry found in HLT keys folder for run " << run << endl;
1284 }
1285}
1286
1287void
1289 HLTFrame & hltFrame,
1290 unsigned int & masterConfigKey,
1291 unsigned int & /*hltPrescaleKey*/,
1292 string & configSource)
1293{
1294 readHLTPayload( run, hltFrame);
1295 masterConfigKey = hltFrame.smk();
1296 configSource = hltFrame.configSource();
1297}
1298
1299
1300void
1302 CTPConfig & ctpc)
1303{
1304
1309
1310 readL1Menu( run, ctpc );
1311}
1312
1313void
1315 vector<PIT*>& pits,
1316 vector<TIP*>& tips )
1317{
1318 AutoDBOpen db(this, READ_ONLY);
1319 ValidityRange vr(run, 1);
1320 IObjectIteratorPtr objects;
1322 vector<bool> foundTip(512,false);
1323 for(ChannelId channel = 0; channel < 512; ++channel) {
1324 objects = folder->browseObjects( vr.since(), vr.until()-1, channel );
1325 if(objects->size()==0) continue;
1326 while ( objects->goToNext() ) {
1327 const IObject& obj = objects->currentRef();
1328 const IRecord & payload = obj.payload();
1329 PIT* pit = readLvl1InputMap( payload.attributeList() );
1330 TIP* tip = readLvl1TIPMap( payload.attributeList() );
1331 uint16_t tipNumber = obj.channelId();
1332 if(tipNumber > 511) {
1333 m_ostream << "TIP number " << tipNumber << " out of bounds!" << endl;
1334 throw runtime_error("TIP number ouf ot bounds!");
1335 } else {
1336 if(foundTip[tipNumber]) {
1337 stringstream str;
1338 str << "TIP '" << tipNumber << "' had already been read!";
1339 throw runtime_error(str.str());
1340 }
1341 foundTip[tipNumber] = true;
1342 pit->setPitNumber(tipNumber);
1343 tip->setTipNumber(tipNumber);
1344 tip->setClock(tipNumber%2);
1345 pits.push_back(pit);
1346 tips.push_back(tip);
1347 }
1348 }
1349 }
1350}
1351
1352void
1354 vector<ThresholdMonitor*>& mons)
1355{
1356 AutoDBOpen db(this, READ_ONLY);
1357 ValidityRange vr(run, 1);
1358
1359 IObjectIteratorPtr objects;
1361 vector<bool> foundCounter(768,false);
1362
1363 for(ChannelId channel = 0; channel < 768; ++channel) {
1364
1365 objects = folder->browseObjects( vr.since(), vr.until()-1, channel );
1366 if(objects->size()==0) continue;
1367 while ( objects->goToNext() ) {
1368 const IObject& obj = objects->currentRef();
1369 const IRecord & payload = obj.payload();
1370 vector<ThresholdMonitor*> counters = readLvl1MonMap( payload );
1371 int counterNumber = obj.channelId();
1372 if(counterNumber > 768) {
1373 m_ostream << "Monitoring counter number " << counterNumber << " out of bounds!" << endl;
1374 throw runtime_error("Monitoring counter ouf of bounds!");
1375 } else {
1376 if(foundCounter[counterNumber]) {
1377 stringstream str;
1378 str << "MonCounter '" << counterNumber << "' had already been read!";
1379 throw runtime_error(str.str());
1380 }
1381 foundCounter[counterNumber] = true;
1382 for(size_t i = 0 ; i < counters.size(); ++i) {
1383 counters[i]->setInternalCounter(counterNumber);
1384 mons.push_back( counters[i] );
1385 }
1386 }
1387 }
1388 ++channel;
1389 }
1390}
1391
1392void
1394 vector<TriggerItem*>& items)
1395{
1396 AutoDBOpen db(this, READ_ONLY);
1397 ValidityRange vr(run, 1);
1398
1399 IObjectIteratorPtr objects;
1401 vector<bool> foundItem(512,false);
1402
1403 //for(ChannelId channel = 0; channel < 512; ++channel) {
1404 objects = folder->browseObjects( vr.since(), vr.until()-1,cool::ChannelSelection());
1405 //if(objects->size()==0) continue;
1406 while ( objects->goToNext() ) {
1407 const cool::IObject& obj = objects->currentRef();
1408 const cool::IRecord & payload = obj.payload();
1409 TriggerItem* item = createLvl1TriggerItem( payload.attributeList() );
1410 uint32_t ctpId = obj.channelId();
1411 if(ctpId > 511) {
1412 m_ostream << "Item ctpid " << ctpId << " out of bounds!" << endl;
1413 throw runtime_error("Item ctpid ouf ot bounds!");
1414 } else {
1415 if(foundItem[ctpId]) {
1416 stringstream str;
1417 str << "Item '" << ctpId << "' had already been read!";
1418 throw runtime_error(str.str());
1419 }
1420 foundItem[ctpId] = true;
1421 item->setCtpId(ctpId);
1422 items.push_back(item);
1423 }
1424 }
1425 // }
1426
1427}
1428
1429
1430void
1432 vector<TriggerThreshold*>& thrs) {
1433 AutoDBOpen db(this, READ_ONLY);
1434 ValidityRange vr(run, 1);
1435 thrs.clear();
1437 IObjectIteratorPtr objects = L1thrFolder->browseObjects( vr.since(), vr.until()-1, cool::ChannelSelection() );
1438 while ( objects->goToNext() ) {
1439 const IObject& obj = objects->currentRef();
1440 const IRecord & payload = obj.payload();
1441 thrs.push_back( createLvl1Threshold( payload.attributeList() ) );
1442 }
1443}
1444
1445
1446void
1448 const vector<TriggerItem*>& items,
1449 const vector<TriggerThreshold*>& thrs)
1450{
1451 AutoDBOpen db(this, READ_ONLY);
1452 ValidityRange vr(run, 1);
1453
1454 IFolderPtr L1ItemDefFolder = TrigConfCoolFolderSpec::getLvl1ItemDefFolder(m_dbPtr);
1455 for(TriggerItem* item: items) {
1456 ChannelId itemChannel = item->ctpId();
1457 IObjectIteratorPtr objects = L1ItemDefFolder->browseObjects( vr.since(), vr.until()-1, itemChannel );
1458 while ( objects->goToNext() ) {
1459 const IObject& obj = objects->currentRef();
1460 const IRecord & payload = obj.payload();
1461 addThresholdsToTriggerItem( payload.attributeList(), item, thrs);
1462 }
1463 }
1464}
1465
1466
1467void
1469{
1470 AutoDBOpen db(this, READ_ONLY);
1471
1472 Menu & menu = ctpc.menu();
1473
1474 // thresholds
1475 vector<TriggerThreshold*> thrs;
1476 readL1Thresholds(run, thrs);
1477
1483 bool isRun2 = false;
1484 for(TriggerThreshold* thr : thrs) {
1485 if( thr->cableName()=="EM1" || thr->cableName()=="EM2" ||
1486 thr->cableName()=="JET1" || thr->cableName()=="JET2" ||
1487 thr->cableName()=="TOPO1" || thr->cableName()=="TOPO2" ||
1488 thr->cableName()=="TAU1" || thr->cableName()=="TAU2") {
1489 isRun2 = true;
1490 break;
1491 }
1492 }
1493 ctpc.setCTPVersion(isRun2 ? 4 : 3);
1494 ctpc.setL1Version(isRun2 ? 1 : 0);
1496 cout << "TrigConfCoolWriter::readL1Menu for run " << run << ". Determined format " << (isRun2 ? "Run 2" : "Run 1") << endl;
1497
1498 // items
1499 vector<TriggerItem*> items;
1500 readL1Items(run, items);
1501 for(TriggerItem* item: items)
1502 menu.addTriggerItem(item);
1503
1504
1505 readL1ItemDef(run, items, thrs);
1506
1507 CaloInfo ci;
1508
1509 for(TriggerThreshold* thr: thrs) {
1510
1511 if ( thr->name()=="JetWeights" ) {
1512 if(!isRun2) {
1513 for ( const string& weights : split( thr->cableName(),",") )
1514 ci.addJetWeight( std::stoi(weights) );
1515 }
1516 }
1517 else if ( thr->name()=="METSigParams" ) {
1518 vector<string> metvals = split( thr->cableName(),",");
1519 int XSSigmaScale = std::stoi(metvals[0]);
1520 int XSSigmaOffset = std::stoi(metvals[1]);
1521 int XEmin = std::stoi(metvals[2]);
1522 int XEmax = std::stoi(metvals[3]);
1523 int TESqrtMin = std::stoi(metvals[4]);
1524 int TESqrtMax = std::stoi(metvals[5]);
1525 ci.metSigParam().setValues( XSSigmaScale, XSSigmaOffset,
1526 XEmin, XEmax, TESqrtMin, TESqrtMax);
1527 }
1528 else {
1529 // trigger thresholds sorted by type
1530 menu.thresholdConfig().addTriggerThreshold(thr);
1531 }
1532 }
1533 menu.setCaloInfo(ci);
1534
1535 // PITs (run1), TIPs (run2)
1536 vector<PIT*> pits;
1537 vector<TIP*> tips;
1538 readL1InputMapPayload(run, pits, tips);
1539 for ( PIT* pit : pits) {
1540 if(pit->ctpinSlot()==10) continue;
1541 menu.addPit(pit);
1542 }
1543 for ( TIP* tip : tips) {
1544 // cout << tip->tipNumber() << " : thr = " << tip->thresholdName() << ", slot = " << tip->slot() << ", conn = " << tip->connector() << ", thrBit = "
1545 // << tip->thresholdBit() << ", cableBit = " << tip->cableBit() << endl;
1546 menu.addTip(tip);
1547 }
1548}
1549
1550
1551pair< vector<string>, map<unsigned int,unsigned char> >
1553{
1554 AutoDBOpen db(this, READ_ONLY);
1555 ValidityRange vr(run);
1557 IObjectIteratorPtr objects = folder->browseObjects( vr.since(), vr.until()-1, 0 );
1558 if (not objects->goToNext()){
1559 throw std::runtime_error("TrigConfCoolWriter::readL1BunchGroupRunPayload: 'objects' is empty.");
1560 }
1561 const IObject& obj = objects->currentRef();
1562 const IRecord & payload = obj.payload();
1563 return readLvl1BGDesc( payload.attributeList() );
1564}
1565
1566
1567// ------------------------------------------------------------
1568// readLVL1BGPayload
1569// requires:
1570// runNumber, lumiblockNumber
1571// returns:
1572// Lvl1 BunchGroupSet
1573// lvl1BunchGroupKey
1574// ------------------------------------------------------------
1575void
1576TrigConfCoolWriter::readL1BunchGroupLBPayload( unsigned int run, unsigned int lb, int& bgKey,
1577 BunchGroupSet& bgs)
1578{
1579 AutoDBOpen db(this, READ_ONLY);
1580 ValidityRange vr(run,lb);
1581 vr.until() = vr.since(); // single LB
1582
1583 // read the bunch group key
1584 IFolderPtr lvl1BGKeyFolder = TrigConfCoolFolderSpec::getLvl1BGKeyFolder(m_dbPtr);
1585 IObjectIteratorPtr objects = lvl1BGKeyFolder->browseObjects( vr.since(), vr.until(), 0 );
1586 if (not objects->goToNext()){
1587 throw std::runtime_error("TrigConfCoolWriter::readL1BunchGroupLBPayload: 'objects' is empty.");
1588 }
1589 const IObject& obj = objects->currentRef();
1590 const IRecord & payload1 = obj.payload();
1591 bgKey = readLvl1BGKey( payload1.attributeList() );
1592
1593 // read the bunch group content
1594 IFolderPtr lvl1BGContentFolder = TrigConfCoolFolderSpec::getLvl1BGContentFolder(m_dbPtr);
1595 IObjectIteratorPtr objects2 = lvl1BGContentFolder->browseObjects( vr.since(), vr.until(), 0);
1596 if (not objects2->goToNext()){
1597 throw std::runtime_error("TrigConfCoolWriter::readL1BunchGroupLBPayload: 'objects2' is empty.");
1598 }
1599 const IObject& obj2 = objects2->currentRef();
1600 const IRecord & payload2 = obj2.payload();
1601 vector<BunchGroup> bgV = readLvl1BGContent( payload2.attributeList() );
1602
1603 // read the bunch group names
1604 pair< vector<string>, map<unsigned int,unsigned char> > bg_pair = readL1BunchGroupRunPayload(run);
1605 vector<string> names = bg_pair.first;
1606
1607
1608
1609 uint newBGSSize = bgV.size() <= names.size() ? bgV.size() : names.size();
1610
1611 if(bgV.size() != names.size()) {
1612 cout << "WARNING Bunchgroup content vector is of size " << bgV.size()
1613 << ", which is different from the size of the names vector: " << names.size()
1614 << ". Using " << newBGSSize << endl;
1615
1616 }
1617
1618 // create a new bunch group set, set names and bunch groups
1619 bgs = BunchGroupSet();
1620 for(unsigned int i=0; i<newBGSSize; i++) {
1621 string bgname = names[i];
1622 if(bgname=="") bgname = "NoName";
1623 bgV[i].setName(bgname);
1624 bgV[i].setInternalNumber(i);
1625 bgs.addBunchGroup(bgV[i]);
1626 }
1627 bgs.setId(bgKey);
1628}
1629
1630
1631// ------------------------------------------------------------
1632// readLbPayload
1633// requires:
1634// runNumber, lumiblockNumber
1635// returns:
1636// Lvl1 prescales
1637// lvl1PrescaleKey
1638// ------------------------------------------------------------
1639void
1641 unsigned int& lvl1PrescaleKey,
1642 PrescaleSet & prescale)
1643{
1644 AutoDBOpen db(this, READ_ONLY);
1645 ValidityRange vr(run,lb);
1646 vr.until() = vr.since()+1; // single LB
1647
1648 IFolderPtr lvl1CkFolder = TrigConfCoolFolderSpec::getLvl1ConfKeyFolder(m_dbPtr);
1649 IObjectIteratorPtr objects = lvl1CkFolder->browseObjects( vr.since(), vr.since()+1, 0 );
1650 if (not objects->goToNext()){
1651 throw std::runtime_error("TrigConfCoolWriter::readL1PrescalePayload: 'objects' is empty.");
1652 }
1653 const IObject& obj = objects->currentRef();
1654 const IRecord & payload = obj.payload();
1655 readLvl1ConfigKey( payload.attributeList(), lvl1PrescaleKey );
1656 cool::IFolderPtr lvl1PsFolder = TrigConfCoolFolderSpec::getLvl1PrescalesFolder(m_dbPtr);
1657
1658 // resize the vector to the correct size
1659 size_t nPrescales = lvl1PsFolder->listChannels().size();
1660 bool isRun2 = ( nPrescales == 512 );
1661 prescale.resize( nPrescales );
1662
1663 for(cool::ChannelId channel = 0; channel < nPrescales; channel++) {
1664 objects = lvl1PsFolder->browseObjects( vr.since(), vr.until(), channel );
1665 if(objects->size()!=1) {
1666 throw std::runtime_error("Lvl1 prescale access error: found empty prescale channel ");
1667 }
1668 //already checked size, so this should be ok
1669 (void)objects->goToNext();
1670 const IObject& obj = objects->currentRef();
1671 const IRecord & payload = obj.payload();
1672 int64_t prescaleVal=0;
1673 readLvl1Prescale( payload.attributeList(), prescaleVal );
1674 if( isRun2 ) {
1675 prescale.setCut( channel, prescaleVal );
1676 } else {
1677 prescale.setPrescale( channel, (float)prescaleVal );
1678 }
1679 }
1680 prescale.setId( lvl1PrescaleKey );
1681}
1682
1683
1684bool
1686 AutoDBOpen db(this, READ_ONLY);
1687 return m_dbPtr->existsFolder( "/TRIGGER/HLT/Prescales" );
1688}
1689
1690
1691/*------------------------------------------------------------
1692 Shows status of all folders for a certain run
1693 (starting at lb)
1694
1695 displayMode : 0 - no indicator index
1696 1 - indicator index in front of empty
1697 folders
1698 2 - indicator index in front of empty
1699 and multiversion folders
1700 *-----------------------------------------------------------*/
1701
1702vector<string>
1703TrigConf::TrigConfCoolWriter::checkPayloadSize(unsigned int run, unsigned int lb, int displayMode, bool openend, unsigned int lbend) {
1704 AutoDBOpen db(this, READ_ONLY);
1705
1706
1707 ValidityRange vr(run);
1708
1709 if(openend) {
1710 vr = ValidityRange(run, lb);
1711 } else {
1712 ValidityKey since(run); since <<= 32; since += lb;
1713 ValidityKey until(run); until <<= 32; until += lbend+1;
1714 vr = ValidityRange(since, until);
1715 }
1716 m_ostream << "Checking for run " << run << " and lb range " << (vr.since() & 0xFFFFFFFF) << " - " << ( (vr.until()-1) & 0xFFFFFFFF) << endl
1717 << endl
1718 << " Folder Payload Size" << endl
1719 << "================================================================================" << endl;
1720
1721 vector<string> foldersToFix;
1722
1723 vector<string> folderList = {
1724 "/TRIGGER/LVL1/Menu",
1725 "/TRIGGER/LVL1/ItemDef",
1726 "/TRIGGER/LVL1/Thresholds",
1727 "/TRIGGER/LVL1/CTPCoreInputMapping",
1728 "/TRIGGER/LVL1/Lvl1ConfigKey",
1729 "/TRIGGER/LVL1/Prescales",
1730 "/TRIGGER/LVL1/BunchGroupKey",
1731 "/TRIGGER/LVL1/BunchGroupContent",
1732 "/TRIGGER/LVL1/BunchGroupDescription",
1733 "/TRIGGER/HLT/HltConfigKeys",
1734 "/TRIGGER/HLT/Menu",
1735 "/TRIGGER/HLT/Groups",
1736 "/TRIGGER/HLT/PrescaleKey",
1737 "/TRIGGER/HLT/Prescales"
1738 };
1739
1740 for(const string & folderName : folderList) {
1741 IFolderPtr folder = m_dbPtr->getFolder( folderName );
1742 unsigned int size = folder->countObjects( vr.since(), vr.until()-1, ChannelSelection() );
1743 bool isSingleVersion = folder->versioningMode()==FolderVersioning::SINGLE_VERSION;
1744 bool needsFixing = (size == 0);
1745
1746 bool displayFixing = false;
1747 if(displayMode==1) { // only allow fixing of folders that are empty
1748 displayFixing = (size == 0);
1749 } else if(displayMode==2) { // allow fixing of folders that are empty or mv
1750 displayFixing = (size == 0) || !isSingleVersion;
1751 }
1752
1753 string fn = folderName + (isSingleVersion ? " (sv)" : " (mv)");
1754 if(displayFixing) {
1755 m_ostream << setw(2) << foldersToFix.size()+1 << ") ";
1756 foldersToFix.push_back(folderName);
1757 } else {
1758 m_ostream << " ";
1759 }
1760 m_ostream << left << setw(40) << fn << right << setw(15) << size << " " << ( needsFixing ? "NEEDS FIX" : " OK") << endl;
1761 }
1762
1763 return foldersToFix;
1764
1765}
const boost::regex rr(r_r)
std::shared_ptr< HepMC3::Writer > writer
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
unsigned int uint
static Double_t sc
size_t size() const
Number of registered mappings.
#define READ_ONLY
#define READ_WRITE
AutoDBOpen(TrigConfCoolWriter *writer, bool readOnly)
TrigConfCoolWriter * m_writer
void addBunchGroup(const BunchGroup &)
unsigned int l1Version() const
Definition CTPConfig.h:35
const BunchGroupSet & bunchGroupSet() const
Definition CTPConfig.h:41
const Menu & menu() const
Definition CTPConfig.h:39
const PrescaleSet & prescaleSet(unsigned int partition=0) const
Definition CTPConfig.h:40
void setL1Version(unsigned int v)
Definition CTPConfig.cxx:37
void setCTPVersion(unsigned int v)
Definition CTPConfig.cxx:31
const std::vector< int > & jetWeights() const
Definition CaloInfo.h:46
METSigParam & metSigParam()
Definition CaloInfo.h:50
void addJetWeight(int)
Definition CaloInfo.cxx:29
bool addHLTChain(HLTChain *ch)
adds an HLTChain to the menu
HLT chain configuration information.
The HLT trigger menu,.
Definition HLTFrame.h:33
const std::string & configSource() const
Definition HLTFrame.h:54
HLTSequenceList & theHLTSequenceList()
accessor to the list of HLT sequences
Definition HLTFrame.h:45
const HLTPrescaleSetCollection & getPrescaleSetCollection() const
Definition HLTFrame.h:51
HLTChainList & theHLTChainList()
accessor to the list of HLT chains
Definition HLTFrame.h:44
const HLTChainList & getHLTChainList() const
const accessor to the list of HLT chains
Definition HLTFrame.h:49
void setConfigSource(const std::string &src)
Definition HLTFrame.h:59
HLT chain configuration information.
void setIOV(uint32_t start_run, uint32_t start_lb, uint32_t end_run, uint32_t end_lb)
sets the IOV of the prescale set
bool hasPrescale(unsigned int counter, TrigConf::HLTLevel level=HLT) const
HLTPrescale & thePrescale(unsigned int chain_counter, HLTLevel level)
const HLTPrescale & getPrescale(unsigned int chain_counter, HLTLevel level=HLT) const
HLTPrescale & setRerunPrescale(const std::string &targetName, float ps)
HLTPrescale & setPassThrough(float pass_through)
Definition HLTPrescale.h:47
HLTPrescale & setPrescale(float prescale)
Definition HLTPrescale.h:46
static std::set< std::string > allTEsProduced(const TrigConf::HLTFrame &frame)
static std::string ChainCondenseDisplay(const HLTChain &chain, const HLTFrame &frame)
static void setMaxThresholdsFromL1Version(unsigned int l1version)
Definition L1DataDef.cxx:65
virtual void print(const std::string &indent="", unsigned int detail=1) const
void setValues(int XSSigmaScale, int XSSigmaOffset, int XEmin, int XEmax, int TESqrtMin, int TESqrtMax)
const std::vector< ThresholdMonitor * > & moncountVector() const
Definition Menu.h:69
const CaloInfo & caloInfo() const
Definition Menu.h:74
const ThresholdConfig & thresholdConfig() const
Definition Menu.h:73
const ItemContainer & items() const
Definition Menu.h:140
const std::vector< TIP * > & tipVector() const
Definition Menu.h:71
void setPitNumber(const uint16_t &pitnumber)
Definition PIT.h:30
void setPrescale(unsigned int num, int64_t prescaleValue) __attribute__((deprecated))
Set the prescale NUM from the int64 value prescaleValue.
virtual void print(const std::string &indent="", unsigned int detail=1) const override
void setCut(unsigned int num, int32_t cut)
const std::vector< int32_t > & cuts() const
Definition PrescaleSet.h:44
void resize(size_t size)
void setTipNumber(const uint16_t &tipnumber)
Definition TIP.h:30
void setClock(const int &clock)
Definition TIP.h:54
const std::vector< TriggerThreshold * > & thresholdVector(L1DataDef::TriggerType) const
unsigned int l1Version() const
static cool::IFolderSetPtr createMonFolderStructure(cool::IDatabasePtr db, int schemaVersion=0)
creates the folder structure in the monitoring COOL database
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::IFolderPtr getHltChainGroupFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1ConfKeyFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getHltMenuFolder(cool::IDatabasePtr db)
static int readSchemaVersion(cool::IDatabasePtr db)
get the version of the COOL database
static cool::IFolderPtr getMonConfKeyFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1ItemDefFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1BGContentFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getHltConfKeyFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1PrescalesFolder(cool::IDatabasePtr db)
static int getDefaultSchemaVersion()
access to the version
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::IFolderPtr getLvl1BGDescFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1BGKeyFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1ThresholdFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1InputMapFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getLvl1MenuFolder(cool::IDatabasePtr db)
static cool::IFolderPtr getHltPrescalesFolder(cool::IDatabasePtr db)
Reading/Writing of trigger configuration data from/to COOL.
void writeL1BunchGroupRunPayload(ValidityRange vr, const Menu &lvl1Menu, const BunchGroupSet &bgs)
Writing run-wise L1 bunch group names and item to bunch group mapping to COOL.
bool dbIsOpen()
check if db is open
void closeDb(cool::IDatabasePtr &db)
close the COOL database
void printSchema(std::ostream &o)
Prints the schema in the COOL database.
void readL1Thresholds(unsigned int runNumber, std::vector< TrigConf::TriggerThreshold * > &thrs)
Read run-wise L1 threshold vector from COOL database.
bool checkDbConnection(bool readonly)
void writeHltPrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, const TrigConf::HLTPrescaleSet &pss)
Writing luminosityblock-wise configuration information the COOL database.
void writeL1CTPCoreInputMapping(ValidityRange vr, const Menu &lvl1Menu)
void writeL1MenuPayload(ValidityRange vr, const TrigConf::Menu &lvl1Menu)
Writing L1 run-wise configuration information to the COOL database.
void readL1BunchGroupLBPayload(unsigned int runNumber, unsigned int lumiblockNumber, int &bgKey, TrigConf::BunchGroupSet &bgs)
Reading lb-wise bunch group configuration information from COOL database.
void writeL1PrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, unsigned int lvl1PrescaleKey, const TrigConf::PrescaleSet &prescale)
Writing luminosityblock-wise configuration information the COOL database.
void readL1InputMapPayload(unsigned int runNumber, std::vector< TrigConf::PIT * > &pits, std::vector< TrigConf::TIP * > &tips)
Read run-wise PIT configuration from COOL database.
bool shouldFolderBeUpdated(const std::string &foldername)
check if foldername is in list of writeable folders
std::pair< std::vector< std::string >, std::map< unsigned int, unsigned char > > readL1BunchGroupRunPayload(unsigned int runNumber)
Reading bunch group configuration information from COOL database.
void readL1Payload(unsigned int run, CTPConfig &ctpc)
void readL1Menu(unsigned int runNumber, CTPConfig &ctpc)
Read L1 menu from COOL database.
cool::IDatabasePtr openDb(bool readOnly=true)
open COOL db connection
void writeL1MonPayload(unsigned int runNumber, const TrigConf::Menu *lvl1Menu)
Writing L1 run-wise monitoring configuration to COOL.
void readHltPrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, TrigConf::HLTPrescaleSet &pss)
Reading luminosityblock-wise configuration information the COOL database.
cool::Application m_coolApp
COOL application.
void rangeInfo(const std::string &content, cool::ValidityKey since, cool::ValidityKey until)
void writeRunPayload(unsigned int runNumber, unsigned int masterConfigKey, unsigned int hltPrescaleKey, const TrigConf::ThresholdConfig &lvl1Thr, const TrigConf::CTPConfig &ctpConfig, const TrigConf::CaloInfo &caloInfo, const TrigConf::HLTFrame &hltFrame, const std::string &configSource)
Writing run-wise configuration information the COOL database.
void recreateSchema(int schemaVersion=0)
Create a new schema in the COOL database with prior deletion of the old one.
cool::IDatabasePtr m_dbPtr
COOL database pointer.
void createSchema(int schemaVersion=0)
Create a new schema in the COOL database.
void printSchemaVersion(std::ostream &o)
Prints the schema in the COOL database.
void dropDb()
delete the COOL database
cool::IDatabaseSvc & databaseService()
get COOL db service
void readL1PrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, unsigned int &lvl1PrescaleKey, TrigConf::PrescaleSet &prescale)
Reading luminosityblock-wise configuration information the COOL database.
void writeHLTPayload(ValidityRange vr, const HLTFrame &hltFrame, const std::string &configSource)
std::ostream & m_ostream
output stream for all messages
void readRunPayload(unsigned int runNumber, TrigConf::HLTFrame &hltFrame, unsigned int &masterConfigKey, unsigned int &hltPrescaleKey, std::string &configSource)
Reading run-wise configuration information from COOL database.
void readL1Items(unsigned int runNumber, std::vector< TrigConf::TriggerItem * > &items)
Read run-wise L1 item vector from COOL database.
void writeMCKPayload(ValidityRange vr, unsigned int mck, std::string &release, std::string &info)
cool::DatabaseId m_dbId
db connection string
void writeL1Payload(ValidityRange vr, const CTPConfig &ctpConfig)
void readL1MonMapPayload(unsigned int runNumber, std::vector< TrigConf::ThresholdMonitor * > &mons)
Read run-wise LVL1 monitoring configuration from COOL database.
cool::IDatabasePtr createDb()
create a new COOL database
void writeL1BunchGroupLBPayload(const RunRangeVec &runRanges, unsigned int bgKey, const BunchGroupSet &bgs)
Writing LB-wise L1 bunch group definition to the COOL database.
void readHLTPayload(unsigned int run, HLTFrame &hltFrame)
void readL1ItemDef(unsigned int runNumber, const std::vector< TrigConf::TriggerItem * > &items, const std::vector< TrigConf::TriggerThreshold * > &thrs)
Read run-wise L1 item defintions (conditions) from COOL database.
std::vector< std::string > checkPayloadSize(unsigned int run, unsigned int lb, int displayMode, bool openend, unsigned int lbend)
unsigned int id() const
void setId(unsigned int id)
unsigned int smk() const
void setCtpId(int id)
Definition TriggerItem.h:46
make the sidebar many part of the config
Definition hcg.cxx:554
static std::string release
Definition computils.h:50
int lb
Definition globals.cxx:23
static std::vector< uint32_t > lbend
Definition iLumiCalc.h:39
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
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
std::vector< TrigConf::ThresholdMonitor * > readLvl1MonMap(const cool::IRecord &payload)
Build a LVL1 mon counter object from COOL payload.
cool::Record createLvl1MonMapPayload(cool::IFolderPtr, const std::string &type, const uint16_t &bgId, const std::string &threshName, const std::string &slot, const std::string &con, const std::string &mult, const std::string &start, const std::string &end, const std::string &active, const std::string &monName=std::string(""), const std::string &CounterLogic=std::string(""))
build a COOL db record from a monitoring-mapping string value
cool::Record createLvl1METSigPayload(cool::IFolderPtr, const METSigParam &metSigParams)
build a COOL db record from a L1 MET significance global parameters
cool::Record createLvl1ConfigKeyPayload(cool::IFolderPtr, unsigned int lvl1PrescaleKey)
build a COOL db record from a LVL1 configuration key
std::pair< std::vector< std::string >, std::map< unsigned int, unsigned char > > readLvl1BGDesc(const coral::AttributeList &al)
build the LVL1 Bunchgroup descriptions from a coral::AttributeList
cool::Record createLvl1BGKeyPayload(cool::IFolderPtr, unsigned int lvl1BunchgroupKey)
build a COOL db record from a LVL1 bunch group key
cool::Record createLvl1MenuPayload(cool::IFolderPtr, const TrigConf::TriggerItem &item)
build a COOL db record from a LVL1 TriggerItem (the item name and version)
cool::Record createLvl1PrescalesPayload(cool::IFolderPtr, int prescale)
build a COOL db record from a LVL1 prescale value
TrigConf::PIT * readLvl1InputMap(const coral::AttributeList &al)
Build a LVL1 PIT object from COOL payload.
TrigConf::TIP * readLvl1TIPMap(const coral::AttributeList &al)
void readLvl1Prescale(const coral::AttributeList &al, int &ps)
build the LVL1 prescale value from a coral::AttributeList
cool::Record createLvl1BGDescPayload(cool::IFolderPtr fld, const TrigConf::BunchGroupSet &bgs, const TrigConf::Menu &lvl1Menu)
build a COOL db record from a bunch group description
cool::Record createLvl1BGContentPayload(cool::IFolderPtr fld, const TrigConf::BunchGroupSet &bgs)
build a COOL db record from a bunch group definition value
cool::Record createLvl1ItemDefPayload(cool::IFolderPtr, const TrigConf::TriggerItem &item)
build a COOL db record from a LVL1 TriggerItem (the conditions)
void readLvl1ConfigKey(const coral::AttributeList &al, unsigned int &lvl1PrescaleKey)
build the LVL1 configuration key from a coral::AttributeList
std::vector< TrigConf::BunchGroup > readLvl1BGContent(const coral::AttributeList &al)
build the LVL1 Bunchgroup code
TriggerItem * createLvl1TriggerItem(const coral::AttributeList &al)
build a LVL1 TriggerItem from a COOL db record
cool::Record createLvl1InputMapPayload(cool::IFolderPtr, const TrigConf::TIP &tip)
build a COOL db record from a PIT-mapping string value
cool::Record createLvl1ThresholdPayload(cool::IFolderPtr, const TrigConf::TriggerThreshold &thr)
build a COOL db record from a LVL1 TriggerItem
void addThresholdsToTriggerItem(const coral::AttributeList &al, TriggerItem *item, const std::vector< TrigConf::TriggerThreshold * > &thrs)
build a TriggerThreshold definition from a COOL db record and add to the corresponding item
TriggerThreshold * createLvl1Threshold(const coral::AttributeList &al)
build a LVL1 TriggerThreshold from a COOL db record
cool::Record createLvl1JetWeightPayload(cool::IFolderPtr, const std::vector< int > &jetweights)
build a COOL db record from a L1 Jet Weights vector
int readLvl1BGKey(const coral::AttributeList &al)
build the LVL1 Bunchgroup key value
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=" ")
std::pair< unsigned int, unsigned int > RunRange
std::vector< RunRange > RunRangeVec
Definition index.py:1
STL namespace.
int run(int argc, char *argv[])