]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigitCalibrator.cxx
Adding StatusMap data member (Laurent)
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitCalibrator.cxx
CommitLineData
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
d99769c3 20#include "AliLog.h"
21#include "AliMUONCalibrationData.h"
22#include "AliMUONConstants.h"
23#include "AliMUONData.h"
24#include "AliMUONDigit.h"
c795d086 25#include "AliMUONVCalibParam.h"
d99769c3 26#include "TClonesArray.h"
27
7945aae7 28/// \class AliMUONDigitCalibrator
1171bb0a 29/// Class used to calibrate digits (either real or simulated ones).
30///
31/// The calibration consists of subtracting the pedestal
32/// and multiplying by a gain, so that
33/// Signal = (ADC-pedestal)*gain
34///
35/// Please note also that for the moment, if a digit lies on a dead channel
36/// we remove this digit from the list of digits.
37/// FIXME: this has to be revisited. By using the AliMUONDigit::fFlags we
38/// should in principle flag a digit as bad w/o removing it, but this
39/// then requires some changes in the cluster finder to deal with this extra
40/// information correctly (e.g. to set a quality for the cluster if it contains
41/// bad digits).
42///
7945aae7 43/// \author Laurent Aphecetche
44
1171bb0a 45
7945aae7 46/// \cond CLASSIMP
d99769c3 47ClassImp(AliMUONDigitCalibrator)
7945aae7 48/// \endcond
d99769c3 49
50//_____________________________________________________________________________
51AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
c795d086 52 AliMUONCalibrationData* calib)
d99769c3 53: TTask("AliMUONDigitCalibrator","Subtract pedestal from digit charge"),
54 fData(muonData),
55 fCalibrationData(calib)
56{
7945aae7 57 /// ctor. This class need the muonData to get access to the digit,
58 /// and the calibrationData to get access to calibration parameters.
d99769c3 59}
60
61//_____________________________________________________________________________
62AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
63{
7945aae7 64 /// empty dtor.
d99769c3 65}
66
67//_____________________________________________________________________________
68void
69AliMUONDigitCalibrator::Exec(Option_t*)
70{
7945aae7 71 /// Main method.
72 /// We loop on tracking chambers (i.e. we do nothing for trigger)
73 /// and for each digit in that chamber, we calibrate it :
74 /// a) if the corresponding channel is known to be bad, we set the signal to 0
75 /// (so that digit can be suppressed later on)
76 /// b) we then apply pedestal and gain corrections.
c795d086 77
d99769c3 78 for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
79 {
80 TClonesArray* digitArray = fData->Digits(ch);
81 Int_t nDigits = digitArray->GetEntriesFast();
82 for ( Int_t d = 0; d < nDigits; ++d )
83 {
84 AliMUONDigit* digit =
85 static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
86
c795d086 87 // Very first check is whether this channel is known to be bad,
88 // in which case we set the signal to zero.
89 AliMUONVCalibParam* dead = static_cast<AliMUONVCalibParam*>
1171bb0a 90 (fCalibrationData->DeadChannels(digit->DetElemId(),digit->ManuId()));
c795d086 91 if ( dead && dead->ValueAsInt(digit->ManuChannel()) )
92 {
1171bb0a 93 AliWarning(Form("Removing dead channel detElemId %d manuId %d "
c795d086 94 "manuChannel %d",digit->DetElemId(),digit->ManuId(),
95 digit->ManuChannel()));
96 digit->SetSignal(0);
97 continue;
98 }
99
100 // If the channel is good, go on with the calibration itself.
101
102 AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
1171bb0a 103 (fCalibrationData->Pedestals(digit->DetElemId(),digit->ManuId()));
c795d086 104
105 AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
1171bb0a 106 (fCalibrationData->Gains(digit->DetElemId(),digit->ManuId()));
d99769c3 107
d99769c3 108 if (!pedestal)
109 {
c795d086 110 AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
111 digit->DetElemId(),digit->ManuId()));
d99769c3 112
113 }
114 if (!gain)
115 {
c795d086 116 AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
117 digit->DetElemId(),digit->ManuId()));
d99769c3 118 }
119
c795d086 120 Int_t manuChannel = digit->ManuChannel();
45dd3605 121 Float_t adc = digit->Signal();
c795d086 122 Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
123 if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) )
d99769c3 124 {
125 padc = 0.0;
126 }
c795d086 127 Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
45dd3605 128 digit->SetSignal(charge);
c795d086 129 Int_t saturation = gain->ValueAsInt(manuChannel,1);
45dd3605 130 if ( charge >= saturation )
c795d086 131 {
132 digit->Saturated(kTRUE);
133 }
d99769c3 134 }
135 }
136}