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