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