1 #include "AliHLTPHOSPulseGenerator.h"
2 #include "AliHLTPHOSRawAnalyzerPeakFinder.h"
6 void setFileName(char *fName, int start, int length, double tau, double fs);
9 * Testing of the Class AliPHOSFitter
14 int start = 0; // Start index of subarray of sample array
15 int N = 128; // Number of samples
16 char fileName[100]; // Name of file containing Peakfinder vectors
17 double amplitude; // Amplitude/energy in ADC levels
18 double t0; // timedelay in nanoseconds
20 double tau = 2; // risetime in microseconds
21 double fs = 20; // sample frequency in Megahertz
22 double timeVector[N]; // Peakfinder vector for reconstruction of time
23 double amplitudeVector[N]; // Peakfinder vector for reconstruction of energy
27 int ts = (int)(1000/fs);
28 printf("\nts=%d\n", ts);
30 printf("type amplitude in ADC levels (0-1023):");
31 scanf("%lf", &litude);
32 printf("type timedelay in nanoseconds (0-%d):", ts);
35 AliHLTPHOSPulseGenerator *pulseGenPtr = new AliHLTPHOSPulseGenerator(amplitude, t0, N, tau, fs);
36 double *data = pulseGenPtr->GetPulse();
38 setFileName(fileName, start, N, tau, fs);
39 fp = fopen(fileName,"r");
43 printf("\nFile does not exist\n");
47 for(int i=0; i < N; i++)
49 fscanf(fp, "%lf", &litudeVector[i]);
54 for(int i=0; i < N; i++)
56 fscanf(fp, "%lf", &timeVector[i]);
59 fscanf(fp, "%lf", &aSystError);
60 fscanf(fp, "%lf", &tSystError);
61 printf("\nPeakfinder vectors loaded from %s\n", fileName);
65 tSystError = tSystError*pow(10, 9); //to give systematic error of timing in nanoseconds
66 aSystError = aSystError*100; //to give systematic error of amplitude in percent
69 // AliHLTPHOSAnalyzerPeakFinder *fitPtr= new AliHLTPHOSAnalyzerPeakFinder(data, fs);
70 AliHLTPHOSRawAnalyzerPeakFinder *fitPtr= new AliHLTPHOSRawAnalyzerPeakFinder();
72 fitPtr->SetData(data);
73 fitPtr->SetSampleFreq(fs);
74 fitPtr->SetTVector(timeVector, 100);
75 fitPtr->SetAVector(amplitudeVector, 100);
77 fitPtr->Evaluate(start, N);
82 time = fitPtr->GetTiming();
83 energy = fitPtr->GetEnergy();
85 printf("\nReal amplitude \t\t= %lf ADC counts \nReconstructed amplitude\t= %lf ADC counts\n", amplitude, energy);
86 printf("\nReal time \t\t= %lf nanoseconds \nReconstructed time\t= %lf nanoseconds\n", t0, time);
87 printf("\n\nMaximum systematic error in amplitude \t= %lf %%", aSystError);
88 printf("\nMaximum systematic error for timing \t= %lf nanoseconds\n\n", tSystError);
92 void setFileName(char *fName, int start, int N, double tau, double fs)
94 sprintf(fName, "PFVectors/start%dN%dtau%.ffs%.f.txt", start, N, tau, fs);
95 // printf("\nfilename: %s\n", fName);