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>
32 #include<TLorentzVector.h>
35 #include <TVirtualMC.h>
38 #include "AliITSGeant3Geometry.h"
39 #include "AliITSgeom.h"
40 #include "AliITSgeomSDD.h"
41 #include "AliITSgeomSPD.h"
42 #include "AliITSgeomSSD.h"
43 #include "AliITShit.h"
44 #include "AliITSvtest.h"
50 //_____________________________________________________________________________
51 AliITSvtest::AliITSvtest() {
52 // Standard constructor for the ITS
59 fGeomDetOut = kFALSE; // Don't write .det file
60 fGeomDetIn = kTRUE; // Read .det file
61 fMajorVersion = IsVersion();
63 for(i=0;i<60;i++) fRead[i] = '\0';
64 for(i=0;i<60;i++) fWrite[i] = '\0';
65 for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
67 //____________________________________________________________________________
68 AliITSvtest::AliITSvtest(const AliITSvtest &source) : AliITS(source){
69 ////////////////////////////////////////////////////////////////////////
70 // Copy Constructor for ITS test version.
71 ////////////////////////////////////////////////////////////////////////
72 if(&source == this) return;
73 Warning("Copy Constructor","Not allowed to copy AliITSvtest");
76 //_____________________________________________________________________________
77 AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
78 ////////////////////////////////////////////////////////////////////////
79 // Assignment operator for the ITS version 1.
80 ////////////////////////////////////////////////////////////////////////
81 if(&source == this) return *this;
82 Warning("= operator","Not allowed to copy AliITSvtest");
85 //_____________________________________________________________________________
86 AliITSvtest::~AliITSvtest() {
87 // Standard destructor for the ITS
89 //_____________________________________________________________________________
90 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
91 const char *name, const char *title)
92 : AliITS(name, title){
94 // Standard constructor for the ITS
97 fIdName = new TString[fIdN];
104 fIdSens = new Int_t[fIdN];
105 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
106 fMajorVersion = IsVersion();
109 fGeomDetOut = kFALSE; // Don't write .det file
110 fGeomDetIn = kTRUE; // Read .det file
112 fEuclidMaterial = filetme;
113 fEuclidGeometry = fileeuc;
114 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
115 strncpy(fRead,fEuclidGeomDet,60);
116 strncpy(fWrite,fEuclidGeomDet,60);
117 // The .det file for the geometry must have the same name as fileeuc with
118 // .euc replaced by .det.
122 //_____________________________________________________________________________
123 void AliITSvtest::CreateMaterials(){
125 // Read materials for the ITS
129 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
130 // FILE *file = fopen(fEuclidMaterial.Data(),"r");
131 FILE *file = fopen(filtmp,"r");
134 // ReadEuclidMedia(fEuclidMaterial.Data(),this);
135 ReadEuclidMedia(filtmp);
137 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
138 // fEuclidMaterial.Data());
144 //_____________________________________________________________________________
145 void AliITSvtest::CreateGeometry(){
146 //////////////////////////////////////////////////////////////////////
147 ////////////////////////////////////////////////////////////////////////
148 // Read geometry for the ITS
153 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
154 FILE *file = fopen(filtmp,"r");
158 printf("Ready to read Euclid geometry file\n");
159 ReadEuclid(fEuclidGeometry.Data(),topvol);
160 printf("Read in euclid geometries\n");
162 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
163 fEuclidGeometry.Data());
167 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
170 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
172 //---Outputs the geometry tree in the EUCLID/CAD format
175 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
176 } // end if (fEuclidOut)
177 cout <<"finished with euclid geometrys"<< endl;
179 //______________________________________________________________________
180 void AliITSvtest::InitAliITSgeom(){
181 // Based on the geometry tree defined in Geant 3.21, this
182 // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
184 // if(gMC->IsA()!=TGeant3::Class()) {
185 if(strcmp(gMC->GetName(),"TGeant3")) {
186 Error("InitAliITSgeom",
187 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
190 cout << "Reading Geometry transformation directly from Geant 3." << endl;
191 const Int_t kNlayers = 6;
192 const Int_t kndeep = 9;
193 Int_t itsGeomTreeNames[kNlayers][kndeep],lnam[20],lnum[20];
194 Int_t nlad[kNlayers],ndet[kNlayers];
196 Float_t par[20],att[20];
197 Int_t npar,natt,idshape,imat,imed;
198 AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
199 Int_t mod,lay,lad,det,i,j,k;
200 const char *names[kNlayers][kndeep] = {
201 {"ALIC","ITSV","ITSD","IT12","I12B","I10B","I107","I101","ITS1"}, // lay=1
202 {"ALIC","ITSV","ITSD","IT12","I12B","I20B","I1D7","I1D1","ITS2"}, // lay=2
203 {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"," "," "}, // lay=3
204 {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"," "," "}, // lay=4
205 {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"," "," "}, // lay=5
206 {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"," "," "}};// lay=6
207 Int_t itsGeomTreeCopys[kNlayers][kndeep] = {{1,1,1,1,10, 2, 4, 1, 1},// lay=1
208 {1,1,1,1,10, 4, 4, 1, 1},// lay=2
209 {1,1,1,1,14, 6, 1, 0, 0},// lay=3
210 {1,1,1,1,22, 8, 1, 0, 0},// lay=4
211 {1,1,1,1,34,22, 1, 0, 0},// lay=5
212 {1,1,1,1,38,25, 1, 0, 0}};//lay=6
214 // Sorry, but this is not very pritty code. It should be replaced
215 // at some point with a version that can search through the geometry
217 cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
218 for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
219 for(i=0;i<kNlayers;i++)for(j=0;j<kndeep;j++)
220 strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4);
221 // itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
223 for(i=0;i<kNlayers;i++){
225 for(j=0;j<kndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
226 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
230 if(GetITSgeom()!=0) SetITSgeom(0x0);
231 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
232 ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
233 SetITSgeom(new AliITSgeom(0,6,nlad,ndet,mod));
235 for(lay=1;lay<=kNlayers;lay++){
236 for(j=0;j<kndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
237 for(j=0;j<kndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
239 case 1: case 2: // layers 1 and 2 are a bit special
241 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
243 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
246 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
249 ig->GetGeometry(kndeep,lnam,lnum,t,r,idshape,npar,natt,
251 GetITSgeom()->CreateMatrix(mod,lay,lad,det,kSPD,t,r);
252 if(!(GetITSgeom()->IsShapeDefined((Int_t)kSPD)))
253 if(fMinorVersion==1){
254 GetITSgeom()->ReSetShape(kSPD,
255 new AliITSgeomSPD425Short());
256 } else if(fMinorVersion==2)
257 GetITSgeom()->ReSetShape(kSPD,
258 new AliITSgeomSPD425Short());
263 case 3: case 4: case 5: case 6: // layers 3-6
265 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
267 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
270 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
274 GetITSgeom()->CreateMatrix(mod,lay,lad,det,kSDD,t,r);
275 if(!(GetITSgeom()->IsShapeDefined(kSDD)))
276 GetITSgeom()->ReSetShape(kSDD,new AliITSgeomSDD256());
279 GetITSgeom()->CreateMatrix(mod,lay,lad,det,kSSD,t,r);
280 if(!(GetITSgeom()->IsShapeDefined(kSSD)))
281 GetITSgeom()->ReSetShape(kSSD,new AliITSgeomSSD275and75());
284 GetITSgeom()->CreateMatrix(mod,lay,lad,det,kSSD,t,r);
285 if(!(GetITSgeom()->IsShapeDefined(kSSD)))
286 GetITSgeom()->ReSetShape(kSSD,new AliITSgeomSSD75and275());
296 //_____________________________________________________________________________
297 void AliITSvtest::Init(){
298 ////////////////////////////////////////////////////////////////////////
299 // Initialise the ITS after it has been created.
300 ////////////////////////////////////////////////////////////////////////
304 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
305 for(i=0;i<28;i++) cout << "*";cout << endl;
307 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
308 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
309 if(GetITSgeom()!=0) SetITSgeom(0x0);
310 SetITSgeom(new AliITSgeom());
311 if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
312 if(!fGeomDetIn) this->InitAliITSgeom();
313 if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
316 for(i=0;i<72;i++) cout << "*";
319 //_____________________________________________________________________________
320 void AliITSvtest::StepManager(){
322 // Called for every step in the ITS
328 TLorentzVector position, momentum;
329 TClonesArray &lhits = *fHits;
333 if(gMC->IsTrackInside()) vol[3] += 1;
334 if(gMC->IsTrackEntering()) vol[3] += 2;
335 if(gMC->IsTrackExiting()) vol[3] += 4;
336 if(gMC->IsTrackOut()) vol[3] += 8;
337 if(gMC->IsTrackDisappeared()) vol[3] += 16;
338 if(gMC->IsTrackStop()) vol[3] += 32;
339 if(gMC->IsTrackAlive()) vol[3] += 64;
341 // Fill hit structure.
342 if(!(gMC->TrackCharge())) return;
344 // Only entering charged tracks
345 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
347 id = gMC->CurrentVolOffID(0,copy);
348 //detector copy in the ladder = 1<->4 (ITS1)
350 gMC->CurrentVolOffID(1,copy1);
351 //ladder copy in the module = 1<->2 (I186)
352 gMC->CurrentVolOffID(2,copy2);
353 //module copy in the layer = 1<->10 (I132)
354 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
355 } else if(id == fIdSens[1]){
357 id = gMC->CurrentVolOffID(0,copy);
358 //detector copy in the ladder = 1<->4 (ITS2)
360 gMC->CurrentVolOffID(1,copy1);
361 //ladder copy in the module = 1<->4 (I131)
362 gMC->CurrentVolOffID(2,copy2);
363 //module copy in the layer = 1<->10 (I132)
364 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
365 } else if(id == fIdSens[2]){
367 id = gMC->CurrentVolOffID(1,copy);
368 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
370 id = gMC->CurrentVolOffID(2,copy);
371 //ladder copy in the layer = 1<->12 (I316)
373 } else if(id == fIdSens[3]){
375 id = gMC->CurrentVolOffID(1,copy);
376 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
378 id = gMC->CurrentVolOffID(2,copy);
379 //ladder copy in the layer = 1<->22 (I417)
381 }else if(id == fIdSens[4]){
383 id = gMC->CurrentVolOffID(1,copy);
384 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
386 id = gMC->CurrentVolOffID(2,copy);
387 //ladder copy in the layer = 1<->34 (I565)
389 }else if(id == fIdSens[5]){
391 id = gMC->CurrentVolOffID(1,copy);
392 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
394 id = gMC->CurrentVolOffID(2,copy);
395 //ladder copy in the layer = 1<->38 (I569)
398 return; // not an ITS volume?
399 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
401 gMC->TrackPosition(position);
402 gMC->TrackMomentum(momentum);
410 hits[7]=gMC->TrackTime();
411 // Fill hit structure with this new hit.
412 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);