]>
Commit | Line | Data |
---|---|---|
d99769c3 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | #include "AliMUONDigitCalibrator.h" | |
19 | ||
861d6ce8 | 20 | #include "AliLog.h" |
d99769c3 | 21 | #include "AliMUONCalibrationData.h" |
fe6ed686 | 22 | #include "AliMUONLogger.h" |
d1c20d08 | 23 | #include "AliMUONPadStatusMaker.h" |
24 | #include "AliMUONPadStatusMapMaker.h" | |
c795d086 | 25 | #include "AliMUONVCalibParam.h" |
861d6ce8 | 26 | #include "AliMUONVDigit.h" |
27 | #include "AliMUONVDigitStore.h" | |
28 | #include "AliMUONVStore.h" | |
29 | #include "AliMpBusPatch.h" | |
de98fdc9 | 30 | #include "AliMpConstants.h" |
de98fdc9 | 31 | #include "AliMpDDLStore.h" |
861d6ce8 | 32 | #include "AliMpDEIterator.h" |
33 | #include "AliMpDetElement.h" | |
d99769c3 | 34 | |
3d1463c8 | 35 | //----------------------------------------------------------------------------- |
7945aae7 | 36 | /// \class AliMUONDigitCalibrator |
1171bb0a | 37 | /// Class used to calibrate digits (either real or simulated ones). |
38 | /// | |
39 | /// The calibration consists of subtracting the pedestal | |
40 | /// and multiplying by a gain, so that | |
41 | /// Signal = (ADC-pedestal)*gain | |
42 | /// | |
43 | /// Please note also that for the moment, if a digit lies on a dead channel | |
44 | /// we remove this digit from the list of digits. | |
45 | /// FIXME: this has to be revisited. By using the AliMUONDigit::fFlags we | |
46 | /// should in principle flag a digit as bad w/o removing it, but this | |
47 | /// then requires some changes in the cluster finder to deal with this extra | |
48 | /// information correctly (e.g. to set a quality for the cluster if it contains | |
49 | /// bad digits). | |
50 | /// | |
7945aae7 | 51 | /// \author Laurent Aphecetche |
3d1463c8 | 52 | //----------------------------------------------------------------------------- |
7945aae7 | 53 | |
1171bb0a | 54 | |
7945aae7 | 55 | /// \cond CLASSIMP |
d99769c3 | 56 | ClassImp(AliMUONDigitCalibrator) |
7945aae7 | 57 | /// \endcond |
d99769c3 | 58 | |
de98fdc9 | 59 | const Int_t AliMUONDigitCalibrator::fgkNoGain(0); |
60 | const Int_t AliMUONDigitCalibrator::fgkGainConstantCapa(1); | |
61 | const Int_t AliMUONDigitCalibrator::fgkGain(2); | |
62 | ||
d99769c3 | 63 | //_____________________________________________________________________________ |
de98fdc9 | 64 | AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONCalibrationData& calib, |
65 | const char* calibMode) | |
42825ed9 | 66 | : TObject(), |
3b6f7dce | 67 | fLogger(new AliMUONLogger(20000)), |
49e396d9 | 68 | fStatusMaker(0x0), |
69 | fStatusMapMaker(0x0), | |
70 | fPedestals(0x0), | |
de98fdc9 | 71 | fGains(0x0), |
72 | fApplyGains(0), | |
630711ed | 73 | fCapacitances(0x0) |
d99769c3 | 74 | { |
42825ed9 | 75 | /// ctor |
de98fdc9 | 76 | |
77 | TString cMode(calibMode); | |
78 | cMode.ToUpper(); | |
79 | ||
80 | if ( cMode == "NOGAIN" ) | |
81 | { | |
82 | fApplyGains = fgkNoGain; | |
83 | AliInfo("Will NOT apply gain correction"); | |
84 | } | |
3b6f7dce | 85 | else if ( cMode == "GAINCONSTANTCAPA" ) |
de98fdc9 | 86 | { |
87 | fApplyGains = fgkGainConstantCapa; | |
88 | AliInfo("Will apply gain correction, but with constant capacitance"); | |
89 | } | |
90 | else if ( cMode == "GAIN" ) | |
91 | { | |
92 | fApplyGains = fgkGain; | |
93 | AliInfo("Will apply gain correction, with measured capacitances"); | |
94 | } | |
95 | else | |
96 | { | |
97 | AliError(Form("Invalid calib mode = %s. Will use NOGAIN instead",calibMode)); | |
98 | fApplyGains = fgkNoGain; | |
99 | } | |
100 | ||
49e396d9 | 101 | fStatusMaker = new AliMUONPadStatusMaker(calib); |
102 | ||
103 | // this is here that we decide on our "goodness" policy, i.e. | |
104 | // what do we call an invalid pad (a pad maybe bad because its HV | |
105 | // was too low, or its pedestals too high, etc..) | |
106 | // FIXME: find a way not to hard-code the goodness policy (i.e. the limits) | |
107 | // here... | |
108 | fStatusMaker->SetHVSt12Limits(1300,1600); | |
109 | fStatusMaker->SetHVSt345Limits(1500,2000); | |
110 | fStatusMaker->SetPedMeanLimits(50,200); | |
111 | fStatusMaker->SetPedSigmaLimits(0.1,3); | |
112 | ||
113 | Int_t mask(0x8080); | |
114 | //FIXME: kind of fake one for the moment, we consider dead only | |
115 | // if ped and/or hv value missing. | |
116 | //WARNING : getting this mask wrong is a very effective way of getting | |
117 | //no digits at all out of this class ;-) | |
118 | ||
119 | Bool_t deferredInitialization = kTRUE; | |
120 | ||
121 | fStatusMapMaker = new AliMUONPadStatusMapMaker(*fStatusMaker,mask,deferredInitialization); | |
122 | ||
123 | fPedestals = calib.Pedestals(); | |
de98fdc9 | 124 | |
125 | fGains = calib.Gains(); // we get gains whatever the calibMode is, in order | |
126 | // to get the saturation value... | |
127 | ||
128 | if ( fApplyGains == fgkGain ) | |
129 | { | |
130 | fCapacitances = calib.Capacitances(); | |
131 | } | |
d99769c3 | 132 | } |
133 | ||
134 | //_____________________________________________________________________________ | |
135 | AliMUONDigitCalibrator::~AliMUONDigitCalibrator() | |
136 | { | |
d1c20d08 | 137 | /// dtor. |
49e396d9 | 138 | delete fStatusMaker; |
139 | delete fStatusMapMaker; | |
fe6ed686 | 140 | |
141 | AliInfo("Summary of messages:"); | |
142 | fLogger->Print(); | |
143 | ||
144 | delete fLogger; | |
d99769c3 | 145 | } |
146 | ||
147 | //_____________________________________________________________________________ | |
148 | void | |
42825ed9 | 149 | AliMUONDigitCalibrator::Calibrate(AliMUONVDigitStore& digitStore) |
d99769c3 | 150 | { |
42825ed9 | 151 | /// Calibrate the digits contained in digitStore |
152 | TIter next(digitStore.CreateTrackerIterator()); | |
153 | AliMUONVDigit* digit; | |
861d6ce8 | 154 | Int_t detElemId(-1); |
155 | Double_t nsigmas(3.0); | |
156 | ||
157 | AliDebug(1,Form("# of digits = %d",digitStore.GetSize())); | |
c795d086 | 158 | |
42825ed9 | 159 | while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) ) |
d99769c3 | 160 | { |
861d6ce8 | 161 | if ( digit->DetElemId() != detElemId ) |
162 | { | |
163 | // Find out occupancy of that DE | |
164 | detElemId = digit->DetElemId(); | |
630711ed | 165 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); |
166 | Double_t nchannels = de->NofChannels(); | |
861d6ce8 | 167 | Double_t occ = digitStore.GetSize(detElemId)/nchannels; |
168 | if ( occ > 0.05 ) | |
169 | { | |
170 | nsigmas = 10.0; // enlarge (a lot) sigma cut if occupancy is high | |
171 | // (which probably means zero suppression was not exactly OK). | |
172 | fLogger->Log(Form("Will use %5.0f*sigma cut for DE %04d " | |
173 | "due to high occupancy",nsigmas,detElemId)); | |
174 | } | |
175 | else | |
176 | { | |
177 | nsigmas = 3.0; | |
178 | } | |
179 | } | |
180 | ||
181 | CalibrateDigit(*digit,nsigmas); | |
42825ed9 | 182 | } |
183 | } | |
184 | ||
185 | //_____________________________________________________________________________ | |
186 | void | |
861d6ce8 | 187 | AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit, Double_t nsigmas) |
42825ed9 | 188 | { |
189 | /// Calibrate one digit | |
190 | ||
cf27231a | 191 | if ( digit.IsCalibrated() ) |
192 | { | |
193 | fLogger->Log("ERROR : trying to calibrate a digit twice"); | |
194 | return; | |
195 | } | |
196 | ||
49e396d9 | 197 | Int_t statusMap = fStatusMapMaker->StatusMap(digit.DetElemId(), |
198 | digit.ManuId(), | |
199 | digit.ManuChannel()); | |
200 | ||
42825ed9 | 201 | digit.SetStatusMap(statusMap); |
202 | digit.Calibrated(kTRUE); | |
49e396d9 | 203 | |
42825ed9 | 204 | if ( ( statusMap & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0 ) |
205 | { | |
206 | // pad itself is bad (not testing its neighbours at this stage) | |
207 | digit.SetCharge(0); | |
208 | fLogger->Log(Form("%s:%d:Channel detElemId %d manuId %d " | |
209 | "manuChannel %d is bad %x",__FILE__,__LINE__, | |
210 | digit.DetElemId(),digit.ManuId(), | |
211 | digit.ManuChannel(),digit.StatusMap())); | |
212 | } | |
213 | else | |
214 | { | |
215 | // If the channel is good, go on with the calibration itself. | |
216 | ||
217 | AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*> | |
49e396d9 | 218 | (fPedestals->FindObject(digit.DetElemId(),digit.ManuId())); |
3b6f7dce | 219 | |
42825ed9 | 220 | if (!pedestal) |
d99769c3 | 221 | { |
3b6f7dce | 222 | // no pedestal -> no charge |
223 | digit.SetCharge(0); | |
c795d086 | 224 | |
3b6f7dce | 225 | fLogger->Log(Form("Got a null pedestal object for DE,manu=%d,%d", |
226 | digit.DetElemId(),digit.ManuId())); | |
227 | return; | |
42825ed9 | 228 | } |
3b6f7dce | 229 | |
230 | ||
de98fdc9 | 231 | AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*> |
232 | (fGains->FindObject(digit.DetElemId(),digit.ManuId())); | |
233 | ||
42825ed9 | 234 | if (!gain) |
235 | { | |
3b6f7dce | 236 | if ( fApplyGains != fgkNoGain ) |
237 | { | |
238 | // no gain -> no charge | |
239 | digit.SetCharge(0); | |
240 | ||
241 | fLogger->Log(Form("Got a null gain object for DE,manu=%d,%d", | |
242 | digit.DetElemId(),digit.ManuId())); | |
243 | return; | |
244 | } | |
42825ed9 | 245 | } |
3b6f7dce | 246 | |
42825ed9 | 247 | Int_t manuChannel = digit.ManuChannel(); |
248 | Float_t adc = digit.ADC(); | |
249 | Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0); | |
cf27231a | 250 | Float_t charge(0); |
de98fdc9 | 251 | Float_t capa(1.0); |
252 | ||
253 | if ( fApplyGains == fgkGainConstantCapa ) | |
254 | { | |
255 | capa = 0.2; // pF | |
256 | } | |
257 | else if ( fApplyGains == fgkGain ) | |
258 | { | |
259 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(digit.DetElemId()); | |
260 | ||
261 | Int_t serialNumber = de->GetManuSerialFromId(digit.ManuId()); | |
262 | ||
263 | AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fCapacitances->FindObject(serialNumber)); | |
264 | ||
3b6f7dce | 265 | if ( param ) |
266 | { | |
267 | capa = param->ValueAsFloat(digit.ManuChannel()); | |
268 | } | |
269 | else | |
270 | { | |
271 | fLogger->Log(Form("No capa found for serialNumber=%d",serialNumber)); | |
272 | capa = 0.0; | |
273 | } | |
de98fdc9 | 274 | } |
275 | ||
861d6ce8 | 276 | if ( padc > nsigmas*pedestal->ValueAsFloat(manuChannel,1) ) |
42825ed9 | 277 | { |
de98fdc9 | 278 | if ( fApplyGains != fgkNoGain ) |
cf27231a | 279 | { |
de98fdc9 | 280 | Float_t a0 = gain->ValueAsFloat(manuChannel,0); |
281 | Float_t a1 = gain->ValueAsFloat(manuChannel,1); | |
282 | Int_t thres = gain->ValueAsInt(manuChannel,2); | |
283 | if ( padc < thres ) | |
284 | { | |
285 | charge = a0*padc; | |
286 | } | |
287 | else | |
288 | { | |
289 | charge = a0*thres + a0*(padc-thres) + a1*(padc-thres)*(padc-thres); | |
290 | } | |
cf27231a | 291 | } |
292 | else | |
293 | { | |
de98fdc9 | 294 | charge = padc; |
cf27231a | 295 | } |
42825ed9 | 296 | } |
3b6f7dce | 297 | |
de98fdc9 | 298 | charge *= capa; |
42825ed9 | 299 | digit.SetCharge(charge); |
3b6f7dce | 300 | |
301 | Int_t saturation(3000); | |
302 | ||
303 | if ( gain ) | |
304 | { | |
305 | saturation = gain->ValueAsInt(manuChannel,4); | |
306 | } | |
307 | ||
de98fdc9 | 308 | if ( padc >= saturation ) |
42825ed9 | 309 | { |
310 | digit.Saturated(kTRUE); | |
d99769c3 | 311 | } |
312 | } | |
313 | } |