]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/icepack/IceCleanHits.cxx
13-nov-2005 NvE IceF2k updated to store also the event trigger information in the...
[u/mrichter/AliRoot.git] / RALICE / icepack / IceCleanHits.cxx
CommitLineData
34d0a9fe 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 IceCleanHits
20// TTask derived class to perform hit cleaning.
21//
22// The code in this processor is based on the algorithms as developed
23// by Oladipo Fadiran and George Japaridze (Clark Atlanta University, USA).
24//
25// Criteria applied for Amanda modules :
26// -------------------------------------
27// 1) ADC within [min,max] Default : [0.3,999999] PE
28// 2) TOT within [min,max] Default : electrical [125,2000] optical [20,2000] ns
69884331 29// 3) abs(LE-Ttrig)<=win Default : win=2250 TDC counts
30// where : LE=uncalibrated hit LE (i.e. TDC counts) Ttrig=trigger pulse LE in TDC counts
34d0a9fe 31// 4) At least one other hit within radius R and time difference dt
32// to remove isolated hits. Defaults : R=70 m dt=500 ns
33//
34// The defaults of the various parameters can be changed by the corresponding
35// Set memberfunctions.
36//
668c6f58 37// Concerning the trigger time :
38// -----------------------------
69884331 39// By default the trigger time is obtained automatically from the IceEvent structure
40// via the device called "Trigger".
41// The uncalibrated LE (i.e. TDC counts) of a specified trigger pulse is used.
42// The user can impose a specific trigger name or time to be used
43// by invokation of the memberfunctions SetTnameA or SetTtimeA, respectively.
eb90778a 44// Specification of a negative trigger time will result in the automatic
69884331 45// trigger time setting corresponding to the "main" trigger.
46// By default the trigger time of the "main" trigger will be used.
668c6f58 47//
34d0a9fe 48// The hits which do not fullfill the criteria are flagged "dead" for the
49// corresponding signal slot. This means they are still present in the
50// IceEvent structure and are as such still accessible.
51// It is left to the user to decide (based on the various "dead" flag settings)
52// whether or not to use these hits in his/her reconstruction or analysis.
53//
54// Note : This processor only works properly on Time and ADC calibrated data.
55//
56//--- Author: Nick van Eijndhoven 13-oct-2005 Utrecht University
57//- Modified: NvE $Date$ Utrecht University
58///////////////////////////////////////////////////////////////////////////
59
60#include "IceCleanHits.h"
61#include "Riostream.h"
62
63ClassImp(IceCleanHits) // Class implementation to enable ROOT I/O
64
65IceCleanHits::IceCleanHits(const char* name,const char* title) : TTask(name,title)
66{
67// Default constructor.
68 fEvt=0;
69 fAdcminA=0.3;
70 fAdcmaxA=999999;
71 fTotminAE=125;
72 fTotmaxAE=2000;
73 fTotminAO=20;
74 fTotmaxAO=2000;
75 fRmaxA=70;
76 fDtmaxA=500;
77 fTwinA=2250;
eb90778a 78 fTtimA=-1;
69884331 79 fTnamA="main";
34d0a9fe 80}
81///////////////////////////////////////////////////////////////////////////
82IceCleanHits::~IceCleanHits()
83{
84// Default destructor.
85}
86///////////////////////////////////////////////////////////////////////////
87void IceCleanHits::SetAdcRangeA(Float_t min,Float_t max)
88{
89// Set Amanda ADC range in PE.
90// The default for the maximum is 999999.
91 fAdcminA=min;
92 fAdcmaxA=max;
93}
94///////////////////////////////////////////////////////////////////////////
95void IceCleanHits::SetTotRangeAE(Float_t min,Float_t max)
96{
97// Set Amanda electrical TOT range in ns.
98// The default for the maximum is 2000.
99 fTotminAE=min;
100 fTotmaxAE=max;
101}
102///////////////////////////////////////////////////////////////////////////
103void IceCleanHits::SetTotRangeAO(Float_t min,Float_t max)
104{
105// Set Amanda optical TOT range in ns.
106// The default for the maximum is 2000.
107 fTotminAO=min;
108 fTotmaxAO=max;
109}
110///////////////////////////////////////////////////////////////////////////
111void IceCleanHits::SetIsolationA(Float_t rmax,Float_t dtmax)
112{
113// Set Amanda isolation radius (in m) and time difference (in ns).
114 fRmaxA=rmax;
115 fDtmaxA=dtmax;
116}
117///////////////////////////////////////////////////////////////////////////
118void IceCleanHits::SetTwindowA(Float_t dtmax)
119{
69884331 120// Set Amanda maximal trigger window (in TDC counts).
34d0a9fe 121// Only hits which occur in [T-dtmax,T+dtmax] will be kept,
69884331 122// where T indicates the trigger time in TDC counts.
123// For the Amanda DAQ hardware, 1 TDC corresponds to about 1.04 ns.
34d0a9fe 124 fTwinA=dtmax;
125}
126///////////////////////////////////////////////////////////////////////////
eb90778a 127void IceCleanHits::SetTtimeA(Float_t t)
128{
69884331 129// Set Amanda trigger time (in TDC counts).
eb90778a 130// A negative value will induce automatic trigger time setting based
69884331 131// on "main" trigger as recorded in the IceEvent structure.
eb90778a 132 fTtimA=t;
69884331 133 fTnamA="user";
134 if (t<0) fTnamA="main";
135}
136///////////////////////////////////////////////////////////////////////////
137void IceCleanHits::SetTnameA(TString name)
138{
139// Set Amanda trigger name.
140// Specification of a non-existing trigger name will result in a trigger time
141// value of -1.
142 fTtimA=-1;
143 fTnamA="name";
eb90778a 144}
145///////////////////////////////////////////////////////////////////////////
34d0a9fe 146void IceCleanHits::Exec(Option_t* opt)
147{
148// Implementation of the hit cleaning procedures.
149
150 TString name=opt;
151 AliJob* parent=(AliJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
152
153 if (!parent) return;
154
155 fEvt=(IceEvent*)parent->GetObject("IceEvent");
156 if (!fEvt) return;
157
158 Amanda();
159 InIce();
160 IceTop();
161}
162///////////////////////////////////////////////////////////////////////////
163void IceCleanHits::Amanda()
164{
165// Hit cleaning for Amanda modules.
166
69884331 167 // Trigger time setting according to the user selection.
168 // By default the "main" trigger of the event will be used.
169 if (fTnamA != "user")
eb90778a 170 {
69884331 171 AliDevice* tdev=(AliDevice*)fEvt->GetDevice("Trigger");
172 if (tdev)
173 {
174 AliSignal* trig=tdev->GetHit(fTnamA);
175 if (trig) fTtimA=trig->GetSignal("trig_pulse_le");
176 }
eb90778a 177 }
668c6f58 178
34d0a9fe 179 // All Amanda OMs with a signal
180 TObjArray* aoms=fEvt->GetDevices("IceAOM");
181
182 // Local OM array with bad/dead OMs (as indicated via IceCalibrate) discarded
183 TObjArray oms;
184 IceAOM* omx=0;
185 for (Int_t i=0; i<aoms->GetEntries(); i++)
186 {
187 omx=(IceAOM*)aoms->At(i);
188 if (!omx) continue;
189 if (omx->GetDeadValue("ADC") || omx->GetDeadValue("LE") || omx->GetDeadValue("TOT")) continue;
190 oms.Add(omx);
191 }
192
193 // Local array with clean hits
194 TObjArray hits;
195 Int_t omid=0;
196 Int_t clean=1;
197 AliSignal* sx=0;
198 Float_t adc,le,tot;
34d0a9fe 199 for (Int_t iom=0; iom<oms.GetEntries(); iom++)
200 {
201 omx=(IceAOM*)oms.At(iom);
202 if (!omx) continue;
203 omid=omx->GetUniqueID();
204 for (Int_t ih=1; ih<=omx->GetNhits(); ih++)
205 {
206 sx=omx->GetHit(ih);
207 if (!sx) continue;
208 adc=sx->GetSignal("ADC",7);
209 le=sx->GetSignal("LE",7);
210 tot=sx->GetSignal("TOT",7);
211
212 // Remove hits with an ADC value outside the range
213 if (adc<fAdcminA || adc>fAdcmaxA)
214 {
215 sx->SetDead("ADC");
216 clean=0;
217 }
218 // Remove hits with a TOT value outside the range
219 // Note : Different ranges for electrical and optical modules
220 if (omid<303) // Electrical OMs
221 {
222 if (tot<fTotminAE || tot>fTotmaxAE)
223 {
224 sx->SetDead("TOT");
225 clean=0;
226 }
227 }
228 else // Optical OMs
229 {
230 if (tot<fTotminAO || tot>fTotmaxAO)
231 {
232 sx->SetDead("TOT");
233 clean=0;
234 }
235 }
668c6f58 236 // Remove hits that are outside the trigger time window.
237 // Since the trigger time was determined from uncalibrated LE's
238 // (to include cable length effects) the uncalibrated LE of each
239 // hit should be used here as well.
240 le=sx->GetSignal("LE",-7);
eb90778a 241 if (fabs(le-fTtimA)>fTwinA)
34d0a9fe 242 {
243 sx->SetDead("LE");
244 clean=0;
245 }
34d0a9fe 246 // Store only the current clean hits in our local hit array
247 // This will save CPU time for the isolation criterion
248 if (clean) hits.Add(sx);
249 }
250 }
251
252 // Isolation cut
253 // Only retain hits that have at least one other hit within a certain
254 // radius and within a certain time window
255 Int_t nhits=hits.GetEntries();
256 AliSignal* sx1=0;
257 AliSignal* sx2=0;
258 Float_t t1,t2;
259 IceAOM* omx1=0;
260 IceAOM* omx2=0;
261 AliPosition r1;
262 AliPosition r2;
263 Float_t dt,dr;
264 Int_t iso;
265 for (Int_t jh1=0; jh1<nhits; jh1++)
266 {
267 sx1=(AliSignal*)hits.At(jh1);
268 if (!sx1) continue;
269 iso=1;
270 for (Int_t jh2=0; jh2<nhits; jh2++)
271 {
272 if (jh1==jh2)
273 {
274 iso=0;
275 continue;
276 }
277 sx2=(AliSignal*)hits.At(jh2);
278 if (!sx2) continue;
279 t1=sx1->GetSignal("LE",7);
280 t2=sx2->GetSignal("LE",7);
281 dt=fabs(t2-t1);
282 if (dt>fDtmaxA) continue;
283 omx1=(IceAOM*)sx1->GetDevice();
284 omx2=(IceAOM*)sx2->GetDevice();
285 if (omx1 && omx2)
286 {
287 r1=omx1->GetPosition();
288 r2=omx2->GetPosition();
289 dr=r1.GetDistance(r2);
290 if (dr>fRmaxA) continue;
291 iso=0;
292 }
293 }
294 if (iso) sx1->SetDead("LE");
295 }
296}
297///////////////////////////////////////////////////////////////////////////
298void IceCleanHits::InIce()
299{
300// Hit cleaning for IceCube InIce DOMs.
301}
302///////////////////////////////////////////////////////////////////////////
303void IceCleanHits::IceTop()
304{
305// Hit cleaning for IceTop DOMs.
306}
307///////////////////////////////////////////////////////////////////////////