ATLAS Offline Software
Loading...
Searching...
No Matches
UploadAMITag.larcaf.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4
5
6#Example command: UploadAMITag.larcaf.py wlampl xxx create_c909 AtlasProduction_20.1.5.6 noisebursts
7
8
9import sys
10
11patcharea='/afs/cern.ch/user/l/larcomm/w0/digitMon/LArCAF'
12setupScript='/afs/cern.ch/atlas/tzero/software/setup/setuptrf.sh'
13specialT0Setup='/afs/cern.ch/atlas/tzero/software/setup/specialsetup_tier0.sh'
14trfsetuppath='/afs/cern.ch/atlas/tzero/software/setup/'
15processConfigs = {}
16
17processConfigs['noisebursts'] = {
18 'inputs': { 'inputESDFile': {} },
19 'outputs': { 'outputNTUP_LARNOISEFile': {'dstype': 'NTUP_LARNOISE'}, },
20 'tasktransinfo': { 'trfpath': 'LArNoiseBursts_tf.py',
21 'trfsetupcmd': setupScript+ ' '+patcharea+' RELEASE ' + specialT0Setup},
22 'phconfig': {},
23 'description': 'Produced LAr noise burst ntuple from ESD files. Uses RELEASE'
24 }
25
26processConfigs['noiseburstsmerge'] = {
27 'inputs': { 'inputNTUP_LARNOISEFile': {} },
28 'outputs': { 'outputNTUP_LARNOISE_MRGFile': {'dstype': 'NTUP_LARNOISE_MRG'}, },
29 'tasktransinfo': { 'trfpath': 'NTUPMerge_tf.py',
30 'trfsetupcmd': setupScript+ ' '+patcharea+' RELEASE ' + specialT0Setup},
31 'phconfig': {},
32 'description': 'Merge LAr noise burst ntuple files. Uses RELEASE'
33 }
34
35
36processConfigs['reco'] = {
37 'inputs': { 'inputBSFile': {} },
38 'outputs': { 'outputNTUP_SAMPLESMONFile': {'dstype': 'NTUP_SAMPLESMON'}, },
39 'tasktransinfo': { 'trfpath': 'LArCAF_tf.py',
40 'trfsetupcmd': setupScript+ ' '+patcharea+' RELEASE ' + specialT0Setup},
41 'phconfig': {},
42 'description': 'Runs LAr Samples monitoring job on LArCells or LArCellsEmpty calibration streams. Uses RELEASE'
43 }
44
45
46processConfigs['merge'] = {
47 'inputs': { 'inputLArFiles': {} },
48 'outputs': { 'outputLArFile': {'dstype': 'NTUP_SAMPLESMON'}, },
49 'tasktransinfo': { 'trfpath': 'LArMerge_trf.py',
50 'trfsetupcmd': trfsetuppath+'setuptrf.sh '+patcharea+' RELEASE '+trfsetuppath+'specialsetup_tier0.sh' },
51 'phconfig': {},
52 'description': 'Merges LAr Samples monitoring ntuples. Uses RELEASE'
53 }
54
55
56processConfigs['histmerge'] = {
57 'inputs': { 'inputHistFiles': {'metatype':'inputLFNlistDA'} },
58 'outputs': { 'outputLArHistFile': {'dstype': 'LARHIST'}, },
59 'tasktransinfo': { 'trfpath': 'LArHistMerge_trf.py',
60 'trfsetupcmd': trfsetuppath+'setuptrf.sh '+patcharea+' RELEASE '+trfsetuppath+'specialsetup_tier0.sh' },
61 'phconfig': {},
62 'description': 'Merges LAr Monitoring Histograms. Uses RELEASE'
63 }
64
65
66
67
68
69
70description_var = '. Used in production from Feb 2015 onwards.'
71
72# example release: AtlasTier0-15.5.3.7
73
74if __name__ == '__main__':
75 if len(sys.argv)==1:
76 print ("##############")
77 print ("Application to create or update AMI tags (for manager only)\n")
78 print ("Usage:")
79 print ("UploadAMITag.py <login> <password> create_AMITag <release> <process>")
80 print ("or")
81 print ("UploadAMITag.py <login> <password> update_AMITag <release> <process>")
82 print ("##############")
83 sys.exit(0)
84
85
86 login=sys.argv[1]
87 password=sys.argv[2]
88 amiTagTmp=sys.argv[3]
89 release=sys.argv[4]
90 process=sys.argv[5]
91 #process='larcaf'
92
93 doWhat="Dunno"
94 amiTag=''
95 if amiTagTmp.startswith("create_"):
96 doWhat="create"
97 amiTag=amiTagTmp.replace("create_", "")
98 elif amiTagTmp.startswith("update_"):
99 doWhat="update"
100 amiTag=amiTagTmp.replace("update_", "")
101
102 #prepare input, output and config dictionaries
103
104 #-----------------------------
105 # Tier0 specific 'moreInfo'. Hopefully temporary.
106 moreInfoDic = {}
107 trfsetupcmd = processConfigs[process]['tasktransinfo']['trfsetupcmd'].replace('RELEASE', str(release))
108 trfpath = processConfigs[process]['tasktransinfo']['trfpath']
109 moreInfoDic['tasktransinfo'] = {'trfsetupcmd': trfsetupcmd, 'trfpath': trfpath}
110
111 #---------------------
112 #Get pyAMI client
113 #try:
114 # import pyAMI.client
115 #except ImportError:
116 # print ("WARNING unable to import AMI from pyAMI with standard $PYTHONPATH.")
117 # print ("Will manually add pyAMI, then try again...")
118 # import sys
119 # sys.path.insert(0,'/afs/cern.ch/atlas/software/tools/pyAMI/5.0.0/lib')
120 # import pyAMI.client
121 #print ("import pyAMI was succesful")
122 #amiclient=pyAMI.client.Client('atlas')
123
124
125 from pyAMI.client import Client
126 amiclient=Client('atlas')
127 #from pyAMI.client import AMIClient
128 #amiclient=Client(False)
129
130 #------------------------
131 #Build final AMI tag info
132 s={} #stable values
133 s['amiTag']=amiTag
134 s['tagType']=amiTag[0]
135 s['AMIUser']=login
136 s['AMIPass']=password
137
138 c={} #changing values
139 c['inputs']=str(processConfigs[process]['inputs'].__str__())
140 c['outputs']=str(processConfigs[process]['outputs'].__str__())
141 c['SWReleaseCache']=str(release)
142 if process=='reco' or process=='noisebursts':
143 c['Geometry']='ATLAS-R2-2015-02-00-00'
144 c['ConditionsTag']='CURRENT'
145 else: #merging case
146 c['Geometry']='n/a'
147 c['ConditionsTag']='n/a'
148 c['phconfig']=str(processConfigs[process]['phconfig'].__str__())
149 c['transformation']=str(moreInfoDic['tasktransinfo']['trfpath'])
150 c['trfsetupcmd']=str(moreInfoDic['tasktransinfo']['trfsetupcmd'])
151 c['moreInfo']=str(moreInfoDic.__str__())
152 c['description']=processConfigs[process]['description'].replace('RELEASE', str(release)) + description_var
153
154
155 #Upload info to AMI
156 if doWhat=="create":
157 l=['AddAMITag'] # noqa: E741
158 for k in s.keys():
159 l.append(k+"=\""+s[k]+"\"")
160 for k in c.keys():
161 l.append(k+"=\""+c[k]+"\"")
162
163 print ("l=",l)
164 result=amiclient.execute(l)
165
166 print (" ================================================ ")
167
168 print (result)
169 print ("\n\n###############################################")
170 print ("# Successfully created new tag %s !! :-) #"%amiTag)
171 print ("###############################################\n\n" )
172
173
174 elif doWhat=="update":
175 l=['UpdateAMITag'] # noqa: E741
176 for k in s.keys():
177 l.append(k+'='+s[k])
178
179 s='xx'
180 l.append('separator='+s)
181
182 nKeys=len(c.keys())
183 n=0
184 tmp='updateField='
185 for k in c.keys():
186 tmp+=k
187 n+=1
188 if n<nKeys:
189 tmp+=s
190 l.append(tmp)
191
192 n=0
193 tmp='updateValue='
194 for k in c.keys():
195 tmp+=c[k]
196 n+=1
197 if n<nKeys:
198 tmp+=s
199 l.append(tmp)
200
201 #print ("l=",l)
202 result=amiclient.execute(l)
203 print (result)
204
205
206 print ("\n\n#####################################################")
207 print ("# Succesfully updated existing tag %s !!! :-) #"%amiTag)
208 print ("#####################################################\n\n" )
209
210 else:
211 raise SyntaxError("Don't know what to do... amiTagTmp='%s' doWhat='%s'"%(amiTagTmp,doWhat))
212
213 print ("To see the corresponding command, do:")
214 print ("GetCommand.py AMI=%s \n"%amiTag)
215 print ("or go to:")
216 print ("http://ami.in2p3.fr/AMI/servlet/net.hep.atlas.Database.Bookkeeping.AMI.Servlet.Command?linkId=501")
217 print ("\n")
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310