~durga/maus/rel709

« back to all changes in this revision

Viewing changes to tests/integration/test_simulation/test_physics_model_full/physics_model_test/code_setup.py

  • Committer: Durga Rajaram
  • Date: 2013-10-01 00:19:57 UTC
  • mfrom: (659.1.74 rc)
  • Revision ID: durga@fnal.gov-20131001001957-iswih60vis9rodw0
Tags: MAUS-v0.7.1
MAUS-v0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
        """Initialise - does nothing"""
168
168
        CodeSetup.__init__(self)
169
169
        if os.getenv('ICOOL') == None:
170
 
            raise EnvironmentError("Need to define $ICOOL environment "+\
171
 
                                   "variable with ICOOL executable path")
172
 
        if os.getenv('ICOOL_VERSION') == None:
173
 
            raise EnvironmentError("Need to define $ICOOL_VERSION "+\
174
 
                                   "environment variable with ICOOL version")
175
 
        self._version = os.getenv('ICOOL_VERSION')
 
170
            icool_version = open(os.path.\
 
171
                                  expandvars('/home/hep/sm1208/icool/README'))\
 
172
                                                                     .readline()
 
173
            icool_version = icool_version.rstrip('\n')
 
174
            icool_version = icool_version.split(' ')[-1]
 
175
            self._version = icool_version
 
176
 
 
177
        else:
 
178
            
 
179
            self._version = os.getenv('ICOOL')
176
180
 
177
181
 
178
182
    def __str__(self):
202
206
              'STEEL304':'FE',
203
207
              'Cu':'CU',
204
208
              'C':'C',
 
209
              'Ti':'TI',
 
210
              'Li':'LI',
 
211
              'Fe':'FE'
205
212
        }
206
213
        return conversions[value]
207
214
 
212
219
 
213
220
    def get_executable(self):
214
221
        """Executable is simulate_mice.py"""
215
 
        return os.path.expandvars('$ICOOL')
 
222
    
 
223
        return os.path.join('/home/hep/sm1208/icool','icool')
 
224
       
216
225
 
217
226
    def get_parameters(self):
218
227
        """Command line parameter to specify control files"""
230
239
        """Bunch is station 2"""
231
240
        return 5
232
241
 
233
 
class G4blSetup(CodeSetup):
234
 
    """
235
 
    Conversions and setup for G4Beamline
236
 
    """
237
 
    def __init__(self):
238
 
        """Initialise - does nothing"""
239
 
        CodeSetup.__init__(self)
240
 
        if os.getenv('G4BL') == None:
241
 
            raise EnvironmentError("Need to define $G4BL environment "+\
242
 
                                   "variable with G4Beamline executable path")
243
 
        if os.getenv('G4BL_VERSION') == None:
244
 
            raise EnvironmentError("Need to define $G4BL_VERSION "+\
245
 
                                   "environment variable with G4bl version")
246
 
        self._version = os.getenv('G4BL_VERSION')
247
 
 
248
 
    def __str__(self):
249
 
        """Return name of this code"""
250
 
        return 'g4bl_'+self._version
251
 
 
252
 
    def convert_position(self, value):
253
 
        """Does nothing"""
254
 
        return value
255
 
 
256
 
    def convert_momentum(self, value):
257
 
        """Does nothing"""
258
 
        return value
259
 
 
260
 
    def convert_pid(self, value):
261
 
        """Does nothing"""
262
 
        return value
263
 
 
264
 
    def convert_material(self, value):
265
 
        """Does nothing"""
266
 
        conversions = {
267
 
            'lH2':'LH2', 'LITHIUM_HYDRIDE':'LITHIUM_HYDRIDE', 'Al':'Al', 
268
 
            'Be':'Be', 'lHe':'lHe', 'STEEL304':'Fe','Cu':'Cu', 'C':'C',
269
 
        }
270
 
        return conversions[value] 
271
 
 
272
 
    def get_substitutions(self):
273
 
        """Input file is configuration file and geometry definitions"""
274
 
        return {geometry.source('g4bl/g4bl_deck.in'):\
275
 
                geometry.temp('g4bl_deck')}
276
 
 
277
 
    def get_executable(self):
278
 
        """Executable is simulate_mice.py"""
279
 
        return os.getenv('G4BL')
280
 
 
281
 
    def get_parameters(self):
282
 
        """Command line parameter to specify control files"""
283
 
        return [geometry.temp('g4bl_deck')]
284
 
 
285
 
    def get_output_filename(self):
286
 
        """Output filename dynamically pulls MAUS version from README"""
287
 
        return 'g4bl.'+self._version+'.ref_data.dat'
288
 
 
289
 
    def get_bunch_read_keys(self):
290
 
        """I/O type is maus_root_virtual_hit"""
291
 
        return ('icool_for009',  geometry.temp('for009_g4bl.txt'))
292
 
 
293
 
    def get_bunch_index(self):
294
 
        return 2
 
242
 
295
243
 
296
244
class G4MICESetup(CodeSetup):
297
245
    """
446
394
    in directory pointed to by $ICOOL_ELMSDB environment variable.
447
395
    """
448
396
    def __init__(self):
449
 
        """
450
 
        Additional initialisation is environment variable giving location of
451
 
        elmsdb
452
 
        """
 
397
       
453
398
        super(IcoolElmsSetup, self).__init__()
454
 
        if os.getenv('ICOOL_ELMSDB') == None:
455
 
            raise EnvironmentError("Need to define $ICOOL_ELMSDB "+\
456
 
                                  "environment variable with ELMS data")
457
 
        run_dir = os.path.expandvars("${ICOOL_ELMSDB}/RunDirectory.txt")
 
399
        #if os.getenv('ICOOL_ELMSDB') == None:
 
400
            #raise EnvironmentError("/home/hep/sm1208/icool/elms")
 
401
        run_dir = os.path.expandvars(\
 
402
                                      "/home/hep/sm1208/icool/elms/"+\
 
403
                                        "RunDirectory.txt")
458
404
        if not os.path.isfile(run_dir):
459
405
            raise EnvironmentError("Couldn't find "+run_dir+" needed for elms")
460
 
        elms_db = "${ICOOL_ELMSDB}/ELMSFv3run*"
 
406
        elms_db = "/home/hep/sm1208/icool/elms/ELMSFv3run*"
461
407
        if len(glob.glob(os.path.expandvars(elms_db))) < 1:
462
408
            raise EnvironmentError("Couldn't find files like "+elms_db+\
463
409
                                                            " needed for elms")
464
410
        IcoolElmsSetup._substitute_elmscom()
 
411
        
 
412
      
 
413
       
465
414
 
466
415
    def __str__(self):
467
416
        """Return icool_elms_<version>"""