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