]>
Commit | Line | Data |
---|---|---|
8562a9e6 | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> | |
3 | <title>AliHLTPHOS: PeakFinderTest.cxx Source File</title> | |
4 | <link href="doxygen.css" rel="stylesheet" type="text/css"> | |
5 | </head><body> | |
6 | <!-- Generated by Doxygen 1.3.9.1 --> | |
9a49f543 | 7 | <div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div> |
8562a9e6 | 8 | <h1>PeakFinderTest.cxx</h1><a href="PeakFinderTest_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#include "<a class="code" href="AliHLTPHOSPulseGenerator_8h.html">AliHLTPHOSPulseGenerator.h</a>"</span> |
eace7fcd | 9 | 00002 <span class="preprocessor">#include "<a class="code" href="AliHLTPHOSRawAnalyzerPeakFinder_8h.html">AliHLTPHOSRawAnalyzerPeakFinder.h</a>"</span> |
8562a9e6 | 10 | 00003 <span class="preprocessor">#include <stdio.h></span> |
11 | 00004 <span class="preprocessor">#include <cmath></span> | |
12 | 00005 | |
13 | 00006 <span class="keywordtype">void</span> <a class="code" href="PeakFinderTest_8cxx.html#a0">setFileName</a>(<span class="keywordtype">char</span> *fName, <span class="keywordtype">int</span> start, <span class="keywordtype">int</span> length, <span class="keywordtype">double</span> tau, <span class="keywordtype">double</span> fs); | |
14 | 00007 | |
15 | <a name="l00011"></a><a class="code" href="PeakFinderTest_8cxx.html#a1">00011</a> <span class="keywordtype">int</span> <a class="code" href="PeakFinderTest_8cxx.html#a1">main</a>() | |
16 | 00012 { | |
17 | 00013 FILE *fp = 0; | |
18 | 00014 <span class="keywordtype">int</span> start = 0; <span class="comment">// Start index of subarray of sample array</span> | |
19 | 00015 <span class="keywordtype">int</span> N = 128; <span class="comment">// Number of samples </span> | |
20 | 00016 <span class="keywordtype">char</span> fileName[100]; <span class="comment">// Name of file containing Peakfinder vectors</span> | |
21 | 00017 <span class="keywordtype">double</span> amplitude; <span class="comment">// Amplitude/energy in ADC levels</span> | |
22 | 00018 <span class="keywordtype">double</span> t0; <span class="comment">// timedelay in nanoseconds </span> | |
23 | 00019 | |
24 | 00020 <span class="keywordtype">double</span> tau = 2; <span class="comment">// risetime in microseconds</span> | |
25 | 00021 <span class="keywordtype">double</span> fs = 20; <span class="comment">// sample frequency in Megahertz</span> | |
26 | 00022 <span class="keywordtype">double</span> timeVector[N]; <span class="comment">// Peakfinder vector for reconstruction of time</span> | |
27 | 00023 <span class="keywordtype">double</span> amplitudeVector[N]; <span class="comment">// Peakfinder vector for reconstruction of energy</span> | |
28 | 00024 <span class="keywordtype">double</span> aSystError; | |
29 | 00025 <span class="keywordtype">double</span> tSystError; | |
30 | 00026 | |
31 | 00027 <span class="keywordtype">int</span> ts = (int)(1000/fs); | |
32 | 00028 printf(<span class="stringliteral">"\nts=%d\n"</span>, ts); | |
33 | 00029 | |
34 | 00030 printf(<span class="stringliteral">"type amplitude in ADC levels (0-1023):"</span>); | |
35 | 00031 scanf(<span class="stringliteral">"%lf"</span>, &amplitude); | |
36 | 00032 printf(<span class="stringliteral">"type timedelay in nanoseconds (0-%d):"</span>, ts); | |
37 | 00033 scanf(<span class="stringliteral">"%lf"</span>, &t0); | |
38 | 00034 | |
39 | 00035 <a class="code" href="classAliHLTPHOSPulseGenerator.html">AliHLTPHOSPulseGenerator</a> *pulseGenPtr = <span class="keyword">new</span> <a class="code" href="classAliHLTPHOSPulseGenerator.html">AliHLTPHOSPulseGenerator</a>(amplitude, t0, N, tau, fs); | |
9a49f543 | 40 | 00036 <span class="keywordtype">double</span> *data = pulseGenPtr-><a class="code" href="classAliHLTPHOSPulseGenerator.html#a9">GetPulse</a>(); |
8562a9e6 | 41 | 00037 |
42 | 00038 <a class="code" href="PeakFinderTest_8cxx.html#a0">setFileName</a>(fileName, start, N, tau, fs); | |
43 | 00039 fp = fopen(fileName,<span class="stringliteral">"r"</span>); | |
44 | 00040 | |
45 | 00041 <span class="keywordflow">if</span>(fp == 0) | |
46 | 00042 { | |
47 | 00043 printf(<span class="stringliteral">"\nFile does not exist\n"</span>); | |
48 | 00044 } | |
49 | 00045 <span class="keywordflow">else</span> | |
50 | 00046 { | |
51 | 00047 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i < N; i++) | |
52 | 00048 { | |
53 | 00049 fscanf(fp, <span class="stringliteral">"%lf"</span>, &amplitudeVector[i]); | |
54 | 00050 } | |
55 | 00051 | |
56 | 00052 fscanf(fp, <span class="stringliteral">"\n"</span>); | |
57 | 00053 | |
58 | 00054 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i < N; i++) | |
59 | 00055 { | |
60 | 00056 fscanf(fp, <span class="stringliteral">"%lf"</span>, &timeVector[i]); | |
61 | 00057 } | |
62 | 00058 | |
63 | 00059 fscanf(fp, <span class="stringliteral">"%lf"</span>, &aSystError); | |
64 | 00060 fscanf(fp, <span class="stringliteral">"%lf"</span>, &tSystError); | |
65 | 00061 printf(<span class="stringliteral">"\nPeakfinder vectors loaded from %s\n"</span>, fileName); | |
66 | 00062 } | |
67 | 00063 | |
68 | 00064 | |
69 | 00065 tSystError = tSystError*pow(10, 9); <span class="comment">//to give systematic error of timing in nanoseconds</span> | |
70 | 00066 aSystError = aSystError*100; <span class="comment">//to give systematic error of amplitude in percent</span> | |
71 | 00067 | |
72 | 00068 | |
73 | 00069 <span class="comment">// AliHLTPHOSAnalyzerPeakFinder *fitPtr= new AliHLTPHOSAnalyzerPeakFinder(data, fs); </span> | |
eace7fcd | 74 | 00070 <a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html">AliHLTPHOSRawAnalyzerPeakFinder</a> *fitPtr= <span class="keyword">new</span> <a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html">AliHLTPHOSRawAnalyzerPeakFinder</a>(); |
8562a9e6 | 75 | 00071 |
9a49f543 | 76 | 00072 fitPtr-><a class="code" href="classAliHLTPHOSRawAnalyzer.html#a10">SetData</a>(data); |
77 | 00073 fitPtr-><a class="code" href="classAliHLTPHOSRawAnalyzer.html#a11">SetSampleFreq</a>(fs); | |
78 | 00074 fitPtr-><a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html#a4">SetTVector</a>(timeVector, 100); | |
79 | 00075 fitPtr-><a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html#a5">SetAVector</a>(amplitudeVector, 100); | |
8562a9e6 | 80 | 00076 <span class="comment">// fitPtr->Set</span> |
9a49f543 | 81 | 00077 fitPtr-><a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html#a6">Evaluate</a>(start, N); |
8562a9e6 | 82 | 00078 |
83 | 00079 <span class="keywordtype">double</span> energy; | |
84 | 00080 <span class="keywordtype">double</span> time; | |
85 | 00081 | |
9a49f543 | 86 | 00082 time = fitPtr-><a class="code" href="classAliHLTPHOSRawAnalyzer.html#a8">GetTiming</a>(); |
87 | 00083 energy = fitPtr-><a class="code" href="classAliHLTPHOSRawAnalyzer.html#a9">GetEnergy</a>(); | |
8562a9e6 | 88 | 00084 |
89 | 00085 printf(<span class="stringliteral">"\nReal amplitude \t\t= %lf ADC counts \nReconstructed amplitude\t= %lf ADC counts\n"</span>, amplitude, energy); | |
90 | 00086 printf(<span class="stringliteral">"\nReal time \t\t= %lf nanoseconds \nReconstructed time\t= %lf nanoseconds\n"</span>, t0, time); | |
91 | 00087 printf(<span class="stringliteral">"\n\nMaximum systematic error in amplitude \t= %lf %%"</span>, aSystError); | |
92 | 00088 printf(<span class="stringliteral">"\nMaximum systematic error for timing \t= %lf nanoseconds\n\n"</span>, tSystError); | |
93 | 00089 <span class="keywordflow">return</span> 0; | |
94 | 00090 } | |
95 | 00091 | |
96 | <a name="l00092"></a><a class="code" href="PeakFinderTest_8cxx.html#a0">00092</a> <span class="keywordtype">void</span> <a class="code" href="PeakFinderTest_8cxx.html#a0">setFileName</a>(<span class="keywordtype">char</span> *fName, <span class="keywordtype">int</span> start, <span class="keywordtype">int</span> N, <span class="keywordtype">double</span> tau, <span class="keywordtype">double</span> fs) | |
97 | 00093 { | |
98 | 00094 sprintf(fName, <span class="stringliteral">"PFVectors/start%dN%dtau%.ffs%.f.txt"</span>, start, N, tau, fs); | |
99 | 00095 <span class="comment">// printf("\nfilename: %s\n", fName);</span> | |
100 | 00096 } | |
101 | 00097 | |
9a49f543 | 102 | </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 4 04:49:52 2007 for AliHLTPHOS by |
8562a9e6 | 103 | <a href="http://www.doxygen.org/index.html"> |
104 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address> | |
105 | </body> | |
106 | </html> |