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">
6 <!-- Generated by Doxygen 1.3.9.1 -->
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>
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>
9 00002 <span class="preprocessor">#include "<a class="code" href="AliHLTPHOSRawAnalyzerPeakFinder_8h.html">AliHLTPHOSRawAnalyzerPeakFinder.h</a>"</span>
10 00003 <span class="preprocessor">#include <stdio.h></span>
11 00004 <span class="preprocessor">#include <cmath></span>
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);
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>()
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>
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;
31 00027 <span class="keywordtype">int</span> ts = (int)(1000/fs);
32 00028 printf(<span class="stringliteral">"\nts=%d\n"</span>, ts);
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);
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);
40 00036 <span class="keywordtype">double</span> *data = pulseGenPtr-><a class="code" href="classAliHLTPHOSPulseGenerator.html#a9">GetPulse</a>();
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>);
45 00041 <span class="keywordflow">if</span>(fp == 0)
47 00043 printf(<span class="stringliteral">"\nFile does not exist\n"</span>);
49 00045 <span class="keywordflow">else</span>
51 00047 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i < N; i++)
53 00049 fscanf(fp, <span class="stringliteral">"%lf"</span>, &amplitudeVector[i]);
56 00052 fscanf(fp, <span class="stringliteral">"\n"</span>);
58 00054 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i < N; i++)
60 00056 fscanf(fp, <span class="stringliteral">"%lf"</span>, &timeVector[i]);
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);
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>
73 00069 <span class="comment">// AliHLTPHOSAnalyzerPeakFinder *fitPtr= new AliHLTPHOSAnalyzerPeakFinder(data, fs); </span>
74 00070 <a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html">AliHLTPHOSRawAnalyzerPeakFinder</a> *fitPtr= <span class="keyword">new</span> <a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html">AliHLTPHOSRawAnalyzerPeakFinder</a>();
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);
80 00076 <span class="comment">// fitPtr->Set</span>
81 00077 fitPtr-><a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html#a6">Evaluate</a>(start, N);
83 00079 <span class="keywordtype">double</span> energy;
84 00080 <span class="keywordtype">double</span> time;
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>();
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;
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)
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>
102 </pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 4 04:49:52 2007 for AliHLTPHOS by
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>