#include "AliMUONDigitCalibrator.h"
-#include "AliCDBEntry.h"
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
#include "AliLog.h"
#include "AliMUONCalibrationData.h"
#include "AliMUONConstants.h"
#include "AliMUONData.h"
#include "AliMUONDigit.h"
+#include "AliMUONLogger.h"
+#include "AliMUONPadStatusMaker.h"
+#include "AliMUONPadStatusMapMaker.h"
+#include "AliMUONV2DStore.h"
#include "AliMUONVCalibParam.h"
-#include "AliMpDEManager.h"
-#include "AliMpPad.h"
-#include "AliMpPlaneType.h"
-#include "AliMpStationType.h"
-#include "AliMpVSegmentation.h"
-#include "Riostream.h"
#include "TClonesArray.h"
+/// \class AliMUONDigitCalibrator
+/// Class used to calibrate digits (either real or simulated ones).
+///
+/// The calibration consists of subtracting the pedestal
+/// and multiplying by a gain, so that
+/// Signal = (ADC-pedestal)*gain
+///
+/// Please note also that for the moment, if a digit lies on a dead channel
+/// we remove this digit from the list of digits.
+/// FIXME: this has to be revisited. By using the AliMUONDigit::fFlags we
+/// should in principle flag a digit as bad w/o removing it, but this
+/// then requires some changes in the cluster finder to deal with this extra
+/// information correctly (e.g. to set a quality for the cluster if it contains
+/// bad digits).
+///
+/// \author Laurent Aphecetche
+
+
+/// \cond CLASSIMP
ClassImp(AliMUONDigitCalibrator)
+/// \endcond
//_____________________________________________________________________________
AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
- AliMUONCalibrationData* calib)
-: TTask("AliMUONDigitCalibrator","Subtract pedestal from digit charge"),
+ AliMUONCalibrationData* calib,
+ Bool_t createAndUseStatusMap)
+: TTask("AliMUONDigitCalibrator","Raw digit calibration"),
fData(muonData),
- fCalibrationData(calib)
+ fCalibrationData(calib),
+ fStatusMap(0x0),
+ fLogger(new AliMUONLogger(1000))
{
- //
- // ctor. This class need the muonData to get access to the digit,
- // and the calibrationData to get access to calibration parameters.
- //
-}
-
-//______________________________________________________________________________
-AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONDigitCalibrator& right)
- : TTask(right)
-{
-/// Protected copy constructor (not implemented)
-
- AliFatal("Copy constructor not provided.");
+ /// ctor. This class needs the muonData to get access to the digit,
+ /// and the calibrationData to get access to calibration parameters.
+
+ if (!calib) {
+ AliFatal("No calibration data defined");
+ }
+
+ if (createAndUseStatusMap)
+ {
+ AliMUONPadStatusMaker maker(*calib);
+
+ // this is here that we decide on our "goodness" policy, i.e.
+ // what do we call an invalid pad (a pad maybe bad because its HV
+ // was too low, or its pedestals too high, etc..)
+ //
+ maker.SetHVSt12Limits(1300,1600);
+ maker.SetHVSt345Limits(1500,2000);
+ maker.SetPedMeanLimits(50,200);
+ maker.SetPedSigmaLimits(0.1,3);
+
+ // From this set of limits, compute the status of all tracker pads.
+ AliMUONV2DStore* status = maker.MakeStatus();
+ // we do not check that status is != 0x0, as this is supposed to be
+ // the responsability of the padStatusMaker.
+
+ AliMUONPadStatusMapMaker mapMaker(*calib);
+
+ Int_t mask(0x8080);
+ //FIXME: kind of fake one for the moment, we consider dead only
+ // if ped and/or hv value missing.
+ //WARNING : getting this mask wrong is a very effective way of getting
+ //no digits at all out of this class ;-)
+
+ fStatusMap = mapMaker.MakePadStatusMap(*status,mask);
+
+ delete status;
+ }
+ else
+ {
+ // make a fake (empty) status map
+ fStatusMap = AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap();
+ }
}
//_____________________________________________________________________________
AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
{
- //
- // empty dtor.
- //
-}
-
-//______________________________________________________________________________
-AliMUONDigitCalibrator&
-AliMUONDigitCalibrator::operator=(const AliMUONDigitCalibrator& right)
-{
-/// Protected assignement operator (not implemented)
-
- // check assignement to self
- if (this == &right) return *this;
+ /// dtor.
+ delete fStatusMap;
+
+ AliInfo("Summary of messages:");
+ fLogger->Print();
- AliFatal("Assignement operator not provided.");
-
- return *this;
-}
+ delete fLogger;
+}
//_____________________________________________________________________________
void
AliMUONDigitCalibrator::Exec(Option_t*)
{
- //
- // Main method.
- // We loop on tracking chambers (i.e. we do nothing for trigger)
- // and for each digit in that chamber, we calibrate it :
- // a) if the corresponding channel is known to be bad, we set the signal to 0
- // (so that digit can be suppressed later on)
- // b) we then apply pedestal and gain corrections.
+ /// Main method.
+ /// We loop on tracking chambers (i.e. we do nothing for trigger)
+ /// and for each digit in that chamber, we calibrate it :
+ /// a) we set its status map and if status is bad, set the signal to zero
+ /// b) we then apply pedestal and gain corrections.
for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
{
AliMUONDigit* digit =
static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
- // Very first check is whether this channel is known to be bad,
- // in which case we set the signal to zero.
- AliMUONVCalibParam* dead = static_cast<AliMUONVCalibParam*>
- (fCalibrationData->DeadChannel(digit->DetElemId(),digit->ManuId()));
- if ( dead && dead->ValueAsInt(digit->ManuChannel()) )
+ AliMUONVCalibParam* deadmap = static_cast<AliMUONVCalibParam*>
+ (fStatusMap->Get(digit->DetElemId(),digit->ManuId()));
+ Int_t statusMap = deadmap->ValueAsInt(digit->ManuChannel());
+ digit->SetStatusMap(statusMap);
+ if ( ( statusMap & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0 ) // pad itself is bad (not testing its neighbours at this stage)
{
- AliDebug(10,Form("Removing dead channel detElemId %d manuId %d "
- "manuChannel %d",digit->DetElemId(),digit->ManuId(),
- digit->ManuChannel()));
digit->SetSignal(0);
+ fLogger->Log(Form("%s:%d:Channel detElemId %d manuId %d "
+ "manuChannel %d is bad %x",__FILE__,__LINE__,
+ digit->DetElemId(),digit->ManuId(),
+ digit->ManuChannel(),digit->StatusMap()));
continue;
}
// If the channel is good, go on with the calibration itself.
AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
- (fCalibrationData->Pedestal(digit->DetElemId(),digit->ManuId()));
+ (fCalibrationData->Pedestals(digit->DetElemId(),digit->ManuId()));
AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
- (fCalibrationData->Gain(digit->DetElemId(),digit->ManuId()));
+ (fCalibrationData->Gains(digit->DetElemId(),digit->ManuId()));
if (!pedestal)
{
}
Int_t manuChannel = digit->ManuChannel();
- Int_t adc = digit->Signal();
+ Float_t adc = digit->Signal();
Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) )
{
padc = 0.0;
}
Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
- Int_t signal = TMath::Nint(charge);
- digit->SetSignal(signal);
+ digit->SetSignal(charge);
Int_t saturation = gain->ValueAsInt(manuChannel,1);
- if ( signal >= saturation )
+ if ( charge >= saturation )
{
digit->Saturated(kTRUE);
}