1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONDigitCalibrator.h"
20 #include "AliMUONCalibrationData.h"
21 #include "AliMUONVDigit.h"
22 #include "AliMUONVDigitStore.h"
23 #include "AliMUONLogger.h"
24 #include "AliMUONPadStatusMaker.h"
25 #include "AliMUONPadStatusMapMaker.h"
26 #include "AliMUONVStore.h"
27 #include "AliMUONVCalibParam.h"
28 #include "AliMpConstants.h"
29 #include "AliMpDetElement.h"
30 #include "AliMpDDLStore.h"
33 //-----------------------------------------------------------------------------
34 /// \class AliMUONDigitCalibrator
35 /// Class used to calibrate digits (either real or simulated ones).
37 /// The calibration consists of subtracting the pedestal
38 /// and multiplying by a gain, so that
39 /// Signal = (ADC-pedestal)*gain
41 /// Please note also that for the moment, if a digit lies on a dead channel
42 /// we remove this digit from the list of digits.
43 /// FIXME: this has to be revisited. By using the AliMUONDigit::fFlags we
44 /// should in principle flag a digit as bad w/o removing it, but this
45 /// then requires some changes in the cluster finder to deal with this extra
46 /// information correctly (e.g. to set a quality for the cluster if it contains
49 /// \author Laurent Aphecetche
50 //-----------------------------------------------------------------------------
54 ClassImp(AliMUONDigitCalibrator)
57 const Int_t AliMUONDigitCalibrator::fgkNoGain(0);
58 const Int_t AliMUONDigitCalibrator::fgkGainConstantCapa(1);
59 const Int_t AliMUONDigitCalibrator::fgkGain(2);
61 //_____________________________________________________________________________
62 AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONCalibrationData& calib,
63 const char* calibMode)
65 fLogger(new AliMUONLogger(1000)),
75 TString cMode(calibMode);
78 if ( cMode == "NOGAIN" )
80 fApplyGains = fgkNoGain;
81 AliInfo("Will NOT apply gain correction");
83 else if ( cMode = "GAINCONSTANTCAPA" )
85 fApplyGains = fgkGainConstantCapa;
86 AliInfo("Will apply gain correction, but with constant capacitance");
88 else if ( cMode == "GAIN" )
90 fApplyGains = fgkGain;
91 AliInfo("Will apply gain correction, with measured capacitances");
95 AliError(Form("Invalid calib mode = %s. Will use NOGAIN instead",calibMode));
96 fApplyGains = fgkNoGain;
99 fStatusMaker = new AliMUONPadStatusMaker(calib);
101 // this is here that we decide on our "goodness" policy, i.e.
102 // what do we call an invalid pad (a pad maybe bad because its HV
103 // was too low, or its pedestals too high, etc..)
104 // FIXME: find a way not to hard-code the goodness policy (i.e. the limits)
106 fStatusMaker->SetHVSt12Limits(1300,1600);
107 fStatusMaker->SetHVSt345Limits(1500,2000);
108 fStatusMaker->SetPedMeanLimits(50,200);
109 fStatusMaker->SetPedSigmaLimits(0.1,3);
112 //FIXME: kind of fake one for the moment, we consider dead only
113 // if ped and/or hv value missing.
114 //WARNING : getting this mask wrong is a very effective way of getting
115 //no digits at all out of this class ;-)
117 Bool_t deferredInitialization = kTRUE;
119 fStatusMapMaker = new AliMUONPadStatusMapMaker(*fStatusMaker,mask,deferredInitialization);
121 fPedestals = calib.Pedestals();
123 fGains = calib.Gains(); // we get gains whatever the calibMode is, in order
124 // to get the saturation value...
126 if ( fApplyGains == fgkGain )
128 fCapacitances = calib.Capacitances();
132 //_____________________________________________________________________________
133 AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
137 delete fStatusMapMaker;
139 AliInfo("Summary of messages:");
145 //_____________________________________________________________________________
147 AliMUONDigitCalibrator::Calibrate(AliMUONVDigitStore& digitStore)
149 /// Calibrate the digits contained in digitStore
150 TIter next(digitStore.CreateTrackerIterator());
151 AliMUONVDigit* digit;
153 while ( ( digit = static_cast<AliMUONVDigit*>(next() ) ) )
155 CalibrateDigit(*digit);
159 //_____________________________________________________________________________
161 AliMUONDigitCalibrator::CalibrateDigit(AliMUONVDigit& digit)
163 /// Calibrate one digit
165 if ( digit.IsCalibrated() )
167 fLogger->Log("ERROR : trying to calibrate a digit twice");
171 Int_t statusMap = fStatusMapMaker->StatusMap(digit.DetElemId(),
173 digit.ManuChannel());
175 digit.SetStatusMap(statusMap);
176 digit.Calibrated(kTRUE);
178 if ( ( statusMap & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0 )
180 // pad itself is bad (not testing its neighbours at this stage)
182 fLogger->Log(Form("%s:%d:Channel detElemId %d manuId %d "
183 "manuChannel %d is bad %x",__FILE__,__LINE__,
184 digit.DetElemId(),digit.ManuId(),
185 digit.ManuChannel(),digit.StatusMap()));
189 // If the channel is good, go on with the calibration itself.
191 AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
192 (fPedestals->FindObject(digit.DetElemId(),digit.ManuId()));
196 AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
197 digit.DetElemId(),digit.ManuId()));
201 AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
202 (fGains->FindObject(digit.DetElemId(),digit.ManuId()));
206 AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
207 digit.DetElemId(),digit.ManuId()));
210 Int_t manuChannel = digit.ManuChannel();
211 Float_t adc = digit.ADC();
212 Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
216 if ( fApplyGains == fgkGainConstantCapa )
220 else if ( fApplyGains == fgkGain )
222 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(digit.DetElemId());
224 Int_t serialNumber = de->GetManuSerialFromId(digit.ManuId());
226 AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fCapacitances->FindObject(serialNumber));
228 capa = param->ValueAsFloat(digit.ManuChannel());
231 if ( padc > 3.0*pedestal->ValueAsFloat(manuChannel,1) )
233 if ( fApplyGains != fgkNoGain )
235 Float_t a0 = gain->ValueAsFloat(manuChannel,0);
236 Float_t a1 = gain->ValueAsFloat(manuChannel,1);
237 Int_t thres = gain->ValueAsInt(manuChannel,2);
244 charge = a0*thres + a0*(padc-thres) + a1*(padc-thres)*(padc-thres);
253 digit.SetCharge(charge);
254 Int_t saturation = gain->ValueAsInt(manuChannel,4);
255 if ( padc >= saturation )
257 digit.Saturated(kTRUE);