2 from __future__
import print_function
3 from builtins
import range
12 parser = argparse.ArgumentParser(description=
'Take card file, blank all INFI directives and insert the INFI directives from the modifier file instead.',
14 formatter_class=argparse.RawDescriptionHelpFormatter)
16 parser.add_argument(
'inCfg', action=
'store',
17 help=
'name of the config-template')
18 parser.add_argument(
'modCfg', action=
'store',
19 help=
'name of the modifier file from mps_split')
20 parser.add_argument(
'outCfg', action=
'store',
21 help=
'name of modified output file')
22 parser.add_argument(
'isn', action=
'store',
23 help=
'number of the job (three digit number with leading zeros)')
24 parser.add_argument(
"--max-events", dest =
"max_events", type = int,
25 help =
"maximum number of events to process")
26 parser.add_argument(
"--skip-events", dest =
"skip_events", type = int,
27 help =
"number of events to skip before processing")
30 args = parser.parse_args()
38 with open(inCfg,
'r') as INFILE: 42 with open(modCfg,
'r') as MODFILE: 47 fileNames = mods.split(
'\n')
48 if 'CastorPool=' in fileNames[0]:
52 body = re.sub(re.compile(
'ISN',re.M), isn, body)
55 with open(outCfg,
'w')
as OUTFILE:
59 numberOfFiles = len(fileNames)
60 numberOfExtends =
int(math.ceil(numberOfFiles/255.))
63 for j
in range(numberOfExtends):
64 insertBlock =
"readFiles.extend([\n " 67 while (i<255)
and ((currentStart+i)<numberOfFiles):
68 entry = fileNames[currentStart+i].
strip()
69 if (i==254)
or ((currentStart+i+1)==numberOfFiles):
70 insertBlock +=
"\'"+entry+
"\'])\n" 72 insertBlock +=
"\'"+entry+
"\',\n " 75 for line
in fileinput.input(outCfg, inplace=1):
77 if re.match(
'readFiles\s*=\s*cms.untracked.vstring()',line):
78 print(insertBlock,end=
'')
80 if args.skip_events
is not None:
81 with open(outCfg,
"a")
as f:
82 f.write(
"process.source.skipEvents = cms.untracked.uint32({0:d})\n" 85 if args.max_events
is not None:
86 with open(outCfg,
"a")
as f:
87 f.write(
"process.maxEvents = cms.untracked.PSet(input = " 88 "cms.untracked.int32({0:d}))\n".
format(args.max_events))
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)