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(const AliMUONDigitCalibrator& right)
56 /// Protected copy constructor (not implemented)
58 AliFatal("Copy constructor not provided.");
61 //_____________________________________________________________________________
62 AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
69 //______________________________________________________________________________
70 AliMUONDigitCalibrator&
71 AliMUONDigitCalibrator::operator=(const AliMUONDigitCalibrator& right)
73 /// Protected assignement operator (not implemented)
75 // check assignement to self
76 if (this == &right) return *this;
78 AliFatal("Assignement operator not provided.");
83 //_____________________________________________________________________________
85 AliMUONDigitCalibrator::Exec(Option_t*)
89 // We loop on tracking chambers (i.e. we do nothing for trigger)
90 // and for each digit in that chamber, we calibrate it :
91 // a) if the corresponding channel is known to be bad, we set the signal to 0
92 // (so that digit can be suppressed later on)
93 // b) we then apply pedestal and gain corrections.
95 for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
97 TClonesArray* digitArray = fData->Digits(ch);
98 Int_t nDigits = digitArray->GetEntriesFast();
99 for ( Int_t d = 0; d < nDigits; ++d )
101 AliMUONDigit* digit =
102 static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
104 // Very first check is whether this channel is known to be bad,
105 // in which case we set the signal to zero.
106 AliMUONVCalibParam* dead = static_cast<AliMUONVCalibParam*>
107 (fCalibrationData->DeadChannel(digit->DetElemId(),digit->ManuId()));
108 if ( dead && dead->ValueAsInt(digit->ManuChannel()) )
110 AliDebug(10,Form("Removing dead channel detElemId %d manuId %d "
111 "manuChannel %d",digit->DetElemId(),digit->ManuId(),
112 digit->ManuChannel()));
117 // If the channel is good, go on with the calibration itself.
119 AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
120 (fCalibrationData->Pedestal(digit->DetElemId(),digit->ManuId()));
122 AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
123 (fCalibrationData->Gain(digit->DetElemId(),digit->ManuId()));
127 AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
128 digit->DetElemId(),digit->ManuId()));
133 AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
134 digit->DetElemId(),digit->ManuId()));
137 Int_t manuChannel = digit->ManuChannel();
138 Int_t adc = digit->Signal();
139 Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
140 if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) )
144 Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
145 Int_t signal = TMath::Nint(charge);
146 digit->SetSignal(signal);
147 Int_t saturation = gain->ValueAsInt(manuChannel,1);
148 if ( signal >= saturation )
150 digit->Saturated(kTRUE);