1 /*******************************************************************************
2 * Copyright(c) 2003, IceCube Experiment at the South Pole. All rights reserved.
4 * Author: The IceCube RALICE-based Offline 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.
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 *******************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // TTask derived class to perform the various calibrations.
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
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
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.
46 //--- Author: Nick van Eijndhoven 18-sep-2005 Utrecht University
47 //- Modified: NvE $Date$ Utrecht University
48 ///////////////////////////////////////////////////////////////////////////
50 #include "IceCalibrate.h"
51 #include "Riostream.h"
53 ClassImp(IceCalibrate) // Class implementation to enable ROOT I/O
55 IceCalibrate::IceCalibrate(const char* name,const char* title) : TTask(name,title)
57 // Default constructor.
61 ///////////////////////////////////////////////////////////////////////////
62 IceCalibrate::~IceCalibrate()
64 // Default destructor.
71 ///////////////////////////////////////////////////////////////////////////
72 void IceCalibrate::SetOMdbase(AliObjMatrix* omdb)
74 // Set the pointer to the OM database.
75 // Note : this will overrule a previously attached database.
78 ///////////////////////////////////////////////////////////////////////////
79 void IceCalibrate::SetCalibFile(TString name)
81 // Set the calibration ROOT file as created with IceCal2Root.
82 // Note : this will overrule a previously attached database.
83 fCalfile=new TFile(name.Data());
86 fOmdb=(AliObjMatrix*)fCalfile->Get("Cal-OMDBASE");
89 ///////////////////////////////////////////////////////////////////////////
90 void IceCalibrate::Exec(Option_t* opt)
92 // Implementation of the various calibration procedures.
95 AliJob* parent=(AliJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
99 IceEvent* evt=(IceEvent*)parent->GetObject("IceEvent");
102 // All OMs with a signal
103 TObjArray* mods=evt->GetDevices("IceGOM");
105 Int_t nmods=mods->GetEntries();
108 IceGOM* ome=0; // The event OM pointer
109 IceGOM* omd=0; // The database OM pointer
117 for (Int_t imod=0; imod<nmods; imod++)
119 ome=(IceGOM*)mods->At(imod);
122 id=ome->GetUniqueID();
125 if (fOmdb) omd=(IceGOM*)fOmdb->GetObject(id,1);
127 // Set global OM constants
130 ome->SetPosition((Ali3Vector&)omd->GetPosition());
131 for (Int_t ind=1; ind<=omd->GetNnames(); ind++)
133 slotname=omd->GetSlotName(ind);
134 ome->SetSlotName(slotname.Data(),ind);
136 for (Int_t isd=1; isd<=omd->GetNvalues(); isd++)
138 ome->SetSignal(omd->GetSignal(isd),isd);
143 for (Int_t ise=8; ise<=ome->GetNvalues(); ise++)
145 ome->SetSignal(0,ise);
148 ome->SetSignal(1,12);
149 ome->SetSignal(1,15);
152 // Make signals of bad modules available
153 ome->SetAlive("ADC");
155 ome->SetAlive("TOT");
157 // (De)calibrate all hit signals for this OM
158 for (Int_t ithit=1; ithit<=ome->GetNhits(); ithit++)
160 AliSignal* sx=ome->GetHit(ithit);
163 // ADC (de)calibration
164 sig=sx->GetSignal("ADC",-7); // Get uncalibrated signal
169 fcal=omd->GetCalFunction("ADC");
170 fdecal=omd->GetDecalFunction("ADC");
172 if (fcal) // Store calibrated signal
174 sigc=fcal->Eval(sig);
175 sx->SetSignal(sigc,"ADC");
176 ome->SetCalFunction(0,"ADC");
177 ome->SetDecalFunction(fdecal,"ADC");
179 else // Store uncalibrated signal
181 sx->SetSignal(sig,"ADC");
182 ome->SetCalFunction(fcal,"ADC");
183 ome->SetDecalFunction(0,"ADC");
186 // LE (TDC) (de)calibration
187 sig=sx->GetSignal("LE",-7); // Get uncalibrated signal
192 fcal=omd->GetCalFunction("LE");
193 fdecal=omd->GetDecalFunction("LE");
195 // Store the ADC independent (de)calibration function in the OM
198 ome->SetCalFunction(0,"LE");
199 ome->SetDecalFunction(fdecal,"LE");
203 ome->SetCalFunction(fcal,"LE");
204 ome->SetDecalFunction(0,"LE");
206 // Store the hit-specific ADC dependent (de)calibration function in the hit itself
207 sx->SetCalFunction(fcal,"LE");
208 sx->SetDecalFunction(fdecal,"LE");
209 fcal=sx->GetCalFunction("LE");
210 fdecal=sx->GetDecalFunction("LE");
211 sigc=sx->GetSignal("ADC",-7);
214 if (fcal) fcal->SetParameter(3,sigc);
215 if (fdecal) fdecal->SetParameter(3,sigc);
219 if (fcal) fcal->SetParameter(3,1.e20);
220 if (fdecal) fdecal->SetParameter(3,1.e20);
222 if (fcal) // Store calibrated signal
224 sigc=fcal->Eval(sig);
225 sx->SetSignal(sigc,"LE");
226 sx->SetCalFunction(0,"LE");
227 sx->SetDecalFunction(fdecal,"LE");
229 else // Store uncalibrated signal
231 sx->SetSignal(sig,"LE");
232 sx->SetCalFunction(fcal,"LE");
233 sx->SetDecalFunction(0,"LE");
236 // TOT (de)calibration
237 sig=sx->GetSignal("TOT",-7); // Get uncalibrated signal
242 fcal=omd->GetCalFunction("TOT");
243 fdecal=omd->GetDecalFunction("TOT");
245 if (fcal) // Store calibrated signal
247 sigc=fcal->Eval(sig);
248 sx->SetSignal(sigc,"TOT");
249 ome->SetCalFunction(0,"TOT");
250 ome->SetDecalFunction(fdecal,"TOT");
252 else // Store uncalibrated signal
254 sx->SetSignal(sig,"TOT");
255 ome->SetCalFunction(fcal,"TOT");
256 ome->SetDecalFunction(0,"TOT");
262 if (omd->GetDeadValue("ADC")) ome->SetDead("ADC");
263 if (omd->GetDeadValue("LE")) ome->SetDead("LE");
264 if (omd->GetDeadValue("TOT")) ome->SetDead("TOT");
268 ///////////////////////////////////////////////////////////////////////////