ATLAS Offline Software
Loading...
Searching...
No Matches
ReadLumiBlock Class Reference

Helper class to read in lumi block length info from COOL for a run. More...

#include <ReadLumiBlock.h>

Inheritance diagram for ReadLumiBlock:
Collaboration diagram for ReadLumiBlock:

Public Member Functions

 ReadLumiBlock ()
 Construct helper class for reading in lumi block length from COOL.
 ~ReadLumiBlock ()
bool updateLumiBlocks (uint32_t run, MsgStream &msg)
 Load information for.
float getLumiBlockLength (uint32_t lb, MsgStream &msg) const
void setConnectionCOOL (const std::string &id)
 Set which COOL instance to connect to (run1, run2)
bool getTriedSetup ()
 True when a connection attempt has been made.
cool::DatabaseId & cool_id ()
 Get reference to COOL database ID.
cool::IDatabasePtr & cool_ptr ()
 Get reference to COOL database ptr.
const std::string & cool_source () const
 Get name of COOL data source.
uint32_t getRun () const
 Get run number.

Private Member Functions

bool dbIsOpen ()
 Check if DB connection is open.
void closeDb (MsgStream &msg)
 Close DB connection.
bool openDb (bool readOnly, MsgStream &msg)
 Open a DB connection.

Private Attributes

std::map< uint32_t, uint64_t > m_lbLength
cool::DatabaseId m_cool_id
cool::DatabaseId m_cool_id_run1
cool::DatabaseId m_cool_id_run2
cool::IDatabasePtr m_cool_ptr
std::string m_cool_source
uint32_t m_run
bool m_triedSetup

Detailed Description

Helper class to read in lumi block length info from COOL for a run.

Definition at line 28 of file ReadLumiBlock.h.

Constructor & Destructor Documentation

◆ ReadLumiBlock()

ReadLumiBlock::ReadLumiBlock ( )

Construct helper class for reading in lumi block length from COOL.

Definition at line 26 of file ReadLumiBlock.cxx.

27 :m_cool_id(),
28 m_cool_id_run1("COOLONL_TRIGGER/COMP200"),
29 m_cool_id_run2("COOLONL_TRIGGER/CONDBR2"),
31 m_run(0),
32 m_triedSetup(false)
33{
34}
cool::DatabaseId m_cool_id_run1
cool::DatabaseId m_cool_id
std::string m_cool_source
cool::DatabaseId m_cool_id_run2

◆ ~ReadLumiBlock()

ReadLumiBlock::~ReadLumiBlock ( )

Definition at line 37 of file ReadLumiBlock.cxx.

38{
39}

Member Function Documentation

◆ closeDb()

void ReadLumiBlock::closeDb ( MsgStream & msg)
private

Close DB connection.

Definition at line 138 of file ReadLumiBlock.cxx.

139{
140 try {
141 if(dbIsOpen()) {
142 msg << MSG::DEBUG << "ReadLumiBlock::closeDd - closing database '" << m_cool_id << endmsg;
143 m_cool_ptr->closeDatabase();
144 }
145 } catch(std::exception& e) {
146 msg << MSG::ERROR << "ReadLumiBlock::closeDB - COOL exception caught: " << e.what() << endmsg;
147 msg << MSG::ERROR << " could not close COOL database: " << m_cool_id << endmsg;
148 }
149 return;
150}
#define endmsg
cool::IDatabasePtr m_cool_ptr
bool dbIsOpen()
Check if DB connection is open.
MsgStream & msg
Definition testRead.cxx:32

◆ cool_id()

cool::DatabaseId & ReadLumiBlock::cool_id ( )
inline

Get reference to COOL database ID.

Definition at line 43 of file ReadLumiBlock.h.

◆ cool_ptr()

cool::IDatabasePtr & ReadLumiBlock::cool_ptr ( )
inline

Get reference to COOL database ptr.

Definition at line 44 of file ReadLumiBlock.h.

◆ cool_source()

const std::string & ReadLumiBlock::cool_source ( ) const
inline

Get name of COOL data source.

Definition at line 46 of file ReadLumiBlock.h.

◆ dbIsOpen()

bool ReadLumiBlock::dbIsOpen ( )
private

Check if DB connection is open.

Definition at line 113 of file ReadLumiBlock.cxx.

114{
115 return m_cool_ptr.use_count() > 0 && m_cool_ptr->isOpen();
116}

◆ getLumiBlockLength()

float ReadLumiBlock::getLumiBlockLength ( uint32_t lb,
MsgStream & msg ) const
Returns
Length of lb

Definition at line 102 of file ReadLumiBlock.cxx.

103{
104
105 if (m_lbLength.count(lb) != 1) {
106 msg << MSG::INFO << "Unknown lumiblock number " << lb << endmsg;
107 return 60.0; // Sensible default
108 }
109 return m_lbLength.at(lb) * 1e-9; // Convert from ns
110}
std::map< uint32_t, uint64_t > m_lbLength
int lb
Definition globals.cxx:23

◆ getRun()

uint32_t ReadLumiBlock::getRun ( ) const
inline

Get run number.

Definition at line 48 of file ReadLumiBlock.h.

◆ getTriedSetup()

