]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigitCalibrator.cxx
Compilation with Root v5-15-3
[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"
d1c20d08 25#include "AliMUONPadStatusMaker.h"
26#include "AliMUONPadStatusMapMaker.h"
27#include "AliMUONV2DStore.h"
c795d086 28#include "AliMUONVCalibParam.h"
d99769c3 29#include "TClonesArray.h"
30
7945aae7 31/// \class AliMUONDigitCalibrator
1171bb0a 32/// Class used to calibrate digits (either real or simulated ones).
33///
34/// The calibration consists of subtracting the pedestal
35/// and multiplying by a gain, so that
36/// Signal = (ADC-pedestal)*gain
37///
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
44/// bad digits).
45///
7945aae7 46/// \author Laurent Aphecetche
47
1171bb0a 48
7945aae7 49/// \cond CLASSIMP
d99769c3 50ClassImp(AliMUONDigitCalibrator)
7945aae7 51/// \endcond
d99769c3 52
53//_____________________________________________________________________________
54AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
20356e33 55 AliMUONCalibrationData* calib,
56 Bool_t createAndUseStatusMap)
d1c20d08 57: TTask("AliMUONDigitCalibrator","Raw digit calibration"),
d99769c3 58 fData(muonData),
d1c20d08 59 fCalibrationData(calib),
60 fStatusMap(0x0)
d99769c3 61{
d1c20d08 62 /// ctor. This class needs the muonData to get access to the digit,
7945aae7 63 /// and the calibrationData to get access to calibration parameters.
d1c20d08 64
65 if (!calib) throw;
66
20356e33 67 if (createAndUseStatusMap)
68 {
69 AliMUONPadStatusMaker maker(*calib);
70
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..)
74 //
75 maker.SetHVSt12Limits(1300,1600);
76 maker.SetHVSt345Limits(1500,2000);
77 maker.SetPedMeanLimits(50,200);
78 maker.SetPedSigmaLimits(0.1,3);
79
80 // From this set of limits, compute the status of all tracker pads.
81 AliMUONV2DStore* status = maker.MakeStatus();
82
83 AliMUONPadStatusMapMaker mapMaker;
84
85 Int_t mask(0x8000000);
d1c20d08 86 //FIXME: fake one (consider dead only if ped mean too high or hv switch off)
20356e33 87
88 fStatusMap = mapMaker.MakePadStatusMap(*status,mask);
89
90 delete status;
91 }
92 else
93 {
94 // make a fake (empty) status map
95 fStatusMap = AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap();
96 }
d99769c3 97}
98
99//_____________________________________________________________________________
100AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
101{
d1c20d08 102 /// dtor.
103 delete fStatusMap;
d99769c3 104}
105
106//_____________________________________________________________________________
107void
108AliMUONDigitCalibrator::Exec(Option_t*)
109{
7945aae7 110 /// Main method.
111 /// We loop on tracking chambers (i.e. we do nothing for trigger)
112 /// and for each digit in that chamber, we calibrate it :
d1c20d08 113 /// a) we set its status map and if status is bad, set the signal to zero
7945aae7 114 /// b) we then apply pedestal and gain corrections.
c795d086 115
d99769c3 116 for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
117 {
118 TClonesArray* digitArray = fData->Digits(ch);
119 Int_t nDigits = digitArray->GetEntriesFast();
120 for ( Int_t d = 0; d < nDigits; ++d )
121 {
122 AliMUONDigit* digit =
123 static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
124
d1c20d08 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)
c795d086 130 {
c795d086 131 digit->SetSignal(0);
d1c20d08 132 AliWarning(Form("Channel detElemId %d manuId %d "
133 "manuChannel %d is bad %x",digit->DetElemId(),digit->ManuId(),
134 digit->ManuChannel(),digit->StatusMap()));
c795d086 135 continue;
136 }
137
138 // If the channel is good, go on with the calibration itself.
139
140 AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
1171bb0a 141 (fCalibrationData->Pedestals(digit->DetElemId(),digit->ManuId()));
c795d086 142
143 AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
1171bb0a 144 (fCalibrationData->Gains(digit->DetElemId(),digit->ManuId()));
d99769c3 145
d99769c3 146 if (!pedestal)
147 {
c795d086 148 AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
149 digit->DetElemId(),digit->ManuId()));
d99769c3 150
151 }
152 if (!gain)
153 {
c795d086 154 AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
155 digit->DetElemId(),digit->ManuId()));
d99769c3 156 }
157
c795d086 158 Int_t manuChannel = digit->ManuChannel();
45dd3605 159 Float_t adc = digit->Signal();
c795d086 160 Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
161 if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) )
d99769c3 162 {
163 padc = 0.0;
164 }
c795d086 165 Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
45dd3605 166 digit->SetSignal(charge);
c795d086 167 Int_t saturation = gain->ValueAsInt(manuChannel,1);
45dd3605 168 if ( charge >= saturation )
c795d086 169 {
170 digit->Saturated(kTRUE);
171 }
d99769c3 172 }
173 }
174}