ATLAS Offline Software
ReadLumiBlock.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIG_ReadLumiBlock_H
6 #define TRIG_ReadLumiBlock_H
7 
8 //
9 // Connect to COOL and get LB lengths for a run
10 //
11 
12 // COOL
13 #include "CoolApplication/Application.h"
14 #include "CoolKernel/DatabaseId.h"
15 #include "CoolKernel/Exception.h"
16 #include "CoolKernel/IDatabaseSvc.h"
17 #include "CoolKernel/IDatabase.h"
18 
19 #include "GaudiKernel/MsgStream.h"
20 
21 // C/C++
22 #include <map>
23 #include <string>
24 
28 class ReadLumiBlock : public cool::Application {
29 public:
30 
34  ReadLumiBlock();
36 
37  bool updateLumiBlocks(uint32_t run, MsgStream& msg);
38  float getLumiBlockLength(uint32_t lb, MsgStream& msg) const;
39 
40  void setConnectionCOOL(const std::string &id) { m_cool_id = id; }
41  bool getTriedSetup() { return m_triedSetup; }
42 
43  cool::DatabaseId& cool_id() { return m_cool_id; }
44  cool::IDatabasePtr& cool_ptr() { return m_cool_ptr; }
45 
46  const std::string& cool_source() const { return m_cool_source; }
47 
48  uint32_t getRun() const { return m_run; }
49 
50 private:
51 
52  bool dbIsOpen();
53  void closeDb(MsgStream& msg);
54  bool openDb(bool readOnly, MsgStream& msg);
55 
56 private:
57 
58  std::map<uint32_t, uint64_t> m_lbLength; // Hold the runs LB lengths
59 
60  cool::DatabaseId m_cool_id; // COOL connection id
61  cool::DatabaseId m_cool_id_run1; // COOL connection id for run 1 data
62  cool::DatabaseId m_cool_id_run2; // COOL connection id for run 2 data
63  cool::IDatabasePtr m_cool_ptr; // COOL database pointer
64 
65  std::string m_cool_source; // COOL configuration source
66  uint32_t m_run; // Run number
67  bool m_triedSetup; // If we have tried to get a DB connection
68 };
69 
70 #endif
ReadLumiBlock::cool_source
const std::string & cool_source() const
Get name of COOL data source.
Definition: ReadLumiBlock.h:46
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ReadLumiBlock::getLumiBlockLength
float getLumiBlockLength(uint32_t lb, MsgStream &msg) const
Definition: ReadLumiBlock.cxx:102
ReadLumiBlock::m_cool_source
std::string m_cool_source
Definition: ReadLumiBlock.h:65
ReadLumiBlock::m_run
uint32_t m_run
Definition: ReadLumiBlock.h:66
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
ReadLumiBlock::m_cool_ptr
cool::IDatabasePtr m_cool_ptr
Definition: ReadLumiBlock.h:63
ReadLumiBlock::cool_id
cool::DatabaseId & cool_id()
Get reference to COOL database ID.
Definition: ReadLumiBlock.h:43
ReadLumiBlock::openDb
bool openDb(bool readOnly, MsgStream &msg)
Open a DB connection.
Definition: ReadLumiBlock.cxx:119
run
Definition: run.py:1
ReadLumiBlock::updateLumiBlocks
bool updateLumiBlocks(uint32_t run, MsgStream &msg)
Load information for.
Definition: ReadLumiBlock.cxx:42
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
ReadLumiBlock::m_cool_id
cool::DatabaseId m_cool_id
Definition: ReadLumiBlock.h:60
ReadLumiBlock::getTriedSetup
bool getTriedSetup()
True when a connection attempt has been made.
Definition: ReadLumiBlock.h:41
ReadLumiBlock::cool_ptr
cool::IDatabasePtr & cool_ptr()
Get reference to COOL database ptr.
Definition: ReadLumiBlock.h:44
ReadLumiBlock::~ReadLumiBlock
~ReadLumiBlock()
Definition: ReadLumiBlock.cxx:37
ReadLumiBlock::closeDb
void closeDb(MsgStream &msg)
Close DB connection.
Definition: ReadLumiBlock.cxx:138
ReadLumiBlock::m_lbLength
std::map< uint32_t, uint64_t > m_lbLength
Definition: ReadLumiBlock.h:58
ReadLumiBlock::setConnectionCOOL
void setConnectionCOOL(const std::string &id)
Set which COOL instance to connect to (run1, run2)
Definition: ReadLumiBlock.h:40
ReadLumiBlock::getRun
uint32_t getRun() const
Get run number.
Definition: ReadLumiBlock.h:48
ReadLumiBlock::m_cool_id_run1
cool::DatabaseId m_cool_id_run1
Definition: ReadLumiBlock.h:61
ReadLumiBlock::dbIsOpen
bool dbIsOpen()
Check if DB connection is open.
Definition: ReadLumiBlock.cxx:113
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
ReadLumiBlock
Helper class to read in lumi block length info from COOL for a run.
Definition: ReadLumiBlock.h:28
ReadLumiBlock::m_cool_id_run2
cool::DatabaseId m_cool_id_run2
Definition: ReadLumiBlock.h:62
ReadLumiBlock::ReadLumiBlock
ReadLumiBlock()
Construct helper class for reading in lumi block length from COOL.
Definition: ReadLumiBlock.cxx:26
ReadLumiBlock::m_triedSetup
bool m_triedSetup
Definition: ReadLumiBlock.h:67