]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSvSSD03.cxx
fixed the tainted variables
[u/mrichter/AliRoot.git] / ITS / AliITSvSSD03.cxx
index 7646707380fb6d42bde23cb34b7e534407c65ae3..f793f900358fe3b93d7fbe90549eeec4f6f2604b 100644 (file)
 // Enrico Fragiacomo - 15/03/2004
 // Geometry for the June 2003 SSD beam test
 
-#include <TGeometry.h>
-#include <TNode.h>
-#include <TLorentzVector.h>
 #include <TClonesArray.h>
-#include <TBRIK.h>
-#include <TVirtualMC.h>
+#include <TGeoGlobalMagField.h>
+#include <TGeoManager.h>
 #include <TGeoMatrix.h>
+#include <TLorentzVector.h>
+#include <TVirtualMC.h>
 
 #include "AliRun.h"
 #include "AliMagF.h"
 ClassImp(AliITSvSSD03)
 
 //______________________________________________________________________
-AliITSvSSD03::AliITSvSSD03() {
+AliITSvSSD03::AliITSvSSD03():
+AliITS(),                  // Base Class
+fMajorVersion(IsVersion()),// Major version number == IsVersion
+fMinorVersion(-1),         // Minor version number 
+fGeomNumber(2003),         // Geometry version number (year)
+fIDMother(0),              //! ITS Mother Volume id.
+fIgm(kvSSD03){             //! AliITSInitGeometry object {
     ////////////////////////////////////////////////////////////////////////
     // Standard default constructor for the ITS SSD test beam 2003 version 1.
     // Inputs:
@@ -60,23 +65,19 @@ AliITSvSSD03::AliITSvSSD03() {
     // Return:
     //    A default created class.
     ////////////////////////////////////////////////////////////////////////
-    Int_t i;
 
     fIdN          = 0;
     fIdName       = 0;
     fIdSens       = 0;
-    fEuclidOut    = kFALSE; // Don't write Euclide file
-    fGeomDetOut   = kFALSE; // Don't write .det file
-    fGeomDetIn    = kFALSE; // Don't Read .det file
-    fMajorVersion = IsVersion();
-    fMinorVersion = -1;
-    fGeomNumber   = 2003; // 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';
 }
 //______________________________________________________________________
-AliITSvSSD03::AliITSvSSD03(const char *title,Int_t gn) : AliITS("ITS", title){
+AliITSvSSD03::AliITSvSSD03(const char *title,Int_t gn) :
+AliITS("ITS",title),       // Base Class
+fMajorVersion(IsVersion()),// Major version number == IsVersion
+fMinorVersion(2),         // Minor version number 
+fGeomNumber(gn),         // Geometry version number (year)
+fIDMother(0),              //! ITS Mother Volume id.
+fIgm(kvSSD03){             //! AliITSInitGeometry object {
     ////////////////////////////////////////////////////////////////////////
     //    Standard constructor for the ITS SSD testbeam 2003 version 1.
     // Inputs:
@@ -89,29 +90,13 @@ AliITSvSSD03::AliITSvSSD03(const char *title,Int_t gn) : AliITS("ITS", title){
     ////////////////////////////////////////////////////////////////////////
     Int_t i;
 
-    fGeomNumber = gn;
 
     fIdN = 1; 
     fIdName = new TString[fIdN];
     fIdName[0] = "ITST";
     fIdSens    = new Int_t[fIdN];
-    for(i=0;i<fIdN;i++) fIdSens[i] = 0;
-
-    fMajorVersion = IsVersion();
-    fMinorVersion = 2;
-    fEuclidOut    = kFALSE; // Don't write Euclide file
-    fGeomDetOut   = kFALSE; // Don't write .det file
-    fGeomDetIn    = kFALSE; // Don't Read .det file
-
-    SetThicknessDet1();
-    SetThicknessDet2();
-    SetThicknessChip1();
-    SetThicknessChip2();                        
-
-    fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vSSD03.euc";
-    strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vSSD03.det",60);
-    strncpy(fRead,fEuclidGeomDet,60);
-    strncpy(fWrite,fEuclidGeomDet,60);
+    for(i=0;i<fIdN;i++) fIdSens[i] = 0;                         
+
 }
 //______________________________________________________________________
 AliITSvSSD03::~AliITSvSSD03() {
@@ -125,14 +110,14 @@ AliITSvSSD03::~AliITSvSSD03() {
     //    none.
     ////////////////////////////////////////////////////////////////////////
 }
+
 //______________________________________________________________________
-void AliITSvSSD03::BuildGeometry(){
+void AliITSvSSD03::CreateGeometry(){
     ////////////////////////////////////////////////////////////////////////
-    //    Geometry builder for the ITS SSD test beam 2003 version 1.
+    //   Geometry builder for the ITS SSD test beam 2003 version 1.
     //    ALIC    ALICE Mother Volume
     //     |- ITSV     ITS Mother Volume
-    //         |- ITST       Detector under Test
-    //
+    //         |- IDET       Detector under Test
     // Inputs:
     //    none.
     // Outputs:
@@ -140,24 +125,43 @@ void AliITSvSSD03::BuildGeometry(){
     // Return:
     //    none.
     ////////////////////////////////////////////////////////////////////////
-    // Get the top alice volume.
 
     switch (fGeomNumber){
     case 2003:
-        BuildGeometry2003();
+        CreateGeometry2003();
         break;
     default:
-        BuildGeometry2003();
+        CreateGeometry2003();
         break;
     } // end switch
 }
 //______________________________________________________________________
-void AliITSvSSD03::BuildGeometry2003(){
+void AliITSvSSD03::CreateGeometry2003(){
     ////////////////////////////////////////////////////////////////////////
-    //    Geometry builder for the ITS SSD test beam 2003 version 1.
+    //
     //    ALIC    ALICE Mother Volume
-    //     |- ITSV     ITS Mother Volume
-    //         |- ITST       Detector under Test
+    //     |- ITSV     Beamtest Mother Volume
+    //         |
+    //         |- ITSA       Aluminum cover for scintillator
+    //         |    |-ITSS    first Trieste trigger plastic scintillator 
+    //         |- ITSA       Aluminum cover for scintillator
+    //         |    |-ITSS    second Trieste's trigger plastic scintillator
+    //         |
+    //         |- IGAR       Black box around ITST       
+    //         |    |-IAIR    Air inside the black box
+    //         |        |-ITST    Detector under Test 
+    //         |
+    //         |- IFRA       Aluminum cover for scintillator
+    //         |    |-IFRS    French plastic scintillator 
+    //         |
+    //         |- ITSA       Aluminum cover for scintillator
+    //         |    |-ITSS    third Trieste's plastic scintillator
+    //
+    //      ITSA ITSA IGAR IFRA ITSA
+    // Z->  -282 -280   0   16   270
+    //        |    |    |    |    |
+    // cpn0   1    2    1    1    3
+    //
     // Inputs:
     //    none.
     // Outputs:
@@ -165,111 +169,43 @@ void AliITSvSSD03::BuildGeometry2003(){
     // Return:
     //    none.
     ////////////////////////////////////////////////////////////////////////
-
-    // Get the top alice volume.
-    TNode *aALIC = gAlice->GetGeometry()->GetNode("alice");
-    aALIC->cd();
-
-    // Define ITS Mother Volume
-    Float_t data[3];
-    Float_t ddettest=300.0E-4;
+    Float_t data[49];
+    // Define media off-set
+    Int_t *idtmed = fIdtmed->GetArray()+1; // array of media indexes
+    Int_t idrotm[4]; // Array of rotation matrix indexes
+    // These constant character strings are set by cvs during commit
+    // do not change them unless you know what you are doing!
+    const Char_t *cvsDate="$Date$";
+    const Char_t *cvsRevision="$Revision$";
     //Float_t yposition= 0.0;
-    TRotMatrix *r0 = new TRotMatrix("ITSidrotm0","ITSidrotm0",
-                                   90.0,0,0.0,0,90.0,270.0);
-
-    // Mother volume (beam along z)
-    data[0] = 10.0;   // in centimeter
-    data[1] = 50.0;
-    data[2] = 100.0;
-    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);
-    iITSV->cd(); // set ourselve into ITSV subvolume of aALIC
-
-    // SSD part of telescope  (Note. strips in local xz plan)
-    data[0] = 3.5;   // half-length of the SSD module
-    data[1] = 0.5*ddettest;    // half-width of the SSD module 
-    data[2] = 2.0;   // half-heigth of the SSD module
-    TBRIK *iITSTshape = new TBRIK("ITSTshape","SSD sensitive volume","Si",
-                                data[0],data[1],data[2]);
-    TNode *iITST = new TNode("ITST","SSD sensitive volume",iITSTshape,
-                           0.0,0.0,0.0,r0,0);
-
-    aALIC->cd();
-    iITST->SetLineColor(kYellow);
-    fNodes->Add(iITST);
-}
-//______________________________________________________________________
-void AliITSvSSD03::CreateGeometry(){
-    ////////////////////////////////////////////////////////////////////////
-    //   Geometry builder for the ITS SSD test beam 2003 version 1.
-    //    ALIC    ALICE Mother Volume
-    //     |- ITSV     ITS Mother Volume
-    //         |- IDET       Detector under Test
-    // Inputs:
-    //    none.
-    // Outputs:
-    //    none.
-    // Return:
-    //    none.
-    ////////////////////////////////////////////////////////////////////////
-
-    switch (fGeomNumber){
-    case 2003:
-        CreateGeometry2003();
-        break;
-    default:
-        CreateGeometry2003();
-        break;
-    } // end switch
-}
-//______________________________________________________________________
-void AliITSvSSD03::CreateGeometry2003(){
-  ////////////////////////////////////////////////////////////////////////
-  //
-  //    ALIC    ALICE Mother Volume
-  //     |- ITSV     Beamtest Mother Volume
-  //         |
-  //         |- ITSA       Aluminum cover for scintillator
-  //         |    |-ITSS    first Trieste trigger plastic scintillator 
-  //         |- ITSA       Aluminum cover for scintillator
-  //         |    |-ITSS    second Trieste's trigger plastic scintillator
-  //         |
-  //         |- IGAR       Black box around ITST       
-  //         |    |-IAIR    Air inside the black box
-  //         |        |-ITST    Detector under Test 
-  //         |
-  //         |- IFRA       Aluminum cover for scintillator
-  //         |    |-IFRS    French plastic scintillator 
-  //         |
-  //         |- ITSA       Aluminum cover for scintillator
-  //         |    |-ITSS    third Trieste's plastic scintillator
-  // Inputs:
-  //    none.
-  // Outputs:
-  //    none.
-  // Return:
-  //    none.
-  ////////////////////////////////////////////////////////////////////////
-  
-  Float_t data[49];
-  // Define media off-set
-  Int_t *idtmed = fIdtmed->GetArray()+1; // array of media indexes
-  Int_t idrotm[4]; // Array of rotation matrix indexes
-   //Float_t yposition= 0.0;
   
   if(gMC==0) return;
   // Define Rotation-reflextion Matrixes needed
   // 0 is the unit matrix
 
+  /*
   // Beamtest mother volume (air) positioned in ALIC mother volume
   data[0] = 500.0;
   data[1] = 500.0;
   data[2] = 1000.0;
   gMC->Gsvolu("ITSV","BOX",idtmed[0],data,3);
   gMC->Gspos("ITSV",1,"ALIC",0.0,0.0,0.0,0,"ONLY");
+  */
+    TGeoVolumeAssembly *itsV = gGeoManager->MakeVolumeAssembly("ITSV");
+    const Int_t length=100;
+    Char_t vstrng[length];
+    if(fIgm.WriteVersionString(vstrng,length,(AliITSVersion_t)IsVersion(),
+                               fMinorVersion,cvsDate,cvsRevision))
+        itsV->SetTitle(vstrng);
+    else Error("CreateGeometry","Error writing/setting version string");
+    //printf("Title set to %s\n",vstrng);
+    TGeoVolume *alic = gGeoManager->GetVolume("ALIC");
+    if(alic==0) {
+        Error("CreateGeometry","alic=0");
+        return;
+    } // end if
+    // See idrotm[199] for angle definitions.
+    alic->AddNode(itsV,1,0);
   
   // Trieste's plastic scintillators for the trigger (2 at beam enter)
   // ...define them (aluminum cover + scintillator inside)
@@ -394,8 +330,8 @@ void AliITSvSSD03::CreateMaterials2003(){
     //    none.
     /////////////////////////////////////////////////////////////////////////
 
-    Int_t   ifield = gAlice->Field()->Integ();
-    Float_t fieldm = gAlice->Field()->Max();   
+    Int_t   ifield = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
+    Float_t fieldm = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();   
 
     // Scintillator CH
     Float_t ascin[2]={1.01,12.01};
@@ -446,7 +382,7 @@ void AliITSvSSD03::CreateMaterials2003(){
     // Kapton
     AliMaterial(5, "Kapton$", 12.011, 6., 1.3, 31.27, 999.);
     AliMedium(5, "Kapton$",    5, 0,ifield,fieldm, 10., .01, .1, .003, .003);
-}
+}/*
 //______________________________________________________________________
 void AliITSvSSD03::InitAliITSgeom(){
   // sturture.
@@ -474,7 +410,7 @@ void AliITSvSSD03::InitAliITSgeom(){
     geom->SetRotMatrix(0,materix.GetRotationMatrix());
     geom->GetGeomMatrix(0)->SetPath(kname.Data());
     return;
-}
+}*/
 //______________________________________________________________________
 void AliITSvSSD03::Init(){
     ////////////////////////////////////////////////////////////////////////
@@ -486,28 +422,19 @@ void AliITSvSSD03::Init(){
     // Return:
     //    none.
     ////////////////////////////////////////////////////////////////////////
-    Int_t i;
 
-    cout << endl;
-    for(i=0;i<26;i++) cout << "*";
-    cout << " ITSvSSD03" << fMinorVersion << "_Init ";
-    for(i=0;i<25;i++) cout << "*";cout << endl;
-//
-    if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
-    if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
-    if(GetITSgeom()!=0) SetITSgeom(0x0);
-    AliITSgeom* geom = new AliITSgeom();
-    SetITSgeom(geom);
-    if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
-    if(!fGeomDetIn) this->InitAliITSgeom();
-    if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
+
+    Info("Init","**********AliITSvSSD03 %d _Init *************",fMinorVersion);
+
+    AliDebug(1,Form("Init: Major version %d Minor version %d",fMajorVersion,
+                 fMinorVersion));
+    //
+    UpdateInternalGeometry();
     AliITS::Init();
-//
-    for(i=0;i<72;i++) cout << "*";
-    cout << endl;
-    if(gMC) fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
-    else fIDMother = 0;
-}
+
+    fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
+
+}/*
 //______________________________________________________________________
 void AliITSvSSD03::SetDefaults(){
     // sets the default segmentation, rerponse, digit and raw cluster classes
@@ -549,15 +476,15 @@ void AliITSvSSD03::SetDefaults(){
 //    SetSimulationModel(kSSD,new AliITSsimulationSSD(seg0,resp0));
 //    iDetType->ReconstructionModel(new AliITSClusterFinderSSD());
 
-/*
-    SetResponseModel(kSPD,new AliITSCalibrationSPD());
-    SetSegmentationModel(kSPD,new AliITSsegmentationSPD());
-    fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
 
-    SetResponseModel(kSDD,new AliITSCalibrationSDD());
-    SetSegmentationModel(kSDD,new AliITSsegmentationSDD());
-    fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
-*/
+    //SetResponseModel(kSPD,new AliITSCalibrationSPD());
+    //SetSegmentationModel(kSPD,new AliITSsegmentationSPD());
+    //fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
+
+    //SetResponseModel(kSDD,new AliITSCalibrationSDD());
+    //SetSegmentationModel(kSDD,new AliITSsegmentationSDD());
+    //fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
+
 
 
     if(fgkNTYPES>3){
@@ -581,46 +508,45 @@ void AliITSvSSD03::SetDefaultSimulation(){
   AliITSsimulation *sim;
   //  AliITSsegmentation *seg;
   // AliITSCalibration *res;
-  /*
+
   //SPD
-  if(fDetTypeSim){
-    sim = fDetTypeSim->GetSimulationModel(kSPD);
-    if (!sim) {
-      seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD);
-      res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(nspd);
-      sim = new AliITSsimulationSPDdubna(seg,res,1);
-      SetSimulationModel(kSPD,sim);
-    }else{ // simulation exists, make sure it is set up properly.
-      sim->SetSegmentationModel((AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD));
-      sim->SetResponseModel((AliITSCalibration*)fDetTypeSim->GetResponseModel(nspd));
-      ((AliITSsimulation*)sim)->Init();
+  //if(fDetTypeSim){
+    //sim = fDetTypeSim->GetSimulationModel(kSPD);
+    //if (!sim) {
+      //seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD);
+      //res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(nspd);
+      //sim = new AliITSsimulationSPDdubna(seg,res,1);
+      //SetSimulationModel(kSPD,sim);
+    //}else{ // simulation exists, make sure it is set up properly.
+      //sim->SetSegmentationModel((AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD));
+      //sim->SetResponseModel((AliITSCalibration*)fDetTypeSim->GetResponseModel(nspd));
+      //((AliITSsimulation*)sim)->Init();
       //        if(sim->GetResponseModel()==0) sim->SetResponseModel(
       //            (AliITSCalibration*)iDetType->GetResponseModel());
       //        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
       //            (AliITSsegmentation*)iDetType->GetSegmentationModel());
-    } // end if
-  } // end if !fDetTypeSim
+    //} // end if
+  //} // end if !fDetTypeSim
 
   //SDD
-  if(fDetTypeSim){
-    sim = fDetTypeSim->GetSimulationModel(kSDD);
-    if (!sim) {
-      seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD);
-      res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(nsdd);
-      sim = new AliITSsimulationSDD(seg,res);
-      SetSimulationModel(kSDD,sim);
-    }else{ // simulation exists, make sure it is set up properly.
-      sim->SetSegmentationModel((AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD));
-      sim->SetResponseModel((AliITSCalibration*)fDetTypeSim->GetResponseModel(nsdd));
-
-      ((AliITSsimulation*)sim)->Init();
+  //if(fDetTypeSim){
+    //sim = fDetTypeSim->GetSimulationModel(kSDD);
+    //if (!sim) {
+      //seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD);
+      //res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(nsdd);
+      //sim = new AliITSsimulationSDD(seg,res);
+      //SetSimulationModel(kSDD,sim);
+    //}else{ // simulation exists, make sure it is set up properly.
+      //sim->SetSegmentationModel((AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD));
+      //sim->SetResponseModel((AliITSCalibration*)fDetTypeSim->GetResponseModel(nsdd));
+
+      //((AliITSsimulation*)sim)->Init();
       //        if(sim->GetResponseModel()==0) sim->SetResponseModel(
       //            (AliITSCalibration*)iDetType->GetResponseModel());
       //        if(sim->GetSegmentationModel()==0) sim->SetSegmentationModel(
       //            (AliITSsegmentation*)iDetType->GetSegmentationModel());
-    } //end if
-  } // end if !iDetType
-  */
+    //} //end if
+  //} // end if !iDetType
   //SSD
   if(fDetTypeSim){
     sim = fDetTypeSim->GetSimulationModel(kSSD);
@@ -640,7 +566,7 @@ void AliITSvSSD03::SetDefaultSimulation(){
     } // end if
   } // end if !iDetType
 }
-
+*/
 //______________________________________________________________________
 void AliITSvSSD03::DrawModule() const {
     ////////////////////////////////////////////////////////////////////////
@@ -682,63 +608,60 @@ void AliITSvSSD03::StepManager(){
     // Return:
     //    none.
     ////////////////////////////////////////////////////////////////////////
-    Int_t         copy=0, id;
-    TLorentzVector position, momentum;
-    static TLorentzVector position0;
-    static Int_t stat0=0;
-
-    if((id=gMC->CurrentVolID(copy) == fIDMother)&&
-       (gMC->IsTrackEntering()||gMC->IsTrackExiting())){
-       copy = fTrackReferences->GetEntriesFast();
-       TClonesArray &lTR = *fTrackReferences;
-       // Fill TrackReference structure with this new TrackReference.
-       new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
-    } // if Outer ITS mother Volume
-
     if(!(this->IsActive())){
-       return;
+        return;
     } // end if !Active volume.
+    if(!(gMC->TrackCharge())) return;
 
-
-    Int_t   vol[5];
-    TClonesArray &lhits = *fHits;
+    Int_t cpy0,mod,id,status;
+    TLorentzVector position, momentum;
+    static AliITShit hit;// Saves on calls to construtors
+    //TClonesArray &lhits = *(GetDetTypeSim()->GetHits());
+    TClonesArray &lhits = *(Hits());
     //
     // Track status
-    vol[3] = 0;
-    vol[4] = 0;
-    if(gMC->IsTrackInside())      vol[3] +=  1;
-    if(gMC->IsTrackEntering())    vol[3] +=  2;
-    if(gMC->IsTrackExiting())     vol[3] +=  4;
-    if(gMC->IsTrackOut())         vol[3] +=  8;
-    if(gMC->IsTrackDisappeared()) vol[3] += 16;
-    if(gMC->IsTrackStop())        vol[3] += 32;
-    if(gMC->IsTrackAlive())       vol[3] += 64;
+    // Track status
+    status = 0;
+    if(gMC->IsTrackInside())      status +=  1;
+    if(gMC->IsTrackEntering())    status +=  2;
+    if(gMC->IsTrackExiting())     status +=  4;
+    if(gMC->IsTrackOut())         status +=  8;
+    if(gMC->IsTrackDisappeared()) status += 16;
+    if(gMC->IsTrackStop())        status += 32;
+    if(gMC->IsTrackAlive())       status += 64;
     //
     // Fill hit structure.
-    if(!(gMC->TrackCharge())) return;
-    id = gMC->CurrentVolID(copy);
+    id = gMC->CurrentVolID(cpy0);
     if(id==fIdSens[0]){  // Volume name "ITST"
-       vol[2] = vol[1] = vol[0] = 1; // Det, ladder
+       mod=2; // Det, ladder
     } else return; // end if
     //
+    //
+    // Fill hit structure.
+    //
+    hit.SetModule(mod);
+    hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
     gMC->TrackPosition(position);
     gMC->TrackMomentum(momentum);
-    vol[4] = stat0;
+    hit.SetPosition(position);
+    hit.SetTime(gMC->TrackTime());
+    hit.SetMomentum(momentum);
+    hit.SetStatus(status);
+    hit.SetEdep(gMC->Edep());
+    hit.SetShunt(GetIshunt());
     if(gMC->IsTrackEntering()){
-       position0 = position;
-       stat0 = vol[3];
-       return;
+        hit.SetStartPosition(position);
+        hit.SetStartTime(gMC->TrackTime());
+        hit.SetStartStatus(status);
+        return; // don't save entering hit.
     } // end if IsEntering
-
-    // Fill hit structure with this new hit only for non-entrerance hits.
-    else new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
-                                       gMC->Edep(),gMC->TrackTime(),position,
-                                       position0,momentum);
-    //cout<<gMC->Edep()<<endl;
-    //
-    position0 = position;
-    stat0 = vol[3];
-
+    // Fill hit structure with this new hit.
+    //Info("StepManager","Calling Copy Constructor");
+    new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
+    // Save old position... for next hit.
+    hit.SetStartPosition(position);
+    hit.SetStartTime(gMC->TrackTime());
+    hit.SetStartStatus(status);
     return;
 }