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