]>
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$ | |
d962cab4 | 18 | Revision 1.9 2000/08/29 20:19:03 nilsen |
19 | Removed dependancy on structure AliITSeomS and replaced it with class | |
20 | AliITSgeomMatrix. Added many new functions with many new arguments. Most | |
21 | in the form of in line functions for speed. | |
22 | ||
269f57ed | 23 | Revision 1.4.4.6 2000/06/04 16:33:32 Nilsen |
24 | A restructured AliITSgeom class. Now used AliITSgeomMatrix. | |
25 | ||
26 | Revision 1.4.4.5 2000/03/04 23:42:39 Nilsen | |
593e9459 | 27 | Updated the comments/documentations and improved the maintainability of the |
28 | code. | |
29 | ||
269f57ed | 30 | Revision 1.4.4.4 2000/03/02 21:27:07 Nilsen |
593e9459 | 31 | Added two functions, SetByAngles and SetTrans. |
32 | ||
269f57ed | 33 | Revision 1.4.4.3 2000/01/23 03:09:10 Nilsen |
593e9459 | 34 | // fixed compiler warnings for new function LtLErrorMatrix(...) |
35 | ||
269f57ed | 36 | Revision 1.4.4.2 2000/01/19 23:18:20 Nilsen |
593e9459 | 37 | Added transformations of Error matrix to AliITSgeom and fixed some typos |
38 | in AliITS.h and AliITShitIndex.h | |
39 | ||
269f57ed | 40 | Revision 1.4.4.1 2000/01/12 19:03:32 Nilsen |
593e9459 | 41 | This is the version of the files after the merging done in December 1999. |
42 | See the ReadMe110100.txt file for details | |
43 | ||
44 | Revision 1.4 1999/10/15 07:03:20 fca | |
45 | Fixed bug in GetModuleId(Int_t index,Int_t &lay,Int_t &lad, Int_t &det) and | |
46 | a typo in the creator. aliroot need to be rerun to get a fixed geometry. | |
47 | ||
aa6248e2 | 48 | Revision 1.3 1999/10/04 15:20:12 fca |
49 | Correct syntax accepted by g++ but not standard for static members, remove minor warnings | |
50 | ||
ad0e60d9 | 51 | Revision 1.2 1999/09/29 09:24:20 fca |
52 | Introduction of the Copyright and cvs Log | |
53 | ||
4c039060 | 54 | */ |
55 | ||
58005f18 | 56 | /////////////////////////////////////////////////////////////////////// |
593e9459 | 57 | // ITS geometry manipulation routines. // |
58005f18 | 58 | // Created April 15 1999. // |
59 | // version: 0.0.0 // | |
60 | // By: Bjorn S. Nilsen // | |
61 | // version: 0.0.1 // | |
62 | // Updated May 27 1999. // | |
593e9459 | 63 | // Added Cylindrical random and global based changes. // |
58005f18 | 64 | // Added function PrintComparison. // |
65 | /////////////////////////////////////////////////////////////////////// | |
593e9459 | 66 | |
67 | ||
68 | //////////////////////////////////////////////////////////////////////// | |
593e9459 | 69 | // The local coordinate system by, default, is show in the following |
70 | // figures. Also shown are the ladder numbering scheme. | |
71 | //Begin_Html | |
72 | /* | |
269f57ed | 73 | <img src="picts/ITS/AliITSgeomMatrix_L1.gif"> |
74 | </pre> | |
75 | <br clear=left> | |
76 | <font size=+2 color=blue> | |
77 | <p>This shows the relative geometry differences between the ALICE Global | |
78 | coordinate system and the local detector coordinate system. | |
79 | </font> | |
80 | <pre> | |
81 | ||
82 | <pre> | |
593e9459 | 83 | <img src="picts/ITS/its1+2_convention_front_5.gif"> |
84 | </pre> | |
85 | <br clear=left> | |
86 | <font size=+2 color=blue> | |
87 | <p>This shows the front view of the SPDs and the orientation of the local | |
88 | pixel coordinate system. Note that the inner pixel layer has its y coordinate | |
89 | in the opposite direction from all of the other layers. | |
90 | </font> | |
91 | <pre> | |
92 | ||
93 | <pre> | |
94 | <img src="picts/ITS/its3+4_convention_front_5.gif"> | |
95 | </pre> | |
96 | <br clear=left> | |
97 | <font size=+2 color=blue> | |
98 | <p>This shows the front view of the SDDs and the orientation of the local | |
99 | pixel coordinate system. | |
100 | </font> | |
101 | <pre> | |
102 | ||
103 | <pre> | |
104 | <img src="picts/ITS/its5+6_convention_front_5.gif"> | |
105 | </pre> | |
106 | <br clear=left> | |
107 | <font size=+2 color=blue> | |
108 | <p>This shows the front view of the SSDs and the orientation of the local | |
109 | pixel coordinate system. | |
110 | </font> | |
111 | <pre> | |
112 | */ | |
113 | //End_Html | |
269f57ed | 114 | // |
593e9459 | 115 | //////////////////////////////////////////////////////////////////////// |
116 | ||
117 | //////////////////////////////////////////////////////////////////////// | |
118 | // | |
119 | // version: 0 | |
120 | // Written by Bjorn S. Nilsen | |
121 | // | |
122 | // Data Members: | |
123 | // | |
124 | // Int_t fNlayers | |
125 | // The number of ITS layers for this geometry. By default this | |
126 | // is 6, but can be modified by the creator function if there are | |
127 | // more layers defined. | |
128 | // | |
129 | // Int_t *fNlad | |
130 | // A pointer to an array fNlayers long containing the number of | |
131 | // ladders for each layer. This array is typically created and filled | |
132 | // by the AliITSgeom creator function. | |
133 | // | |
134 | // Int_t *fNdet | |
135 | // A pointer to an array fNlayers long containing the number of | |
136 | // active detector volumes for each ladder. This array is typically | |
137 | // created and filled by the AliITSgeom creator function. | |
138 | // | |
269f57ed | 139 | // AliITSgeomMatrix *fGm |
140 | // A pointer to an array of AliITSgeomMatrix classes. One element | |
141 | // per module (detector) in the ITS. AliITSgeomMatrix basicly contains | |
142 | // all of the necessary information about the detector and it's coordinate | |
143 | // transformations. | |
593e9459 | 144 | // |
145 | // TObjArray *fShape | |
146 | // A pointer to an array of TObjects containing the detailed shape | |
147 | // information for each type of detector used in the ITS. For example | |
148 | // I have created AliITSgeomSPD, AliITSgeomSDD, and AliITSgeomSSD as | |
149 | // example structures, derived from TObjects, to hold the detector | |
150 | // information. I would recommend that one element in each of these | |
151 | // structures, that which describes the shape of the active volume, | |
152 | // be one of the ROOT classes derived from TShape. In this way it would | |
153 | // be easy to have the display program display the correct active | |
154 | // ITS volumes. See the example classes AliITSgeomSPD, AliITSgeomSDD, | |
155 | // and AliITSgeomSSD for a more detailed example. | |
593e9459 | 156 | //////////////////////////////////////////////////////////////////////// |
58005f18 | 157 | #include <iostream.h> |
269f57ed | 158 | #include <fstream.h> |
58005f18 | 159 | #include <iomanip.h> |
160 | #include <stdio.h> | |
269f57ed | 161 | #include <string.h> |
162 | #include <ctype.h> | |
163 | #include <TObject.h> | |
164 | #include <TRandom.h> | |
e8189707 | 165 | |
58005f18 | 166 | #include "AliITSgeom.h" |
269f57ed | 167 | #include "AliITSgeomMatrix.h" |
168 | #include "AliITSgeomSPD.h" | |
169 | #include "AliITSgeomSDD.h" | |
170 | #include "AliITSgeomSSD.h" | |
58005f18 | 171 | |
172 | ClassImp(AliITSgeom) | |
173 | ||
174 | //_____________________________________________________________________ | |
175 | AliITSgeom::AliITSgeom(){ | |
176 | //////////////////////////////////////////////////////////////////////// | |
177 | // The default constructor for the AliITSgeom class. It, by default, | |
178 | // sets fNlayers to zero and zeros all pointers. | |
179 | //////////////////////////////////////////////////////////////////////// | |
180 | // Default constructor. | |
181 | // Do not allocate anything zero everything | |
269f57ed | 182 | fTrans = 0; // standard GEANT global/local coordinate system. |
58005f18 | 183 | fNlayers = 0; |
184 | fNlad = 0; | |
185 | fNdet = 0; | |
269f57ed | 186 | fGm = 0; |
58005f18 | 187 | fShape = 0; |
188 | return; | |
189 | } | |
190 | ||
191 | //_____________________________________________________________________ | |
192 | AliITSgeom::~AliITSgeom(){ | |
193 | //////////////////////////////////////////////////////////////////////// | |
194 | // The destructor for the AliITSgeom class. If the arrays fNlad, | |
085bb6ed | 195 | // fNdet, or fGm have had memory allocated to them, there pointer values |
58005f18 | 196 | // are non zero, then this memory space is freed and they are set |
197 | // to zero. In addition, fNlayers is set to zero. The destruction of | |
198 | // TObjArray fShape is, by default, handled by the TObjArray destructor. | |
199 | //////////////////////////////////////////////////////////////////////// | |
200 | // Default destructor. | |
593e9459 | 201 | // if arrays exist delete them. Then set everything to zero. |
085bb6ed | 202 | if(fGm!=0){ |
269f57ed | 203 | for(Int_t i=0;i<fNlayers;i++) delete fGm[i]; |
204 | delete fGm; | |
085bb6ed | 205 | } // end if fGm!=0 |
58005f18 | 206 | if(fNlad!=0) delete[] fNlad; |
207 | if(fNdet!=0) delete[] fNdet; | |
208 | fNlayers = 0; | |
209 | fNlad = 0; | |
210 | fNdet = 0; | |
269f57ed | 211 | fGm = 0; |
58005f18 | 212 | return; |
213 | } | |
269f57ed | 214 | //______________________________________________________________________ |
215 | void AliITSgeom::ReadNewFile(const char *filename){ | |
216 | printf("New file format not defined yet\n"); | |
217 | return; | |
218 | } | |
58005f18 | 219 | //_____________________________________________________________________ |
220 | AliITSgeom::AliITSgeom(const char *filename){ | |
221 | //////////////////////////////////////////////////////////////////////// | |
222 | // The constructor for the AliITSgeom class. All of the data to fill | |
223 | // this structure is read in from the file given my the input filename. | |
224 | //////////////////////////////////////////////////////////////////////// | |
225 | FILE *pf; | |
269f57ed | 226 | Int_t i,lm=0,id[3]; |
58005f18 | 227 | Int_t l,a,d; |
228 | Float_t x,y,z,o,p,q,r,s,t; | |
269f57ed | 229 | Double_t rot6[6],tran[3]; |
230 | char buf[200],*buff=0; // input character buffer; | |
58005f18 | 231 | |
232 | pf = fopen(filename,"r"); | |
233 | ||
234 | fNlayers = 6; // set default number of ladders | |
269f57ed | 235 | TryAgain: |
58005f18 | 236 | fNlad = new Int_t[fNlayers]; |
237 | fNdet = new Int_t[fNlayers]; | |
269f57ed | 238 | fNmodules = 0; |
593e9459 | 239 | // find the number of ladders and detectors in this geometry. |
58005f18 | 240 | for(i=0;i<fNlayers;i++){fNlad[i]=fNdet[i]=0;} // zero out arrays |
269f57ed | 241 | while(fgets(buf,200,pf)!=NULL){ // for ever loop |
242 | for(i=0;i<200;i++)if(buf[i]!=' '){ // remove blank spaces. | |
243 | buff = &(buf[i]); | |
244 | break; | |
245 | } // end for i | |
246 | // remove blank lines and comments. | |
247 | if(buff[0]=='\n'||buff[0]=='#'||buff[0]=='!'|| | |
248 | (buff[0]=='/'&&buff[1]=='/')) continue; | |
249 | if(isalpha(buff[0])) { // must be the new file formated file. | |
250 | fclose(pf); | |
251 | delete[] fNlad;delete[] fNdet; | |
252 | ReadNewFile(filename); | |
253 | return; | |
254 | } // end if isalpha(buff[0]) | |
255 | sscanf(buff,"%d %d %d %f %f %f %f %f %f %f %f %f", | |
256 | &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t); | |
257 | if(l>lm) lm = l; | |
58005f18 | 258 | if(l<1 || l>fNlayers) { |
269f57ed | 259 | printf("error in file %s layer=%d min. is 1 max is %d/n", |
58005f18 | 260 | filename,l,fNlayers); |
261 | continue; | |
262 | }// end if l | |
269f57ed | 263 | fNmodules++; |
264 | if(l<=fNlayers&&fNlad[l-1]<a) fNlad[l-1] = a; | |
265 | if(l<=fNlayers&&fNdet[l-1]<d) fNdet[l-1] = d; | |
266 | } // end while ever loop | |
267 | if(lm>fNlayers){ | |
268 | delete[] fNlad; | |
269 | delete[] fNdet; | |
270 | fNlayers = lm; | |
271 | goto TryAgain; | |
272 | } // end if lm>fNlayers | |
593e9459 | 273 | // counted the number of ladders and detectors now allocate space. |
269f57ed | 274 | fGm = new AliITSgeomMatrix*[fNmodules]; |
58005f18 | 275 | |
276 | // Set up Shapes for a default configuration of 6 layers. | |
269f57ed | 277 | fTrans = 0; // standard GEANT global/local coordinate system. |
085bb6ed | 278 | fShape = new TObjArray(3); |
269f57ed | 279 | AddShape((TObject *) new AliITSgeomSPD()); // shape 0 |
58005f18 | 280 | AddShape((TObject *) new AliITSgeomSDD()); // shape 1 |
269f57ed | 281 | AddShape((TObject *) new AliITSgeomSPD()); // shape 2 |
58005f18 | 282 | |
593e9459 | 283 | // prepare to read in transforms |
269f57ed | 284 | lm = 0; // reuse lm as counter of modules. |
58005f18 | 285 | rewind(pf); // start over reading file |
269f57ed | 286 | while(fgets(buf,200,pf)!=NULL){ // for ever loop |
287 | for(i=0;i<200;i++)if(buf[i]!=' '){ // remove blank spaces. | |
288 | buff = &(buf[i]); | |
289 | break; | |
290 | } // end for i | |
291 | // remove blank lines and comments. | |
292 | if(buff[0]=='\n'||buff[0]=='#'||buff[0]=='!'|| | |
293 | (buff[0]=='/'&&buff[1]=='/')) continue; | |
294 | x = y = z = o = p = q = r = s = t = 0.0; | |
295 | sscanf(buff,"%d %d %d %f %f %f %f %f %f %f %f %f", | |
296 | &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t); | |
58005f18 | 297 | if(l<1 || l>fNlayers) { |
269f57ed | 298 | printf("error in file %s layer=%d min. is 1 max is %d/n", |
58005f18 | 299 | filename,l,fNlayers); |
300 | continue; | |
301 | }// end if l | |
269f57ed | 302 | id[0] = l;id[1] = a;id[2] = d; |
303 | tran[0] = tran[1] = tran[2] = 0.0; | |
304 | tran[0] = (Double_t)x;tran[1] = (Double_t)y;tran[2] = (Double_t)z; | |
305 | rot6[0] = rot6[1] = rot6[2] = rot6[3] = rot6[4] = rot6[5] =0.0; | |
306 | rot6[0] = (Double_t)o;rot6[1] = (Double_t)p;rot6[2] = (Double_t)q; | |
307 | rot6[3] = (Double_t)r;rot6[4] = (Double_t)s;rot6[5] = (Double_t)t; | |
308 | switch (l){ | |
309 | case 1: case 2: // layer 1 or2 SPD | |
310 | fGm[lm++] = new AliITSgeomMatrix(rot6,0,id,tran); | |
311 | break; | |
312 | case 3: case 4: // layer 3 or 4 SDD | |
313 | fGm[lm++] = new AliITSgeomMatrix(rot6,1,id,tran); | |
314 | break; | |
315 | case 5: case 6: // layer 5 or 6 SSD | |
316 | fGm[lm++] = new AliITSgeomMatrix(rot6,2,id,tran); | |
317 | break; | |
318 | } // end switch | |
319 | } // end while ever loop | |
58005f18 | 320 | fclose(pf); |
321 | } | |
322 | ||
323 | //________________________________________________________________________ | |
269f57ed | 324 | AliITSgeom::AliITSgeom(AliITSgeom &source){ |
58005f18 | 325 | //////////////////////////////////////////////////////////////////////// |
326 | // The copy constructor for the AliITSgeom class. It calls the | |
327 | // = operator function. See the = operator function for more details. | |
328 | //////////////////////////////////////////////////////////////////////// | |
593e9459 | 329 | |
330 | *this = source; // Just use the = operator for now. | |
331 | ||
332 | return; | |
58005f18 | 333 | } |
334 | ||
335 | //________________________________________________________________________ | |
269f57ed | 336 | void AliITSgeom::operator=(AliITSgeom &source){ |
58005f18 | 337 | //////////////////////////////////////////////////////////////////////// |
338 | // The = operator function for the AliITSgeom class. It makes an | |
339 | // independent copy of the class in such a way that any changes made | |
340 | // to the copied class will not affect the source class in any way. | |
341 | // This is required for many ITS alignment studies where the copied | |
342 | // class is then modified by introducing some misalignment. | |
343 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 344 | Int_t i; |
58005f18 | 345 | |
346 | if(this == &source) return; // don't assign to ones self. | |
347 | ||
348 | // if there is an old structure allocated delete it first. | |
269f57ed | 349 | if(this->fGm != 0){ |
350 | for(i=0;i<this->fNmodules;i++) delete this->fGm[i]; | |
351 | delete this->fGm; | |
085bb6ed | 352 | } // end if fGm != 0 |
353 | if(fNlad != 0) delete[] fNlad; | |
354 | if(fNdet != 0) delete[] fNdet; | |
355 | ||
269f57ed | 356 | this->fTrans = source.fTrans; |
357 | this->fNmodules = source.fNmodules; | |
358 | this->fNlayers = source.fNlayers; | |
359 | this->fNlad = new Int_t[fNlayers]; | |
360 | for(i=0;i<this->fNlayers;i++) this->fNlad[i] = source.fNlad[i]; | |
361 | this->fNdet = new Int_t[fNlayers]; | |
362 | for(i=0;i<this->fNlayers;i++) this->fNdet[i] = source.fNdet[i]; | |
363 | this->fShape = new TObjArray(*(source.fShape));//This does not make a proper copy. | |
364 | this->fGm = new AliITSgeomMatrix*[this->fNmodules]; | |
365 | for(i=0;i<this->fNmodules;i++){ | |
366 | this->fGm[i] = new AliITSgeomMatrix(*(source.fGm[i])); | |
085bb6ed | 367 | } // end for i |
58005f18 | 368 | return; |
269f57ed | 369 | }//_____________________________________________________________________ |
370 | Int_t AliITSgeom::GetModuleIndex(const Int_t lay,const Int_t lad, | |
371 | const Int_t det){ | |
593e9459 | 372 | //////////////////////////////////////////////////////////////////////// |
373 | // This routine computes the module index number from the layer, | |
374 | // ladder, and detector numbers. The number of ladders and detectors | |
375 | // per layer is determined when this geometry package is constructed, | |
376 | // see AliITSgeom(const char *filename) for specifics. | |
377 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 378 | Int_t i,j,k,id[3]; |
593e9459 | 379 | |
380 | i = fNdet[lay-1] * (lad-1) + det - 1; | |
381 | j = 0; | |
382 | for(k=0;k<lay-1;k++) j += fNdet[k]*fNlad[k]; | |
269f57ed | 383 | i = i+j; |
384 | fGm[i]->GetIndex(id); | |
385 | if(id[0]==lay&&id[1]==lad&&id[2]==det) return i; | |
386 | // Array of modules fGm is not in expected order. Search for this index | |
387 | for(i=0;i<fNmodules;i++){ | |
388 | fGm[i]->GetIndex(id); | |
389 | if(id[0]==lay&&id[1]==lad&&id[2]==det) return i; | |
390 | } // end for i | |
391 | // This layer ladder and detector combination does not exist return -1. | |
392 | return -1; | |
593e9459 | 393 | } |
269f57ed | 394 | //______________________________________________________________________ |
395 | void AliITSgeom::GetModuleId(const Int_t index, | |
396 | Int_t &lay,Int_t &lad,Int_t &det){ | |
593e9459 | 397 | //////////////////////////////////////////////////////////////////////// |
398 | // This routine computes the layer, ladder and detector number | |
399 | // given the module index number. The number of ladders and detectors | |
400 | // per layer is determined when this geometry package is constructed, | |
401 | // see AliITSgeom(const char *filename) for specifics. | |
402 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 403 | Int_t id[3]; |
593e9459 | 404 | |
269f57ed | 405 | fGm[index]->GetIndex(id); |
406 | lay = id[0]; lad = id[1]; det = id[2]; | |
407 | return; | |
408 | ||
409 | // The old way kept for posterity. | |
410 | /* | |
411 | Int_t i,j,k; | |
593e9459 | 412 | j = 0; |
413 | for(k=0;k<fNlayers;k++){ | |
58005f18 | 414 | j += fNdet[k]*fNlad[k]; |
aa6248e2 | 415 | if(j>index)break; |
58005f18 | 416 | } // end for k |
417 | lay = k+1; | |
418 | i = index -j + fNdet[k]*fNlad[k]; | |
419 | j = 0; | |
420 | for(k=0;k<fNlad[lay-1];k++){ | |
aa6248e2 | 421 | j += fNdet[lay-1]; |
422 | if(j>i)break; | |
58005f18 | 423 | } // end for k |
424 | lad = k+1; | |
425 | det = 1+i-fNdet[lay-1]*k; | |
426 | return; | |
269f57ed | 427 | */ |
58005f18 | 428 | } |
429 | //___________________________________________________________________________ | |
269f57ed | 430 | Int_t AliITSgeom::GetStartDet(const Int_t dtype){ |
085bb6ed | 431 | ///////////////////////////////////////////////////////////////////////// |
432 | // returns the starting module index value for a give type of detector id | |
433 | ///////////////////////////////////////////////////////////////////////// | |
269f57ed | 434 | |
435 | switch(dtype){ | |
085bb6ed | 436 | case 0: |
269f57ed | 437 | return GetModuleIndex(1,1,1); |
085bb6ed | 438 | break; |
439 | case 1: | |
269f57ed | 440 | return GetModuleIndex(3,1,1); |
085bb6ed | 441 | break; |
442 | case 2: | |
269f57ed | 443 | return GetModuleIndex(5,1,1); |
085bb6ed | 444 | break; |
445 | default: | |
446 | printf("<AliITSgeom::GetFirstDet> undefined detector type\n"); | |
269f57ed | 447 | return 0; |
448 | } // end switch | |
085bb6ed | 449 | |
269f57ed | 450 | printf("<AliITSgeom::GetFirstDet> undefined detector type\n"); |
451 | return 0; | |
085bb6ed | 452 | } |
453 | ||
454 | //___________________________________________________________________________ | |
269f57ed | 455 | Int_t AliITSgeom::GetLastDet(const Int_t dtype){ |
085bb6ed | 456 | ///////////////////////////////////////////////////////////////////////// |
457 | // returns the last module index value for a give type of detector id | |
458 | ///////////////////////////////////////////////////////////////////////// | |
269f57ed | 459 | |
460 | switch(dtype){ | |
085bb6ed | 461 | case 0: |
269f57ed | 462 | return GetLastSPD(); |
085bb6ed | 463 | break; |
464 | case 1: | |
269f57ed | 465 | return GetLastSDD(); |
085bb6ed | 466 | break; |
467 | case 2: | |
269f57ed | 468 | return GetLastSSD(); |
085bb6ed | 469 | break; |
470 | default: | |
471 | printf("<AliITSgeom::GetLastDet> undefined detector type\n"); | |
269f57ed | 472 | return 0; |
473 | } // end switch | |
474 | ||
475 | printf("<AliITSgeom::GetLastDet> undefined detector type\n"); | |
476 | return 0; | |
085bb6ed | 477 | } |
478 | ||
58005f18 | 479 | //___________________________________________________________________________ |
593e9459 | 480 | void AliITSgeom::PrintComparison(FILE *fp,AliITSgeom *other){ |
58005f18 | 481 | //////////////////////////////////////////////////////////////////////// |
482 | // This function was primarily created for diagnostic reasons. It | |
483 | // print to a file pointed to by the file pointer fp the difference | |
484 | // between two AliITSgeom classes. The format of the file is basicly, | |
485 | // define d? to be the difference between the same element of the two | |
085bb6ed | 486 | // classes. For example dfrx = this->fGm[i][j].frx - other->fGm[i][j].frx. |
58005f18 | 487 | // if(at least one of dfx0, dfy0, dfz0,dfrx,dfry,dfrz are non zero) then print |
488 | // layer ladder detector dfx0 dfy0 dfz0 dfrx dfry dfrz | |
489 | // if(at least one of the 9 elements of dfr[] are non zero) then print | |
490 | // layer ladder detector dfr[0] dfr[1] dfr[2] | |
491 | // dfr[3] dfr[4] dfr[5] | |
492 | // dfr[6] dfr[7] dfr[8] | |
493 | // Only non zero values are printed to save space. The differences are | |
494 | // typical written to a file because there are usually a lot of numbers | |
495 | // printed out and it is usually easier to read them in some nice editor | |
496 | // rather than zooming quickly past you on a screen. fprintf is used to | |
497 | // do the printing. The fShapeIndex difference is not printed at this time. | |
498 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 499 | Int_t i,j,idt[3],ido[3]; |
500 | Double_t tt[3],to[3]; // translation | |
501 | Double_t rt[3],ro[3]; // phi in radians | |
502 | Double_t mt[3][3],mo[3][3]; // matrixes | |
503 | AliITSgeomMatrix *gt,*go; | |
58005f18 | 504 | Bool_t t; |
505 | ||
269f57ed | 506 | for(i=0;i<this->fNmodules;i++){ |
507 | gt = this->GetGeomMatrix(i); | |
508 | go = other->GetGeomMatrix(i); | |
509 | gt->GetIndex(idt); | |
510 | go->GetIndex(ido); | |
511 | t = kFALSE; | |
512 | for(i=0;i<3;i++) t = t&&idt[i]!=ido[i]; | |
513 | if(t) fprintf(fp,"%4.4d %1.1d %2.2d %2.2d %1.1d %2.2d %2.2d\n",i, | |
514 | idt[0],idt[1],idt[2],ido[0],ido[1],ido[2]); | |
515 | gt->GetTranslation(tt); | |
516 | go->GetTranslation(to); | |
517 | gt->GetAngles(rt); | |
518 | go->GetAngles(ro); | |
519 | t = kFALSE; | |
520 | for(i=0;i<3;i++) t = t&&tt[i]!=to[i]; | |
521 | if(t) fprintf(fp,"%1.1d %2.2d %2.2d dTrans=%f %f %f drot=%f %f %f\n", | |
522 | idt[0],idt[1],idt[2], | |
523 | tt[0]-to[0],tt[1]-to[1],tt[2]-to[2], | |
524 | rt[0]-ro[0],rt[1]-ro[1],rt[2]-ro[2]); | |
58005f18 | 525 | t = kFALSE; |
269f57ed | 526 | gt->GetMatrix(mt); |
527 | go->GetMatrix(mo); | |
528 | for(i=0;i<3;i++)for(j=0;j<3;j++) t = mt[i][j] != mo[i][j]; | |
58005f18 | 529 | if(t){ |
269f57ed | 530 | fprintf(fp,"%1.1d %2.2d %2.2d dfr= %e %e %e\n", |
531 | idt[0],idt[1],idt[2], | |
532 | mt[0][0]-mo[0][0],mt[0][1]-mo[0][1],mt[0][2]-mo[0][2]); | |
58005f18 | 533 | fprintf(fp," dfr= %e %e %e\n", |
269f57ed | 534 | mt[1][0]-mo[1][0],mt[1][1]-mo[1][1],mt[1][2]-mo[1][2]); |
58005f18 | 535 | fprintf(fp," dfr= %e %e %e\n", |
269f57ed | 536 | mt[2][0]-mo[2][0],mt[2][1]-mo[2][1],mt[2][2]-mo[2][2]); |
537 | } // end if t | |
58005f18 | 538 | } // end for i |
539 | return; | |
540 | } | |
541 | ||
542 | //___________________________________________________________________________ | |
269f57ed | 543 | void AliITSgeom::PrintData(FILE *fp, |
544 | const Int_t lay,const Int_t lad,const Int_t det){ | |
58005f18 | 545 | //////////////////////////////////////////////////////////////////////// |
546 | // This function prints out the coordinate transformations for | |
547 | // the particular detector defined by layer, ladder, and detector | |
593e9459 | 548 | // to the file pointed to by the File pointer fp. fprintf statements |
58005f18 | 549 | // are used to print out the numbers. The format is |
550 | // layer ladder detector Trans= fx0 fy0 fz0 rot= frx fry frz Shape=fShapeIndex | |
551 | // dfr= fr[0] fr[1] fr[2] | |
552 | // dfr= fr[3] fr[4] fr[5] | |
553 | // dfr= fr[6] fr[7] fr[8] | |
554 | // By indicating which detector, some control over the information | |
555 | // is given to the user. The output it written to the file pointed | |
556 | // to by the file pointer fp. This can be set to stdout if you want. | |
557 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 558 | AliITSgeomMatrix *gt; |
559 | Double_t t[3],r[3],m[3][3]; | |
58005f18 | 560 | |
269f57ed | 561 | gt = this->GetGeomMatrix(GetModuleIndex(lay,lad,det)); |
562 | gt->GetTranslation(t); | |
563 | gt->GetAngles(r); | |
58005f18 | 564 | fprintf(fp,"%1.1d %2.2d %2.2d Trans=%f %f %f rot=%f %f %f Shape=%d\n", |
269f57ed | 565 | lay,lad,det,t[0],t[1],t[2],r[0],r[1],r[2], |
566 | gt->GetDetectorIndex()); | |
567 | gt->GetMatrix(m); | |
568 | fprintf(fp," dfr= %e %e %e\n",m[0][0],m[0][1],m[0][2]); | |
569 | fprintf(fp," dfr= %e %e %e\n",m[1][0],m[1][1],m[1][2]); | |
570 | fprintf(fp," dfr= %e %e %e\n",m[2][0],m[2][1],m[2][2]); | |
58005f18 | 571 | return; |
572 | } | |
573 | //___________________________________________________________________________ | |
269f57ed | 574 | ofstream & AliITSgeom::PrintGeom(ofstream &R__b){ |
58005f18 | 575 | //////////////////////////////////////////////////////////////////////// |
576 | // The default Streamer function "written by ROOT" doesn't write out | |
577 | // the arrays referenced by pointers. Therefore, a specific Streamer function | |
578 | // has to be written. This function should not be modified but instead added | |
579 | // on to so that older versions can still be read. The proper handling of | |
580 | // the version dependent streamer function hasn't been written do to the lack | |
593e9459 | 581 | // of finding an example at the time of writing. |
582 | //////////////////////////////////////////////////////////////////////// | |
583 | // Stream an object of class AliITSgeom. | |
269f57ed | 584 | Int_t i; |
593e9459 | 585 | |
269f57ed | 586 | R__b.setf(ios::scientific); |
587 | R__b << fTrans << " "; | |
588 | R__b << fNmodules << " "; | |
589 | R__b << fNlayers << " "; | |
590 | for(i=0;i<fNlayers;i++) R__b << fNlad[i] << " "; | |
591 | for(i=0;i<fNlayers;i++) R__b << fNdet[i] << "\n"; | |
592 | for(i=0;i<fNmodules;i++) { | |
593 | R__b <<setprecision(16) << *(fGm[i]) << "\n"; | |
594 | } // end for i | |
595 | return R__b; | |
593e9459 | 596 | } |
597 | //___________________________________________________________________________ | |
269f57ed | 598 | ifstream & AliITSgeom::ReadGeom(ifstream &R__b){ |
593e9459 | 599 | //////////////////////////////////////////////////////////////////////// |
600 | // The default Streamer function "written by ROOT" doesn't write out | |
601 | // the arrays referenced by pointers. Therefore, a specific Streamer function | |
602 | // has to be written. This function should not be modified but instead added | |
603 | // on to so that older versions can still be read. The proper handling of | |
604 | // the version dependent streamer function hasn't been written do to the lack | |
605 | // of finding an example at the time of writing. | |
58005f18 | 606 | //////////////////////////////////////////////////////////////////////// |
607 | // Stream an object of class AliITSgeom. | |
269f57ed | 608 | Int_t i; |
58005f18 | 609 | |
58005f18 | 610 | fNlad = new Int_t[fNlayers]; |
611 | fNdet = new Int_t[fNlayers]; | |
085bb6ed | 612 | if(fGm!=0){ |
269f57ed | 613 | for(i=0;i<fNmodules;i++) delete fGm[i]; |
614 | delete fGm; | |
085bb6ed | 615 | } // end if fGm!=0 |
269f57ed | 616 | |
617 | R__b >> fTrans >> fNmodules >> fNlayers; | |
618 | fNlad = new Int_t[fNlayers]; | |
619 | fNdet = new Int_t[fNlayers]; | |
620 | for(i=0;i<fNlayers;i++) R__b >> fNlad[i]; | |
621 | for(i=0;i<fNlayers;i++) R__b >> fNdet[i]; | |
622 | fGm = new AliITSgeomMatrix*[fNmodules]; | |
623 | for(i=0;i<fNmodules;i++){ | |
624 | fGm[i] = new AliITSgeomMatrix; | |
625 | R__b >> *(fGm[i]); | |
58005f18 | 626 | } // end for i |
269f57ed | 627 | return R__b; |
593e9459 | 628 | } |
269f57ed | 629 | //___________________________________________________________________________ |
630 | void AliITSgeom::Streamer(TBuffer &R__b){ | |
593e9459 | 631 | //////////////////////////////////////////////////////////////////////// |
269f57ed | 632 | // The default Streamer function "written by ROOT" doesn't write out |
633 | // the arrays referenced by pointers. Therefore, a specific Streamer function | |
634 | // has to be written. This function should not be modified but instead added | |
635 | // on to so that older versions can still be read. The proper handling of | |
636 | // the version dependent streamer function hasn't been written do to the lack | |
637 | // of finding an example at the time of writing. | |
593e9459 | 638 | //////////////////////////////////////////////////////////////////////// |
269f57ed | 639 | // Stream an object of class AliITSgeom. |
640 | Int_t i,j,k,l; | |
641 | UInt_t R__s=0, R__c=0; | |
642 | ||
643 | if (R__b.IsReading()) { | |
644 | Version_t R__v = R__b.ReadVersion(); | |
645 | if (R__v==1) { | |
646 | if(fNlad!=0) delete[] fNlad; | |
647 | if(fNdet!=0) delete[] fNdet; | |
648 | if(fGm!=0){ | |
649 | for(i=0;i<fNlayers;i++) delete[] fGm[i]; | |
650 | delete[] fGm; | |
651 | } // end if fGm!=0 | |
652 | Int_t idt,id[3],inmax; | |
653 | Double_t t[3],r[3],m[9],s[3][3]; | |
654 | TObject::Streamer(R__b); | |
655 | fTrans = 0; | |
656 | R__b >> fNlayers; | |
657 | fNlad = new Int_t[fNlayers]; | |
658 | fNdet = new Int_t[fNlayers]; | |
659 | for(i=0;i<fNlayers;i++) R__b >> fNlad[i]; | |
660 | for(i=0;i<fNlayers;i++) R__b >> fNdet[i]; | |
661 | fNmodules = GetModuleIndex(fNlayers,fNlad[fNlayers-1], | |
662 | fNdet[fNlayers-1]); | |
663 | fGm = new AliITSgeomMatrix*[fNmodules]; | |
664 | inmax = 0; | |
665 | for(i=0;i<fNlayers;i++){ | |
666 | for(j=0;j<fNlad[i]*fNdet[i];j++){ | |
667 | R__b >> idt; | |
668 | R__b >> t[0]; | |
669 | R__b >> t[1]; | |
670 | R__b >> t[2]; | |
671 | R__b >> r[0]; | |
672 | R__b >> r[1]; | |
673 | R__b >> r[2]; | |
674 | for(k=0;k<9;k++) R__b >> m[k]; | |
675 | for(k=0;k<3;k++)for(l=0;l<3;l++) s[k][l] = m[3*k+l]; | |
676 | GetModuleId(inmax,id[0],id[1],id[2]); | |
677 | fGm[inmax++] = new AliITSgeomMatrix(idt,id,s,t); | |
678 | } // end for j | |
679 | } // end for i | |
680 | R__b >> fShape; | |
681 | } else if(R__v==2){ | |
682 | if(fNlad!=0) delete[] fNlad; | |
683 | if(fNdet!=0) delete[] fNdet; | |
684 | if(fGm!=0){for(i=0;i<fNmodules;i++) delete fGm[i];delete[] fGm;} | |
685 | TObject::Streamer(R__b); | |
686 | R__b >> fTrans; | |
687 | R__b >> fNlayers; | |
688 | R__b.ReadArray(fNlad); | |
689 | R__b.ReadArray(fNdet); | |
690 | R__b >> fShape; | |
691 | R__b >> fNmodules; | |
692 | fGm = new AliITSgeomMatrix*[fNmodules]; | |
693 | for(i=0;i<fNmodules;i++){ | |
694 | fGm[i] = new AliITSgeomMatrix; | |
695 | fGm[i]->Streamer(R__b); | |
696 | } // end for i | |
697 | //R__b.ReadArray(fGm); | |
698 | R__b.CheckByteCount(R__s, R__c, AliITSgeom::IsA()); | |
699 | } // end if R__v==? | |
700 | } else { // Writing. | |
701 | R__c = R__b.WriteVersion(AliITSgeom::IsA(), kTRUE); | |
702 | TObject::Streamer(R__b); | |
703 | R__b << fTrans; | |
704 | R__b << fNlayers; | |
705 | R__b.WriteArray(fNlad, fNlayers); | |
706 | R__b.WriteArray(fNdet, fNlayers); | |
707 | R__b << fShape; | |
708 | R__b << fNmodules; | |
709 | //R__b.WriteArray(fGm, __COUNTER__); | |
710 | for(i=0;i<fNmodules;i++){ | |
711 | fGm[i]->Streamer(R__b); | |
712 | } // end for i | |
713 | R__b.SetByteCount(R__c, kTRUE); | |
714 | } // end if reading/writing. | |
593e9459 | 715 | } |
716 | //______________________________________________________________________ | |
269f57ed | 717 | // The following routines modify the transformation of "this" |
718 | // geometry transformations in a number of different ways. | |
593e9459 | 719 | //______________________________________________________________________ |
269f57ed | 720 | void AliITSgeom::GlobalChange(const Float_t *tran,const Float_t *rot){ |
593e9459 | 721 | //////////////////////////////////////////////////////////////////////// |
722 | // This function performs a Cartesian translation and rotation of | |
723 | // the full ITS from its default position by an amount determined by | |
724 | // the three element arrays dtranslation and drotation. If every element | |
725 | // of dtranslation and drotation are zero then there is no change made | |
726 | // the geometry. The change is global in that the exact same translation | |
727 | // and rotation is done to every detector element in the exact same way. | |
728 | // The units of the translation are those of the Monte Carlo, usually cm, | |
729 | // and those of the rotation are in radians. The elements of dtranslation | |
730 | // are dtranslation[0] = x, dtranslation[1] = y, and dtranslation[2] = z. | |
731 | // The elements of drotation are drotation[0] = rx, drotation[1] = ry, and | |
732 | // drotation[2] = rz. A change in x will move the hole ITS in the ALICE | |
733 | // global x direction, the same for a change in y. A change in z will | |
734 | // result in a translation of the ITS as a hole up or down the beam line. | |
735 | // A change in the angles will result in the inclination of the ITS with | |
736 | // respect to the beam line, except for an effective rotation about the | |
737 | // beam axis which will just rotate the ITS as a hole about the beam axis. | |
738 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 739 | Int_t i,j; |
740 | Double_t t[3],r[3]; | |
741 | AliITSgeomMatrix *g; | |
742 | ||
743 | fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true. | |
744 | for(i=0;i<fNmodules;i++){ | |
745 | g = this->GetGeomMatrix(i); | |
746 | g->GetTranslation(t); | |
747 | g->GetAngles(r); | |
748 | for(j=0;j<3;j++){ | |
749 | t[j] += tran[j]; | |
750 | r[j] += rot[j]; | |
751 | } // end for j | |
752 | g->SetTranslation(t); | |
753 | g->SetAngles(r); | |
593e9459 | 754 | } // end for i |
755 | return; | |
756 | } | |
593e9459 | 757 | //___________________________________________________________________________ |
269f57ed | 758 | void AliITSgeom::GlobalCylindericalChange(const Float_t *tran,const Float_t *rot){ |
593e9459 | 759 | //////////////////////////////////////////////////////////////////////// |
760 | // This function performs a cylindrical translation and rotation of | |
761 | // each ITS element by a fixed about in radius, rphi, and z from its | |
762 | // default position by an amount determined by the three element arrays | |
763 | // dtranslation and drotation. If every element of dtranslation and | |
764 | // drotation are zero then there is no change made the geometry. The | |
765 | // change is global in that the exact same distance change in translation | |
766 | // and rotation is done to every detector element in the exact same way. | |
767 | // The units of the translation are those of the Monte Carlo, usually cm, | |
768 | // and those of the rotation are in radians. The elements of dtranslation | |
769 | // are dtranslation[0] = r, dtranslation[1] = rphi, and dtranslation[2] = z. | |
770 | // The elements of drotation are drotation[0] = rx, drotation[1] = ry, and | |
771 | // drotation[2] = rz. A change in r will results in the increase of the | |
772 | // radius of each layer by the same about. A change in rphi will results in | |
773 | // the rotation of each layer by a different angle but by the same | |
774 | // circumferential distance. A change in z will result in a translation | |
775 | // of the ITS as a hole up or down the beam line. A change in the angles | |
776 | // will result in the inclination of the ITS with respect to the beam | |
777 | // line, except for an effective rotation about the beam axis which will | |
778 | // just rotate the ITS as a hole about the beam axis. | |
779 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 780 | Int_t i,j; |
781 | Double_t t[3],ro[3],r,r0,phi,rphi; | |
782 | AliITSgeomMatrix *g; | |
783 | ||
784 | fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true. | |
785 | for(i=0;i<fNmodules;i++){ | |
786 | g = this->GetGeomMatrix(i); | |
787 | g->GetTranslation(t); | |
788 | g->GetAngles(ro); | |
789 | r = r0= TMath::Hypot(t[1],t[0]); | |
790 | phi = TMath::ATan2(t[1],t[0]); | |
593e9459 | 791 | rphi = r0*phi; |
792 | r += tran[0]; | |
793 | rphi += tran[1]; | |
794 | phi = rphi/r0; | |
269f57ed | 795 | t[0] = r*TMath::Cos(phi); |
796 | t[1] = r*TMath::Sin(phi); | |
797 | t[2] += tran[2]; | |
798 | for(j=0;j<3;j++){ | |
799 | ro[j] += rot[j]; | |
800 | } // end for j | |
801 | g->SetTranslation(t); | |
802 | g->SetAngles(ro); | |
593e9459 | 803 | } // end for i |
804 | return; | |
805 | } | |
593e9459 | 806 | //___________________________________________________________________________ |
269f57ed | 807 | void AliITSgeom::RandomChange(const Float_t *stran,const Float_t *srot){ |
593e9459 | 808 | //////////////////////////////////////////////////////////////////////// |
809 | // This function performs a Gaussian random displacement and/or | |
810 | // rotation about the present global position of each active | |
811 | // volume/detector of the ITS. The sigma of the random displacement | |
812 | // is determined by the three element array stran, for the | |
813 | // x y and z translations, and the three element array srot, | |
814 | // for the three rotation about the axis x y and z. | |
815 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 816 | Int_t i,j; |
817 | Double_t t[3],r[3]; | |
818 | TRandom ran; | |
819 | AliITSgeomMatrix *g; | |
820 | ||
821 | fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true. | |
822 | for(i=0;i<fNmodules;i++){ | |
823 | g = this->GetGeomMatrix(i); | |
824 | g->GetTranslation(t); | |
825 | g->GetAngles(r); | |
826 | for(j=0;j<3;j++){ | |
827 | t[j] += ran.Gaus(0.0,stran[j]); | |
828 | r[j] += ran.Gaus(0.0, srot[j]); | |
829 | } // end for j | |
830 | g->SetTranslation(t); | |
831 | g->SetAngles(r); | |
593e9459 | 832 | } // end for i |
833 | return; | |
834 | } | |
593e9459 | 835 | //___________________________________________________________________________ |
269f57ed | 836 | void AliITSgeom::RandomCylindericalChange(const Float_t *stran, |
837 | const Float_t *srot){ | |
593e9459 | 838 | //////////////////////////////////////////////////////////////////////// |
839 | // This function performs a Gaussian random displacement and/or | |
840 | // rotation about the present global position of each active | |
841 | // volume/detector of the ITS. The sigma of the random displacement | |
842 | // is determined by the three element array stran, for the | |
843 | // r rphi and z translations, and the three element array srot, | |
844 | // for the three rotation about the axis x y and z. This random change | |
845 | // in detector position allow for the simulation of a random uncertainty | |
846 | // in the detector positions of the ITS. | |
847 | //////////////////////////////////////////////////////////////////////// | |
269f57ed | 848 | Int_t i,j; |
849 | Double_t t[3],ro[3],r,r0,phi,rphi; | |
850 | TRandom ran; | |
851 | AliITSgeomMatrix *g; | |
852 | ||
853 | fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true. | |
854 | for(i=0;i<fNmodules;i++){ | |
855 | g = this->GetGeomMatrix(i); | |
856 | g->GetTranslation(t); | |
857 | g->GetAngles(ro); | |
858 | r = r0= TMath::Hypot(t[1],t[0]); | |
859 | phi = TMath::ATan2(t[1],t[0]); | |
860 | rphi = r0*phi; | |
593e9459 | 861 | r += ran.Gaus(0.0,stran[0]); |
269f57ed | 862 | rphi += ran.Gaus(0.0,stran[1]); |
863 | phi = rphi/r0; | |
864 | t[0] = r*TMath::Cos(phi); | |
865 | t[1] = r*TMath::Sin(phi); | |
866 | t[2] += ran.Gaus(0.0,stran[2]); | |
867 | for(j=0;j<3;j++){ | |
868 | ro[j] += ran.Gaus(0.0, srot[j]); | |
869 | } // end for j | |
870 | g->SetTranslation(t); | |
871 | g->SetAngles(ro); | |
593e9459 | 872 | } // end for i |
873 | return; | |
874 | } | |
875 | //______________________________________________________________________ | |
876 | void AliITSgeom::GeantToTracking(AliITSgeom &source){ | |
877 | ///////////////////////////////////////////////////////////////////////// | |
269f57ed | 878 | // Copy the geometry data but change it to go between the ALICE |
879 | // Global coordinate system to that used by the ITS tracking. A slightly | |
880 | // different coordinate system is used when tracking. This coordinate | |
881 | // system is only relevant when the geometry represents the cylindrical | |
882 | // ALICE ITS geometry. For tracking the Z axis is left alone but X-> -Y | |
883 | // and Y-> X such that X always points out of the ITS cylinder for every | |
884 | // layer including layer 1 (where the detectors are mounted upside down). | |
885 | //Begin_Html | |
886 | /* | |
887 | <img src="picts/ITS/AliITSgeomMatrix_T1.gif"> | |
888 | */ | |
889 | //End_Html | |
890 | //////////////////////////////////////////////////////////////////////// | |
891 | Int_t i,j,k,l,id[3]; | |
892 | Double_t R0[3][3],R1[3][3]; | |
893 | Double_t A0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}}; | |
894 | Double_t A1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}}; | |
895 | ||
896 | *this = source; // copy everything | |
897 | for(i=0;i<GetIndexMax();i++){ | |
898 | fGm[i]->GetIndex(id); | |
899 | fGm[i]->GetMatrix(R0); | |
900 | if(id[0]==1){ // Layer 1 is treated different from the others. | |
901 | for(j=0;j<3;j++) for(k=0;k<3;k++){ | |
902 | R1[j][k] = 0.; | |
903 | for(l=0;l<3;l++) R1[j][k] += A0[j][l]*R0[l][k]; | |
904 | } // end for j,k | |
905 | }else{ | |
906 | for(j=0;j<3;j++) for(k=0;k<3;k++){ | |
907 | R1[j][k] = 0.; | |
908 | for(l=0;l<3;l++) R1[j][k] += A1[j][l]*R0[l][k]; | |
909 | } // end for j,k | |
910 | } // end if | |
911 | fGm[i]->SetMatrix(R1); | |
593e9459 | 912 | } // end for i |
269f57ed | 913 | this->fTrans = (this->fTrans && 0xfffe) + 1; // set bit 0 true. |
593e9459 | 914 | return; |
58005f18 | 915 | } |
269f57ed | 916 | //______________________________________________________________________ |
d962cab4 | 917 | Int_t AliITSgeom::GetNearest(const Double_t g[3],const Int_t lay){ |
085bb6ed | 918 | //////////////////////////////////////////////////////////////////////// |
269f57ed | 919 | // Finds the Detector (Module) that is nearest the point g [cm] in |
920 | // ALICE Global coordinates. If layer !=0 then the search is restricted | |
921 | // to Detectors (Modules) in that particular layer. | |
085bb6ed | 922 | //////////////////////////////////////////////////////////////////////// |
269f57ed | 923 | Int_t i,l,a,e,in=0; |
924 | Double_t d,dn=1.0e10; | |
925 | Bool_t t=lay!=0; // skip if lay = 0 default value check all layers. | |
085bb6ed | 926 | |
269f57ed | 927 | for(i=0;i<fNmodules;i++){ |
928 | if(t){GetModuleId(i,l,a,e);if(l!=lay) continue;} | |
929 | if((d=fGm[i]->Distance2(g))<dn){ | |
930 | dn = d; | |
931 | in = i; | |
932 | } // end if | |
933 | } // end for i | |
934 | return in; | |
085bb6ed | 935 | } |
269f57ed | 936 | //______________________________________________________________________ |
d962cab4 | 937 | void AliITSgeom::GetNearest27(const Double_t g[3],Int_t n[27],const Int_t lay){ |
269f57ed | 938 | //////////////////////////////////////////////////////////////////////// |
939 | // Finds 27 Detectors (Modules) that are nearest the point g [cm] in | |
940 | // ALICE Global coordinates. If layer !=0 then the search is restricted | |
941 | // to Detectors (Modules) in that particular layer. The number 27 comes | |
942 | // from including the nearest detector and all those around it (up, down, | |
943 | // left, right, forwards, backwards, and the corners). | |
944 | //////////////////////////////////////////////////////////////////////// | |
945 | Int_t i,l,a,e,in[27]={0,0,0,0,0,0,0,0,0, | |
946 | 0,0,0,0,0,0,0,0,0, | |
947 | 0,0,0,0,0,0,0,0,0,}; | |
948 | Double_t d,dn[27]={1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10, | |
949 | 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10, | |
950 | 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10, | |
951 | 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10, | |
952 | 1.0e10,1.0e10,1.0e10}; | |
953 | Bool_t t=(lay!=0); // skip if lay = 0 default value check all layers. | |
954 | ||
955 | for(i=0;i<fNmodules;i++){ | |
956 | if(t){GetModuleId(i,l,a,e);if(l!=lay) continue;} | |
957 | for(a=0;a<27;a++){ | |
958 | d = fGm[i]->Distance2(g); | |
959 | if(d<dn[a]){ | |
960 | for(e=26;e>a;e--){dn[e] = dn[e-1];in[e] = in[e-1];} | |
961 | dn[a] = d; in[a] = i; | |
962 | } // end if d<dn[i] | |
963 | } // end for a | |
964 | } // end for i | |
965 | for(i=0;i<27;i++) n[i] = in[i]; | |
966 | } | |
967 | //---------------------------------------------------------------------- |