]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzer.cxx
77619e888ccc567e50ab46570011d68faaf4ab10
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzer.cxx
1 /**************************************************************************
2  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
3  *                                                                        *
4  * Author: Per Thomas Hille for the ALICE HLT Project.                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 #include "AliHLTPHOSRawAnalyzer.h"
17 #include <iostream>
18
19 using std::cout;
20 using std::endl;
21
22
23
24 AliHLTPHOSRawAnalyzer:: AliHLTPHOSRawAnalyzer():fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999)
25 {
26   fFloatDataPtr = new double[1008];
27 }
28
29 AliHLTPHOSRawAnalyzer::~AliHLTPHOSRawAnalyzer()
30 {
31
32 }
33
34 AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(AliHLTPHOSRawAnalyzer const&):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999), fStartIndex(0)
35 {
36
37 }
38
39 /**
40 * Main constructor
41 * @param dataPtr Data array for wich a subarray will be taken to perform the fit
42 * @param fs the sampling frequency in entities of MHz. Needed in order to calculate physical time
43 **/
44 AliHLTPHOSRawAnalyzer::AliHLTPHOSRawAnalyzer(double *dtaPtr, double fs):fFloatDataPtr(0), fSampleFrequency(10), fTau(2), fDTof(99999), fDAmpl(99999), n(99999), fStartIndex(0)
45 {
46   fFloatDataPtr = dtaPtr;  
47   fSampleFrequency = fs;
48 } //end  
49
50
51 /**
52 * Attemps to level the basline to zero.
53 * The baseline will be calculated from the pretrigger samples and subtracted from the 
54 * data array. 
55 * If pretrigger samples are not present then the basline correction will be incorrect. 
56 * @param dataPtr array for wich to correct the basline 
57 * @param N the number of pretrigger samples used to calculate the baseline.
58 **/
59 void 
60 AliHLTPHOSRawAnalyzer::BaselineCorrection(double *dataPtr, int N)
61 {
62   fFloatDataPtr = dataPtr;  
63   n=N;
64   cout << "Baseline correction not yet implemeted" << endl;
65 } //end BaselineCorrection
66
67
68 /**
69 * Shifts the basline with the amount given by baselineValue
70 * If pretrigger samples are not present then the basline correction will be incorrect. 
71 * @param dataPtr array for wich to correct the basline 
72 * @param BaslineValue the basline value to subtract..
73 **/
74 void 
75 AliHLTPHOSRawAnalyzer::BaselineCorrection(double *dataPtr, double baselineValue)
76 {
77   fFloatDataPtr = dataPtr;   
78   printf("\nbaselineValue = %f\n", baselineValue);
79   cout << "Baseline correction not yet implemeted" << endl;
80 } //end BaslineCorrection
81
82
83 /**
84  * Gives the timing in entities of sample indexes
85  * Physical time is found by multiplying  with the sampling intervall (Ts).
86  **/
87 float
88 AliHLTPHOSRawAnalyzer::GetTiming()
89 {
90   return fDTof;
91 } //end GetTiming
92
93
94 /**
95  * Gives the time in entities of ADC channels (quantization levels).  
96  * Absolute enrgy is found by multiplying with offline calibration constants.
97  **/
98 float
99 AliHLTPHOSRawAnalyzer::GetEnergy()
100 {
101   return fDAmpl;
102 } //end GetEnergy
103
104
105 /**
106  * Set data array. Overrides data data array set in the constructor.
107  **/
108 void 
109 AliHLTPHOSRawAnalyzer::SetData(double *data)
110 {
111   //  double *dta;
112   //  dta = data;
113   fFloatDataPtr = data;
114   //  cout << "Set data not yet implemented" << endl;
115 }
116
117 void 
118 AliHLTPHOSRawAnalyzer::SetSampleFreq(double freq)
119 {
120   fSampleFrequency = freq;
121 }
122
123 int 
124 AliHLTPHOSRawAnalyzer::FindStartIndex(double treshold)
125 {
126   printf("\ntreshold = %f \n", treshold);
127   cout << "Find Start index not yet implemented" << endl;
128   return 0;
129 } //end FindStartIndex
130
131
132 /**
133  * This function applies only to the Chi and Least mean square fit. An initial guess is made
134  * based on the average of the first 5 samples and the first value exeeding this value.
135  **/
136 void 
137 AliHLTPHOSRawAnalyzer::MakeInitialGuess()
138 {
139   cout << "Make initial guess not yet implemeted" << endl;
140 }
141
142
143 /**
144  * This function applies only to the Chi and Least mean square fit. An initial guess is made
145  * based on the average of the first 5 samples and the first value exeeding threshold + this value.
146  * @param treshold The index of the first value above treshold is ntaken to be the first value.
147  **/
148 void 
149 AliHLTPHOSRawAnalyzer::MakeInitialGuess(int treshold)
150 {
151   printf("\ntreshold = %d\n", treshold);
152   cout << "Make initial guess not yet implemeted" << endl;  
153 }
154
155 void
156 AliHLTPHOSRawAnalyzer::SetStartIndex(int index)
157 {
158   fStartIndex = index;
159 }
160
161 void 
162 AliHLTPHOSRawAnalyzer::SetTVector(Double_t *tVector, Int_t size)
163 {
164   cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetTVector:  You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
165 }
166
167
168 void
169 AliHLTPHOSRawAnalyzer::SetAVector(Double_t *aVector, Int_t size)
170 {
171  cout <<"ERROR: AliHLTPHOSRawAnalyzer::SetAVector:  You cannot set the peakfindervector here, must be set in derived class peakfinder"<<endl;
172 }
173
174
175 Double_t
176 AliHLTPHOSRawAnalyzer::GetMaxValue(Double_t *dta, Int_t size)
177 {
178
179   Double_t tmpMax = 0;
180
181   for(int i = 0; i < size; i++)
182     {
183       if(dta[i] > tmpMax)
184         {
185           tmpMax = dta[i];
186         }
187
188     }
189   
190   return tmpMax;
191
192 }