Remove warnings on SunOS
[u/mrichter/AliRoot.git] / RICH / AliRICHpoints.cxx
CommitLineData
ddae0931 1///////////////////////////////////////////////////////////////////////////////
2// //
3// This class contains the points for the ALICE event display //
4// //
5//Begin_Html
6/*
7<img src="gif/AliRICHpointsClass.gif">
8*/
9//End_Html
10// //
11// //
12///////////////////////////////////////////////////////////////////////////////
13#include "AliRICHdisplay.h"
14#include "AliRICHpoints.h"
15#include "AliRun.h"
16#include "TPad.h"
17#include "TView.h"
18#include "TMath.h"
19
20const Int_t MAX_Nipx=400, MAX_Nipy=800;
21
22ClassImp(AliRICHpoints)
23
24//_____________________________________________________________________________
25AliRICHpoints::AliRICHpoints()
26{
27 //
28 // Default constructor
29 //
30 fHitIndex = 0;
31 fTrackIndex = 0;
32 fDigitIndex = 0;
33}
34
35//_____________________________________________________________________________
36AliRICHpoints::AliRICHpoints(Int_t npoints)
37 :AliPoints(npoints)
38{
39 //
40 // Standard constructor
41 //
42 fHitIndex = 0;
43 fTrackIndex = 0;
44 fDigitIndex = 0;
45}
46
47//_____________________________________________________________________________
48AliRICHpoints::~AliRICHpoints()
49{
50 //
51 // Default destructor
52 //
53 fHitIndex = 0;
54 fTrackIndex = 0;
55 fDigitIndex = 0;
56}
57
58//_____________________________________________________________________________
59void AliRICHpoints::DumpHit()
60{
61 //
62 // Dump hit corresponding to this point
63 //
64 AliRICHhit *hit = GetHit();
65 if (hit) hit->Dump();
66}
67
68//_____________________________________________________________________________
69void AliRICHpoints::DumpDigit()
70{
71 //
72 // Dump digit corresponding to this point
73 //
74 AliRICHdigit *digit = GetDigit();
75 if (digit) digit->Dump();
76}
77
78//_____________________________________________________________________________
79void AliRICHpoints::InspectHit()
80{
81 //
82 // Inspect hit corresponding to this point
83 //
84 AliRICHhit *hit = GetHit();
85 if (hit) hit->Inspect();
86}
87
88//_____________________________________________________________________________
89void AliRICHpoints::InspectDigit()
90{
91 //
92 // Inspect digit corresponding to this point
93 //
94 AliRICHdigit *digit = GetDigit();
95 if (digit) digit->Inspect();
96}
97
98//_____________________________________________________________________________
99Int_t AliRICHpoints::GetTrackIndex()
100{
101 //
102 // Dump digit corresponding to this point
103 //
104 printf("GetTrackIndex - fTrackIndex %d \n",fTrackIndex);
105 this->Inspect();
106 return fTrackIndex;
107}
108
109//_____________________________________________________________________________
110AliRICHhit *AliRICHpoints::GetHit() const
111{
112 //
113 // Returns pointer to hit index in AliRun::fParticles
114 //
115 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
116 gAlice->TreeH()->GetEvent(fTrackIndex);
117 TClonesArray *RICHhits = RICH->Hits();
118 Int_t nhits = RICHhits->GetEntriesFast();
119 if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
120 return (AliRICHhit*)RICHhits->UncheckedAt(fHitIndex);
121}
122
123//_____________________________________________________________________________
124AliRICHdigit *AliRICHpoints::GetDigit() const
125{
126 //
127 // Returns pointer to digit index in AliRun::fParticles
128 //
129
130 AliRICHdisplay *display=(AliRICHdisplay*)gAlice->Display();
131 Int_t chamber=display->GetChamber();
132 Int_t cathode=display->GetCathode();
133
134 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
135 TClonesArray *RICHdigits = RICH->DigitsAddress(chamber-1);
136 gAlice->TreeD()->GetEvent(cathode);
137 Int_t ndigits = RICHdigits->GetEntriesFast();
138 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
139 return (AliRICHdigit*)RICHdigits->UncheckedAt(fDigitIndex);
140}
141//_____________________________________________________________________________
142struct Bin {
143 const AliRICHdigit *dig;
144 int idx;
145 Bin() {dig=0; idx=-1;}
146};
147
148struct PreCluster : public AliRICHreccluster {
149 const AliRICHdigit* summit;
150 int idx;
151 int cut;
152 int npeaks;
153 PreCluster() : AliRICHreccluster() {cut=npeaks=0;}
154};
155//_____________________________________________________________________________
156
157static void FindCluster(AliRICHchamber *iChamber, AliRICHsegmentation *segmentation, int i, int j, Bin bins[MAX_Nipx][MAX_Nipy], PreCluster &c)
158
159{
160
161 //
162 // Find clusters
163 //
164
165 printf("I'm in FindCluster \n");
166
167 Bin& b=bins[i][j];
168 Int_t q=b.dig->fSignal;
169
170 printf("FindCluster - i j q %d %d %d\n",i,j,q);
171
172 if (q<0) {
173 q=-q;
174 c.cut=1;
175 }
176 if (b.idx >= 0 && b.idx != c.idx) {
177 c.idx=b.idx;
178 c.npeaks++;
179 }
180
181 if (q > TMath::Abs(c.summit->fSignal)) c.summit=b.dig;
182
183 Int_t npx = segmentation->Npx();
184 Int_t npy = segmentation->Npy();
185 Float_t x,y;
186 segmentation->GetPadCxy(i-npx, j-npy, x,y);
187 printf("FindCluster - x y %f %f \n",x,y);
188
189
190 c.fX += q*x;
191 c.fY += q*y;
192 c.fQ += q;
193
194 b.dig = 0; b.idx = c.idx;
195
196 if (bins[i-1][j].dig) FindCluster(iChamber,segmentation,i-1,j,bins,c);
197 if (bins[i][j-1].dig) FindCluster(iChamber,segmentation,i,j-1,bins,c);
198 if (bins[i+1][j].dig) FindCluster(iChamber,segmentation,i+1,j,bins,c);
199 if (bins[i][j+1].dig) FindCluster(iChamber,segmentation,i,j+1,bins,c);
200
201}
202
203//_____________________________________________________________________________
204
205void AliRICHpoints::GetCenterOfGravity()
206{
207 //
208 // simple RICH cluster finder from digits -- finds neighbours and
209 // calculates center of gravity for the cluster
210 //
f91473f6 211 const Int_t MAX_nipx=400, MAX_nipy=800;
ddae0931 212 printf("\n Hallo world");
213 AliRICHdisplay *display=(AliRICHdisplay*)gAlice->Display();
214 Int_t chamber=display->GetChamber();
215 Int_t cathode=display->GetCathode();
216
217 AliRICH *RICH = (AliRICH*)gAlice->GetDetector("RICH");
218 AliRICHchamber *iChamber;
219 AliRICHsegmentation *segmentation;
220 iChamber =&(RICH->Chamber(chamber-1));
221 segmentation=iChamber->GetSegmentationModel(cathode);
222 Int_t npx = segmentation->Npx();
223 Int_t npy = segmentation->Npy();
224 Float_t zpos=iChamber->ZPosition();
225
226 TClonesArray *RICHdigits = RICH->DigitsAddress(chamber-1);
227 gAlice->TreeD()->GetEvent(cathode);
228 Int_t ndigits = RICHdigits->GetEntriesFast();
229 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return;
230
231 AliRICHdigit *dig;
232 dig=(AliRICHdigit*)RICHdigits->UncheckedAt(fDigitIndex);
233 Int_t ipx=dig->fPadX;
234 Int_t ipy=dig->fPadY;
f91473f6 235 Bin bins[MAX_nipx][MAX_nipy];
ddae0931 236 bins[ipx+npx][ipy+npy].dig=dig;
237
238 int ndig;
239 int ncls=0;
240 for (ndig=0; ndig<ndigits; ndig++) {
241 dig = (AliRICHdigit*)RICHdigits->UncheckedAt(ndig);
242 int i=dig->fPadX, j=dig->fPadY;
243 bins[i+npx][j+npy].dig=dig;
244 }
245
246 PreCluster c; c.summit=bins[ipx+npx][ipy+npy].dig; c.idx=ncls;
247 FindCluster(iChamber,segmentation,ipx+npx, ipy+npy, bins, c);
248 if (c.npeaks>1) {
249 printf("GetCenterOfGravity -- more than one peak");
250 }
251 c.fX /= c.fQ;
252 c.fY /= c.fQ;
253 printf("GetCenterOfGravity - c.fX c.fY c.fQ %f %f %d \n",c.fX,c.fY,c.fQ);
254
255 c.fTracks[0]=c.summit->fTracks[0];
256 c.fTracks[1]=c.summit->fTracks[1];
257 c.fTracks[2]=c.summit->fTracks[2];
258 ncls++;
259 AliRICHpoints *points = 0;
260 points = new AliRICHpoints(1);
261 points->SetMarkerColor(kYellow);
262 points->SetMarkerStyle(5);
263 points->SetMarkerSize(1.);
264 points->SetPoint(0,c.fX,c.fY,zpos);
265 points->Draw();
266
267 printf("GetCenterOfGravity -- ncls %d \n",ncls);
268
269}
270
271
272