]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSvtest.cxx
First commit.
[u/mrichter/AliRoot.git] / ITS / AliITSvtest.cxx
CommitLineData
3fccfd9e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
5d02ea6f 18Revision 1.15 2002/10/22 14:46:03 alibrary
19Introducing Riostream.h
20
4ae5bbc4 21Revision 1.14 2002/10/14 14:57:10 hristov
22Merging the VirtualMC branch to the main development branch (HEAD)
23
b9d0a01d 24Revision 1.13.8.2 2002/08/30 15:45:56 alibrary
25Adding geant4vmc support
26
27Revision 1.13.8.1 2002/06/10 17:51:17 hristov
28Merged with v3-08-02
29
30Revision 1.13 2001/10/01 19:34:09 nilsen
31Fixed a bug in asigning detector types in SetDefaults under SSD layer 6.
32
1570d46d 33Revision 1.12 2001/08/24 21:04:36 nilsen
34Added some include files. Needed due to new forward declorations in other
35files
36
04436464 37Revision 1.11 2001/05/30 16:15:47 fca
38Correct comparison wiht AliGeant3::Class() introduced. Thanks to I.Hrivnacova
39
cbfdea0d 40Revision 1.10 2001/05/30 15:55:35 hristov
41Strings compared instead of pointers
42
268b9c60 43Revision 1.9 2001/05/30 14:04:31 hristov
44Dynamic cast replaced (F.Carminati)
45
4154d3d8 46Revision 1.8 2001/02/13 16:53:35 nilsen
47Fixed a but when trying to use GEANT4. Needed to replace
48if(!((TGeant3*)gMC)) with if(!(dynamic_casst<TGeant3*>(gMC)))
49because just casting gMC to be TGeant3* even when it realy is a TGeant3 pointer
50did not result in a zero value. For AliITSv5asymm and AliITSv5symm, needed
51to fix a bug in the initilizers and a bug in BuildGeometry. This is now done
52in the same way as in AliITSv5.cxx.
53
9a4c6ea3 54Revision 1.7 2001/02/09 20:06:26 nilsen
55Fixed bug in distructor. Can't distroy fixxed length arrays. Thanks Peter.
56
58e13d99 57Revision 1.6 2001/02/09 00:05:31 nilsen
58Added fMajor/MinorVersion variables and made other changes to better make
59use of the new code changes in AliITSgeom related classes.
60
bae7e562 61Revision 1.5 2001/01/30 09:23:14 hristov
62Streamers removed (R.Brun)
63
a8a6107b 64Revision 1.4 2001/01/18 06:25:09 barbera
65ITS geometry using test Euclid files
66
3fccfd9e 67Revision 1.1.2.8 2000/10/05 20:28:18 nilsen
68Now using root generated streamer function.
69
70Revision 1.1.2.7 2000/07/31 13:51:22 barbera
71Updated from the release
72
73Revision 1.2 2000/07/10 16:07:19 fca
74Release version of ITS code
75
76Revision 1.1.2.2 2000/03/02 21:53:36 nilsen
77to make it compatable with the changes in AliRun/AliModule.
78
79Revision 1.1.2.1 2000/01/12 20:19:03 nilsen
80 The changes made with this latest inclusion of code is very large.
81Many of the new files were added just in December when P. Cerello added his
82SDD simulations to the distrobutions. Also added are some file of P. Skowronski
83for SSD cluster finding and ghost RecPoints. None of this "new" code has been
84proporly tested. Other code new to this cvs repository is explained in the
85ITS Off-line web page. In general the changes are too large to give a resonable
86discription of them but probably should be taken as the starting point for
87the developement branch (ITS-working).
88 B. S. Nilsen
89
90Revision 1.13 1999/10/16 19:49:00 BSN
91$Name$
92$Author$
93$Id$
94*/
95
96///////////////////////////////////////////////////////////////////////////////
97// //
98// Inner Traking System version Test //
99// This class contains the base procedures for the Inner Tracking System //
100// //
101// Authors: R. Barbera, B. S. Nilsen. //
102// version Test //
103// Created October 16 1999. //
104// //
105///////////////////////////////////////////////////////////////////////////////
106#include <stdio.h>
107#include <stdlib.h>
4ae5bbc4 108#include <Riostream.h>
3fccfd9e 109#include <TMath.h>
110#include <TGeometry.h>
111#include <TNode.h>
112#include <TTUBE.h>
113#include <TFile.h> // only required for Tracking function?
114#include <TCanvas.h>
115#include <TObjArray.h>
116#include <TObjString.h>
117#include <TClonesArray.h>
118#include <TLorentzVector.h>
119#include <TBRIK.h>
120#include <TSystem.h>
121
3fccfd9e 122#include "AliRun.h"
bae7e562 123#include "AliITSGeant3Geometry.h"
3fccfd9e 124#include "AliITShit.h"
125#include "AliITS.h"
126#include "AliITSvtest.h"
127#include "AliITSgeom.h"
bae7e562 128#include "AliITSgeomSPD.h"
129#include "AliITSgeomSDD.h"
130#include "AliITSgeomSSD.h"
3fccfd9e 131
132ClassImp(AliITSvtest)
133
134//_____________________________________________________________________________
135AliITSvtest::AliITSvtest() {
3fccfd9e 136 // Standard constructor for the ITS
bae7e562 137 Int_t i;
138
3fccfd9e 139 fIdN = 0;
140 fIdName = 0;
141 fIdSens = 0;
bae7e562 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();
3fccfd9e 146 fMinorVersion = -1;
bae7e562 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';
3fccfd9e 150}
151//____________________________________________________________________________
152AliITSvtest::AliITSvtest(const AliITSvtest &source){
153////////////////////////////////////////////////////////////////////////
154// Copy Constructor for ITS test version.
155////////////////////////////////////////////////////////////////////////
156 if(&source == this) return;
bae7e562 157 Warning("Copy Constructor","Not allowed to copy AliITSvtest");
3fccfd9e 158 return;
159}
160//_____________________________________________________________________________
161AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
162////////////////////////////////////////////////////////////////////////
163// Assignment operator for the ITS version 1.
164////////////////////////////////////////////////////////////////////////
165 if(&source == this) return *this;
bae7e562 166 Warning("= operator","Not allowed to copy AliITSvtest");
3fccfd9e 167 return *this;
168}
169//_____________________________________________________________________________
170AliITSvtest::~AliITSvtest() {
3fccfd9e 171 // Standard destructor for the ITS
3fccfd9e 172}
173//_____________________________________________________________________________
174AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
175 const char *name, const char *title)
176 : AliITS(name, title){
177 //
178 // Standard constructor for the ITS
179 //
180 fIdN = 6;
3fccfd9e 181 fIdName = new TString[fIdN];
182 fIdName[0] = "ITS1";
183 fIdName[1] = "ITS2";
184 fIdName[2] = "ITS3";
185 fIdName[3] = "ITS4";
186 fIdName[4] = "ITS5";
187 fIdName[5] = "ITS6";
188 fIdSens = new Int_t[fIdN];
189 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
bae7e562 190 fMajorVersion = IsVersion();
3fccfd9e 191 fMinorVersion = 1;
bae7e562 192 fEuclidOut = kFALSE; // Don't write Euclide file
193 fGeomDetOut = kFALSE; // Don't write .det file
194 fGeomDetIn = kTRUE; // Read .det file
3fccfd9e 195
196 fEuclidMaterial = filetme;
197 fEuclidGeometry = fileeuc;
bae7e562 198 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
199 strncpy(fRead,fEuclidGeomDet,60);
200 strncpy(fWrite,fEuclidGeomDet,60);
3fccfd9e 201// The .det file for the geometry must have the same name as fileeuc with
202// .euc replaced by .det.
203}
204
205
206//_____________________________________________________________________________
207void AliITSvtest::CreateMaterials(){
208 //
209 // Read materials for the ITS
210 //
211 char *filtmp;
212//
213 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
214// FILE *file = fopen(fEuclidMaterial.Data(),"r");
215 FILE *file = fopen(filtmp,"r");
216 if(file) {
217 fclose(file);
218// ReadEuclidMedia(fEuclidMaterial.Data(),this);
219 ReadEuclidMedia(filtmp);
220 } else {
221 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
222// fEuclidMaterial.Data());
223 filtmp);
224 exit(1);
225 } // end if(file)
226}
227
228//_____________________________________________________________________________
229void AliITSvtest::CreateGeometry(){
230//////////////////////////////////////////////////////////////////////
231////////////////////////////////////////////////////////////////////////
232// Read geometry for the ITS
233//
3fccfd9e 234 char topvol[5];
235 char *filtmp;
236//
237 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
238 FILE *file = fopen(filtmp,"r");
239 delete [] filtmp;
240 if(file) {
241 fclose(file);
242 printf("Ready to read Euclid geometry file\n");
243 ReadEuclid(fEuclidGeometry.Data(),topvol);
244 printf("Read in euclid geometries\n");
245 } else {
246 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
247 fEuclidGeometry.Data());
248 exit(1);
249 } // end if(file)
250 //
251 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
252 // invisible
253 //
254 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
255 //
256 //---Outputs the geometry tree in the EUCLID/CAD format
257
258 if (fEuclidOut) {
259 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
260 } // end if (fEuclidOut)
bae7e562 261 cout <<"finished with euclid geometrys"<< endl;
3fccfd9e 262}
bae7e562 263//______________________________________________________________________
264void 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
267// sturture.
b9d0a01d 268// if(gMC->IsA()!=TGeant3::Class()) {
269 if(strcmp(gMC->GetName(),"TGeant3")) {
bae7e562 270 Error("InitAliITSgeom",
271 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
272 return;
273 } // end if
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];
279 Double_t t[3],r[10];
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
297
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
300 // tree its self.
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]);
305 mod = 0;
306 for(i=0;i<nlayers;i++){
307 k = 1;
308 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
309 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
310 mod += k;
311 } // end for i
3fccfd9e 312
bae7e562 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);
317 mod = -1;
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];
321 switch (lay){
322 case 1: case 2: // layers 1 and 2 are a bit special
323 lad = 0;
324 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
325 lnum[4] = j;
326 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
327 lad++;
328 lnum[5] = k;
329 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
330 lnum[6] = det;
331 mod++;
332 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
333 par,att,imat,imed);
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());
342 } // end for det
343 } // end for k
344 } // end for j
345 break;
346 case 3: case 4: case 5: case 6: // layers 3-6
347 lnum[6] = 1;
348 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
349 lnum[4] = lad;
350 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
351 lnum[5] = det;
352 mod++;
353 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
354 par,att,imat,imed);
355 switch (lay){
356 case 3: case 4:
357 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
358 if(!(fITSgeom->IsShapeDefined(kSDD)))
359 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
360 break;
361 case 5:
362 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
363 if(!(fITSgeom->IsShapeDefined(kSSD)))
364 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75());
365 break;
366 case 6:
1570d46d 367 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
368 if(!(fITSgeom->IsShapeDefined(kSSD)))
369 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD75and275());
bae7e562 370 break;
371 } // end switch
372 } // end for det
373 } // end for lad
374 break;
375 } // end switch
376 } // end for lay
377 return;
378}
3fccfd9e 379//_____________________________________________________________________________
380void AliITSvtest::Init(){
bae7e562 381////////////////////////////////////////////////////////////////////////
382// Initialise the ITS after it has been created.
383////////////////////////////////////////////////////////////////////////
384 Int_t i;
385
386 cout << endl;
387 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
388 for(i=0;i<28;i++) cout << "*";cout << endl;
389//
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);
3fccfd9e 397 AliITS::Init();
bae7e562 398//
399 for(i=0;i<72;i++) cout << "*";
400 cout << endl;
401}
3fccfd9e 402//_____________________________________________________________________________
403void AliITSvtest::StepManager(){
404 //
405 // Called for every step in the ITS
406 //
407 Int_t copy, id;
408 Int_t copy1,copy2;
409 Float_t hits[8];
410 Int_t vol[4];
411 TLorentzVector position, momentum;
412 TClonesArray &lhits = *fHits;
413 //
414 // Track status
415 vol[3] = 0;
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;
423 //
424 // Fill hit structure.
425 if(!(gMC->TrackCharge())) return;
426 //
427 // Only entering charged tracks
428 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
429 vol[0] = 1;
430 id = gMC->CurrentVolOffID(0,copy);
431 //detector copy in the ladder = 1<->4 (ITS1)
432 vol[1] = copy;
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]){
439 vol[0] = 2;
440 id = gMC->CurrentVolOffID(0,copy);
441 //detector copy in the ladder = 1<->4 (ITS2)
442 vol[1] = copy;
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]){
449 vol[0] = 3;
450 id = gMC->CurrentVolOffID(1,copy);
451 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
452 vol[1] = copy;
453 id = gMC->CurrentVolOffID(2,copy);
454 //ladder copy in the layer = 1<->12 (I316)
455 vol[2] = copy;
456 } else if(id == fIdSens[3]){
457 vol[0] = 4;
458 id = gMC->CurrentVolOffID(1,copy);
459 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
460 vol[1] = copy;
461 id = gMC->CurrentVolOffID(2,copy);
462 //ladder copy in the layer = 1<->22 (I417)
463 vol[2] = copy;
464 }else if(id == fIdSens[4]){
465 vol[0] = 5;
466 id = gMC->CurrentVolOffID(1,copy);
467 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
468 vol[1] = copy;
469 id = gMC->CurrentVolOffID(2,copy);
470 //ladder copy in the layer = 1<->34 (I565)
471 vol[2] = copy;
472 }else if(id == fIdSens[5]){
473 vol[0] = 6;
474 id = gMC->CurrentVolOffID(1,copy);
475 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
476 vol[1] = copy;
477 id = gMC->CurrentVolOffID(2,copy);
478 //ladder copy in the layer = 1<->38 (I569)
479 vol[2] = copy;
480 } else {
481 return; // not an ITS volume?
482 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
483//
484 gMC->TrackPosition(position);
485 gMC->TrackMomentum(momentum);
486 hits[0]=position[0];
487 hits[1]=position[1];
488 hits[2]=position[2];
489 hits[3]=momentum[0];
490 hits[4]=momentum[1];
491 hits[5]=momentum[2];
492 hits[6]=gMC->Edep();
493 hits[7]=gMC->TrackTime();
494 // Fill hit structure with this new hit.
495 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
496 return;
497}
3fccfd9e 498