SND@LHC Software
Loading...
Searching...
No Matches
goliath2root.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# file to convert goliath fieldmap text file to root
3# EvH 11/4/2018
4
5
6import ROOT,os,sys
7import rootUtils as ut
8import shipunit as u
9import shipRoot_conf
10
11h={}
12# new limits x: -1118.6, 1241.4 (59); y: -411.40, 768.60 (20); z: -2512.7, 2537.3 (101)
13#
14
15ut.bookHist(h,'Bx','Bx',60,-113.86,126.14,21,-44.09,79.81,102,-253.77,256.27)
16ut.bookHist(h,'By','By',60,-113.86,126.14,21,-44.09,79.81,102,-253.77,256.27)
17ut.bookHist(h,'Bz','Bz',60,-113.86,126.14,21,-44.09,79.81,102,-253.77,256.27)
18ut.bookHist(h,'Byvsz','By vs z for x=1.4,y=1.6',102,-253.77,256.27)
19f=open('ExtGoliathFieldMap.txt','r')
20
21i=0
22for line in f:
23 i+=1
24 if i<6: continue
25 x,y,z,Bx,By,Bz = line.split()
26 x=float(x)/10.
27 y=float(y)/10.
28 z=float(z)/10.
29 Bx = Bx
30 By = By
31 Bz = Bz
32
33 rc=h['Bx'].Fill(float(x),float(y),float(z),float(Bx))
34 rc=h['By'].Fill(float(x),float(y),float(z),float(By))
35 rc=h['Bz'].Fill(float(x),float(y),float(z),float(Bz))
36
37 if (round(x,2)==0.14) and (round(y,2)==0.16):
38 rc=h['Byvsz'].Fill(float(z),float(By))
39
40ut.writeHists(h,"GoliathFieldMap.root")