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