]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/latex/PeakFinderTest_8cxx.tex
New documentation
[u/mrichter/AliRoot.git] / HLT / PHOS / latex / PeakFinderTest_8cxx.tex
1 \section{Peak\-Finder\-Test.cxx File Reference}
2 \label{PeakFinderTest_8cxx}\index{PeakFinderTest.cxx@{PeakFinderTest.cxx}}
3
4
5 {\tt \#include \char`\"{}Ali\-HLTPHOSPulse\-Generator.h\char`\"{}}\par
6 {\tt \#include \char`\"{}Ali\-HLTPHOSRaw\-Analyzer\-Peak\-Finder.h\char`\"{}}\par
7 {\tt \#include $<$stdio.h$>$}\par
8 {\tt \#include $<$cmath$>$}\par
9 \subsection*{Functions}
10 \begin{CompactItemize}
11 \item 
12 void {\bf set\-File\-Name} (char $\ast$f\-Name, int start, int length, double tau, double fs)
13 \item 
14 int {\bf main} ()
15 \end{CompactItemize}
16
17
18 \subsection{Function Documentation}
19 \index{PeakFinderTest.cxx@{Peak\-Finder\-Test.cxx}!main@{main}}
20 \index{main@{main}!PeakFinderTest.cxx@{Peak\-Finder\-Test.cxx}}
21 \subsubsection{\setlength{\rightskip}{0pt plus 5cm}int main ()}\label{PeakFinderTest_8cxx_a1}
22
23
24 Testing of the Class Ali\-PHOSFitter 
25
26 Definition at line 11 of file Peak\-Finder\-Test.cxx.
27
28 References Ali\-HLTPHOSRaw\-Analyzer\-Peak\-Finder::Evaluate(), Ali\-HLTPHOSRaw\-Analyzer::Get\-Energy(), Ali\-HLTPHOSPulse\-Generator::Get\-Pulse(), Ali\-HLTPHOSRaw\-Analyzer::Get\-Timing(), Ali\-HLTPHOSRaw\-Analyzer\-Peak\-Finder::Set\-AVector(), Ali\-HLTPHOSRaw\-Analyzer::Set\-Data(), set\-File\-Name(), Ali\-HLTPHOSRaw\-Analyzer::Set\-Sample\-Freq(), and Ali\-HLTPHOSRaw\-Analyzer\-Peak\-Finder::Set\-TVector().
29
30 \footnotesize\begin{verbatim}12 {
31 13   FILE *fp = 0;
32 14   int start  = 0;               // Start index of subarray of sample array
33 15   int N = 128;                  // Number of samples 
34 16   char fileName[100];           // Name of file containing Peakfinder vectors
35 17   double amplitude;             // Amplitude/energy in ADC levels
36 18   double t0;                    // timedelay in nanoseconds  
37 19 
38 20   double tau = 2;               // risetime in microseconds
39 21   double fs = 20;               // sample frequency in Megahertz
40 22   double timeVector[N];         // Peakfinder vector for reconstruction of time
41 23   double amplitudeVector[N];    // Peakfinder vector for reconstruction of energy
42 24   double aSystError;
43 25   double tSystError;
44 26 
45 27   int ts = (int)(1000/fs);  
46 28   printf("\nts=%d\n", ts);
47 29 
48 30   printf("type amplitude in ADC levels (0-1023):");
49 31   scanf("%lf", &amplitude);
50 32   printf("type timedelay in nanoseconds (0-%d):", ts); 
51 33   scanf("%lf", &t0);
52 34 
53 35   AliHLTPHOSPulseGenerator *pulseGenPtr = new AliHLTPHOSPulseGenerator(amplitude, t0, N, tau, fs);
54 36   double *data = pulseGenPtr->GetPulse(); 
55 37 
56 38   setFileName(fileName, start, N, tau, fs);
57 39   fp = fopen(fileName,"r");
58 40 
59 41   if(fp == 0)
60 42     {
61 43       printf("\nFile does not exist\n");
62 44     }
63 45   else
64 46     {
65 47       for(int i=0; i < N; i++)
66 48         {
67 49           fscanf(fp, "%lf", &amplitudeVector[i]);
68 50         }
69 51 
70 52       fscanf(fp, "\n");
71 53 
72 54      for(int i=0; i < N; i++)
73 55         {
74 56           fscanf(fp, "%lf", &timeVector[i]);
75 57         }
76 58 
77 59      fscanf(fp, "%lf", &aSystError);
78 60      fscanf(fp, "%lf", &tSystError);
79 61      printf("\nPeakfinder vectors loaded from %s\n", fileName);
80 62     }
81 63 
82 64 
83 65    tSystError = tSystError*pow(10, 9); //to give systematic error of timing in nanoseconds
84 66    aSystError = aSystError*100;        //to give systematic error of amplitude in percent
85 67 
86 68 
87 69    //  AliHLTPHOSAnalyzerPeakFinder *fitPtr= new AliHLTPHOSAnalyzerPeakFinder(data, fs); 
88 70    AliHLTPHOSRawAnalyzerPeakFinder *fitPtr= new AliHLTPHOSRawAnalyzerPeakFinder(); 
89 71   
90 72    fitPtr->SetData(data);
91 73    fitPtr->SetSampleFreq(fs);
92 74    fitPtr->SetTVector(timeVector, 100);
93 75    fitPtr->SetAVector(amplitudeVector, 100);
94 76    //   fitPtr->Set
95 77    fitPtr->Evaluate(start, N);
96 78   
97 79   double energy;
98 80   double time;
99 81 
100 82   time    = fitPtr->GetTiming();
101 83   energy  = fitPtr->GetEnergy();
102 84 
103 85   printf("\nReal amplitude \t\t= %lf ADC counts \nReconstructed amplitude\t= %lf ADC counts\n", amplitude, energy);
104 86   printf("\nReal time \t\t= %lf nanoseconds \nReconstructed time\t= %lf nanoseconds\n", t0, time);
105 87   printf("\n\nMaximum systematic error in amplitude \t= %lf %%", aSystError);
106 88   printf("\nMaximum systematic error for timing \t= %lf nanoseconds\n\n", tSystError);
107 89   return 0;
108 90 }
109 \end{verbatim}\normalsize 
110
111
112 \index{PeakFinderTest.cxx@{Peak\-Finder\-Test.cxx}!setFileName@{setFileName}}
113 \index{setFileName@{setFileName}!PeakFinderTest.cxx@{Peak\-Finder\-Test.cxx}}
114 \subsubsection{\setlength{\rightskip}{0pt plus 5cm}void set\-File\-Name (char $\ast$ {\em f\-Name}, int {\em start}, int {\em length}, double {\em tau}, double {\em fs})}\label{PeakFinderTest_8cxx_a0}
115
116
117
118
119 Definition at line 92 of file Peak\-Finder\-Test.cxx.
120
121 Referenced by main().
122
123 \footnotesize\begin{verbatim}93 {
124 94   sprintf(fName, "PFVectors/start%dN%dtau%.ffs%.f.txt", start, N, tau, fs);
125 95   //  printf("\nfilename: %s\n", fName);
126 96 }
127 \end{verbatim}\normalsize 
128
129