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