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