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