]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSv5.cxx
Corrected setting of magnetic field
[u/mrichter/AliRoot.git] / ITS / AliITSv5.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19//
20// Inner Traking System version 5
21// This class contains the base procedures for the Inner Tracking System
22//
23// Authors: R. Barbera, B. S. Nilsen.
24// version 5.
25// Created September 17 1999.
26//
27///////////////////////////////////////////////////////////////////////////////
28#include <Riostream.h>
29#include <stdio.h>
30#include <stdlib.h>
31
32#include <TBRIK.h>
33#include <TCanvas.h>
34#include <TClonesArray.h>
35#include <TFile.h> // only required for Tracking function?
36#include <TGeometry.h>
37#include <TLorentzVector.h>
38#include <TMath.h>
39#include <TNode.h>
40#include <TObjArray.h>
41#include <TObjString.h>
42#include <TSystem.h>
43#include <TTUBE.h>
44#include <TVirtualMC.h>
45
46#include "AliRun.h"
47#include "AliITShit.h"
48#include "AliITSGeant3Geometry.h"
49#include "AliITSgeom.h"
50#include "AliITSgeomSDD.h"
51#include "AliITSgeomSPD.h"
52#include "AliITSgeomSSD.h"
53#include "AliITShit.h"
54#include "AliITSv5.h"
55#include "AliRun.h"
56#include "AliMC.h"
57
58ClassImp(AliITSv5)
59
60//_____________________________________________________________________________
61AliITSv5::AliITSv5() {
62////////////////////////////////////////////////////////////////////////
63// Standard default constructor for the ITS version 5.
64////////////////////////////////////////////////////////////////////////
65 Int_t i;
66
67 fIdN = 0;
68 fIdName = 0;
69 fIdSens = 0;
70 fEuclidOut = kFALSE; // Don't write Euclide file
71 fGeomDetOut = kFALSE; // Don't write .det file
72 fGeomDetIn = kFALSE; // Don't Read .det file
73 fGeomOldDetIn = kFALSE; // Don't Read old formatted .det file
74 fMajorVersion = IsVersion();
75 fMinorVersion = 1;
76 for(i=0;i<60;i++) fRead[i] = '\0';
77 for(i=0;i<60;i++) fWrite[i] = '\0';
78 for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
79}
80//_____________________________________________________________________________
81AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
82////////////////////////////////////////////////////////////////////////
83// Standard constructor for the ITS version 5.
84////////////////////////////////////////////////////////////////////////
85 Int_t i;
86
87 fIdN = 6;
88 fIdName = new TString[fIdN];
89 fIdName[0] = "ITS1";
90 fIdName[1] = "ITS2";
91 fIdName[2] = "ITS3";
92 fIdName[3] = "ITS4";
93 fIdName[4] = "ITS5";
94 fIdName[5] = "ITS6";
95 fIdSens = new Int_t[fIdN];
96 for (i=0;i<fIdN;i++) fIdSens[i] = 0;
97 fEuclidOut = kFALSE; // Don't write Euclide file
98 fGeomDetOut = kFALSE; // Don't write .det file
99 fGeomDetIn = kFALSE; // Don't Read .det file
100 fGeomOldDetIn = kFALSE; // Don't Read old formatted .det file
101 fMajorVersion = IsVersion();
102 fMinorVersion = 1;
103 for(i=0;i<60;i++) fRead[i] = '\0';
104 for(i=0;i<60;i++) fWrite[i] = '\0';
105
106 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
107 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
108 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_v5.det",60);
109 strncpy(fRead,fEuclidGeomDet,60);
110 strncpy(fWrite,fEuclidGeomDet,60);
111}
112//____________________________________________________________________________
113AliITSv5::AliITSv5(const AliITSv5 &source) : AliITS(source){
114////////////////////////////////////////////////////////////////////////
115// Copy Constructor for ITS version 5.
116////////////////////////////////////////////////////////////////////////
117 if(&source == this) return;
118 Warning("Copy Constructor","Not allowed to copy AliITSv5");
119 return;
120}
121//_____________________________________________________________________________
122AliITSv5& AliITSv5::operator=(const AliITSv5 &source){
123////////////////////////////////////////////////////////////////////////
124// Assignment operator for the ITS version 5.
125////////////////////////////////////////////////////////////////////////
126
127 if(&source == this) return *this;
128 Warning("= operator","Not allowed to copy AliITSv5");
129 return *this;
130
131}
132//_____________________________________________________________________________
133AliITSv5::~AliITSv5() {
134////////////////////////////////////////////////////////////////////////
135// Standard destructor for the ITS version 5.
136////////////////////////////////////////////////////////////////////////
137}
138//______________________________________________________________________
139void AliITSv5::BuildGeometry(){
140////////////////////////////////////////////////////////////////////////
141// Geometry builder for the ITS version 5.
142////////////////////////////////////////////////////////////////////////
143 //
144 // Build ITS TNODE geometry for event display using detailed geometry.
145 // This function builds a simple ITS geometry used by the ROOT macro
146 // ITSdisplay.C.
147
148 TNode *top;
149 TNode *nd;
150 //const int kColorITSSPD=kRed;
151 //const int kColorITSSDD=kGreen;
152 const int kColorITSSSD=kBlue;
153 //
154 AliITSgeom *gm = this->GetITSgeom();
155 if(gm==0) return;
156 top=gAlice->GetGeometry()->GetNode("alice");
157
158 Int_t lay,lad,det,i;
159 Text_t name[10];
160 Float_t xg[3];
161 Float_t rt[9];
162 Double_t rtd[9];
163 TBRIK *box;
164 TRotMatrix *rm;
165 //TCanvas *c1 = new TCanvas("c1","ITS");
166
167 for(lay=1;lay<=2;lay++)
168 for(lad=1;lad<=gm->GetNladders(lay);lad++)
169 for(det=1;det<=gm->GetNdetectors(lay);det++){
170 try {
171 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
172 0.64,0.0075,4.19);
173 } catch (...) {
174 cout << "EXCEPTION in box = new TBRIK" << endl;
175 return;
176 }
177 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
178 gm->GetRotMatrix(lay,lad,det,rt);
179 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
180 for(i=0;i<9;i++) rtd[i] = rt[i];
181 try {
182 rm = new TRotMatrix(name,name,rtd);
183 } catch (...) {
184 cout << "EXCEPTION in new TRotMatrix" << endl;
185 return;
186 }
187 top->cd();
188 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
189 try {
190 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
191 } catch (...) {
192 cout << "EXCEPTION in new TNode" << endl;
193 return;
194 }
195 nd->SetLineColor(kColorITSSSD);
196 fNodes->Add(nd);
197 }
198
199 for(lay=3;lay<=3;lay++)
200 for(lad=1;lad<=gm->GetNladders(lay);lad++)
201 for(det=1;det<=gm->GetNdetectors(lay);det++){
202 try {
203 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
204 3.5,0.014,3.763);
205 } catch (...) {
206 cout << "EXCEPTION in box = new TBRIK" << endl;
207 return;
208 }
209 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
210 gm->GetRotMatrix(lay,lad,det,rt);
211 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
212 for(i=0;i<9;i++) rtd[i] = rt[i];
213 try {
214 rm = new TRotMatrix(name,name,rtd);
215 } catch (...) {
216 cout << "EXCEPTION in new TRotMatrix" << endl;
217 return;
218 }
219 top->cd();
220 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
221 try {
222 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
223 } catch (...) {
224 cout << "EXCEPTION in new TNode" << endl;
225 return;
226 }
227 nd->SetLineColor(kColorITSSSD);
228 fNodes->Add(nd);
229 }
230
231 for(lay=4;lay<=4;lay++)
232 for(lad=1;lad<=gm->GetNladders(lay);lad++)
233 for(det=1;det<=gm->GetNdetectors(lay);det++){
234 try {
235 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
236 3.5,0.014,3.763);
237 } catch (...) {
238 cout << "EXCEPTION in box = new TBRIK" << endl;
239 return;
240 }
241 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
242 gm->GetRotMatrix(lay,lad,det,rt);
243 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
244 for(i=0;i<9;i++) rtd[i] = rt[i];
245 try {
246 rm = new TRotMatrix(name,name,rtd);
247 } catch (...) {
248 cout << "EXCEPTION in new TRotMatrix" << endl;
249 return;
250 }
251 top->cd();
252 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
253 try {
254 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
255 } catch (...) {
256 cout << "EXCEPTION in new TNode" << endl;
257 return;
258 }
259 nd->SetLineColor(kColorITSSSD);
260 fNodes->Add(nd);
261 }
262 for(lay=5;lay<=5;lay++)
263 for(lad=1;lad<=gm->GetNladders(lay);lad++)
264 for(det=1;det<=gm->GetNdetectors(lay);det++){
265 try {
266 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
267 3.65,0.015,2.0);
268 } catch (...) {
269 cout << "EXCEPTION in box = new TBRIK" << endl;
270 return;
271 }
272 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
273 gm->GetRotMatrix(lay,lad,det,rt);
274 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
275 for(i=0;i<9;i++) rtd[i] = rt[i];
276 try {
277 rm = new TRotMatrix(name,name,rtd);
278 } catch (...) {
279 cout << "EXCEPTION in new TRotMatrix" << endl;
280 return;
281 }
282 top->cd();
283 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
284 try {
285 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
286 } catch (...) {
287 cout << "EXCEPTION in new TNode" << endl;
288 return;
289 }
290 nd->SetLineColor(kColorITSSSD);
291 fNodes->Add(nd);
292 }
293
294 for(lay=6;lay<=6;lay++)
295 for(lad=1;lad<=gm->GetNladders(lay);lad++)
296 for(det=1;det<=gm->GetNdetectors(lay);det++){
297 try {
298 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
299 3.65,0.015,2.0);
300 } catch (...) {
301 cout << "EXCEPTION in box = new TBRIK" << endl;
302 return;
303 }
304
305 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
306 gm->GetRotMatrix(lay,lad,det,rt);
307 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
308 for(i=0;i<9;i++) rtd[i] = rt[i];
309 try {
310 rm = new TRotMatrix(name,name,rtd);
311 } catch (...) {
312 cout << "EXCEPTION in new TRotMatrix" << endl;
313 return;
314 }
315 top->cd();
316 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
317 try {
318 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
319 } catch (...) {
320 cout << "EXCEPTION in new TNode" << endl;
321 return;
322 }
323 nd->SetLineColor(kColorITSSSD);
324 fNodes->Add(nd);
325 }
326
327
328}
329//_____________________________________________________________________________
330void AliITSv5::CreateMaterials(){
331////////////////////////////////////////////////////////////////////////
332// Read a file containing the materials for the ITS version 5.
333////////////////////////////////////////////////////////////////////////
334 char *filtmp;
335
336 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
337
338 FILE *file = fopen(filtmp,"r");
339 if(file) {
340 fclose(file);
341 ReadEuclidMedia(filtmp);
342 } else {
343 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
344 exit(1);
345 } // end if(file)
346}
347//_____________________________________________________________________________
348void AliITSv5::CreateGeometry(){
349//////////////////////////////////////////////////////////////////////
350// This is the geometry used for the ITS Pre-TDR and comes from an
351// Euclid to Geant conversion. The only difference
352// is in the details of the ITS supports. The detectors elements,
353// detector numbering, and local and global reference frames are shown in
354// the following figures.
355//Begin_Html
356/*
357<img src="picts/ITS/its1+2_convention_front_5.gif">
358</pre>
359<br clear=left>
360<font size=+2 color=red>
361<p>This shows the front view of the SPDs.
362</font>
363<pre>
364<img src="picts/ITS/its1+2_convention_side_5.gif">
365</pre>
366<br clear=left>
367<font size=+2 color=red>
368<p>This shows the perspective view of the SPDs.
369</font>
370<img src="picts/ITS/its1+2_tree.gif">
371</pre>
372<br clear=left>
373<font size=+2 color=red>
374<p>This shows the geometry Tree for the SPDs.
375</font>
376<pre>
377
378<pre>
379<img src="picts/ITS/its3+4_convention_front_5.gif">
380</pre>
381<br clear=left>
382<font size=+2 color=red>
383<p>This shows the front view of the SDDs.
384</font>
385<pre>
386<img src="picts/ITS/its3+4_convention_side_5.gif">
387</pre>
388<br clear=left>
389<font size=+2 color=red>
390<p>This shows the perspective view of the SDDs.
391</font>
392<img src="picts/ITS/its3+4_tree.gif">
393</pre>
394<br clear=left>
395<font size=+2 color=red>
396<p>This shows the geometry Tree for the SDDs.
397</font>
398<pre>
399
400<pre>
401<img src="picts/ITS/its5+6_convention_front_5.gif">
402</pre>
403<br clear=left>
404<font size=+2 color=red>
405<p>This shows the front view of the SSDs.
406</font>
407<pre>
408<img src="picts/ITS/its5+6_convention_side_5.gif">
409</pre>
410<br clear=left>
411<font size=+2 color=red>
412<p>This shows the perspective view of the SSDs.
413</font>
414<pre>
415<img src="picts/ITS/its5+6_tree.gif">
416</pre>
417<br clear=left>
418<font size=+2 color=red>
419<p>This shows the geometry Tree for the SSDs.
420</font>
421<pre>
422
423
424<img src="picts/ITS/its_layer1-6_2.gif">
425</pre>
426<br clear=left>
427<font size=+2 color=red>
428<p>This shows the front view of the whole ITS..
429</font>
430<pre>
431
432<img src="picts/ITS/its_layer1-6_1.gif">
433</pre>
434<br clear=left>
435<font size=+2 color=red>
436<p>This shows the perspective view of the whole ITS..
437</font>
438<pre>
439
440<img src="picts/ITS/its1-6_tree.gif">
441</pre>
442<br clear=left>
443<font size=+2 color=red>
444<p>This shows the geometry Tree for the whole ITS.
445</font>
446<pre>
447*/
448//End_Html
449//
450//
451// Here are shown the details of the ITS support cones and services.
452// First is a GEANT tree showing the organization of all of the volumes
453// that make up the ITS supports and services.
454//Begin_Html
455/*
456<img src="picts/ITS/supports_tree.gif">
457 */
458//End_Html
459// What follows are a number of figures showing what these support
460// structures look like.
461//Begin_Html
462/*
463
464<img src="picts/ITS/supports_3.gif">
465</pre>
466<br clear=left>
467<font size=+2 color=red>
468<p>This shows the geometry of the supports for the Drift and Strip layers only.
469</font>
470<pre>
471
472<img src="picts/ITS/supports_2.gif">
473</pre>
474<br clear=left>
475<font size=+2 color=red>
476<p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
477</font>
478<pre>
479
480<img src="picts/ITS/supports_1.gif">
481</pre>
482<br clear=left>
483<font size=+2 color=red>
484<p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
485</font>
486<pre>
487
488<img src="picts/ITS/suppssd.gif">
489</pre>
490<br clear=left>
491<font size=+2 color=red>
492<p>This shows the geometry for the Strip layers supports.
493</font>
494<pre>
495
496<img src="picts/ITS/suppsdd.gif">
497</pre>
498<br clear=left>
499<font size=+2 color=red>
500<p>This shows the geometry for the Drift layers supports.
501</font>
502<pre>
503 */
504//End_Html
505//
506// Read a file containing the geometry for the ITS version 5.
507////////////////////////////////////////////////////////////////////////
508
509
510 char topvol[5];
511 char *filtmp;
512
513 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
514 FILE *file = fopen(filtmp,"r");
515 delete [] filtmp;
516 if(file) {
517 fclose(file);
518 cout << "Ready to read Euclid geometry file" << endl;
519 ReadEuclid(fEuclidGeometry.Data(),topvol);
520 printf("Read in euclid geometries\n");
521 } else {
522 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
523 fEuclidGeometry.Data());
524 exit(1);
525 } // end if(file)
526 //
527 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
528 // invisible
529 //
530 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
531 //
532 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
533
534 if (fEuclidOut) {
535 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
536 } // end if (fEuclidOut)
537
538 cout << "finished with euclid geometrys" << endl;
539}
540//______________________________________________________________________
541void AliITSv5::ReadOldGeometry(const char *filename){
542 // read in the file containing the transformations for the active
543 // volumes for the ITS version 5. This is expected to be in a file
544 // ending in .det. This geometry is kept in the AliITSgeom class.
545 Int_t size;
546 char *filtmp;
547 FILE *file;
548
549 if(fITSgeom!=0) delete fITSgeom;
550 filtmp = gSystem->ExpandPathName(filename);
551 size = strlen(filtmp);
552 if(size>4 && fGeomDetIn){
553 filtmp[size-3] = 'd'; // change from .euc to .det
554 filtmp[size-2] = 'e';
555 filtmp[size-1] = 't';
556 file = fopen(filtmp,"r");
557 if(file){ // if file exists use it to fill AliITSgeom structure.
558 fclose(file);
559 fITSgeom = new AliITSgeom(filtmp);
560 fITSgeom->DefineShapes(3); // if fShape isn't defined define it.
561 // Now define the detector types/shapes.
562 fITSgeom->ReSetShape(kSPD,new AliITSgeomSPD300());
563 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
564 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
565 }else{
566 fITSgeom = 0;
567 // fill AliITSgeom structure from geant structure just filled above
568 }// end if(file)
569 delete [] filtmp;
570 }// end if(size>4)
571}
572//______________________________________________________________________
573void AliITSv5::InitAliITSgeom(){
574// Based on the geometry tree defined in Geant 3.21, this
575// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
576// sturture.
577// if(gMC->IsA()!=TGeant3::Class()) {
578 if(strcmp(gMC->GetName(),"TGeant3")) {
579 Error("InitAliITSgeom",
580 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
581 return;
582 } // end if
583 cout << "Reading Geometry transformation directly from Geant 3." << endl;
584 const Int_t nlayers = 6;
585 const Int_t ndeep = 7;
586 Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
587 Int_t nlad[nlayers],ndet[nlayers];
588 Double_t t[3],r[10];
589 Float_t par[20],att[20];
590 Int_t npar,natt,idshape,imat,imed;
591 AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
592 Int_t mod,lay,lad,det,i,j,k;
593 char *names[nlayers][ndeep] = {
594 {"ALIC","ITSV","ITSD","IT12","I132","I186","ITS1"}, // lay=1
595 {"ALIC","ITSV","ITSD","IT12","I132","I131","ITS2"}, // lay=2
596 {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"}, // lay=3
597 {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"}, // lay=4
598 {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"}, // lay=5
599 {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"}};// lay=6
600 Int_t itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2,4}, // lay=1
601 {1,1,1,1,10, 4,4}, // lay=2
602 {1,1,1,1,14, 6,1}, // lay=3
603 {1,1,1,1,22, 8,1}, // lay=4
604 {1,1,1,1,34,23,1}, // lay=5
605 {1,1,1,1,38,26,1}};// lay=6
606
607 // Sorry, but this is not very pritty code. It should be replaced
608 // at some point with a version that can search through the geometry
609 // tree its self.
610 for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
611 for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++)
612 strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4);
613 // itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
614 mod = 0;
615 for(i=0;i<nlayers;i++){
616 k = 1;
617 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
618 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
619 mod += k;
620 } // end for i
621
622 if(fITSgeom!=0) delete fITSgeom;
623 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
624 ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
625 fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
626 mod = -1;
627 for(lay=1;lay<=nlayers;lay++){
628 for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
629 for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
630 switch (lay){
631 case 1: case 2: // layers 1 and 2 are a bit special
632 lad = 0;
633 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
634 lnum[4] = j;
635 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
636 lad++;
637 lnum[5] = k;
638 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
639 lnum[6] = det;
640 mod++;
641 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
642 par,att,imat,imed);
643 fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
644 if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
645 fITSgeom->ReSetShape(kSPD,
646 new AliITSgeomSPD300());
647 } // end for det
648 } // end for k
649 } // end for j
650 break;
651 case 3: case 4: case 5: case 6: // layers 3-6
652 lnum[6] = 1;
653 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
654 lnum[4] = lad;
655 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
656 lnum[5] = det;
657 mod++;
658 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
659 par,att,imat,imed);
660 switch (lay){
661 case 3: case 4:
662 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
663 if(!(fITSgeom->IsShapeDefined(kSDD)))
664 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
665 break;
666 case 5: case 6:
667 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
668 if(!(fITSgeom->IsShapeDefined(kSSD)))
669 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
670 break;
671 } // end switch
672 } // end for det
673 } // end for lad
674 break;
675 } // end switch
676 } // end for lay
677 return;
678}
679//_____________________________________________________________________________
680void AliITSv5::Init(){
681////////////////////////////////////////////////////////////////////////
682// Initialise the ITS after it has been created.
683////////////////////////////////////////////////////////////////////////
684 Int_t i;
685
686 cout << endl;
687 for(i=0;i<30;i++) cout << "*";cout << " ITSv5_Init ";
688 for(i=0;i<30;i++) cout << "*";cout << endl;
689//
690 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
691 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
692 if(fGeomDetIn && !fGeomOldDetIn){
693 if(fITSgeom!=0) delete fITSgeom;
694 fITSgeom = new AliITSgeom();
695 fITSgeom->ReadNewFile(fRead);
696 } // end if
697 if(fGeomDetIn && fGeomOldDetIn) ReadOldGeometry(fEuclidGeometry.Data());
698
699 if(!fGeomDetIn) this->InitAliITSgeom();
700 if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
701 AliITS::Init();
702//
703 for(i=0;i<72;i++) cout << "*";
704 cout << endl;
705}
706//_____________________________________________________________________________
707void AliITSv5::StepManager(){
708////////////////////////////////////////////////////////////////////////
709// Called for every step in the ITS, then calles the AliITShit class
710// creator with the information to be recoreded about that hit.
711// The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
712// printing of information to a file which can be used to create a .det
713// file read in by the routine CreateGeometry(). If set to 0 or any other
714// value except 1, the default behavior, then no such file is created nor
715// it the extra variables and the like used in the printing allocated.
716////////////////////////////////////////////////////////////////////////
717 Int_t copy, id;
718 Int_t copy1,copy2;
719 Float_t hits[8];
720 Int_t vol[4];
721 TLorentzVector position, momentum;
722 TClonesArray &lhits = *fHits;
723 //
724 // Track status
725 vol[3] = 0;
726 if(gMC->IsTrackInside()) vol[3] += 1;
727 if(gMC->IsTrackEntering()) vol[3] += 2;
728 if(gMC->IsTrackExiting()) vol[3] += 4;
729 if(gMC->IsTrackOut()) vol[3] += 8;
730 if(gMC->IsTrackDisappeared()) vol[3] += 16;
731 if(gMC->IsTrackStop()) vol[3] += 32;
732 if(gMC->IsTrackAlive()) vol[3] += 64;
733 //
734 // Fill hit structure.
735 if(!(gMC->TrackCharge())) return;
736 //
737 // Only entering charged tracks
738 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
739 vol[0] = 1;
740 id = gMC->CurrentVolOffID(0,copy);
741 //detector copy in the ladder = 1<->4 (ITS1)
742 vol[1] = copy;
743 gMC->CurrentVolOffID(1,copy1);
744 //ladder copy in the module = 1<->2 (I186)
745 gMC->CurrentVolOffID(2,copy2);
746 //module copy in the layer = 1<->10 (I132)
747 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
748 } else if(id == fIdSens[1]){
749 vol[0] = 2;
750 id = gMC->CurrentVolOffID(0,copy);
751 //detector copy in the ladder = 1<->4 (ITS2)
752 vol[1] = copy;
753 gMC->CurrentVolOffID(1,copy1);
754 //ladder copy in the module = 1<->4 (I131)
755 gMC->CurrentVolOffID(2,copy2);
756 //module copy in the layer = 1<->10 (I132)
757 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
758 } else if(id == fIdSens[2]){
759 vol[0] = 3;
760 id = gMC->CurrentVolOffID(1,copy);
761 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
762 vol[1] = copy;
763 id = gMC->CurrentVolOffID(2,copy);
764 //ladder copy in the layer = 1<->12 (I316)
765 vol[2] = copy;
766 } else if(id == fIdSens[3]){
767 vol[0] = 4;
768 id = gMC->CurrentVolOffID(1,copy);
769 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
770 vol[1] = copy;
771 id = gMC->CurrentVolOffID(2,copy);
772 //ladder copy in the layer = 1<->22 (I417)
773 vol[2] = copy;
774 }else if(id == fIdSens[4]){
775 vol[0] = 5;
776 id = gMC->CurrentVolOffID(1,copy);
777 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
778 vol[1] = copy;
779 id = gMC->CurrentVolOffID(2,copy);
780 //ladder copy in the layer = 1<->34 (I565)
781 vol[2] = copy;
782 }else if(id == fIdSens[5]){
783 vol[0] = 6;
784 id = gMC->CurrentVolOffID(1,copy);
785 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
786 vol[1] = copy;
787 id = gMC->CurrentVolOffID(2,copy);
788 //ladder copy in the layer = 1<->38 (I569)
789 vol[2] = copy;
790 } else {
791 return; // not an ITS volume?
792 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
793//
794 gMC->TrackPosition(position);
795 gMC->TrackMomentum(momentum);
796 hits[0]=position[0];
797 hits[1]=position[1];
798 hits[2]=position[2];
799 hits[3]=momentum[0];
800 hits[4]=momentum[1];
801 hits[5]=momentum[2];
802 hits[6]=gMC->Edep();
803 hits[7]=gMC->TrackTime();
804 // Fill hit structure with this new hit.
805 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
806 return;
807}