]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDigitCalibrator.cxx
Removing implementation of protected copy constructor &
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitCalibrator.cxx
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 "AliMUONVCalibParam.h"
26 #include "TClonesArray.h"
27
28 ///
29 /// Class used to calibrate digits (either real or simulated ones).
30 ///
31 /// The calibration consists of subtracting the pedestal
32 /// and multiplying by a gain, so that
33 /// Signal = (ADC-pedestal)*gain
34 ///
35 /// Please note also that for the moment, if a digit lies on a dead channel
36 /// we remove this digit from the list of digits.
37 /// FIXME: this has to be revisited. By using the AliMUONDigit::fFlags we
38 /// should in principle flag a digit as bad w/o removing it, but this 
39 /// then requires some changes in the cluster finder to deal with this extra
40 /// information correctly (e.g. to set a quality for the cluster if it contains
41 /// bad digits).
42 ///
43
44 ClassImp(AliMUONDigitCalibrator)
45
46 //_____________________________________________________________________________
47 AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData,
48                                               AliMUONCalibrationData* calib)
49 : TTask("AliMUONDigitCalibrator","Subtract pedestal from digit charge"),
50   fData(muonData),
51   fCalibrationData(calib)
52 {
53     //
54     // ctor. This class need the muonData to get access to the digit,
55     // and the calibrationData to get access to calibration parameters.
56     //
57 }
58
59 //_____________________________________________________________________________
60 AliMUONDigitCalibrator::~AliMUONDigitCalibrator()
61 {
62   //
63   // empty dtor.
64   //
65 }
66
67 //_____________________________________________________________________________
68 void
69 AliMUONDigitCalibrator::Exec(Option_t*)
70 {
71   //
72   // Main method.
73   // We loop on tracking chambers (i.e. we do nothing for trigger)
74   // and for each digit in that chamber, we calibrate it :
75   // a) if the corresponding channel is known to be bad, we set the signal to 0
76   //    (so that digit can be suppressed later on)
77   // b) we then apply pedestal and gain corrections.
78   
79   for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch )
80   {
81     TClonesArray* digitArray = fData->Digits(ch);
82     Int_t nDigits = digitArray->GetEntriesFast();
83     for ( Int_t d = 0; d < nDigits; ++d )
84     {
85       AliMUONDigit* digit = 
86         static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d));
87  
88       // Very first check is whether this channel is known to be bad,
89       // in which case we set the signal to zero.
90       AliMUONVCalibParam* dead = static_cast<AliMUONVCalibParam*>
91         (fCalibrationData->DeadChannels(digit->DetElemId(),digit->ManuId()));
92       if ( dead && dead->ValueAsInt(digit->ManuChannel()) )
93       {
94         AliWarning(Form("Removing dead channel detElemId %d manuId %d "
95                         "manuChannel %d",digit->DetElemId(),digit->ManuId(),
96                         digit->ManuChannel()));
97         digit->SetSignal(0);
98         continue;
99       }
100           
101       // If the channel is good, go on with the calibration itself.
102       
103       AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*>
104         (fCalibrationData->Pedestals(digit->DetElemId(),digit->ManuId()));
105       
106       AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*>
107         (fCalibrationData->Gains(digit->DetElemId(),digit->ManuId()));
108       
109       if (!pedestal)
110       {
111         AliFatal(Form("Got a null ped object for DE,manu=%d,%d",
112                       digit->DetElemId(),digit->ManuId()));
113         
114       }
115       if (!gain)
116       {
117         AliFatal(Form("Got a null gain object for DE,manu=%d,%d",
118                       digit->DetElemId(),digit->ManuId()));        
119       }
120       
121       Int_t manuChannel = digit->ManuChannel();
122       Int_t adc = digit->Signal();
123       Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0);
124       if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) ) 
125       {
126         padc = 0.0;
127       }
128       Float_t charge = padc*gain->ValueAsFloat(manuChannel,0);
129       Int_t signal = TMath::Nint(charge);
130       digit->SetSignal(signal);
131       Int_t saturation = gain->ValueAsInt(manuChannel,1);
132       if ( signal >= saturation )
133       {
134         digit->Saturated(kTRUE);
135       }
136     }
137   }
138 }