]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSvSPD02.cxx
segmentation warning removed
[u/mrichter/AliRoot.git] / ITS / AliITSvSPD02.cxx
index 245cf22b6ec2ca4ba38d81bcdf00aa8346472916..00c77b38ee69077acbfa1892bd3379fb8eb8a7cb 100644 (file)
 /* $Id$ */
 
 #include <Riostream.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <TMath.h>
 #include <TGeometry.h>
 #include <TNode.h>
-#include <TTUBE.h>
-#include <TTUBS.h>
-#include <TPCON.h>
-#include <TFile.h>    // only required for Tracking function?
-#include <TCanvas.h>
-#include <TObjArray.h>
 #include <TLorentzVector.h>
-#include <TObjString.h>
 #include <TClonesArray.h>
 #include <TBRIK.h>
-#include <TSystem.h>
 
 #include "AliRun.h"
 #include "AliMagF.h"
-#include "AliConst.h"
 #include "AliITSGeant3Geometry.h"
 #include "AliTrackReference.h"
 #include "AliITShit.h"
@@ -43,7 +32,6 @@
 #include "AliITSvSPD02.h"
 #include "AliITSgeom.h"
 #include "AliITSgeomSPD.h"
-#include "AliITSgeomSDD.h"
 #include "AliITSgeomSSD.h"
 #include "AliITSDetType.h"
 #include "AliITSresponseSPD.h"
 #include "AliITSsimulationSPD.h"
 #include "AliITSsimulationSDD.h"
 #include "AliITSsimulationSSD.h"
-#include "AliITSClusterFinderSPD.h"
-#include "AliITSClusterFinderSDD.h"
-#include "AliITSClusterFinderSSD.h"
-
+#include "AliMC.h"
 
+///////////////////////////////////////////////////////////////////////
+// Step manager and 
+// geometry class
+// for the ITS 
+// SPD test beam
+// geometry of summer 2002
+// 
+///////////////////////////////////////////////////////////////////////
 ClassImp(AliITSvSPD02)
 
 //______________________________________________________________________
@@ -83,16 +76,18 @@ AliITSvSPD02::AliITSvSPD02() {
     fGeomDetIn    = kFALSE; // Don't Read .det file
     fMajorVersion = IsVersion();
     fMinorVersion = -1;
+    fGeomNumber   = 2002; // default value
     for(i=0;i<60;i++) fRead[i] = '\0';
     for(i=0;i<60;i++) fWrite[i] = '\0';
     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
 }
 //______________________________________________________________________
