1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Inner Traking System version Test //
21 // This class contains the base procedures for the Inner Tracking System //
23 // Authors: R. Barbera, B. S. Nilsen. //
25 // Created October 16 1999. //
27 ///////////////////////////////////////////////////////////////////////////////
29 #include <Riostream.h>
34 #include <TObjArray.h>
35 #include <TObjString.h>
38 #include <TVirtualMC.h>
41 #include "AliITSGeant3Geometry.h"
42 #include "AliITSgeom.h"
43 #include "AliITSgeomSDD.h"
44 #include "AliITSgeomSPD.h"
45 #include "AliITSgeomSSD.h"
46 #include "AliITShit.h"
47 #include "AliITSvtest.h"
52 //_____________________________________________________________________________
53 AliITSvtest::AliITSvtest() {
54 // Standard constructor for the ITS
60 fEuclidOut = kFALSE; // Don't write Euclide file
61 fGeomDetOut = kFALSE; // Don't write .det file
62 fGeomDetIn = kTRUE; // Read .det file
63 fMajorVersion = IsVersion();
65 for(i=0;i<60;i++) fRead[i] = '\0';
66 for(i=0;i<60;i++) fWrite[i] = '\0';
67 for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
69 //____________________________________________________________________________
70 AliITSvtest::AliITSvtest(const AliITSvtest &source){
71 ////////////////////////////////////////////////////////////////////////
72 // Copy Constructor for ITS test version.
73 ////////////////////////////////////////////////////////////////////////
74 if(&source == this) return;
75 Warning("Copy Constructor","Not allowed to copy AliITSvtest");
78 //_____________________________________________________________________________
79 AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
80 ////////////////////////////////////////////////////////////////////////
81 // Assignment operator for the ITS version 1.
82 ////////////////////////////////////////////////////////////////////////
83 if(&source == this) return *this;
84 Warning("= operator","Not allowed to copy AliITSvtest");
87 //_____________________________________________________________________________
88 AliITSvtest::~AliITSvtest() {
89 // Standard destructor for the ITS
91 //_____________________________________________________________________________
92 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
93 const char *name, const char *title)
94 : AliITS(name, title){
96 // Standard constructor for the ITS
99 fIdName = new TString[fIdN];
106 fIdSens = new Int_t[fIdN];
107 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
108 fMajorVersion = IsVersion();
110 fEuclidOut = kFALSE; // Don't write Euclide file
111 fGeomDetOut = kFALSE; // Don't write .det file
112 fGeomDetIn = kTRUE; // Read .det file
114 fEuclidMaterial = filetme;
115 fEuclidGeometry = fileeuc;
116 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
117 strncpy(fRead,fEuclidGeomDet,60);
118 strncpy(fWrite,fEuclidGeomDet,60);
119 // The .det file for the geometry must have the same name as fileeuc with
120 // .euc replaced by .det.
124 //_____________________________________________________________________________
125 void AliITSvtest::CreateMaterials(){
127 // Read materials for the ITS
131 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
132 // FILE *file = fopen(fEuclidMaterial.Data(),"r");
133 FILE *file = fopen(filtmp,"r");
136 // ReadEuclidMedia(fEuclidMaterial.Data(),this);
137 ReadEuclidMedia(filtmp);
139 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
140 // fEuclidMaterial.Data());
146 //_____________________________________________________________________________
147 void AliITSvtest::CreateGeometry(){
148 //////////////////////////////////////////////////////////////////////
149 ////////////////////////////////////////////////////////////////////////
150 // Read geometry for the ITS
155 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
156 FILE *file = fopen(filtmp,"r");
160 printf("Ready to read Euclid geometry file\n");
161 ReadEuclid(fEuclidGeometry.Data(),topvol);
162 printf("Read in euclid geometries\n");
164 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
165 fEuclidGeometry.Data());
169 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
172 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
174 //---Outputs the geometry tree in the EUCLID/CAD format
177 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
178 } // end if (fEuclidOut)
179 cout <<"finished with euclid geometrys"<< endl;
181 //______________________________________________________________________
182 void AliITSvtest::InitAliITSgeom(){
183 // Based on the geometry tree defined in Geant 3.21, this
184 // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
186 // if(gMC->IsA()!=TGeant3::Class()) {
187 if(strcmp(gMC->GetName(),"TGeant3")) {
188 Error("InitAliITSgeom",
189 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
192 cout << "Reading Geometry transformation directly from Geant 3." << endl;
193 const Int_t nlayers = 6;
194 const Int_t ndeep = 9;
195 Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
196 Int_t nlad[nlayers],ndet[nlayers];
198 Float_t par[20],att[20];
199 Int_t npar,natt,idshape,imat,imed;
200 AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
201 Int_t mod,lay,lad,det,i,j,k;
202 char *names[nlayers][ndeep] = {
203 {"ALIC","ITSV","ITSD","IT12","I12B","I10B","I107","I101","ITS1"}, // lay=1
204 {"ALIC","ITSV","ITSD","IT12","I12B","I20B","I1D7","I1D1","ITS2"}, // lay=2
205 {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"," "," "}, // lay=3
206 {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"," "," "}, // lay=4
207 {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"," "," "}, // lay=5
208 {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"," "," "}};// lay=6
209 Int_t itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2, 4, 1, 1},// lay=1
210 {1,1,1,1,10, 4, 4, 1, 1},// lay=2
211 {1,1,1,1,14, 6, 1, 0, 0},// lay=3
212 {1,1,1,1,22, 8, 1, 0, 0},// lay=4
213 {1,1,1,1,34,22, 1, 0, 0},// lay=5
214 {1,1,1,1,38,25, 1, 0, 0}};//lay=6
216 // Sorry, but this is not very pritty code. It should be replaced
217 // at some point with a version that can search through the geometry
219 cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
220 for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
221 for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++)
222 itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
224 for(i=0;i<nlayers;i++){
226 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
227 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
231 if(fITSgeom!=0) delete fITSgeom;
232 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
233 ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
234 fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
236 for(lay=1;lay<=nlayers;lay++){
237 for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
238 for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
240 case 1: case 2: // layers 1 and 2 are a bit special
242 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
244 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
247 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
250 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
252 fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
253 if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
254 if(fMinorVersion==1){
255 fITSgeom->ReSetShape(kSPD,
256 new AliITSgeomSPD425Short());
257 } else if(fMinorVersion==2)
258 fITSgeom->ReSetShape(kSPD,
259 new AliITSgeomSPD425Short());
264 case 3: case 4: case 5: case 6: // layers 3-6
266 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
268 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
271 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
275 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
276 if(!(fITSgeom->IsShapeDefined(kSDD)))
277 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
280 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
281 if(!(fITSgeom->IsShapeDefined(kSSD)))
282 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75());
285 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
286 if(!(fITSgeom->IsShapeDefined(kSSD)))
287 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD75and275());
297 //_____________________________________________________________________________
298 void AliITSvtest::Init(){
299 ////////////////////////////////////////////////////////////////////////
300 // Initialise the ITS after it has been created.
301 ////////////////////////////////////////////////////////////////////////
305 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
306 for(i=0;i<28;i++) cout << "*";cout << endl;
308 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
309 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
310 if(fITSgeom!=0) delete fITSgeom;
311 fITSgeom = new AliITSgeom();
312 if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
313 if(!fGeomDetIn) this->InitAliITSgeom();
314 if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
317 for(i=0;i<72;i++) cout << "*";
320 //_____________________________________________________________________________
321 void AliITSvtest::StepManager(){
323 // Called for every step in the ITS
329 TLorentzVector position, momentum;
330 TClonesArray &lhits = *fHits;
334 if(gMC->IsTrackInside()) vol[3] += 1;
335 if(gMC->IsTrackEntering()) vol[3] += 2;
336 if(gMC->IsTrackExiting()) vol[3] += 4;
337 if(gMC->IsTrackOut()) vol[3] += 8;
338 if(gMC->IsTrackDisappeared()) vol[3] += 16;
339 if(gMC->IsTrackStop()) vol[3] += 32;
340 if(gMC->IsTrackAlive()) vol[3] += 64;
342 // Fill hit structure.
343 if(!(gMC->TrackCharge())) return;
345 // Only entering charged tracks
346 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
348 id = gMC->CurrentVolOffID(0,copy);
349 //detector copy in the ladder = 1<->4 (ITS1)
351 gMC->CurrentVolOffID(1,copy1);
352 //ladder copy in the module = 1<->2 (I186)
353 gMC->CurrentVolOffID(2,copy2);
354 //module copy in the layer = 1<->10 (I132)
355 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
356 } else if(id == fIdSens[1]){
358 id = gMC->CurrentVolOffID(0,copy);
359 //detector copy in the ladder = 1<->4 (ITS2)
361 gMC->CurrentVolOffID(1,copy1);
362 //ladder copy in the module = 1<->4 (I131)
363 gMC->CurrentVolOffID(2,copy2);
364 //module copy in the layer = 1<->10 (I132)
365 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
366 } else if(id == fIdSens[2]){
368 id = gMC->CurrentVolOffID(1,copy);
369 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
371 id = gMC->CurrentVolOffID(2,copy);
372 //ladder copy in the layer = 1<->12 (I316)
374 } else if(id == fIdSens[3]){
376 id = gMC->CurrentVolOffID(1,copy);
377 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
379 id = gMC->CurrentVolOffID(2,copy);
380 //ladder copy in the layer = 1<->22 (I417)
382 }else if(id == fIdSens[4]){
384 id = gMC->CurrentVolOffID(1,copy);
385 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
387 id = gMC->CurrentVolOffID(2,copy);
388 //ladder copy in the layer = 1<->34 (I565)
390 }else if(id == fIdSens[5]){
392 id = gMC->CurrentVolOffID(1,copy);
393 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
395 id = gMC->CurrentVolOffID(2,copy);
396 //ladder copy in the layer = 1<->38 (I569)
399 return; // not an ITS volume?
400 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
402 gMC->TrackPosition(position);
403 gMC->TrackMomentum(momentum);
411 hits[7]=gMC->TrackTime();
412 // Fill hit structure with this new hit.
413 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);