Package madgraph :: Package madweight :: Module create_run
[hide private]
[frames] | no frames]

Source Code for Module madgraph.madweight.create_run

  1  #!/usr/bin/env python 
  2   
  3  #Extension 
  4  from __future__ import absolute_import 
  5  from __future__ import print_function 
  6  import string,os,sys,re,time,stat,filecmp 
  7  from six.moves import range 
  8  from six.moves import input 
  9   
 10  try:  
 11      import madgraph.madweight.mod_file as mod_file 
 12      import madgraph.madweight.change_tf as change_tf 
 13      #import madgraph.various.progressbar as progressbar 
 14  except ImportError: 
 15      import internal.madweight.mod_file as mod_file 
 16      #import internal.madweight.progressbar as progressbar 
 17   
 18   
 19  ########################################################################### 
 20  ##                                CONTENT                                ## 
 21  ##                                -------                                ## 
 22  ##                                                                       ## 
 23  ##    + update_cuts_status                                               ## 
 24  ##         activate/desactivate the cuts in ME/MW                        ## 
 25  ##     + cut_is_active (send cut status)                                 ## 
 26  ##     + check_Subprocesses_update (check if Subprocces/(MW_?)P files    ## 
 27  ##         follows the last version of the file -protection against cp-) ## 
 28  ##    + active_acceptance_run                                            ## 
 29  ##    + desactive_acceptance_run                                         ## 
 30  ##    + del_old_dir                                                      ## 
 31  ##    + create_dir                                                       ## 
 32  ##    + copy_file                                                        ## 
 33  ##    + put_data                                                         ## 
 34  ##    + restore_last_info_for_control (not use anymore)                  ## 
 35  ##    + create_all_MWdir                                                 ## 
 36  ##    + create_all_Pdir                                                  ## 
 37  ##    + create_all_schedular                                             ## 
 38  ########################################################################### 
 39   
 40   
 41  ########################################################################### 
 42  ###################           VARIABLE GLOBALE           ################## 
 43  ########################################################################### 
 44  opt=sys.argv 
 45  write = sys.stdout.write 
 46   
 47   
