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"
20 #include "AliCDBEntry.h"
21 #include "AliCDBManager.h"
22 #include "AliCDBStorage.h"
24 #include "AliMUONCalibrationData.h"
25 #include "AliMUONConstants.h"
26 #include "AliMUONData.h"
27 #include "AliMUONDigit.h"
28 #include "AliMUONVCalibParam.h"
29 #include "AliMpDEManager.h"
31 #include "AliMpPlaneType.h"
32 #include "AliMpStationType.h"
33 #include "AliMpVSegmentation.h"
34 #include "Riostream.h"
35 #include "TClonesArray.h"
37 ClassImp(AliMUONDigitCalibrator)
39 //_____________________________________________________________________________
40 AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
41 AliMUONCalibrationData* calib)
42 : TTask("AliMUONDigitCalibrator","Subtract pedestal from digit charge"),
44 fCalibrationData(calib)
47 // ctor. This class need the muonData to get access to the digit,
48 // and the calibrationData to get access to calibration parameters.
52 //_____________________________________________________________________________
53 AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
60 //_____________________________________________________________________________
62 AliMUONDigitCalibrator::Exec(Option_t*)
66 // We loop on tracking chambers (i.e. we do nothing for trigger)
67 // and for each digit in that chamber, we calibrate it :
68 // a) if the corresponding channel is known to be bad, we set the signal to 0
69 // (so that digit can be suppressed later on)
70 // b) we then apply pedestal and gain corrections.
72 for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
74 TClonesArray* digitArray = fData->Digits(ch);
75 Int_t nDigits = digitArray->GetEntriesFast();
76 for ( Int_t d = 0; d < nDigits; ++d )
79 static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
81 // Very first check is whether this channel is known to be bad,
82 // in which case we set the signal to zero.
83 AliMUONVCalibParam* dead = static_cast<AliMUONVCalibParam*>
84 (fCalibrationData->DeadChannel(digit->DetElemId(),digit->ManuId()));
85 if ( dead && dead->ValueAsInt(digit->ManuChannel()) )
87 AliDebug(10,Form("Removing dead channel detElemId %d manuId %d "
88 "manuChannel %d",digit->DetElemId(),digit->ManuId(),
89 digit->ManuChannel()));
94 // If the channel is good, go on with the calibration itself.
96 AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
97 (fCalibrationData->Pedestal(digit->DetElemId(),digit->ManuId()));
99 AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
100 (fCalibrationData->Gain(digit->DetElemId(),digit->ManuId()));
104 AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
105 digit->DetElemId(),digit->ManuId()));
110 AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
111 digit->DetElemId(),digit->ManuId()));
114 Int_t manuChannel = digit->ManuChannel();
115 Int_t adc = digit->Signal();
116 Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
117 if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) )
121 Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
122 Int_t signal = TMath::Nint(charge);
123 digit->SetSignal(signal);
124 Int_t saturation = gain->ValueAsInt(manuChannel,1);
125 if ( signal >= saturation )
127 digit->Saturated(kTRUE);