]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv5.cxx
Updated for new ITS code.
[u/mrichter/AliRoot.git] / ITS / AliITSv5.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.4.9  2000/06/12 19:14:51  barbera
19 Remove partical transision to new Config.C calling convension. Bug Found.
20
21 Revision 1.14.4.8  2000/06/12 18:15:52  barbera
22 fixed posible compilation errors on HP unix. Modifided default constructor
23 for use with new calling requirements.
24
25 Revision 1.14.4.7  2000/06/11 20:37:59  barbera
26 coding convenstion update.
27
28 Revision 1.14.4.4  2000/05/19 10:10:21  nilsen
29 fix for bug with HP and Sun unix + fix for event display in ITS-working branch
30
31 Revision 1.14.4.3  2000/03/04 23:46:38  nilsen
32 Fixed up the comments/documentation.
33
34 Revision 1.14.4.2  2000/03/02 21:53:02  nilsen
35 To make it compatable with the changes in AliRun/AliModule.
36
37 Revision 1.14.4.1  2000/01/12 19:03:33  nilsen
38 This is the version of the files after the merging done in December 1999.
39 See the ReadMe110100.txt file for details
40
41 Revision 1.14  1999/10/22 08:16:49  fca
42 Correct destructors, thanks to I.Hrivnacova
43
44 Revision 1.13  1999/10/06 10:15:19  fca
45 Correct bug in allocation of layer name and add destructor
46
47 Revision 1.12  1999/10/05 08:05:09  fca
48 Minor corrections for uninitialised variables.
49
50 Revision 1.11  1999/09/29 09:24:20  fca
51 Introduction of the Copyright and cvs Log
52
53 */
54
55 ///////////////////////////////////////////////////////////////////////////////
56 //
57 //  Inner Traking System version 5
58 //  This class contains the base procedures for the Inner Tracking System
59 //
60 // Authors: R. Barbera, B. S. Nilsen.
61 // version 5.
62 // Created September 17 1999.
63 //
64 ///////////////////////////////////////////////////////////////////////////////
65
66 // See AliITSv5::StepManager().
67 #define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
68 //#define ALIITSPRINTGEOM 1 // print out geometry information
69
70 #include <stdio.h>
71 #include <stdlib.h>
72 #include <TMath.h>
73 #include <TGeometry.h>
74 #include <TNode.h>
75 #include <TTUBE.h>
76 #include <TFile.h>    // only required for Tracking function?
77 #include <TCanvas.h>
78 #include <TObjArray.h>
79 #include <TClonesArray.h>
80
81 #include "AliRun.h"
82 #include "TSystem.h"
83 #if ALIITSPRINTGEOM==1
84 #include "../TGeant3/TGeant3.h"
85 #endif
86 #include "AliITShit.h"
87 #include "AliITS.h"
88 #include "AliITSv5.h"
89 #include "AliITSgeom.h"
90
91 ClassImp(AliITSv5)
92  
93 //_____________________________________________________________________________
94   AliITSv5::AliITSv5()/*:AliITS("ITS","TDR version")*/{
95 ////////////////////////////////////////////////////////////////////////
96 //    Standard default constructor for the ITS version 5.
97 ////////////////////////////////////////////////////////////////////////
98     fId5N = 6;
99     fId5Name = new char*[fId5N];
100     fId5Name[0] = "ITS1";
101     fId5Name[1] = "ITS2";
102     fId5Name[2] = "ITS3";
103     fId5Name[3] = "ITS4";
104     fId5Name[4] = "ITS5";
105     fId5Name[5] = "ITS6";
106
107     fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
108     fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
109     printf("Created ITS TDR Detailed version reading geometry from file\n");
110 }
111 //____________________________________________________________________________
112 AliITSv5::AliITSv5(const AliITSv5 &source){
113 ////////////////////////////////////////////////////////////////////////
114 //     Copy Constructor for ITS version 5.
115 ////////////////////////////////////////////////////////////////////////
116     if(&source == this) return;
117     this->fId5N = source.fId5N;
118     this->fId5Name = new char*[fId5N];
119     Int_t i;
120     for(i=0;i<6;i++) strcpy(this->fId5Name[i],source.fId5Name[i]);
121     return;
122 }
123 //_____________________________________________________________________________
124 AliITSv5& AliITSv5::operator=(const AliITSv5 &source){
125 ////////////////////////////////////////////////////////////////////////
126 //    Assignment operator for the ITS version 1.
127 ////////////////////////////////////////////////////////////////////////
128   if(&source == this) return *this;
129   this->fId5N = source.fId5N;
130   this->fId5Name = new char*[fId5N];
131   Int_t i;
132   for(i=0;i<6;i++) strcpy(this->fId5Name[i],source.fId5Name[i]);
133   return *this;
134 }
135 //_____________________________________________________________________________
136 AliITSv5::~AliITSv5() {
137 ////////////////////////////////////////////////////////////////////////
138 //    Standard destructor for the ITS version 5.
139 ////////////////////////////////////////////////////////////////////////
140   delete [] fId5Name;
141 }
142 //_____________________________________________________________________________
143 AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
144 ////////////////////////////////////////////////////////////////////////
145 //    Standard constructor for the ITS version 5.
146 ////////////////////////////////////////////////////////////////////////
147     fId5N = 6;
148     fId5Name = new char*[fId5N];
149     fId5Name[0] = "ITS1";
150     fId5Name[1] = "ITS2";
151     fId5Name[2] = "ITS3";
152     fId5Name[3] = "ITS4";
153     fId5Name[4] = "ITS5";
154     fId5Name[5] = "ITS6";
155
156     fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
157     fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
158     printf("Created ITS TDR Detailed version reading geometry from file\n");
159 }
160 //_____________________________________________________________________________
161 void AliITSv5::BuildGeometry(){
162 ////////////////////////////////////////////////////////////////////////
163 //    Geometry builder for the ITS version 5.
164 ////////////////////////////////////////////////////////////////////////
165   //
166   // Build ITS TNODE geometry for event display using detailed geometry.
167   // This function builds a simple ITS geometry used by the ROOT macro
168   // ITSdisplay.C.
169
170   TNode *top;
171   TNode *nd;
172   //const Int_t kColorITSSPD=kRed;
173   //const Int_t kColorITSSDD=kGreen;
174   const Int_t kColorITSSSD=kBlue;
175   //
176   top=gAlice->GetGeometry()->GetNode("alice");
177   AliITSgeom  *gm = this->GetITSgeom();
178
179   Int_t       lay,lad,det,i;
180   Text_t      name[10];
181   Float_t     xg[3];
182   Float_t     rt[9];
183   Double_t    rtd[9];
184   TBRIK       *box;
185   TRotMatrix  *rm;
186   //TCanvas     *c1 = new TCanvas("c1","ITS");
187
188   for(lay=1;lay<=2;lay++)
189    for(lad=1;lad<=gm->GetNladders(lay);lad++)
190     for(det=1;det<=gm->GetNdetectors(lay);det++){
191           try {
192               box  = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
193                                     0.64,0.0075,4.19); 
194           } catch (...) {
195               cout << "EXCEPTION in box = new TBRIK" << endl;
196               return;
197           }
198           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
199           gm->GetRotMatrix(lay,lad,det,rt);
200           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
201           for(i=0;i<9;i++) rtd[i] = rt[i];
202           try {
203                 rm  = new TRotMatrix(name,name,rtd);
204           } catch (...) {
205                 cout << "EXCEPTION in   new TRotMatrix" << endl;
206                 return;
207           }
208          top->cd();
209           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
210          try {
211               nd  = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
212          } catch (...) {
213               cout << "EXCEPTION in new TNode" << endl;
214               return;
215          }
216          nd->SetLineColor(kColorITSSSD);
217          fNodes->Add(nd);
218     }
219
220   for(lay=3;lay<=3;lay++)
221    for(lad=1;lad<=gm->GetNladders(lay);lad++)
222     for(det=1;det<=gm->GetNdetectors(lay);det++){
223           try {
224               box  = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
225                                     3.5,0.014,3.763); 
226           } catch (...) {
227               cout << "EXCEPTION in box = new TBRIK" << endl;
228               return;
229           }
230           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
231           gm->GetRotMatrix(lay,lad,det,rt);
232           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
233           for(i=0;i<9;i++) rtd[i] = rt[i];
234           try {
235                 rm  = new TRotMatrix(name,name,rtd);
236           } catch (...) {
237                 cout << "EXCEPTION in   new TRotMatrix" << endl;
238                 return;
239           }
240          top->cd();
241           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
242          try {
243               nd  = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
244          } catch (...) {
245               cout << "EXCEPTION in new TNode" << endl;
246               return;
247          }
248          nd->SetLineColor(kColorITSSSD);
249          fNodes->Add(nd);
250     }
251
252   for(lay=4;lay<=4;lay++)
253    for(lad=1;lad<=gm->GetNladders(lay);lad++)
254     for(det=1;det<=gm->GetNdetectors(lay);det++){
255           try {
256               box  = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
257                                     3.5,0.014,3.763); 
258           } catch (...) {
259               cout << "EXCEPTION in box = new TBRIK" << endl;
260               return;
261           }
262           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
263           gm->GetRotMatrix(lay,lad,det,rt);
264           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
265           for(i=0;i<9;i++) rtd[i] = rt[i];
266           try {
267                 rm  = new TRotMatrix(name,name,rtd);
268           } catch (...) {
269                 cout << "EXCEPTION in   new TRotMatrix" << endl;
270                 return;
271           }
272          top->cd();
273           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
274          try {
275               nd  = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
276          } catch (...) {
277               cout << "EXCEPTION in new TNode" << endl;
278               return;
279          }
280          nd->SetLineColor(kColorITSSSD);
281          fNodes->Add(nd);
282     }
283  for(lay=5;lay<=5;lay++)
284    for(lad=1;lad<=gm->GetNladders(lay);lad++)
285     for(det=1;det<=gm->GetNdetectors(lay);det++){
286           try {
287               box  = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
288                                     3.65,0.015,2.0); 
289           } catch (...) {
290               cout << "EXCEPTION in box = new TBRIK" << endl;
291               return;
292           }
293           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
294           gm->GetRotMatrix(lay,lad,det,rt);
295           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
296           for(i=0;i<9;i++) rtd[i] = rt[i];
297           try {
298                 rm  = new TRotMatrix(name,name,rtd);
299           } catch (...) {
300                 cout << "EXCEPTION in   new TRotMatrix" << endl;
301                 return;
302           }
303          top->cd();
304           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
305          try {
306               nd  = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
307          } catch (...) {
308               cout << "EXCEPTION in new TNode" << endl;
309               return;
310          }
311          nd->SetLineColor(kColorITSSSD);
312          fNodes->Add(nd);
313     }
314
315  for(lay=6;lay<=6;lay++)
316    for(lad=1;lad<=gm->GetNladders(lay);lad++)
317     for(det=1;det<=gm->GetNdetectors(lay);det++){
318           try {
319               box  = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
320                                     3.65,0.015,2.0); 
321           } catch (...) {
322               cout << "EXCEPTION in box = new TBRIK" << endl;
323               return;
324           }
325
326           gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]); 
327           gm->GetRotMatrix(lay,lad,det,rt);
328           //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
329           for(i=0;i<9;i++) rtd[i] = rt[i];
330           try {
331                 rm  = new TRotMatrix(name,name,rtd);
332           } catch (...) {
333                 cout << "EXCEPTION in   new TRotMatrix" << endl;
334                 return;
335           }
336          top->cd();
337           //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det); 
338          try {
339               nd  = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
340          } catch (...) {
341               cout << "EXCEPTION in new TNode" << endl;
342               return;
343          }
344          nd->SetLineColor(kColorITSSSD);
345          fNodes->Add(nd);
346     }
347
348
349
350 //_____________________________________________________________________________
351 void AliITSv5::CreateMaterials(){
352 ////////////////////////////////////////////////////////////////////////
353 //     Read a file containing the materials for the ITS version 5.
354 ////////////////////////////////////////////////////////////////////////
355     char *filtmp;
356
357   filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
358
359   FILE *file = fopen(filtmp,"r");
360   if(file) {
361     fclose(file);
362     ReadEuclidMedia(filtmp);
363   } else {
364     Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
365     exit(1);
366   } // end if(file)
367 }
368 //_____________________________________________________________________________
369 void AliITSv5::CreateGeometry(){
370 //////////////////////////////////////////////////////////////////////
371 //    This is the geometry used for the ITS Pre-TDR and comes from an 
372 // Euclid to Geant conversion. The only difference
373 // is in the details of the ITS supports. The detectors elements, 
374 // detector numbering, and local and global reference frames are shown in
375 //  the following figures.
376 //Begin_Html
377 /*
378 <img src="picts/ITS/its1+2_convention_front_5.gif">
379 </pre>
380 <br clear=left>
381 <font size=+2 color=red>
382 <p>This shows the front view of the SPDs.
383 </font>
384 <pre>
385 <img src="picts/ITS/its1+2_convention_side_5.gif">
386 </pre>
387 <br clear=left>
388 <font size=+2 color=red>
389 <p>This shows the perspective view of the SPDs.
390 </font>
391 <img src="picts/ITS/its1+2_tree.gif">
392 </pre>
393 <br clear=left>
394 <font size=+2 color=red>
395 <p>This shows the geometry Tree for the SPDs.
396 </font>
397 <pre>
398
399 <pre>
400 <img src="picts/ITS/its3+4_convention_front_5.gif">
401 </pre>
402 <br clear=left>
403 <font size=+2 color=red>
404 <p>This shows the front view of the SDDs.
405 </font>
406 <pre>
407 <img src="picts/ITS/its3+4_convention_side_5.gif">
408 </pre>
409 <br clear=left>
410 <font size=+2 color=red>
411 <p>This shows the perspective view of the SDDs.
412 </font>
413 <img src="picts/ITS/its3+4_tree.gif">
414 </pre>
415 <br clear=left>
416 <font size=+2 color=red>
417 <p>This shows the geometry Tree for the SDDs.
418 </font>
419 <pre>
420
421 <pre>
422 <img src="picts/ITS/its5+6_convention_front_5.gif">
423 </pre>
424 <br clear=left>
425 <font size=+2 color=red>
426 <p>This shows the front view of the SSDs.
427 </font>
428 <pre>
429 <img src="picts/ITS/its5+6_convention_side_5.gif">
430 </pre>
431 <br clear=left>
432 <font size=+2 color=red>
433 <p>This shows the perspective view of the SSDs.
434 </font>
435 <pre>
436 <img src="picts/ITS/its5+6_tree.gif">
437 </pre>
438 <br clear=left>
439 <font size=+2 color=red>
440 <p>This shows the geometry Tree for the SSDs.
441 </font>
442 <pre>
443
444
445 <img src="picts/ITS/its_layer1-6_2.gif">
446 </pre>
447 <br clear=left>
448 <font size=+2 color=red>
449 <p>This shows the front view of the whole ITS..
450 </font>
451 <pre>
452
453 <img src="picts/ITS/its_layer1-6_1.gif">
454 </pre>
455 <br clear=left>
456 <font size=+2 color=red>
457 <p>This shows the perspective view of the whole ITS..
458 </font>
459 <pre>
460
461 <img src="picts/ITS/its1-6_tree.gif">
462 </pre>
463 <br clear=left>
464 <font size=+2 color=red>
465 <p>This shows the geometry Tree for the whole ITS.
466 </font>
467 <pre>
468 */
469 //End_Html
470 //
471 //
472 //      Here are shown the details of the ITS support cones and services.
473 // First is a GEANT tree showing the organization of all of the volumes
474 // that make up the ITS supports and services.
475 //Begin_Html
476 /*
477 <img src="picts/ITS/supports_tree.gif">
478  */
479 //End_Html
480 //     What follows are a number of figures showing what these support
481 // structures look like.
482 //Begin_Html
483 /*
484
485 <img src="picts/ITS/supports_3.gif">
486 </pre>
487 <br clear=left>
488 <font size=+2 color=red>
489 <p>This shows the geometry of the supports for the Drift and Strip layers only.
490 </font>
491 <pre>
492
493 <img src="picts/ITS/supports_2.gif">
494 </pre>
495 <br clear=left>
496 <font size=+2 color=red>
497 <p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
498 </font>
499 <pre>
500
501 <img src="picts/ITS/supports_1.gif">
502 </pre>
503 <br clear=left>
504 <font size=+2 color=red>
505 <p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
506 </font>
507 <pre>
508
509 <img src="picts/ITS/suppssd.gif">
510 </pre>
511 <br clear=left>
512 <font size=+2 color=red>
513 <p>This shows the geometry for the Strip layers supports.
514 </font>
515 <pre>
516
517 <img src="picts/ITS/suppsdd.gif">
518 </pre>
519 <br clear=left>
520 <font size=+2 color=red>
521 <p>This shows the geometry for the Drift layers supports.
522 </font>
523 <pre>
524  */
525 //End_Html
526 //
527 //    Read a file containing the geometry for the ITS version 5.
528 ////////////////////////////////////////////////////////////////////////
529
530     Int_t size;
531     char topvol[5];
532     char *filtmp;
533
534   filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
535   FILE *file = fopen(filtmp,"r");
536   delete [] filtmp;
537   if(file) {
538     fclose(file);
539     printf("Ready to read Euclid geometry file\n");
540     ReadEuclid(fEuclidGeometry.Data(),topvol);
541     printf("Read in euclid geometries\n");
542   } else {
543     Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
544           fEuclidGeometry.Data());
545     exit(1);
546   } // end if(file)
547   //
548   // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
549   // invisible
550   //
551   gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
552   //
553   // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
554   
555     if (fEuclidOut) {
556       gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
557     } // end if (fEuclidOut)
558
559     // read in the file containing the transformations for the active
560     // volumes for the ITS version 5. This is expected to be in a file
561     // ending in .det. This geometry is kept in the AliITSgeom class.
562     filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
563     size = strlen(filtmp);
564     if(size>4){
565         filtmp[size-3] = 'd'; // change from .euc to .det
566         filtmp[size-2] = 'e';
567         filtmp[size-1] = 't';
568         file = fopen(filtmp,"r");
569         if(file){ // if file exists use it to fill AliITSgeom structure.
570             fclose(file);
571             printf("ready to read .det file %s\n",filtmp);
572             fITSgeom = new AliITSgeom(filtmp);
573         }else{
574             fITSgeom = 0;
575             // fill AliITSgeom structure from geant structure just filled above
576         }// end if(file)
577         delete [] filtmp;
578     }// end if(size>4)
579     printf("finished with euclid geometrys\n");
580 }
581 //_____________________________________________________________________________
582 void AliITSv5::Init(){
583 ////////////////////////////////////////////////////////////////////////
584 //     Initialise the ITS after it has been created.
585 ////////////////////////////////////////////////////////////////////////
586     Int_t i,j,l;
587
588     fIdN    = fId5N;
589     fIdName = new char*[fId5N];
590     fIdSens = new Int_t[fId5N];
591     for(i=0;i<fId5N;i++) {
592         l = strlen(fId5Name[i]);
593         fIdName[i] = new char[l+1];
594         for(j=0;j<l;j++) fIdName[i][j] = fId5Name[i][j];
595         fIdName[i][l] = '\0'; // Null terminate this string.
596     } // end for i
597
598     AliITS::Init();
599     fMajorVersion = 5;
600     fMinorVersion = 0;
601
602 //_____________________________________________________________________________
603 void AliITSv5::StepManager(){
604 ////////////////////////////////////////////////////////////////////////
605 //    Called for every step in the ITS, then calles the AliITShit class
606 // creator with the information to be recoreded about that hit.
607 //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
608 // printing of information to a file which can be used to create a .det
609 // file read in by the routine CreateGeometry(). If set to 0 or any other
610 // value except 1, the default behavior, then no such file is created nor
611 // it the extra variables and the like used in the printing allocated.
612 ////////////////////////////////////////////////////////////////////////
613   Int_t          copy, id;
614   Int_t          copy1,copy2;
615   Float_t        hits[8];
616   Int_t          vol[4];
617   TLorentzVector position, momentum;
618   TClonesArray   &lhits = *fHits;
619 #if ALIITSPRINTGEOM==1
620   FILE          *fp;
621   Int_t         i;
622   Float_t       xl[3],xt[3],angl[6];
623 //  Float_t       par[20],att[20];
624   Float_t      mat[9];
625   static Bool_t first=kTRUE,printit[6][50][50];
626   if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
627       for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
628   first = kFALSE;
629   }
630   // end if first
631 #endif
632   //
633   // Track status
634   vol[3] = 0;
635   if(gMC->IsTrackInside())      vol[3] +=  1;
636   if(gMC->IsTrackEntering())    vol[3] +=  2;
637   if(gMC->IsTrackExiting())     vol[3] +=  4;
638   if(gMC->IsTrackOut())         vol[3] +=  8;
639   if(gMC->IsTrackDisappeared()) vol[3] += 16;
640   if(gMC->IsTrackStop())        vol[3] += 32;
641   if(gMC->IsTrackAlive())       vol[3] += 64;
642   //
643   // Fill hit structure.
644   if(!(gMC->TrackCharge())) return;
645   //
646   // Only entering charged tracks
647   if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
648       vol[0] = 1;
649       id = gMC->CurrentVolOffID(0,copy);
650       //detector copy in the ladder = 1<->4  (ITS1)
651       vol[1] = copy;
652       gMC->CurrentVolOffID(1,copy1);
653       //ladder copy in the module   = 1<->2  (I186)
654       gMC->CurrentVolOffID(2,copy2);
655       //module copy in the layer    = 1<->10 (I132)
656       vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
657   } else if(id == fIdSens[1]){
658       vol[0] = 2;
659       id = gMC->CurrentVolOffID(0,copy);
660       //detector copy in the ladder = 1<->4  (ITS2)
661       vol[1] = copy;
662       gMC->CurrentVolOffID(1,copy1);
663       //ladder copy in the module   = 1<->4  (I131)
664       gMC->CurrentVolOffID(2,copy2);
665       //module copy in the layer    = 1<->10 (I132)
666       vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
667   } else if(id == fIdSens[2]){
668       vol[0] = 3;
669       id = gMC->CurrentVolOffID(1,copy);
670       //detector copy in the ladder = 1<->5  (ITS3 is inside I314)
671       vol[1] = copy;
672       id = gMC->CurrentVolOffID(2,copy);
673       //ladder copy in the layer    = 1<->12 (I316)
674       vol[2] = copy;
675   } else if(id == fIdSens[3]){
676       vol[0] = 4;
677       id = gMC->CurrentVolOffID(1,copy);
678       //detector copy in the ladder = 1<->8  (ITS4 is inside I414)
679       vol[1] = copy;
680       id = gMC->CurrentVolOffID(2,copy);
681       //ladder copy in the layer    = 1<->22 (I417)
682       vol[2] = copy;
683   }else if(id == fIdSens[4]){
684       vol[0] = 5;
685       id = gMC->CurrentVolOffID(1,copy);
686       //detector copy in the ladder = 1<->23  (ITS5 is inside I562)
687       vol[1] = copy;
688       id = gMC->CurrentVolOffID(2,copy);
689      //ladder copy in the layer    = 1<->34 (I565)
690       vol[2] = copy;
691   }else if(id == fIdSens[5]){
692       vol[0] = 6;
693       id = gMC->CurrentVolOffID(1,copy);
694       //detector copy in the ladder = 1<->26  (ITS6 is inside I566)
695       vol[1] = copy;
696       id = gMC->CurrentVolOffID(2,copy);
697       //ladder copy in the layer = 1<->38 (I569)
698       vol[2] = copy;
699   } else {
700       return; // not an ITS volume?
701   } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
702 //
703   gMC->TrackPosition(position);
704   gMC->TrackMomentum(momentum);
705   hits[0]=position[0];
706   hits[1]=position[1];
707   hits[2]=position[2];
708   hits[3]=momentum[0];
709   hits[4]=momentum[1];
710   hits[5]=momentum[2];
711   hits[6]=gMC->Edep();
712   hits[7]=gMC->TrackTime();
713   // Fill hit structure with this new hit.
714   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
715 #if ALIITSPRINTGEOM==1
716   if(printit[vol[0]][vol[2]][vol[1]]){
717       printit[vol[0]][vol[2]][vol[1]] = kFALSE;
718       xl[0] = xl[1] = xl[2] = 0.0;
719       gMC->Gdtom(xl,xt,1);
720       for(i=0;i<9;i++) mat[i] = 0.0;
721       mat[0] = mat[4] = mat[8] = 1.0;  // default with identity matrix
722       xl[0] = 1.0;
723       xl[1] = xl[2] =0.0;
724       gMC->Gdtom(xl,&(mat[0]),2);
725       xl[1] = 1.0;
726       xl[0] = xl[2] =0.0;
727       gMC->Gdtom(xl,&(mat[3]),2);
728       xl[2] = 1.0;
729       xl[1] = xl[0] =0.0;
730       gMC->Gdtom(xl,&(mat[6]),2);
731
732       angl[0] = TMath::ACos(mat[2]);
733       if(mat[2]==1.0) angl[0] = 0.0;
734       angl[1] = TMath::ATan2(mat[1],mat[0]);
735       if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
736
737       angl[2] = TMath::ACos(mat[5]);
738       if(mat[5]==1.0) angl[2] = 0.0;
739       angl[3] = TMath::ATan2(mat[4],mat[3]);
740       if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
741
742       angl[4] = TMath::ACos(mat[8]);
743       if(mat[8]==1.0) angl[4] = 0.0;
744       angl[5] = TMath::ATan2(mat[7],mat[6]);
745       if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
746
747       for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
748       fp = fopen("ITSgeometry_v5.det","a");
749       fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
750               vol[0],vol[2],vol[1], // layer ladder detector
751               xt[0],xt[1],xt[2],    // Translation vector
752               angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
753                                                            // angles (degrees)
754               );
755       fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
756              mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
757           );  // Adding the rotation matrix.
758       fprintf(fp,"\n");
759       fclose(fp);
760   } // end if printit[layer][ladder][detector]
761 #endif
762   return;
763 }
764 //____________________________________________________________________________
765 void AliITSv5::Streamer(TBuffer &R__b){
766 ////////////////////////////////////////////////////////////////////////
767 //    A dummy Streamer function for this class AliITSv5. By default it
768 // only streams the AliITS class as it is required. Since this class
769 // dosen't contain any "real" data to be saved, it doesn't.
770 ////////////////////////////////////////////////////////////////////////
771
772   //    printf("AliITSv5Streamer Starting\n");
773    if (R__b.IsReading()) {
774       Version_t R__v = R__b.ReadVersion(); 
775       if (R__v==1) {
776           AliITS::Streamer(R__b);
777           // This information does not need to be read. It is "hard wired"
778           // into this class via its creators.
779           //R__b >> fId5N;
780           //R__b.ReadArray(fId5Name);
781       }else{
782       } // end if R__v==1
783    } else {
784       R__b.WriteVersion(AliITSv5::IsA());
785       AliITS::Streamer(R__b);
786       // This information does not need to be saved. It is "hard wired"
787       // into this class via its creators.
788       //R__b << fId5N;
789       //R__b.WriteArray(fId5Name, __COUNTER__);
790    } // end if R__b.IsReading()
791    //    printf("AliITSv5Streamer Finishing\n");
792 }
793