]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/html/PeakFinderTest_8cxx-source.html
New component for writing calibration data to fxs (Oystein)
[u/mrichter/AliRoot.git] / HLT / PHOS / html / PeakFinderTest_8cxx-source.html
CommitLineData
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&nbsp;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&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;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 900002 <span class="preprocessor">#include "<a class="code" href="AliHLTPHOSRawAnalyzerPeakFinder_8h.html">AliHLTPHOSRawAnalyzerPeakFinder.h</a>"</span>
8562a9e6 1000003 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
1100004 <span class="preprocessor">#include &lt;cmath&gt;</span>
1200005
1300006 <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);
1400007
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>()
1600012 {
1700013 FILE *fp = 0;
1800014 <span class="keywordtype">int</span> start = 0; <span class="comment">// Start index of subarray of sample array</span>
1900015 <span class="keywordtype">int</span> N = 128; <span class="comment">// Number of samples </span>
2000016 <span class="keywordtype">char</span> fileName[100]; <span class="comment">// Name of file containing Peakfinder vectors</span>
2100017 <span class="keywordtype">double</span> amplitude; <span class="comment">// Amplitude/energy in ADC levels</span>
2200018 <span class="keywordtype">double</span> t0; <span class="comment">// timedelay in nanoseconds </span>
2300019
2400020 <span class="keywordtype">double</span> tau = 2; <span class="comment">// risetime in microseconds</span>
2500021 <span class="keywordtype">double</span> fs = 20; <span class="comment">// sample frequency in Megahertz</span>
2600022 <span class="keywordtype">double</span> timeVector[N]; <span class="comment">// Peakfinder vector for reconstruction of time</span>
2700023 <span class="keywordtype">double</span> amplitudeVector[N]; <span class="comment">// Peakfinder vector for reconstruction of energy</span>
2800024 <span class="keywordtype">double</span> aSystError;
2900025 <span class="keywordtype">double</span> tSystError;
3000026
3100027 <span class="keywordtype">int</span> ts = (int)(1000/fs);
3200028 printf(<span class="stringliteral">"\nts=%d\n"</span>, ts);
3300029
3400030 printf(<span class="stringliteral">"type amplitude in ADC levels (0-1023):"</span>);
3500031 scanf(<span class="stringliteral">"%lf"</span>, &amp;amplitude);
3600032 printf(<span class="stringliteral">"type timedelay in nanoseconds (0-%d):"</span>, ts);
3700033 scanf(<span class="stringliteral">"%lf"</span>, &amp;t0);
3800034
3900035 <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 4000036 <span class="keywordtype">double</span> *data = pulseGenPtr-&gt;<a class="code" href="classAliHLTPHOSPulseGenerator.html#a9">GetPulse</a>();
8562a9e6 4100037
4200038 <a class="code" href="PeakFinderTest_8cxx.html#a0">setFileName</a>(fileName, start, N, tau, fs);
4300039 fp = fopen(fileName,<span class="stringliteral">"r"</span>);
4400040
4500041 <span class="keywordflow">if</span>(fp == 0)
4600042 {
4700043 printf(<span class="stringliteral">"\nFile does not exist\n"</span>);
4800044 }
4900045 <span class="keywordflow">else</span>
5000046 {
5100047 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i &lt; N; i++)
5200048 {
5300049 fscanf(fp, <span class="stringliteral">"%lf"</span>, &amp;amplitudeVector[i]);
5400050 }
5500051
5600052 fscanf(fp, <span class="stringliteral">"\n"</span>);
5700053
5800054 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i &lt; N; i++)
5900055 {
6000056 fscanf(fp, <span class="stringliteral">"%lf"</span>, &amp;timeVector[i]);
6100057 }
6200058
6300059 fscanf(fp, <span class="stringliteral">"%lf"</span>, &amp;aSystError);
6400060 fscanf(fp, <span class="stringliteral">"%lf"</span>, &amp;tSystError);
6500061 printf(<span class="stringliteral">"\nPeakfinder vectors loaded from %s\n"</span>, fileName);
6600062 }
6700063
6800064
6900065 tSystError = tSystError*pow(10, 9); <span class="comment">//to give systematic error of timing in nanoseconds</span>
7000066 aSystError = aSystError*100; <span class="comment">//to give systematic error of amplitude in percent</span>
7100067
7200068
7300069 <span class="comment">// AliHLTPHOSAnalyzerPeakFinder *fitPtr= new AliHLTPHOSAnalyzerPeakFinder(data, fs); </span>
eace7fcd 7400070 <a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html">AliHLTPHOSRawAnalyzerPeakFinder</a> *fitPtr= <span class="keyword">new</span> <a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html">AliHLTPHOSRawAnalyzerPeakFinder</a>();
8562a9e6 7500071
9a49f543 7600072 fitPtr-&gt;<a class="code" href="classAliHLTPHOSRawAnalyzer.html#a10">SetData</a>(data);
7700073 fitPtr-&gt;<a class="code" href="classAliHLTPHOSRawAnalyzer.html#a11">SetSampleFreq</a>(fs);
7800074 fitPtr-&gt;<a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html#a4">SetTVector</a>(timeVector, 100);
7900075 fitPtr-&gt;<a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html#a5">SetAVector</a>(amplitudeVector, 100);
8562a9e6 8000076 <span class="comment">// fitPtr-&gt;Set</span>
9a49f543 8100077 fitPtr-&gt;<a class="code" href="classAliHLTPHOSRawAnalyzerPeakFinder.html#a6">Evaluate</a>(start, N);
8562a9e6 8200078
8300079 <span class="keywordtype">double</span> energy;
8400080 <span class="keywordtype">double</span> time;
8500081
9a49f543 8600082 time = fitPtr-&gt;<a class="code" href="classAliHLTPHOSRawAnalyzer.html#a8">GetTiming</a>();
8700083 energy = fitPtr-&gt;<a class="code" href="classAliHLTPHOSRawAnalyzer.html#a9">GetEnergy</a>();
8562a9e6 8800084
8900085 printf(<span class="stringliteral">"\nReal amplitude \t\t= %lf ADC counts \nReconstructed amplitude\t= %lf ADC counts\n"</span>, amplitude, energy);
9000086 printf(<span class="stringliteral">"\nReal time \t\t= %lf nanoseconds \nReconstructed time\t= %lf nanoseconds\n"</span>, t0, time);
9100087 printf(<span class="stringliteral">"\n\nMaximum systematic error in amplitude \t= %lf %%"</span>, aSystError);
9200088 printf(<span class="stringliteral">"\nMaximum systematic error for timing \t= %lf nanoseconds\n\n"</span>, tSystError);
9300089 <span class="keywordflow">return</span> 0;
9400090 }
9500091
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)
9700093 {
9800094 sprintf(fName, <span class="stringliteral">"PFVectors/start%dN%dtau%.ffs%.f.txt"</span>, start, N, tau, fs);
9900095 <span class="comment">// printf("\nfilename: %s\n", fName);</span>
10000096 }
10100097
9a49f543 102</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri May 4 04:49:52 2007 for AliHLTPHOS by&nbsp;
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>