]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSvtest.cxx
Adapt to new QuadSet implementation.
[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>
3be5c40b 32#include <TLorentzVector.h>
3fccfd9e 33#include <TMath.h>
3fccfd9e 34#include <TSystem.h>
88cb7938 35#include <TVirtualMC.h>
3be5c40b 36#include <TGeoMatrix.h>
3fccfd9e 37
3fccfd9e 38#include "AliRun.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}
3fccfd9e 67//_____________________________________________________________________________
68AliITSvtest::~AliITSvtest() {
3fccfd9e 69 // Standard destructor for the ITS
3fccfd9e 70}
71//_____________________________________________________________________________
72AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
73 const char *name, const char *title)
74 : AliITS(name, title){
75 //
76 // Standard constructor for the ITS
77 //
78 fIdN = 6;
3fccfd9e 79 fIdName = new TString[fIdN];
80 fIdName[0] = "ITS1";
81 fIdName[1] = "ITS2";
82 fIdName[2] = "ITS3";
83 fIdName[3] = "ITS4";
84 fIdName[4] = "ITS5";
85 fIdName[5] = "ITS6";
86 fIdSens = new Int_t[fIdN];
87 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
bae7e562 88 fMajorVersion = IsVersion();
3fccfd9e 89 fMinorVersion = 1;
a8e8915c 90 SetEUCLID(kFALSE);
bae7e562 91 fGeomDetOut = kFALSE; // Don't write .det file
92 fGeomDetIn = kTRUE; // Read .det file
3fccfd9e 93
94 fEuclidMaterial = filetme;
95 fEuclidGeometry = fileeuc;
bae7e562 96 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
97 strncpy(fRead,fEuclidGeomDet,60);
98 strncpy(fWrite,fEuclidGeomDet,60);
3fccfd9e 99// The .det file for the geometry must have the same name as fileeuc with
100// .euc replaced by .det.
101}
102
103
104//_____________________________________________________________________________
105void AliITSvtest::CreateMaterials(){
106 //
107 // Read materials for the ITS
108 //
109 char *filtmp;
110//
111 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
112// FILE *file = fopen(fEuclidMaterial.Data(),"r");
113 FILE *file = fopen(filtmp,"r");
114 if(file) {
115 fclose(file);
116// ReadEuclidMedia(fEuclidMaterial.Data(),this);
117 ReadEuclidMedia(filtmp);
118 } else {
119 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
120// fEuclidMaterial.Data());
121 filtmp);
122 exit(1);
123 } // end if(file)
124}
125
126//_____________________________________________________________________________
127void AliITSvtest::CreateGeometry(){
128//////////////////////////////////////////////////////////////////////
129////////////////////////////////////////////////////////////////////////
130// Read geometry for the ITS
131//
3fccfd9e 132 char topvol[5];
133 char *filtmp;
134//
135 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
136 FILE *file = fopen(filtmp,"r");
137 delete [] filtmp;
138 if(file) {
139 fclose(file);
140 printf("Ready to read Euclid geometry file\n");
141 ReadEuclid(fEuclidGeometry.Data(),topvol);
142 printf("Read in euclid geometries\n");
143 } else {
144 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
145 fEuclidGeometry.Data());
146 exit(1);
147 } // end if(file)
148 //
149 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
150 // invisible
151 //
152 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
153 //
154 //---Outputs the geometry tree in the EUCLID/CAD format
155
156 if (fEuclidOut) {
157 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
158 } // end if (fEuclidOut)
bae7e562 159 cout <<"finished with euclid geometrys"<< endl;
3fccfd9e 160}
bae7e562 161//______________________________________________________________________
162void AliITSvtest::InitAliITSgeom(){
3be5c40b 163 // Based on the geometry tree defined in Geant 3.21, this
164 // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
165 // sturture.
166 // Inputs:
167 // none.
168 // Outputs:
169 // none.
170 // Return:
171 // none.
172 const Int_t knlayers = 6;
173 const Int_t kndeep = 3;
174 const AliITSDetector idet[knlayers]={kSPD,kSPD,kSDD,kSDD,kSSD,kSSDp};
175 const TString names[2][knlayers] = {
176 {"/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12A_%d/I10A_%d/I103_%d/I101_1/ITS1_1", // lay=1
177 "/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12A_%d/I20A_%d/I1D3_%d/I1D1_1/ITS2_1", // lay=2
178 "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
179 "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
180 "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
181 "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d"},// lay=6
182 {"/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
183 "/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
184 "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
185 "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
186 "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
187 "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d"}
188 };
189 const Int_t itsGeomTreeCopys[knlayers][kndeep]= {{10, 2, 4},// lay=1
190 {10, 4, 4},// lay=2
191 {14, 6, 1},// lay=3
192 {22, 8, 1},// lay=4
193 {34,22, 1},// lay=5
194 {38,25, 1}};//lay=6
195 Int_t nlad[knlayers],ndet[knlayers];
196 Int_t mod,lay,lad=0,det=0,i,j,k,cp0,cp1,cp2;
197 TString path,shapeName;
198 TGeoHMatrix matrix;
199 Double_t trans[3]={3*0.0},rot[10]={9*0.0,1.0};
200 TArrayD shapePar;
201 TArrayF shapeParF;
202 Bool_t shapeDefined[4]={kFALSE,kFALSE,kFALSE,kFALSE};
bae7e562 203
3be5c40b 204 AliDebug(1,"Reading Geometry transformation directly from Modler.");
bae7e562 205 mod = 0;
3be5c40b 206 for(i=0;i<knlayers;i++){
207 k = 1;
208 for(j=0;j<kndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
209 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
210 mod += k;
bae7e562 211 } // end for i
3fccfd9e 212
3be5c40b 213 SetITSgeom(0);
bae7e562 214 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
3be5c40b 215 ndet[0]= 4;ndet[1]= 4;ndet[2]= 6;ndet[3]= 8;ndet[4]=22;ndet[5]=25;
216 AliITSgeom* geom = new AliITSgeom(0,6,nlad,ndet,mod);
217 SetITSgeom(geom);
218 mod = 0;
219 for(lay=1;lay<=knlayers;lay++){
220 for(cp0=1;cp0<=itsGeomTreeCopys[lay-1][0];cp0++){
221 for(cp1=1;cp1<=itsGeomTreeCopys[lay-1][1];cp1++){
222 for(cp2=1;cp2<=itsGeomTreeCopys[lay-1][2];cp2++){
223 path.Form(names[fMinorVersion-1][lay-1].Data(),
224 cp0,cp1,cp2);
225 switch (lay){
226 case 1:{
227 det = cp2;
228 lad = cp1+2*(cp0-1);
229 }break;
230 case 2:{
231 det = cp2;
232 lad = cp1+4*(cp0-1);
233 } break;
234 case 3: case 4: case 5: case 6:{
235 det = cp1;
236 lad = cp0;
237 } break;
238 } // end switch
239 //AliInfo(Form("path=%s lay=%d lad=%d det=%d",
240 // path.Data(),lay,lad,det));
241 gMC->GetTransformation(path.Data(),matrix);
242 gMC->GetShape(path.Data(),shapeName,shapePar);
243 shapeParF.Set(shapePar.GetSize());
244 for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
245 geom->CreateMatrix(mod,lay,lad,det,idet[lay-1],trans,rot);
246 geom->SetTrans(mod,matrix.GetTranslation());
247 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
248 geom->GetGeomMatrix(mod)->SetPath(path.Data());
249 switch (lay){
250 case 1: case 2:
251 if(!shapeDefined[kSPD]){
252 geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(
253 shapeParF.GetSize(),shapeParF.GetArray()));
254 shapeDefined[kSPD] = kTRUE;
255 }break;
256 case 3: case 4:
257 if(!shapeDefined[kSDD]){
258 geom->ReSetShape(kSDD,new AliITSgeomSDD256(
259 shapeParF.GetSize(),shapeParF.GetArray()));
260 shapeDefined[kSDD] = kTRUE;
261 }break;
262 case 5:
263 if(!shapeDefined[kSSD]){
264 geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(
265 shapeParF.GetSize(),shapeParF.GetArray()));
266 shapeDefined[kSSD] = kTRUE;
267 }break;
268 case 6:
269 if(!shapeDefined[kSSDp]){
270 geom->ReSetShape(kSSDp,new AliITSgeomSSD275and75(
271 shapeParF.GetSize(),shapeParF.GetArray()));
272 shapeDefined[kSSDp] = kTRUE;
273 }break;
274 default:{
275 }break;
276 } // end switch
277 mod++;
278 } /// end for cp2
279 } // end for cp1
280 } // end for cp0
bae7e562 281 } // end for lay
282 return;
283}
3fccfd9e 284//_____________________________________________________________________________
285void AliITSvtest::Init(){
bae7e562 286////////////////////////////////////////////////////////////////////////
287// Initialise the ITS after it has been created.
288////////////////////////////////////////////////////////////////////////
289 Int_t i;
290
291 cout << endl;
292 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
293 for(i=0;i<28;i++) cout << "*";cout << endl;
294//
295 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
296 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
7d62fb64 297 if(GetITSgeom()!=0) SetITSgeom(0x0);
298 SetITSgeom(new AliITSgeom());
299 if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
bae7e562 300 if(!fGeomDetIn) this->InitAliITSgeom();
7d62fb64 301 if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
3fccfd9e 302 AliITS::Init();
bae7e562 303//
304 for(i=0;i<72;i++) cout << "*";
305 cout << endl;
306}
3fccfd9e 307//_____________________________________________________________________________
308void AliITSvtest::StepManager(){
309 //
310 // Called for every step in the ITS
311 //
312 Int_t copy, id;
313 Int_t copy1,copy2;
314 Float_t hits[8];
315 Int_t vol[4];
316 TLorentzVector position, momentum;
317 TClonesArray &lhits = *fHits;
318 //
319 // Track status
320 vol[3] = 0;
321 if(gMC->IsTrackInside()) vol[3] += 1;
322 if(gMC->IsTrackEntering()) vol[3] += 2;
323 if(gMC->IsTrackExiting()) vol[3] += 4;
324 if(gMC->IsTrackOut()) vol[3] += 8;
325 if(gMC->IsTrackDisappeared()) vol[3] += 16;
326 if(gMC->IsTrackStop()) vol[3] += 32;
327 if(gMC->IsTrackAlive()) vol[3] += 64;
328 //
329 // Fill hit structure.
330 if(!(gMC->TrackCharge())) return;
331 //
332 // Only entering charged tracks
333 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
334 vol[0] = 1;
335 id = gMC->CurrentVolOffID(0,copy);
336 //detector copy in the ladder = 1<->4 (ITS1)
337 vol[1] = copy;
338 gMC->CurrentVolOffID(1,copy1);
339 //ladder copy in the module = 1<->2 (I186)
340 gMC->CurrentVolOffID(2,copy2);
341 //module copy in the layer = 1<->10 (I132)
342 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
343 } else if(id == fIdSens[1]){
344 vol[0] = 2;
345 id = gMC->CurrentVolOffID(0,copy);
346 //detector copy in the ladder = 1<->4 (ITS2)
347 vol[1] = copy;
348 gMC->CurrentVolOffID(1,copy1);
349 //ladder copy in the module = 1<->4 (I131)
350 gMC->CurrentVolOffID(2,copy2);
351 //module copy in the layer = 1<->10 (I132)
352 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
353 } else if(id == fIdSens[2]){
354 vol[0] = 3;
355 id = gMC->CurrentVolOffID(1,copy);
356 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
357 vol[1] = copy;
358 id = gMC->CurrentVolOffID(2,copy);
359 //ladder copy in the layer = 1<->12 (I316)
360 vol[2] = copy;
361 } else if(id == fIdSens[3]){
362 vol[0] = 4;
363 id = gMC->CurrentVolOffID(1,copy);
364 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
365 vol[1] = copy;
366 id = gMC->CurrentVolOffID(2,copy);
367 //ladder copy in the layer = 1<->22 (I417)
368 vol[2] = copy;
369 }else if(id == fIdSens[4]){
370 vol[0] = 5;
371 id = gMC->CurrentVolOffID(1,copy);
372 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
373 vol[1] = copy;
374 id = gMC->CurrentVolOffID(2,copy);
375 //ladder copy in the layer = 1<->34 (I565)
376 vol[2] = copy;
377 }else if(id == fIdSens[5]){
378 vol[0] = 6;
379 id = gMC->CurrentVolOffID(1,copy);
380 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
381 vol[1] = copy;
382 id = gMC->CurrentVolOffID(2,copy);
383 //ladder copy in the layer = 1<->38 (I569)
384 vol[2] = copy;
385 } else {
386 return; // not an ITS volume?
387 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
388//
389 gMC->TrackPosition(position);
390 gMC->TrackMomentum(momentum);
391 hits[0]=position[0];
392 hits[1]=position[1];
393 hits[2]=position[2];
394 hits[3]=momentum[0];
395 hits[4]=momentum[1];
396 hits[5]=momentum[2];
397 hits[6]=gMC->Edep();
398 hits[7]=gMC->TrackTime();
399 // Fill hit structure with this new hit.
5d12ce38 400 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);
3fccfd9e 401 return;
402}
3fccfd9e 403