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 hit cleaning.
22 // In case an event has been rejected by an AliEventSelector (based) processor,
23 // this task (and its sub-tasks) is not executed.
25 // The code in this processor is based on the algorithms as developed
26 // by Oladipo Fadiran and George Japaridze (Clark Atlanta University, USA).
28 // Criteria applied for Amanda MuDaq data :
29 // ----------------------------------------
30 // 1) ADC within [min,max] Default : [0.3,999999] PE
31 // 2) TOT within [min,max] Default : electrical [125,2000] optical [20,2000] ns
32 // 3) abs(LE-Ttrig)<=win Default : win=2250 TDC counts
33 // where : LE=uncalibrated hit LE (i.e. TDC counts) Ttrig=trigger pulse LE in TDC counts
34 // 4) At least one hit in another OM within radius R and time difference dt
35 // to remove isolated hits. Defaults : R=70 m dt=500 ns
37 // Criteria applied for Amanda TWRDaq data :
38 // ----------------------------------------
39 // 1) ADC within [min,max] Default : [0.3,999999] PE
40 // 2) TOT within [min,max] Default : electrical [125,2000] optical [20,2000] ns
41 // 3) abs(LE-Ttrig)<=win Default : win=3000 ns
42 // where : LE=uncalibrated hit LE Ttrig=trigger pulse LE
43 // 4) At least one hit in another OM within radius R and time difference dt
44 // to remove isolated hits. Defaults : R=70 m dt=500 ns
46 // The actual DAQ system is obtained automatically from the IceEvent structure
47 // via the device called "Daq".
49 // The defaults of the various parameters can be changed by the corresponding
50 // Set memberfunctions.
52 // Information about the actual parameter settings can be found in the event
53 // structure itself via the device named "IceCleanHits".
55 // Concerning the trigger time :
56 // -----------------------------
57 // By default the trigger time is obtained automatically from the IceEvent structure
58 // via the device called "Trigger".
59 // The uncalibrated LE of a specified trigger pulse is used.
60 // The user can impose a specific trigger name or time to be used
61 // by invokation of the memberfunctions SetTnameA or SetTtimeA, respectively.
62 // Specification of a negative trigger time will result in the automatic
63 // trigger time setting corresponding to the "main" trigger.
64 // By default the trigger time of the "main" trigger will be used.
66 // The hits which do not fullfill the criteria are flagged "dead" for the
67 // corresponding signal slot. This means they are still present in the
68 // IceEvent structure and are as such still accessible.
69 // It is left to the user to decide (based on the various "dead" flag settings)
70 // whether or not to use these hits in his/her reconstruction or analysis.
72 // Note : This processor only works properly on Time and ADC calibrated data.
74 //--- Author: Nick van Eijndhoven 13-oct-2005 Utrecht University
75 //- Modified: NvE $Date$ Utrecht University
76 ///////////////////////////////////////////////////////////////////////////
78 #include "IceCleanHits.h"
79 #include "Riostream.h"
81 ClassImp(IceCleanHits) // Class implementation to enable ROOT I/O
83 IceCleanHits::IceCleanHits(const char* name,const char* title) : TTask(name,title)
85 // Default constructor.
108 ///////////////////////////////////////////////////////////////////////////
109 IceCleanHits::~IceCleanHits()
111 // Default destructor.
113 ///////////////////////////////////////////////////////////////////////////
114 void IceCleanHits::SetAdcRangeA(Float_t min,Float_t max,TString s)
116 // Set Amanda ADC range in PE.
117 // The default for the maximum is 999999.
118 // The argument "s" specifies the DAQ system (i.e. "MuDaq" or "TWRDaq").
119 // For backward compatibility the default is s="MuDaq".
132 ///////////////////////////////////////////////////////////////////////////
133 void IceCleanHits::SetTotRangeAE(Float_t min,Float_t max,TString s)
135 // Set Amanda electrical TOT range in ns.
136 // The default for the maximum is 2000.
137 // The argument "s" specifies the DAQ system (i.e. "MuDaq" or "TWRDaq").
138 // For backward compatibility the default is s="MuDaq".
151 ///////////////////////////////////////////////////////////////////////////
152 void IceCleanHits::SetTotRangeAO(Float_t min,Float_t max,TString s)
154 // Set Amanda optical TOT range in ns.
155 // The default for the maximum is 2000.
156 // The argument "s" specifies the DAQ system (i.e. "MuDaq" or "TWRDaq").
157 // For backward compatibility the default is s="MuDaq".
170 ///////////////////////////////////////////////////////////////////////////
171 void IceCleanHits::SetIsolationA(Float_t rmax,Float_t dtmax)
173 // Set Amanda isolation radius (in m) and time difference (in ns).
177 ///////////////////////////////////////////////////////////////////////////
178 void IceCleanHits::SetTwindowA(Float_t dtmax,TString s)
180 // Set Amanda maximal trigger window.
181 // Only hits which occur in [T-dtmax,T+dtmax] will be kept,
182 // where T indicates the trigger time.
183 // For the Amanda MuDaq hardware, the times are all in TDC counts,
184 // where 1 TDC corresponds to about 1.04 ns.
185 // For the TWRDaq, the times are all in nanoseconds.
186 // The argument "s" specifies the DAQ system (i.e. "MuDaq" or "TWRDaq").
187 // For backward compatibility the default is s="MuDaq".
189 if (s=="MuDaq") fTwinAM=dtmax;
190 if (s=="TWRDaq") fTwinAT=dtmax;
192 ///////////////////////////////////////////////////////////////////////////
193 void IceCleanHits::SetTtimeA(Float_t t,TString s)
195 // Set Amanda trigger time.
196 // For the Amanda MuDaq hardware, the times are all in TDC counts,
197 // where 1 TDC corresponds to about 1.04 ns.
198 // For the TWRDaq, the times are all in nanoseconds.
199 // The argument "s" specifies the DAQ system (i.e. "MuDaq" or "TWRDaq").
200 // For backward compatibility the default is s="MuDaq".
201 // A negative value will induce automatic trigger time setting based
202 // on "main" trigger as recorded in the IceEvent structure.
208 if (t<0) fTnamAM="main";
214 if (t<0) fTnamAT="main";
217 ///////////////////////////////////////////////////////////////////////////
218 void IceCleanHits::SetTnameA(TString name,TString s)
220 // Set Amanda trigger name.
221 // The argument "s" specifies the DAQ system (i.e. "MuDaq" or "TWRDaq").
222 // For backward compatibility the default is s="MuDaq".
223 // Specification of a non-existing trigger name will result in a trigger time
237 ///////////////////////////////////////////////////////////////////////////
238 void IceCleanHits::Exec(Option_t* opt)
240 // Implementation of the hit cleaning procedures.
243 AliJob* parent=(AliJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
247 fEvt=(IceEvent*)parent->GetObject("IceEvent");
250 // Only process accepted events
251 AliDevice* seldev=(AliDevice*)fEvt->GetDevice("AliEventSelector");
254 if (seldev->GetSignal("Select") < 0.1) return;
257 // Storage of the used parameters in the IceCleanHits device
259 params.SetNameTitle("IceCleanHits","IceCleanHits processor parameters");
260 params.SetSlotName("AdcminAM",1);
261 params.SetSlotName("AdcmaxAM",2);
262 params.SetSlotName("TotminAEM",3);
263 params.SetSlotName("TotmaxAEM",4);
264 params.SetSlotName("TotminAOM",5);
265 params.SetSlotName("TotmaxAOM",6);
266 params.SetSlotName("RmaxA",7);
267 params.SetSlotName("DtmaxA",8);
268 params.SetSlotName("TwinAM",9);
269 params.SetSlotName("TtimAM",10);
270 params.SetSlotName("AdcminAT",11);
271 params.SetSlotName("AdcmaxAT",12);
272 params.SetSlotName("TotminAET",13);
273 params.SetSlotName("TotmaxAET",14);
274 params.SetSlotName("TotminAOT",15);
275 params.SetSlotName("TotmaxAOT",16);
276 params.SetSlotName("TwinAT",17);
277 params.SetSlotName("TtimAT",18);
279 params.SetSignal(fAdcminAM,1);
280 params.SetSignal(fAdcmaxAM,2);
281 params.SetSignal(fTotminAEM,3);
282 params.SetSignal(fTotmaxAEM,4);
283 params.SetSignal(fTotminAOM,5);
284 params.SetSignal(fTotmaxAOM,6);
285 params.SetSignal(fRmaxA,7);
286 params.SetSignal(fDtmaxA,8);
287 params.SetSignal(fTwinAM,9);
288 params.SetSignal(fTtimAM,10);
289 params.SetSignal(fAdcminAT,11);
290 params.SetSignal(fAdcmaxAT,12);
291 params.SetSignal(fTotminAET,13);
292 params.SetSignal(fTotmaxAET,14);
293 params.SetSignal(fTotminAOT,15);
294 params.SetSignal(fTotmaxAOT,16);
295 params.SetSignal(fTwinAT,17);
296 params.SetSignal(fTtimAT,18);
298 fEvt->AddDevice(params);
304 ///////////////////////////////////////////////////////////////////////////
305 void IceCleanHits::Amanda()
307 // Hit cleaning for Amanda modules.
309 AliDevice* daq=(AliDevice*)fEvt->GetDevice("Daq");
312 if (daq->GetSignal("Muon")) MuDaq();
313 if (daq->GetSignal("TWR")) TWRDaq();
315 ///////////////////////////////////////////////////////////////////////////
316 void IceCleanHits::MuDaq()
318 // Hit cleaning for Amanda MuDaq data.
320 // Trigger time setting according to the user selection.
321 // By default the "main" trigger of the event will be used.
322 if (fTnamAM != "user")
324 AliDevice* tdev=(AliDevice*)fEvt->GetDevice("Trigger");
327 AliSignal* trig=tdev->GetHit(fTnamAM);
328 if (trig) fTtimAM=trig->GetSignal("trig_pulse_le");
332 // All Amanda OMs with a signal
333 TObjArray* aoms=fEvt->GetDevices("IceAOM");
336 // Local OM array with bad/dead OMs (as indicated via IceCalibrate) discarded
339 for (Int_t i=0; i<aoms->GetEntries(); i++)
341 omx=(IceAOM*)aoms->At(i);
343 if (omx->GetDeadValue("ADC") || omx->GetDeadValue("LE") || omx->GetDeadValue("TOT")) continue;
347 // Local array with clean hits
354 for (Int_t iom=0; iom<oms.GetEntries(); iom++)
356 omx=(IceAOM*)oms.At(iom);
358 omid=omx->GetUniqueID();
359 readout=int(omx->GetSignal("READOUT"));
360 // General readout setting in case info was missing
364 if (omid>=303) readout=2; // Optical OMs
366 for (Int_t ih=1; ih<=omx->GetNhits(); ih++)
370 adc=sx->GetSignal("ADC",7);
371 le=sx->GetSignal("LE",7);
372 tot=sx->GetSignal("TOT",7);
374 // Remove hits with an ADC value outside the range
375 if (adc<fAdcminAM || adc>fAdcmaxAM)
380 // Remove hits with a TOT value outside the range
381 // Note : Different ranges for electrical and optical modules
382 if (readout==1) // Electrical OMs
384 if (tot<fTotminAEM || tot>fTotmaxAEM)
392 if (tot<fTotminAOM || tot>fTotmaxAOM)
398 // Remove hits that are outside the trigger time window.
399 // Since the trigger time was determined from uncalibrated LE's
400 // (to include cable length effects) the uncalibrated LE of each
401 // hit should be used here as well.
402 le=sx->GetSignal("LE",-7);
403 if (fabs(le-fTtimAM)>fTwinAM)
408 // Store only the current clean hits in our local hit array
409 // This will save CPU time for the isolation criterion
410 if (clean) hits.Add(sx);
415 // Only retain hits that have at least one hit of another OM within a certain
416 // radius and within a certain time window
417 Int_t nhits=hits.GetEntries();
427 for (Int_t jh1=0; jh1<nhits; jh1++)
429 sx1=(AliSignal*)hits.At(jh1);
433 for (Int_t jh2=0; jh2<nhits; jh2++)
435 sx2=(AliSignal*)hits.At(jh2);
438 omx1=(IceAOM*)sx1->GetDevice();
439 omx2=(IceAOM*)sx2->GetDevice();
440 if (omx1==omx2) continue;
442 t1=sx1->GetSignal("LE",7);
443 t2=sx2->GetSignal("LE",7);
445 if (dt>fDtmaxA) continue;
449 r1=omx1->GetPosition();
450 r2=omx2->GetPosition();
451 dr=r1.GetDistance(r2);
452 if (dr>fRmaxA) continue;
456 if (iso) sx1->SetDead("LE");
459 ///////////////////////////////////////////////////////////////////////////
460 void IceCleanHits::TWRDaq()
462 // Hit cleaning for Amanda TWRDaq data.
464 // Trigger time setting according to the user selection.
465 // By default the "main" trigger of the event will be used.
466 if (fTnamAT != "user")
468 AliDevice* tdev=(AliDevice*)fEvt->GetDevice("Trigger");
471 AliSignal* trig=tdev->GetHit(fTnamAT);
472 if (trig) fTtimAT=trig->GetSignal("trig_pulse_le");
476 // All Amanda OMs with a signal
477 TObjArray* aoms=fEvt->GetDevices("IceAOM");
480 // Local OM array with bad/dead OMs (as indicated via IceCalibrate) discarded
483 for (Int_t i=0; i<aoms->GetEntries(); i++)
485 omx=(IceAOM*)aoms->At(i);
487 if (omx->GetDeadValue("ADC") || omx->GetDeadValue("LE") || omx->GetDeadValue("TOT")) continue;
491 // Local array with clean hits
498 for (Int_t iom=0; iom<oms.GetEntries(); iom++)
500 omx=(IceAOM*)oms.At(iom);
502 omid=omx->GetUniqueID();
503 readout=int(omx->GetSignal("READOUT"));
504 // General readout setting in case info was missing
508 if (omid>=303) readout=2; // Optical OMs
510 for (Int_t ih=1; ih<=omx->GetNhits(); ih++)
514 adc=sx->GetSignal("ADC",7);
515 le=sx->GetSignal("LE",7);
516 tot=sx->GetSignal("TOT",7);
518 // Remove hits with an ADC value outside the range
519 if (adc<fAdcminAT || adc>fAdcmaxAT)
524 // Remove hits with a TOT value outside the range
525 // Note : Different ranges for electrical and optical modules
526 if (readout==1) // Electrical OMs
528 if (tot<fTotminAET || tot>fTotmaxAET)
536 if (tot<fTotminAOT || tot>fTotmaxAOT)
542 // Remove hits that are outside the trigger time window.
543 // Since the trigger time was determined from uncalibrated LE's
544 // (to include cable length effects) the uncalibrated LE of each
545 // hit should be used here as well.
546 le=sx->GetSignal("LE",-7);
547 if (fabs(le-fTtimAT)>fTwinAT)
552 // Store only the current clean hits in our local hit array
553 // This will save CPU time for the isolation criterion
554 if (clean) hits.Add(sx);
559 // Only retain hits that have at least one hit of another OM within a certain
560 // radius and within a certain time window
561 Int_t nhits=hits.GetEntries();
571 for (Int_t jh1=0; jh1<nhits; jh1++)
573 sx1=(AliSignal*)hits.At(jh1);
577 for (Int_t jh2=0; jh2<nhits; jh2++)
579 sx2=(AliSignal*)hits.At(jh2);
582 omx1=(IceAOM*)sx1->GetDevice();
583 omx2=(IceAOM*)sx2->GetDevice();
584 if (omx1==omx2) continue;
586 t1=sx1->GetSignal("LE",7);
587 t2=sx2->GetSignal("LE",7);
589 if (dt>fDtmaxA) continue;
593 r1=omx1->GetPosition();
594 r2=omx2->GetPosition();
595 dr=r1.GetDistance(r2);
596 if (dr>fRmaxA) continue;
600 if (iso) sx1->SetDead("LE");
603 ///////////////////////////////////////////////////////////////////////////
604 void IceCleanHits::InIce()
606 // Hit cleaning for IceCube InIce DOMs.
608 ///////////////////////////////////////////////////////////////////////////
609 void IceCleanHits::IceTop()
611 // Hit cleaning for IceTop DOMs.
613 ///////////////////////////////////////////////////////////////////////////