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