48 -class NoMoreEvent(Exception):
49 pass
50 51 ########################################################################### 52 ################### GESTION OF CUT (des)ACTIVATE ################## 53 ########################################################################### 54
55 -def update_cuts_status(MW_param):
56 """ remove the call to the cuts if asked in MadWeight_Card.dat """ 57 58 # Pierre: pass 59 return 60 61 #check cut status for cross section: 62 if (MW_param.info['mw_run']['use_cut']+cut_is_active('cuts.f'))%2: #pass if not coherent between asked and actual status 63 file_to_mod=['./SubProcesses/cuts.f'] 64 rule=['./Source/MadWeight/mod_file/suppress_cuts_MG'] 65 #modify file 66 mod_file.mod_file(file_to_mod,rule,opt={'nowarning':"""['PASSCUTS','MW_NEW_DEF','DESACTIVATE_BW_CUT']"""}) 67 #check update 68 check_Subprocesses_update('cuts.f',MW_param.P_listdir,'./Source/MadWeight/mod_file/suppress_cuts_MG') 69 70 #check cut status for Weight computation: 71 if (MW_param.info['mw_run']['use_cut']+cut_is_active('cuts_MW.f'))%2: #pass if not coherent between asked and actual status 72 file_to_mod=['./SubProcesses/cuts_MW.f'] 73 rule=['./Source/MadWeight/mod_file/suppress_cuts_MW'] 74 #modify file 75 mod_file.mod_file(file_to_mod,rule,opt={'nowarning':"""['PASSCUTS','TO_SPECISA','DESACTIVATE_BW_CUT']"""}) 76 #check update 77 check_Subprocesses_update('cuts_MW.f',MW_param.MW_listdir,'./Source/MadWeight/mod_file/suppress_cuts_MW') 78 79 #check BW cut status for cross section 80 if (MW_param['mw_run']['bw_cut']+bw_cut_is_active('cuts.f'))%2: #pass if not coherent between asked and actual status 81 file_to_mod=['./SubProcesses/cuts.f'] 82 rule=['./Source/MadWeight/mod_file/suppress_BW_cuts'] 83 #modify file 84 mod_file.mod_file(file_to_mod,rule,opt={'nowarning':"""['PASSCUTS','MW_NEW_DEF']"""}) 85 #check update 86 check_Subprocesses_update('cuts.f',MW_param.P_listdir,'./Source/MadWeight/mod_file/suppress_BW_cuts') 87 88 #check cut status for Weight computation: 89 if (MW_param.info['mw_run']['bw_cut']+bw_cut_is_active('cuts_MW.f'))%2: #pass if not coherent between asked and actual status 90 file_to_mod=['./SubProcesses/cuts_MW.f'] 91 rule=['./Source/MadWeight/mod_file/suppress_BW_cuts'] 92 #modify file 93 mod_file.mod_file(file_to_mod,rule,opt={'nowarning':"""['PASSCUTS','TO_SPECISA']"""}) 94 #check update 95 check_Subprocesses_update('cuts_MW.f',MW_param.MW_listdir,'./Source/MadWeight/mod_file/suppress_BW_cuts')
96 97 98 99 100
101 -def cut_is_active(filename):
102 """ check is the cut is active or not """ 103 104 # Pierre: pass the fucntion 105 pass
106 107 # for line in file('./SubProcesses/'+filename): 108 # if line.count('DESACTIVATE_CUT'): 109 # return 1 110 # elif line.count('ACTIVATE_CUT'): 111 # return 0 112
113 -def bw_cut_is_active(filename):
114 """ check is the bw_cutt is active or not """ 115 for line in open('./SubProcesses/'+filename): 116 if 'DESACTIVATE_BW_CUT' in line: 117 return 1 118 elif 'ACTIVATE_BW_CUT' in line: 119 return 0 120 raise Exception
121 122 123
124 -class check_Subprocesses_update:
125 """ check if Subprocces/'listdir' files follows the last version of 126 ./SubProcesses/'filename'. This is a protection against copy files 127 -normally they are just linked- 128 129 different mode are available 130 warning: 131 0: no warning apply modification 132 1: warning and apply modification 133 2: warning and user choice 134 3: warning but no modification 135 4: no warning and no modification 136 5: warning and raising error 137 modifrule: 138 '', copy the original file 139 else: apply the modification asked in modifrule 140 141 """ 142
143 - class ERROR_DifferenceInFile(Exception):pass
144 145 146
147 - def __init__(self,filelist,listdir,modifrule='',warning=1,run=1):
148 149 #chek type input: 150 if type(filelist)==str: 151 self.filelist=[filelist] 152 else: 153 self.filelist=filelist 154 if type(listdir)==str: 155 self.listdir=[listdir] 156 else: self.listdir=listdir 157 158 self.modifrule=modifrule 159 160 161 #assign tag mode 162 usewarning=0 163 if int(warning) in [1,2,3,5]: 164 self.usewarning=1 165 166 self.usemodif=0 167 self.intmode=0 168 self.raiseerror=0 169 if int(warning) in [0,1]: 170 self.usemodif=1 #apply 171 elif int(warning)==2: 172 self.intmode=1 #interactive mode 173 elif int(warning)==5: 174 self.raiseerror==1 #raising error 175 176 if run: 177 self.compare()
178 179
180 - def compare(self):
181 #main loop 182 for dirname in self.listdir: 183 for filename in self.filelist: 184 status=filecmp.cmp('./SubProcesses/'+filename,'./SubProcesses/'+dirname+'/'+filename) 185 186 if status: 187 continue #continue check if ok 188 189 #warning 190 if self.usewarning: 191 self.printwarning('./SubProcesses/'+filename,'./SubProcesses/'+dirname+'/'+filename) 192 193 #error 194 if self.raiseerror: 195 raise self.ERROR_DifferenceInFile 196 197 #interactive mode 198 if self.intmode: 199 self.usemodif=self.printintmode('./SubProcesses/'+dirname+'/'+filename) 200 201 #modif file 202 if self.usemodif: 203 self.modiffile('./SubProcesses/'+dirname+'/'+filename,self.modifrule)
204 205
206 - def printwarning(self,filename1,filename2):
207 208 print(""" WARNING: those file are supposed to be identical (symbolic link):\n\ 209 ./SubProcesses/"""+filename1+"""\n./SubProcesses/"""+filename2) 210 print(""" define the tag MW_run/901 to change the rule for modification """) 211 if self.usemodif==0: 212 print(""" no modification to the file are done """) 213 elif self.usemodif==1: 214 print(""" modify the file """)
215
216 - def printintmode(self,file):
217 218 a=input('modify file '+file+'with rule'+self.modifrule+'? (y/n)') 219 if a=='y': 220 return 1 221 elif a=='n': 222 return 0 223 else: 224 a=self.printintmode(file) 225 return a
226
227 - def modiffile(self,file,rule):
229 230 ########################################################################### 231 ######### ACTIVATE/DESACTIVATE ACCEPTANCE TERM ########### 232 ###########################################################################
233 -class AcceptanceError(Exception): pass
234
235 -def activate_acceptance_run():
236 """ 1. reactivate the write of events .lhe 237 2. modify combine_event.f 238 3. modify pythia-pgs/src/pythia.f --> Pass in standard in special package 239 4. modify pythia-pgs/src/pgs.f --> Pass in standard in special package 240 5. compile those modification 241 """ 242 #0. test if the card/directory exist 243 if not( os.path.isfile('./Cards/pythia_card.dat') and 244 os.path.isfile('./Cards/pgs_card.dat') and 245 os.path.isdir('../MW_pythia-pgs')): 246 raise AcceptanceError('Cards or MW_pythia-pgs missing... impossible to load acceptance module') 247 248 #1. test if the acc is already loaded 249 if os.path.isfile('./Source/MadWeight_file/acc.in'): 250 return 251 os.system('touch ./Source/MadWeight_file/acc.in') 252 253 #2. reactivate the write of events .lhe 254 mod_file.mod_file('./SubProcesses/unwgt.f',{'S-DECOMMENT_C':''}) 255 256 #3. change combine_events.f 257 mod_file.mod_file('./Source/combine_events.f','./Source/MadWeight/mod_file/mod_combine_events') 258 259 #4. modify pythia_card.dat 260 mod_file.mod_file('./Cards/pythia_card.dat','./Source/MadWeight/mod_file/mod_combine_events') 261 262 #4. modify pythia-pgs/src/pythia.f 263 #os.system('cp ../pythia-pgs/src/pythia.f ../pythia-pgs/src/pythia_default.f') 264 #rule={} 265 #rule['def_file']=change_tf.put_in_fortran_format(""" 266 # write(*,*) 'enter input/output file for MW run' 267 # read(*,*) input_file,output_file 268 #pythia_card='../Cards/pythia_card.dat' 269 # nfiles=1 270 #""") 271 #mod_file.mod_file('../pythia-pgs/src/pythia.f',rule) 272 273 #4. modify pythia-pgs/src/pgs.f 274 #os.system('cp ../pythia-pgs/src/pgs.f ../pythia-pgs/src/pgs_default.f') 275 #rule={} 276 #rule['def_file']=change_tf.put_in_fortran_format(""" 277 # write(*,*) 'enter input file for MW run' 278 # read(*,*) pgs_input_file 279 # write(*,*) 'enter output file for MW run' 280 # read(*,*) pgs_output_file 281 #""") 282 #mod_file.mod_file('../pythia-pgs/src/pgs.f',rule) 283 284 #5.compile the new files 285 os.system("cd Source;make ../bin/combine_events;cd -") 286 os.system("cd ../MW_pythia-pgs;make &>/dev/null")
287 288
289 -def desactivate_acceptance_run():
290 """ check that the event are not written """ 291 292 if os.path.isfile('./Source/MadWeight_file/acc.in'): 293 import expand_MadWeight 294 expand_MadWeight.expand_all(echap=['MadWeight_card.dat']) 295 os.system('rm ./Source/MadWeight_file/acc.in')
296 297
298 -def restore_pythia_pgs():
299 pass
300 # os.system('cp ../pythia-pgs/src/pythia_default.f ../pythia-pgs/src/pythia.f') 301 # os.system('cp ../pythia-pgs/src/pgs_default.f ../pythia-pgs/src/pgs.f') 302 # os.system("cd ../pythia-pgs;make &>/dev/null") 303 304 305 ########################################################################### 306 ######### CREATION DES DOSSIER/FICHIERS DE SORTIE ########### 307 ########################################################################### 308 309 #1 ##################################################################################
310 -class create_dir:
311 """create all the directory for the run """ 312 313 #2 ##############################################################################
314 - def __init__(self,MWparam):
315 316 self.MWparam=MWparam 317 self.dir_name=MWparam.name 318 319 self.ref_card=self.MWparam.actif_param[0] #card where the file verif.lhco are written and not linked 320 self.created=0
321 322 #2 ##############################################################################
323 - def all(self):
324 325 print('creating all directories') 326 327 # Pierre 328 # if self.MWparam.norm_with_cross: 329 # for dir in self.MWparam.P_listdir: 330 # self.all_dir(dir) 331 # else: 332 # pass 333 334 if self.MWparam.nb_event: 335 for dir in self.MWparam.MW_listdir: 336 self.all_dir(dir)
337 338 #2 ##############################################################################
339 - def all_dir(self,dir):
340 """creates the directory for standard run """ 341 342 self.dir_type='M' # dir[0] Pierre: only one dir type (MadWeight type) 343 self.Sdir_pos='./SubProcesses/'+dir 344 try: 345 os.mkdir('./SubProcesses/'+dir) 346 except: 347 pass 348 349 350 if self.dir_type=='M': 351 if self.MWparam['mw_run']['22']: 352 self.add_events() 353 else: 354 print('create M dir') 355 self.create_M_dir() 356 else: 357 if self.MWparam['mw_run']['22']: 358 return 359 self.create_P_dir() 360 361 print('created',self.created,'directories') 362 self.created=0
363 364 #2 ##############################################################################
365 - def update_card_status(self,cardref=-1,number_of_event=-1):
366 """creates the directory for standard run 367 number_of_event[-1]:-1:automatic (number of event of cardref if !=-1, highest existing event in other case 368 """ 369 370 #check if all card have a directory in P_ 371 list_card=[num for num in self.MWparam.actif_param] 372 #progress bar 373 pbar = progressbar.progbar('update Pdir',len(list_card)*len(self.MWparam.P_listdir)) 374 for directory in self.MWparam.P_listdir: 375 self.dir_type=directory[0] 376 self.Sdir_pos='./SubProcesses/'+directory 377 for card in list_card: 378 self.create_one_P_dir(card,remove_old=0) 379 pbar.update() 380 pbar.finish() 381 382 #find cardref and number_of_event if not defined 383 if number_of_event==-1 and cardref==-1: #search the card with the maximum of event defined 384 self.dir_type='M' 385 self.Sdir_pos='./SubProcesses/'+self.MWparam.MW_listdir[0] 386 for card in self.MWparam.actif_param: 387 event=self.find_exist_event(card) 388 if event>=number_of_event: 389 cardref=card 390 number_of_event=event 391 elif cardref==-1: 392 ref_num=number_of_event-1 #-1 due to the starting at zero 393 for card in self.MWparam.actif_param: 394 if self.find_exist_event(card)>=ref_num: 395 cardref=card 396 397 if cardref==-1 or number_of_event==-1: 398 sys.exit('impossible to update card and/or number of event not defined') 399 else: 400 self.ref_card=cardref 401 402 #update events 403 #progress bar 404 list_card=self.MWparam.actif_param 405 list_event=list(range(0,number_of_event)) 406 if (len(list_card))*(len(list_event))*len(self.MWparam.MW_listdir)>0: 407 pbar = progressbar.progbar('update MWdir',(len(list_card))*(len(list_event))*len(self.MWparam.P_listdir)) 408 for dir in self.MWparam.MW_listdir: 409 self.dir_type=dir[0] 410 self.Sdir_pos='./SubProcesses/'+dir 411 412 #then pass in update mode for all the card 413 for card in list_card: 414 for event in list_event: 415 self.create_one_M_dir(card,event,remove_old=0) 416 pbar.update() 417 pbar.finish()
418 419 420 #2 ##############################################################################
421 - def add_events(self):
422 423 self.file_event=open(self.Sdir_pos+'/'+self.MWparam.name+'/verif.lhco') 424 self.line_event=self.file_event.readline() 425 426 nb_exist_event=self.find_exist_event() 427 list_card=self.MWparam.actif_param 428 list_event=list(range(nb_exist_event,nb_exist_event+self.MWparam.nb_event)) 429 pbar = progressbar.progbar('create_dir',(len(list_card))*(len(list_event))) 430 for card in list_card: 431 for event in list_event: 432 self.create_one_M_dir(card,event) 433 pbar.update() 434 pbar.finish()
435 436 437 438 #2 ###############################################################################
439 - def find_exist_event(self,card_nb=-1):
440 """ find the maximal event number in this SubProcess""" 441 442 if card_nb==-1: 443 card_nb=self.ref_card 444 directory=self.Sdir_pos+'/'+self.MWparam.name 445 446 return self.MWparam.find_existing_events(directory,card_nb)
447 448 #2 ##############################################################################
449 - def create_M_dir(self):
450 451 self.file_event=open(self.Sdir_pos+'/'+self.MWparam.name+'/verif.lhco') 452 self.line_event=self.file_event.readline() 453 dirname = self.Sdir_pos.split('/')[-1] 454 self.del_old_dir() 455 list_card=self.MWparam.actif_param 456 457 #progress bar 458 pbar = progressbar.progbar('create_dir',(len(list_card))*(self.MWparam.nb_event_MW[dirname])) 459 for card in list_card: 460 list_event=list(range(0, self.MWparam.nb_event_MW[dirname])) 461 try: 462 os.mkdir(self.Sdir_pos+'/'+self.MWparam.name+'/card_'+str(card)) 463 except: 464 pass 465 for event in list_event: 466 try: 467 self.create_one_M_dir(card,event) 468 except NoMoreEvent: 469 os.system('rm -rf %s' % self.Sdir_pos+'/'+self.MWparam.name+'/card_'+str(card)) 470 self.MWparam.nb_event_MW[dirname] = event 471 break 472 473 pbar.update() 474 pbar.finish()
475 476 #2 ##############################################################################
477 - def create_P_dir(self):
478 479 self.del_old_dir() 480 list_card=[num for num in self.MWparam.actif_param] 481 #progress bar 482 pbar = progressbar.progbar('create_dir',len(list_card)) 483 for card in list_card: 484 self.create_one_P_dir(card) 485 pbar.update() 486 pbar.finish()
487 488 #2 ##############################################################################
489 - def create_one_M_dir(self,card,event,remove_old=1):
490 """ create the directory for the event \"event\" and the card nb \"card\" 491 """ 492 dir_name=self.MWparam.name 493 pos=self.Sdir_pos+'/'+dir_name+'/card_'+str(card)+'/event_'+str(event)+'/' 494 #check that upper level exist 495 if not os.path.isdir(self.Sdir_pos+'/'+dir_name+'/card_'+str(card)): 496 os.mkdir(self.Sdir_pos+'/'+dir_name+'/card_'+str(card)) 497 498 # if not os.path.isdir(pos): 499 # os.mkdir(pos) 500 501 try: 502 os.mkdir(pos) 503 except OSError: 504 if remove_old: 505 os.system('rm '+pos+'/* >/dev/null') 506 # else: 507 # return 508 509 510 ff=open(pos+'/param.dat','w') 511 ff.writelines('param_card_'+str(card)+'.dat\n') 512 ff.writelines(str(self.MWparam['mw_run']['MW_int_points'])+'\n') 513 ff.close() 514 515 if card==self.ref_card: 516 data=self.give_new_exp_point() 517 hh=open(pos+'/verif.lhco','w') 518 hh.writelines(data) 519 hh.close() 520 else: 521 try: 522 os.symlink('../../card_'+str(self.ref_card)+'/event_'+str(event)+'/verif.lhco',pos+'/verif.lhco') 523 except OSError: 524 pass 525 self.created+=1
526 527 528 #2 ##############################################################################
529 - def create_one_P_dir(self,card,remove_old=1):
530 """ create the directory for the event \"event\" and the card nb \"card\" 531 """ 532 dir_name=self.MWparam.name 533 pos=self.Sdir_pos+'/'+dir_name+'/card_'+str(card) 534 try: 535 os.mkdir(pos) 536 except: 537 if remove_old: 538 os.system('rm '+pos+'/* >/dev/null') 539 else: 540 return 541 ff=open(pos+'/param.dat','w') 542 ff.writelines('param_card_'+str(card)+'.dat\n') 543 ff.writelines(str(self.MWparam['mw_run']['MW_int_points'])+'\n') 544 ff.close() 545 os.system('ln -s ../../madevent.py '+pos+'/madevent.py') 546 os.system('ln -s ../../madevent '+pos+'/madevent') 547 os.system('ln -s ../../input_app.txt '+pos+'/input_app.txt') 548 os.system('ln -s ../../symfact.dat '+pos+'/symfact.dat') 549 #add link to a job: 550 for file in os.listdir(pos+'/../../'): 551 if len(file)>4 and file[:4]=='ajob': 552 os.system('ln -s ../../'+file+' '+pos) 553 554 self.created+=1
555 556 Pattern=re.compile(r'''^\s*0\s+\d+\s+\d+\s*$''',re.I) 557 #2 ##############################################################################
558 - def give_new_exp_point(self):
559 560 data=self.line_event 561 while 1: 562 try: 563 line=self.file_event.readline() 564 except ValueError: 565 raise NoMoreEvent 566 567 if line=='': 568 self.file_event.close() 569 if data == '': 570 raise NoMoreEvent 571 return data 572 if self.Pattern.search(line): 573 self.line_event=line 574 return data 575 else: 576 data+=line
577 578 #2 ##############################################################################
579 - def del_old_dir(self):
580 ''' delete old event directory ''' 581 582 output=1 583 #verification du format des dossiers 584 list_dir=os.listdir(os.pardir) 585 if self.MWparam.info['mw_run']['22']: 586 print(self.Sdir_pos.split('/')[-1],': no deleting') 587 return output 588 589 print(self.Sdir_pos.split('/')[-1],': deleting old run directory') 590 print(os.getcwd()) 591 os.system('mkdir '+self.Sdir_pos+'/'+self.MWparam.name+'/') 592 for datafile in os.listdir(self.Sdir_pos+'/'+self.MWparam.name): 593 if datafile not in ['verif.lhco']: 594 try: os.system('rm '+self.Sdir_pos+'/'+self.MWparam.name+'/'+datafile+' -rf') 595 except: 596 print("WARNING: this directory ", os.getcwd()+'/'+self.Sdir_pos+'/'+self.MWparam.name," are not deleted") 597 output=0 598 599 600 601 return output
602 603 ###### copy file
604 -def copy_file(list,i):
605 pos=os.getcwd() 606 init_dir=os.sep+pos.split(os.sep)[-1] 607 608 title=[] 609 content=[] 610 611 for file in list: 612 title.append(file.split('/')[-1]) 613 ff=open(file,'r') 614 content.append(ff.readlines()) 615 ff.close() 616 617 # for i in range(0,nmax): 618 os.chdir('../'+dir_name+str(i)) 619 for i in range(0,len(title)): 620 ff=open('./'+title[i],'w') 621 ff.writelines(content[i]) 622 ff.close() 623 os.chdir(os.pardir+init_dir)
624
625 -def restore_last_info_for_control(MW_param):
626 """ restore run info for controlling """ 627 628 pattern=re.compile(r'''condor_id/\s*(?P<run_list>.+)\s*/job/\s*(?P<job>\d*)''',re.DOTALL) 629 launch_job=0 630 run_job=[] 631 dir_list=[] 632 633 for dir in MW_param.P_listdir+MW_param.MW_listdir: 634 ff=open('./SubProcesses/'+dir+'/schedular/condor.log','r') 635 text=ff.readline() 636 ff.close() 637 pat=pattern.search(text) 638 if pat: 639 launch_job+=int(pat.group('job')) 640 prov_job=eval(pat.group('run_list')) 641 dir_list+=[dir]*len(prov_job) 642 run_job+=prov_job 643 return launch_job,run_job,dir_list
644 645 646 #def return_failed(dir,MW_param): 647 # """read the failed process and return them in a list """ 648 # 649 # try: 650 # ff=open('./SubProcesses/'+dir+'/'+MW_param.name+'/failed_job.dat','r') 651 # except: 652 # return [] 653 # out=[] 654 # while 1: 655 # line=ff.readline() 656 # if line=='': 657 # break 658 # out.append(line.replace('\n','')) 659 # 660 # return out 661 662 663 ########################################################################### 664 ################### MAIN PROGRAM ################## 665 ########################################################################### 666 #def create_all_MWdir(dir,MW_param): 667 # """n: number of data , name : name_run""" 668 # 669 # run_name=MW_param.name 670 # try: 671 # os.chdir('./SubProcesses/'+dir+'/schedular') 672 # except: 673 # os.mkdir('./SubProcesses/'+dir+'/schedular') 674 # os.chdir('./SubProcesses/'+dir+'/schedular') 675 # 676 # os.system('mkdir ../'+run_name+'&>/dev/null') 677 # dir_sche=create_dir(MW_param) 678 # dir_sche.all() 679 # os.chdir("../../../") 680 # print 'created',dir_sche.created,'directories' 681 # return dir_sche.created 682 683 ########################################################################### 684 ################### MAIN PROGRAM 2 ################## 685 ########################################################################### 686 687 #def create_all_Pdir(dir,MW_param): 688 # """n: number of data , name : name_run"""## 689 # 690 # #re-init global parameter 691 # run_name=MW_param.name 692 ## os.system(' mkdir ./SubProcesses/'+dir+'/schedular') 693 # os.chdir('./SubProcesses/'+dir+'/schedular') 694 # os.system(' mkdir ../'+run_name+'&>/dev/null') 695 # dir_sche=create_dir(MW_param) 696 # dir_sche.all() 697 # os.chdir("../../../") 698 # print 'created',dir_sche.created,'directories' 699 # return dir_sche.created 700 701
702 -def create_all_schedular(MWparam):
703 704 for directory in MWparam.MW_listdir+MWparam.P_listdir: 705 try: 706 os.mkdir('./SubProcesses/'+directory+'/schedular') 707 except: 708 pass
709 710 711 712 713 714 715 ############################################################################################## 716 ## Single Launch ## 717 ############################################################################################## 718 if __name__=='__main__': 719 720 721 #reupdate all the active card to a certain number of event 722 #import global run opt 723 import MW_param 724 MW_param.go_to_main_dir() 725 MWparam=MW_param.MW_info('MadWeight_card.dat') 726 727 #launch the check 728 create_obj=create_dir(MWparam) 729 create_obj.update_card_status() 730 # for dir in MWparam.MW_listdir: 731 # create_obj.Sdir_pos='./SubProcesses/'+dir 732 # print create_obj.find_exist_event(1) 733