-
Notifications
You must be signed in to change notification settings - Fork 1
/
UserVsd-CaloTower.py
70 lines (55 loc) · 1.84 KB
/
UserVsd-CaloTower.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import ROOT
import json
ROOT.gSystem.Load("libVsdDict.so")
Vfile = ROOT.TFile("UserVsdTower.root", "RECREATE")
Vtree = ROOT.TTree("VSD", "Custom plain VSD tree")
pcv = ROOT.std.vector('VsdCandidate')()
candBr = Vtree.Branch("PinkCands", pcv)
candCfg = {
"filter" : "i.pt() > 1",
"color" : ROOT.kViolet
}
candBr.SetTitle(json.dumps(candCfg))
# calorimeter towers (1)
ctv1 = ROOT.std.vector('VsdCaloTower')()
ct1Br = Vtree.Branch("CaloTowers-1", ctv1)
cfg = {
"color" : ROOT.kCyan
}
ct1Br.SetTitle(json.dumps(cfg))
# calorimeter towers (1)
ctv2 = ROOT.std.vector('VsdCaloTower')()
ct2Br = Vtree.Branch("CaloTowers-2", ctv2)
cfg = {
"color" : ROOT.kGray
}
ct2Br.SetTitle(json.dumps(cfg))
for i in range(10):
pcv.clear()
ctv1.clear()
ctv2.clear()
for j in range(10 + ROOT.gRandom.Integer(11)):
cnd = ROOT.VsdCandidate(
ROOT.gRandom.Uniform(0.1, 20),
ROOT.gRandom.Uniform(-2.5, 2.5),
ROOT.gRandom.Uniform(-ROOT.TMath.Pi(), ROOT.TMath.Pi()),
(1 if ROOT.gRandom.Rndm() > 0.5 else -1))
cnd.name = f"Candidate_{j}"
cnd.setPos(ROOT.gRandom.Uniform(0.1, 20),ROOT.gRandom.Uniform(0.1, 20), ROOT.gRandom.Uniform(0.1, 20))
pcv.push_back(cnd);
for j in range(3 + ROOT.gRandom.Integer(50)):
tower = ROOT.VsdCaloTower(
ROOT.gRandom.Uniform(0.1, 10),
ROOT.gRandom.Uniform(-2.5, 2.5),
ROOT.gRandom.Uniform(-ROOT.TMath.Pi(), ROOT.TMath.Pi()))
ctv1.push_back(tower)
for j in range(3 + ROOT.gRandom.Integer(120)):
tower = ROOT.VsdCaloTower(
ROOT.gRandom.Uniform(0.01, 2),
ROOT.gRandom.Uniform(-2.5, 2.5),
ROOT.gRandom.Uniform(-ROOT.TMath.Pi(), ROOT.TMath.Pi()))
ctv2.push_back(tower)
Vtree.Fill()
# Save the TTree to a file and close it
Vtree.Write()
Vfile.Close()