ATLAS Offline Software
Loading...
Searching...
No Matches
SCNT.py
Go to the documentation of this file.
1# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2
3
6def SCNTHeader(num):
7 outfile = open("SCNT.sql","wt")
8 outfile.write("SET echo OFF;\n")
9 outfile.write("set linesize 132;\n")
10# outfile.write("drop table SCNT_data2tag cascade constraints;\n")
11# outfile.write("drop table SCNT_data cascade constraints;\n")
12 outfile.write("create table SCNT_data (\n")
13 outfile.write("SCNT_data_id number(10),\n")
14 outfile.write("ITEM number(10),\n")
15 outfile.write("DR float(63),\n")
16 outfile.write("RC float(63),\n")
17 outfile.write("ZP float(63),\n")
18 outfile.write("DRW float(63),\n")
19 outfile.write("DT float(63),\n")
20 outfile.write("DTW float(63),\n")
21 outfile.write("DPHI float(63) \n")
22 outfile.write(") ;\n")
23 outfile.write("\n")
24 outfile.write("alter table SCNT_data add constraint SCNT_data_pk\n")
25 outfile.write("primary key (SCNT_data_id);\n")
26 outfile.write("\n")
27 outfile.write("create table SCNT_data2tag (\n")
28 outfile.write(" SCNT_vers varchar2(255),\n")
29 outfile.write(" SCNT_data_id number(10)\n")
30 outfile.write(") ;\n")
31
32 outfile.close()
33 return num
34
35# ---------------------------------------------------------------------------------------------------------------
36def SCNTComments(num):
37 outfile = open("SCNT.sql","awt")
38 outfile.write("\n")
39 outfile.write("comment on column SCNT_data.SCNT_data_id is 'TileCal SCNT, Section';\n")
40 outfile.write("comment on column SCNT_data.ITEM is 'Scintillator number:")
41 outfile.write(" 1-bar,2-ext,3-ITC1,4-ITC2,5-Gap,6-Crack';\n")
42 outfile.write("comment on column SCNT_data.DR is 'Dimension along R';\n")
43 outfile.write("comment on column SCNT_data.RC is 'R position with respect to the lower edge of module';\n")
44 outfile.write("comment on column SCNT_data.ZP is 'Z position';\n")
45 outfile.write("comment on column SCNT_data.DRW is 'Radial space for wrapping';\n")
46 outfile.write("comment on column SCNT_data.DT is 'Scintillator thickness in Z';\n")
47 outfile.write("comment on column SCNT_data.DTW is 'Wrapping thickness in Z';\n")
48 outfile.write("comment on column SCNT_data.DPHI is 'Distance between scintillator and absorber edge in phi';\n")
49 outfile.close()
50 return num
51
52# ---------------------------------------------------------------------------------------------------------------
53def SCNT(num):
54 import string
55 inpfile = open("SCNT-GEO-03","rt")
56 outfile = open("SCNT.sql","awt")
57 line =modname =comment =volline =cindx =' '
58 nmax =0
59 n1 =n2 =0
60 r3 =r4 =r5 =r6 =r7 =r8 =r9 =0.0
61
62 outfile.write("\n")
63
64 indx = -1
65 while 1 :
66 line = inpfile.readline()
67 indx = indx + 1
68 cindx = str(indx)
69 if line == "":
70 break
71
72 name = string.split(line)
73 nmax = len(name)
74 try:
75 if nmax < 1:
76 raise IndexError
77 if nmax > 9:
78 raise IndexError
79
80 if name[0] == "###":
81 break
82
83 n1 = int(name[0])
84 r2 = float(name[1])
85 r3 = float(name[2])
86 r4 = float(name[3])
87 r5 = float(name[4])
88 r6 = float(name[5])
89 r7 = float(name[6])
90 r8 = float(name[7])
91
92 volline = str(indx)+","+str(n1)+","+str(r2)+","+str(r3)+","+str(r4)+","+str(r5)
93 volline = volline+","+str(r6)+","+str(r7)+","+str(r8)
94
95 outfile.write("insert into SCNT_data (SCNT_data_id, ITEM, DR,RC,ZP,DRW,DT,DTW,DPHI) values (\n")
96 outfile.write(volline)
97 outfile.write(");\n")
98 outfile.write("insert into SCNT_data2tag values ('SCNT-GEO-03', ")
99 outfile.write(cindx)
100 outfile.write(");\n")
101
102 except IndexError: # coments are in line
103 print ' IndexError : ',nmax,' ',name
104
105 inpfile.close()
106 outfile.close()
107 return num
108
109# ---------------------------------------------------------------------------------------------------------------
110print 'Tile SCNT wirh python '
111print ' Tile Header', SCNTHeader('Header')
112print ' Tile Values ',SCNT('SCNT-GEO-03')
113print ' Tile Coments',SCNTComments('Comments')
114
Definition SCNT.py:1
SCNTComments(num)
Definition SCNT.py:36
SCNTHeader(num)
Definition SCNT.py:6