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