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"
21 #include "AliMUONCalibrationData.h"
22 #include "AliMUONConstants.h"
23 #include "AliMUONData.h"
24 #include "AliMUONDigit.h"
25 #include "AliMUONPadStatusMaker.h"
26 #include "AliMUONPadStatusMapMaker.h"
27 #include "AliMUONV2DStore.h"
28 #include "AliMUONVCalibParam.h"
29 #include "TClonesArray.h"
31 /// \class AliMUONDigitCalibrator
32 /// Class used to calibrate digits (either real or simulated ones).
34 /// The calibration consists of subtracting the pedestal
35 /// and multiplying by a gain, so that
36 /// Signal = (ADC-pedestal)*gain
38 /// Please note also that for the moment, if a digit lies on a dead channel
39 /// we remove this digit from the list of digits.
40 /// FIXME: this has to be revisited. By using the AliMUONDigit::fFlags we
41 /// should in principle flag a digit as bad w/o removing it, but this
42 /// then requires some changes in the cluster finder to deal with this extra
43 /// information correctly (e.g. to set a quality for the cluster if it contains
46 /// \author Laurent Aphecetche
50 ClassImp(AliMUONDigitCalibrator)
53 //_____________________________________________________________________________
54 AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
55 AliMUONCalibrationData* calib,
56 Bool_t createAndUseStatusMap)
57 : TTask("AliMUONDigitCalibrator","Raw digit calibration"),
59 fCalibrationData(calib),
62 /// ctor. This class needs the muonData to get access to the digit,
63 /// and the calibrationData to get access to calibration parameters.
67 if (createAndUseStatusMap)
69 AliMUONPadStatusMaker maker(*calib);
71 // this is here that we decide on our "goodness" policy, i.e.
72 // what do we call an invalid pad (a pad maybe bad because it's HV
73 // was too low, or its pedestals too high, etc..)
75 maker.SetHVSt12Limits(1300,1600);
76 maker.SetHVSt345Limits(1500,2000);
77 maker.SetPedMeanLimits(50,200);
78 maker.SetPedSigmaLimits(0.1,3);
80 // From this set of limits, compute the status of all tracker pads.
81 AliMUONV2DStore* status = maker.MakeStatus();
83 AliMUONPadStatusMapMaker mapMaker;
85 Int_t mask(0x8000000);
86 //FIXME: fake one (consider dead only if ped mean too high or hv switch off)
88 fStatusMap = mapMaker.MakePadStatusMap(*status,mask);
94 // make a fake (empty) status map
95 fStatusMap = AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap();
99 //_____________________________________________________________________________
100 AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
106 //_____________________________________________________________________________
108 AliMUONDigitCalibrator::Exec(Option_t*)
111 /// We loop on tracking chambers (i.e. we do nothing for trigger)
112 /// and for each digit in that chamber, we calibrate it :
113 /// a) we set its status map and if status is bad, set the signal to zero
114 /// b) we then apply pedestal and gain corrections.
116 for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
118 TClonesArray* digitArray = fData->Digits(ch);
119 Int_t nDigits = digitArray->GetEntriesFast();
120 for ( Int_t d = 0; d < nDigits; ++d )
122 AliMUONDigit* digit =
123 static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
125 AliMUONVCalibParam* deadmap = static_cast<AliMUONVCalibParam*>
126 (fStatusMap->Get(digit->DetElemId(),digit->ManuId()));
127 Int_t statusMap = deadmap->ValueAsInt(digit->ManuChannel());
128 digit->SetStatusMap(statusMap);
129 if ( ( statusMap & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0 ) // pad itself is bad (not testing its neighbours at this stage)
132 AliWarning(Form("Channel detElemId %d manuId %d "
133 "manuChannel %d is bad %x",digit->DetElemId(),digit->ManuId(),
134 digit->ManuChannel(),digit->StatusMap()));
138 // If the channel is good, go on with the calibration itself.
140 AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
141 (fCalibrationData->Pedestals(digit->DetElemId(),digit->ManuId()));
143 AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
144 (fCalibrationData->Gains(digit->DetElemId(),digit->ManuId()));
148 AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
149 digit->DetElemId(),digit->ManuId()));
154 AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
155 digit->DetElemId(),digit->ManuId()));
158 Int_t manuChannel = digit->ManuChannel();
159 Float_t adc = digit->Signal();
160 Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
161 if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) )
165 Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
166 digit->SetSignal(charge);
167 Int_t saturation = gain->ValueAsInt(manuChannel,1);
168 if ( charge >= saturation )
170 digit->Saturated(kTRUE);