Optmization of SSD ClusterFinder (C. Cheshkov)
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraMode.cxx
CommitLineData
55a288e5 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/* $Id$ */
17
18/////////////////////////////////////////////////////////////////////////////////
19//
20// AliTRDCalibraMode
21//
22// This class is for the modes of the TRD calibration.
23// The user has to choose with the functions SetNz and SetNrphi the precision of the calibration.
24//Begin_Html
25/*
26<br>
27<CENTER>
28<TABLE border=1>
29<TR><TD><center>Nz</center></TD><TD><center> 0 </center></TD><TD><center> 1 </center></TD><TD><center> 2 </center></TD><TD><center> 3 </center></TD><TD><center> 4 </center></TD></TR>
30<TR><TD><CENTER>group of row pads per detector</CENTER></TD><TD><CENTER>1</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>4</CENTER></TD><TD><CENTER>6(chamb2)<br> 8(others chambers)</CENTER></TD><TD><CENTER>12 (chamb2)<br> 16 (chamb0)</CENTER></TD></TR>
31<TR><TD><CENTER>row pads per group</CENTER></TD><TD><CENTER>12 (chamb2)<br> 16 (chamb0)</CENTER></TD><TD><CENTER>6 (chamb2)<br> 8 (chamb0)</CENTER></TD><TD><CENTER>3 (chamb2)<br> 4 (chamb0)</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>1</CENTER></TD></TR>
32<TR><TD><CENTER>~distance [cm]</CENTER></TD><TD><CENTER>106 (chamb2)<br> 130 (chamb0)</CENTER></TD><TD><CENTER>53 (chamb2)<br> 65 (chamb0)</CENTER></TD><TD><CENTER>26.5 (chamb2)<br> 32.5 (chamb0)</CENTER></TD><TD><CENTER>17 (chamb2)<br> 17 (chamb0)</CENTER></TD><TD><CENTER>9 (chamb2)<br> 9 (chamb0)</CENTER></TD></TR>
33<CAPTION>In the z direction</CAPTION>
34</TABLE>
35</CENTER>
36<CENTER>
37<br>
38<TABLE border=1>
39<TR><TD><center>Nrphi</center></TD><TD><center> 0 </center></TD><TD><center> 1 </center></TD><TD><center> 2 </center></TD><TD><center> 3 </center></TD><TD><center> 4 </center></TD><TD><center> 5 </center></TD><TD><center> 6 </center></TD></TR>
40<TR><TD><CENTER>group of col pads per detector</CENTER></TD><TD><CENTER>1</CENTER></TD><TD><CENTER>2</CENTER></TD><TD><CENTER>4</CENTER></TD><TD><CENTER>8</CENTER></TD><TD><CENTER>16</CENTER></TD><TD><center>36</center></TD><TD><center>144</center></TD></TR>
41<TR><TD><CENTER>col pads per group</CENTER></TD><TD><CENTER>144</CENTER></TD><TD><CENTER>72</CENTER></TD><TD><CENTER>36</CENTER></TD><TD><CENTER>18</CENTER></TD><TD><CENTER>9</CENTER></TD><TD><center>4</center></TD><TD><center>1</center></TD></TR>
42<TR><TD><CENTER>~distance [cm]</CENTER></TD><TD><CENTER>113.4</CENTER></TD><TD><CENTER>56.7</CENTER></TD><TD><CENTER>25.3</CENTER></TD><TD><CENTER>14.3</CENTER></TD><TD><CENTER>7.25</CENTER></TD><TD><center>3.2</center></TD><TD><center>0.8</center></TD></TR>
43<CAPTION>In the rphi direction</CAPTION>
44</TABLE>
45</CENTER>
46<br>
47*/
48//End_Html
49//
50//
51// Author:
52// R. Bailhache (R.Bailhache@gsi.de)
53//
54//////////////////////////////////////////////////////////////////////////////////////
55
56#include "AliLog.h"
57
58#include "AliTRDCalibraMode.h"
59#include "AliTRDCommonParam.h"
60
61ClassImp(AliTRDCalibraMode)
62
63//______________________________________________________________________________________
64AliTRDCalibraMode::AliTRDCalibraMode()
65 :TObject()
66{
67 //
68 // Default constructor
69 //
70
71 for (Int_t i = 0; i < 3; i++) {
72 fNz[i] = 0;
73 fNrphi[i] = 0;
74 }
75
76 for (Int_t k = 0; k < 3; k++) {
77 fDetChamb2[k] = 0;
78 fDetChamb0[k] = 0;
79 }
80
81 for (Int_t i = 0; i < 3; i++) {
82 fRowMin[i] = -1;
83 fRowMax[i] = -1;
84 fColMax[i] = -1;
85 fColMin[i] = -1;
86 fNnZ[i] = -1;
87 fNnRphi[i] = -1;
88 fNfragZ[i] = -1;
89 fNfragRphi[i] = -1;
90 fXbins[i] = -1;
91 }
92
93}
94
95//______________________________________________________________________________________
96AliTRDCalibraMode::AliTRDCalibraMode(const AliTRDCalibraMode &c)
97 :TObject(c)
98{
99 //
100 // Copy constructor
101 //
102
103}
104
105//____________________________________________________________________________________
106AliTRDCalibraMode::~AliTRDCalibraMode()
107{
108 //
109 // AliTRDCalibraMode destructor
110 //
111
112}
113
114//_____________________________________________________________________________
115void AliTRDCalibraMode::SetNz(Int_t i, Short_t Nz)
116{
117 //
118 // Set the mode of calibration group in the z direction for the parameter i
119 //
120
121 if ((Nz >= 0) &&
122 (Nz < 5)) {
123 fNz[i] = Nz;
124 }
125 else {
126 AliInfo("You have to choose between 0 and 4");
127 }
128
129}
130
131//_____________________________________________________________________________
132void AliTRDCalibraMode::SetNrphi(Int_t i, Short_t Nrphi)
133{
134 //
135 // Set the mode of calibration group in the rphi direction for the parameter i
136 //
137
138 if ((Nrphi >= 0) &&
139 (Nrphi < 7)) {
140 fNrphi[i] = Nrphi;
141 }
142 else {
143 AliInfo("You have to choose between 0 and 6");
144 }
145
146}
147
148//_______________________________________________________________________________________
149void AliTRDCalibraMode::ModePadCalibration(Int_t iChamb, Int_t i)
150{
151 //
152 // Definition of the calibration mode
153 // from Nz and Nrphi, the number of row and col pads per calibration groups are setted
154 //
155
156
157 fNnZ[i] = 0;
158 fNnRphi[i] = 0;
159
160 if ((fNz[i] == 0) && (iChamb == 2)) {
161 fNnZ[i] = 12;
162 }
163 if ((fNz[i] == 0) && (iChamb != 2)) {
164 fNnZ[i] = 16;
165 }
166 if ((fNz[i] == 1) && (iChamb == 2)) {
167 fNnZ[i] = 6;
168 }
169 if ((fNz[i] == 1) && (iChamb != 2)) {
170 fNnZ[i] = 8;
171 }
172 if ((fNz[i] == 2) && (iChamb == 2)) {
173 fNnZ[i] = 3;
174 }
175 if ((fNz[i] == 2) && (iChamb != 2)) {
176 fNnZ[i] = 4;
177 }
178 if (fNz[i] == 3) {
179 fNnZ[i] = 2;
180 }
181 if (fNz[i] == 4) {
182 fNnZ[i] = 1;
183 }
184
185 if (fNrphi[i] == 0) {
186 fNnRphi[i] = 144;
187 }
188 if (fNrphi[i] == 1) {
189 fNnRphi[i] = 72;
190 }
191 if (fNrphi[i] == 2) {
192 fNnRphi[i] = 36;
193 }
194 if (fNrphi[i] == 3) {
195 fNnRphi[i] = 18;
196 }
197 if (fNrphi[i] == 4) {
198 fNnRphi[i] = 9;
199 }
200 if (fNrphi[i] == 5) {
201 fNnRphi[i] = 4;
202 }
203 if (fNrphi[i] == 6) {
204 fNnRphi[i] = 1;
205 }
206
207}
208
209//_____________________________________________________________________________________________
210Bool_t AliTRDCalibraMode::ModePadFragmentation(Int_t iPlane,Int_t iChamb, Int_t iSect, Int_t i)
211{
212 //
213 // Definition of the calibration mode
214 // From the number of row and col pads per calibration groups the
215 // number of calibration groups are setted
216 //
217
218 fNfragZ[i] = 0;
219 fNfragRphi[i] = 0;
220
221 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
222 if (!parCom) {
223 AliInfo("Could not get CommonParam Manager");
224 return kFALSE;
225 }
226
227 // A little geometry:
228 Int_t rowMax = parCom->GetRowMax(iPlane,iChamb,iSect);
229 Int_t colMax = parCom->GetColMax(iPlane);
230
231 // The fragmentation
232 if (fNnZ[i] != 0) {
233 fNfragZ[i] = (Int_t) rowMax / fNnZ[i];
234 }
235
236 if (fNnRphi[i] != 0) {
237 fNfragRphi[i] = (Int_t) colMax / fNnRphi[i];
238 }
239
240 return kTRUE;
241
242}
243
244//_____________________________________________________________________________
245void AliTRDCalibraMode::ReconstructionRowPadGroup(Int_t idect, Int_t i)
246{
247 //
248 // For the calibration group idect in a detector calculate the
249 // first and last row pad and col pad.
250 // The pads in the interval will have the same calibrated coefficients
251 //
252
253 Int_t posc = -1;
254 Int_t posr = -1;
255 fRowMin[i] = -1;
256 fRowMax[i] = -1;
257 fColMin[i] = -1;
258 fColMax[i] = -1;
259
260 if (fNfragZ[i] != 0) {
261 posc = (Int_t) idect / fNfragZ[i];
262 }
263 if (fNfragRphi[i] != 0) {
264 posr = (Int_t) idect % fNfragZ[i];
265 }
266 fRowMin[i] = posr * fNnZ[i];
267 fRowMax[i] = (posr+1) * fNnZ[i];
268 fColMin[i] = posc * fNnRphi[i];
269 fColMax[i] = (posc+1) * fNnRphi[i];
270
271}
272
273//_____________________________________________________________________________
274void AliTRDCalibraMode::CalculXBins(Int_t idect, Int_t i)
275{
276 //
277 // For the detector idect calcul the first Xbins
278 //
279
280 fXbins[i] = 0;
281 AliDebug(2, Form("detector: %d", idect));
282
283 // In which sector?
284 Int_t sector = GetSector(idect);
285 fXbins[i] += sector*(6*fDetChamb2[i]+6*4*fDetChamb0[i]);
286
287 // In which chamber?
288 Int_t chamber = GetChamber(idect);
289 Int_t kc = 0;
290 while (kc < chamber) {
291 if (kc == 2) {
292 fXbins[i] += 6 * fDetChamb2[i];
293 }
294 else {
295 fXbins[i] += 6 * fDetChamb0[i];
296 }
297 kc ++;
298 }
299
300 // In which plane?
301 Int_t plane = GetPlane(idect);
302 if (chamber == 2) {
303 fXbins[i] += plane*fDetChamb2[i];
304 }
305 else {
306 fXbins[i] += plane*fDetChamb0[i];
307 }
308
309}
310
311//_____________________________________________________________________________
312void AliTRDCalibraMode::ResetMinMax(Int_t i)
313{
314 //
315 // Reset fRowMin fRowMax fColMin fColMax [i]
316 //
317
318 fRowMin[i] = -1;
319 fRowMax[i] = -1;
320 fColMin[i] = -1;
321 fColMax[i] = -1;
322
323}
324
325//_____________________________________________________________________________
326void AliTRDCalibraMode::SetDetChamb0(Int_t i)
327{
328 //
329 // Set the number of calibration group per detector != 2
330 //
331
332 fDetChamb0[i] = fNfragZ[i] * fNfragRphi[i];
333
334}
335
336//_____________________________________________________________________________
337void AliTRDCalibraMode::SetDetChamb2(Int_t i)
338{
339 //
340 // Set the number of calibration group per detector == 2
341 //
342
343 fDetChamb2[i] = fNfragZ[i] * fNfragRphi[i];
344
345}
346
347//_____________________________________________________________________________
348Int_t AliTRDCalibraMode::GetPlane(Int_t d) const
349{
350 //
351 // Reconstruct the plane number from the detector number
352 //
353
354 return ((Int_t) (d % 6));
355
356}
357
358//_____________________________________________________________________________
359Int_t AliTRDCalibraMode::GetChamber(Int_t d) const
360{
361 //
362 // Reconstruct the chamber number from the detector number
363 //
364
365 Int_t fgkNplan = 6;
366
367 return ((Int_t) (d % 30) / fgkNplan);
368
369}
370
371//_____________________________________________________________________________
372Int_t AliTRDCalibraMode::GetSector(Int_t d) const
373{
374 //
375 // Reconstruct the sector number from the detector number
376 //
377
378 Int_t fg = 30;
379
380 return ((Int_t) (d / fg));
381
382}