ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigCost
EnhancedBiasWeighter
Root
ReadLumiBlock.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
// Trigger
6
#include "
EnhancedBiasWeighter/ReadLumiBlock.h
"
7
8
// COOL
9
#include "CoolKernel/ValidityKey.h"
10
#include "CoolKernel/IFolder.h"
11
#include "CoolKernel/Exception.h"
12
#include "CoolKernel/IObject.h"
13
#include "CoolKernel/IObjectIterator.h"
14
#include "CoolKernel/IDatabaseSvc.h"
15
#include "CoralKernel/Context.h"
16
17
// C/C++
18
#include <cmath>
19
#include <iomanip>
20
#include <iostream>
21
#include <sstream>
22
23
using namespace
std
;
24
25
//-----------------------------------------------------------------------------
26
ReadLumiBlock::ReadLumiBlock
()
27
:
m_cool_id
(),
28
m_cool_id_run1
(
"COOLONL_TRIGGER/COMP200"
),
29
m_cool_id_run2
(
"COOLONL_TRIGGER/CONDBR2"
),
30
m_cool_source
(),
31
m_run
(0),
32
m_triedSetup
(false)
33
{
34
}
35
36
//-----------------------------------------------------------------------------
37
ReadLumiBlock::~ReadLumiBlock
()
38
{
39
}
40
41
//-----------------------------------------------------------------------------
42
bool
ReadLumiBlock::updateLumiBlocks
(
const
uint32_t
run
, MsgStream&
msg
)
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
;
52
else
m_cool_id
=
m_cool_id_run2
;
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
85
m_lbLength
[lumi] =
length
;
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
}
101
102
float
ReadLumiBlock::getLumiBlockLength
(
const
uint32_t
lb
, MsgStream&
msg
)
const
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
}
111
112
//---------------------------------------------------------------------------------------
113
bool
ReadLumiBlock::dbIsOpen
()
114
{
115
return
m_cool_ptr
.use_count() > 0 &&
m_cool_ptr
->isOpen();
116
}
117
118
//---------------------------------------------------------------------------------------
119
bool
ReadLumiBlock::openDb
(
bool
readOnly, MsgStream&
msg
)
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
}
136
137
//---------------------------------------------------------------------------------------
138
void
ReadLumiBlock::closeDb
(MsgStream&
msg
)
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
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
length
double length(const pvec &v)
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
ReadLumiBlock.h
ReadLumiBlock::updateLumiBlocks
bool updateLumiBlocks(uint32_t run, MsgStream &msg)
Load information for.
Definition
ReadLumiBlock.cxx:42
ReadLumiBlock::m_cool_ptr
cool::IDatabasePtr m_cool_ptr
Definition
ReadLumiBlock.h:63
ReadLumiBlock::m_run
uint32_t m_run
Definition
ReadLumiBlock.h:66
ReadLumiBlock::m_lbLength
std::map< uint32_t, uint64_t > m_lbLength
Definition
ReadLumiBlock.h:58
ReadLumiBlock::getLumiBlockLength
float getLumiBlockLength(uint32_t lb, MsgStream &msg) const
Definition
ReadLumiBlock.cxx:102
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
ReadLumiBlock::closeDb
void closeDb(MsgStream &msg)
Close DB connection.
Definition
ReadLumiBlock.cxx:138
ReadLumiBlock::m_cool_id
cool::DatabaseId m_cool_id
Definition
ReadLumiBlock.h:60
ReadLumiBlock::~ReadLumiBlock
~ReadLumiBlock()
Definition
ReadLumiBlock.cxx:37
ReadLumiBlock::ReadLumiBlock
ReadLumiBlock()
Construct helper class for reading in lumi block length from COOL.
Definition
ReadLumiBlock.cxx:26
ReadLumiBlock::openDb
bool openDb(bool readOnly, MsgStream &msg)
Open a DB connection.
Definition
ReadLumiBlock.cxx:119
ReadLumiBlock::m_triedSetup
bool m_triedSetup
Definition
ReadLumiBlock.h:67
ReadLumiBlock::m_cool_source
std::string m_cool_source
Definition
ReadLumiBlock.h:65
ReadLumiBlock::m_cool_id_run2
cool::DatabaseId m_cool_id_run2
Definition
ReadLumiBlock.h:62
lb
int lb
Definition
globals.cxx:23
std
STL namespace.
msg
MsgStream & msg
Definition
testRead.cxx:32
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0