]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSvUpgrade.cxx
cleanup
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSvUpgrade.cxx
CommitLineData
29998a6e 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: AliITSvUpgrade.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: AliITSvUpgrade.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 "AliITSUpg.h"
44#include "AliITSDetTypeSim.h"
45#include "AliITShit.h"
46#include "AliLog.h"
47#include "AliMC.h"
48#include "AliMagF.h"
49#include "AliRun.h"
50#include "AliTrackReference.h"
51#include "AliITSInitGeometryUpg.h"
52#include "AliITSv11Geometry.h"
53#include "AliITSv11GeometryUpgrade.h"
362fe8e0 54#include "AliITSv11GeomBeamPipe.h"
29998a6e 55#include "AliITSvUpgrade.h"
56#include "AliGeomManager.h"
57
362fe8e0 58const Double_t AliITSvUpgrade::fgkBeamPipeHalfZLen = 400;
59
60
29998a6e 61ClassImp(AliITSvUpgrade)
62
63//______________________________________________________________________
64AliITSvUpgrade::AliITSvUpgrade():
65 fMajorVersion(IsVersion()),
66 fMinorVersion(-1),
67 fNumberOfLayers(0),
68 fLayTurbo(0),
69 fLayRadii(0),
70 fLayZLength(0),
71 fLaddPerLay(0),
72 fModPerLadd(0),
73 fLadThick(0),
74 fLadWidth(0),
75 fLadTilt(0),
76 fDetThick(0),
362fe8e0 77 fBeamPipe(0),
78 fBeamPipeRmin(0),
79 fBeamPipeRmax(0),
80 fBeamPipeZlen(0),
29998a6e 81 fInitGeom((AliITSVersion_t)fMajorVersion,fMinorVersion),
362fe8e0 82 fUpGeom(0),
83 fBPGeom(0)
29998a6e 84 {
85 // Standard default constructor
86 // Inputs:
87 // none.
88 // Outputs:
89 // none.
90 // Return:
91 // none.
92}
93
94//______________________________________________________________________
95AliITSvUpgrade::AliITSvUpgrade(const char *title):
96 AliITSUpg("ITS", title),
97 fMajorVersion(IsVersion()),
98 fMinorVersion(-1),
99 fNumberOfLayers(0),
100 fLayTurbo(0),
101 fLayRadii(0),
102 fLayZLength(0),
103 fLaddPerLay(0),
104 fModPerLadd(0),
105 fLadThick(0),
106 fLadWidth(0),
107 fLadTilt(0),
108 fDetThick(0),
362fe8e0 109 fBeamPipe(0),
110 fBeamPipeRmin(0),
111 fBeamPipeRmax(0),
112 fBeamPipeZlen(0),
29998a6e 113 fInitGeom((AliITSVersion_t)fMajorVersion,fMinorVersion),
362fe8e0 114 fUpGeom(0),
115 fBPGeom(0)
29998a6e 116{
117 // Standard constructor for the Upgrade geometry.
118 // Inputs:
119 // const char * title Arbitrary title
120 // Outputs:
121 // none.
122 // Return:
123 // none.
124
125 fIdN = 6;
126 fIdName = new TString[fIdN];
127
128 fIdName[0] = "ITS1";
129 fIdName[1] = "ITS2";
130 fIdName[2] = "ITS3";
131 fIdName[3] = "ITS4";
132 fIdName[4] = "ITS5";
133 fIdName[5] = "ITS6";
134
135 fIdSens = new Int_t[fIdN];
136 for(Int_t i=0; i<fIdN; i++) fIdSens[i] = 0;
137
138 fLayTurbo = new Bool_t[fIdN];
139 fLayRadii = new Double_t[fIdN];
140 fLayZLength = new Double_t[fIdN];
141 fLaddPerLay = new Int_t[fIdN];
142 fModPerLadd = new Int_t[fIdN];
143 fLadThick = new Double_t[fIdN];
144 fLadWidth = new Double_t[fIdN];
145 fLadTilt = new Double_t[fIdN];
146 fDetThick = new Double_t[fIdN];
147
148 fUpGeom = new AliITSv11GeometryUpgrade*[fIdN];
149
150 if (fNumberOfLayers > 0) // if not, we'll Fatal-ize in CreateGeometry
151 for (Int_t j=0; j<fNumberOfLayers; j++) {
152 fLayRadii[j] = 0.;
153 fLayZLength[j] = 0.;
154 fLaddPerLay[j] = 0;
155 fModPerLadd[j] = 0;
156 fLadWidth[j] = 0.;
157 fDetThick[j] = 0.;
158 fUpGeom[j] = 0;
159 }
160
161}
162
163//______________________________________________________________________
164AliITSvUpgrade::AliITSvUpgrade(const char *name, const char *title,
165 const Int_t nlay):
166 AliITSUpg("ITS", title),
167 fMajorVersion(IsVersion()),
168 fMinorVersion(1),
169 fNumberOfLayers(nlay),
170 fLayTurbo(0),
171 fLayRadii(0),
172 fLayZLength(0),
173 fLaddPerLay(0),
174 fModPerLadd(0),
175 fLadThick(0),
176 fLadWidth(0),
177 fLadTilt(0),
178 fDetThick(0),
362fe8e0 179 fBeamPipe(0),
180 fBeamPipeRmin(0),
181 fBeamPipeRmax(0),
182 fBeamPipeZlen(0),
29998a6e 183 fInitGeom((AliITSVersion_t)fMajorVersion,fMinorVersion),
362fe8e0 184 fUpGeom(0),
185 fBPGeom(0)
29998a6e 186{
187 // Standard constructor for the Upgrade geometry.
188 // Inputs:
189 // const char * name Ignored, set to "ITS"
190 // const char * title Arbitrary title
191 // const Int_t nlay Number of layers
192 // Outputs:
193 // none.
194 // Return:
195 // none.
196
197 fIdN = nlay;
198 fIdName = new TString[fIdN];
199
200 for (Int_t j=0; j<fIdN; j++)
201 fIdName[j].Form("ITSupgSensor%d",j); // See AliITSv11GeometryUpgrade
202
203 (void) name; // removes warning message
204
205 fIdSens = new Int_t[fIdN];
206 for(Int_t i=0; i<fIdN; i++) fIdSens[i] = 0;
207
208 fLayTurbo = new Bool_t[fIdN];
209 fLayRadii = new Double_t[fIdN];
210 fLayZLength = new Double_t[fIdN];
211 fLaddPerLay = new Int_t[fIdN];
212 fModPerLadd = new Int_t[fIdN];
213 fLadThick = new Double_t[fIdN];
214 fLadWidth = new Double_t[fIdN];
215 fLadTilt = new Double_t[fIdN];
216 fDetThick = new Double_t[fIdN];
217
218 fUpGeom = new AliITSv11GeometryUpgrade*[fIdN];
219
220 if (fNumberOfLayers > 0) // if not, we'll Fatal-ize in CreateGeometry
221 for (Int_t j=0; j<fNumberOfLayers; j++) {
222 fLayRadii[j] = 0.;
223 fLayZLength[j] = 0.;
224 fLaddPerLay[j] = 0;
225 fModPerLadd[j] = 0;
226 fLadWidth[j] = 0.;
227 fDetThick[j] = 0.;
228 fUpGeom[j] = 0;
229 }
230
231}
232
233//______________________________________________________________________
234AliITSvUpgrade::~AliITSvUpgrade() {
235 // Standard destructor
236 // Inputs:
237 // none.
238 // Outputs:
239 // none.
240 // Return:
241 // none.
242 delete [] fLayTurbo;
243 delete [] fLayRadii;
244 delete [] fLayZLength;
245 delete [] fLaddPerLay;
246 delete [] fModPerLadd;
247 delete [] fLadThick;
248 delete [] fLadWidth;
249 delete [] fLadTilt;
250 delete [] fDetThick;
251 delete [] fUpGeom;
252
253}
254
255//______________________________________________________________________
256void AliITSvUpgrade::SetT2Lmatrix(Int_t uid, Double_t yShift,
257 Bool_t yFlip, Bool_t yRot180) const {
258
259 //
260 // Creates the TGeo Local to Tracking transformation matrix
261 // and sends it to the corresponding TGeoPNEntry
262 //
263 // This function is used in AddAlignableVolumes()
264
265 TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(uid);
266 TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
267
268 Double_t *gtrans = globMatrix->GetTranslation(), rotMatrix[9];
269 memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
270 Double_t al = TMath::ATan2(rotMatrix[1],rotMatrix[0]);
271 if (yRot180) {
272 al = TMath::ATan2(rotMatrix[1],-rotMatrix[0]);
273 }
274 Double_t xShift = gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al);
275 Double_t zShift = -gtrans[2];
276
277 TGeoHMatrix *matLtoT = new TGeoHMatrix;
278 matLtoT->SetDx( xShift ); // translation
279 matLtoT->SetDy( yShift );
280 matLtoT->SetDz( zShift );
281 rotMatrix[0]= 0; rotMatrix[1]= 1; rotMatrix[2]= 0; // + rotation
282 rotMatrix[3]= 1; rotMatrix[4]= 0; rotMatrix[5]= 0;
283 rotMatrix[6]= 0; rotMatrix[7]= 0; rotMatrix[8]=-1;
284 if (yFlip) rotMatrix[3] = -1; // flipping in y (for SPD1)
285 if (yFlip) rotMatrix[1] = -1; // flipping in y (for SPD1)
286
287 if (yRot180) { // rotation of pi around the axis perpendicular to the wafer
288 if (yFlip) matLtoT->SetDx( -xShift ); // flipping in y (for SPD1)
289 matLtoT->SetDy( -yShift );
290 matLtoT->SetDz( -zShift );
291 rotMatrix[8]=1;
292 rotMatrix[3] = -1;
293 if (yFlip) rotMatrix[3] = 1; // flipping in y (for SPD1)
294 }
295
296 TGeoRotation rot;
297 rot.SetMatrix(rotMatrix);
298 matLtoT->MultiplyLeft(&rot);
299 TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
300 delete matLtoT;
301 alignableEntry->SetMatrix(matTtoL);
302}
303
304//______________________________________________________________________
305void AliITSvUpgrade::AddAlignableVolumes() const{
306 // Creates entries for alignable volumes associating the symbolic volume
307 // name with the corresponding volume path.
308 //
309 // Records in the alignable entries the transformation matrices converting
310 // TGeo local coordinates (in the RS of alignable volumes) to the tracking
311 // system
312 // For this, this function has to run before the misalignment because we
313 // are using the ideal positions in the AliITSgeom object.
314 // Inputs:
315 // none.
316 // Outputs:
317 // none.
318 // Return:
319 // none.
320
321 AliInfo("Add ITS alignable volumes");
322
323 if (!gGeoManager) {
324 AliFatal("TGeoManager doesn't exist !");
325 return;
326 }
327 // To be done - dummy for the time being
328}
329
362fe8e0 330//______________________________________________________________________
331void AliITSvUpgrade::AddBeamPipe(const Double_t rmin, const Double_t rmax,
332 const Double_t halfzlen) {
333
334 // Define the parameters for the beam pipe
335 if (fBeamPipe)
336 AliWarning("Redefining beam pipe parameters");
337
338 if (rmin <= 0) {
339 AliError(Form("Beam pipe min radius (%f) wrong",rmin));
340 return;
341 } else
342 fBeamPipeRmin = rmin;
343
344 if (rmax <= 0) {
345 AliError(Form("Beam pipe max radius (%f) wrong",rmax));
346 return;
347 } else
348 fBeamPipeRmax = rmax;
349
350 if (halfzlen < 0) {
351 AliError(Form("Beam pipe half Zlength (%f) wrong",halfzlen));
352 return;
353 } else {
354 if (halfzlen == 0) // Use default value
355 fBeamPipeZlen = fgkBeamPipeHalfZLen;
356 else
357 fBeamPipeZlen = halfzlen;
358 }
359
360 fBeamPipe = kTRUE;
361}
362
29998a6e 363//______________________________________________________________________
364void AliITSvUpgrade::CreateGeometry() {
365
366 // Create the geometry and insert it in the mother volume ITSV
367
368
369 TGeoManager *geoManager = gGeoManager;
370
371 TGeoVolume *vALIC = geoManager->GetVolume("ALIC");
372
373 new TGeoVolumeAssembly("ITSV");
374 TGeoVolume *vITSV = geoManager->GetVolume("ITSV");
375 vALIC->AddNode(vITSV, 2, 0); // Copy number is 2 to cheat AliGeoManager::CheckSymNamesLUT
376
377 //
378 const Char_t *cvsDate="$Date: 2011-03-11 18:17:13 +0100 (Fri, 11 Mar 2011) $";
379 const Char_t *cvsRevision="$Revision: 48336 $";
380 const Int_t kLength=100;
381 Char_t vstrng[kLength];
382 if(fInitGeom.WriteVersionString(vstrng,kLength,(AliITSVersion_t)IsVersion(),
383 fMinorVersion,cvsDate,cvsRevision)) {
384 vITSV->SetTitle(vstrng);
385 }
386
387 // Check that we have all needed parameters
388 if (fNumberOfLayers <= 0)
389 AliFatal(Form("Wrong number of layers (%d)",fNumberOfLayers));
390
391 for (Int_t j=0; j<fNumberOfLayers; j++) {
392 if (fLayRadii[j] <= 0)
393 AliFatal(Form("Wrong layer radius for layer %d (%f)",j,fLayRadii[j]));
394 if (fLayZLength[j] <= 0)
395 AliFatal(Form("Wrong layer length for layer %d (%f)",j,fLayZLength[j]));
396 if (fLaddPerLay[j] <= 0)
397 AliFatal(Form("Wrong number of ladders for layer %d (%d)",j,
398 fLaddPerLay[j]));
399 if (fModPerLadd[j] <= 0)
400 AliFatal(Form("Wrong number of modules for layer %d (%d)",j,
401 fModPerLadd[j]));
402 if (fLadThick[j] < 0)
403 AliFatal(Form("Wrong ladder thickness for layer %d (%f)",j,
404 fLadThick[j]));
405 if (fLayTurbo[j] && fLadWidth[j] <= 0)
406 AliFatal(Form("Wrong ladder width for layer %d (%f)",j,
407 fLadWidth[j]));
408 if (fDetThick[j] < 0)
409 AliFatal(Form("Wrong module thickness for layer %d (%f)",j,
410 fDetThick[j]));
411
412 if (j > 0) {
413 if (fLayRadii[j] <= fLayRadii[j-1])
414 AliError(Form("Layer %d radius (%f) is smaller than layer %d radius (%f)",
415 j,fLayRadii[j],j-1,fLayRadii[j-1]));
416 if (fLayZLength[j] <= fLayZLength[j-1])
417 AliWarning(Form("Layer %d length (%f) is smaller than layer %d length (%f)",
418 j,fLayZLength[j],j-1,fLayZLength[j-1]));
419 } // if (j > 0)
420
421 if (fLadThick[j] == 0)
422 AliInfo(Form("Ladder thickness for layer %d not set, using default",j));
423
424 if (fDetThick[j] == 0)
425 AliInfo(Form("Module thickness for layer %d not set, using default",j));
426
427 } // for (Int_t j=0; j<fNumberOfLayers; j++)
428
429 // Now create the actual geometry
430 for (Int_t j=0; j<fNumberOfLayers; j++) {
431 if (fLayTurbo[j]) {
432 fUpGeom[j] = new AliITSv11GeometryUpgrade(j,kTRUE,kFALSE);
433 fUpGeom[j]->SetLadderWidth(fLadWidth[j]);
434 fUpGeom[j]->SetLadderTilt(fLadTilt[j]);
435 }
436 else
437 fUpGeom[j] = new AliITSv11GeometryUpgrade(j,kFALSE);
438 fUpGeom[j]->SetRadius(fLayRadii[j]);
439 fUpGeom[j]->SetZLength(fLayZLength[j]);
440 fUpGeom[j]->SetNLadders(fLaddPerLay[j]);
441 fUpGeom[j]->SetNModules(fModPerLadd[j]);
442 if (fLadThick[j] != 0) fUpGeom[j]->SetLadderThick(fLadThick[j]);
443 if (fDetThick[j] != 0) fUpGeom[j]->SetSensorThick(fDetThick[j]);
444 fUpGeom[j]->CreateLayer(vITSV);
445 }
446
362fe8e0 447 // Finally add the beam pipe
448 if (fBeamPipe) {
449 fBPGeom = new AliITSv11GeomBeamPipe(fBeamPipeRmin, fBeamPipeRmax,
450 fBeamPipeZlen, kFALSE);
451 fBPGeom->CreateBeamPipe(vALIC); // We put the BP in the ALIC volume
452 }
453
29998a6e 454}
455
456//______________________________________________________________________
457void AliITSvUpgrade::CreateMaterials(){
458 // Create ITS materials
459 // This function defines the default materials used in the Geant
460 // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
461 // AliITSv11Hybrid.
462 // In general it is automatically replaced by
463 // the CreateMaterials routine defined in AliITSv?. Should the function
464 // CreateMaterials not exist for the geometry version you are using this
465 // one is used. See the definition found in AliITSv5 or the other routine
466 // for a complete definition.
467 // Inputs:
468 // none.
469 // Outputs:
470 // none.
471 // Return:
472 // none.
473
474 Int_t ifield = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
475 Float_t fieldm = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
476
477 Float_t tmaxfd = 0.1; // 1.0; // Degree
478 Float_t stemax = 1.0; // cm
479 Float_t deemax = 0.1; // 30.0; // Fraction of particle's energy 0<deemax<=1
480 Float_t epsil = 1.0E-4; // 1.0; // cm
481 Float_t stmin = 0.0; // cm "Default value used"
482
483 Float_t tmaxfdSi = 0.1; // .10000E+01; // Degree
484 Float_t stemaxSi = 0.0075; // .10000E+01; // cm
485 Float_t deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
486 Float_t epsilSi = 1.0E-4;// .10000E+01;
487 Float_t stminSi = 0.0; // cm "Default value used"
488
489 Float_t tmaxfdAir = 0.1; // .10000E+01; // Degree
490 Float_t stemaxAir = .10000E+01; // cm
491 Float_t deemaxAir = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
492 Float_t epsilAir = 1.0E-4;// .10000E+01;
493 Float_t stminAir = 0.0; // cm "Default value used"
494
29998a6e 495 // AIR
29998a6e 496 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
497 Float_t zAir[4]={6.,7.,8.,18.};
498 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
499 Float_t dAir = 1.20479E-3;
500
29998a6e 501
502 AliMaterial(1,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
503 AliMedium(1,"SI$",1,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
504
29998a6e 505 AliMixture(5,"AIR$",aAir,zAir,dAir,4,wAir);
506 AliMedium(5,"AIR$",5,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
507
362fe8e0 508 AliMaterial(8,"BERILLIUM$",9.01, 4., 1.848, 35.3, 36.7);// From AliPIPEv3
509 AliMedium(8,"BERILLIUM$",8,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
29998a6e 510
29998a6e 511}
512
513//______________________________________________________________________
514void AliITSvUpgrade::DefineLayer(const Int_t nlay, const Double_t r,
515 const Double_t zlen, const Int_t nladd,
516 const Int_t nmod, const Double_t lthick,
517 const Double_t dthick){
518 // Sets the layer parameters
519 // Inputs:
520 // nlay layer number
521 // r layer radius
522 // zlen layer length
523 // nladd number of ladders
524 // nmod number of modules per ladder
525 // lthick ladder thickness (if omitted, defaults to 0)
526 // dthick detector thickness (if omitted, defaults to 0)
527 // Outputs:
528 // none.
529 // Return:
530 // none.
531
532 if (nlay >= fNumberOfLayers || nlay < 0) {
533 AliError(Form("Wrong layer number (%d)",nlay));
534 return;
535 }
536
537 fLayTurbo[nlay] = kFALSE;
538 fLayRadii[nlay] = r;
539 fLayZLength[nlay] = zlen;
540 fLaddPerLay[nlay] = nladd;
541 fModPerLadd[nlay] = nmod;
542 fLadThick[nlay] = lthick;
543 fDetThick[nlay] = dthick;
544}
545
546//______________________________________________________________________
547void AliITSvUpgrade::DefineLayerTurbo(const Int_t nlay, const Double_t r,
548 const Double_t zlen, const Int_t nladd,
549 const Int_t nmod, const Double_t width,
550 const Double_t tilt,
551 const Double_t lthick,
552 const Double_t dthick){
553 // Sets the layer parameters for a "turbo" layer
554 // (i.e. a layer whose ladders overlap in phi)
555 // Inputs:
556 // nlay layer number
557 // r layer radius
558 // zlen layer length
559 // nladd number of ladders
560 // nmod number of modules per ladder
561 // width layer width
562 // tilt layer tilt angle (degrees)
563 // lthick ladder thickness (if omitted, defaults to 0)
564 // dthick detector thickness (if omitted, defaults to 0)
565 // Outputs:
566 // none.
567 // Return:
568 // none.
569
570 if (nlay >= fNumberOfLayers || nlay < 0) {
571 AliError(Form("Wrong layer number (%d)",nlay));
572 return;
573 }
574
575 fLayTurbo[nlay] = kTRUE;
576 fLayRadii[nlay] = r;
577 fLayZLength[nlay] = zlen;
578 fLaddPerLay[nlay] = nladd;
579 fModPerLadd[nlay] = nmod;
580 fLadThick[nlay] = lthick;
581 fLadWidth[nlay] = width;
582 fLadTilt[nlay] = tilt;
583 fDetThick[nlay] = dthick;
584}
585
362fe8e0 586//______________________________________________________________________
587void AliITSvUpgrade::GetBeamPipeParameters(Double_t &rmin, Double_t &rmax,
588 Double_t &hzlen){
589 // Gets the beam pipe parameters
590 // Inputs:
591 // none.
592 // Outputs:
593 // rmin min radius
594 // rmax max radius
595 // hzlen half Z length
596 // Return:
597 // none.
598
599 rmin = fBeamPipeRmin;
600 rmax = fBeamPipeRmax;
601 hzlen = fBeamPipeZlen;
602
603}
604
29998a6e 605//______________________________________________________________________
606void AliITSvUpgrade::GetLayerParameters(const Int_t nlay,
607 Double_t &r, Double_t &zlen,
608 Int_t &nladd, Int_t &nmod,
609 Double_t &width, Double_t &tilt,
610 Double_t &lthick, Double_t &dthick){
611 // Gets the layer parameters
612 // Inputs:
613 // nlay layer number
614 // Outputs:
615 // r layer radius
616 // zlen layer length
617 // nladd number of ladders
618 // nmod number of modules per ladder
619 // width ladder width
620 // tilt ladder tilt angle
621 // lthick ladder thickness
622 // dthick detector thickness
623 // Return:
624 // none.
625
626 if (nlay >= fNumberOfLayers || nlay < 0) {
627 AliError(Form("Wrong layer number (%d)",nlay));
628 return;
629 }
630
631 r = fLayRadii[nlay];
632 zlen = fLayZLength[nlay];
633 nladd = fLaddPerLay[nlay];
634 nmod = fModPerLadd[nlay];
635 width = fLadWidth[nlay];
636 tilt = fLadTilt[nlay];
637 lthick = fLadThick[nlay];
638 dthick = fDetThick[nlay];
639}
640
641//______________________________________________________________________
642void AliITSvUpgrade::Init(){
643 // Initialise the ITS after it has been created.
644 // Inputs:
645 // none.
646 // Outputs:
647 // none.
648 // Return:
649 // none.
650
651 AliDebug(1,Form("Init: Major version %d Minor version %d",fMajorVersion,
652 fMinorVersion));
653 UpdateInternalGeometry();
654 AliITSUpg::Init();
655
656}
657
658//______________________________________________________________________
659Bool_t AliITSvUpgrade::IsLayerTurbo(const Int_t nlay){
660 // Returns true if the layer is a "turbo" layer
661 // Inputs:
662 // nlay layer number
663 // Outputs:
664 // none.
665 // Return:
666 // kTRUE if the layer is a turbo layer
667
668 if ( nlay < 0 || nlay > fNumberOfLayers ) {
669 AliError(Form("Wrong layer number %d",nlay));
670 return kFALSE;
671 } else
672 return fUpGeom[nlay]->IsTurbo();
673
674}
675
676//______________________________________________________________________
677void AliITSvUpgrade::SetDefaults(){
678 // sets the default segmentation, response, digit and raw cluster classes
679 // Inputs:
680 // none.
681 // Outputs:
682 // none.
683 // Return:
684 // none.
685
686 if(!fDetTypeSim){
687 Warning("SetDefaults","Error fDetTypeSim not defined");
688 return;
689 }
690
691 fDetTypeSim->SetDefaults();
692
693 return;
694}
695
696//______________________________________________________________________
697void AliITSvUpgrade::StepManager(){
698 // Called for every step in the ITS, then calles the AliITShit class
699 // creator with the information to be recoreded about that hit.
700 // The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
701 // printing of information to a file which can be used to create a .det
702 // file read in by the routine CreateGeometry(). If set to 0 or any other
703 // value except 1, the default behavior, then no such file is created nor
704 // it the extra variables and the like used in the printing allocated.
705 // Inputs:
706 // none.
707 // Outputs:
708 // none.
709 // Return:
710 // none.
711
712 if(!(this->IsActive())) return;
713 if(!(gMC->TrackCharge())) return;
714
715 Int_t copy, lay = 0;
716 Int_t id = gMC->CurrentVolID(copy);
717
718 Bool_t notSens = kFALSE;
719 while ((lay<fIdN) && (notSens = id != fIdSens[lay])) ++lay;
720 if (notSens) return;
721
722 if(gMC->IsTrackExiting()) {
723 AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
724 } // if Outer ITS mother Volume
725
726 static TLorentzVector position, momentum; // Saves on calls to construtors
727 static AliITShit hit;// Saves on calls to constructors
728
729 TClonesArray &lhits = *(Hits());
730 Int_t cpn0, cpn1, mod, status = 0;
731 //
732 // Track status
733 if(gMC->IsTrackInside()) status += 1;
734 if(gMC->IsTrackEntering()) status += 2;
735 if(gMC->IsTrackExiting()) status += 4;
736 if(gMC->IsTrackOut()) status += 8;
737 if(gMC->IsTrackDisappeared()) status += 16;
738 if(gMC->IsTrackStop()) status += 32;
739 if(gMC->IsTrackAlive()) status += 64;
740
741 //
742 // retrieve the indices with the volume path
743 //
744 if (lay < 0 || lay > fIdN) {
745 AliError(Form("Invalid value: lay=%d. Not an ITS sensitive volume",lay));
746 return; // not an ITS sensitive volume.
747 } else {
748 copy = 1;
749 gMC->CurrentVolOffID(1,cpn1);
750 gMC->CurrentVolOffID(2,cpn0);
751 } //
752
753 fInitGeom.DecodeDetector(mod,lay,cpn0,cpn1,copy);
754 // We should not need to pass by the switch !
755 // This is time consuming...
756 // therefore DecodeDetectorv11Upgrade(...) shouldn't be private !
757 // and we should be able to use instead :
758 //fInitGeom.DecodeDetectorv11Upgrade(mod,lay+1,cpn0,cpn1,copy);
759
760 //
761 // Fill hit structure.
762 //
763 hit.SetModule(mod);
764 hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
765 gMC->TrackPosition(position);
766 gMC->TrackMomentum(momentum);
767 hit.SetPosition(position);
768 hit.SetTime(gMC->TrackTime());
769 hit.SetMomentum(momentum);
770 hit.SetStatus(status);
771 hit.SetEdep(gMC->Edep());
772 hit.SetShunt(GetIshunt());
773 if(gMC->IsTrackEntering()){
774 hit.SetStartPosition(position);
775 hit.SetStartTime(gMC->TrackTime());
776 hit.SetStartStatus(status);
777 return; // don't save entering hit.
778 } // end if IsEntering
779 // Fill hit structure with this new hit.
780 //Info("StepManager","Calling Copy Constructor");
781 new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
782 // Save old position... for next hit.
783 hit.SetStartPosition(position);
784 hit.SetStartTime(gMC->TrackTime());
785 hit.SetStartStatus(status);
786
787 return;
788}
789