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