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 "AliMUONLogger.h"
26 #include "AliMUONPadStatusMaker.h"
27 #include "AliMUONPadStatusMapMaker.h"
28 #include "AliMUONV2DStore.h"
29 #include "AliMUONVCalibParam.h"
30 #include "TClonesArray.h"
32 /// \class AliMUONDigitCalibrator
33 /// Class used to calibrate digits (either real or simulated ones).
35 /// The calibration consists of subtracting the pedestal
36 /// and multiplying by a gain, so that
37 /// Signal = (ADC-pedestal)*gain
39 /// Please note also that for the moment, if a digit lies on a dead channel
40 /// we remove this digit from the list of digits.
41 /// FIXME: this has to be revisited. By using the AliMUONDigit::fFlags we
42 /// should in principle flag a digit as bad w/o removing it, but this
43 /// then requires some changes in the cluster finder to deal with this extra
44 /// information correctly (e.g. to set a quality for the cluster if it contains
47 /// \author Laurent Aphecetche
51 ClassImp(AliMUONDigitCalibrator)
54 //_____________________________________________________________________________
55 AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
56 AliMUONCalibrationData* calib,
57 Bool_t createAndUseStatusMap)
58 : TTask("AliMUONDigitCalibrator","Raw digit calibration"),
60 fCalibrationData(calib),
62 fLogger(new AliMUONLogger(1000))
64 /// ctor. This class needs the muonData to get access to the digit,
65 /// and the calibrationData to get access to calibration parameters.
68 AliFatal("No calibration data defined");
71 if (createAndUseStatusMap)
73 AliMUONPadStatusMaker maker(*calib);
75 // this is here that we decide on our "goodness" policy, i.e.
76 // what do we call an invalid pad (a pad maybe bad because it's HV
77 // was too low, or its pedestals too high, etc..)
79 maker.SetHVSt12Limits(1300,1600);
80 maker.SetHVSt345Limits(1500,2000);
81 maker.SetPedMeanLimits(50,200);
82 maker.SetPedSigmaLimits(0.1,3);
84 // From this set of limits, compute the status of all tracker pads.
85 AliMUONV2DStore* status = maker.MakeStatus();
86 // we do not check that status is != 0x0, as this is supposed to be
87 // the responsability of the padStatusMaker.
89 AliMUONPadStatusMapMaker mapMaker;
92 //FIXME: kind of fake one for the moment, we consider dead only
93 // if ped and/or hv value missing.
94 //WARNING : getting this mask wrong is a very effective way of getting
95 //no digits at all out of this class ;-)
97 fStatusMap = mapMaker.MakePadStatusMap(*status,mask);
103 // make a fake (empty) status map
104 fStatusMap = AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap();
108 //_____________________________________________________________________________
109 AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
114 AliInfo("Summary of messages:");
120 //_____________________________________________________________________________
122 AliMUONDigitCalibrator::Exec(Option_t*)
125 /// We loop on tracking chambers (i.e. we do nothing for trigger)
126 /// and for each digit in that chamber, we calibrate it :
127 /// a) we set its status map and if status is bad, set the signal to zero
128 /// b) we then apply pedestal and gain corrections.
130 for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
132 TClonesArray* digitArray = fData->Digits(ch);
133 Int_t nDigits = digitArray->GetEntriesFast();
134 for ( Int_t d = 0; d < nDigits; ++d )
136 AliMUONDigit* digit =
137 static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
139 AliMUONVCalibParam* deadmap = static_cast<AliMUONVCalibParam*>
140 (fStatusMap->Get(digit->DetElemId(),digit->ManuId()));
141 Int_t statusMap = deadmap->ValueAsInt(digit->ManuChannel());
142 digit->SetStatusMap(statusMap);
143 if ( ( statusMap & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0 ) // pad itself is bad (not testing its neighbours at this stage)
146 fLogger->Log(Form("%s:%d:Channel detElemId %d manuId %d "
147 "manuChannel %d is bad %x",__FILE__,__LINE__,
148 digit->DetElemId(),digit->ManuId(),
149 digit->ManuChannel(),digit->StatusMap()));
153 // If the channel is good, go on with the calibration itself.
155 AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
156 (fCalibrationData->Pedestals(digit->DetElemId(),digit->ManuId()));
158 AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
159 (fCalibrationData->Gains(digit->DetElemId(),digit->ManuId()));
163 AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
164 digit->DetElemId(),digit->ManuId()));
169 AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
170 digit->DetElemId(),digit->ManuId()));
173 Int_t manuChannel = digit->ManuChannel();
174 Float_t adc = digit->Signal();
175 Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
176 if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) )
180 Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
181 digit->SetSignal(charge);
182 Int_t saturation = gain->ValueAsInt(manuChannel,1);
183 if ( charge >= saturation )
185 digit->Saturated(kTRUE);