]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSv5symm.cxx
New version compatible with the current HEAD
[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$
18c21458 18Revision 1.8 2001/03/23 00:12:23 nilsen
19Set Reading of AliITSgeom data from Geant3 common blocks as the default and
20not a .det file. Removed redundent calls to BuildGeometry.
21
0646a0e8 22Revision 1.7 2001/02/13 16:53:35 nilsen
23Fixed a but when trying to use GEANT4. Needed to replace
24if(!((TGeant3*)gMC)) with if(!(dynamic_casst<TGeant3*>(gMC)))
25because just casting gMC to be TGeant3* even when it realy is a TGeant3 pointer
26did not result in a zero value. For AliITSv5asymm and AliITSv5symm, needed
27to fix a bug in the initilizers and a bug in BuildGeometry. This is now done
28in the same way as in AliITSv5.cxx.
29
9a4c6ea3 30Revision 1.6 2001/02/09 20:06:26 nilsen
31Fixed bug in distructor. Can't distroy fixxed length arrays. Thanks Peter.
32
58e13d99 33Revision 1.5 2001/02/09 00:05:31 nilsen
34Added fMajor/MinorVersion variables and made other changes to better make
35use of the new code changes in AliITSgeom related classes.
36
bae7e562 37Revision 1.4 2001/02/02 23:57:29 nilsen
38Added include file that are no londer included in AliITSgeom.h
39
d953664a 40Revision 1.3 2001/01/30 09:23:13 hristov
41Streamers removed (R.Brun)
42
a8a6107b 43Revision 1.2 2000/11/30 11:13:11 barbera
44 Added changes suggested by Federico Carminati on nov, 30, 2000
45
a07ced09 46Revision 1.1 2000/10/07 15:46:29 barbera
47Version 5 of the geometry with symmetric services
48
e5745edc 49Revision 1.25 2000/10/05 20:50:00 nilsen
50Now using root generated streamers.
51
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
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
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
71Revision 1.14 1999/10/22 08:16:49 fca
72Correct destructors, thanks to I.Hrivnacova
73
74Revision 1.13 1999/10/06 10:15:19 fca
75Correct bug in allocation of layer name and add destructor
76
77Revision 1.12 1999/10/05 08:05:09 fca
78Minor corrections for uninitialised variables.
79
80Revision 1.11 1999/09/29 09:24:20 fca
81Introduction of the Copyright and cvs Log
82
83*/
84
85///////////////////////////////////////////////////////////////////////////////
86//
87// Inner Traking System version 5 with symmetric services
88// This class contains the base procedures for the Inner Tracking System
89//
90// Authors: R. Barbera, B. S. Nilsen.
91// version 5.
92// Created October 7 2000.
93//
94///////////////////////////////////////////////////////////////////////////////
d953664a 95#include <iostream.h>
96#include <iomanip.h>
e5745edc 97#include <stdio.h>
98#include <stdlib.h>
99#include <TMath.h>
100#include <TGeometry.h>
101#include <TNode.h>
102#include <TTUBE.h>
103#include <TFile.h> // only required for Tracking function?
104#include <TCanvas.h>
105#include <TObjArray.h>
a07ced09 106#include <TLorentzVector.h>
e5745edc 107#include <TObjString.h>
108#include <TClonesArray.h>
109#include <TBRIK.h>
110#include <TSystem.h>
111
112#include "AliMC.h"
113#include "AliRun.h"
e5745edc 114#include "../TGeant3/TGeant3.h"
e5745edc 115#include "AliITShit.h"
bae7e562 116#include "AliITSGeant3Geometry.h"
e5745edc 117#include "AliITS.h"
118#include "AliITSv5symm.h"
119#include "AliITSgeom.h"
bae7e562 120#include "AliITSgeomSPD.h"
121#include "AliITSgeomSDD.h"
122#include "AliITSgeomSSD.h"
e5745edc 123
124ClassImp(AliITSv5symm)
125
126//_____________________________________________________________________________
127AliITSv5symm::AliITSv5symm() {
128////////////////////////////////////////////////////////////////////////
129// Standard default constructor for the ITS version 5.
130////////////////////////////////////////////////////////////////////////
bae7e562 131 Int_t i;
e5745edc 132
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 = 2;
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//_____________________________________________________________________________
147AliITSv5symm::AliITSv5symm(const char *name, const char *title) : AliITS(name, title){
148/////////////////////////////////////////////////////////////////////////////
149// Standard constructor for the ITS version 5 with symmetrical services.
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 = 2;
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_5symm.tme";
173 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.euc";
174 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_v5symm.det",60);
175 strncpy(fRead,fEuclidGeomDet,60);
176 strncpy(fWrite,fEuclidGeomDet,60);
e5745edc 177}
178//____________________________________________________________________________
179AliITSv5symm::AliITSv5symm(const AliITSv5symm &source){
180////////////////////////////////////////////////////////////////////////
181// Copy Constructor for ITS version 5.
182////////////////////////////////////////////////////////////////////////
183 if(&source == this) return;
bae7e562 184 Warning("Copy Constructor","Not allowed to copy AliITSv5symm");
e5745edc 185 return;
186}
187//_____________________________________________________________________________
188AliITSv5symm& AliITSv5symm::operator=(const AliITSv5symm &source){
189////////////////////////////////////////////////////////////////////////
bae7e562 190// Assignment operator for the ITS version 5.
e5745edc 191////////////////////////////////////////////////////////////////////////
192
193 if(&source == this) return *this;
bae7e562 194 Warning("= operator","Not allowed to copy AliITSv5symm");
e5745edc 195 return *this;
196
197}
198//_____________________________________________________________________________
199AliITSv5symm::~AliITSv5symm() {
200////////////////////////////////////////////////////////////////////////
201// Standard destructor for the ITS version 5.
202////////////////////////////////////////////////////////////////////////
e5745edc 203}
204//_____________________________________________________________________________
205void AliITSv5symm::BuildGeometry(){
206////////////////////////////////////////////////////////////////////////
207// Geometry builder for the ITS version 5.
208////////////////////////////////////////////////////////////////////////
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
214 TNode *top;
215 TNode *nd;
216 //const int kColorITSSPD=kRed;
217 //const int kColorITSSDD=kGreen;
218 const int kColorITSSSD=kBlue;
219 //
e5745edc 220 AliITSgeom *gm = this->GetITSgeom();
9a4c6ea3 221 if(gm==0) return;
222 top=gAlice->GetGeometry()->GetNode("alice");
e5745edc 223
224 Int_t lay,lad,det,i;
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
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++){
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);
246 for(i=0;i<9;i++) rtd[i] = rt[i];
247 try {
248 rm = new TRotMatrix(name,name,rtd);
249 } catch (...) {
250 cout << "EXCEPTION in new TRotMatrix" << endl;
251 return;
252 }
253 top->cd();
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 }
261 nd->SetLineColor(kColorITSSSD);
262 fNodes->Add(nd);
263 }
264
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++){
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);
278 for(i=0;i<9;i++) rtd[i] = rt[i];
279 try {
280 rm = new TRotMatrix(name,name,rtd);
281 } catch (...) {
282 cout << "EXCEPTION in new TRotMatrix" << endl;
283 return;
284 }
285 top->cd();
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 }
293 nd->SetLineColor(kColorITSSSD);
294 fNodes->Add(nd);
295 }
296
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++){
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);
310 for(i=0;i<9;i++) rtd[i] = rt[i];
311 try {
312 rm = new TRotMatrix(name,name,rtd);
313 } catch (...) {
314 cout << "EXCEPTION in new TRotMatrix" << endl;
315 return;
316 }
317 top->cd();
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 }
325 nd->SetLineColor(kColorITSSSD);
326 fNodes->Add(nd);
327 }
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++){
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);
341 for(i=0;i<9;i++) rtd[i] = rt[i];
342 try {
343 rm = new TRotMatrix(name,name,rtd);
344 } catch (...) {
345 cout << "EXCEPTION in new TRotMatrix" << endl;
346 return;
347 }
348 top->cd();
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 }
356 nd->SetLineColor(kColorITSSSD);
357 fNodes->Add(nd);
358 }
359
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++){
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);
374 for(i=0;i<9;i++) rtd[i] = rt[i];
375 try {
376 rm = new TRotMatrix(name,name,rtd);
377 } catch (...) {
378 cout << "EXCEPTION in new TRotMatrix" << endl;
379 return;
380 }
381 top->cd();
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 }
389 nd->SetLineColor(kColorITSSSD);
390 fNodes->Add(nd);
391 }
392
393
394}
395//_____________________________________________________________________________
396void AliITSv5symm::CreateMaterials(){
397////////////////////////////////////////////////////////////////////////
398// Read a file containing the materials for the ITS version 5.
399////////////////////////////////////////////////////////////////////////
400 char *filtmp;
401
402 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
403
404 FILE *file = fopen(filtmp,"r");
405 if(file) {
406 fclose(file);
407 ReadEuclidMedia(filtmp);
408 } else {
409 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
410 exit(1);
411 } // end if(file)
412}
413//_____________________________________________________________________________
414void AliITSv5symm::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/*
423<img src="picts/ITS/its1+2_convention_front_5.gif">
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>
430<img src="picts/ITS/its1+2_convention_side_5.gif">
431</pre>
432<br clear=left>
433<font size=+2 color=red>
434<p>This shows the perspective view of the SPDs.
435</font>
436<img src="picts/ITS/its1+2_tree.gif">
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>
445<img src="picts/ITS/its3+4_convention_front_5.gif">
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>
452<img src="picts/ITS/its3+4_convention_side_5.gif">
453</pre>
454<br clear=left>
455<font size=+2 color=red>
456<p>This shows the perspective view of the SDDs.
457</font>
458<img src="picts/ITS/its3+4_tree.gif">
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>
465
466<pre>
467<img src="picts/ITS/its5+6_convention_front_5.gif">
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>
474<img src="picts/ITS/its5+6_convention_side_5.gif">
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>
481<img src="picts/ITS/its5+6_tree.gif">
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
490<img src="picts/ITS/its_layer1-6_2.gif">
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
498<img src="picts/ITS/its_layer1-6_1.gif">
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
506<img src="picts/ITS/its1-6_tree.gif">
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//
516//
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/*
522<img src="picts/ITS/supports_tree.gif">
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
530<img src="picts/ITS/supports_3.gif">
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
538<img src="picts/ITS/supports_2.gif">
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
546<img src="picts/ITS/supports_1.gif">
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
554<img src="picts/ITS/suppssd.gif">
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
562<img src="picts/ITS/suppsdd.gif">
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
571//
572// Read a file containing the geometry for the ITS version 5.
573////////////////////////////////////////////////////////////////////////
e5745edc 574 char topvol[5];
575 char *filtmp;
576
577 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
578 FILE *file = fopen(filtmp,"r");
579 delete [] filtmp;
580 if(file) {
581 fclose(file);
582 printf("Ready to read Euclid geometry file\n");
583 ReadEuclid(fEuclidGeometry.Data(),topvol);
584 printf("Read in euclid geometries\n");
585 } else {
586 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
587 fEuclidGeometry.Data());
588 exit(1);
589 } // end if(file)
590 //
591 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
592 // invisible
593 //
594 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
595 //
596 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
597
598 if (fEuclidOut) {
599 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
600 } // end if (fEuclidOut)
bae7e562 601 cout << "finished with euclid geometrys" << endl;
602}
603//______________________________________________________________________
604void AliITSv5symm::ReadOldGeometry(const char *filename){
e5745edc 605 // read in the file containing the transformations for the active
606 // volumes for the ITS version 5. This is expected to be in a file
607 // ending in .det. This geometry is kept in the AliITSgeom class.
bae7e562 608 Int_t size;
609 char *filtmp;
610 FILE *file;
611
612 filtmp = gSystem->ExpandPathName(filename);
e5745edc 613 size = strlen(filtmp);
bae7e562 614 if(size>4 && fGeomDetIn){
615 filtmp[size-3] = 'd'; // change from .euc to .det
e5745edc 616 filtmp[size-2] = 'e';
617 filtmp[size-1] = 't';
bae7e562 618 file = fopen(filtmp,"r");
619 if(file){ // if file exists use it to fill AliITSgeom structure.
620 fclose(file);
621 fITSgeom = new AliITSgeom(filtmp);
622 fITSgeom->DefineShapes(3); // if fShape isn't defined define it.
623 // Now define the detector types/shapes.
624 fITSgeom->ReSetShape(kSPD,(TObject *) new AliITSgeomSPD300());
625 fITSgeom->ReSetShape(kSDD,(TObject *) new AliITSgeomSDD300());
626 fITSgeom->ReSetShape(kSSD,(TObject *) new AliITSgeomSSD());
627 }else{
628 fITSgeom = 0;
629 // fill AliITSgeom structure from geant structure just filled above
630 }// end if(file)
e5745edc 631 delete [] filtmp;
632 }// end if(size>4)
bae7e562 633}
634//______________________________________________________________________
635void AliITSv5symm::InitAliITSgeom(){
636// Based on the geometry tree defined in Geant 3.21, this
637// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
638// sturture.
9a4c6ea3 639 if(!(dynamic_cast<TGeant3*>(gMC))) {
bae7e562 640 Error("InitAliITSgeom",
641 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
642 return;
643 } // end if
644 cout << "Reading Geometry transformation directly from Geant 3." << endl;
645 const Int_t nlayers = 6;
646 const Int_t ndeep = 7;
647 Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
648 Int_t nlad[nlayers],ndet[nlayers];
649 Double_t t[3],r[10];
650 Float_t par[20],att[20];
651 Int_t npar,natt,idshape,imat,imed;
652 AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
653 Int_t mod,lay,lad,det,i,j,k;
654 char *names[nlayers][ndeep] = {
655 {"ALIC","ITSV","ITSD","IT12","I132","I186","ITS1"}, // lay=1
656 {"ALIC","ITSV","ITSD","IT12","I132","I131","ITS2"}, // lay=2
657 {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"}, // lay=3
658 {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"}, // lay=4
659 {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"}, // lay=5
660 {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"}};// lay=6
661 Int_t itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2,4}, // lay=1
662 {1,1,1,1,10, 4,4}, // lay=2
663 {1,1,1,1,14, 6,1}, // lay=3
664 {1,1,1,1,22, 8,1}, // lay=4
665 {1,1,1,1,34,23,1}, // lay=5
666 {1,1,1,1,38,26,1}};// lay=6
667
668 // Sorry, but this is not very pritty code. It should be replaced
669 // at some point with a version that can search through the geometry
670 // tree its self.
671 cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
672 for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
673 for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++)
674 itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
675 mod = 0;
676 for(i=0;i<nlayers;i++){
677 k = 1;
678 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
679 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
680 mod += k;
681 } // end for i
682
683 if(fITSgeom!=0) delete fITSgeom;
684 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
18c21458 685 ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=23;ndet[5]=26;
bae7e562 686 fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
687 mod = -1;
688 for(lay=1;lay<=nlayers;lay++){
689 for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
690 for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
691 switch (lay){
692 case 1: case 2: // layers 1 and 2 are a bit special
693 lad = 0;
694 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
695 lnum[4] = j;
696 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
697 lad++;
698 lnum[5] = k;
699 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
700 lnum[6] = det;
701 mod++;
702 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
703 par,att,imat,imed);
704 fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
705 if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
706 if(fMinorVersion==1){
707 fITSgeom->ReSetShape(kSPD,
708 new AliITSgeomSPD300());
709 } else if(fMinorVersion==2)
710 fITSgeom->ReSetShape(kSPD,
711 new AliITSgeomSPD300());
712 } // end for det
713 } // end for k
714 } // end for j
715 break;
716 case 3: case 4: case 5: case 6: // layers 3-6
717 lnum[6] = 1;
718 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
719 lnum[4] = lad;
720 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
721 lnum[5] = det;
722 mod++;
723 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
724 par,att,imat,imed);
725 switch (lay){
726 case 3: case 4:
727 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
728 if(!(fITSgeom->IsShapeDefined(kSDD)))
729 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
730 break;
731 case 5: case 6:
732 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
733 if(!(fITSgeom->IsShapeDefined(kSSD)))
734 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
735 break;
736 } // end switch
737 } // end for det
738 } // end for lad
739 break;
740 } // end switch
741 } // end for lay
742 return;
e5745edc 743}
744//_____________________________________________________________________________
745void AliITSv5symm::Init(){
746////////////////////////////////////////////////////////////////////////
747// Initialise the ITS after it has been created.
748////////////////////////////////////////////////////////////////////////
bae7e562 749 Int_t i;
e5745edc 750
bae7e562 751 cout << endl;
0646a0e8 752 for(i=0;i<28;i++) cout << "*";cout << " ITSv5symm_Init ";
753 for(i=0;i<28;i++) cout << "*";cout << endl;
bae7e562 754//
755 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
756 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
757 if(fITSgeom!=0) delete fITSgeom;
758 fITSgeom = new AliITSgeom();
759 if(fGeomDetIn && !fGeomOldDetIn) fITSgeom->ReadNewFile(fRead);
760 if(fGeomDetIn && fGeomOldDetIn) this->ReadOldGeometry(fRead);
761
762 if(!fGeomDetIn) this->InitAliITSgeom();
763 if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
e5745edc 764 AliITS::Init();
bae7e562 765//
766 for(i=0;i<72;i++) cout << "*";
767 cout << endl;
e5745edc 768}
769//_____________________________________________________________________________
770void AliITSv5symm::StepManager(){
771////////////////////////////////////////////////////////////////////////
772// Called for every step in the ITS, then calles the AliITShit class
773// creator with the information to be recoreded about that hit.
774// The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
775// printing of information to a file which can be used to create a .det
776// file read in by the routine CreateGeometry(). If set to 0 or any other
777// value except 1, the default behavior, then no such file is created nor
778// it the extra variables and the like used in the printing allocated.
779////////////////////////////////////////////////////////////////////////
780 Int_t copy, id;
781 Int_t copy1,copy2;
782 Float_t hits[8];
783 Int_t vol[4];
784 TLorentzVector position, momentum;
785 TClonesArray &lhits = *fHits;
e5745edc 786 //
787 // Track status
788 vol[3] = 0;
789 if(gMC->IsTrackInside()) vol[3] += 1;
790 if(gMC->IsTrackEntering()) vol[3] += 2;
791 if(gMC->IsTrackExiting()) vol[3] += 4;
792 if(gMC->IsTrackOut()) vol[3] += 8;
793 if(gMC->IsTrackDisappeared()) vol[3] += 16;
794 if(gMC->IsTrackStop()) vol[3] += 32;
795 if(gMC->IsTrackAlive()) vol[3] += 64;
796 //
797 // Fill hit structure.
798 if(!(gMC->TrackCharge())) return;
799 //
800 // Only entering charged tracks
801 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
802 vol[0] = 1;
803 id = gMC->CurrentVolOffID(0,copy);
804 //detector copy in the ladder = 1<->4 (ITS1)
805 vol[1] = copy;
806 gMC->CurrentVolOffID(1,copy1);
807 //ladder copy in the module = 1<->2 (I186)
808 gMC->CurrentVolOffID(2,copy2);
809 //module copy in the layer = 1<->10 (I132)
810 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
811 } else if(id == fIdSens[1]){
812 vol[0] = 2;
813 id = gMC->CurrentVolOffID(0,copy);
814 //detector copy in the ladder = 1<->4 (ITS2)
815 vol[1] = copy;
816 gMC->CurrentVolOffID(1,copy1);
817 //ladder copy in the module = 1<->4 (I131)
818 gMC->CurrentVolOffID(2,copy2);
819 //module copy in the layer = 1<->10 (I132)
820 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
821 } else if(id == fIdSens[2]){
822 vol[0] = 3;
823 id = gMC->CurrentVolOffID(1,copy);
824 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
825 vol[1] = copy;
826 id = gMC->CurrentVolOffID(2,copy);
827 //ladder copy in the layer = 1<->12 (I316)
828 vol[2] = copy;
829 } else if(id == fIdSens[3]){
830 vol[0] = 4;
831 id = gMC->CurrentVolOffID(1,copy);
832 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
833 vol[1] = copy;
834 id = gMC->CurrentVolOffID(2,copy);
835 //ladder copy in the layer = 1<->22 (I417)
836 vol[2] = copy;
837 }else if(id == fIdSens[4]){
838 vol[0] = 5;
839 id = gMC->CurrentVolOffID(1,copy);
840 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
841 vol[1] = copy;
842 id = gMC->CurrentVolOffID(2,copy);
843 //ladder copy in the layer = 1<->34 (I565)
844 vol[2] = copy;
845 }else if(id == fIdSens[5]){
846 vol[0] = 6;
847 id = gMC->CurrentVolOffID(1,copy);
848 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
849 vol[1] = copy;
850 id = gMC->CurrentVolOffID(2,copy);
851 //ladder copy in the layer = 1<->38 (I569)
852 vol[2] = copy;
853 } else {
854 return; // not an ITS volume?
855 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
856//
857 gMC->TrackPosition(position);
858 gMC->TrackMomentum(momentum);
859 hits[0]=position[0];
860 hits[1]=position[1];
861 hits[2]=position[2];
862 hits[3]=momentum[0];
863 hits[4]=momentum[1];
864 hits[5]=momentum[2];
865 hits[6]=gMC->Edep();
866 hits[7]=gMC->TrackTime();
867 // Fill hit structure with this new hit.
868 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
e5745edc 869 return;
870}