]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUv11.cxx
- Some trigger informations were not properly recovered from ESD
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUv11.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, 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 /* $Id: AliITSUv11.cxx */
18
19
20 //========================================================================
21 //
22 //        Geometry for the Upgrade of the Inner Tracking System
23 //
24 // Mario Sitta (sitta@to.infn.it)
25 //
26 //========================================================================
27
28
29
30 // $Log: AliITSUv11.cxx,v $
31
32 #include <TClonesArray.h>
33 #include <TGeoGlobalMagField.h>
34 #include <TGeoManager.h>
35 #include <TGeoMatrix.h>
36 #include <TGeoPhysicalNode.h>
37 #include <TGeoVolume.h>
38 #include <TGeoXtru.h>
39 #include <TLorentzVector.h>
40 #include <TString.h>
41 #include <TVirtualMC.h>
42
43 #include "AliITSU.h"
44 #include "AliITSUHit.h"
45 #include "AliLog.h"
46 #include "AliMC.h"
47 #include "AliMagF.h"
48 #include "AliRun.h"
49 #include "AliTrackReference.h"
50 #include "AliITSv11Geometry.h"
51 #include "AliITSUv11Layer.h"
52 #include "AliITSUv11.h"
53 #include "AliITSUGeomTGeo.h"
54 #include "AliGeomManager.h"
55
56
57 ClassImp(AliITSUv11)
58
59 //______________________________________________________________________
60 AliITSUv11::AliITSUv11()
61 :  fLayTurbo(0)
62   ,fLayRadii(0)
63   ,fLayZLength(0)
64   ,fLaddPerLay(0)
65   ,fModPerLadd(0)
66   ,fLadThick(0)
67   ,fLadWidth(0)
68   ,fLadTilt(0)
69   ,fDetThick(0)
70   ,fDetTypeID(0)
71   ,fUpGeom(0)
72 {
73   //    Standard default constructor
74   // Inputs:
75   //   none.
76   // Outputs:
77   //   none.
78   // Return:
79   //   none.
80 }
81
82 //______________________________________________________________________
83 AliITSUv11::AliITSUv11(const char *title,const Int_t nlay)
84   :AliITSU(title,nlay)
85   ,fLayTurbo(0)
86   ,fLayRadii(0)
87   ,fLayZLength(0)
88   ,fLaddPerLay(0)
89   ,fModPerLadd(0)
90   ,fLadThick(0)
91   ,fLadWidth(0)
92   ,fLadTilt(0)
93   ,fDetThick(0)
94   ,fDetTypeID(0)
95   ,fUpGeom(0)
96 {
97   //    Standard constructor for the Upgrade geometry.
98   // Inputs:
99   //   const char * name   Ignored, set to "ITS"
100   //   const char * title  Arbitrary title
101   //   const Int_t nlay    Number of layers
102   //
103   fLayerName = new TString[fNLayers];
104   //
105   for (Int_t j=0; j<fNLayers; j++) fLayerName[j].Form("%s%d",AliITSUGeomTGeo::GetITSSensorPattern(),j); // See AliITSUv11Layer
106   //
107   fLayTurbo   = new Bool_t[fNLayers];
108   fLayRadii   = new Double_t[fNLayers];
109   fLayZLength = new Double_t[fNLayers];
110   fLaddPerLay = new Int_t[fNLayers];
111   fModPerLadd = new Int_t[fNLayers];
112   fLadThick   = new Double_t[fNLayers];
113   fLadWidth   = new Double_t[fNLayers];
114   fLadTilt    = new Double_t[fNLayers];
115   fDetThick   = new Double_t[fNLayers];
116   fDetTypeID  = new UInt_t[fNLayers];
117
118   fUpGeom = new AliITSUv11Layer*[fNLayers];
119   
120   if (fNLayers > 0) { // if not, we'll Fatal-ize in CreateGeometry
121     for (Int_t j=0; j<fNLayers; j++) {
122       fLayRadii[j] = 0.;
123       fLayZLength[j] = 0.;
124       fLaddPerLay[j] = 0;
125       fModPerLadd[j] = 0;
126       fLadWidth[j] = 0.;
127       fDetThick[j] = 0.;
128       fDetTypeID[j] = 0.;
129       fUpGeom[j] = 0;
130     }
131   }
132 }
133
134 //______________________________________________________________________
135 AliITSUv11::~AliITSUv11() {
136   //    Standard destructor
137   // Inputs:
138   //   none.
139   // Outputs:
140   //   none.
141   // Return:
142   //   none.
143   delete [] fLayTurbo;
144   delete [] fLayRadii;
145   delete [] fLayZLength;
146   delete [] fLaddPerLay;
147   delete [] fModPerLadd;
148   delete [] fLadThick;
149   delete [] fLadWidth;
150   delete [] fLadTilt;
151   delete [] fDetThick;
152   delete [] fDetTypeID;
153   delete [] fUpGeom;
154
155 }
156
157 //______________________________________________________________________
158 void AliITSUv11::SetT2Lmatrix(Int_t uid, Double_t yShift, 
159                                   Bool_t yFlip, Bool_t yRot180) const {
160
161   //
162   // Creates the TGeo Local to Tracking transformation matrix
163   // and sends it to the corresponding TGeoPNEntry 
164   //
165   // This function is used in AddAlignableVolumes()
166
167   TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(uid);
168   TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
169
170   Double_t *gtrans = globMatrix->GetTranslation(), rotMatrix[9];
171   memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
172   Double_t al = TMath::ATan2(rotMatrix[1],rotMatrix[0]);
173   if (yRot180) {
174     al = TMath::ATan2(rotMatrix[1],-rotMatrix[0]);
175   }
176   Double_t xShift = gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al);
177   Double_t zShift = -gtrans[2];
178
179   TGeoHMatrix *matLtoT = new TGeoHMatrix;
180   matLtoT->SetDx( xShift ); // translation
181   matLtoT->SetDy( yShift );
182   matLtoT->SetDz( zShift );
183   rotMatrix[0]= 0;  rotMatrix[1]= 1;  rotMatrix[2]= 0; // + rotation
184   rotMatrix[3]= 1;  rotMatrix[4]= 0;  rotMatrix[5]= 0;
185   rotMatrix[6]= 0;  rotMatrix[7]= 0;  rotMatrix[8]=-1;
186   if (yFlip) rotMatrix[3] = -1;  // flipping in y  (for SPD1)
187   if (yFlip) rotMatrix[1] = -1;  // flipping in y  (for SPD1)
188
189   if (yRot180) { // rotation of pi around the axis perpendicular to the wafer
190     if (yFlip) matLtoT->SetDx( -xShift ); // flipping in y  (for SPD1)
191     matLtoT->SetDy( -yShift );
192     matLtoT->SetDz( -zShift );
193     rotMatrix[8]=1;
194     rotMatrix[3] = -1;
195     if (yFlip) rotMatrix[3] = 1;  // flipping in y  (for SPD1)
196   }
197
198   TGeoRotation rot;
199   rot.SetMatrix(rotMatrix);
200   matLtoT->MultiplyLeft(&rot);
201   TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
202   delete matLtoT;
203   alignableEntry->SetMatrix(matTtoL);
204 }
205
206 //______________________________________________________________________
207 void AliITSUv11::AddAlignableVolumes() const{
208   // Creates entries for alignable volumes associating the symbolic volume
209   // name with the corresponding volume path.
210   // 
211   // Records in the alignable entries the transformation matrices converting
212   // TGeo local coordinates (in the RS of alignable volumes) to the tracking
213   // system
214   // For this, this function has to run before the misalignment because we
215   // are using the ideal positions in the AliITSgeom object.
216   // Inputs:
217   //   none.
218   // Outputs:
219   //   none.
220   // Return:
221   //   none.
222
223   AliInfo("Add ITS alignable volumes");
224
225   if (!gGeoManager) { AliFatal("TGeoManager doesn't exist !"); return;  }
226   TString pth,snm;
227   //
228   pth = Form("ALIC_1/%s_2",AliITSUGeomTGeo::GetITSVolPattern());
229   // RS: to be checked with MS
230   if( !gGeoManager->SetAlignableEntry("ITS",pth.Data()) )
231     AliFatal(Form("Unable to set alignable entry ! %s :: %s","ITS",pth.Data()));    
232   //
233   int modNum = 0;
234   //
235   for (int lr=0; lr<fNLayers; lr++) {
236     //
237     pth = Form("ALIC_1/%s_2/%s%d_1",AliITSUGeomTGeo::GetITSVolPattern(),AliITSUGeomTGeo::GetITSLayerPattern(),lr);
238     snm = Form("ITS/%s%d",AliITSUGeomTGeo::GetITSLayerPattern(),lr);
239     //printf("SetAlignable: %s %s\n",snm.Data(),pth.Data());
240     gGeoManager->SetAlignableEntry(snm.Data(),pth.Data());
241     //
242     for (int ld=0; ld<fLaddPerLay[lr]; ld++) {
243       //
244       TString pthL = Form("%s/%s%d_%d",pth.Data(),AliITSUGeomTGeo::GetITSLadderPattern(),lr,ld);
245       TString snmL = Form("%s/%s%d",snm.Data(),AliITSUGeomTGeo::GetITSLadderPattern(),ld);
246       //printf("SetAlignable: %s %s\n",snmL.Data(),pthL.Data());
247       gGeoManager->SetAlignableEntry(snmL.Data(),pthL.Data());
248       //
249       for (int md=0; md<fModPerLadd[lr]; md++) {
250         //
251         TString pthM = Form("%s/%s%d_%d",pthL.Data(),AliITSUGeomTGeo::GetITSModulePattern(),lr,md);
252         TString snmM = Form("%s/%s%d",snmL.Data(),AliITSUGeomTGeo::GetITSModulePattern(),md);
253         //
254         // RS: Attention, this is a hack: AliGeomManager cannot accomodate all ITSU modules w/o
255         // conflicts with TPC. For this reason we define the UID of the module to be simply its ID
256         //      int modUID = AliGeomManager::LayerToVolUID(lr+1,modNum++); // here modNum would be module within the layer
257         int modUID = AliITSUGeomTGeo::ModuleVolUID( modNum++ );
258         // 
259         gGeoManager->SetAlignableEntry(snmM.Data(),pthM.Data(),modUID);
260         //
261         double yshift = -(fUpGeom[lr]->GetSensorThick()-fUpGeom[lr]->GetLadderThick())/2;
262         //      SetT2Lmatrix(modUID,yshift, kTRUE,kTRUE); // RS: do we need here special matrix, ask MS
263         SetT2Lmatrix(modUID,yshift, kTRUE,kFALSE); // RS: do we need here special matrix, ask MS
264         //
265       }
266     }
267   }
268   //
269 }
270
271 //______________________________________________________________________
272 void AliITSUv11::CreateGeometry() {
273
274   // Create the geometry and insert it in the mother volume ITSV
275   TGeoManager *geoManager = gGeoManager;
276
277   TGeoVolume *vALIC = geoManager->GetVolume("ALIC");
278
279   new TGeoVolumeAssembly(AliITSUGeomTGeo::GetITSVolPattern());
280   TGeoVolume *vITSV = geoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern());
281   vALIC->AddNode(vITSV, 2, 0);  // Copy number is 2 to cheat AliGeoManager::CheckSymNamesLUT
282
283   //
284   const Int_t kLength=100;
285   Char_t vstrng[kLength] = "xxxRS"; //?
286   vITSV->SetTitle(vstrng);
287   //
288   // Check that we have all needed parameters
289   if (fNLayers <= 0) AliFatal(Form("Wrong number of layers (%d)",fNLayers));
290   //
291   for (Int_t j=0; j<fNLayers; j++) {
292     if (fLayRadii[j] <= 0)                 AliFatal(Form("Wrong layer radius for layer %d (%f)",j,fLayRadii[j]));
293     if (fLayZLength[j] <= 0)               AliFatal(Form("Wrong layer length for layer %d (%f)",j,fLayZLength[j]));
294     if (fLaddPerLay[j] <= 0)               AliFatal(Form("Wrong number of ladders for layer %d (%d)",j,fLaddPerLay[j]));
295     if (fModPerLadd[j] <= 0)               AliFatal(Form("Wrong number of modules for layer %d (%d)",j,fModPerLadd[j]));
296     if (fLadThick[j] < 0)                  AliFatal(Form("Wrong ladder thickness for layer %d (%f)",j,fLadThick[j]));
297     if (fLayTurbo[j] && fLadWidth[j] <= 0) AliFatal(Form("Wrong ladder width for layer %d (%f)",j,fLadWidth[j]));
298     if (fDetThick[j] < 0)                  AliFatal(Form("Wrong module thickness for layer %d (%f)",j,fDetThick[j]));
299     //
300     if (j > 0) {
301       if (fLayRadii[j]<=fLayRadii[j-1])    AliFatal(Form("Layer %d radius (%f) is smaller than layer %d radius (%f)",
302                                                          j,fLayRadii[j],j-1,fLayRadii[j-1]));
303     } // if (j > 0)
304
305     if (fLadThick[j] == 0) AliInfo(Form("Ladder thickness for layer %d not set, using default",j));
306     if (fDetThick[j] == 0) AliInfo(Form("Module thickness for layer %d not set, using default",j));
307
308   } // for (Int_t j=0; j<fNLayers; j++)
309
310   // Now create the actual geometry
311   for (Int_t j=0; j<fNLayers; j++) {
312     if (fLayTurbo[j]) {
313       fUpGeom[j] = new AliITSUv11Layer(j,kTRUE,kFALSE);
314       fUpGeom[j]->SetLadderWidth(fLadWidth[j]);
315       fUpGeom[j]->SetLadderTilt(fLadTilt[j]);
316     }
317     else fUpGeom[j] = new AliITSUv11Layer(j,kFALSE);
318     //
319     fUpGeom[j]->SetRadius(fLayRadii[j]);
320     fUpGeom[j]->SetZLength(fLayZLength[j]);
321     fUpGeom[j]->SetNLadders(fLaddPerLay[j]);
322     fUpGeom[j]->SetNModules(fModPerLadd[j]);
323     fUpGeom[j]->SetDetType(fDetTypeID[j]);
324     //
325     if (fLadThick[j] != 0) fUpGeom[j]->SetLadderThick(fLadThick[j]);
326     if (fDetThick[j] != 0) fUpGeom[j]->SetSensorThick(fDetThick[j]);
327     fUpGeom[j]->CreateLayer(vITSV);
328   }
329   //
330 }
331
332 //______________________________________________________________________
333 void AliITSUv11::CreateMaterials() {
334   // Create ITS materials
335   //     This function defines the default materials used in the Geant
336   // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
337   // AliITSv11Hybrid.
338   // In general it is automatically replaced by
339   // the CreateMaterials routine defined in AliITSv?. Should the function
340   // CreateMaterials not exist for the geometry version you are using this
341   // one is used. See the definition found in AliITSv5 or the other routine
342   // for a complete definition.
343   // Inputs:
344   //   none.
345   // Outputs:
346   //   none.
347   // Return:
348   //   none.
349
350   Int_t   ifield = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
351   Float_t fieldm = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
352
353   Float_t tmaxfd = 0.1; // 1.0; // Degree
354   Float_t stemax = 1.0; // cm
355   Float_t deemax = 0.1; // 30.0; // Fraction of particle's energy 0<deemax<=1
356   Float_t epsil  = 1.0E-4; // 1.0; // cm
357   Float_t stmin  = 0.0; // cm "Default value used"
358
359   Float_t tmaxfdSi = 0.1; // .10000E+01; // Degree
360   Float_t stemaxSi = 0.0075; //  .10000E+01; // cm
361   Float_t deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
362   Float_t epsilSi  = 1.0E-4;// .10000E+01;
363   Float_t stminSi  = 0.0; // cm "Default value used"
364
365   Float_t tmaxfdAir = 0.1; // .10000E+01; // Degree
366   Float_t stemaxAir = .10000E+01; // cm
367   Float_t deemaxAir = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
368   Float_t epsilAir  = 1.0E-4;// .10000E+01;
369   Float_t stminAir  = 0.0; // cm "Default value used"
370
371   // AIR
372   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
373   Float_t zAir[4]={6.,7.,8.,18.};
374   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
375   Float_t dAir = 1.20479E-3;
376
377
378   AliMaterial(1,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
379   AliMedium(1,"SI$",1,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
380
381   AliMixture(5,"AIR$",aAir,zAir,dAir,4,wAir);
382   AliMedium(5,"AIR$",5,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
383
384   AliMaterial(8,"BERILLIUM$",9.01, 4., 1.848, 35.3, 36.7);// From AliPIPEv3
385   AliMedium(8,"BERILLIUM$",8,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
386     
387 }
388
389 //______________________________________________________________________
390 void AliITSUv11::DefineLayer(const Int_t nlay, const Double_t r,
391                                  const Double_t zlen, const Int_t nladd,
392                                  const Int_t nmod, const Double_t lthick,
393                                  const Double_t dthick, const UInt_t dettypeID)
394 {
395   //     Sets the layer parameters
396   // Inputs:
397   //          nlay    layer number
398   //          r       layer radius
399   //          zlen    layer length
400   //          nladd   number of ladders
401   //          nmod    number of modules per ladder
402   //          lthick  ladder thickness (if omitted, defaults to 0)
403   //          dthick  detector thickness (if omitted, defaults to 0)
404   // Outputs:
405   //   none.
406   // Return:
407   //   none.
408   
409   if (nlay >= fNLayers || nlay < 0) {
410     AliError(Form("Wrong layer number (%d)",nlay));
411     return;
412   }
413   
414   fLayTurbo[nlay] = kFALSE;
415   fLayRadii[nlay] = r;
416   fLayZLength[nlay] = zlen;
417   fLaddPerLay[nlay] = nladd;
418   fModPerLadd[nlay] = nmod;
419   fLadThick[nlay] = lthick;
420   fDetThick[nlay] = dthick;
421   fDetTypeID[nlay] = dettypeID;
422     
423 }
424
425 //______________________________________________________________________
426 void AliITSUv11::DefineLayerTurbo(const Int_t nlay, const Double_t r,
427                                       const Double_t zlen, const Int_t nladd,
428                                       const Int_t nmod, const Double_t width,
429                                       const Double_t tilt,
430                                       const Double_t lthick,
431                                       const Double_t dthick,
432                                       const UInt_t dettypeID)
433 {
434   //     Sets the layer parameters for a "turbo" layer
435   //     (i.e. a layer whose ladders overlap in phi)
436   // Inputs:
437   //          nlay    layer number
438   //          r       layer radius
439   //          zlen    layer length
440   //          nladd   number of ladders
441   //          nmod    number of modules per ladder
442   //          width   layer width
443   //          tilt    layer tilt angle (degrees)
444   //          lthick  ladder thickness (if omitted, defaults to 0)
445   //          dthick  detector thickness (if omitted, defaults to 0)
446   // Outputs:
447   //   none.
448   // Return:
449   //   none.
450
451   if (nlay >= fNLayers || nlay < 0) {
452     AliError(Form("Wrong layer number (%d)",nlay));
453     return;
454   }
455
456   fLayTurbo[nlay] = kTRUE;
457   fLayRadii[nlay] = r;
458   fLayZLength[nlay] = zlen;
459   fLaddPerLay[nlay] = nladd;
460   fModPerLadd[nlay] = nmod;
461   fLadThick[nlay] = lthick;
462   fLadWidth[nlay] = width;
463   fLadTilt[nlay] = tilt;
464   fDetThick[nlay] = dthick;
465   fDetTypeID[nlay] = dettypeID;
466   //
467 }
468
469 //______________________________________________________________________
470 void AliITSUv11::GetLayerParameters(const Int_t nlay,
471                                         Double_t &r, Double_t &zlen,
472                                         Int_t &nladd, Int_t &nmod,
473                                         Double_t &width, Double_t &tilt,
474                                         Double_t &lthick, Double_t &dthick){
475   //     Gets the layer parameters
476   // Inputs:
477   //          nlay    layer number
478   // Outputs:
479   //          r       layer radius
480   //          zlen    layer length
481   //          nladd   number of ladders
482   //          nmod    number of modules per ladder
483   //          width   ladder width
484   //          tilt    ladder tilt angle
485   //          lthick  ladder thickness
486   //          dthick  detector thickness
487   // Return:
488   //   none.
489
490   if (nlay >= fNLayers || nlay < 0) {
491     AliError(Form("Wrong layer number (%d)",nlay));
492     return;
493   }
494
495   r = fLayRadii[nlay];
496   zlen = fLayZLength[nlay];
497   nladd = fLaddPerLay[nlay];
498   nmod = fModPerLadd[nlay];
499   width = fLadWidth[nlay];
500   tilt = fLadTilt[nlay];
501   lthick = fLadThick[nlay];
502   dthick = fDetThick[nlay];
503 }
504
505 //______________________________________________________________________
506 void AliITSUv11::Init()
507 {
508   //     Initialise the ITS after it has been created.
509   UpdateInternalGeometry();
510   AliITSU::Init();
511   //  
512 }
513
514 //______________________________________________________________________
515 Bool_t AliITSUv11::IsLayerTurbo(const Int_t nlay)
516 {
517   //     Returns true if the layer is a "turbo" layer
518   if ( nlay < 0 || nlay > fNLayers ) {
519     AliError(Form("Wrong layer number %d",nlay));
520     return kFALSE;
521   } 
522   else return fUpGeom[nlay]->IsTurbo();
523 }
524
525 //______________________________________________________________________
526 void AliITSUv11::SetDefaults()
527 {
528   // sets the default segmentation, response, digit and raw cluster classes
529 }
530
531 //______________________________________________________________________
532 void AliITSUv11::StepManager()
533 {
534   //    Called for every step in the ITS, then calles the AliITSUHit class
535   // creator with the information to be recoreded about that hit.
536   //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
537   // printing of information to a file which can be used to create a .det
538   // file read in by the routine CreateGeometry(). If set to 0 or any other
539   // value except 1, the default behavior, then no such file is created nor
540   // it the extra variables and the like used in the printing allocated.
541   // Inputs:
542   //   none.
543   // Outputs:
544   //   none.
545   // Return:
546   //   none.
547   if(!(this->IsActive())) return;
548   if(!(gMC->TrackCharge())) return;
549   //
550   Int_t copy, lay = 0;
551   Int_t id = gMC->CurrentVolID(copy);
552
553   Bool_t notSens = kFALSE;
554   while ((lay<fNLayers)  && (notSens = (id!=fIdSens[lay]))) ++lay;
555   //printf("R: %.1f | Lay: %d  NotSens: %d\n",positionRS.Pt(), lay, notSens);
556            
557   if (notSens) return;
558
559   if(gMC->IsTrackExiting()) {
560     AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
561   } // if Outer ITS mother Volume
562
563   static TLorentzVector position, momentum; // Saves on calls to construtors
564   static AliITSUHit hit;// Saves on calls to constructors
565
566   TClonesArray &lhits = *(Hits());
567   Int_t   cpn0, cpn1, mod, status = 0;
568   //
569   // Track status
570   if(gMC->IsTrackInside())      status +=  1;
571   if(gMC->IsTrackEntering())    status +=  2;
572   if(gMC->IsTrackExiting())     status +=  4;
573   if(gMC->IsTrackOut())         status +=  8;
574   if(gMC->IsTrackDisappeared()) status += 16;
575   if(gMC->IsTrackStop())        status += 32;
576   if(gMC->IsTrackAlive())       status += 64;
577
578   //
579   // retrieve the indices with the volume path
580   //
581   if (lay < 0 || lay >= fNLayers) {
582     AliError(Form("Invalid value: lay=%d. Not an ITS sensitive volume",lay));
583     return; // not an ITS sensitive volume.
584   } else {
585     copy = 1;
586     gMC->CurrentVolOffID(1,cpn1);
587     gMC->CurrentVolOffID(2,cpn0);
588   } //
589
590   mod = fGeomTGeo->GetModuleIndex(lay,cpn0,cpn1);
591   //RS2DEL  fInitGeom.DecodeDetector(mod,lay+1,cpn0,cpn1,copy);
592   //
593   // Fill hit structure.
594   //
595   hit.SetModule(mod);
596   hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
597   gMC->TrackPosition(position);
598   gMC->TrackMomentum(momentum);
599   hit.SetPosition(position);
600   hit.SetTime(gMC->TrackTime());
601   hit.SetMomentum(momentum);
602   hit.SetStatus(status);
603   hit.SetEdep(gMC->Edep());
604   hit.SetShunt(GetIshunt());
605   if(gMC->IsTrackEntering()){
606     hit.SetStartPosition(position);
607     hit.SetStartTime(gMC->TrackTime());
608     hit.SetStartStatus(status);
609     return; // don't save entering hit.
610   } // end if IsEntering
611     // Fill hit structure with this new hit.
612     //Info("StepManager","Calling Copy Constructor");
613   new(lhits[fNhits++]) AliITSUHit(hit); // Use Copy Construtor.
614   // Save old position... for next hit.
615   hit.SetStartPosition(position);
616   hit.SetStartTime(gMC->TrackTime());
617   hit.SetStartStatus(status);
618
619   return;
620 }
621
622 //______________________________________________________________________
623 void AliITSUv11::SetLayerDetTypeID(Int_t lr, UInt_t id)
624 {
625   // set det type
626   if (!fDetTypeID || fNLayers<=lr) AliFatal(Form("Number of layers %d, %d is manipulated",fNLayers,lr));
627   fDetTypeID[lr] = id;
628 }
629
630 //______________________________________________________________________
631 Int_t AliITSUv11::GetLayerDetTypeID(Int_t lr)
632 {
633   // set det type
634   if (!fDetTypeID || fNLayers<=lr) AliFatal(Form("Number of layers %d, %d is manipulated",fNLayers,lr));
635   return fDetTypeID[lr];
636 }