Project

General

Profile

Bug #1866 » muon_charge.py

Blackmore, Victoria, 01 September 2016 16:08

 
1
import numpy as np
2
import read_ttree as read
3
from ROOT import TFile, TCanvas, gDirectory, TTree, TGraph, TGraphErrors, TMath, TLegend, TMultiGraph, TH1F, TH2F, TColor, gStyle, gROOT, TF2, TEllipse
4

    
5
import matplotlib.pyplot as pyplot
6
from mpl_toolkits.mplot3d import Axes3D
7

    
8

    
9
def main():
10
    filename = '~/Documents/Work/MICE Data/Data run 7469/run7469_extracted_data__MAUS2pt5_b.root'
11
    
12
    fig, ax = pyplot.subplots(5, 5) # makes a 5x5 set of plots
13
    
14
    fig2 = pyplot.figure(2)
15
    ax2 = fig2.gca(projection='3d')
16
    ax2.set_xlabel('x')
17
    ax2.set_ylabel('y')
18
    ax2.set_zlabel('z, beam')
19

    
20
    f = TFile(filename, 'read')
21
    tree = f.Get("T")
22
    
23
    row, column = 0, 0
24
    
25
    for entry in tree:
26
        if entry.cut_allPassed == 1 and row*column < 16:
27
            x1 = entry.TKU_s1_x
28
            x2 = entry.TKU_s2_x
29
            x3 = entry.TKU_s3_x
30
            x4 = entry.TKU_s4_x
31
            x5 = entry.TKU_s5_x
32

    
33
            y1 = entry.TKU_s1_y
34
            y2 = entry.TKU_s2_y
35
            y3 = entry.TKU_s3_y
36
            y4 = entry.TKU_s4_y
37
            y5 = entry.TKU_s5_y
38
            
39
            z1 = entry.TKU_s1_z
40
            z2 = entry.TKU_s2_z
41
            z3 = entry.TKU_s3_z
42
            z4 = entry.TKU_s4_z
43
            z5 = entry.TKU_s5_z
44
            
45
            x = [x5, x4, x3, x2, x1]
46
            y = [y5, y4, y3, y2, y1]
47
            z = [z5, z4, z3, z2, z1]
48
            
49
            ax[row, column].plot(x1, y1, 'ko')
50
            ax[row, column].plot(x2, y2, 'bo')
51
            ax[row, column].plot(x3, y3, 'co')
52
            ax[row, column].plot(x4, y4, 'go')
53
            ax[row, column].plot(x5, y5, 'ro')
54
            
55
            print "(row, column) = ", row, column
56
            
57
            if row == 0 and column == 0:
58
                ax2.plot(x, y, z)
59
                ax2.scatter(x5, y5, z5, c='r')
60
                ax2.scatter(x4, y4, z4, c='g')
61
                ax2.scatter(x3, y3, z3, c='c')
62
                ax2.scatter(x2, y2, z2, c='b')
63
                ax2.scatter(x1, y1, z1, c='k')
64

    
65
            if column == 4:
66
                row += 1
67
                column = 0
68
            else:
69
                column += 1
70

    
71

    
72
        if row*column > 16:
73
            break
74

    
75
    pyplot.show()
76

    
77

    
78

    
79

    
80
main()
(10-10/16)