Blame view

Modules/Generation.py 780 Bytes
7030f150   Thomas Fitoussi   Full reorganisati...
1
2
3
4
5
6
from numpy import shape, arange
from matplotlib.pyplot import figure, show, hist
from Read import ReadGeneration, ReadWeight


def drawGeneration(files):
f4246390   Thomas Fitoussi   Improve angular d...
7
8
9
10
11
   '''
      Plot histogram of particles'generations
      Input: list of directories
      Output: histogram of generations
   '''
7030f150   Thomas Fitoussi   Full reorganisati...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
   fig = figure()
   ax = fig.add_subplot(111)
   nbBins = 7
   for fileId in files:
      weight = ReadWeight(fileId)
      generation = ReadGeneration(fileId)
      print "file", fileId, "->", shape(generation)[0], "events" 
      hist(generation,nbBins,range=[2,9],log=1,alpha=.5, weights=weight,label=fileId)

   xtick=arange(9)
   ax.legend(loc='best')
   ax.set_xticks(xtick+0.5)
   ax.set_xticklabels(xtick)
   ax.set_xlabel("Generation")
   ax.set_ylabel("Number of events")

   show()