def setUp(self): """Set up decay model""" # Read the full SM sm_path = import_ufo.find_ufo_path("sm") self.base_model = import_ufo.import_full_model(sm_path) model = copy.deepcopy(self.base_model) self.model = import_ufo.RestrictModel(model) self.restrict_file = os.path.join(_file_path, os.path.pardir, "input_files", "restrict_sm.dat")
def setUp(self): """Set up decay model""" #Read the full SM sm_path = import_ufo.find_ufo_path('sm') self.base_model = import_ufo.import_full_model(sm_path) model = copy.deepcopy(self.base_model) self.model = import_ufo.RestrictModel(model) self.restrict_file = os.path.join(_file_path, os.path.pardir, 'input_files', 'restrict_sm.dat')
def make_UFO_pkl(): """ """ file_cond = lambda p: os.path.exists( os.path.join(MG5DIR, 'models', p, 'particles.py')) #1. find UFO model: ufo_model = [ os.path.join(MG5DIR, 'models', p) for p in os.listdir(os.path.join(MG5DIR, 'models')) if file_cond(p) ] # model.pkl for model_path in ufo_model: start = time.time() print 'make model.pkl for %s :' % os.path.basename(model_path), #remove old pkl try: os.remove(os.path.join(model_path, 'model.pkl')) except: pass import_ufo.import_full_model(model_path) print '%2fs' % (time.time() - start) return # aloha routine for model_path in ufo_model: start = time.time() print 'make ALOHA for %s' % os.path.basename(model_path) #remove old pkl try: os.remove(os.path.join(model_path, 'aloha.pkl')) except: pass try: os.system('rm -rf %s &> /dev/null' % os.path.join(model_path, 'Fortran')) except: pass ufo_path, ufo_name = os.path.split(model_path) sys.path.insert(0, ufo_path) output_dir = os.path.join(model_path, 'Fortran') create_aloha.AbstractALOHAModel(ufo_name, write_dir=output_dir, format='Fortran') print 'done in %2fs' % (time.time() - start)
def setUp(self): """Set up decay model""" #Read the full SM sm_path = import_ufo.find_ufo_path('sm') self.base_model = import_ufo.import_full_model(sm_path) model = copy.deepcopy(self.base_model) self.model = import_ufo.RestrictModel(model) self.restrict_file = os.path.join(_file_path, os.path.pardir, 'input_files', 'restrict_sm.dat') self.model.set_parameters_and_couplings(self.restrict_file)
def make_UFO_pkl(): """ """ file_cond = lambda p : os.path.exists(os.path.join(MG5DIR,'models',p,'particles.py')) #1. find UFO model: ufo_model = [os.path.join(MG5DIR,'models',p) for p in os.listdir(os.path.join(MG5DIR,'models')) if file_cond(p)] # model.pkl for model_path in ufo_model: start = time.time() print 'make model.pkl for %s :' % os.path.basename(model_path), #remove old pkl try: os.remove(os.path.join(model_path,'model.pkl')) except: pass import_ufo.import_full_model(model_path) print '%2fs' % (time.time() - start) return # aloha routine for model_path in ufo_model: start = time.time() print 'make ALOHA for %s' % os.path.basename(model_path) #remove old pkl try: os.remove(os.path.join(model_path,'aloha.pkl')) except: pass try: os.system('rm -rf %s &> /dev/null' % os.path.join(model_path,'Fortran')) except: pass ufo_path, ufo_name =os.path.split(model_path) sys.path.insert(0, ufo_path) output_dir = os.path.join(model_path, 'Fortran') create_aloha.AbstractALOHAModel(ufo_name, write_dir=output_dir, format='Fortran') print 'done in %2fs' % (time.time() - start)
def setUp(self): """load the hardcoded NLO toy model to compare against the imported one""" self.hardcoded_loopmodel = loadLoopToyModel() # Make sure to move the pickle first in order not to load it if os.path.exists(os.path.join(_input_file_path, "loop_ToyModel", "model.pkl")): os.system( "mv -f " + str(os.path.join(_input_file_path, "loop_ToyModel", "model.pkl")) + " " + str(os.path.join(_input_file_path, "loop_ToyModel", "model_old.pkl")) ) # self.imported_loopmodel = models.import_full_model(os.path.join(\ # _input_file_path,'loop_ToyModel')) self.imported_loopmodel = models.import_full_model(os.path.join(_input_file_path, "LoopSMTest")) self.imported_loopmodel.actualize_dictionaries() self.hardcoded_loopmodel.actualize_dictionaries()
def setUp(self): """load the hardcoded NLO toy model to compare against the imported one""" self.hardcoded_loopmodel = loadLoopToyModel() # Make sure to move the pickle first in order not to load it if os.path.exists(os.path.join(\ _input_file_path,'loop_ToyModel','model.pkl')): os.system("mv -f "+str(os.path.join(\ _input_file_path,'loop_ToyModel','model.pkl'))+" "+\ str(os.path.join(_input_file_path,'loop_ToyModel',\ 'model_old.pkl'))) # self.imported_loopmodel = models.import_full_model(os.path.join(\ # _input_file_path,'loop_ToyModel')) self.imported_loopmodel = models.import_full_model(os.path.join(\ _input_file_path,'LoopSMTest')) self.imported_loopmodel.actualize_dictionaries() self.hardcoded_loopmodel.actualize_dictionaries()
outPath = pjoin(os.path.dirname(os.path.realpath(eventFile)), '%s_rwgt_%i.%s' % (evtFileName, i, evtFileExt)) try: evtBanner = banner.Banner(eventFile) evtFile = lhe_parser.EventFile(eventFile) except: logging.error("Could not read event file %s." % eventFile) # Start by loading the model of the banner try: model_name = evtBanner.get_detail('model') model_name = model_name.split('-')[0] # For now use the model 'sm' no matter what since it is only used for the particle naming scheme model_name = 'sm' user_model = import_ufo.import_full_model( pjoin(proc_path, os.pardir, 'models', model_name)) except: logging.error("Could not load the model %s used for generating the event file"\ %evtBanner.get_detail('model')) exit() # Detect the total number of event in an efficient way n_evts = int( subprocess.Popen('grep -rin "<event>" %s | wc -l' % os.path.realpath(eventFile), stdout=subprocess.PIPE, shell=True).communicate()[0]) logging.info("Writing out the reweighted event file on\n %s" % outPath) # Write out the output event file outputEvtFile = open(outPath, 'w')
def test_get_nflav_sm(self): """Tests the get_nflav_function for the full SM. Here b and c quark are massive""" sm_path = import_ufo.find_ufo_path('sm') model = import_ufo.import_full_model(sm_path) self.assertEqual(model.get_nflav(), 3)
def setUp(self): """Set up decay model""" #Read the full SM sm_path = import_ufo.find_ufo_path('heft') self.base_model = import_ufo.import_full_model(sm_path)
outPath=pjoin(os.path.dirname(os.path.realpath(eventFile)), '%s_rwgt_%i.%s'%(evtFileName,i,evtFileExt)) try: evtBanner = banner.Banner(eventFile) evtFile = lhe_parser.EventFile(eventFile) except: logging.error("Could not read event file %s."%eventFile) # Start by loading the model of the banner try: model_name=evtBanner.get_detail('model') model_name=model_name.split('-')[0] # For now use the model 'sm' no matter what since it is only used for the particle naming scheme model_name='sm' user_model = import_ufo.import_full_model(pjoin(proc_path,os.pardir,'models',model_name)) except: logging.error("Could not load the model %s used for generating the event file"\ %evtBanner.get_detail('model')) exit() # Detect the total number of event in an efficient way n_evts = int(subprocess.Popen('grep -rin "<event>" %s | wc -l'%os.path.realpath(eventFile), stdout=subprocess.PIPE, shell=True).communicate()[0]) logging.info("Writing out the reweighted event file on\n %s"%outPath) # Write out the output event file outputEvtFile = open(outPath,'w') outputEvtFile.write(evtFile.banner) # List the channel present in the process output