1 from __future__ import division
2
3 import itertools
4 import xml.etree.ElementTree as ET
5 import math
6 import StringIO
7 import os
8 import re
9 import shutil
10 import logging
11 import random
12
13 logger = logging.getLogger('madgraph.models')
14
15 try:
16 import madgraph.iolibs.file_writers as file_writers
17 import madgraph.various.misc as misc
18 except:
19 import internal.file_writers as file_writers
20 import internal.misc as misc
21
22 import StringIO
25 """ a class for invalid param_card """
26 pass
27
29 """A class for a param_card parameter"""
30
31 - def __init__(self, param=None, block=None, lhacode=None, value=None, comment=None):
32 """Init the parameter"""
33
34 self.format = 'float'
35 if param:
36 block = param.lhablock
37 lhacode = param.lhacode
38 value = param.value
39 comment = param.comment
40 format = param.format
41
42 self.lhablock = block
43 if lhacode:
44 self.lhacode = lhacode
45 else:
46 self.lhacode = []
47 self.value = value
48 self.comment = comment
49
51 """ set the block name """
52
53 self.lhablock = block
54
56 """ initialize the information from a str"""
57
58 if '#' in text:
59 data, self.comment = text.split('#',1)
60 else:
61 data, self.comment = text, ""
62
63
64 data = data.split()
65 if any(d.startswith('scan') for d in data):
66 position = [i for i,d in enumerate(data) if d.startswith('scan')][0]
67 data = data[:position] + [' '.join(data[position:])]
68 if not len(data):
69 return
70 try:
71 self.lhacode = tuple([int(d) for d in data[:-1]])
72 except Exception:
73 self.lhacode = tuple([int(d) for d in data[:-1] if d.isdigit()])
74 self.value= ' '.join(data[len(self.lhacode):])
75 else:
76 self.value = data[-1]
77
78
79 try:
80 self.value = float(self.value)
81 except:
82 self.format = 'str'
83 pass
84 else:
85 if self.lhablock == 'modsel':
86 self.format = 'int'
87 self.value = int(self.value)
88
90 """ initialize the decay information from a str"""
91
92 if '#' in text:
93 data, self.comment = text.split('#',1)
94 else:
95 data, self.comment = text, ""
96
97
98 data = data.split()
99 if not len(data):
100 return
101 self.lhacode = [int(d) for d in data[2:]]
102 self.lhacode.sort()
103 self.lhacode = tuple([len(self.lhacode)] + self.lhacode)
104
105 self.value = float(data[0])
106 self.format = 'decay_table'
107
109 """ return a SLAH string """
110
111 format = self.format
112 if self.format == 'float':
113 try:
114 value = float(self.value)
115 except:
116 format = 'str'
117
118 self.comment = self.comment.strip()
119 if format == 'float':
120 if self.lhablock == 'decay' and not isinstance(self.value,basestring):
121 return 'DECAY %s %e # %s' % (' '.join([str(d) for d in self.lhacode]), self.value, self.comment)
122 elif self.lhablock == 'decay':
123 return 'DECAY %s Auto # %s' % (' '.join([str(d) for d in self.lhacode]), self.comment)
124 elif self.lhablock and self.lhablock.startswith('qnumbers'):
125 return ' %s %i # %s' % (' '.join([str(d) for d in self.lhacode]), int(self.value), self.comment)
126 else:
127 return ' %s %e # %s' % (' '.join([str(d) for d in self.lhacode]), self.value, self.comment)
128 elif format == 'int':
129 return ' %s %i # %s' % (' '.join([str(d) for d in self.lhacode]), int(self.value), self.comment)
130 elif format == 'str':
131 if self.lhablock == 'decay':
132 return 'DECAY %s %s # %s' % (' '.join([str(d) for d in self.lhacode]),self.value, self.comment)
133 return ' %s %s # %s' % (' '.join([str(d) for d in self.lhacode]), self.value, self.comment)
134 elif self.format == 'decay_table':
135 return ' %e %s # %s' % ( self.value,' '.join([str(d) for d in self.lhacode]), self.comment)
136 elif self.format == 'int':
137 return ' %s %i # %s' % (' '.join([str(d) for d in self.lhacode]), int(self.value), self.comment)
138 else:
139 if self.lhablock == 'decay':
140 return 'DECAY %s %d # %s' % (' '.join([str(d) for d in self.lhacode]), self.value, self.comment)
141 else:
142 return ' %s %d # %s' % (' '.join([str(d) for d in self.lhacode]), self.value, self.comment)
143
146 """ list of parameter """
147
149 if name:
150 self.name = name.lower()
151 else:
152 self.name = name
153 self.scale = None
154 self.comment = ''
155 self.decay_table = {}
156 self.param_dict={}
157 list.__init__(self)
158
159 - def get(self, lhacode, default=None):
160 """return the parameter associate to the lhacode"""
161 if not self.param_dict:
162 self.create_param_dict()
163
164 if isinstance(lhacode, int):
165 lhacode = (lhacode,)
166
167 try:
168 return self.param_dict[tuple(lhacode)]
169 except KeyError:
170 if default is None:
171 raise KeyError, 'id %s is not in %s' % (tuple(lhacode), self.name)
172 else:
173 return Parameter(block=self, lhacode=lhacode, value=default,
174 comment='not define')
175
177 """ remove a parameter """
178 list.remove(self, self.get(lhacode))
179
180 return self.param_dict.pop(tuple(lhacode))
181
182 - def __eq__(self, other, prec=1e-4):
183 """ """
184 if len(self) != len(other):
185 return False
186
187 return not any(abs(param.value-other.param_dict[key].value)> prec * abs(param.value)
188 for key, param in self.param_dict.items())
189
190 - def __ne__(self, other, prec=1e-4):
191 return not self.__eq__(other, prec)
192
194
195 assert isinstance(obj, Parameter)
196 if not hasattr(self, 'name'):
197 self.__init__(obj.lhablock)
198 assert not obj.lhablock or obj.lhablock == self.name
199
200
201
202 if not hasattr(self, 'param_dict'):
203 self.param_dict = {}
204
205 if tuple(obj.lhacode) in self.param_dict:
206 if self.param_dict[tuple(obj.lhacode)].value != obj.value:
207 raise InvalidParamCard, '%s %s is already define to %s impossible to assign %s' % \
208 (self.name, obj.lhacode, self.param_dict[tuple(obj.lhacode)].value, obj.value)
209 return
210 list.append(self, obj)
211
212 self.param_dict[tuple(obj.lhacode)] = obj
213
215 """create a link between the lhacode and the Parameter"""
216 for param in self:
217 self.param_dict[tuple(param.lhacode)] = param
218
219 return self.param_dict
220
222 """ """
223 self.scale = scale
224
226 "set inforamtion from the line"
227
228 if '#' in text:
229 data, self.comment = text.split('#',1)
230 else:
231 data, self.commant = text, ""
232
233 data = data.lower()
234 data = data.split()
235 self.name = data[1]
236 if len(data) == 3:
237 if data[2].startswith('q='):
238
239 self.scale = float(data[2][2:])
240 elif self.name == 'qnumbers':
241 self.name += ' %s' % data[2]
242 elif len(data) == 4 and data[2] == 'q=':
243
244 self.scale = float(data[3])
245
246 return self
247
249 """returns the list of id define in this blocks"""
250
251 return [p.lhacode for p in self]
252
254 """ return a str in the SLAH format """
255
256 text = """###################################""" + \
257 """\n## INFORMATION FOR %s""" % self.name.upper() +\
258 """\n###################################\n"""
259
260
261 if self.name == 'decay':
262 for param in self:
263 pid = param.lhacode[0]
264 param.set_block('decay')
265 text += str(param)+ '\n'
266 if self.decay_table.has_key(pid):
267 text += str(self.decay_table[pid])+'\n'
268 return text
269 elif self.name.startswith('decay'):
270 text = ''
271
272 elif not self.scale:
273 text += 'BLOCK %s # %s\n' % (self.name.upper(), self.comment)
274 else:
275 text += 'BLOCK %s Q= %e # %s\n' % (self.name.upper(), self.scale, self.comment)
276
277 text += '\n'.join([str(param) for param in self])
278 return text + '\n'
279
282 """ a param Card: list of Block """
283 mp_prefix = 'MP__'
284
285 header = \
286 """######################################################################\n""" + \
287 """## PARAM_CARD AUTOMATICALY GENERATED BY MG5 ####\n""" + \
288 """######################################################################\n"""
289
290
292 self.order = []
293
294 if isinstance(input_path, ParamCard):
295 self.read(input_path.write())
296 self.input_path = input_path.input_path
297 else:
298 self.input_path = input_path
299 if input_path:
300 self.read(input_path)
301
302 - def read(self, input_path):
303 """ read a card and full this object with the content of the card """
304
305 if isinstance(input_path, str):
306 if '\n' in input_path:
307 input = StringIO.StringIO(input_path)
308 else:
309 input = open(input_path)
310 else:
311 input = input_path
312
313
314 cur_block = None
315 for line in input:
316 line = line.strip()
317 if not line or line[0] == '#':
318 continue
319 line = line.lower()
320 if line.startswith('block'):
321 cur_block = Block()
322 cur_block.load_str(line)
323 self.append(cur_block)
324 continue
325
326 if line.startswith('decay'):
327 if not self.has_block('decay'):
328 cur_block = Block('decay')
329 self.append(cur_block)
330 else:
331 cur_block = self['decay']
332 param = Parameter()
333 param.set_block(cur_block.name)
334 param.load_str(line[6:])
335 cur_block.append(param)
336 continue
337
338 if cur_block is None:
339 continue
340
341 if cur_block.name == 'decay':
342
343 id = cur_block[-1].lhacode[0]
344 cur_block = Block('decay_table_%s' % id)
345 self['decay'].decay_table[id] = cur_block
346
347
348
349
350 if cur_block.name.startswith('decay_table'):
351 param = Parameter()
352 param.load_decay(line)
353 try:
354 cur_block.append(param)
355 except InvalidParamCard:
356 pass
357 else:
358 param = Parameter()
359 param.set_block(cur_block.name)
360 param.load_str(line)
361 cur_block.append(param)
362
363 return self
364
366 """ Analyzes the comment of the parameter in the param_card and returns
367 a dictionary with parameter names in values and the tuple (lhablock, id)
368 in value as well as a dictionary for restricted values.
369 WARNING: THIS FUNCTION RELIES ON THE FORMATTING OF THE COMMENT IN THE
370 CARD TO FETCH THE PARAMETER NAME. This is mostly ok on the *_default.dat
371 but typically dangerous on the user-defined card."""
372
373 pname2block = {}
374 restricted_value = {}
375
376 for bname, block in self.items():
377 for lha_id, param in block.param_dict.items():
378 all_var = []
379 comment = param.comment
380
381 if comment.strip().startswith('set of param :'):
382 all_var = list(re.findall(r'''[^-]1\*(\w*)\b''', comment))
383
384 elif len(comment.split()) == 1:
385 all_var = [comment.strip().lower()]
386
387 else:
388 split = comment.split()
389 if len(split) >2 and split[1] == ':':
390
391 restricted_value[(bname, lha_id)] = ' '.join(split[1:])
392 elif len(split) == 2:
393 if re.search(r'''\[[A-Z]\]eV\^''', split[1]):
394 all_var = [comment.strip().lower()]
395 elif len(split) >=2 and split[1].startswith('('):
396 all_var = [split[0].strip().lower()]
397 else:
398 if not bname.startswith('qnumbers'):
399 logger.debug("not recognize information for %s %s : %s",
400 bname, lha_id, comment)
401
402 continue
403
404 for var in all_var:
405 var = var.lower()
406 if var in pname2block:
407 pname2block[var].append((bname, lha_id))
408 else:
409 pname2block[var] = [(bname, lha_id)]
410
411 return pname2block, restricted_value
412
413 - def write(self, outpath=None):
414 """schedular for writing a card"""
415
416
417 blocks = self.order_block()
418 text = self.header
419 text += ''.join([str(block) for block in blocks])
420
421 if not outpath:
422 return text
423 elif isinstance(outpath, str):
424 file(outpath,'w').write(text)
425 else:
426 outpath.write(text)
427
429 """return a text file allowing to pass from this card to the new one
430 via the set command"""
431
432 diff = ''
433 for blockname, block in self.items():
434 for param in block:
435 lhacode = param.lhacode
436 value = param.value
437 new_value = new_card[blockname].get(lhacode).value
438 if not misc.equal(value, new_value, 6, zero_limit=False):
439 lhacode = ' '.join([str(i) for i in lhacode])
440 diff += 'set param_card %s %s %s # orig: %s\n' % \
441 (blockname, lhacode , new_value, value)
442 return diff
443
444
445 - def write_inc_file(self, outpath, identpath, default, need_mp=False):
446 """ write a fortran file which hardcode the param value"""
447
448 fout = file_writers.FortranWriter(outpath)
449 defaultcard = ParamCard(default)
450 for line in open(identpath):
451 if line.startswith('c ') or line.startswith('ccccc'):
452 continue
453 split = line.split()
454 if len(split) < 3:
455 continue
456 block = split[0]
457 lhaid = [int(i) for i in split[1:-1]]
458 variable = split[-1]
459 if block in self:
460 try:
461 value = self[block].get(tuple(lhaid)).value
462 except KeyError:
463 value =defaultcard[block].get(tuple(lhaid)).value
464 logger.warning('information about \"%s %s" is missing using default value: %s.' %\
465 (block, lhaid, value))
466 else:
467 value =defaultcard[block].get(tuple(lhaid)).value
468 logger.warning('information about \"%s %s" is missing (full block missing) using default value: %s.' %\
469 (block, lhaid, value))
470 value = str(value).lower()
471 fout.writelines(' %s = %s' % (variable, ('%e'%float(value)).replace('e','d')))
472 if need_mp:
473 fout.writelines(' mp__%s = %s_16' % (variable, value))
474
476 """ Convert this param_card to the convention used for the complex mass scheme:
477 This includes, removing the Yukawa block if present and making sure the EW input
478 scheme is (MZ, MW, aewm1). """
479
480
481 if self.has_block('yukawa'):
482
483 for lhacode in [param.lhacode for param in self['yukawa']]:
484 self.remove_param('yukawa', lhacode)
485
486
487 EW_input = {('sminputs',(1,)):None,
488 ('sminputs',(2,)):None,
489 ('mass',(23,)):None,
490 ('mass',(24,)):None}
491 for block, lhaid in EW_input.keys():
492 try:
493 EW_input[(block,lhaid)] = self[block].get(lhaid).value
494 except:
495 pass
496
497
498
499
500 internal_param = [key for key,value in EW_input.items() if value is None]
501 if len(internal_param)==0:
502
503 return
504
505 if len(internal_param)!=1:
506 raise InvalidParamCard,' The specified EW inputs has more than one'+\
507 ' unknown: [%s]'%(','.join([str(elem) for elem in internal_param]))
508
509
510 if not internal_param[0] in [('mass',(24,)), ('sminputs',(2,)),
511 ('sminputs',(1,))]:
512 raise InvalidParamCard, ' The only EW input scheme currently supported'+\
513 ' are those with either the W mass or GF left internal.'
514
515
516 if internal_param[0] == ('mass',(24,)):
517 aewm1 = EW_input[('sminputs',(1,))]
518 Gf = EW_input[('sminputs',(2,))]
519 Mz = EW_input[('mass',(23,))]
520 try:
521 Mw = math.sqrt((Mz**2/2.0)+math.sqrt((Mz**4/4.0)-((
522 (1.0/aewm1)*math.pi*Mz**2)/(Gf*math.sqrt(2.0)))))
523 except:
524 InvalidParamCard, 'The EW inputs 1/a_ew=%f, Gf=%f, Mz=%f are inconsistent'%\
525 (aewm1,Gf,Mz)
526 self.remove_param('sminputs', (2,))
527 self.add_param('mass', (24,), Mw, 'MW')
528
530 """add an object to this"""
531
532 assert isinstance(obj, Block)
533 self[obj.name] = obj
534 if not obj.name.startswith('decay_table'):
535 self.order.append(obj)
536
537
538
540 return self.has_key(name)
541
543 """ reorganize the block """
544 return self.order
545
547 """ rename the blocks """
548
549 for old_name, new_name in name_dict.items():
550 self[new_name] = self.pop(old_name)
551 self[new_name].name = new_name
552 for param in self[new_name]:
553 param.lhablock = new_name
554
556 """ remove a blocks """
557 assert len(self[name])==0
558 [self.order.pop(i) for i,b in enumerate(self.order) if b.name == name]
559 self.pop(name)
560
562 """ remove a parameter """
563 if self.has_param(block, lhacode):
564 self[block].remove(lhacode)
565 if len(self[block]) == 0:
566 self.remove_block(block)
567
569 """check if param exists"""
570
571 try:
572 self[block].get(lhacode)
573 except:
574 return False
575 else:
576 return True
577
578 - def copy_param(self,old_block, old_lha, block=None, lhacode=None):
579 """ make a parameter, a symbolic link on another one """
580
581
582 old_block_obj = self[old_block]
583 parameter = old_block_obj.get(old_lha)
584 if not block:
585 block = old_block
586 if not lhacode:
587 lhacode = old_lha
588
589 self.add_param(block, lhacode, parameter.value, parameter.comment)
590
591 - def add_param(self,block, lha, value, comment=''):
592
593 parameter = Parameter(block=block, lhacode=lha, value=value,
594 comment=comment)
595 try:
596 new_block = self[block]
597 except KeyError:
598
599 new_block = Block(block)
600 self.append(new_block)
601 new_block.append(parameter)
602
603
604 - def mod_param(self, old_block, old_lha, block=None, lhacode=None,
605 value=None, comment=None):
606 """ change a parameter to a new one. This is not a duplication."""
607
608
609 old_block = self[old_block]
610 try:
611 parameter = old_block.get(old_lha)
612 except:
613 if lhacode is not None:
614 lhacode=old_lha
615 self.add_param(block, lhacode, value, comment)
616 return
617
618
619
620 if block:
621 parameter.lhablock = block
622 if lhacode:
623 parameter.lhacode = lhacode
624 if value:
625 parameter.value = value
626 if comment:
627 parameter.comment = comment
628
629
630 if block:
631 old_block.remove(old_lha)
632 if not len(old_block):
633 self.remove_block(old_block.name)
634 try:
635 new_block = self[block]
636 except KeyError:
637
638 new_block = Block(block)
639 self.append(new_block)
640 new_block.append(parameter)
641 elif lhacode:
642 old_block.param_dict[tuple(lhacode)] = \
643 old_block.param_dict.pop(tuple(old_lha))
644
645
647 """ check that the value is coherent and remove it"""
648
649 if self.has_param(block, lhacode):
650 param = self[block].get(lhacode)
651 if param.value != value:
652 error_msg = 'This card is not suitable to be convert to SLAH1\n'
653 error_msg += 'Parameter %s %s should be %s' % (block, lhacode, value)
654 raise InvalidParamCard, error_msg
655 self.remove_param(block, lhacode)
656
659 """ a param Card: list of Block with also MP definition of variables"""
660
662 """ write a fortran file which hardcode the param value"""
663
664 fout = file_writers.FortranWriter(outpath)
665 defaultcard = ParamCard(default)
666 for line in open(identpath):
667 if line.startswith('c ') or line.startswith('ccccc'):
668 continue
669 split = line.split()
670 if len(split) < 3:
671 continue
672 block = split[0]
673 lhaid = [int(i) for i in split[1:-1]]
674 variable = split[-1]
675 if block in self:
676 try:
677 value = self[block].get(tuple(lhaid)).value
678 except KeyError:
679 value =defaultcard[block].get(tuple(lhaid)).value
680 else:
681 value =defaultcard[block].get(tuple(lhaid)).value
682
683 fout.writelines(' %s = %s' % (variable, ('%e' % value).replace('e','d')))
684 fout.writelines(' %s%s = %s_16' % (self.mp_prefix,
685 variable, ('%e' % value)))
686
690 """A class keeping track of the scan: flag in the param_card and
691 having an __iter__() function to scan over all the points of the scan.
692 """
693
694 logging = True
700
702 """generate the next param_card (in a abstract way) related to the scan.
703 Technically this generates only the generator."""
704
705 if hasattr(self, 'iterator'):
706 return self.iterator
707 self.iterator = self.iterate()
708 return self.iterator
709
710 - def next(self, autostart=False):
711 """call the next iteration value"""
712 try:
713 iterator = self.iterator
714 except:
715 if autostart:
716 iterator = self.__iter__()
717 else:
718 raise
719 try:
720 out = iterator.next()
721 except StopIteration:
722 del self.iterator
723 raise
724 return out
725
727 """create the actual generator"""
728 all_iterators = {}
729 auto = 'Auto'
730 pattern = re.compile(r'''scan\s*(?P<id>\d*)\s*:\s*(?P<value>[^#]*)''', re.I)
731
732
733 for block in self.order:
734 for param in block:
735 if isinstance(param.value, str) and param.value.strip().lower().startswith('scan'):
736 try:
737 key, def_list = pattern.findall(param.value)[0]
738 except:
739 raise Exception, "Fail to handle scanning tag: Please check that the syntax is valid"
740 if key == '':
741 key = -1 * len(all_iterators)
742 if key not in all_iterators:
743 all_iterators[key] = []
744 try:
745 all_iterators[key].append( (param, eval(def_list)))
746 except SyntaxError, error:
747 raise Exception, "Fail to handle your scan definition. Please check your syntax:\n entry: %s \n Error reported: %s" %(def_list, error)
748
749 keys = all_iterators.keys()
750 param_card = ParamCard(self)
751
752 for key in keys:
753 for param, values in all_iterators[key]:
754 self.param_order.append("%s#%s" % (param.lhablock, '_'.join(`i` for i in param.lhacode)))
755
756
757 lengths = [range(len(all_iterators[key][0][1])) for key in keys]
758 for positions in itertools.product(*lengths):
759 self.itertag = []
760 if self.logging:
761 logger.info("Create the next param_card in the scan definition", '$MG:color:BLACK')
762 for i, pos in enumerate(positions):
763 key = keys[i]
764 for param, values in all_iterators[key]:
765
766 param_card[param.lhablock].get(param.lhacode).value = values[pos]
767 self.itertag.append(values[pos])
768 if self.logging:
769 logger.info("change parameter %s with code %s to %s", \
770 param.lhablock, param.lhacode, values[pos])
771
772 yield param_card
773
774
775 - def store_entry(self, run_name, cross):
776 """store the value of the cross-section"""
777 self.cross.append({'bench' : self.itertag, 'run_name': run_name, 'cross':cross})
778
779
781 """ """
782
783 ff = open(path, 'w')
784 ff.write("#%-19s %-20s %-20s\n" % ('run_name',' '.join(self.param_order), 'cross(pb)'))
785 for info in self.cross:
786 bench = [str(p) for p in info['bench']]
787 cross = info['cross']
788 name = info['run_name']
789 ff.write("%-20s %-20s %-20s \n" % (name,' '.join(bench) ,cross))
790
791
793 """returns a smart name for the next run"""
794
795 if '_' in run_name:
796 name, value = run_name.rsplit('_',1)
797 if value.isdigit():
798 return '%s_%02i' % (name, float(value)+1)
799
800 return '%s_scan_02' % run_name
801
804 """ A class for storing the linked between the different parameter of
805 the param_card.
806 Able to write a file 'param_card_rule.dat'
807 Able to read a file 'param_card_rule.dat'
808 Able to check the validity of a param_card.dat
809 """
810
811
813 """initialize an object """
814
815
816 self.zero = []
817 self.one = []
818 self.identical = []
819 self.opposite = []
820
821
822 self.rule = []
823
824 if inputpath:
825 self.load_rule(inputpath)
826
827 - def add_zero(self, lhablock, lhacode, comment=''):
828 """add a zero rule"""
829 self.zero.append( (lhablock, lhacode, comment) )
830
831 - def add_one(self, lhablock, lhacode, comment=''):
832 """add a one rule"""
833 self.one.append( (lhablock, lhacode, comment) )
834
835 - def add_identical(self, lhablock, lhacode, lhacode2, comment=''):
836 """add a rule for identical value"""
837 self.identical.append( (lhablock, lhacode, lhacode2, comment) )
838
839 - def add_opposite(self, lhablock, lhacode, lhacode2, comment=''):
840 """add a rule for identical value"""
841 self.opposite.append( (lhablock, lhacode, lhacode2, comment) )
842
843
844 - def add_rule(self, lhablock, lhacode, rule, comment=''):
845 """add a rule for constraint value"""
846 self.rule.append( (lhablock, lhacode, rule) )
847
849
850 text = """<file>######################################################################
851 ## VALIDITY RULE FOR THE PARAM_CARD ####
852 ######################################################################\n"""
853
854
855 text +='<zero>\n'
856 for name, id, comment in self.zero:
857 text+=' %s %s # %s\n' % (name, ' '.join([str(i) for i in id]),
858 comment)
859
860 text +='</zero>\n<one>\n'
861 for name, id, comment in self.one:
862 text+=' %s %s # %s\n' % (name, ' '.join([str(i) for i in id]),
863 comment)
864
865 text +='</one>\n<identical>\n'
866 for name, id,id2, comment in self.identical:
867 text+=' %s %s : %s # %s\n' % (name, ' '.join([str(i) for i in id]),
868 ' '.join([str(i) for i in id2]), comment)
869
870
871 text +='</identical>\n<opposite>\n'
872 for name, id,id2, comment in self.opposite:
873 text+=' %s %s : %s # %s\n' % (name, ' '.join([str(i) for i in id]),
874 ' '.join([str(i) for i in id2]), comment)
875
876
877 text += '</opposite>\n<constraint>\n'
878 for name, id, rule, comment in self.rule:
879 text += ' %s %s : %s # %s\n' % (name, ' '.join([str(i) for i in id]),
880 rule, comment)
881 text += '</constraint>\n</file>'
882
883 if isinstance(output, str):
884 output = open(output,'w')
885 if hasattr(output, 'write'):
886 output.write(text)
887 return text
888
890 """ import a validity rule file """
891
892
893 try:
894 tree = ET.parse(inputpath)
895 except IOError:
896 if '\n' in inputpath:
897
898 tree = ET.fromstring(inputpath)
899 else:
900 raise
901
902
903 element = tree.find('zero')
904 if element is not None:
905 for line in element.text.split('\n'):
906 line = line.split('#',1)[0]
907 if not line:
908 continue
909 lhacode = line.split()
910 blockname = lhacode.pop(0)
911 lhacode = [int(code) for code in lhacode ]
912 self.add_zero(blockname, lhacode, '')
913
914
915 element = tree.find('one')
916 if element is not None:
917 for line in element.text.split('\n'):
918 line = line.split('#',1)[0]
919 if not line:
920 continue
921 lhacode = line.split()
922 blockname = lhacode.pop(0)
923 lhacode = [int(code) for code in lhacode ]
924 self.add_one(blockname, lhacode, '')
925
926
927 element = tree.find('identical')
928 if element is not None:
929 for line in element.text.split('\n'):
930 line = line.split('#',1)[0]
931 if not line:
932 continue
933 line, lhacode2 = line.split(':')
934 lhacode = line.split()
935 blockname = lhacode.pop(0)
936 lhacode = [int(code) for code in lhacode ]
937 lhacode2 = [int(code) for code in lhacode2.split() ]
938 self.add_identical(blockname, lhacode, lhacode2, '')
939
940
941 element = tree.find('opposite')
942 if element is not None:
943 for line in element.text.split('\n'):
944 line = line.split('#',1)[0]
945 if not line:
946 continue
947 line, lhacode2 = line.split(':')
948 lhacode = line.split()
949 blockname = lhacode.pop(0)
950 lhacode = [int(code) for code in lhacode ]
951 lhacode2 = [int(code) for code in lhacode2.split() ]
952 self.add_opposite(blockname, lhacode, lhacode2, '')
953
954
955 element = tree.find('rule')
956 if element is not None:
957 for line in element.text.split('\n'):
958 line = line.split('#',1)[0]
959 if not line:
960 continue
961 line, rule = line.split(':')
962 lhacode = line.split()
963 blockname = lhacode.pop(0)
964 self.add_rule(blockname, lhacode, rule, '')
965
966 @staticmethod
968 """ read a param_card and return a dictionary with the associated value."""
969
970 output = ParamCard(path)
971
972
973
974 return output
975
976 @staticmethod
978 """ read a param_card and return a dictionary with the associated value."""
979
980 output = {}
981
982 if isinstance(path, str):
983 output = open(path, 'w')
984 else:
985 output = path
986
987 data.write(path)
988
989
991 """Check that the restriction card are applied"""
992
993 card = self.read_param_card(path)
994
995
996 for block, id, comment in self.zero:
997 try:
998 value = float(card[block].get(id).value)
999 except KeyError:
1000 if modify:
1001 new_param = Parameter(block=block,lhacode=id, value=0,
1002 comment='fixed by the model')
1003 if block in card:
1004 card[block].append(new_param)
1005 else:
1006 new_block = Block(block)
1007 card.append(new_block)
1008 new_block.append(new_param)
1009 else:
1010 if value != 0:
1011 if not modify:
1012 raise InvalidParamCard, 'parameter %s: %s is not at zero' % \
1013 (block, ' '.join([str(i) for i in id]))
1014 else:
1015 param = card[block].get(id)
1016 param.value = 0.0
1017 param.comment += ' fixed by the model'
1018
1019
1020 for block, id, comment in self.one:
1021 try:
1022 value = card[block].get(id).value
1023 except KeyError:
1024 if modify:
1025 new_param = Parameter(block=block,lhacode=id, value=1,
1026 comment='fixed by the model')
1027 if block in card:
1028 card[block].append(new_param)
1029 else:
1030 new_block = Block(block)
1031 card.append(new_block)
1032 new_block.append(new_param)
1033 else:
1034 if value != 1:
1035 if not modify:
1036 raise InvalidParamCard, 'parameter %s: %s is not at one but at %s' % \
1037 (block, ' '.join([str(i) for i in id]), value)
1038 else:
1039 param = card[block].get(id)
1040 param.value = 1.0
1041 param.comment += ' fixed by the model'
1042
1043
1044
1045 for block, id1, id2, comment in self.identical:
1046 if block not in card:
1047 logger.warning('''Param card is not complete: Block %s is simply missing.
1048 We will use model default for all missing value! Please cross-check that
1049 this correspond to your expectation.''' % block)
1050 continue
1051 value2 = float(card[block].get(id2).value)
1052 try:
1053 param = card[block].get(id1)
1054 except KeyError:
1055 if modify:
1056 new_param = Parameter(block=block,lhacode=id1, value=value2,
1057 comment='must be identical to %s' %id2)
1058 card[block].append(new_param)
1059 else:
1060 value1 = float(param.value)
1061
1062 if value1 != value2:
1063 if not modify:
1064 raise InvalidParamCard, 'parameter %s: %s is not to identical to parameter %s' % \
1065 (block, ' '.join([str(i) for i in id1]),
1066 ' '.join([str(i) for i in id2]))
1067 else:
1068 param = card[block].get(id1)
1069 param.value = value2
1070 param.comment += ' must be identical to %s' % id2
1071
1072
1073 for block, id1, id2, comment in self.opposite:
1074 value2 = float(card[block].get(id2).value)
1075 try:
1076 param = card[block].get(id1)
1077 except KeyError:
1078 if modify:
1079 new_param = Parameter(block=block,lhacode=id1, value=-value2,
1080 comment='must be opposite to to %s' %id2)
1081 card[block].append(new_param)
1082 else:
1083 value1 = float(param.value)
1084
1085 if value1 != -value2:
1086 if not modify:
1087 raise InvalidParamCard, 'parameter %s: %s is not to opposite to parameter %s' % \
1088 (block, ' '.join([str(i) for i in id1]),
1089 ' '.join([str(i) for i in id2]))
1090 else:
1091 param = card[block].get(id1)
1092 param.value = -value2
1093 param.comment += ' must be opposite to %s' % id2
1094
1095 return card
1096
1099 """ """
1100
1101 if not outputpath:
1102 outputpath = path
1103 card = ParamCard(path)
1104 if not 'usqmix' in card:
1105
1106 card.write(outputpath)
1107 return
1108
1109
1110
1111 card.copy_param('mass', [6], 'sminputs', [6])
1112 card.copy_param('mass', [15], 'sminputs', [7])
1113 card.copy_param('mass', [23], 'sminputs', [4])
1114
1115
1116
1117 card.add_param('modsel',[1], value=1)
1118 card['modsel'].get([1]).format = 'int'
1119
1120
1121 scale = card['hmix'].scale
1122 if not scale:
1123 scale = 1
1124
1125
1126 if not card.has_param('sminputs', [2]):
1127 aem1 = card['sminputs'].get([1]).value
1128 mz = card['mass'].get([23]).value
1129 mw = card['mass'].get([24]).value
1130 gf = math.pi / math.sqrt(2) / aem1 * mz**2/ mw**2 /(mz**2-mw**2)
1131 card.add_param('sminputs', [2], gf, 'G_F [GeV^-2]')
1132
1133
1134 card.check_and_remove('usqmix', [1,1], 1.0)
1135 card.check_and_remove('usqmix', [2,2], 1.0)
1136 card.check_and_remove('usqmix', [4,4], 1.0)
1137 card.check_and_remove('usqmix', [5,5], 1.0)
1138 card.mod_param('usqmix', [3,3], 'stopmix', [1,1])
1139 card.mod_param('usqmix', [3,6], 'stopmix', [1,2])
1140 card.mod_param('usqmix', [6,3], 'stopmix', [2,1])
1141 card.mod_param('usqmix', [6,6], 'stopmix', [2,2])
1142
1143
1144 card.check_and_remove('dsqmix', [1,1], 1.0)
1145 card.check_and_remove('dsqmix', [2,2], 1.0)
1146 card.check_and_remove('dsqmix', [4,4], 1.0)
1147 card.check_and_remove('dsqmix', [5,5], 1.0)
1148 card.mod_param('dsqmix', [3,3], 'sbotmix', [1,1])
1149 card.mod_param('dsqmix', [3,6], 'sbotmix', [1,2])
1150 card.mod_param('dsqmix', [6,3], 'sbotmix', [2,1])
1151 card.mod_param('dsqmix', [6,6], 'sbotmix', [2,2])
1152
1153
1154
1155 card.check_and_remove('selmix', [1,1], 1.0)
1156 card.check_and_remove('selmix', [2,2], 1.0)
1157 card.check_and_remove('selmix', [4,4], 1.0)
1158 card.check_and_remove('selmix', [5,5], 1.0)
1159 card.mod_param('selmix', [3,3], 'staumix', [1,1])
1160 card.mod_param('selmix', [3,6], 'staumix', [1,2])
1161 card.mod_param('selmix', [6,3], 'staumix', [2,1])
1162 card.mod_param('selmix', [6,6], 'staumix', [2,2])
1163
1164
1165 card.mod_param('fralpha', [1], 'alpha', [' '])
1166
1167
1168 if not card.has_param('hmix', [3]):
1169 aem1 = card['sminputs'].get([1]).value
1170 tanb = card['hmix'].get([2]).value
1171 mz = card['mass'].get([23]).value
1172 mw = card['mass'].get([24]).value
1173 sw = math.sqrt(mz**2 - mw**2)/mz
1174 ee = 2 * math.sqrt(1/aem1) * math.sqrt(math.pi)
1175 vu = 2 * mw *sw /ee * math.sin(math.atan(tanb))
1176 card.add_param('hmix', [3], vu, 'higgs vev(Q) MSSM DRb')
1177 card['hmix'].scale= scale
1178
1179
1180 card.check_and_remove('vckm', [1,1], 1.0)
1181 card.check_and_remove('vckm', [2,2], 1.0)
1182 card.check_and_remove('vckm', [3,3], 1.0)
1183
1184
1185 card.check_and_remove('snumix', [1,1], 1.0)
1186 card.check_and_remove('snumix', [2,2], 1.0)
1187 card.check_and_remove('snumix', [3,3], 1.0)
1188
1189
1190 card.check_and_remove('upmns', [1,1], 1.0)
1191 card.check_and_remove('upmns', [2,2], 1.0)
1192 card.check_and_remove('upmns', [3,3], 1.0)
1193
1194
1195 ye = card['ye'].get([3, 3]).value
1196 te = card['te'].get([3, 3]).value
1197 card.mod_param('te', [3,3], 'ae', [3,3], value= te/ye, comment='A_tau(Q) DRbar')
1198 card.add_param('ae', [1,1], 0, 'A_e(Q) DRbar')
1199 card.add_param('ae', [2,2], 0, 'A_mu(Q) DRbar')
1200 card['ae'].scale = scale
1201 card['ye'].scale = scale
1202
1203
1204 yu = card['yu'].get([3, 3]).value
1205 tu = card['tu'].get([3, 3]).value
1206 card.mod_param('tu', [3,3], 'au', [3,3], value= tu/yu, comment='A_t(Q) DRbar')
1207 card.add_param('au', [1,1], 0, 'A_u(Q) DRbar')
1208 card.add_param('au', [2,2], 0, 'A_c(Q) DRbar')
1209 card['au'].scale = scale
1210 card['yu'].scale = scale
1211
1212
1213 yd = card['yd'].get([3, 3]).value
1214 td = card['td'].get([3, 3]).value
1215 if td:
1216 card.mod_param('td', [3,3], 'ad', [3,3], value= td/yd, comment='A_b(Q) DRbar')
1217 else:
1218 card.mod_param('td', [3,3], 'ad', [3,3], value= 0., comment='A_b(Q) DRbar')
1219 card.add_param('ad', [1,1], 0, 'A_d(Q) DRbar')
1220 card.add_param('ad', [2,2], 0, 'A_s(Q) DRbar')
1221 card['ad'].scale = scale
1222 card['yd'].scale = scale
1223
1224
1225 value = card['msl2'].get([1, 1]).value
1226 card.mod_param('msl2', [1,1], 'msoft', [31], math.sqrt(value))
1227 value = card['msl2'].get([2, 2]).value
1228 card.mod_param('msl2', [2,2], 'msoft', [32], math.sqrt(value))
1229 value = card['msl2'].get([3, 3]).value
1230 card.mod_param('msl2', [3,3], 'msoft', [33], math.sqrt(value))
1231 card['msoft'].scale = scale
1232
1233
1234 value = card['mse2'].get([1, 1]).value
1235 card.mod_param('mse2', [1,1], 'msoft', [34], math.sqrt(value))
1236 value = card['mse2'].get([2, 2]).value
1237 card.mod_param('mse2', [2,2], 'msoft', [35], math.sqrt(value))
1238 value = card['mse2'].get([3, 3]).value
1239 card.mod_param('mse2', [3,3], 'msoft', [36], math.sqrt(value))
1240
1241
1242 value = card['msq2'].get([1, 1]).value
1243 card.mod_param('msq2', [1,1], 'msoft', [41], math.sqrt(value))
1244 value = card['msq2'].get([2, 2]).value
1245 card.mod_param('msq2', [2,2], 'msoft', [42], math.sqrt(value))
1246 value = card['msq2'].get([3, 3]).value
1247 card.mod_param('msq2', [3,3], 'msoft', [43], math.sqrt(value))
1248
1249
1250 value = card['msu2'].get([1, 1]).value
1251 card.mod_param('msu2', [1,1], 'msoft', [44], math.sqrt(value))
1252 value = card['msu2'].get([2, 2]).value
1253 card.mod_param('msu2', [2,2], 'msoft', [45], math.sqrt(value))
1254 value = card['msu2'].get([3, 3]).value
1255 card.mod_param('msu2', [3,3], 'msoft', [46], math.sqrt(value))
1256
1257
1258 value = card['msd2'].get([1, 1]).value
1259 card.mod_param('msd2', [1,1], 'msoft', [47], math.sqrt(value))
1260 value = card['msd2'].get([2, 2]).value
1261 card.mod_param('msd2', [2,2], 'msoft', [48], math.sqrt(value))
1262 value = card['msd2'].get([3, 3]).value
1263 card.mod_param('msd2', [3,3], 'msoft', [49], math.sqrt(value))
1264
1265
1266
1267
1268
1269
1270 card.write(outputpath)
1271
1275 """
1276 """
1277
1278 if not outputpath:
1279 outputpath = path
1280 card = ParamCard(path)
1281 if 'usqmix' in card:
1282
1283 if outputpath != path and writting:
1284 card.write(outputpath)
1285 return card
1286
1287
1288
1289 card.remove_param('sminputs', [2])
1290 card.remove_param('sminputs', [4])
1291 card.remove_param('sminputs', [6])
1292 card.remove_param('sminputs', [7])
1293
1294
1295
1296 card.remove_param('modsel',[1])
1297
1298
1299
1300 card.add_param('usqmix', [1,1], 1.0)
1301 card.add_param('usqmix', [2,2], 1.0)
1302 card.add_param('usqmix', [4,4], 1.0)
1303 card.add_param('usqmix', [5,5], 1.0)
1304 card.mod_param('stopmix', [1,1], 'usqmix', [3,3])
1305 card.mod_param('stopmix', [1,2], 'usqmix', [3,6])
1306 card.mod_param('stopmix', [2,1], 'usqmix', [6,3])
1307 card.mod_param('stopmix', [2,2], 'usqmix', [6,6])
1308
1309
1310 card.add_param('dsqmix', [1,1], 1.0)
1311 card.add_param('dsqmix', [2,2], 1.0)
1312 card.add_param('dsqmix', [4,4], 1.0)
1313 card.add_param('dsqmix', [5,5], 1.0)
1314 card.mod_param('sbotmix', [1,1], 'dsqmix', [3,3])
1315 card.mod_param('sbotmix', [1,2], 'dsqmix', [3,6])
1316 card.mod_param('sbotmix', [2,1], 'dsqmix', [6,3])
1317 card.mod_param('sbotmix', [2,2], 'dsqmix', [6,6])
1318
1319
1320
1321 card.add_param('selmix', [1,1], 1.0)
1322 card.add_param('selmix', [2,2], 1.0)
1323 card.add_param('selmix', [4,4], 1.0)
1324 card.add_param('selmix', [5,5], 1.0)
1325 card.mod_param('staumix', [1,1], 'selmix', [3,3])
1326 card.mod_param('staumix', [1,2], 'selmix', [3,6])
1327 card.mod_param('staumix', [2,1], 'selmix', [6,3])
1328 card.mod_param('staumix', [2,2], 'selmix', [6,6])
1329
1330
1331 card.mod_param('alpha', [], 'fralpha', [1])
1332
1333
1334 card.remove_param('hmix', [3])
1335
1336
1337 card.add_param('vckm', [1,1], 1.0)
1338 card.add_param('vckm', [2,2], 1.0)
1339 card.add_param('vckm', [3,3], 1.0)
1340
1341
1342 card.add_param('snumix', [1,1], 1.0)
1343 card.add_param('snumix', [2,2], 1.0)
1344 card.add_param('snumix', [3,3], 1.0)
1345
1346
1347 card.add_param('upmns', [1,1], 1.0)
1348 card.add_param('upmns', [2,2], 1.0)
1349 card.add_param('upmns', [3,3], 1.0)
1350
1351
1352 ye = card['ye'].get([1, 1], default=0).value
1353 ae = card['ae'].get([1, 1], default=0).value
1354 card.mod_param('ae', [1,1], 'te', [1,1], value= ae * ye, comment='T_e(Q) DRbar')
1355 if ae * ye:
1356 raise InvalidParamCard, '''This card is not suitable to be converted to MSSM UFO model
1357 Parameter ae [1, 1] times ye [1,1] should be 0'''
1358 card.remove_param('ae', [1,1])
1359
1360 ye = card['ye'].get([2, 2], default=0).value
1361
1362 ae = card['ae'].get([2, 2], default=0).value
1363 card.mod_param('ae', [2,2], 'te', [2,2], value= ae * ye, comment='T_mu(Q) DRbar')
1364 if ae * ye:
1365 raise InvalidParamCard, '''This card is not suitable to be converted to MSSM UFO model
1366 Parameter ae [2, 2] times ye [2,2] should be 0'''
1367 card.remove_param('ae', [2,2])
1368
1369 ye = card['ye'].get([3, 3], default=0).value
1370 ae = card['ae'].get([3, 3], default=0).value
1371 card.mod_param('ae', [3,3], 'te', [3,3], value= ae * ye, comment='T_tau(Q) DRbar')
1372
1373
1374 yu = card['yu'].get([1, 1], default=0).value
1375 au = card['au'].get([1, 1], default=0).value
1376 card.mod_param('au', [1,1], 'tu', [1,1], value= au * yu, comment='T_u(Q) DRbar')
1377 if au * yu:
1378 raise InvalidParamCard, '''This card is not suitable to be converted to MSSM UFO model
1379 Parameter au [1, 1] times yu [1,1] should be 0'''
1380 card.remove_param('au', [1,1])
1381
1382 ye = card['yu'].get([2, 2], default=0).value
1383
1384 ae = card['au'].get([2, 2], default=0).value
1385 card.mod_param('au', [2,2], 'tu', [2,2], value= au * yu, comment='T_c(Q) DRbar')
1386 if au * yu:
1387 raise InvalidParamCard, '''This card is not suitable to be converted to MSSM UFO model
1388 Parameter au [2, 2] times yu [2,2] should be 0'''
1389 card.remove_param('au', [2,2])
1390
1391 yu = card['yu'].get([3, 3]).value
1392 au = card['au'].get([3, 3]).value
1393 card.mod_param('au', [3,3], 'tu', [3,3], value= au * yu, comment='T_t(Q) DRbar')
1394
1395
1396 yd = card['yd'].get([1, 1], default=0).value
1397 ad = card['ad'].get([1, 1], default=0).value
1398 card.mod_param('ad', [1,1], 'td', [1,1], value= ad * yd, comment='T_d(Q) DRbar')
1399 if ad * yd:
1400 raise InvalidParamCard, '''This card is not suitable to be converted to MSSM UFO model
1401 Parameter ad [1, 1] times yd [1,1] should be 0'''
1402 card.remove_param('ad', [1,1])
1403
1404 ye = card['yd'].get([2, 2], default=0).value
1405
1406 ae = card['ad'].get([2, 2], default=0).value
1407 card.mod_param('ad', [2,2], 'td', [2,2], value= ad * yd, comment='T_s(Q) DRbar')
1408 if ad * yd:
1409 raise InvalidParamCard, '''This card is not suitable to be converted to MSSM UFO model
1410 Parameter ad [2, 2] times yd [2,2] should be 0'''
1411 card.remove_param('ad', [2,2])
1412
1413 yd = card['yd'].get([3, 3]).value
1414 ad = card['ad'].get([3, 3]).value
1415 card.mod_param('ad', [3,3], 'td', [3,3], value= ad * yd, comment='T_b(Q) DRbar')
1416
1417
1418
1419 value = card['msoft'].get([31]).value
1420 card.mod_param('msoft', [31], 'msl2', [1,1], value**2)
1421 value = card['msoft'].get([32]).value
1422 card.mod_param('msoft', [32], 'msl2', [2,2], value**2)
1423 value = card['msoft'].get([33]).value
1424 card.mod_param('msoft', [33], 'msl2', [3,3], value**2)
1425
1426
1427 value = card['msoft'].get([34]).value
1428 card.mod_param('msoft', [34], 'mse2', [1,1], value**2)
1429 value = card['msoft'].get([35]).value
1430 card.mod_param('msoft', [35], 'mse2', [2,2], value**2)
1431 value = card['msoft'].get([36]).value
1432 card.mod_param('msoft', [36], 'mse2', [3,3], value**2)
1433
1434
1435 value = card['msoft'].get([41]).value
1436 card.mod_param('msoft', [41], 'msq2', [1,1], value**2)
1437 value = card['msoft'].get([42]).value
1438 card.mod_param('msoft', [42], 'msq2', [2,2], value**2)
1439 value = card['msoft'].get([43]).value
1440 card.mod_param('msoft', [43], 'msq2', [3,3], value**2)
1441
1442
1443 value = card['msoft'].get([44]).value
1444 card.mod_param('msoft', [44], 'msu2', [1,1], value**2)
1445 value = card['msoft'].get([45]).value
1446 card.mod_param('msoft', [45], 'msu2', [2,2], value**2)
1447 value = card['msoft'].get([46]).value
1448 card.mod_param('msoft', [46], 'msu2', [3,3], value**2)
1449
1450
1451 value = card['msoft'].get([47]).value
1452 card.mod_param('msoft', [47], 'msd2', [1,1], value**2)
1453 value = card['msoft'].get([48]).value
1454 card.mod_param('msoft', [48], 'msd2', [2,2], value**2)
1455 value = card['msoft'].get([49]).value
1456 card.mod_param('msoft', [49], 'msd2', [3,3], value**2)
1457
1458
1459
1460
1461 if writting:
1462 card.write(outputpath)
1463 return card
1464
1467 """ modify the current param_card such that it agrees with the restriction"""
1468
1469 if not outputpath:
1470 outputpath = path
1471
1472 cardrule = ParamCardRule()
1473 cardrule.load_rule(restrictpath)
1474 try :
1475 cardrule.check_param_card(path, modify=False)
1476 except InvalidParamCard:
1477 new_data = cardrule.check_param_card(path, modify=True)
1478 cardrule.write_param_card(outputpath, new_data)
1479 else:
1480 if path != outputpath:
1481 shutil.copy(path, outputpath)
1482 return cardrule
1483
1485 """ check if the current param_card agrees with the restriction"""
1486
1487 if restrictpath is None:
1488 restrictpath = os.path.dirname(path)
1489 restrictpath = os.path.join(restrictpath, os.pardir, os.pardir, 'Source',
1490 'MODEL', 'param_card_rule.dat')
1491 if not os.path.exists(restrictpath):
1492 restrictpath = os.path.dirname(path)
1493 restrictpath = os.path.join(restrictpath, os.pardir, 'Source',
1494 'MODEL', 'param_card_rule.dat')
1495 if not os.path.exists(restrictpath):
1496 return True
1497
1498 cardrule = ParamCardRule()
1499 cardrule.load_rule(restrictpath)
1500 cardrule.check_param_card(path, modify=False)
1501
1502 if '__main__' == __name__:
1503
1504
1505
1506
1507 import sys
1508 args = sys.argv
1509 sys.path.append(os.path.dirname(__file__))
1510 convert_to_slha1(args[1] , args[2])
1511