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