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) : AliITS(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 strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4);
223 // itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
225 for(i=0;i<nlayers;i++){
227 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
228 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
232 if(fITSgeom!=0) delete fITSgeom;
233 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
234 ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
235 fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
237 for(lay=1;lay<=nlayers;lay++){
238 for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
239 for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
241 case 1: case 2: // layers 1 and 2 are a bit special
243 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
245 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
248 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
251 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
253 fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
254 if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
255 if(fMinorVersion==1){
256 fITSgeom->ReSetShape(kSPD,
257 new AliITSgeomSPD425Short());
258 } else if(fMinorVersion==2)
259 fITSgeom->ReSetShape(kSPD,
260 new AliITSgeomSPD425Short());
265 case 3: case 4: case 5: case 6: // layers 3-6
267 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
269 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
272 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
276 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
277 if(!(fITSgeom->IsShapeDefined(kSDD)))
278 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
281 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
282 if(!(fITSgeom->IsShapeDefined(kSSD)))
283 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75());
286 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
287 if(!(fITSgeom->IsShapeDefined(kSSD)))
288 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD75and275());
298 //_____________________________________________________________________________
299 void AliITSvtest::Init(){
300 ////////////////////////////////////////////////////////////////////////
301 // Initialise the ITS after it has been created.
302 ////////////////////////////////////////////////////////////////////////
306 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
307 for(i=0;i<28;i++) cout << "*";cout << endl;
309 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
310 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
311 if(fITSgeom!=0) delete fITSgeom;
312 fITSgeom = new AliITSgeom();
313 if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
314 if(!fGeomDetIn) this->InitAliITSgeom();
315 if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
318 for(i=0;i<72;i++) cout << "*";
321 //_____________________________________________________________________________
322 void AliITSvtest::StepManager(){
324 // Called for every step in the ITS
330 TLorentzVector position, momentum;
331 TClonesArray &lhits = *fHits;
335 if(gMC->IsTrackInside()) vol[3] += 1;
336 if(gMC->IsTrackEntering()) vol[3] += 2;
337 if(gMC->IsTrackExiting()) vol[3] += 4;
338 if(gMC->IsTrackOut()) vol[3] += 8;
339 if(gMC->IsTrackDisappeared()) vol[3] += 16;
340 if(gMC->IsTrackStop()) vol[3] += 32;
341 if(gMC->IsTrackAlive()) vol[3] += 64;
343 // Fill hit structure.
344 if(!(gMC->TrackCharge())) return;
346 // Only entering charged tracks
347 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
349 id = gMC->CurrentVolOffID(0,copy);
350 //detector copy in the ladder = 1<->4 (ITS1)
352 gMC->CurrentVolOffID(1,copy1);
353 //ladder copy in the module = 1<->2 (I186)
354 gMC->CurrentVolOffID(2,copy2);
355 //module copy in the layer = 1<->10 (I132)
356 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
357 } else if(id == fIdSens[1]){
359 id = gMC->CurrentVolOffID(0,copy);
360 //detector copy in the ladder = 1<->4 (ITS2)
362 gMC->CurrentVolOffID(1,copy1);
363 //ladder copy in the module = 1<->4 (I131)
364 gMC->CurrentVolOffID(2,copy2);
365 //module copy in the layer = 1<->10 (I132)
366 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
367 } else if(id == fIdSens[2]){
369 id = gMC->CurrentVolOffID(1,copy);
370 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
372 id = gMC->CurrentVolOffID(2,copy);
373 //ladder copy in the layer = 1<->12 (I316)
375 } else if(id == fIdSens[3]){
377 id = gMC->CurrentVolOffID(1,copy);
378 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
380 id = gMC->CurrentVolOffID(2,copy);
381 //ladder copy in the layer = 1<->22 (I417)
383 }else if(id == fIdSens[4]){
385 id = gMC->CurrentVolOffID(1,copy);
386 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
388 id = gMC->CurrentVolOffID(2,copy);
389 //ladder copy in the layer = 1<->34 (I565)
391 }else if(id == fIdSens[5]){
393 id = gMC->CurrentVolOffID(1,copy);
394 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
396 id = gMC->CurrentVolOffID(2,copy);
397 //ladder copy in the layer = 1<->38 (I569)
400 return; // not an ITS volume?
401 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
403 gMC->TrackPosition(position);
404 gMC->TrackMomentum(momentum);
412 hits[7]=gMC->TrackTime();
413 // Fill hit structure with this new hit.
414 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);