-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateRecoRate.py
More file actions
70 lines (50 loc) · 2.42 KB
/
generateRecoRate.py
File metadata and controls
70 lines (50 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#External Dependencies
import sys
import math
import numpy as np
import ROOT as root
from array import array
#Internal Dependencies
from dataTypes import *
import driver
def main(argv):
volume = DetectorVolume(1000.0, 1000.0)
wirePitches = [5.0, 5.0, 5.0]
angles = driver.generateAngles(len(wirePitches))
numbersOfBlobs = [3]
alphas = [0.01]
numberOfIterations = 100
for numberOfBlobs in numbersOfBlobs:
for alpha in alphas:
c1 = root.TCanvas( "RecoRateCanvas", "RecoRateCanvas", 200, 10, 700, 500 )
correctFractions = root.TH1F("correctFractions", ("Correct Identification Fraction"), 100, -0.1, 1.1)
fakeFractions = root.TH1F("fakeFractions", ("Fake Identification Fraction"), 100, -0.1, 1.1)
for i in range(numberOfIterations):
blobs, cells, channelList, geometryMatrix, recoWireMatrix, recoCellMatrix, trueCellMatrix = driver.drive(volume, wirePitches, angles, numberOfBlobs, alpha)
recoCells = list(map(lambda x: not math.isclose(x,0,rel_tol=1e-5),recoCellMatrix))
trueCells = list(map(lambda x: not math.isclose(x,0,rel_tol=1e-5),trueCellMatrix))
correctID = sum(bool(x[0]) and bool(x[1]) for x in zip(trueCells,recoCells))
fakeID = sum(not bool(x[0]) and bool(x[1]) for x in zip(trueCells,recoCells))
correctFraction = correctID/len(blobs)
fakeFraction = fakeID/len(blobs)
correctFractions.Fill(correctFraction)
fakeFractions.Fill(fakeFraction)
correctFractions.SetTitle("")
correctFractions.GetYaxis().SetTitleSize(0.04)
correctFractions.GetYaxis().SetTitleOffset(1.2)
correctFractions.GetYaxis().SetLabelSize(0.04)
correctFractions.GetXaxis().SetTitleSize(0.04)
correctFractions.GetXaxis().SetTitleOffset(1)
correctFractions.GetXaxis().SetLabelSize(0.04)
correctFractions.SetLineWidth(2)
fakeFractions.SetLineWidth(2)
# correctFractions.SetLineStyle(2)
fakeFractions.SetLineStyle(2)
correctFractions.SetLineColor(root.kBlue)
fakeFractions.SetLineColor(root.kRed)
root.gStyle.SetOptStat(0)
correctFractions.Draw("HIST")
fakeFractions.Draw("HIST SAMES")
root.gApplication.Run()
if __name__ == "__main__":
main(sys.argv)