Updated for coding convenstions compilation errors and warnings and the like.
[u/mrichter/AliRoot.git] / ITS / AliITSv5.cxx
CommitLineData
4c039060 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$
481937a6 18Revision 1.14.4.9 2000/06/12 19:14:51 barbera
19Remove partical transision to new Config.C calling convension. Bug Found.
20
21Revision 1.14.4.8 2000/06/12 18:15:52 barbera
22fixed posible compilation errors on HP unix. Modifided default constructor
23for use with new calling requirements.
24
25Revision 1.14.4.7 2000/06/11 20:37:59 barbera
26coding convenstion update.
27
855190cc 28Revision 1.14.4.4 2000/05/19 10:10:21 nilsen
29fix for bug with HP and Sun unix + fix for event display in ITS-working branch
fc0f0f90 30
31Revision 1.14.4.3 2000/03/04 23:46:38 nilsen
32Fixed up the comments/documentation.
33
34Revision 1.14.4.2 2000/03/02 21:53:02 nilsen
35To make it compatable with the changes in AliRun/AliModule.
36
37Revision 1.14.4.1 2000/01/12 19:03:33 nilsen
38This is the version of the files after the merging done in December 1999.
39See the ReadMe110100.txt file for details
40
b13db077 41Revision 1.14 1999/10/22 08:16:49 fca
42Correct destructors, thanks to I.Hrivnacova
43
5b8cc8df 44Revision 1.13 1999/10/06 10:15:19 fca
45Correct bug in allocation of layer name and add destructor
46
1ef401ff 47Revision 1.12 1999/10/05 08:05:09 fca
48Minor corrections for uninitialised variables.
49
593d2ea1 50Revision 1.11 1999/09/29 09:24:20 fca
51Introduction of the Copyright and cvs Log
52
4c039060 53*/
54
fe4da5cc 55///////////////////////////////////////////////////////////////////////////////
fc0f0f90 56//
57// Inner Traking System version 5
58// This class contains the base procedures for the Inner Tracking System
59//
58005f18 60// Authors: R. Barbera, B. S. Nilsen.
61// version 5.
62// Created September 17 1999.
fc0f0f90 63//
fe4da5cc 64///////////////////////////////////////////////////////////////////////////////
65
fc0f0f90 66// See AliITSv5::StepManager().
67#define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
68//#define ALIITSPRINTGEOM 1 // print out geometry information
69
58005f18 70#include <stdio.h>
71#include <stdlib.h>
fe4da5cc 72#include <TMath.h>
c9a71be1 73#include <TGeometry.h>
74#include <TNode.h>
75#include <TTUBE.h>
855190cc 76#include <TFile.h> // only required for Tracking function?
77#include <TCanvas.h>
78#include <TObjArray.h>
79#include <TClonesArray.h>
58005f18 80
fe4da5cc 81#include "AliRun.h"
fe4da5cc 82#include "TSystem.h"
fc0f0f90 83#if ALIITSPRINTGEOM==1
84#include "../TGeant3/TGeant3.h"
85#endif
58005f18 86#include "AliITShit.h"
87#include "AliITS.h"
88#include "AliITSv5.h"
89#include "AliITSgeom.h"
fe4da5cc 90
91ClassImp(AliITSv5)
92
93//_____________________________________________________________________________
481937a6 94 AliITSv5::AliITSv5()/*:AliITS("ITS","TDR version")*/{
fc0f0f90 95////////////////////////////////////////////////////////////////////////
96// Standard default constructor for the ITS version 5.
97////////////////////////////////////////////////////////////////////////
1ef401ff 98 fId5N = 6;
58005f18 99 fId5Name = new char*[fId5N];
100 fId5Name[0] = "ITS1";
101 fId5Name[1] = "ITS2";
102 fId5Name[2] = "ITS3";
103 fId5Name[3] = "ITS4";
104 fId5Name[4] = "ITS5";
105 fId5Name[5] = "ITS6";
481937a6 106
107 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
108 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
109 printf("Created ITS TDR Detailed version reading geometry from file\n");
fe4da5cc 110}
855190cc 111//____________________________________________________________________________
112AliITSv5::AliITSv5(const AliITSv5 &source){
113////////////////////////////////////////////////////////////////////////
114// Copy Constructor for ITS version 5.
115////////////////////////////////////////////////////////////////////////
116 if(&source == this) return;
117 this->fId5N = source.fId5N;
118 this->fId5Name = new char*[fId5N];
481937a6 119 Int_t i;
120 for(i=0;i<6;i++) strcpy(this->fId5Name[i],source.fId5Name[i]);
121 return;
855190cc 122}
123//_____________________________________________________________________________
124AliITSv5& AliITSv5::operator=(const AliITSv5 &source){
125////////////////////////////////////////////////////////////////////////
126// Assignment operator for the ITS version 1.
127////////////////////////////////////////////////////////////////////////
481937a6 128 if(&source == this) return *this;
129 this->fId5N = source.fId5N;
130 this->fId5Name = new char*[fId5N];
131 Int_t i;
132 for(i=0;i<6;i++) strcpy(this->fId5Name[i],source.fId5Name[i]);
133 return *this;
855190cc 134}
fe4da5cc 135//_____________________________________________________________________________
1ef401ff 136AliITSv5::~AliITSv5() {
fc0f0f90 137////////////////////////////////////////////////////////////////////////
138// Standard destructor for the ITS version 5.
139////////////////////////////////////////////////////////////////////////
1ef401ff 140 delete [] fId5Name;
1ef401ff 141}
142//_____________________________________________________________________________
58005f18 143AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
fc0f0f90 144////////////////////////////////////////////////////////////////////////
145// Standard constructor for the ITS version 5.
146////////////////////////////////////////////////////////////////////////
58005f18 147 fId5N = 6;
148 fId5Name = new char*[fId5N];
149 fId5Name[0] = "ITS1";
150 fId5Name[1] = "ITS2";
151 fId5Name[2] = "ITS3";
152 fId5Name[3] = "ITS4";
153 fId5Name[4] = "ITS5";
154 fId5Name[5] = "ITS6";
155
156 fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
157 fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
481937a6 158 printf("Created ITS TDR Detailed version reading geometry from file\n");
c9a71be1 159}
160//_____________________________________________________________________________
161void AliITSv5::BuildGeometry(){
855190cc 162////////////////////////////////////////////////////////////////////////
163// Geometry builder for the ITS version 5.
164////////////////////////////////////////////////////////////////////////
c9a71be1 165 //
166 // Build ITS TNODE geometry for event display using detailed geometry.
167 // This function builds a simple ITS geometry used by the ROOT macro
168 // ITSdisplay.C.
169
855190cc 170 TNode *top;
c9a71be1 171 TNode *nd;
481937a6 172 //const Int_t kColorITSSPD=kRed;
173 //const Int_t kColorITSSDD=kGreen;
174 const Int_t kColorITSSSD=kBlue;
c9a71be1 175 //
855190cc 176 top=gAlice->GetGeometry()->GetNode("alice");
c9a71be1 177 AliITSgeom *gm = this->GetITSgeom();
178
24314ecd 179 Int_t lay,lad,det,i;
c9a71be1 180 Text_t name[10];
181 Float_t xg[3];
182 Float_t rt[9];
183 Double_t rtd[9];
184 TBRIK *box;
185 TRotMatrix *rm;
186 //TCanvas *c1 = new TCanvas("c1","ITS");
187
24314ecd 188 for(lay=1;lay<=2;lay++)
189 for(lad=1;lad<=gm->GetNladders(lay);lad++)
190 for(det=1;det<=gm->GetNdetectors(lay);det++){
c9a71be1 191 try {
192 box = new TBRIK ("ActiveSPD","Active volume of SPD","SPD SI DET",
193 0.64,0.0075,4.19);
194 } catch (...) {
195 cout << "EXCEPTION in box = new TBRIK" << endl;
196 return;
197 }
198 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
199 gm->GetRotMatrix(lay,lad,det,rt);
200 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
ca9d4947 201 for(i=0;i<9;i++) rtd[i] = rt[i];
c9a71be1 202 try {
203 rm = new TRotMatrix(name,name,rtd);
204 } catch (...) {
205 cout << "EXCEPTION in new TRotMatrix" << endl;
206 return;
207 }
855190cc 208 top->cd();
c9a71be1 209 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
210 try {
211 nd = new TNode("SPD"," ",box,xg[0],xg[1],xg[2],rm);
212 } catch (...) {
213 cout << "EXCEPTION in new TNode" << endl;
214 return;
215 }
855190cc 216 nd->SetLineColor(kColorITSSSD);
c9a71be1 217 fNodes->Add(nd);
218 }
219
24314ecd 220 for(lay=3;lay<=3;lay++)
221 for(lad=1;lad<=gm->GetNladders(lay);lad++)
222 for(det=1;det<=gm->GetNdetectors(lay);det++){
c9a71be1 223 try {
224 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
225 3.5,0.014,3.763);
226 } catch (...) {
227 cout << "EXCEPTION in box = new TBRIK" << endl;
228 return;
229 }
230 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
231 gm->GetRotMatrix(lay,lad,det,rt);
232 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
ca9d4947 233 for(i=0;i<9;i++) rtd[i] = rt[i];
c9a71be1 234 try {
235 rm = new TRotMatrix(name,name,rtd);
236 } catch (...) {
237 cout << "EXCEPTION in new TRotMatrix" << endl;
238 return;
239 }
855190cc 240 top->cd();
c9a71be1 241 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
242 try {
243 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
244 } catch (...) {
245 cout << "EXCEPTION in new TNode" << endl;
246 return;
247 }
855190cc 248 nd->SetLineColor(kColorITSSSD);
c9a71be1 249 fNodes->Add(nd);
250 }
251
24314ecd 252 for(lay=4;lay<=4;lay++)
253 for(lad=1;lad<=gm->GetNladders(lay);lad++)
254 for(det=1;det<=gm->GetNdetectors(lay);det++){
c9a71be1 255 try {
256 box = new TBRIK ("ActiveSDD","Active volume of SDD","SDD SI DET",
257 3.5,0.014,3.763);
258 } catch (...) {
259 cout << "EXCEPTION in box = new TBRIK" << endl;
260 return;
261 }
262 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
263 gm->GetRotMatrix(lay,lad,det,rt);
264 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
ca9d4947 265 for(i=0;i<9;i++) rtd[i] = rt[i];
c9a71be1 266 try {
267 rm = new TRotMatrix(name,name,rtd);
268 } catch (...) {
269 cout << "EXCEPTION in new TRotMatrix" << endl;
270 return;
271 }
855190cc 272 top->cd();
c9a71be1 273 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
274 try {
275 nd = new TNode("SDD"," ",box,xg[0],xg[1],xg[2],rm);
276 } catch (...) {
277 cout << "EXCEPTION in new TNode" << endl;
278 return;
279 }
855190cc 280 nd->SetLineColor(kColorITSSSD);
c9a71be1 281 fNodes->Add(nd);
282 }
24314ecd 283 for(lay=5;lay<=5;lay++)
284 for(lad=1;lad<=gm->GetNladders(lay);lad++)
285 for(det=1;det<=gm->GetNdetectors(lay);det++){
c9a71be1 286 try {
287 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
288 3.65,0.015,2.0);
289 } catch (...) {
290 cout << "EXCEPTION in box = new TBRIK" << endl;
291 return;
292 }
293 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
294 gm->GetRotMatrix(lay,lad,det,rt);
295 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
ca9d4947 296 for(i=0;i<9;i++) rtd[i] = rt[i];
c9a71be1 297 try {
298 rm = new TRotMatrix(name,name,rtd);
299 } catch (...) {
300 cout << "EXCEPTION in new TRotMatrix" << endl;
301 return;
302 }
855190cc 303 top->cd();
c9a71be1 304 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
305 try {
306 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
307 } catch (...) {
308 cout << "EXCEPTION in new TNode" << endl;
309 return;
310 }
855190cc 311 nd->SetLineColor(kColorITSSSD);
c9a71be1 312 fNodes->Add(nd);
313 }
314
24314ecd 315 for(lay=6;lay<=6;lay++)
316 for(lad=1;lad<=gm->GetNladders(lay);lad++)
317 for(det=1;det<=gm->GetNdetectors(lay);det++){
c9a71be1 318 try {
319 box = new TBRIK ("ActiveSSD","Active volume of SSD","SSD SI DET",
320 3.65,0.015,2.0);
321 } catch (...) {
322 cout << "EXCEPTION in box = new TBRIK" << endl;
323 return;
324 }
325
326 gm->GetTrans(lay,lad,det,xg[0],xg[1],xg[2]);
327 gm->GetRotMatrix(lay,lad,det,rt);
328 //sprintf(name,"ROT%1.1d2.2d2.2d",lay,lad,det);
24314ecd 329 for(i=0;i<9;i++) rtd[i] = rt[i];
c9a71be1 330 try {
331 rm = new TRotMatrix(name,name,rtd);
332 } catch (...) {
333 cout << "EXCEPTION in new TRotMatrix" << endl;
334 return;
335 }
855190cc 336 top->cd();
c9a71be1 337 //sprintf(name,"ND%1.1d2.2d2.2d",lay,lad,det);
338 try {
339 nd = new TNode("SSD"," ",box,xg[0],xg[1],xg[2],rm);
340 } catch (...) {
341 cout << "EXCEPTION in new TNode" << endl;
342 return;
343 }
855190cc 344 nd->SetLineColor(kColorITSSSD);
c9a71be1 345 fNodes->Add(nd);
346 }
347
348
855190cc 349}
fe4da5cc 350//_____________________________________________________________________________
58005f18 351void AliITSv5::CreateMaterials(){
fc0f0f90 352////////////////////////////////////////////////////////////////////////
353// Read a file containing the materials for the ITS version 5.
354////////////////////////////////////////////////////////////////////////
58005f18 355 char *filtmp;
fc0f0f90 356
58005f18 357 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
fc0f0f90 358
1808a5a2 359 FILE *file = fopen(filtmp,"r");
fe4da5cc 360 if(file) {
361 fclose(file);
b13db077 362 ReadEuclidMedia(filtmp);
fe4da5cc 363 } else {
fc0f0f90 364 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",filtmp);
fe4da5cc 365 exit(1);
58005f18 366 } // end if(file)
fe4da5cc 367}
fe4da5cc 368//_____________________________________________________________________________
58005f18 369void AliITSv5::CreateGeometry(){
370//////////////////////////////////////////////////////////////////////
371// This is the geometry used for the ITS Pre-TDR and comes from an
372// Euclid to Geant conversion. The only difference
373// is in the details of the ITS supports. The detectors elements,
374// detector numbering, and local and global reference frames are shown in
375// the following figures.
376//Begin_Html
377/*
a92b2b7d 378<img src="picts/ITS/its1+2_convention_front_5.gif">
58005f18 379</pre>
380<br clear=left>
381<font size=+2 color=red>
382<p>This shows the front view of the SPDs.
383</font>
384<pre>
a92b2b7d 385<img src="picts/ITS/its1+2_convention_side_5.gif">
58005f18 386</pre>
387<br clear=left>
388<font size=+2 color=red>
389<p>This shows the perspective view of the SPDs.
390</font>
a92b2b7d 391<img src="picts/ITS/its1+2_tree.gif">
58005f18 392</pre>
393<br clear=left>
394<font size=+2 color=red>
395<p>This shows the geometry Tree for the SPDs.
396</font>
397<pre>
398
399<pre>
a92b2b7d 400<img src="picts/ITS/its3+4_convention_front_5.gif">
58005f18 401</pre>
402<br clear=left>
403<font size=+2 color=red>
404<p>This shows the front view of the SDDs.
405</font>
406<pre>
a92b2b7d 407<img src="picts/ITS/its3+4_convention_side_5.gif">
58005f18 408</pre>
409<br clear=left>
410<font size=+2 color=red>
411<p>This shows the perspective view of the SDDs.
412</font>
a92b2b7d 413<img src="picts/ITS/its3+4_tree.gif">
58005f18 414</pre>
415<br clear=left>
416<font size=+2 color=red>
417<p>This shows the geometry Tree for the SDDs.
418</font>
419<pre>
fe4da5cc 420
58005f18 421<pre>
a92b2b7d 422<img src="picts/ITS/its5+6_convention_front_5.gif">
58005f18 423</pre>
424<br clear=left>
425<font size=+2 color=red>
426<p>This shows the front view of the SSDs.
427</font>
428<pre>
a92b2b7d 429<img src="picts/ITS/its5+6_convention_side_5.gif">
58005f18 430</pre>
431<br clear=left>
432<font size=+2 color=red>
433<p>This shows the perspective view of the SSDs.
434</font>
435<pre>
a92b2b7d 436<img src="picts/ITS/its5+6_tree.gif">
58005f18 437</pre>
438<br clear=left>
439<font size=+2 color=red>
440<p>This shows the geometry Tree for the SSDs.
441</font>
442<pre>
443
444
a92b2b7d 445<img src="picts/ITS/its_layer1-6_2.gif">
58005f18 446</pre>
447<br clear=left>
448<font size=+2 color=red>
449<p>This shows the front view of the whole ITS..
450</font>
451<pre>
452
a92b2b7d 453<img src="picts/ITS/its_layer1-6_1.gif">
58005f18 454</pre>
455<br clear=left>
456<font size=+2 color=red>
457<p>This shows the perspective view of the whole ITS..
458</font>
459<pre>
460
a92b2b7d 461<img src="picts/ITS/its1-6_tree.gif">
58005f18 462</pre>
463<br clear=left>
464<font size=+2 color=red>
465<p>This shows the geometry Tree for the whole ITS.
466</font>
467<pre>
468*/
469//End_Html
470//
fe4da5cc 471//
58005f18 472// Here are shown the details of the ITS support cones and services.
473// First is a GEANT tree showing the organization of all of the volumes
474// that make up the ITS supports and services.
475//Begin_Html
476/*
a92b2b7d 477<img src="picts/ITS/supports_tree.gif">
58005f18 478 */
479//End_Html
480// What follows are a number of figures showing what these support
481// structures look like.
482//Begin_Html
483/*
484
a92b2b7d 485<img src="picts/ITS/supports_3.gif">
58005f18 486</pre>
487<br clear=left>
488<font size=+2 color=red>
489<p>This shows the geometry of the supports for the Drift and Strip layers only.
490</font>
491<pre>
492
a92b2b7d 493<img src="picts/ITS/supports_2.gif">
58005f18 494</pre>
495<br clear=left>
496<font size=+2 color=red>
497<p>This shows the geometry of the supports for the Drift and Strip layers in front cut out.
498</font>
499<pre>
500
a92b2b7d 501<img src="picts/ITS/supports_1.gif">
58005f18 502</pre>
503<br clear=left>
504<font size=+2 color=red>
505<p>This shows the geometry of the supports for the Drift and Strip layers in a back cut out..
506</font>
507<pre>
508
a92b2b7d 509<img src="picts/ITS/suppssd.gif">
58005f18 510</pre>
511<br clear=left>
512<font size=+2 color=red>
513<p>This shows the geometry for the Strip layers supports.
514</font>
515<pre>
516
a92b2b7d 517<img src="picts/ITS/suppsdd.gif">
58005f18 518</pre>
519<br clear=left>
520<font size=+2 color=red>
521<p>This shows the geometry for the Drift layers supports.
522</font>
523<pre>
524 */
525//End_Html
58005f18 526//
fc0f0f90 527// Read a file containing the geometry for the ITS version 5.
528////////////////////////////////////////////////////////////////////////
58005f18 529
530 Int_t size;
531 char topvol[5];
532 char *filtmp;
fc0f0f90 533
58005f18 534 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
fe4da5cc 535 FILE *file = fopen(filtmp,"r");
536 delete [] filtmp;
537 if(file) {
538 fclose(file);
58005f18 539 printf("Ready to read Euclid geometry file\n");
b13db077 540 ReadEuclid(fEuclidGeometry.Data(),topvol);
58005f18 541 printf("Read in euclid geometries\n");
fe4da5cc 542 } else {
58005f18 543 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
544 fEuclidGeometry.Data());
fe4da5cc 545 exit(1);
58005f18 546 } // end if(file)
fe4da5cc 547 //
fc0f0f90 548 // Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
549 // invisible
fe4da5cc 550 //
cfce8870 551 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
fe4da5cc 552 //
fc0f0f90 553 // Outputs the geometry tree in the EUCLID/CAD format if requested to do so
fe4da5cc 554
555 if (fEuclidOut) {
cfce8870 556 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
58005f18 557 } // end if (fEuclidOut)
558
fc0f0f90 559 // read in the file containing the transformations for the active
560 // volumes for the ITS version 5. This is expected to be in a file
561 // ending in .det. This geometry is kept in the AliITSgeom class.
58005f18 562 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
563 size = strlen(filtmp);
564 if(size>4){
565 filtmp[size-3] = 'd'; // change from .euc to .det
566 filtmp[size-2] = 'e';
567 filtmp[size-1] = 't';
568 file = fopen(filtmp,"r");
569 if(file){ // if file exists use it to fill AliITSgeom structure.
570 fclose(file);
571 printf("ready to read .det file %s\n",filtmp);
572 fITSgeom = new AliITSgeom(filtmp);
573 }else{
574 fITSgeom = 0;
575 // fill AliITSgeom structure from geant structure just filled above
576 }// end if(file)
577 delete [] filtmp;
578 }// end if(size>4)
579 printf("finished with euclid geometrys\n");
fe4da5cc 580}
fe4da5cc 581//_____________________________________________________________________________
58005f18 582void AliITSv5::Init(){
fc0f0f90 583////////////////////////////////////////////////////////////////////////
584// Initialise the ITS after it has been created.
585////////////////////////////////////////////////////////////////////////
58005f18 586 Int_t i,j,l;
587
588 fIdN = fId5N;
589 fIdName = new char*[fId5N];
590 fIdSens = new Int_t[fId5N];
591 for(i=0;i<fId5N;i++) {
592 l = strlen(fId5Name[i]);
593 fIdName[i] = new char[l+1];
594 for(j=0;j<l;j++) fIdName[i][j] = fId5Name[i][j];
595 fIdName[i][l] = '\0'; // Null terminate this string.
596 } // end for i
597
598 AliITS::Init();
c9a71be1 599 fMajorVersion = 5;
600 fMinorVersion = 0;
fe4da5cc 601}
fe4da5cc 602//_____________________________________________________________________________
58005f18 603void AliITSv5::StepManager(){
fc0f0f90 604////////////////////////////////////////////////////////////////////////
605// Called for every step in the ITS, then calles the AliITShit class
606// creator with the information to be recoreded about that hit.
607// The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
608// printing of information to a file which can be used to create a .det
609// file read in by the routine CreateGeometry(). If set to 0 or any other
610// value except 1, the default behavior, then no such file is created nor
611// it the extra variables and the like used in the printing allocated.
612////////////////////////////////////////////////////////////////////////
58005f18 613 Int_t copy, id;
614 Int_t copy1,copy2;
615 Float_t hits[8];
616 Int_t vol[4];
0a6d8768 617 TLorentzVector position, momentum;
58005f18 618 TClonesArray &lhits = *fHits;
fc0f0f90 619#if ALIITSPRINTGEOM==1
620 FILE *fp;
621 Int_t i;
622 Float_t xl[3],xt[3],angl[6];
623// Float_t par[20],att[20];
624 Float_t mat[9];
625 static Bool_t first=kTRUE,printit[6][50][50];
626 if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
627 for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
628 first = kFALSE;
629 }
630 // end if first
631#endif
fe4da5cc 632 //
58005f18 633 // Track status
634 vol[3] = 0;
635 if(gMC->IsTrackInside()) vol[3] += 1;
636 if(gMC->IsTrackEntering()) vol[3] += 2;
637 if(gMC->IsTrackExiting()) vol[3] += 4;
638 if(gMC->IsTrackOut()) vol[3] += 8;
639 if(gMC->IsTrackDisappeared()) vol[3] += 16;
640 if(gMC->IsTrackStop()) vol[3] += 32;
641 if(gMC->IsTrackAlive()) vol[3] += 64;
642 //
643 // Fill hit structure.
644 if(!(gMC->TrackCharge())) return;
645 //
646 // Only entering charged tracks
647 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
648 vol[0] = 1;
649 id = gMC->CurrentVolOffID(0,copy);
650 //detector copy in the ladder = 1<->4 (ITS1)
651 vol[1] = copy;
652 gMC->CurrentVolOffID(1,copy1);
653 //ladder copy in the module = 1<->2 (I186)
654 gMC->CurrentVolOffID(2,copy2);
655 //module copy in the layer = 1<->10 (I132)
656 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
657 } else if(id == fIdSens[1]){
658 vol[0] = 2;
659 id = gMC->CurrentVolOffID(0,copy);
660 //detector copy in the ladder = 1<->4 (ITS2)
661 vol[1] = copy;
662 gMC->CurrentVolOffID(1,copy1);
663 //ladder copy in the module = 1<->4 (I131)
664 gMC->CurrentVolOffID(2,copy2);
665 //module copy in the layer = 1<->10 (I132)
666 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
667 } else if(id == fIdSens[2]){
668 vol[0] = 3;
669 id = gMC->CurrentVolOffID(1,copy);
670 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
671 vol[1] = copy;
672 id = gMC->CurrentVolOffID(2,copy);
673 //ladder copy in the layer = 1<->12 (I316)
674 vol[2] = copy;
675 } else if(id == fIdSens[3]){
676 vol[0] = 4;
677 id = gMC->CurrentVolOffID(1,copy);
678 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
679 vol[1] = copy;
680 id = gMC->CurrentVolOffID(2,copy);
681 //ladder copy in the layer = 1<->22 (I417)
682 vol[2] = copy;
683 }else if(id == fIdSens[4]){
684 vol[0] = 5;
685 id = gMC->CurrentVolOffID(1,copy);
686 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
687 vol[1] = copy;
688 id = gMC->CurrentVolOffID(2,copy);
689 //ladder copy in the layer = 1<->34 (I565)
690 vol[2] = copy;
691 }else if(id == fIdSens[5]){
692 vol[0] = 6;
693 id = gMC->CurrentVolOffID(1,copy);
694 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
695 vol[1] = copy;
696 id = gMC->CurrentVolOffID(2,copy);
697 //ladder copy in the layer = 1<->38 (I569)
698 vol[2] = copy;
699 } else {
700 return; // not an ITS volume?
701 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
702//
703 gMC->TrackPosition(position);
704 gMC->TrackMomentum(momentum);
705 hits[0]=position[0];
706 hits[1]=position[1];
707 hits[2]=position[2];
708 hits[3]=momentum[0];
709 hits[4]=momentum[1];
710 hits[5]=momentum[2];
711 hits[6]=gMC->Edep();
712 hits[7]=gMC->TrackTime();
713 // Fill hit structure with this new hit.
714 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
fc0f0f90 715#if ALIITSPRINTGEOM==1
716 if(printit[vol[0]][vol[2]][vol[1]]){
717 printit[vol[0]][vol[2]][vol[1]] = kFALSE;
718 xl[0] = xl[1] = xl[2] = 0.0;
719 gMC->Gdtom(xl,xt,1);
720 for(i=0;i<9;i++) mat[i] = 0.0;
721 mat[0] = mat[4] = mat[8] = 1.0; // default with identity matrix
722 xl[0] = 1.0;
723 xl[1] = xl[2] =0.0;
724 gMC->Gdtom(xl,&(mat[0]),2);
725 xl[1] = 1.0;
726 xl[0] = xl[2] =0.0;
727 gMC->Gdtom(xl,&(mat[3]),2);
728 xl[2] = 1.0;
729 xl[1] = xl[0] =0.0;
730 gMC->Gdtom(xl,&(mat[6]),2);
731
732 angl[0] = TMath::ACos(mat[2]);
733 if(mat[2]==1.0) angl[0] = 0.0;
734 angl[1] = TMath::ATan2(mat[1],mat[0]);
735 if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
736
737 angl[2] = TMath::ACos(mat[5]);
738 if(mat[5]==1.0) angl[2] = 0.0;
739 angl[3] = TMath::ATan2(mat[4],mat[3]);
740 if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
741
742 angl[4] = TMath::ACos(mat[8]);
743 if(mat[8]==1.0) angl[4] = 0.0;
744 angl[5] = TMath::ATan2(mat[7],mat[6]);
745 if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
746
747 for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
748 fp = fopen("ITSgeometry_v5.det","a");
749 fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
750 vol[0],vol[2],vol[1], // layer ladder detector
751 xt[0],xt[1],xt[2], // Translation vector
752 angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
753 // angles (degrees)
754 );
755 fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
756 mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
757 ); // Adding the rotation matrix.
758 fprintf(fp,"\n");
759 fclose(fp);
760 } // end if printit[layer][ladder][detector]
761#endif
58005f18 762 return;
fe4da5cc 763}
58005f18 764//____________________________________________________________________________
fc0f0f90 765void AliITSv5::Streamer(TBuffer &R__b){
766////////////////////////////////////////////////////////////////////////
767// A dummy Streamer function for this class AliITSv5. By default it
768// only streams the AliITS class as it is required. Since this class
769// dosen't contain any "real" data to be saved, it doesn't.
770////////////////////////////////////////////////////////////////////////
855190cc 771
481937a6 772 // printf("AliITSv5Streamer Starting\n");
58005f18 773 if (R__b.IsReading()) {
fc0f0f90 774 Version_t R__v = R__b.ReadVersion();
775 if (R__v==1) {
776 AliITS::Streamer(R__b);
777 // This information does not need to be read. It is "hard wired"
778 // into this class via its creators.
779 //R__b >> fId5N;
780 //R__b.ReadArray(fId5Name);
781 }else{
782 } // end if R__v==1
58005f18 783 } else {
784 R__b.WriteVersion(AliITSv5::IsA());
785 AliITS::Streamer(R__b);
786 // This information does not need to be saved. It is "hard wired"
787 // into this class via its creators.
788 //R__b << fId5N;
789 //R__b.WriteArray(fId5Name, __COUNTER__);
fc0f0f90 790 } // end if R__b.IsReading()
481937a6 791 // printf("AliITSv5Streamer Finishing\n");
58005f18 792}
793