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