ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileConditions
python
TileSampleNoiseConfig.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3
"""Define methods to construct configured Tile sample noise tool and conditions algorithm"""
4
5
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
6
from
AthenaConfiguration.ComponentFactory
import
CompFactory
7
8
def
TileSampleNoiseCondAlgCfg
(flags, **kwargs):
9
"""Return component accumulator with configured Tile sample noise conditions algorithm
10
11
Arguments:
12
flags -- Athena configuration flags
13
Keyword arguments:
14
Source -- source of Tile sample noise conditions (COOL, FILE). Defaults to COOL.
15
ForceOnline -- flag to use online sample noise in offline. Defaults to False.
16
TileSampleNoise -- name of Tile sample noise conditions object.
17
Defaults to TileOnlineSampleNoise if ForceOnline else TileSampleNoise.
18
"""
19
20
acc = ComponentAccumulator()
21
22
source = kwargs.get(
'Source'
,
'COOL'
)
23
sampleNoise = kwargs.get(
'TileSampleNoise'
,
'TileSampleNoise'
)
24
forceOnline = kwargs.get(
'ForceOnline'
,
False
)
25
26
name = sampleNoise +
'CondAlg'
27
28
if
source ==
'COOL'
:
29
# Connect COOL Tile conditions proxies to the algorithm (default)
30
31
from
TileConditions.TileFolders
import
TileFolders
32
folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
33
34
if
flags.IOVDb.DatabaseInstance ==
'CONDBR2'
:
35
onlineSampleNoiseFolder =
'/TILE/ONL01/NOISE/SAMPLE'
36
else
:
37
onlineSampleNoiseFolder =
'/TILE/OFL01/NOISE/SAMPLE'
38
39
if
forceOnline:
40
sampleNoiseFolder = folders.add(onlineSampleNoiseFolder,
'TILE'
)
41
else
:
42
sampleNoiseFolder = folders.addSplitOnline(onlineSampleNoiseFolder,
'/TILE/OFL02/NOISE/SAMPLE'
)
43
44
TileCondProxyCoolFlt=CompFactory.getComp(
"TileCondProxyCool<TileCalibDrawerFlt>"
)
45
sampleNoiseProxy =
TileCondProxyCoolFlt
(
'TileCondProxyCool_NoiseSample'
, Source = sampleNoiseFolder)
46
47
from
IOVDbSvc.IOVDbSvcConfig
import
addFolderList
48
acc.merge( addFolderList(flags, folders.get()) )
49
50
elif
source ==
'FILE'
:
51
# Connect FILE Tile conditions proxies to the algorithm
52
TileCondProxyFileFlt=CompFactory.getComp(
"TileCondProxyFile<TileCalibDrawerFlt>"
)
53
sampleNoiseProxy =
TileCondProxyFileFlt
(
'TileCondProxyFile_NoiseSample'
, Source =
'TileDefault.ped'
)
54
55
else
:
56
raise(Exception(
"Invalid source: %s"
% source))
57
58
TileSampleNoiseCondAlg = CompFactory.getComp(
"TileCondAlg<TileSampleNoise,TileCalibDrawerFlt>"
)
59
sampleNoiseCondAlg =
TileSampleNoiseCondAlg
( name = name,
60
ConditionsProxy = sampleNoiseProxy,
61
TileCondData = sampleNoise)
62
63
acc.addCondAlgo(sampleNoiseCondAlg)
64
65
return
acc
66
67
68
69
def
TileCondToolNoiseSampleCfg
(flags, **kwargs):
70
"""Return component accumulator with configured private Tile sample noise tool
71
Arguments:
72
flags -- Athena configuration flags
73
Keyword arguments:
74
Source -- source of Tile sample noise conditions (COOL, FILE). Defaults to COOL.
75
TileSampleNoise -- name of Tile sample noise conditions object. Defaults to TileSampleNoise.
76
TileOnlineSampleNoise -- name of Tile online sample noise conditions object. If it is not empty
77
online sample noise will be accessible in offline also and that allows
78
to get difference between pedestal used in online and corrected one
79
in offline. Proposed name: TileOnlineSampleNoise. Defaults to empty.
80
"""
81
82
from
AthenaCommon.Logging
import
logging
83
msg = logging.getLogger(
'TileCondToolNoiseSample'
)
84
85
acc = ComponentAccumulator()
86
87
kwargs.setdefault(
'Source'
,
'COOL'
)
88
kwargs.setdefault(
'TileSampleNoise'
,
'TileSampleNoise'
)
89
90
sampleNoise = kwargs[
'TileSampleNoise'
]
91
onlineSampleNoise = kwargs.pop(
'TileOnlineSampleNoise'
,
''
)
92
93
name =
'TileCondToolNoiseSample'
94
95
from
TileConditions.TileEMScaleConfig
import
TileEMScaleCondAlgCfg
96
acc.merge( TileEMScaleCondAlgCfg(flags, **kwargs) )
97
98
acc.merge(
TileSampleNoiseCondAlgCfg
(flags, **kwargs) )
99
100
if
onlineSampleNoise:
101
if
flags.Common.isOnline:
102
msg.warning(
'Not necessary to configure online sample noise in online especially'
)
103
onlineSampleNoise = sampleNoise
104
else
:
105
kwargs[
'TileSampleNoise'
] = onlineSampleNoise
106
acc.merge(
TileSampleNoiseCondAlgCfg
(flags, ForceOnline =
True
, **kwargs) )
107
108
TileCondToolNoiseSample=CompFactory.TileCondToolNoiseSample
109
acc.setPrivateTools(
TileCondToolNoiseSample
(name, TileSampleNoise = sampleNoise,
110
TileOnlineSampleNoise = onlineSampleNoise) )
111
112
return
acc
113
114
115
if
__name__ ==
"__main__"
:
116
117
from
AthenaConfiguration.AllConfigFlags
import
initConfigFlags
118
from
AthenaConfiguration.TestDefaults
import
defaultTestFiles
119
from
AthenaCommon.Logging
import
log
120
from
AthenaCommon.Constants
import
DEBUG
121
122
# Test setup
123
log.setLevel(DEBUG)
124
125
flags = initConfigFlags()
126
flags.Input.Files = defaultTestFiles.RAW_RUN2
127
flags.Common.isOnline =
True
128
flags.lock()
129
130
acc = ComponentAccumulator()
131
132
sampleNoiseTool = acc.popToolsAndMerge(
TileCondToolNoiseSampleCfg
(flags) )
133
print
(sampleNoiseTool)
134
135
accOnlSampleNoise =
TileCondToolNoiseSampleCfg
(flags,
136
TileSampleNoise =
'TileSampleNoise'
,
137
TileOnlineSampleNoise =
'TileOnlineSampleNoise'
)
138
139
sampleNoiseTool = acc.popToolsAndMerge( accOnlSampleNoise )
140
print
(sampleNoiseTool)
141
142
acc.printConfig(withDetails =
True
, summariseProps =
True
)
143
print
(acc.getService(
'IOVDbSvc'
))
144
acc.store( open(
'TileSampleNoise.pkl'
,
'wb'
) )
145
146
print
(
'All OK'
)
147
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
TileCondAlg< TileSampleNoise, TileCalibDrawerFlt >
TileCondProxyCool< TileCalibDrawerFlt >
TileCondProxyFile< TileCalibDrawerFlt >
TileCondToolNoiseSample
Definition
TileCondToolNoiseSample.h:22
Constants
python.TileSampleNoiseConfig.TileSampleNoiseCondAlgCfg
TileSampleNoiseCondAlgCfg(flags, **kwargs)
Definition
TileSampleNoiseConfig.py:8
python.TileSampleNoiseConfig.TileCondToolNoiseSampleCfg
TileCondToolNoiseSampleCfg(flags, **kwargs)
Definition
TileSampleNoiseConfig.py:69
Generated on
for ATLAS Offline Software by
1.17.0