]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/icepack/IceXtalk.cxx
25-sep-2006 NvE AliSample extended with memberfunction GetSpread() and also
[u/mrichter/AliRoot.git] / RALICE / icepack / IceXtalk.cxx
CommitLineData
deeffe5c 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 IceXtalk
20// TTask derived class to perform cross talk hit correction.
21//
22// This task takes the current event in memory and uses the attached
23// OM database to identify pairs of OMs which might induce cross talk.
24// For each particular transmitter and receiver pair within the event
25// a probability for cross talk induction is determined on basis of
26// the hit data and the cross talk probability functions from the OM database.
27// If this probability is above a certain threshold "pmin" and the difference
28// in LE between transmitter and receiver signal is within the bounds as
29// given by the Xtalk calibration data, the occurrence of a cross talk signal
30// of "pe" photo-electrons in the receiver is assumed and this signal is
31// lateron subtracted from the receiver ADC signal.
32// The subtraction of the Xtalk signal from the various hits is delayed
33// until the very end, since receiver OMs may also act as transmitter OMs
34// for other pair combinations.
35// In case a transmitter OM was flagged as a bad module, the check on the
36// LE time difference will not be performed and a cross talk induction
37// decision will be solely based on the corresponding probability, since
38// the latter only depends on the un-calibrated signal amplitude of the
39// transmitter hit.
40// So, hits which have induced cross talk are not completely removed
41// but their signal is corrected for the cross talk.
42// This will prevent severe losses when studying UHE events, where cross
43// talk effects are expected to have negligible effects on the observed
44// large module signals.
45//
6f94f699 46// Note : The amount with which the ADC value was corrected is stored
47// in the signal as an ADC offset. This will allow easy investigation
48// of Xtalk corrected signals and also enables successive
49// applications of this Xtalk processor to investigate (systematic)
50// effects of various criteria.
51// Example : In case an amount of 1 pe was subtracted from the ADC
52// value, the ADC offset will be set to 1.
53//
deeffe5c 54// The values of "pmin" and "pe" can be set by the user via the
55// SetMinProb() and SetXtalkPE() memberfunctions.
56// The default values are pmin=0.5 and pe=1.
57//
25eefd00 58// Information about the actual parameter settings can be found in the event
59// structure itself via the device named "IceXtalk".
60//
deeffe5c 61// In case this processor is followed by an ADC threshold hit cleaning
62// procedure, hits which only contained cross talk can be efficiently
63// skipped or removed from the event.
64// In case one would like to always remove a hit which containes induced
65// cross talk, one could set the "pe" parameter to some very large value.
66// This will result in cross talk induced hits to get large negative ADC
67// signals and can as such easily be skipped/removed afterwards.
68//
69// Note : This processor only works properly on Time and ADC calibrated data.
eb90778a 70// In case no OM database has been specified for this processor,
71// no cross talk hit correction will be performed.
deeffe5c 72//
73//--- Author: Nick van Eijndhoven 11-aug-2005 Utrecht University
74//- Modified: NvE $Date$ Utrecht University
75///////////////////////////////////////////////////////////////////////////
76
77#include "IceXtalk.h"
78#include "Riostream.h"
79
80ClassImp(IceXtalk) // Class implementation to enable ROOT I/O
81
82IceXtalk::IceXtalk(const char* name,const char* title) : TTask(name,title)
83{
84// Default constructor.
85 fCalfile=0;
86 fOmdb=0;
87 fPmin=0.5;
88 fPe=1;
89}
90///////////////////////////////////////////////////////////////////////////
91IceXtalk::~IceXtalk()
92{
93// Default destructor.
94 if (fCalfile)
95 {
96 delete fCalfile;
97 fCalfile=0;
98 }
99}
100///////////////////////////////////////////////////////////////////////////
101void IceXtalk::SetOMdbase(AliObjMatrix* omdb)
102{
103// Set the pointer to the OM database.
104// Note : this will overrule a previously attached database.
105 fOmdb=omdb;
106}
107///////////////////////////////////////////////////////////////////////////
108void IceXtalk::SetCalibFile(TString name)
109{
110// Set the calibration ROOT file as created with IceCal2Root.
111// Note : this will overrule a previously attached database.
112 fCalfile=new TFile(name.Data());
113 if (fCalfile)
114 {
27e6d856 115 fOmdb=(AliObjMatrix*)fCalfile->Get("Cal-OMDBASE");
deeffe5c 116 }
117}
118///////////////////////////////////////////////////////////////////////////
119void IceXtalk::SetMinProb(Float_t pmin)
120{
121// Set the minimal probability for cross talk induction.
122 fPmin=pmin;
123}
124///////////////////////////////////////////////////////////////////////////
125void IceXtalk::SetXtalkPE(Float_t pe)
126{
127// Set the nominal Xtalk signal in photo-electron equivalent.
128 fPe=pe;
129}
130///////////////////////////////////////////////////////////////////////////
131void IceXtalk::Exec(Option_t* opt)
132{
133// Implementation of cross talk hit correction.
134
eb90778a 135 if (!fOmdb) return;
136
deeffe5c 137 TString name=opt;
138 AliJob* parent=(AliJob*)(gROOT->GetListOfTasks()->FindObject(name.Data()));
139
140 if (!parent) return;
141
142 IceEvent* evt=(IceEvent*)parent->GetObject("IceEvent");
143 if (!evt) return;
144
25eefd00 145 // Storage of the used parameters in the IceXtalk device
146 AliSignal params;
147 params.SetNameTitle("IceXtalk","IceXtalk processor parameters");
148 params.SetSlotName("Pmin",1);
149 params.SetSlotName("Pe",2);
150
151 params.SetSignal(fPmin,1);
152 params.SetSignal(fPe,2);
153
154 evt->AddDevice(params);
155
69884331 156 // All Amanda OMs with a signal
157 TObjArray* mods=evt->GetDevices("IceAOM");
158
159 Int_t nmods=mods->GetEntries();
160 if (!nmods) return;
161
deeffe5c 162 TObjArray xhits; // Array with pointers to Xtalk hits to be corrected
163
164 IceAOM* omt=0; // Transmitter OM
165 IceAOM* omr=0; // Receiver OM
166 TF1* fxtalk=0; // The Xtalk probability function
167 Int_t idtrans=0;
168 Int_t idrec=0;
169 Float_t adct=0,let=0;
170 Float_t p=0;
171 Float_t adcr=0,ler=0;
172 Int_t ibad=0;
173 Float_t cpar=0,bpar=0,dlemin=0,dlemax=0,test=0;
174 Float_t dle=0;
175 Float_t sigcor=0;
69884331 176 for (Int_t imod=0; imod<nmods; imod++)
deeffe5c 177 {
69884331 178 omt=(IceAOM*)mods->At(imod);
deeffe5c 179 if (!omt) continue;
180 idtrans=omt->GetUniqueID();
181
182 // Also take bad transmitter modules into account
183 ibad=omt->GetDeadValue("ADC");
184 if (ibad) omt->SetAlive("ADC");
185
186 // Check for corresponding receiver modules
69884331 187 for (Int_t jmod=0; jmod<nmods; jmod++)
deeffe5c 188 {
189 // No Xtalk from a module to itself
69884331 190 if (jmod==imod) continue;
deeffe5c 191
69884331 192 omr=(IceAOM*)mods->At(jmod);
deeffe5c 193 if (!omr) continue;
194 idrec=omr->GetUniqueID();
195
196 fxtalk=(TF1*)fOmdb->GetObject(idtrans,idrec+1);
197 if (!fxtalk) continue;
198
199 // Determine Xtalk probability for each transmitter hit
200 for (Int_t ithit=1; ithit<=omt->GetNhits(); ithit++)
201 {
202 AliSignal* st=omt->GetHit(ithit);
203 if (!st) continue;
204
6f94f699 205 // Eliminate possible previous Xtalk correction
206 sigcor=st->GetOffset("ADC");
207 st->AddSignal(sigcor,"ADC");
208 st->ResetOffset("ADC");
deeffe5c 209 adct=st->GetSignal("ADC",-4); // Get uncalibrated amplitude
210 dlemin=fxtalk->GetParameter("dLE-min");
211 dlemax=fxtalk->GetParameter("dLE-max");
212 // Protection against overflow in Xtalk prob. function
213 cpar=fxtalk->GetParameter("C");
214 bpar=fxtalk->GetParameter("B");
215 test=(adct-cpar)/bpar;
216 if (test>100)
217 {
218 p=1;
219 }
220 else if (test<-100)
221 {
222 p=0;
223 }
224 else
225 {
226 p=fxtalk->Eval(adct);
227 }
228 if (p<fPmin) continue;
229
230 // Xtalk flagging for each receiver hit
231 for (Int_t irhit=1; irhit<=omr->GetNhits(); irhit++)
232 {
233 AliSignal* sr=omr->GetHit(irhit);
234 if (!sr) continue;
235
236 // Check calibrated LE time differences
237 if (!ibad)
238 {
239 let=st->GetSignal("LE",4);
240 ler=sr->GetSignal("LE",4);
241 dle=ler-let;
242 if (dle<dlemin || dle>dlemax) continue;
243 }
244 // Register this receiver hit to be corrected
245 xhits.Add(sr);
246 }
247 } // end of transmitter hit loop
248 } // end of receiver OM loop
249
250 // Restore the original transmitter dead flag value
251 if (ibad) omt->SetDead("ADC");
252 } // end of transmitter OM loop
253
254 // Perform the Xtalk signal correction to the registered receiver hits
6f94f699 255 // The correction value is stored in the signal data as an offset value
deeffe5c 256 for (Int_t ix=0; ix<xhits.GetEntries(); ix++)
257 {
258 AliSignal* sx=(AliSignal*)xhits.At(ix);
259 if (!sx) continue;
6f94f699 260
261 // Eliminate possible previous Xtalk correction
262 sigcor=sx->GetOffset("ADC");
263 adcr=sx->GetSignal("ADC")+sigcor;
deeffe5c 264 sigcor=fPe;
265 // If stored ADC data is un-calibrated, convert fPe to raw ADC value
266 AliSignal* parent=(AliSignal*)sx->GetDevice();
267 if (parent)
268 {
269 if (parent->GetCalFunction("ADC"));
270 {
271 idrec=parent->GetUniqueID();
272 omr=(IceAOM*)fOmdb->GetObject(idrec,1);
273 TF1* fdecal=0;
274 if (omr) fdecal=omr->GetDecalFunction("ADC");
275 if (fdecal) sigcor=fdecal->Eval(fPe);
276 }
277 }
278 adcr=adcr-sigcor;
279 sx->SetSignal(adcr,"ADC");
6f94f699 280 sx->SetOffset(sigcor,"ADC");
deeffe5c 281 }
282}
283///////////////////////////////////////////////////////////////////////////