Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
atlas
athena
Commits
eb3ec368
Commit
eb3ec368
authored
Aug 05, 2020
by
Frank Winklmeier
Browse files
Merge branch 'eventtagbuilder' into 'master'
Cleanup EventInfoTagBuilder See merge request
atlas/athena!35330
parents
c86923d6
598dd556
Changes
8
Hide whitespace changes
Inline
Side-by-side
Database/AthenaPOOL/OutputStreamAthenaPool/python/CreateOutputStreams.py
View file @
eb3ec368
...
...
@@ -8,7 +8,6 @@
from
__future__
import
print_function
from
AthenaCommon.AppMgr
import
theApp
from
AthenaCommon.AppMgr
import
ServiceMgr
as
svcMgr
from
AthenaServices.AthenaServicesConf
import
AthenaOutputStream
from
AthenaServices.AthenaServicesConf
import
AthenaOutputStreamTool
...
...
@@ -48,8 +47,9 @@ def createOutputStream( streamName, fileName = "", asAlg = False, noTag = False,
# Tell tool to pick it up
outputStream
.
WritingTool
.
AttributeListKey
=
key
# build eventinfo attribute list
from
.OutputStreamAthenaPoolConf
import
EventInfoAttListTool
,
EventInfoTagBuilder
EventInfoTagBuilder
=
EventInfoTagBuilder
(
AttributeList
=
key
,
EventInfoKey
=
eventInfoKey
,
FilterString
=
decisionFilter
)
from
.OutputStreamAthenaPoolConf
import
EventInfoAttListTool
,
EventInfoTagBuilder
EventInfoTagBuilder
=
EventInfoTagBuilder
(
AttributeList
=
key
,
EventInfoKey
=
eventInfoKey
,
FilterString
=
decisionFilter
,
Tool
=
EventInfoAttListTool
())
from
AthenaCommon.GlobalFlags
import
globalflags
if
globalflags
.
InputFormat
()
==
'bytestream'
:
#No event-tag input in bytestream
...
...
Database/AthenaPOOL/OutputStreamAthenaPool/python/OutputStreamConfig.py
View file @
eb3ec368
...
...
@@ -55,8 +55,8 @@ def OutputStreamCfg(configFlags, streamName, ItemList=[], disableEventTag=False
outputStream
.
WritingTool
.
AttributeListKey
=
key
# build eventinfo attribute list
EventInfoAttListTool
,
EventInfoTagBuilder
=
CompFactory
.
getComps
(
"EventInfoAttListTool"
,
"EventInfoTagBuilder"
,)
result
.
addPublicTool
(
EventInfoAttListTool
())
tagBuilder
=
EventInfoTagBuilder
(
AttributeList
=
key
)
tagBuilder
=
EventInfoTagBuilder
(
AttributeList
=
key
,
Tool
=
EventInfoAttListTool
()
)
result
.
addEventAlgo
(
tagBuilder
)
# For xAOD output
...
...
Database/AthenaPOOL/OutputStreamAthenaPool/src/EventInfoTagBuilder.cxx
View file @
eb3ec368
...
...
@@ -4,84 +4,77 @@
#include
"EventInfoTagBuilder.h"
#include
"StoreGate/ReadHandle.h"
#include
"StoreGate/WriteHandle.h"
EventInfoTagBuilder
::
EventInfoTagBuilder
(
const
std
::
string
&
name
,
ISvcLocator
*
pSvcLocator
)
:
AthAlgorithm
(
name
,
pSvcLocator
),
m_tool
(
"EventInfoAttListTool/EventInfoAttListTool"
,
this
)
{
declareProperty
(
"EventInfoKey"
,
m_evtKey
=
"EventInfo"
);
declareProperty
(
"InputList"
,
m_inputAttList
=
"Input"
);
declareProperty
(
"AttributeList"
,
m_attributeListName
);
declareProperty
(
"PropagateInput"
,
m_propInput
=
true
);
declareProperty
(
"FilterString"
,
m_filter
=
""
);
#include
<StoreGate/ReadHandle.h>
#include
<StoreGate/WriteHandle.h>
EventInfoTagBuilder
::
EventInfoTagBuilder
(
const
std
::
string
&
name
,
ISvcLocator
*
pSvcLocator
)
:
AthAlgorithm
(
name
,
pSvcLocator
)
{
}
EventInfoTagBuilder
::~
EventInfoTagBuilder
()
{}
StatusCode
EventInfoTagBuilder
::
initialize
()
{
StatusCode
EventInfoTagBuilder
::
initialize
()
{
ATH_MSG_DEBUG
(
"Initializing "
<<
name
()
);
if
(
m_attributeListName
.
empty
())
{
ATH_MSG_ERROR
(
"Output attribute list name should not be empty."
);
return
StatusCode
::
FAILURE
;
}
ATH_CHECK
(
m_tool
.
retrieve
()
);
ATH_CHECK
(
m_evtKey
.
initialize
()
);
ATH_CHECK
(
m_attributeListName
.
initialize
()
);
ATH_CHECK
(
m_inputAttList
.
initialize
()
);
ATH_CHECK
(
m_attributeListName
.
initialize
()
);
return
StatusCode
::
SUCCESS
;
}
StatusCode
EventInfoTagBuilder
::
execute
()
{
StatusCode
EventInfoTagBuilder
::
execute
()
{
ATH_MSG_DEBUG
(
"Executing "
<<
name
()
);
SG
::
ReadHandle
<
xAOD
::
EventInfo
>
h_evt
(
m_evtKey
);
if
(
!
h_evt
.
isValid
())
{
ATH_MSG_ERROR
(
"Did not find xAOD::EventInfo"
);
return
StatusCode
::
FAILURE
;
}
/** create a EventInfo Tag and ask the tool to fill it */
if
(
h_evt
.
isValid
())
{
std
::
unique_ptr
<
AthenaAttributeList
>
attribList
=
m_tool
->
getAttributeListPtr
(
*
h_evt
);
// Check whether to propagate
if
(
m_propInput
)
{
SG
::
ReadHandle
<
AthenaAttributeList
>
h_att
(
m_inputAttList
);
// Check if there is an input to propagate
if
(
h_att
.
isValid
())
{
for
(
auto
it
=
h_att
->
specification
().
begin
();
it
!=
h_att
->
specification
().
end
();
++
it
)
{
// Only propagate bool properties
if
(
it
->
typeName
()
==
"bool"
&&!
attribList
->
exists
(
it
->
name
()))
{
// Check if there is filtering on the name
if
(
m_filter
!=
""
)
{
if
(
it
->
name
().
find
(
m_filter
)
!=
std
::
string
::
npos
)
{
// Add those bools to the output attribute list
(
*
attribList
).
extend
(
it
->
name
(),
it
->
type
());
(
*
attribList
)[
it
->
name
()].
data
<
bool
>
()
=
(
*
h_att
)[
it
->
name
()].
data
<
bool
>
();
}
/** create a EventInfo Tag and ask the tool to fill it */
std
::
unique_ptr
<
AthenaAttributeList
>
attribList
=
m_tool
->
getAttributeListPtr
(
*
h_evt
);
// Check whether to propagate
if
(
m_propInput
)
{
SG
::
ReadHandle
<
AthenaAttributeList
>
h_att
(
m_inputAttList
);
// Check if there is an input to propagate
if
(
h_att
.
isValid
())
{
for
(
auto
it
=
h_att
->
specification
().
begin
();
it
!=
h_att
->
specification
().
end
();
++
it
)
{
// Only propagate bool properties
if
(
it
->
typeName
()
==
"bool"
&&!
attribList
->
exists
(
it
->
name
()))
{
// Check if there is filtering on the name
if
(
m_filter
!=
""
)
{
if
(
it
->
name
().
find
(
m_filter
)
!=
std
::
string
::
npos
)
{
// Add those bools to the output attribute list
(
*
attribList
).
extend
(
it
->
name
(),
it
->
type
());
(
*
attribList
)[
it
->
name
()].
data
<
bool
>
()
=
(
*
h_att
)[
it
->
name
()].
data
<
bool
>
();
}
}
// take only bools
}
// loop
}
else
{
// valid input
ATH_MSG_INFO
(
"No input attribute list"
);
}
}
// propagate
/** record attribute list to SG */
SG
::
WriteHandle
<
AthenaAttributeList
>
wh
(
m_attributeListName
);
ATH_CHECK
(
wh
.
record
(
std
::
move
(
attribList
))
);
}
else
{
ATH_MSG_WARNING
(
"Did not find xAOD::EventInfo"
);
}
}
}
// take only bools
}
// loop
}
else
{
// valid input
ATH_MSG_INFO
(
"No input attribute list"
);
}
}
// propagate
/** record attribute list to SG */
SG
::
WriteHandle
<
AthenaAttributeList
>
wh
(
m_attributeListName
);
ATH_CHECK
(
wh
.
record
(
std
::
move
(
attribList
))
);
ATH_MSG_DEBUG
(
"Finished "
<<
name
()
);
return
StatusCode
::
SUCCESS
;
}
StatusCode
EventInfoTagBuilder
::
finalize
()
{
return
StatusCode
::
SUCCESS
;
}
Database/AthenaPOOL/OutputStreamAthenaPool/src/EventInfoTagBuilder.h
View file @
eb3ec368
/*
Copyright (C) 2002-20
17
CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-20
20
CERN for the benefit of the ATLAS collaboration
*/
#ifndef EVENTTAGALGS_EVENTINFOTAGBUILDER_H
...
...
@@ -14,8 +14,8 @@ Updated : February 2006
DESCRIPTION:
Retrieves event tag data from an AOD file, stores this data in an attribute
list object and records the attribute list object in the TDS for subsequent
Retrieves event tag data from an AOD file, stores this data in an attribute
list object and records the attribute list object in the TDS for subsequent
inclusion in an event tag database.
*****************************************************************************/
...
...
@@ -27,37 +27,39 @@ inclusion in an event tag database.
*/
#include
"AthenaBaseComps/AthAlgorithm.h"
#include
<AthenaBaseComps/AthAlgorithm.h>
#include
<GaudiKernel/ToolHandle.h>
#include
<PersistentDataModel/AthenaAttributeList.h>
#include
<StoreGate/ReadHandleKey.h>
#include
<StoreGate/WriteHandleKey.h>
#include
<xAODEventInfo/EventInfo.h>
#include
"EventInfoAttListTool.h"
#include
"StoreGate/ReadHandleKey.h"
#include
"StoreGate/WriteHandleKey.h"
#include
"xAODEventInfo/EventInfo.h"
#include
"PersistentDataModel/AthenaAttributeList.h"
#include
"GaudiKernel/ToolHandle.h"
class
EventInfoTagBuilder
:
public
AthAlgorithm
{
class
EventInfoTagBuilder
:
public
AthAlgorithm
{
public:
/// Standard constructor.
EventInfoTagBuilder
(
const
std
::
string
&
name
,
ISvcLocator
*
pSvcLocator
);
/// Destructor.
~
EventInfoTagBuilder
();
StatusCode
initialize
();
StatusCode
execute
();
StatusCode
finalize
();
~
EventInfoTagBuilder
()
=
default
;
virtual
StatusCode
initialize
()
override
;
virtual
StatusCode
execute
()
override
;
private:
/// Global Event Tag Tool
ToolHandle
<
EventInfoAttListTool
>
m_tool
;
ToolHandle
<
EventInfoAttListTool
>
m_tool
{
this
,
"Tool"
,
"EventInfoAttListTool/EventInfoAttListTool"
,
"EventInfoAttListTool used"
};
SG
::
ReadHandleKey
<
xAOD
::
EventInfo
>
m_evtKey
{
this
,
"EventInfoKey"
,
"EventInfo"
,
"xAOD::EventInfo ReadHandleKey"
};
SG
::
ReadHandleKey
<
AthenaAttributeList
>
m_inputAttList
{
this
,
"InputList"
,
"Input"
,
"Input Athena attribute list ReadHandleKey"
};
SG
::
WriteHandleKey
<
AthenaAttributeList
>
m_attributeListName
{
this
,
"AttributeList"
,
"SimpleTag"
,
"Output Athena attribute list WriteHandleKey"
};
SG
::
ReadHandleKey
<
xAOD
::
EventInfo
>
m_evtKey
;
SG
::
ReadHandleKey
<
AthenaAttributeList
>
m_inputAttList
;
SG
::
WriteHandleKey
<
AthenaAttributeList
>
m_attributeListName
;
bool
m_propInput
;
std
::
string
m_filter
;
Gaudi
::
Property
<
bool
>
m_propInput
{
this
,
"PropagateInput"
,
true
,
"Propagate input attribute list to the output"
};
Gaudi
::
Property
<
std
::
string
>
m_filter
{
this
,
"FilterString"
,
""
,
"Filter input attribute list when propagating to the output"
};
};
...
...
Simulation/G4Atlas/G4AtlasApps/python/SimSkeleton.py
View file @
eb3ec368
...
...
@@ -64,7 +64,7 @@ class SimSkeleton(object):
## only changing it in Hive.
as_alg
=
is_hive
## NB. Two-arg constructor is needed, since otherwise metadata writing fails!
stream1
=
AthenaPoolOutputStream
(
"StreamHITS"
,
athenaCommonFlags
.
PoolHitsOutput
(),
asAlg
=
as_alg
)
stream1
=
AthenaPoolOutputStream
(
"StreamHITS"
,
athenaCommonFlags
.
PoolHitsOutput
(),
asAlg
=
as_alg
,
noTag
=
True
)
## Write geometry tag info - move to main method
#import EventInfoMgt.EventInfoMgtInit
...
...
Simulation/G4Atlas/G4AtlasApps/share/G4Atlas.flat.configuration.py
View file @
eb3ec368
...
...
@@ -162,7 +162,7 @@ if not simFlags.ISFRun:
else
:
as_alg
=
False
## NB. Two-arg constructor is needed, since otherwise metadata writing fails!
stream1
=
AthenaPoolOutputStream
(
"StreamHITS"
,
athenaCommonFlags
.
PoolHitsOutput
(),
asAlg
=
as_alg
)
stream1
=
AthenaPoolOutputStream
(
"StreamHITS"
,
athenaCommonFlags
.
PoolHitsOutput
(),
asAlg
=
as_alg
,
noTag
=
True
)
## Write geometry tag info - move to main method
#import EventInfoMgt.EventInfoMgtInit
...
...
Simulation/G4Atlas/G4AtlasApps/share/Tile2000_2003.flat.configuration.py
View file @
eb3ec368
...
...
@@ -151,7 +151,7 @@ if not simFlags.ISFRun:
else
:
as_alg
=
False
## NB. Two-arg constructor is needed, since otherwise metadata writing fails!
stream1
=
AthenaPoolOutputStream
(
"StreamHITS"
,
athenaCommonFlags
.
PoolHitsOutput
(),
asAlg
=
as_alg
)
stream1
=
AthenaPoolOutputStream
(
"StreamHITS"
,
athenaCommonFlags
.
PoolHitsOutput
(),
asAlg
=
as_alg
,
noTag
=
True
)
## Write geometry tag info - move to main method
#import EventInfoMgt.EventInfoMgtInit
...
...
Simulation/ISF/ISF_Example/python/ISF_Output.py
View file @
eb3ec368
...
...
@@ -151,7 +151,7 @@ class ISF_HITSStream:
stream1
=
None
if
athenaCommonFlags
.
PoolHitsOutput
.
statusOn
:
output_file
=
athenaCommonFlags
.
PoolHitsOutput
()
stream1
=
AthenaPoolOutputStream
(
"StreamHITS"
,
output_file
)
stream1
=
AthenaPoolOutputStream
(
"StreamHITS"
,
output_file
,
noTag
=
True
)
stream1
.
ItemList
=
getHITSStreamItemList
()
## Make stream aware of aborted events
stream1
.
AcceptAlgs
=
[
ISF_Flags
.
Simulator
.
KernelName
()]
...
...
@@ -162,7 +162,7 @@ class ISF_HITSStream:
xAODStream
=
None
if
simFlags
.
SimulationFlavour
==
"ParametricSimulation"
:
output_file
=
athenaCommonFlags
.
PoolAODOutput
()
xAODStream
=
AthenaPoolOutputStream
(
"StreamAOD"
,
output_file
)
xAODStream
=
AthenaPoolOutputStream
(
"StreamAOD"
,
output_file
,
noTag
=
True
)
xAODStream
.
ItemList
=
getAODStreamItemList
()
## Make stream aware of aborted events
xAODStream
.
AcceptAlgs
=
[
ISF_Flags
.
Simulator
.
KernelName
()]
...
...
Frank Winklmeier
@fwinkl
mentioned in commit
9154a0ed
·
Aug 06, 2020
mentioned in commit
9154a0ed
mentioned in commit 9154a0ed45499063e84470e85900d23e934d01c1
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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