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