23 import Alignment.MillePedeAlignmentAlgorithm.mpslib.tools
as mps_tools
24 import Alignment.MillePedeAlignmentAlgorithm.mpslib.Mpslibclass
as mpslib
29 """Main routine of the script. 32 - `argv`: arguments passed to the main routine 39 parser.add_argument(
"-d",
"--mps-db", dest=
"mps_db", required=
True,
40 metavar=
"PATH", help=
"MPS database file ('mps.db')")
41 parser.add_argument(
"--his", dest=
"his_file", required=
True,
42 metavar=
"PATH", help=
"pede histogram file")
43 parser.add_argument(
"-c",
"--cfg", dest=
"cfg", metavar=
"PATH", required=
True,
44 help=
"python configuration file of pede job")
45 parser.add_argument(
"-b",
"--no-binary-check", dest=
"no_binary_check",
46 default=
False, action=
"store_true",
47 help=(
"skip check for existing binaries " 48 "(possibly needed if used interactively)"))
49 args = parser.parse_args(argv)
52 for input_file
in (args.mps_db, args.his_file, args.cfg):
53 if not os.path.exists(input_file):
54 print "Could not find input file:", input_file
61 if len(his_data) != len(used_binaries):
62 print "The number of used binaries is", len(used_binaries),
63 print "whereas in contrast, however, the <chi2/ndf> histogram in Pede has",
64 print len(his_data),
"bins (Pede version >= rev92 might help if #bins < #binaries).",
68 with open(
"chi2pedehis.txt",
"w")
as f:
69 for i, b
in enumerate(used_binaries):
72 f.write(
" ".
join([name,
"{:03d}".
format(b), his_data[i]])+
"\n")
77 """Returns two lists containing the mille job IDs and the associated names. 80 - `mps_db`: path to the MPS database file 83 lib = mpslib.jobdatabase()
86 ids = lib.JOBNUMBER[:lib.nJobs]
87 names = lib.JOBSP3[:lib.nJobs]
93 """Returns list of used binary IDs. 96 - `cfg`: python config used to run the pede job 97 - `no_binary_check`: if 'True' a check for file existence is skipped 100 cms_process = mps_tools.get_process_object(cfg)
102 binaries = cms_process.AlignmentProducer.algoConfig.mergeBinaryFiles
104 used_binaries = binaries
107 used_binaries = [b
for b
in binaries
108 if os.path.exists(os.path.join(os.path.dirname(cfg), b))]
110 used_binaries = [
int(re.sub(
r"milleBinary(\d+)\.dat",
r"\1", b))
111 for b
in used_binaries]
117 """Parse the pede histogram file. 120 - `his_file`: pede histogram file 124 with open(his_file,
"r") as his: 125 found_chi2_start = False;
128 if r"final <Chi^2/Ndf> from accepted local fits vs file number" in line:
129 found_chi2_start =
True 130 if not found_chi2_start:
133 if r"end of xy-data" in line:
break 134 if not re.search(
"\d", line):
continue 135 if re.search(
r"[a-z]", line):
continue 136 splitted = line.split()
137 his_data.append(splitted[-1])
143 if __name__ ==
"__main__":
def get_his_data(his_file)
def get_used_binaries(cfg, no_binary_check)
static std::string join(char **cmd)
def get_all_ids_names(mps_db)