]>
Commit | Line | Data |
---|---|---|
4c039060 | 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$ | |
7d83513f | 18 | Revision 1.2 1999/09/29 09:24:35 fca |
19 | Introduction of the Copyright and cvs Log | |
20 | ||
4c039060 | 21 | */ |
22 | ||
99d5402e | 23 | /////////////////////////////////////////////////////////////////////////////// |
24 | // // | |
25 | // Contains the pixel information for one TRD chamber // | |
26 | // // | |
27 | /////////////////////////////////////////////////////////////////////////////// | |
28 | ||
29 | #include "AliTRDmatrix.h" | |
30 | ||
31 | ClassImp(AliTRDmatrix) | |
32 | ||
33 | //_____________________________________________________________________________ | |
34 | AliTRDmatrix::AliTRDmatrix():TObject() | |
35 | { | |
36 | // | |
37 | // Create a TRD detector matrix | |
38 | // | |
39 | ||
40 | fRow = 0; | |
41 | fCol = 0; | |
42 | fTime = 0; | |
43 | fPixel = 0; | |
44 | fSector = 0; | |
45 | fChamber = 0; | |
46 | fPlane = 0; | |
47 | fPixelArray = NULL; | |
48 | ||
49 | } | |
50 | ||
51 | //_____________________________________________________________________________ | |
52 | AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime | |
53 | , Int_t iSec, Int_t iCha, Int_t iPla) | |
54 | :TObject() | |
55 | { | |
56 | // | |
57 | // Create a TRD detector matrix with a given size | |
58 | // | |
59 | ||
60 | fRow = nRow; | |
61 | fCol = nCol; | |
62 | fTime = nTime; | |
63 | fPixel = nRow * nCol * nTime; | |
64 | fSector = iSec; | |
65 | fChamber = iCha; | |
66 | fPlane = iPla; | |
67 | fPixelArray = new TObjArray(fPixel); | |
68 | for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) { | |
69 | AliTRDpixel *pixel = new AliTRDpixel(); | |
70 | fPixelArray->Add(pixel); | |
71 | } | |
72 | ||
73 | } | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | AliTRDmatrix::~AliTRDmatrix() | |
77 | { | |
78 | ||
79 | if (fPixelArray) { | |
80 | fPixelArray->Delete(); | |
81 | delete fPixelArray; | |
82 | } | |
83 | ||
84 | } | |
85 | ||
86 | //_____________________________________________________________________________ | |
87 | void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal) | |
88 | { | |
89 | // | |
90 | // Add a value to the amplitude of the signal for one specific pixel | |
91 | // | |
92 | ||
93 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
94 | if (pixel) { | |
95 | signal += pixel->GetSignal(); | |
96 | pixel->SetSignal(signal); | |
97 | } | |
98 | ||
99 | } | |
100 | ||
101 | //_____________________________________________________________________________ | |
7d83513f | 102 | void AliTRDmatrix::Draw(Option_t *) |
99d5402e | 103 | { |
104 | // | |
105 | // Draws a 3D view of the detector matrix | |
106 | // | |
107 | ||
108 | Char_t ctitle[50]; | |
109 | sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)" | |
110 | ,fSector,fChamber,fPlane); | |
111 | TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5 | |
112 | ,fCol ,-0.5,fCol +0.5 | |
113 | ,fTime,-0.5,fTime+0.5); | |
114 | ||
115 | for (Int_t iRow = 0; iRow < fRow; iRow++ ) { | |
116 | for (Int_t iCol = 0; iCol < fCol; iCol++ ) { | |
117 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
118 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
119 | if (pixel) hMatrix->Fill3(iRow,iCol,iTime,pixel->GetSignal()); | |
120 | } | |
121 | } | |
122 | } | |
123 | ||
124 | gStyle->SetOptStat(0); | |
125 | TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view" | |
126 | ,50,50,600,400); | |
127 | cMatrix->ToggleEventStatus(); | |
128 | hMatrix->SetXTitle("Pad-row (z)"); | |
129 | hMatrix->SetYTitle("Pad-column (rphi)"); | |
130 | hMatrix->SetZTitle("Timebucket"); | |
131 | hMatrix->Draw("BOX"); | |
132 | ||
133 | } | |
134 | ||
135 | //_____________________________________________________________________________ | |
136 | void AliTRDmatrix::DrawRow(Int_t iRow) | |
137 | { | |
138 | // | |
139 | // Draws a 2D slice of the detector matrix along one row | |
140 | // | |
141 | ||
142 | if ((iRow < 0) || (iRow >= fRow)) { | |
143 | printf("Index out of bounds (%d/%d)\n",iRow,fRow); | |
144 | return; | |
145 | } | |
146 | ||
147 | Char_t ctitle[50]; | |
148 | sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)" | |
149 | ,iRow,fSector,fChamber,fPlane); | |
150 | TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5 | |
151 | ,fTime,-0.5,fTime+0.5); | |
152 | ||
153 | for (Int_t iCol = 0; iCol < fCol; iCol++ ) { | |
154 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
155 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
156 | if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal()); | |
157 | } | |
158 | } | |
159 | ||
160 | gStyle->SetOptStat(0); | |
161 | TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice" | |
162 | ,50,50,600,400); | |
163 | cSliceRow->ToggleEventStatus(); | |
164 | hSliceRow->SetXTitle("Pad-column (rphi)"); | |
165 | hSliceRow->SetYTitle("Timebucket"); | |
166 | hSliceRow->Draw("COLZ"); | |
167 | ||
168 | } | |
169 | ||
170 | //_____________________________________________________________________________ | |
171 | void AliTRDmatrix::DrawCol(Int_t iCol) | |
172 | { | |
173 | // | |
174 | // Draws a 2D slice of the detector matrix along one column | |
175 | // | |
176 | ||
177 | if ((iCol < 0) || (iCol >= fCol)) { | |
178 | printf("Index out of bounds (%d/%d)\n",iCol,fCol); | |
179 | return; | |
180 | } | |
181 | ||
182 | Char_t ctitle[50]; | |
183 | sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)" | |
184 | ,iCol,fSector,fChamber,fPlane); | |
185 | TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5 | |
186 | ,fTime,-0.5,fTime+0.5); | |
187 | ||
188 | for (Int_t iRow = 0; iRow < fRow; iRow++ ) { | |
189 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
190 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
191 | if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal()); | |
192 | } | |
193 | } | |
194 | ||
195 | gStyle->SetOptStat(0); | |
196 | TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice" | |
197 | ,50,50,600,400); | |
198 | cSliceCol->ToggleEventStatus(); | |
199 | hSliceCol->SetXTitle("Pad-row (z)"); | |
200 | hSliceCol->SetYTitle("Timebucket"); | |
201 | hSliceCol->Draw("COLZ"); | |
202 | ||
203 | } | |
204 | ||
205 | //_____________________________________________________________________________ | |
206 | void AliTRDmatrix::DrawTime(Int_t iTime) | |
207 | { | |
208 | // | |
209 | // Draws a 2D slice of the detector matrix along one time slice | |
210 | // | |
211 | ||
212 | if ((iTime < 0) || (iTime >= fTime)) { | |
213 | printf("Index out of bounds (%d/%d)\n",iTime,fTime); | |
214 | return; | |
215 | } | |
216 | ||
217 | Char_t ctitle[50]; | |
218 | sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)" | |
219 | ,iTime,fSector,fChamber,fPlane); | |
220 | TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5 | |
221 | ,fCol,-0.5,fCol+0.5); | |
222 | ||
223 | for (Int_t iRow = 0; iRow < fRow; iRow++) { | |
224 | for (Int_t iCol = 0; iCol < fCol; iCol++) { | |
225 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
226 | if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal()); | |
227 | } | |
228 | } | |
229 | ||
230 | gStyle->SetOptStat(0); | |
231 | TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice" | |
232 | ,50,50,600,400); | |
233 | cSliceTime->ToggleEventStatus(); | |
234 | hSliceTime->SetXTitle("Pad-row (z)"); | |
235 | hSliceTime->SetYTitle("Pad-column (rphi)"); | |
236 | hSliceTime->Draw("COLZ"); | |
237 | ||
238 | } | |
239 | ||
240 | //_____________________________________________________________________________ | |
241 | void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal) | |
242 | { | |
243 | // | |
244 | // Set the amplitude of the signal for one specific pixel | |
245 | // | |
246 | ||
247 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
248 | if (pixel) { | |
249 | pixel->SetSignal(signal); | |
250 | } | |
251 | ||
252 | } | |
253 | ||
254 | //_____________________________________________________________________________ | |
255 | Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track) | |
256 | { | |
257 | // | |
258 | // Add this track number to the stored tracks passing through this pixel. | |
259 | // If there are already three stored the return status is FALSE. | |
260 | // | |
261 | ||
262 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
263 | if (!(pixel)) return kTRUE; | |
264 | ||
265 | Bool_t trackSet = kFALSE; | |
266 | for (Int_t i = 0; i < kTrackPixel; i++) { | |
267 | if (pixel->GetTrack(i) == track) { | |
268 | trackSet = kTRUE; | |
269 | break; | |
270 | } | |
271 | if (pixel->GetTrack(i) == 0) { | |
272 | pixel->SetTrack(i,track); | |
273 | trackSet = kTRUE; | |
274 | break; | |
275 | } | |
276 | } | |
277 | ||
278 | return trackSet; | |
279 | ||
280 | } | |
281 | ||
282 | //_____________________________________________________________________________ | |
283 | void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime | |
284 | , Int_t iTrack, Int_t track) | |
285 | { | |
286 | // | |
287 | // Store the number of a track which is passing through this pixel | |
288 | // | |
289 | ||
290 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
291 | if (pixel) { | |
292 | pixel->SetTrack(iTrack,track); | |
293 | } | |
294 | ||
295 | } | |
296 | ||
297 | //_____________________________________________________________________________ | |
298 | Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime) | |
299 | { | |
300 | // | |
301 | // Returns the amplitude of the signal for one specific pixel | |
302 | // | |
303 | ||
304 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
305 | if (pixel) { | |
306 | return (pixel->GetSignal()); | |
307 | } | |
308 | else { | |
309 | return 0; | |
310 | } | |
311 | ||
312 | } | |
313 | ||
314 | //_____________________________________________________________________________ | |
315 | Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack) | |
316 | { | |
317 | // | |
318 | // Returns the numbers of the tracks passing through one specific pixel | |
319 | // | |
320 | ||
321 | if ((iTrack < 0) || (iTrack >= kTrackPixel)) { | |
322 | printf("GetTrack: Index out of bounds (%d)\n",iTrack); | |
323 | return 0; | |
324 | } | |
325 | ||
326 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
327 | if (pixel) { | |
328 | return (pixel->GetTrack(iTrack)); | |
329 | } | |
330 | else { | |
331 | return 0; | |
332 | } | |
333 | ||
334 | } | |
335 | ||
336 | //_____________________________________________________________________________ | |
337 | Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime) | |
338 | { | |
339 | ||
340 | if ((iRow >= 0) && (iRow < fRow ) && | |
341 | (iCol >= 0) && (iCol < fCol ) && | |
342 | (iTime >= 0) && (iTime < fTime)) { | |
343 | return (iTime + iCol * fTime + iRow * fTime * fCol); | |
344 | } | |
345 | else { | |
346 | return -1; | |
347 | } | |
348 | ||
349 | } | |
350 | ||
351 | //_____________________________________________________________________________ | |
352 | AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime) | |
353 | { | |
354 | ||
355 | Int_t iPixel = GetIndex(iRow,iCol,iTime); | |
356 | if (iPixel < 0) { | |
357 | return NULL; | |
358 | } | |
359 | else { | |
360 | return ((AliTRDpixel *) fPixelArray->At(iPixel)); | |
361 | } | |
362 | ||
363 | } |