9 import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass
as mpslib
14 lib = mpslib.jobdatabase()
19 description=
'Produce Config for Pede-job from Mille-config.')
22 parser.add_argument(
'-c',
'--checkok', action=
'store_true',
23 help=
'check which jobs are OK and write just them to the config')
24 parser.add_argument(
'-w',
'--checkweight', action=
'store_true',
25 help=
'check for weight assignments in mps.db and add them to binarylist')
26 parser.add_argument(
"-a",
"--append", dest=
"append", metavar=
"SNIPPET",
27 help=
"config snippet to be appended to the output config")
30 parser.add_argument(
'inCfg', action=
'store',
31 help=
'path to cfg-file, that is used as base')
32 parser.add_argument(
'mergeCfg', action=
'store',
33 help=
'path and name of the config that is produced')
34 parser.add_argument(
'mergeDir', action=
'store',
35 help=
'path to the merge directory')
36 parser.add_argument(
'nJobs', action=
'store', type=int,
37 help=
'number of jobs')
40 args = parser.parse_args()
42 mergeCfg = args.mergeCfg
43 mergeDir = args.mergeDir
45 checkok = args.checkok
46 checkweight = args.checkweight
48 if checkok
or checkweight:
55 if not os.path.isdir(mergeDir):
56 os.system(
'mkdir '+mergeDir)
59 with open(inCfg,
'r') as INFILE:
64 match = re.search(
'setupAlgoMode\s*?\=\s*?[\"\'].*?[\"\']', body)
66 body = re.sub(
'setupAlgoMode\s*?\=\s*?[\"\'].*?[\"\']',
67 'setupAlgoMode = \"pede\"',
70 print 'Error in mps_merge: No setupAlgoMode found in baseconfig.'
76 for i
in xrange(nJobs):
80 if checkok
and lib.JOBSTATUS[i]!=
'OK':
84 newName =
'milleBinary%03d.dat' % (i+1)
85 if checkweight
and (lib.JOBSP2[i]!=
'' and lib.JOBSP2[i]!=
'1.0'):
86 weight = lib.JOBSP2[i]
87 print 'Adding %s to list of binary files using weight %s' % (newName,weight)
88 binaryList =
'%s%s\'%s -- %s\'' % (binaryList, separator, newName, weight)
90 print 'Adding %s to list of binary files' % newName
91 binaryList =
'%s%s\'%s\'' % (binaryList, separator, newName)
95 match = re.search(
'[\"\']placeholder_binaryList[\"\']', body)
97 body = re.sub(
'[\"\']placeholder_binaryList[\"\']',
101 print 'Error in mps_merge: No \'placeholder_binaryList\' found in baseconfig.'
107 for i
in xrange(nJobs):
111 if checkok
and lib.JOBSTATUS[i]!=
'OK':
115 newName =
'treeFile%03d.root' % (i+1)
116 print 'Adding %s to list of tree files.' % newName
117 treeList =
'%s%s\'%s\'' % (treeList, separator, newName)
121 match = re.search(
'[\"\']placeholder_treeList[\"\']', body)
123 body = re.sub(
'[\"\']placeholder_treeList[\"\']',
127 print 'Error in mps_merge: No \'placeholder_treeList\' found in baseconfig.'
129 if args.append
is not None:
130 with open(args.append)
as snippet:
131 body += snippet.read()
133 with open(mergeCfg,
'w')
as OUTFILE: