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 Revision 1.15 2002/10/22 14:46:03 alibrary
19 Introducing Riostream.h
21 Revision 1.14 2002/10/14 14:57:10 hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
24 Revision 1.13.8.2 2002/08/30 15:45:56 alibrary
25 Adding geant4vmc support
27 Revision 1.13.8.1 2002/06/10 17:51:17 hristov
30 Revision 1.13 2001/10/01 19:34:09 nilsen
31 Fixed a bug in asigning detector types in SetDefaults under SSD layer 6.
33 Revision 1.12 2001/08/24 21:04:36 nilsen
34 Added some include files. Needed due to new forward declorations in other
37 Revision 1.11 2001/05/30 16:15:47 fca
38 Correct comparison wiht AliGeant3::Class() introduced. Thanks to I.Hrivnacova
40 Revision 1.10 2001/05/30 15:55:35 hristov
41 Strings compared instead of pointers
43 Revision 1.9 2001/05/30 14:04:31 hristov
44 Dynamic cast replaced (F.Carminati)
46 Revision 1.8 2001/02/13 16:53:35 nilsen
47 Fixed a but when trying to use GEANT4. Needed to replace
48 if(!((TGeant3*)gMC)) with if(!(dynamic_casst<TGeant3*>(gMC)))
49 because just casting gMC to be TGeant3* even when it realy is a TGeant3 pointer
50 did not result in a zero value. For AliITSv5asymm and AliITSv5symm, needed
51 to fix a bug in the initilizers and a bug in BuildGeometry. This is now done
52 in the same way as in AliITSv5.cxx.
54 Revision 1.7 2001/02/09 20:06:26 nilsen
55 Fixed bug in distructor. Can't distroy fixxed length arrays. Thanks Peter.
57 Revision 1.6 2001/02/09 00:05:31 nilsen
58 Added fMajor/MinorVersion variables and made other changes to better make
59 use of the new code changes in AliITSgeom related classes.
61 Revision 1.5 2001/01/30 09:23:14 hristov
62 Streamers removed (R.Brun)
64 Revision 1.4 2001/01/18 06:25:09 barbera
65 ITS geometry using test Euclid files
67 Revision 1.1.2.8 2000/10/05 20:28:18 nilsen
68 Now using root generated streamer function.
70 Revision 1.1.2.7 2000/07/31 13:51:22 barbera
71 Updated from the release
73 Revision 1.2 2000/07/10 16:07:19 fca
74 Release version of ITS code
76 Revision 1.1.2.2 2000/03/02 21:53:36 nilsen
77 to make it compatable with the changes in AliRun/AliModule.
79 Revision 1.1.2.1 2000/01/12 20:19:03 nilsen
80 The changes made with this latest inclusion of code is very large.
81 Many of the new files were added just in December when P. Cerello added his
82 SDD simulations to the distrobutions. Also added are some file of P. Skowronski
83 for SSD cluster finding and ghost RecPoints. None of this "new" code has been
84 proporly tested. Other code new to this cvs repository is explained in the
85 ITS Off-line web page. In general the changes are too large to give a resonable
86 discription of them but probably should be taken as the starting point for
87 the developement branch (ITS-working).
90 Revision 1.13 1999/10/16 19:49:00 BSN
96 ///////////////////////////////////////////////////////////////////////////////
98 // Inner Traking System version Test //
99 // This class contains the base procedures for the Inner Tracking System //
101 // Authors: R. Barbera, B. S. Nilsen. //
103 // Created October 16 1999. //
105 ///////////////////////////////////////////////////////////////////////////////
108 #include <Riostream.h>
110 #include <TGeometry.h>
113 #include <TFile.h> // only required for Tracking function?
115 #include <TObjArray.h>
116 #include <TObjString.h>
117 #include <TClonesArray.h>
118 #include <TLorentzVector.h>
123 #include "AliITSGeant3Geometry.h"
124 #include "AliITShit.h"
126 #include "AliITSvtest.h"
127 #include "AliITSgeom.h"
128 #include "AliITSgeomSPD.h"
129 #include "AliITSgeomSDD.h"
130 #include "AliITSgeomSSD.h"
132 ClassImp(AliITSvtest)
134 //_____________________________________________________________________________
135 AliITSvtest::AliITSvtest() {
136 // Standard constructor for the ITS
142 fEuclidOut = kFALSE; // Don't write Euclide file
143 fGeomDetOut = kFALSE; // Don't write .det file
144 fGeomDetIn = kTRUE; // Read .det file
145 fMajorVersion = IsVersion();
147 for(i=0;i<60;i++) fRead[i] = '\0';
148 for(i=0;i<60;i++) fWrite[i] = '\0';
149 for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
151 //____________________________________________________________________________
152 AliITSvtest::AliITSvtest(const AliITSvtest &source){
153 ////////////////////////////////////////////////////////////////////////
154 // Copy Constructor for ITS test version.
155 ////////////////////////////////////////////////////////////////////////
156 if(&source == this) return;
157 Warning("Copy Constructor","Not allowed to copy AliITSvtest");
160 //_____________________________________________________________________________
161 AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
162 ////////////////////////////////////////////////////////////////////////
163 // Assignment operator for the ITS version 1.
164 ////////////////////////////////////////////////////////////////////////
165 if(&source == this) return *this;
166 Warning("= operator","Not allowed to copy AliITSvtest");
169 //_____________________________________________________________________________
170 AliITSvtest::~AliITSvtest() {
171 // Standard destructor for the ITS
173 //_____________________________________________________________________________
174 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
175 const char *name, const char *title)
176 : AliITS(name, title){
178 // Standard constructor for the ITS
181 fIdName = new TString[fIdN];
188 fIdSens = new Int_t[fIdN];
189 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
190 fMajorVersion = IsVersion();
192 fEuclidOut = kFALSE; // Don't write Euclide file
193 fGeomDetOut = kFALSE; // Don't write .det file
194 fGeomDetIn = kTRUE; // Read .det file
196 fEuclidMaterial = filetme;
197 fEuclidGeometry = fileeuc;
198 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
199 strncpy(fRead,fEuclidGeomDet,60);
200 strncpy(fWrite,fEuclidGeomDet,60);
201 // The .det file for the geometry must have the same name as fileeuc with
202 // .euc replaced by .det.
206 //_____________________________________________________________________________
207 void AliITSvtest::CreateMaterials(){
209 // Read materials for the ITS
213 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
214 // FILE *file = fopen(fEuclidMaterial.Data(),"r");
215 FILE *file = fopen(filtmp,"r");
218 // ReadEuclidMedia(fEuclidMaterial.Data(),this);
219 ReadEuclidMedia(filtmp);
221 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
222 // fEuclidMaterial.Data());
228 //_____________________________________________________________________________
229 void AliITSvtest::CreateGeometry(){
230 //////////////////////////////////////////////////////////////////////
231 ////////////////////////////////////////////////////////////////////////
232 // Read geometry for the ITS
237 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
238 FILE *file = fopen(filtmp,"r");
242 printf("Ready to read Euclid geometry file\n");
243 ReadEuclid(fEuclidGeometry.Data(),topvol);
244 printf("Read in euclid geometries\n");
246 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
247 fEuclidGeometry.Data());
251 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
254 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
256 //---Outputs the geometry tree in the EUCLID/CAD format
259 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
260 } // end if (fEuclidOut)
261 cout <<"finished with euclid geometrys"<< endl;
263 //______________________________________________________________________
264 void AliITSvtest::InitAliITSgeom(){
265 // Based on the geometry tree defined in Geant 3.21, this
266 // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
268 // if(gMC->IsA()!=TGeant3::Class()) {
269 if(strcmp(gMC->GetName(),"TGeant3")) {
270 Error("InitAliITSgeom",
271 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
274 cout << "Reading Geometry transformation directly from Geant 3." << endl;
275 const Int_t nlayers = 6;
276 const Int_t ndeep = 9;
277 Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
278 Int_t nlad[nlayers],ndet[nlayers];
280 Float_t par[20],att[20];
281 Int_t npar,natt,idshape,imat,imed;
282 AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
283 Int_t mod,lay,lad,det,i,j,k;
284 char *names[nlayers][ndeep] = {
285 {"ALIC","ITSV","ITSD","IT12","I12B","I10B","I107","I101","ITS1"}, // lay=1
286 {"ALIC","ITSV","ITSD","IT12","I12B","I20B","I1D7","I1D1","ITS2"}, // lay=2
287 {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"," "," "}, // lay=3
288 {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"," "," "}, // lay=4
289 {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"," "," "}, // lay=5
290 {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"," "," "}};// lay=6
291 Int_t itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2, 4, 1, 1},// lay=1
292 {1,1,1,1,10, 4, 4, 1, 1},// lay=2
293 {1,1,1,1,14, 6, 1, 0, 0},// lay=3
294 {1,1,1,1,22, 8, 1, 0, 0},// lay=4
295 {1,1,1,1,34,22, 1, 0, 0},// lay=5
296 {1,1,1,1,38,25, 1, 0, 0}};//lay=6
298 // Sorry, but this is not very pritty code. It should be replaced
299 // at some point with a version that can search through the geometry
301 cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
302 for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
303 for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++)
304 itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
306 for(i=0;i<nlayers;i++){
308 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
309 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
313 if(fITSgeom!=0) delete fITSgeom;
314 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
315 ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
316 fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
318 for(lay=1;lay<=nlayers;lay++){
319 for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
320 for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
322 case 1: case 2: // layers 1 and 2 are a bit special
324 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
326 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
329 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
332 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
334 fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
335 if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
336 if(fMinorVersion==1){
337 fITSgeom->ReSetShape(kSPD,
338 new AliITSgeomSPD425Short());
339 } else if(fMinorVersion==2)
340 fITSgeom->ReSetShape(kSPD,
341 new AliITSgeomSPD425Short());
346 case 3: case 4: case 5: case 6: // layers 3-6
348 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
350 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
353 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
357 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
358 if(!(fITSgeom->IsShapeDefined(kSDD)))
359 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
362 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
363 if(!(fITSgeom->IsShapeDefined(kSSD)))
364 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75());
367 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
368 if(!(fITSgeom->IsShapeDefined(kSSD)))
369 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD75and275());
379 //_____________________________________________________________________________
380 void AliITSvtest::Init(){
381 ////////////////////////////////////////////////////////////////////////
382 // Initialise the ITS after it has been created.
383 ////////////////////////////////////////////////////////////////////////
387 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
388 for(i=0;i<28;i++) cout << "*";cout << endl;
390 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
391 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
392 if(fITSgeom!=0) delete fITSgeom;
393 fITSgeom = new AliITSgeom();
394 if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
395 if(!fGeomDetIn) this->InitAliITSgeom();
396 if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
399 for(i=0;i<72;i++) cout << "*";
402 //_____________________________________________________________________________
403 void AliITSvtest::StepManager(){
405 // Called for every step in the ITS
411 TLorentzVector position, momentum;
412 TClonesArray &lhits = *fHits;
416 if(gMC->IsTrackInside()) vol[3] += 1;
417 if(gMC->IsTrackEntering()) vol[3] += 2;
418 if(gMC->IsTrackExiting()) vol[3] += 4;
419 if(gMC->IsTrackOut()) vol[3] += 8;
420 if(gMC->IsTrackDisappeared()) vol[3] += 16;
421 if(gMC->IsTrackStop()) vol[3] += 32;
422 if(gMC->IsTrackAlive()) vol[3] += 64;
424 // Fill hit structure.
425 if(!(gMC->TrackCharge())) return;
427 // Only entering charged tracks
428 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
430 id = gMC->CurrentVolOffID(0,copy);
431 //detector copy in the ladder = 1<->4 (ITS1)
433 gMC->CurrentVolOffID(1,copy1);
434 //ladder copy in the module = 1<->2 (I186)
435 gMC->CurrentVolOffID(2,copy2);
436 //module copy in the layer = 1<->10 (I132)
437 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
438 } else if(id == fIdSens[1]){
440 id = gMC->CurrentVolOffID(0,copy);
441 //detector copy in the ladder = 1<->4 (ITS2)
443 gMC->CurrentVolOffID(1,copy1);
444 //ladder copy in the module = 1<->4 (I131)
445 gMC->CurrentVolOffID(2,copy2);
446 //module copy in the layer = 1<->10 (I132)
447 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
448 } else if(id == fIdSens[2]){
450 id = gMC->CurrentVolOffID(1,copy);
451 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
453 id = gMC->CurrentVolOffID(2,copy);
454 //ladder copy in the layer = 1<->12 (I316)
456 } else if(id == fIdSens[3]){
458 id = gMC->CurrentVolOffID(1,copy);
459 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
461 id = gMC->CurrentVolOffID(2,copy);
462 //ladder copy in the layer = 1<->22 (I417)
464 }else if(id == fIdSens[4]){
466 id = gMC->CurrentVolOffID(1,copy);
467 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
469 id = gMC->CurrentVolOffID(2,copy);
470 //ladder copy in the layer = 1<->34 (I565)
472 }else if(id == fIdSens[5]){
474 id = gMC->CurrentVolOffID(1,copy);
475 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
477 id = gMC->CurrentVolOffID(2,copy);
478 //ladder copy in the layer = 1<->38 (I569)
481 return; // not an ITS volume?
482 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
484 gMC->TrackPosition(position);
485 gMC->TrackMomentum(momentum);
493 hits[7]=gMC->TrackTime();
494 // Fill hit structure with this new hit.
495 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);