source: fact/tools/pyscripts/sandbox/dneise/rdietlic/ftcalapp.py@ 14912

Last change on this file since 14912 was 13368, checked in by neise, 13 years ago
initial commit of my sandbox
File size: 3.7 KB
Line 
1# Program to calculate integral deviation for several Datasets
2#
3# Remo Dietlicher
4# ETH Zürich
5# Semesterarbeit
6#
7#
8
9import pyfact
10from myhisto import *
11from hist import *
12import numpy as np
13import numpy.random as rnd
14from scipy import interpolate as ip
15from ROOT import *
16from time import time
17from optparse import OptionParser
18from ftcal2 import ftcal
19from periods2 import periods2
20
21
22NROI = 1024 # Region of interest
23NChip = 2 # Number of Chips
24NEvents = 400 # Number of Events
25fsampling = 1024./512. # sampling frequency
26
27# Open default Datafiles
28
29Datafiles = []
30
31Datafiles.append(["/data00/fact-construction/raw/2011/11/24/20111124_014.fits.gz",
32 "/data00/fact-construction/raw/2011/11/24/20111124_012.drs.fits.gz"])
33
34Datafiles.append(["/data00/fact-construction/raw/2011/11/24/20111124_034.fits.gz",
35 "/data00/fact-construction/raw/2011/11/24/20111124_032.drs.fits.gz"])
36
37Datafiles.append(["/data00/fact-construction/raw/2011/11/24/20111124_053.fits.gz",
38 "/data00/fact-construction/raw/2011/11/24/20111124_051.drs.fits.gz"])
39
40Datafiles.append(["/data00/fact-construction/raw/2011/11/24/20111124_073.fits.gz",
41 "/data00/fact-construction/raw/2011/11/24/20111124_071.drs.fits.gz"])
42
43Datafiles.append(["/data00/fact-construction/raw/2011/11/24/20111124_093.fits.gz",
44 "/data00/fact-construction/raw/2011/11/24/20111124_091.drs.fits.gz"])
45
46Datafiles.append(["/data00/fact-construction/raw/2011/11/24/20111124_113.fits.gz",
47 "/data00/fact-construction/raw/2011/11/24/20111124_111.drs.fits.gz"])
48
49
50count = 6
51
52h = range(count)
53
54for dat in range(count):
55 h[dat] = hist_list(ftcalappHistograms, NChip, "Chip")
56
57# Parser for extended Version
58
59parser = OptionParser()
60parser.add_option('-e', '--extended', action = 'store_true', dest='extend', default = False )
61(options, args) = parser.parse_args()
62
63path = "/data00/fact-construction/raw/"
64
65
66# Open any Datafile
67
68if(options.extend):
69
70 Datafiles = []
71
72 year = raw_input("Daten aus welchem Jahr? ")
73 month = raw_input("Daten aus welchem Monat? ")
74 day = raw_input("Daten von welchem Tag? ")
75 path = "/data00/fact-construction/raw/"+str(year)+"/"+str(month)+"/"+str(day)+"/"
76
77 count = int(raw_input("Wieviele runs? "))
78 h = range(count)
79
80
81 for dat in range(count):
82 run = year+month+day+"_"+raw_input("Welcher Datenrun? ")+".fits.gz"
83 drs = year+month+day+"_"+raw_input("Welcher Kalibrationsrun? ")+".drs.fits.gz"
84 Datafiles.append([str(path)+str(run), str(path)+str(drs)])
85 h[dat] = hist_list(ftcalappHistograms, NChip, "Chip")
86
87
88 NChip = int(raw_input("Wieviele Chips? ([1, ... ,160]): "))
89 NEvents = int(raw_input("Wieviele Events? ([1, ... , 1000]) "))
90
91
92save = raw_input("Sollen die Kalibrationskonstanten Gespeichert weden? (yes/no) ")
93
94
95
96
97CellTime = np.zeros([count, NChip, NROI+1])
98DataMean = np.zeros([count, NChip, NROI])
99
100for dat in range(count):
101 print "Datafile: ", Datafiles[dat][0]
102 CellTime[dat], DataMean[dat] = ftcal(NChip, NEvents, h[dat], Datafiles[dat][0], Datafiles[dat][1])
103
104for dat in range(count):
105 for Chip in range(NChip):
106 for i in range(NROI):
107 h[dat].list[Chip].dict["int_dev"].SetBinContent(i+1, CellTime[dat][Chip][i]-i/fsampling)
108
109 periods2(DataMean[dat][Chip], CellTime[dat][Chip], h[dat].list[Chip])
110
111
112 pyfact.SaveHistograms(h[dat].list, str(Datafiles[dat][0][-20:-8])+"_"+str(NEvents)+"x"+str(NChip)+".root", "RECREATE")
113
114
115 print "Histogram saved as: ", str(Datafiles[dat][0][-20:-8])+"_"+str(NEvents)+"x"+str(NChip)+".root"
116
117
118
119if(save == "yes"):
120 for dat in range(count):
121 np.save("FtcalKonst/"+str(Datafiles[dat][0][-20:-8])+"_"+str(NEvents)+"x"+str(NChip), CellTime[dat])
122 print "calibration constants saved as: ", str(Datafiles[dat][0][-20:-8])+"_"+str(NEvents)+"x"+str(NChip)+".npy"
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
Note: See TracBrowser for help on using the repository browser.