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