]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11.cxx
Updated geometry
[u/mrichter/AliRoot.git] / ITS / AliITSv11.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2008, 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 //************************************************************************
18 //
19 //                 Inner Traking System geometry v11
20 //
21 //  Based on ROOT geometrical modeler
22 //
23 // B. Nilsen, L. Gaudichet
24 //************************************************************************
25
26
27 #include <TClonesArray.h>
28 #include <TLorentzVector.h>
29
30 #include "AliITS.h"
31 #include "AliITSDetTypeSim.h"
32 #include <TVirtualMC.h>
33
34 #include "AliITSgeom.h"
35 #include "AliITShit.h"
36
37 #include "AliITSCalibrationSDD.h"
38
39 #include "AliITSsegmentationSDD.h"
40 #include "AliITSsegmentationSPD.h"
41 #include "AliITSsegmentationSSD.h"
42 #include "AliMagF.h"
43 #include "AliRun.h"
44 #include "AliTrackReference.h"
45 #include "AliMC.h"
46
47 #include <TGeoManager.h>
48 #include <TGeoVolume.h>
49 #include <TGeoPcon.h>
50 #include "AliITSv11.h"
51 #include "AliITSv11GeometrySPD.h"
52 #include "AliITSv11GeometrySDD.h"
53 #include "AliITSv11GeometrySSD.h"
54 #include "AliITSv11GeometrySupport.h"
55
56
57
58 ClassImp(AliITSv11)
59  
60
61
62 //______________________________________________________________________
63 AliITSv11::AliITSv11() : 
64 AliITS(),
65 fGeomDetOut(kFALSE),
66 fGeomDetIn(kFALSE),
67 fByThick(kTRUE),
68 fMajorVersion(IsVersion()),
69 fMinorVersion(0),
70 fEuclidGeomDet(),
71 fRead(),
72 fWrite(),
73 fSPDgeom(),
74 fSDDgeom(0),
75 fSSDgeom(),
76 fSupgeom(),
77 fIgm(kv11)
78 {
79   //    Standard default constructor for the ITS version 11.
80
81     fIdN          = 0;
82     fIdName       = 0;
83     fIdSens       = 0;
84     Int_t i;
85     for(i=0;i<60;i++) fRead[i] = '\0';
86     for(i=0;i<60;i++) fWrite[i] = '\0';
87     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
88     strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
89 }
90
91
92 //______________________________________________________________________
93 AliITSv11::AliITSv11(const char *name, const char *title): 
94 AliITS("ITS", title),
95 fGeomDetOut(kFALSE),
96 fGeomDetIn(kFALSE),
97 fByThick(kTRUE),
98 fMajorVersion(IsVersion()),
99 fMinorVersion(0),
100 fEuclidGeomDet(),
101 fRead(),
102 fWrite(),
103 fSPDgeom(),
104 fSDDgeom(0),
105 fSSDgeom(),
106 fSupgeom(),
107 fIgm(kv11)
108 {
109   //    Standard constructor for the ITS version 11.
110
111   fSDDgeom = new AliITSv11GeometrySDD(0);
112
113   Int_t i;
114   fIdN = 6;
115   fIdName = new TString[fIdN];
116   fIdName[0] = name; // removes warning message
117   fIdName[0] = "ITS1";
118   fIdName[1] = "ITS2";
119   fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
120   fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
121   fIdName[4] = "ITS5";
122   fIdName[5] = "ITS6";
123   fIdSens    = new Int_t[fIdN];
124   for(i=0;i<fIdN;i++) fIdSens[i] = 0;
125   // not needed, fByThick set to kTRUE in in the member initialization lis
126   
127
128   fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
129   strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
130   strncpy(fRead,fEuclidGeomDet,60);
131   strncpy(fWrite,fEuclidGeomDet,60);
132   strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
133 }
134 //______________________________________________________________________
135 AliITSv11::AliITSv11(Int_t debugITS,Int_t debugSPD,Int_t debugSDD,
136                    Int_t debugSSD,Int_t debugSUP) :
137 AliITS("ITS","ITS geometry v11"),
138 fGeomDetOut(kFALSE),
139 fGeomDetIn(kFALSE),
140 fByThick(kTRUE),
141 fMajorVersion(IsVersion()),
142 fMinorVersion(0),
143 fEuclidGeomDet(),
144 fRead(),
145 fWrite(),
146 fSPDgeom(),
147 fSDDgeom(0),
148 fSSDgeom(),
149 fSupgeom(),
150 fIgm(kv11)
151 {
152   // Standard default constructor for the ITS version 11.
153
154
155   //   fSPDgeom = new AliITSv11GeometrySPD(debugSPD);
156   fSDDgeom = new AliITSv11GeometrySDD(debugSDD);
157   fSDDgeom->SetDebug(debugSDD);
158   //   fSupgeom = new AliITSv11GeometrySupport(debugSUP);
159
160   Int_t i;
161   fIdN = 6;
162   fIdName = new TString[fIdN];
163   fIdName[0] = fSPDgeom->GetSenstiveVolumeName1();
164   fIdName[1] = fSPDgeom->GetSenstiveVolumeName2();
165   fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
166   fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
167   fIdName[4] = fSSDgeom->GetSenstiveVolumeName5();
168   fIdName[5] = fSSDgeom->GetSenstiveVolumeName6();
169   fIdSens    = new Int_t[fIdN];
170   for(i=0;i<fIdN;i++) fIdSens[i] = 0;
171   fEuclidOut    = kFALSE; // Don't write Euclide file
172   
173   fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
174   strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
175   strncpy(fRead,fEuclidGeomDet,60);
176   strncpy(fWrite,fEuclidGeomDet,60);
177   strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
178
179   debugITS = (debugSPD && debugSSD && debugSUP && debugSDD); //remove temp. warnings
180 }
181 //______________________________________________________________________
182 AliITSv11::~AliITSv11() {
183   delete fSDDgeom;
184 }
185 //______________________________________________________________________
186 void AliITSv11::BuildGeometry(){
187
188 }
189 //______________________________________________________________________
190 void AliITSv11::CreateGeometry(){
191     //
192     // Create ROOT geometry
193     //
194     // These constant character strings are set by cvs during commit
195     // do not change them unless you know what you are doing!
196     const Char_t *cvsDate="$Date$";
197     const Char_t *cvsRevision="$Revision$";
198
199     TGeoManager *geoManager = gGeoManager;
200     TGeoVolume *vALIC = geoManager->GetTopVolume();
201
202     TGeoPcon *sITS = new TGeoPcon("ITS Top Volume",0.0,360.0,2);
203
204     // DefineSection(section number, Z, Rmin, Rmax).
205     const Double_t kcm = 1.0;
206     sITS->DefineSection(0,-300.0*kcm,0.01*kcm,50.0*kcm);
207     sITS->DefineSection(1,+300.0*kcm,0.01*kcm,50.0*kcm);
208
209     TGeoMedium *air = gGeoManager->GetMedium("ITS_AIR$");
210     TGeoVolume *vITS = new TGeoVolume("ITSV",sITS,air);
211     vITS->SetVisibility(kFALSE);
212     const Int_t length=100;
213     Char_t vstrng[length];
214     if(fIgm.WriteVersionString(vstrng,length,(AliITSVersion_t)IsVersion(),
215                                fMinorVersion,cvsDate,cvsRevision))
216         vITS->SetTitle(vstrng);
217     //printf("Title set to %s\n",vstrng);
218     vALIC->AddNode(vITS,1,0);
219
220 //   fSPDgeom->CenteralSPD(vITS);
221
222   fSDDgeom->Layer3(vITS);
223   fSDDgeom->Layer4(vITS);
224
225 //     fSupgeom->SPDCone(vITS);
226 //     fSupgeom->SPDThermalSheald(vITS);
227 //     fSupgeom->SDDCone(vITS);
228 //     fSupgeom->SSDCone(vITS);
229 //     fSupgeom->ServicesCableSupport(vITS);
230
231 }
232 //______________________________________________________________________
233 void AliITSv11::CreateMaterials(){
234     // Create Standard ITS Materials
235     // Inputs:
236     //  none.
237     // Outputs:
238     //  none.
239     // Return:
240     // none.
241
242     
243     //
244     fSPDgeom->AliITSv11Geometry::CreateDefaultMaterials();
245     // Detector specific material definistions
246     fSPDgeom->CreateMaterials();
247     fSDDgeom->CreateMaterials();
248     fSSDgeom->CreateMaterials();
249     fSupgeom->CreateMaterials();
250 }
251 /*
252 //______________________________________________________________________
253 void AliITSv11::InitAliITSgeom(){
254   //
255   // Fill fITSgeom with the 3 sub-detector geometries
256   //
257
258   if (gGeoManager) gGeoManager->Export("geometry.root");
259
260     const Int_t knlayers = 6;
261     const Int_t kndeep = 3;
262     const AliITSDetector kidet[knlayers]={kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
263     const TString knames[knlayers] = {
264       "AliITSv11:spd missing",  // lay=1
265       "AliITSv11:spd missing",  // lay=2
266       "/ALIC_1/ITSV_1/ITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_%d", // lay=3
267       "/ALIC_1/ITSV_1/ITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_%d", // lay=4
268       "AliITSv11:ssd missing",  // lay=5
269       "AliITSv11:ssd missing"   // lay=6
270     };
271
272     const Int_t kitsGeomTreeCopys[knlayers][kndeep]= {{10, 2, 4},// lay=1
273                                                      {10, 4, 4}, // lay=2
274                                                      {14, 6, 1}, // lay=3
275                                                      {22, 8, 1}, // lay=4
276                                                      {34,22, 1}, // lay=5
277                                                      {38,25, 1}};// lay=6
278     Int_t       nlad[knlayers],ndet[knlayers];
279     Int_t       mod,lay,lad=0,det=0,i,j,k,cp0,cp1,cp2;
280     TString path,shapeName;
281     TGeoHMatrix materix;
282     Double_t trans[3]={3*0.0},rot[10]={9*0.0,1.0};
283     TArrayD shapePar;
284     TArrayF shapeParF;
285     Bool_t shapeDefined[3]={kFALSE,kFALSE,kFALSE};
286
287     AliDebug(1,"Reading Geometry transformation directly from Modler.");
288     mod = 0;
289     for(i=0;i<knlayers;i++){
290         k = 1;
291         for(j=0;j<kndeep;j++) if(kitsGeomTreeCopys[i][j]!=0)
292             k *= TMath::Abs(kitsGeomTreeCopys[i][j]);
293         mod += k;
294     } // end for i
295
296     SetITSgeom(0);
297     nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
298     ndet[0]= 4;ndet[1]= 4;ndet[2]= 6;ndet[3]= 8;ndet[4]=22;ndet[5]=25;
299     AliITSgeom* geom = new AliITSgeom(0,6,nlad,ndet,mod);
300     SetITSgeom(geom);
301     mod = 0;
302     for(lay=1;lay<=knlayers;lay++){
303
304         for(cp0=0; cp0<kitsGeomTreeCopys[lay-1][0]; cp0++){
305             for(cp1=0; cp1<kitsGeomTreeCopys[lay-1][1]; cp1++){
306                 for(cp2=1; cp2<=kitsGeomTreeCopys[lay-1][2]; cp2++){
307
308                     path.Form(knames[lay-1].Data(),
309                               cp0,cp1,cp2);
310                     switch (lay){
311                     case 1:{
312                         det = cp2;
313                         lad = cp1+2*(cp0-1);
314                     }break;
315                     case 2:{
316                         det = cp2;
317                         lad = cp1+4*(cp0-1);
318                     } break;
319                     case 3: case 4: case 5: case 6:{
320                         det = cp1;
321                         lad = cp0;
322                     } break;
323                     } // end switch
324                          //AliInfo(Form("path=%s lay=%d lad=%d det=%d",
325                          //             path.Data(),lay,lad,det));
326                     gMC->GetTransformation(path.Data(),materix);
327                     gMC->GetShape(path.Data(),shapeName,shapePar);
328                     shapeParF.Set(shapePar.GetSize());
329                     for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
330                     geom->CreateMatrix(mod,lay,lad,det,kidet[lay-1],trans,rot);
331                     geom->SetTrans(mod,materix.GetTranslation());
332                     geom->SetRotMatrix(mod,materix.GetRotationMatrix());
333                     geom->GetGeomMatrix(mod)->SetPath(path.Data());
334                     switch (lay){
335                     case 1: case 2:
336                         if(!shapeDefined[kSPD]){
337                         geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(
338                                 shapeParF.GetSize(),shapeParF.GetArray()));
339                         shapeDefined[kSPD] = kTRUE;
340                     }break;
341                     case 3: case 4:
342                         if(!shapeDefined[kSDD]){
343                         geom->ReSetShape(kSDD,new AliITSgeomSDD256(
344                                 shapeParF.GetSize(),shapeParF.GetArray()));
345                         shapeDefined[kSDD] = kTRUE;
346                     }break;
347                     case 5: case 6:
348                         if(!shapeDefined[kSSD]){
349                         geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(
350                                 shapeParF.GetSize(),shapeParF.GetArray()));
351                         shapeDefined[kSSD] = kTRUE;
352                     }break;
353                     default:{
354                     }break;
355                     } // end switch
356                     mod++;
357                 } /// end for cp2
358             } // end for cp1
359         } // end for cp0
360     } // end for lay
361
362 //   fSDDgeom->ExportSensorGeometry(GetITSgeom(), +3, 0);  //SDD
363 }
364 */
365 //______________________________________________________________________
366 void AliITSv11::Init(){
367   //
368   //     Initialise the ITS after it has been created.
369   //
370
371   //AliInfo(Form("Minor version %d",fMinorVersion));
372     //
373     UpdateInternalGeometry();
374     AliITS::Init();
375     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
376
377     //
378 /*
379     if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
380     if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
381     if(GetITSgeom()!=0) SetITSgeom(0x0);
382     AliITSgeom* geom = new AliITSgeom();
383     SetITSgeom(geom);
384     if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
385     else this->InitAliITSgeom();
386     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
387     AliITS::Init();
388 */    //
389 }
390
391
392 //______________________________________________________________________
393 void AliITSv11::SetDefaults(){
394   //
395   // Set response and segmentation models for SPD, SDD and SSD
396   //
397
398 //     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
399 //     fDetTypeSim->SetITSgeom(GetITSgeom());
400     if(!fDetTypeSim) {
401       Warning("SetDefaults","Error fDetTypeSim not defined");
402       return;
403     }
404   
405     fDetTypeSim->ResetCalibrationArray();
406     fDetTypeSim->ResetSegmentation();
407     fDetTypeSim->SetDefaults();
408     
409     if(fgkNTYPES>3){
410         Warning("SetDefaults",
411                 "Only the four basic detector types are initialised!");
412     }// end if
413
414     
415     return;
416 }
417
418
419
420
421
422 //______________________________________________________________________
423 void AliITSv11::DrawModule() const{
424
425 }
426
427 // //______________________________________________________________________
428 // void AliITSv11::StepManager(){
429 //   //
430 //   //    Called for every step in the ITS, then calles the AliITShit class
431 //   // creator with the information to be recoreded about that hit.
432 //   //
433 //     Int_t         copy, id;
434 //     TLorentzVector position, momentum;
435 //     static TLorentzVector position0;
436 //     static Int_t stat0=0;
437
438 //     if(!(this->IsActive())){
439 //      return;
440 //     } // end if !Active volume.
441
442 //     if(!(gMC->TrackCharge())) return;
443
444 //     id=gMC->CurrentVolID(copy);
445
446 //     Bool_t sensvol = kFALSE;
447 //     for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
448 //     if(sensvol && (gMC->IsTrackExiting())){
449 //      copy = fTrackReferences->GetEntriesFast();
450 //      TClonesArray &lTR = *fTrackReferences;
451 //      // Fill TrackReference structure with this new TrackReference.
452 //      new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
453 //     } // if Outer ITS mother Volume
454
455
456 //     Int_t   copy1,copy2;  
457 //     Int_t   vol[5];
458 //     TClonesArray &lhits = *fHits;
459 //     //
460 //     // Track status
461 //     vol[3] = 0;
462 //     vol[4] = 0;
463 //     if(gMC->IsTrackInside())      vol[3] +=  1;
464 //     if(gMC->IsTrackEntering())    vol[3] +=  2;
465 //     if(gMC->IsTrackExiting())     vol[3] +=  4;
466 //     if(gMC->IsTrackOut())         vol[3] +=  8;
467 //     if(gMC->IsTrackDisappeared()) vol[3] += 16;
468 //     if(gMC->IsTrackStop())        vol[3] += 32;
469 //     if(gMC->IsTrackAlive())       vol[3] += 64;
470 //     //
471 //     // Fill hit structure.
472 //     if(!(gMC->TrackCharge())) return;
473 //     //
474 //     // Only entering charged tracks
475 //     if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
476 //      vol[0] = 1;
477 //      id = gMC->CurrentVolOffID(2,copy);
478 //      //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
479 //      vol[1] = copy;
480 //      gMC->CurrentVolOffID(3,copy1);
481 //      //ladder copy in the module   = 1<->2  (I10A < I12A)
482 //      gMC->CurrentVolOffID(4,copy2);
483 //      //module copy in the layer    = 1<->10 (I12A < IT12)
484 //      vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
485 //     } else if(id == fIdSens[1]){
486 //      vol[0] = 2;
487 //      id = gMC->CurrentVolOffID(2,copy);
488 //      //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
489 //      vol[1] = copy;
490 //      gMC->CurrentVolOffID(3,copy1);
491 //      //ladder copy in the module   = 1<->4  (I20A < I12A)
492 //      gMC->CurrentVolOffID(4,copy2);
493 //      //module copy in the layer    = 1<->10 (I12A < IT12)
494 //      vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
495 //     } else if(id == fIdSens[2]){
496 //      vol[0] = 3;
497 //      id = gMC->CurrentVolOffID(1,copy);
498 //      //detector copy in the ladder = 1<->6  (ITS3 < I302 < I004)
499 //      vol[1] = copy;
500 //      id = gMC->CurrentVolOffID(2,copy);
501 //      //ladder copy in the layer    = 1<->14 (I004 < IT34)
502 //      vol[2] = copy;
503 //     } else if(id == fIdSens[3]){
504 //      vol[0] = 4;
505 //      id = gMC->CurrentVolOffID(1,copy);
506 //      //detector copy in the ladder = 1<->8  (ITS4 < I402 < I005)
507 //      vol[1] = copy;
508 //      id = gMC->CurrentVolOffID(2,copy);
509 //      //ladder copy in the layer    = 1<->22 (I005 < IT34))
510 //      vol[2] = copy;
511 //     }else if(id == fIdSens[4]){
512 //      vol[0] = 5;
513 //      id = gMC->CurrentVolOffID(1,copy);
514 //      //detector copy in the ladder = 1<->22  (ITS5 < I562 < I565)
515 //      vol[1] = copy;
516 //      id = gMC->CurrentVolOffID(2,copy);
517 //      //ladder copy in the layer    = 1<->34 (I565 < IT56)
518 //      vol[2] = copy;
519 //     }else if(id == fIdSens[5]){
520 //      vol[0] = 6;
521 //      id = gMC->CurrentVolOffID(1,copy);
522 //      //detector copy in the ladder = 1<->25  (ITS6 < I566 < I569)
523 //      vol[1] = copy;
524 //      id = gMC->CurrentVolOffID(2,copy);
525 //      //ladder copy in the layer = 1<->38 (I569 < IT56)
526 //      vol[2] = copy;
527 //     } else {
528 //      return; // not an ITS volume?
529 //     } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
530 //     //
531 //     gMC->TrackPosition(position);
532 //     gMC->TrackMomentum(momentum);
533 //     vol[4] = stat0;
534 //     if(gMC->IsTrackEntering()){
535 //      position0 = position;
536 //      stat0 = vol[3];
537 //      return;
538 //     } // end if IsEntering
539 //     // Fill hit structure with this new hit.
540     
541 //     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
542 //                                 gMC->Edep(),gMC->TrackTime(),position,
543 //                                 position0,momentum);
544
545 //     position0 = position;
546 //     stat0 = vol[3];
547
548 //     return;
549 // }
550
551
552 //______________________________________________________________________
553 void AliITSv11::StepManager(){
554   //
555   //    Called for every step in the ITS, then calles the AliITShit class
556   // creator with the information to be recoreded about that hit.
557   //
558     Int_t         copy, id;
559     TLorentzVector position, momentum;
560     static TLorentzVector position0;
561     static Int_t stat0=0;
562
563     if(!(this->IsActive())){
564         return;
565     } // end if !Active volume.
566
567     if(!(gMC->TrackCharge())) return;
568
569     id=gMC->CurrentVolID(copy);
570
571     Bool_t sensvol = kFALSE;
572     for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
573     if(sensvol && (gMC->IsTrackExiting())){
574         AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
575     } // if Outer ITS mother Volume
576
577
578     Int_t   copy1,copy2;  
579     Int_t   vol[5];
580     TClonesArray &lhits = *fHits;
581     //
582     // Track status
583     vol[3] = 0;
584     vol[4] = 0;
585     if(gMC->IsTrackInside())      vol[3] +=  1;
586     if(gMC->IsTrackEntering())    vol[3] +=  2;
587     if(gMC->IsTrackExiting())     vol[3] +=  4;
588     if(gMC->IsTrackOut())         vol[3] +=  8;
589     if(gMC->IsTrackDisappeared()) vol[3] += 16;
590     if(gMC->IsTrackStop())        vol[3] += 32;
591     if(gMC->IsTrackAlive())       vol[3] += 64;
592     //
593     // Fill hit structure.
594     if(!(gMC->TrackCharge())) return;
595
596     // Only entering charged tracks
597     if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
598         vol[0] = 1;
599         id = gMC->CurrentVolOffID(2,copy);
600         //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
601         vol[1] = copy;
602         gMC->CurrentVolOffID(3,copy1);
603         //ladder copy in the module   = 1<->2  (I10A < I12A)
604         gMC->CurrentVolOffID(4,copy2);
605         //module copy in the layer    = 1<->10 (I12A < IT12)
606         vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
607
608     } else if(id == fIdSens[1]){
609         vol[0] = 2;
610         id = gMC->CurrentVolOffID(2,copy);
611         //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
612         vol[1] = copy;
613         gMC->CurrentVolOffID(3,copy1);
614         //ladder copy in the module   = 1<->4  (I20A < I12A)
615         gMC->CurrentVolOffID(4,copy2);
616         //module copy in the layer    = 1<->10 (I12A < IT12)
617         vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
618
619     } else if(id == fIdSens[2]){
620         vol[0] = 3;
621         id = gMC->CurrentVolOffID(1,copy);
622         //detector copy in the ladder = 1<->6  (ITS3 < I302 < I004)
623         vol[1] = copy;
624         id = gMC->CurrentVolOffID(2,copy);
625         //ladder copy in the layer    = 1<->14 (I004 < IT34)
626         vol[2] = copy;
627
628     } else if(id == fIdSens[3]){
629         vol[0] = 4;
630         id = gMC->CurrentVolOffID(1,copy);
631         //detector copy in the ladder = 1<->8  (ITS4 < I402 < I005)
632         vol[1] = copy;
633         id = gMC->CurrentVolOffID(2,copy);
634         //ladder copy in the layer    = 1<->22 (I005 < IT34))
635         vol[2] = copy;
636
637     }else if(id == fIdSens[4]){
638         vol[0] = 5;
639         id = gMC->CurrentVolOffID(1,copy);
640         //detector copy in the ladder = 1<->22  (ITS5 < I562 < I565)
641         vol[1] = copy;
642         id = gMC->CurrentVolOffID(2,copy);
643         //ladder copy in the layer    = 1<->34 (I565 < IT56)
644         vol[2] = copy;
645
646     }else if(id == fIdSens[5]){
647         vol[0] = 6;
648         id = gMC->CurrentVolOffID(1,copy);
649         //detector copy in the ladder = 1<->25  (ITS6 < I566 < I569)
650         vol[1] = copy;
651         id = gMC->CurrentVolOffID(2,copy);
652         //ladder copy in the layer = 1<->38 (I569 < IT56)
653         vol[2] = copy;
654     } else {
655         return; // not an ITS volume?
656     } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
657     //
658     gMC->TrackPosition(position);
659     gMC->TrackMomentum(momentum);
660     vol[4] = stat0;
661     if(gMC->IsTrackEntering()){
662         position0 = position;
663         stat0 = vol[3];
664         return;
665     } // end if IsEntering
666     // Fill hit structure with this new hit.
667     
668     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
669                                    gMC->Edep(),gMC->TrackTime(),position,
670                                    position0,momentum);
671
672     position0 = position;
673     stat0 = vol[3];
674
675     return;
676 }
677