]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv5symm.cxx
ebc2fb299611f1455ea75476ec54e1ac59e75c85
[u/mrichter/AliRoot.git] / ITS / AliITSv5symm.cxx
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$
18 Revision 1.4  2001/02/02 23:57:29  nilsen
19 Added include file that are no londer included in AliITSgeom.h
20
21 Revision 1.3  2001/01/30 09:23:13  hristov
22 Streamers removed (R.Brun)
23
24 Revision 1.2  2000/11/30 11:13:11  barbera
25  Added changes suggested by Federico Carminati on nov, 30, 2000
26
27 Revision 1.1  2000/10/07 15:46:29  barbera
28 Version 5 of the geometry with symmetric services
29
30 Revision 1.25  2000/10/05 20:50:00  nilsen
31 Now using root generated streamers.
32
33 Revision 1.14.4.12  2000/10/02 16:04:03  barbera
34 Forward declarations added
35
36 Revision 1.22  2000/07/10 16:07:19  fca
37 Release version of ITS code
38
39 Revision 1.14.4.4  2000/05/19 10:10:21  nilsen
40 fix for bug with HP and Sun unix + fix for event display in ITS-working branch
41
42 Revision 1.14.4.3  2000/03/04 23:46:38  nilsen
43 Fixed up the comments/documentation.
44
45 Revision 1.14.4.2  2000/03/02 21:53:02  nilsen
46 To make it compatable with the changes in AliRun/AliModule.
47
48 Revision 1.14.4.1  2000/01/12 19:03:33  nilsen
49 This is the version of the files after the merging done in December 1999.
50 See the ReadMe110100.txt file for details
51
52 Revision 1.14  1999/10/22 08:16:49  fca
53 Correct destructors, thanks to I.Hrivnacova
54
55 Revision 1.13  1999/10/06 10:15:19  fca
56 Correct bug in allocation of layer name and add destructor
57
58 Revision 1.12  1999/10/05 08:05:09  fca
59 Minor corrections for uninitialised variables.
60
61 Revision 1.11  1999/09/29 09:24:20  fca
62 Introduction of the Copyright and cvs Log
63
64 */
65
66 ///////////////////////////////////////////////////////////////////////////////
67 //
68 //  Inner Traking System version 5 with symmetric services
69 //  This class contains the base procedures for the Inner Tracking System
70 //
71 // Authors: R. Barbera, B. S. Nilsen.
72 // version 5.
73 // Created October 7 2000.
74 //
75 ///////////////////////////////////////////////////////////////////////////////
76 #include <iostream.h>
77 #include <iomanip.h>
78 #include <stdio.h>
79 #include <stdlib.h>
80 #include <TMath.h>
81 #include <TGeometry.h>
82 #include <TNode.h>
83 #include <TTUBE.h>
84 #include <TFile.h>    // only required for Tracking function?
85 #include <TCanvas.h>
86 #include <TObjArray.h>
87 #include <TLorentzVector.h>
88 #include <TObjString.h>
89 #include <TClonesArray.h>
90 #include <TBRIK.h>
91 #include <TSystem.h>
92
93 #include "AliMC.h"
94 #include "AliRun.h"
95 #include "../TGeant3/TGeant3.h"
96 #include "AliITShit.h"
97 #include "AliITSGeant3Geometry.h"
98 #include "AliITS.h"
99 #include "AliITSv5symm.h"
100 #include "AliITSgeom.h"
101 #include "AliITSgeomSPD.h"
102 #include "AliITSgeomSDD.h"
103 #include "AliITSgeomSSD.h"
104
105 ClassImp(AliITSv5symm)
106  
107 //_____________________________________________________________________________
108 AliITSv5symm::AliITSv5symm() {
109 ////////////////////////////////////////////////////////////////////////
110 //    Standard default constructor for the ITS version 5.
111 ////////////////////////////////////////////////////////////////////////
112     Int_t i;
113
114     fIdN    = 0;
115     fIdName = 0;
116     fIdSens = 0;
117     fEuclidOut    = kFALSE; // Don't write Euclide file
118     fGeomDetOut   = kFALSE; // Don't write .det file
119     fGeomDetIn    = kFALSE; // Read .det file
120     fGeomOldDetIn = kTRUE;  // Read old formatted .det file
121     fMajorVersion = IsVersion();
122     fMinorVersion = 2;
123     for(i=0;i<60;i++) fRead[i] = '\0';
124     for(i=0;i<60;i++) fWrite[i] = '\0';
125     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
126 }
127 //_____________________________________________________________________________
128 AliITSv5symm::AliITSv5symm(const char *name, const char *title) : AliITS(name, title){
129 /////////////////////////////////////////////////////////////////////////////
130 //    Standard constructor for the ITS version 5 with symmetrical services.
131 /////////////////////////////////////////////////////////////////////////////
132     Int_t i;
133
134     fIdN    = 6;
135     fIdName    = new TString[fIdN];
136     fIdName[0] = "ITS1";
137     fIdName[1] = "ITS2";
138     fIdName[2] = "ITS3";
139     fIdName[3] = "ITS4";
140     fIdName[4] = "ITS5";
141     fIdName[5] = "ITS6";
142     fIdSens    = new Int_t[fIdN];
143     for (i=0;i<fIdN;i++) fIdSens[i] = 0;
144     fEuclidOut    = kFALSE; // Don't write Euclide file
145     fGeomDetOut   = kFALSE; // Don't write .det file
146     fGeomDetIn    = kFALSE; // Read .det file
147     fGeomOldDetIn = kTRUE;  // Read old formatted .det file
148     fMajorVersion = IsVersion();
149     fMinorVersion = 2;
150     for(i=0;i<60;i++) fRead[i] = '\0';
151     for(i=0;i<60;i++) fWrite[i] = '\0';
152
153     fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.tme";
154     fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.euc";
155     strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_v5symm.det",60);
156     strncpy(fRead,fEuclidGeomDet,60);
157     strncpy(fWrite,fEuclidGeomDet,60);
158 }
159 //____________________________________________________________________________
160 AliITSv5symm::AliITSv5symm(const AliITSv5symm &source){
161 ////////////////////////////////////////////////////////////////////////
162 //     Copy Constructor for ITS version 5.
163 ////////////////////////////////////////////////////////////////////////
164     if(&source == this) return;
165     Warning("Copy Constructor","Not allowed to copy AliITSv5symm");
166     return;
167 }
168 //_____________________________________________________________________________
169 AliITSv5symm& AliITSv5symm::operator=(const AliITSv5symm &source){
170 ////////////////////////////////////////////////////////////////////////
171 //    Assignment operator for the ITS version 5.
172 ////////////////////////////////////////////////////////////////////////
173
174     if(&source == this) return *this;
175     Warning("= operator","Not allowed to copy AliITSv5symm");
176     return *this;
177
178 }
179 //_____________________________________________________________________________
180 AliITSv5symm::~AliITSv5symm() {
181 ////////////////////////////////////////////////////////////////////////
182 //    Standard destructor for the ITS version 5.
183 ////////////////////////////////////////////////////////////////////////
184     if(fRead!=0) delete fRead;
185     if(fWrite!=0) delete fWrite;
186     if(fEuclidGeomDet!=0) delete fEuclidGeomDet;
187 }
188 //_____________________________________________________________________________
189 void AliITSv5symm::BuildGeometry(){
190 ////////////////////////////////////////////////////////////////////////
191 //    Geometry builder for the ITS version 5.
192 ////////////////////////////////////////////////////////////////////////
193   //
194   // Build ITS TNODE geometry for event display using detailed geometry.
195   // This function builds a simple ITS geometry used by the ROOT macro
196   // ITSdisplay.C.
197
198   TNode *top;
199   TNode *nd;
200   //const int kColorITSSPD=kRed;
201   //const int kColorITSSDD=kGreen;
202   const int kColorITSSSD=kBlue;
203   //
204   top=gAlice->GetGeometry()->GetNode("alice");
205   AliITSgeom  *gm = this->GetITSgeom();
206
207   Int_t       lay,lad,det,i;
208   Text_t      name[10];
209   Float_t     xg[3];
210   Float_t     rt[9];
211   Double_t    rtd[9];
212   TBRIK       *box;
213   TRotMatrix  *rm;
214   //TCanvas     *c1 = new TCanvas("c1","ITS");
215
216   for(lay=1;lay<=2;lay++)
217    for(lad=1;lad<=gm->GetNladders(lay);lad++)
218     for(det=1;det<=gm->GetNdetectors(lay);det++){
219           try {
220               box  = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
221                                     0.64,0.0075,4.19); 
222           } catch (...) {
223               cout << "EXCEPTION in box = new TBRIK" << endl;
224               return;
225           }
226           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
227           gm->GetRotMatrix(lay,lad,det,rt);
228           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
229           for(i=0;i<9;i++) rtd[i] = rt[i];
230           try {
231                 rm  = new TRotMatrix(name,name,rtd);
232           } catch (...) {
233                 cout << "EXCEPTION in   new TRotMatrix" << endl;
234                 return;
235           }
236          top->cd();
237           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
238          try {
239               nd  = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
240          } catch (...) {
241               cout << "EXCEPTION in new TNode" << endl;
242               return;
243          }
244          nd->SetLineColor(kColorITSSSD);
245          fNodes->Add(nd);
246     }
247
248   for(lay=3;lay<=3;lay++)
249    for(lad=1;lad<=gm->GetNladders(lay);lad++)
250     for(det=1;det<=gm->GetNdetectors(lay);det++){
251           try {
252               box  = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
253                                     3.5,0.014,3.763); 
254           } catch (...) {
255               cout << "EXCEPTION in box = new TBRIK" << endl;
256               return;
257           }
258           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
259           gm->GetRotMatrix(lay,lad,det,rt);
260           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
261           for(i=0;i<9;i++) rtd[i] = rt[i];
262           try {
263                 rm  = new TRotMatrix(name,name,rtd);
264           } catch (...) {
265                 cout << "EXCEPTION in   new TRotMatrix" << endl;
266                 return;
267           }
268          top->cd();
269           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
270          try {
271               nd  = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
272          } catch (...) {
273               cout << "EXCEPTION in new TNode" << endl;
274               return;
275          }
276          nd->SetLineColor(kColorITSSSD);
277          fNodes->Add(nd);
278     }
279
280   for(lay=4;lay<=4;lay++)
281    for(lad=1;lad<=gm->GetNladders(lay);lad++)
282     for(det=1;det<=gm->GetNdetectors(lay);det++){
283           try {
284               box  = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
285                                     3.5,0.014,3.763); 
286           } catch (...) {
287               cout << "EXCEPTION in box = new TBRIK" << endl;
288               return;
289           }
290           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
291           gm->GetRotMatrix(lay,lad,det,rt);
292           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
293           for(i=0;i<9;i++) rtd[i] = rt[i];
294           try {
295                 rm  = new TRotMatrix(name,name,rtd);
296           } catch (...) {
297                 cout << "EXCEPTION in   new TRotMatrix" << endl;
298                 return;
299           }
300          top->cd();
301           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
302          try {
303               nd  = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
304          } catch (...) {
305               cout << "EXCEPTION in new TNode" << endl;
306               return;
307          }
308          nd->SetLineColor(kColorITSSSD);
309          fNodes->Add(nd);
310     }
311  for(lay=5;lay<=5;lay++)
312    for(lad=1;lad<=gm->GetNladders(lay);lad++)
313     for(det=1;det<=gm->GetNdetectors(lay);det++){
314           try {
315               box  = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
316                                     3.65,0.015,2.0); 
317           } catch (...) {
318               cout << "EXCEPTION in box = new TBRIK" << endl;
319               return;
320           }
321           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
322           gm->GetRotMatrix(lay,lad,det,rt);
323           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
324           for(i=0;i<9;i++) rtd[i] = rt[i];
325           try {
326                 rm  = new TRotMatrix(name,name,rtd);
327           } catch (...) {
328                 cout << "EXCEPTION in   new TRotMatrix" << endl;
329                 return;
330           }
331          top->cd();
332           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
333          try {
334               nd  = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
335          } catch (...) {
336               cout << "EXCEPTION in new TNode" << endl;
337               return;
338          }
339          nd->SetLineColor(kColorITSSSD);
340          fNodes->Add(nd);
341     }
342
343  for(lay=6;lay<=6;lay++)
344    for(lad=1;lad<=gm->GetNladders(lay);lad++)
345     for(det=1;det<=gm->GetNdetectors(lay);det++){
346           try {
347               box  = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
348                                     3.65,0.015,2.0); 
349           } catch (...) {
350               cout << "EXCEPTION in box = new TBRIK" << endl;
351               return;
352           }
353
354           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]); 
355           gm->GetRotMatrix(lay,lad,det,rt);
356           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
357           for(i=0;i<9;i++) rtd[i] = rt[i];
358           try {
359                 rm  = new TRotMatrix(name,name,rtd);
360           } catch (...) {
361                 cout << "EXCEPTION in   new TRotMatrix" << endl;
362                 return;
363           }
364          top->cd();
365           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
366          try {
367               nd  = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
368          } catch (...) {
369               cout << "EXCEPTION in new TNode" << endl;
370               return;
371          }
372          nd->SetLineColor(kColorITSSSD);
373          fNodes->Add(nd);
374     }
375
376
377
378 //_____________________________________________________________________________
379 void AliITSv5symm::CreateMaterials(){
380 ////////////////////////////////////////////////////////////////////////
381 //     Read a file containing the materials for the ITS version 5.
382 ////////////////////////////////////////////////////////////////////////
383     char *filtmp;
384
385   filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
386
387   FILE *file = fopen(filtmp,"r");
388   if(file) {
389     fclose(file);
390     ReadEuclidMedia(filtmp);
391   } else {
392     Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
393     exit(1);
394   } // end if(file)
395 }
396 //_____________________________________________________________________________
397 void AliITSv5symm::CreateGeometry(){
398 //////////////////////////////////////////////////////////////////////
399 //    This is the geometry used for the ITS Pre-TDR and comes from an 
400 // Euclid to Geant conversion. The only difference
401 // is in the details of the ITS supports. The detectors elements, 
402 // detector numbering, and local and global reference frames are shown in
403 //  the following figures.
404 //Begin_Html
405 /*
406 <img src="picts/ITS/its1+2_convention_front_5.gif">
407 </pre>
408 <br clear=left>
409 <font size=+2 color=red>
410 <p>This shows the front view of the SPDs.
411 </font>
412 <pre>
413 <img src="picts/ITS/its1+2_convention_side_5.gif">
414 </pre>
415 <br clear=left>
416 <font size=+2 color=red>
417 <p>This shows the perspective view of the SPDs.
418 </font>
419 <img src="picts/ITS/its1+2_tree.gif">
420 </pre>
421 <br clear=left>
422 <font size=+2 color=red>
423 <p>This shows the geometry Tree for the SPDs.
424 </font>
425 <pre>
426
427 <pre>
428 <img src="picts/ITS/its3+4_convention_front_5.gif">
429 </pre>
430 <br clear=left>
431 <font size=+2 color=red>
432 <p>This shows the front view of the SDDs.
433 </font>
434 <pre>
435 <img src="picts/ITS/its3+4_convention_side_5.gif">
436 </pre>
437 <br clear=left>
438 <font size=+2 color=red>
439 <p>This shows the perspective view of the SDDs.
440 </font>
441 <img src="picts/ITS/its3+4_tree.gif">
442 </pre>
443 <br clear=left>
444 <font size=+2 color=red>
445 <p>This shows the geometry Tree for the SDDs.
446 </font>
447 <pre>
448
449 <pre>
450 <img src="picts/ITS/its5+6_convention_front_5.gif">
451 </pre>
452 <br clear=left>
453 <font size=+2 color=red>
454 <p>This shows the front view of the SSDs.
455 </font>
456 <pre>
457 <img src="picts/ITS/its5+6_convention_side_5.gif">
458 </pre>
459 <br clear=left>
460 <font size=+2 color=red>
461 <p>This shows the perspective view of the SSDs.
462 </font>
463 <pre>
464 <img src="picts/ITS/its5+6_tree.gif">
465 </pre>
466 <br clear=left>
467 <font size=+2 color=red>
468 <p>This shows the geometry Tree for the SSDs.
469 </font>
470 <pre>
471
472
473 <img src="picts/ITS/its_layer1-6_2.gif">
474 </pre>
475 <br clear=left>
476 <font size=+2 color=red>
477 <p>This shows the front view of the whole ITS..
478 </font>
479 <pre>
480
481 <img src="picts/ITS/its_layer1-6_1.gif">
482 </pre>
483 <br clear=left>
484 <font size=+2 color=red>
485 <p>This shows the perspective view of the whole ITS..
486 </font>
487 <pre>
488
489 <img src="picts/ITS/its1-6_tree.gif">
490 </pre>
491 <br clear=left>
492 <font size=+2 color=red>
493 <p>This shows the geometry Tree for the whole ITS.
494 </font>
495 <pre>
496 */
497 //End_Html
498 //
499 //
500 //      Here are shown the details of the ITS support cones and services.
501 // First is a GEANT tree showing the organization of all of the volumes
502 // that make up the ITS supports and services.
503 //Begin_Html
504 /*
505 <img src="picts/ITS/supports_tree.gif">
506  */
507 //End_Html
508 //     What follows are a number of figures showing what these support
509 // structures look like.
510 //Begin_Html
511 /*
512
513 <img src="picts/ITS/supports_3.gif">
514 </pre>
515 <br clear=left>
516 <font size=+2 color=red>
517 <p>This shows the geometry of the supports for the Drift and Strip layers only.
518 </font>
519 <pre>
520
521 <img src="picts/ITS/supports_2.gif">
522 </pre>
523 <br clear=left>
524 <font size=+2 color=red>
525 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
526 </font>
527 <pre>
528
529 <img src="picts/ITS/supports_1.gif">
530 </pre>
531 <br clear=left>
532 <font size=+2 color=red>
533 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
534 </font>
535 <pre>
536
537 <img src="picts/ITS/suppssd.gif">
538 </pre>
539 <br clear=left>
540 <font size=+2 color=red>
541 <p>This shows the geometry for the Strip layers supports.
542 </font>
543 <pre>
544
545 <img src="picts/ITS/suppsdd.gif">
546 </pre>
547 <br clear=left>
548 <font size=+2 color=red>
549 <p>This shows the geometry for the Drift layers supports.
550 </font>
551 <pre>
552  */
553 //End_Html
554 //
555 //    Read a file containing the geometry for the ITS version 5.
556 ////////////////////////////////////////////////////////////////////////
557     char topvol[5];
558     char *filtmp;
559
560   filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
561   FILE *file = fopen(filtmp,"r");
562   delete [] filtmp;
563   if(file) {
564     fclose(file);
565     printf("Ready to read Euclid geometry file\n");
566     ReadEuclid(fEuclidGeometry.Data(),topvol);
567     printf("Read in euclid geometries\n");
568   } else {
569     Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
570           fEuclidGeometry.Data());
571     exit(1);
572   } // end if(file)
573   //
574   // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
575   // invisible
576   //
577   gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
578   //
579   // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
580   
581     if (fEuclidOut) {
582       gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
583     } // end if (fEuclidOut)
584     cout << "finished with euclid geometrys" << endl;
585 }
586 //______________________________________________________________________
587 void AliITSv5symm::ReadOldGeometry(const char *filename){
588     // read in the file containing the transformations for the active
589     // volumes for the ITS version 5. This is expected to be in a file
590     // ending in .det. This geometry is kept in the AliITSgeom class.
591     Int_t size;
592     char *filtmp;
593     FILE *file;
594
595     filtmp = gSystem->ExpandPathName(filename);
596     size = strlen(filtmp);
597     if(size>4 && fGeomDetIn){
598         filtmp[size-3] = 'd'; // change from .euc to .det
599         filtmp[size-2] = 'e';
600         filtmp[size-1] = 't';
601         file = fopen(filtmp,"r");
602         if(file){ // if file exists use it to fill AliITSgeom structure.
603             fclose(file);
604             fITSgeom = new AliITSgeom(filtmp);
605             fITSgeom->DefineShapes(3); // if fShape isn't defined define it.
606             // Now define the detector types/shapes.
607             fITSgeom->ReSetShape(kSPD,(TObject *) new AliITSgeomSPD300());
608             fITSgeom->ReSetShape(kSDD,(TObject *) new AliITSgeomSDD300());
609             fITSgeom->ReSetShape(kSSD,(TObject *) new AliITSgeomSSD());
610         }else{
611             fITSgeom = 0;
612             // fill AliITSgeom structure from geant structure just filled above
613         }// end if(file)
614         delete [] filtmp;
615     }// end if(size>4)
616 }
617 //______________________________________________________________________
618 void AliITSv5symm::InitAliITSgeom(){
619 //     Based on the geometry tree defined in Geant 3.21, this
620 // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
621 // sturture.
622     if(!((TGeant3*)gMC)) {
623         Error("InitAliITSgeom",
624                 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
625         return;
626     } // end if
627     cout << "Reading Geometry transformation directly from Geant 3." << endl;
628     const Int_t nlayers = 6;
629     const Int_t ndeep = 7;
630     Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
631     Int_t nlad[nlayers],ndet[nlayers];
632     Double_t t[3],r[10];
633     Float_t  par[20],att[20];
634     Int_t    npar,natt,idshape,imat,imed;
635     AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
636     Int_t mod,lay,lad,det,i,j,k;
637     char *names[nlayers][ndeep] = {
638         {"ALIC","ITSV","ITSD","IT12","I132","I186","ITS1"}, // lay=1
639         {"ALIC","ITSV","ITSD","IT12","I132","I131","ITS2"}, // lay=2
640         {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"}, // lay=3
641         {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"}, // lay=4
642         {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"}, // lay=5
643         {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"}};// lay=6
644     Int_t itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2,4}, // lay=1
645                                               {1,1,1,1,10, 4,4}, // lay=2
646                                               {1,1,1,1,14, 6,1}, // lay=3
647                                               {1,1,1,1,22, 8,1}, // lay=4
648                                               {1,1,1,1,34,23,1}, // lay=5
649                                               {1,1,1,1,38,26,1}};// lay=6
650
651     // Sorry, but this is not very pritty code. It should be replaced
652     // at some point with a version that can search through the geometry
653     // tree its self.
654     cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
655     for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
656     for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) 
657         itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
658     mod = 0;
659     for(i=0;i<nlayers;i++){
660         k = 1;
661         for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
662             k *= TMath::Abs(itsGeomTreeCopys[i][j]);
663         mod += k;
664     } // end for i
665
666     if(fITSgeom!=0) delete fITSgeom;
667     nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
668     ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
669     fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
670     mod = -1;
671     for(lay=1;lay<=nlayers;lay++){
672         for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
673         for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
674         switch (lay){
675         case 1: case 2: // layers 1 and 2 are a bit special
676             lad = 0;
677             for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
678                 lnum[4] = j;
679                 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
680                     lad++;
681                     lnum[5] = k;
682                     for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
683                         lnum[6] = det;
684                         mod++;
685                         ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
686                                         par,att,imat,imed);
687                         fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
688                         if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
689                             if(fMinorVersion==1){
690                              fITSgeom->ReSetShape(kSPD,
691                                                   new AliITSgeomSPD300());
692                             } else if(fMinorVersion==2)
693                              fITSgeom->ReSetShape(kSPD,
694                                                   new AliITSgeomSPD300());
695                     } // end for det
696                 } // end for k
697             } // end for j
698             break;
699         case 3: case 4: case 5: case 6: // layers 3-6
700             lnum[6] = 1;
701             for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
702                 lnum[4] = lad;
703                 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
704                     lnum[5] = det;
705                     mod++;
706                     ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
707                                     par,att,imat,imed);
708                     switch (lay){
709                     case 3: case 4:
710                         fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
711                         if(!(fITSgeom->IsShapeDefined(kSDD))) 
712                             fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
713                             break;
714                     case 5: case 6:
715                             fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
716                             if(!(fITSgeom->IsShapeDefined(kSSD))) 
717                                 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
718                             break;
719                         } // end switch
720                 } // end for det
721             } // end for lad
722             break;
723         } // end switch
724     } // end for lay
725     return;
726 }
727 //_____________________________________________________________________________
728 void AliITSv5symm::Init(){
729 ////////////////////////////////////////////////////////////////////////
730 //     Initialise the ITS after it has been created.
731 ////////////////////////////////////////////////////////////////////////
732     Int_t i;
733
734     cout << endl;
735     for(i=0;i<30;i++) cout << "*";cout << " ITSv5_Init ";
736     for(i=0;i<30;i++) cout << "*";cout << endl;
737 //
738     if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
739     if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
740     if(fITSgeom!=0) delete fITSgeom;
741     fITSgeom = new AliITSgeom();
742     if(fGeomDetIn && !fGeomOldDetIn) fITSgeom->ReadNewFile(fRead);
743     if(fGeomDetIn &&  fGeomOldDetIn) this->ReadOldGeometry(fRead);
744
745     if(!fGeomDetIn) this->InitAliITSgeom();
746     if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
747     AliITS::Init();
748 //
749     for(i=0;i<72;i++) cout << "*";
750     cout << endl;
751
752 //_____________________________________________________________________________
753 void AliITSv5symm::StepManager(){
754 ////////////////////////////////////////////////////////////////////////
755 //    Called for every step in the ITS, then calles the AliITShit class
756 // creator with the information to be recoreded about that hit.
757 //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
758 // printing of information to a file which can be used to create a .det
759 // file read in by the routine CreateGeometry(). If set to 0 or any other
760 // value except 1, the default behavior, then no such file is created nor
761 // it the extra variables and the like used in the printing allocated.
762 ////////////////////////////////////////////////////////////////////////
763   Int_t          copy, id;
764   Int_t          copy1,copy2;
765   Float_t        hits[8];
766   Int_t          vol[4];
767   TLorentzVector position, momentum;
768   TClonesArray   &lhits = *fHits;
769   //
770   // Track status
771   vol[3] = 0;
772   if(gMC->IsTrackInside())      vol[3] +=  1;
773   if(gMC->IsTrackEntering())    vol[3] +=  2;
774   if(gMC->IsTrackExiting())     vol[3] +=  4;
775   if(gMC->IsTrackOut())         vol[3] +=  8;
776   if(gMC->IsTrackDisappeared()) vol[3] += 16;
777   if(gMC->IsTrackStop())        vol[3] += 32;
778   if(gMC->IsTrackAlive())       vol[3] += 64;
779   //
780   // Fill hit structure.
781   if(!(gMC->TrackCharge())) return;
782   //
783   // Only entering charged tracks
784   if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
785       vol[0] = 1;
786       id = gMC->CurrentVolOffID(0,copy);
787       //detector copy in the ladder = 1<->4  (ITS1)
788       vol[1] = copy;
789       gMC->CurrentVolOffID(1,copy1);
790       //ladder copy in the module   = 1<->2  (I186)
791       gMC->CurrentVolOffID(2,copy2);
792       //module copy in the layer    = 1<->10 (I132)
793       vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
794   } else if(id == fIdSens[1]){
795       vol[0] = 2;
796       id = gMC->CurrentVolOffID(0,copy);
797       //detector copy in the ladder = 1<->4  (ITS2)
798       vol[1] = copy;
799       gMC->CurrentVolOffID(1,copy1);
800       //ladder copy in the module   = 1<->4  (I131)
801       gMC->CurrentVolOffID(2,copy2);
802       //module copy in the layer    = 1<->10 (I132)
803       vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
804   } else if(id == fIdSens[2]){
805       vol[0] = 3;
806       id = gMC->CurrentVolOffID(1,copy);
807       //detector copy in the ladder = 1<->5  (ITS3 is inside I314)
808       vol[1] = copy;
809       id = gMC->CurrentVolOffID(2,copy);
810       //ladder copy in the layer    = 1<->12 (I316)
811       vol[2] = copy;
812   } else if(id == fIdSens[3]){
813       vol[0] = 4;
814       id = gMC->CurrentVolOffID(1,copy);
815       //detector copy in the ladder = 1<->8  (ITS4 is inside I414)
816       vol[1] = copy;
817       id = gMC->CurrentVolOffID(2,copy);
818       //ladder copy in the layer    = 1<->22 (I417)
819       vol[2] = copy;
820   }else if(id == fIdSens[4]){
821       vol[0] = 5;
822       id = gMC->CurrentVolOffID(1,copy);
823       //detector copy in the ladder = 1<->23  (ITS5 is inside I562)
824       vol[1] = copy;
825       id = gMC->CurrentVolOffID(2,copy);
826      //ladder copy in the layer    = 1<->34 (I565)
827       vol[2] = copy;
828   }else if(id == fIdSens[5]){
829       vol[0] = 6;
830       id = gMC->CurrentVolOffID(1,copy);
831       //detector copy in the ladder = 1<->26  (ITS6 is inside I566)
832       vol[1] = copy;
833       id = gMC->CurrentVolOffID(2,copy);
834       //ladder copy in the layer = 1<->38 (I569)
835       vol[2] = copy;
836   } else {
837       return; // not an ITS volume?
838   } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
839 //
840   gMC->TrackPosition(position);
841   gMC->TrackMomentum(momentum);
842   hits[0]=position[0];
843   hits[1]=position[1];
844   hits[2]=position[2];
845   hits[3]=momentum[0];
846   hits[4]=momentum[1];
847   hits[5]=momentum[2];
848   hits[6]=gMC->Edep();
849   hits[7]=gMC->TrackTime();
850   // Fill hit structure with this new hit.
851   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
852   return;
853 }