ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkMuons
scripts
create_period_container.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4
12
13
14
import
sys
15
import
pyAMI.client
16
import
pyAMI.atlas.api
as
AtlasAPI
17
from
subprocess
import
call
18
19
client = pyAMI.client.Client(
'atlas'
)
20
AtlasAPI.init()
21
22
23
def
getRuns
(grl):
24
listGRL = []
25
for
i
in
grl.split(
','
):
26
import
xml.etree.ElementTree
27
listGRL += [atype.text.split(
','
)
for
atype
in
xml.etree.ElementTree.parse(grl).getroot().
find
(
'NamedLumiRange'
).findall(
'Metadata'
)
if
atype.get(
'Name'
) ==
'RunList'
]
28
return
listGRL
29
30
class
config1
:
31
def
__init__
(self, project, derivation, period, acceptTags, sTag, autoCreate=False, grl=None):
32
self.
project
= project
33
self.
period
= period
34
self.
sTag
= sTag
35
self.
derivation
= derivation
36
self.
acceptTags
= acceptTags
37
self.
autoCreate
= autoCreate
38
self.
grl
= grl
39
self.
outScript
=
None
40
41
def
makeContainer
(c1):
42
43
x0 = AtlasAPI.list_datasets(client, patterns = [c1.project+
'.%.physics_Main.merge.AOD%'
], fields = [
'run_number'
,
'ldn'
,
'events'
,
'total_size'
], order=
None
, limit=
None
, show_archived=
False
, grl=c1.grl, data_period=c1.period)
44
runs =
set
([a[
'run_number'
]
for
a
in
x0])
45
46
if
len(runs)==0:
47
print
(
'no run in period'
+c1.period+
' is listed in GRL:'
, c1.grl)
48
return
49
50
51
x = AtlasAPI.list_datasets(client, patterns = [c1.project+
'.%.physics_Main.merg%'
+c1.derivation+
'%'
], fields = [
'run_number'
,
'ldn'
,
'events'
,
'total_size'
], order=
None
, limit=
None
, show_archived=
False
, grl=c1.grl, data_period=c1.period)
52
53
54
dic1={}
55
for
a
in
x:
56
print
(a[
'run_number'
], a[
'ldn'
])
57
try
:
58
dic1[a[
'ldn'
].
split
(
'_'
)[-1]].append((a[
'run_number'
],a[
'ldn'
]))
59
except
KeyError:
60
dic1[a[
'ldn'
].
split
(
'_'
)[-1]] = [(a[
'run_number'
],a[
'ldn'
])]
61
62
63
allTags = sorted(dic1.keys(), key=
lambda
k: len(dic1[k]),reverse=
True
)
64
for
tag
in
allTags:
65
print
(tag,
':'
, end=
''
)
66
for
xx
in
dic1[tag]:
67
print
(xx[0], end=
''
)
68
print
()
69
70
71
t_acceptTags = c1.acceptTags
if
c1.acceptTags
else
allTags
72
73
74
ds = []
75
for
t
in
t_acceptTags:
76
for
a
in
dic1.get(t,[]):
77
found =
False
78
for
d
in
ds:
79
if
d[0] == a[0]:
80
found =
True
81
break
82
if
not
found:
83
ds.append(a)
84
85
86
if
len(ds)==0:
87
print
(
'No dataset in period'
,c1.period+
', exiting...'
)
88
return
89
90
91
for
d
in
ds:
92
print
(d[0],d[1])
93
runs.remove(d[0])
94
print
(runs)
95
96
97
if
len(runs) !=0:
98
print
(
'!'
*10)
99
print
(
'MISSING '
,
' '
.join(runs))
100
101
102
dlist=
','
.join([d[1]
for
d
in
ds])
103
superTag =
'period'
+c1.period+
','
+c1.sTag+ds[0][1][-5:]
104
comments = superTag+
','
+c1.derivation
105
106
cmd=
'ami cmd COMAPopulateSuperProductionDataset -rucioRegistration="yes" -creationComment="'
+comments+
'" -selectionType="run_config" -superTag="'
+superTag+
'" -containedDatasets="'
+dlist+
'" -separator="," '
107
print
(
'command:'
,cmd)
108
109
110
if
c1.outScript:
111
with
open(c1.outScript,
'a'
)
as
f1:
112
f1.write(cmd+
'\n'
)
113
return
114
115
116
if
not
c1.autoCreate:
117
while
True
:
118
x = raw_input(
"create contianer: y[es]/N[o]/e[xit]"
)
119
if
x ==
'e'
or
x==
'N'
:
return
120
elif
x==
'y'
:
break
121
122
call(cmd, shell=
True
)
123
124
125
def
doFirstTry
():
126
grl15 =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data15_13TeV/20160720/physics_25ns_20.7.xml'
127
grl16 =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data16_13TeV/20160916/physics_25ns_20.7_ignoreToroidStatus.xml'
128
c1 =
config1
(
'data16_13TeV'
,
'MUON0'
,
'A'
, sTag=
'grp16_v01_'
, acceptTags=[
'p2769'
,
'p2689'
,
'p2667'
], autoCreate=
False
, grl=grl16)
129
c1.outScript =
'createIt_15.sh'
130
131
# periods = AtlasAPI.list_dataperiods(client, 2, 16)
132
133
periods = AtlasAPI.list_dataperiods(client, 2, 15)
134
c1.project =
'data15_13TeV'
135
c1.sTag=
'grp15_v01_'
136
c1.acceptTags=[
'p2667'
]
137
c1.grl = grl15
138
139
pds =[p[
'period'
]
for
p
in
periods
if
p[
'status'
]==
'frozen'
]
140
# print (pds)
141
# sys.exit(0)
142
143
for
p
in
pds:
144
for
d
in
[
'MUON0'
,
'MUON1'
,
'MUON2'
,
'MUON3'
]:
145
# for d in ['MUON0']:
146
c1.period = p
147
c1.derivation = d
148
makeContainer
(c1)
149
150
def
doData15
():
151
grl15 =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data15_13TeV/20160720/physics_25ns_20.7.xml'
152
c1 =
config1
(
'data15_13TeV'
,
'MUON0'
,
'A'
, sTag=
'grp15_v01_'
, acceptTags=
None
, autoCreate=
False
, grl=
None
)
153
c1.outScript =
'createIt_15v2.sh'
154
155
periods = AtlasAPI.list_dataperiods(client, 2, 15)
156
c1.project =
'data15_13TeV'
157
c1.sTag=
'grp15_v02_'
158
c1.acceptTags=[
'p2889'
]
159
c1.grl = grl15
160
161
pds =[p[
'period'
]
for
p
in
periods
if
p[
'status'
]==
'frozen'
]
162
# print (pds)
163
# sys.exit(0)
164
165
for
p
in
pds:
166
for
d
in
[
'MUON0'
,
'MUON1'
,
'MUON2'
,
'MUON3'
]:
167
c1.period = p
168
c1.derivation = d
169
makeContainer
(c1)
170
171
172
def
do2016LaterPeriods
():
173
grl16 =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data16_13TeV/20161101/physics_25ns_20.7_ignoreToroidStatus.xml'
174
c1 =
config1
(
'data16_13TeV'
,
'MUON0'
,
'A'
, sTag=
'grp16_v01_'
, acceptTags=[
'p2769'
,
'p2689'
,
'p2667'
], autoCreate=
False
, grl=grl16)
175
c1.outScript =
'createIt_16Later2.sh'
176
177
periods = AtlasAPI.list_dataperiods(client, 2, 16)
178
179
c1.project =
'data16_13TeV'
180
c1.sTag=
'grp16_v01_'
181
c1.acceptTags=
None
182
c1.grl = grl16
183
184
# pds =[p['period'] for p in periods if p['status']=='frozen']
185
# print (pds)
186
# sys.exit(0)
187
pds = [
'J'
,
'K'
,
'L'
]
188
189
for
p
in
pds:
190
for
d
in
[
'MUON0'
,
'MUON1'
,
'MUON2'
,
'MUON3'
]:
191
c1.period = p
192
c1.derivation = d
193
makeContainer
(c1)
194
195
if
__name__ ==
'__main__'
:
196
do2016LaterPeriods
()
197
# doData15()
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
create_period_container.config1
Definition
create_period_container.py:30
create_period_container.config1.project
project
Definition
create_period_container.py:32
create_period_container.config1.grl
grl
Definition
create_period_container.py:38
create_period_container.config1.__init__
__init__(self, project, derivation, period, acceptTags, sTag, autoCreate=False, grl=None)
Definition
create_period_container.py:31
create_period_container.config1.autoCreate
autoCreate
Definition
create_period_container.py:37
create_period_container.config1.acceptTags
acceptTags
Definition
create_period_container.py:36
create_period_container.config1.outScript
outScript
Definition
create_period_container.py:39
create_period_container.config1.derivation
derivation
Definition
create_period_container.py:35
create_period_container.config1.period
period
Definition
create_period_container.py:33
create_period_container.config1.sTag
sTag
Definition
create_period_container.py:34
set
STL class.
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:179
create_period_container.getRuns
getRuns(grl)
Definition
create_period_container.py:23
create_period_container.doData15
doData15()
Definition
create_period_container.py:150
create_period_container.makeContainer
makeContainer(c1)
Definition
create_period_container.py:41
create_period_container.do2016LaterPeriods
do2016LaterPeriods()
Definition
create_period_container.py:172
create_period_container.doFirstTry
doFirstTry()
Definition
create_period_container.py:125
Generated on
for ATLAS Offline Software by
1.17.0