14Compare a left/right LUT with a table of true left/right counts for each pattern.
15(see generateTrueLRTable.py)
19innerLUT = np.loadtxt(
'trg/cdc/data/innerLUT_Bkg_p0.70_b0.80.coe',
20 skiprows=2, delimiter=
',', usecols=[0], comments=
';')
21outerLUT = np.loadtxt(
'trg/cdc/data/outerLUT_Bkg_p0.70_b0.80.coe',
22 skiprows=2, delimiter=
',', usecols=[0], comments=
';')
26innerTrueLRTable = np.loadtxt(
'innerTrueLRTable_Bkg1.0_5.dat')
27outerTrueLRTable = np.loadtxt(
'outerTrueLRTable_Bkg1.0_5.dat')
30def check(LUT, TrueLRTable):
37 for pattern, trueLR
in enumerate(TrueLRTable):
40 nCorrectMC += trueLR[LUTLR - 1]
41 nWrongMC += trueLR[2 - LUTLR]
42 nKnownBkg += trueLR[2]
44 nUnknownMC += trueLR[0] + trueLR[1]
45 nUnknownBkg += trueLR[2]
46 return nCorrectMC, nWrongMC, nUnknownMC, nKnownBkg, nUnknownBkg
49def printFractions(checkResults):
50 nCorrectMC, nWrongMC, nUnknownMC, nKnownBkg, nUnknownBkg = checkResults
51 nMC = nCorrectMC + nWrongMC + nUnknownMC
52 nBkg = nKnownBkg + nUnknownBkg
53 print(f
" {int(nMC)} TS with MC hit in priority wire")
55 print(
" %d correct, %d wrong, %d unknown"
56 % (nCorrectMC, nWrongMC, nUnknownMC))
57 print(
" correct fraction", 100. * nCorrectMC / (nCorrectMC + nWrongMC),
58 "+-", 100. * np.sqrt(nCorrectMC * nWrongMC / (nCorrectMC + nWrongMC) ** 3))
59 print(
" unknown fraction", 100. * nUnknownMC / nMC,
60 "+-", 100. * np.sqrt(nUnknownMC * (nMC - nUnknownMC) / nMC ** 3))
61 print(f
" {int(nBkg)} TS with Bkg hit in priority wire")
63 print(f
" {int(nKnownBkg)} known, {int(nUnknownBkg)} unknown")
64 print(
" unknown fraction", 100. * nUnknownBkg / nBkg,
65 "+-", 100. * np.sqrt(nUnknownBkg * (nBkg - nUnknownBkg) / nBkg ** 3))
68innerCheck = check(innerLUT, innerTrueLRTable)
69outerCheck = check(outerLUT, outerTrueLRTable)
71print(
"\ninnermost super layer:")
72printFractions(innerCheck)
73print(
"\nouter super layers:")
74printFractions(outerCheck)
75print(
"\nall super layers:")
76printFractions(np.array(innerCheck) + np.array(outerCheck))