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