]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliCalcluster.cxx
New version of the code, see history.txt for more details
[u/mrichter/AliRoot.git] / RALICE / AliCalcluster.cxx
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$
18 Revision 1.3  1999/11/03 14:23:17  fca
19 New version of RALICE introduced
20
21 Revision 1.2  1999/09/29 09:24:28  fca
22 Introduction of the Copyright and cvs Log
23
24 */
25
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
36 //- Modified: NvE 18-jan-2000 UU-SAP Utrecht 
37 ///////////////////////////////////////////////////////////////////////////
38
39 #include "AliCalcluster.h"
40  
41 ClassImp(AliCalcluster) // Class implementation to enable ROOT I/O
42  
43 AliCalcluster::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 ///////////////////////////////////////////////////////////////////////////
58 AliCalcluster::~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 ///////////////////////////////////////////////////////////////////////////
69 AliCalcluster::AliCalcluster(AliCalmodule& m)
70 {
71 // Cluster constructor with module m as center.
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.  
79
80  Ali3Vector r;
81
82  if (m.GetClusteredSignal()>0. && m.GetDeadValue()==0)
83  {
84   fCenter=&m;
85   r=m.GetPosition();
86   SetPosition(r);
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;
101   SetPosition(r);
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 ///////////////////////////////////////////////////////////////////////////
114 Int_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 ///////////////////////////////////////////////////////////////////////////
127 Int_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 ///////////////////////////////////////////////////////////////////////////
140 Float_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 ///////////////////////////////////////////////////////////////////////////
166 Int_t AliCalcluster::GetNmodules()
167 {
168 // Provide the number of modules in the cluster
169  return fNmods;
170 }
171 ///////////////////////////////////////////////////////////////////////////
172 Float_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 ///////////////////////////////////////////////////////////////////////////
185 Float_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 ///////////////////////////////////////////////////////////////////////////
198 void AliCalcluster::Start(AliCalmodule& m)
199 {
200 // Reset cluster data and start with module m.
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.  
208
209  Ali3Vector r;
210
211  if (m.GetClusteredSignal()>0. && m.GetDeadValue()==0)
212  {
213   fCenter=&m;
214   r=m.GetPosition();
215   SetPosition(r);
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;
228   SetPosition(r);
229   fSig=0.;
230   fNmods=0;
231   fSig11=0.;
232   fSig33=0.;
233   fSig55=0.;
234   fRowdisp=0.;
235   fColdisp=0.;
236  }
237 }
238 ///////////////////////////////////////////////////////////////////////////
239 void AliCalcluster::Add(AliCalmodule& m)
240 {
241 // Add module data to the cluster.
242 // Dead modules are NOT added to the cluster.
243
244  Float_t signal=m.GetClusteredSignal();
245  
246  if (signal>0. && m.GetDeadValue()==0) // only add unused modules
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 ///////////////////////////////////////////////////////////////////////////
260 void AliCalcluster::AddVetoSignal(Float_t* r,TString f,Float_t s)
261 {
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.
265 // Note : The default signal value (s) is 0
266  if (!fVetos)
267  {
268   fNvetos=0;
269   fVetos=new TObjArray();
270  } 
271
272  fVetos->Add(new AliSignal(1));
273  fNvetos++;
274
275  ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f);
276  ((AliSignal*)fVetos->At(fNvetos-1))->SetSignal(s);
277 }
278 ///////////////////////////////////////////////////////////////////////////
279 Int_t AliCalcluster::GetNvetos()
280 {
281 // Provide the number of veto signals associated to the cluster
282  return fNvetos;
283 }
284 ///////////////////////////////////////////////////////////////////////////
285 AliSignal* AliCalcluster::GetVetoSignal(Int_t i)
286 {
287 // Provide access to the i-th veto signal of this cluster.
288 // Note : The first hit corresponds to i=1.
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 ///////////////////////////////////////////////////////////////////////////
303 Float_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 ///////////////////////////////////////////////////////////////////////////
319 Int_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 ///////////////////////////////////////////////////////////////////////////