forked from awhitbeck/LDMX_TS
-
Notifications
You must be signed in to change notification settings - Fork 2
/
count_anomalous.py
55 lines (45 loc) · 1.67 KB
/
count_anomalous.py
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
# this code calculates the number of events for which the true num for the Upsteam array was greater than the true num of tagger array
import ROOT as r
from ts_digi_container import *
import pandas as pd
from sklearn import svm
import numpy as np
from array import array
r.gStyle.SetOptStat(0)
r.gROOT.ProcessLine(".L tdrstyle.C")
r.gROOT.ProcessLine("setTDRStyle()")
r.gROOT.SetBatch(True)
Dict = {}
## set configurable parameters
coll="TriggerPadTagger"
min_pe=2
df=pd.DataFrame(columns=["TrueData","TaggerData","UpstreamData"])
##initialize histograms
can=r.TCanvas("can","can",500,500)
hist = r.TH2F("confusion_hist",coll+";True Electrons;Pred Electrons",8,-0.5,7.5,8,-0.5,7.5)
secondaries= r.TH1D("secondaries","Secondaries Distribution;Secondaries;Events",10,0,10)
## intialize contain to read target input file
cont = ts_digi_container("~whitbeck/raid/LDMX/trigger_pad_sim/Dec18/trig_scin_digi_mip_respons_10_noise_0p02.root")
cont.setup()
n=0
for i in range(cont.tin.GetEntries()):
#if i >100: break
## initialize container
cont.getEvent(i)
## get true number of electrons
true_num=cont.count_true(coll+"SimHits")
true_num2=cont.count_true("TriggerPadUpSimHits")
if true_num < true_num2:
n+=1
Dict.setdefault(i,[]).append(true_num)
Dict.setdefault(i,[]).append(true_num2)
Dict.setdefault(i,[]).append(cont.get_num_secondaries())
secondaries.Fill(cont.get_num_secondaries())
print "Number of Analomous Events",n
print "\n"
print Dict
secondaries.SetFillColor(38)
secondaries.Draw()
#secondaries.GetXaxis().SetTitle( 'Min_Pe' )
#secondaries.GetYaxis().SetTitle( 'Efficiency Rate' )
can.SaveAs("strange_secondaries.png")