]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSvtest.cxx
Corrections in the detector response function (Yu.Belikov)
[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
88cb7938 16/* $Id$ */
3fccfd9e 17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// Inner Traking System version Test //
21// This class contains the base procedures for the Inner Tracking System //
22// //
23// Authors: R. Barbera, B. S. Nilsen. //
24// version Test //
25// Created October 16 1999. //
26// //
27///////////////////////////////////////////////////////////////////////////////
88cb7938 28
29#include <Riostream.h>
3fccfd9e 30#include <stdio.h>
31#include <stdlib.h>
32#include <TMath.h>
3fccfd9e 33#include <TNode.h>
3fccfd9e 34#include <TObjArray.h>
35#include <TObjString.h>
3fccfd9e 36#include <TSystem.h>
88cb7938 37#include <TTUBE.h>
38#include <TVirtualMC.h>
3fccfd9e 39
3fccfd9e 40#include "AliRun.h"
bae7e562 41#include "AliITSGeant3Geometry.h"
3fccfd9e 42#include "AliITSgeom.h"
bae7e562 43#include "AliITSgeomSDD.h"
88cb7938 44#include "AliITSgeomSPD.h"
bae7e562 45#include "AliITSgeomSSD.h"
88cb7938 46#include "AliITShit.h"
47#include "AliITSvtest.h"
48#include "AliRun.h"
5d12ce38 49#include "AliMC.h"
3fccfd9e 50
51ClassImp(AliITSvtest)
52
53//_____________________________________________________________________________
54AliITSvtest::AliITSvtest() {
3fccfd9e 55 // Standard constructor for the ITS
bae7e562 56 Int_t i;
57
3fccfd9e 58 fIdN = 0;
59 fIdName = 0;
60 fIdSens = 0;
bae7e562 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();
3fccfd9e 65 fMinorVersion = -1;
bae7e562 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';
3fccfd9e 69}
70//____________________________________________________________________________
ac74f489 71AliITSvtest::AliITSvtest(const AliITSvtest &source) : AliITS(source){
3fccfd9e 72////////////////////////////////////////////////////////////////////////
73// Copy Constructor for ITS test version.
74////////////////////////////////////////////////////////////////////////
75 if(&source == this) return;
bae7e562 76 Warning("Copy Constructor","Not allowed to copy AliITSvtest");
3fccfd9e 77 return;
78}
79//_____________________________________________________________________________
80AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
81////////////////////////////////////////////////////////////////////////
82// Assignment operator for the ITS version 1.
83////////////////////////////////////////////////////////////////////////
84 if(&source == this) return *this;
bae7e562 85 Warning("= operator","Not allowed to copy AliITSvtest");
3fccfd9e 86 return *this;
87}
88//_____________________________________________________________________________
89AliITSvtest::~AliITSvtest() {
3fccfd9e 90 // Standard destructor for the ITS
3fccfd9e 91}
92//_____________________________________________________________________________
93AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
94 const char *name, const char *title)
95 : AliITS(name, title){
96 //
97 // Standard constructor for the ITS
98 //
99 fIdN = 6;
3fccfd9e 100 fIdName = new TString[fIdN];
101 fIdName[0] = "ITS1";
102 fIdName[1] = "ITS2";
103 fIdName[2] = "ITS3";
104 fIdName[3] = "ITS4";
105 fIdName[4] = "ITS5";
106 fIdName[5] = "ITS6";
107 fIdSens = new Int_t[fIdN];
108 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
bae7e562 109 fMajorVersion = IsVersion();
3fccfd9e 110 fMinorVersion = 1;
bae7e562 111 fEuclidOut = kFALSE; // Don't write Euclide file
112 fGeomDetOut = kFALSE; // Don't write .det file
113 fGeomDetIn = kTRUE; // Read .det file
3fccfd9e 114
115 fEuclidMaterial = filetme;
116 fEuclidGeometry = fileeuc;
bae7e562 117 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
118 strncpy(fRead,fEuclidGeomDet,60);
119 strncpy(fWrite,fEuclidGeomDet,60);
3fccfd9e 120// The .det file for the geometry must have the same name as fileeuc with
121// .euc replaced by .det.
122}
123
124
125//_____________________________________________________________________________
126void AliITSvtest::CreateMaterials(){
127 //
128 // Read materials for the ITS
129 //
130 char *filtmp;
131//
132 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
133// FILE *file = fopen(fEuclidMaterial.Data(),"r");
134 FILE *file = fopen(filtmp,"r");
135 if(file) {
136 fclose(file);
137// ReadEuclidMedia(fEuclidMaterial.Data(),this);
138 ReadEuclidMedia(filtmp);
139 } else {
140 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
141// fEuclidMaterial.Data());
142 filtmp);
143 exit(1);
144 } // end if(file)
145}
146
147//_____________________________________________________________________________
148void AliITSvtest::CreateGeometry(){
149//////////////////////////////////////////////////////////////////////
150////////////////////////////////////////////////////////////////////////
151// Read geometry for the ITS
152//
3fccfd9e 153 char topvol[5];
154 char *filtmp;
155//
156 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
157 FILE *file = fopen(filtmp,"r");
158 delete [] filtmp;
159 if(file) {
160 fclose(file);
161 printf("Ready to read Euclid geometry file\n");
162 ReadEuclid(fEuclidGeometry.Data(),topvol);
163 printf("Read in euclid geometries\n");
164 } else {
165 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
166 fEuclidGeometry.Data());
167 exit(1);
168 } // end if(file)
169 //
170 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
171 // invisible
172 //
173 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
174 //
175 //---Outputs the geometry tree in the EUCLID/CAD format
176
177 if (fEuclidOut) {
178 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
179 } // end if (fEuclidOut)
bae7e562 180 cout <<"finished with euclid geometrys"<< endl;
3fccfd9e 181}
bae7e562 182//______________________________________________________________________
183void 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
186// sturture.
b9d0a01d 187// if(gMC->IsA()!=TGeant3::Class()) {
188 if(strcmp(gMC->GetName(),"TGeant3")) {
bae7e562 189 Error("InitAliITSgeom",
190 "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
191 return;
192 } // end if
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];
198 Double_t t[3],r[10];
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 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
216
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
219 // tree its self.
220 cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
221 for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
18f30131 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]);
bae7e562 225 mod = 0;
226 for(i=0;i<nlayers;i++){
227 k = 1;
228 for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
229 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
230 mod += k;
231 } // end for i
3fccfd9e 232
bae7e562 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);
237 mod = -1;
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];
241 switch (lay){
242 case 1: case 2: // layers 1 and 2 are a bit special
243 lad = 0;
244 for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
245 lnum[4] = j;
246 for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
247 lad++;
248 lnum[5] = k;
249 for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
250 lnum[6] = det;
251 mod++;
252 ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,
253 par,att,imat,imed);
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());
262 } // end for det
263 } // end for k
264 } // end for j
265 break;
266 case 3: case 4: case 5: case 6: // layers 3-6
267 lnum[6] = 1;
268 for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
269 lnum[4] = lad;
270 for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
271 lnum[5] = det;
272 mod++;
273 ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
274 par,att,imat,imed);
275 switch (lay){
276 case 3: case 4:
277 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
278 if(!(fITSgeom->IsShapeDefined(kSDD)))
279 fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
280 break;
281 case 5:
282 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
283 if(!(fITSgeom->IsShapeDefined(kSSD)))
284 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75());
285 break;
286 case 6:
1570d46d 287 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
288 if(!(fITSgeom->IsShapeDefined(kSSD)))
289 fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD75and275());
bae7e562 290 break;
291 } // end switch
292 } // end for det
293 } // end for lad
294 break;
295 } // end switch
296 } // end for lay
297 return;
298}
3fccfd9e 299//_____________________________________________________________________________
300void AliITSvtest::Init(){
bae7e562 301////////////////////////////////////////////////////////////////////////
302// Initialise the ITS after it has been created.
303////////////////////////////////////////////////////////////////////////
304 Int_t i;
305
306 cout << endl;
307 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
308 for(i=0;i<28;i++) cout << "*";cout << endl;
309//
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);
3fccfd9e 317 AliITS::Init();
bae7e562 318//
319 for(i=0;i<72;i++) cout << "*";
320 cout << endl;
321}
3fccfd9e 322//_____________________________________________________________________________
323void AliITSvtest::StepManager(){
324 //
325 // Called for every step in the ITS
326 //
327 Int_t copy, id;
328 Int_t copy1,copy2;
329 Float_t hits[8];
330 Int_t vol[4];
331 TLorentzVector position, momentum;
332 TClonesArray &lhits = *fHits;
333 //
334 // Track status
335 vol[3] = 0;
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;
343 //
344 // Fill hit structure.
345 if(!(gMC->TrackCharge())) return;
346 //
347 // Only entering charged tracks
348 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
349 vol[0] = 1;
350 id = gMC->CurrentVolOffID(0,copy);
351 //detector copy in the ladder = 1<->4 (ITS1)
352 vol[1] = copy;
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]){
359 vol[0] = 2;
360 id = gMC->CurrentVolOffID(0,copy);
361 //detector copy in the ladder = 1<->4 (ITS2)
362 vol[1] = copy;
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]){
369 vol[0] = 3;
370 id = gMC->CurrentVolOffID(1,copy);
371 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
372 vol[1] = copy;
373 id = gMC->CurrentVolOffID(2,copy);
374 //ladder copy in the layer = 1<->12 (I316)
375 vol[2] = copy;
376 } else if(id == fIdSens[3]){
377 vol[0] = 4;
378 id = gMC->CurrentVolOffID(1,copy);
379 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
380 vol[1] = copy;
381 id = gMC->CurrentVolOffID(2,copy);
382 //ladder copy in the layer = 1<->22 (I417)
383 vol[2] = copy;
384 }else if(id == fIdSens[4]){
385 vol[0] = 5;
386 id = gMC->CurrentVolOffID(1,copy);
387 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
388 vol[1] = copy;
389 id = gMC->CurrentVolOffID(2,copy);
390 //ladder copy in the layer = 1<->34 (I565)
391 vol[2] = copy;
392 }else if(id == fIdSens[5]){
393 vol[0] = 6;
394 id = gMC->CurrentVolOffID(1,copy);
395 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
396 vol[1] = copy;
397 id = gMC->CurrentVolOffID(2,copy);
398 //ladder copy in the layer = 1<->38 (I569)
399 vol[2] = copy;
400 } else {
401 return; // not an ITS volume?
402 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
403//
404 gMC->TrackPosition(position);
405 gMC->TrackMomentum(momentum);
406 hits[0]=position[0];
407 hits[1]=position[1];
408 hits[2]=position[2];
409 hits[3]=momentum[0];
410 hits[4]=momentum[1];
411 hits[5]=momentum[2];
412 hits[6]=gMC->Edep();
413 hits[7]=gMC->TrackTime();
414 // Fill hit structure with this new hit.
5d12ce38 415 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
3fccfd9e 416 return;
417}
3fccfd9e 418