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 | |
20 | #include "AliCDBEntry.h" |
21 | #include "AliCDBManager.h" |
22 | #include "AliCDBStorage.h" |
23 | #include "AliLog.h" |
24 | #include "AliMUONCalibrationData.h" |
25 | #include "AliMUONConstants.h" |
26 | #include "AliMUONData.h" |
27 | #include "AliMUONDigit.h" |
c795d086 |
28 | #include "AliMUONVCalibParam.h" |
d99769c3 |
29 | #include "AliMpDEManager.h" |
30 | #include "AliMpPad.h" |
31 | #include "AliMpPlaneType.h" |
32 | #include "AliMpStationType.h" |
33 | #include "AliMpVSegmentation.h" |
34 | #include "Riostream.h" |
35 | #include "TClonesArray.h" |
36 | |
37 | ClassImp(AliMUONDigitCalibrator) |
38 | |
39 | //_____________________________________________________________________________ |
40 | AliMUONDigitCalibrator::AliMUONDigitCalibrator(AliMUONData* muonData, |
c795d086 |
41 | AliMUONCalibrationData* calib) |
d99769c3 |
42 | : TTask("AliMUONDigitCalibrator","Subtract pedestal from digit charge"), |
43 | fData(muonData), |
44 | fCalibrationData(calib) |
45 | { |
c795d086 |
46 | // |
47 | // ctor. This class need the muonData to get access to the digit, |
48 | // and the calibrationData to get access to calibration parameters. |
49 | // |
d99769c3 |
50 | } |
51 | |
884a73f1 |
52 | //______________________________________________________________________________ |
53 | AliMUONDigitCalibrator::AliMUONDigitCalibrator(const AliMUONDigitCalibrator& right) |
54 | : TTask(right) |
55 | { |
56 | /// Protected copy constructor (not implemented) |
57 | |
58 | AliFatal("Copy constructor not provided."); |
59 | } |
60 | |
d99769c3 |
61 | //_____________________________________________________________________________ |
62 | AliMUONDigitCalibrator::~AliMUONDigitCalibrator() |
63 | { |
c795d086 |
64 | // |
65 | // empty dtor. |
66 | // |
d99769c3 |
67 | } |
68 | |
884a73f1 |
69 | //______________________________________________________________________________ |
70 | AliMUONDigitCalibrator& |
71 | AliMUONDigitCalibrator::operator=(const AliMUONDigitCalibrator& right) |
72 | { |
73 | /// Protected assignement operator (not implemented) |
74 | |
75 | // check assignement to self |
76 | if (this == &right) return *this; |
77 | |
78 | AliFatal("Assignement operator not provided."); |
79 | |
80 | return *this; |
81 | } |
82 | |
d99769c3 |
83 | //_____________________________________________________________________________ |
84 | void |
85 | AliMUONDigitCalibrator::Exec(Option_t*) |
86 | { |
c795d086 |
87 | // |
88 | // Main method. |
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. |
94 | |
d99769c3 |
95 | for ( Int_t ch = 0; ch < AliMUONConstants::NTrackingCh(); ++ch ) |
96 | { |
97 | TClonesArray* digitArray = fData->Digits(ch); |
98 | Int_t nDigits = digitArray->GetEntriesFast(); |
99 | for ( Int_t d = 0; d < nDigits; ++d ) |
100 | { |
101 | AliMUONDigit* digit = |
102 | static_cast<AliMUONDigit*>(digitArray->UncheckedAt(d)); |
103 | |
c795d086 |
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()) ) |
109 | { |
110 | AliDebug(10,Form("Removing dead channel detElemId %d manuId %d " |
111 | "manuChannel %d",digit->DetElemId(),digit->ManuId(), |
112 | digit->ManuChannel())); |
113 | digit->SetSignal(0); |
114 | continue; |
115 | } |
116 | |
117 | // If the channel is good, go on with the calibration itself. |
118 | |
119 | AliMUONVCalibParam* pedestal = static_cast<AliMUONVCalibParam*> |
120 | (fCalibrationData->Pedestal(digit->DetElemId(),digit->ManuId())); |
121 | |
122 | AliMUONVCalibParam* gain = static_cast<AliMUONVCalibParam*> |
123 | (fCalibrationData->Gain(digit->DetElemId(),digit->ManuId())); |
d99769c3 |
124 | |
d99769c3 |
125 | if (!pedestal) |
126 | { |
c795d086 |
127 | AliFatal(Form("Got a null ped object for DE,manu=%d,%d", |
128 | digit->DetElemId(),digit->ManuId())); |
d99769c3 |
129 | |
130 | } |
131 | if (!gain) |
132 | { |
c795d086 |
133 | AliFatal(Form("Got a null gain object for DE,manu=%d,%d", |
134 | digit->DetElemId(),digit->ManuId())); |
d99769c3 |
135 | } |
136 | |
c795d086 |
137 | Int_t manuChannel = digit->ManuChannel(); |
d99769c3 |
138 | Int_t adc = digit->Signal(); |
c795d086 |
139 | Float_t padc = adc-pedestal->ValueAsFloat(manuChannel,0); |
140 | if ( padc < 3.0*pedestal->ValueAsFloat(manuChannel,1) ) |
d99769c3 |
141 | { |
142 | padc = 0.0; |
143 | } |
c795d086 |
144 | Float_t charge = padc*gain->ValueAsFloat(manuChannel,0); |
d99769c3 |
145 | Int_t signal = TMath::Nint(charge); |
146 | digit->SetSignal(signal); |
c795d086 |
147 | Int_t saturation = gain->ValueAsInt(manuChannel,1); |
148 | if ( signal >= saturation ) |
149 | { |
150 | digit->Saturated(kTRUE); |
151 | } |
d99769c3 |
152 | } |
153 | } |
154 | } |