]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11.cxx
Protection against events with no or insufficient number of clusters. Plus some chang...
[u/mrichter/AliRoot.git] / ITS / AliITSv11.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2008, 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 //************************************************************************
18 //
19 //                 Inner Traking System geometry v11
20 //
21 //  Based on ROOT geometrical modeler
22 //
23 // B. Nilsen, L. Gaudichet
24 //************************************************************************
25
26
27 #include <TClonesArray.h>
28 #include <TLorentzVector.h>
29
30 #include "AliITS.h"
31 #include "AliITSDetTypeSim.h"
32 #include <TVirtualMC.h>
33
34 #include "AliITSgeom.h"
35 #include "AliITSgeomSDD.h"
36 #include "AliITSgeomSPD.h"
37 #include "AliITSgeomSSD.h"
38 #include "AliITShit.h"
39
40 #include "AliITSCalibrationSDD.h"
41
42 #include "AliITSsegmentationSDD.h"
43 #include "AliITSsegmentationSPD.h"
44 #include "AliITSsegmentationSSD.h"
45 #include "AliMagF.h"
46 #include "AliRun.h"
47 #include "AliTrackReference.h"
48 #include "AliMC.h"
49
50 #include <TGeoManager.h>
51 #include <TGeoVolume.h>
52 #include <TGeoPcon.h>
53 #include "AliITSv11.h"
54 #include "AliITSv11GeometrySPD.h"
55 #include "AliITSv11GeometrySDD.h"
56 #include "AliITSv11GeometrySSD.h"
57 #include "AliITSv11GeometrySupport.h"
58
59
60
61 ClassImp(AliITSv11)
62  
63
64
65 //______________________________________________________________________
66 AliITSv11::AliITSv11() : 
67 AliITS(),
68 fGeomDetOut(kFALSE),
69 fGeomDetIn(kFALSE),
70 fByThick(kTRUE),
71 fMajorVersion(IsVersion()),
72 fMinorVersion(0),
73 fEuclidGeomDet(),
74 fRead(),
75 fWrite(),
76 fSPDgeom(),
77 fSDDgeom(0),
78 fSSDgeom(),
79 fSupgeom(),
80 fIgm(kv11)
81 {
82   //    Standard default constructor for the ITS version 11.
83
84     fIdN          = 0;
85     fIdName       = 0;
86     fIdSens       = 0;
87     Int_t i;
88     for(i=0;i<60;i++) fRead[i] = '\0';
89     for(i=0;i<60;i++) fWrite[i] = '\0';
90     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
91     strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
92 }
93
94
95 //______________________________________________________________________
96 AliITSv11::AliITSv11(const char *name, const char *title): 
97 AliITS("ITS", title),
98 fGeomDetOut(kFALSE),
99 fGeomDetIn(kFALSE),
100 fByThick(kTRUE),
101 fMajorVersion(IsVersion()),
102 fMinorVersion(0),
103 fEuclidGeomDet(),
104 fRead(),
105 fWrite(),
106 fSPDgeom(),
107 fSDDgeom(0),
108 fSSDgeom(),
109 fSupgeom(),
110 fIgm(kv11)
111 {
112   //    Standard constructor for the ITS version 11.
113
114   fSDDgeom = new AliITSv11GeometrySDD(0);
115
116   Int_t i;
117   fIdN = 6;
118   fIdName = new TString[fIdN];
119   fIdName[0] = name; // removes warning message
120   fIdName[0] = "ITS1";
121   fIdName[1] = "ITS2";
122   fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
123   fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
124   fIdName[4] = "ITS5";
125   fIdName[5] = "ITS6";
126   fIdSens    = new Int_t[fIdN];
127   for(i=0;i<fIdN;i++) fIdSens[i] = 0;
128   // not needed, fByThick set to kTRUE in in the member initialization lis
129   
130
131   fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
132   strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
133   strncpy(fRead,fEuclidGeomDet,60);
134   strncpy(fWrite,fEuclidGeomDet,60);
135   strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
136 }
137 //______________________________________________________________________
138 AliITSv11::AliITSv11(Int_t debugITS,Int_t debugSPD,Int_t debugSDD,
139                    Int_t debugSSD,Int_t debugSUP) :
140 AliITS("ITS","ITS geometry v11"),
141 fGeomDetOut(kFALSE),
142 fGeomDetIn(kFALSE),
143 fByThick(kTRUE),
144 fMajorVersion(IsVersion()),
145 fMinorVersion(0),
146 fEuclidGeomDet(),
147 fRead(),
148 fWrite(),
149 fSPDgeom(),
150 fSDDgeom(0),
151 fSSDgeom(),
152 fSupgeom(),
153 fIgm(kv11)
154 {
155   // Standard default constructor for the ITS version 11.
156
157
158   //   fSPDgeom = new AliITSv11GeometrySPD(debugSPD);
159   fSDDgeom = new AliITSv11GeometrySDD(debugSDD);
160   fSDDgeom->SetDebug(debugSDD);
161   //   fSupgeom = new AliITSv11GeometrySupport(debugSUP);
162
163   Int_t i;
164   fIdN = 6;
165   fIdName = new TString[fIdN];
166   fIdName[0] = fSPDgeom->GetSenstiveVolumeName1();
167   fIdName[1] = fSPDgeom->GetSenstiveVolumeName2();
168   fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
169   fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
170   fIdName[4] = fSSDgeom->GetSenstiveVolumeName5();
171   fIdName[5] = fSSDgeom->GetSenstiveVolumeName6();
172   fIdSens    = new Int_t[fIdN];
173   for(i=0;i<fIdN;i++) fIdSens[i] = 0;
174   fEuclidOut    = kFALSE; // Don't write Euclide file
175   
176   fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
177   strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
178   strncpy(fRead,fEuclidGeomDet,60);
179   strncpy(fWrite,fEuclidGeomDet,60);
180   strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
181
182   debugITS = (debugSPD && debugSSD && debugSUP && debugSDD); //remove temp. warnings
183 }
184 //______________________________________________________________________
185 AliITSv11::~AliITSv11() {
186   delete fSDDgeom;
187 }
188 //______________________________________________________________________
189 void AliITSv11::BuildGeometry(){
190
191 }
192 //______________________________________________________________________
193 void AliITSv11::CreateGeometry(){
194     //
195     // Create ROOT geometry
196     //
197     // These constant character strings are set by cvs during commit
198     // do not change them unless you know what you are doing!
199     const Char_t *cvsDate="$Date$";
200     const Char_t *cvsRevision="$Revision$";
201
202     TGeoManager *geoManager = gGeoManager;
203     TGeoVolume *vALIC = geoManager->GetTopVolume();
204
205     TGeoPcon *sITS = new TGeoPcon("ITS Top Volume",0.0,360.0,2);
206
207     // DefineSection(section number, Z, Rmin, Rmax).
208     const Double_t kcm = 1.0;
209     sITS->DefineSection(0,-300.0*kcm,0.01*kcm,50.0*kcm);
210     sITS->DefineSection(1,+300.0*kcm,0.01*kcm,50.0*kcm);
211
212     TGeoMedium *air = gGeoManager->GetMedium("ITS_AIR$");
213     TGeoVolume *vITS = new TGeoVolume("ITSV",sITS,air);
214     vITS->SetVisibility(kFALSE);
215     const Int_t length=100;
216     Char_t vstrng[length];
217     if(fIgm.WriteVersionString(vstrng,length,(AliITSVersion_t)IsVersion(),
218                                fMinorVersion,cvsDate,cvsRevision))
219         vITS->SetTitle(vstrng);
220     //printf("Title set to %s\n",vstrng);
221     vALIC->AddNode(vITS,1,0);
222
223 //   fSPDgeom->CenteralSPD(vITS);
224
225   fSDDgeom->Layer3(vITS);
226   fSDDgeom->Layer4(vITS);
227
228 //     fSupgeom->SPDCone(vITS);
229 //     fSupgeom->SPDThermalSheald(vITS);
230 //     fSupgeom->SDDCone(vITS);
231 //     fSupgeom->SSDCone(vITS);
232 //     fSupgeom->ServicesCableSupport(vITS);
233
234 }
235 //______________________________________________________________________
236 void AliITSv11::CreateMaterials(){
237     // Create Standard ITS Materials
238     // Inputs:
239     //  none.
240     // Outputs:
241     //  none.
242     // Return:
243     // none.
244
245     
246     //
247     fSPDgeom->AliITSv11Geometry::CreateDefaultMaterials();
248     // Detector specific material definistions
249     fSPDgeom->CreateMaterials();
250     fSDDgeom->CreateMaterials();
251     fSSDgeom->CreateMaterials();
252     fSupgeom->CreateMaterials();
253 }
254 /*
255 //______________________________________________________________________
256 void AliITSv11::InitAliITSgeom(){
257   //
258   // Fill fITSgeom with the 3 sub-detector geometries
259   //
260
261   if (gGeoManager) gGeoManager->Export("geometry.root");
262
263     const Int_t knlayers = 6;
264     const Int_t kndeep = 3;
265     const AliITSDetector kidet[knlayers]={kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
266     const TString knames[knlayers] = {
267       "AliITSv11:spd missing",  // lay=1
268       "AliITSv11:spd missing",  // lay=2
269       "/ALIC_1/ITSV_1/ITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_%d", // lay=3
270       "/ALIC_1/ITSV_1/ITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_%d", // lay=4
271       "AliITSv11:ssd missing",  // lay=5
272       "AliITSv11:ssd missing"   // lay=6
273     };
274
275     const Int_t kitsGeomTreeCopys[knlayers][kndeep]= {{10, 2, 4},// lay=1
276                                                      {10, 4, 4}, // lay=2
277                                                      {14, 6, 1}, // lay=3
278                                                      {22, 8, 1}, // lay=4
279                                                      {34,22, 1}, // lay=5
280                                                      {38,25, 1}};// lay=6
281     Int_t       nlad[knlayers],ndet[knlayers];
282     Int_t       mod,lay,lad=0,det=0,i,j,k,cp0,cp1,cp2;
283     TString path,shapeName;
284     TGeoHMatrix materix;
285     Double_t trans[3]={3*0.0},rot[10]={9*0.0,1.0};
286     TArrayD shapePar;
287     TArrayF shapeParF;
288     Bool_t shapeDefined[3]={kFALSE,kFALSE,kFALSE};
289
290     AliDebug(1,"Reading Geometry transformation directly from Modler.");
291     mod = 0;
292     for(i=0;i<knlayers;i++){
293         k = 1;
294         for(j=0;j<kndeep;j++) if(kitsGeomTreeCopys[i][j]!=0)
295             k *= TMath::Abs(kitsGeomTreeCopys[i][j]);
296         mod += k;
297     } // end for i
298
299     SetITSgeom(0);
300     nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
301     ndet[0]= 4;ndet[1]= 4;ndet[2]= 6;ndet[3]= 8;ndet[4]=22;ndet[5]=25;
302     AliITSgeom* geom = new AliITSgeom(0,6,nlad,ndet,mod);
303     SetITSgeom(geom);
304     mod = 0;
305     for(lay=1;lay<=knlayers;lay++){
306
307         for(cp0=0; cp0<kitsGeomTreeCopys[lay-1][0]; cp0++){
308             for(cp1=0; cp1<kitsGeomTreeCopys[lay-1][1]; cp1++){
309                 for(cp2=1; cp2<=kitsGeomTreeCopys[lay-1][2]; cp2++){
310
311                     path.Form(knames[lay-1].Data(),
312                               cp0,cp1,cp2);
313                     switch (lay){
314                     case 1:{
315                         det = cp2;
316                         lad = cp1+2*(cp0-1);
317                     }break;
318                     case 2:{
319                         det = cp2;
320                         lad = cp1+4*(cp0-1);
321                     } break;
322                     case 3: case 4: case 5: case 6:{
323                         det = cp1;
324                         lad = cp0;
325                     } break;
326                     } // end switch
327                          //AliInfo(Form("path=%s lay=%d lad=%d det=%d",
328                          //             path.Data(),lay,lad,det));
329                     gMC->GetTransformation(path.Data(),materix);
330                     gMC->GetShape(path.Data(),shapeName,shapePar);
331                     shapeParF.Set(shapePar.GetSize());
332                     for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
333                     geom->CreateMatrix(mod,lay,lad,det,kidet[lay-1],trans,rot);
334                     geom->SetTrans(mod,materix.GetTranslation());
335                     geom->SetRotMatrix(mod,materix.GetRotationMatrix());
336                     geom->GetGeomMatrix(mod)->SetPath(path.Data());
337                     switch (lay){
338                     case 1: case 2:
339                         if(!shapeDefined[kSPD]){
340                         geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(
341                                 shapeParF.GetSize(),shapeParF.GetArray()));
342                         shapeDefined[kSPD] = kTRUE;
343                     }break;
344                     case 3: case 4:
345                         if(!shapeDefined[kSDD]){
346                         geom->ReSetShape(kSDD,new AliITSgeomSDD256(
347                                 shapeParF.GetSize(),shapeParF.GetArray()));
348                         shapeDefined[kSDD] = kTRUE;
349                     }break;
350                     case 5: case 6:
351                         if(!shapeDefined[kSSD]){
352                         geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(
353                                 shapeParF.GetSize(),shapeParF.GetArray()));
354                         shapeDefined[kSSD] = kTRUE;
355                     }break;
356                     default:{
357                     }break;
358                     } // end switch
359                     mod++;
360                 } /// end for cp2
361             } // end for cp1
362         } // end for cp0
363     } // end for lay
364
365 //   fSDDgeom->ExportSensorGeometry(GetITSgeom(), +3, 0);  //SDD
366 }
367 */
368 //______________________________________________________________________
369 void AliITSv11::Init(){
370   //
371   //     Initialise the ITS after it has been created.
372   //
373
374   //AliInfo(Form("Minor version %d",fMinorVersion));
375     //
376     UpdateInternalGeometry();
377     AliITS::Init();
378     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
379
380     //
381 /*
382     if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
383     if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
384     if(GetITSgeom()!=0) SetITSgeom(0x0);
385     AliITSgeom* geom = new AliITSgeom();
386     SetITSgeom(geom);
387     if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
388     else this->InitAliITSgeom();
389     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
390     AliITS::Init();
391 */    //
392 }
393
394 // //______________________________________________________________________
395 // void AliITSv11::SetDefaults(){
396 //   //
397 //   // Set response ans segmentation models for SPD, SDD and SSD
398 //   //
399 //      const Float_t kconv = 1.0e+04; // convert cm to microns
400 //     AliInfo("Called");    
401
402 //     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
403 //     fDetTypeSim->SetITSgeom(GetITSgeom());
404   
405 //     AliITSgeomSPD  *s0;
406 //     AliITSgeomSDD  *s1;
407 //     AliITSgeomSSD  *s2;
408 //     Int_t i;
409 //     Float_t bx[256],bz[280];
410    
411 //     fDetTypeSim->ResetCalibrationArray();
412 //     fDetTypeSim->ResetSegmentation();
413 //     fDetTypeSim->SetDefaults();
414     
415 //     //SPD
416 //     s0 = (AliITSgeomSPD*) GetITSgeom()->GetShape(kSPD);// Get shape info. Do it this way for now.
417 //     AliITSsegmentationSPD* seg0 = (AliITSsegmentationSPD*)fDetTypeSim->GetSegmentationModel(0);
418 //     seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
419 //                   s0->GetDz()*2.*kconv, // for now.
420 //                   s0->GetDy()*2.*kconv); // x,z,y full width in microns.
421 //     seg0->SetNPads(256,160);// Number of Bins in x and z
422 //     for(i=000;i<256;i++) bx[i] =  50.0; // in x all are 50 microns.
423 //     for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
424 //     for(i=160;i<280;i++) bz[i] =   0.0; // Outside of detector.
425 //     bz[ 31] = bz[ 32] = 625.0; // first chip boundry
426 //     bz[ 63] = bz[ 64] = 625.0; // first chip boundry
427 //     bz[ 95] = bz[ 96] = 625.0; // first chip boundry
428 //     bz[127] = bz[128] = 625.0; // first chip boundry
429 //     bz[160] = 425.0; // Set so that there is no zero pixel size for fNz.
430 //     seg0->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
431 //     SetSegmentationModel(kSPD,seg0);
432 //     // set digit and raw cluster classes to be used
433 //     const char *kData0=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSPD()))->DataType();
434 //     if (strstr(kData0,"real")) fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigit");
435 //     else fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
436
437
438
439 //     // SDD
440 //     s1 = (AliITSgeomSDD*) GetITSgeom()->GetShape(kSDD);// Get shape info. Do it this way for now.
441 //     AliITSsegmentationSDD* seg1 = (AliITSsegmentationSDD*)fDetTypeSim->GetSegmentationModel(1);
442 //     seg1->SetDetSize(s1->GetDx()*kconv, // base this on AliITSgeomSDD
443 //                   s1->GetDz()*2.*kconv, // for now.
444 //                   s1->GetDy()*2.*kconv); // x,z,y full width in microns.
445 //     seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
446 //     SetSegmentationModel(kSDD,seg1);
447 //     const char *kData1=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD()))->DataType();
448 //     AliITSCalibrationSDD* rsp = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD());
449 //     const char *kopt=rsp->GetZeroSuppOption();
450 //     if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
451 //      fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigit");
452 //     } else fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
453
454
455 //     // SSD
456 //     s2 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);// Get shape info. Do it this way for now.
457 //     AliITSsegmentationSSD* seg2 = (AliITSsegmentationSSD*)fDetTypeSim->GetSegmentationModel(2);
458 //     seg2->SetDetSize(s2->GetDx()*2.*kconv, // base this on AliITSgeomSSD
459 //                   s2->GetDz()*2.*kconv, // for now.
460 //                   s2->GetDy()*2.*kconv); // x,z,y full width in microns.
461 //     seg2->SetPadSize(95.,0.); // strip x pitch in microns
462 //     seg2->SetNPads(768,0); // number of strips on each side.
463 //     seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
464 //     seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
465 //     seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
466 //     SetSegmentationModel(kSSD,seg2); 
467 //         const char *kData2=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSSD()))->DataType();
468 //     if(strstr(kData2,"real") ) fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigit");
469 //     else fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigitSSD");
470 //     if(fgkNTYPES>3){
471 //      Warning("SetDefaults",
472 //              "Only the four basic detector types are initialised!");
473 //     }// end if
474
475     
476 //     return;
477 // }
478
479
480 //______________________________________________________________________
481 void AliITSv11::SetDefaults(){
482   //
483   // Set response and segmentation models for SPD, SDD and SSD
484   //
485      const Float_t kconv = 1.0e+04; // convert cm to microns
486     AliInfo("Called");    
487
488 //     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
489 //     fDetTypeSim->SetITSgeom(GetITSgeom());
490     if(!fDetTypeSim) {
491       Warning("SetDefaults","Error fDetTypeSim not defined");
492       return;
493     }
494   
495     AliITSgeomSPD  *s0;
496     AliITSgeomSDD  *s1;
497     AliITSgeomSSD  *s2;
498     Int_t i;
499     Float_t bx[256],bz[280];
500    
501     fDetTypeSim->ResetCalibrationArray();
502     fDetTypeSim->ResetSegmentation();
503     fDetTypeSim->SetDefaults();
504     
505     //SPD
506     s0 = (AliITSgeomSPD*) GetITSgeom()->GetShape(kSPD);// Get shape info. Do it this way for now.
507     AliITSsegmentationSPD* seg0 = (AliITSsegmentationSPD*)fDetTypeSim->GetSegmentationModel(0);
508     seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
509                      s0->GetDz()*2.*kconv, // for now.
510                      s0->GetDy()*2.*kconv); // x,z,y full width in microns.
511     seg0->SetNPads(256,160);// Number of Bins in x and z
512     for(i=000;i<256;i++) bx[i] =  50.0; // in x all are 50 microns.
513     for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
514     for(i=160;i<280;i++) bz[i] =   0.0; // Outside of detector.
515     bz[ 31] = bz[ 32] = 625.0; // first chip boundry
516     bz[ 63] = bz[ 64] = 625.0; // first chip boundry
517     bz[ 95] = bz[ 96] = 625.0; // first chip boundry
518     bz[127] = bz[128] = 625.0; // first chip boundry
519     bz[160] = 425.0; // Set so that there is no zero pixel size for fNz.
520     seg0->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
521     SetSegmentationModel(kSPD,seg0);
522     // set digit and raw cluster classes to be used
523     const char *kData0=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSPD()))->DataType();
524     if (strstr(kData0,"real")) fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigit");
525     else fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
526
527
528
529     // SDD
530     s1 = (AliITSgeomSDD*) GetITSgeom()->GetShape(kSDD);// Get shape info. Do it this way for now.
531     AliITSsegmentationSDD* seg1 = (AliITSsegmentationSDD*)fDetTypeSim->GetSegmentationModel(1);
532     seg1->SetDetSize(s1->GetDx()*kconv, // base this on AliITSgeomSDD
533                      s1->GetDz()*2.*kconv, // for now.
534                      s1->GetDy()*2.*kconv); // x,z,y full width in microns.
535     seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
536     SetSegmentationModel(kSDD,seg1);
537     const char *kData1=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD()))->DataType();
538     AliITSCalibrationSDD* rsp = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD());
539     const char *kopt=rsp->GetZeroSuppOption();
540     if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
541         fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigit");
542     } else fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
543
544
545     // SSD
546     s2 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);// Get shape info. Do it this way for now.
547     AliITSsegmentationSSD* seg2 = (AliITSsegmentationSSD*)fDetTypeSim->GetSegmentationModel(2);
548     seg2->SetDetSize(s2->GetDx()*2.*kconv, // base this on AliITSgeomSSD
549                      s2->GetDz()*2.*kconv, // for now.
550                      s2->GetDy()*2.*kconv); // x,z,y full width in microns.
551     seg2->SetPadSize(95.,0.); // strip x pitch in microns
552     seg2->SetNPads(768,0); // number of strips on each side.
553     seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
554     seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
555     seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
556     SetSegmentationModel(kSSD,seg2); 
557         const char *kData2=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSSD()))->DataType();
558     if(strstr(kData2,"real") ) fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigit");
559     else fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigitSSD");
560     if(fgkNTYPES>3){
561         Warning("SetDefaults",
562                 "Only the four basic detector types are initialised!");
563     }// end if
564
565     
566     return;
567 }
568
569
570
571
572
573 //______________________________________________________________________
574 void AliITSv11::DrawModule() const{
575
576 }
577
578 // //______________________________________________________________________
579 // void AliITSv11::StepManager(){
580 //   //
581 //   //    Called for every step in the ITS, then calles the AliITShit class
582 //   // creator with the information to be recoreded about that hit.
583 //   //
584 //     Int_t         copy, id;
585 //     TLorentzVector position, momentum;
586 //     static TLorentzVector position0;
587 //     static Int_t stat0=0;
588
589 //     if(!(this->IsActive())){
590 //      return;
591 //     } // end if !Active volume.
592
593 //     if(!(gMC->TrackCharge())) return;
594
595 //     id=gMC->CurrentVolID(copy);
596
597 //     Bool_t sensvol = kFALSE;
598 //     for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
599 //     if(sensvol && (gMC->IsTrackExiting())){
600 //      copy = fTrackReferences->GetEntriesFast();
601 //      TClonesArray &lTR = *fTrackReferences;
602 //      // Fill TrackReference structure with this new TrackReference.
603 //      new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
604 //     } // if Outer ITS mother Volume
605
606
607 //     Int_t   copy1,copy2;  
608 //     Int_t   vol[5];
609 //     TClonesArray &lhits = *fHits;
610 //     //
611 //     // Track status
612 //     vol[3] = 0;
613 //     vol[4] = 0;
614 //     if(gMC->IsTrackInside())      vol[3] +=  1;
615 //     if(gMC->IsTrackEntering())    vol[3] +=  2;
616 //     if(gMC->IsTrackExiting())     vol[3] +=  4;
617 //     if(gMC->IsTrackOut())         vol[3] +=  8;
618 //     if(gMC->IsTrackDisappeared()) vol[3] += 16;
619 //     if(gMC->IsTrackStop())        vol[3] += 32;
620 //     if(gMC->IsTrackAlive())       vol[3] += 64;
621 //     //
622 //     // Fill hit structure.
623 //     if(!(gMC->TrackCharge())) return;
624 //     //
625 //     // Only entering charged tracks
626 //     if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
627 //      vol[0] = 1;
628 //      id = gMC->CurrentVolOffID(2,copy);
629 //      //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
630 //      vol[1] = copy;
631 //      gMC->CurrentVolOffID(3,copy1);
632 //      //ladder copy in the module   = 1<->2  (I10A < I12A)
633 //      gMC->CurrentVolOffID(4,copy2);
634 //      //module copy in the layer    = 1<->10 (I12A < IT12)
635 //      vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
636 //     } else if(id == fIdSens[1]){
637 //      vol[0] = 2;
638 //      id = gMC->CurrentVolOffID(2,copy);
639 //      //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
640 //      vol[1] = copy;
641 //      gMC->CurrentVolOffID(3,copy1);
642 //      //ladder copy in the module   = 1<->4  (I20A < I12A)
643 //      gMC->CurrentVolOffID(4,copy2);
644 //      //module copy in the layer    = 1<->10 (I12A < IT12)
645 //      vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
646 //     } else if(id == fIdSens[2]){
647 //      vol[0] = 3;
648 //      id = gMC->CurrentVolOffID(1,copy);
649 //      //detector copy in the ladder = 1<->6  (ITS3 < I302 < I004)
650 //      vol[1] = copy;
651 //      id = gMC->CurrentVolOffID(2,copy);
652 //      //ladder copy in the layer    = 1<->14 (I004 < IT34)
653 //      vol[2] = copy;
654 //     } else if(id == fIdSens[3]){
655 //      vol[0] = 4;
656 //      id = gMC->CurrentVolOffID(1,copy);
657 //      //detector copy in the ladder = 1<->8  (ITS4 < I402 < I005)
658 //      vol[1] = copy;
659 //      id = gMC->CurrentVolOffID(2,copy);
660 //      //ladder copy in the layer    = 1<->22 (I005 < IT34))
661 //      vol[2] = copy;
662 //     }else if(id == fIdSens[4]){
663 //      vol[0] = 5;
664 //      id = gMC->CurrentVolOffID(1,copy);
665 //      //detector copy in the ladder = 1<->22  (ITS5 < I562 < I565)
666 //      vol[1] = copy;
667 //      id = gMC->CurrentVolOffID(2,copy);
668 //      //ladder copy in the layer    = 1<->34 (I565 < IT56)
669 //      vol[2] = copy;
670 //     }else if(id == fIdSens[5]){
671 //      vol[0] = 6;
672 //      id = gMC->CurrentVolOffID(1,copy);
673 //      //detector copy in the ladder = 1<->25  (ITS6 < I566 < I569)
674 //      vol[1] = copy;
675 //      id = gMC->CurrentVolOffID(2,copy);
676 //      //ladder copy in the layer = 1<->38 (I569 < IT56)
677 //      vol[2] = copy;
678 //     } else {
679 //      return; // not an ITS volume?
680 //     } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
681 //     //
682 //     gMC->TrackPosition(position);
683 //     gMC->TrackMomentum(momentum);
684 //     vol[4] = stat0;
685 //     if(gMC->IsTrackEntering()){
686 //      position0 = position;
687 //      stat0 = vol[3];
688 //      return;
689 //     } // end if IsEntering
690 //     // Fill hit structure with this new hit.
691     
692 //     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
693 //                                 gMC->Edep(),gMC->TrackTime(),position,
694 //                                 position0,momentum);
695
696 //     position0 = position;
697 //     stat0 = vol[3];
698
699 //     return;
700 // }
701
702
703 //______________________________________________________________________
704 void AliITSv11::StepManager(){
705   //
706   //    Called for every step in the ITS, then calles the AliITShit class
707   // creator with the information to be recoreded about that hit.
708   //
709     Int_t         copy, id;
710     TLorentzVector position, momentum;
711     static TLorentzVector position0;
712     static Int_t stat0=0;
713
714     if(!(this->IsActive())){
715         return;
716     } // end if !Active volume.
717
718     if(!(gMC->TrackCharge())) return;
719
720     id=gMC->CurrentVolID(copy);
721
722     Bool_t sensvol = kFALSE;
723     for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
724     if(sensvol && (gMC->IsTrackExiting())){
725         AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
726     } // if Outer ITS mother Volume
727
728
729     Int_t   copy1,copy2;  
730     Int_t   vol[5];
731     TClonesArray &lhits = *fHits;
732     //
733     // Track status
734     vol[3] = 0;
735     vol[4] = 0;
736     if(gMC->IsTrackInside())      vol[3] +=  1;
737     if(gMC->IsTrackEntering())    vol[3] +=  2;
738     if(gMC->IsTrackExiting())     vol[3] +=  4;
739     if(gMC->IsTrackOut())         vol[3] +=  8;
740     if(gMC->IsTrackDisappeared()) vol[3] += 16;
741     if(gMC->IsTrackStop())        vol[3] += 32;
742     if(gMC->IsTrackAlive())       vol[3] += 64;
743     //
744     // Fill hit structure.
745     if(!(gMC->TrackCharge())) return;
746
747     // Only entering charged tracks
748     if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
749         vol[0] = 1;
750         id = gMC->CurrentVolOffID(2,copy);
751         //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
752         vol[1] = copy;
753         gMC->CurrentVolOffID(3,copy1);
754         //ladder copy in the module   = 1<->2  (I10A < I12A)
755         gMC->CurrentVolOffID(4,copy2);
756         //module copy in the layer    = 1<->10 (I12A < IT12)
757         vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
758
759     } else if(id == fIdSens[1]){
760         vol[0] = 2;
761         id = gMC->CurrentVolOffID(2,copy);
762         //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
763         vol[1] = copy;
764         gMC->CurrentVolOffID(3,copy1);
765         //ladder copy in the module   = 1<->4  (I20A < I12A)
766         gMC->CurrentVolOffID(4,copy2);
767         //module copy in the layer    = 1<->10 (I12A < IT12)
768         vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
769
770     } else if(id == fIdSens[2]){
771         vol[0] = 3;
772         id = gMC->CurrentVolOffID(1,copy);
773         //detector copy in the ladder = 1<->6  (ITS3 < I302 < I004)
774         vol[1] = copy;
775         id = gMC->CurrentVolOffID(2,copy);
776         //ladder copy in the layer    = 1<->14 (I004 < IT34)
777         vol[2] = copy;
778
779     } else if(id == fIdSens[3]){
780         vol[0] = 4;
781         id = gMC->CurrentVolOffID(1,copy);
782         //detector copy in the ladder = 1<->8  (ITS4 < I402 < I005)
783         vol[1] = copy;
784         id = gMC->CurrentVolOffID(2,copy);
785         //ladder copy in the layer    = 1<->22 (I005 < IT34))
786         vol[2] = copy;
787
788     }else if(id == fIdSens[4]){
789         vol[0] = 5;
790         id = gMC->CurrentVolOffID(1,copy);
791         //detector copy in the ladder = 1<->22  (ITS5 < I562 < I565)
792         vol[1] = copy;
793         id = gMC->CurrentVolOffID(2,copy);
794         //ladder copy in the layer    = 1<->34 (I565 < IT56)
795         vol[2] = copy;
796
797     }else if(id == fIdSens[5]){
798         vol[0] = 6;
799         id = gMC->CurrentVolOffID(1,copy);
800         //detector copy in the ladder = 1<->25  (ITS6 < I566 < I569)
801         vol[1] = copy;
802         id = gMC->CurrentVolOffID(2,copy);
803         //ladder copy in the layer = 1<->38 (I569 < IT56)
804         vol[2] = copy;
805     } else {
806         return; // not an ITS volume?
807     } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
808     //
809     gMC->TrackPosition(position);
810     gMC->TrackMomentum(momentum);
811     vol[4] = stat0;
812     if(gMC->IsTrackEntering()){
813         position0 = position;
814         stat0 = vol[3];
815         return;
816     } // end if IsEntering
817     // Fill hit structure with this new hit.
818     
819     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
820                                    gMC->Edep(),gMC->TrackTime(),position,
821                                    position0,momentum);
822
823     position0 = position;
824     stat0 = vol[3];
825
826     return;
827 }
828