Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
atlas
athena
Commits
faab2965
Commit
faab2965
authored
Nov 21, 2019
by
Joerg Stelzer
Browse files
HLTPrescaleCondAlg working version
parent
bfe7d4da
Changes
5
Hide whitespace changes
Inline
Side-by-side
Trigger/TrigConfiguration/TrigConfData/TrigConfData/HLTPrescalesSet.h
View file @
faab2965
...
...
@@ -28,6 +28,9 @@ namespace TrigConf {
/** Constructor */
HLTPrescalesSet
();
/** Copy constructor */
HLTPrescalesSet
(
const
HLTPrescalesSet
&
);
/** Constructor initialized with configuration data
* @param data The data containing the HLT prescales
*/
...
...
Trigger/TrigConfiguration/TrigConfData/src/HLTPrescalesSet.cxx
View file @
faab2965
...
...
@@ -7,6 +7,12 @@
TrigConf
::
HLTPrescalesSet
::
HLTPrescalesSet
()
{}
TrigConf
::
HLTPrescalesSet
::
HLTPrescalesSet
(
const
TrigConf
::
HLTPrescalesSet
&
o
)
:
DataStructure
(
o
.
m_data
)
{
update
();
}
TrigConf
::
HLTPrescalesSet
::
HLTPrescalesSet
(
const
boost
::
property_tree
::
ptree
&
data
)
:
DataStructure
(
data
)
{
...
...
Trigger/TrigConfiguration/TrigConfigSvc/python/TrigConfigSvcCfg.py
View file @
faab2965
...
...
@@ -85,7 +85,7 @@ def getTrigConfigFromFlag( flags=None ):
bgk
=
int
(
bgk
)
if
bgk
!=
""
else
None
tcdict
=
{
"source"
:
source
.
upper
(),
# DB, FILE, COOL
"dbconn"
:
dbconn
,
# db connection (if origin==DB or COOL) or "JOS" if connection is to be taken from TrigConf::IJobOptionsSvc
"dbconn"
:
dbconn
,
# db connection (if origin==DB or COOL) or "JOS
VC
" if connection is to be taken from TrigConf::IJobOptionsSvc
"smk"
:
smk
,
"l1psk"
:
l1psk
,
"hltpsk"
:
hltpsk
,
...
...
@@ -191,7 +191,6 @@ def setupHLTPrescaleCondAlg( flags = None ):
raise
RuntimeError
(
"trigger configuration flag 'trigConfig' starts with %s, which is not understood"
%
tc
[
"source"
])
if
flags
is
None
:
# old style config
from
AthenaCommon.AlgSequence
import
AthSequencer
condSequence
=
AthSequencer
(
"AthCondSeq"
)
...
...
@@ -232,7 +231,7 @@ def HLTPrescaleCondAlgCfg( flags ):
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
from
IOVDbSvc.IOVDbSvcConfig
import
addFolders
acc
=
ComponentAccumulator
()
acc
.
addCondAlgo
(
setupHLTPrescaleCondAlg
Cfg
(
flags
)
)
acc
.
addCondAlgo
(
setupHLTPrescaleCondAlg
(
flags
)
)
acc
.
merge
(
addFolders
(
flags
,
_hltPrescaleKeyFolderName
,
"TRIGGER_ONL"
,
className
=
"AthenaAttributeList"
))
log
.
info
(
"Adding folder %s to CompAcc"
,
_hltPrescaleKeyFolderName
)
return
acc
...
...
Trigger/TrigConfiguration/TrigConfigSvc/src/HLTPrescaleCondAlg.cxx
View file @
faab2965
...
...
@@ -9,18 +9,63 @@
#include "CoolKernel/types.h"
#include <memory>
TrigConf
::
HLTPrescaleCondAlg
::
HLTPrescaleCondAlg
(
const
std
::
string
&
name
,
ISvcLocator
*
pSvcLocator
)
:
AthReentrantAlgorithm
(
name
,
pSvcLocator
)
{}
TrigConf
::
HLTPrescalesSet
*
TrigConf
::
HLTPrescaleCondAlg
::
createFromFile
(
const
std
::
string
&
filename
)
const
{
auto
pss
=
new
HLTPrescalesSet
;
// load the file into the HLT prescales set
ATH_MSG_DEBUG
(
"Setting up JsonFileLoader with file "
<<
filename
);
TrigConf
::
JsonFileLoader
psLoader
;
psLoader
.
setLevel
(
TrigConf
::
MSGTC
::
WARNING
);
ATH_MSG_DEBUG
(
"Going to load prescales"
);
if
(
psLoader
.
loadFile
(
filename
,
*
pss
)
)
{
ATH_MSG_INFO
(
"HLT prescales set successfully loaded from file "
<<
filename
);
}
else
{
ATH_MSG_ERROR
(
"Failed loading HLT prescales set from file "
<<
filename
);
delete
pss
;
pss
=
nullptr
;
}
return
pss
;
}
TrigConf
::
HLTPrescalesSet
*
TrigConf
::
HLTPrescaleCondAlg
::
createFromDB
(
unsigned
int
psk
)
const
{
auto
pss
=
new
HLTPrescalesSet
;
// load the HLT psk into the HLT prescales set
ATH_MSG_DEBUG
(
"Setting up TrigDBHLTPrescalesSetLoader with DB connection "
<<
m_dbConnection
.
value
()
);
TrigConf
::
TrigDBHLTPrescalesSetLoader
psLoader
(
m_dbConnection
);
psLoader
.
setLevel
(
TrigConf
::
MSGTC
::
WARNING
);
ATH_MSG_DEBUG
(
"Going to load prescales"
);
if
(
psLoader
.
loadHLTPrescales
(
psk
,
*
pss
)
)
{
ATH_MSG_INFO
(
"HLT prescales set successfully loaded from db with key "
<<
psk
);
}
else
{
ATH_MSG_ERROR
(
"Failed loading HLT prescales set from db with key "
<<
psk
);
delete
pss
;
pss
=
nullptr
;
}
return
pss
;
}
StatusCode
TrigConf
::
HLTPrescaleCondAlg
::
initialize
()
{
ATH_MSG_DEBUG
(
"HLTPrescaleCondAlg::initialize()"
);
ATH_CHECK
(
m_pskFolderInputKey
.
initialize
());
if
(
m_configSource
==
"FILE"
||
m_configSource
==
"DB"
)
{
renounce
(
m_pskFolderInputKey
);
// need to disable updates when the COOL folder changes
}
ATH_CHECK
(
m_hltPrescaleSetOutputKey
.
initialize
());
ATH_CHECK
(
m_hltPrescale
s
SetOutputKey
.
initialize
());
if
(
m_configSource
==
"COOL"
&&
m_dbConnection
==
"JOSVC"
)
{
if
(
auto
joSvc
=
serviceLocator
()
->
service
<
TrigConf
::
IJobOptionsSvc
>
(
"JobOptionsSvc"
)
)
{
...
...
@@ -34,10 +79,25 @@ TrigConf::HLTPrescaleCondAlg::initialize() {
}
}
ATH_MSG_DEBUG
(
"Source "
<<
m_configSource
);
ATH_MSG_DEBUG
(
"TriggerDB "
<<
m_dbConnection
);
ATH_MSG_DEBUG
(
"HLTPsk "
<<
m_psk
);
ATH_MSG_DEBUG
(
"Filename "
<<
m_filename
.
value
());
ATH_MSG_DEBUG
(
m_configSource
);
ATH_MSG_DEBUG
(
m_dbConnection
);
ATH_MSG_DEBUG
(
m_psk
);
ATH_MSG_DEBUG
(
m_filename
);
if
(
m_configSource
==
"FILE"
)
{
// index 0 indicates that the configuration is from a file, a DB
// PSK is greater than 0
m_pssMap
[
0
]
=
createFromFile
(
m_filename
);
}
else
if
(
m_psk
!=
0
)
{
// this is for the case where the reading from the DB was
// configured and also when we read from COOL online and get a
// PSK through the JobOptionsSvc
m_pssMap
[
m_psk
]
=
createFromDB
(
m_psk
);
}
return
StatusCode
::
SUCCESS
;
}
...
...
@@ -45,12 +105,13 @@ TrigConf::HLTPrescaleCondAlg::initialize() {
StatusCode
TrigConf
::
HLTPrescaleCondAlg
::
execute
(
const
EventContext
&
ctx
)
const
{
ATH_MSG_DEBUG
(
"HLTPrescaleCondAlg::execute
"
);
ATH_MSG_DEBUG
(
"HLTPrescaleCondAlg::execute
with lb "
<<
ctx
.
eventID
().
lumi_block
()
);
unsigned
int
hltPsk
=
m_psk
;
EventIDRange
range
;
if
(
m_configSource
==
"COOL"
)
{
// get prescale key and range from COOL
SG
::
ReadCondHandle
<
AthenaAttributeList
>
readH
(
m_pskFolderInputKey
,
ctx
);
const
AthenaAttributeList
*
pskAL
{
*
readH
};
if
(
pskAL
==
nullptr
)
{
...
...
@@ -59,18 +120,19 @@ TrigConf::HLTPrescaleCondAlg::execute(const EventContext& ctx) const {
}
else
{
ATH_MSG_DEBUG
(
"Retrieved the AthenaAttributeList"
);
}
if
(
not
readH
.
range
(
range
))
{
ATH_MSG_FATAL
(
"Failed to retrieve validity range for "
<<
readH
.
key
());
return
StatusCode
::
FAILURE
;
}
else
{
ATH_MSG_DEBUG
(
"Retrieved the current IOV of the readHandle"
);
}
// get the prescale key from the cool folder
hltPsk
=
(
*
pskAL
)[
"HltPrescaleKey"
].
data
<
cool
::
UInt32
>
();
ATH_MSG_DEBUG
(
"Extracted the HLT PSK "
<<
hltPsk
<<
" for run "
<<
ctx
.
eventID
().
run_number
()
<<
" and lb "
<<
ctx
.
eventID
().
lumi_block
()
);
ATH_MSG_DEBUG
(
"Extracted the HLT PSK "
<<
hltPsk
<<
" for run "
<<
ctx
.
eventID
().
run_number
()
<<
" and lb "
<<
ctx
.
eventID
().
lumi_block
()
);
}
else
{
// in case of reading from DB or from FILE, the EventID range is always the full run
EventIDBase
::
number_type
run
=
ctx
.
eventID
().
run_number
();
EventIDBase
start
,
stop
;
start
.
set_run_number
(
run
);
...
...
@@ -78,37 +140,24 @@ TrigConf::HLTPrescaleCondAlg::execute(const EventContext& ctx) const {
stop
.
set_run_number
(
run
+
1
);
stop
.
set_lumi_block
(
0
);
range
=
EventIDRange
(
start
,
stop
);
}
TrigConf
::
HLTPrescalesSet
*
pss
=
new
TrigConf
::
HLTPrescalesSet
;
HLTPrescalesSet
*
pss
(
nullptr
);
if
(
m_configSource
==
"FILE"
)
{
// load the file into the HLT prescales set
ATH_MSG_DEBUG
(
"Setting up JsonFileLoader with file "
<<
m_filename
.
value
()
);
TrigConf
::
JsonFileLoader
psLoader
;
psLoader
.
setLevel
(
TrigConf
::
MSGTC
::
WARNING
);
ATH_MSG_DEBUG
(
"Going to load prescales"
);
if
(
psLoader
.
loadFile
(
m_filename
,
*
pss
)
)
{
ATH_MSG_INFO
(
"HLT prescales set successfully loaded from file "
<<
m_filename
.
value
()
);
}
else
{
ATH_MSG_ERROR
(
"Failed loading HLT prescales set from file "
<<
m_filename
.
value
()
);
return
StatusCode
::
FAILURE
;
}
pss
=
m_pssMap
.
at
(
0
);
}
else
if
(
hltPsk
!=
0
)
{
}
else
if
(
hltPsk
!=
0
)
{
// load the HLT psk into HLT prescales set
ATH_MSG_DEBUG
(
"Setting up TrigDBHLTPrescalesSetLoader with DB connection "
<<
m_dbConnection
.
value
()
);
TrigConf
::
TrigDBHLTPrescalesSetLoader
psLoader
(
m_dbConnection
);
psLoader
.
setLevel
(
TrigConf
::
MSGTC
::
WARNING
);
ATH_MSG_DEBUG
(
"Going to load prescales"
);
if
(
psLoader
.
loadHLTPrescales
(
hltPsk
,
*
pss
)
)
{
ATH_MSG_INFO
(
"HLT prescales set successfully loaded from db with key "
<<
m_psk
.
value
()
);
}
else
{
ATH_MSG_ERROR
(
"Failed loading HLT prescales set from db with key "
<<
m_psk
.
value
()
);
return
StatusCode
::
FAILURE
;
auto
pssi
=
m_pssMap
.
find
(
hltPsk
);
if
(
pssi
==
m_pssMap
.
end
())
{
m_pssMap
[
hltPsk
]
=
createFromDB
(
hltPsk
);
pss
=
m_pssMap
.
at
(
hltPsk
);
}
}
else
{
...
...
@@ -118,11 +167,11 @@ TrigConf::HLTPrescaleCondAlg::execute(const EventContext& ctx) const {
}
// record
ing
HLT prescales set
SG
::
WriteCondHandle
<
TrigConf
::
HLTPrescalesSet
>
writeCondHandle
(
m_hltPrescaleSetOutputKey
,
ctx
);
// record HLT prescales set
SG
::
WriteCondHandle
<
TrigConf
::
HLTPrescalesSet
>
writeCondHandle
(
m_hltPrescale
s
SetOutputKey
,
ctx
);
ATH_MSG_INFO
(
"Recording HLT prescales set with range "
<<
range
);
ATH_CHECK
(
writeCondHandle
.
record
(
range
,
pss
));
ATH_CHECK
(
writeCondHandle
.
record
(
range
,
new
HLTPrescalesSet
(
*
pss
)
)
);
return
StatusCode
::
SUCCESS
;
}
Trigger/TrigConfiguration/TrigConfigSvc/src/HLTPrescaleCondAlg.h
View file @
faab2965
...
...
@@ -13,6 +13,8 @@
#include "AthenaPoolUtilities/AthenaAttributeList.h"
#include <tbb/concurrent_unordered_map.h>
namespace
TrigConf
{
/**
...
...
@@ -34,16 +36,25 @@ namespace TrigConf {
virtual
StatusCode
execute
(
const
EventContext
&
ctx
)
const
override
;
private:
// helper function to load a HLT prescales set from a file
HLTPrescalesSet
*
createFromFile
(
const
std
::
string
&
filename
)
const
;
// helper function to load a HLT prescales set from a prescale key
HLTPrescalesSet
*
createFromDB
(
unsigned
int
psk
)
const
;
// map the prescale key to a HLTPrescalesSet
mutable
tbb
::
concurrent_unordered_map
<
unsigned
int
,
HLTPrescalesSet
*>
m_pssMap
;
// input key to the HLT Prescale Key folder
SG
::
ReadCondHandleKey
<
AthenaAttributeList
>
m_pskFolderInputKey
{
this
,
"PSKFolder"
,
"/TRIGGER/HLT/PrescaleKey"
,
"SG Key of AthenaAttributeList containing hlt psk"
};
// output key to store the HLTPrescalesSet
SG
::
WriteCondHandleKey
<
TrigConf
::
HLTPrescalesSet
>
m_hltPrescaleSetOutputKey
{
this
,
"HLTPrescales"
,
"HLTPrescales"
,
"HLT prescales"
};
SG
::
WriteCondHandleKey
<
TrigConf
::
HLTPrescalesSet
>
m_hltPrescale
s
SetOutputKey
{
this
,
"HLTPrescales"
,
"HLTPrescales"
,
"HLT prescales"
};
// properties
Gaudi
::
Property
<
std
::
string
>
m_configSource
{
this
,
"Source"
,
"FILE"
,
"Configuration source, can be 'FILE', 'DB', or 'COOL'"
};
Gaudi
::
Property
<
std
::
string
>
m_dbConnection
{
this
,
"TriggerDB"
,
"
TRIGGERDB
"
,
"DB connection alias"
};
Gaudi
::
Property
<
std
::
string
>
m_dbConnection
{
this
,
"TriggerDB"
,
""
,
"DB connection alias"
};
Gaudi
::
Property
<
unsigned
int
>
m_psk
{
this
,
"HLTPsk"
,
0
,
"HLT prescale key"
};
Gaudi
::
Property
<
std
::
string
>
m_filename
{
this
,
"Filename"
,
""
,
"HLT prescale json file"
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment