]>
Commit | Line | Data |
---|---|---|
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" | |
3fccfd9e | 49 | |
50 | ClassImp(AliITSvtest) | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliITSvtest::AliITSvtest() { | |
3fccfd9e | 54 | // Standard constructor for the ITS |
bae7e562 | 55 | Int_t i; |
56 | ||
3fccfd9e | 57 | fIdN = 0; |
58 | fIdName = 0; | |
59 | fIdSens = 0; | |
bae7e562 | 60 | fEuclidOut = kFALSE; // Don't write Euclide file |
61 | fGeomDetOut = kFALSE; // Don't write .det file | |
62 | fGeomDetIn = kTRUE; // Read .det file | |
63 | fMajorVersion = IsVersion(); | |
3fccfd9e | 64 | fMinorVersion = -1; |
bae7e562 | 65 | for(i=0;i<60;i++) fRead[i] = '\0'; |
66 | for(i=0;i<60;i++) fWrite[i] = '\0'; | |
67 | for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0'; | |
3fccfd9e | 68 | } |
69 | //____________________________________________________________________________ | |
70 | AliITSvtest::AliITSvtest(const AliITSvtest &source){ | |
71 | //////////////////////////////////////////////////////////////////////// | |
72 | // Copy Constructor for ITS test version. | |
73 | //////////////////////////////////////////////////////////////////////// | |
74 | if(&source == this) return; | |
bae7e562 | 75 | Warning("Copy Constructor","Not allowed to copy AliITSvtest"); |
3fccfd9e | 76 | return; |
77 | } | |
78 | //_____________________________________________________________________________ | |
79 | AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){ | |
80 | //////////////////////////////////////////////////////////////////////// | |
81 | // Assignment operator for the ITS version 1. | |
82 | //////////////////////////////////////////////////////////////////////// | |
83 | if(&source == this) return *this; | |
bae7e562 | 84 | Warning("= operator","Not allowed to copy AliITSvtest"); |
3fccfd9e | 85 | return *this; |
86 | } | |
87 | //_____________________________________________________________________________ | |
88 | AliITSvtest::~AliITSvtest() { | |
3fccfd9e | 89 | // Standard destructor for the ITS |
3fccfd9e | 90 | } |
91 | //_____________________________________________________________________________ | |
92 | AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme, | |
93 | const char *name, const char *title) | |
94 | : AliITS(name, title){ | |
95 | // | |
96 | // Standard constructor for the ITS | |
97 | // | |
98 | fIdN = 6; | |
3fccfd9e | 99 | fIdName = new TString[fIdN]; |
100 | fIdName[0] = "ITS1"; | |
101 | fIdName[1] = "ITS2"; | |
102 | fIdName[2] = "ITS3"; | |
103 | fIdName[3] = "ITS4"; | |
104 | fIdName[4] = "ITS5"; | |
105 | fIdName[5] = "ITS6"; | |
106 | fIdSens = new Int_t[fIdN]; | |
107 | for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0; | |
bae7e562 | 108 | fMajorVersion = IsVersion(); |
3fccfd9e | 109 | fMinorVersion = 1; |
bae7e562 | 110 | fEuclidOut = kFALSE; // Don't write Euclide file |
111 | fGeomDetOut = kFALSE; // Don't write .det file | |
112 | fGeomDetIn = kTRUE; // Read .det file | |
3fccfd9e | 113 | |
114 | fEuclidMaterial = filetme; | |
115 | fEuclidGeometry = fileeuc; | |
bae7e562 | 116 | strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60); |
117 | strncpy(fRead,fEuclidGeomDet,60); | |
118 | strncpy(fWrite,fEuclidGeomDet,60); | |
3fccfd9e | 119 | // The .det file for the geometry must have the same name as fileeuc with |
120 | // .euc replaced by .det. | |
121 | } | |
122 | ||
123 | ||
124 | //_____________________________________________________________________________ | |
125 | void AliITSvtest::CreateMaterials(){ | |
126 | // | |
127 | // Read materials for the ITS | |
128 | // | |
129 | char *filtmp; | |
130 | // | |
131 | filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data()); | |
132 | // FILE *file = fopen(fEuclidMaterial.Data(),"r"); | |
133 | FILE *file = fopen(filtmp,"r"); | |
134 | if(file) { | |
135 | fclose(file); | |
136 | // ReadEuclidMedia(fEuclidMaterial.Data(),this); | |
137 | ReadEuclidMedia(filtmp); | |
138 | } else { | |
139 | Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !", | |
140 | // fEuclidMaterial.Data()); | |
141 | filtmp); | |
142 | exit(1); | |
143 | } // end if(file) | |
144 | } | |
145 | ||
146 | //_____________________________________________________________________________ | |
147 | void AliITSvtest::CreateGeometry(){ | |
148 | ////////////////////////////////////////////////////////////////////// | |
149 | //////////////////////////////////////////////////////////////////////// | |
150 | // Read geometry for the ITS | |
151 | // | |
3fccfd9e | 152 | char topvol[5]; |
153 | char *filtmp; | |
154 | // | |
155 | filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data()); | |
156 | FILE *file = fopen(filtmp,"r"); | |
157 | delete [] filtmp; | |
158 | if(file) { | |
159 | fclose(file); | |
160 | printf("Ready to read Euclid geometry file\n"); | |
161 | ReadEuclid(fEuclidGeometry.Data(),topvol); | |
162 | printf("Read in euclid geometries\n"); | |
163 | } else { | |
164 | Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !", | |
165 | fEuclidGeometry.Data()); | |
166 | exit(1); | |
167 | } // end if(file) | |
168 | // | |
169 | //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it | |
170 | // invisible | |
171 | // | |
172 | gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY"); | |
173 | // | |
174 | //---Outputs the geometry tree in the EUCLID/CAD format | |
175 | ||
176 | if (fEuclidOut) { | |
177 | gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5); | |
178 | } // end if (fEuclidOut) | |
bae7e562 | 179 | cout <<"finished with euclid geometrys"<< endl; |
3fccfd9e | 180 | } |
bae7e562 | 181 | //______________________________________________________________________ |
182 | void AliITSvtest::InitAliITSgeom(){ | |
183 | // Based on the geometry tree defined in Geant 3.21, this | |
184 | // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry | |
185 | // sturture. | |
b9d0a01d | 186 | // if(gMC->IsA()!=TGeant3::Class()) { |
187 | if(strcmp(gMC->GetName(),"TGeant3")) { | |
bae7e562 | 188 | Error("InitAliITSgeom", |
189 | "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls"); | |
190 | return; | |
191 | } // end if | |
192 | cout << "Reading Geometry transformation directly from Geant 3." << endl; | |
193 | const Int_t nlayers = 6; | |
194 | const Int_t ndeep = 9; | |
195 | Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20]; | |
196 | Int_t nlad[nlayers],ndet[nlayers]; | |
197 | Double_t t[3],r[10]; | |
198 | Float_t par[20],att[20]; | |
199 | Int_t npar,natt,idshape,imat,imed; | |
200 | AliITSGeant3Geometry *ig = new AliITSGeant3Geometry(); | |
201 | Int_t mod,lay,lad,det,i,j,k; | |
202 | char *names[nlayers][ndeep] = { | |
203 | {"ALIC","ITSV","ITSD","IT12","I12B","I10B","I107","I101","ITS1"}, // lay=1 | |
204 | {"ALIC","ITSV","ITSD","IT12","I12B","I20B","I1D7","I1D1","ITS2"}, // lay=2 | |
205 | {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3"," "," "}, // lay=3 | |
206 | {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4"," "," "}, // lay=4 | |
207 | {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5"," "," "}, // lay=5 | |
208 | {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6"," "," "}};// lay=6 | |
209 | Int_t itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2, 4, 1, 1},// lay=1 | |
210 | {1,1,1,1,10, 4, 4, 1, 1},// lay=2 | |
211 | {1,1,1,1,14, 6, 1, 0, 0},// lay=3 | |
212 | {1,1,1,1,22, 8, 1, 0, 0},// lay=4 | |
213 | {1,1,1,1,34,22, 1, 0, 0},// lay=5 | |
214 | {1,1,1,1,38,25, 1, 0, 0}};//lay=6 | |
215 | ||
216 | // Sorry, but this is not very pritty code. It should be replaced | |
217 | // at some point with a version that can search through the geometry | |
218 | // tree its self. | |
219 | cout << "Reading Geometry informaton from Geant3 common blocks" << endl; | |
220 | for(i=0;i<20;i++) lnam[i] = lnum[i] = 0; | |
18f30131 | 221 | for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) |
222 | strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4); | |
223 | // itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]); | |
bae7e562 | 224 | mod = 0; |
225 | for(i=0;i<nlayers;i++){ | |
226 | k = 1; | |
227 | for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0) | |
228 | k *= TMath::Abs(itsGeomTreeCopys[i][j]); | |
229 | mod += k; | |
230 | } // end for i | |
3fccfd9e | 231 | |
bae7e562 | 232 | if(fITSgeom!=0) delete fITSgeom; |
233 | nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38; | |
234 | ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25; | |
235 | fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod); | |
236 | mod = -1; | |
237 | for(lay=1;lay<=nlayers;lay++){ | |
238 | for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j]; | |
239 | for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j]; | |
240 | switch (lay){ | |
241 | case 1: case 2: // layers 1 and 2 are a bit special | |
242 | lad = 0; | |
243 | for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){ | |
244 | lnum[4] = j; | |
245 | for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){ | |
246 | lad++; | |
247 | lnum[5] = k; | |
248 | for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){ | |
249 | lnum[6] = det; | |
250 | mod++; | |
251 | ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt, | |
252 | par,att,imat,imed); | |
253 | fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r); | |
254 | if(!(fITSgeom->IsShapeDefined((Int_t)kSPD))) | |
255 | if(fMinorVersion==1){ | |
256 | fITSgeom->ReSetShape(kSPD, | |
257 | new AliITSgeomSPD425Short()); | |
258 | } else if(fMinorVersion==2) | |
259 | fITSgeom->ReSetShape(kSPD, | |
260 | new AliITSgeomSPD425Short()); | |
261 | } // end for det | |
262 | } // end for k | |
263 | } // end for j | |
264 | break; | |
265 | case 3: case 4: case 5: case 6: // layers 3-6 | |
266 | lnum[6] = 1; | |
267 | for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){ | |
268 | lnum[4] = lad; | |
269 | for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){ | |
270 | lnum[5] = det; | |
271 | mod++; | |
272 | ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt, | |
273 | par,att,imat,imed); | |
274 | switch (lay){ | |
275 | case 3: case 4: | |
276 | fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r); | |
277 | if(!(fITSgeom->IsShapeDefined(kSDD))) | |
278 | fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256()); | |
279 | break; | |
280 | case 5: | |
281 | fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r); | |
282 | if(!(fITSgeom->IsShapeDefined(kSSD))) | |
283 | fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75()); | |
284 | break; | |
285 | case 6: | |
1570d46d | 286 | fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r); |
287 | if(!(fITSgeom->IsShapeDefined(kSSD))) | |
288 | fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD75and275()); | |
bae7e562 | 289 | break; |
290 | } // end switch | |
291 | } // end for det | |
292 | } // end for lad | |
293 | break; | |
294 | } // end switch | |
295 | } // end for lay | |
296 | return; | |
297 | } | |
3fccfd9e | 298 | //_____________________________________________________________________________ |
299 | void AliITSvtest::Init(){ | |
bae7e562 | 300 | //////////////////////////////////////////////////////////////////////// |
301 | // Initialise the ITS after it has been created. | |
302 | //////////////////////////////////////////////////////////////////////// | |
303 | Int_t i; | |
304 | ||
305 | cout << endl; | |
306 | for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init "; | |
307 | for(i=0;i<28;i++) cout << "*";cout << endl; | |
308 | // | |
309 | if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60); | |
310 | if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60); | |
311 | if(fITSgeom!=0) delete fITSgeom; | |
312 | fITSgeom = new AliITSgeom(); | |
313 | if(fGeomDetIn) fITSgeom->ReadNewFile(fRead); | |
314 | if(!fGeomDetIn) this->InitAliITSgeom(); | |
315 | if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite); | |
3fccfd9e | 316 | AliITS::Init(); |
bae7e562 | 317 | // |
318 | for(i=0;i<72;i++) cout << "*"; | |
319 | cout << endl; | |
320 | } | |
3fccfd9e | 321 | //_____________________________________________________________________________ |
322 | void AliITSvtest::StepManager(){ | |
323 | // | |
324 | // Called for every step in the ITS | |
325 | // | |
326 | Int_t copy, id; | |
327 | Int_t copy1,copy2; | |
328 | Float_t hits[8]; | |
329 | Int_t vol[4]; | |
330 | TLorentzVector position, momentum; | |
331 | TClonesArray &lhits = *fHits; | |
332 | // | |
333 | // Track status | |
334 | vol[3] = 0; | |
335 | if(gMC->IsTrackInside()) vol[3] += 1; | |
336 | if(gMC->IsTrackEntering()) vol[3] += 2; | |
337 | if(gMC->IsTrackExiting()) vol[3] += 4; | |
338 | if(gMC->IsTrackOut()) vol[3] += 8; | |
339 | if(gMC->IsTrackDisappeared()) vol[3] += 16; | |
340 | if(gMC->IsTrackStop()) vol[3] += 32; | |
341 | if(gMC->IsTrackAlive()) vol[3] += 64; | |
342 | // | |
343 | // Fill hit structure. | |
344 | if(!(gMC->TrackCharge())) return; | |
345 | // | |
346 | // Only entering charged tracks | |
347 | if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) { | |
348 | vol[0] = 1; | |
349 | id = gMC->CurrentVolOffID(0,copy); | |
350 | //detector copy in the ladder = 1<->4 (ITS1) | |
351 | vol[1] = copy; | |
352 | gMC->CurrentVolOffID(1,copy1); | |
353 | //ladder copy in the module = 1<->2 (I186) | |
354 | gMC->CurrentVolOffID(2,copy2); | |
355 | //module copy in the layer = 1<->10 (I132) | |
356 | vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2 | |
357 | } else if(id == fIdSens[1]){ | |
358 | vol[0] = 2; | |
359 | id = gMC->CurrentVolOffID(0,copy); | |
360 | //detector copy in the ladder = 1<->4 (ITS2) | |
361 | vol[1] = copy; | |
362 | gMC->CurrentVolOffID(1,copy1); | |
363 | //ladder copy in the module = 1<->4 (I131) | |
364 | gMC->CurrentVolOffID(2,copy2); | |
365 | //module copy in the layer = 1<->10 (I132) | |
366 | vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4 | |
367 | } else if(id == fIdSens[2]){ | |
368 | vol[0] = 3; | |
369 | id = gMC->CurrentVolOffID(1,copy); | |
370 | //detector copy in the ladder = 1<->5 (ITS3 is inside I314) | |
371 | vol[1] = copy; | |
372 | id = gMC->CurrentVolOffID(2,copy); | |
373 | //ladder copy in the layer = 1<->12 (I316) | |
374 | vol[2] = copy; | |
375 | } else if(id == fIdSens[3]){ | |
376 | vol[0] = 4; | |
377 | id = gMC->CurrentVolOffID(1,copy); | |
378 | //detector copy in the ladder = 1<->8 (ITS4 is inside I414) | |
379 | vol[1] = copy; | |
380 | id = gMC->CurrentVolOffID(2,copy); | |
381 | //ladder copy in the layer = 1<->22 (I417) | |
382 | vol[2] = copy; | |
383 | }else if(id == fIdSens[4]){ | |
384 | vol[0] = 5; | |
385 | id = gMC->CurrentVolOffID(1,copy); | |
386 | //detector copy in the ladder = 1<->23 (ITS5 is inside I562) | |
387 | vol[1] = copy; | |
388 | id = gMC->CurrentVolOffID(2,copy); | |
389 | //ladder copy in the layer = 1<->34 (I565) | |
390 | vol[2] = copy; | |
391 | }else if(id == fIdSens[5]){ | |
392 | vol[0] = 6; | |
393 | id = gMC->CurrentVolOffID(1,copy); | |
394 | //detector copy in the ladder = 1<->26 (ITS6 is inside I566) | |
395 | vol[1] = copy; | |
396 | id = gMC->CurrentVolOffID(2,copy); | |
397 | //ladder copy in the layer = 1<->38 (I569) | |
398 | vol[2] = copy; | |
399 | } else { | |
400 | return; // not an ITS volume? | |
401 | } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i]) | |
402 | // | |
403 | gMC->TrackPosition(position); | |
404 | gMC->TrackMomentum(momentum); | |
405 | hits[0]=position[0]; | |
406 | hits[1]=position[1]; | |
407 | hits[2]=position[2]; | |
408 | hits[3]=momentum[0]; | |
409 | hits[4]=momentum[1]; | |
410 | hits[5]=momentum[2]; | |
411 | hits[6]=gMC->Edep(); | |
412 | hits[7]=gMC->TrackTime(); | |
413 | // Fill hit structure with this new hit. | |
642f15cf | 414 | new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits); |
3fccfd9e | 415 | return; |
416 | } | |
3fccfd9e | 417 |