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