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