-AliITSvSPD02::AliITSvSPD02(const char *title) : AliITS("ITS", title){
+AliITSvSPD02::AliITSvSPD02(const char *title,Int_t gn) : AliITS("ITS", title){
     ////////////////////////////////////////////////////////////////////////
     //    Standard constructor for the ITS SPD testbeam 2002 version 1.
     // Inputs:
     //    const char *title    title for this ITS geometry.
+    //    Int_t      gn        Geometry version number (year) default 2002.
     // Outputs:
     //    none.
     // Return:
@@ -100,6 +95,7 @@ AliITSvSPD02::AliITSvSPD02(const char *title) : AliITS("ITS", title){
     ////////////////////////////////////////////////////////////////////////
     Int_t i;
 
+    fGeomNumber = gn;
     fIdN = 2;
     fIdName = new TString[fIdN];
     fIdName[0] = "IMBS";
@@ -187,8 +183,40 @@ void AliITSvSPD02::BuildGeometry(){
     //    none.
     ////////////////////////////////////////////////////////////////////////
     // Get the top alice volume.
-    TNode *ALIC = gAlice->GetGeometry()->GetNode("alice");
-    ALIC->cd();
+
+    switch (fGeomNumber){
+    case 2002:
+        BuildGeometry2002();
+        break;
+    default:
+        BuildGeometry2002();
+        break;
+    } // end switch
+}
+//______________________________________________________________________
+void AliITSvSPD02::BuildGeometry2002(){
+    ////////////////////////////////////////////////////////////////////////
+    //    Geometry builder for the ITS SPD test beam 2002 version 1.
+    //    ALIC    ALICE Mother Volume
+    //     |- ITSV     ITS Mother Volume
+    //         |- IDET       Detector under Test
+    //         |   |- ITS0       SPD Si Chip
+    //         |   |  |- ITST      SPD Sensitivve Volume
+    //         |   |- IPC0 *5    Readout chip
+    //         |- ITEL *4    SPD Telescope
+    //             |- IMB0       SPD Si Chip
+    //             |   |- IMBS     SPD Sensitive volume
+    //             |- ICMB       Chip MiniBus.
+    // Inputs:
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    none.
+    ////////////////////////////////////////////////////////////////////////
+    // Get the top alice volume.
+    TNode *aALIC = gAlice->GetGeometry()->GetNode("alice");
+    aALIC->cd();
 
     // Define ITS Mother Volume
     Float_t data[3];
@@ -200,34 +228,35 @@ void AliITSvSPD02::BuildGeometry(){
     data[0] = 10.0;
     data[1] = 50.0;
     data[2] = 100.0;
-    TBRIK *ITSVshape = new TBRIK("ITSVshape","ITS Logical Mother Volume","Air",
-                                data[0],data[1],data[2]);
-    TNode *ITSV = new TNode("ITSV","ITS Mother Volume",ITSVshape,
+    TBRIK *iITSVshape = new TBRIK("ITSVshape",
+                                  "ITS Logical Mother Volume","Air",
+                                  data[0],data[1],data[2]);
+    TNode *iITSV = new TNode("ITSV","ITS Mother Volume",iITSVshape,
                            0.0,0.0,0.0,0,0);
-    ITSV->cd(); // set ourselve into ITSV subvolume of ALIC
+    iITSV->cd(); // set ourselve into ITSV subvolume of aALIC
 
     // SPD part of telescope (MiniBuS)
     data[0] = 0.705;
     data[1] = 0.5*ddettelescope;
     data[2] = 3.536;
-    TBRIK *IMB0shape = new TBRIK("IMB0shape","SPD wafer","Si",
+    TBRIK *iIMB0shape = new TBRIK("IMB0shape","SPD wafer","Si",
                                 data[0],data[1],data[2]);
     Float_t detMiniBusX,detMiniBusY,detMiniBusZ;
     data[0] = detMiniBusX = 0.64;
     data[1] = detMiniBusY = 0.5*ddettelescope;
     data[2] = detMiniBusZ = 3.48;
-    TBRIK *IMBSshape = new TBRIK("IMBSshape","SPD Sensitive volume","Si",
+    TBRIK *iIMBSshape = new TBRIK("IMBSshape","SPD Sensitive volume","Si",
                                 data[0],data[1],data[2]);
     Float_t chipMiniBusX,chipMiniBusY,chipMiniBusZ;
     data[0] = chipMiniBusX = 0.793;
     data[1] = chipMiniBusY = 0.5*dchipMiniBus;
     data[2] = chipMiniBusZ = 0.68;
-    TBRIK *ICMBshape = new TBRIK("ICMBshape","chip Minibus","Si",
+    TBRIK *iICMBshape = new TBRIK("ICMBshape","chip Minibus","Si",
                                 data[0],data[1],data[2]);
     data[0] = TMath::Max(detMiniBusX,chipMiniBusX);
     data[1] = detMiniBusY+chipMiniBusY;
     data[2] = TMath::Max(detMiniBusZ,chipMiniBusZ);
-    TBRIK *ITELshape = new TBRIK("ITELshape","ITELshape","Air",
+    TBRIK *iITELshape = new TBRIK("ITELshape","ITELshape","Air",
                                 data[0],data[1],data[2]);
 
     // SPD under test
@@ -235,23 +264,23 @@ void AliITSvSPD02::BuildGeometry(){
     data[0] = 0.705;
     data[1] = ddettest;
     data[2] = 3.536;
-    TBRIK *ITS0shape = new TBRIK("ITS0shape","SPD wafer","Si",
+    TBRIK *iITS0shape = new TBRIK("ITS0shape","SPD wafer","Si",
                                 data[0],data[1],data[2]); // contains detector
     data[0] = spdX = 0.64;
     data[1] = spdY = ddettest;
     data[2] = spdZ = 3.48;
-    TBRIK *ITSTshape = new TBRIK("ITSTshape","SPD sensitive volume","Si",
+    TBRIK *iITSTshape = new TBRIK("ITSTshape","SPD sensitive volume","Si",
                                 data[0],data[1],data[2]);
     // ITS0 with no translation and unit rotation matrix.
     data[0] = spdchipX = 0.793;
     data[1] = spdchipY = dchiptest;
     data[2] = spdchipZ = 0.68;
-    TBRIK *IPC0shape = new TBRIK("IPC0shape","Readout Chips","Si",
+    TBRIK *iIPC0shape = new TBRIK("IPC0shape","Readout Chips","Si",
                                 data[0],data[1],data[2]); // chip under test
     data[0] = TMath::Max(spdchipX,spdX);
     data[1] = spdY+spdchipY;
     data[2] = TMath::Max(spdchipZ,spdZ);
-    TBRIK *IDETshape = new TBRIK("IDETshape","Detector Under Test","Air",
+    TBRIK *iIDETshape = new TBRIK("IDETshape","Detector Under Test","Air",
                                 data[0],data[1],data[2]);
     // Place volumes in geometry
     Int_t i,j;
@@ -260,44 +289,44 @@ void AliITSvSPD02::BuildGeometry(){
     pz[1] = pz[0]+2.0;
     pz[2] = pz[1]+38.0+spdY+spdchipY+34.5;
     pz[3] = pz[2]+2.0;
-    TNode *ITEL[4],*ICMB[4],*IMB0[4],*IMBS[4];
-    TNode *IDET = new TNode("IDET","Detector Under Test",IDETshape,
+    TNode *iITEL[4],*iICMB[4],*iIMB0[4],*iIMBS[4];
+    TNode *iIDET = new TNode("IDET","Detector Under Test",iIDETshape,
                            0.0,0.0,pz[1]+38.0,r0,0);
-    IDET->cd();
-    TNode *ITS0 = new TNode("ITS0","SPD Chip",ITS0shape,
-                           0.0,IDETshape->GetDy()-spdY,0.0,0,0);
-    TNode *IPC0[5];
+    iIDET->cd();
+    TNode *iITS0 = new TNode("ITS0","SPD Chip",iITS0shape,
+                           0.0,iIDETshape->GetDy()-spdY,0.0,0,0);
+    TNode *iIPC0[5];
     for(i=0;i<5;i++) { //place readout chips on the back of SPD chip under test
        sprintf(name,"IPC0%d",i);
        sprintf(title,"Readout chip #%d",i+1);
        j = i-2;
-       IPC0[i] = new TNode(name,title,IPC0shape,
-                           0.0,spdchipY-IDETshape->GetDy(),
+       iIPC0[i] = new TNode(name,title,iIPC0shape,
+                           0.0,spdchipY-iIDETshape->GetDy(),
                            j*2.0*spdchipZ+j*0.25*(spdZ-5.*spdchipZ),0,0);
     } // end for i
-    ITS0->cd();
-    TNode *ITST = new TNode("ITST","SPD sensitive volume",ITSTshape,
+    iITS0->cd();
+    TNode *iITST = new TNode("ITST","SPD sensitive volume",iITSTshape,
                            0.0,0.0,0.0,0,0);
     for(Int_t i=0;i<4;i++){
-       ITSV->cd();
+       iITSV->cd();
        sprintf(name,"ITEL%d",i);
        sprintf(title,"Test beam telescope element #%d",i+1);
-       ITEL[i] = new TNode(name,title,ITELshape,px,py,pz[i],r0,0);
-       ITEL[i]->cd();
-       ICMB[i] = new TNode("ICMB","Chip MiniBus",ICMBshape,
-                           0.0,-ITELshape->GetDy()+detMiniBusY,0.0,0,0);
-       IMB0[i] = new TNode("IMB0","Chip MiniBus",IMB0shape,
-                           0.0, ITELshape->GetDy()-detMiniBusY,0.0,0,0);
-       IMB0[i]->cd();
-       IMBS[i] = new TNode("IMBS","IMBS",IMBSshape,0.0,0.0,0.0,0,0);
+       iITEL[i] = new TNode(name,title,iITELshape,px,py,pz[i],r0,0);
+       iITEL[i]->cd();
+       iICMB[i] = new TNode("ICMB","Chip MiniBus",iICMBshape,
+                           0.0,-iITELshape->GetDy()+detMiniBusY,0.0,0,0);
+       iIMB0[i] = new TNode("IMB0","Chip MiniBus",iIMB0shape,
+                           0.0, iITELshape->GetDy()-detMiniBusY,0.0,0,0);
+       iIMB0[i]->cd();
+       iIMBS[i] = new TNode("IMBS","IMBS",iIMBSshape,0.0,0.0,0.0,0,0);
        // place IMBS inside IMB0 with no translation and unit rotation matrix.
     } // end for i
-    ALIC->cd();
-    ITST->SetLineColor(kYellow);
-    fNodes->Add(ITST);
+    aALIC->cd();
+    iITST->SetLineColor(kYellow);
+    fNodes->Add(iITST);
     for(i=0;i<4;i++){
-       IMBS[i]->SetLineColor(kGreen);
-       fNodes->Add(IMBS[i]);
+       iIMBS[i]->SetLineColor(kGreen);
+       fNodes->Add(iIMBS[i]);
     } // end for i
 }
 //______________________________________________________________________
@@ -321,6 +350,37 @@ void AliITSvSPD02::CreateGeometry(){
     // Return:
     //    none.
     ////////////////////////////////////////////////////////////////////////
+
+    switch (fGeomNumber){
+    case 2002:
+        CreateGeometry2002();
+        break;
+    default:
+        CreateGeometry2002();
+        break;
+    } // end switch
+}
+//______________________________________________________________________
+void AliITSvSPD02::CreateGeometry2002(){
+    ////////////////////////////////////////////////////////////////////////
+    //  This routine defines and Creates the geometry for version 1 of the ITS.
+    //    ALIC    ALICE Mother Volume
+    //     |- ITSV     ITS Mother Volume
+    //         |- IDET       Detector under Test
+    //         |   |- ITS0       SPD Si Chip
+    //         |   |  |- ITST      SPD Sensitivve Volume
+    //         |   |- IPC0 *5    Readout chip
+    //         |- ITEL *4    SPD Telescope
+    //             |- IMB0       SPD Si Chip
+    //             |   |- IMBS     SPD Sensitive volume
+    //             |- ICMB       Chip MiniBus.
+    // Inputs:
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    none.
+    ////////////////////////////////////////////////////////////////////////
     Float_t data[49];
     // Define media off-set
     Int_t *idtmed = fIdtmed->GetArray()+1; // array of media indexes
@@ -329,6 +389,7 @@ void AliITSvSPD02::CreateGeometry(){
     Float_t dchipMiniBus=750.0E-4,dchiptest=300.0E-4;
     Float_t yposition= 0.0;
 
+    if(gMC==0) return;
     // Define Rotation-reflextion Matrixes needed
     // 0 is the unit matrix
     AliMatrix(idrotm[0], 90.0,0.0, 0.0,0.0, 90.0,270.0);
@@ -433,6 +494,37 @@ void AliITSvSPD02::CreateMaterials(){
     // Return:
     //    none.
     /////////////////////////////////////////////////////////////////////////
+
+    switch (fGeomNumber){
+    case 2002:
+        CreateMaterials2002();
+        break;
+    default:
+        CreateMaterials2002();
+        break;
+    } // end switch
+}
+//______________________________________________________________________
+void AliITSvSPD02::CreateMaterials2002(){
+    ////////////////////////////////////////////////////////////////////////
+    //
+    // Create ITS SPD test beam materials
+    //     This function defines the default materials used in the Geant
+    // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
+    // AliITSvSPD02.
+    // In general it is automatically replaced by
+    // the CreatMaterials routine defined in AliITSv?. Should the function
+    // CreateMaterials not exist for the geometry version you are using this
+    // one is used. See the definition found in AliITSv5 or the other routine
+    // for a complete definition.
+    //
+    // Inputs:
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    none.
+    /////////////////////////////////////////////////////////////////////////
     Float_t tmaxfdSi = 0.1; // Degree
     Float_t stemaxSi = 0.0075; // cm
     Float_t deemaxSi = 0.1; // Fraction of particle's energy 0<deemax<=1
@@ -468,30 +560,56 @@ void AliITSvSPD02::InitAliITSgeom(){
     //    none.
     // Return:
     //    none.
+    const Int_t kltypess = 2;
+    const Int_t knlayers = 5;
+    const Int_t kndeep = 5;
+    Int_t itsGeomTreeNames[kltypess][kndeep],lnam[20],lnum[20];
+    Int_t nlad[knlayers],ndet[knlayers];
+    Double_t t[3],r[10];
+    Float_t  par[20],att[20];
+    Int_t    npar,natt,idshape,imat,imed;
+    AliITSGeant3Geometry *ig=0;
+    Int_t mod=0,typ=0,lay=0,lad=0,det=0,cpy=0,i=0,j=0,k=0;
+
+    if(gMC==0) {// No Monti Carlo to init. Default set fITSgeom by hand
+        if(fITSgeom!=0) delete fITSgeom;
+        nlad[0]=1;nlad[1]=1;nlad[2]=1;nlad[3]=1;nlad[4]=1;
+        ndet[0]=1;ndet[1]=1;ndet[2]=1;ndet[3]=1;ndet[4]=1;
+        fITSgeom = new AliITSgeom(0,knlayers,nlad,ndet,mod);
+        r[0] = 1.0; r[1] =  0.0; r[2] = 0.0;
+        r[3] = 0.0; r[4] =  0.0; r[5] = 1.0;
+        r[6] = 0.0; r[7] = -1.0; r[8] = 0.0; r[9] = 1.0; // not Unit.
+        Double_t tt[5][3]={{0.0,0.0,-37.9625}, // 0,0,P00Z+.5*chipMiniBusY
+                           {0.0,0.0,-35.9625}, // 0,0,P00Z+2+.5*chipMiniBusY
+                           {0.0,0.0,  2.0150}, // 0,0,P01Z+38+SPDchipY
+                           {0.0,0.0, 36.5375}, //0,0,PdetZ+34.5+.5*chipMiniBusY
+                           {0.0,0.0, 38.5375}};// 0,0,P00Z+2+.5*chipMiniBusY
+        for(mod=0;mod<5;mod++){
+            lay = 1;
+            lad = 1;
+            det = mod+1;
+            t[0] = tt[mod][0]; t[1] = tt[mod][1]; t[2] = tt[mod][2];
+            fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+            npar=3;par[0]=0.64;par[1]=0.5*300.0E-4;par[2]=3.48;
+            fITSgeom->ReSetShape(kSPD,new AliITSgeomSPD425Short(npar,par));
+        } // end for det
+        return;
+    } // end if gMC==0
     if(strcmp(gMC->GetName(),"TGeant3")) {
        Error("InitAliITSgeom",
                "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
        return;
     } // end if
     cout << "Reading Geometry transformation directly from Geant 3." << endl;
-    const Int_t ltypess = 2;
-    const Int_t nlayers = 5;
-    const Int_t ndeep = 5;
-    Int_t itsGeomTreeNames[ltypess][ndeep],lnam[20],lnum[20];
-    Int_t nlad[nlayers],ndet[nlayers];
-    Double_t t[3],r[10];
-    Float_t  par[20],att[20];
-    Int_t    npar,natt,idshape,imat,imed;
-    AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
-    Int_t mod,typ,lay,lad,det,cpy,i,j,k;
-    Char_t names[ltypess][ndeep][4];
-    Int_t itsGeomTreeCopys[ltypess][ndeep];
-    Char_t *namesA[ltypess][ndeep] = {
+    ig = new AliITSGeant3Geometry();
+    Char_t names[kltypess][kndeep][4];
+    Int_t itsGeomTreeCopys[kltypess][kndeep];
+    const char *namesA[kltypess][kndeep] = {
      {"ALIC","ITSV","ITEL","IMB0","IMBS"}, // lay=1
      {"ALIC","ITSV","IDET","ITS0","ITST"}};// Test SPD
-    Int_t itsGeomTreeCopysA[ltypess][ndeep]= {{1,1,4,1,1},// lay=1
+    Int_t itsGeomTreeCopysA[kltypess][kndeep]= {{1,1,4,1,1},// lay=1
                                              {1,1,1,1,1}};//lay=2 TestSPD
-    for(i=0;i<ltypess;i++)for(j=0;j<ndeep;j++){
+    for(i=0;i<kltypess;i++)for(j=0;j<kndeep;j++){
        for(k=0;k<4;k++) names[i][j][k] = namesA[i][j][k];
        itsGeomTreeCopys[i][j] = itsGeomTreeCopysA[i][j];
     } // end for i,j
@@ -500,17 +618,17 @@ void AliITSvSPD02::InitAliITSgeom(){
     // tree its self.
     cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
     for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
-    for(i=0;i<ltypess;i++)for(j=0;j<ndeep;j++) 
+    for(i=0;i<kltypess;i++)for(j=0;j<kndeep;j++) 
         strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4);
     // itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
     mod = 5;
     if(fITSgeom!=0) delete fITSgeom;
     nlad[0]=1;nlad[1]=1;nlad[2]=1;nlad[3]=1;nlad[4]=1;
     ndet[0]=1;ndet[1]=1;ndet[2]=1;ndet[3]=1;ndet[4]=1;
-    fITSgeom = new AliITSgeom(0,nlayers,nlad,ndet,mod);
-    for(typ=1;typ<=ltypess;typ++){
-       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[typ-1][j];
-       for(j=0;j<ndeep;j++) lnum[j] = itsGeomTreeCopys[typ-1][j];
+    fITSgeom = new AliITSgeom(0,knlayers,nlad,ndet,mod);
+    for(typ=1;typ<=kltypess;typ++){
+       for(j=0;j<kndeep;j++) lnam[j] = itsGeomTreeNames[typ-1][j];
+       for(j=0;j<kndeep;j++) lnum[j] = itsGeomTreeCopys[typ-1][j];
        lad = 1;
        det = 1;
        for(cpy=1;cpy<=itsGeomTreeCopys[typ-1][2];cpy++){
@@ -519,7 +637,7 @@ void AliITSvSPD02::InitAliITSgeom(){
            if(cpy>2 && typ==1) lay = cpy +1;
            if(typ==2) lay = 3;
            mod = lay-1;
-           ig->GetGeometry(ndeep,lnam,lnum,t,r,idshape,npar,natt,par,att,
+           ig->GetGeometry(kndeep,lnam,lnum,t,r,idshape,npar,natt,par,att,
                            imat,imed);
            fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
            if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
@@ -558,7 +676,8 @@ void AliITSvSPD02::Init(){
 //
     for(i=0;i<72;i++) cout << "*";
     cout << endl;
-    fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
+    if(gMC) fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
+    else fIDMother = 0;
 }
 //______________________________________________________________________
 void AliITSvSPD02::SetDefaults(){
@@ -583,6 +702,8 @@ void AliITSvSPD02::SetDefaults(){
     // Get shape info. Do it this way for now.
     s0 = (AliITSgeomSPD*) fITSgeom->GetShape(kSPD);
     AliITSresponse *resp0=new AliITSresponseSPD();
+    resp0->SetTemperature();
+    resp0->SetDistanceOverVoltage();
     SetResponseModel(kSPD,resp0);
     AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
     seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
@@ -622,7 +743,71 @@ void AliITSvSPD02::SetDefaults(){
     return;
 }
 //______________________________________________________________________
-void AliITSvSPD02::DrawModule(){
+void AliITSvSPD02::SetDefaultSimulation(){
+    // sets the default simulation.
+    // Inputs:
+    //      none.
+    // Outputs:
+    //      none.
+    // Return:
+    //      none.
+
+    AliITSDetType *iDetType;
+    AliITSsimulation *sim;
+    iDetType=DetType(kSPD);
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
+        AliITSsegmentation *seg0=
+            (AliITSsegmentation*)iDetType->GetSegmentationModel();
+        AliITSresponse *res0 = (AliITSresponse*)iDetType->GetResponseModel();
+        AliITSsimulationSPD *sim0=new AliITSsimulationSPD(seg0,res0);
+        SetSimulationModel(kSPD,sim0);
+    }else{ // simulation exists, make sure it is set up properly.
+        ((AliITSsimulationSPD*)sim)->Init(
+            (AliITSsegmentationSPD*) iDetType->GetSegmentationModel(),
+            (AliITSresponseSPD*) iDetType->GetResponseModel());
+//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//            (AliITSresponse*)iDetType->GetResponseModel());
+//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
+    } // end if
+    iDetType=DetType(kSDD);
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
+        AliITSsegmentation *seg1=
+            (AliITSsegmentation*)iDetType->GetSegmentationModel();
+        AliITSresponse *res1 = (AliITSresponse*)iDetType->GetResponseModel();
+        AliITSsimulationSDD *sim1=new AliITSsimulationSDD(seg1,res1);
+        SetSimulationModel(kSDD,sim1);
+    }else{ // simulation exists, make sure it is set up properly.
+        ((AliITSsimulationSDD*)sim)->Init(
+            (AliITSsegmentationSDD*) iDetType->GetSegmentationModel(),
+            (AliITSresponseSDD*) iDetType->GetResponseModel());
+//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//            (AliITSresponse*)iDetType->GetResponseModel());
+//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
+    } //end if
+    iDetType=DetType(kSSD);
+    sim = iDetType->GetSimulationModel();
+    if (!sim) {
+        AliITSsegmentation *seg2=
+            (AliITSsegmentation*)iDetType->GetSegmentationModel();
+        AliITSresponse *res2 = (AliITSresponse*)iDetType->GetResponseModel();
+        AliITSsimulationSSD *sim2=new AliITSsimulationSSD(seg2,res2);
+        SetSimulationModel(kSDD,sim2);
+    }else{ // simulation exists, make sure it is set up properly.
+        ((AliITSsimulationSSD*)sim)->Init(
+            (AliITSsegmentationSSD*) iDetType->GetSegmentationModel(),
+            (AliITSresponseSSD*) iDetType->GetResponseModel());
+//        if(sim->GetResponseModel()==0) sim->SetResponseModel(
+//            (AliITSresponse*)iDetType->GetResponseModel());
+//        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
+//            (AliITSsegmentation*)iDetType->GetSegmentationModel());
+    } // end if
+}
+//______________________________________________________________________
+void AliITSvSPD02::DrawModule() const {
     ////////////////////////////////////////////////////////////////////////
     //     Draw a shaded view of the ITS SPD test beam version 1.
     // Inputs:
@@ -678,7 +863,7 @@ void AliITSvSPD02::StepManager(){
        copy = fTrackReferences->GetEntriesFast();
        TClonesArray &lTR = *fTrackReferences;
        // Fill TrackReference structure with this new TrackReference.
-       new(lTR[copy]) AliTrackReference(gAlice->GetCurrentTrackNumber());
+       new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
     } // if Outer ITS mother Volume
     if(!(this->IsActive())){
        return;
@@ -723,7 +908,7 @@ void AliITSvSPD02::StepManager(){
        return;
     } // end if IsEntering
     // Fill hit structure with this new hit only for non-entrerance hits.
-    else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,
+    else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
                                        gMC->Edep(),gMC->TrackTime(),position,
                                        position0,momentum);
     //