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