]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSvSSD03.cxx
Conversion of data from surveyors into alignment objects
[u/mrichter/AliRoot.git] / ITS / AliITSvSSD03.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 // Enrico Fragiacomo - 15/03/2004
17 // Geometry for the June 2003 SSD beam test
18
19 #include <TGeometry.h>
20 #include <TNode.h>
21 #include <TLorentzVector.h>
22 #include <TClonesArray.h>
23 #include <TBRIK.h>
24 #include <TVirtualMC.h>
25 #include <TGeoMatrix.h>
26
27 #include "AliRun.h"
28 #include "AliMagF.h"
29 #include "AliTrackReference.h"
30 #include "AliITShit.h"
31 #include "AliITS.h"
32 #include "AliITSvSSD03.h"
33 #include "AliITSgeom.h"
34 #include "AliITSgeomSSD.h"
35 #include "AliITSDetTypeSim.h"
36 #include "AliITSCalibrationSSD.h"
37 #include "AliITSsegmentationSSD.h"
38 #include "AliITSsimulationSSD.h"
39 #include "AliMC.h"
40
41
42 ///////////////////////////////////////////////////////////////////////
43 // Step manager and 
44 // geometry class
45 // for the ITS 
46 // SSD test beam
47 // geometry of June 2003
48 // 
49 ///////////////////////////////////////////////////////////////////////
50 ClassImp(AliITSvSSD03)
51
52 //______________________________________________________________________
53 AliITSvSSD03::AliITSvSSD03() {
54     ////////////////////////////////////////////////////////////////////////
55     // Standard default constructor for the ITS SSD test beam 2003 version 1.
56     // Inputs:
57     //    none.
58     // Outputs:
59     //    none.
60     // Return:
61     //    A default created class.
62     ////////////////////////////////////////////////////////////////////////
63     Int_t i;
64
65     fIdN          = 0;
66     fIdName       = 0;
67     fIdSens       = 0;
68     fEuclidOut    = kFALSE; // Don't write Euclide file
69     fGeomDetOut   = kFALSE; // Don't write .det file
70     fGeomDetIn    = kFALSE; // Don't Read .det file
71     fMajorVersion = IsVersion();
72     fMinorVersion = -1;
73     fGeomNumber   = 2003; // default value
74     for(i=0;i<60;i++) fRead[i] = '\0';
75     for(i=0;i<60;i++) fWrite[i] = '\0';
76     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
77 }
78 //______________________________________________________________________
79 AliITSvSSD03::AliITSvSSD03(const char *title,Int_t gn) : AliITS("ITS", title){
80     ////////////////////////////////////////////////////////////////////////
81     //    Standard constructor for the ITS SSD testbeam 2003 version 1.
82     // Inputs:
83     //    const char *title    title for this ITS geometry.
84     //    Int_t      gn        Geometry version number (year) default 2003.
85     // Outputs:
86     //    none.
87     // Return:
88     //    A standard created class.
89     ////////////////////////////////////////////////////////////////////////
90     Int_t i;
91
92     fGeomNumber = gn;
93
94     fIdN = 1; 
95     fIdName = new TString[fIdN];
96     fIdName[0] = "ITST";
97     fIdSens    = new Int_t[fIdN];
98     for(i=0;i<fIdN;i++) fIdSens[i] = 0;
99
100     fMajorVersion = IsVersion();
101     fMinorVersion = 2;
102     fEuclidOut    = kFALSE; // Don't write Euclide file
103     fGeomDetOut   = kFALSE; // Don't write .det file
104     fGeomDetIn    = kFALSE; // Don't Read .det file
105
106     SetThicknessDet1();
107     SetThicknessDet2();
108     SetThicknessChip1();
109     SetThicknessChip2();                         
110
111     fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vSSD03.euc";
112     strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vSSD03.det",60);
113     strncpy(fRead,fEuclidGeomDet,60);
114     strncpy(fWrite,fEuclidGeomDet,60);
115 }
116 //______________________________________________________________________
117 AliITSvSSD03::~AliITSvSSD03() {
118     ////////////////////////////////////////////////////////////////////////
119     //    Standard destructor for the ITS SSD test beam 2003 version 1.
120     // Inputs:
121     //    none.
122     // Outputs:
123     //    none.
124     // Return:
125     //    none.
126     ////////////////////////////////////////////////////////////////////////
127 }
128 //______________________________________________________________________
129 void AliITSvSSD03::BuildGeometry(){
130     ////////////////////////////////////////////////////////////////////////
131     //    Geometry builder for the ITS SSD test beam 2003 version 1.
132     //    ALIC    ALICE Mother Volume
133     //     |- ITSV     ITS Mother Volume
134     //         |- ITST       Detector under Test
135     //
136     // Inputs:
137     //    none.
138     // Outputs:
139     //    none.
140     // Return:
141     //    none.
142     ////////////////////////////////////////////////////////////////////////
143     // Get the top alice volume.
144
145     switch (fGeomNumber){
146     case 2003:
147         BuildGeometry2003();
148         break;
149     default:
150         BuildGeometry2003();
151         break;
152     } // end switch
153 }
154 //______________________________________________________________________
155 void AliITSvSSD03::BuildGeometry2003(){
156     ////////////////////////////////////////////////////////////////////////
157     //    Geometry builder for the ITS SSD test beam 2003 version 1.
158     //    ALIC    ALICE Mother Volume
159     //     |- ITSV     ITS Mother Volume
160     //         |- ITST       Detector under Test
161     // Inputs:
162     //    none.
163     // Outputs:
164     //    none.
165     // Return:
166     //    none.
167     ////////////////////////////////////////////////////////////////////////
168
169     // Get the top alice volume.
170     TNode *aALIC = gAlice->GetGeometry()->GetNode("alice");
171     aALIC->cd();
172
173     // Define ITS Mother Volume
174     Float_t data[3];
175     Float_t ddettest=300.0E-4;
176     //Float_t yposition= 0.0;
177     TRotMatrix *r0 = new TRotMatrix("ITSidrotm0","ITSidrotm0",
178                                     90.0,0,0.0,0,90.0,270.0);
179
180     // Mother volume (beam along z)
181     data[0] = 10.0;   // in centimeter
182     data[1] = 50.0;
183     data[2] = 100.0;
184     TBRIK *iITSVshape = new TBRIK("ITSVshape",
185                                   "ITS Logical Mother Volume","Air",
186                                   data[0],data[1],data[2]);
187     TNode *iITSV = new TNode("ITSV","ITS Mother Volume",iITSVshape,
188                             0.0,0.0,0.0,0,0);
189     iITSV->cd(); // set ourselve into ITSV subvolume of aALIC
190
191     // SSD part of telescope  (Note. strips in local xz plan)
192     data[0] = 3.5;   // half-length of the SSD module
193     data[1] = 0.5*ddettest;    // half-width of the SSD module 
194     data[2] = 2.0;   // half-heigth of the SSD module
195     TBRIK *iITSTshape = new TBRIK("ITSTshape","SSD sensitive volume","Si",
196                                  data[0],data[1],data[2]);
197     TNode *iITST = new TNode("ITST","SSD sensitive volume",iITSTshape,
198                             0.0,0.0,0.0,r0,0);
199
200     aALIC->cd();
201     iITST->SetLineColor(kYellow);
202     fNodes->Add(iITST);
203 }
204 //______________________________________________________________________
205 void AliITSvSSD03::CreateGeometry(){
206     ////////////////////////////////////////////////////////////////////////
207     //   Geometry builder for the ITS SSD test beam 2003 version 1.
208     //    ALIC    ALICE Mother Volume
209     //     |- ITSV     ITS Mother Volume
210     //         |- IDET       Detector under Test
211     // Inputs:
212     //    none.
213     // Outputs:
214     //    none.
215     // Return:
216     //    none.
217     ////////////////////////////////////////////////////////////////////////
218
219     switch (fGeomNumber){
220     case 2003:
221         CreateGeometry2003();
222         break;
223     default:
224         CreateGeometry2003();
225         break;
226     } // end switch
227 }
228 //______________________________________________________________________
229 void AliITSvSSD03::CreateGeometry2003(){
230   ////////////////////////////////////////////////////////////////////////
231   //
232   //    ALIC    ALICE Mother Volume
233   //     |- ITSV     Beamtest Mother Volume
234   //         |
235   //         |- ITSA       Aluminum cover for scintillator
236   //         |    |-ITSS    first Trieste trigger plastic scintillator 
237   //         |- ITSA       Aluminum cover for scintillator
238   //         |    |-ITSS    second Trieste's trigger plastic scintillator
239   //         |
240   //         |- IGAR       Black box around ITST       
241   //         |    |-IAIR    Air inside the black box
242   //         |        |-ITST    Detector under Test 
243   //         |
244   //         |- IFRA       Aluminum cover for scintillator
245   //         |    |-IFRS    French plastic scintillator 
246   //         |
247   //         |- ITSA       Aluminum cover for scintillator
248   //         |    |-ITSS    third Trieste's plastic scintillator
249   // Inputs:
250   //    none.
251   // Outputs:
252   //    none.
253   // Return:
254   //    none.
255   ////////////////////////////////////////////////////////////////////////
256   
257   Float_t data[49];
258   // Define media off-set
259   Int_t *idtmed = fIdtmed->GetArray()+1; // array of media indexes
260   Int_t idrotm[4]; // Array of rotation matrix indexes
261    //Float_t yposition= 0.0;
262   
263   if(gMC==0) return;
264   // Define Rotation-reflextion Matrixes needed
265   // 0 is the unit matrix
266
267   // Beamtest mother volume (air) positioned in ALIC mother volume
268   data[0] = 500.0;
269   data[1] = 500.0;
270   data[2] = 1000.0;
271   gMC->Gsvolu("ITSV","BOX",idtmed[0],data,3);
272   gMC->Gspos("ITSV",1,"ALIC",0.0,0.0,0.0,0,"ONLY");
273   
274   // Trieste's plastic scintillators for the trigger (2 at beam enter)
275   // ...define them (aluminum cover + scintillator inside)
276   // aluminum cover
277   data[0] = 30.01; // size+2x50 microns Kapton
278   data[1] = 1.01;
279   data[2] = 20.01;
280   //gMC->Gsvolu("ITSA","BOX ",idtmed[3],data,3);// 
281   gMC->Gsvolu("ITSA","BOX ",idtmed[4],data,3);// 
282   data[0] = 30.0;
283   data[1] = 1.0;
284   data[2] = 20.0;
285   // plastic scintillator
286   gMC->Gsvolu("ITSS","BOX ",idtmed[2],data,3);
287   gMC->Gspos("ITSS",1,"ITSA",0.0,0.0,0.0,0,"ONLY"); 
288   // ... and place them inside ITSV
289   AliMatrix(idrotm[0], 90.0,0.0, 0.0,0.0, 90.0,270.0);
290   // first scintillator 
291   gMC->Gspos("ITSA",1,"ITSV",0.0,0.0,-282.0,idrotm[0],"ONLY"); 
292   // second scintillator 
293   gMC->Gspos("ITSA",2,"ITSV",0.0,0.0,-280.0,idrotm[0],"ONLY"); 
294
295   // black kapton box with the SSD sensor inside (width 50 microns)
296   data[0] = 20.0;
297   data[1] = 20.0;
298   data[2] = 20.0;
299   gMC->Gsvolu("IGAR","BOX ",idtmed[4],data,3); //
300   // air in the black kapton box 
301   data[0] = 19.99;
302   data[1] = 19.99;
303   data[2] = 19.99;
304   gMC->Gsvolu("IAIR","BOX ",idtmed[0],data,3); //
305   // SSD sensor 
306   Float_t ddettest=300.0E-4;
307   data[0] = 3.5;
308   data[1] = 0.5*ddettest;
309   data[2] = 2.0;
310   gMC->Gsvolu("ITST","BOX ",idtmed[1],data,3);// sensitive detector volume
311   // place ITST inside IAIR (no rotation: it will be rotated with IGAR)
312   gMC->Gspos("ITST",1,"IAIR",0.0,0.0,0.0,0,"ONLY"); 
313   // place IAIR inside IGAR
314   gMC->Gspos("IAIR",1,"IGAR",0.0,0.0,0.0,0,"ONLY"); 
315   // place IGAR inside ITSV
316   AliMatrix(idrotm[0], 90.0,0.0, 0.0,0.0, 90.0,270.0);
317   gMC->Gspos("IGAR",1,"ITSV",0.0,0.0,0.0,idrotm[0],"ONLY"); 
318   //gMC->Gspos("IGAR",1,"ITSV",0.0,0.0,0.0,0,"ONLY"); 
319  
320   // The so called French detector 
321   // ...define it (Kapton cover + scintillator inside)
322   // Kapton cover
323   data[0] = 2.01; // size+2x50 microns Kapton width
324   data[1] = 1.01;
325   data[2] = 1.01;
326   gMC->Gsvolu("IFRA","BOX ",idtmed[4],data,3);// 
327   data[0] = 2.0;
328   data[1] = 1.0;
329   data[2] = 1.0;
330   // plastic scintillator
331   gMC->Gsvolu("IFRS","BOX ",idtmed[2],data,3);
332   gMC->Gspos("IFRS",1,"IFRA",0.0,0.0,0.0,0,"ONLY"); 
333   // ... and place it inside ITSV
334   AliMatrix(idrotm[0], 90.0,0.0, 0.0,0.0, 90.0,270.0); 
335   gMC->Gspos("IFRA",1,"ITSV",0.0,0.0,16.0,idrotm[0],"ONLY"); 
336
337   // An other Trieste's plastic scintillator for the trigger 
338   // ...just place an other copy inside ITSV
339   AliMatrix(idrotm[0], 90.0,0.0, 0.0,0.0, 90.0,270.0);
340   gMC->Gspos("ITSA",3,"ITSV",0.0,0.0,270.0,idrotm[0],"ONLY"); 
341  
342 }
343
344 //______________________________________________________________________
345 void AliITSvSSD03::CreateMaterials(){
346     ////////////////////////////////////////////////////////////////////////
347     //
348     // Create ITS SSD test beam materials
349     //     This function defines the default materials used in the Geant
350     // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
351     // AliITSvSSD03.
352     // In general it is automatically replaced by
353     // the CreateMaterials routine defined in AliITSv?. Should the function
354     // CreateMaterials not exist for the geometry version you are using this
355     // one is used. See the definition found in AliITSv5 or the other routine
356     // for a complete definition.
357     //
358     // Inputs:
359     //    none.
360     // Outputs:
361     //    none.
362     // Return:
363     //    none.
364     /////////////////////////////////////////////////////////////////////////
365
366     switch (fGeomNumber){
367     case 2003:
368         CreateMaterials2003();
369         break;
370     default:
371         CreateMaterials2003();
372         break;
373     } // end switch
374 }
375 //______________________________________________________________________
376 void AliITSvSSD03::CreateMaterials2003(){
377     ////////////////////////////////////////////////////////////////////////
378     //
379     // Create ITS SSD test beam materials
380     //     This function defines the default materials used in the Geant
381     // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
382     // AliITSvSSD03.
383     // In general it is automatically replaced by
384     // the CreateMaterials routine defined in AliITSv?. Should the function
385     // CreateMaterials not exist for the geometry version you are using this
386     // one is used. See the definition found in AliITSv5 or the other routine
387     // for a complete definition.
388     //
389     // Inputs:
390     //    none.
391     // Outputs:
392     //    none.
393     // Return:
394     //    none.
395     /////////////////////////////////////////////////////////////////////////
396
397     Int_t   ifield = gAlice->Field()->Integ();
398     Float_t fieldm = gAlice->Field()->Max();   
399
400     // Scintillator CH
401     Float_t ascin[2]={1.01,12.01};
402     Float_t zscin[2]={1,6};
403     Float_t wscin[2]={1,1};
404     Float_t denscin=1.03;
405     AliMixture( 3, "Scintillator$",ascin,zscin,denscin,-2,wscin);
406     AliMedium(3, "Scintillator$", 3, 1, ifield, fieldm, 0.1, .01, 
407               0.1, .0001, 0.0);
408     
409     // Aluminum
410     Float_t tmaxfdAl = 0.1; // Degree
411     Float_t stemaxAl = 0.01; // cm
412     Float_t deemaxAl = 0.1; // Fraction of particle's energy 0<deemax<=1
413     Float_t epsilAl  = 1.0E-4;//
414     Float_t stminAl  = 0.0; // cm "Default value used"
415     AliMaterial(4,  "Al$", 26.98, 13., 2.7, 8.9, 37.2);
416     AliMedium(4,  "Al$",  4, 0, ifield, fieldm, tmaxfdAl, stemaxAl, 
417               deemaxAl, epsilAl, stminAl);
418
419     // Air
420     Float_t tmaxfdAir = 0.1; // Degree
421     Float_t stemaxAir = .10000E+01; // cm
422     Float_t deemaxAir = 0.1; // Fraction of particle's energy 0<deemax<=1
423     Float_t epsilAir  = 1.0E-4;//
424     Float_t stminAir  = 0.0; // cm "Default value used"
425     AliMaterial(1,"AIR$",0.14610E+03,0.73000E+01,0.12050E-03,
426                 0.30423E+05,0.99900E+03);
427     AliMedium(1,"AIR$",1,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,
428               epsilAir,stminAir);
429     
430     // Silicon
431     Float_t tmaxfdSi = 0.1; // Degree
432     //Float_t stemaxSi = 0.0075; // cm
433     //Float_t deemaxSi = 0.1; // Fraction of particle's energy 0<deemax<=1
434     //Float_t stminSi  = 0.0; // cm "Default value used"
435     //Float_t tmaxfdSi = 10; // Degree
436     Float_t stemaxSi = 0.01; // cm
437     Float_t deemaxSi = 0.1; // Fraction of particle's energy 0<deemax<=1
438     Float_t epsilSi  = 1.0E-4;//
439     //Float_t epsilSi  = 0.003;//
440     Float_t stminSi  = 0.003; // cm "Default value used"
441     AliMaterial(2,"SSD SI$",0.28086E+02,0.14000E+02,0.23300E+01,
442                 0.93600E+01,0.99900E+03);
443     AliMedium(2,"SSD SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
444               epsilSi,stminSi);
445
446     // Kapton
447     AliMaterial(5, "Kapton$", 12.011, 6., 1.3, 31.27, 999.);
448     AliMedium(5, "Kapton$",    5, 0,ifield,fieldm, 10., .01, .1, .003, .003);
449 }
450 //______________________________________________________________________
451 void AliITSvSSD03::InitAliITSgeom(){
452   // sturture.
453   // Inputs:
454   //    none.
455   // Outputs:
456   //    none.
457   // Return:
458   //    none.
459     const Int_t knlayers=1;
460     const TString kname="ALIC_1/ITSV_1/IGAR_1/IAIR_1/ITST_1";
461     const Int_t knlad[knlayers]={knlayers*1},kndet[knlayers]={knlayers*1};
462     Int_t npar;
463     Float_t par[20];
464     Double_t trans[3]={3*0.0},rot[10]={10*0.0};
465     TGeoHMatrix materix;
466
467     AliITSgeom* geom = new AliITSgeom(0,knlayers,knlad,kndet,1);
468     SetITSgeom(geom);
469     npar=3;par[0]=3.5;par[1]=0.5*300.0E-4;par[2]=2.0;
470     geom->ReSetShape(kSSD,new AliITSgeomSSD275and75(npar,par));
471     gMC->GetTransformation(kname.Data(),materix);
472     geom->CreateMatrix(0,1,1,1,kSSD,trans,rot);
473     geom->SetTrans(0,materix.GetTranslation());
474     geom->SetRotMatrix(0,materix.GetRotationMatrix());
475     geom->GetGeomMatrix(0)->SetPath(kname.Data());
476     return;
477 }
478 //______________________________________________________________________
479 void AliITSvSSD03::Init(){
480     ////////////////////////////////////////////////////////////////////////
481     //     Initialise the ITS after it has been created.
482     // Inputs:
483     //    none.
484     // Outputs:
485     //    none.
486     // Return:
487     //    none.
488     ////////////////////////////////////////////////////////////////////////
489     Int_t i;
490
491     cout << endl;
492     for(i=0;i<26;i++) cout << "*";
493     cout << " ITSvSSD03" << fMinorVersion << "_Init ";
494     for(i=0;i<25;i++) cout << "*";cout << endl;
495 //
496     if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
497     if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
498     if(GetITSgeom()!=0) SetITSgeom(0x0);
499     AliITSgeom* geom = new AliITSgeom();
500     SetITSgeom(geom);
501     if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
502     if(!fGeomDetIn) this->InitAliITSgeom();
503     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
504     AliITS::Init();
505 //
506     for(i=0;i<72;i++) cout << "*";
507     cout << endl;
508     if(gMC) fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
509     else fIDMother = 0;
510 }
511 //______________________________________________________________________
512 void AliITSvSSD03::SetDefaults(){
513     // sets the default segmentation, rerponse, digit and raw cluster classes
514     // Inputs:
515     //    none.
516     // Outputs:
517     //    none.
518     // Return:
519     //    none.
520     const Float_t kconv = 1.0e+04; // convert cm to microns
521
522     Info("SetDefaults","Setting up only SSD detector");
523
524     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
525     fDetTypeSim->SetITSgeom(GetITSgeom());
526     AliITSgeomSSD  *s0;
527     fDetTypeSim->ResetCalibrationArray();
528     fDetTypeSim->ResetSegmentation();
529  
530     //SSD
531
532     // Get shape info. Do it this way for now.
533     s0 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);
534     AliITSCalibration *resp0=new AliITSCalibrationSSD("simulated");
535     SetCalibrationModel(GetITSgeom()->GetStartSSD(),resp0);     
536
537     AliITSsegmentationSSD *seg0=new AliITSsegmentationSSD();
538     seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSSD
539                      s0->GetDz()*2.*kconv, // for now.
540                      s0->GetDy()*2.*kconv); // x,z,y full width in microns.
541     //seg0->SetNPads(256,160);// Number of Bins in x and z
542
543     SetSegmentationModel(kSSD,seg0);
544
545     // set digit and raw cluster classes to be used
546     const char *kData0=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSSD()))->DataType();
547     if (strstr(kData0,"real")) fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigit");
548     else fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigitSSD");
549 //    SetSimulationModel(kSSD,new AliITSsimulationSSD(seg0,resp0));
550 //    iDetType->ReconstructionModel(new AliITSClusterFinderSSD());
551
552 /*
553     SetResponseModel(kSPD,new AliITSCalibrationSPD());
554     SetSegmentationModel(kSPD,new AliITSsegmentationSPD());
555     fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
556
557     SetResponseModel(kSDD,new AliITSCalibrationSDD());
558     SetSegmentationModel(kSDD,new AliITSsegmentationSDD());
559     fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
560 */
561
562
563     if(fgkNTYPES>3){
564         Warning("SetDefaults",
565                 "Only the four basic detector types are initialised!");
566     }// end if
567     return;
568 }
569 //______________________________________________________________________
570 void AliITSvSSD03::SetDefaultSimulation(){
571     // sets the default simulation.
572     // Inputs:
573     //      none.
574     // Outputs:
575     //      none.
576     // Return:
577     //      none.
578
579   if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
580
581   AliITSsimulation *sim;
582   //  AliITSsegmentation *seg;
583   // AliITSCalibration *res;
584   /*
585   //SPD
586   if(fDetTypeSim){
587     sim = fDetTypeSim->GetSimulationModel(kSPD);
588     if (!sim) {
589       seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD);
590       res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(nspd);
591       sim = new AliITSsimulationSPDdubna(seg,res,1);
592       SetSimulationModel(kSPD,sim);
593     }else{ // simulation exists, make sure it is set up properly.
594       sim->SetSegmentationModel((AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD));
595       sim->SetResponseModel((AliITSCalibration*)fDetTypeSim->GetResponseModel(nspd));
596       ((AliITSsimulation*)sim)->Init();
597       //        if(sim->GetResponseModel()==0) sim->SetResponseModel(
598       //            (AliITSCalibration*)iDetType->GetResponseModel());
599       //        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
600       //            (AliITSsegmentation*)iDetType->GetSegmentationModel());
601     } // end if
602   } // end if !fDetTypeSim
603
604   //SDD
605   if(fDetTypeSim){
606     sim = fDetTypeSim->GetSimulationModel(kSDD);
607     if (!sim) {
608       seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD);
609       res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(nsdd);
610       sim = new AliITSsimulationSDD(seg,res);
611       SetSimulationModel(kSDD,sim);
612     }else{ // simulation exists, make sure it is set up properly.
613       sim->SetSegmentationModel((AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD));
614       sim->SetResponseModel((AliITSCalibration*)fDetTypeSim->GetResponseModel(nsdd));
615
616       ((AliITSsimulation*)sim)->Init();
617       //        if(sim->GetResponseModel()==0) sim->SetResponseModel(
618       //            (AliITSCalibration*)iDetType->GetResponseModel());
619       //        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
620       //            (AliITSsegmentation*)iDetType->GetSegmentationModel());
621     } //end if
622   } // end if !iDetType
623   */
624   //SSD
625   if(fDetTypeSim){
626     sim = fDetTypeSim->GetSimulationModel(kSSD);
627     if (!sim) {
628       //  seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSSD);
629       // res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSSD());
630       sim = new AliITSsimulationSSD(fDetTypeSim);
631       SetSimulationModel(kSSD,sim);
632     }else{ // simulation exists, make sure it is set up properly.
633       sim->SetSegmentationModel(kSSD,(AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSSD));
634       sim->SetCalibrationModel(GetITSgeom()->GetStartSSD(),(AliITSCalibration*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSSD()));
635       ((AliITSsimulation*)sim)->Init();
636       //        if(sim->GetResponseModel()==0) sim->SetResponseModel(
637       //            (AliITSCalibration*)iDetType->GetResponseModel());
638       //        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
639       //            (AliITSsegmentation*)iDetType->GetSegmentationModel());
640     } // end if
641   } // end if !iDetType
642 }
643
644 //______________________________________________________________________
645 void AliITSvSSD03::DrawModule() const {
646     ////////////////////////////////////////////////////////////////////////
647     //     Draw a shaded view of the ITS SSD test beam version 1.
648     // Inputs:
649     //    none.
650     // Outputs:
651     //    none.
652     // Return:
653     //    none.
654     ////////////////////////////////////////////////////////////////////////
655
656     gMC->Gsatt("*", "seen", -1);
657     gMC->Gsatt("ALIC","SEEN",0);
658     gMC->Gsatt("ITSV","SEEN",0);
659     gMC->Gsatt("ITSA","SEEN",1);
660     gMC->Gsatt("ITSS","SEEN",1);
661     gMC->Gsatt("IGAR","SEEN",1);
662     gMC->Gsatt("IAIR","SEEN",0);
663     gMC->Gsatt("ITST","SEEN",1);
664     gMC->Gsatt("IFRA","SEEN",1);
665     gMC->Gsatt("IFRS","SEEN",1);
666 }
667 //______________________________________________________________________
668 void AliITSvSSD03::StepManager(){
669     ////////////////////////////////////////////////////////////////////////
670     //    Called for every step in the ITS SSD, then calles the 
671     // AliITShit class  creator with the information to be recoreded about
672     //  that hit.
673     //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
674     // printing of information to a file which can be used to create a .det
675     // file read in by the routine CreateGeometry(). If set to 0 or any other
676     // value except 1, the default behavior, then no such file is created nor
677     // it the extra variables and the like used in the printing allocated.
678     // Inputs:
679     //    none.
680     // Outputs:
681     //    none.
682     // Return:
683     //    none.
684     ////////////////////////////////////////////////////////////////////////
685     Int_t         copy=0, id;
686     TLorentzVector position, momentum;
687     static TLorentzVector position0;
688     static Int_t stat0=0;
689
690     if((id=gMC->CurrentVolID(copy) == fIDMother)&&
691        (gMC->IsTrackEntering()||gMC->IsTrackExiting())){
692         copy = fTrackReferences->GetEntriesFast();
693         TClonesArray &lTR = *fTrackReferences;
694         // Fill TrackReference structure with this new TrackReference.
695         new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
696     } // if Outer ITS mother Volume
697
698     if(!(this->IsActive())){
699         return;
700     } // end if !Active volume.
701
702
703     Int_t   vol[5];
704     TClonesArray &lhits = *fHits;
705     //
706     // Track status
707     vol[3] = 0;
708     vol[4] = 0;
709     if(gMC->IsTrackInside())      vol[3] +=  1;
710     if(gMC->IsTrackEntering())    vol[3] +=  2;
711     if(gMC->IsTrackExiting())     vol[3] +=  4;
712     if(gMC->IsTrackOut())         vol[3] +=  8;
713     if(gMC->IsTrackDisappeared()) vol[3] += 16;
714     if(gMC->IsTrackStop())        vol[3] += 32;
715     if(gMC->IsTrackAlive())       vol[3] += 64;
716     //
717     // Fill hit structure.
718     if(!(gMC->TrackCharge())) return;
719     id = gMC->CurrentVolID(copy);
720     if(id==fIdSens[0]){  // Volume name "ITST"
721         vol[2] = vol[1] = vol[0] = 1; // Det, ladder
722     } else return; // end if
723     //
724     gMC->TrackPosition(position);
725     gMC->TrackMomentum(momentum);
726     vol[4] = stat0;
727     if(gMC->IsTrackEntering()){
728         position0 = position;
729         stat0 = vol[3];
730         return;
731     } // end if IsEntering
732
733     // Fill hit structure with this new hit only for non-entrerance hits.
734     else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
735                                         gMC->Edep(),gMC->TrackTime(),position,
736                                         position0,momentum);
737     //cout<<gMC->Edep()<<endl;
738     //
739     position0 = position;
740     stat0 = vol[3];
741
742     return;
743 }
744