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