-
Notifications
You must be signed in to change notification settings - Fork 2
/
hits.py
58 lines (36 loc) · 961 Bytes
/
hits.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
#!/usr/bin/env python
# coding: utf-8
import sys, os, glob, yaml
import math
import random
import numpy as np
import pandas as pd
import trackml.dataset
import torch
import ROOT
%jsroot on
inputdir='./run_all/fwp_feature_store'
proc_files = sorted(glob.glob(os.path.join(inputdir, "*")))
h1 = ROOT.TH1F("h1", "Number of Hits;No. of Hits;Counts", 200, 100, 500)
h2 = ROOT.TH1F("h2", "Number of Hits;No. of Hits;Counts", 200, 100, 500)
i = 0
# Loop over events
print(" Total Files:", len(proc_files))
for f in proc_files[1000]:
i = i+1
if i != 0 and i%1000 == 0:
print("Processed Events:", i)
# load event
feature_data = torch.load(f, map_location='cpu')
nhits = feature_data.hid.size(0)
# fill hist
h1.Fill(nhits)
# PyROOT: TCanvas
can = ROOT.TCanvas("can","",600,500)
can.cd();
h1.GetXaxis().SetTitleOffset(1.5);
h1.Draw();
can.Draw()
can.SaveAs("hits.pdf")
can.SaveAs("hits.C")
can.Close()