bool ReadLumiBlock::getTriedSetup ( )
inline

True when a connection attempt has been made.

Definition at line 41 of file ReadLumiBlock.h.

◆ openDb()

bool ReadLumiBlock::openDb ( bool readOnly,
MsgStream & msg )
private

Open a DB connection.

Definition at line 119 of file ReadLumiBlock.cxx.

120{
121 if(dbIsOpen()) return true;
122
123 try {
124 msg << MSG::DEBUG << "ReadLumiBlock::openDb - opening database '" << m_cool_id << "'" << endmsg;
125 m_cool_ptr = databaseService().openDatabase(m_cool_id, readOnly);
126
127 return true;
128 } catch(cool::DatabaseDoesNotExist& e) {
129 msg << MSG::ERROR << "ReadLumiBlock::openDb - COOL exception caught: " << e.what() << endmsg;
130 msg << MSG::ERROR << " could not open database: " << m_cool_id << endmsg;
131 return false;
132 }
133
134 return false;
135}

◆ setConnectionCOOL()

void ReadLumiBlock::setConnectionCOOL ( const std::string & id)
inline

Set which COOL instance to connect to (run1, run2)

Definition at line 40 of file ReadLumiBlock.h.

◆ updateLumiBlocks()

bool ReadLumiBlock::updateLumiBlocks ( uint32_t run,
MsgStream & msg )

Load information for.

Parameters
run

Definition at line 42 of file ReadLumiBlock.cxx.

43{
44 //
45 // Read configuration keys from COOL
46 //
47 m_triedSetup = true;
48 m_cool_source.clear();
49 m_run = run;
50
51 if (m_run < 238742) m_cool_id = m_cool_id_run1;
53
54 cool::ValidityKey since(run);
55 cool::ValidityKey until(run);
56 cool::ValidityKey maskLB(0xffffffff);
57
58 since <<= 32; // upper 31 bits are run number
59 until <<= 32; // upper 31 bits are run number
60 until += maskLB;
61
62 if (!dbIsOpen()) {
63 if (!openDb(true, msg)) {
64 msg << MSG::FATAL << "updateLumiBlocks - failed to open DB... " << m_cool_id << endmsg;
65 return false;
66 }
67 }
68
69 if (m_cool_ptr->existsFolder("/TRIGGER/LUMI/LBLB")) {
70
71 msg << MSG::INFO << "ReadRunData - reading folder: /TRIGGER/LUMI/LBLB" << endmsg;
72
73 cool::IFolderPtr folderLB = m_cool_ptr->getFolder("/TRIGGER/LUMI/LBLB");
74 cool::IObjectIteratorPtr objectsLB = folderLB->browseObjects(since, until, 0);
75
76 while ( objectsLB -> goToNext() ) {
77 const cool::IObject &obj = objectsLB->currentRef();
78 const cool::IRecord &payload = obj.payload();
79 const uint32_t lumi = (obj.since() & 0xffff);
80
81 const uint64_t start = payload["StartTime"].data<cool::UInt63>();
82 const uint64_t end = payload["EndTime"].data<cool::UInt63>();
83 const uint64_t length = end - start;
84
86
87 msg << MSG::DEBUG << " run=" << run
88 << " LB=" << lumi
89 << " Start=" << start
90 << " End=" << end
91 << " Length=" << length << endmsg;
92 }
93 } else {
94 msg << MSG::INFO << "ReadRunData - missing COOL folder: /TRIGGER/LUMI/LBLB in " << m_cool_id << endmsg;
95 }
96 // more lumi info can be got from http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Trigger/TrigCost/TrigCostRate/src/ReadCool.cxx
97
98 closeDb(msg);
99 return true;
100}
double length(const pvec &v)
void closeDb(MsgStream &msg)
Close DB connection.
bool openDb(bool readOnly, MsgStream &msg)
Open a DB connection.
setEventNumber uint32_t

Member Data Documentation

◆ m_cool_id

cool::DatabaseId ReadLumiBlock::m_cool_id
private

Definition at line 60 of file ReadLumiBlock.h.

◆ m_cool_id_run1

cool::DatabaseId ReadLumiBlock::m_cool_id_run1
private

Definition at line 61 of file ReadLumiBlock.h.

◆ m_cool_id_run2

cool::DatabaseId ReadLumiBlock::m_cool_id_run2
private

Definition at line 62 of file ReadLumiBlock.h.

◆ m_cool_ptr

cool::IDatabasePtr ReadLumiBlock::m_cool_ptr
private

Definition at line 63 of file ReadLumiBlock.h.

◆ m_cool_source

std::string ReadLumiBlock::m_cool_source
private

Definition at line 65 of file ReadLumiBlock.h.

◆ m_lbLength

std::map<uint32_t, uint64_t> ReadLumiBlock::m_lbLength
private

Definition at line 58 of file ReadLumiBlock.h.

◆ m_run

uint32_t ReadLumiBlock::m_run
private

Definition at line 66 of file ReadLumiBlock.h.

◆ m_triedSetup

bool ReadLumiBlock::m_triedSetup
private

Definition at line 67 of file ReadLumiBlock.h.


The documentation for this class was generated from the following files: