NCFS-Pack
A generic (astro)particle physics analysis framework
 
Loading...
Searching...
No Matches
IceCalibrate.cxx
Go to the documentation of this file.
1
17
19
59
60#include "IceCalibrate.h"
61#include "Riostream.h"
62
63ClassImp(IceCalibrate); // Class implementation to enable ROOT I/O
64
66IceCalibrate::IceCalibrate(const char* name,const char* title) : TTask(name,title)
67{
73
74 fCalfile=0;
75 fMuDaqDB=0;
76 fTWRDaqDB=0;
77 fJEBTDaqDB=0;
78 fJEBADaqDB=0;
79}
80
82{
88
89 if (fCalfile)
90 {
91 delete fCalfile;
92 fCalfile=0;
93 }
94}
95
96void IceCalibrate::SetOMdbase(NcObjMatrix* omdb, TString name)
97{
105
106 if(name=="MuDaq") fMuDaqDB=omdb;
107 else if(name=="TWRDaq") fTWRDaqDB=omdb;
108 else if(name=="JEBTDaq") fJEBTDaqDB=omdb;
109 else if(name=="JEBADaq") fJEBADaqDB=omdb;
110 else cout << "IceCalibrate::SetOMdbase Unknown database: " << name.Data() << endl;
111}
112
114{
124
125 // Expand the path name of the provided input file
126 name=gSystem->ExpandPathName(name.Data());
127
128 if (fCalfile)
129 {
130 delete fCalfile;
131 fCalfile=0;
132 }
133 fCalfile=new TFile(name.Data());
134
135 fMuDaqDB=(NcObjMatrix*)fCalfile->Get("MuDaq-OMDBASE");
136 fTWRDaqDB=(NcObjMatrix*)fCalfile->Get("TWRDaq-OMDBASE");
137 fJEBTDaqDB=(NcObjMatrix*)fCalfile->Get("JEBTDaq-OMDBASE");
138 fJEBADaqDB=(NcObjMatrix*)fCalfile->Get("JEBADaq-OMDBASE");
139}
140
141void IceCalibrate::Exec(Option_t* opt)
142{
148
149 TString name=opt;
150 NcJob* parent=(NcJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
151
152 if (!parent) return;
153
154 IceEvent* evt=(IceEvent*)parent->GetObject("IceEvent");
155 if (!evt) return;
156
157 // Only process accepted events
158 NcDevice* seldev=(NcDevice*)evt->GetDevice("NcEventSelector");
159 if (seldev)
160 {
161 if (seldev->GetSignal("Select") < 0.1) return;
162 }
163
164 Int_t mudaq=0;
165 Int_t twrdaq=0;
166 Int_t jebdaq=0;
167 NcSignal* daq=(NcSignal*)evt->GetDevice("Daq");
168 mudaq=int(daq->GetSignal("Muon"));
169 twrdaq=int(daq->GetSignal("TWR"));
170 jebdaq=int(daq->GetSignal("JEB"));
171
172 // Storage of the used parameters in the IceCalibrate device
173 NcDevice params;
174 params.SetNameTitle("IceCalibrate","IceCalibrate processor parameters");
175 params.AddNamedSlot("MuDaq-OMDBASE");
176 if (fMuDaqDB) params.SetSignal(1,"MuDaq-OMDBASE");
177 params.AddNamedSlot("TWRDaq-OMDBASE");
178 if (fTWRDaqDB) params.SetSignal(1,"TWRDaq-OMDBASE");
179 params.AddNamedSlot("JEBTDaq-OMDBASE");
180 if (fJEBTDaqDB) params.SetSignal(1,"JEBTDaq-OMDBASE");
181 params.AddNamedSlot("JEBADaq-OMDBASE");
182 if (fJEBADaqDB) params.SetSignal(1,"JEBADaq-OMDBASE");
183
184 evt->AddDevice(params);
185
186 // All OMs with a signal
187 TObjArray* mods=evt->GetDevices("IceGOM");
188 if (!mods) return;
189
190 Int_t nmods=mods->GetEntries();
191 if (!nmods) return;
192
193 IceGOM* ome=0; // The event OM pointer
194 IceGOM* omd=0; // The database OM pointer
195 Int_t id=0;
196 Float_t adc=0,le=0,tot=0; // Uncalibrated values
197 Float_t cadc=0,cle=0,ctot=0; // Calibrated values
198 TF1* fcal=0;
199 TF1* fdecal=0;
200 TString slotname;
201
202 for (Int_t imod=0; imod<nmods; imod++)
203 {
204 ome=(IceGOM*)mods->At(imod);
205 if (!ome) continue;
206
207 id=ome->GetUniqueID();
208
209 omd=0;
210
211 // Amanda OM
212 if(ome->InheritsFrom("IceAOM")){
213 if(mudaq && fMuDaqDB) omd=(IceGOM*)fMuDaqDB->GetObject(id,1);
214 if(twrdaq && fTWRDaqDB) omd=(IceGOM*)fTWRDaqDB->GetObject(id,1);
215 if(jebdaq && fJEBTDaqDB) omd=(IceGOM*)fJEBTDaqDB->GetObject(id,1);
216 }
217 // IceCube DOM
218 if(ome->InheritsFrom("IceDOM")){
219 if(jebdaq && fJEBADaqDB) omd=(IceGOM*)fJEBADaqDB->GetObject(id,1);
220 }
221
222 // Set global OM constants
223 if (omd)
224 {
225 ome->SetPosition((Nc3Vector&)omd->GetPosition());
226 for (Int_t ind=1; ind<=omd->GetNnames(); ind++)
227 {
228 slotname=omd->GetSlotName(ind);
229 ome->AddNamedSlot(slotname);
230 }
231 for (Int_t isd=1; isd<=omd->GetNvalues(); isd++)
232 {
233 ome->SetSignal(omd->GetSignal(isd),omd->GetSlotName(isd));
234 }
235 }
236
237 // Make signals of bad modules available
238 ome->SetAlive("ADC");
239 ome->SetAlive("LE");
240 ome->SetAlive("TOT");
241
242 // (De)calibrate all hit signals for this OM
243 for (Int_t ithit=1; ithit<=ome->GetNhits(); ithit++)
244 {
245 NcSignal* sx=ome->GetHit(ithit);
246 if (!sx) continue;
247
248 // ADC (de)calibration
249 adc=sx->GetSignal("ADC",-7); // Get uncalibrated signal
250 fcal=0;
251 fdecal=0;
252 if (omd)
253 {
254 fcal=omd->GetCalFunction("ADC");
255 fdecal=omd->GetDecalFunction("ADC");
256 }
257 if (fcal) // Store calibrated signal
258 {
259 cadc=fcal->Eval(adc);
260 sx->SetSignal(cadc,"ADC");
261 }
262 else // Store uncalibrated signal
263 {
264 sx->SetSignal(adc,"ADC");
265 }
266
267 // LE (TDC) (de)calibration
268 le=sx->GetSignal("LE",-7); // Get uncalibrated signal
269 fcal=0;
270 fdecal=0;
271 if (omd)
272 {
273 fcal=omd->GetCalFunction("LE");
274 fdecal=omd->GetDecalFunction("LE");
275 }
276
277 // MuDaq only : Store the hit-specific ADC dependent (de)calibration function in the hit itself
278 if (mudaq)
279 {
280 sx->SetCalFunction(fcal,"LE");
281 sx->SetDecalFunction(fdecal,"LE");
282 fcal=sx->GetCalFunction("LE");
283 fdecal=sx->GetDecalFunction("LE");
284 if (adc>0)
285 {
286 if (fcal) fcal->SetParameter(3,adc);
287 if (fdecal) fdecal->SetParameter(3,adc);
288 }
289 else
290 {
291 if (fcal) fcal->SetParameter(3,1.e20);
292 if (fdecal) fdecal->SetParameter(3,1.e20);
293 }
294 }
295
296 if (fcal) // Store calibrated signal
297 {
298 cle=fcal->Eval(le);
299 sx->SetSignal(cle,"LE");
300 if (mudaq) // MuDaq only
301 {
302 sx->SetCalFunction(0,"LE");
303 sx->SetDecalFunction(fdecal,"LE");
304 }
305 }
306 else // Store uncalibrated signal
307 {
308 sx->SetSignal(le,"LE");
309 if (mudaq) // MuDaq only
310 {
311 sx->SetCalFunction(fcal,"LE");
312 sx->SetDecalFunction(0,"LE");
313 }
314 }
315
316 // TOT (de)calibration
317 tot=sx->GetSignal("TOT",-7); // Get uncalibrated signal
318 fcal=0;
319 fdecal=0;
320 if (omd)
321 {
322 fcal=omd->GetCalFunction("TOT");
323 fdecal=omd->GetDecalFunction("TOT");
324 }
325 if (fcal) // Store calibrated signal
326 {
327 ctot=fcal->Eval(tot);
328 sx->SetSignal(ctot,"TOT");
329 }
330 else // Store uncalibrated signal
331 {
332 sx->SetSignal(tot,"TOT");
333 }
334 } // End of loop over hits of the OM
335
336 // Set bad OM flags according to dbase info
337 if (omd)
338 {
339 if (omd->GetDeadValue("ADC")) ome->SetDead("ADC");
340 if (omd->GetDeadValue("LE")) ome->SetDead("LE");
341 if (omd->GetDeadValue("TOT")) ome->SetDead("TOT");
342 }
343
344 // Store ADC (de)calibration function in this OM according to dbase info
345 fcal=0;
346 fdecal=0;
347 if (omd)
348 {
349 fcal=omd->GetCalFunction("ADC");
350 fdecal=omd->GetDecalFunction("ADC");
351 }
352 if (fcal) // Calibrated ADC signals were stored
353 {
354 ome->SetCalFunction(0,"ADC");
355 ome->SetDecalFunction(fdecal,"ADC");
356 }
357 else // Uncalibrated ADC signals were stored
358 {
359 ome->SetCalFunction(fcal,"ADC");
360 ome->SetDecalFunction(0,"ADC");
361 }
362
363 // Store LE (de)calibration function in this OM according to dbase info
364 // Note for MuDaq only : This is the ADC independent function.
365 // The ADC dependent calibration function is in the hits themselves
366 fcal=0;
367 fdecal=0;
368 if (omd)
369 {
370 fcal=omd->GetCalFunction("LE");
371 fdecal=omd->GetDecalFunction("LE");
372 }
373 if (fcal) // Calibrated LE signals were stored
374 {
375 ome->SetCalFunction(0,"LE");
376 ome->SetDecalFunction(fdecal,"LE");
377 }
378 else // Uncalibrated LE signals were stored
379 {
380 ome->SetCalFunction(fcal,"LE");
381 ome->SetDecalFunction(0,"LE");
382 }
383
384 // Store TOT (de)calibration function in this OM according to dbase info
385 fcal=0;
386 fdecal=0;
387 if (omd)
388 {
389 fcal=omd->GetCalFunction("TOT");
390 fdecal=omd->GetDecalFunction("TOT");
391 }
392 if (fcal) // Calibrated TOT signals were stored
393 {
394 ome->SetCalFunction(0,"TOT");
395 ome->SetDecalFunction(fdecal,"TOT");
396 }
397 else // Uncalibrated TOT signals were stored
398 {
399 ome->SetCalFunction(fcal,"TOT");
400 ome->SetDecalFunction(0,"TOT");
401 }
402 } // End of loop over OM's of the event
403}
404
ClassImp(IceCalibrate)
TTask derived class to perform the various calibrations.
NcObjMatrix * fJEBTDaqDB
TFile * fCalfile
void SetOMdbase(NcObjMatrix *omdb, TString name="MuDaq")
void SetCalibFile(TString name)
NcObjMatrix * fMuDaqDB
virtual void Exec(Option_t *opt)
NcObjMatrix * fJEBADaqDB
IceCalibrate(const char *name="", const char *title="")
NcObjMatrix * fTWRDaqDB
virtual ~IceCalibrate()
Handling of IceCube event data.
Definition IceEvent.h:20
Signal (Hit) handling of a generic IceCube Optical Module (GOM).
Definition IceGOM.h:12
Handling of 3-vectors in various reference frames.
Definition Nc3Vector.h:15
TString GetSlotName(Int_t j=1) const
void SetCalFunction(TF1 *f, Int_t j=1)
void SetAlive(Int_t j=1)
Definition NcAttrib.cxx:946
void AddNamedSlot(TString s)
void SetDecalFunction(TF1 *f, Int_t j=1)
Int_t GetDeadValue(Int_t j=1) const
TF1 * GetCalFunction(Int_t j=1) const
void SetDead(Int_t j=1)
Definition NcAttrib.cxx:886
TF1 * GetDecalFunction(Int_t j=1) const
Int_t GetNnames() const
Definition NcAttrib.cxx:248
Signal (Hit) handling of a generic device.
Definition NcDevice.h:14
Int_t GetNhits() const
Definition NcDevice.cxx:437
NcSignal * GetHit(Int_t j) const
Definition NcDevice.cxx:489
void AddDevice(NcDevice &d)
Definition NcEvent.cxx:1210
NcDevice * GetDevice(Int_t i) const
Definition NcEvent.cxx:1380
TObjArray * GetDevices(TString classname, TObjArray *devices=0)
Definition NcEvent.cxx:1656
Base class for top level job in a task based procedure.
Definition NcJob.h:18
TObject * GetObject(const char *classname) const
Definition NcJob.cxx:456
Handling of a matrix structure of objects.
Definition NcObjMatrix.h:13
void GetPosition(Double_t *r, TString f, TString u="rad", Float_t s=-1) const
void SetPosition(Double_t *r, TString f, TString u="rad")
Generic handling of (extrapolated) detector signals.
Definition NcSignal.h:23
virtual void SetSignal(Double_t sig, Int_t j=1)
Definition NcSignal.cxx:516
virtual Float_t GetSignal(Int_t j=1, Int_t mode=0) const
Definition NcSignal.cxx:651
Int_t GetNvalues() const