52783dbc |
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 | /////////////////////////////////////////////////////////////////////////////// |
19 | // // |
20 | // class for PHOS calibration // |
21 | // // |
22 | /////////////////////////////////////////////////////////////////////////////// |
23 | |
fc6706cb |
24 | #include "TMath.h" |
25 | #include "TRandom.h" |
52783dbc |
26 | #include "AliPHOSCalibData.h" |
fc6706cb |
27 | #include "AliCDBManager.h" |
28 | #include "AliCDBStorage.h" |
29 | #include "AliCDBId.h" |
30 | #include "AliCDBEntry.h" |
52783dbc |
31 | |
32 | ClassImp(AliPHOSCalibData) |
33 | |
34 | //________________________________________________________________ |
fc6706cb |
35 | AliPHOSCalibData::AliPHOSCalibData(): |
36 | TNamed(), fCalibDataEmc(0x0), fCalibDataCpv(0x0) |
52783dbc |
37 | { |
fc6706cb |
38 | // Default constructor |
39 | |
df0d5123 |
40 | fEmcDataPath="PHOS/Calib/EmcGainPedestals"; |
41 | fCpvDataPath="PHOS/Calib/CpvGainPedestals"; |
fc6706cb |
42 | |
52783dbc |
43 | } |
44 | |
45 | //________________________________________________________________ |
fc6706cb |
46 | AliPHOSCalibData::AliPHOSCalibData(Int_t runNumber) : |
47 | TNamed("phosCalib","PHOS Calibration Data Manager"), |
48 | fCalibDataEmc(0x0), fCalibDataCpv(0x0) |
52783dbc |
49 | { |
50 | // Constructor |
fc6706cb |
51 | |
df0d5123 |
52 | fEmcDataPath="PHOS/Calib/EmcGainPedestals"; |
53 | fCpvDataPath="PHOS/Calib/CpvGainPedestals"; |
fc6706cb |
54 | |
55 | AliCDBEntry* entryEmc = AliCDBManager::Instance()->Get(fEmcDataPath.Data(),runNumber); |
56 | if(entryEmc) |
57 | fCalibDataEmc = (AliPHOSEmcCalibData*)entryEmc->GetObject(); |
58 | |
59 | AliCDBEntry* entryCpv = AliCDBManager::Instance()->Get(fCpvDataPath.Data(),runNumber); |
60 | if(entryCpv) |
61 | fCalibDataCpv = (AliPHOSCpvCalibData*)entryCpv->GetObject(); |
52783dbc |
62 | |
52783dbc |
63 | } |
64 | |
65 | //________________________________________________________________ |
66 | AliPHOSCalibData::~AliPHOSCalibData() |
67 | { |
68 | // Destructor |
fc6706cb |
69 | |
52783dbc |
70 | } |
71 | |
72 | //________________________________________________________________ |
73 | void AliPHOSCalibData::Reset() |
74 | { |
75 | // Set all pedestals to 0 and all ADC channels to 1 |
fc6706cb |
76 | |
77 | fCalibDataEmc->Reset(); |
78 | fCalibDataCpv->Reset(); |
52783dbc |
79 | } |
80 | |
81 | //________________________________________________________________ |
82 | void AliPHOSCalibData::Print(Option_t *option) const |
83 | { |
df0d5123 |
84 | if (fCalibDataEmc) fCalibDataEmc->Print(option); |
85 | if (fCalibDataCpv) fCalibDataCpv->Print(option); |
fc6706cb |
86 | } |
87 | |
88 | //________________________________________________________________ |
89 | void AliPHOSCalibData::CreateNew() |
90 | { |
91 | if(fCalibDataEmc) delete fCalibDataEmc; |
92 | fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC"); |
93 | |
94 | if(fCalibDataCpv) delete fCalibDataCpv; |
95 | fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV"); |
96 | |
97 | } |
98 | |
99 | //________________________________________________________________ |
100 | Bool_t AliPHOSCalibData::WriteEmc(Int_t firstRun, Int_t lastRun, AliCDBMetaData *md) |
101 | { |
102 | |
103 | if(!fCalibDataEmc) return kFALSE; |
104 | |
105 | AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS"); |
df0d5123 |
106 | if(!storage) |
107 | storage = AliCDBManager::Instance()->GetDefaultStorage(); |
108 | |
fc6706cb |
109 | if(storage) { |
110 | AliCDBId id(fEmcDataPath.Data(),firstRun,lastRun); |
111 | storage->Put(fCalibDataEmc,id, md); |
112 | return kTRUE; |
52783dbc |
113 | } |
fc6706cb |
114 | else |
115 | return kFALSE; |
52783dbc |
116 | |
fc6706cb |
117 | } |
118 | |
119 | //________________________________________________________________ |
120 | Bool_t AliPHOSCalibData::WriteCpv(Int_t firstRun, Int_t lastRun, AliCDBMetaData *md) |
121 | { |
122 | |
123 | if(!fCalibDataCpv) return kFALSE; |
124 | |
125 | AliCDBStorage* storage = AliCDBManager::Instance()->GetSpecificStorage("PHOS"); |
df0d5123 |
126 | if(!storage) |
127 | storage = AliCDBManager::Instance()->GetDefaultStorage(); |
128 | |
fc6706cb |
129 | if(storage) { |
130 | AliCDBId id(fCpvDataPath.Data(),firstRun,lastRun); |
131 | storage->Put(fCalibDataCpv,id, md); |
132 | return kTRUE; |
52783dbc |
133 | } |
fc6706cb |
134 | else |
135 | return kFALSE; |
136 | |
52783dbc |
137 | } |
072de3a8 |
138 | |
fc6706cb |
139 | //________________________________________________________________ |
072de3a8 |
140 | Float_t AliPHOSCalibData::GetADCchannelEmc(Int_t module, Int_t column, Int_t row) const |
141 | { |
142 | //module, column,raw should follow the internal PHOS convention: |
143 | //module 1:5, column 1:56, row 1:64 |
144 | |
fc6706cb |
145 | if(fCalibDataEmc) |
146 | return fCalibDataEmc->GetADCchannelEmc(module,column,row); |
147 | else |
148 | return 0.0015; // default width of one EMC ADC channel in GeV |
072de3a8 |
149 | } |
150 | |
151 | Float_t AliPHOSCalibData::GetADCpedestalEmc(Int_t module, Int_t column, Int_t row) const |
152 | { |
fc6706cb |
153 | if(fCalibDataEmc) |
154 | return fCalibDataEmc->GetADCpedestalEmc(module,column,row); |
155 | else |
156 | return 0.005; // default EMC ADC pedestal |
072de3a8 |
157 | } |
158 | |
159 | void AliPHOSCalibData::SetADCchannelEmc(Int_t module, Int_t column, Int_t row, Float_t value) |
160 | { |
fc6706cb |
161 | if(!fCalibDataEmc) |
162 | fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC"); |
163 | |
164 | fCalibDataEmc->SetADCchannelEmc(module,column,row,value); |
072de3a8 |
165 | } |
166 | |
167 | void AliPHOSCalibData::SetADCpedestalEmc(Int_t module, Int_t column, Int_t row, Float_t value) |
168 | { |
fc6706cb |
169 | if(!fCalibDataEmc) |
170 | fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC"); |
171 | |
172 | fCalibDataEmc->SetADCpedestalEmc(module,column,row,value); |
173 | } |
174 | |
175 | //________________________________________________________________ |
176 | Float_t AliPHOSCalibData::GetADCchannelCpv(Int_t module, Int_t column, Int_t row) const |
177 | { |
178 | //module, column,raw should follow the internal CPV convention: |
179 | //module 1:5, column 1:64, row 1:128 |
180 | |
181 | if(fCalibDataCpv) |
182 | return fCalibDataCpv->GetADCchannelCpv(module,column,row); |
183 | else |
184 | return 0.0012; // default width of one ADC channel in CPV 'popugais' |
185 | } |
186 | |
187 | Float_t AliPHOSCalibData::GetADCpedestalCpv(Int_t module, Int_t column, Int_t row) const |
188 | { |
189 | if(fCalibDataCpv) |
190 | return fCalibDataCpv->GetADCpedestalCpv(module,column,row); |
191 | else |
192 | return 0.012; // default CPV ADC pedestal |
193 | } |
194 | |
195 | void AliPHOSCalibData::SetADCchannelCpv(Int_t module, Int_t column, Int_t row, Float_t value) |
196 | { |
197 | if(!fCalibDataCpv) |
198 | fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV"); |
199 | |
200 | fCalibDataCpv->SetADCchannelCpv(module,column,row,value); |
201 | } |
202 | |
203 | void AliPHOSCalibData::SetADCpedestalCpv(Int_t module, Int_t column, Int_t row, Float_t value) |
204 | { |
205 | if(!fCalibDataCpv) |
206 | fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV"); |
207 | |
208 | fCalibDataCpv->SetADCpedestalCpv(module,column,row,value); |
209 | } |
210 | |
211 | //________________________________________________________________ |
212 | void AliPHOSCalibData::RandomEmc() |
213 | { |
214 | |
215 | if(fCalibDataEmc) delete fCalibDataEmc; |
216 | fCalibDataEmc = new AliPHOSEmcCalibData("PHOS-EMC"); |
217 | |
218 | TRandom rn; |
219 | rn.SetSeed(0); //the seed is set to the current machine clock |
220 | |
221 | Float_t ADCchanelEmc,ADCpedestalEmc; |
222 | |
223 | for(Int_t module=1; module<6; module++) { |
224 | for(Int_t column=1; column<57; column++) { |
225 | for(Int_t row=1; row<65; row++) { |
226 | ADCchanelEmc=rn.Uniform(0.00075,0.00375); // Cmax/Cmin = 5, (Cmax-Cmin)/2 = 0.0015 |
227 | ADCpedestalEmc=rn.Uniform(0.0045,0.0055); //+-10% spread of pedestals from 0.005 |
228 | fCalibDataEmc->SetADCchannelEmc(module,column,row,ADCchanelEmc); |
229 | fCalibDataEmc->SetADCpedestalEmc(module,column,row,ADCpedestalEmc); |
230 | } |
231 | } |
232 | } |
233 | |
234 | } |
235 | |
236 | //________________________________________________________________ |
237 | void AliPHOSCalibData::RandomCpv() |
238 | { |
239 | |
240 | if(fCalibDataCpv) delete fCalibDataCpv; |
241 | fCalibDataCpv = new AliPHOSCpvCalibData("PHOS-CPV"); |
242 | |
243 | TRandom rn; |
244 | rn.SetSeed(0); //the seed is set to the current machine clock |
245 | |
246 | Float_t ADCchanelCpv,ADCpedestalCpv; |
247 | |
248 | for(Int_t module=1; module<6; module++) { |
249 | for(Int_t column=1; column<65; column++) { |
250 | for(Int_t row=1; row<129; row++) { |
251 | ADCchanelCpv=TMath::Abs(rn.Uniform(0.0009,0.0015)); // 0.0012 +- 25% |
252 | ADCpedestalCpv=rn.Uniform(0.0048,0.0192); // Ped[max]/Ped[min] = 4, <Ped> = 0.012 |
253 | fCalibDataCpv->SetADCchannelCpv(module,column,row,ADCchanelCpv); |
254 | fCalibDataCpv->SetADCpedestalCpv(module,column,row,ADCpedestalCpv); |
255 | } |
256 | } |
257 | } |
072de3a8 |
258 | } |