source: fact/tools/pyscripts/sandbox/dneise/rdietlic/periods2.py@ 13449

Last change on this file since 13449 was 13368, checked in by neise, 12 years ago
initial commit of my sandbox
File size: 1.3 KB
Line 
1# Programm zur Bestimmung der Genauigkeit des konvergierten Algorithmus
2#
3# Remo Dietlicher
4#
5#
6
7from optparse import OptionParser
8import pyfact
9from myhisto import *
10from hist import *
11import numpy as np
12import numpy.random as rnd
13from ROOT import *
14from time import time
15
16def periods2(Data, CellTime, h):
17
18 NROI = 1024 # length of the DRS pipeline
19 fsampling = 2. # sampling frequency
20 freq = 250. # testfrequency
21 P_nom = 1000./freq # nominal Period due to testfrequency
22
23
24 nomCellTime = np.linspace(0., 1024., 1025)/fsampling
25
26
27 # FUNCTION TO DETERMINE CROSSINGS
28
29 def Crossing(Mean, rCellTime):
30 TimeXing = np.zeros(NROI)
31 MeanXing = np.zeros(NROI)
32 NumXing = 0
33
34 for i in range(NROI-1):
35 if ((Data[i] > Mean) & (Data[i+1] < Mean)):
36 MeanXing[NumXing] = i
37
38 FirstCell = rCellTime[i]
39 SecondCell = rCellTime[i+1]
40
41 TimeXing[NumXing] = FirstCell+(SecondCell-FirstCell)/(1.-Data[i+1]/(Data[i]))*(1.-Mean/(Data[i]))
42 NumXing += 1
43
44 return MeanXing, TimeXing
45
46 def CalculatePeriods(rCellTime, name):
47
48 Period = np.zeros(126)
49
50 MeanXing, TimeXing = Crossing(np.average(Data), rCellTime)
51
52 for i in range(int(126)):
53 Period[i] = TimeXing[i+1] - TimeXing[i]
54
55 for val in Period:
56 h.dict[str(name)].Fill(val)
57
58 return
59
60 CalculatePeriods(CellTime, "avperiods")
61 CalculatePeriods(nomCellTime, "avperiods0")
62
63 return
64
65
66
67
Note: See TracBrowser for help on using the repository browser.