ATLAS Offline Software
InnerDetector
InDetCalibAlgs
SCT_CalibAlgs
scripts
getReferenceRun.py
Go to the documentation of this file.
1
#!/afs/cern.ch/sw/lcg/external/Python/2.6.5/i686-slc5-gcc43-opt/bin/python
2
3
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
4
5
import
os, sys, re
6
import
subprocess
7
8
'''set up the environment '''
9
def
setenv
():
10
os.environ[
"STAGE_SVCCLASS"
]=
"atlcal"
11
12
def
execute
(cmd,args=[]):
13
argList=[cmd]
14
argList.extend(args)
15
myobj=
None
16
try
:
17
myobj=subprocess.Popen(argList,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
18
s,e=myobj.communicate()
19
return
s,e
20
except
:
21
print
e
22
return
s,e
23
24
def
extractFilename
(dirLine):
25
#matchString="[drwx-]10\s+\d+\s+\d+\s+zp\s+\d+\s+[A-Za-z]3\s+\d+(.+)"
26
items=dirLine.split(
' '
)
27
return
items[-1]
28
29
def
ls
(fpath):
30
errs=
None
31
fileList=os.listdir(fpath)
32
return
fileList,errs
33
34
def
composeSctPath
(rootDir,runStr):
35
d=
"/"
36
return
rootDir+d+runStr+d+
"calibration_SCTNoise"
37
38
def
availableFiles
():
39
setenv
()
40
lastInList=-1
41
rootDir=
"/afs/cern.ch/user/s/sctcalib/scratch0/test_results/data"
42
listing,errs=
ls
(rootDir)
43
runNames=listing
44
try
:
45
#take the last run
46
# runNumberStr=runNames[lastInList]
47
# sctNoiseDir=composeSctPath(rootDir,runNumberStr)
48
listing,errs=
ls
(rootDir)
49
return
rootDir, listing
50
except
IndexError:
51
print
"Files not found in %s"
%rootDir
52
print
"listing gave %s"
%listing
53
return
rootDir,
""
54
55
def
lastAvailableFile
():
56
lastInList=-1
57
dirPath,fileList=
availableFiles
()
58
try
:
59
return
dirPath+
"/"
+fileList[lastInList]
60
except
IndexError:
61
print
"No files in %s"
%dirPath
62
63
def
main
():
64
print
lastAvailableFile
()
65
return
0
66
67
if
__name__ ==
"__main__"
:
68
sys.exit(
main
())
69
70
71
getReferenceRun.main
def main()
Definition:
getReferenceRun.py:63
getReferenceRun.availableFiles
def availableFiles()
Definition:
getReferenceRun.py:38
getReferenceRun.composeSctPath
def composeSctPath(rootDir, runStr)
Definition:
getReferenceRun.py:34
getReferenceRun.extractFilename
def extractFilename(dirLine)
Definition:
getReferenceRun.py:24
getReferenceRun.setenv
def setenv()
Definition:
getReferenceRun.py:9
getReferenceRun.lastAvailableFile
def lastAvailableFile()
Definition:
getReferenceRun.py:55
getReferenceRun.ls
def ls(fpath)
Definition:
getReferenceRun.py:29
getReferenceRun.execute
def execute(cmd, args=[])
Definition:
getReferenceRun.py:12
Generated on Thu Nov 7 2024 21:15:50 for ATLAS Offline Software by
1.8.18