]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliCalcluster.cxx
31362affbdf10ff892757db9d76a19bf59fbb824
[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 */
19
20 #include "AliCalcluster.h"
21  
22 ClassImp(AliCalcluster) // Class implementation to enable ROOT I/O
23  
24 AliCalcluster::AliCalcluster()
25 {
26 // Default constructer, all data is set to 0
27  fCenter=0;
28  fSig=0.;
29  fNmods=0;
30  fSig11=0.;
31  fSig33=0.;
32  fSig55=0.;
33  fRowdisp=0.;
34  fColdisp=0.;
35  fNvetos=0;
36  fVetos=0;
37 }
38 ///////////////////////////////////////////////////////////////////////////
39 AliCalcluster::~AliCalcluster()
40 {
41 // Destructor to delete dynamically allocated memory
42  if (fVetos)
43  {
44   fVetos->Delete();
45   delete fVetos;
46   fVetos=0;
47  }
48 }
49 ///////////////////////////////////////////////////////////////////////////
50 AliCalcluster::AliCalcluster(AliCalmodule& m)
51 {
52 // Cluster constructor with module m as center.
53 // Module data is only entered for a module which contains
54 // a signal and has not been used in a cluster yet.
55 // Modules situated at a detector edge are not allowed to start a cluster.
56
57  Float_t pos[3]={0,0,0};
58
59  if ((m.GetClusteredSignal() > 0.) && (m.GetEdgeValue() == 0))
60  {
61   fCenter=&m;
62   m.GetPosition(pos,"sph");
63   SetPosition(pos,"sph");
64   fSig=m.GetClusteredSignal();
65   fNmods=1;
66   fSig11=m.GetClusteredSignal();
67   fSig33=m.GetClusteredSignal();
68   fSig55=m.GetClusteredSignal();
69   fRowdisp=0.;
70   fColdisp=0.;
71   m.SetClusteredSignal(0.); // mark module as used in cluster
72   fNvetos=0;
73   fVetos=0;
74  }
75  else
76  {
77   fCenter=0;
78   SetPosition(pos,"sph");
79   fSig=0.;
80   fNmods=0;
81   fSig11=0.;
82   fSig33=0.;
83   fSig55=0.;
84   fRowdisp=0.;
85   fColdisp=0.;
86   fNvetos=0;
87   fVetos=0;
88 }
89 }
90 ///////////////////////////////////////////////////////////////////////////
91 Int_t AliCalcluster::GetRow()
92 {
93 // Provide the row number of the cluster center
94  if (fCenter)
95  {
96   return fCenter->GetRow();
97  }
98  else
99  {
100   return 0;
101  }
102 }
103 ///////////////////////////////////////////////////////////////////////////
104 Int_t AliCalcluster::GetColumn()
105 {
106 // Provide the column number of the cluster center
107  if (fCenter)
108  {
109   return fCenter->GetColumn();
110  }
111  else
112  {
113   return 0;
114  }
115 }
116 ///////////////////////////////////////////////////////////////////////////
117 Float_t AliCalcluster::GetSignal(Int_t n)
118 {
119 // Provide the total signal of a module matrix of n modules around
120 // the cluster center.
121 // Example : n=9 --> total signal in the 3x3 matrix
122 //             1 --> signal of central module
123 // Note : n=0 provides the total cluster signal (Default)
124  
125  Float_t signal=-1;
126  
127  if (n == 0)  signal=fSig;
128  if (n == 1)  signal=fSig11;
129  if (n == 9)  signal=fSig33;
130  if (n == 25) signal=fSig55;
131  
132  if (signal > 0.)
133  {
134   return signal;
135  }
136  else
137  {
138   cout << " *AliCalcluster::GetSignal* Invalid argument n = " << n << endl;
139   return 0;
140  }
141 }
142 ///////////////////////////////////////////////////////////////////////////
143 Int_t AliCalcluster::GetNmodules()
144 {
145 // Provide the number of modules in the cluster
146  return fNmods;
147 }
148 ///////////////////////////////////////////////////////////////////////////
149 Float_t AliCalcluster::GetRowDispersion()
150 {
151 // Provide the normalised row dispersion of the cluster
152  if (fSig > 0.)
153  {
154   return fRowdisp/fSig;
155  }
156  else
157  {
158   return 0.;
159  }
160 }
161 ///////////////////////////////////////////////////////////////////////////
162 Float_t AliCalcluster::GetColumnDispersion()
163 {
164 // Provide the normalised column dispersion of the cluster
165  if (fSig > 0.)
166  {
167   return fColdisp/fSig;
168  }
169  else
170  {
171   return 0.;
172  }
173 }
174 ///////////////////////////////////////////////////////////////////////////
175 void AliCalcluster::Start(AliCalmodule& m)
176 {
177 // Reset cluster data and start with module m
178 // A module can only start a cluster when it contains
179 // a signal, has not been used in a cluster yet and is not
180 // situated at a detector edge
181
182  Float_t pos[3]={0,0,0};
183
184  if ((m.GetClusteredSignal() > 0.) && (m.GetEdgeValue() == 0))
185  {
186   fCenter=&m;
187   m.GetPosition(pos,"sph");
188   SetPosition(pos,"sph");
189   fSig=m.GetSignal();
190   fNmods=1;
191   fSig11=m.GetSignal();
192   fSig33=m.GetSignal();
193   fSig55=m.GetSignal();
194   fRowdisp=0.;
195   fColdisp=0.;
196   m.SetClusteredSignal(0.); // mark module as used in cluster
197  }
198  else
199  {
200   fCenter=0;
201   SetPosition(pos,"sph");
202   fSig=0.;
203   fNmods=0;
204   fSig11=0.;
205   fSig33=0.;
206   fSig55=0.;
207   fRowdisp=0.;
208   fColdisp=0.;
209  }
210 }
211 ///////////////////////////////////////////////////////////////////////////
212 void AliCalcluster::Add(AliCalmodule& m)
213 {
214 // Add module data to the cluster
215
216  Float_t signal=m.GetClusteredSignal();
217  
218  if (signal > 0.) // only add unused modules
219  {
220   fSig+=signal;
221   fNmods+=1;
222   Int_t drow=int(fabs(double(GetRow()-m.GetRow())));       // row distance to center
223   Int_t dcol=int(fabs(double(GetColumn()-m.GetColumn()))); // column distance to center
224   if ((drow < 2) && (dcol < 2)) fSig33+=signal;
225   if ((drow < 3) && (dcol < 3)) fSig55+=signal;
226   fRowdisp+=signal*float(drow*drow);
227   fColdisp+=signal*float(dcol*dcol);
228   m.SetClusteredSignal(0.); // mark module as used in cluster
229  }
230 }
231 ///////////////////////////////////////////////////////////////////////////
232 void AliCalcluster::AddVetoSignal(Float_t* r,TString f,Float_t s)
233 {
234 // Associate an (extrapolated) AliSignal at location r as veto to the cluster
235 // Note : The default signal value (s) is 0
236  if (!fVetos)
237  {
238   fNvetos=0;
239   fVetos=new TObjArray();
240  } 
241
242  fVetos->Add(new AliSignal);
243  fNvetos++;
244
245  ((AliSignal*)fVetos->At(fNvetos-1))->SetPosition(r,f);
246  ((AliSignal*)fVetos->At(fNvetos-1))->SetSignal(s);
247 }
248 ///////////////////////////////////////////////////////////////////////////
249 Int_t AliCalcluster::GetNvetos()
250 {
251 // Provide the number of veto signals associated to the cluster
252  return fNvetos;
253 }
254 ///////////////////////////////////////////////////////////////////////////
255 AliSignal* AliCalcluster::GetVetoSignal(Int_t i)
256 {
257 // Provide access to the i-th veto signal of this cluster
258 // Note : The first hit corresponds to i=1
259
260  if (i>0 && i<=fNvetos)
261  {
262   return (AliSignal*)fVetos->At(i-1);
263  }
264  else
265  {
266   cout << " *AliCalcluster::GetVetoSignal* Signal number " << i
267        << " out of range." << endl;
268   cout << " --- First signal (if any) returned." << endl;
269   return (AliSignal*)fVetos->At(0);
270  }
271 }
272 ///////////////////////////////////////////////////////////////////////////