| 1 | # Programm zur Bestimmung der Genauigkeit des konvergierten Algorithmus | 
|---|
| 2 | # | 
|---|
| 3 | # Remo Dietlicher | 
|---|
| 4 | # | 
|---|
| 5 | # | 
|---|
| 6 |  | 
|---|
| 7 | from optparse import OptionParser | 
|---|
| 8 | import pyfact | 
|---|
| 9 | from myhisto import * | 
|---|
| 10 | from hist import * | 
|---|
| 11 | import numpy as np | 
|---|
| 12 | import numpy.random as rnd | 
|---|
| 13 | from ROOT import * | 
|---|
| 14 | from time import time | 
|---|
| 15 |  | 
|---|
| 16 | def 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 |  | 
|---|