]>
Commit | Line | Data |
---|---|---|
d655d7dd | 1 | /************************************************************************** |
2 | * This file is property of and copyright by * | |
3 | * the Relativistic Heavy Ion Group (RHIG), Yale University, US, 2009 * | |
4 | * * | |
5 | * Primary Author: Per Thomas Hille <p.t.hille@fys.uio.no> * | |
6 | * * | |
7 | * Contributors are mentioned in the code where appropriate. * | |
8 | * Please report bugs to p.t.hille@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 | ||
20 | // Base class for extraction | |
21 | // of signal amplitude and peak position | |
22 | // From EMCAL Calorimeter RAW data (from the RCU) | |
23 | // Contains some utilities for preparing / selecting | |
24 | // Signals suitable for signal extraction | |
25 | // By derived classes | |
26 | ||
27 | #include "AliLog.h" | |
28 | #include "AliEMCALRawAnalyzer.h" | |
29 | #include "AliEMCALBunchInfo.h" | |
30 | #include "AliEMCALFitResults.h" | |
31 | #include <iostream> | |
32 | using namespace std; | |
33 | ||
34 | ||
35 | AliEMCALRawAnalyzer::AliEMCALRawAnalyzer() : TObject(), | |
36 | fMinTimeIndex(-1), | |
37 | fMaxTimeIndex(-1), | |
38 | fFitArrayCut(5), | |
39 | fAmpCut(4), | |
40 | fNsampleCut(5), | |
41 | fIsZerosupressed( false ), | |
42 | fVerbose( false ) | |
43 | { | |
44 | //Comment | |
45 | for(int i=0; i < MAXSAMPLES; i++ ) | |
46 | { | |
47 | fReversed[i] = 0; | |
48 | } | |
49 | } | |
50 | ||
51 | AliEMCALRawAnalyzer::~AliEMCALRawAnalyzer() | |
52 | { | |
53 | ||
54 | } | |
55 | ||
56 | ||
57 | void | |
58 | AliEMCALRawAnalyzer::SetTimeConstraint(const int min, const int max ) | |
59 | { | |
60 | //Require that the bin if the maximum ADC value is between min and max (timebin) | |
61 | if( ( min > max ) || min > MAXSAMPLES || max > MAXSAMPLES ) | |
62 | { | |
63 | AliWarning( Form( "Attempt to set Invalid time bin range (Min , Max) = (%d, %d), Ingored", min, max ) ); | |
64 | } | |
65 | else | |
66 | { | |
67 | fMinTimeIndex = min; | |
68 | fMaxTimeIndex = max; | |
69 | } | |
70 | } | |
71 | ||
72 | ||
73 | UShort_t | |
74 | AliEMCALRawAnalyzer::Max(const UShort_t *data, const int length ) const | |
75 | { | |
76 | //------------ | |
77 | UShort_t tmpmax = data[0]; | |
78 | ||
79 | for(int i=0; i < length; i++) | |
80 | { | |
81 | if( tmpmax < data[i] ) | |
82 | { | |
83 | tmpmax = data[i]; | |
84 | } | |
85 | } | |
86 | return tmpmax; | |
87 | } | |
88 | ||
89 | ||
90 | void | |
91 | AliEMCALRawAnalyzer::SelectSubarray( const Double_t *fData, const int length, const short maxindex, int *const first, int *const last ) const | |
92 | { | |
93 | //Selection of subset of data from one bunch that will be used for fitting or | |
94 | //Peak finding. Go to the left and right of index of the maximum time bin | |
95 | //Untile the ADC value is less that fFitArrayCut | |
96 | int tmpfirst = maxindex; | |
97 | int tmplast = maxindex; | |
98 | ||
99 | while(( tmpfirst ) > 0 && ( fData[tmpfirst] > fFitArrayCut )) | |
100 | { | |
101 | tmpfirst -- ; | |
102 | } | |
103 | ||
104 | while(( tmplast ) < length && ( fData [tmplast] > fFitArrayCut )) | |
105 | { | |
106 | tmplast ++; | |
107 | } | |
108 | ||
109 | *first = tmpfirst +1; | |
110 | *last = tmplast -1; | |
111 | } | |
112 | ||
113 | ||
114 | ||
115 | Float_t | |
116 | AliEMCALRawAnalyzer::ReverseAndSubtractPed( const AliEMCALBunchInfo *bunch, const UInt_t /*altrocfg1*/, const UInt_t /*altrocfg2*/, double *outarray ) const | |
117 | { | |
118 | //Time sample comes in reversed order, revers them back | |
119 | //Subtract the baseline based on content of altrocfg1 and altrocfg2. | |
120 | Int_t length = bunch->GetLength(); | |
121 | const UShort_t *sig = bunch->GetData(); | |
122 | ||
123 | double ped = 0; | |
124 | double tmp = 0; | |
125 | ||
126 | if( fIsZerosupressed == false ) | |
127 | { | |
128 | for(int i=0; i < 5; i++ ) | |
129 | { | |
130 | tmp += sig[i]; | |
131 | } | |
132 | } | |
133 | ped = tmp / 5; | |
134 | for( int i=0; i < length; i++ ) | |
135 | { | |
136 | outarray[i] = sig[length -i -1] - ped; | |
137 | } | |
138 | ||
139 | return ped; | |
140 | } | |
141 | ||
142 | ||
143 | short | |
144 | AliEMCALRawAnalyzer::Max( const AliEMCALBunchInfo *const bunch , int *const maxindex ) const | |
145 | { | |
146 | //comment | |
147 | short tmpmax = -1; | |
148 | int tmpindex = -1; | |
149 | const UShort_t *sig = bunch->GetData(); | |
150 | ||
151 | for(int i=0; i < bunch->GetLength(); i++ ) | |
152 | { | |
153 | if( sig[i] > tmpmax ) | |
154 | { | |
155 | tmpmax = sig[i]; | |
156 | tmpindex = i; | |
157 | } | |
158 | } | |
159 | ||
160 | if(maxindex != 0 ) | |
161 | { | |
162 | *maxindex = bunch->GetLength() -1 - tmpindex + bunch->GetStartBin(); | |
163 | } | |
164 | ||
165 | return tmpmax; | |
166 | } | |
167 | ||
168 | ||
169 | int | |
170 | AliEMCALRawAnalyzer::SelectBunch( const vector<AliEMCALBunchInfo> &bunchvector,short *const maxampbin, short *const maxamplitude ) const | |
171 | { | |
172 | //We select the bunch with the highest amplitude unless any time constraints is set | |
173 | short max = -1; | |
174 | short bunchindex = -1; | |
175 | short maxall = -1; | |
176 | int indx = -1; | |
177 | ||
178 | for(unsigned int i=0; i < bunchvector.size(); i++ ) | |
179 | { | |
180 | max = Max( &bunchvector.at(i), &indx ); | |
181 | if( IsInTimeRange( indx) ) | |
182 | { | |
183 | if( max > maxall ) | |
184 | { | |
185 | maxall = max; | |
186 | bunchindex = i; | |
187 | } | |
188 | } | |
189 | } | |
190 | ||
191 | *maxampbin = indx; | |
192 | *maxamplitude = max; | |
193 | return bunchindex; | |
194 | } | |
195 | ||
196 | ||
197 | bool | |
198 | AliEMCALRawAnalyzer::IsInTimeRange( const int maxindex ) const | |
199 | { | |
200 | // Ckeck if the index of the max ADC vaue is consistent with trigger. | |
201 | if( ( fMinTimeIndex < 0 && fMaxTimeIndex < 0) ||fMaxTimeIndex < 0 ) | |
202 | { | |
203 | return true; | |
204 | } | |
205 | return ( maxindex < fMaxTimeIndex ) && ( maxindex > fMinTimeIndex ) ? true : false; | |
206 | } | |
207 | ||
208 | ||
209 | void | |
210 | AliEMCALRawAnalyzer::PrintBunches( const vector<AliEMCALBunchInfo> &bvctr ) const | |
211 | { | |
212 | //comment | |
213 | cout << __FILE__ << __LINE__<< "*************** Printing Bunches *******************" << endl; | |
214 | cout << __FILE__ << __LINE__<< "*** There are " << bvctr.size() << ", bunches" << endl; | |
215 | ||
216 | for(unsigned int i=0; i < bvctr.size() ; i++ ) | |
217 | { | |
218 | PrintBunch( bvctr.at(i) ); | |
219 | cout << " bunch = " << i << endl; | |
220 | } | |
221 | cout << __FILE__ << __LINE__<< "*************** Done ... *******************" << endl; | |
222 | } | |
223 | ||
224 | ||
225 | void | |
226 | AliEMCALRawAnalyzer::PrintBunch( const AliEMCALBunchInfo &bunch ) const | |
227 | { | |
228 | //comment | |
229 | cout << __FILE__ << ":" << __LINE__ << endl; | |
230 | cout << __FILE__ << __LINE__ << ", startimebin = " << bunch.GetStartBin() << ", length =" << bunch.GetLength() << endl; | |
231 | const UShort_t *sig = bunch.GetData(); | |
232 | ||
233 | for ( Int_t j = 0; j < bunch.GetLength(); j++) | |
234 | { | |
235 | printf("%d\t", sig[j] ); | |
236 | } | |
237 | cout << endl; | |
238 | } | |
239 | ||
240 |