]>
Commit | Line | Data |
---|---|---|
379c5c09 | 1 | /************************************************************************** |
2 | * Copyright(c) 2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line 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 | /* $Id: $ */ | |
17 | ||
18 | // This class extracts the signal parameters (energy, time, quality) | |
19 | // from ALTRO samples. Energy is in ADC counts, time is in time bin units. | |
20 | // A coarse algorithm takes the energy as the maximum | |
21 | // sample, time is the first sample index, and the quality is the number | |
22 | // of bunches in the signal. | |
23 | // | |
24 | // AliPHOSRawFitterv0 *fitterv0=new AliPHOSRawFitterv0(); | |
25 | // fitterv0->SetSamples(sig,sigStart,sigLength); | |
26 | // fitterv0->SetNBunches(nBunches); | |
27 | // fitterv0->SetChannelGeo(module,cellX,cellZ,caloFlag); | |
28 | // fitterv0->SetCalibData(fgCalibData) ; | |
29 | // fitterv0->Eval(); | |
30 | // Double_t amplitude = fitterv0.GetEnergy(); | |
31 | // Double_t time = fitterv0.GetTime(); | |
32 | // Bool_t isLowGain = fitterv0.GetCaloFlag()==0; | |
33 | ||
34 | // Author: Yuri Kharlov | |
35 | ||
36 | // --- ROOT system --- | |
37 | #include "TArrayI.h" | |
38 | #include "TMath.h" | |
39 | #include "TObject.h" | |
40 | ||
41 | // --- AliRoot header files --- | |
42 | #include "AliPHOSRawFitterv0.h" | |
43 | #include "AliPHOSCalibData.h" | |
44 | #include "AliLog.h" | |
45 | ||
46 | ClassImp(AliPHOSRawFitterv0) | |
47 | ||
48 | //----------------------------------------------------------------------------- | |
49 | AliPHOSRawFitterv0::AliPHOSRawFitterv0(): | |
50 | TObject(), | |
379c5c09 | 51 | fModule(0), |
52 | fCellX(0), | |
53 | fCellZ(0), | |
54 | fCaloFlag(0), | |
379c5c09 | 55 | fNBunches(0), |
56 | fPedSubtract(kFALSE), | |
57 | fEnergy(-111), | |
58 | fTime(-111), | |
59 | fQuality(0.), | |
60 | fPedestalRMS(0.), | |
61 | fAmpOffset(0), | |
62 | fAmpThreshold(0), | |
63 | fOverflow(kFALSE), | |
64 | fCalibData(0) | |
65 | { | |
66 | //Default constructor | |
67 | } | |
68 | ||
69 | //----------------------------------------------------------------------------- | |
70 | AliPHOSRawFitterv0::~AliPHOSRawFitterv0() | |
71 | { | |
72 | //Destructor | |
379c5c09 | 73 | } |
74 | ||
75 | //----------------------------------------------------------------------------- | |
76 | AliPHOSRawFitterv0::AliPHOSRawFitterv0(const AliPHOSRawFitterv0 &phosFitter ): | |
77 | TObject(), | |
379c5c09 | 78 | fModule (phosFitter.fModule), |
79 | fCellX (phosFitter.fCellX), | |
80 | fCellZ (phosFitter.fCellZ), | |
81 | fCaloFlag (phosFitter.fCaloFlag), | |
379c5c09 | 82 | fNBunches (phosFitter.fNBunches), |
83 | fPedSubtract (phosFitter.fPedSubtract), | |
84 | fEnergy (phosFitter.fEnergy), | |
85 | fTime (phosFitter.fTime), | |
86 | fQuality (phosFitter.fQuality), | |
87 | fPedestalRMS (phosFitter.fPedestalRMS), | |
88 | fAmpOffset (phosFitter.fAmpOffset), | |
89 | fAmpThreshold(phosFitter.fAmpThreshold), | |
90 | fOverflow (phosFitter.fOverflow), | |
91 | fCalibData (phosFitter.fCalibData) | |
92 | { | |
93 | //Copy constructor | |
94 | } | |
95 | ||
96 | //----------------------------------------------------------------------------- | |
97 | AliPHOSRawFitterv0& AliPHOSRawFitterv0::operator = (const AliPHOSRawFitterv0 &phosFitter) | |
98 | { | |
99 | //Assignment operator. | |
100 | ||
101 | if(this != &phosFitter) { | |
379c5c09 | 102 | fModule = phosFitter.fModule; |
103 | fCellX = phosFitter.fCellX; | |
104 | fCellZ = phosFitter.fCellZ; | |
105 | fCaloFlag = phosFitter.fCaloFlag; | |
379c5c09 | 106 | fNBunches = phosFitter.fNBunches; |
107 | fPedSubtract = phosFitter.fPedSubtract; | |
108 | fEnergy = phosFitter.fEnergy; | |
109 | fTime = phosFitter.fTime; | |
110 | fQuality = phosFitter.fQuality; | |
111 | fPedestalRMS = phosFitter.fPedestalRMS; | |
112 | fAmpOffset = phosFitter.fAmpOffset; | |
113 | fAmpThreshold = phosFitter.fAmpThreshold; | |
114 | fOverflow = phosFitter.fOverflow; | |
115 | fCalibData = phosFitter.fCalibData; | |
116 | } | |
117 | ||
118 | return *this; | |
119 | } | |
120 | ||
121 | //----------------------------------------------------------------------------- | |
122 | ||
123 | void AliPHOSRawFitterv0::SetSamples(const UShort_t *sig, Int_t sigStart, Int_t sigLength) | |
124 | { | |
125 | // Set the sample array, its start and length in time bin units | |
126 | ||
92236b27 | 127 | // fStart = sigStart; |
128 | // fLength = sigLength; | |
129 | // fSignal = sig; | |
130 | // fSignal = new UShort_t[fLength]; | |
131 | // for (Int_t i=0; i<fLength; i++) { | |
132 | // fSignal[i] = sig[i]; | |
133 | // } | |
379c5c09 | 134 | } |
135 | //----------------------------------------------------------------------------- | |
136 | ||
137 | void AliPHOSRawFitterv0::SetChannelGeo(const Int_t module, const Int_t cellX, | |
138 | const Int_t cellZ, const Int_t caloFlag) | |
139 | { | |
140 | // Set geometry address of the channel | |
141 | // (for a case if fitting parameters are different for different channels) | |
142 | ||
143 | fModule = module; | |
144 | fCellX = cellX; | |
145 | fCellZ = cellZ; | |
146 | fCaloFlag = caloFlag; | |
147 | } | |
148 | //----------------------------------------------------------------------------- | |
149 | ||
92236b27 | 150 | Bool_t AliPHOSRawFitterv0::Eval(const UShort_t *signal, Int_t sigStart, Int_t sigLength) |
379c5c09 | 151 | { |
152 | // Calculate signal parameters (energy, time, quality) from array of samples | |
153 | // Energy is a maximum sample minus pedestal 9 | |
154 | // Time is the first time bin | |
155 | // Signal overflows is there are at least 3 samples of the same amplitude above 900 | |
156 | ||
157 | fEnergy = 0; | |
158 | if (fNBunches > 1) { | |
159 | fQuality = 1000; | |
160 | return kTRUE; | |
161 | } | |
162 | ||
163 | const Float_t kBaseLine = 1.0; | |
164 | const Int_t kPreSamples = 10; | |
165 | ||
166 | Float_t pedMean = 0; | |
167 | Float_t pedRMS = 0; | |
168 | Int_t nPed = 0; | |
169 | UShort_t maxSample = 0; | |
170 | Int_t nMax = 0; | |
171 | ||
92236b27 | 172 | for (Int_t i=0; i<sigLength; i++) { |
379c5c09 | 173 | if (i<kPreSamples) { |
174 | nPed++; | |
92236b27 | 175 | pedMean += signal[i]; |
176 | pedRMS += signal[i]*signal[i] ; | |
379c5c09 | 177 | } |
92236b27 | 178 | if(signal[i] > maxSample) maxSample = signal[i]; |
179 | if(signal[i] == maxSample) nMax++; | |
a85e6165 | 180 | |
181 | if(fPedSubtract) { | |
92236b27 | 182 | if( (signal[i]-(Float_t)(pedMean/nPed)) >kBaseLine ) fTime = (Double_t)i; |
a85e6165 | 183 | } |
184 | else //ZS | |
92236b27 | 185 | if( (signal[i]-(Float_t)fAmpOffset ) >kBaseLine ) fTime = (Double_t)i; |
379c5c09 | 186 | } |
a85e6165 | 187 | |
379c5c09 | 188 | fEnergy = (Double_t)maxSample; |
189 | if (maxSample > 900 && nMax > 2) fOverflow = kTRUE; | |
190 | ||
191 | if (fPedSubtract) { | |
192 | if (nPed > 0) { | |
193 | fPedestalRMS=(pedRMS - pedMean*pedMean/nPed)/nPed ; | |
194 | if(fPedestalRMS > 0.) | |
195 | fPedestalRMS = TMath::Sqrt(fPedestalRMS) ; | |
196 | fEnergy -= (Double_t)(pedMean/nPed); // pedestal subtraction | |
197 | } | |
198 | else | |
199 | return kFALSE; | |
200 | } | |
201 | else { | |
202 | //take pedestals from DB | |
203 | Double_t pedestal = (Double_t) fAmpOffset ; | |
204 | if (fCalibData) { | |
205 | Float_t truePed = fCalibData->GetADCpedestalEmc(fModule, fCellZ, fCellX) ; | |
206 | Int_t altroSettings = fCalibData->GetAltroOffsetEmc(fModule, fCellZ, fCellX) ; | |
207 | pedestal += truePed - altroSettings ; | |
208 | } | |
209 | else{ | |
210 | AliWarning(Form("Can not read data from OCDB")) ; | |
211 | } | |
212 | fEnergy-=pedestal ; | |
213 | } | |
214 | if (fEnergy < kBaseLine) fEnergy = 0; | |
215 | ||
216 | return kTRUE; | |
217 | ||
218 | } |