]>
Commit | Line | Data |
---|---|---|
a4b77ddf | 1 | /******************************************************************************* |
2 | * Copyright(c) 2003, IceCube Experiment at the South Pole. All rights reserved. | |
3 | * | |
4 | * Author: The IceCube RALICE-based Offline 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. | |
12 | * The authors make no claims about the suitability of this software for | |
13 | * any purpose. It is provided "as is" without express or implied warranty. | |
14 | *******************************************************************************/ | |
15 | ||
16 | // $Id$ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////// | |
19 | // Class IceCalibrate | |
20 | // TTask derived class to perform the various calibrations. | |
21 | // | |
22 | // This task takes the current event in memory and uses the attached | |
23 | // OM database to access the various calibration functions. | |
24 | // A specific OM database may be attached by means of the SetOMdbase() | |
25 | // or SetCalibFile() memberfunctions. | |
26 | // Further details about the OM database can be found in the docs | |
27 | // of IceCal2Root. | |
28 | // | |
29 | // In the calibration procedure, all event data in memory is scanned and | |
30 | // replaced by calibrated data if a calibration function is present. | |
31 | // When data is succesfully calibrated, the corresponding de-calibration | |
32 | // function is stored in the event data at the appropriate place to allow | |
33 | // access to uncalibrated data as well (see AliSignal::GetSignal for | |
34 | // further details). | |
35 | // When the input event in memory already contained calibrated data | |
36 | // (i.e. de-calibration functions are present in the event data), the event | |
37 | // data is first de-calibrated (using the corresponding de-calibration functions | |
38 | // contained in the event data) before the new calibration is performed. | |
39 | // In case no corresponding calibration function is present, the calibration | |
40 | // of those specific data will not be performed. | |
41 | // This implies that running this task on calibrated data without having | |
42 | // attached an OM database, will result in fully de-calibrated data. | |
43 | // In case an OM slot was flagged as bad in the OM database, this flag | |
44 | // will be copied into the event data for the corresponding OM. | |
45 | // | |
25eefd00 | 46 | // Information about the actual parameter settings can be found in the event |
47 | // structure itself via the device named "IceCalibrate". | |
48 | // | |
a4b77ddf | 49 | //--- Author: Nick van Eijndhoven 18-sep-2005 Utrecht University |
50 | //- Modified: NvE $Date$ Utrecht University | |
51 | /////////////////////////////////////////////////////////////////////////// | |
52 | ||
53 | #include "IceCalibrate.h" | |
54 | #include "Riostream.h" | |
55 | ||
56 | ClassImp(IceCalibrate) // Class implementation to enable ROOT I/O | |
57 | ||
58 | IceCalibrate::IceCalibrate(const char* name,const char* title) : TTask(name,title) | |
59 | { | |
60 | // Default constructor. | |
61 | fCalfile=0; | |
62 | fOmdb=0; | |
63 | } | |
64 | /////////////////////////////////////////////////////////////////////////// | |
65 | IceCalibrate::~IceCalibrate() | |
66 | { | |
67 | // Default destructor. | |
68 | if (fCalfile) | |
69 | { | |
70 | delete fCalfile; | |
71 | fCalfile=0; | |
72 | } | |
73 | } | |
74 | /////////////////////////////////////////////////////////////////////////// | |
75 | void IceCalibrate::SetOMdbase(AliObjMatrix* omdb) | |
76 | { | |
77 | // Set the pointer to the OM database. | |
78 | // Note : this will overrule a previously attached database. | |
79 | fOmdb=omdb; | |
80 | } | |
81 | /////////////////////////////////////////////////////////////////////////// | |
82 | void IceCalibrate::SetCalibFile(TString name) | |
83 | { | |
84 | // Set the calibration ROOT file as created with IceCal2Root. | |
85 | // Note : this will overrule a previously attached database. | |
630ba23e | 86 | if (fCalfile) |
87 | { | |
88 | delete fCalfile; | |
89 | fCalfile=0; | |
90 | } | |
a4b77ddf | 91 | fCalfile=new TFile(name.Data()); |
630ba23e | 92 | fOmdb=0; |
a4b77ddf | 93 | } |
94 | /////////////////////////////////////////////////////////////////////////// | |
95 | void IceCalibrate::Exec(Option_t* opt) | |
96 | { | |
97 | // Implementation of the various calibration procedures. | |
98 | ||
99 | TString name=opt; | |
100 | AliJob* parent=(AliJob*)(gROOT->GetListOfTasks()->FindObject(name.Data())); | |
101 | ||
102 | if (!parent) return; | |
103 | ||
104 | IceEvent* evt=(IceEvent*)parent->GetObject("IceEvent"); | |
105 | if (!evt) return; | |
106 | ||
95f2b820 | 107 | Int_t mudaq=0; |
108 | Int_t twrdaq=0; | |
109 | AliSignal* daq=(AliSignal*)evt->GetDevice("Daq"); | |
eff2c77c | 110 | mudaq=int(daq->GetSignal("Muon")); |
111 | twrdaq=int(daq->GetSignal("TWR")); | |
95f2b820 | 112 | |
630ba23e | 113 | if (!fOmdb && fCalfile) |
95f2b820 | 114 | { |
115 | if (mudaq) | |
116 | { | |
117 | fOmdb=(AliObjMatrix*)fCalfile->Get("MuDaq-OMDBASE"); | |
118 | // Next statement for compatibility with old calibration file format | |
119 | if (!fOmdb) fOmdb=(AliObjMatrix*)fCalfile->Get("Cal-OMDBASE"); | |
120 | } | |
121 | if (twrdaq) fOmdb=(AliObjMatrix*)fCalfile->Get("TWRDaq-OMDBASE"); | |
122 | } | |
123 | ||
25eefd00 | 124 | // Storage of the used parameters in the IceCalibrate device |
125 | AliSignal params; | |
126 | params.SetNameTitle("IceCalibrate","IceCalibrate processor parameters"); | |
127 | params.SetSlotName("Omdb",1); | |
128 | ||
129 | if (fOmdb) params.SetSignal(1,1); | |
130 | ||
131 | evt->AddDevice(params); | |
132 | ||
69884331 | 133 | // All OMs with a signal |
134 | TObjArray* mods=evt->GetDevices("IceGOM"); | |
8a394508 | 135 | if (!mods) return; |
69884331 | 136 | |
137 | Int_t nmods=mods->GetEntries(); | |
138 | if (!nmods) return; | |
139 | ||
a4b77ddf | 140 | IceGOM* ome=0; // The event OM pointer |
141 | IceGOM* omd=0; // The database OM pointer | |
142 | Int_t id=0; | |
5ae71069 | 143 | Float_t adc=0,le=0,tot=0; // Uncalibrated values |
144 | Float_t cadc=0,cle=0,ctot=0; // Calibrated values | |
a4b77ddf | 145 | TF1* fcal=0; |
146 | TF1* fdecal=0; | |
9c826438 | 147 | TString slotname; |
a4b77ddf | 148 | |
69884331 | 149 | for (Int_t imod=0; imod<nmods; imod++) |
a4b77ddf | 150 | { |
69884331 | 151 | ome=(IceGOM*)mods->At(imod); |
a4b77ddf | 152 | if (!ome) continue; |
153 | ||
154 | id=ome->GetUniqueID(); | |
155 | ||
156 | omd=0; | |
157 | if (fOmdb) omd=(IceGOM*)fOmdb->GetObject(id,1); | |
158 | ||
159 | // Set global OM constants | |
160 | if (omd) | |
161 | { | |
e51b7d1a | 162 | ome->SetPosition((Ali3Vector&)omd->GetPosition()); |
9c826438 | 163 | for (Int_t ind=1; ind<=omd->GetNnames(); ind++) |
164 | { | |
165 | slotname=omd->GetSlotName(ind); | |
5ae71069 | 166 | ome->AddNamedSlot(slotname); |
9c826438 | 167 | } |
168 | for (Int_t isd=1; isd<=omd->GetNvalues(); isd++) | |
a4b77ddf | 169 | { |
5ae71069 | 170 | ome->SetSignal(omd->GetSignal(isd),omd->GetSlotName(isd)); |
a4b77ddf | 171 | } |
172 | } | |
a4b77ddf | 173 | |
174 | // Make signals of bad modules available | |
175 | ome->SetAlive("ADC"); | |
176 | ome->SetAlive("LE"); | |
177 | ome->SetAlive("TOT"); | |
178 | ||
179 | // (De)calibrate all hit signals for this OM | |
180 | for (Int_t ithit=1; ithit<=ome->GetNhits(); ithit++) | |
181 | { | |
182 | AliSignal* sx=ome->GetHit(ithit); | |
183 | if (!sx) continue; | |
184 | ||
185 | // ADC (de)calibration | |
5ae71069 | 186 | adc=sx->GetSignal("ADC",-7); // Get uncalibrated signal |
a4b77ddf | 187 | fcal=0; |
188 | fdecal=0; | |
189 | if (omd) | |
190 | { | |
191 | fcal=omd->GetCalFunction("ADC"); | |
192 | fdecal=omd->GetDecalFunction("ADC"); | |
193 | } | |
194 | if (fcal) // Store calibrated signal | |
195 | { | |
5ae71069 | 196 | cadc=fcal->Eval(adc); |
197 | sx->SetSignal(cadc,"ADC"); | |
a4b77ddf | 198 | } |
199 | else // Store uncalibrated signal | |
200 | { | |
5ae71069 | 201 | sx->SetSignal(adc,"ADC"); |
a4b77ddf | 202 | } |
203 | ||
204 | // LE (TDC) (de)calibration | |
5ae71069 | 205 | le=sx->GetSignal("LE",-7); // Get uncalibrated signal |
a4b77ddf | 206 | fcal=0; |
207 | fdecal=0; | |
208 | if (omd) | |
209 | { | |
210 | fcal=omd->GetCalFunction("LE"); | |
211 | fdecal=omd->GetDecalFunction("LE"); | |
212 | } | |
95f2b820 | 213 | |
214 | // MuDaq only : Store the hit-specific ADC dependent (de)calibration function in the hit itself | |
215 | if (mudaq) | |
a4b77ddf | 216 | { |
95f2b820 | 217 | sx->SetCalFunction(fcal,"LE"); |
218 | sx->SetDecalFunction(fdecal,"LE"); | |
219 | fcal=sx->GetCalFunction("LE"); | |
220 | fdecal=sx->GetDecalFunction("LE"); | |
221 | if (adc>0) | |
222 | { | |
223 | if (fcal) fcal->SetParameter(3,adc); | |
224 | if (fdecal) fdecal->SetParameter(3,adc); | |
225 | } | |
226 | else | |
227 | { | |
228 | if (fcal) fcal->SetParameter(3,1.e20); | |
229 | if (fdecal) fdecal->SetParameter(3,1.e20); | |
230 | } | |
a4b77ddf | 231 | } |
95f2b820 | 232 | |
a4b77ddf | 233 | if (fcal) // Store calibrated signal |
234 | { | |
5ae71069 | 235 | cle=fcal->Eval(le); |
236 | sx->SetSignal(cle,"LE"); | |
95f2b820 | 237 | if (mudaq) // MuDaq only |
238 | { | |
239 | sx->SetCalFunction(0,"LE"); | |
240 | sx->SetDecalFunction(fdecal,"LE"); | |
241 | } | |
a4b77ddf | 242 | } |
243 | else // Store uncalibrated signal | |
244 | { | |
5ae71069 | 245 | sx->SetSignal(le,"LE"); |
95f2b820 | 246 | if (mudaq) // MuDaq only |
247 | { | |
248 | sx->SetCalFunction(fcal,"LE"); | |
249 | sx->SetDecalFunction(0,"LE"); | |
250 | } | |
a4b77ddf | 251 | } |
252 | ||
253 | // TOT (de)calibration | |
5ae71069 | 254 | tot=sx->GetSignal("TOT",-7); // Get uncalibrated signal |
a4b77ddf | 255 | fcal=0; |
256 | fdecal=0; | |
257 | if (omd) | |
258 | { | |
259 | fcal=omd->GetCalFunction("TOT"); | |
260 | fdecal=omd->GetDecalFunction("TOT"); | |
261 | } | |
262 | if (fcal) // Store calibrated signal | |
263 | { | |
5ae71069 | 264 | ctot=fcal->Eval(tot); |
265 | sx->SetSignal(ctot,"TOT"); | |
a4b77ddf | 266 | } |
267 | else // Store uncalibrated signal | |
268 | { | |
5ae71069 | 269 | sx->SetSignal(tot,"TOT"); |
a4b77ddf | 270 | } |
5ae71069 | 271 | } // End of loop over hits of the OM |
a4b77ddf | 272 | |
5ae71069 | 273 | // Set bad OM flags according to dbase info |
a4b77ddf | 274 | if (omd) |
275 | { | |
276 | if (omd->GetDeadValue("ADC")) ome->SetDead("ADC"); | |
277 | if (omd->GetDeadValue("LE")) ome->SetDead("LE"); | |
278 | if (omd->GetDeadValue("TOT")) ome->SetDead("TOT"); | |
279 | } | |
5ae71069 | 280 | |
281 | // Store ADC (de)calibration function in this OM according to dbase info | |
282 | fcal=0; | |
283 | fdecal=0; | |
284 | if (omd) | |
285 | { | |
286 | fcal=omd->GetCalFunction("ADC"); | |
287 | fdecal=omd->GetDecalFunction("ADC"); | |
288 | } | |
289 | if (fcal) // Calibrated ADC signals were stored | |
290 | { | |
291 | ome->SetCalFunction(0,"ADC"); | |
292 | ome->SetDecalFunction(fdecal,"ADC"); | |
293 | } | |
294 | else // Uncalibrated ADC signals were stored | |
295 | { | |
296 | ome->SetCalFunction(fcal,"ADC"); | |
297 | ome->SetDecalFunction(0,"ADC"); | |
298 | } | |
299 | ||
95f2b820 | 300 | // Store LE (de)calibration function in this OM according to dbase info |
301 | // Note for MuDaq only : This is the ADC independent function. | |
302 | // The ADC dependent calibration function is in the hits themselves | |
5ae71069 | 303 | fcal=0; |
304 | fdecal=0; | |
305 | if (omd) | |
306 | { | |
307 | fcal=omd->GetCalFunction("LE"); | |
308 | fdecal=omd->GetDecalFunction("LE"); | |
309 | } | |
310 | if (fcal) // Calibrated LE signals were stored | |
311 | { | |
312 | ome->SetCalFunction(0,"LE"); | |
313 | ome->SetDecalFunction(fdecal,"LE"); | |
314 | } | |
315 | else // Uncalibrated LE signals were stored | |
316 | { | |
317 | ome->SetCalFunction(fcal,"LE"); | |
318 | ome->SetDecalFunction(0,"LE"); | |
319 | } | |
320 | ||
321 | // Store TOT (de)calibration function in this OM according to dbase info | |
322 | fcal=0; | |
323 | fdecal=0; | |
324 | if (omd) | |
325 | { | |
326 | fcal=omd->GetCalFunction("TOT"); | |
327 | fdecal=omd->GetDecalFunction("TOT"); | |
328 | } | |
329 | if (fcal) // Calibrated TOT signals were stored | |
330 | { | |
331 | ome->SetCalFunction(0,"TOT"); | |
332 | ome->SetDecalFunction(fdecal,"TOT"); | |
333 | } | |
334 | else // Uncalibrated TOT signals were stored | |
335 | { | |
336 | ome->SetCalFunction(fcal,"TOT"); | |
337 | ome->SetDecalFunction(0,"TOT"); | |
338 | } | |
339 | } // End of loop over OM's of the event | |
a4b77ddf | 340 | } |
341 | /////////////////////////////////////////////////////////////////////////// |