fixed the tainted variables
[u/mrichter/AliRoot.git] / ITS / AliITSgeom.cxx
CommitLineData
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
88cb7938 16/* $Id$ */
4c039060 17
58005f18 18///////////////////////////////////////////////////////////////////////
593e9459 19// ITS geometry manipulation routines. //
58005f18 20// Created April 15 1999. //
21// version: 0.0.0 //
22// By: Bjorn S. Nilsen //
23// version: 0.0.1 //
24// Updated May 27 1999. //
023ae34b 25// Added Cylindrical random and global based changes. //
58005f18 26// Added function PrintComparison. //
023ae34b 27// Modified and added functions Feb. 7 2006 //
58005f18 28///////////////////////////////////////////////////////////////////////
593e9459 29
30
31////////////////////////////////////////////////////////////////////////
593e9459 32// The local coordinate system by, default, is show in the following
33// figures. Also shown are the ladder numbering scheme.
34//Begin_Html
35/*
269f57ed 36<img src="picts/ITS/AliITSgeomMatrix_L1.gif">
37</pre>
38<br clear=left>
39<font size=+2 color=blue>
40<p>This shows the relative geometry differences between the ALICE Global
41coordinate system and the local detector coordinate system.
42</font>
43<pre>
44
45<pre>
593e9459 46<img src="picts/ITS/its1+2_convention_front_5.gif">
47</pre>
48<br clear=left>
49<font size=+2 color=blue>
50<p>This shows the front view of the SPDs and the orientation of the local
51pixel coordinate system. Note that the inner pixel layer has its y coordinate
52in the opposite direction from all of the other layers.
53</font>
54<pre>
55
56<pre>
57<img src="picts/ITS/its3+4_convention_front_5.gif">
58</pre>
59<br clear=left>
60<font size=+2 color=blue>
61<p>This shows the front view of the SDDs and the orientation of the local
62pixel coordinate system.
63</font>
64<pre>
65
66<pre>
67<img src="picts/ITS/its5+6_convention_front_5.gif">
68</pre>
69<br clear=left>
70<font size=+2 color=blue>
71<p>This shows the front view of the SSDs and the orientation of the local
72pixel coordinate system.
73</font>
74<pre>
75*/
76//End_Html
269f57ed 77//
593e9459 78////////////////////////////////////////////////////////////////////////
79
80////////////////////////////////////////////////////////////////////////
81//
82// version: 0
83// Written by Bjorn S. Nilsen
84//
85// Data Members:
86//
023ae34b 87// TString fVersion
88// Transformation version.
89// Int_t fTrans
90// Flag to keep track of which transformation
91// Int_t fNmodules
92// The total number of modules
593e9459 93// Int_t fNlayers
94// The number of ITS layers for this geometry. By default this
95// is 6, but can be modified by the creator function if there are
96// more layers defined.
97//
023ae34b 98// TArrayI fNlad
593e9459 99// A pointer to an array fNlayers long containing the number of
100// ladders for each layer. This array is typically created and filled
101// by the AliITSgeom creator function.
102//
023ae34b 103// TArrayI fNdet
593e9459 104// A pointer to an array fNlayers long containing the number of
105// active detector volumes for each ladder. This array is typically
106// created and filled by the AliITSgeom creator function.
107//
023ae34b 108// TObjArray fGm containing objects of type AliITSgeomMatrix
269f57ed 109// A pointer to an array of AliITSgeomMatrix classes. One element
110// per module (detector) in the ITS. AliITSgeomMatrix basicly contains
111// all of the necessary information about the detector and it's coordinate
112// transformations.
593e9459 113//
023ae34b 114// TObjArray fShape containting objects of type AliITSgeom
593e9459 115// A pointer to an array of TObjects containing the detailed shape
116// information for each type of detector used in the ITS. For example
023ae34b 117// I have created AliITSgeomSPD, AliITSgeomSDD, and
118// AliITSsegmenttionSSD as example structures, derived from TObjects,
119// to hold the detector information. I would recommend that one element
120// in each of these structures, that which describes the shape of the
121// active volume, be one of the ROOT classes derived from TShape. In this
122// way it would be easy to have the display program display the correct
123// active ITS volumes. See the example classes AliITSgeomSPD,
124// AliITSgeomSDD, and AliITSgeomSSD for a more detailed
125// example.
593e9459 126////////////////////////////////////////////////////////////////////////
4ae5bbc4 127#include <Riostream.h>
5cf690c1 128#include <ctype.h>
8253cd9a 129
269f57ed 130#include <TRandom.h>
f77f13c8 131#include <TSystem.h>
023ae34b 132#include <TArrayI.h>
e8189707 133
f77f13c8 134#include "AliITSgeomSPD.h"
023ae34b 135#include "AliITSgeomSDD.h"
269f57ed 136#include "AliITSgeomSSD.h"
023ae34b 137#include "AliITSgeom.h"
f77f13c8 138#include "AliLog.h"
58005f18 139
140ClassImp(AliITSgeom)
141
85f1e34a 142//______________________________________________________________________
023ae34b 143AliITSgeom::AliITSgeom():
144TObject(),
145fVersion("GEANT"),// Transformation version.
146fTrans(0), // Flag to keep track of which transformation
147fNmodules(0), // The total number of modules
148fNlayers(0), // The number of layers.
149fNlad(), //[] Array of the number of ladders/layer(layer)
150fNdet(), //[] Array of the number of detector/ladder(layer)
151fGm(0,0), // Structure of translation. and rotation.
152fShape(0,0) // Array of shapes and detector information.
153{
85f1e34a 154 // The default constructor for the AliITSgeom class. It, by default,
155 // sets fNlayers to zero and zeros all pointers.
156 // Do not allocate anything zero everything.
023ae34b 157 // Inputs:
158 // none.
159 // Outputs:
160 // none.
161 // Return:
162 // a zeroed AliITSgeom object.
85f1e34a 163
023ae34b 164 fGm.SetOwner(kTRUE);
165 fShape.SetOwner(kTRUE);
8253cd9a 166 return;
167}
e56160b8 168
85f1e34a 169//______________________________________________________________________
023ae34b 170AliITSgeom::AliITSgeom(Int_t itype,Int_t nlayers,const Int_t *nlads,
171 const Int_t *ndets,Int_t mods):
172TObject(),
173fVersion("GEANT"), // Transformation version.
174fTrans(itype), // Flag to keep track of which transformation
175fNmodules(mods), // The total number of modules
176fNlayers(nlayers), // The number of layers.
177fNlad(nlayers,nlads),//[] Array of the number of ladders/layer(layer)
178fNdet(nlayers,ndets),//[] Array of the number of detector/ladder(layer)
179fGm(mods,0), // Structure of translation. and rotation.
180fShape(5,0) // Array of shapes and detector information.
181{
85f1e34a 182 // A simple constructor to set basic geometry class variables
183 // Inputs:
023ae34b 184 // Int_t itype the type of transformation kept.
185 // bit 0 => Standard GEANT
186 // bit 1 => ITS tracking
012f0f4c 187 // bit 2 => A change in the coordinate system
188 // has been made. others are still to be defined
189 // as needed.
190 // Int_t nlayers The number of ITS layers also set the size of
191 // the arrays
192 // Int_t *nlads an array of the number of ladders for each
023ae34b 193 // layer. This array must be nlayers long.
012f0f4c 194 // Int_t *ndets an array of the number of detectors per ladder
195 // for each layer. This array must be nlayers long.
023ae34b 196 // Int_t mods The number of modules. Typically the sum of all the
197 // detectors on every layer and ladder.
85f1e34a 198 // Outputs:
023ae34b 199 // none
200 // Return:
201 // A properly inilized AliITSgeom object.
202
203 fGm.SetOwner(kTRUE);
204 fShape.SetOwner(kTRUE);
205 return;
206}
207//______________________________________________________________________
208void AliITSgeom::Init(Int_t itype,Int_t nlayers,const Int_t *nlads,
209 const Int_t *ndets,Int_t mods){
210 // A simple Inilizer to set basic geometry class variables
211 // Inputs:
212 // Int_t itype the type of transformation kept.
213 // bit 0 => Standard GEANT
214 // bit 1 => ITS tracking
012f0f4c 215 // bit 2 => A change in the coordinate system
216 // has been made. others are still to be defined
217 // as needed.
218 // Int_t nlayers The number of ITS layers also set the size of
219 // the arrays
220 // Int_t *nlads an array of the number of ladders for each
023ae34b 221 // layer. This array must be nlayers long.
012f0f4c 222 // Int_t *ndets an array of the number of detectors per ladder
223 // for each layer. This array must be nlayers long.
023ae34b 224 // Int_t mods The number of modules. Typically the sum of all the
225 // detectors on every layer and ladder.
226 // Outputs:
227 // none
228 // Return:
229 // A properly inilized AliITSgeom object.
8253cd9a 230
023ae34b 231 fVersion = "GEANT"; // Transformation version.
232 fTrans = itype; // Flag to keep track of which transformation
233 fNmodules = mods; // The total number of modules
234 fNlayers = nlayers; // The number of layers.
235 fNlad.Set(nlayers,nlads);//[] Array of the number of ladders/layer(layer)
236 fNdet.Set(nlayers,ndets);//[] Array of the number of detector/ladder(layer)
237 fGm.Clear();
238 fGm.Expand(mods); // Structure of translation. and rotation.
239 fGm.SetOwner(kTRUE);
240 fShape.Clear();
241 fShape.Expand(5); // Array of shapes and detector information.
242 fShape.SetOwner(kTRUE);
8253cd9a 243 return;
58005f18 244}
8253cd9a 245//______________________________________________________________________
023ae34b 246void AliITSgeom::CreateMatrix(Int_t mod,Int_t lay,Int_t lad,Int_t det,
247 AliITSDetector idet,const Double_t tran[3],
248 const Double_t rot[10]){
85f1e34a 249 // Given the translation vector tran[3] and the rotation matrix rot[1],
250 // this function creates and adds to the TObject Array fGm the
251 // AliITSgeomMatrix object.
85f1e34a 252 // The rot[10] matrix is set up like:
253 /* / rot[0] rot[1] rot[2] \
254 // | rot[3] rot[4] rot[5] |
255 // \ rot[6] rot[7] rot[8] / if(rot[9]!=0) then the Identity matrix
256 // is used regardless of the values in rot[0]-rot[8].
257 */
023ae34b 258 // Inputs:
259 // Int_t mod The module number. The location in TObjArray
260 // Int_t lay The layer where this module is
261 // Int_t lad On which ladder this module is
262 // Int_t det Which detector on this ladder this module is
263 // AliITSDetector idet The type of detector see AliITSgeom.h
264 // Double_t tran[3] The translation vector
265 // Double_t rot[10] The rotation matrix.
266 // Outputs:
267 // none
268 // Return:
269 // none.
8253cd9a 270 Int_t id[3];
271 Double_t r[3][3] = {{1.0,0.0,0.0},{0.0,1.0,0.0},{0.0,0.0,1.0}};
58005f18 272
023ae34b 273 if(mod<0||mod>=fGm.GetSize()){
274 Error("CreateMatrix","mod=%d is out of bounds max value=%d",mod,
275 fGm.GetSize());
276 return;
277 } // end if
278 delete fGm.At(mod);
8253cd9a 279 id[0] = lay; id[1] = lad; id[2] = det;
280 if(rot[9]!=0.0) { // null rotation
023ae34b 281 r[0][0] = rot[0]; r[0][1] = rot[1]; r[0][2] = rot[2];
282 r[1][0] = rot[3]; r[1][1] = rot[4]; r[1][2] = rot[5];
283 r[2][0] = rot[6]; r[2][1] = rot[7]; r[2][2] = rot[8];
8253cd9a 284 } // end if
023ae34b 285 fGm.AddAt(new AliITSgeomMatrix(idet,id,r,tran),mod);
8253cd9a 286}
85f1e34a 287//______________________________________________________________________
58005f18 288AliITSgeom::~AliITSgeom(){
85f1e34a 289 // The destructor for the AliITSgeom class. If the arrays fNlad,
290 // fNdet, or fGm have had memory allocated to them, there pointer values
291 // are non zero, then this memory space is freed and they are set
292 // to zero. In addition, fNlayers is set to zero. The destruction of
293 // TObjArray fShape is, by default, handled by the TObjArray destructor.
023ae34b 294 // Inputs:
295 // none.
296 // Outputs:
297 // none.
298 // Return:
299 // none.
85f1e34a 300
023ae34b 301 return;
58005f18 302}
269f57ed 303//______________________________________________________________________
304void AliITSgeom::ReadNewFile(const char *filename){
023ae34b 305 // It is generally preferred to define the geometry in AliITSgeom
85f1e34a 306 // directly from the GEANT geometry, see AliITSvPPRasymm.cxx for
307 // and example. Under some circumstances this may not be possible.
308 // This function will read in a formatted file for all of the
309 // information needed to define the geometry in AliITSgeom.
310 // Unlike the older file format, this file may contain comments
311 // and the order of the data does not need to be completely
312 // respected. A file can be created using the function WriteNewFile
313 // defined below.
023ae34b 314 // Inputs:
315 // const char *filename The file name of the file to be read in.
316 // Outputs:
317 // none
318 // Return:
319 // none.
8253cd9a 320 Int_t ncmd=9;
5c9c741e 321 const char *cmda[]={"Version" ,"fTrans" ,"fNmodules",
322 "fNlayers" ,"fNladers","fNdetectors",
323 "fNDetectorTypes","fShape" ,"Matrix"};
8253cd9a 324 Int_t i,j,lNdetTypes,ldet;
325 char cmd[20],c;
164da35c 326 AliITSgeomMatrix *m=0;
327 ifstream *fp=0;
328 char *filtmp=0;
023ae34b 329 Bool_t arrayGm = kFALSE, arrayShape = kFALSE;
8253cd9a 330
331 filtmp = gSystem->ExpandPathName(filename);
f77f13c8 332 AliInfo(Form("Reading New .det file %s",filtmp));
8253cd9a 333 fp = new ifstream(filtmp,ios::in); // open file to write
334 while(fp->get(c)!=NULL){ // for ever loop
023ae34b 335 if(c==' ') continue; // remove blanks
336 if(c=='\n') continue;
337 if(c=='#' || c=='!') {while(fp->get(c)) if(c=='\n') break; continue;}
338 if(c=='/'){
339 fp->get(c);{
340 if(c=='/') {while(fp->get(c)) if(c=='\n') break; continue;}
341 if(c=='*'){
342 NotYet:
343 while(fp->get(c)) if(c=='*') break;
344 fp->get(c);{
345 if(c=='/') continue;
346 goto NotYet;
347 } //
348 } // end if c=='*'
349 } // end if second /
350 } // end if first /
351 fp->putback(c);
352 *fp >> cmd;
353 for(i=0;i<ncmd;i++) if(strcmp(cmd,cmda[i])==0) break;
354 switch (i){
355 case 0: // Version
5cf690c1 356 while(isspace(fp->peek())) fp->get(); // skip spaces
357 if(isdigit(fp->peek())){ // new TString
358 *fp >> j;
359 fVersion.Resize(j);
360 for(j=0;j<fVersion.Length();j++) *fp >> fVersion[j];
361 }else{
362 fVersion.Resize(20);
363 for(j=0;isprint(fp->peek())&&j<20;j++) *fp >> fVersion[j];
364 } // end if isdigit
023ae34b 365 break;
366 case 1: // fTrans
367 *fp >> fTrans;
368 break;
369 case 2: // fNModules
370 *fp >> fNmodules;
371 fGm.Clear();
372 fGm.Expand(fNmodules);
373 fGm.SetOwner(kTRUE);
374 arrayGm = kTRUE;
375 break;
376 case 3: // fNlayers
377 *fp >> fNlayers;
378 fNlad.Set(fNlayers);
379 fNdet.Set(fNlayers);
380 break;
381 case 4: // fNladers
382 for(j=0;j<fNlayers;j++) *fp >> fNlad[j];
383 break;
384 case 5: // fNdetectors
385 for(j=0;j<fNlayers;j++) *fp >> fNdet[j];
386 break;
387 case 6: // fNDetectorTypes
388 *fp >> lNdetTypes;
389 fShape.Clear();
390 fShape.Expand(lNdetTypes);
391 fShape.SetOwner(kTRUE);
392 arrayShape = kTRUE;
393 break;
394 case 7: // fShape
395 *fp >> ldet;
396 if(!arrayShape) fShape.Expand(5);
397 fShape.SetOwner(kTRUE);
398 switch (ldet){
399 case kSPD :{
400 AliITSgeomSPD *spd = new AliITSgeomSPD();
401 *fp >> *spd;
402 ReSetShape(ldet,spd);
403 } break;
404 case kSDD : case kSDDp:{
405 AliITSgeomSDD *sdd = new AliITSgeomSDD();
406 *fp >> *sdd;
407 ReSetShape(ldet,sdd);
408 }break;
409 case kSSD : case kSSDp :{
410 AliITSgeomSSD *ssd = new AliITSgeomSSD();
411 *fp >> *ssd;
412 ReSetShape(ldet,ssd);
413 }break;
414 default:{
415 AliError(Form("Unknown fShape type number=%d c=%c",ldet,c));
416 while(fp->get(c)) if(c=='\n') break; // skip to end of line.
417 }break;
418 } // end switch
419 break;
420 case 8: // Matrix
421 *fp >> ldet;
422 if(!arrayGm){
423 fGm.Clear();
424 fGm.Expand(2270);
425 arrayGm = kTRUE;
426 } // end if
427 if(ldet<0||ldet>=fGm.GetSize()){
a5a317a9 428 Error("ReadNewFile","ldet<0||ldet>=fGm.GetSize()=%d , ldet=%d",
429 fGm.GetSize(),ldet);
023ae34b 430 return;
8253cd9a 431 } // end if
023ae34b 432 delete fGm.At(ldet);
433 fGm.AddAt((TObject*)new AliITSgeomMatrix(),ldet);
434 m = (AliITSgeomMatrix*) fGm.At(ldet);
435 *fp >> *m;
436 m = 0;
437 break;
438 default:
e7fbc766 439 AliError(Form("Data line i=%d ",i));
023ae34b 440 while(fp->get(c)) if(c=='\n') break; // skip this line
441 break;
442 } // end switch i
8253cd9a 443 } // end while
444 delete fp;
445
446 return;
447}
448//______________________________________________________________________
5cf690c1 449void AliITSgeom::WriteNewFile(const char *filename)const{
023ae34b 450 // Writes AliITSgeom, AliITSgeomMatrix, and the defined
451 // AliITSgeomS*D classes to a file in a format that
452 // is more readable and commendable.
453 // Inputs:
454 // const char *filename The file name of the file to be write to.
455 // Outputs:
456 // none
457 // Return:
458 // none
8253cd9a 459 ofstream *fp;
460 Int_t i;
461 char *filtmp;
462
463 filtmp = gSystem->ExpandPathName(filename);
464 fp = new ofstream(filtmp,ios::out); // open file to write
465 *fp << "//Comment lines begin with two //, one #, or one !" << endl;
466 *fp << "#Blank lines are skipped including /* and */ sections." << endl;
467 *fp << "!and, in principle the order of the lines is not important" <<endl;
468 *fp << "/* In AliITSgeom.h are defined an enumerated type called" << endl;
469 *fp << " AliITSDetectors These are kSPD=" << (Int_t) kSPD ;
470 *fp << ", kSDD=" << (Int_t) kSDD << ", kSSD=" << (Int_t) kSSD;
5c9c741e 471 *fp << ", kSSDp=" << (Int_t) kSSDp << ", and kSDDp=" << (Int_t) kSDDp;
472 *fp << "*/" << endl;
012f0f4c 473 *fp << "Version "<< fVersion.Length()<<" " << fVersion.Data() << endl;//
474 // This should be consistent
475 // with the geometry version.
8253cd9a 476 *fp << "fTrans " << fTrans << endl;
477 *fp << "fNmodules " << fNmodules << endl;
478 *fp << "fNlayers " << fNlayers << endl;
479 *fp << "fNladers ";
480 for(i=0;i<fNlayers;i++) *fp << fNlad[i] << " ";
481 *fp << endl;
482 *fp << "fNdetectors ";
483 for(i=0;i<fNlayers;i++) *fp << fNdet[i] << " ";
484 *fp << endl;
023ae34b 485 *fp << "fNDetectorTypes " << fShape.GetEntriesFast() << endl;
486 for(i=0;i<fShape.GetEntriesFast();i++){
8253cd9a 487 if(!IsShapeDefined(i)) continue; // only print out used shapes.
488 switch (i){
489 case kSPD :
490 *fp << "fShape " << (Int_t) kSPD << " ";
023ae34b 491 *fp << *((AliITSgeomSPD*)(fShape.At(i)));
8253cd9a 492 break;
493 case kSDD :
494 *fp << "fShape " << (Int_t) kSDD << " ";
023ae34b 495 *fp << *((AliITSgeomSDD*)(fShape.At(i)));
8253cd9a 496 break;
497 case kSSD : case kSSDp :
498 *fp << "fShape " << i << " ";
023ae34b 499 *fp << *((AliITSgeomSSD*)(fShape.At(i)));
8253cd9a 500 break;
501 default:
502 Error("AliITSgeom::WriteNewFile","Unknown Shape value");
503 } // end switch (i)
504 } // end for i
505 for(i=0;i<fNmodules;i++){
506 *fp << "Matrix " << i << " ";
507 *fp << *GetGeomMatrix(i);
508 } // end for i
509 *fp << "//End of File" << endl;;
510
511 delete fp;
269f57ed 512 return;
513}
85f1e34a 514//______________________________________________________________________
023ae34b 515AliITSgeom::AliITSgeom(const char *filename):
516TObject(),
517fVersion("test"),// Transformation version.
518fTrans(0), // Flag to keep track of which transformation
519fNmodules(0), // The total number of modules
520fNlayers(0), // The number of layers.
521fNlad(), // TArrayI of the number of ladders/layer(layer)
522fNdet(), // TArrayI of the number of detector/ladder(layer)
523fGm(0,0), // TObjArray Structure of translation. and rotation.
524fShape(0,0) // TObjArray of detector geom.
525{
85f1e34a 526 // The constructor for the AliITSgeom class. All of the data to fill
527 // this structure is read in from the file given my the input filename.
023ae34b 528 // Inputs:
529 // const char *filename The file name of the file to be read in.
530 // Outputs:
531 // none
532 // Return:
533 // An AliITSgeom class initialized from a file.
85f1e34a 534 FILE *pf=0;
535 Int_t i,lm=0,id[3];
536 Int_t l,a,d;
537 Float_t x,y,z,o,p,q,r,s,t;
538 Double_t rot6[6],tran[3];
539 char buf[200],*buff=0; // input character buffer;
023ae34b 540 char *filtmp;
58005f18 541
85f1e34a 542 filtmp = gSystem->ExpandPathName(filename);
023ae34b 543 Info("AliITSgeom","reading old .det file %s",filtmp);
544 fVersion="GEANT5";
85f1e34a 545 pf = fopen(filtmp,"r");
546
547 fNlayers = 6; // set default number of ladders
023ae34b 548 TryAgain:
549 fNlad.Set(fNlayers);
550 fNdet.Set(fNlayers);
85f1e34a 551 fNmodules = 0;
552 // find the number of ladders and detectors in this geometry.
553 for(i=0;i<fNlayers;i++){fNlad[i]=fNdet[i]=0;} // zero out arrays
554 while(fgets(buf,200,pf)!=NULL){ // for ever loop
023ae34b 555 for(i=0;i<200;i++)if(buf[i]!=' '){ // remove blank spaces.
556 buff = &(buf[i]);
557 break;
558 } // end for i
559 // remove blank lines and comments.
560 if(buff[0]=='\n'||buff[0]=='#'||buff[0]=='!'||
561 (buff[0]=='/'&&buff[1]=='/')) continue;
562 if(isalpha(buff[0])) { // must be the new file formated file.
269f57ed 563 fclose(pf);
269f57ed 564 ReadNewFile(filename);
565 return;
023ae34b 566 } // end if isalpha(buff[0])
567 sscanf(buff,"%d %d %d %f %f %f %f %f %f %f %f %f",
568 &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t);
569 if(l>lm) lm = l;
570 if(l<1 || l>fNlayers) {
012f0f4c 571 printf("error in file %s layer=%d min. is 1 max is %d"
572 " Trying new format\n",filename,l,fNlayers);
5cf690c1 573 fclose(pf);
574 ReadNewFile(filename);
575 return;
576 //continue;
023ae34b 577 }// end if l
578 fNmodules++;
579 if(l<=fNlayers&&fNlad[l-1]<a) fNlad[l-1] = a;
580 if(l<=fNlayers&&fNdet[l-1]<d) fNdet[l-1] = d;
85f1e34a 581 } // end while ever loop
582 if(lm>fNlayers){
023ae34b 583 fNlayers = lm;
584 goto TryAgain;
85f1e34a 585 } // end if lm>fNlayers
586 // counted the number of ladders and detectors now allocate space.
023ae34b 587 fGm.Expand(fNmodules);
588 fGm.SetOwner(kTRUE);
589 fShape.SetOwner(kTRUE);
58005f18 590
85f1e34a 591 // Set up Shapes for a default configuration of 6 layers.
592 fTrans = 0; // standard GEANT global/local coordinate system.
593 // prepare to read in transforms
594 lm = 0; // reuse lm as counter of modules.
595 rewind(pf); // start over reading file
596 while(fgets(buf,200,pf)!=NULL){ // for ever loop
023ae34b 597 for(i=0;i<200;i++)if(buf[i]!=' '){ // remove blank spaces.
598 buff = &(buf[i]);
599 break;
600 } // end for i
601 // remove blank lines and comments.
602 if(buff[0]=='\n'||buff[0]=='#'||buff[0]=='!'||
603 (buff[0]=='/'&&buff[1]=='/')) continue;
604 x = y = z = o = p = q = r = s = t = 0.0;
605 sscanf(buff,"%d %d %d %f %f %f %f %f %f %f %f %f",
606 &l,&a,&d,&x,&y,&z,&o,&p,&q,&r,&s,&t);
607 if(l<1 || l>fNlayers) {
012f0f4c 608 Warning("AliITSgeom","error in file %s layer=%d"
609 " min. is 1 max is %d",filename,l,fNlayers);
023ae34b 610 continue;
611 }// end if l
612 id[0] = l;id[1] = a;id[2] = d;
613 tran[0] = tran[1] = tran[2] = 0.0;
614 tran[0] = (Double_t)x;tran[1] = (Double_t)y;tran[2] = (Double_t)z;
615 rot6[0] = rot6[1] = rot6[2] = rot6[3] = rot6[4] = rot6[5] =0.0;
616 rot6[0] = (Double_t)o;rot6[1] = (Double_t)p;rot6[2] = (Double_t)q;
617 rot6[3] = (Double_t)r;rot6[4] = (Double_t)s;rot6[5] = (Double_t)t;
618 if(lm<0||lm>=fGm.GetSize()){
a5a317a9 619 Error("AliITSgeom(filename)","lm<0||lm>=fGm.GetSize()=%d , lm=%d",
620 fGm.GetSize(),lm);
023ae34b 621 return;
622 } // end if
623 switch (l){
624 case 1: case 2: // layer 1 or2 SPD
625 fGm.AddAt(new AliITSgeomMatrix(rot6,kSPD,id,tran),lm++);
626 break;
627 case 3: case 4: // layer 3 or 4 SDD
628 fGm.AddAt(new AliITSgeomMatrix(rot6,kSDD,id,tran),lm++);
629 break;
630 case 5: case 6: // layer 5 or 6 SSD
631 fGm.AddAt(new AliITSgeomMatrix(rot6,kSSD,id,tran),lm++);
632 break;
633 } // end switch
85f1e34a 634 } // end while ever loop
635 fclose(pf);
58005f18 636}
85f1e34a 637//______________________________________________________________________
012f0f4c 638AliITSgeom::AliITSgeom(const AliITSgeom &source) :
639TObject(source),
640fVersion(source.fVersion), // Transformation version.
641fTrans(source.fTrans), // Flag to keep track of which transformation
642fNmodules(source.fNmodules),// The total number of modules
643fNlayers(source.fNlayers), // The number of layers.
644fNlad(source.fNlad), // Array of the number of ladders/layer(layer)
645fNdet(source.fNdet), // Array of the number of detector/ladder(layer)
646fGm(source.fGm.GetSize(),source.fGm.LowerBound()),// Structure of
647 // translation and rotation.
648fShape(source.fShape.GetSize(),source.fShape.LowerBound())// Array of shapes
649 // and detector information.
e56160b8 650{
85f1e34a 651 // The copy constructor for the AliITSgeom class. It calls the
652 // = operator function. See the = operator function for more details.
023ae34b 653 // Inputs:
654 // AliITSgeom &source The AliITSgeom class with which to make this
655 // a copy of.
656 // Outputs:
657 // none.
658 // Return:
659 // none.
012f0f4c 660 Int_t i,n;
593e9459 661
012f0f4c 662 n = source.fGm.GetLast()+1;
663 for(i=source.fGm.LowerBound();i<n;i++){
664 fGm.AddAt(new AliITSgeomMatrix(*((AliITSgeomMatrix*)(
665 source.fGm.At(i)))),i);
666 } // end for i
667 fGm.SetOwner(kTRUE);
668 n = source.fShape.GetLast()+1;
669 for(i=source.fShape.LowerBound();i<n;i++){
670 switch ((AliITSDetector)i){
671 case kSPD :{
672 fShape.AddAt(new AliITSgeomSPD(*((AliITSgeomSPD*)(
673 source.fShape.At(i)))),i);
674 } break;
675 case kSDD : case kSDDp:{
676 fShape.AddAt(new AliITSgeomSDD(*((AliITSgeomSDD*)(
677 source.fShape.At(i)))),i);
678 }break;
679 case kSSD : case kSSDp :{
680 fShape.AddAt(new AliITSgeomSSD(*((AliITSgeomSSD*)(
681 source.fShape.At(i)))),i);
682 }break;
683 default:{
684 AliError(Form("Unknown fShape type number=%d",i));
685 }break;
686 } // end switch
687 } // end for i
688 fShape.SetOwner(kTRUE);
689 return;
58005f18 690}
85f1e34a 691//______________________________________________________________________
7f6ab649 692AliITSgeom& AliITSgeom::operator=(const AliITSgeom &source){
85f1e34a 693 // The = operator function for the AliITSgeom class. It makes an
694 // independent copy of the class in such a way that any changes made
695 // to the copied class will not affect the source class in any way.
696 // This is required for many ITS alignment studies where the copied
697 // class is then modified by introducing some misalignment.
023ae34b 698 // Inputs:
699 // AliITSgeom &source The AliITSgeom class with which to make this
700 // a copy of.
701 // Outputs:
702 // none.
703 // Return:
704 // *this The a new copy of source.
705 Int_t i;
58005f18 706
023ae34b 707 if(this == &source) return *this; // don't assign to ones self.
58005f18 708
023ae34b 709 // if there is an old structure allocated delete it first.
710 this->fGm.Clear();
711 this->fShape.Clear();
085bb6ed 712
023ae34b 713 this->fVersion = source.fVersion;
714 this->fTrans = source.fTrans;
715 this->fNmodules = source.fNmodules;
012f0f4c 716 this->fNlayers = source.fNlayers;
717 this->fNlad = source.fNlad;
718 this->fNdet = source.fNdet;
023ae34b 719 this->fGm.Expand(this->fNmodules);
012f0f4c 720 for(i=source.fGm.LowerBound();i<source.fGm.GetLast();i++){
721 fGm.AddAt(new AliITSgeomMatrix(*((AliITSgeomMatrix*)(
722 source.fGm.At(i)))),i);
723 } // end for i
724 fGm.SetOwner(kTRUE);
725 this->fShape.Expand(source.fShape.GetEntriesFast());
726 for(i=source.fShape.LowerBound();i<source.fShape.GetLast();i++){
727 switch ((AliITSDetector)i){
728 case kSPD :{
729 fShape.AddAt(new AliITSgeomSPD(*((AliITSgeomSPD*)(
730 source.fShape.At(i)))),i);
731 } break;
732 case kSDD : case kSDDp:{
733 fShape.AddAt(new AliITSgeomSDD(*((AliITSgeomSDD*)(
734 source.fShape.At(i)))),i);
735 }break;
736 case kSSD : case kSSDp :{
737 fShape.AddAt(new AliITSgeomSSD(*((AliITSgeomSSD*)(
738 source.fShape.At(i)))),i);
739 }break;
740 default:{
741 AliError(Form("Unknown fShape type number=%d",i));
742 }break;
743 } // end switch
744 } // end for i
745 fShape.SetOwner(kTRUE);
023ae34b 746 return *this;
85f1e34a 747}
748//______________________________________________________________________
5cf690c1 749Int_t AliITSgeom::GetModuleIndex(Int_t lay,Int_t lad,Int_t det)const{
85f1e34a 750 // This routine computes the module index number from the layer,
751 // ladder, and detector numbers. The number of ladders and detectors
752 // per layer is determined when this geometry package is constructed,
753 // see AliITSgeom(const char *filename) for specifics.
023ae34b 754 // Inputs:
755 // Int_t lay The layer number. Starting from 1.
756 // Int_t lad The ladder number. Starting from 1.
757 // Int_t det The detector number. Starting from 1.
758 // Outputs:
759 // none.
760 // Return:
761 // the module index number, starting from zero.
269f57ed 762 Int_t i,j,k,id[3];
58005f18 763
764 i = fNdet[lay-1] * (lad-1) + det - 1;
765 j = 0;
766 for(k=0;k<lay-1;k++) j += fNdet[k]*fNlad[k];
269f57ed 767 i = i+j;
7e932df0 768 if(i>=fNmodules) return -1;
8253cd9a 769 GetGeomMatrix(i)->GetIndex(id);
269f57ed 770 if(id[0]==lay&&id[1]==lad&&id[2]==det) return i;
771 // Array of modules fGm is not in expected order. Search for this index
772 for(i=0;i<fNmodules;i++){
023ae34b 773 GetGeomMatrix(i)->GetIndex(id);
774 if(id[0]==lay&&id[1]==lad&&id[2]==det) return i;
269f57ed 775 } // end for i
776 // This layer ladder and detector combination does not exist return -1.
777 return -1;
58005f18 778}
269f57ed 779//______________________________________________________________________
012f0f4c 780void AliITSgeom::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det)
781const{
85f1e34a 782 // This routine computes the layer, ladder and detector number
783 // given the module index number. The number of ladders and detectors
784 // per layer is determined when this geometry package is constructed,
785 // see AliITSgeom(const char *filename) for specifics.
023ae34b 786 // Inputs:
787 // Int_t index The module index number, starting from zero.
788 // Outputs:
789 // Int_t lay The layer number. Starting from 1.
790 // Int_t lad The ladder number. Starting from 1.
791 // Int_t det The detector number. Starting from 1.
792 // Return:
793 // none.
269f57ed 794 Int_t id[3];
88cb7938 795 AliITSgeomMatrix *g = GetGeomMatrix(index);
269f57ed 796
023ae34b 797 if (g == 0x0){
798 Error("GetModuleId","Can not get GeoMatrix for index = %d",index);
799 lay = -1; lad = -1; det = -1;
800 }else{
801 g->GetIndex(id);
802 lay = id[0]; lad = id[1]; det = id[2];
803 }// End if
804 return;
269f57ed 805 // The old way kept for posterity.
806/*
807 Int_t i,j,k;
58005f18 808 j = 0;
809 for(k=0;k<fNlayers;k++){
810 j += fNdet[k]*fNlad[k];
aa6248e2 811 if(j>index)break;
58005f18 812 } // end for k
813 lay = k+1;
814 i = index -j + fNdet[k]*fNlad[k];
815 j = 0;
816 for(k=0;k<fNlad[lay-1];k++){
aa6248e2 817 j += fNdet[lay-1];
818 if(j>i)break;
58005f18 819 } // end for k
820 lad = k+1;
821 det = 1+i-fNdet[lay-1]*k;
822 return;
269f57ed 823*/
58005f18 824}
85f1e34a 825//______________________________________________________________________
5cf690c1 826Int_t AliITSgeom::GetNDetTypes(Int_t &max)const{
023ae34b 827 // Finds and returns the number of detector types used and the
828 // maximum detector type value. Only counts id >=0 (no undefined
829 // values. See AliITSgeom.h for list of AliITSDetecor enumerated types.
830 // Inputs:
831 // none.
832 // Outputs:
833 // The maximum detector type used
834 // Return:
835 // The number of detector types used
836 Int_t i,*n,id;
837
838 max = -1;
839 for(i=0;i<GetIndexMax();i++){
840 id = GetModuleType(i);
841 if(id>max) max=id;
842 } // end for i
843 n = new Int_t[max+1];
844 for(i=0;i<max;i++) n[i] = 0;
845 for(i=0;i<GetIndexMax();i++){
846 id = GetModuleType(i);
847 if(id>-1)n[id]++; // note id=-1 => undefined.
848 } // end for i
849 id = 0;
850 for(i=0;i<max;i++) if(n[i]!=0) id++;
851 delete[] n;
852 return id+1;
853}
854//______________________________________________________________________
5cf690c1 855Int_t AliITSgeom::GetNDetTypes(TArrayI &maxs,AliITSDetector *types)const{
023ae34b 856 // Finds and returns the number of detector types used and the
857 // number of each detector type. Only counts id >=0 (no undefined
858 // values. See AliITSgeom.h for list of AliITSDetecor enumerated types.
859 // Inputs:
860 // none.
861 // Outputs:
862 // The maximum detector type used
863 // Return:
864 // The number of detector types used
865 Int_t i,j,*n,id,max;
866
867 max = -1;
868 for(i=0;i<GetIndexMax();i++){
869 id = GetModuleType(i);
870 if(id>max) max=id;
871 } // end for i
872 n = new Int_t[max+1];
873 for(i=0;i<max;i++) n[i] = 0;
874 for(i=0;i<GetIndexMax();i++){
875 id = GetModuleType(i);
876 if(id>-1)n[id]++; // note id=-1 => undefined.
877 } // end for i
878 id = 0;
879 for(i=0;i<=max;i++) if(n[i]!=0) id++;
880 maxs.Set(id);
881 j = 0;
882 for(i=0;i<=max;i++) if(n[i]!=0){
883 maxs[j] = n[i];
884 types[j++] = (AliITSDetector) i;
885 } // end for i/end if
886 delete[] n;
887 return id;
888}
889//______________________________________________________________________
5cf690c1 890Int_t AliITSgeom::GetStartDet(Int_t dtype)const{
85f1e34a 891 // returns the starting module index value for a give type of detector id.
892 // This assumes that the detector types are different on different layers
893 // and that they are not mixed up.
023ae34b 894 // Inputs:
012f0f4c 895 // Int_t dtype A detector type number. 0 for SPD, 1 for SDD,
896 // and 2 for SSD.
023ae34b 897 // Outputs:
898 // none.
899 // Return:
900 // the module index for the first occurrence of that detector type.
85f1e34a 901
902 switch(dtype){
903 case 0:
023ae34b 904 return GetModuleIndex(1,1,1);
905 break;
85f1e34a 906 case 1:
023ae34b 907 return GetModuleIndex(3,1,1);
908 break;
85f1e34a 909 case 2:
023ae34b 910 return GetModuleIndex(5,1,1);
911 break;
85f1e34a 912 default:
023ae34b 913 Warning("GetStartDet","undefined detector type %d",dtype);
914 return 0;
85f1e34a 915 } // end switch
916
917 Warning("GetStartDet","undefined detector type %d",dtype);
918 return 0;
085bb6ed 919}
85f1e34a 920//______________________________________________________________________
5cf690c1 921Int_t AliITSgeom::GetLastDet(Int_t dtype)const{
85f1e34a 922 // returns the last module index value for a give type of detector id.
923 // This assumes that the detector types are different on different layers
924 // and that they are not mixed up.
023ae34b 925 // Inputs:
012f0f4c 926 // Int_t dtype A detector type number. 0 for SPD, 1 for SDD,
927 // and 2 for SSD.
023ae34b 928 // Outputs:
929 // Return:
930 // the module index for the last occurrence of that detector type.
85f1e34a 931
a1e4be5b 932 switch((AliITSDetector)dtype){
933 case kSPD:
934 return GetModuleIndex(3,1,1)-1;
023ae34b 935 break;
a1e4be5b 936 case kSDD:
937 return GetModuleIndex(5,1,1)-1;
023ae34b 938 break;
a1e4be5b 939 case kSSD:
e8d3012e 940 return GetIndexMax()-1;
023ae34b 941 break;
a1e4be5b 942 case kSSDp: case kSDDp: case kND:
85f1e34a 943 default:
023ae34b 944 Warning("GetLastDet","undefined detector type %d",dtype);
945 return 0;
85f1e34a 946 } // end switch
947
948 Warning("GetLastDet","undefined detector type %d",dtype);
949 return 0;
085bb6ed 950}
85f1e34a 951//______________________________________________________________________
012f0f4c 952Bool_t AliITSgeom::IsInside(Int_t module,Double_t point[3])const{
953 // Determins if the give point is inside of the module as defined
954 // by this set of coordinate transforms.
955 // Inputs:
956 // Int_t module The module to be checked
957 // Double_t point[3] A 3 vector global point
958 // Outputs:
959 // none.
960 // Return:
961 // kTRUE if point is inside of module, kFALSE otherwise.
962 Double_t l[3],dx,dy,dz;
963 AliITSDetector idet = (AliITSDetector)(this->GetGeomMatrix(module)->
964 GetDetectorIndex());
965
966 this->GtoL(module,point,l);
967 switch(idet){
968 case kSPD:{
969 AliITSgeomSPD *spd = (AliITSgeomSPD*)(fShape.At((Int_t)idet));
970 dx = spd->GetDx();
971 dy = spd->GetDy();
972 dz = spd->GetDz();}
973 break;
974 case kSDD: case kSDDp:{
975 AliITSgeomSDD *sdd = (AliITSgeomSDD*)(fShape.At((Int_t)idet));
976 dx = sdd->GetDx();
977 dy = sdd->GetDy();
978 dz = sdd->GetDz();}
979 break;
980 case kSSD: case kSSDp:{
981 AliITSgeomSSD *ssd = (AliITSgeomSSD*)(fShape.At((Int_t)idet));
982 dx = ssd->GetDx();
983 dy = ssd->GetDy();
984 dz = ssd->GetDz();}
985 break;
986 default: // Detector not defined.
987 return kFALSE;
988 break;
989 }// end switch
990 if(TMath::Abs(l[0])>dx) return kFALSE;
991 if(TMath::Abs(l[2])>dz) return kFALSE;
992 if(TMath::Abs(l[1])>dy) return kFALSE;
993 return kTRUE;
994}
995//______________________________________________________________________
5cf690c1 996void AliITSgeom::PrintComparison(FILE *fp,AliITSgeom *other)const{
85f1e34a 997 // This function was primarily created for diagnostic reasons. It
998 // print to a file pointed to by the file pointer fp the difference
023ae34b 999 // between two AliITSgeom classes. The format of the file is basically,
85f1e34a 1000 // define d? to be the difference between the same element of the two
1001 // classes. For example dfrx = this->GetGeomMatrix(i)->frx
1002 // - other->GetGeomMatrix(i)->frx.
1003 // if(at least one of dfx0, dfy0, dfz0,dfrx,dfry,dfrz are non zero) then
1004 // print layer ladder detector dfx0 dfy0 dfz0 dfrx dfry dfrz
1005 // if(at least one of the 9 elements of dfr[] are non zero) then print
1006 // layer ladder detector dfr[0] dfr[1] dfr[2]
1007 // dfr[3] dfr[4] dfr[5]
1008 // dfr[6] dfr[7] dfr[8]
1009 // Only non zero values are printed to save space. The differences are
1010 // typical written to a file because there are usually a lot of numbers
1011 // printed out and it is usually easier to read them in some nice editor
1012 // rather than zooming quickly past you on a screen. fprintf is used to
1013 // do the printing. The fShapeIndex difference is not printed at this time.
023ae34b 1014 // Inputs:
012f0f4c 1015 // FILE *fp A file pointer to an opened file for writing
1016 // in which the results of the comparison will
1017 // be written.
023ae34b 1018 // AliITSgeom *other The other AliITSgeom class to which this one is
1019 // being compared.
1020 // Outputs:
1021 // none.
1022 // Return:
1023 // none.
85f1e34a 1024 Int_t i,j,idt[3],ido[3];
1025 Double_t tt[3],to[3]; // translation
1026 Double_t rt[3],ro[3]; // phi in radians
023ae34b 1027 Double_t mt[3][3],mo[3][3]; // matrices
85f1e34a 1028 AliITSgeomMatrix *gt,*go;
1029 Bool_t t;
1030
1031 for(i=0;i<this->fNmodules;i++){
023ae34b 1032 gt = this->GetGeomMatrix(i);
1033 go = other->GetGeomMatrix(i);
1034 gt->GetIndex(idt);
1035 go->GetIndex(ido);
1036 t = kFALSE;
1037 for(i=0;i<3;i++) t = t&&idt[i]!=ido[i];
1038 if(t) fprintf(fp,"%4.4d %1.1d %2.2d %2.2d %1.1d %2.2d %2.2d\n",i,
1039 idt[0],idt[1],idt[2],ido[0],ido[1],ido[2]);
1040 gt->GetTranslation(tt);
1041 go->GetTranslation(to);
1042 gt->GetAngles(rt);
1043 go->GetAngles(ro);
1044 t = kFALSE;
1045 for(i=0;i<3;i++) t = t&&tt[i]!=to[i];
1046 if(t) fprintf(fp,"%1.1d %2.2d %2.2d dTrans=%f %f %f drot=%f %f %f\n",
1047 idt[0],idt[1],idt[2],
1048 tt[0]-to[0],tt[1]-to[1],tt[2]-to[2],
1049 rt[0]-ro[0],rt[1]-ro[1],rt[2]-ro[2]);
1050 t = kFALSE;
1051 gt->GetMatrix(mt);
1052 go->GetMatrix(mo);
1053 for(i=0;i<3;i++)for(j=0;j<3;j++) t = mt[i][j] != mo[i][j];
1054 if(t){
1055 fprintf(fp,"%1.1d %2.2d %2.2d dfr= %e %e %e\n",
1056 idt[0],idt[1],idt[2],
1057 mt[0][0]-mo[0][0],mt[0][1]-mo[0][1],mt[0][2]-mo[0][2]);
1058 fprintf(fp," dfr= %e %e %e\n",
1059 mt[1][0]-mo[1][0],mt[1][1]-mo[1][1],mt[1][2]-mo[1][2]);
1060 fprintf(fp," dfr= %e %e %e\n",
1061 mt[2][0]-mo[2][0],mt[2][1]-mo[2][1],mt[2][2]-mo[2][2]);
1062 } // end if t
85f1e34a 1063 } // end for i
1064 return;
593e9459 1065}
85f1e34a 1066//______________________________________________________________________
5cf690c1 1067void AliITSgeom::PrintData(FILE *fp,Int_t lay,Int_t lad,Int_t det)const{
85f1e34a 1068 // This function prints out the coordinate transformations for
1069 // the particular detector defined by layer, ladder, and detector
1070 // to the file pointed to by the File pointer fp. fprintf statements
1071 // are used to print out the numbers. The format is
1072 // layer ladder detector Trans= fx0 fy0 fz0 rot= frx fry frz
1073 // Shape=fShapeIndex
1074 // dfr= fr[0] fr[1] fr[2]
1075 // dfr= fr[3] fr[4] fr[5]
1076 // dfr= fr[6] fr[7] fr[8]
1077 // By indicating which detector, some control over the information
1078 // is given to the user. The output it written to the file pointed
1079 // to by the file pointer fp. This can be set to stdout if you want.
023ae34b 1080 // Inputs:
012f0f4c 1081 // FILE *fp A file pointer to an opened file for
1082 // writing in which the results of the
1083 // comparison will be written.
023ae34b 1084 // Int_t lay The layer number. Starting from 1.
1085 // Int_t lad The ladder number. Starting from 1.
1086 // Int_t det The detector number. Starting from 1.
1087 // Outputs:
1088 // none
1089 // Return:
1090 // none.
85f1e34a 1091 AliITSgeomMatrix *gt;
1092 Double_t t[3],r[3],m[3][3];
1093
1094 gt = this->GetGeomMatrix(GetModuleIndex(lay,lad,det));
1095 gt->GetTranslation(t);
1096 gt->GetAngles(r);
1097 fprintf(fp,"%1.1d %2.2d %2.2d Trans=%f %f %f rot=%f %f %f Shape=%d\n",
023ae34b 1098 lay,lad,det,t[0],t[1],t[2],r[0],r[1],r[2],
1099 gt->GetDetectorIndex());
85f1e34a 1100 gt->GetMatrix(m);
1101 fprintf(fp," dfr= %e %e %e\n",m[0][0],m[0][1],m[0][2]);
1102 fprintf(fp," dfr= %e %e %e\n",m[1][0],m[1][1],m[1][2]);
1103 fprintf(fp," dfr= %e %e %e\n",m[2][0],m[2][1],m[2][2]);
1104 return;
593e9459 1105}
85f1e34a 1106//______________________________________________________________________
012f0f4c 1107void AliITSgeom::PrintGeom(ostream *wb)const{
85f1e34a 1108 // Stream out an object of class AliITSgeom to standard output.
023ae34b 1109 // Intputs:
012f0f4c 1110 // ofstream *wb The output streaming buffer.
023ae34b 1111 // Outputs:
1112 // none.
1113 // Return:
012f0f4c 1114 // none.
023ae34b 1115 Int_t i,nshapes;
593e9459 1116
012f0f4c 1117 wb->setf(ios::scientific);
1118 *wb << fTrans << " ";
1119 *wb << fNmodules << " ";
1120 *wb << fNlayers << " ";
1121 for(i=0;i<fNlayers;i++) *wb << fNlad[i] << " ";
1122 for(i=0;i<fNlayers;i++) *wb << fNdet[i] << "\n";
269f57ed 1123 for(i=0;i<fNmodules;i++) {
012f0f4c 1124 *wb <<setprecision(16) << *(GetGeomMatrix(i)) << "\n";
269f57ed 1125 } // end for i
023ae34b 1126 nshapes = fShape.GetEntries();
012f0f4c 1127 *wb << nshapes <<endl;
023ae34b 1128 for(i=0;i<nshapes;i++) if(fShape.At(i)!=0) switch (i){
164da35c 1129 case kSPD:
012f0f4c 1130 *wb << kSPD <<","<< (AliITSgeomSPD*)(fShape.At(kSPD));
023ae34b 1131 break;
164da35c 1132 case kSDD:
012f0f4c 1133 *wb << kSDD <<","<< (AliITSgeomSDD*)(fShape.At(kSDD));
023ae34b 1134 break;
164da35c 1135 case kSSD:
012f0f4c 1136 *wb << kSSD <<","<< (AliITSgeomSSD*)(fShape.At(kSSD));
023ae34b 1137 break;
164da35c 1138 case kSSDp:
012f0f4c 1139 *wb << kSSDp <<","<< (AliITSgeomSSD*)(fShape.At(kSSDp));
023ae34b 1140 break;
164da35c 1141 case kSDDp:
012f0f4c 1142 *wb << kSDDp <<","<< (AliITSgeomSDD*)(fShape.At(kSDDp));
023ae34b 1143 break;
164da35c 1144 } // end for i / switch
012f0f4c 1145 return;
593e9459 1146}
85f1e34a 1147//______________________________________________________________________
012f0f4c 1148void AliITSgeom::ReadGeom(istream *rb){
85f1e34a 1149 // Stream in an object of class AliITSgeom from standard input.
023ae34b 1150 // Intputs:
012f0f4c 1151 // ifstream *rb The input streaming buffer.
023ae34b 1152 // Outputs:
1153 // none.
1154 // Return:
012f0f4c 1155 // none.
164da35c 1156 Int_t i,j;
269f57ed 1157
023ae34b 1158 fGm.Clear();
85f1e34a 1159
012f0f4c 1160 *rb >> fTrans >> fNmodules >> fNlayers;
023ae34b 1161 fNlad.Set(fNlayers);
1162 fNdet.Set(fNlayers);
012f0f4c 1163 for(i=0;i<fNlayers;i++) *rb >> fNlad[i];
1164 for(i=0;i<fNlayers;i++) *rb >> fNdet[i];
023ae34b 1165 fGm.Expand(fNmodules);
1166 fGm.SetOwner(kTRUE);
85f1e34a 1167 for(i=0;i<fNmodules;i++){
023ae34b 1168 if(i<0||i>=fGm.GetSize()){
a5a317a9 1169 Error("ReadGeom","i<0||i>=fGm.GetSize()=%d , i=%d",
1170 fGm.GetSize(),i);
012f0f4c 1171 return;
023ae34b 1172 } // end if
1173 fGm.AddAt(new AliITSgeomMatrix,i);
012f0f4c 1174 *rb >> *(GetGeomMatrix(i));
85f1e34a 1175 } // end for i
012f0f4c 1176 *rb >> i;
023ae34b 1177 fShape.Expand(i);
1178 fShape.SetOwner(kTRUE);
1179 for(i=0;i<fShape.GetEntries();i++) {
012f0f4c 1180 *rb >> j;
023ae34b 1181 switch (j){
1182 case kSPD:{
1183 AliITSgeomSPD *s = new AliITSgeomSPD();
012f0f4c 1184 *rb >> *s;
023ae34b 1185 fShape.AddAt(s,kSPD);}
1186 break;
1187 case kSDD:{
1188 AliITSgeomSDD *s = new AliITSgeomSDD();
012f0f4c 1189 *rb >> *s;
023ae34b 1190 fShape.AddAt(s,kSDD);}
1191 break;
1192 case kSSD:{
1193 AliITSgeomSSD *s = new AliITSgeomSSD();
012f0f4c 1194 *rb >> *s;
023ae34b 1195 fShape.AddAt(s,kSSD);}
1196 break;
1197 case kSSDp:{
1198 AliITSgeomSSD *s = new AliITSgeomSSD();
012f0f4c 1199 *rb >> *s;
023ae34b 1200 fShape.AddAt(s,kSSDp);}
1201 break;
1202 case kSDDp:{
1203 AliITSgeomSDD *s = new AliITSgeomSDD();
012f0f4c 1204 *rb >> *s;
023ae34b 1205 fShape.AddAt(s,kSDDp);}
1206 break;
1207 } // end switch
164da35c 1208 } // end for i
012f0f4c 1209 return;
593e9459 1210}
593e9459 1211//______________________________________________________________________
269f57ed 1212// The following routines modify the transformation of "this"
1213// geometry transformations in a number of different ways.
593e9459 1214//______________________________________________________________________
269f57ed 1215void AliITSgeom::GlobalChange(const Float_t *tran,const Float_t *rot){
85f1e34a 1216 // This function performs a Cartesian translation and rotation of
1217 // the full ITS from its default position by an amount determined by
1218 // the three element arrays tran and rot. If every element
1219 // of tran and rot are zero then there is no change made
1220 // the geometry. The change is global in that the exact same translation
1221 // and rotation is done to every detector element in the exact same way.
1222 // The units of the translation are those of the Monte Carlo, usually cm,
1223 // and those of the rotation are in radians. The elements of tran
1224 // are tran[0] = x, tran[1] = y, and tran[2] = z.
1225 // The elements of rot are rot[0] = rx, rot[1] = ry, and
1226 // rot[2] = rz. A change in x will move the hole ITS in the ALICE
1227 // global x direction, the same for a change in y. A change in z will
1228 // result in a translation of the ITS as a hole up or down the beam line.
1229 // A change in the angles will result in the inclination of the ITS with
1230 // respect to the beam line, except for an effective rotation about the
1231 // beam axis which will just rotate the ITS as a hole about the beam axis.
023ae34b 1232 // Intputs:
012f0f4c 1233 // Float_t *tran A 3 element array representing the global
1234 // translations. the elements are x,y,z in cm.
023ae34b 1235 // Float_t *rot A 3 element array representing the global rotation
1236 // angles about the three axis x,y,z in radians
1237 // Outputs:
1238 // none.
1239 // Return:
1240 // none.
85f1e34a 1241 Int_t i,j;
1242 Double_t t[3],r[3];
1243 AliITSgeomMatrix *g;
1244
1245 fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true.
1246 for(i=0;i<fNmodules;i++){
023ae34b 1247 g = this->GetGeomMatrix(i);
1248 g->GetTranslation(t);
1249 g->GetAngles(r);
1250 for(j=0;j<3;j++){
1251 t[j] += tran[j];
1252 r[j] += rot[j];
1253 } // end for j
1254 g->SetTranslation(t);
1255 g->SetAngles(r);
85f1e34a 1256 } // end for i
1257 return;
58005f18 1258}
85f1e34a 1259//______________________________________________________________________
1260void AliITSgeom::GlobalCylindericalChange(const Float_t *tran,
1261 const Float_t *rot){
1262 // This function performs a cylindrical translation and rotation of
1263 // each ITS element by a fixed about in radius, rphi, and z from its
1264 // default position by an amount determined by the three element arrays
1265 // tran and rot. If every element of tran and
1266 // rot are zero then there is no change made the geometry. The
1267 // change is global in that the exact same distance change in translation
1268 // and rotation is done to every detector element in the exact same way.
1269 // The units of the translation are those of the Monte Carlo, usually cm,
1270 // and those of the rotation are in radians. The elements of tran
1271 // are tran[0] = r, tran[1] = rphi, and tran[2] = z.
1272 // The elements of rot are rot[0] = rx, rot[1] = ry, and
1273 // rot[2] = rz. A change in r will results in the increase of the
1274 // radius of each layer by the same about. A change in rphi will results in
1275 // the rotation of each layer by a different angle but by the same
1276 // circumferential distance. A change in z will result in a translation
1277 // of the ITS as a hole up or down the beam line. A change in the angles
1278 // will result in the inclination of the ITS with respect to the beam
1279 // line, except for an effective rotation about the beam axis which will
1280 // just rotate the ITS as a hole about the beam axis.
023ae34b 1281 // Intputs:
012f0f4c 1282 // Float_t *tran A 3 element array representing the global
1283 // translations. the elements are r,theta,z in
1284 // cm/radians.
023ae34b 1285 // Float_t *rot A 3 element array representing the global rotation
1286 // angles about the three axis x,y,z in radians
1287 // Outputs:
1288 // none.
1289 // Return:
1290 // none.
85f1e34a 1291 Int_t i,j;
1292 Double_t t[3],ro[3],r,r0,phi,rphi;
1293 AliITSgeomMatrix *g;
1294
1295 fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true.
1296 for(i=0;i<fNmodules;i++){
023ae34b 1297 g = this->GetGeomMatrix(i);
1298 g->GetTranslation(t);
1299 g->GetAngles(ro);
1300 r = r0= TMath::Hypot(t[1],t[0]);
1301 phi = TMath::ATan2(t[1],t[0]);
1302 rphi = r0*phi;
1303 r += tran[0];
1304 rphi += tran[1];
1305 phi = rphi/r0;
1306 t[0] = r*TMath::Cos(phi);
1307 t[1] = r*TMath::Sin(phi);
1308 t[2] += tran[2];
1309 for(j=0;j<3;j++){
1310 ro[j] += rot[j];
1311 } // end for j
1312 g->SetTranslation(t);
1313 g->SetAngles(ro);
85f1e34a 1314 } // end for i
1315 return;
58005f18 1316}
85f1e34a 1317//______________________________________________________________________
269f57ed 1318void AliITSgeom::RandomChange(const Float_t *stran,const Float_t *srot){
85f1e34a 1319 // This function performs a Gaussian random displacement and/or
1320 // rotation about the present global position of each active
1321 // volume/detector of the ITS. The sigma of the random displacement
1322 // is determined by the three element array stran, for the
1323 // x y and z translations, and the three element array srot,
1324 // for the three rotation about the axis x y and z.
023ae34b 1325 // Intputs:
012f0f4c 1326 // Float_t *stran A 3 element array representing the global
1327 // translations variances. The elements are x,
1328 // y,z in cm.
023ae34b 1329 // Float_t *srot A 3 element array representing the global rotation
012f0f4c 1330 // angles variances about the three axis x,y,z in
1331 // radians.
023ae34b 1332 // Outputs:
1333 // none.
1334 // Return:
1335 // none.
85f1e34a 1336 Int_t i,j;
1337 Double_t t[3],r[3];
1338 AliITSgeomMatrix *g;
1339
1340 fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true.
1341 for(i=0;i<fNmodules;i++){
023ae34b 1342 g = this->GetGeomMatrix(i);
1343 g->GetTranslation(t);
1344 g->GetAngles(r);
1345 for(j=0;j<3;j++){
1346 t[j] += gRandom->Gaus(0.0,stran[j]);
1347 r[j] += gRandom->Gaus(0.0, srot[j]);
1348 } // end for j
1349 g->SetTranslation(t);
1350 g->SetAngles(r);
85f1e34a 1351 } // end for i
1352 return;
58005f18 1353}
85f1e34a 1354//______________________________________________________________________
269f57ed 1355void AliITSgeom::RandomCylindericalChange(const Float_t *stran,
1356 const Float_t *srot){
85f1e34a 1357 // This function performs a Gaussian random displacement and/or
1358 // rotation about the present global position of each active
1359 // volume/detector of the ITS. The sigma of the random displacement
1360 // is determined by the three element array stran, for the
1361 // r rphi and z translations, and the three element array srot,
1362 // for the three rotation about the axis x y and z. This random change
1363 // in detector position allow for the simulation of a random uncertainty
1364 // in the detector positions of the ITS.
023ae34b 1365 // Intputs:
012f0f4c 1366 // Float_t *stran A 3 element array representing the global
1367 // translations variances. The elements are r,
1368 // theta,z in cm/radians.
023ae34b 1369 // Float_t *srot A 3 element array representing the global rotation
012f0f4c 1370 // angles variances about the three axis x,y,z in
1371 // radians.
023ae34b 1372 // Outputs:
1373 // none.
1374 // Return:
1375 // none.
85f1e34a 1376 Int_t i,j;
1377 Double_t t[3],ro[3],r,r0,phi,rphi;
1378 TRandom ran;
1379 AliITSgeomMatrix *g;
1380
1381 fTrans = (fTrans && 0xfffd) + 2; // set bit 1 true.
1382 for(i=0;i<fNmodules;i++){
023ae34b 1383 g = this->GetGeomMatrix(i);
1384 g->GetTranslation(t);
1385 g->GetAngles(ro);
1386 r = r0= TMath::Hypot(t[1],t[0]);
1387 phi = TMath::ATan2(t[1],t[0]);
1388 rphi = r0*phi;
1389 r += ran.Gaus(0.0,stran[0]);
1390 rphi += ran.Gaus(0.0,stran[1]);
1391 phi = rphi/r0;
1392 t[0] = r*TMath::Cos(phi);
1393 t[1] = r*TMath::Sin(phi);
1394 t[2] += ran.Gaus(0.0,stran[2]);
1395 for(j=0;j<3;j++){
1396 ro[j] += ran.Gaus(0.0, srot[j]);
1397 } // end for j
1398 g->SetTranslation(t);
1399 g->SetAngles(ro);
85f1e34a 1400 } // end for i
1401 return;
58005f18 1402}
593e9459 1403//______________________________________________________________________
5cf690c1 1404void AliITSgeom::GeantToTracking(const AliITSgeom &source){
85f1e34a 1405 // Copy the geometry data but change it to go between the ALICE
1406 // Global coordinate system to that used by the ITS tracking. A slightly
1407 // different coordinate system is used when tracking. This coordinate
1408 // system is only relevant when the geometry represents the cylindrical
1409 // ALICE ITS geometry. For tracking the Z axis is left alone but X-> -Y
1410 // and Y-> X such that X always points out of the ITS cylinder for every
1411 // layer including layer 1 (where the detectors are mounted upside down).
85f1e34a 1412 //Begin_Html
1413 /*
1414 <img src="picts/ITS/AliITSgeomMatrix_T1.gif">
1415 */
1416 //End_Html
023ae34b 1417 // Input:
1418 // AliITSgeom &source The AliITSgeom class with which to make this
1419 // a copy of.
1420 // Output:
1421 // none.
1422 // Return:
1423 // none.
85f1e34a 1424 Int_t i,j,k,l,id[3];
1425 Double_t r0[3][3],r1[3][3];
1426 Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
1427 Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
1428
1429 *this = source; // copy everything
1430 for(i=0;i<GetIndexMax();i++){
023ae34b 1431 GetGeomMatrix(i)->GetIndex(id);
1432 GetGeomMatrix(i)->GetMatrix(r0);
1433 if(id[0]==1){ // Layer 1 is treated different from the others.
1434 for(j=0;j<3;j++) for(k=0;k<3;k++){
1435 r1[j][k] = 0.;
1436 for(l=0;l<3;l++) r1[j][k] += a0[j][l]*r0[l][k];
1437 } // end for j,k
1438 }else{
1439 for(j=0;j<3;j++) for(k=0;k<3;k++){
1440 r1[j][k] = 0.;
1441 for(l=0;l<3;l++) r1[j][k] += a1[j][l]*r0[l][k];
1442 } // end for j,k
1443 } // end if
1444 GetGeomMatrix(i)->SetMatrix(r1);
85f1e34a 1445 } // end for i
1446 this->fTrans = (this->fTrans && 0xfffe) + 1; // set bit 0 true.
1447 return;
58005f18 1448}
269f57ed 1449//______________________________________________________________________
5cf690c1 1450Int_t AliITSgeom::GetNearest(const Double_t g[3],Int_t lay)const{
85f1e34a 1451 // Finds the Detector (Module) that is nearest the point g [cm] in
1452 // ALICE Global coordinates. If layer !=0 then the search is restricted
1453 // to Detectors (Modules) in that particular layer.
023ae34b 1454 // Inputs:
1455 // Double_t g[3] The ALICE Cartesian global coordinate from which the
1456 // distance is to be calculated with.
1457 // Int_t lay The layer to restrict the search to. If layer=0 then
1458 // all layers are searched. Default is lay=0.
1459 // Output:
1460 // none.
1461 // Return:
1462 // The module number representing the nearest module.
85f1e34a 1463 Int_t i,l,a,e,in=0;
1464 Double_t d,dn=1.0e10;
1465 Bool_t t=lay!=0; // skip if lay = 0 default value check all layers.
085bb6ed 1466
85f1e34a 1467 for(i=0;i<fNmodules;i++){
023ae34b 1468 if(t){GetModuleId(i,l,a,e);if(l!=lay) continue;}
1469 if((d=GetGeomMatrix(i)->Distance2(g))<dn){
1470 dn = d;
1471 in = i;
1472 } // end if
85f1e34a 1473 } // end for i
1474 return in;
085bb6ed 1475}
269f57ed 1476//______________________________________________________________________
5cf690c1 1477void AliITSgeom::GetNearest27(const Double_t g[3],Int_t n[27],Int_t lay)const{
85f1e34a 1478 // Finds 27 Detectors (Modules) that are nearest the point g [cm] in
1479 // ALICE Global coordinates. If layer !=0 then the search is restricted
1480 // to Detectors (Modules) in that particular layer. The number 27 comes
1481 // from including the nearest detector and all those around it (up, down,
1482 // left, right, forwards, backwards, and the corners).
023ae34b 1483 // Input:
1484 // Double_t g[3] The ALICE Cartesian global coordinate from which the
1485 // distance is to be calculated with.
1486 // Int_t lay The layer to restrict the search to. If layer=0 then
1487 // all layers are searched. Default is lay=0.
1488 // Output:
1489 // Int_t n[27] The module number representing the nearest 27 modules
1490 // in order.
1491 // Return:
1492 // none.
85f1e34a 1493 Int_t i,l,a,e,in[27]={0,0,0,0,0,0,0,0,0,
023ae34b 1494 0,0,0,0,0,0,0,0,0,
1495 0,0,0,0,0,0,0,0,0,};
85f1e34a 1496 Double_t d,dn[27]={1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,
023ae34b 1497 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,
1498 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,
1499 1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,1.0e10,
1500 1.0e10,1.0e10,1.0e10};
85f1e34a 1501 Bool_t t=(lay!=0); // skip if lay = 0 default value check all layers.
269f57ed 1502
85f1e34a 1503 for(i=0;i<fNmodules;i++){
023ae34b 1504 if(t){GetModuleId(i,l,a,e);if(l!=lay) continue;}
1505 for(a=0;a<27;a++){
1506 d = GetGeomMatrix(i)->Distance2(g);
1507 if(d<dn[a]){
1508 for(e=26;e>a;e--){dn[e] = dn[e-1];in[e] = in[e-1];}
1509 dn[a] = d; in[a] = i;
1510 } // end if d<dn[i]
1511 } // end for a
85f1e34a 1512 } // end for i
1513 for(i=0;i<27;i++) n[i] = in[i];
269f57ed 1514}
023ae34b 1515//----------------------------------------------------------------------
5cf690c1 1516Double_t AliITSgeom::GetAverageRadiusOfLayer(Int_t layer,Double_t &range)const{
023ae34b 1517 // Loops over all modules for a given layer and computes the
1518 // average cylindrical radius (about the z axis) and the range of
1519 // radii covered by this layer. Units, [cm] the Alice default unit.
1520 // Input:
1521 // Int_t layer The layer for which the average radii is to be found
1522 // Output:
1523 // Double_t &range The range of radii covered by this layer
1524 // Return:
1525 // The average radii for this layer.
1526 Double_t r=0.0,rmin=1.0e6,rmax=-1.0,rp,t[3],l[3],dl[3];
1527 Int_t n=0,i,j,lay,lad,det;
5cf690c1 1528 AliITSDetector idet;
023ae34b 1529
1530 for(i=0;i<GetIndexMax();i++) {
1531 GetModuleId(i,lay,lad,det);
5cf690c1 1532 idet = GetModuleType(i);
023ae34b 1533 if(lay!=layer) continue;
1534 dl[0] = dl[1] = dl[2] = 0.0;
5cf690c1 1535 if(IsShapeDefined((Int_t)idet)) {
1536 switch(idet){
1537 case kSPD:{
1538 dl[0] = ((AliITSgeomSPD*)GetShape(idet))->GetDx();
1539 dl[1] = ((AliITSgeomSPD*)GetShape(idet))->GetDy();
1540 dl[2] = ((AliITSgeomSPD*)GetShape(idet))->GetDz();
023ae34b 1541 } break;
5cf690c1 1542 case kSDD: case kSDDp:{
1543 dl[0] = ((AliITSgeomSDD*)GetShape(idet))->GetDx();
1544 dl[1] = ((AliITSgeomSDD*)GetShape(idet))->GetDy();
1545 dl[2] = ((AliITSgeomSDD*)GetShape(idet))->GetDz();
023ae34b 1546 } break;
5cf690c1 1547 case kSSD: case kSSDp:{
1548 dl[0] = ((AliITSgeomSSD*)GetShape(idet))->GetDx();
1549 dl[1] = ((AliITSgeomSSD*)GetShape(idet))->GetDy();
1550 dl[2] = ((AliITSgeomSSD*)GetShape(idet))->GetDz();
023ae34b 1551 } break;
22e9f252 1552 case kND:{
1553 Warning("GetAverageRadiusOfLayer",
1554 "idet=kND undefined detector type");
1555 continue;
1556 }break;
1557 default:{
1558 Warning("GetAverageRadiusOfLayer",
1559 "idet=%d not a defined value",(Int_t)idet);
1560 continue;
1561 }break;
023ae34b 1562 }// end switch.
1563 } // end of
1564 n++;
1565 GetTransCyln(i,t);
1566 rp = t[0];
1567 r += rp;
1568 if(rmin>rp) rmin = rp;
1569 if(rmax<rp) rmax = rp;
1570 for(j=0;j<8;j++){ // loop over the corners
1571 l[0] = dl[0];if(j%2==0) l[0] = -dl[0];
1572 l[1] = dl[1];if(j==2||j==3||j==6||j==7) l[1] = -dl[1];
1573 l[2] = dl[2];if(j>3) l[2] = -dl[2];
1574 LtoG(i,l,t);
1575 rp = TMath::Sqrt(t[0]*t[0]+t[1]*t[1]);
1576 if(rmin>rp) rmin = rp;
1577 if(rmax<rp) rmax = rp;
1578 } // end for j
1579 } // end for i
1580 r /= (Double_t)n;
1581 range = TMath::Max(rmax-r,r-rmin);
1582 return r;
1583}
00a7cc50 1584//_______________________________________________________________________
012f0f4c 1585void AliITSgeom::DetLToTrackingV2(Int_t md,Float_t xin,Float_t zin,
1586 Float_t &yout,Float_t &zout) {
00a7cc50 1587
012f0f4c 1588 //Conversion from local coordinates on detectors to local
1589 //coordinates used for tracking ("v2")
1590 // Inputs:
1591 // Int_t md Module number
1592 // Float_t xin Standard local coordinate x
1593 // Float_t zin Standard local coordinate z
1594 // Output:
1595 // Float_t yout Tracking local coordinate y
1596 // Float_t zout Tracking local coordinate z
1597 // Return:
1598 // none.
1599 Float_t x,y,z;
1600 Double_t rt[9],al;
00a7cc50 1601
012f0f4c 1602 GetTrans(md,x,y,z);
1603 GetRotMatrix(md,rt);
1604 al = TMath::ATan2(rt[1],rt[0])+TMath::Pi();
1605 yout = -(-xin+(x*((Float_t)TMath::Cos(al))+y*((Float_t)TMath::Sin(al))));
1606 if(md<(GetModuleIndex(2,1,1))) yout *= -1;
1607 zout = -zin+z;
1608}
00a7cc50 1609//_______________________________________________________________________
012f0f4c 1610void AliITSgeom::TrackingV2ToDetL(Int_t md,Float_t yin,Float_t zin,
1611 Float_t &xout,Float_t &zout) {
1612 //Conversion from local coordinates used for tracking ("v2") to
1613 //local detector coordinates
1614 // Inputs:
1615 // Int_t md Module number
1616 // Float_t yin Tracking local coordinate y
1617 // Float_t zin Tracking local coordinate z
1618 // Output:
1619 // Float_t xout Standard local coordinate x
1620 // Float_t zout Standard local coordinate z
1621 // Return:
1622 // none.
1623 Float_t x,y,z;
1624 Double_t rt[9],al;
1625
1626 GetTrans(md,x,y,z);
1627 GetRotMatrix(md,rt);
1628 al = TMath::ATan2(rt[1],rt[0])+TMath::Pi();
1629 xout = yin;
1630 if(md<(GetModuleIndex(2,1,1))) xout = -xout;
1631 xout += (x*((Float_t)TMath::Cos(al))+y*((Float_t)TMath::Sin(al)));
1632 zout = -zin+z;
00a7cc50 1633}
012f0f4c 1634//----------------------------------------------------------------------
1635ostream &operator<<(ostream &os,AliITSgeom &p){
1636 // Standard output streaming function.
1637 // Inputs:
1638 // ostream os The output stream
1639 // AliITSgeom p The AliITSgeom class to be printed out
1640 // Outputs:
1641 // none.
1642 // Return:
1643 // The input stream
1644
1645 p.PrintGeom(&os);
1646 return os;
1647}
1648//----------------------------------------------------------------------
1649istream &operator>>(istream &is,AliITSgeom &r){
1650 // Standard input streaming function.
1651 // Inputs:
1652 // istream is The input stream
1653 // AliITSgeom p The AliITSgeom class to be filled from this
1654 // input stream
1655 // Outputs:
1656 // none.
1657 // Return:
1658 // The input stream
1659
1660 r.ReadGeom(&is);
1661 return is;
1662}
1663//----------------------------------------------------------------------
1664