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