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