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