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