source: trunk/source/processes/electromagnetic/lowenergy/test/G4ComptonTest.py @ 1199

Last change on this file since 1199 was 1199, checked in by garnier, 15 years ago

nvx fichiers dans CVS

File size: 1.6 KB
Line 
1global tree, hf
2
3tree = tf.create("comptonhisto.hbook",1,1,"hbook")
4tree.thisown=1
5hf = af.createHistogramFactory(tree)
6
7# ... and load them into memory:
8hEKin    = tree.findH1D("10")
9hP       = tree.findH1D("20")
10hNSec    = tree.findH1D("30")
11hDeposit = tree.findH1D("40")
12hTheta   = tree.findH1D("50")
13hPhi     = tree.findH1D("60")
14
15# set plotter to 3*2 zones
16pl.createRegions(3,2)
17
18# ... and plot the histograms
19pl.plot(hEKin   ) ; pl.show() ; pl.next()
20pl.plot(hP      ) ; pl.show() ; pl.next()
21pl.plot(hNSec   ) ; pl.show() ; pl.next()
22pl.plot(hDeposit) ; pl.show() ; pl.next()
23pl.plot(hTheta  ) ; pl.show() ; pl.next()
24pl.plot(hPhi    ) ; pl.show() ; pl.next()
25
26wait()
27
28# reset number of zones
29pl.createRegions(2,1)
30
31# helper function
32def nplot(tup, col, cut, xmin, xmax, nbins=100):
33  global hf
34  h1 = hf.create1D("1000000","temp hist", nbins, xmin, xmax)
35  colId = tup.findColumn(col)
36  bNextRow=tup.start()                                         # Looping over the tuple entries
37  while bNextRow:
38    h1.fill(tup.getFloat(colId))
39    bNextRow=tup.next()                                        # Retrieving the subsequent row
40  pl.plot(h1) ; pl.show() ; pl.next()
41  tree.rm("1000000")
42  return
43
44# get the primary ntuple from the NtupleManager
45nt1 = tree.findTuple("1" )
46
47# plot a few quantities using the shortcut
48nplot(nt1,"initen" ,"",0,20)
49nplot(nt1,"dedx"   ,"",0.,100)
50
51# prompt user for <return>
52wait()
53
54# get the secondaries ntuple and plot a few attributes from it
55nt2 = tree.findTuple("2" )
56nplot(nt2, "parttyp", "", 0., 42)
57nplot(nt2, "e"      , "", 0., 100.)
58
59pl.write("secondaries.ps", "ps")
60
61tree.commit()
62tree.close()
63del tree
64
65
66
67
Note: See TracBrowser for help on using the repository browser.