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