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