9 from __future__
import print_function
10 from builtins
import range
11 import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass
as mpslib
16 lib = mpslib.jobdatabase()
20 parser = argparse.ArgumentParser(
21 description=
'Produce Config for Pede-job from Mille-config.')
24 parser.add_argument(
'-c',
'--checkok', action=
'store_true',
25 help=
'check which jobs are OK and write just them to the config')
26 parser.add_argument(
'-w',
'--checkweight', action=
'store_true',
27 help=
'check for weight assignments in mps.db and add them to binarylist')
28 parser.add_argument(
"-a",
"--append", dest=
"append", metavar=
"SNIPPET",
29 help=
"config snippet to be appended to the output config")
32 parser.add_argument(
'inCfg', action=
'store',
33 help=
'path to cfg-file, that is used as base')
34 parser.add_argument(
'mergeCfg', action=
'store',
35 help=
'path and name of the config that is produced')
36 parser.add_argument(
'mergeDir', action=
'store',
37 help=
'path to the merge directory')
38 parser.add_argument(
'nJobs', action=
'store', type=int,
39 help=
'number of jobs')
42 args = parser.parse_args()
44 mergeCfg = args.mergeCfg
45 mergeDir = args.mergeDir
47 checkok = args.checkok
48 checkweight = args.checkweight
50 if checkok
or checkweight:
57 if not os.path.isdir(mergeDir):
58 os.system(
'mkdir '+mergeDir)
61 with open(inCfg,
'r') as INFILE: body = INFILE.read() 65 match = re.search(
'setupAlgoMode\s*?\=\s*?[\"\'].*?[\"\']', body)
67 body = re.sub(
'setupAlgoMode\s*?\=\s*?[\"\'].*?[\"\']',
68 'setupAlgoMode = \"pede\"',
71 print(
'Error in mps_merge: No setupAlgoMode found in baseconfig.')
81 if checkok
and lib.JOBSTATUS[i]!=
'OK':
85 newName =
'milleBinary%03d.dat' % (i+1)
86 if checkweight
and (lib.JOBSP2[i]!=
'' and lib.JOBSP2[i]!=
'1.0'):
87 weight = lib.JOBSP2[i]
88 print(
'Adding %s to list of binary files using weight %s' % (newName,weight))
89 binaryList =
'%s%s\'%s -- %s\'' % (binaryList, separator, newName, weight)
91 print(
'Adding %s to list of binary files' % newName)
92 binaryList =
'%s%s\'%s\'' % (binaryList, separator, newName)
96 match = re.search(
'[\"\']placeholder_binaryList[\"\']', body)
98 body = re.sub(
'[\"\']placeholder_binaryList[\"\']',
102 print(
'Error in mps_merge: No \'placeholder_binaryList\' found in baseconfig.')
108 for i
in range(nJobs):
112 if checkok
and lib.JOBSTATUS[i]!=
'OK':
116 newName =
'treeFile%03d.root' % (i+1)
117 print(
'Adding %s to list of tree files.' % newName)
118 treeList =
'%s%s\'%s\'' % (treeList, separator, newName)
122 match = re.search(
'[\"\']placeholder_treeList[\"\']', body)
124 body = re.sub(
'[\"\']placeholder_treeList[\"\']',
128 print(
'Error in mps_merge: No \'placeholder_treeList\' found in baseconfig.')
130 if args.append
is not None:
131 with open(args.append)
as snippet:
132 body += snippet.read()
134 with open(mergeCfg,
'w')
as OUTFILE:
136 void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)