]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSvSDD03.cxx
Separated TOF libraries (base,rec,sim)
[u/mrichter/AliRoot.git] / ITS / AliITSvSDD03.cxx
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
16 /*
17  $Id$ 
18 */
19
20 #include <Riostream.h>
21 #include <TMath.h>
22 #include <TGeometry.h>
23 #include <TNode.h>
24 #include <TBRIK.h>
25 #include <TLorentzVector.h>
26 #include <TVirtualMC.h>
27
28 #include "AliMC.h"
29 #include "AliRun.h"
30 #include "AliMagF.h"
31 #include "AliITSGeant3Geometry.h"
32 #include "AliTrackReference.h"
33 #include "AliITShit.h"
34 #include "AliITS.h"
35 #include "AliITSvSDD03.h"
36 #include "AliITSgeom.h"
37 #include "AliITSgeomSPD.h"
38 #include "AliITSgeomSDD.h"
39 #include "AliITSgeomSSD.h"
40 #include "AliITSDetType.h"
41 #include "AliITSresponseSPD.h"
42 #include "AliITSresponseSDD.h"
43 #include "AliITSresponseSSD.h"
44 #include "AliITSsegmentationSPD.h"
45 #include "AliITSsegmentationSDD.h"
46 #include "AliITSsegmentationSSD.h"
47 #include "AliITSsimulationSPDdubna.h"
48 #include "AliITSsimulationSDD.h"
49 #include "AliITSsimulationSSD.h"
50
51 ClassImp(AliITSvSDD03)
52
53 //______________________________________________________________________
54 AliITSvSDD03::AliITSvSDD03() :
55 AliITS(),
56 fGeomDetOut(kFALSE),
57 fGeomDetIn(kFALSE),
58 fMajorVersion(1),
59 fMinorVersion(2),
60 fEuclidGeomDet(),
61 fRead(),
62 fWrite(),
63 fDet1(300.0),
64 fDet2(300.0),
65 fChip1(300.0),
66 fChip2(300.0),
67 fIDMother(0),
68 fYear(2003){
69     ////////////////////////////////////////////////////////////////////////
70     // Standard default constructor for the ITS SDD test beam 2002 version 1.
71     // Inputs:
72     //    none.
73     // Outputs:
74     //    none.
75     // Return:
76     //    A default created class.
77     ////////////////////////////////////////////////////////////////////////
78     Int_t i;
79
80     fIdN          = 0;
81     fIdName       = 0;
82     fIdSens       = 0;
83     fEuclidOut    = kFALSE; // Don't write Euclide file
84     for(i=0;i<60;i++) fRead[i] = '\0';
85     for(i=0;i<60;i++) fWrite[i] = '\0';
86     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
87 }
88 //______________________________________________________________________
89 AliITSvSDD03::AliITSvSDD03(const char *title,Int_t year):
90 AliITS("ITS", title),
91 fGeomDetOut(kFALSE),
92 fGeomDetIn(kFALSE),
93 fMajorVersion(1),
94 fMinorVersion(2),
95 fEuclidGeomDet(),
96 fRead(),
97 fWrite(),
98 fDet1(300.0),
99 fDet2(300.0),
100 fChip1(300.0),
101 fChip2(300.0),
102 fIDMother(0),
103 fYear(2003){
104     ////////////////////////////////////////////////////////////////////////
105     //    Standard constructor for the ITS SDD testbeam 2002 version 1.
106     // Inputs:
107     //    const char *title    title for this ITS geometry.
108     // Outputs:
109     //    none.
110     // Return:
111     //    A standard created class.
112     ////////////////////////////////////////////////////////////////////////
113     Int_t i;
114
115     fIdN = 3;
116     fIdName = new TString[fIdN];
117     fIdName[0] = "IMBS";
118     fIdName[1] = "ITST";
119     fIdName[2] = "ISNT";
120     fIdSens    = new Int_t[fIdN];
121     for(i=0;i<fIdN;i++) fIdSens[i] = 0;
122     fEuclidOut    = kFALSE; // Don't write Euclide file
123     fYear         = year;
124     SetThicknessDet1();
125     SetThicknessDet2();
126     SetThicknessChip1();
127     SetThicknessChip2();                         
128
129     fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vSDD032.euc";
130     strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vSDD032.det",60);
131     strncpy(fRead,fEuclidGeomDet,60);
132     strncpy(fWrite,fEuclidGeomDet,60);
133 }
134 //______________________________________________________________________
135 AliITSvSDD03::AliITSvSDD03(const AliITSvSDD03 &source) :  AliITS(source){
136     ////////////////////////////////////////////////////////////////////////
137     //     Copy Constructor for ITS SDD test beam 2002 version 1.
138     // This class is not to be copied. Function only dummy.
139     // Inputs:
140     //    const AliITSvSDD03 &source   The class to be copied
141     // Outputs:
142     //    none.
143     // Return:
144     //    A warning message.
145     ////////////////////////////////////////////////////////////////////////
146     if(&source == this) return;
147     Warning("Copy Constructor","Not allowed to copy AliITSvSDD03");
148     return;
149 }
150 //______________________________________________________________________
151 AliITSvSDD03& AliITSvSDD03::operator=(const AliITSvSDD03 &source){
152     ////////////////////////////////////////////////////////////////////////
153     //    Assignment operator for the ITS SDD test beam 2002 version 1.
154     // This class is not to be copied. Function only dummy.
155     // Inputs:
156     //    const AliITSvSDD03 &source   The class to be copied
157     // Outputs:
158     //    none.
159     // Return:
160     //    A Warning message
161     ////////////////////////////////////////////////////////////////////////
162     if(&source == this) return *this;
163     Warning("= operator","Not allowed to copy AliITSvSDD03");
164     return *this;
165 }
166 //______________________________________________________________________
167 AliITSvSDD03::~AliITSvSDD03() {
168     ////////////////////////////////////////////////////////////////////////
169     //    Standard destructor for the ITS SDD test beam 2002 version 1.
170     // Inputs:
171     //    none.
172     // Outputs:
173     //    none.
174     // Return:
175     //    none.
176     ////////////////////////////////////////////////////////////////////////
177 }
178 //______________________________________________________________________
179 void AliITSvSDD03::BuildGeometry(){
180     ////////////////////////////////////////////////////////////////////////
181     //    Geometry builder for the ITS SDD test beam 2002 version 1.
182     //    ALIC    ALICE Mother Volume
183     //     |- ITSV     ITS Mother Volume
184     //         |- IDET       Detector under Test
185     //         |   |- ITS0       SDD Si Chip
186     //         |   |  |- ITST      SDD Sensitivve Volume
187     //         |   |- IPC0 *5    Readout chip
188     //         |- ITEL *4    SDD Telescope
189     //             |- IMB0       SDD Si Chip
190     //             |   |- IMBS     SDD Sensitive volume
191     //             |- ICMB       Chip MiniBus.
192     // Inputs:
193     //    none.
194     // Outputs:
195     //    none.
196     // Return:
197     //    none.
198     ////////////////////////////////////////////////////////////////////////
199     // Get the top alice volume.
200     TNode *nALIC = gAlice->GetGeometry()->GetNode("alice");
201     nALIC->cd();
202
203     // Define ITS Mother Volume
204     Float_t data[3];
205     Float_t ddettest=200.0E-4,ddettelescope=300.0E-4;
206     Float_t dchipMiniBus=750.0E-4,dchiptest=300.0E-4;
207     //Float_t yposition= 0.0;
208     TRotMatrix *r0 = new TRotMatrix("ITSidrotm0","ITSidrotm0",
209                                     90.0,0,0.0,0,90.0,270.0);
210     data[0] = 10.0;
211     data[1] = 50.0;
212     data[2] = 100.0;
213     TBRIK *sITSVshape =new TBRIK("ITSVshape","ITS Logical Mother Volume","Air",
214                                  data[0],data[1],data[2]);
215     TNode *sITSV = new TNode("ITSV","ITS Mother Volume",sITSVshape,
216                             0.0,0.0,0.0,0,0);
217     sITSV->cd(); // set ourselve into ITSV subvolume of ALIC
218
219     // SDD part of telescope (MiniBuS)
220     data[0] = 0.705;
221     data[1] = 0.5*ddettelescope;
222     data[2] = 3.536;
223     TBRIK *sIMB0shape = new TBRIK("IMB0shape","SDD wafer","Si",
224                                  data[0],data[1],data[2]);
225     Float_t detMiniBusX,detMiniBusY,detMiniBusZ;
226     data[0] = detMiniBusX = 0.64;
227     data[1] = detMiniBusY = 0.5*ddettelescope;
228     data[2] = detMiniBusZ = 3.48;
229     TBRIK *sIMBSshape = new TBRIK("IMBSshape","SDD Sensitive volume","Si",
230                                  data[0],data[1],data[2]);
231     Float_t chipMiniBusX,chipMiniBusY,chipMiniBusZ;
232     data[0] = chipMiniBusX = 0.793;
233     data[1] = chipMiniBusY = 0.5*dchipMiniBus;
234     data[2] = chipMiniBusZ = 0.68;
235     TBRIK *sICMBshape = new TBRIK("ICMBshape","chip Minibus","Si",
236                                  data[0],data[1],data[2]);
237     data[0] = TMath::Max(detMiniBusX,chipMiniBusX);
238     data[1] = detMiniBusY+chipMiniBusY;
239     data[2] = TMath::Max(detMiniBusZ,chipMiniBusZ);
240     TBRIK *sITELshape = new TBRIK("ITELshape","ITELshape","Air",
241                                  data[0],data[1],data[2]);
242
243     // SDD under test
244     Float_t spdX,spdY,spdZ,spdchipX,spdchipY,spdchipZ;
245     data[0] = 0.705;
246     data[1] = ddettest;
247     data[2] = 3.536;
248     TBRIK *sITS0shape = new TBRIK("ITS0shape","SDD wafer","Si",
249                                  data[0],data[1],data[2]); // contains detector
250     data[0] = spdX = 0.64;
251     data[1] = spdY = ddettest;
252     data[2] = spdZ = 3.48;
253     TBRIK *sITSTshape = new TBRIK("ITSTshape","SDD sensitive volume","Si",
254                                  data[0],data[1],data[2]);
255     // ITS0 with no translation and unit rotation matrix.
256     data[0] = spdchipX = 0.793;
257     data[1] = spdchipY = dchiptest;
258     data[2] = spdchipZ = 0.68;
259     TBRIK *sIPC0shape = new TBRIK("IPC0shape","Readout Chips","Si",
260                                  data[0],data[1],data[2]); // chip under test
261     data[0] = TMath::Max(spdchipX,spdX);
262     data[1] = spdY+spdchipY;
263     data[2] = TMath::Max(spdchipZ,spdZ);
264     TBRIK *sIDETshape = new TBRIK("IDETshape","Detector Under Test","Air",
265                                  data[0],data[1],data[2]);
266     // Place volumes in geometry
267     Int_t i,j;
268     char name[20],title[50];
269     Double_t px=0.0,py=0.0,pz[4]={-38.0,0.0,0.0,0.0};
270     pz[1] = pz[0]+2.0;
271     pz[2] = pz[1]+38.0+spdY+spdchipY+34.5;
272     pz[3] = pz[2]+2.0;
273     TNode *nITEL[4],*nICMB[4],*nIMB0[4],*nIMBS[4];
274     TNode *nIDET = new TNode("IDET","Detector Under Test",sIDETshape,
275                             0.0,0.0,pz[1]+38.0,r0,0);
276     nIDET->cd();
277     TNode *nITS0 = new TNode("ITS0","SDD Chip",sITS0shape,
278                             0.0,sIDETshape->GetDy()-spdY,0.0,0,0);
279     TNode *nIPC0[5];
280     for(i=0;i<5;i++) { //place readout chips on the back of SDD chip under test
281         sprintf(name,"IPC0%d",i);
282         sprintf(title,"Readout chip #%d",i+1);
283         j = i-2;
284         nIPC0[i] = new TNode(name,title,sIPC0shape,
285                             0.0,spdchipY-sIDETshape->GetDy(),
286                             j*2.0*spdchipZ+j*0.25*(spdZ-5.*spdchipZ),0,0);
287     } // end for i
288     nITS0->cd();
289     TNode *nITST = new TNode("ITST","SDD sensitive volume",sITSTshape,
290                             0.0,0.0,0.0,0,0);
291     for(Int_t i=0;i<4;i++){
292         sITSV->cd();
293         sprintf(name,"ITEL%d",i);
294         sprintf(title,"Test beam telescope element #%d",i+1);
295         nITEL[i] = new TNode(name,title,sITELshape,px,py,pz[i],r0,0);
296         nITEL[i]->cd();
297         nICMB[i] = new TNode("ICMB","Chip MiniBus",sICMBshape,
298                             0.0,-sITELshape->GetDy()+detMiniBusY,0.0,0,0);
299         nIMB0[i] = new TNode("IMB0","Chip MiniBus",sIMB0shape,
300                             0.0, sITELshape->GetDy()-detMiniBusY,0.0,0,0);
301         nIMB0[i]->cd();
302         nIMBS[i] = new TNode("IMBS","IMBS",sIMBSshape,0.0,0.0,0.0,0,0);
303         // place IMBS inside IMB0 with no translation and unit rotation matrix.
304     } // end for i
305     nALIC->cd();
306     nITST->SetLineColor(kYellow);
307     fNodes->Add(nITST);
308     for(i=0;i<4;i++){
309         nIMBS[i]->SetLineColor(kGreen);
310         fNodes->Add(nIMBS[i]);
311     } // end for i
312 }
313 //______________________________________________________________________
314 Int_t AliITSvSDD03::DecodeDetector(Int_t id,Int_t cpy,Int_t &lay,
315                                    Int_t &lad,Int_t &det) const{
316     // Given the Geant id and copy volume number, returns the layer, ladder,
317     // and detector number, allong with the module number of the detector
318     // involved. Returns -1 and lay=0, lad=0, and det=0 if not a sensitive 
319     // volume.
320     // Inputs:
321     //    Int_t id    Geometry volume id number
322     //    Int_t cpy   Geometry copy number
323     // Outputs:
324     //    Int_t lay   ITS layer number
325     //    Int_t lad   ITS ladder number
326     //    Int_t det   ITS detector number
327     // Return:
328     //    Int_t module number.
329     Int_t mod;
330
331     lay = 0; lad = 0; det = 0; mod = -1;
332     if(id==fIdSens[0]){ // Volume name is IMBS (ITEL)
333         lad = 1; det = 1;
334         lay = cpy;
335         if(cpy>4) lay++;
336         mod = lay-1;
337         return mod;
338     }// end if
339     if(id==fIdSens[1]){ // Volume name is ITST (IDet)
340         lad = 1; det = 1;lay = 5; mod = 4;
341         return mod;
342     }// end if
343     return mod;
344 }
345 //______________________________________________________________________
346 void AliITSvSDD03::CreateGeometry(){
347     ////////////////////////////////////////////////////////////////////////
348     //  This routine defines and Creates the geometry for version 1 of the ITS.
349     //    ALIC    ALICE Mother Volume
350     //     |- ITSV     ITS Mother Volume
351     //         |- IDET       Detector under Test (box containing SDD)
352     //         |   |-IDAI        Air inside box
353     //         |       |- ITS0       SDD Si Chip
354     //         |          |- ITST      SDD Sensitivve Volume
355     //         |- ITEL *10   SSD Telescope (plastic box containting SSD's)
356     //         |   |- ITAI       Air inside box
357     //         |       |- IMB0       SDD Si Chip
358     //         |           |- IMBS     SDD Sensitive volume
359     //         |-ISNT*4    Sintilator triggers
360     // Inputs:
361     //    none.
362     // Outputs:
363     //    none.
364     // Return:
365     //    none.
366     ////////////////////////////////////////////////////////////////////////
367     Float_t data[49];
368     // Define media off-set
369     Int_t *idtmed = fIdtmed->GetArray()+1; // array of media indexes
370     Int_t idrotm[4]; // Array of rotation matrix indexes
371     //Float_t ddettest=200.0E-4,ddettelescope=300.0E-4;
372     //Float_t dchipMiniBus=750.0E-4,dchiptest=300.0E-4;
373     //Float_t yposition= 0.0;
374     const Float_t kmm=0.1,kcm=1.0,kmicm=0.001;
375
376     // Define Rotation-reflextion Matrixes needed
377     // 0 is the unit matrix
378     AliMatrix(idrotm[0], 90.0,0.0, 0.0,0.0, 90.0,270.0); // SDD and SSD X
379     AliMatrix(idrotm[1], 90.0,0.0, 0.0,0.0, 90.0,270.0); // SSD Y
380     data[0] = 100.0*kmm;
381     data[1] = 100.0*kmm;
382     data[2] = 800.0*kcm;
383     gMC->Gsvolu("ITSV","BOX ",idtmed[0],data,3);
384     gMC->Gspos("ITSV",1,"ALIC",0.0,0.0,0.0,0,"ONLY");
385
386     //cout << "idtmed[0]=" << idtmed[0]<<endl;
387     //cout << "idtmed[1]=" << idtmed[1]<<endl;
388     // Crossed sintilator triggers (2 in front 2 in back)
389     AliMatrix(idrotm[2],90.0,0.0,90.0,90.0,90.0,0.0);//Rotate about Z 90 degree
390     data[0] = 10.0*kcm;
391     data[1] = 2.0*kcm;
392     data[2] = 2.0*kmm;
393     gMC->Gsvolu("ISNT","BOX ",idtmed[2],data,3);
394     gMC->Gspos("ISNT",1,"ITSV",0.0,0.0,800.0*kmm+data[2],0,"ONLY");
395     gMC->Gspos("ISNT",2,"ITSV",0.0,0.0,800.0*kmm,idrotm[2],"ONLY");
396     gMC->Gspos("ISNT",3,"ITSV",0.0,0.0,-800.0*kmm,0,"ONLY");
397     gMC->Gspos("ISNT",4,"ITSV",0.0,0.0,-800.0*kmm-data[2],idrotm[2],"ONLY");
398     Float_t detMiniBusX,detMiniBusY,detMiniBusZ;
399     // SSD part of telescope (MiniBuS)
400     data[0] = detMiniBusX = 10600.0*kmicm;
401     data[1] = detMiniBusY = 0.0150*kcm;
402     data[2] = detMiniBusZ = 1.1*kcm;
403     gMC->Gsvolu("IMB0", "BOX ", idtmed[1], data, 3);   // contains detector
404     data[0] = 0.5*384*50*kmicm;
405     data[1] = 0.1499*kcm;
406     data[2] = 1.0*kcm;
407     gMC->Gsvolu("IMBS","BOX ",idtmed[1],data,3); // sensitive detecor volulme
408     gMC->Gspos("IMBS",1,"IMB0",0.0,0.0,0.0,0,"ONLY"); // place IMBS inside
409     // Box containing SSD's
410     data[0] = 11.6*kcm;
411     data[1] = 0.500*kcm;
412     data[2] = 5.0*kcm;
413     gMC->Gsvolu("ITAI","BOX ",idtmed[0],data,3);
414     // Plastic box size = insize + thickness.
415     data[0] = data[0] + 2.0*kmm;
416     data[1] = data[1] + 200.0*kmicm;
417     data[2] = data[2] + 2.0*kmm;
418     gMC->Gsvolu("ITEL","BOX ",idtmed[3],data,3);
419     gMC->Gspos("ITAI",1,"ITEL",0.0,0.0,0.0,0,"ONLY");
420     gMC->Gspos("IMB0",1,"ITAI",0.0,0.0,0.0,0,"ONLY");
421
422     // SDD under test
423     Float_t sddX,sddY,sddZ;
424     data[0] = sddX = 3.62500*kcm;
425     data[1] = sddY = 0.01500*kcm;
426     data[2] = sddZ = 4.37940*kcm;
427     gMC->Gsvolu("ITS0", "BOX ", idtmed[1], data, 3);   // contains detector
428     data[0] = 3.50860*kcm;
429     data[1] = 0.01499*kcm;
430     data[2] = 3.76320*kcm;
431     gMC->Gsvolu("ITST","BOX ",idtmed[1],data,3);// sensitive detecor volume
432     gMC->Gspos("ITST",1,"ITS0",0.0,0.0,0.0,0,"ONLY"); // place ITST inside
433     // Box containing SDD under test
434     data[0] = 4.0*kcm;
435     data[1] = 0.5*kcm;
436     data[2] = 5.0*kcm;
437     gMC->Gsvolu("IDAI","BOX ",idtmed[0],data,3);
438     data[0] = data[0] + 2.0*kmm;
439     data[1] = data[1] + 200.0*kmicm;
440     data[2] = data[2] + 2.0*kmm;
441     gMC->Gsvolu("IDET","BOX ",idtmed[3],data,3);
442     gMC->Gspos("IDAI",1,"IDET",0.0,0.0,0.0,0,"ONLY");
443     gMC->Gspos("ITS0",1,"IDAI",0.0,0.0,0.0,0,"ONLY");
444
445     // Positions detectors, Beam Axis Z, X to the right, Y up to the sky.
446     Float_t p00X,p00Y,p00Z,p01X,p01Y,p01Z,p10X,p10Y,p10Z,p11X,p11Y,p11Z;
447     p00X = 0.0*kcm;
448     p00Y = 0.0*kcm;
449     p00Z = -694*kmm;
450     gMC->Gspos("ITEL",1,"ITSV",p00X,p00Y,p00Z,idrotm[0],"ONLY");//SSD X
451     p01X = 0.0*kcm;
452     p01Y = 0.0*kcm;
453     p01Z = -684*kmm;
454     gMC->Gspos("ITEL",2,"ITSV",p01X,p01Y,p01Z,idrotm[1],"ONLY");//SSD Y
455     p01X = 0.0*kcm;
456     p01Y = 0.0*kcm;
457     p01Z = -612*kmm;
458     gMC->Gspos("ITEL",3,"ITSV",p01X,p01Y,p01Z,idrotm[0],"ONLY");//SSD X
459     p01X = 0.0*kcm;
460     p01Y = 0.0*kcm;
461     p01Z = -602*kmm;
462     Float_t pdetX,pdetY,pdetZ;
463     gMC->Gspos("ITEL",4,"ITSV",p01X,p01Y,p01Z,idrotm[1],"ONLY");//SSD Y
464     pdetX = 0.0*kcm;
465     pdetY = 0.0*kcm;
466     pdetZ = 0.0*kcm;
467     gMC->Gspos("IDET",1,"ITSV",pdetX,pdetY,pdetZ,idrotm[0],"ONLY");// Detecor
468     p10X = 0.0*kcm;
469     p10Y = 0.0*kcm;
470     p10Z = +450.0*kmm;
471     gMC->Gspos("ITEL",5,"ITSV",p10X,p10Y,p10Z,idrotm[0],"ONLY");//SSD X
472     p11X = 0.0*kcm;
473     p11Y = 0.0*kcm;
474     p11Z = +460.0*kcm;
475     gMC->Gspos("ITEL",6,"ITSV",p11X,p11Y,p11Z,idrotm[1],"ONLY");//SSD Y
476     p11X = 0.0*kcm;
477     p11Y = 0.0*kcm;
478     p11Z = +540.0*kcm;
479     gMC->Gspos("ITEL",7,"ITSV",p11X,p11Y,p11Z,idrotm[0],"ONLY");//SSD X
480     p11X = 0.0*kcm;
481     p11Y = 0.0*kcm;
482     p11Z = +550.0*kcm;
483     gMC->Gspos("ITEL",8,"ITSV",p11X,p11Y,p11Z,idrotm[1],"ONLY");//SSD Y
484     p11X = 0.0*kcm;
485     p11Y = 0.0*kcm;
486     p11Z = +737.0*kcm;
487     gMC->Gspos("ITEL",9,"ITSV",p11X,p11Y,p11Z,idrotm[0],"ONLY");//SSD X
488     p11X = 0.0*kcm;
489     p11Y = 0.0*kcm;
490     p11Z = +747.0*kcm;
491     gMC->Gspos("ITEL",10,"ITSV",p11X,p11Y,p11Z,idrotm[1],"ONLY");//SSD Y
492 }
493 //______________________________________________________________________
494 void AliITSvSDD03::CreateMaterials(){
495     ////////////////////////////////////////////////////////////////////////
496     //
497     // Create ITS SDD test beam materials
498     //     This function defines the default materials used in the Geant
499     // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
500     // AliITSvSDD03.
501     // In general it is automatically replaced by
502     // the CreatMaterials routine defined in AliITSv?. Should the function
503     // CreateMaterials not exist for the geometry version you are using this
504     // one is used. See the definition found in AliITSv5 or the other routine
505     // for a complete definition.
506     //
507     // Inputs:
508     //    none.
509     // Outputs:
510     //    none.
511     // Return:
512     //    none.
513     /////////////////////////////////////////////////////////////////////////
514     Float_t tmaxfdSi = 0.1; // Degree
515     Float_t stemaxSi = 0.0075; // cm
516     Float_t deemaxSi = 0.1; // Fraction of particle's energy 0<deemax<=1
517     Float_t epsilSi  = 1.0E-4;//
518     Float_t stminSi  = 0.0; // cm "Default value used"
519
520     Float_t tmaxfdAir = 0.1; // Degree
521     Float_t stemaxAir = .10000E+01; // cm
522     Float_t deemaxAir = 0.1; // Fraction of particle's energy 0<deemax<=1
523     Float_t epsilAir  = 1.0E-4;//
524     Float_t stminAir  = 0.0; // cm "Default value used"
525     Int_t   ifield = gAlice->Field()->Integ();
526     Float_t fieldm = gAlice->Field()->Max();
527     //
528     const Float_t kgpcm3=1.0,kcm=1.0;
529     //
530     Float_t z[10],a[10],w[10];
531
532     z[0] = 7.0; a[0] = 14.00674; w[0] = 0.80;
533     z[1] = 8.0; a[1] = 15.99940; w[1] = 0.20;
534     AliMixture(1,"AIR$",a,z,0.12050E-02*kgpcm3,2,w);
535     AliMedium(1,"AIR$",1,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,
536               epsilAir,stminAir);
537
538     AliMaterial(2,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,
539                 0.93600E+01*kcm,0.99900E+03);
540     AliMedium(2,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
541               epsilSi,stminSi);
542     // sintilator is Lucite
543     z[0] = 1.0; a[0] =  1.00; w[0] = 8.;  // H8
544     z[1] = 6.0; a[1] = 12.00; w[1] = 5.;  // C5
545     z[2] = 8.0; a[2] = 16.00; w[2] = 2.;  // O2
546     AliMixture(3,"Sintilator$",a,z,1.190*kgpcm3,-3,w);
547     AliMedium(3,"Sintilator$",3,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
548               epsilSi,stminSi);
549     // assumed to be Lucite/Plexiglas
550     z[0] = 1.0; a[0] =  1.00; w[0] = 8.;  // H8
551     z[1] = 6.0; a[1] = 12.00; w[1] = 5.;  // C5
552     z[2] = 8.0; a[2] = 16.00; w[2] = 2.;  // O2
553     AliMixture(4,"PlasticBox$",a,z,1.190*kgpcm3,-3,w);
554     AliMedium(4,"PlasticBox$",4,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
555               epsilSi,stminSi);
556 }
557 //______________________________________________________________________
558 void AliITSvSDD03::InitAliITSgeom(){
559     //     Based on the geometry tree defined in Geant 3.21, this
560     // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
561     // sturture.
562     // Inputs:
563     //    none.
564     // Outputs:
565     //    none.
566     // Return:
567     //    none.
568
569     if(strcmp(gMC->GetName(),"TGeant3")) {
570         Error("InitAliITSgeom",
571               "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
572         return;
573     } // end if
574     cout << "Reading Geometry transformation directly from Geant 3." << endl;
575     const Int_t np=384;
576     const Float_t pitch=50.E-4;/*cm*/
577     Float_t box[3]={0.5*pitch*(Float_t)np,150.E-4,1.0},p[np],n[np];
578     const Int_t ltypess = 2;
579     const Int_t nlayers = 11;
580     const Int_t ndeep = 6;
581     Int_t itsGeomTreeNames[ltypess][ndeep],lnam[20],lnum[20];
582     Int_t nlad[nlayers],ndet[nlayers];
583     Double_t t[3],r[10];
584     Float_t  par[20],att[20];
585     Int_t    npar,natt,idshape,imat,imed,id;
586     AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
587     Int_t mod,typ,lay,lad,det,cpy,i,j,k;
588     Char_t names[ltypess][ndeep][4];
589     Int_t itsGeomTreeCopys[ltypess][ndeep];
590     Char_t *namesA[ltypess][ndeep] = {
591         {"ALIC","ITSV","ITEL","ITAI","IMB0","IMBS"}, // lay=5
592         {"ALIC","ITSV","IDET","IDAI","ITS0","ITST"}};// Test SDD
593     Int_t itsGeomTreeCopysA[ltypess][ndeep]= {{1,1,10,1,1,1},// lay=5
594                                               {1,1,1,1,1,1}};//lay=3 TestSDD
595     for(i=0;i<ltypess;i++)for(j=0;j<ndeep;j++){
596         for(k=0;k<4;k++) names[i][j][k] = namesA[i][j][k];
597         itsGeomTreeCopys[i][j] = itsGeomTreeCopysA[i][j];
598     } // end for i,j
599     for(i=0;i<np;i++){// Fill in anode and cathode strip locations (lower edge)
600         p[i] = 0.5*pitch*(Float_t)np + pitch*(Float_t)i;
601         n[i] = pitch*(Float_t)np - p[i];
602     } // end for i
603     // Sorry, but this is not very pritty code. It should be replaced
604     // at some point with a version that can search through the geometry
605     // tree its self.
606     cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
607     for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
608     for(i=0;i<ltypess;i++)for(j=0;j<ndeep;j++) 
609         strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4);
610     //  itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
611     mod = 11;
612     if(fITSgeom!=0) delete fITSgeom;
613     nlad[0]=1;nlad[1]=1;nlad[2]=1;nlad[3]=1;nlad[4]=1;nlad[5]=1;
614     nlad[6]=1;nlad[7]=1;nlad[8]=1;nlad[9]=1;nlad[10]=1;
615     ndet[0]=1;ndet[1]=1;ndet[2]=1;ndet[3]=1;ndet[4]=1;ndet[5]=1;
616     ndet[6]=1;ndet[7]=1;ndet[8]=1;ndet[9]=1;ndet[10]=1;
617     fITSgeom = new AliITSgeom(0,nlayers,nlad,ndet,mod);
618     fIdSens[0] = 0; fIdSens[1] = 1; // Properly reset in Init later.
619     for(typ=1;typ<=ltypess;typ++){
620         for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[typ-1][j];
621         for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[typ-1][j];
622         if(typ == 1) id = fIdSens[0];
623         else id = fIdSens[1];
624         lad = 1;
625         det = 1;
626         for(cpy=1;cpy<=itsGeomTreeCopys[typ-1][2];cpy++){
627             mod = DecodeDetector(id,cpy,lay,lad,det);
628             ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,par,att,
629                             imat,imed);
630             cout << "0: id,cpy="<<id<<","<<cpy<<" mod,lay,lad,det"<<mod
631                  << ","<<lay<<","<<lad<<","<<det;
632             switch (typ){
633             case 2:
634                 fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
635                 cout <<" SDD"<<endl;
636                 if(!(fITSgeom->IsShapeDefined((Int_t)kSDD))){
637                     fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256(npar,par));
638                 } // end if
639                 break;
640             case 1:
641                 fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
642                 cout <<" SSD"<<endl;
643                 if(!(fITSgeom->IsShapeDefined((Int_t)kSSD))){
644                     fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD(box,0.0,0.0,
645                                                               np+1,p,np+1,n));
646                 } // end if
647                 break;
648             } // end switch
649         } // end for cpy
650     } // end for typ
651     return;
652 }
653 //______________________________________________________________________
654 void AliITSvSDD03::Init(){
655     ////////////////////////////////////////////////////////////////////////
656     //     Initialise the ITS after it has been created.
657     // Inputs:
658     //    none.
659     // Outputs:
660     //    none.
661     // Return:
662     //    none.
663     ////////////////////////////////////////////////////////////////////////
664     Int_t i;
665
666     cout << endl;
667     for(i=0;i<26;i++) cout << "*";
668     cout << " AliITSvSDD03" << fMinorVersion << "_Init ";
669     for(i=0;i<25;i++) cout << "*";cout << endl;
670
671     if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
672     if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
673     if(fITSgeom!=0) delete fITSgeom;
674     fITSgeom = new AliITSgeom();
675     if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
676     if(!fGeomDetIn) this->InitAliITSgeom();
677     if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
678     AliITS::Init();
679     fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
680
681     for(i=0;i<72;i++) cout << "*";
682     cout << endl;
683 }
684 //______________________________________________________________________
685 void AliITSvSDD03::SetDefaults(){
686     // sets the default segmentation, response, digit and raw cluster classes
687     // Inputs:
688     //    none.
689     // Outputs:
690     //    none.
691     // Return:
692     //    none.
693     const Float_t kconv = 1.0e+04; // convert cm to microns
694
695     Info("SetDefaults","Setting up only SDD detector");
696
697     AliITSDetType *iDetType;
698     AliITSgeomSDD *s1;
699     AliITSgeomSSD *s2;
700     iDetType=DetType(kSPD);
701     SetResponseModel(kSPD,new AliITSresponseSPD());
702     SetSegmentationModel(kSPD,new AliITSsegmentationSPD());
703     const char *kData0=(iDetType->GetResponseModel())->DataType();
704     if(strstr(kData0,"real") ) iDetType->ClassNames("AliITSdigit",
705                                                     "AliITSRawClusterSPD");
706     else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
707
708     // SDD
709     iDetType=DetType(kSDD);
710     s1 = (AliITSgeomSDD*) fITSgeom->GetShape(kSDD);// Get shape info. Do it this way for now.
711     AliITSresponseSDD *resp1=new AliITSresponseSDD("simulated");
712     SetResponseModel(kSDD,resp1);
713     AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
714     seg1->SetDetSize(s1->GetDx()*kconv, // base this on AliITSgeomSDD
715                      s1->GetDz()*2.*kconv, // for now.
716                      s1->GetDy()*2.*kconv); // x,z,y full width in microns.
717     seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
718     SetSegmentationModel(kSDD,seg1);
719     const char *kData1=(iDetType->GetResponseModel())->DataType();
720     const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
721     if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
722         iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
723     } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
724
725     // SSD  Layer 5
726     iDetType=DetType(kSSD);
727     s2 = (AliITSgeomSSD*) fITSgeom->GetShape(kSSD);// Get shape info. Do it this way for now.
728     AliITSresponse *resp2=new AliITSresponseSSD("simulated");
729     SetResponseModel(kSSD,resp2);
730     AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
731     seg2->SetDetSize(s2->GetDx()*2.*kconv, // base this on AliITSgeomSSD
732                      s2->GetDz()*2.*kconv, // for now.
733                      s2->GetDy()*2.*kconv); // x,z,y full width in microns.
734     seg2->SetPadSize(95.,0.); // strip x pitch in microns
735     seg2->SetNPads(768,0); // number of strips on each side.
736     seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
737     seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
738     seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
739     SetSegmentationModel(kSSD,seg2); 
740     const char *kData2=(iDetType->GetResponseModel())->DataType();
741     if(strstr(kData2,"real") ) iDetType->ClassNames("AliITSdigit",
742                                                     "AliITSRawClusterSSD");
743     else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
744
745     if(kNTYPES>3){
746         Warning("SetDefaults",
747                 "Only the four basic detector types are initialised!");
748     }// end if
749     return;
750 }
751 //______________________________________________________________________
752 void AliITSvSDD03::SetDefaultSimulation(){
753     // sets the default simulation.
754     // Inputs:
755     //      none.
756     // Outputs:
757     //      none.
758     // Return:
759     //      none.
760
761     AliITSDetType *iDetType;
762     AliITSsimulation *sim;
763     AliITSsegmentation *seg;
764     AliITSresponse *res;
765     iDetType = DetType(kSPD);
766     if(iDetType){
767         sim = iDetType->GetSimulationModel();
768         if (!sim) {
769             seg =(AliITSsegmentation*)iDetType->GetSegmentationModel();
770             if(seg==0) seg = new AliITSsegmentationSPD();
771             res = (AliITSresponse*)iDetType->GetResponseModel();
772             if(res==0) res = new AliITSresponseSPD();
773             sim = new AliITSsimulationSPDdubna(seg,res,0);
774             SetSimulationModel(kSPD,sim);
775         }else{ // simulation exists, make sure it is set up properly.
776             sim->Init();
777         } // end if
778     } // end if iDetType
779     iDetType = DetType(kSDD);
780     if(iDetType){
781         sim = iDetType->GetSimulationModel();
782         if (!sim) {
783             seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
784             res = (AliITSresponse*)iDetType->GetResponseModel();
785             sim = new AliITSsimulationSDD(seg,res);
786             SetSimulationModel(kSDD,sim);
787         }else{ // simulation exists, make sure it is set up properly.
788             sim->Init();
789         } //end if
790     } // end if iDetType
791     iDetType = DetType(kSSD);
792     if(iDetType){
793         sim = iDetType->GetSimulationModel();
794         if (!sim) {
795             seg = (AliITSsegmentation*)iDetType->GetSegmentationModel();
796             res = (AliITSresponse*)iDetType->GetResponseModel();
797             sim = new AliITSsimulationSSD(seg,res);
798             SetSimulationModel(kSSD,sim);
799         }else{ // simulation exists, make sure it is set up properly.
800             sim->Init();
801         } // end if
802     } // end if iDetType
803 }
804 //______________________________________________________________________
805 void AliITSvSDD03::DrawModule() const{
806     ////////////////////////////////////////////////////////////////////////
807     //     Draw a shaded view of the ITS SDD test beam version 1.
808     // Inputs:
809     //    none.
810     // Outputs:
811     //    none.
812     // Return:
813     //    none.
814     ////////////////////////////////////////////////////////////////////////
815     // Set everything unseen
816     gMC->Gsatt("*", "seen", -1);
817     // Set ALIC mother visible
818     gMC->Gsatt("ALIC","SEEN",0);
819     // Set ALIC ITS visible
820     gMC->Gsatt("ITSV","SEEN",0);
821     // Set ALIC Telescopes visible
822     gMC->Gsatt("ITEL","SEEN",0);
823     // Set ALIC detetcor visible
824     gMC->Gsatt("IDET","SEEN",0);
825     // Set Detector chip mother visible and drawn
826     gMC->Gsatt("IPC0","SEEN",1);
827     // Set Detector mother visible and drawn
828     gMC->Gsatt("ITS0","SEEN",1);
829     // Set minibus chip mother visible and drawn
830     gMC->Gsatt("ICMB","SEEN",1);
831     // Set minibus mother visible and drawn
832     gMC->Gsatt("IMB0","SEEN",1);
833 }
834 //______________________________________________________________________
835 void AliITSvSDD03::StepManager(){
836     ////////////////////////////////////////////////////////////////////////
837     //    Called for every step in the ITS SDD test beam, then calles the 
838     // AliITShit class  creator with the information to be recoreded about
839     //  that hit.
840     //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
841     // printing of information to a file which can be used to create a .det
842     // file read in by the routine CreateGeometry(). If set to 0 or any other
843     // value except 1, the default behavior, then no such file is created nor
844     // it the extra variables and the like used in the printing allocated.
845     // Inputs:
846     //    none.
847     // Outputs:
848     //    none.
849     // Return:
850     //    none.
851     ////////////////////////////////////////////////////////////////////////
852     Int_t  copy, id;
853     static TLorentzVector position0;
854     static Int_t stat0=0;
855     if((id=gMC->CurrentVolID(copy) == fIDMother)&&
856        (gMC->IsTrackEntering()||gMC->IsTrackExiting())){
857         copy = fTrackReferences->GetEntriesFast();
858         TClonesArray &lTR = *fTrackReferences;
859         // Fill TrackReference structure with this new TrackReference.
860         new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->
861                                          GetCurrentTrackNumber());
862     } // if Outer ITS mother Volume
863     //if(!(this->IsActive())) return;
864     if(!(gMC->TrackCharge())) return;
865     Int_t   vol[5],copy3;
866     TLorentzVector position, momentum;
867     TClonesArray &lhits = *fHits;
868     //
869     // Fill hit structure.
870     gMC->TrackPosition(position);
871     gMC->TrackMomentum(momentum);
872     id   = gMC->CurrentVolID(copy);
873     if(id==fIdSens[0] || id==fIdSens[1]){ // Volumes "ITST" or "IMBS"
874         copy = gMC->CurrentVolOffID(3,copy3);
875         copy = DecodeDetector(id,copy3,vol[0],vol[1],vol[2]);
876         //cout << "0: mod,lay,lad,det="<<copy<<","<<vol[0]<<","<<vol[1]
877         //     <<","<<vol[2]<<" name="<<gMC->CurrentVolName()<<" z="
878         //     <<position.Z()<<endl;
879     }else if(id==fIdSens[2]){ // "ISNT" Sintilator
880         //cout << "1: id,copy="<<id<<","<<copy
881         //     <<" name="<<gMC->CurrentVolName()<<" z="
882         //     <<position.Z()<<endl;
883         return; // Do nothing for now.
884     }else{
885         //cout << "2: id,copy="<<id<<","<<copy
886         //     <<" name="<<gMC->CurrentVolName()<<" z="
887         //     <<position.Z()<<endl;
888         return;
889     } // end if
890     //
891     // Track status
892     vol[3] = 0;
893     vol[4] = 0;
894     if(gMC->IsTrackInside())      vol[3] +=  1;
895     if(gMC->IsTrackEntering())    vol[3] +=  2;
896     if(gMC->IsTrackExiting())     vol[3] +=  4;
897     if(gMC->IsTrackOut())         vol[3] +=  8;
898     if(gMC->IsTrackDisappeared()) vol[3] += 16;
899     if(gMC->IsTrackStop())        vol[3] += 32;
900     if(gMC->IsTrackAlive())       vol[3] += 64;
901     //
902     vol[4] = stat0;
903     if(gMC->IsTrackEntering()){
904         position0 = position;
905         stat0 = vol[3];
906         return;
907     }else{
908         new(lhits[fNhits++]) AliITShit(fIshunt,
909                                    gAlice->GetMCApp()->GetCurrentTrackNumber(),
910                                        vol,gMC->Edep(),gMC->TrackTime(),
911                                        position,position0,momentum);
912     }// end if gMC->IsTrackEnetering()
913     position0 = position;
914     stat0 = vol[3];
915
916     return;
917 }
918