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"
53 //_____________________________________________________________________________
54 AliITSvtest::AliITSvtest() {
55 // Standard constructor for the ITS
61 fEuclidOut = kFALSE; // Don't write Euclide file
62 fGeomDetOut = kFALSE; // Don't write .det file
63 fGeomDetIn = kTRUE; // Read .det file
64 fMajorVersion = IsVersion();
66 for(i=0;i<60;i++) fRead[i] = '\0';
67 for(i=0;i<60;i++) fWrite[i] = '\0';
68 for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
70 //____________________________________________________________________________
71 AliITSvtest::AliITSvtest(const AliITSvtest &source) : AliITS(source){
72 ////////////////////////////////////////////////////////////////////////
73 // Copy Constructor for ITS test version.
74 ////////////////////////////////////////////////////////////////////////
75 if(&source == this) return;
76 Warning("Copy Constructor","Not allowed to copy AliITSvtest");
79 //_____________________________________________________________________________
80 AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
81 ////////////////////////////////////////////////////////////////////////
82 // Assignment operator for the ITS version 1.
83 ////////////////////////////////////////////////////////////////////////
84 if(&source == this) return *this;
85 Warning("= operator","Not allowed to copy AliITSvtest");
88 //_____________________________________________________________________________
89 AliITSvtest::~AliITSvtest() {
90 // Standard destructor for the ITS
92 //_____________________________________________________________________________
93 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
94 const char *name, const char *title)
95 : AliITS(name, title){
97 // Standard constructor for the ITS
100 fIdName = new TString[fIdN];
107 fIdSens = new Int_t[fIdN];
108 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
109 fMajorVersion = IsVersion();
111 fEuclidOut = kFALSE; // Don't write Euclide file
112 fGeomDetOut = kFALSE; // Don't write .det file
113 fGeomDetIn = kTRUE; // Read .det file
115 fEuclidMaterial = filetme;
116 fEuclidGeometry = fileeuc;
117 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
118 strncpy(fRead,fEuclidGeomDet,60);
119 strncpy(fWrite,fEuclidGeomDet,60);
120 // The .det file for the geometry must have the same name as fileeuc with
121 // .euc replaced by .det.
125 //_____________________________________________________________________________
126 void AliITSvtest::CreateMaterials(){
128 // Read materials for the ITS
132 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
133 // FILE *file = fopen(fEuclidMaterial.Data(),"r");
134 FILE *file = fopen(filtmp,"r");
137 // ReadEuclidMedia(fEuclidMaterial.Data(),this);
138 ReadEuclidMedia(filtmp);
140 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
141 // fEuclidMaterial.Data());
147 //_____________________________________________________________________________
148 void AliITSvtest::CreateGeometry(){
149 //////////////////////////////////////////////////////////////////////
150 ////////////////////////////////////////////////////////////////////////
151 // Read geometry for the ITS
156 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
157 FILE *file = fopen(filtmp,"r");
161 printf("Ready to read Euclid geometry file\n");
162 ReadEuclid(fEuclidGeometry.Data(),topvol);
163 printf("Read in euclid geometries\n");
165 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
166 fEuclidGeometry.Data());
170 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
173 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
175 //---Outputs the geometry tree in the EUCLID/CAD format
178 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
179 } // end if (fEuclidOut)
180 cout <<"finished with euclid geometrys"<< endl;
182 //______________________________________________________________________
183 void AliITSvtest::InitAliITSgeom(){
184 // Based on the geometry tree defined in Geant 3.21, this
185 // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
187 // if(gMC->IsA()!=TGeant3::Class()) {
188 if(strcmp(gMC->GetName(),"TGeant3")) {
189 Error("InitAliITSgeom",
190 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
193 cout << "Reading Geometry transformation directly from Geant 3." << endl;
194 const Int_t nlayers = 6;
195 const Int_t ndeep = 9;
196 Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
197 Int_t nlad[nlayers],ndet[nlayers];
199 Float_t par[20],att[20];
200 Int_t npar,natt,idshape,imat,imed;
201 AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
202 Int_t mod,lay,lad,det,i,j,k;
203 const char *names[nlayers][ndeep] = {
204 {"ALIC","ITSV","ITSD","IT12","I12B","I10B","I107","I101","ITS1"}, // lay=1
205 {"ALIC","ITSV","ITSD","IT12","I12B","I20B","I1D7","I1D1","ITS2"}, // lay=2
206 {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"," "," "}, // lay=3
207 {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"," "," "}, // lay=4
208 {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"," "," "}, // lay=5
209 {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"," "," "}};// lay=6
210 Int_t itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2, 4, 1, 1},// lay=1
211 {1,1,1,1,10, 4, 4, 1, 1},// lay=2
212 {1,1,1,1,14, 6, 1, 0, 0},// lay=3
213 {1,1,1,1,22, 8, 1, 0, 0},// lay=4
214 {1,1,1,1,34,22, 1, 0, 0},// lay=5
215 {1,1,1,1,38,25, 1, 0, 0}};//lay=6
217 // Sorry, but this is not very pritty code. It should be replaced
218 // at some point with a version that can search through the geometry
220 cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
221 for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
222 for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++)
223 strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4);
224 // itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
226 for(i=0;i<nlayers;i++){
228 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
229 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
233 if(fITSgeom!=0) delete fITSgeom;
234 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
235 ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
236 fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
238 for(lay=1;lay<=nlayers;lay++){
239 for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
240 for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
242 case 1: case 2: // layers 1 and 2 are a bit special
244 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
246 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
249 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
252 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
254 fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
255 if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
256 if(fMinorVersion==1){
257 fITSgeom->ReSetShape(kSPD,
258 new AliITSgeomSPD425Short());
259 } else if(fMinorVersion==2)
260 fITSgeom->ReSetShape(kSPD,
261 new AliITSgeomSPD425Short());
266 case 3: case 4: case 5: case 6: // layers 3-6
268 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
270 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
273 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
277 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
278 if(!(fITSgeom->IsShapeDefined(kSDD)))
279 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
282 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
283 if(!(fITSgeom->IsShapeDefined(kSSD)))
284 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75());
287 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
288 if(!(fITSgeom->IsShapeDefined(kSSD)))
289 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD75and275());
299 //_____________________________________________________________________________
300 void AliITSvtest::Init(){
301 ////////////////////////////////////////////////////////////////////////
302 // Initialise the ITS after it has been created.
303 ////////////////////////////////////////////////////////////////////////
307 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
308 for(i=0;i<28;i++) cout << "*";cout << endl;
310 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
311 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
312 if(fITSgeom!=0) delete fITSgeom;
313 fITSgeom = new AliITSgeom();
314 if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
315 if(!fGeomDetIn) this->InitAliITSgeom();
316 if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
319 for(i=0;i<72;i++) cout << "*";
322 //_____________________________________________________________________________
323 void AliITSvtest::StepManager(){
325 // Called for every step in the ITS
331 TLorentzVector position, momentum;
332 TClonesArray &lhits = *fHits;
336 if(gMC->IsTrackInside()) vol[3] += 1;
337 if(gMC->IsTrackEntering()) vol[3] += 2;
338 if(gMC->IsTrackExiting()) vol[3] += 4;
339 if(gMC->IsTrackOut()) vol[3] += 8;
340 if(gMC->IsTrackDisappeared()) vol[3] += 16;
341 if(gMC->IsTrackStop()) vol[3] += 32;
342 if(gMC->IsTrackAlive()) vol[3] += 64;
344 // Fill hit structure.
345 if(!(gMC->TrackCharge())) return;
347 // Only entering charged tracks
348 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
350 id = gMC->CurrentVolOffID(0,copy);
351 //detector copy in the ladder = 1<->4 (ITS1)
353 gMC->CurrentVolOffID(1,copy1);
354 //ladder copy in the module = 1<->2 (I186)
355 gMC->CurrentVolOffID(2,copy2);
356 //module copy in the layer = 1<->10 (I132)
357 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
358 } else if(id == fIdSens[1]){
360 id = gMC->CurrentVolOffID(0,copy);
361 //detector copy in the ladder = 1<->4 (ITS2)
363 gMC->CurrentVolOffID(1,copy1);
364 //ladder copy in the module = 1<->4 (I131)
365 gMC->CurrentVolOffID(2,copy2);
366 //module copy in the layer = 1<->10 (I132)
367 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
368 } else if(id == fIdSens[2]){
370 id = gMC->CurrentVolOffID(1,copy);
371 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
373 id = gMC->CurrentVolOffID(2,copy);
374 //ladder copy in the layer = 1<->12 (I316)
376 } else if(id == fIdSens[3]){
378 id = gMC->CurrentVolOffID(1,copy);
379 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
381 id = gMC->CurrentVolOffID(2,copy);
382 //ladder copy in the layer = 1<->22 (I417)
384 }else if(id == fIdSens[4]){
386 id = gMC->CurrentVolOffID(1,copy);
387 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
389 id = gMC->CurrentVolOffID(2,copy);
390 //ladder copy in the layer = 1<->34 (I565)
392 }else if(id == fIdSens[5]){
394 id = gMC->CurrentVolOffID(1,copy);
395 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
397 id = gMC->CurrentVolOffID(2,copy);
398 //ladder copy in the layer = 1<->38 (I569)
401 return; // not an ITS volume?
402 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
404 gMC->TrackPosition(position);
405 gMC->TrackMomentum(momentum);
413 hits[7]=gMC->TrackTime();
414 // Fill hit structure with this new hit.
415 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);