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