]>
Commit | Line | Data |
---|---|---|
909b16e7 | 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 | ||
451f5018 | 16 | /* $Id: AliITSUSegmentationPix.cxx 47180 2011-02-08 09:42:29Z masera $ */ |
909b16e7 | 17 | #include <TGeoManager.h> |
18 | #include <TGeoVolume.h> | |
19 | #include <TGeoBBox.h> | |
e5373622 | 20 | #include <TObjArray.h> |
21 | #include <TString.h> | |
22 | #include <TSystem.h> | |
23 | #include <TFile.h> | |
451f5018 | 24 | #include "AliITSUGeomTGeo.h" |
25 | #include "AliITSUSegmentationPix.h" | |
a11ef2e4 | 26 | using namespace TMath; |
909b16e7 | 27 | |
28 | //////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
29 | // Segmentation class for pixels // | |
30 | // Questions to solve: are guardrings needed and do they belong to the sensor or to the module in TGeo // | |
31 | // At the moment assume that the local coord syst. is located at bottom left corner // | |
32 | // of the ACTIVE matrix. If the guardring to be accounted in the local coords, in // | |
33 | // the Z and X conversions one needs to first subtract the fGuardLft and fGuardBot // | |
34 | // from the local Z,X coordinates // | |
35 | // // | |
36 | //////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
37 | ||
451f5018 | 38 | ClassImp(AliITSUSegmentationPix) |
909b16e7 | 39 | |
02d6eccc | 40 | const char* AliITSUSegmentationPix::fgkSegmListName = "ITSUSegmentations"; |
e5373622 | 41 | |
909b16e7 | 42 | //_____________________________________________________________________________RS |
451f5018 | 43 | AliITSUSegmentationPix::AliITSUSegmentationPix(UInt_t id, int nchips,int ncol,int nrow, |
909b16e7 | 44 | double pitchX,double pitchZ, |
909b16e7 | 45 | double thickness, |
e5373622 | 46 | double pitchLftC,double pitchRgtC, |
909b16e7 | 47 | double edgL,double edgR,double edgT,double edgB) |
48 | : AliITSsegmentation() | |
49 | ,fGuardLft(edgL) | |
50 | ,fGuardRgt(edgR) | |
51 | ,fGuardTop(edgT) | |
52 | ,fGuardBot(edgB) | |
53 | ,fPitchX(pitchX) | |
54 | ,fPitchZ(pitchZ) | |
55 | ,fPitchZLftCol(pitchLftC<0 ? pitchZ:pitchLftC) | |
56 | ,fPitchZRgtCol(pitchRgtC<0 ? pitchZ:pitchRgtC) | |
57 | ,fChipDZ(0) | |
58 | ,fNChips(nchips) | |
59 | ,fNColPerChip(nchips>0 ? ncol/nchips:0) | |
60 | ,fNRow(nrow) | |
61 | ,fNCol(ncol) | |
ee58ce21 | 62 | ,fDiodShiftMatNCol(0) |
63 | ,fDiodShiftMatNRow(0) | |
64 | ,fDiodShiftMatDim(0) | |
65 | ,fDiodShidtMatX(0) | |
66 | ,fDiodShidtMatZ(0) | |
909b16e7 | 67 | { |
29f5e263 | 68 | // Default constructor, sizes in cm |
451f5018 | 69 | if (nchips) SetUniqueID( AliITSUGeomTGeo::ComposeDetTypeID(id) ); |
909b16e7 | 70 | fChipDZ = (fNColPerChip-2)*fPitchZ + fPitchZLftCol + fPitchZRgtCol; |
71 | SetDetSize( fNRow*fPitchX /*+fGuardTop+fGuardBot*/, | |
72 | fNChips*fChipDZ /*+fGuardLft+fGuardRgt*/, | |
73 | thickness); | |
74 | // | |
75 | } | |
76 | ||
77 | //_____________________________________________________________________________RS | |
451f5018 | 78 | void AliITSUSegmentationPix::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const |
909b16e7 | 79 | { |
0e84ce67 | 80 | // Returns pixel coordinates (ix,iz) for given coordinates (x,z counted from col/row 0:0) |
81 | // expects x, z in cm. | |
82 | ix = int(x/fPitchX); | |
83 | iz = int(Z2Col(z)); | |
909b16e7 | 84 | // |
0e84ce67 | 85 | if (iz<0) { AliWarning(Form("Z=%f gives col=%d ouside [%d:%d)",z,iz,0,fNCol)); iz=0; } |
86 | else if (iz >= fNCol) { AliWarning(Form("Z=%f gives col=%d ouside [%d:%d)",z,iz,0,fNCol)); iz= fNCol-1;} | |
87 | if (ix<0) { AliWarning(Form("X=%f gives row=%d ouside [%d:%d)",x,ix,0,fNRow)); ix=0; } | |
88 | else if (ix >= fNRow) { AliWarning(Form("X=%f gives row=%d ouside [%d:%d)",x,ix,0,fNRow)); ix= fNRow-1;} | |
909b16e7 | 89 | // |
90 | } | |
91 | ||
92 | //_____________________________________________________________________________RS | |
451f5018 | 93 | void AliITSUSegmentationPix::GetPadTxz(Float_t &x,Float_t &z) const |
909b16e7 | 94 | { |
95 | // local transformation of real local coordinates (x,z) | |
29f5e263 | 96 | // expects x, z in cm |
909b16e7 | 97 | x /= fPitchX; |
98 | z = Z2Col(z); | |
99 | // | |
100 | } | |
101 | ||
102 | //_____________________________________________________________________________RS | |
451f5018 | 103 | void AliITSUSegmentationPix::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z) const |
909b16e7 | 104 | { |
105 | // Transform from pixel to real local coordinates | |
5e375bb4 | 106 | // returns x, z in cm. |
107 | x = Float_t((ix+0.5)*fPitchX); | |
909b16e7 | 108 | z = Col2Z(iz); |
109 | // | |
110 | } | |
111 | ||
112 | //_____________________________________________________________________________RS | |
451f5018 | 113 | Float_t AliITSUSegmentationPix::Z2Col(Float_t z) const |
909b16e7 | 114 | { |
ed2591c4 | 115 | // get column number (from 0) from local Z (wrt bottom left corner of the active matrix) |
4fa9d550 | 116 | int chip = int(z/fChipDZ); |
909b16e7 | 117 | float col = chip*fNColPerChip; |
118 | z -= chip*fChipDZ; | |
ed2591c4 | 119 | if (z>fPitchZLftCol) col += 1+(z-fPitchZLftCol)/fPitchZ; |
909b16e7 | 120 | return col; |
121 | } | |
122 | ||
123 | //_____________________________________________________________________________RS | |
451f5018 | 124 | Float_t AliITSUSegmentationPix::Col2Z(Int_t col) const |
909b16e7 | 125 | { |
126 | // convert column number (from 0) to Z coordinate | |
127 | int nchip = col/fNColPerChip; | |
128 | col %= fNColPerChip; | |
129 | float z = nchip*fChipDZ; | |
4fa9d550 | 130 | if (col>0) { |
131 | if (col<fNColPerChip-1) z += fPitchZLftCol + (col-0.5)*fPitchZ; | |
132 | else z += fChipDZ - fPitchZRgtCol/2; | |
133 | } | |
134 | else z += fPitchZLftCol/2; | |
909b16e7 | 135 | return z; |
136 | // | |
137 | } | |
138 | ||
139 | //______________________________________________________________________RS | |
451f5018 | 140 | AliITSUSegmentationPix& AliITSUSegmentationPix::operator=(const AliITSUSegmentationPix &src) |
909b16e7 | 141 | { |
142 | // = operator | |
143 | if(this==&src) return *this; | |
144 | AliITSsegmentation::operator=(src); | |
145 | fNCol = src.fNCol; | |
146 | fNRow = src.fNRow; | |
147 | fNColPerChip = src.fNColPerChip; | |
148 | fNChips = src.fNChips; | |
149 | fChipDZ = src.fChipDZ; | |
150 | fPitchZRgtCol = src.fPitchZRgtCol; | |
151 | fPitchZLftCol = src.fPitchZLftCol; | |
152 | fPitchZ = src.fPitchZ; | |
153 | fPitchX = src.fPitchX; | |
154 | // | |
155 | fGuardBot = src.fGuardBot; | |
156 | fGuardTop = src.fGuardTop; | |
157 | fGuardRgt = src.fGuardRgt; | |
158 | fGuardLft = src.fGuardLft; | |
159 | // | |
ee58ce21 | 160 | fDiodShiftMatNCol = src.fDiodShiftMatNCol; |
161 | fDiodShiftMatNRow = src.fDiodShiftMatNRow; | |
162 | fDiodShiftMatDim = src.fDiodShiftMatDim; | |
163 | delete fDiodShidtMatX; fDiodShidtMatX = 0; | |
164 | delete fDiodShidtMatZ; fDiodShidtMatZ = 0; | |
165 | if (fDiodShiftMatDim) { | |
166 | fDiodShidtMatX = new Double32_t[fDiodShiftMatDim]; | |
167 | fDiodShidtMatZ = new Double32_t[fDiodShiftMatDim]; | |
168 | for (int i=fDiodShiftMatDim;i--;) { | |
169 | fDiodShidtMatX[i] = src.fDiodShidtMatX[i]; | |
170 | fDiodShidtMatZ[i] = src.fDiodShidtMatZ[i]; | |
171 | } | |
172 | } | |
173 | // | |
909b16e7 | 174 | return *this; |
175 | } | |
176 | ||
177 | //____________________________________________________________________________RS | |
451f5018 | 178 | AliITSUSegmentationPix::AliITSUSegmentationPix(const AliITSUSegmentationPix &src) : |
909b16e7 | 179 | AliITSsegmentation(src) |
180 | ,fGuardLft(src.fGuardLft) | |
181 | ,fGuardRgt(src.fGuardRgt) | |
182 | ,fGuardTop(src.fGuardTop) | |
183 | ,fGuardBot(src.fGuardBot) | |
184 | ,fPitchX(src.fPitchX) | |
185 | ,fPitchZ(src.fPitchZ) | |
186 | ,fPitchZLftCol(src.fPitchZLftCol) | |
187 | ,fPitchZRgtCol(src.fPitchZRgtCol) | |
188 | ,fChipDZ(src.fChipDZ) | |
189 | ,fNChips(src.fNChips) | |
190 | ,fNColPerChip(src.fNColPerChip) | |
191 | ,fNRow(src.fNRow) | |
192 | ,fNCol(src.fNCol) | |
ee58ce21 | 193 | ,fDiodShiftMatNCol(src.fDiodShiftMatNCol) |
194 | ,fDiodShiftMatNRow(src.fDiodShiftMatNRow) | |
195 | ,fDiodShiftMatDim(src.fDiodShiftMatDim) | |
196 | ,fDiodShidtMatX(0) | |
197 | ,fDiodShidtMatZ(0) | |
909b16e7 | 198 | { |
ee58ce21 | 199 | // copy constructor |
200 | if (fDiodShiftMatDim) { | |
201 | fDiodShidtMatX = new Double32_t[fDiodShiftMatDim]; | |
202 | fDiodShidtMatZ = new Double32_t[fDiodShiftMatDim]; | |
203 | for (int i=fDiodShiftMatDim;i--;) { | |
204 | fDiodShidtMatX[i] = src.fDiodShidtMatX[i]; | |
205 | fDiodShidtMatZ[i] = src.fDiodShidtMatZ[i]; | |
206 | } | |
207 | } | |
909b16e7 | 208 | } |
209 | ||
210 | //____________________________________________________________________________RS | |
451f5018 | 211 | Float_t AliITSUSegmentationPix::Dpx(Int_t ) const |
909b16e7 | 212 | { |
213 | //returs x pixel pitch for a give pixel | |
214 | return fPitchX; | |
215 | } | |
216 | ||
217 | //____________________________________________________________________________RS | |
451f5018 | 218 | Float_t AliITSUSegmentationPix::Dpz(Int_t col) const |
909b16e7 | 219 | { |
220 | // returns z pixel pitch for a given pixel (cols starts from 0) | |
221 | col %= fNColPerChip; | |
222 | if (!col) return fPitchZLftCol; | |
223 | if (col==fNColPerChip-1) return fPitchZRgtCol; | |
224 | return fPitchZ; | |
225 | // | |
226 | } | |
227 | ||
228 | //------------------------------ | |
451f5018 | 229 | void AliITSUSegmentationPix::Neighbours(Int_t iX, Int_t iZ, Int_t* nlist, Int_t xlist[8], Int_t zlist[8]) const |
909b16e7 | 230 | { |
231 | // returns the neighbouring pixels for use in Cluster Finders and the like. | |
232 | // | |
233 | *nlist=8; | |
234 | xlist[0]=xlist[1]=iX; | |
235 | xlist[2]=iX-1; | |
236 | xlist[3]=iX+1; | |
237 | zlist[0]=iZ-1; | |
238 | zlist[1]=iZ+1; | |
239 | zlist[2]=zlist[3]=iZ; | |
240 | // Diagonal elements | |
241 | xlist[4]=iX+1; | |
242 | zlist[4]=iZ+1; | |
243 | // | |
244 | xlist[5]=iX-1; | |
245 | zlist[5]=iZ-1; | |
246 | // | |
247 | xlist[6]=iX-1; | |
248 | zlist[6]=iZ+1; | |
249 | // | |
250 | xlist[7]=iX+1; | |
251 | zlist[7]=iZ-1; | |
252 | // | |
253 | } | |
254 | ||
255 | //______________________________________________________________________ | |
451f5018 | 256 | Bool_t AliITSUSegmentationPix::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const |
909b16e7 | 257 | { |
258 | // Transformation from Geant detector centered local coordinates (cm) to | |
259 | // Pixel cell numbers ix and iz. | |
260 | // Input: | |
261 | // Float_t x detector local coordinate x in cm with respect to | |
262 | // the center of the sensitive volume. | |
263 | // Float_t z detector local coordinate z in cm with respect to | |
264 | // the center of the sensitive volulme. | |
265 | // Output: | |
266 | // Int_t ix detector x cell coordinate. Has the range | |
267 | // 0<=ix<fNRow. | |
268 | // Int_t iz detector z cell coordinate. Has the range | |
269 | // 0<=iz<fNCol. | |
270 | // Return: | |
271 | // kTRUE if point x,z is inside sensitive volume, kFALSE otherwise. | |
272 | // A value of -1 for ix or iz indecates that this point is outside of the | |
273 | // detector segmentation as defined. | |
29f5e263 | 274 | x += 0.5*Dx(); |
275 | z += 0.5*Dz(); | |
909b16e7 | 276 | ix = iz = -1; |
277 | if(x<0 || x>Dx()) return kFALSE; // outside x range. | |
278 | if(z<0 || z>Dz()) return kFALSE; // outside z range. | |
279 | ix = int(x/fPitchX); | |
280 | iz = Z2Col(z); | |
281 | return kTRUE; // Found ix and iz, return. | |
282 | } | |
283 | ||
284 | //______________________________________________________________________ | |
451f5018 | 285 | void AliITSUSegmentationPix::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const |
909b16e7 | 286 | { |
287 | // Transformation from Detector cell coordiantes to Geant detector centerd | |
288 | // local coordinates (cm). | |
289 | // Input: | |
290 | // Int_t ix detector x cell coordinate. Has the range 0<=ix<fNRow. | |
291 | // Int_t iz detector z cell coordinate. Has the range 0<=iz<fNCol. | |
292 | // Output: | |
293 | // Float_t x detector local coordinate x in cm with respect to the | |
294 | // center of the sensitive volume. | |
295 | // Float_t z detector local coordinate z in cm with respect to the | |
296 | // center of the sensitive volulme. | |
297 | // If ix and or iz is outside of the segmentation range a value of -0.5*Dx() | |
298 | // or -0.5*Dz() is returned. | |
299 | // | |
29f5e263 | 300 | x = -0.5*Dx(); // default value. |
301 | z = -0.5*Dz(); // default value. | |
909b16e7 | 302 | // RS: to check: why we don't do strict check for [0:n) |
0e84ce67 | 303 | if(ix<0 || ix>=fNRow) {AliWarning(Form("Obtained row %d is not in range [%d:%d)",ix,0,fNRow)); return;} // outside of detector |
304 | if(iz<0 || iz>=fNCol) {AliWarning(Form("Obtained col %d is not in range [%d:%d)",ix,0,fNCol)); return;} // outside of detector | |
29f5e263 | 305 | x += (ix+0.5)*fPitchX; // RS: we go to the center of the pad, i.e. + pitch/2, not to the boundary as in SPD |
306 | z += Col2Z(iz); | |
909b16e7 | 307 | return; // Found x and z, return. |
308 | } | |
309 | ||
310 | //______________________________________________________________________ | |
451f5018 | 311 | void AliITSUSegmentationPix::CellBoundries(Int_t ix,Int_t iz,Double_t &xl,Double_t &xu,Double_t &zl,Double_t &zu) const |
909b16e7 | 312 | { |
313 | // Transformation from Detector cell coordiantes to Geant detector centerd | |
314 | // local coordinates (cm). | |
315 | // Input: | |
316 | // Int_t ix detector x cell coordinate. Has the range 0<=ix<fNRow. | |
317 | // Int_t iz detector z cell coordinate. Has the range 0<=iz<fNCol. | |
318 | // Output: | |
319 | // Double_t xl detector local coordinate cell lower bounds x in cm | |
320 | // with respect to the center of the sensitive volume. | |
321 | // Double_t xu detector local coordinate cell upper bounds x in cm | |
322 | // with respect to the center of the sensitive volume. | |
323 | // Double_t zl detector local coordinate lower bounds z in cm with | |
324 | // respect to the center of the sensitive volulme. | |
325 | // Double_t zu detector local coordinate upper bounds z in cm with | |
326 | // respect to the center of the sensitive volulme. | |
327 | // If ix and or iz is outside of the segmentation range a value of -0.5*Dx() | |
328 | // and -0.5*Dx() or -0.5*Dz() and -0.5*Dz() are returned. | |
329 | Float_t x,z; | |
330 | DetToLocal(ix,iz,x,z); | |
331 | // | |
332 | if( ix<0 || ix>=fNRow || iz<0 || iz>=fNCol) { | |
29f5e263 | 333 | xl = xu = -0.5*Dx(); // default value. |
334 | zl = zu = -0.5*Dz(); // default value. | |
909b16e7 | 335 | return; // outside of detctor |
336 | } | |
29f5e263 | 337 | float zpitchH = Dpz(iz)*0.5; |
338 | float xpitchH = fPitchX*0.5; | |
909b16e7 | 339 | xl -= xpitchH; |
340 | xu += xpitchH; | |
341 | zl -= zpitchH; | |
342 | zu += zpitchH; | |
343 | return; // Found x and z, return. | |
344 | } | |
345 | ||
346 | //______________________________________________________________________ | |
451f5018 | 347 | Int_t AliITSUSegmentationPix::GetChipFromChannel(Int_t, Int_t iz) const |
909b16e7 | 348 | { |
349 | // returns chip number (in range 0-4) starting from channel number | |
350 | if(iz>=fNCol || iz<0 ){ | |
351 | AliWarning("Bad cell number"); | |
352 | return -1; | |
353 | } | |
354 | return iz/fNColPerChip; | |
355 | } | |
356 | ||
357 | //______________________________________________________________________ | |
451f5018 | 358 | Int_t AliITSUSegmentationPix::GetChipFromLocal(Float_t, Float_t zloc) const |
909b16e7 | 359 | { |
360 | // returns chip number (in range 0-4) starting from local coordinates | |
361 | Int_t ix0,iz; | |
362 | if (!LocalToDet(0,zloc,ix0,iz)) { | |
363 | AliWarning("Bad local coordinate"); | |
364 | return -1; | |
365 | } | |
366 | return GetChipFromChannel(ix0,iz); | |
367 | } | |
368 | ||
369 | //______________________________________________________________________ | |
451f5018 | 370 | Int_t AliITSUSegmentationPix::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t, Float_t) const |
909b16e7 | 371 | { |
372 | // returns the number of chips containing a road defined by given local coordinate limits | |
373 | // | |
909b16e7 | 374 | if (zmin>zmax) { |
375 | AliWarning("Bad coordinate limits: zmin>zmax!"); | |
376 | return -1; | |
377 | } | |
378 | // | |
379 | Int_t nChipInW = 0; | |
380 | // | |
29f5e263 | 381 | Float_t zminDet = -0.5*Dz(); |
382 | Float_t zmaxDet = 0.5*Dz(); | |
909b16e7 | 383 | if(zmin<zminDet) zmin=zminDet; |
384 | if(zmax>zmaxDet) zmax=zmaxDet; | |
385 | ||
386 | Int_t n1 = GetChipFromLocal(0,zmin); | |
387 | array[nChipInW] = n1; | |
388 | nChipInW++; | |
389 | ||
390 | Int_t n2 = GetChipFromLocal(0,zmax); | |
391 | ||
392 | if(n2!=n1){ | |
a11ef2e4 | 393 | Int_t imin=Min(n1,n2); |
394 | Int_t imax=Max(n1,n2); | |
909b16e7 | 395 | for(Int_t ichip=imin; ichip<=imax; ichip++){ |
396 | if(ichip==n1) continue; | |
397 | array[nChipInW]=ichip; | |
398 | nChipInW++; | |
399 | } | |
400 | } | |
401 | // | |
402 | return nChipInW; | |
403 | } | |
a84c4b15 | 404 | |
405 | //______________________________________________________________________ | |
451f5018 | 406 | void AliITSUSegmentationPix::Init() |
a84c4b15 | 407 | { |
408 | // init settings | |
409 | } | |
e5373622 | 410 | |
411 | //______________________________________________________________________ | |
451f5018 | 412 | Bool_t AliITSUSegmentationPix::Store(const char* outf) |
e5373622 | 413 | { |
414 | // store in the special list under given ID | |
415 | TString fns = outf; | |
416 | gSystem->ExpandPathName(fns); | |
417 | if (fns.IsNull()) {AliFatal("No file name provided"); return kFALSE;} | |
418 | TFile* fout = TFile::Open(fns.Data(),"update"); | |
419 | if (!fout) {AliFatal(Form("Failed to open output file %s",outf)); return kFALSE;} | |
420 | TObjArray* arr = (TObjArray*)fout->Get(fgkSegmListName); | |
451f5018 | 421 | int id = GetUniqueID(); |
e5373622 | 422 | if (!arr) arr = new TObjArray(); |
451f5018 | 423 | else if (arr->At(id)) {AliFatal(Form("Segmenation %d already exists in file %s",id,outf));return kFALSE;} |
e5373622 | 424 | // |
451f5018 | 425 | arr->AddAtAndExpand(this,id); |
e5373622 | 426 | arr->SetOwner(kTRUE); |
427 | fout->WriteObject(arr,fgkSegmListName,"kSingleKey"); | |
428 | fout->Close(); | |
429 | delete fout; | |
451f5018 | 430 | arr->RemoveAt(id); |
e5373622 | 431 | delete arr; |
432 | AliInfo(Form("Stored segmentation %d in %s",id,outf)); | |
433 | return kTRUE; | |
434 | // | |
435 | } | |
436 | ||
437 | //______________________________________________________________________ | |
451f5018 | 438 | AliITSUSegmentationPix* AliITSUSegmentationPix::LoadWithID(UInt_t id, const char* inpf) |
e5373622 | 439 | { |
440 | // store in the special list under given ID | |
441 | TString fns = inpf; | |
442 | gSystem->ExpandPathName(fns); | |
443 | if (fns.IsNull()) {AliFatalGeneral("LoadWithID","No file name provided"); return 0;} | |
444 | TFile* finp = TFile::Open(fns.Data()); | |
445 | if (!finp) {AliFatalGeneral("LoadWithID",Form("Failed to open file %s",inpf)); return 0;} | |
446 | TObjArray* arr = (TObjArray*)finp->Get(fgkSegmListName); | |
447 | if (!arr) { | |
448 | AliFatalGeneral("LoadWithID",Form("Failed to find segmenation array %s in %s",fgkSegmListName,inpf)); | |
449 | return 0; | |
450 | } | |
451f5018 | 451 | AliITSUSegmentationPix* segm = dynamic_cast<AliITSUSegmentationPix*>(arr->At(id)); |
452 | if (!segm || segm->GetUniqueID()!=id) {AliFatalGeneral("LoadWithID",Form("Failed to find segmenation %d in %s",id,inpf)); return 0;} | |
e5373622 | 453 | // |
451f5018 | 454 | arr->RemoveAt(id); |
e5373622 | 455 | arr->SetOwner(kTRUE); // to not leave in memory other segmenations |
456 | finp->Close(); | |
457 | delete finp; | |
458 | delete arr; | |
459 | // | |
460 | return segm; | |
461 | } | |
451f5018 | 462 | |
463 | //______________________________________________________________________ | |
464 | void AliITSUSegmentationPix::LoadSegmentations(TObjArray* dest, const char* inpf) | |
465 | { | |
466 | // store in the special list under given ID | |
467 | if (!dest) return; | |
468 | TString fns = inpf; | |
469 | gSystem->ExpandPathName(fns); | |
470 | if (fns.IsNull()) AliFatalGeneral("LoadWithID","No file name provided"); | |
471 | TFile* finp = TFile::Open(fns.Data()); | |
472 | if (!finp) AliFatalGeneral("LoadWithID",Form("Failed to open file %s",inpf)); | |
473 | TObjArray* arr = (TObjArray*)finp->Get(fgkSegmListName); | |
474 | if (!arr) AliFatalGeneral("LoadWithID",Form("Failed to find segmenation array %s in %s",fgkSegmListName,inpf)); | |
475 | int nent = arr->GetEntriesFast(); | |
476 | TObject *segm = 0; | |
477 | for (int i=nent;i--;) if ((segm=arr->At(i))) dest->AddAtAndExpand(segm,segm->GetUniqueID()); | |
478 | AliInfoGeneral("LoadSegmentations",Form("Loaded %d segmantions from %s",arr->GetEntries(),inpf)); | |
479 | arr->SetOwner(kFALSE); | |
02d6eccc | 480 | arr->Clear(); |
451f5018 | 481 | finp->Close(); |
482 | delete finp; | |
483 | delete arr; | |
484 | // | |
485 | } | |
ee58ce21 | 486 | |
487 | //______________________________________________________________________ | |
488 | void AliITSUSegmentationPix::SetDiodShiftMatrix(Int_t nrow,Int_t ncol, const Double_t *shiftX, const Double_t *shiftZ) | |
489 | { | |
490 | // set matrix of periodic shifts of diod center. provided arrays must be in the format shift[nrow][ncol] | |
491 | if (fDiodShiftMatDim) { | |
492 | delete fDiodShidtMatX; | |
493 | delete fDiodShidtMatZ; | |
494 | fDiodShidtMatX = fDiodShidtMatZ = 0; | |
495 | } | |
496 | // | |
497 | fDiodShiftMatNCol = ncol; | |
498 | fDiodShiftMatNRow = nrow; | |
499 | fDiodShiftMatDim = fDiodShiftMatNCol*fDiodShiftMatNRow; | |
500 | if (fDiodShiftMatDim) { | |
501 | fDiodShidtMatX = new Double32_t[fDiodShiftMatDim]; | |
502 | fDiodShidtMatZ = new Double32_t[fDiodShiftMatDim]; | |
503 | for (int ir=0;ir<fDiodShiftMatNRow;ir++) { | |
504 | for (int ic=0;ic<fDiodShiftMatNCol;ic++) { | |
505 | int cnt = ic+ir*fDiodShiftMatNCol; | |
506 | fDiodShidtMatX[cnt] = shiftX ? shiftX[cnt] : 0.; | |
507 | fDiodShidtMatZ[cnt] = shiftZ ? shiftZ[cnt] : 0.; | |
508 | } | |
509 | } | |
510 | } | |
511 | ||
512 | } | |
513 | ||
514 | //______________________________________________________________________ | |
515 | void AliITSUSegmentationPix::Print(Option_t* option) const | |
516 | { | |
517 | // print itself | |
518 | const double kmc=1e4; | |
519 | printf("Segmentation %d: Size: DX: %.1f DZ: %.1f DY: %.1f | Pitch: X:%.1f Z:%.1f\n", | |
520 | GetUniqueID(),kmc*Dx(),kmc*Dy(),kmc*Dz(),kmc*Dpx(1),kmc*Dpz(1)); | |
521 | printf("%d chips along Z: chip Ncol=%d Nrow=%d\n",fNChips, fNColPerChip,fNRow); | |
522 | if (Abs(fPitchZLftCol-fPitchZ)>1e-5) printf("Special left column pitch: %.1f\n",fPitchZLftCol*kmc); | |
523 | if (Abs(fPitchZRgtCol-fPitchZ)>1e-5) printf("Special right column pitch: %.1f\n",fPitchZRgtCol*kmc); | |
524 | printf("Guard-rings: Left: %.1f Right: %.1f Top: %.1f Bottom: %.1f\n",kmc*fGuardLft,kmc*fGuardRgt,kmc*fGuardTop,kmc*fGuardBot); | |
525 | // | |
526 | if (fDiodShiftMatDim) { | |
527 | double dx,dz=0; | |
528 | printf("Diod shift periodicity pattern (X,Z[row][col])\n"); | |
529 | for (int irow=0;irow<fDiodShiftMatNRow;irow++) { | |
530 | for (int icol=0;icol<fDiodShiftMatNCol;icol++) { | |
531 | GetDiodShift(irow,icol,dx,dz); | |
532 | printf("%.1f/%.1f |",kmc*dx,kmc*dz); | |
533 | } | |
534 | printf("\n"); | |
535 | } | |
536 | } | |
537 | } | |
538 | ||
539 | //______________________________________________________________________ | |
540 | void AliITSUSegmentationPix::GetDiodShift(Int_t row,Int_t col, Float_t &dx,Float_t &dz) const | |
541 | { | |
542 | // obtain optional diod shift | |
543 | if (!fDiodShiftMatDim) {dx=dz=0; return;} | |
544 | int cnt = (col%fDiodShiftMatNCol) + (row%fDiodShiftMatNRow)*fDiodShiftMatNCol; | |
545 | dx = fDiodShidtMatX[cnt]; | |
546 | dz = fDiodShidtMatZ[cnt]; | |
547 | // | |
548 | } |