9def main( runNum = None, procType = None, forceSkipQueue = 0, Stream = None ):
10
11
12 if runNum is None:
13 print(
'ERROR no run number given')
14 return False
15 Run0 = runNum
16
17 if procType is None:
18 print(
'ERROR no process type given')
19 return False
20 if Stream is None:
21 print(
'ERROR no stream given')
22 return False
23 for iType in procType:
24 if iType not in ['doNoisyStrip','doNoiseOccupancy','doDeadChip','doDeadStrip','doHV','doBSErrorDB','doRawOccupancy','doEfficiency','doLorentzAngle']:
25 print(
'ERROR process type does not match any possible candidates')
26 return False
27 else :
28 pType = iType
29
30
31
34
35
36 runQuery = 'AtlRunQuery.py '
37 runQuery += '--run \"' + str(Run0) + '\" '
38
39 if 'cos' not in Stream and 'idcomm' not in Stream:
40 runQuery += '--lhc \"stablebeams TRUE\" '
41
42 runQuery += '--partition \"ATLAS\" '
43 runQuery += '--detmaskin \"240A\" '
44
45
46 if 'eV' in Stream:
47 runQuery += '--projecttag \"data*_*eV\" '
48 elif 'hi' in Stream:
49 runQuery += '--projecttag \"data*_hi\" '
50 elif 'cos' in Stream:
51 runQuery += '--projecttag \"data*_cos\" '
52 else:
53 runQuery += '--projecttag \"data*_idcom\" '
54
55 if pType == 'doNoisyStrip':
56 runQuery += '--streams \"*calibration_SCTNoise 10000+\" '
57 runQuery += '--show \"streams *calibration_SCTNoise\" '
58
59 if pType == 'doDeadChip' or pType == 'doDeadStrip':
60
61 if 'cos' not in Stream:
62 runQuery += '--streams \"*express 200000+\" '
63 runQuery += '--show \"streams *express\" '
64 else:
65 runQuery += '--streams \"*IDCosmic 200000+\" '
66 runQuery += '--show \"streams *IDCosmic\" '
67
68
69 runQuery += '--show run --show projecttag --show events --show time --show \"lhc\" '
70 runQuery += '--noroot --nohtml --verbose'
72 os.system(runQuery)
73
74
76
77
78 if 'cos' not in Stream and 'idcomm' not in Stream:
79
80 StableBeam = False
81 if os.path.exists('./data/MyLBCollection.xml'):
82 f = open('./data/MyLBCollection.xml')
83 line = f.readline()
84 while line:
85 if "Metadata" in line and "RunList" in line and str(Run0) in line:
86 StableBeam = True
87 print(
"Run %s : run selection passed ---> job will be launched" %(Run0))
88 line = f.readline()
89 f.close()
90
91 else:
92 print(
"ERROR problem in access to /data/MyLBCollection.xml file produced by AtlRunQuery.py --- probably due to AtlRunQuery crash...")
93 sys.exit( -1 )
94
95 if not StableBeam:
96 print(
"Run %s : run selection didn't pass Stable Beam check--- job will be finished" %(Run0))
97 return False
98
99
100
101 Wait = True
102 if pType != 'doNoisyStrip' or forceSkipQueue == 1 :
103 Wait = False
104
105
106 while Wait:
107
108 RunLast = '0'
109 if os.path.exists('/afs/cern.ch/work/s/sctcalib/lastRun') :
110 f = open('/afs/cern.ch/work/s/sctcalib/lastRun')
111 line = f.readline()
112 while line:
113 RunLast = line
114 line = f.readline()
115 f.close()
116 print(
"Run %s : the last run uploaded" %(RunLast)[:-1])
117
118
119 if int(RunLast) > int(Run0) :
120 print(
"Run %s : taken later than the current run ---> job will not be run" %(RunLast)[:-1])
121 return False
122
123
124 runQuery = 'AtlRunQuery.py '
125 runQuery += '--run \"' + str(RunLast[:-1]) + '+\" '
126
127
128 if 'cos' not in Stream and 'idcomm' not in Stream:
129 runQuery += '--lhc \"stablebeams TRUE\" '
130 runQuery += '--partition \"ATLAS\" '
131 runQuery += '--detmaskin \"240A\" '
132
133 if 'eV' in Stream:
134 runQuery += '--projecttag \"data*_*eV\" '
135 elif 'hi' in Stream:
136 runQuery += '--projecttag \"data*_hi\" '
137 elif 'cos' in Stream:
138 runQuery += '--projecttag \"data*_cos\" '
139 else:
140 runQuery += '--projecttag \"data*_idcomm\" '
141
142
143
144
145
146 runQuery += '--streams \"*calibration_SCTNoise 10000+\" '
147 runQuery += '--show \"streams *calibration_SCTNoise\" '
148 runQuery += '--show run --show projecttag --show events --show time --show \"lhc\" '
149 runQuery += '--noroot --nohtml --verbose'
151 os.system(runQuery)
152
153
154 runList=[]
155 runDict={}
156 runNum=''
157 runPro=''
158 if os.path.exists("./data/QueryResult.txt") :
159 f = open('./data/QueryResult.txt')
160 line = f.readline()
161 while line:
162 if 'Run:' in line and runNum=='':
163 runNum = line.split(':')[1]
164 runNum = runNum.replace(
"\n",
'').
replace(
' ',
'')
165 if 'Project tag:' in line and runPro=='':
166 runPro = line.split('\'')[1]
167 if runNum!='' and runPro!='':
168 if 'data' in runPro:
169 runList.append(runNum)
170 runDict[runNum] = runPro
171 runNum=''
172 runPro=''
173 line = f.readline()
174
175 f.close()
176
177
178 RunWait = 0
179 for iRun in range( int(RunLast)+1, int(Run0) ):
180 if str(iRun) in runList:
181 RunWait += 1
182 print(
"Run %s: this run has to be processed/uploaded ---> job in pending state " %(iRun))
183
184
185 if RunWait == 0:
186 Wait = False
187 print(
"Run %s : checked the last run uploaded ---> job will be launched" %(Run0))
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209 if Wait:
210 print(
'Run %s : waiting for previous run(s) processed/uploaded' %(Run0))
211 time.sleep(5)
212
213
214 print(
'Run %s : job starts running now' %(Run0))
215 return True
216
217
void print(char *figname, TCanvas *c1)
std::string replace(std::string s, const std::string &s2, const std::string &s3)