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(const AliITSvtest &source) : AliITS(source){
69 ////////////////////////////////////////////////////////////////////////
70 // Copy Constructor for ITS test version.
71 ////////////////////////////////////////////////////////////////////////
72 if(&source == this) return;
73 Warning("Copy Constructor","Not allowed to copy AliITSvtest");
76 //_____________________________________________________________________________
77 AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
78 ////////////////////////////////////////////////////////////////////////
79 // Assignment operator for the ITS version 1.
80 ////////////////////////////////////////////////////////////////////////
81 if(&source == this) return *this;
82 Warning("= operator","Not allowed to copy AliITSvtest");
85 //_____________________________________________________________________________
86 AliITSvtest::~AliITSvtest() {
87 // Standard destructor for the ITS
89 //_____________________________________________________________________________
90 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
91 const char *name, const char *title)
92 : AliITS(name, title){
94 // Standard constructor for the ITS
97 fIdName = new TString[fIdN];
104 fIdSens = new Int_t[fIdN];
105 for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
106 fMajorVersion = IsVersion();
109 fGeomDetOut = kFALSE; // Don't write .det file
110 fGeomDetIn = kTRUE; // Read .det file
112 fEuclidMaterial = filetme;
113 fEuclidGeometry = fileeuc;
114 strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
115 strncpy(fRead,fEuclidGeomDet,60);
116 strncpy(fWrite,fEuclidGeomDet,60);
117 // The .det file for the geometry must have the same name as fileeuc with
118 // .euc replaced by .det.
122 //_____________________________________________________________________________
123 void AliITSvtest::CreateMaterials(){
125 // Read materials for the ITS
129 filtmp = gSystem->ExpandPathName(fEuclidMaterial.Data());
130 // FILE *file = fopen(fEuclidMaterial.Data(),"r");
131 FILE *file = fopen(filtmp,"r");
134 // ReadEuclidMedia(fEuclidMaterial.Data(),this);
135 ReadEuclidMedia(filtmp);
137 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",
138 // fEuclidMaterial.Data());
144 //_____________________________________________________________________________
145 void AliITSvtest::CreateGeometry(){
146 //////////////////////////////////////////////////////////////////////
147 ////////////////////////////////////////////////////////////////////////
148 // Read geometry for the ITS
153 filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
154 FILE *file = fopen(filtmp,"r");
158 printf("Ready to read Euclid geometry file\n");
159 ReadEuclid(fEuclidGeometry.Data(),topvol);
160 printf("Read in euclid geometries\n");
162 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",
163 fEuclidGeometry.Data());
167 //---Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
170 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
172 //---Outputs the geometry tree in the EUCLID/CAD format
175 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
176 } // end if (fEuclidOut)
177 cout <<"finished with euclid geometrys"<< endl;
179 //______________________________________________________________________
180 void 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
190 const Int_t knlayers = 6;
191 const Int_t kndeep = 3;
192 const AliITSDetector idet[knlayers]={kSPD,kSPD,kSDD,kSDD,kSSD,kSSDp};
193 const TString names[2][knlayers] = {
194 {"/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12A_%d/I10A_%d/I103_%d/I101_1/ITS1_1", // lay=1
195 "/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12A_%d/I20A_%d/I1D3_%d/I1D1_1/ITS2_1", // lay=2
196 "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
197 "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
198 "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
199 "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d"},// lay=6
200 {"/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
201 "/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
202 "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
203 "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
204 "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
205 "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d"}
207 const Int_t itsGeomTreeCopys[knlayers][kndeep]= {{10, 2, 4},// lay=1
213 Int_t nlad[knlayers],ndet[knlayers];
214 Int_t mod,lay,lad=0,det=0,i,j,k,cp0,cp1,cp2;
215 TString path,shapeName;
217 Double_t trans[3]={3*0.0},rot[10]={9*0.0,1.0};
220 Bool_t shapeDefined[4]={kFALSE,kFALSE,kFALSE,kFALSE};
222 AliDebug(1,"Reading Geometry transformation directly from Modler.");
224 for(i=0;i<knlayers;i++){
226 for(j=0;j<kndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
227 k *= TMath::Abs(itsGeomTreeCopys[i][j]);
232 nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
233 ndet[0]= 4;ndet[1]= 4;ndet[2]= 6;ndet[3]= 8;ndet[4]=22;ndet[5]=25;
234 AliITSgeom* geom = new AliITSgeom(0,6,nlad,ndet,mod);
237 for(lay=1;lay<=knlayers;lay++){
238 for(cp0=1;cp0<=itsGeomTreeCopys[lay-1][0];cp0++){
239 for(cp1=1;cp1<=itsGeomTreeCopys[lay-1][1];cp1++){
240 for(cp2=1;cp2<=itsGeomTreeCopys[lay-1][2];cp2++){
241 path.Form(names[fMinorVersion-1][lay-1].Data(),
252 case 3: case 4: case 5: case 6:{
257 //AliInfo(Form("path=%s lay=%d lad=%d det=%d",
258 // path.Data(),lay,lad,det));
259 gMC->GetTransformation(path.Data(),matrix);
260 gMC->GetShape(path.Data(),shapeName,shapePar);
261 shapeParF.Set(shapePar.GetSize());
262 for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
263 geom->CreateMatrix(mod,lay,lad,det,idet[lay-1],trans,rot);
264 geom->SetTrans(mod,matrix.GetTranslation());
265 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
266 geom->GetGeomMatrix(mod)->SetPath(path.Data());
269 if(!shapeDefined[kSPD]){
270 geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(
271 shapeParF.GetSize(),shapeParF.GetArray()));
272 shapeDefined[kSPD] = kTRUE;
275 if(!shapeDefined[kSDD]){
276 geom->ReSetShape(kSDD,new AliITSgeomSDD256(
277 shapeParF.GetSize(),shapeParF.GetArray()));
278 shapeDefined[kSDD] = kTRUE;
281 if(!shapeDefined[kSSD]){
282 geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(
283 shapeParF.GetSize(),shapeParF.GetArray()));
284 shapeDefined[kSSD] = kTRUE;
287 if(!shapeDefined[kSSDp]){
288 geom->ReSetShape(kSSDp,new AliITSgeomSSD275and75(
289 shapeParF.GetSize(),shapeParF.GetArray()));
290 shapeDefined[kSSDp] = kTRUE;
302 //_____________________________________________________________________________
303 void AliITSvtest::Init(){
304 ////////////////////////////////////////////////////////////////////////
305 // Initialise the ITS after it has been created.
306 ////////////////////////////////////////////////////////////////////////
310 for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
311 for(i=0;i<28;i++) cout << "*";cout << endl;
313 if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
314 if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
315 if(GetITSgeom()!=0) SetITSgeom(0x0);
316 SetITSgeom(new AliITSgeom());
317 if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
318 if(!fGeomDetIn) this->InitAliITSgeom();
319 if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
322 for(i=0;i<72;i++) cout << "*";
325 //_____________________________________________________________________________
326 void AliITSvtest::StepManager(){
328 // Called for every step in the ITS
334 TLorentzVector position, momentum;
335 TClonesArray &lhits = *fHits;
339 if(gMC->IsTrackInside()) vol[3] += 1;
340 if(gMC->IsTrackEntering()) vol[3] += 2;
341 if(gMC->IsTrackExiting()) vol[3] += 4;
342 if(gMC->IsTrackOut()) vol[3] += 8;
343 if(gMC->IsTrackDisappeared()) vol[3] += 16;
344 if(gMC->IsTrackStop()) vol[3] += 32;
345 if(gMC->IsTrackAlive()) vol[3] += 64;
347 // Fill hit structure.
348 if(!(gMC->TrackCharge())) return;
350 // Only entering charged tracks
351 if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
353 id = gMC->CurrentVolOffID(0,copy);
354 //detector copy in the ladder = 1<->4 (ITS1)
356 gMC->CurrentVolOffID(1,copy1);
357 //ladder copy in the module = 1<->2 (I186)
358 gMC->CurrentVolOffID(2,copy2);
359 //module copy in the layer = 1<->10 (I132)
360 vol[2] = copy1+(copy2-1)*2;//# of ladders in one module = 2
361 } else if(id == fIdSens[1]){
363 id = gMC->CurrentVolOffID(0,copy);
364 //detector copy in the ladder = 1<->4 (ITS2)
366 gMC->CurrentVolOffID(1,copy1);
367 //ladder copy in the module = 1<->4 (I131)
368 gMC->CurrentVolOffID(2,copy2);
369 //module copy in the layer = 1<->10 (I132)
370 vol[2] = copy1+(copy2-1)*4;//# of ladders in one module = 4
371 } else if(id == fIdSens[2]){
373 id = gMC->CurrentVolOffID(1,copy);
374 //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
376 id = gMC->CurrentVolOffID(2,copy);
377 //ladder copy in the layer = 1<->12 (I316)
379 } else if(id == fIdSens[3]){
381 id = gMC->CurrentVolOffID(1,copy);
382 //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
384 id = gMC->CurrentVolOffID(2,copy);
385 //ladder copy in the layer = 1<->22 (I417)
387 }else if(id == fIdSens[4]){
389 id = gMC->CurrentVolOffID(1,copy);
390 //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
392 id = gMC->CurrentVolOffID(2,copy);
393 //ladder copy in the layer = 1<->34 (I565)
395 }else if(id == fIdSens[5]){
397 id = gMC->CurrentVolOffID(1,copy);
398 //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
400 id = gMC->CurrentVolOffID(2,copy);
401 //ladder copy in the layer = 1<->38 (I569)
404 return; // not an ITS volume?
405 } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
407 gMC->TrackPosition(position);
408 gMC->TrackMomentum(momentum);
416 hits[7]=gMC->TrackTime();
417 // Fill hit structure with this new hit.
418 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits);