Do not save CVS subdirectories
[u/mrichter/AliRoot.git] / MUON / AliMUONpoints.cxx
CommitLineData
fe4da5cc 1///////////////////////////////////////////////////////////////////////////////
2// //
3// This class contains the points for the ALICE event display //
4// //
5//Begin_Html
6/*
7<img src="gif/AliMUONpointsClass.gif">
8*/
9//End_Html
10// //
11// //
12///////////////////////////////////////////////////////////////////////////////
13#include "AliMUONdisplay.h"
14#include "AliMUONpoints.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(AliMUONpoints)
23
24//_____________________________________________________________________________
25AliMUONpoints::AliMUONpoints()
26{
27 //
28 // Default constructor
29 //
30 fHitIndex = 0;
31 fTrackIndex = 0;
32 fDigitIndex = 0;
33}
34
35//_____________________________________________________________________________
36AliMUONpoints::AliMUONpoints(Int_t npoints)
37 :AliPoints(npoints)
38{
39 //
40 // Standard constructor
41 //
42 fHitIndex = 0;
43 fTrackIndex = 0;
44 fDigitIndex = 0;
45}
46
47//_____________________________________________________________________________
48AliMUONpoints::~AliMUONpoints()
49{
50 //
51 // Default destructor
52 //
53 fHitIndex = 0;
54 fTrackIndex = 0;
55 fDigitIndex = 0;
56}
57
58//_____________________________________________________________________________
59void AliMUONpoints::DumpHit()
60{
61 //
62 // Dump hit corresponding to this point
63 //
64 AliMUONhit *hit = GetHit();
65 if (hit) hit->Dump();
66}
67
68//_____________________________________________________________________________
69void AliMUONpoints::DumpDigit()
70{
71 //
72 // Dump digit corresponding to this point
73 //
74 AliMUONdigit *digit = GetDigit();
75 if (digit) digit->Dump();
76}
77
78//_____________________________________________________________________________
79void AliMUONpoints::InspectHit()
80{
81 //
82 // Inspect hit corresponding to this point
83 //
84 AliMUONhit *hit = GetHit();
85 if (hit) hit->Inspect();
86}
87
88//_____________________________________________________________________________
89void AliMUONpoints::InspectDigit()
90{
91 //
92 // Inspect digit corresponding to this point
93 //
94 AliMUONdigit *digit = GetDigit();
95 if (digit) digit->Inspect();
96}
97
98//_____________________________________________________________________________
99Int_t AliMUONpoints::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//_____________________________________________________________________________
110AliMUONhit *AliMUONpoints::GetHit() const
111{
112 //
113 // Returns pointer to hit index in AliRun::fParticles
114 //
0f439796 115 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
fe4da5cc 116 gAlice->TreeH()->GetEvent(fTrackIndex);
117 TClonesArray *MUONhits = MUON->Hits();
118 Int_t nhits = MUONhits->GetEntriesFast();
119 if (fHitIndex < 0 || fHitIndex >= nhits) return 0;
120 return (AliMUONhit*)MUONhits->UncheckedAt(fHitIndex);
121}
122
123//_____________________________________________________________________________
124AliMUONdigit *AliMUONpoints::GetDigit() const
125{
126 //
127 // Returns pointer to digit index in AliRun::fParticles
128 //
129
130 AliMUONdisplay *display=(AliMUONdisplay*)gAlice->Display();
131 Int_t chamber=display->GetChamber();
132 Int_t cathode=display->GetCathode();
133
0f439796 134 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
fe4da5cc 135 TClonesArray *MUONdigits = MUON->DigitsAddress(chamber-1);
136 gAlice->TreeD()->GetEvent(cathode);
137 Int_t ndigits = MUONdigits->GetEntriesFast();
138 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return 0;
139 return (AliMUONdigit*)MUONdigits->UncheckedAt(fDigitIndex);
140}
141//_____________________________________________________________________________
142struct Bin {
143 const AliMUONdigit *dig;
144 int idx;
145 Bin() {dig=0; idx=-1;}
146};
147
148struct PreCluster : public AliMUONreccluster {
149 const AliMUONdigit* summit;
150 int idx;
151 int cut;
152 int npeaks;
153 PreCluster() : AliMUONreccluster() {cut=npeaks=0;}
154};
155//_____________________________________________________________________________
156
157static void FindCluster(AliMUONchamber *iChamber, AliMUONsegmentation *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 AliMUONpoints::GetCenterOfGravity()
206{
207 //
208 // simple MUON cluster finder from digits -- finds neighbours and
209 // calculates center of gravity for the cluster
210 //
211 const Int_t MAX_Nipx=400, MAX_Nipy=800;
212 printf("\n Hallo world");
213 AliMUONdisplay *display=(AliMUONdisplay*)gAlice->Display();
214 Int_t chamber=display->GetChamber();
215 Int_t cathode=display->GetCathode();
216
0f439796 217 AliMUON *MUON = (AliMUON*)gAlice->GetModule("MUON");
fe4da5cc 218 AliMUONchamber *iChamber;
219 AliMUONsegmentation *segmentation;
220 iChamber =&(MUON->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 *MUONdigits = MUON->DigitsAddress(chamber-1);
227 gAlice->TreeD()->GetEvent(cathode);
228 Int_t ndigits = MUONdigits->GetEntriesFast();
229 if (fDigitIndex < 0 || fDigitIndex >= ndigits) return;
230
231 AliMUONdigit *dig;
232 dig=(AliMUONdigit*)MUONdigits->UncheckedAt(fDigitIndex);
233 Int_t ipx=dig->fPadX;
234 Int_t ipy=dig->fPadY;
235 Bin bins[MAX_Nipx][MAX_Nipy];
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 = (AliMUONdigit*)MUONdigits->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 AliMUONpoints *points = 0;
260 points = new AliMUONpoints(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