]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzerPeakFinder.cxx
f7e20a155af0da32f06d89cec182f853afdd8d35
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerPeakFinder.cxx
1 /**************************************************************************
2  * This file is property of and copyright by the Experimental Nuclear     *
3  * Physics Group, Dep. of Physics                                         *
4  * University of Oslo, Norway, 2007                                       *
5  *                                                                        * 
6  * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
7  * Contributors are mentioned in the code where appropriate.              *
8  * Please report bugs to perthi@fys.uio.no                                * 
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 #include "AliHLTPHOSRawAnalyzerPeakFinder.h"
20 #include <iostream>
21 #include <cmath>
22
23 using std::cout;
24 using std::endl;
25
26 ClassImp(AliHLTPHOSRawAnalyzerPeakFinder) 
27
28
29 AliHLTPHOSRawAnalyzerPeakFinder::AliHLTPHOSRawAnalyzerPeakFinder(const AliHLTPHOSRawAnalyzerPeakFinder&):AliHLTPHOSRawAnalyzer() , fTVectorPtr(0), fAVectorPtr(0), fTVectorSize(0), fAVectorSize(0)
30 {
31
32
33 }
34
35
36 /**
37  * The AliHLTPHOSPeakfinder class is the class for extracting the basic signal parameters
38  * "timing" and "energy" from the PHOS raw data. Physical data will for a given readout channel be
39  * a sequense of ADC digitized 10 bit integer values, however for performance reasons all values used in
40  * calculation is of type double.
41  **/
42 AliHLTPHOSRawAnalyzerPeakFinder::AliHLTPHOSRawAnalyzerPeakFinder():AliHLTPHOSRawAnalyzer(), fTVectorPtr(0), fAVectorPtr(0), fTVectorSize(0), fAVectorSize(0)
43 {
44   //  cout <<"PeakFinder:You cannot invoke the Fitter without arguments"<<endl;;
45 }
46
47
48
49 AliHLTPHOSRawAnalyzerPeakFinder::~AliHLTPHOSRawAnalyzerPeakFinder()
50 {
51
52 } //end AliHLTPHOSRawAnalyzerPeakFinder
53
54 void 
55 AliHLTPHOSRawAnalyzerPeakFinder::SetTVector(Double_t *tVec, Int_t size)
56 {
57   fTVectorSize = size;
58
59   if(fTVectorPtr != 0)
60     {
61       delete fTVectorPtr;
62     }
63   
64   fTVectorPtr = new Double_t[size];
65
66   for(int i=0; i< size; i++)
67     {
68       fTVectorPtr[i] = tVec[i];
69     }
70 }
71
72
73 void
74 AliHLTPHOSRawAnalyzerPeakFinder::SetAVector(Double_t *aVec, Int_t size)
75 {
76     
77   fAVectorSize = size;
78
79   if(fAVectorPtr != 0)
80     {
81       delete fAVectorPtr;
82     }
83   
84   fAVectorPtr = new Double_t[size];
85
86   for(int i=0; i< size; i++)
87     {
88       fAVectorPtr[i] = aVec[i];
89     }
90 }
91
92 /**
93 * Extraction of timing and energy using the Peakfinde Algorithm.
94 * The. The parameters "start" and "length" defines a sub array  of the data array
95 * that will be used for the the fit. If start+length must not exeed the total length
96 * of the Data array. "start" must be chosen as close as possible to t0.
97 * The baseline must also be subtracted.
98 * The length of "tVector" and "aVector" mus be equal to length.
99 * "index + length" must not exeed the length of the data array set in the constructor.
100 * @param start the start index of the subarray of the data array. 
101 * @param length the number of samples to use starting from index 
102 * @param tVector the peakfinder vector for timing
103 * @param aVector the peakfinder vector for amplitude (energy)
104 **/
105 void 
106 AliHLTPHOSRawAnalyzerPeakFinder::Evaluate(int start, int length)
107 {
108   fDTof = 0;
109   fDAmpl = 0;
110   Int_t tmpLength;
111
112   if(fTVectorPtr == 0 || fAVectorPtr == 0)
113     {
114       //      printf("\nError: the peakfinder vectors are not specified, aborting !!!\n");
115     }
116   else
117     {
118       
119       if(length <  fTVectorSize)
120         {
121           tmpLength = length;
122         }
123       else
124         {
125           tmpLength = fTVectorSize;
126         }
127       
128       for(int i=0; i < tmpLength; i++)
129         {  
130           fDAmpl += fAVectorPtr[i]*fFloatDataPtr[i];    
131         }
132
133       for(int i=0; i < tmpLength; i++)
134         {   
135           fDTof += fTVectorPtr[i]*fFloatDataPtr[i]; 
136         }
137       
138       if(fDAmpl > 900)
139         {
140           Double_t tmpMax = GetMaxValue(fFloatDataPtr, tmpLength);
141           if(tmpMax == 1023)
142             {
143               fDAmpl = tmpMax;
144             }
145         }
146
147       fDTof = fDTof/fDAmpl;
148
149     }
150 } //end Evaluate
151
152
153
154