1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Inner Traking System version Test //
21 // This class contains the base procedures for the Inner Tracking System //
23 // Authors: R. Barbera, B. S. Nilsen. //
25 // Created October 16 1999. //
27 ///////////////////////////////////////////////////////////////////////////////
29 #include <Riostream.h>
32 #include <TLorentzVector.h>
35 #include <TVirtualMC.h>
36 #include <TGeoMatrix.h>
39 #include "AliITSgeom.h"
40 #include "AliITSgeomSDD.h"
41 #include "AliITSgeomSPD.h"
42 #include "AliITSgeomSSD.h"
43 #include "AliITShit.h"
44 #include "AliITSvtest.h"
50 //_____________________________________________________________________________
51 AliITSvtest::AliITSvtest() {
52 // Standard constructor for the ITS
59 fGeomDetOut = kFALSE; // Don't write .det file
60 fGeomDetIn = kTRUE; // Read .det file
61 fMajorVersion = IsVersion();
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';
67 //_____________________________________________________________________________
68 AliITSvtest::~AliITSvtest() {
69 // Standard destructor for the ITS
71 //_____________________________________________________________________________
72 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
73 const char *name, const char *title)
74 : AliITS(name, title){
76 // Standard constructor for the ITS
79 fIdName = new TString[fIdN];
86 fIdSens = new Int_t[fIdN];
87 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
88 fMajorVersion = IsVersion();
91 fGeomDetOut = kFALSE; // Don't write .det file
92 fGeomDetIn = kTRUE; // Read .det file
94 fEuclidMaterial = filetme;
95 fEuclidGeometry = fileeuc;
96 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
97 strncpy(fRead,fEuclidGeomDet,60);
98 strncpy(fWrite,fEuclidGeomDet,60);
99 // The .det file for the geometry must have the same name as fileeuc with
100 // .euc replaced by .det.
104 //_____________________________________________________________________________
105 void AliITSvtest::CreateMaterials(){
107 // Read materials for the ITS
111 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
112 // FILE *file = fopen(fEuclidMaterial.Data(),"r");
113 FILE *file = fopen(filtmp,"r");
116 // ReadEuclidMedia(fEuclidMaterial.Data(),this);
117 ReadEuclidMedia(filtmp);
119 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
120 // fEuclidMaterial.Data());
126 //_____________________________________________________________________________
127 void AliITSvtest::CreateGeometry(){
128 //////////////////////////////////////////////////////////////////////
129 ////////////////////////////////////////////////////////////////////////
130 // Read geometry for the ITS
135 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
136 FILE *file = fopen(filtmp,"r");
140 printf("Ready to read Euclid geometry file\n");
141 ReadEuclid(fEuclidGeometry.Data(),topvol);
142 printf("Read in euclid geometries\n");
144 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
145 fEuclidGeometry.Data());
149 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
152 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
154 //---Outputs the geometry tree in the EUCLID/CAD format
157 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
158 } // end if (fEuclidOut)
159 cout <<"finished with euclid geometrys"<< endl;
161 //______________________________________________________________________
162 void AliITSvtest::InitAliITSgeom(){
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
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"}
189 const Int_t itsGeomTreeCopys[knlayers][kndeep]= {{10, 2, 4},// lay=1
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;
199 Double_t trans[3]={3*0.0},rot[10]={9*0.0,1.0};
202 Bool_t shapeDefined[4]={kFALSE,kFALSE,kFALSE,kFALSE};
204 AliDebug(1,"Reading Geometry transformation directly from Modler.");
206 for(i=0;i<knlayers;i++){
208 for(j=0;j<kndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
209 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
214 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
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);
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(),
234 case 3: case 4: case 5: case 6:{
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());
251 if(!shapeDefined[kSPD]){
252 geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(
253 shapeParF.GetSize(),shapeParF.GetArray()));
254 shapeDefined[kSPD] = kTRUE;
257 if(!shapeDefined[kSDD]){
258 geom->ReSetShape(kSDD,new AliITSgeomSDD256(
259 shapeParF.GetSize(),shapeParF.GetArray()));
260 shapeDefined[kSDD] = kTRUE;
263 if(!shapeDefined[kSSD]){
264 geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(
265 shapeParF.GetSize(),shapeParF.GetArray()));
266 shapeDefined[kSSD] = kTRUE;
269 if(!shapeDefined[kSSDp]){
270 geom->ReSetShape(kSSDp,new AliITSgeomSSD275and75(
271 shapeParF.GetSize(),shapeParF.GetArray()));
272 shapeDefined[kSSDp] = kTRUE;
284 //_____________________________________________________________________________
285 void AliITSvtest::Init(){
286 ////////////////////////////////////////////////////////////////////////
287 // Initialise the ITS after it has been created.
288 ////////////////////////////////////////////////////////////////////////
292 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
293 for(i=0;i<28;i++) cout << "*";cout << endl;
295 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
296 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
297 if(GetITSgeom()!=0) SetITSgeom(0x0);
298 SetITSgeom(new AliITSgeom());
299 if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
300 if(!fGeomDetIn) this->InitAliITSgeom();
301 if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
304 for(i=0;i<72;i++) cout << "*";
307 //_____________________________________________________________________________
308 void AliITSvtest::StepManager(){
310 // Called for every step in the ITS
316 TLorentzVector position, momentum;
317 TClonesArray &lhits = *fHits;
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;
329 // Fill hit structure.
330 if(!(gMC->TrackCharge())) return;
332 // Only entering charged tracks
333 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
335 id = gMC->CurrentVolOffID(0,copy);
336 //detector copy in the ladder = 1<->4 (ITS1)
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]){
345 id = gMC->CurrentVolOffID(0,copy);
346 //detector copy in the ladder = 1<->4 (ITS2)
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]){
355 id = gMC->CurrentVolOffID(1,copy);
356 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
358 id = gMC->CurrentVolOffID(2,copy);
359 //ladder copy in the layer = 1<->12 (I316)
361 } else if(id == fIdSens[3]){
363 id = gMC->CurrentVolOffID(1,copy);
364 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
366 id = gMC->CurrentVolOffID(2,copy);
367 //ladder copy in the layer = 1<->22 (I417)
369 }else if(id == fIdSens[4]){
371 id = gMC->CurrentVolOffID(1,copy);
372 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
374 id = gMC->CurrentVolOffID(2,copy);
375 //ladder copy in the layer = 1<->34 (I565)
377 }else if(id == fIdSens[5]){
379 id = gMC->CurrentVolOffID(1,copy);
380 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
382 id = gMC->CurrentVolOffID(2,copy);
383 //ladder copy in the layer = 1<->38 (I569)
386 return; // not an ITS volume?
387 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
389 gMC->TrackPosition(position);
390 gMC->TrackMomentum(momentum);
398 hits[7]=gMC->TrackTime();
399 // Fill hit structure with this new hit.
400 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);