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