]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONDigitCalibrator.cxx
Copy constructor implemented.
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitCalibrator.cxx
... / ...
CommitLineData
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
20#include "AliLog.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"
30
31/// \class AliMUONDigitCalibrator
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///
46/// \author Laurent Aphecetche
47
48
49/// \cond CLASSIMP
50ClassImp(AliMUONDigitCalibrator)
51/// \endcond
52
53//_____________________________________________________________________________
54AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
55 AliMUONCalibrationData* calib,
56 Bool_t createAndUseStatusMap)
57: TTask("AliMUONDigitCalibrator","Raw digit calibration"),
58 fData(muonData),
59 fCalibrationData(calib),
60 fStatusMap(0x0)
61{
62 /// ctor. This class needs the muonData to get access to the digit,
63 /// and the calibrationData to get access to calibration parameters.
64
65 if (!calib) throw;
66
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);
86 //FIXME: fake one (consider dead only if ped mean too high or hv switch off)
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 }
97}
98
99//_____________________________________________________________________________
100AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
101{
102 /// dtor.
103 delete fStatusMap;
104}
105
106//_____________________________________________________________________________
107void
108AliMUONDigitCalibrator::Exec(Option_t*)
109{
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 :
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.
115
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
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)
130 {
131 digit->SetSignal(0);
132 AliWarning(Form("Channel detElemId %d manuId %d "
133 "manuChannel %d is bad %x",digit->DetElemId(),digit->ManuId(),
134 digit->ManuChannel(),digit->StatusMap()));
135 continue;
136 }
137
138 // If the channel is good, go on with the calibration itself.
139
140 AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
141 (fCalibrationData->Pedestals(digit->DetElemId(),digit->ManuId()));
142
143 AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
144 (fCalibrationData->Gains(digit->DetElemId(),digit->ManuId()));
145
146 if (!pedestal)
147 {
148 AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
149 digit->DetElemId(),digit->ManuId()));
150
151 }
152 if (!gain)
153 {
154 AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
155 digit->DetElemId(),digit->ManuId()));
156 }
157
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) )
162 {
163 padc = 0.0;
164 }
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 )
169 {
170 digit->Saturated(kTRUE);
171 }
172 }
173 }
174}