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