def do_treatcards(self, line): """MadWeight Function:create the various param_card // compile input for the run_card""" self.configure() args = self.split_arg(line) create_param.Param_card(run_name=self.MWparam) self.MWparam.update_nb_card() Cards.create_include_file(self.MWparam) create_run.update_cuts_status(self.MWparam)
def __init__(self, card_name): """ init all the param for the run """ self.mw_card = Cards.Card(card_name) self.info = self.mw_card.info for key, value in self.info.items(): self[key] = value dict.__init__(self.info) self.check_info() #assign special value self.nb_event = self.info['mw_run']['nb_exp_events'] self.nb_card = self.number_of_P_run() try: self.name = self.info['mw_run']['name'] except: self.name = self.take_run_name() self.P_listdir, self.MW_listdir = self.detect_SubProcess() self.nb_event_MW = {} for MW in self.MW_listdir: self.nb_event_MW[MW] = self.nb_event self.init_run_opt() self.def_actif_param() self.Pinupdate = [] self.Minpudate = [] self.startevent = 0
def charge_particle_content(self): """ find the ingoing and outgoing particles for this Subprocess store this information in self.particles=[list of PID] return the dictionary """ self.particles = Cards.read_leshouches_file(self.dir+'/leshouche.inc') return self.particles
def update_dir(name, make, MW_dir): main = '../../../' os.system("cp ./ident_mw_card.dat " + main + "/Cards/") os.system("cp transfer_card.dat " + main + "/Cards/") os.system("cp data/transfer_card_" + name + ".dat " + main + "/Cards/transfer_card.dat &>/dev/null") os.system("cp data/transfer_card_" + name + ".dat " + main + "/Cards/transfer_card_default.dat &>/dev/null") if make: os.chdir(main + "/Source/") os.system("make") for directory in MW_dir: os.chdir(main + "/SubProcesses/" + directory) os.system( "ln -s ../../Source/MadWeight/transfer_function/TF_param.inc TF_param.inc" ) os.system( "ln -s ../../Source/MadWeight/transfer_function/nb_tf.inc nb_tf.inc" ) os.system("make") os.chdir('../../') else: os.system("make ") # always compile libTF ... os.chdir(main) for directory in MW_dir: os.chdir("SubProcesses/" + directory) os.system( "ln -s ../../Source/MadWeight/transfer_function/TF_param.inc TF_param.inc" ) os.system( "ln -s ../../Source/MadWeight/transfer_function/nb_tf.inc nb_tf.inc" ) os.chdir('../../') #charge card ident = Cards.Card('./Cards/ident_mw_card.dat') madweight = Cards.Card('./Cards/MadWeight_card.dat') transfer = Cards.Card('./Cards/transfer_card.dat') #create output madweight.create_include_file(ident, './Source/madweight_card.inc') transfer.create_include_file_tf(ident, './Source/MadWeight/transfer_function') os.chdir('./Source/MadWeight/transfer_function')
def import_ext_part(self, dir_file): """ read leshouches.inc information """ pid_list = Cards.read_leshouches_file(dir_file + '/' + 'leshouche.inc') #create the particle object and put them in the content of the diag #add the mass corresponding to the card for i in range(1, len(pid_list) + 1): #MG start at one a = external_part(i, pid_list[i - 1]) self.add_content(i, a)
def import_ext_part(self,dir_file): """ read leshouches.inc information """ pid_list = Cards.read_leshouches_file(dir_file+'/'+'leshouche.inc') #create the particle object and put them in the content of the diag #add the mass corresponding to the card for i in range(1,len(pid_list)+1):#MG start at one a=external_part(i,pid_list[i-1]) self.add_content(i,a)
def read_card(name_card): """put all card information in a dictionary""" card = Cards.Card(name_card) return card.info
def load_particles_file(self,filepos='./Source/MODEL/particles.dat'): """ load the particles file if not already loaded """ if not self.particles_file: self.particles_file = Cards.Particles_file(filepos)
def define_tf_width(self, file): """ assign width of the TF function for all external particle """ if not hasattr(self, 'ParticlesFile'): self.ParticlesFile = Cards.Particles_file( './Source/MODEL/particles.dat') dico_pid_to_label = self.ParticlesFile.give_pid_to_label() dico_type_to_tflevel = {} has_theta_tf, has_phi_tf = [], [] ff = open(file, 'r') #pattern pattern = re.compile(r'''^\s*(?P<width>\w+)\s+(?P<type>[\w,01]*)''', re.VERBOSE) #read file while 1: line = ff.readline() if line == '': break if pattern.search(line): re_obj = pattern.search(line) if re_obj.group('width').lower() == 'delta': tf_level = 0 elif (re_obj.group('width').lower() == 'thin'): tf_level = 1 elif (re_obj.group('width').lower() == 'x'): self.x_constrained = int(re_obj.group('type')) continue elif (re_obj.group('width').lower() == 'theta'): list = re_obj.group('type').split(',') for tag in list: has_theta_tf.append(tag) continue elif (re_obj.group('width').lower() == 'phi'): list = re_obj.group('type').split(',') for tag in list: has_phi_tf.append(tag) continue else: tf_level = 2 list = re_obj.group('type').split(',') for tag in list: dico_type_to_tflevel[tag] = tf_level #put information in external particle for part in self.ext_content: try: label = dico_pid_to_label[abs(part.pid)] except KeyError: logger.info( 'particle with pdg %s has no transfer function define: Treated as missing energy' % part.pid) label = None if not part.neutrino: if label in dico_type_to_tflevel: part.tf_level = dico_type_to_tflevel[label] else: part.tf_level = 0 #delta is the default else: part.tf_level = 3 if label in has_theta_tf: part.has_theta_tf = True if label in has_phi_tf: part.has_phi_tf = True