ATLAS Offline Software
Loading...
Searching...
No Matches
SFGenUtils Namespace Reference

Classes

class  SFGenConfig

Functions

 writeInputDAT (Init)
 run_command (command, stdin=None)
 SFGenInitialize (Init, stdin=None)
 SFGenExecute (Init)
 SFGenRun (Init, genSeq)

Variables

 logger = Logging.logging.getLogger("SFGen_i")
 Get handle to Athena logging.

Function Documentation

◆ run_command()

SFGenUtils.run_command ( command,
stdin = None )
Run a command and print output continuously

Definition at line 159 of file SFGenUtils.py.

159def run_command(command, stdin = None ):
160 """
161 Run a command and print output continuously
162 """
163 process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stdin=stdin)
164 while True:
165 output = process.stdout.readline().decode("utf-8")
166 if output == '' and process.poll() is not None:
167 break
168 if output:
169 # remove ANSI escape formatting characters
170 reaesc = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')
171 text = reaesc.sub('', output.strip())
172 logger.info(text)
173
174 rc = process.poll()
175 return rc
176
177# SFGen initialization
178

◆ SFGenExecute()

SFGenUtils.SFGenExecute ( Init)

Definition at line 212 of file SFGenUtils.py.

212def SFGenExecute(Init):
213
214 logger.info("Starting SFGen Itself")
215
216 if not os.path.exists('evrecs'):
217 os.makedirs('evrecs')
218 if not os.path.exists('outputs'):
219 os.makedirs('outputs')
220
221
222 try:
223 inputDAT = open('input.DAT')
224 except IOError:
225 raise Exception ("Problem with IO; potentially input.DAT not created correctly")
226 else:
227
228 try:
229
230 rc = run_command(Init.sfgenpath+'/bin/SFGen', stdin=inputDAT)
231
232 except OSError:
233 raise Exception("SFGen executable or file not found")
234
235 except Exception:
236 raise Exception("Non-OSError or IOError in SFGen execution block")
237
238 if rc:
239 raise Exception('Unexpected error in sfgen execution in SFGenExecute')
240
241 return
242
243# SFGen running
244

◆ SFGenInitialize()

SFGenUtils.SFGenInitialize ( Init,
stdin = None )

Definition at line 179 of file SFGenUtils.py.

179def SFGenInitialize(Init, stdin=None):
180
181 logger.info("Starting SFGen Initialization")
182
183 if not os.path.exists('evrecs'):
184 os.makedirs('evrecs')
185 if not os.path.exists('outputs'):
186 os.makedirs('outputs')
187
188
189 try:
190 inputDAT = open('input.DAT')
191
192 except IOError:
193 raise Exception("Problem with file IO; potentially input.DAT not created correctly")
194 else:
195
196 try:
197 rc = run_command(Init.sfgenpath+"/bin/SFGen", inputDAT)
198
199 except OSError:
200 raise Exception("File not found")
201
202 except Exception:
203 raise Exception("Non-OSError or IOError in execution block")
204
205 if rc:
206 raise Exception('Unexpected error in sfgen execution in SFGenInitialize')
207
208 return
209
210# SFGen execution
211

◆ SFGenRun()

SFGenUtils.SFGenRun ( Init,
genSeq )

Definition at line 245 of file SFGenUtils.py.

245def SFGenRun(Init, genSeq):
246
247 # dump the job configuration for fortran code
248 print(Init.toFortran())
249
250 # attach config to genSequence for later using in showering
251 genSeq.SFGenConfig = Init
252
253 writeInputDAT(Init)
254 SFGenInitialize(Init)
255 SFGenExecute(Init)
256
257 return
void print(char *figname, TCanvas *c1)

◆ writeInputDAT()

SFGenUtils.writeInputDAT ( Init)

Definition at line 151 of file SFGenUtils.py.

151def writeInputDAT(Init):
152
153 with open("input.DAT", "w") as outF:
154 outF.write(Init.toFortran())
155
156 return
157
158

Variable Documentation

◆ logger

SFGenUtils.logger = Logging.logging.getLogger("SFGen_i")

Get handle to Athena logging.

Definition at line 9 of file SFGenUtils.py.