coherent WaveBurst
Library Reference Guide
home
cWB_docker
git
cWB
library
tools
cwb
tutorials
ReadFileWAVE.py
Go to the documentation of this file.
1
# this is a python script which shows how to read the waveburst root file
2
3
# load ROOT stuff
4
from
ROOT
import
*
5
6
# load HEALPix stuff
7
gSystem.Load(
"$HOME_CFITSIO/libcfitsio.so"
)
8
gSystem.Load(
"$HOME_HEALPIX/src/cxx/cxxsupport/lib/libcxxsupport.so"
)
9
gSystem.Load(
"$HOME_HEALPIX/src/cxx/libfftpack/lib/libfftpack.so"
)
10
gSystem.Load(
"$HOME_HEALPIX/src/cxx/c_utils/lib/libc_utils.so"
)
11
gSystem.Load(
"$HOME_HEALPIX/src/cxx/libpsht/lib/libpsht.so"
)
12
gSystem.Load(
"$HOME_HEALPIX/src/cxx/Healpix_cxx/lib/HEALPix.so"
)
13
14
# load wavelet library
15
gSystem.Load(
"wavelet.so"
)
16
17
# open waveburst root file
18
f = TFile(
'wave_file.root'
)
19
# get waveburst tree
20
tree = f.Get(
"waveburst"
)
21
# define tree cuts
22
treeformula = TTreeFormula(
"cuts"
,
"rho[1]>5 && netcc[0]>0.8"
, tree);
23
24
# define histogram for netcc[0] plot
25
hist = TH1F(
'hist'
,
'netcc'
, 100, 0., 1. )
26
27
# get the number of entries
28
size = tree.GetEntries()
29
print
size
30
31
# loop over the tree entries
32
for
j
in
range(0,size-1):
33
# get entry j
34
tree.GetEntry(j)
35
# select entry
36
if
treeformula.EvalInstance() != 0:
37
print
tree.netcc[0]
38
print
tree.rho[1]
39
# fill histogram
40
hist.Fill(tree.netcc[0])
41
42
# plot and save histogram
43
c = TCanvas()
44
hist.Draw()
45
c.Print(
"netcc0.png"
)
46
47
# plot and save rho[1]
48
tree.Draw(
"rho[1]"
,
"rho[1]>5 && netcc[0]>0.8"
)
49
c.Print(
"rho1.png"
)
50
51
# plot and save rho[1] netcc[0]
52
tree.Draw(
"rho[1]:netcc[0]"
,
"rho[1]>5 && netcc[0]>0.8"
,
"colz"
)
53
c.Print(
"rho1_vs_netcc0.png"
)
54