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