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