-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpytest.py
executable file
·60 lines (49 loc) · 1.31 KB
/
pytest.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
#!/usr/bin/python3
import ROOT
from array import array
LEN=200
# define double array?
x,c = array('d'), array( 'd' )
for i in range( LEN ):
x.append(i )
c.append(i+100)
filename="pytest_TGraph.root"
print("T... create .root file with graph TEST:", filename)
f=ROOT.TFile( filename,"recreate")
gc=ROOT.TGraph( LEN ,x ,c )
gc.SetName("clona")
gc.SetTitle("clona")
gc.Write()
f.Close()
print("i... graph file created and closed")
filename="pytest_TH1.root"
f=ROOT.TFile( filename,"recreate")
print("T... file woith TH1 test: ")
h1=ROOT.TH1F("hpytest","test histogram", 4000,0,4000 )
for i in range(LEN):
h1.Fill( i )
if i<100:h1.Fill( i )
if i<50:h1.Fill( i )
h1.Write()
f.Close()
print("i... TH1F file created and closed")
mmapfile="mmap.histo"
print("T... test mmap feature: (good for gregory)", mmapfile)
allhist=[]
from ROOT import TFile, TH1F, TH1D, TMapFile
f = TMapFile.Create( mmapfile );
print(f)
mr=f.GetFirst()
while f.OrgAddress(mr):
print(mr,mr.GetClassName() )
if mr.GetClassName()=="TH1F":
name=mr.GetName()
allhist.append( f.Get( name ) )
#print( mr.GetNext() )
mr=mr.GetNext()
print("i... printing all histograms:", allhist)
if len(allhist)==0:print("!... no histograms found")
for h in allhist:
print("h",h)
h.Draw()
print("i mmap file was tested")