1 | # Program to calculate integral deviation for several Datasets
|
---|
2 | #
|
---|
3 | # Remo Dietlicher
|
---|
4 | # ETH Zürich
|
---|
5 | # Semesterarbeit
|
---|
6 | #
|
---|
7 | #
|
---|
8 |
|
---|
9 | import pyfact
|
---|
10 | from myhisto import *
|
---|
11 | from hist import *
|
---|
12 | import numpy as np
|
---|
13 | import numpy.random as rnd
|
---|
14 | from scipy import interpolate as ip
|
---|
15 | from ROOT import *
|
---|
16 | from time import time
|
---|
17 | from optparse import OptionParser
|
---|
18 | from ftcal2 import ftcal
|
---|
19 | from periods2 import periods2
|
---|
20 |
|
---|
21 |
|
---|
22 | NROI = 1024 # Region of interest
|
---|
23 | NChip = 2 # Number of Chips
|
---|
24 | NEvents = 400 # Number of Events
|
---|
25 | fsampling = 1024./512. # sampling frequency
|
---|
26 |
|
---|
27 | # Open default Datafiles
|
---|
28 |
|
---|
29 | Datafiles = []
|
---|
30 |
|
---|
31 | Datafiles.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 |
|
---|
34 | Datafiles.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 |
|
---|
37 | Datafiles.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 |
|
---|
40 | Datafiles.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 |
|
---|
43 | Datafiles.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 |
|
---|
46 | Datafiles.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 |
|
---|
50 | count = 6
|
---|
51 |
|
---|
52 | h = range(count)
|
---|
53 |
|
---|
54 | for dat in range(count):
|
---|
55 | h[dat] = hist_list(ftcalappHistograms, NChip, "Chip")
|
---|
56 |
|
---|
57 | # Parser for extended Version
|
---|
58 |
|
---|
59 | parser = OptionParser()
|
---|
60 | parser.add_option('-e', '--extended', action = 'store_true', dest='extend', default = False )
|
---|
61 | (options, args) = parser.parse_args()
|
---|
62 |
|
---|
63 | path = "/data00/fact-construction/raw/"
|
---|
64 |
|
---|
65 |
|
---|
66 | # Open any Datafile
|
---|
67 |
|
---|
68 | if(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 |
|
---|
92 | save = raw_input("Sollen die Kalibrationskonstanten Gespeichert weden? (yes/no) ")
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 | CellTime = np.zeros([count, NChip, NROI+1])
|
---|
98 | DataMean = np.zeros([count, NChip, NROI])
|
---|
99 |
|
---|
100 | for 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 |
|
---|
104 | for 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 |
|
---|
119 | if(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 |
|
---|