7 Compare a left/right LUT with a table of true left/right counts for each pattern.
8 (see generateTrueLRTable.py)
12 innerLUT = np.loadtxt(
'trg/cdc/data/innerLUT_Bkg_p0.70_b0.80.coe',
13 skiprows=2, delimiter=
',', usecols=[0], comments=
';')
14 outerLUT = np.loadtxt(
'trg/cdc/data/outerLUT_Bkg_p0.70_b0.80.coe',
15 skiprows=2, delimiter=
',', usecols=[0], comments=
';')
19 innerTrueLRTable = np.loadtxt(
'innerTrueLRTable_Bkg1.0_5.dat')
20 outerTrueLRTable = np.loadtxt(
'outerTrueLRTable_Bkg1.0_5.dat')
23 def check(LUT, TrueLRTable):
30 for pattern, trueLR
in enumerate(TrueLRTable):
33 nCorrectMC += trueLR[LUTLR - 1]
34 nWrongMC += trueLR[2 - LUTLR]
35 nKnownBkg += trueLR[2]
37 nUnknownMC += trueLR[0] + trueLR[1]
38 nUnknownBkg += trueLR[2]
39 return nCorrectMC, nWrongMC, nUnknownMC, nKnownBkg, nUnknownBkg
42 def printFractions(checkResults):
43 nCorrectMC, nWrongMC, nUnknownMC, nKnownBkg, nUnknownBkg = checkResults
44 nMC = nCorrectMC + nWrongMC + nUnknownMC
45 nBkg = nKnownBkg + nUnknownBkg
46 print(
" %d TS with MC hit in priority wire" % nMC)
48 print(
" %d correct, %d wrong, %d unknown"
49 % (nCorrectMC, nWrongMC, nUnknownMC))
50 print(
" correct fraction", 100. * nCorrectMC / (nCorrectMC + nWrongMC),
51 "+-", 100. * np.sqrt(nCorrectMC * nWrongMC / (nCorrectMC + nWrongMC) ** 3))
52 print(
" unknown fraction", 100. * nUnknownMC / nMC,
53 "+-", 100. * np.sqrt(nUnknownMC * (nMC - nUnknownMC) / nMC ** 3))
54 print(
" %d TS with Bkg hit in priority wire" % nBkg)
56 print(
" %d known, %d unknown"
57 % (nKnownBkg, nUnknownBkg))
58 print(
" unknown fraction", 100. * nUnknownBkg / nBkg,
59 "+-", 100. * np.sqrt(nUnknownBkg * (nBkg - nUnknownBkg) / nBkg ** 3))
62 innerCheck = check(innerLUT, innerTrueLRTable)
63 outerCheck = check(outerLUT, outerTrueLRTable)
65 print(
"\ninnermost super layer:")
66 printFractions(innerCheck)
67 print(
"\nouter super layers:")
68 printFractions(outerCheck)
69 print(
"\nall super layers:")
70 printFractions(np.array(innerCheck) + np.array(outerCheck))