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" |
fe6ed686 |
25 | #include "AliMUONLogger.h" |
d1c20d08 |
26 | #include "AliMUONPadStatusMaker.h" |
27 | #include "AliMUONPadStatusMapMaker.h" |
28 | #include "AliMUONV2DStore.h" |
c795d086 |
29 | #include "AliMUONVCalibParam.h" |
d99769c3 |
30 | #include "TClonesArray.h" |
31 | |
7945aae7 |
32 | /// \class AliMUONDigitCalibrator |
1171bb0a |
33 | /// Class used to calibrate digits (either real or simulated ones). |
34 | /// |
35 | /// The calibration consists of subtracting the pedestal |
36 | /// and multiplying by a gain, so that |
37 | /// Signal = (ADC-pedestal)*gain |
38 | /// |
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 |
45 | /// bad digits). |
46 | /// |
7945aae7 |
47 | /// \author Laurent Aphecetche |
48 | |
1171bb0a |
49 | |
7945aae7 |
50 | /// \cond CLASSIMP |
d99769c3 |
51 | ClassImp(AliMUONDigitCalibrator) |
7945aae7 |
52 | /// \endcond |
d99769c3 |
53 | |
54 | //_____________________________________________________________________________ |
55 | AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData, |
20356e33 |
56 | AliMUONCalibrationData* calib, |
57 | Bool_t createAndUseStatusMap) |
d1c20d08 |
58 | : TTask("AliMUONDigitCalibrator","Raw digit calibration"), |
d99769c3 |
59 | fData(muonData), |
d1c20d08 |
60 | fCalibrationData(calib), |
fe6ed686 |
61 | fStatusMap(0x0), |
62 | fLogger(new AliMUONLogger(1000)) |
d99769c3 |
63 | { |
d1c20d08 |
64 | /// ctor. This class needs the muonData to get access to the digit, |
7945aae7 |
65 | /// and the calibrationData to get access to calibration parameters. |
d1c20d08 |
66 | |
fe6ed686 |
67 | if (!calib) { |
68 | AliFatal("No calibration data defined"); |
69 | } |
d1c20d08 |
70 | |
20356e33 |
71 | if (createAndUseStatusMap) |
72 | { |
73 | AliMUONPadStatusMaker maker(*calib); |
74 | |
75 | // this is here that we decide on our "goodness" policy, i.e. |
92c444bc |
76 | // what do we call an invalid pad (a pad maybe bad because its HV |
20356e33 |
77 | // was too low, or its pedestals too high, etc..) |
78 | // |
79 | maker.SetHVSt12Limits(1300,1600); |
80 | maker.SetHVSt345Limits(1500,2000); |
81 | maker.SetPedMeanLimits(50,200); |
82 | maker.SetPedSigmaLimits(0.1,3); |
83 | |
84 | // From this set of limits, compute the status of all tracker pads. |
fe6ed686 |
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. |
20356e33 |
88 | |
92c444bc |
89 | AliMUONPadStatusMapMaker mapMaker(*calib); |
20356e33 |
90 | |
fe6ed686 |
91 | Int_t mask(0x8080); |
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 ;-) |
20356e33 |
96 | |
97 | fStatusMap = mapMaker.MakePadStatusMap(*status,mask); |
98 | |
99 | delete status; |
100 | } |
101 | else |
102 | { |
103 | // make a fake (empty) status map |
104 | fStatusMap = AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap(); |
105 | } |
d99769c3 |
106 | } |
107 | |
108 | //_____________________________________________________________________________ |
109 | AliMUONDigitCalibrator::~AliMUONDigitCalibrator() |
110 | { |
d1c20d08 |
111 | /// dtor. |
112 | delete fStatusMap; |
fe6ed686 |
113 | |
114 | AliInfo("Summary of messages:"); |
115 | fLogger->Print(); |
116 | |
117 | delete fLogger; |
d99769c3 |
118 | } |
119 | |
120 | //_____________________________________________________________________________ |
121 | void |
122 | AliMUONDigitCalibrator::Exec(Option_t*) |
123 | { |
7945aae7 |
124 | /// Main method. |
125 | /// We loop on tracking chambers (i.e. we do nothing for trigger) |
126 | /// and for each digit in that chamber, we calibrate it : |
d1c20d08 |
127 | /// a) we set its status map and if status is bad, set the signal to zero |
7945aae7 |
128 | /// b) we then apply pedestal and gain corrections. |
c795d086 |
129 | |
d99769c3 |
130 | for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch ) |
131 | { |
132 | TClonesArray* digitArray = fData->Digits(ch); |
133 | Int_t nDigits = digitArray->GetEntriesFast(); |
134 | for ( Int_t d = 0; d < nDigits; ++d ) |
135 | { |
136 | AliMUONDigit* digit = |
137 | static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d)); |
138 | |
d1c20d08 |
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) |
c795d086 |
144 | { |
c795d086 |
145 | digit->SetSignal(0); |
fe6ed686 |
146 | fLogger->Log(Form("%s:%d:Channel detElemId %d manuId %d " |
147 | "manuChannel %d is bad %x",__FILE__,__LINE__, |
148 | digit->DetElemId(),digit->ManuId(), |
d1c20d08 |
149 | digit->ManuChannel(),digit->StatusMap())); |
c795d086 |
150 | continue; |
151 | } |
152 | |
153 | // If the channel is good, go on with the calibration itself. |
154 | |
155 | AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*> |
1171bb0a |
156 | (fCalibrationData->Pedestals(digit->DetElemId(),digit->ManuId())); |
c795d086 |
157 | |
158 | AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*> |
1171bb0a |
159 | (fCalibrationData->Gains(digit->DetElemId(),digit->ManuId())); |
d99769c3 |
160 | |
d99769c3 |
161 | if (!pedestal) |
162 | { |
c795d086 |
163 | AliFatal(Form("Got a null ped object for DE,manu=%d,%d", |
164 | digit->DetElemId(),digit->ManuId())); |
d99769c3 |
165 | |
166 | } |
167 | if (!gain) |
168 | { |
c795d086 |
169 | AliFatal(Form("Got a null gain object for DE,manu=%d,%d", |
170 | digit->DetElemId(),digit->ManuId())); |
d99769c3 |
171 | } |
172 | |
c795d086 |
173 | Int_t manuChannel = digit->ManuChannel(); |
45dd3605 |
174 | Float_t adc = digit->Signal(); |
c795d086 |
175 | Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0); |
176 | if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) ) |
d99769c3 |
177 | { |
178 | padc = 0.0; |
179 | } |
c795d086 |
180 | Float_t charge = padc*gain->ValueAsFloat(manuChannel,0); |
45dd3605 |
181 | digit->SetSignal(charge); |
c795d086 |
182 | Int_t saturation = gain->ValueAsInt(manuChannel,1); |
45dd3605 |
183 | if ( charge >= saturation ) |
c795d086 |
184 | { |
185 | digit->Saturated(kTRUE); |
186 | } |
d99769c3 |
187 | } |
188 | } |
189 | } |