]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/AliCalcluster.cxx
A cluster finder and hit reconstruction class for RICH (adapted from MUON).
[u/mrichter/AliRoot.git] / RALICE / AliCalcluster.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line 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. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Log$
f40f8fbd 18Revision 1.3 1999/11/03 14:23:17 fca
19New version of RALICE introduced
20
959fbac5 21Revision 1.2 1999/09/29 09:24:28 fca
22Introduction of the Copyright and cvs Log
23
4c039060 24*/
25
959fbac5 26///////////////////////////////////////////////////////////////////////////
27// Class AliCalcluster
28// Description of a cluster of calorimeter modules.
29// A matrix geometry is assumed in which a cluster center
30// is identified by (row,col) and contains sig as signal
31// being the signal of the complete cluster.
32// Some info about cluster topology is provided in order
33// to enable EM or hadronic cluster identification.
34//
35//--- Author: Nick van Eijndhoven 13-jun-1997 UU-SAP Utrecht
f40f8fbd 36//- Modified: NvE 18-jan-2000 UU-SAP Utrecht
959fbac5 37///////////////////////////////////////////////////////////////////////////
38
d88f97cc 39#include "AliCalcluster.h"
40
41ClassImp(AliCalcluster) // Class implementation to enable ROOT I/O
42
43AliCalcluster::AliCalcluster()
44{
45// Default constructer, all data is set to 0
46 fCenter=0;
47 fSig=0.;
48 fNmods=0;
49 fSig11=0.;
50 fSig33=0.;
51 fSig55=0.;
52 fRowdisp=0.;
53 fColdisp=0.;
54 fNvetos=0;
55 fVetos=0;
56}
57///////////////////////////////////////////////////////////////////////////
58AliCalcluster::~AliCalcluster()
59{
60// Destructor to delete dynamically allocated memory
61 if (fVetos)
62 {
63 fVetos->Delete();
64 delete fVetos;
65 fVetos=0;
66 }
67}
68///////////////////////////////////////////////////////////////////////////
69AliCalcluster::AliCalcluster(AliCalmodule& m)
70{
71// Cluster constructor with module m as center.
f40f8fbd 72// Module data is only entered for a module which contains a signal,
73// has not been used in a cluster yet, and is not declared dead.
74//
75// Note :
76// It is advised NOT to start a cluster with modules situated at a detector edge.
77// This feature is automatically checked when using the built-in clustering
78// of AliCalorimeter.
d88f97cc 79
f40f8fbd 80 Ali3Vector r;
d88f97cc 81
f40f8fbd 82 if (m.GetClusteredSignal()>0. && m.GetDeadValue()==0)
d88f97cc 83 {
84 fCenter=&m;
f40f8fbd 85 r=m.GetPosition();
86 SetPosition(r);
d88f97cc 87 fSig=m.GetClusteredSignal();
88 fNmods=1;
89 fSig11=m.GetClusteredSignal();
90 fSig33=m.GetClusteredSignal();
91 fSig55=m.GetClusteredSignal();
92 fRowdisp=0.;
93 fColdisp=0.;
94 m.SetClusteredSignal(0.); // mark module as used in cluster
95 fNvetos=0;
96 fVetos=0;
97 }
98 else
99 {
100 fCenter=0;
f40f8fbd 101 SetPosition(r);
d88f97cc 102 fSig=0.;
103 fNmods=0;
104 fSig11=0.;
105 fSig33=0.;
106 fSig55=0.;
107 fRowdisp=0.;
108 fColdisp=0.;
109 fNvetos=0;
110 fVetos=0;
111}
112}
113///////////////////////////////////////////////////////////////////////////
114Int_t AliCalcluster::GetRow()
115{
116// Provide the row number of the cluster center
117 if (fCenter)
118 {
119 return fCenter->GetRow();
120 }
121 else
122 {
123 return 0;
124 }
125}
126///////////////////////////////////////////////////////////////////////////
127Int_t AliCalcluster::GetColumn()
128{
129// Provide the column number of the cluster center
130 if (fCenter)
131 {
132 return fCenter->GetColumn();
133 }
134 else
135 {
136 return 0;
137 }
138}
139///////////////////////////////////////////////////////////////////////////
140Float_t AliCalcluster::GetSignal(Int_t n)
141{
142// Provide the total signal of a module matrix of n modules around
143// the cluster center.
144// Example : n=9 --> total signal in the 3x3 matrix
145// 1 --> signal of central module
146// Note : n=0 provides the total cluster signal (Default)
147
148 Float_t signal=-1;
149
150 if (n == 0) signal=fSig;
151 if (n == 1) signal=fSig11;
152 if (n == 9) signal=fSig33;
153 if (n == 25) signal=fSig55;
154
155 if (signal > 0.)
156 {
157 return signal;
158 }
159 else
160 {
161 cout << " *AliCalcluster::GetSignal* Invalid argument n = " << n << endl;
162 return 0;
163 }
164}
165///////////////////////////////////////////////////////////////////////////
166Int_t AliCalcluster::GetNmodules()
167{
168// Provide the number of modules in the cluster
169 return fNmods;
170}
171///////////////////////////////////////////////////////////////////////////
172Float_t AliCalcluster::GetRowDispersion()
173{
174// Provide the normalised row dispersion of the cluster
175 if (fSig > 0.)
176 {
177 return fRowdisp/fSig;
178 }
179 else
180 {
181 return 0.;
182 }
183}
184///////////////////////////////////////////////////////////////////////////
185Float_t AliCalcluster::GetColumnDispersion()
186{
187// Provide the normalised column dispersion of the cluster
188 if (fSig > 0.)
189 {
190 return fColdisp/fSig;
191 }
192 else
193 {
194 return 0.;
195 }
196}
197///////////////////////////////////////////////////////////////////////////
198void AliCalcluster::Start(AliCalmodule& m)
199{
959fbac5 200// Reset cluster data and start with module m.
f40f8fbd 201// A module can only start a cluster when it contains a signal,
202// has not been used in a cluster yet, and is not declared dead.
203//
204// Note :
205// It is advised NOT to start a cluster with modules situated at a detector edge.
206// This feature is automatically checked when using the built-in clustering
207// of AliCalorimeter.
d88f97cc 208
f40f8fbd 209 Ali3Vector r;
d88f97cc 210
f40f8fbd 211 if (m.GetClusteredSignal()>0. && m.GetDeadValue()==0)
d88f97cc 212 {
213 fCenter=&m;
f40f8fbd 214 r=m.GetPosition();
215 SetPosition(r);
d88f97cc 216 fSig=m.GetSignal();
217 fNmods=1;
218 fSig11=m.GetSignal();
219 fSig33=m.GetSignal();
220 fSig55=m.GetSignal();
221 fRowdisp=0.;
222 fColdisp=0.;
223 m.SetClusteredSignal(0.); // mark module as used in cluster
224 }
225 else
226 {
227 fCenter=0;
f40f8fbd 228 SetPosition(r);
d88f97cc 229 fSig=0.;
230 fNmods=0;
231 fSig11=0.;
232 fSig33=0.;
233 fSig55=0.;
234 fRowdisp=0.;
235 fColdisp=0.;
236 }
237}
238///////////////////////////////////////////////////////////////////////////
239void AliCalcluster::Add(AliCalmodule& m)
240{
f40f8fbd 241// Add module data to the cluster.
242// Dead modules are NOT added to the cluster.
d88f97cc 243
244 Float_t signal=m.GetClusteredSignal();
245
f40f8fbd 246 if (signal>0. && m.GetDeadValue()==0) // only add unused modules
d88f97cc 247 {
248 fSig+=signal;
249 fNmods+=1;
250 Int_t drow=int(fabs(double(GetRow()-m.GetRow()))); // row distance to center
251 Int_t dcol=int(fabs(double(GetColumn()-m.GetColumn()))); // column distance to center
252 if ((drow < 2) && (dcol < 2)) fSig33+=signal;
253 if ((drow < 3) && (dcol < 3)) fSig55+=signal;
254 fRowdisp+=signal*float(drow*drow);
255 fColdisp+=signal*float(dcol*dcol);
256 m.SetClusteredSignal(0.); // mark module as used in cluster
257 }
258}
259///////////////////////////////////////////////////////////////////////////
260void AliCalcluster::AddVetoSignal(Float_t* r,TString f,Float_t s)
261{
959fbac5 262// Associate an (extrapolated) AliSignal at location r as veto to the cluster.
263// The signal value s indicates the confidence level of hit association
264// and has to be provided by the user.
d88f97cc 265// Note : The default signal value (s) is 0
266 if (!fVetos)
267 {
268 fNvetos=0;
269 fVetos=new TObjArray();
270 }
271
959fbac5 272 fVetos->Add(new AliSignal(1));
d88f97cc 273 fNvetos++;
274
275 ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f);
276 ((AliSignal*)fVetos->At(fNvetos-1))->SetSignal(s);
277}
278///////////////////////////////////////////////////////////////////////////
279Int_t AliCalcluster::GetNvetos()
280{
281// Provide the number of veto signals associated to the cluster
282 return fNvetos;
283}
284///////////////////////////////////////////////////////////////////////////
285AliSignal* AliCalcluster::GetVetoSignal(Int_t i)
286{
959fbac5 287// Provide access to the i-th veto signal of this cluster.
288// Note : The first hit corresponds to i=1.
d88f97cc 289
290 if (i>0 && i<=fNvetos)
291 {
292 return (AliSignal*)fVetos->At(i-1);
293 }
294 else
295 {
296 cout << " *AliCalcluster::GetVetoSignal* Signal number " << i
297 << " out of range." << endl;
298 cout << " --- First signal (if any) returned." << endl;
299 return (AliSignal*)fVetos->At(0);
300 }
301}
302///////////////////////////////////////////////////////////////////////////
959fbac5 303Float_t AliCalcluster::GetVetoLevel()
304{
305// Provide the confidence level of best associated veto signal.
306 Float_t cl=0;
307 Float_t clmax=0;
308 if (fVetos)
309 {
310 for (Int_t i=0; i<fNvetos; i++)
311 {
312 cl=((AliSignal*)fVetos->At(i))->GetSignal();
313 if (cl>clmax) clmax=cl;
314 }
315 }
316 return clmax;
317}
318///////////////////////////////////////////////////////////////////////////
319Int_t AliCalcluster::HasVetoHit(Double_t cl)
320{
321// Investigate if cluster has an associated veto hit with conf. level > cl.
322// Returns 1 if there is such an associated veto hit, otherwise returns 0.
323// Note : This function is faster than GetVetoLevel().
324 if (fVetos)
325 {
326 for (Int_t i=0; i<fNvetos; i++)
327 {
328 if (((AliSignal*)fVetos->At(i))->GetSignal() > cl) return 1;
329 }
330 }
331 return 0;
332}
333///////////////////////////////////////////////////////////////////////////