From 451f5018be601d9e06d2f29793f00729d6ad4b5a Mon Sep 17 00:00:00 2001 From: shahoian Date: Fri, 17 Aug 2012 00:48:30 +0000 Subject: [PATCH] 1) Added classes for digitization 2) Brought to uniform naming scheme AliITSU... 3) Removed AliITSgeom and AliITSInitGeometry dependencies: all geom manipulations are done via AliITSUGeomTGeo class, which is not anymore static. --- ITS/UPGRADE/AliITSDetTypeSimUpg.cxx | 242 --- ITS/UPGRADE/AliITSDetTypeSimUpg.h | 71 - ITS/UPGRADE/AliITSU.cxx | 820 ++++++++++ ITS/UPGRADE/AliITSU.h | 155 ++ ...onPixUpg.cxx => AliITSUCalibrationPix.cxx} | 79 +- ...rationPixUpg.h => AliITSUCalibrationPix.h} | 29 +- ...ITSdigitPixUpg.cxx => AliITSUDigitPix.cxx} | 20 +- ...{AliITSdigitPixUpg.h => AliITSUDigitPix.h} | 16 +- ITS/UPGRADE/AliITSUDigitizer.cxx | 252 +++ ITS/UPGRADE/AliITSUDigitizer.h | 48 + ...ITSgeomTGeoUpg.cxx => AliITSUGeomTGeo.cxx} | 551 +++---- ITS/UPGRADE/AliITSUGeomTGeo.h | 245 +++ ITS/UPGRADE/AliITSUHit.cxx | 100 ++ ITS/UPGRADE/AliITSUHit.cxx~ | 100 ++ ITS/UPGRADE/AliITSUHit.h | 44 + ...eometryUpg.cxx => AliITSUInitGeometry.cxx} | 189 +-- ...nitGeometryUpg.h => AliITSUInitGeometry.h} | 52 +- ...{AliITSLoaderUpg.cxx => AliITSULoader.cxx} | 105 +- .../{AliITSLoaderUpg.h => AliITSULoader.h} | 26 +- ITS/UPGRADE/AliITSUModule.cxx | 344 ++++ ITS/UPGRADE/AliITSUModule.h | 68 + ITS/UPGRADE/AliITSUSDigit.cxx | 274 ++++ ITS/UPGRADE/AliITSUSDigit.h | 68 + ...nPixUpg.cxx => AliITSUSegmentationPix.cxx} | 103 +- ...ationPixUpg.h => AliITSUSegmentationPix.h} | 25 +- ITS/UPGRADE/AliITSUSensMap.cxx | 143 ++ ITS/UPGRADE/AliITSUSensMap.h | 81 + ITS/UPGRADE/AliITSUSimuParam.cxx | 485 ++++++ ITS/UPGRADE/AliITSUSimuParam.h | 151 ++ ITS/UPGRADE/AliITSUSimulation.cxx | 166 ++ ITS/UPGRADE/AliITSUSimulation.h | 96 ++ ITS/UPGRADE/AliITSUSimulationPix.cxx | 787 ++++++++++ ITS/UPGRADE/AliITSUSimulationPix.h | 66 + ITS/UPGRADE/AliITSUpg.cxx | 1393 ----------------- ITS/UPGRADE/AliITSUpg.h | 175 --- ITS/UPGRADE/AliITSUv11.cxx | 704 +++++++++ ITS/UPGRADE/AliITSUv11.h | 95 ++ ...eometryUpgrade.cxx => AliITSUv11Layer.cxx} | 56 +- ...v11GeometryUpgrade.h => AliITSUv11Layer.h} | 20 +- ITS/UPGRADE/AliITSgeomTGeoUpg.h | 146 -- ITS/UPGRADE/AliITSresponsePixUpg.cxx | 46 - ITS/UPGRADE/AliITSresponsePixUpg.h | 34 - ITS/UPGRADE/AliITSsimulationPixUpg.cxx | 1020 ------------ ITS/UPGRADE/AliITSsimulationPixUpg.h | 126 -- ITS/UPGRADE/CMakelibITSUpgradeBase.pkg | 11 +- ITS/UPGRADE/CMakelibITSUpgradeSim.pkg | 15 +- ITS/UPGRADE/ITSUpgradeBaseLinkDef.h | 11 +- ITS/UPGRADE/ITSUpgradeSimLinkDef.h | 15 +- 48 files changed, 5867 insertions(+), 4001 deletions(-) delete mode 100644 ITS/UPGRADE/AliITSDetTypeSimUpg.cxx delete mode 100644 ITS/UPGRADE/AliITSDetTypeSimUpg.h create mode 100644 ITS/UPGRADE/AliITSU.cxx create mode 100644 ITS/UPGRADE/AliITSU.h rename ITS/UPGRADE/{AliITSCalibrationPixUpg.cxx => AliITSUCalibrationPix.cxx} (77%) rename ITS/UPGRADE/{AliITSCalibrationPixUpg.h => AliITSUCalibrationPix.h} (75%) rename ITS/UPGRADE/{AliITSdigitPixUpg.cxx => AliITSUDigitPix.cxx} (89%) rename ITS/UPGRADE/{AliITSdigitPixUpg.h => AliITSUDigitPix.h} (70%) create mode 100644 ITS/UPGRADE/AliITSUDigitizer.cxx create mode 100644 ITS/UPGRADE/AliITSUDigitizer.h rename ITS/UPGRADE/{AliITSgeomTGeoUpg.cxx => AliITSUGeomTGeo.cxx} (53%) create mode 100644 ITS/UPGRADE/AliITSUGeomTGeo.h create mode 100644 ITS/UPGRADE/AliITSUHit.cxx create mode 100644 ITS/UPGRADE/AliITSUHit.cxx~ create mode 100644 ITS/UPGRADE/AliITSUHit.h rename ITS/UPGRADE/{AliITSInitGeometryUpg.cxx => AliITSUInitGeometry.cxx} (86%) rename ITS/UPGRADE/{AliITSInitGeometryUpg.h => AliITSUInitGeometry.h} (56%) rename ITS/UPGRADE/{AliITSLoaderUpg.cxx => AliITSULoader.cxx} (78%) rename ITS/UPGRADE/{AliITSLoaderUpg.h => AliITSULoader.h} (89%) create mode 100644 ITS/UPGRADE/AliITSUModule.cxx create mode 100644 ITS/UPGRADE/AliITSUModule.h create mode 100644 ITS/UPGRADE/AliITSUSDigit.cxx create mode 100644 ITS/UPGRADE/AliITSUSDigit.h rename ITS/UPGRADE/{AliITSsegmentationPixUpg.cxx => AliITSUSegmentationPix.cxx} (80%) rename ITS/UPGRADE/{AliITSsegmentationPixUpg.h => AliITSUSegmentationPix.h} (78%) create mode 100644 ITS/UPGRADE/AliITSUSensMap.cxx create mode 100644 ITS/UPGRADE/AliITSUSensMap.h create mode 100644 ITS/UPGRADE/AliITSUSimuParam.cxx create mode 100644 ITS/UPGRADE/AliITSUSimuParam.h create mode 100644 ITS/UPGRADE/AliITSUSimulation.cxx create mode 100644 ITS/UPGRADE/AliITSUSimulation.h create mode 100644 ITS/UPGRADE/AliITSUSimulationPix.cxx create mode 100644 ITS/UPGRADE/AliITSUSimulationPix.h delete mode 100644 ITS/UPGRADE/AliITSUpg.cxx delete mode 100644 ITS/UPGRADE/AliITSUpg.h create mode 100644 ITS/UPGRADE/AliITSUv11.cxx create mode 100644 ITS/UPGRADE/AliITSUv11.h rename ITS/UPGRADE/{AliITSv11GeometryUpgrade.cxx => AliITSUv11Layer.cxx} (87%) rename ITS/UPGRADE/{AliITSv11GeometryUpgrade.h => AliITSUv11Layer.h} (84%) delete mode 100644 ITS/UPGRADE/AliITSgeomTGeoUpg.h delete mode 100644 ITS/UPGRADE/AliITSresponsePixUpg.cxx delete mode 100644 ITS/UPGRADE/AliITSresponsePixUpg.h delete mode 100644 ITS/UPGRADE/AliITSsimulationPixUpg.cxx delete mode 100644 ITS/UPGRADE/AliITSsimulationPixUpg.h diff --git a/ITS/UPGRADE/AliITSDetTypeSimUpg.cxx b/ITS/UPGRADE/AliITSDetTypeSimUpg.cxx deleted file mode 100644 index 914eb51c828..00000000000 --- a/ITS/UPGRADE/AliITSDetTypeSimUpg.cxx +++ /dev/null @@ -1,242 +0,0 @@ -/*************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - -/* - $Id: AliITSDetTypeSimUpg.cxx 56993 2012-06-08 08:24:17Z fca $ -*/ - - -///////////////////////////////////////////////////////////////////// -// Base simulation functions for ITS upgrade // -// // -// // -///////////////////////////////////////////////////////////////////// -#include "TBranch.h" -#include "TClonesArray.h" -#include "TObjArray.h" -#include "TTree.h" - -#include "AliRun.h" - -#include "AliCDBManager.h" -#include "AliCDBId.h" -#include "AliCDBStorage.h" -#include "AliCDBEntry.h" -#include "AliCDBMetaData.h" -#include "AliITSdigit.h" -#include "AliITSdigitPixUpg.h" -#include "AliITSgeom.h" -#include "AliITSDetTypeSimUpg.h" -#include "AliITSpListItem.h" -#include "AliITSCalibration.h" -#include "AliITSsimulation.h" -#include "AliITSTriggerConditions.h" -#include "AliITSsegmentation.h" -#include "AliITSsegmentationPixUpg.h" -#include "AliITSsimulationPixUpg.h" -#include "AliBaseLoader.h" - -using std::endl; -using std::cout; -ClassImp(AliITSDetTypeSimUpg) - -const char* AliITSDetTypeSimUpg::fgkDetTypeName[AliITSDetTypeSimUpg::kNDetTypes] = {"PixUpg"}; - - -//---------------------------------------------------------------------- -AliITSDetTypeSimUpg::AliITSDetTypeSimUpg() -{ - // Default Constructor - // Note: the base class AliITSDetTypeSim is badly designed, since its - // default c-tor dynamically creates lot of stuff. - // To be derived directly from TObject later... - // Inputs: - // none. - // Outputs: - // none. - // Return: - // A properly zero-ed AliITSDetTypeSimUpg class. - if (kNDetTypes>3) AliFatal("The hack failed: kNDetTypes>fgkNdettypes"); - // - for (int i=kNDetTypes;i--;) fDetNModules[i] = 0; -} - -//---------------------------------------------------------------------- -AliITSDetTypeSimUpg::~AliITSDetTypeSimUpg() -{ - // Destructor - // RS: delegate everything to base class -} - -//_______________________________________________________________________ -void AliITSDetTypeSimUpg::SetDefaultSegmentation(Int_t idet) -{ - // Set default segmentation model objects - AliITSsegmentation *seg = 0; - // - if (GetSegmentationModel(idet)) delete GetSegmentation()->RemoveAt(idet); - // - switch (idet) - { - case kDetPixUpg: seg = new AliITSsegmentationPixUpg(); break; - default : AliFatal(Form("Uknown detector type %d",idet)); - }; - SetSegmentationModel(idet,seg); - // -} - -//_______________________________________________________________________ -AliITSCalibration* AliITSDetTypeSimUpg::GetCalibrationModel(Int_t iMod) const -{ - //Get response model for module number iMod - // - TObjArray* calarr = GetCalibrationArray(); - if (!calarr) { - AliError("Calibration array is not initialized"); - return 0; - } - return (AliITSCalibration*)calarr->At(iMod); -} - -//_______________________________________________________________________ -void AliITSDetTypeSimUpg::SetDefaults() -{ - //Set defaults for segmentation and response - - if(GetITSgeom()==0){ - Warning("SetDefaults","GetITSgeom() is 0!"); - return; - } // end if - if (GetCalibrationArray()==0) { - CreateCalibrationArray(); - } // end if - // - ResetSegmentation(); - if(!GetCalibration()){AliFatal("Exit"); exit(0);} - - SetDigitClassName(0,"AliITSdigitPixUpg"); - // - for(Int_t idet=0;idetGetRun()); - Int_t run=GetRunNumber(); - - Bool_t isCacheActive = kTRUE; - if (run) { - isCacheActive=kFALSE; - fCalibration->SetOwner(kTRUE); - } - else{ - fCalibration->SetOwner(kFALSE); - } - - AliCDBManager::Instance()->SetCacheFlag(isCacheActive); - // - // TO DO, RS - */ - return kTRUE; -} - -//_______________________________________________________________________ -void AliITSDetTypeSimUpg::SetDefaultSimulation() -{ - //Set default simulation for detector type - // - if (GetITSgeom()==0) { - Warning("SetDefaultSimulation","GetITSgeom() is 0!"); - return; - } - if (GetCalibrationArray()==0) { - Warning("SetDefaultSimulation","fCalibration is 0!"); - return; - } - if (GetSegmentation()==0) { - Warning("SetDefaultSimulation","fSegmentation is 0!"); - for (Int_t i=0;i -#include "AliITSLoader.h" -#include "AliITSSimuParam.h" -#include "AliITSDetTypeSim.h" - -class TObjArray; -class TClonesArray; -class TTree; -class AliCDBMetaData; -class AliITSdigit; -class AliITSdigitPixUpg; -class AliITSmodule; -class AliITSpListItem; -class AliITSsimulation; -class AliITSsegmentation; -class AliITSresponse; -class AliITSCalibration; -class AliITSgeom; -class AliITSTriggerConditions; - - -class AliITSDetTypeSimUpg : public AliITSDetTypeSim { - public: - // - enum {kDetPixUpg, kNDetTypes}; - // - AliITSDetTypeSimUpg(); - virtual ~AliITSDetTypeSimUpg(); - - virtual AliITSCalibration* GetCalibrationModel(Int_t iMod) const; - virtual AliITSTriggerConditions* GetTriggerConditions() {return 0;} // tmp - - virtual void SetDefaults(); - virtual void SetDefaultSimulation(); - // - virtual void AddSimDigit(Int_t branch, const AliITSdigit *d); - virtual void AddSimDigit(Int_t branch,Float_t phys,Int_t* digits, - Int_t* tracks,Int_t *hits,Float_t* trkcharges, - Int_t sigexpanded=-1000); - - protected: - virtual Bool_t GetCalibration(); - - private: - AliITSDetTypeSimUpg(const AliITSDetTypeSimUpg &source); - AliITSDetTypeSimUpg& operator=(const AliITSDetTypeSimUpg &source); - void SetDefaultSegmentation(Int_t idet); // creates def segm. - // - Int_t fDetNModules[kNDetTypes]; // Total numbers of modules of each type, RS - // - static const char* fgkDetTypeName[kNDetTypes]; // detector names - // - ClassDef(AliITSDetTypeSimUpg,1) // ITS Upg Simulation structure - -}; - -#endif diff --git a/ITS/UPGRADE/AliITSU.cxx b/ITS/UPGRADE/AliITSU.cxx new file mode 100644 index 00000000000..3b137bd6d7b --- /dev/null +++ b/ITS/UPGRADE/AliITSU.cxx @@ -0,0 +1,820 @@ +/* +*/ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliITSU.cxx $ */ + + +/////////////////////////////////////////////////////////////////////////////// +// // +// An overview of the basic philosophy of the ITS code development // +// and analysis is show in the figure below. // +//Begin_Html // +/* + + +
+ +

Roberto Barbera is in charge of the ITS Offline code (1999). +Roberto Barbera. + +

+*/
+//End_Html
+//
+//  AliITSU. Inner Traking System base class.
+//  This class contains the base procedures for the Inner Tracking System
+//
+//Begin_Html
+/*
+
+
+
+ +

This show the class diagram of the different elements that are part of +the AliITS class. + +

+*/
+//End_Html
+//
+// Version: 0
+// Written by Rene Brun, Federico Carminati, and Roberto Barbera
+//
+// Version: 1
+// Modified and documented by Bjorn S. Nilsen
+// July 11 1999
+//
+// Version: 2
+// Modified and documented by A. Bologna
+// October 18 1999
+//
+// AliITSU is the general base class for the ITS. Also see AliDetector for
+// futher information.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "AliDetector.h"
+#include "AliITSU.h"
+#include "AliITSLoader.h"
+#include "AliITSULoader.h"
+#include "AliITSUHit.h"
+#include "AliITSUSDigit.h"
+#include "AliITSUSimulation.h"
+#include "AliITSUSimulationPix.h"
+#include "AliITSsimulationFastPoints.h"
+#include "AliMC.h"
+#include "AliITSUDigitizer.h"
+#include "AliITSRecPoint.h"
+#include "AliRawReader.h"
+#include "AliRun.h"
+#include "AliLog.h"
+#include "AliITSdigit.h"
+#include "AliITSUModule.h"
+#include "AliITSUDigitPix.h"
+#include "AliITSsegmentation.h"
+#include "AliITSUSegmentationPix.h"
+#include "AliITSUSimuParam.h"
+#include "AliITSFOSignalsSPD.h"
+
+ClassImp(AliITSU)
+
+//______________________________________________________________________
+AliITSU::AliITSU() : 
+AliDetector()
+  ,fEuclidOut(0)
+  ,fNLayers(0)
+  ,fIdSens(0)
+  ,fLayerName(0)
+  ,fTiming(kFALSE)
+  ,fSimuParam(0)
+  ,fGeomTGeo(0)
+  ,fModA(0)
+  ,fpSDigits(0)
+  ,fSDigits(0)
+  ,fDetHits(0)
+  ,fModuleHits(0)
+  ,fDetDigits(0)
+  ,fSensMap(0)
+  ,fSimulation(0)
+  ,fSegmentation(0)
+  ,fCalibration(0)
+  ,fRunNumber(0)
+  ,fSimInitDone(kFALSE)
+{
+  // Default initializer for ITS  
+}
+
+//______________________________________________________________________
+AliITSU::AliITSU(const Char_t *title, Int_t nlay) :
+  AliDetector("ITS",title)
+  ,fEuclidOut(0)
+  ,fNLayers(nlay)
+  ,fIdSens(0)
+  ,fLayerName(0)
+  ,fTiming(kFALSE)
+  ,fSimuParam(0)
+  ,fGeomTGeo(0)
+  ,fModA(0)
+  ,fpSDigits(0)
+  ,fSDigits(0)
+  ,fDetHits(0)
+  ,fModuleHits(0)
+  ,fDetDigits(0)
+  ,fSensMap(0)
+  ,fSimulation(0)
+  ,fSegmentation(0)
+  ,fCalibration(0)
+  ,fRunNumber(0)
+  ,fSimInitDone(kFALSE)
+{
+  //     The standard Constructor for the ITS class. 
+}
+
+
+//______________________________________________________________________
+AliITSU::~AliITSU()
+{
+  // Default destructor for ITS.
+  //  
+  delete fHits;
+  delete fModuleHits;
+  delete fSimuParam;
+  delete fSensMap;
+  if (fSimulation) fSimulation->Delete();
+  delete fSimulation;
+  delete fSegmentation;
+  delete[] fLayerName;  // Array of TStrings
+  delete[] fIdSens;
+  //
+  int nmod = fGeomTGeo ? fGeomTGeo->GetNModules() : 0;
+  if (fModuleHits) fModuleHits->Delete();
+  delete fModuleHits;
+  if(fModA){
+    for(Int_t j=0; jDelete();
+      delete fModA[j];
+    }
+    delete[] fModA;
+  }
+  if (fpSDigits) { fpSDigits->Delete(); delete fpSDigits; }
+  if (fSDigits)  { fSDigits->Delete(); delete fSDigits; }
+  delete fGeomTGeo;
+  //
+}
+
+//______________________________________________________________________
+AliDigitizer* AliITSU::CreateDigitizer(AliDigitizationInput* manager) const
+{
+  // Creates the AliITSDigitizer in a standard way for use via AliModule.
+  // This function can not be included in the .h file because of problems
+  // with the order of inclusion (recursive).
+  // Inputs:
+  //    AliDigitizationInput *manager  The Manger class for Digitization
+  // Output:
+  //    none.
+  // Return:
+  //    A new AliITSRunDigitizer (cast as a AliDigitizer).
+  //
+  if (!IsSimInitDone()) AliFatal("Simulation is not initialized");
+  return new AliITSUDigitizer(manager);
+}
+
+//______________________________________________________________________
+void AliITSU::Init() 
+{
+  // Initializer ITS after it has been built
+  //     This routine initializes the AliITS class. It is intended to be
+  // called from the Init function in AliITSv?. Besides displaying a banner
+  // indicating that it has been called it initializes the array fIdSens
+  // and sets the default segmentation, response, digit and raw cluster
+  // classes therefore it should be called after a call to CreateGeometry.
+  //
+  if (!fIdSens) fIdSens = new Int_t[fNLayers];
+  for(int i=0;iVolId(fLayerName[i]) : 0;
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::MakeBranch(Option_t* option)
+{
+  // Creates Tree branches for the ITS.
+  // Inputs:
+  //      Option_t *option    String of Tree types S,D, and/or R.
+  //      const char *file    String of the file name where these branches
+  //                          are to be stored. If blank then these branches
+  //                          are written to the same tree as the Hits were
+  //                          read from.
+  // Outputs:
+  //      none.
+  // Return:
+  //      none.
+  
+  Bool_t cH = (strstr(option,"H")!=0);
+  Bool_t cS = (strstr(option,"S")!=0);
+  Bool_t cD = (strstr(option,"D")!=0);
+  
+  if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITSUHit", 1560);
+  AliDetector::MakeBranch(option);
+  
+  if(cS) MakeBranchS(0);
+  if(cD) MakeBranchD(0);
+  // 
+}
+
+//___________________________________________________________________
+void AliITSU::MakeBranchS(const char* fl) 
+{
+  // Creates Tree Branch for the ITS summable digits.
+  // Inputs:
+  //      cont char *fl  File name where SDigits branch is to be written
+  //                     to. If blank it write the SDigits to the same
+  //                     file in which the Hits were found.
+  //  
+  Int_t buffersize = 4000;
+  char branchname[31];
+  //
+  // only one branch for SDigits.
+  snprintf(branchname,30,"%s",GetName());
+  if(fLoader->TreeS()) MakeBranchInTree(fLoader->TreeS(),branchname,&fSDigits,buffersize,fl);
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::MakeBranchD(const char* file)
+{
+  //Make branch for digits
+  MakeBranchInTreeD(fLoader->TreeD(),file);
+}
+
+//___________________________________________________________________
+void AliITSU:: MakeBranchInTreeD(TTree* treeD, const char* file)
+{
+  // Creates Tree branches for the ITS.
+  //
+  if (!treeD) {AliFatal("No tree provided");}
+  Int_t buffersize = 4000;
+  if (!fDetDigits) InitArrays();
+  //
+  for (Int_t i=0;iAt(i);
+    AliDetector::MakeBranchInTree(treeD,Form("%sDigits%s",GetName(),fGeomTGeo->GetDetTypeName(i)),
+				  &darr,buffersize,file);
+  }
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::InitArrays()
+{
+  // initialize arrays
+  //
+  fHits = new TClonesArray("AliITSUHit",1560); // from AliDetector
+  if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
+  if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
+  //  
+  fDetDigits = new TObjArray(kNDetTypes);
+  for (Int_t i=0;iAddAt(new TClonesArray(GetDigitClassName(i),100),i);
+  //
+  fSDigits = new TClonesArray("AliITSUSDigit",100);
+  //
+  fDetHits = new TClonesArray("AliITSUHit",100);
+  //
+  fModuleHits = new TObjArray(fGeomTGeo->GetNModules());
+  for (int i=0;iGetNModules();i++) fModuleHits->AddLast( new AliITSUModule(i,fGeomTGeo) );
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::SetTreeAddress()
+{
+  // Set branch address for the Trees.
+  TTree *treeS = fLoader->TreeS();
+  if (treeS) treeS->GetBranch(GetName())->SetAddress(&fSDigits);
+  //
+  TTree *treeD = fLoader->TreeD();
+  if (treeD) {
+    if (!fDetDigits) InitArrays();
+    for (int i=0;iGetBranch(brname.Data());
+      if (!br) AliFatal(Form("Did not find branch for %s",brname.Data()));
+      TClonesArray* darr = (TClonesArray*)fDetDigits->At(i);
+      br->SetAddress(&darr);
+    }
+  }
+  if (fLoader->TreeH() && (fHits == 0x0)) fHits = new TClonesArray("AliITSUHit", 1560);
+  AliDetector::SetTreeAddress();
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::AddHit(Int_t track, Int_t *vol, Float_t *hits)
+{
+  // Add an ITS hit
+  //     The function to add information to the AliITSUHit class. See the
+  // AliITSUHit class for a full description. This function allocates the
+  // necessary new space for the hit information and passes the variable
+  // track, and the pointers *vol and *hits to the AliITSUHit constructor
+  // function.
+  // Inputs:
+  //      Int_t   track   Track number which produced this hit.
+  //      Int_t   *vol    Array of Integer Hit information. See AliITSUHit.h
+  //      Float_t *hits   Array of Floating Hit information.  see AliITSUHit.h
+  TClonesArray &lhits = *fHits;
+  new(lhits[fNhits++]) AliITSUHit(fIshunt,track,vol,hits);
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::FillModules(Int_t bgrev, Option_t *option, const char *filename) 
+{
+  // fill the modules with the sorted by module hits; add hits from
+  // background if option=Add.
+  //
+  static TTree *trH1=0;                 //Tree with background hits
+  static Bool_t first=kTRUE;
+  static TFile *file = 0;
+  const char *addBgr = strstr(option,"Add");
+  //
+  if (addBgr ) {
+    if(first) {
+      file = new TFile(filename);    
+      first=kFALSE;
+    }
+    file->cd();
+    file->ls();
+    // Get Hits Tree header from file
+    if (trH1) {delete trH1; trH1=0;}
+    //
+    char treeName[21];
+    snprintf(treeName,20,"TreeH%d",bgrev);
+    trH1 = (TTree*)gDirectory->Get(treeName);
+    if (!trH1) Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
+    // Set branch addresses
+  } // end if addBgr
+  
+  FillModules(fLoader->TreeH(),0); // fill from this file's tree.
+  //
+  if (addBgr ) {
+    FillModules(trH1,10000000); // Default mask 10M.
+    TTree *fAli=fLoader->GetRunLoader()->TreeK();
+    TFile *fileAli=0;
+    if (fAli) {
+      fileAli = fAli->GetCurrentFile();
+      fileAli->cd();
+    }
+  } // end if add
+  //  
+}
+
+//______________________________________________________________________
+void AliITSU::FillModules(TTree *treeH, Int_t /*mask*/)
+{
+  // fill the modules with the sorted by module hits; 
+  // can be called many times to do a merging
+  // Inputs:
+  //      TTree *treeH  The tree containing the hits to be copied into
+  //                    the modules.
+  //      Int_t mask    The track number mask to indecate which file
+  //                    this hits came from.
+  //  
+  if (treeH == 0x0) { AliError("Tree H  is NULL"); return; }
+  //
+  Int_t lay,lad,det,index;
+  AliITSUHit *itsHit=0;
+  char branchname[21];
+  snprintf(branchname,20,"%s",GetName());
+  TBranch *branch = treeH->GetBranch(branchname);
+  if (!branch) {Error("FillModules","%s branch in TreeH not found",branchname); return;} // end if !branch
+  //
+  branch->SetAddress(&fHits);
+  Int_t nTracks =(Int_t) treeH->GetEntries();
+  Int_t iPrimTrack,h;
+  for (iPrimTrack=0; iPrimTrackGetEvent(iPrimTrack);
+    if (nBytes <= 0) continue;
+    Int_t nHits = fHits->GetEntriesFast();
+    for (h=0; hUncheckedAt(h);
+      itsHit->GetDetectorID(lay,lad,det);
+      index = fGeomTGeo->GetModuleIndex(--lay,--lad,--det); // !!! AliITSHit counts indices from 1!
+      itsHit = new( (*fDetHits)[fDetHits->GetEntriesFast()] ) AliITSUHit(*itsHit);
+      itsHit->SetUniqueID(h);
+      GetModule(index)->AddHit(itsHit);
+      // do we need to add a mask?
+      // itsHit->SetTrack(itsHit->GetTrack()+mask);
+    } // end loop over hits 
+  } // end loop over tracks
+}
+
+//______________________________________________________________________
+void AliITSU::ClearModules()
+{
+  // clear accumulated hits
+  if (!fModuleHits || !fDetHits) AliFatal("Hits accumulation arrays are not defined");
+  for (int i=fGeomTGeo->GetNModules();i--;) GetModule(i)->Clear();
+  fDetHits->Clear();
+}
+
+//______________________________________________________________________
+void AliITSU::Hits2SDigits()
+{
+  // Standard Hits to summable Digits function.
+  // Inputs:
+  //      none.
+  // Outputs:
+  //      none.
+  if (!IsSimInitDone()) InitSimulation();
+  fLoader->LoadHits("read");
+  fLoader->LoadSDigits("recreate");
+  AliRunLoader* rl = fLoader->GetRunLoader(); 
+  //
+  for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
+    rl->GetEvent(iEvent);
+    if (!fLoader->TreeS()) fLoader->MakeTree("S");
+    MakeBranch("S");
+    SetTreeAddress();
+    Hits2SDigits(iEvent,0," "," ");
+  } // end for iEvent
+    //
+  fLoader->UnloadHits();
+  fLoader->UnloadSDigits();
+  // 
+}
+
+//______________________________________________________________________
+void AliITSU::Hits2SDigits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename)
+{
+  // Keep galice.root for signal and name differently the file for 
+  // background when add! otherwise the track info for signal will be lost !
+  // Inputs:
+  //      Int_t evnt       Event to be processed.
+  //      Int_t bgrev      Background Hit tree number.
+  //      Int_t nmodules   Not used.
+  //      Option_t *option String indicating if merging hits or not. To
+  //                       merge hits set equal to "Add". Otherwise no
+  //                       background hits are considered.
+  //      Test_t *filename File name containing the background hits..
+  //
+  if (!IsSimInitDone()) InitSimulation();
+  FillModules(bgrev,option,filename);
+  //
+  Int_t nmodules = fGeomTGeo->GetNModules();
+  for(int module=0;moduleGetModuleDetTypeID(module);
+    AliITSUSimulation* sim = GetSimulationModel(id);
+    if (!sim) AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id));
+    sim->SDigitiseModule( GetModule(module), module, evNumber, GetSegmentation(id));
+    fLoader->TreeS()->Fill();      // fills all branches - wasted disk space
+    ResetSDigits();
+  } 
+  //
+  ClearModules();
+  //
+  fLoader->TreeS()->GetEntries();
+  fLoader->TreeS()->AutoSave();
+  fLoader->WriteSDigits("OVERWRITE");
+  fLoader->TreeS()->Reset();
+}
+
+//______________________________________________________________________
+void AliITSU::Hits2Digits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename)
+{
+  //   Keep galice.root for signal and name differently the file for 
+  // background when add! otherwise the track info for signal will be lost !
+  // Inputs:
+  //      Int_t evnt       Event to be processed.
+  //      Int_t bgrev      Background Hit tree number.
+  //      Option_t *option String indicating if merging hits or not. To
+  //                       merge hits set equal to "Add". Otherwise no
+  //                       background hits are considered.
+  //      Test_t *filename File name containing the background hits..
+  // Outputs:
+  //  
+  if (!IsSimInitDone()) InitSimulation();
+  FillModules(bgrev,option,filename);
+  // 
+  Int_t nmodules = fGeomTGeo->GetNModules();
+  for (Int_t module=0;moduleGetModuleDetTypeID(module);
+    AliITSUSimulation* sim = GetSimulationModel(id);
+    if (!sim) AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id));
+    sim->DigitiseModule( GetModule(module) ,module, evNumber, GetSegmentation(id));
+    // fills all branches - wasted disk space
+    fLoader->TreeD()->Fill(); 
+    ResetDigits();
+  } // end for module
+  //
+  ClearModules();
+  //
+  //    WriteFOSignals(); // Add Fast-OR signals to event (only one object per event)
+  fLoader->TreeD()->GetEntries();
+  fLoader->TreeD()->AutoSave();
+  fLoader->TreeD()->Reset(); 
+  //
+}
+
+//_____________________________________________________________________
+void AliITSU::Hits2FastRecPoints(Int_t bgrev,Option_t *opt,const char *flnm)
+{
+  // keep galice.root for signal and name differently the file for 
+  // background when add! otherwise the track info for signal will be lost !
+  // Inputs:
+  //      Int_t evnt       Event to be processed.
+  //      Int_t bgrev      Background Hit tree number.
+  //      Option_t *opt    Option passed to FillModules. See FillModules.
+  //      Test_t *flnm     File name containing the background hits..
+  // Outputs:
+  //      none.
+  // Return:
+  //      none.
+  if (!IsSimInitDone()) InitSimulation();
+  AliITSULoader *pITSloader = (AliITSULoader*)fLoader;
+  Int_t nmodules = fGeomTGeo->GetNModules();
+  FillModules(bgrev,opt,flnm);
+  //
+  TTree *lTR = pITSloader->TreeR();
+  if(!lTR) {
+    pITSloader->MakeTree("R");
+    lTR = pITSloader->TreeR();
+  }
+  //
+  TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
+  TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
+  branch->SetAddress(&ptarray);
+  for (int module=0;moduleGetModuleDetTypeID(module);
+    AliITSUSimulation* sim = GetSimulationModel(id);
+    if (!sim) AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id));
+    sim->CreateFastRecPoints( GetModule(module) ,module,gRandom,ptarray);
+    lTR->Fill();
+    ptarray->Clear();
+  } // end for module
+  //
+  ClearModules();
+  fLoader->WriteRecPoints("OVERWRITE");
+  delete ptarray;
+}
+
+//_____________________________________________________________________
+Int_t AliITSU::Hits2Clusters(TTree *hTree, TTree *cTree)
+{
+  /* RS: TODO
+  // This function creates ITS clusters
+  if (!IsSimInitDone()) InitSimulation();
+  Int_t mmax = 0;
+  FillModules(hTree,0);
+  //
+  TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
+  TBranch *branch=cTree->GetBranch("ITSRecPoints");
+  if (!branch) cTree->Branch("ITSRecPoints",&points);
+  else branch->SetAddress(&points);
+  //
+  AliITSsimulationFastPoints sim;
+  Int_t ncl=0;
+  for (Int_t m=0; mGetEntriesFast();
+    cTree->Fill();
+    points->Clear();
+  }
+  //
+  ClearModules();
+  //
+  AliDebug(1,Form("Number of found fast clusters : %d",ncl));
+  //cTree->Write();
+  delete points;
+  */
+  return 0;
+}
+
+//_____________________________________________________________________
+void AliITSU::CheckLabels(Int_t lab[3]) const //RSDONE
+{
+  // Tries to find mother's labels
+  //
+  if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
+  //
+  Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
+  for (Int_t i=0;i<3;i++){
+    Int_t label = lab[i];
+    if (label>=0 && labelGetMCApp()->Particle(label);
+      if (part->P() < 0.005) {
+	Int_t m=part->GetFirstMother();
+	if (m<0) continue;
+	if (part->GetStatusCode()>0) continue;
+	lab[i]=m;       
+      }
+    }    
+  }
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::ResetDigits() //RSDONE?
+{
+  // Reset number of digits and the digits array for the ITS detector.
+  if (fDetDigits) for (int i=kNDetTypes;i--;) ResetDigits(i);
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::ResetDigits(Int_t branch)
+{
+  // Reset number of digits and the digits array for this branch.
+  if (fDetDigits) ((TClonesArray*)fDetDigits->At(branch))->Clear();
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::AddSumDigit(AliITSUSDigit &sdig)
+{
+  // Adds the module summable digits to the summable digits tree.
+  new( (*fSDigits)[fSDigits->GetEntriesFast()]) AliITSUSDigit(sdig);
+  //  
+}
+
+//______________________________________________________________________
+void AliITSU::AddSimDigit(Int_t branch, AliITSdigit *d)
+{
+  //    Add a simulated digit.
+  // Inputs:
+  //      Int_t id        Detector type number.
+  //      AliITSdigit *d  Digit to be added to the Digits Tree. See 
+  //                      AliITSdigit.h
+  TClonesArray &ldigits = *((TClonesArray*)fDetDigits->At(branch));
+  int nd = ldigits.GetEntriesFast();
+  switch(branch){
+  case AliITSUGeomTGeo::kDetTypePixUpg:
+    new(ldigits[nd]) AliITSUDigitPix(*((AliITSUDigitPix*)d));
+    break;
+  default:
+    AliFatal(Form("Unknown digits branch %d",branch));
+  }
+}
+
+//______________________________________________________________________
+void AliITSU::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
+			    Int_t *hits,Float_t *charges, Int_t sigexpanded)
+{
+  // Add a simulated digit to the list.
+  // Inputs:
+  //      Int_t id        Detector type number.
+  //      Float_t phys    Physics indicator. See AliITSdigits.h
+  //      Int_t *digits   Integer array containing the digits info. See 
+  //                      AliITSdigit.h
+  //      Int_t *tracks   Integer array [AliITSdigitS?D::GetNTracks()] 
+  //                      containing the track numbers that contributed to
+  //                      this digit.
+  //      Int_t *hits     Integer array [AliITSdigitS?D::GetNTracks()]
+  //                      containing the hit numbers, from AliITSmodule, that
+  //                      contributed to this digit.
+  //      Float_t *charge Floating point array of the signals contributed
+  //                      to this digit by each track.
+  TClonesArray &ldigits = *((TClonesArray*)fDetDigits->At(branch));
+  int nd = ldigits.GetEntriesFast();
+  switch(branch){
+  case AliITSUGeomTGeo::kDetTypePixUpg:
+    new(ldigits[nd]) AliITSUDigitPix(digits,tracks,hits);
+    break;
+  default:
+    AliFatal(Form("Unknown digits branch %d",branch));
+  }  
+  //
+}
+
+//______________________________________________________________________
+void AliITSU::Digits2Raw()
+{
+  AliError("Not ready");
+}
+
+//______________________________________________________________________
+AliLoader* AliITSU::MakeLoader(const char* topfoldername)
+{ 
+  //builds ITSgetter (AliLoader type)
+  //if detector wants to use castomized getter, it must overload this method
+  
+  AliDebug(1,Form("Creating AliITSULoader. Top folder is %s.",topfoldername));
+  fLoader = new AliITSULoader(GetName(),topfoldername);
+  return fLoader;
+}
+
+//______________________________________________________________________
+Bool_t AliITSU::Raw2SDigits(AliRawReader* rawReader)
+{
+  AliError("Not ready");
+  return kFALSE;
+}
+
+//______________________________________________________________________
+/*
+AliTriggerDetector* AliITSU::CreateTriggerDetector() const 
+{
+  // create an AliITSTrigger object (and set trigger conditions as input)
+  return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
+}
+*/
+
+//______________________________________________________________________
+void AliITSU::WriteFOSignals()
+{
+  // This method write FO signals in Digits tree both in Hits2Digits
+  // or SDigits2Digits
+  AliError("Not ready");
+  //  fDetTypeSim->ProcessNoiseForFastOr();
+}
+
+//_______________________________________________________________________
+void AliITSU::SDigits2Digits()
+{
+  // Standard Summable digits to Digits function.
+  //
+  if (!IsSimInitDone()) InitSimulation();
+  TTree* trees = fLoader->TreeS();
+  if( !(trees && fSDigits) ) AliFatal("Error: No trees or SDigits.");
+  TBranch* brchSDigits = trees->GetBranch(GetName());
+  //
+  int nmodules = fGeomTGeo->GetNModules();
+  for (int module=0;moduleGetModuleDetTypeID(module);
+    AliITSUSimulation *sim = GetSimulationModel(id);
+    if(!sim){
+      AliFatal(Form("The sim.class for module %d of DetTypeID %d is missing",module,id));
+      exit(1);
+    }
+    sim->InitSimulationModule(module,gAlice->GetEvNumber(),GetSegmentation(id));
+    fSDigits->Clear();
+    brchSDigits->GetEvent(module);
+    sim->AddSDigitsToModule(fSDigits,0);
+    sim->FinishSDigitiseModule();
+    fLoader->TreeD()->Fill();
+    ResetDigits();
+  }
+  //  WriteFOSignals(); 
+  fLoader->TreeD()->GetEntries();
+  fLoader->TreeD()->AutoSave();
+  fLoader->TreeD()->Reset();
+}
+
+//_______________________________________________________________________
+void AliITSU::InitSimulation()
+{
+  // Initialize arrays, segmentations ets, needed for simulation
+  // Equivalent of old AliITSDetTypeSim construction
+  //
+  if (fSimInitDone) {AliInfo("Already done"); return;}
+  //
+  fGeomTGeo     = new AliITSUGeomTGeo(kTRUE);
+  fSimuParam    = new AliITSUSimuParam();
+  fSensMap      = new AliITSUSensMap("AliITSUSDigit",0,0);
+  fSimulation   = new TObjArray(kNDetTypes);
+  fSegmentation = new TObjArray();
+  AliITSUSegmentationPix::LoadSegmentations(fSegmentation, AliITSUGeomTGeo::GetITSsegmentationFileName());
+  fSegmentation->SetOwner(kTRUE);
+  //
+  // add known simulation types used in the setup
+  for (int i=fNLayers;i--;) {
+    int sType = fGeomTGeo->GetLayerDetTypeID(i)/AliITSUGeomTGeo::kMaxSegmPerDetType;
+    if (fSimulation->At(sType)) continue;
+    //
+    AliITSUSimulation* simUpg = 0;
+    switch (sType) {
+    case AliITSUGeomTGeo::kDetTypePixUpg : 
+      simUpg = new AliITSUSimulationPix(fSimuParam,fSensMap); 
+      break;
+    default: AliFatal(Form("No %d detector type is defined",sType));
+    };
+    fSimulation->AddAtAndExpand(simUpg,sType);
+  }
+  //
+  InitArrays();
+  //
+  fSimInitDone = kTRUE;
+  //
+}
diff --git a/ITS/UPGRADE/AliITSU.h b/ITS/UPGRADE/AliITSU.h
new file mode 100644
index 00000000000..d14ed02a1f3
--- /dev/null
+++ b/ITS/UPGRADE/AliITSU.h
@@ -0,0 +1,155 @@
+#ifndef ALIITSU_H
+#define ALIITSU_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliITSU.h */
+
+////////////////////////////////////////////////////////////////////////
+//           Manager class for set: ITS Upgrade                       //
+////////////////////////////////////////////////////////////////////////
+
+
+#include  // used in inline function GetModule.
+#include "AliDetector.h"
+#include "AliITSTrigger.h"
+#include "AliITSDetTypeSim.h"
+#include "AliITSUGeomTGeo.h"
+
+class TString;
+class TTree;
+class AliITSUSDigit;
+class AliITSUSimulation;
+class AliITSsegmentation;
+class AliITSUModule;
+class AliITSCalibration;
+class AliITSUHit;
+class AliITSgeom;
+class AliITSdigit;
+class AliDigitizationInput;
+class AliITSUSensMap;
+class AliITSUSimuParam;
+
+
+class AliITSU : public AliDetector {
+
+ public:
+  //
+  // number detector types
+  enum {kNDetTypes = AliITSUGeomTGeo::kNDetTypes};
+  //
+  //================= Standard Classes ===============================
+  AliITSU();  // Default creator.
+  AliITSU(const char *title, Int_t nlayers); // extended standard Creator
+  virtual ~AliITSU(); // destructor
+  virtual Int_t IsVersion() const {return 11;}
+  
+  //===================== Simulation Geometry ========================
+  // get geometry version - detailed (major) or coarse (minor)
+  virtual Int_t GetMajorVersion() const {return -1;}
+  virtual Int_t GetMinorVersion() const {return -1;}
+  virtual void  GetGeometryVersion(Int_t &a,Int_t &b) const {a = GetMajorVersion();b=GetMinorVersion();return;}
+  virtual void  SetEUCLID(Bool_t euclid=kTRUE) {fEuclidOut = euclid;}
+  virtual Bool_t GetEUCLID()const {return fEuclidOut;}
+  //-------------------- Geometry Transformations --------------------
+  
+  // ITS geometry functions From Simulation
+  AliITSUGeomTGeo* GetITSGeomTGeo() const {return fGeomTGeo;}
+  //RS  AliITSgeom* GetITSgeom() const {return fDetTypeSim->GetITSgeom();}
+  //RS  void   SetITSgeom(AliITSgeom *geom) {fDetTypeSim->SetITSgeom(geom);}
+  // return pointer to the array of modules
+  
+  AliITSUModule   * GetModule(Int_t index) {return (AliITSUModule*)fModuleHits->UncheckedAt(index);}
+  AliITSUSimuParam* GetSimuParam() const {return fSimuParam;}
+    
+  //================ Necessary general Classes =======================
+  virtual void Init();
+  virtual AliLoader* MakeLoader(const char* topfoldername);
+  virtual void MakeBranch(Option_t *opt=" ");
+  virtual void MakeBranchS(const char* fl);
+  virtual void MakeBranchD(const char* file);
+  virtual void MakeBranchInTreeD(TTree* treeD, const char* file=0);
+  virtual void SetTreeAddress();
+  virtual AliITSUSimulation* GetSimulationModel(Int_t id) {return (AliITSUSimulation*)fSimulation->At(id/AliITSUGeomTGeo::kMaxSegmPerDetType);}
+  virtual AliITSsegmentation*  GetSegmentation(Int_t id)    {return (AliITSsegmentation*) fSegmentation->At(id);}
+  //=================== Hits =========================================
+  virtual void StepManager() {} // See Step Manager for specific geometry.
+  //------------ sort hits by module for Digitisation ----------------
+  virtual void FillModules(Int_t bgrev, Option_t *opt, const char *filename); 
+  virtual void FillModules(TTree *treeH, Int_t mask = 0);
+  virtual void ClearModules();
+  virtual void AddHit(Int_t track, Int_t *vol, Float_t *hits);
+  void         InitSimulation();
+  //
+  // Trigger
+  //  virtual AliTriggerDetector* CreateTriggerDetector() const;
+
+  AliDigitizer* CreateDigitizer(AliDigitizationInput* manager) const;
+  virtual void SDigits2Digits();
+  virtual void Hits2Digits(); 
+  virtual void Hits2SDigits();
+  virtual void Hits2Digits(Int_t evNumber,Int_t bgrev,Option_t *option, const char *filename);
+  virtual void Hits2SDigits(Int_t evNumber,Int_t bgrev,Option_t *option,const char *filename);
+    
+  virtual void ResetSDigits()       {if (fSDigits) fSDigits->Clear();}
+  virtual void ResetDigits();
+  virtual void ResetDigits(Int_t branch);
+  virtual void AddSumDigit(AliITSUSDigit &sdig);
+  virtual void AddSimDigit(Int_t branch, AliITSdigit *d);
+  virtual void AddSimDigit(Int_t branch,Float_t phys,Int_t* digits,Int_t* tracks,Int_t *hits,Float_t* trkcharges,Int_t sigexpanded=-1000);
+  TObjArray*   GetDigits()                const {return fDetDigits;}
+  TClonesArray *DigitsAddress(Int_t id)  {return fDetDigits ? (TClonesArray*)fDetDigits->At(id) : 0;}
+  //Fast simulation
+  virtual void  Hits2FastRecPoints(Int_t bgrev,Option_t *opr, const char *filename);
+  virtual Int_t Hits2Clusters(TTree *in, TTree *out);
+  virtual void  CheckLabels(Int_t lab[3]) const;
+
+  //===================== Raw Data IO ================================
+  // Write digits into raw data format
+  virtual void   Digits2Raw();
+  virtual Bool_t Raw2SDigits(AliRawReader*);
+    
+  //===================== FO signals ================================
+  // Write FO signals in UserInfo of SDigits/Digits tree
+  void    WriteFOSignals();
+
+  void    SetRunNumber(Int_t rn=0)        {fRunNumber = rn;}
+  Int_t   GetNLayers()              const {return fNLayers;}
+  Int_t   GetRunNumber()            const {return fRunNumber;}
+  Bool_t  IsSimInitDone()           const {return fSimInitDone;}
+
+ protected:
+  void        InitArrays();
+  const char* GetDigitClassName(Int_t i) {return Form("AliITSdigit%s",AliITSUGeomTGeo::GetDetTypeName(i));}
+  const char* GetDetTypeName(Int_t i) {return AliITSUGeomTGeo::GetDetTypeName(i);}
+  
+ protected:
+  //================== Data Members ==================================
+  Bool_t                fEuclidOut;      // Flag to write geometry in euclid format
+  Int_t                 fNLayers;        // the number of layers
+  Int_t                *fIdSens;         //[fNLayers] layer identifier
+  TString              *fLayerName;      //[fNLayers] layer identifier
+  Bool_t                fTiming;         // flag to turn on/off timers.
+  AliITSUSimuParam*   fSimuParam;      //simulation parameters
+  AliITSUGeomTGeo*    fGeomTGeo;       //  access to geometry details
+  TClonesArray**        fModA;           //! Used by Raw2SDigits (one TC per module)
+  TClonesArray*         fpSDigits;       //! Branch address to build SD from raw data 
+  TClonesArray*         fSDigits;        //! Branch address to build SD
+  TClonesArray*         fDetHits;        //! array of full detector hits
+  TObjArray*            fModuleHits;     //! module's hits container in (pointers on the fDetHits)
+  TObjArray*            fDetDigits;      //! AliDetector has TClonesArray fDigits, avoid same name
+  AliITSUSensMap*     fSensMap;        //! sensor map for digitization
+  //
+  TObjArray            *fSimulation;     //! simulation objects per det.type
+  TObjArray            *fSegmentation;   //! segmentation objects per det.type (and segmentation)
+  TObjArray            *fCalibration;    //! calibration objects
+  Int_t                 fRunNumber;      //! run number
+  Bool_t                fSimInitDone;    //! flag initialized simulation
+
+ private:
+  AliITSU(const AliITSU &source); // copy constructor. Not to be used!
+  AliITSU& operator=(const AliITSU &source); // = operator. Not to be used!
+  ClassDef(AliITSU,1) // Base class for ITS
+};
+
+#endif
diff --git a/ITS/UPGRADE/AliITSCalibrationPixUpg.cxx b/ITS/UPGRADE/AliITSUCalibrationPix.cxx
similarity index 77%
rename from ITS/UPGRADE/AliITSCalibrationPixUpg.cxx
rename to ITS/UPGRADE/AliITSUCalibrationPix.cxx
index 7ce9319ef96..cc8016fd9b8 100644
--- a/ITS/UPGRADE/AliITSCalibrationPixUpg.cxx
+++ b/ITS/UPGRADE/AliITSUCalibrationPix.cxx
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 #include "TArrayI.h"
-#include "AliITSCalibrationPixUpg.h"
+#include "AliITSUCalibrationPix.h"
 
 ///////////////////////////////////////////////////////////////////////////
 //
@@ -26,15 +26,15 @@
 //
 ///////////////////////////////////////////////////////////////////////////
 
-ClassImp(AliITSCalibrationPixUpg)
+ClassImp(AliITSUCalibrationPix)
 
 //______________________________________________________________________
-AliITSCalibrationPixUpg::AliITSCalibrationPixUpg() 
+AliITSUCalibrationPix::AliITSUCalibrationPix() 
 : fNChips(0)
   ,fNColPerChip(0)
   ,fNCol(0)
   ,fNRow(0)
-  ,fNrBad(0)
+  ,fNrBadSingle(0)
   ,fBadChips(0)
   ,fBadChannels(0)
 {
@@ -44,12 +44,12 @@ AliITSCalibrationPixUpg::AliITSCalibrationPixUpg()
 }
 
 //______________________________________________________________________
-AliITSCalibrationPixUpg::AliITSCalibrationPixUpg(Short_t nChips,Short_t nColPerChip,Short_t nRow) 
+AliITSUCalibrationPix::AliITSUCalibrationPix(Short_t nChips,Short_t nColPerChip,Short_t nRow) 
 : fNChips(0)
   ,fNColPerChip(0)
   ,fNCol(0)
   ,fNRow(0)
-  ,fNrBad(0)
+  ,fNrBadSingle(0)
   ,fBadChips(0)
   ,fBadChannels(0)
 {
@@ -60,40 +60,40 @@ AliITSCalibrationPixUpg::AliITSCalibrationPixUpg(Short_t nChips,Short_t nColPerC
 }
 
 //______________________________________________________________________
-AliITSCalibrationPixUpg::AliITSCalibrationPixUpg(const AliITSCalibrationPixUpg &src) : 
+AliITSUCalibrationPix::AliITSUCalibrationPix(const AliITSUCalibrationPix &src) : 
   AliITSCalibration(src)
   ,fNChips(src.fNChips)
   ,fNColPerChip(src.fNColPerChip)
   ,fNCol(src.fNCol)
   ,fNRow(src.fNRow)
-  ,fNrBad(src.fNrBad)
+  ,fNrBadSingle(src.fNrBadSingle)
   ,fBadChips(src.fBadChips)
   ,fBadChannels(src.fBadChannels)
 {
 }
 
 //____________________________________________________________________________
-void AliITSCalibrationPixUpg::ClearBad() 
+void AliITSUCalibrationPix::ClearBad() 
 {
   // clear all bad pixels (single+chips)
   fBadChannels.Reset();
-  fNrBad=0;
+  fNrBadSingle=0;
   fBadChips = 0;
   //
 }
 
 //____________________________________________________________________________
-void AliITSCalibrationPixUpg::AddBad(Int_t col, Int_t row) 
+void AliITSUCalibrationPix::AddBad(Int_t col, Int_t row) 
 {
   // add single bad pixel 
-  fBadChannels.Set(fNrBad*2+2);
-  fBadChannels.AddAt(col,fNrBad*2);
-  fBadChannels.AddAt(row,fNrBad*2+1);
-  fNrBad++;
+  fBadChannels.Set(fNrBadSingle*2+2);
+  fBadChannels.AddAt(col,fNrBadSingle*2);
+  fBadChannels.AddAt(row,fNrBadSingle*2+1);
+  fNrBadSingle++;
 }
 
 //____________________________________________________________________________
-void AliITSCalibrationPixUpg::SetChipBad(Int_t chip) 
+void AliITSUCalibrationPix::SetChipBad(Int_t chip) 
 {
   // set full chip bad
   if ((int)chip>=fNChips) {AliError(Form("chip number %d exceeds allowed limit %d",chip,fNChips)); return;}
@@ -102,7 +102,7 @@ void AliITSCalibrationPixUpg::SetChipBad(Int_t chip)
 }
 
 //____________________________________________________________________________
-void AliITSCalibrationPixUpg::UnSetChipBad(Int_t chip) 
+void AliITSUCalibrationPix::UnSetChipBad(Int_t chip) 
 {
   // unset full chip bad
   if (chip>=fNChips) {AliError(Form("chip number %d exceeds allowed limit %d",chip,fNChips)); return;}
@@ -111,7 +111,7 @@ void AliITSCalibrationPixUpg::UnSetChipBad(Int_t chip)
 }
 
 //____________________________________________________________________________
-Int_t AliITSCalibrationPixUpg::GetBadColAt(Int_t index) const 
+Int_t AliITSUCalibrationPix::GetBadColAt(Int_t index) const 
 {
   // Get column of index-th bad pixel
   int nrc = fNColPerChip*fNRow;
@@ -134,7 +134,7 @@ Int_t AliITSCalibrationPixUpg::GetBadColAt(Int_t index) const
 }
 
 //____________________________________________________________________________
-Int_t AliITSCalibrationPixUpg::GetBadRowAt(Int_t index) const 
+Int_t AliITSUCalibrationPix::GetBadRowAt(Int_t index) const 
 {
   // Get row of index-th bad pixel
   int nrc = fNColPerChip*fNRow;
@@ -157,7 +157,7 @@ Int_t AliITSCalibrationPixUpg::GetBadRowAt(Int_t index) const
 }
 
 //____________________________________________________________________________
-void AliITSCalibrationPixUpg::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const 
+void AliITSUCalibrationPix::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const 
 {
   // i: is the i-th bad pixel in single bad pixel list
   // row: is the corresponding row (-1 if i is out of range)
@@ -189,27 +189,38 @@ void AliITSCalibrationPixUpg::GetBadPixel(Int_t index, Int_t &row, Int_t &col) c
   AliError(Form("Index %d is out of bounds - nothing done",index));
 }
 
+//____________________________________________________________________________
+void AliITSUCalibrationPix::GetBadPixelSingle(Int_t index, UInt_t &row, UInt_t &col) const 
+{
+  // i: is the i-th bad pixel in single bad pixel list
+  // row: is the corresponding row (-1 if i is out of range)
+  // col: is the corresponding column (-1 if i is out of range)
+  if(index<0 && index>=GetNrBadSingle())  AliFatal(Form("Index %d >= NrBadSingle=%d",index,fNrBadSingle));
+  col = fBadChannels.At(index*2);
+  row = fBadChannels.At(index*2+1);
+}
+
 //___________________________________________________________________________
-Int_t  AliITSCalibrationPixUpg::GetNrBad() const 
+Int_t  AliITSUCalibrationPix::GetNrBad() const 
 {
   // Total number of bad pixels (including bad chips) in a given module
   Int_t bad=0;
   // single pixels:
-  bad += fNrBad;
+  bad += fNrBadSingle;
   // whole chips:
   for (int chip=fNChips; chip--;) if (IsChipMarkedBad(chip)) bad += fNColPerChip*fNRow;
   return bad;
 }
 
 //___________________________________________________________________________
-Int_t  AliITSCalibrationPixUpg::GetNrBadInChip(Int_t chip) const 
+Int_t  AliITSUCalibrationPix::GetNrBadInChip(Int_t chip) const 
 {
   // Total number of bad pixels (including bad chips) in a given chip
   if(chip<0 || chip>=fNChips) {AliError("Wrong chip number"); return -1;}
   if (IsChipMarkedBad(chip)) return fNColPerChip*fNRow;
   else {
     Int_t bad=0;
-    for (int i=fNrBad; i--;) {
+    for (int i=fNrBadSingle; i--;) {
       Int_t col = GetBadColAt(i);
       if (col!=-1) if (GetChipIndexFromCol(col)==chip) bad++;
     }
@@ -218,20 +229,20 @@ Int_t  AliITSCalibrationPixUpg::GetNrBadInChip(Int_t chip) const
 }
 
 //___________________________________________________________________________
-Int_t  AliITSCalibrationPixUpg::GetNrBadInColumn(Int_t col) const 
+Int_t  AliITSUCalibrationPix::GetNrBadInColumn(Int_t col) const 
 {
   // Total number of bad pixels (including bad chips) in a given column: col. range
   if(col<0 || col>=fNCol) {AliError("Wrong column number"); return -1;}
   if (IsChipMarkedBad(GetChipIndexFromCol(col))) return fNRow;
   else {
     Int_t bad=0;
-    for (int i=fNrBad; i--;) if (GetBadColAt(i)==col) bad++;
+    for (int i=fNrBadSingle; i--;) if (GetBadColAt(i)==col) bad++;
     return bad;
   }
 }
 
 //______________________________________________________________________
-Bool_t AliITSCalibrationPixUpg::IsBad() const 
+Bool_t AliITSUCalibrationPix::IsBad() const 
 {
   // Are all chips of this module bad?
   for (Int_t chip=fNChips; chip--;) if (!IsChipMarkedBad(chip)) return kFALSE;
@@ -239,32 +250,32 @@ Bool_t AliITSCalibrationPixUpg::IsBad() const
 }
 
 //______________________________________________________________________
-Bool_t AliITSCalibrationPixUpg::IsChipBad(Int_t chip) const 
+Bool_t AliITSUCalibrationPix::IsChipBad(Int_t chip) const 
 {
   // Is the full chip bad?
   return (GetNrBadInChip(chip)==fNColPerChip*fNRow);
 }
 
 //______________________________________________________________________
-Bool_t AliITSCalibrationPixUpg::IsColumnBad(Int_t col) const 
+Bool_t AliITSUCalibrationPix::IsColumnBad(Int_t col) const 
 {
   // Is the full column bad?
   return (GetNrBadInColumn(col)==fNRow);
 }
 
 //____________________________________________________________________________
-Bool_t AliITSCalibrationPixUpg::IsPixelBad(Int_t col, Int_t row) const 
+Bool_t AliITSUCalibrationPix::IsPixelBad(Int_t col, Int_t row) const 
 {
   // Is this pixel bad?
   if(col<0 || col>=fNCol) {AliError("Wrong column number"); return kFALSE;}
   Int_t chip = GetChipIndexFromCol(col);
   if (IsChipMarkedBad(chip)) return kTRUE;
-  for (Int_t i=fNrBad; i--;) if (GetBadColAt(i)==col && GetBadRowAt(i)==row) return kTRUE;
+  for (Int_t i=fNrBadSingle; i--;) if (GetBadColAt(i)==col && GetBadRowAt(i)==row) return kTRUE;
   return kFALSE;
 }
 
 //______________________________________________________________________
-Int_t AliITSCalibrationPixUpg::GetChipIndexFromCol(Int_t col) const 
+Int_t AliITSUCalibrationPix::GetChipIndexFromCol(Int_t col) const 
 {
   // returns chip index for specific column
   if(col>=fNCol) {AliWarning("Wrong column number"); return -1;}
@@ -272,14 +283,14 @@ Int_t AliITSCalibrationPixUpg::GetChipIndexFromCol(Int_t col) const
 }
 
 //______________________________________________________________________
-void AliITSCalibrationPixUpg::SetNrBad(Int_t /*nr*/) 
+void AliITSUCalibrationPix::SetNrBad(Int_t /*nr*/) 
 {
   // should not be used anymore !!!
   AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
 }
 
 //____________________________________________________________________________
-void  AliITSCalibrationPixUpg::SetColRowData(Short_t nchip, Short_t ncolperchip, Short_t nrow) 
+void  AliITSUCalibrationPix::SetColRowData(Short_t nchip, Short_t ncolperchip, Short_t nrow) 
 {
   // set segmentation data
   fNChips = nchip; 
diff --git a/ITS/UPGRADE/AliITSCalibrationPixUpg.h b/ITS/UPGRADE/AliITSUCalibrationPix.h
similarity index 75%
rename from ITS/UPGRADE/AliITSCalibrationPixUpg.h
rename to ITS/UPGRADE/AliITSUCalibrationPix.h
index 8da3efe5b9a..1f7cf6116b6 100644
--- a/ITS/UPGRADE/AliITSCalibrationPixUpg.h
+++ b/ITS/UPGRADE/AliITSUCalibrationPix.h
@@ -1,9 +1,9 @@
-#ifndef ALIITSCALIBRATIONPIXUPG_H
-#define ALIITSCALIBRATIONPIXUPG_H
+#ifndef ALIITSUCALIBRATIONPIX_H
+#define ALIITSUCALIBRATIONPIX_H
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id: AliITSCalibrationPixUpg.h 53595 2011-12-14 16:13:16Z masera $ */
+/* $Id: AliITSUCalibrationPix.h 53595 2011-12-14 16:13:16Z masera $ */
 //#include "TRandom.h"
 #include "AliITSCalibration.h"
 #include "TArrayS.h"
@@ -13,13 +13,13 @@
 // ITS response class for pixels                  //
 ////////////////////////////////////////////////////
 
-class AliITSCalibrationPixUpg :  public AliITSCalibration {
+class AliITSUCalibrationPix :  public AliITSCalibration {
  public:
-    AliITSCalibrationPixUpg(); // default constructor
-    AliITSCalibrationPixUpg(Short_t nChips,Short_t nColPerChip,Short_t nRow); // default constructor
-    AliITSCalibrationPixUpg(const AliITSCalibrationPixUpg &src);
+    AliITSUCalibrationPix(); // default constructor
+    AliITSUCalibrationPix(Short_t nChips,Short_t nColPerChip,Short_t nRow); // default constructor
+    AliITSUCalibrationPix(const AliITSUCalibrationPix &src);
     //    
-    virtual ~AliITSCalibrationPixUpg() {;} // destructror
+    virtual ~AliITSUCalibrationPix() {;} // destructror
 
     virtual void   ClearBad();
 
@@ -30,9 +30,10 @@ class AliITSCalibrationPixUpg :  public AliITSCalibration {
     virtual Int_t  GetBadColAt(Int_t index) const;
     virtual Int_t  GetBadRowAt(Int_t index) const;
     virtual void   GetBadPixel(Int_t index, Int_t &row, Int_t &col) const;
+    virtual void   GetBadPixelSingle(Int_t i,UInt_t &row, UInt_t &col) const;
 
-    virtual Int_t  GetNrBadSingle() const {return fNrBad;}
-    virtual void   SetNrBadSingle(Int_t nr) {fNrBad=nr;} // used to be called SetNrBad, but misleading
+    virtual Int_t  GetNrBadSingle() const {return fNrBadSingle;}
+    virtual void   SetNrBadSingle(Int_t nr) {fNrBadSingle=nr;} // used to be called SetNrBad, but misleading
     virtual void   SetBadList(TArrayS badlist) {fBadChannels=badlist;}
     virtual void   SetNrBad(Int_t /*nr*/); // Use SetNrBadSingle!!!
 
@@ -69,13 +70,13 @@ class AliITSCalibrationPixUpg :  public AliITSCalibration {
     Short_t  fNColPerChip;     // n of columns per chip
     Short_t  fNCol;            // number of columns
     Short_t  fNRow;            // number of rows
-    Int_t    fNrBad;           // Nr of SINGLE bad pixels
+    Int_t    fNrBadSingle;     // Nr of SINGLE bad pixels
     UInt_t   fBadChips;        // bit pattern of completely dead chips?
-    TArrayS  fBadChannels;     // Array with bad channels info (col0,row0,col1...rowN) N = fNrBad
+    TArrayS  fBadChannels;     // Array with bad channels info (col0,row0,col1...rowN) N = fNrBadSingle
     //
-    AliITSCalibrationPixUpg& operator=(const AliITSCalibrationPixUpg& source);
+    AliITSUCalibrationPix& operator=(const AliITSUCalibrationPix& source);
     //
-    ClassDef(AliITSCalibrationPixUpg,1) // pixels response
+    ClassDef(AliITSUCalibrationPix,1) // pixels response
 };
 
 #endif
diff --git a/ITS/UPGRADE/AliITSdigitPixUpg.cxx b/ITS/UPGRADE/AliITSUDigitPix.cxx
similarity index 89%
rename from ITS/UPGRADE/AliITSdigitPixUpg.cxx
rename to ITS/UPGRADE/AliITSUDigitPix.cxx
index a99141da27b..21e5437f586 100644
--- a/ITS/UPGRADE/AliITSdigitPixUpg.cxx
+++ b/ITS/UPGRADE/AliITSUDigitPix.cxx
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-#include 
+#include 
 #include 
 
 ///////////////////////////////////////////////////////////////////
@@ -24,10 +24,10 @@
 //                                                               //
 ///////////////////////////////////////////////////////////////////
 
-ClassImp(AliITSdigitPixUpg)
+ClassImp(AliITSUDigitPix)
 
 //______________________________________________________________________
-AliITSdigitPixUpg::AliITSdigitPixUpg():AliITSdigit(),
+AliITSUDigitPix::AliITSUDigitPix():AliITSdigit(),
 fSignalPix(0){
     // default constructor, zero coordinates and set array
     // elements to clearly unphysical values. A value of 0 may
@@ -39,7 +39,7 @@ fSignalPix(0){
 }
 
 //______________________________________________________________________
-AliITSdigitPixUpg::AliITSdigitPixUpg(const Int_t *digits):
+AliITSUDigitPix::AliITSUDigitPix(const Int_t *digits):
   fSignalPix(digits[2])
 {
     // Creates a pixel digit object
@@ -53,7 +53,7 @@ AliITSdigitPixUpg::AliITSdigitPixUpg(const Int_t *digits):
 }
 
 //______________________________________________________________________
-AliITSdigitPixUpg::AliITSdigitPixUpg(const Int_t *digits,const Int_t *tracks,
+AliITSUDigitPix::AliITSUDigitPix(const Int_t *digits,const Int_t *tracks,
 			       const Int_t *hits):
 fSignalPix(digits[2])
 {
@@ -69,7 +69,7 @@ fSignalPix(digits[2])
 }
 
 //______________________________________________________________________
-Int_t AliITSdigitPixUpg::GetListOfTracks(TArrayI &t)
+Int_t AliITSUDigitPix::GetListOfTracks(TArrayI &t)
 {
     // Fills the TArrayI t with the tracks found in fTracks removing
     // duplicated tracks, but otherwise in the same order. It will return
@@ -102,7 +102,7 @@ Int_t AliITSdigitPixUpg::GetListOfTracks(TArrayI &t)
 }
 
 //______________________________________________________________________
-void AliITSdigitPixUpg::Print(ostream *os)
+void AliITSUDigitPix::Print(ostream *os)
 {
     //Standard output format for this class
     Int_t i;
@@ -114,7 +114,7 @@ void AliITSdigitPixUpg::Print(ostream *os)
 }
 
 //______________________________________________________________________
-void AliITSdigitPixUpg::Read(istream *os)
+void AliITSUDigitPix::Read(istream *os)
 {
     //Standard input for this class
     Int_t i;
@@ -126,7 +126,7 @@ void AliITSdigitPixUpg::Read(istream *os)
 }
 
 //______________________________________________________________________
-ostream &operator<<(ostream &os,AliITSdigitPixUpg &source)
+ostream &operator<<(ostream &os,AliITSUDigitPix &source)
 {
     // Standard output streaming function.
 
@@ -135,7 +135,7 @@ ostream &operator<<(ostream &os,AliITSdigitPixUpg &source)
 }
 
 //______________________________________________________________________
-istream &operator>>(istream &os,AliITSdigitPixUpg &source)
+istream &operator>>(istream &os,AliITSUDigitPix &source)
 {
     // Standard output streaming function.
 
diff --git a/ITS/UPGRADE/AliITSdigitPixUpg.h b/ITS/UPGRADE/AliITSUDigitPix.h
similarity index 70%
rename from ITS/UPGRADE/AliITSdigitPixUpg.h
rename to ITS/UPGRADE/AliITSUDigitPix.h
index 9c38c11c64b..59d1c974051 100644
--- a/ITS/UPGRADE/AliITSdigitPixUpg.h
+++ b/ITS/UPGRADE/AliITSUDigitPix.h
@@ -8,14 +8,14 @@
 #include 
 
 //______________________________________________________________________
-class AliITSdigitPixUpg: public AliITSdigit {
+class AliITSUDigitPix: public AliITSdigit {
 
  public:
-    AliITSdigitPixUpg(); //default creator
-    AliITSdigitPixUpg(const Int_t *digits);//standard creator digits only
+    AliITSUDigitPix(); //default creator
+    AliITSUDigitPix(const Int_t *digits);//standard creator digits only
     //standard creator with digits, tracks, and hits
-    AliITSdigitPixUpg(const Int_t *digits,const Int_t *tracks,const Int_t *hits);
-    virtual ~AliITSdigitPixUpg(){/*destructor*/}
+    AliITSUDigitPix(const Int_t *digits,const Int_t *tracks,const Int_t *hits);
+    virtual ~AliITSUDigitPix(){/*destructor*/}
     // returns the signal in electrons
     Int_t GetSignalPix() const {return fSignalPix;}
     virtual Int_t GetListOfTracks(TArrayI &t);
@@ -30,11 +30,11 @@ class AliITSdigitPixUpg: public AliITSdigit {
     
     Int_t fSignalPix;   // Signal in electrons
 
-    ClassDef(AliITSdigitPixUpg,1)   // Simulated digit object for Pixels
+    ClassDef(AliITSUDigitPix,1)   // Simulated digit object for Pixels
 
 };
 // Input and output functions for standard C++ input/output.
-ostream &operator<<(ostream &os,AliITSdigitPixUpg &source);
-istream &operator>>(istream &os,AliITSdigitPixUpg &source);
+ostream &operator<<(ostream &os,AliITSUDigitPix &source);
+istream &operator>>(istream &os,AliITSUDigitPix &source);
 
 #endif
diff --git a/ITS/UPGRADE/AliITSUDigitizer.cxx b/ITS/UPGRADE/AliITSUDigitizer.cxx
new file mode 100644
index 00000000000..2ec5d7f20f4
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUDigitizer.cxx
@@ -0,0 +1,252 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+ 
+/* $Id: AliITSUDigitizer.cxx 52261 2011-10-23 15:46:57Z hristov $ */
+///////////////////////////////////////////////////////////////////////////
+//Piotr.Skowronski@cern.ch :                                             //
+//Corrections applied in order to compile (only)                         // 
+//   with new I/O and folder structure                                   //
+//To be implemented correctly by responsible                             //
+//                                                                       //
+//  Class used to steer                                                  //
+//  the digitization for ITS                                             //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+#include 
+#include 
+#include 
+#include 
+
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliLoader.h"
+#include "AliLog.h"
+#include "AliDigitizationInput.h"
+#include "AliITSUDigitizer.h"
+#include "AliITSUGeomTGeo.h"
+#include "AliITSUSimulation.h"
+#include "AliITSUSDigit.h"
+
+ClassImp(AliITSUDigitizer)
+
+//______________________________________________________________________
+AliITSUDigitizer::AliITSUDigitizer() 
+:  fITS(0)
+  ,fModActive(0)
+  ,fInit(kFALSE)
+  ,fRoif(-1)
+  ,fRoiifile(0)
+  ,fFlagFirstEv(kTRUE)
+{
+  // Default constructor.
+}
+
+//______________________________________________________________________
+AliITSUDigitizer::AliITSUDigitizer(AliDigitizationInput* digInp) 
+  :AliDigitizer(digInp)
+  ,fITS(0)
+  ,fModActive(0)
+  ,fInit(kFALSE)
+  ,fRoif(-1)
+  ,fRoiifile(0)
+  ,fFlagFirstEv(kTRUE)
+{
+  // Standard constructor.
+}
+
+//______________________________________________________________________
+AliITSUDigitizer::~AliITSUDigitizer()
+{
+  // destructor. 
+  fITS = 0; // don't delete fITS. Done else where.
+  delete[] fModActive;
+}
+
+//______________________________________________________________________
+Bool_t AliITSUDigitizer::Init()
+{
+  // Initialization. Set up region of interest, if switched on, and loads ITS and ITSgeom.
+  //
+  if (fInit) return kTRUE;
+  //
+  fInit = kTRUE; // Assume for now init will work.
+  //
+  if(!gAlice) {
+    fITS      = 0;
+    fRoiifile = 0;
+    fInit     = kFALSE;
+    AliFatal("gAlice not found");
+  } // end if
+  //
+  fITS = (AliITSU *)(gAlice->GetDetector("ITS"));
+  if(!fITS){
+    fRoiifile = 0;
+    fInit     = kFALSE;
+    AliFatal("ITS not found");
+  } 
+  int nm = fITS->GetITSGeomTGeo()->GetNModules();
+  fModActive = new Bool_t[nm];
+  for (Int_t i=nm;i--;) fModActive[i] = kTRUE;
+
+  return fInit;
+}
+
+//______________________________________________________________________
+void AliITSUDigitizer::Digitize(Option_t* opt)
+{
+  // Main digitization function. 
+  //
+  if (!fInit) AliFatal("Init not successful, aborting.");
+  //
+  Int_t nfiles = GetDigInput()->GetNinputs();
+  Int_t event  = GetDigInput()->GetOutputEventNr();
+  //
+  TString loadname = Form("%sLoader",fITS->GetName());
+  //
+  AliITSUGeomTGeo* geom = fITS->GetITSGeomTGeo();
+  Int_t nModules  = geom->GetNModules();
+  Bool_t lmod;
+  Int_t *fl = new Int_t[nfiles];
+  fl[0] = fRoiifile;
+  int mask = 1;
+  for (int id=0;idGetOutputFolderName());    
+  if (!outRL) AliFatal("Can not get Output Run Loader");
+  //
+  outRL->GetEvent(event);
+  outgime = outRL->GetLoader(loadname);
+  if ( outgime == 0x0) AliFatal("Can not get Output ITS Loader");
+  //
+  outgime->LoadDigits("update");
+  if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
+  //
+  // Digitize
+  fITS->MakeBranchInTreeD(outgime->TreeD());
+  if(fRoif!=0) AliDebug(1,"Region of Interest digitization selected");
+  else         AliDebug(1,"No Region of Interest selected. Digitizing everything");
+  //
+  for (int ifiles=0; ifilesGetInputFolderName(fl[ifiles]));
+    ingime = inRL->GetLoader(loadname);
+    if (ingime->TreeS() == 0x0) ingime->LoadSDigits();
+  }
+  //
+  for (int module=0; moduleGetModuleDetTypeID(module);
+    AliITSUSimulation *sim = fITS->GetSimulationModel(id);
+    if (!sim) AliFatal(Form("The simulation model %d is not available",id));
+    //
+    // Fill the module with the sum of SDigits
+    sim->InitSimulationModule(module, event, fITS->GetSegmentation(id));
+    //
+    for (int ifiles=0; ifilesGetInputFolderName(fl[ifiles]));
+      ingime = inRL->GetLoader(loadname);
+      //
+      TTree *treeS = ingime->TreeS();
+      fITS->SetTreeAddress();
+      //
+      if( !treeS  ) continue; 
+      TBranch *brchSDigits = treeS->GetBranch( fITS->GetName() );
+      if( brchSDigits )	brchSDigits->SetAddress( &sdig ); 
+      else {
+	AliError(Form("branch ITS not found in TreeS, input file %d ", ifiles));
+	delete [] fl;
+	return;
+      } 
+      //
+      sdig->Clear();
+      mask = GetDigInput()->GetMask(ifiles);
+      brchSDigits->GetEvent( module );
+      lmod = sim->AddSDigitsToModule(sdig,mask);
+      if(GetRegionOfInterest() && !ifiles) fModActive[module] = lmod;
+      //
+    } 
+    // Digitize current module sum(SDigits)->Digits
+    sim->FinishSDigitiseModule();
+    //
+    outgime->TreeD()->Fill();       // fills all branches - wasted disk space
+    fITS->ResetDigits();
+  } // end for module
+  //
+  //  fITS->WriteFOSignals(); 
+  outgime->TreeD()->AutoSave();
+  outgime->WriteDigits("OVERWRITE");
+  outgime->UnloadDigits();
+  for(int ifiles=0; ifilesGetInputFolderName(fl[ifiles]));
+    ingime = inRL->GetLoader(loadname);
+    ingime->UnloadSDigits();
+  }
+  //
+  delete[] fl;
+  sdig->Clear();
+  delete sdig;
+  for (Int_t i=nModules;i--;) fModActive[i] = kTRUE;
+  //
+  return;
+}
+
+//______________________________________________________________________
+void AliITSUDigitizer::SetByRegionOfInterest(TTree *ts)
+{
+  // Scans through the ITS branch of the SDigits tree, ts, for modules
+  // which have SDigits in them. For these modules, a flag is set to
+  // digitize only these modules. The value of fRoif determines how many
+  // neighboring modules will also be turned on. fRoif=0 will turn on only
+  // those modules with SDigits in them. fRoif=1 will turn on, in addition,
+  // those modules that are +-1 module from the one with the SDigits. And
+  // So on. This last feature is not supported yet.
+  // Inputs:
+  //      TTree *ts  The tree in which the existing SDigits will define the
+  //                 region of interest.
+  if (fRoif==0) return;
+  if (ts==0)    return;
+  TBranch *brchSDigits = ts->GetBranch(fITS->GetName());
+  TClonesArray * sdig = new TClonesArray( "AliITSUSDigit",1000 );
+  //
+  if( brchSDigits ) brchSDigits->SetAddress( &sdig );
+  else  {AliError("Branch ITS not found in TreeS"); return;}
+  //
+  int nm = fITS->GetITSGeomTGeo()->GetNModules();
+  for (int m=0;mClear();
+    brchSDigits->GetEvent(m);
+    int ndig = sdig->GetEntries();
+    for(int i=0;iAt(m))->GetSumSignal()>0.0 ) { // Must have non zero signal.
+	fModActive[m] = kTRUE;
+	break;
+      } // end if
+    } // end if. end for i.
+  } // end for m
+  AliDebug(1,"Digitization by Region of Interest selected");
+  sdig->Clear();
+  delete sdig;
+  return;
+}
diff --git a/ITS/UPGRADE/AliITSUDigitizer.h b/ITS/UPGRADE/AliITSUDigitizer.h
new file mode 100644
index 00000000000..48f1c4dfed4
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUDigitizer.h
@@ -0,0 +1,48 @@
+#ifndef ALIITSUDIGITIZER_H
+#define ALIITSUDIGITIZER_H
+/* Copyright (c) 1998-2001, ALICE Experiment at CERN, All rights reserved *
+ * See cxx source for full Copyright notice                               */
+
+/*
+  $Id: AliITSUDigitizer.h 52261 2011-10-23 15:46:57Z hristov $
+ */
+//////////////////////////////////////////////////////////////////
+// Digitizer class for ITS                                      //
+//////////////////////////////////////////////////////////////////
+class TObjArray;
+class TTree;
+
+class AliDigitizationInput;
+
+#include "AliDigitizer.h" // Base class from which this one is derived
+#include "AliITSU.h"   // ITS class functions used in inline functions.
+
+class AliITSUDigitizer : public AliDigitizer {
+ public:
+  AliITSUDigitizer();
+  AliITSUDigitizer(AliDigitizationInput* digInput);
+  
+  virtual ~AliITSUDigitizer();
+  virtual Bool_t Init();
+  virtual void Digitize(Option_t* opt=0);
+  virtual void SetModuleActive(Int_t i){if(fModActive) fModActive[i] = kTRUE;}
+  virtual void SetModuleInActive(Int_t i){if(fModActive) fModActive[i] = kFALSE;}
+  virtual void SetByRegionOfInterestFlag(Int_t i=0){fRoif = i;};
+  virtual void SetByRegionOfFileNumber(Int_t i=-1){fRoiifile = i;};
+  virtual void ClearByRegionOfInterestFlag(){fRoif = 0;};
+ private:
+  AliITSUDigitizer(const AliITSUDigitizer& dig);
+  AliITSUDigitizer& operator=(const AliITSUDigitizer &source);
+  AliDigitizationInput* GetDigInput(){return fDigInput;}
+  virtual void SetByRegionOfInterest(TTree *ts);
+ private:
+  AliITSU *fITS;      //! local pointer to ITS
+  Bool_t    *fModActive;//! flag to indicate which module to digitize.
+  Bool_t     fInit;     //! flag to indecate Initilization when well.
+  Int_t      fRoif;     //! Region of interest flag.
+  Int_t      fRoiifile; //! The file number with which to determing the region of interest from.
+  Bool_t     fFlagFirstEv; //! Flag to control calibration access
+  
+  ClassDef(AliITSUDigitizer,1) // Task to Digitize ITS from summable hits.
+};
+#endif
diff --git a/ITS/UPGRADE/AliITSgeomTGeoUpg.cxx b/ITS/UPGRADE/AliITSUGeomTGeo.cxx
similarity index 53%
rename from ITS/UPGRADE/AliITSgeomTGeoUpg.cxx
rename to ITS/UPGRADE/AliITSUGeomTGeo.cxx
index 9059de04df7..31140f3c624 100644
--- a/ITS/UPGRADE/AliITSgeomTGeoUpg.cxx
+++ b/ITS/UPGRADE/AliITSUGeomTGeo.cxx
@@ -14,7 +14,7 @@
  **************************************************************************/
 
 ///////////////////////////////////////////////////////////////////////////
-//    AliITSgeomTGeoUpg is a simple interface class to TGeoManager       //
+//    AliITSUGeomTGeo is a simple interface class to TGeoManager       //
 //    It is used in the simulation and reconstruction in order to        //
 //    query the TGeo ITS geometry                                        //
 //                                                                       //
@@ -22,6 +22,9 @@
 //    15/02/2007                                                         //
 //    adapted to ITSupg 18/07/2012 - ruben.shahoyan@cern.ch              //
 //                                                                       //
+//    ATTENTION: In opposite to ols AliITSgeomTGeo, all indices start    //
+//    from 0, not from 1!!!                                              //
+//                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
 #include 
@@ -30,182 +33,221 @@
 #include 
 #include 
 
-#include "AliITSgeomTGeoUpg.h"
+#include "AliITSUGeomTGeo.h"
 #include "AliLog.h"
 #include "AliAlignObj.h"
 
-ClassImp(AliITSgeomTGeoUpg)
+ClassImp(AliITSUGeomTGeo)
+
 
+const char* AliITSUGeomTGeo::fgkITSVolName = "ITSV";
+const char* AliITSUGeomTGeo::fgkITSLrName  = "ITSupgLayer";
+const char* AliITSUGeomTGeo::fgkITSLadName = "ITSupgLadder";
+const char* AliITSUGeomTGeo::fgkITSModName = "ITSupgModule";
+const char* AliITSUGeomTGeo::fgkITSSensName ="ITSupgSensor";
+const char* AliITSUGeomTGeo::fgkITSDetTypeName[AliITSUGeomTGeo::kNDetTypes] = {"PixUpg"};
+//
+TString     AliITSUGeomTGeo::fgITSsegmFileName = "itsSegmentations.root";
 
-const char* AliITSgeomTGeoUpg::fgkITSVolName = "ITSV";
-const char* AliITSgeomTGeoUpg::fgkITSLrName  = "ITSupgLayer";
-const char* AliITSgeomTGeoUpg::fgkITSLadName = "ITSupgLadder";
-const char* AliITSgeomTGeoUpg::fgkITSModName = "ITSupgModule";
-const char* AliITSgeomTGeoUpg::fgkITSSensName ="ITSupgSensor";
+//______________________________________________________________________
+AliITSUGeomTGeo::AliITSUGeomTGeo(Bool_t build)
+:  fVersion(kITSVNA)
+  ,fNLayers(0)
+  ,fNModules(0)
+  ,fNLadders(0)
+  ,fLrDetType(0)
+  ,fNDetectors(0)
+  ,fLastModIndex(0)
+{
+  // default c-tor
+  if (build) BuildITS();
+}
 
-const Int_t AliITSgeomTGeoUpg::fgkNModulesOld = 2198;
-const Int_t AliITSgeomTGeoUpg::fgkNLaddersOld[AliITSgeomTGeoUpg::kNLayersOld] = {20,40,14,22,34,38};
-const Int_t AliITSgeomTGeoUpg::fgkNDetectorsOld[AliITSgeomTGeoUpg::kNLayersOld] = {4,4,6,8,22,25};
+//______________________________________________________________________
+AliITSUGeomTGeo::AliITSUGeomTGeo(const AliITSUGeomTGeo &src)
+  :TObject(src)
+  ,fVersion(src.fVersion)
+  ,fNLayers(src.fNLayers)
+  ,fNModules(src.fNModules)
+  ,fNLadders(0)
+  ,fLrDetType(0)
+  ,fNDetectors(0)
+  ,fLastModIndex(0)
+{
+  // copy c-tor
+  if (fNLayers) {
+    fNLadders   = new Int_t[fNLayers];
+    fNDetectors = new Int_t[fNLayers];
+    fLrDetType  = new Int_t[fNLayers];
+    fLastModIndex   = new Int_t[fNLayers];
+    for (int i=fNLayers;i--;) {
+      fNLadders[i] = src.fNLadders[i];
+      fNDetectors[i] = src.fNDetectors[i];
+      fLrDetType[i]  = src.fLrDetType[i];
+      fLastModIndex[i] = src.fLastModIndex[i];
+    }
+  }
+}
 
-Int_t  AliITSgeomTGeoUpg::fgVersion = 0;
-Int_t  AliITSgeomTGeoUpg::fgNLayers = 0;
-Int_t  AliITSgeomTGeoUpg::fgNModules = 0;
-Int_t* AliITSgeomTGeoUpg::fgNLadders = 0;
-Int_t* AliITSgeomTGeoUpg::fgNDetectors = 0;
-Int_t* AliITSgeomTGeoUpg::fgLrDetType = 0;
+//______________________________________________________________________
+AliITSUGeomTGeo::~AliITSUGeomTGeo()
+{
+  //d-tor
+  delete[] fNLadders;
+  delete[] fLrDetType;
+  delete[] fNDetectors;
+  delete[] fLastModIndex;
+}
 
 
 //______________________________________________________________________
-Int_t AliITSgeomTGeoUpg::GetModuleIndex(Int_t lay,Int_t lad,Int_t det)
+AliITSUGeomTGeo& AliITSUGeomTGeo::operator=(const AliITSUGeomTGeo &src)
+{
+  // cp op.
+  if (this!=&src) {
+    delete[] fNLadders;
+    delete[] fLrDetType;
+    delete[] fNDetectors;
+    delete[] fLastModIndex;
+    fNLadders = fLrDetType = fNDetectors = fLastModIndex = 0;
+    fVersion = src.fVersion;
+    fNLayers = src.fNLayers;
+    fNModules = src.fNModules;
+    if (fNLayers) {
+      fNLadders   = new Int_t[fNLayers];
+      fNDetectors = new Int_t[fNLayers];
+      fLrDetType  = new Int_t[fNLayers];
+      fLastModIndex   = new Int_t[fNLayers];
+      for (int i=fNLayers;i--;) {
+	fNLadders[i] = src.fNLadders[i];
+	fNDetectors[i] = src.fNDetectors[i];
+	fLrDetType[i]  = src.fLrDetType[i];
+	fLastModIndex[i] = src.fLastModIndex[i];
+      }
+    }    
+  }
+  return *this;
+}
+
+//______________________________________________________________________
+Int_t AliITSUGeomTGeo::GetModuleIndex(Int_t lay,Int_t lad,Int_t det) const
 {
-  // The method is taken from the old AliITSgeom class by Bjorn Nilsen
-  //
   // This routine computes the module index number from the layer,
   // ladder, and detector numbers. The number of ladders and detectors
   // per layer is set statically
   // see above for details.
   // Inputs:
-  //    Int_t lay  The layer number. Starting from 1.
-  //    Int_t lad  The ladder number. Starting from 1.
-  //    Int_t det  The detector number. Starting from 1.
-  // Return:
-  //    the module index number, starting from zero.
-  //    -1 in case of error
-  CheckInit();
+  //    Int_t lay  The layer number. Starting from 0.
+  //    Int_t lad  The ladder number. Starting from 0
+  //    Int_t det  The detector number in the ladder. Starting from 0
   //
-  if (lay < 1 || lay > fgNLayers) {
-    AliErrorClass(Form("Invalid layer: %d (1 -> %d",lay,fgNLayers));
-    return -1;
-  }
-
-  if (lad < 1 || lad > fgNLadders[lay-1] ||
-      det < 1 || det > fgNDetectors[lay-1]) {
-    AliErrorClass(Form("Invalid layer,ladder,detector combination: %d, %d, %d",lay,lad,det));
-    return -1;
-  }
-
-  Int_t index = fgNDetectors[lay-1] * (lad-1) + (det-1);
-  for(Int_t iLayer=0;iLayer < (lay-1); iLayer++)
-    index += fgNDetectors[iLayer]*fgNLadders[iLayer];
-
-  return index;
+  return GetFirstModIndex(lay) + fNDetectors[lay]*lad + det;
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GetLayer(Int_t index,Int_t &lay,Int_t &index2) 
+Bool_t AliITSUGeomTGeo::GetLayer(Int_t index,Int_t &lay,Int_t &index2)  const
 {
-  // The method is taken from the old AliITSgeom class by Bjorn Nilsen
-  //
   // This routine computes the layer number for a
-  // given the module index. The number of ladders and detectors
-  // per layer is defined statically,
-  // see above for details.
+  // given the module index. The 
   // Inputs:
   //     Int_t index  The module index number, starting from zero.
   // Outputs:
   //     Int_t index2 The module index inside a layer, starting from zero.
-  //     Int_t lay    The layer number. Starting from 1.
-  // Return:
-  //     kTRUE in case of valid index
-  //     kFALSE in case of error
-  CheckInit();
-  //
-  if (index < 0 || index >= fgNModules) {
-    index2 = -1;
-    AliErrorClass(Form("Invalid module index: %d (0 -> %d)",index,fgNModules));
-    return -1;
-  }
+  //     Int_t lay    The layer number. Starting from 0.
+  //
+  lay = GetLayer(index);
+  index2 = index - GetFirstModIndex(lay);
+  return kTRUE;
+  //
+}
 
-  lay = 0;
-  index2 = 0;
-  do {
-    index2 += fgNLadders[lay]*fgNDetectors[lay];
-    lay++;
-  } while(index2 <= index);
-  index2 -= fgNLadders[lay-1]*fgNDetectors[lay-1];
-  index2 = index - index2;
+//______________________________________________________________________
+Int_t AliITSUGeomTGeo::GetLayer(Int_t index) const
+{
+  // Get module layer, from 0
+  //
+  int lay = 0;
+  while(index<=fLastModIndex[lay]) lay++;
+  return --lay;
+}
 
-  return lay;
+//______________________________________________________________________
+Int_t AliITSUGeomTGeo::GetLadder(Int_t index) const
+{
+  // Get module ladder, from 0
+  //
+  int lay = 0;
+  while(index<=fLastModIndex[lay]) lay++;
+  index -= GetFirstModIndex(--lay);
+  return index/fNDetectors[lay];
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det) 
+Int_t AliITSUGeomTGeo::GetModIdInLayer(Int_t index) const
+{
+  // Get module number within layer, from 0
+  //
+  int lay = 0;
+  while(index<=fLastModIndex[lay]) lay++;
+  index -= GetFirstModIndex(--lay);
+  return index;
+}
+
+//______________________________________________________________________
+Int_t AliITSUGeomTGeo::GetModIdInLadder(Int_t index) const
+{
+  // Get module number within ladder, from 0
+  //
+  int lay = 0;
+  while(index<=fLastModIndex[lay]) lay++;
+  index -= GetFirstModIndex(--lay);
+  return index%fNDetectors[lay];
+}
+
+//______________________________________________________________________
+Bool_t AliITSUGeomTGeo::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det)  const
 {
   // The method is taken from the old AliITSgeom class by Bjorn Nilsen
   //
   // This routine computes the layer, ladder and detector number 
-  // given the module index number. The number of ladders and detectors
-  // per layer is defined statically,
-  // see above for details.
+  // given the module index number. 
   // Inputs:
   //     Int_t index  The module index number, starting from zero.
   // Outputs:
-  //     Int_t lay    The layer number. Starting from 1.
-  //     Int_t lad    The ladder number. Starting from 1.
-  //     Int_t det    The detector number. Starting from 1.
-  // Return:
-  //     kTRUE in case of valid index
-  //     kFALSE in case of error
-  CheckInit();
-  //
-  if (index < 0 || index >= fgNModules) {
-    lay = lad = det = -1;
-    AliErrorClass(Form("Invalid module index: %d (0 -> %d)",index,fgNModules));
-    return kFALSE;
-  }
-
-  lay  = lad = det = 0;
-  Int_t index2 = 0;
-  do {
-    index2 += fgNLadders[lay]*fgNDetectors[lay];
-    lay++;
-  } while(index2 <= index);
-  index2 -= fgNLadders[lay-1]*fgNDetectors[lay-1];
-
-  do {
-    index2 += fgNDetectors[lay-1];
-    lad++;
-  } while(index2 <= index);
-  index2 -= fgNDetectors[lay-1];
-
-  det = index-index2+1;
-
+  //     Int_t lay    The layer number. Starting from 0
+  //     Int_t lad    The ladder number. Starting from 0
+  //     Int_t det    The detector number. Starting from 0
+  //
+  lay  = GetLayer(index);
+  index -= GetFirstModIndex(lay);
+  lad  = index/fNDetectors[lay];
+  det  = index%fNDetectors[lay];
   return kTRUE;
 }
 
 //______________________________________________________________________
-const char* AliITSgeomTGeoUpg::GetSymName(Int_t index) 
+const char* AliITSUGeomTGeo::GetSymName(Int_t index)  const
 {
   // Get the TGeoPNEntry symbolic name
   // for a given module identified by 'index'
-  CheckInit();
   //
-  if (index < 0 || index >= fgNModules) {
-    AliErrorClass(Form("Invalid ITS module index: %d (0 -> %d) !",index,fgNModules));
-    return NULL;
-  }
-
   Int_t lay, index2;
   if (!GetLayer(index,lay,index2)) return NULL;
-  if (fgVersion == kITSVOld) return AliGeomManager::SymName((AliGeomManager::ELayerID)((lay-1)+AliGeomManager::kSPD1),index2);
-  else {
-    // RS: this is not optimal, but we cannod access directly AliGeomManager, since the latter has hardwired layers 
-    TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID( AliGeomManager::LayerToVolUID(lay,index2) );
-    if (!pne) {
-      AliErrorClass(Form("Failed to find alignable entry with index %d: (Lr%d Mod:%d) !",index,lay,index2));
-      return NULL;
-    }
-    return pne->GetName();
+  // return AliGeomManager::SymName((AliGeomManager::ELayerID)((lay-1)+AliGeomManager::kSPD1),index2);
+  // RS: this is not optimal, but we cannod access directly AliGeomManager, since the latter has hardwired layers 
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID( AliGeomManager::LayerToVolUID(lay+1,index2) );
+  if (!pne) {
+    AliError(Form("Failed to find alignable entry with index %d: (Lr%d Mod:%d) !",index,lay,index2));
+    return NULL;
   }
+  return pne->GetName();
 }
 
 //______________________________________________________________________
-TGeoHMatrix* AliITSgeomTGeoUpg::GetMatrix(Int_t index) 
+TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t index)  const
 {
   // Get the transformation matrix for a given module 'index'
   // by quering the TGeoManager
-  CheckInit();
-  //
   TGeoPNEntry *pne = GetPNEntry(index);
   if (!pne) return NULL;
 
@@ -213,20 +255,22 @@ TGeoHMatrix* AliITSgeomTGeoUpg::GetMatrix(Int_t index)
   if (pnode) return pnode->GetMatrix();
 
   const char* path = pne->GetTitle();
+  gGeoManager->PushPath(); // Preserve the modeler state.
   if (!gGeoManager->cd(path)) {
-    AliErrorClass(Form("Volume path %s not valid!",path));
+    gGeoManager->PopPath();
+    AliError(Form("Volume path %s not valid!",path));
     return NULL;
   }
-  return gGeoManager->GetCurrentMatrix();
+  TGeoHMatrix *mat = gGeoManager->GetCurrentMatrix();
+  gGeoManager->PopPath();
+  return mat;
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GetTranslation(Int_t index, Double_t t[3]) 
+Bool_t AliITSUGeomTGeo::GetTranslation(Int_t index, Double_t t[3])  const
 {
   // Get the translation vector for a given module 'index'
   // by quering the TGeoManager
-  CheckInit();
-  //
   TGeoHMatrix *m = GetMatrix(index);
   if (!m) return kFALSE;
 
@@ -237,12 +281,10 @@ Bool_t AliITSgeomTGeoUpg::GetTranslation(Int_t index, Double_t t[3])
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GetRotation(Int_t index, Double_t r[9]) 
+Bool_t AliITSUGeomTGeo::GetRotation(Int_t index, Double_t r[9])  const
 {
   // Get the rotation matrix for a given module 'index'
   // by quering the TGeoManager
-  CheckInit();
-  //
   TGeoHMatrix *m = GetMatrix(index);
   if (!m) return kFALSE;
 
@@ -253,14 +295,12 @@ Bool_t AliITSgeomTGeoUpg::GetRotation(Int_t index, Double_t r[9])
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GetOrigMatrix(Int_t index, TGeoHMatrix &m)
+Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t index, TGeoHMatrix &m) const
 {
   // Get the original (ideal geometry) TGeo matrix for
   // a given module identified by 'index'.
   // The method is slow, so it should be used
   // with great care.
-  CheckInit();
-  //
   m.Clear();
 
   const char *symname = GetSymName(index);
@@ -270,12 +310,10 @@ Bool_t AliITSgeomTGeoUpg::GetOrigMatrix(Int_t index, TGeoHMatrix &m)
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GetOrigTranslation(Int_t index, Double_t t[3]) 
+Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t index, Double_t t[3])  const
 {
   // Get the original translation vector (ideal geometry)
   // for a given module 'index' by quering the TGeoManager
-  CheckInit();
-  //
   TGeoHMatrix m;
   if (!GetOrigMatrix(index,m)) return kFALSE;
 
@@ -286,12 +324,10 @@ Bool_t AliITSgeomTGeoUpg::GetOrigTranslation(Int_t index, Double_t t[3])
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GetOrigRotation(Int_t index, Double_t r[9]) 
+Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t index, Double_t r[9])  const
 {
   // Get the original rotation matrix (ideal geometry)
   // for a given module 'index' by quering the TGeoManager
-  CheckInit();
-  //
   TGeoHMatrix m;
   if (!GetOrigMatrix(index,m)) return kFALSE;
 
@@ -302,30 +338,26 @@ Bool_t AliITSgeomTGeoUpg::GetOrigRotation(Int_t index, Double_t r[9])
 }
 
 //______________________________________________________________________
-const TGeoHMatrix* AliITSgeomTGeoUpg::GetTracking2LocalMatrix(Int_t index)
+const TGeoHMatrix* AliITSUGeomTGeo::GetTracking2LocalMatrix(Int_t index) const
 {
   // Get the matrix which transforms from the tracking to local r.s.
   // The method queries directly the TGeoPNEntry
-  CheckInit();
-  //
   TGeoPNEntry *pne = GetPNEntry(index);
   if (!pne) return NULL;
 
   const TGeoHMatrix *m = pne->GetMatrix();
   if (!m)
-    AliErrorClass(Form("TGeoPNEntry (%s) contains no matrix !",pne->GetName()));
+    AliError(Form("TGeoPNEntry (%s) contains no matrix !",pne->GetName()));
 
   return m;
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GetTrackingMatrix(Int_t index, TGeoHMatrix &m)
+Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t index, TGeoHMatrix &m) const
 {
   // Get the matrix which transforms from the tracking r.s. to
   // the global one.
   // Returns kFALSE in case of error.
-  CheckInit();
-  //
   m.Clear();
 
   TGeoHMatrix *m1 = GetMatrix(index);
@@ -341,35 +373,58 @@ Bool_t AliITSgeomTGeoUpg::GetTrackingMatrix(Int_t index, TGeoHMatrix &m)
 }
 
 //______________________________________________________________________
-TGeoPNEntry* AliITSgeomTGeoUpg::GetPNEntry(Int_t index)
+TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t lay, Int_t ladd, Int_t detInLad)  const
+{
+  // Get the transformation matrix of the SENSOR (not ncessary the same as the module) for a given module 'index'
+  // by quering the TGeoManager
+  const TString kPathBase = Form("/ALIC_1/%s_1/",AliITSUGeomTGeo::GetITSVolPattern());
+  const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d"
+			      ,AliITSUGeomTGeo::GetITSLayerPattern()
+			      ,AliITSUGeomTGeo::GetITSLadderPattern()
+			      ,AliITSUGeomTGeo::GetITSModulePattern()
+			      ,AliITSUGeomTGeo::GetITSSensorPattern());
+  TString path;
+  //
+  path.Form(kNames.Data(),kPathBase.Data(),lay,lay,ladd,lay,detInLad,lay,1);
+  gGeoManager->PushPath();
+  if (!gGeoManager->cd(path.Data())) {
+    gGeoManager->PopPath();
+    AliError(Form("Error in cd-ing to %s",path.Data()));
+    return 0;
+  } // end if !gGeoManager
+  TGeoHMatrix* mat = gGeoManager->GetCurrentMatrix();
+  // Retstore the modeler state.
+  gGeoManager->PopPath();
+  return mat;
+}
+
+
+//______________________________________________________________________
+TGeoPNEntry* AliITSUGeomTGeo::GetPNEntry(Int_t index) const
 {
   // Get a pointer to the TGeoPNEntry of a module
   // identified by 'index'
   // Returns NULL in case of invalid index,
   // missing TGeoManager or invalid symbolic name
-  CheckInit();
   //
-  if (index < 0 || index >= fgNModules) {
-    AliErrorClass(Form("Invalid ITS module index: %d (0 -> %d) !",index,fgNModules));
+  if (index >= fNModules) {
+    AliError(Form("Invalid ITS module index: %d (0 -> %d) !",index,fNModules));
     return NULL;
   }
   
   if (!gGeoManager || !gGeoManager->IsClosed()) {
-    AliErrorClass("Can't get the matrix! gGeoManager doesn't exist or it is still opened!");
+    AliError("Can't get the matrix! gGeoManager doesn't exist or it is still opened!");
     return NULL;
   }
 
   TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(GetSymName(index));
-  if (!pne)
-    AliErrorClass(Form("The symbolic volume name %s does not correspond to a physical entry!",
-		       GetSymName(index)));
-
+  if (!pne) AliError(Form("The symbolic volume name %s does not correspond to a physical entry!",GetSymName(index)));
+  //
   return pne;
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::LocalToGlobal(Int_t index,
-				     const Double_t *loc, Double_t *glob)
+Bool_t AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob) const
 {
   // Make the conversion from the local sensitive reference system to the global
   // reference system, for an arbitrary local position. The input is the pointer
@@ -377,7 +432,6 @@ Bool_t AliITSgeomTGeoUpg::LocalToGlobal(Int_t index,
   //
   // Please don't use this method to get the global coordinates of clusters, use
   // the direct method of AliCluster instead.
-  CheckInit();
   //
   const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
   if (!m2) return kFALSE;
@@ -393,13 +447,11 @@ Bool_t AliITSgeomTGeoUpg::LocalToGlobal(Int_t index,
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GlobalToLocal(Int_t index,
-				     const Double_t *glob, Double_t *loc)
+Bool_t AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc) const
 {
   // Make the conversion from the global reference system to the sensitive local
   // reference system, for an arbitrary global position. The input is the pointer
   // to the array of global coordinates, the result is sent to the loc pointer.
-  CheckInit();
   //
   TGeoHMatrix *ml = GetMatrix(index);
   if (!ml) return kFALSE;
@@ -415,13 +467,11 @@ Bool_t AliITSgeomTGeoUpg::GlobalToLocal(Int_t index,
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::LocalToGlobalVect(Int_t index,
-					 const Double_t *loc, Double_t *glob)
+Bool_t AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) const
 {
   // Make the conversion from the local sensitive reference system to the global
   // reference system, for an arbitrary vector. The input is the pointer to the
   // array of local coordinates, the result is sent to the glob pointer.
-  CheckInit();
   //
   TGeoHMatrix *ml = GetMatrix(index);
   if (!ml) return kFALSE;
@@ -430,146 +480,53 @@ Bool_t AliITSgeomTGeoUpg::LocalToGlobalVect(Int_t index,
 }
 
 //______________________________________________________________________
-Bool_t AliITSgeomTGeoUpg::GlobalToLocalVect(Int_t index,
-					 const Double_t *glob, Double_t *loc)
+Bool_t AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) const
 {
   // Make the conversion from the global reference system to the sensitive local
   // reference system, for an arbitrary vector. The input is the pointer to the
   // array of global coordinates, the result is sent to the loc pointer.
-  CheckInit();
-  //
   TGeoHMatrix *ml = GetMatrix(index);
   if (!ml) return kFALSE;
   ml->MasterToLocalVect(glob,loc);
-
   return kTRUE;
 }
 
 //______________________________________________________________________
-void AliITSgeomTGeoUpg::BuildITS()
-{
-  // build ITS info from TGeo 
-  if (fgVersion!=kITSVNA) return; // already initialized
-  // 
-  if (!gGeoManager) AliFatalClass("Geometry is not loaded");
-  //
-  // get ITS version
-  TGeoVolume *itsV = gGeoManager->GetVolume(fgkITSVolName);
-  if (!gGeoManager) AliFatalClass(Form("ITS volume %s is not in the geometry",fgkITSVolName));
-  //
-  Int_t minor = 0;
-  TDatime datetime;
-  const Char_t *title = itsV->GetTitle();
-  if(!ReadVersionString(title,fgVersion,minor,datetime))
-    AliFatalClass(Form("Can't read title %s to extract version",title));
-  //
-  if (fgVersion==kITSVNA) AliFatalClass(Form("Failed to detrmine ITS version from title %s",title));
-  //
-  (fgVersion==kITSVOld) ? BuildITSOld() : BuildITSUpg();
-  //
-}
-
-//______________________________________________________________________
-void AliITSgeomTGeoUpg::BuildITSOld()
-{
-  // assign old ITS
-  fgNLayers  = kNLayersOld;
-  fgNModules = fgkNModulesOld;
-  fgNLadders = (Int_t*)fgkNLaddersOld;
-  fgNDetectors = (Int_t*)fgkNDetectorsOld;
-  fgLrDetType = 0;
-}
-
-//______________________________________________________________________
-void AliITSgeomTGeoUpg::BuildITSUpg()
+void AliITSUGeomTGeo::BuildITS()
 {
   // exract upg ITS parameters from TGeo
-  fgNLayers    = ExtractNumberOfLayers();
-  if (!fgNLayers) return;
-  //
-  fgNLadders   = new Int_t[fgNLayers];
-  fgNDetectors = new Int_t[fgNLayers];
-  fgLrDetType  = new Int_t[fgNLayers];
-  fgNModules = 0;
-  for (int i=0;iGetVolume(fgkITSVolName);
-  if (!itsV) AliFatalClass(Form("ITS volume %s is not in the geometry",fgkITSVolName));
+  if (!itsV) AliFatal(Form("ITS volume %s is not in the geometry",fgkITSVolName));
   //
   // Loop on all ITSV nodes, count Layer volumes by checking names
   Int_t nNodes = itsV->GetNodes()->GetEntries();
@@ -579,23 +536,19 @@ Int_t AliITSgeomTGeoUpg::ExtractNumberOfLayers()
 }
 
 //______________________________________________________________________
-Int_t AliITSgeomTGeoUpg::ExtractNumberOfLadders(const Int_t lay)
+Int_t AliITSUGeomTGeo::ExtractNumberOfLadders(Int_t lay) const
 {
   // Determines the number of layers in the Upgrade Geometry
   //
   // Inputs:
-  //   lay: layer number, starting from 1
-  // Outputs:
-  //   none
-  // Return:
-  //   the number of ladders in layer lay
-  //   -1 if not Upgrade Geometry
+  //   lay: layer number, starting from 0
+  //
   // MS
   Int_t numberOfLadders = 0;
   char laynam[30];
   snprintf(laynam, 30, "%s%d",fgkITSLrName,lay);
   TGeoVolume* volLr = gGeoManager->GetVolume(laynam);
-  if (!volLr) AliFatalClass(Form("can't find %s volume",laynam));
+  if (!volLr) AliFatal(Form("can't find %s volume",laynam));
   //
   // Loop on all layer nodes, count Ladder volumes by checking names
   Int_t nNodes = volLr->GetNodes()->GetEntries();
@@ -606,23 +559,18 @@ Int_t AliITSgeomTGeoUpg::ExtractNumberOfLadders(const Int_t lay)
 }
 
 //______________________________________________________________________
-Int_t AliITSgeomTGeoUpg::ExtractNumberOfDetectors(const Int_t lay) 
+Int_t AliITSUGeomTGeo::ExtractNumberOfDetectors(Int_t lay)  const
 {
   // Determines the number of detectors per ladder in the Upgrade Geometry
   //
   // Inputs:
-  //   lay: layer number from 1
-  // Outputs:
-  //   none
-  // Return:
-  //   the number of modules per ladder in layer lay
-  //   -1 if not Upgrade Geometry
+  //   lay: layer number from 0
   // MS
   Int_t numberOfModules = 0;
   char laddnam[30];
   snprintf(laddnam, 30, "%s%d", fgkITSLadName,lay);
   TGeoVolume* volLd = gGeoManager->GetVolume(laddnam);
-  if (!volLd) AliFatalClass(Form("can't find %s volume",laddnam));
+  if (!volLd) AliFatal(Form("can't find %s volume",laddnam));
   //
   // Loop on all ladder nodes, count Module volumes by checking names
   Int_t nNodes = volLd->GetNodes()->GetEntries();
@@ -633,7 +581,7 @@ Int_t AliITSgeomTGeoUpg::ExtractNumberOfDetectors(const Int_t lay)
 }
 
 //______________________________________________________________________
-Int_t AliITSgeomTGeoUpg::ExtractLayerDetType(const Int_t lay) 
+Int_t AliITSUGeomTGeo::ExtractLayerDetType(Int_t lay)  const
 {
   // Determines the layer detector type the Upgrade Geometry
   //
@@ -647,8 +595,15 @@ Int_t AliITSgeomTGeoUpg::ExtractLayerDetType(const Int_t lay)
   char laddnam[30];
   snprintf(laddnam, 30, "%s%d", fgkITSLrName,lay);
   TGeoVolume* volLd = gGeoManager->GetVolume(laddnam);
-  if (!volLd) {AliFatalClass(Form("can't find %s volume",laddnam)); return -1;}
+  if (!volLd) {AliFatal(Form("can't find %s volume",laddnam)); return -1;}
   //
   return volLd->GetUniqueID();
   //
 }
+
+//______________________________________________________________________
+UInt_t AliITSUGeomTGeo::ComposeDetTypeID(UInt_t segmId)
+{
+  if (segmId>=kMaxSegmPerDetType) AliFatalClass(Form("Id=%d is >= max.allowed %d",segmId,kMaxSegmPerDetType));
+  return segmId + kDetTypePixUpg*kMaxSegmPerDetType;
+}
diff --git a/ITS/UPGRADE/AliITSUGeomTGeo.h b/ITS/UPGRADE/AliITSUGeomTGeo.h
new file mode 100644
index 00000000000..6f0c3f41675
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUGeomTGeo.h
@@ -0,0 +1,245 @@
+#ifndef ALIITSUGEOMTGEO_H
+#define ALIITSUGEOMTGEO_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/////////////////////////////////////////////////////////////////////////
+//  AliITSUGeomTGeo is a simple interface class to TGeoManager       //
+//  It is used in the simulation and reconstruction in order to        //
+//  query the TGeo ITS geometry                                        //
+//                                                                     //
+//  author - cvetan.cheshkov@cern.ch                                   //
+//  15/02/2007                                                         //
+//  adapted to ITSupg 18/07/2012 - ruben.shahoyan@cern.ch              //
+//  RS: in order to preserve the static character of the class but     //
+//  make it dynamically access geometry, we need to check in every     //
+//  method if the structures are initialized. To be converted to       //
+//  singleton at later stage.                                          //
+//                                                                     //
+//  Note on the upgrade detector types:                                //
+//  The coarse type defines detectors served by different classes,     //
+//  like PixUpg. Each such a detector type can have kMaxSegmPerDetType //
+//  segmentations (pitch etc.) whose parameteres are stored in the     //
+//  AliITSsegmentation derived class (like AliITSUSegmentationPix)   //
+//  This allows to have in the setup modules served by the same        //
+//  classes but with different segmentations.                          //
+//  The full detector type is composed as:                             //
+//  CoarseType*kMaxSegmPerDetType + segmentationType                   //
+//  The only requirement on the segmentationType that should be        //
+//  < kMaxSegmPerDetType.                                              //
+//  The methods like GetLayerDetTypeID return the full detector type   //
+//                                                                     //
+//                                                                     //
+/////////////////////////////////////////////////////////////////////////
+
+#include 
+#include 
+#include 
+
+class TGeoPNEntry;
+class TDatime;
+
+class AliITSUGeomTGeo : public TObject {
+
+ public:
+  enum {kITSVNA, kITSVUpg}; // ITS version
+  enum {kDetTypePixUpg=0, kNDetTypes, kMaxSegmPerDetType=10}; // defined detector types (each one can have different segmentations)
+  //
+  AliITSUGeomTGeo(Bool_t build = kFALSE);
+  virtual ~AliITSUGeomTGeo(); 
+  AliITSUGeomTGeo(const AliITSUGeomTGeo &src);
+  AliITSUGeomTGeo& operator=(const AliITSUGeomTGeo &geom);
+  //
+  Int_t   GetNModules()                                                   const {return fNModules;}
+  Int_t   GetNDetectors(Int_t lay)                                        const {return fNDetectors[lay];}
+  Int_t   GetNLadders(Int_t lay)                                          const {return fNLadders[lay];}
+  Int_t   GetNLayers()                                                    const {return fNLayers;}
+  
+  Int_t  GetModuleIndex(Int_t lay,Int_t lad,Int_t det)                    const;
+  Bool_t GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det)        const;
+  Int_t  GetLayer(Int_t index)                                            const;
+  Int_t  GetLadder(Int_t index)                                           const;
+  Int_t  GetModIdInLayer(Int_t index)                                     const;
+  Int_t  GetModIdInLadder(Int_t index)                                    const;
+  //
+  Int_t  GetLastModIndex(Int_t lay)                                       const {return fLastModIndex[lay];}
+  Int_t  GetFirstModIndex(Int_t lay)                                      const {return (lay==0) ? 0:fLastModIndex[lay-1]+1;}
+  //  
+  const char *GetSymName(Int_t index)                                     const;
+  const char *GetSymName(Int_t lay,Int_t lad,Int_t det)                   const;
+  //
+  // Attention: these are the matrices for the alignable volumes of the modules, i.e. not necessarily the sensors
+  TGeoHMatrix* GetMatrix(Int_t index)                                     const;
+  TGeoHMatrix* GetMatrix(Int_t lay,Int_t lad,Int_t det)                   const;
+  Bool_t GetTranslation(Int_t index, Double_t t[3])                       const;
+  Bool_t GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3])     const;
+  Bool_t GetRotation(Int_t index, Double_t r[9])                          const;
+  Bool_t GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9])        const;
+  Bool_t GetOrigMatrix(Int_t index, TGeoHMatrix &m)                       const;
+  Bool_t GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m)     const;
+  Bool_t GetOrigTranslation(Int_t index, Double_t t[3])                   const;
+  Bool_t GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const;
+  Bool_t GetOrigRotation(Int_t index, Double_t r[9])                      const;
+  Bool_t GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9])    const;
+  //
+  const TGeoHMatrix* GetTracking2LocalMatrix(Int_t index)                   const;
+  const TGeoHMatrix* GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det) const;
+  //
+  Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m)                   const;
+  Bool_t GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const;
+  //
+  // Attention: these are transformations wrt sensitive volume!
+  TGeoHMatrix* GetMatrixSens(Int_t index)                                 const;
+  TGeoHMatrix* GetMatrixSens(Int_t lay,Int_t lad,Int_t det)               const;
+  Bool_t LocalToGlobal(Int_t index, const Double_t *loc, Double_t *glob)  const;
+  Bool_t LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob) const;
+  //
+  Bool_t GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc)  const;
+  Bool_t GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc) const;
+  //
+  Bool_t LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) const;
+  Bool_t GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) const;
+  Int_t  GetLayerDetTypeID(Int_t lr)                                         const;
+  Int_t  GetModuleDetTypeID(Int_t id)                                        const;
+  //
+  static const char* GetITSVolPattern()                                             {return fgkITSVolName;}
+  static const char* GetITSLayerPattern()                                           {return fgkITSLrName;}
+  static const char* GetITSLadderPattern()                                          {return fgkITSLadName;}
+  static const char* GetITSModulePattern()                                          {return fgkITSModName;}
+  static const char* GetITSSensorPattern()                                          {return fgkITSSensName;}
+  static const char* GetDetTypeName(Int_t i)                                        {return (i<0||i>=kNDetTypes) ? 0 : fgkITSDetTypeName[i];}
+  static const char* GetITSsegmentationFileName()                                   {return fgITSsegmFileName.Data();}
+  static void        SetITSsegmentationFileName(const char* nm)                     {fgITSsegmFileName = nm;}
+  static UInt_t      ComposeDetTypeID(UInt_t segmId);
+  //
+ private:
+//
+  Bool_t       GetLayer(Int_t index,Int_t &lay,Int_t &index2) const;
+  TGeoPNEntry* GetPNEntry(Int_t index)                        const;
+  Int_t        ExtractNumberOfDetectors(Int_t lay)            const;
+  Int_t        ExtractNumberOfLadders(Int_t lay)              const;
+  Int_t        ExtractLayerDetType(Int_t lay)                 const;
+  Int_t        ExtractNumberOfLayers()                        const;
+  void         BuildITS();
+  //
+  Int_t  fVersion;             // ITS Version 
+  Int_t  fNLayers;             // number of layers
+  Int_t  fNModules;            //[fNLayers] The total number of modules
+  Int_t *fNLadders;            //[fNLayers] Array of the number of ladders/layer(layer)
+  Int_t *fLrDetType;           //[fNLayers] Array of layer detector types
+  Int_t *fNDetectors;          //[fNLayers] Array of the number of detector/ladder(layer)
+  Int_t *fLastModIndex;        //[fNLayers] max ID of the detctor in the layer
+  //
+  static const char*  fgkITSVolName;             // ITS mother volume name
+  static const char*  fgkITSLrName;              // ITS Layer name
+  static const char*  fgkITSLadName;             // ITS Ladder name 
+  static const char*  fgkITSModName;             // ITS Module name 
+  static const char*  fgkITSSensName;            // ITS Sensor name 
+  static const char*  fgkITSDetTypeName[kNDetTypes]; // ITS upg detType Names
+  //
+  static TString      fgITSsegmFileName;         // file name for segmentations
+  //
+  ClassDef(AliITSUGeomTGeo, 1) // ITS geometry based on TGeo
+};
+
+//_____________________________________________________________________________________________
+inline const char *AliITSUGeomTGeo::GetSymName(Int_t lay,Int_t lad,Int_t det) const    
+{
+  // sym name
+  return GetSymName(GetModuleIndex(lay,lad,det));
+}
+
+//_____________________________________________________________________________________________
+inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t lay,Int_t lad,Int_t det) const    
+{
+  // module current matrix
+  return GetMatrix(GetModuleIndex(lay,lad,det));
+}
+
+//_____________________________________________________________________________________________
+inline Bool_t AliITSUGeomTGeo::GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const    
+{
+  // translation
+  return GetTranslation(GetModuleIndex(lay,lad,det),t); 
+}
+
+//_____________________________________________________________________________________________
+inline Bool_t AliITSUGeomTGeo::GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const    
+{
+  // rot
+  return GetRotation(GetModuleIndex(lay,lad,det),r); 
+}
+
+//_____________________________________________________________________________________________
+inline Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const    
+{
+  // orig matrix
+  return GetOrigMatrix(GetModuleIndex(lay,lad,det),m); 
+}
+
+//_____________________________________________________________________________________________
+inline Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const    
+{
+  // orig trans
+  return GetOrigTranslation(GetModuleIndex(lay,lad,det),t); 
+}
+
+//_____________________________________________________________________________________________
+inline Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const    
+{
+  // orig rot
+  return GetOrigRotation(GetModuleIndex(lay,lad,det),r); 
+}
+
+//_____________________________________________________________________________________________
+inline const TGeoHMatrix* AliITSUGeomTGeo::GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det) const  
+{
+  // t2l matrix
+  return GetTracking2LocalMatrix(GetModuleIndex(lay,lad,det)); 
+}
+
+//_____________________________________________________________________________________________
+inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const    
+{
+  // tracking mat
+  return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m); 
+}
+
+//_____________________________________________________________________________________________
+inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index) const    
+{
+  // semsor matrix
+  int lr,ld,dt; 
+  return GetModuleId(index,lr,ld,dt) ? GetMatrixSens(GetModuleIndex(lr,ld,dt)) : 0;
+}
+
+//_____________________________________________________________________________________________
+inline Bool_t AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob) const 
+{
+  // Local2Master (sensor)
+  return LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob);
+}
+
+//_____________________________________________________________________________________________
+inline Bool_t AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc) const 
+{
+  // master2local (sensor)
+  return GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc);
+}
+
+//_____________________________________________________________________________________________
+inline Int_t  AliITSUGeomTGeo::GetLayerDetTypeID(Int_t lr) const  
+{
+  // detector type ID of layer
+  return fLrDetType[lr];
+}
+
+//_____________________________________________________________________________________________
+inline Int_t  AliITSUGeomTGeo::GetModuleDetTypeID(Int_t id) const  
+{
+  // detector type ID of module
+  return GetLayerDetTypeID(GetLayer(id));
+} 
+
+
+#endif
diff --git a/ITS/UPGRADE/AliITSUHit.cxx b/ITS/UPGRADE/AliITSUHit.cxx
new file mode 100644
index 00000000000..013b741f77f
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUHit.cxx
@@ -0,0 +1,100 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+#include "AliITSU.h"
+#include "AliITSUGeomTGeo.h"
+#include "AliITSUHit.h"
+
+ClassImp(AliITSUHit)
+
+////////////////////////////////////////////////////////////////////////
+//
+// At the moment the same functionality/data-members as parent AliITShit 
+// except the geometry transformation uses AliITSgeomTGeoUp 
+//
+////////////////////////////////////////////////////////////////////////
+
+//----------------------------------------------------------------------
+AliITSUHit::AliITSUHit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,Float_t tof,
+			   TLorentzVector &x,TLorentzVector &x0,TLorentzVector &p) 
+: AliITShit(shunt,track,vol,edep,tof,x,x0,p)
+{
+  // ct-r
+}
+
+//______________________________________________________________________
+AliITSUHit::AliITSUHit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits) 
+  : AliITShit(shunt, track, vol, hits) 
+{
+  // c-tor
+}
+
+//______________________________________________________________________
+AliITSUHit::AliITSUHit(const AliITSUHit &h)
+: AliITShit(h)
+{
+  // cp c-tor
+}
+
+//______________________________________________________________________
+AliITSUHit& AliITSUHit::operator=(const AliITSUHit &h)
+{
+  // The standard = operator
+  if(this == &h) return *this;
+  AliITShit::operator=(h);
+  return *this;
+}
+
+//______________________________________________________________________
+void AliITSUHit::GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof)
+{
+  // Returns the position and time of flight of this hit in the local
+  // coordinates of this module, and in the units of the Monte Carlo.
+  //
+  AliITSUGeomTGeo *gm = ((AliITSU*)gAlice->GetDetector("ITS"))->GetITSGeomTGeo();
+  if (!gm) AliFatal("NULL pointer to the geometry!");
+  double g[3]={fX,fY,fZ},l[3];
+  gm->GetMatrixSens(fModule)->MasterToLocal(g,l);
+  x = l[0];
+  y = l[1];
+  z = l[2];
+  tof = fTof;
+  //
+}
+
+//______________________________________________________________________
+void AliITSUHit::GetPositionL0(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
+{
+  // Returns the initial position and time of flight of this hit 
+  // in the local coordinates of this module, and in the units of the 
+  AliITSUGeomTGeo *gm = ((AliITSU*)gAlice->GetDetector("ITS"))->GetITSGeomTGeo();
+  if (!gm) AliFatal("NULL pointer to the geometry!");
+  double g[3]={fx0,fy0,fz0},l[3];  
+  gm->GetMatrixSens(fModule)->MasterToLocal(g,l);
+  x = l[0];
+  y = l[1];
+  z = l[2];
+  tof = ft0;
+}
+
+//----------------------------------------------------------------------
+void AliITSUHit::GetDetectorID(Int_t &layer,Int_t &ladder,Int_t &det) const
+{
+  // Returns the layer ladder and detector number lables for this
+  // ITS module. Note: indices start from 0!
+  AliITSUGeomTGeo *gm = ((AliITSU*)gAlice->GetDetector("ITS"))->GetITSGeomTGeo();
+  if (!gm) AliFatal("NULL pointer to the geometry!");
+  gm->GetModuleId(fModule,layer,ladder,det);
+}  
diff --git a/ITS/UPGRADE/AliITSUHit.cxx~ b/ITS/UPGRADE/AliITSUHit.cxx~
new file mode 100644
index 00000000000..52c1080e0d6
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUHit.cxx~
@@ -0,0 +1,100 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+#include "AliITSU.h"
+#include "AliITSUGeomTGeo.h"
+#include "AliITSUHit.h"
+
+ClassImp(AliITSHit)
+
+////////////////////////////////////////////////////////////////////////
+//
+// At the moment the same functionality/data-members as parent AliITShit 
+// except the geometry transformation uses AliITSgeomTGeoUp 
+//
+////////////////////////////////////////////////////////////////////////
+
+//----------------------------------------------------------------------
+AliITSUHit::AliITSUHit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,Float_t tof,
+			   TLorentzVector &x,TLorentzVector &x0,TLorentzVector &p) 
+: AliITShit(shunt,track,vol,edep,tof,x,x0,p)
+{
+  // ct-r
+}
+
+//______________________________________________________________________
+AliITSUHit::AliITSUHit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits) 
+  : AliITShit(shunt, track, vol, hits) 
+{
+  // c-tor
+}
+
+//______________________________________________________________________
+AliITSUHit::AliITSUHit(const AliITSUHit &h)
+: AliITShit(h)
+{
+  // cp c-tor
+}
+
+//______________________________________________________________________
+AliITSUHit& AliITSUHit::operator=(const AliITSUHit &h)
+{
+  // The standard = operator
+  if(this == &h) return *this;
+  AliITShit::operator=(h);
+  return *this;
+}
+
+//______________________________________________________________________
+void AliITSUHit::GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof)
+{
+  // Returns the position and time of flight of this hit in the local
+  // coordinates of this module, and in the units of the Monte Carlo.
+  //
+  AliITSUGeomTGeo *gm = ((AliITSU*)gAlice->GetDetector("ITS"))->GetITSGeomTGeo();
+  if (!gm) AliFatal("NULL pointer to the geometry!");
+  double g[3]={fX,fY,fZ},l[3];
+  gm->GetMatrixSens(fModule)->MasterToLocal(g,l);
+  x = l[0];
+  y = l[1];
+  z = l[2];
+  tof = fTof;
+  //
+}
+
+//______________________________________________________________________
+void AliITSUHit::GetPositionL0(Double_t &x,Double_t &y,Double_t &z,Double_t &tof)
+{
+  // Returns the initial position and time of flight of this hit 
+  // in the local coordinates of this module, and in the units of the 
+  AliITSUGeomTGeo *gm = ((AliITSU*)gAlice->GetDetector("ITS"))->GetITSGeomTGeo();
+  if (!gm) AliFatal("NULL pointer to the geometry!");
+  double g[3]={fx0,fy0,fz0},l[3];  
+  gm->GetMatrixSens(fModule)->MasterToLocal(g,l);
+  x = l[0];
+  y = l[1];
+  z = l[2];
+  tof = ft0;
+}
+
+//----------------------------------------------------------------------
+void AliITSUHit::GetDetectorID(Int_t &layer,Int_t &ladder,Int_t &det) const
+{
+  // Returns the layer ladder and detector number lables for this
+  // ITS module. Note: indices start from 0!
+  AliITSUGeomTGeo *gm = ((AliITSU*)gAlice->GetDetector("ITS"))->GetITSGeomTGeo();
+  if (!gm) AliFatal("NULL pointer to the geometry!");
+  gm->GetModuleId(fModule,layer,ladder,det);
+}  
diff --git a/ITS/UPGRADE/AliITSUHit.h b/ITS/UPGRADE/AliITSUHit.h
new file mode 100644
index 00000000000..c05f22627b6
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUHit.h
@@ -0,0 +1,44 @@
+#ifndef ALIITSUHIT_H
+#define ALIITSUHIT_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+////////////////////////////////////////////////////////////////////////
+//
+// At the moment the same functionality/data-members as parent AliITShit 
+// except the geometry transformation uses AliITSgeomTGeoUp 
+//
+////////////////////////////////////////////////////////////////////////
+
+#include "AliITShit.h" 
+#include "AliRun.h"
+
+class AliITSUHit : public AliITShit {
+
+ public:
+  //
+  AliITSUHit() {}
+  AliITSUHit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits);
+  AliITSUHit(Int_t shunt,Int_t track,Int_t *vol,Float_t edep,Float_t tof,TLorentzVector &x,TLorentzVector &x0,TLorentzVector &p);
+  AliITSUHit(const AliITSUHit &h);
+  AliITSUHit& operator=(const AliITSUHit &h);
+  virtual ~AliITSUHit() {};
+  virtual Int_t GetLayer() const;
+  virtual Int_t GetLadder() const;
+  virtual Int_t GetDetector() const;
+  virtual void  GetDetectorID(Int_t &layer,Int_t &ladder,Int_t &det) const;
+  virtual void  GetPositionL(Float_t &x,Float_t &y,Float_t &z,Float_t &tof);
+  virtual void  GetPositionL(Float_t &x,Float_t &y,Float_t &z) {Float_t tf;GetPositionL(x,y,z,tf);}
+  virtual void  GetPositionL(Double_t &x,Double_t &y,Double_t &z,Double_t &t) {Float_t xf,yf,zf,tf;GetPositionL(xf,yf,zf,tf);x=xf,y=yf;z=zf;t=tf;}
+  virtual void  GetPositionL(Double_t &x,Double_t &y,Double_t &z) {Float_t xf,yf,zf,tf;GetPositionL(xf,yf,zf,tf);x=xf,y=yf;z=zf;}
+  virtual void  GetPositionL0(Double_t &x,Double_t &y,Double_t &z,Double_t &t);
+  
+  //
+ protected:
+
+  ClassDef(AliITSUHit,1)  //Hits object
+	 
+}; 
+
+#endif
diff --git a/ITS/UPGRADE/AliITSInitGeometryUpg.cxx b/ITS/UPGRADE/AliITSUInitGeometry.cxx
similarity index 86%
rename from ITS/UPGRADE/AliITSInitGeometryUpg.cxx
rename to ITS/UPGRADE/AliITSUInitGeometry.cxx
index 8006f1bf75a..001b5650369 100644
--- a/ITS/UPGRADE/AliITSInitGeometryUpg.cxx
+++ b/ITS/UPGRADE/AliITSUInitGeometry.cxx
@@ -14,7 +14,7 @@
  **************************************************************************/
 
 /*
-$Id: AliITSInitGeometryUpg.cxx $
+$Id: AliITSUInitGeometry.cxx $
 */
 ////////////////////////////////////////////////////////////////
 //  This class initializes the class AliITSgeom
@@ -45,97 +45,39 @@ $Id: AliITSInitGeometryUpg.cxx $
 #include 
 
 #include "AliLog.h"
-#include "AliITSgeomTGeoUpg.h"
-#include "AliITSInitGeometryUpg.h"
+#include "AliITSUGeomTGeo.h"
+#include "AliITSUInitGeometry.h"
 #include 
 
-ClassImp(AliITSInitGeometryUpg)
+ClassImp(AliITSUInitGeometry)
 
 //______________________________________________________________________
-AliITSInitGeometryUpg::AliITSInitGeometryUpg():
-TObject(),                   // Base Class
-fName(0),                    // Geometry name
-fMinorVersion(-1),           // Minor version number/type
-fMajorVersion(kvDefault),    // Major versin number
-fTiming(kFALSE),             // Flag to start inilization timing
-fSegGeom(kFALSE),            // Flag to switch between the old use of
-                             // AliITSgeomS?D class, or AliITSsegmentation
-                             // class in fShape of AliITSgeom class.
-fDecode(kFALSE),             // Flag for new/old decoding
-fDebug(0){                   // Debug flag
-    // Default Creator
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return:
-    //   A default inilized AliITSInitGeometryUpg object
-
-    fName = "Undefined";
+AliITSUInitGeometry::AliITSUInitGeometry()
+: TObject()
+  ,fName(0)
+  ,fTiming(kFALSE)
+  ,fDebug(0)
+{  
 }
-//______________________________________________________________________
-AliITSInitGeometryUpg::AliITSInitGeometryUpg(AliITSVersion_t version,
-					     Int_t minorversion):
-TObject(),                   // Base Class
-fName(0),                    // Geometry name
-fMinorVersion(minorversion), // Minor version number/type
-fMajorVersion(version),      // Major versin number
-fTiming(kFALSE),             // Flag to start inilization timing
-fSegGeom(kFALSE),            // Flag to switch between the old use of
-                             // AliITSgeomS?D class, or AliITSsegmentation
-                             // class in fShape of AliITSgeom class.
-fDecode(kFALSE),             // Flag for new/old decoding
-fDebug(0){                   // Debug flag
-    // Default Creator
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return:
-    //   A default inilized AliITSInitGeometryUpg object
 
-  switch (version) {
-    case kv11:
-        fName="AliITSv11";
-	break;
-    case kvUpgrade:
-        fName="AliITSvUpgrade";
-	break;
-    case kvDefault:
-    default:
-        AliFatal(Form("Undefined geometry: fMajorVersion=%d, "
-                      "fMinorVersion= %d",(Int_t)fMajorVersion,fMinorVersion));
-        fName = "Undefined";
-	break;
-    } // switch
-}
 //______________________________________________________________________
-AliITSgeom* AliITSInitGeometryUpg::CreateAliITSgeom(){
-    // Creates and Initilizes the geometry transformation class AliITSgeom
-    // to values appropreate to this specific geometry. Now that
-    // the segmentation is part of AliITSgeom, the detector
-    // segmentations are also defined here.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return:
-    //   A pointer to a new properly inilized AliITSgeom class. If
-    //   pointer = 0 then failed to init.
-
+AliITSgeom* AliITSUInitGeometry::CreateAliITSgeom()
+{
+  // Creates and Initilizes the geometry transformation class AliITSgeom
+  // to values appropreate to this specific geometry. Now that
+  // the segmentation is part of AliITSgeom, the detector
+  // segmentations are also defined here.
+  //
 
   AliITSVersion_t version = kvDefault;
   Int_t minor = 0;
   TDatime datetime;
-  TGeoVolume *itsV = gGeoManager->GetVolume(AliITSgeomTGeoUpg::GetITSVolPattern());
+  TGeoVolume *itsV = gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern());
   if(!itsV){
     Error("CreateAliITSgeom","Can't find ITS volume ITSV, aborting");
     return 0;
   }// end if
-  const Char_t *title = itsV->GetTitle();
-  if(!ReadVersionString(title,(Int_t)strlen(title),version,minor,
-			datetime))
-    Warning("UpdateInternalGeometry","Can't read title=%s\n",title);
+
   SetTiming(kFALSE);
   SetSegGeom(kFALSE);
   SetDecoding(kFALSE);
@@ -143,8 +85,9 @@ AliITSgeom* AliITSInitGeometryUpg::CreateAliITSgeom(){
   AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
   return geom;
 }
+
 //______________________________________________________________________
-AliITSgeom* AliITSInitGeometryUpg::CreateAliITSgeom(Int_t major,Int_t minor){
+AliITSgeom* AliITSUInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){
     // Creates and Initilizes the geometry transformation class AliITSgeom
     // to values appropreate to this specific geometry. Now that
     // the segmentation is part of AliITSgeom, the detector
@@ -164,7 +107,7 @@ AliITSgeom* AliITSInitGeometryUpg::CreateAliITSgeom(Int_t major,Int_t minor){
         SetVersion(kv11,minor);
         break;
     case kvUpgrade:
-        SetGeometryName("AliITSvUpgrade");
+        SetGeometryName("AliITSUv11");
         SetVersion(kvUpgrade,minor);
         break;
     case kvDefault:
@@ -181,7 +124,7 @@ AliITSgeom* AliITSInitGeometryUpg::CreateAliITSgeom(Int_t major,Int_t minor){
     return geom;
 }
 //______________________________________________________________________
-Bool_t AliITSInitGeometryUpg::InitAliITSgeom(AliITSgeom *geom){
+Bool_t AliITSUInitGeometry::InitAliITSgeom(AliITSgeom *geom){
   // Initilizes the geometry transformation class AliITSgeom
   // to values appropreate to this specific geometry. Now that
   // the segmentation is part of AliITSgeom, the detector
@@ -214,7 +157,7 @@ Bool_t AliITSInitGeometryUpg::InitAliITSgeom(AliITSgeom *geom){
     return kFALSE;
 }
 //______________________________________________________________________
-void AliITSInitGeometryUpg::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
+void AliITSUInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
     // Transpose the rotation matrix part of a TGeoHMatrix. This
     // is needed because TGeo stores the transpose of the rotation
     // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
@@ -241,7 +184,7 @@ void AliITSInitGeometryUpg::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
 
 
 //______________________________________________________________________
-Bool_t AliITSInitGeometryUpg::InitAliITSgeomV11(AliITSgeom *geom){
+Bool_t AliITSUInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
   // Initilizes the geometry transformation class AliITSgeom
   // Now that the segmentation is part of AliITSgeom, the detector
   // segmentations are also defined here.
@@ -327,7 +270,7 @@ Bool_t AliITSInitGeometryUpg::InitAliITSgeomV11(AliITSgeom *geom){
   return kTRUE;
 }
 //______________________________________________________________________
-Bool_t AliITSInitGeometryUpg::InitAliITSgeomVUpgrade(AliITSgeom *geom){
+Bool_t AliITSUInitGeometry::InitAliITSgeomVUpgrade(AliITSgeom *geom){
   // Initilizes the geometry transformation class AliITSgeom
   // Now that the segmentation is part of AliITSgeom, the detector
   // segmentations are also defined here.
@@ -341,8 +284,6 @@ Bool_t AliITSInitGeometryUpg::InitAliITSgeomVUpgrade(AliITSgeom *geom){
   const Int_t kItype  = 0; // Type of transformation defined 0=> Geant
   const Int_t klayers = GetNumberOfLayers(); // Number of layers in the ITS
   const AliITSDetector kIdet = AliITSDetector(0); //kUPG; RS temporary
-  TString pathbase = Form("/ALIC_1/%s_2/",AliITSgeomTGeoUpg::GetITSVolPattern()); // We have 2 to cheat AliGeoManager::CheckSymNamesLUT
-
   if (klayers <= 0) {
     AliError("No layers found in ITSV");
     return kFALSE;
@@ -355,12 +296,12 @@ Bool_t AliITSInitGeometryUpg::InitAliITSgeomVUpgrade(AliITSgeom *geom){
     kladders[j] = GetNumberOfLadders(j);
     kdetectors[j] = GetNumberOfModules(j);
   }
-  const TString kPathBase = Form("/ALIC_1/%s_1/",AliITSgeomTGeoUpg::GetITSVolPattern());
+  const TString kPathBase = Form("/ALIC_1/%s_1/",AliITSUGeomTGeo::GetITSVolPattern());
   const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d"
-			      ,AliITSgeomTGeoUpg::GetITSLayerPattern()
-			      ,AliITSgeomTGeoUpg::GetITSLadderPattern()
-			      ,AliITSgeomTGeoUpg::GetITSModulePattern()
-			      ,AliITSgeomTGeoUpg::GetITSSensorPattern()
+			      ,AliITSUGeomTGeo::GetITSLayerPattern()
+			      ,AliITSUGeomTGeo::GetITSLadderPattern()
+			      ,AliITSUGeomTGeo::GetITSModulePattern()
+			      ,AliITSUGeomTGeo::GetITSSensorPattern()
 			      );
   Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2;
   Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
@@ -406,7 +347,7 @@ Bool_t AliITSInitGeometryUpg::InitAliITSgeomVUpgrade(AliITSgeom *geom){
 }
 
 //_______________________________________________________________________
-Bool_t AliITSInitGeometryUpg::GetTransformation(const TString &volumePath,
+Bool_t AliITSUInitGeometry::GetTransformation(const TString &volumePath,
 					     TGeoHMatrix &mat){
     // Returns the Transformation matrix between the volume specified
     // by the path volumePath and the Top or mater volume. The format
@@ -442,7 +383,7 @@ Bool_t AliITSInitGeometryUpg::GetTransformation(const TString &volumePath,
     return kTRUE;
 }
 //______________________________________________________________________
-Bool_t AliITSInitGeometryUpg::GetShape(const TString &volumePath,
+Bool_t AliITSUInitGeometry::GetShape(const TString &volumePath,
 				    TString &shapeType,TArrayD &par){
     // Returns the shape and its parameters for the volume specified
     // by volumeName.
@@ -701,7 +642,7 @@ Bool_t AliITSInitGeometryUpg::GetShape(const TString &volumePath,
     return kFALSE;
 }
 //______________________________________________________________________
-void AliITSInitGeometryUpg::DecodeDetector(
+void AliITSUInitGeometry::DecodeDetector(
     Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
@@ -738,7 +679,7 @@ void AliITSInitGeometryUpg::DecodeDetector(
     return;
 }
 //______________________________________________________________________
-void AliITSInitGeometryUpg::RecodeDetector(Int_t mod,Int_t &cpn0,
+void AliITSUInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
                                         Int_t &cpn1,Int_t &cpn2){
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
@@ -775,7 +716,7 @@ void AliITSInitGeometryUpg::RecodeDetector(Int_t mod,Int_t &cpn0,
     return;
 }
 //______________________________________________________________________
-void AliITSInitGeometryUpg::DecodeDetectorLayers(Int_t mod,Int_t &layer,
+void AliITSUInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
                                               Int_t &lad,Int_t &det){
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
@@ -817,7 +758,7 @@ void AliITSInitGeometryUpg::DecodeDetectorLayers(Int_t mod,Int_t &layer,
 }
 
 //______________________________________________________________________
-void AliITSInitGeometryUpg::DecodeDetectorv11(Int_t &mod,Int_t layer,
+void AliITSUInitGeometry::DecodeDetectorv11(Int_t &mod,Int_t layer,
                                  Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
     // decode geometry into detector module number
     // Inputs:
@@ -858,7 +799,7 @@ void AliITSInitGeometryUpg::DecodeDetectorv11(Int_t &mod,Int_t layer,
 }
 
 //______________________________________________________________________
-void AliITSInitGeometryUpg::DecodeDetectorvUpgrade(Int_t &mod,Int_t layer,
+void AliITSUInitGeometry::DecodeDetectorvUpgrade(Int_t &mod,Int_t layer,
                                  Int_t cpn0,Int_t cpn1,Int_t /*cpn2*/) const {
     // decode geometry into detector module number
     // Inputs:
@@ -883,7 +824,7 @@ void AliITSInitGeometryUpg::DecodeDetectorvUpgrade(Int_t &mod,Int_t layer,
 }
 
 //______________________________________________________________________
-void AliITSInitGeometryUpg::RecodeDetectorv11(Int_t mod,Int_t &cpn0,
+void AliITSUInitGeometry::RecodeDetectorv11(Int_t mod,Int_t &cpn0,
 					   Int_t &cpn1,Int_t &cpn2) {
     // decode geometry into detector module number using the new decoding
     // Scheme.
@@ -916,13 +857,13 @@ void AliITSInitGeometryUpg::RecodeDetectorv11(Int_t mod,Int_t &cpn0,
 	  cpn0--;
         } // end if Lay<5/else
     } // end if lay<3/else
-    /*printf("AliITSInitGeometryUpg::RecodeDetectorv11:"
+    /*printf("AliITSUInitGeometry::RecodeDetectorv11:"
            "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n",
            mod,lay,lad,det,cpn0,cpn1,cpn2);*/
 }
 
 //______________________________________________________________________
-void AliITSInitGeometryUpg::RecodeDetectorvUpgrade(Int_t mod,Int_t &cpn0,
+void AliITSUInitGeometry::RecodeDetectorvUpgrade(Int_t mod,Int_t &cpn0,
 						Int_t &cpn1,Int_t &cpn2) {
     // decode geometry into detector module number using the new decoding
     // Scheme.
@@ -944,13 +885,13 @@ void AliITSInitGeometryUpg::RecodeDetectorvUpgrade(Int_t mod,Int_t &cpn0,
     cpn0 = lad;
 //    cpn1--;
 //    cpn0--;
-    /*printf("AliITSInitGeometryUpg::RecodeDetectorv11:"
+    /*printf("AliITSUInitGeometry::RecodeDetectorv11:"
            "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n",
            mod,lay,lad,det,cpn0,cpn1,cpn2);*/
 }
 
 //______________________________________________________________________
-void AliITSInitGeometryUpg::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
+void AliITSUInitGeometry::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
 						 Int_t &lad,Int_t &det) {
 
   // decode module number into detector indices for v11
@@ -989,7 +930,7 @@ void AliITSInitGeometryUpg::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
 }
 
 //______________________________________________________________________
-void AliITSInitGeometryUpg::DecodeDetectorLayersvUpgrade(Int_t  mod,Int_t &lay,
+void AliITSUInitGeometry::DecodeDetectorLayersvUpgrade(Int_t  mod,Int_t &lay,
 						      Int_t &lad,Int_t &det){
 
   // decode module number into detector indices for vUpgrade
@@ -1030,7 +971,7 @@ void AliITSInitGeometryUpg::DecodeDetectorLayersvUpgrade(Int_t  mod,Int_t &lay,
 }
 
 //______________________________________________________________________
-Bool_t AliITSInitGeometryUpg::WriteVersionString(Char_t *str,Int_t length,
+Bool_t AliITSUInitGeometry::WriteVersionString(Char_t *str,Int_t length,
                         AliITSVersion_t maj,Int_t min,
                         const Char_t *cvsDate,const Char_t *cvsRevision)const{
     // fills the string str with the major and minor version number
@@ -1074,7 +1015,7 @@ Bool_t AliITSInitGeometryUpg::WriteVersionString(Char_t *str,Int_t length,
     n = 50+(Int_t)(TMath::Log10(TMath::Abs((Double_t)i)))+1+
         (Int_t)(TMath::Log10(TMath::Abs((Double_t)min)))+1
         +cvsDateLength-6+cvsRevisionLength-10;
-    if(GetDebug()>1) printf("AliITSInitGeometryUpg::WriteVersionString:"
+    if(GetDebug()>1) printf("AliITSUInitGeometry::WriteVersionString:"
                         "length=%d major=%d minor=%d cvsDate=%s[%d] "
                         "cvsRevision=%s[%d] n=%d\n",length,i,min,cvslikedate,
                         cvsDateLength,cvsRevision,cvsRevisionLength,n);
@@ -1096,7 +1037,7 @@ Bool_t AliITSInitGeometryUpg::WriteVersionString(Char_t *str,Int_t length,
     i = (Int_t)maj;
     snprintf(str,length-1,"Major Version= %d Minor Version= %d Revision: %s Date: %s",i,min,cvsrevision,cvsdate);
     /* this gives compilation warnings on some compilers: descriptor zu
-    if(GetDebug()>1)printf("AliITSInitGeometryUpg::WriteVersionString: "
+    if(GetDebug()>1)printf("AliITSUInitGeometry::WriteVersionString: "
                        "n=%d str=%s revision[%zu] date[%zu]\n",
                        n,str,strlen(cvsrevision),strlen(cvsdate));
     */
@@ -1105,7 +1046,7 @@ Bool_t AliITSInitGeometryUpg::WriteVersionString(Char_t *str,Int_t length,
     return kTRUE;
 }
 //______________________________________________________________________
-Bool_t AliITSInitGeometryUpg::ReadVersionString(const Char_t *str,Int_t length,
+Bool_t AliITSUInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
                                              AliITSVersion_t &maj,Int_t &min,
                                              TDatime &dt)const{
     // fills the string str with the major and minor version number
@@ -1129,7 +1070,7 @@ Bool_t AliITSInitGeometryUpg::ReadVersionString(const Char_t *str,Int_t length,
     memset(cvsDate,0,11*sizeof(Char_t));    
     memset(cvsTime,0,9*sizeof(Char_t));
 
-    if(GetDebug()>1)printf("AliITSInitGeometryUpg::ReadVersionString:"
+    if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString:"
                        "str=%s length=%d\n",
                        str,length);
     if(n<35) return kFALSE; // not enough space for numbers
@@ -1144,10 +1085,10 @@ Bool_t AliITSInitGeometryUpg::ReadVersionString(const Char_t *str,Int_t length,
     ok = m==3;
     if(!ok) return !ok;
     dt.Set(year,month,day,hours,minuits,seconds);
-    if(GetDebug()>1)printf("AliITSInitGeometryUpg::ReadVersionString: i=%d "
+    if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString: i=%d "
                      "min=%d cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
                        i,min,cvsRevision,cvsDate,cvsTime,m);
-    if(GetDebug()>1)printf("AliITSInitGeometryUpg::ReadVersionString: year=%d"
+    if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString: year=%d"
                        " month=%d day=%d hours=%d minuits=%d seconds=%d\n",
                        year,month,day,hours,minuits,seconds);
     switch (i){
@@ -1164,7 +1105,7 @@ Bool_t AliITSInitGeometryUpg::ReadVersionString(const Char_t *str,Int_t length,
     return ok;
 }
 //______________________________________________________________________
-Int_t AliITSInitGeometryUpg::GetNumberOfLayers(){
+Int_t AliITSUInitGeometry::GetNumberOfLayers(){
   // Determines the number of layers in the Upgrade Geometry
   //
   // Inputs:
@@ -1189,20 +1130,20 @@ Int_t AliITSInitGeometryUpg::GetNumberOfLayers(){
       return 0;
     }
 
-    if (!gGeoManager->GetVolume(AliITSgeomTGeoUpg::GetITSVolPattern())) {
-      AliError(Form("can't find %s volume",AliITSgeomTGeoUpg::GetITSVolPattern()));
+    if (!gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())) {
+      AliError(Form("can't find %s volume",AliITSUGeomTGeo::GetITSVolPattern()));
       return 0;
     }
 
     // Loop on all ITSV nodes, count Layer volumes by checking names
-    Int_t nNodes = gGeoManager->GetVolume(AliITSgeomTGeoUpg::GetITSVolPattern())->GetNodes()->GetEntries();
+    Int_t nNodes = gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())->GetNodes()->GetEntries();
 
     if (nNodes == 0)
       return 0;
 
     for (Int_t j=0; jGetVolume(AliITSgeomTGeoUpg::GetITSVolPattern())->GetNodes()->At(j)->GetName(),
-		 AliITSgeomTGeoUpg::GetITSLayerPattern()))
+      if (strstr(gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())->GetNodes()->At(j)->GetName(),
+		 AliITSUGeomTGeo::GetITSLayerPattern()))
 	numberOfLayers++;
 
 
@@ -1210,7 +1151,7 @@ Int_t AliITSInitGeometryUpg::GetNumberOfLayers(){
 }
 
 //______________________________________________________________________
-Int_t AliITSInitGeometryUpg::GetNumberOfLadders(const Int_t lay) const {
+Int_t AliITSUInitGeometry::GetNumberOfLadders(const Int_t lay) const {
   // Determines the number of layers in the Upgrade Geometry
   //
   // Inputs:
@@ -1236,7 +1177,7 @@ Int_t AliITSInitGeometryUpg::GetNumberOfLadders(const Int_t lay) const {
     }
 
     char laynam[15];
-    snprintf(laynam, 15, "%s%d", AliITSgeomTGeoUpg::GetITSLayerPattern(),lay+1);
+    snprintf(laynam, 15, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),lay+1);
     if (!gGeoManager->GetVolume(laynam)) {
       AliError(Form("can't find %s volume",laynam));
       return 0;
@@ -1250,7 +1191,7 @@ Int_t AliITSInitGeometryUpg::GetNumberOfLadders(const Int_t lay) const {
 
     for (Int_t j=0; jGetVolume(laynam)->GetNodes()->At(j)->GetName(),
-		 AliITSgeomTGeoUpg::GetITSLadderPattern()))
+		 AliITSUGeomTGeo::GetITSLadderPattern()))
 	numberOfLadders++;
 
 
@@ -1258,7 +1199,7 @@ Int_t AliITSInitGeometryUpg::GetNumberOfLadders(const Int_t lay) const {
 }
 
 //______________________________________________________________________
-Int_t AliITSInitGeometryUpg::GetLayerDetTypeID(const Int_t lay) const 
+Int_t AliITSUInitGeometry::GetLayerDetTypeID(const Int_t lay) const 
 {
   // Determines the layers det. type in the Upgrade Geometry
   //
@@ -1283,7 +1224,7 @@ Int_t AliITSInitGeometryUpg::GetLayerDetTypeID(const Int_t lay) const
   }
   
   char laynam[15];
-  snprintf(laynam, 15, "%s%d", AliITSgeomTGeoUpg::GetITSLayerPattern(),lay+1);
+  snprintf(laynam, 15, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),lay+1);
   TGeoVolume* volLr = gGeoManager->GetVolume(laynam);
   if (!volLr) {
     AliError(Form("can't find %s volume",laynam));
@@ -1295,7 +1236,7 @@ Int_t AliITSInitGeometryUpg::GetLayerDetTypeID(const Int_t lay) const
 }
 
 //______________________________________________________________________
-Int_t AliITSInitGeometryUpg::GetNumberOfModules(const Int_t lay) const {
+Int_t AliITSUInitGeometry::GetNumberOfModules(const Int_t lay) const {
   // Determines the number of layers in the Upgrade Geometry
   //
   // Inputs:
@@ -1321,7 +1262,7 @@ Int_t AliITSInitGeometryUpg::GetNumberOfModules(const Int_t lay) const {
     }
 
     char laddnam[15];
-    snprintf(laddnam, 15, "%s%d", AliITSgeomTGeoUpg::GetITSLadderPattern(),lay+1);
+    snprintf(laddnam, 15, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(),lay+1);
     if (!gGeoManager->GetVolume(laddnam)) {
       AliError(Form("can't find %s volume",laddnam));
       return 0;
@@ -1335,7 +1276,7 @@ Int_t AliITSInitGeometryUpg::GetNumberOfModules(const Int_t lay) const {
 
     for (Int_t j=0; jGetVolume(laddnam)->GetNodes()->At(j)->GetName(),
-		 AliITSgeomTGeoUpg::GetITSModulePattern()))
+		 AliITSUGeomTGeo::GetITSModulePattern()))
 	numberOfModules++;
 
 
diff --git a/ITS/UPGRADE/AliITSInitGeometryUpg.h b/ITS/UPGRADE/AliITSUInitGeometry.h
similarity index 56%
rename from ITS/UPGRADE/AliITSInitGeometryUpg.h
rename to ITS/UPGRADE/AliITSUInitGeometry.h
index 3e7cbdd55ae..7bf8244847e 100644
--- a/ITS/UPGRADE/AliITSInitGeometryUpg.h
+++ b/ITS/UPGRADE/AliITSUInitGeometry.h
@@ -1,10 +1,10 @@
-#ifndef ALIITSINITGEOMETRYUPG_H
-#define ALIITSINITGEOMETRYUPG_H
+#ifndef ALIITSUINITGEOMETRY_H
+#define ALIITSUINITGEOMETRY_H
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
 /*
-$Id: AliITSInitGeometryUpg.h $
+$Id: AliITSUInitGeometry.h $
 */
 
 /////////////////////////////////////////////////////////////////////
@@ -16,59 +16,35 @@ $Id: AliITSInitGeometryUpg.h $
 #include 
 #include "AliITSgeom.h"
 
-typedef enum {
-  kvDefault=0,kv11=11,kvUpgrade=20
-} AliITSVersion_t;
-
 class TArrayD;
 class TGeoHMatrix;
 class TDatime;
 
-class AliITSInitGeometryUpg : public TObject{
+class AliITSUInitGeometry : public TObject{
  public:
 
-    AliITSInitGeometryUpg();//Default Constructor
-    AliITSInitGeometryUpg(AliITSVersion_t version,
-		       Int_t minorversion=2);//Standard Constructor
-    //virtual ~AliITSInitGeometryUpg(); // Destructor
+    AliITSUInitGeometry();//Default Constructor
+    AliITSUInitGeometry(AliITSVersion_t version,Int_t minorversion=2);//Standard Constructor
+    //virtual ~AliITSUInitGeometry(); // Destructor
     //
     // Create and initialize geometry from TGeo
     AliITSgeom* CreateAliITSgeom();
     AliITSgeom* CreateAliITSgeom(Int_t major,Int_t minor); 
     Bool_t InitAliITSgeom(AliITSgeom *geom);//Initilize geometry from gGeoManager
-    // Getters and Setters
-    // Getters and Setters
-    void    SetVersion(AliITSVersion_t maj,Int_t min) {// Set Major and Minor versions
-        fMajorVersion=maj;fMinorVersion=min;}
     TString GetGeometryName()const {return fName;}// Return geometry name
     void    SetGeometryName(const Char_t *name){fName = name;}// Set Geometry name
-    Int_t   GetMajorVersion()const {return (Int_t)fMajorVersion;} // Return geometry major version
-    Int_t   GetMinorVersion()const{return fMinorVersion;}// Return geometry minor version
     Bool_t  GetTiming()const{return fTiming;} // return routine timing flag
     void    SetTiming(Bool_t time=kTRUE){fTiming=time;}// Set routine timing (on)
-    Bool_t  GetSegGeom()const{return fSegGeom;} // return flag indecating the use of AliITSsegmentation or AliITSgeomS?D class in fShape.
-    void    SetSegGeom(Bool_t seg=kTRUE){fSegGeom = seg;}// Set the use of AliITSsegmentation class' instead of AliITSgeomS?D class in fShape
-    Bool_t  GetDecoding()const{return fDecode;}// Return flag indecating wether to use new/old decoding
-    void    SetDecoding(Bool_t newdec=kFALSE){fDecode = newdec;}// Set flag to use new/old decoding
-     // Set debug level. debug=0 no debug info outputted.
     void    SetDebug(Int_t debug=0){fDebug=debug;};
     // Retrun debug value
     Int_t   GetDebug()const{return fDebug;};
     // Decode module number into old layer, ladder, and detector numbers
     void DecodeDetectorLayers(Int_t mod,Int_t &lay,Int_t &lad,Int_t &det);
     // find module number by layer, and copy numbers
-    void DecodeDetector(Int_t &mod,Int_t lay,Int_t cpn0,
-                        Int_t cpn1,Int_t cpn2) const;
+    void  DecodeDetector(Int_t &mod,Int_t lay,Int_t cpn0,
+			 Int_t cpn1,Int_t cpn2) const;
     // Given module number, find copy numbers.
-    void RecodeDetector(Int_t mod,Int_t &cpn0,Int_t &cpn1,Int_t &cpn2);
-   // fills the string str with the major and minor version number
-    Bool_t WriteVersionString(Char_t *str,Int_t length,
-                              AliITSVersion_t maj,Int_t min,
-                              const Char_t *cvsDate,const Char_t *cvsRev)const;
-    // decodes the string str with the major and minor version number
-    Bool_t ReadVersionString(const Char_t *str,Int_t length,
-                             AliITSVersion_t &maj,Int_t &min,TDatime &dt)const;
-
+    void  RecodeDetector(Int_t mod,Int_t &cpn0,Int_t &cpn1,Int_t &cpn2);
     Int_t GetNumberOfLayers();
     Int_t GetNumberOfLadders(const Int_t lay) const;
     Int_t GetNumberOfModules(const Int_t lay) const;
@@ -102,16 +78,10 @@ class AliITSInitGeometryUpg : public TObject{
     void TransposeTGeoHMatrix(TGeoHMatrix *m) const;
 
     TString         fName;         // Geometry name
-    Int_t           fMinorVersion; // Geometry minor version
-    AliITSVersion_t fMajorVersion; // Geometry swich value
     Bool_t          fTiming;       // Flag to start inilization timing
-    Bool_t          fSegGeom;      // Flag to switch between the old use of
-                                   // AliITSgeomS?D class, or AliITSsegmentation
-                                   // class in fShape of AliITSgeom class.
-    Bool_t          fDecode;       // Flag for new/old decoding
     Int_t           fDebug;        // Debug flag
 
-    ClassDef(AliITSInitGeometryUpg,0) // create/Init AliITSgeom
+    ClassDef(AliITSUInitGeometry,0) // create/Init AliITSgeom
     // 0 in ClassDef indicates that this class will not be "saved" in a file.
 };
 
diff --git a/ITS/UPGRADE/AliITSLoaderUpg.cxx b/ITS/UPGRADE/AliITSULoader.cxx
similarity index 78%
rename from ITS/UPGRADE/AliITSLoaderUpg.cxx
rename to ITS/UPGRADE/AliITSULoader.cxx
index 0099a0985d2..730a1f6ef37 100644
--- a/ITS/UPGRADE/AliITSLoaderUpg.cxx
+++ b/ITS/UPGRADE/AliITSULoader.cxx
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id: AliITSLoaderUpg.cxx $ */
+/* $Id: AliITSULoader.cxx $ */
 
 #include 
 #include 
@@ -21,10 +21,9 @@
 #include 
 
 #include "AliITSdigit.h"
-#include "AliITSLoaderUpg.h"
+#include "AliITSULoader.h"
 #include "AliRunLoader.h"
 #include "AliObjectLoader.h"
-#include "AliITSInitGeometryUpg.h"
 #include "AliLog.h"
 
 ///////////////////////////////////////////////////////////////////////////
@@ -34,17 +33,19 @@
 // V0 and cascade
 // and tracks propagated to the origin
 //////////////////////////////////////////////////////////////////////////
-ClassImp(AliITSLoaderUpg)
+ClassImp(AliITSULoader)
 
 /**********************************************************************/
-  AliITSLoaderUpg::AliITSLoaderUpg():AliLoader(),
-fGeom(0){
+AliITSULoader::AliITSULoader()
+:AliLoader()
+{
   // Default constructor
 }
+
 /*********************************************************************/
-AliITSLoaderUpg::AliITSLoaderUpg(const Char_t *name,const Char_t *topfoldername):
-AliLoader(name,topfoldername),
-fGeom(0){
+AliITSULoader::AliITSULoader(const Char_t *name,const Char_t *topfoldername)
+: AliLoader(name,topfoldername)
+{
   //Constructor   
   TString rawContainerName = "TreeC";
     AliDataLoader* rawClustersDataLoader = new AliDataLoader(
@@ -83,9 +84,9 @@ fGeom(0){
     cascadeDataLoader->SetFolder(GetDetectorDataFolder());
 }
 /**********************************************************************/
-AliITSLoaderUpg::AliITSLoaderUpg(const Char_t *name,TFolder *topfolder): 
-  AliLoader(name,topfolder),
-fGeom(0){
+AliITSULoader::AliITSULoader(const Char_t *name,TFolder *topfolder)
+: AliLoader(name,topfolder)
+{
   //ctor  
    TString rawContainerName="TreeC";
     AliDataLoader*  rawClustersDataLoader = new AliDataLoader(
@@ -125,7 +126,7 @@ fGeom(0){
 
 
 /**********************************************************************/
-AliITSLoaderUpg::~AliITSLoaderUpg(){
+AliITSULoader::~AliITSULoader(){
     //destructor
     UnloadRawClusters();
     AliDataLoader *dl = GetRawClLoader();
@@ -147,12 +148,10 @@ AliITSLoaderUpg::~AliITSLoaderUpg(){
     dl = GetCascadeDataLoader();
     fDataLoaders->Remove(dl);
   
-    if(fGeom)delete fGeom;
-    fGeom = 0;
 }
 /*
 //----------------------------------------------------------------------
-AliITS* AliITSLoaderUpg::GetITS(){
+AliITS* AliITSULoader::GetITS(){
     // Returns the pointer to the ITS, kept on the file. A short cut metthod
     // Inputs:
     //    none.
@@ -177,7 +176,7 @@ AliITS* AliITSLoaderUpg::GetITS(){
     return its;
 }
 //----------------------------------------------------------------------
-void AliITSLoaderUpg::SetupDigits(AliITS *its){
+void AliITSULoader::SetupDigits(AliITS *its){
     // Sets up to store ITS Digits in side AliITS::fDtype TObjArray
     // Inputs:
     //    AliITS *its  Pointer to the ITS
@@ -190,7 +189,7 @@ void AliITSLoaderUpg::SetupDigits(AliITS *its){
 }
 */
 //----------------------------------------------------------------------
-void AliITSLoaderUpg::SetupDigits(TObjArray *digPerDet,Int_t n,
+void AliITSULoader::SetupDigits(TObjArray *digPerDet,Int_t n,
 				  const Char_t **digclass){
     // Sets up digPerDet to store ITS Digits.
     // Inputs:
@@ -251,7 +250,7 @@ void AliITSLoaderUpg::SetupDigits(TObjArray *digPerDet,Int_t n,
     } // end for i
 }
 //---------------------------------------------------------------------
-AliITSdigit * AliITSLoaderUpg::GetDigit(TObjArray *digPerDet,Int_t module,
+AliITSdigit * AliITSULoader::GetDigit(TObjArray *digPerDet,Int_t module,
 					Int_t digit){
     // Gets the digit for for a specific detector type and module.
     // To be used in conjustion with Setupdigits(AliITS *its).
@@ -272,36 +271,8 @@ AliITSdigit * AliITSLoaderUpg::GetDigit(TObjArray *digPerDet,Int_t module,
     } // end if
     return 0;
 }
-/*
-//---------------------------------------------------------------------
-AliITSdigit * AliITSLoaderUpg::GetDigit(AliITS *its,Int_t module,Int_t digit){
-    // Gets the digit for for a specific detector type and module.
-    // To be used in conjustion with Setupdigits(AliITS *its).
-    // Inputs:
-    //   AliITS *its    Pointer to the ITS
-    //   Int_t  module  Module number
-    //   Int_t digit    Digit number
-    // Outputs:
-    //   none.
-    // Return:
-    //   returns the pointer to the digit. if zero then last digit for that
-    //   module.
-    //AliITSDetType *idtype;
-    AliITSgeom *geom = its->GetITSgeom();
-    Int_t idet = geom->GetModuleType(module);
-    TClonesArray *digits;
- 
-    its->ResetDigits();
-    TreeD()->GetEvent(module);
-    digits = its->DigitsAddress(idet);
-    if(digit>-1 && digitGetEntriesFast()){ // if in range.
-        return (AliITSdigit*) digits->At(digit);
-    } // end if
-    return 0;
-}
-*/
 //----------------------------------------------------------------------
-void AliITSLoaderUpg::MakeTree(Option_t *opt){
+void AliITSULoader::MakeTree(Option_t *opt){
     // invokes AliLoader::MakeTree + specific ITS tree(s)
     // Valid options: H,S,D,R,T and C (C=raw clusters)
     AliLoader::MakeTree(opt);
@@ -317,41 +288,3 @@ void AliITSLoaderUpg::MakeTree(Option_t *opt){
     const char *oX = strstr(opt,"X");
     if (oX) MakeCascadeContainer();
 }
-
-//----------------------------------------------------------------------
-AliITSgeom* AliITSLoaderUpg::GetITSgeom(Bool_t force) {
-  // retrieves the ITS geometry from file
-  if(fGeom && !force)return fGeom;
-  if(fGeom && force){
-    delete fGeom;
-    fGeom = 0;
-  }
-  if(!gGeoManager){
-    AliError("gGeoManager is a null pointer - ITS geometry not built");
-    return fGeom;
-  }
-  AliITSInitGeometryUpg initgeom;
-  fGeom = initgeom.CreateAliITSgeom();
-  AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
-  AliDebug(1,Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
-  return fGeom;
-}
-//______________________________________________________________________
-void AliITSLoaderUpg::SetITSgeom(AliITSgeom *geom){
-    // Replaces the AliITSgeom object read from file with the one
-    // given.
-    // Inputs:
-    //   AliITSgeom *geom   The AliITSgeom object to replace the one
-    //                      read from the file
-    // Outputs:
-    //   none.
-    // Return:
-    //   none.
-
-    if(fGeom==geom) return; // Same do nothing
-    if(fGeom) {
-	delete fGeom;
-	fGeom=0;
-    }// end if
-    fGeom=geom;
-}
diff --git a/ITS/UPGRADE/AliITSLoaderUpg.h b/ITS/UPGRADE/AliITSULoader.h
similarity index 89%
rename from ITS/UPGRADE/AliITSLoaderUpg.h
rename to ITS/UPGRADE/AliITSULoader.h
index 2ac1983f5df..029307e5ad6 100644
--- a/ITS/UPGRADE/AliITSLoaderUpg.h
+++ b/ITS/UPGRADE/AliITSULoader.h
@@ -1,22 +1,21 @@
-#ifndef ALIITSLOADERUPG_H
-#define ALIITSLOADERUPG_H
+#ifndef ALIITSULOADER_H
+#define ALIITSULOADER_H
 //////////////////////////////////////////////////////////
 // Loader class for ITS Upgrade                         //
 //////////////////////////////////////////////////////////
 #include 
 #include 
-#include 
 class AliITSpidESD;
 class AliITSdigit;
 class TObjArray;
 
-class AliITSLoaderUpg: public AliLoader{
+class AliITSULoader: public AliLoader{
   public:
-    AliITSLoaderUpg();
-    AliITSLoaderUpg(const Char_t *name,const Char_t *topfoldername);
-    AliITSLoaderUpg(const Char_t *name,TFolder *topfolder);
+    AliITSULoader();
+    AliITSULoader(const Char_t *name,const Char_t *topfoldername);
+    AliITSULoader(const Char_t *name,TFolder *topfolder);
 
-    virtual ~AliITSLoaderUpg();
+    virtual ~AliITSULoader();
 
     void           MakeTree(Option_t* opt);
     virtual void   SetupDigits(TObjArray *digPerDet,Int_t n,
@@ -108,12 +107,10 @@ class AliITSLoaderUpg: public AliLoader{
 
     // Geometry. Geom is read from file, unless already loaded
     // readout from file can be forced if force=kTRUE
-    AliITSgeom* GetITSgeom(Bool_t force=kFALSE); 
-    void SetITSgeom(AliITSgeom* g);
   protected:
 
-    AliITSLoaderUpg(const AliITSLoaderUpg &ob); // copy constructor
-    AliITSLoaderUpg& operator=(const AliITSLoaderUpg & /* source */); // ass.
+    AliITSULoader(const AliITSULoader &ob); // copy constructor
+    AliITSULoader& operator=(const AliITSULoader & /* source */); // ass.
 
     // METHODS
     virtual void   MakeRawClustersContainer() {GetRawClLoader()->MakeTree();}
@@ -132,11 +129,8 @@ class AliITSLoaderUpg: public AliLoader{
     Int_t          PostCascades(){
         return GetCascadeDataLoader()->GetBaseLoader(0)->Post();}
 
-    // DATA
-    AliITSgeom *fGeom;     //! pointer to the ITS geometry class
 
-
-    ClassDef(AliITSLoaderUpg,1) // Loader for additional ITS specific trees.
+    ClassDef(AliITSULoader,1) // Loader for additional ITS specific trees.
 };
  
 #endif
diff --git a/ITS/UPGRADE/AliITSUModule.cxx b/ITS/UPGRADE/AliITSUModule.cxx
new file mode 100644
index 00000000000..a4f63164307
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUModule.cxx
@@ -0,0 +1,344 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id: AliITSUModule.cxx 53509 2011-12-10 18:55:52Z masera $ */
+
+#include 
+
+#include 
+
+#include "AliRun.h"
+#include "AliITS.h"
+#include "AliITSUModule.h"
+#include "AliITSUGeomTGeo.h"
+
+ClassImp(AliITSUModule)
+
+//_______________________________________________________________________
+//
+// Impementation of class AliITSUModule
+//
+// created by: A. Bouchm, W. Peryt, S. Radomski, P. Skowronski 
+//             R. Barbers, B. Batyunia, B. S. Nilsen
+// ver 1.0     CERN 16.09.1999
+//_______________________________________________________________________
+//________________________________________________________________________
+// 
+// Constructors and deconstructor
+//________________________________________________________________________
+//
+AliITSUModule::AliITSUModule()
+:  fHitsM(0)
+  ,fGeomTG(0)
+{
+  // constructor
+}
+
+//_________________________________________________________________________
+AliITSUModule::AliITSUModule(Int_t index, AliITSUGeomTGeo* tg)
+  :fHitsM(new TObjArray())
+  ,fGeomTG(tg)
+{
+  // constructor
+  SetIndex(index);
+}
+
+//__________________________________________________________________________
+AliITSUModule::~AliITSUModule() 
+{
+  // The destructor for AliITSUModule. Before destoring AliITSUModule
+  // we must first destroy all of it's members.
+  if (fHitsM) fHitsM->Clear();
+  delete fHitsM;
+}
+
+//____________________________________________________________________________
+AliITSUModule::AliITSUModule(const AliITSUModule &source)
+ :TObject(source)
+ ,fHitsM(source.fHitsM)
+ ,fGeomTG(source.fGeomTG)
+{
+//     Copy Constructor 
+}
+
+//_____________________________________________________________________________
+AliITSUModule& AliITSUModule::operator=(const AliITSUModule &source)
+{
+  //    Assignment operator 
+  if (this!=&source) {
+    this->~AliITSUModule();
+    new(this) AliITSUModule(source);
+  }
+  return *this;
+}
+
+//___________________________________________________________________________
+Double_t AliITSUModule::PathLength(const AliITSUHit *itsHit1,const AliITSUHit *itsHit2) 
+{
+  // path lenght
+  Float_t  x1g,y1g,z1g;   
+  Float_t  x2g,y2g,z2g;
+  Double_t s;
+  //
+  itsHit1->GetPositionG(x1g,y1g,z1g);
+  itsHit2->GetPositionG(x2g,y2g,z2g);
+  //
+  s = TMath::Sqrt( ((Double_t)(x2g-x1g)*(Double_t)(x2g-x1g)) +
+		   ((Double_t)(y2g-y1g)*(Double_t)(y2g-y1g)) +
+		   ((Double_t)(z2g-z1g)*(Double_t)(z2g-z1g))  );
+   return s;
+}
+
+//___________________________________________________________________________
+void AliITSUModule::PathLength(Float_t x,Float_t y,Float_t z,Int_t status,Int_t &nseg,Float_t &x1,Float_t &y1,Float_t &z1,
+			      Float_t &dx1,Float_t &dy1,Float_t &dz1,Int_t &flag) const
+{
+  // path length
+  static Float_t x0,y0,z0;
+  //
+  if ((status&0x0002)!=0){ // entering
+    x0 = x;
+    y0 = y;
+    z0 = z;
+    nseg = 0;
+    flag = 1;
+  }else{
+    x1 = x0;
+    y1 = y0;
+    z1 = z0;
+    dx1 = x-x1;
+    dy1 = y-y1;
+    dz1 = z-z1;
+    nseg++;
+    if ((status&0x0004)!=0) flag = 0; //exiting
+    if ((status&0x0001)!=0) flag = 2; // inside
+    else flag = 2; //inside ?
+    x0 = x;
+    y0 = y;
+    z0 = z;
+  } // end if
+}
+
+//___________________________________________________________________________
+Bool_t AliITSUModule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,
+				  Double_t &e,Double_t &f,Double_t &de)
+{
+  // line segment
+  AliITSUHit *h1;
+  Double_t t;
+  //  
+  if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
+  //
+  h1 = (AliITSUHit *) (fHitsM->At(hitindex));
+  if(h1->StatusEntering()) return kFALSE; // if track entering volume, get index for next step
+  de = h1->GetIonization();
+  h1->GetPositionL0(a,c,e,t);
+  h1->GetPositionL(b,d,f);
+  b = b - a;
+  d = d - c;
+  f = f - e;
+  return kTRUE;
+}
+
+//___________________________________________________________________________
+Bool_t AliITSUModule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,
+				  Double_t &e,Double_t &f,Double_t &de)
+{
+  // line segment
+  AliITSUHit *h1;
+  Double_t t;
+  //
+  if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
+  h1 = (AliITSUHit *) (fHitsM->At(hitindex));
+  if(h1->StatusEntering()) return kFALSE; // if track entering volume, get index for next step
+  de = h1->GetIonization();
+  h1->GetPositionG0(a,c,e,t);
+  h1->GetPositionG(b,d,f);
+  b = b - a;
+  d = d - c;
+  f = f - e;
+  return kTRUE;
+}
+
+//___________________________________________________________________________
+Bool_t AliITSUModule::LineSegmentL(Int_t hitindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,
+				  Double_t &e,Double_t &f,Double_t &de,Int_t &track)
+{
+  // line segmente
+  AliITSUHit *h1;
+  Double_t t;
+  //
+  if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
+  //
+  h1 = (AliITSUHit *) (fHitsM->At(hitindex));
+  if(h1->StatusEntering()){ // if track entering volume, get index for next
+    // step
+    track = h1->GetTrack();
+    return kFALSE;
+  } // end if StatusEntering()
+    // else stepping
+  de = h1->GetIonization();
+  h1->GetPositionL0(a,c,e,t);
+  h1->GetPositionL(b,d,f);
+  b = b - a;
+  d = d - c;
+  f = f - e;
+  track = h1->GetTrack();
+  return kTRUE;
+}
+
+//___________________________________________________________________________
+Bool_t AliITSUModule::LineSegmentG(Int_t hitindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,
+				  Double_t &e,Double_t &f,Double_t &de,Int_t &track)
+{
+  // line segment
+  AliITSUHit *h1;
+  Double_t t;
+  //
+  if(hitindex>= fHitsM->GetEntriesFast()) return kFALSE;
+  //
+  h1 = (AliITSUHit *) (fHitsM->At(hitindex));
+  if(h1->StatusEntering()){ // if track entering volume, get index for next
+    // step
+    track = h1->GetTrack();
+    return kFALSE;
+  } // end if StatusEntering()
+  de = h1->GetIonization();
+  h1->GetPositionG0(a,c,e,t);
+  h1->GetPositionG(b,d,f);
+  b = b - a;
+  d = d - c;
+  f = f - e;
+  track = h1->GetTrack();
+  return kTRUE;
+}
+
+//______________________________________________________________________
+Bool_t AliITSUModule::MedianHitG(AliITSUHit *h1,AliITSUHit *h2,Float_t &x,Float_t &y,Float_t &z)
+{
+  // Computes the mean hit location for a set of hits that make up a track
+  // passing through a volume. Returns kFALSE untill the the track leaves
+  // the volume.
+  // median hit
+  Float_t x1l=0.,y1l=0.,z1l=0.;
+  Float_t x2l=0.,y2l=0.,z2l=0.;
+  Float_t xMl,yMl=0,zMl;
+  Double_t l[3], g[3];
+  
+  h1->GetPositionG(x1l,y1l,z1l);
+  h2->GetPositionG(x2l,y2l,z2l);
+  
+  if((y2l*y1l)<0.) {
+    xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
+    zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
+  } else {
+    xMl = 0.5*(x1l+x2l);
+    zMl = 0.5*(z1l+z2l);
+  }
+  
+  l[0] = xMl;
+  l[1] = yMl;
+  l[2] = zMl;
+  fGeomTG->LocalToGlobal(h1->GetModule(),l,g);
+  x = g[0];
+  y = g[1];
+  z = g[2];
+  return kTRUE;
+}
+
+//___________________________________________________________________________
+void AliITSUModule::MedianHitG(Int_t index,Float_t hitx1,Float_t hity1,Float_t hitz1,Float_t hitx2,Float_t hity2,Float_t hitz2,
+				 Float_t &xMg, Float_t &yMg, Float_t &zMg)
+{
+  // median hit
+  Float_t x1l,y1l,z1l;
+  Float_t x2l,y2l,z2l;
+  Float_t xMl,yMl=0,zMl;
+  Double_t l[3], g[3];
+  
+  g[0] = hitx1;
+  g[1] = hity1;
+  g[2] = hitz1;
+  fGeomTG->GlobalToLocal(index,g,l);
+  x1l = l[0];
+  y1l = l[1];
+  z1l = l[2];
+  
+  g[0] = hitx2;
+  g[1] = hity2;
+  g[2] = hitz2;
+  fGeomTG->GlobalToLocal(index,g,l);
+  x2l = l[0];
+  y2l = l[1];
+  z2l = l[2];
+  
+  if((y2l*y1l)<0.) {
+    xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
+    zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;
+  } else {
+    xMl = 0.5*(x1l+x2l);
+    zMl = 0.5*(z1l+z2l);
+  }
+  
+  l[0] = xMl;
+  l[1] = yMl;
+  l[2] = zMl;
+  fGeomTG->LocalToGlobal(index,l,g);
+  xMg = g[0];
+  yMg = g[1];
+  zMg = g[2];
+}
+
+//___________________________________________________________________________
+Bool_t AliITSUModule::MedianHitL( AliITSUHit *itsHit1,AliITSUHit *itsHit2, Float_t &xMl, Float_t &yMl, Float_t &zMl) const
+{
+  // median hit
+  Float_t x1l,y1l,z1l;
+  Float_t x2l,y2l,z2l;
+  
+  itsHit1->GetPositionL(x1l,y1l,z1l);
+  itsHit2->GetPositionL(x2l,y2l,z2l);
+  
+  yMl = 0.0;
+  if((y2l*y1l)<0.) {
+    xMl = (-y1l / (y2l-y1l))*(x2l-x1l) + x1l;
+    zMl = (-y1l / (y2l-y1l))*(z2l-z1l) + z1l;	     
+  } else {
+    xMl = 0.5*(x1l+x2l);
+    zMl = 0.5*(z1l+z2l);
+  }
+  return kTRUE;
+}
+
+//___________________________________________________________________________
+void AliITSUModule::MedianHit(Int_t index,Float_t xg,Float_t yg,Float_t zg,Int_t status,
+			     Float_t &xMg,Float_t &yMg,Float_t &zMg,Int_t &flag)
+{
+  // median hit
+  static Float_t x1,y1,z1;
+  //
+  if ((status&0x0002)!=0){ // entering
+    x1 = xg;
+    y1 = yg;
+    z1 = zg;
+    flag = 1;
+  } else if ((status&0x0004)!=0){ // exiting
+    MedianHitG(index,x1,y1,z1,xg,yg,zg,xMg,yMg,zMg);
+    flag = 0;
+  } // end if
+  else  flag = 1;
+}
+
+
diff --git a/ITS/UPGRADE/AliITSUModule.h b/ITS/UPGRADE/AliITSUModule.h
new file mode 100644
index 00000000000..d5e6cad269f
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUModule.h
@@ -0,0 +1,68 @@
+#ifndef ALIITSUMODULE_H
+#define ALIITSUMODULE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliITSUModule.h 53509 2011-12-10 18:55:52Z masera $ */
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+//  Class AliITSUModule                                            //
+//  is a superclass for AliITSUModuleSSD, SPD and SDD.             //
+//  The main function of modules is to simulate DIGITS from          //
+//  GEANT HITS and produce POINTS from DIGITS                        //
+//  It also make fast simulation without use of DIGITS               //
+//                                                                   //
+//  created by: A.Boucham, W.Peryt, S.Radomski, P.Skowronski         //
+//              R.Barbera, B. Batynia, B. Nilsen                     //
+//  ver. 1.0    CERN, 16.09.1999                                     //
+//  modified for upgrade: ruben.shahoyan@cern.ch                     //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#include 
+#include 
+#include "AliITSUHit.h"
+class AliITSUGeomTGeo;
+
+class AliITSUModule: public TObject {
+
+ public:
+  AliITSUModule();             // default constructor
+  AliITSUModule(Int_t index, AliITSUGeomTGeo* tg);
+  virtual ~AliITSUModule();
+  UInt_t     GetIndex()                                 const {return GetUniqueID();}
+  void       SetIndex(UInt_t ind)                             {return SetUniqueID(ind);}
+  Int_t      GetNHits()                                 const {return fHitsM->GetEntriesFast();}
+  TObjArray *GetHits()                                  const {return fHitsM;}
+  AliITSUHit *GetHit(Int_t i)                         const {return (AliITSUHit*)fHitsM->UncheckedAt(i);}
+  void       AddHit(AliITSUHit *hit)                        {fHitsM->AddLast(hit);}
+  void       Clear(Option_t* opt=0);
+  //
+  Bool_t   MedianHitG(AliITSUHit *h1,AliITSUHit *h2,Float_t &x,Float_t &y,Float_t &z);
+  void     MedianHitG(Int_t index, Float_t hitx1,Float_t hity1,Float_t hitz1,Float_t hitx2,Float_t hity2,Float_t hitz2, Float_t &xMg,Float_t &yMg, Float_t &zMg);
+  Bool_t   MedianHitL(AliITSUHit *h1,AliITSUHit *h2,Float_t &x,Float_t &y,Float_t &z) const;
+  void     MedianHitL(Int_t,AliITSUHit *,AliITSUHit *,Float_t &,Float_t &, Float_t &){};
+  Double_t PathLength(const AliITSUHit *itsHit1,const AliITSUHit *itsHit2);
+  void     MedianHit(Int_t index, Float_t xg,Float_t yg,Float_t zg,Int_t status,Float_t &xMg, Float_t &yMg, Float_t &zMg,Int_t &flag);
+  void     PathLength(Float_t x,Float_t y,Float_t z,Int_t status,Int_t &nseg,Float_t &x1,Float_t &y1,Float_t &z1,Float_t &dx1,Float_t &dy1, Float_t &dz1,Int_t &flag) const;
+  Bool_t   LineSegmentL(Int_t hindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,Double_t &e,Double_t &f,Double_t &de);
+  Bool_t   LineSegmentL(Int_t hindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,Double_t &e,Double_t &f,Double_t &de,Int_t &track);
+  //
+  Bool_t   LineSegmentG(Int_t hindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,Double_t &e,Double_t &f,Double_t &de);
+  Bool_t   LineSegmentG(Int_t hindex,Double_t &a,Double_t &b,Double_t &c,Double_t &d,Double_t &e,Double_t &f,Double_t &de,Int_t &track);
+  //
+ protected:
+    AliITSUModule(const AliITSUModule &source); 
+    AliITSUModule& operator=(const AliITSUModule &source); 
+    TObjArray            *fHitsM;     // Pointer to list of hits on this module
+    AliITSUGeomTGeo    *fGeomTG;    // pointed to geometry
+    //
+    ClassDef(AliITSUModule,1) // Copy the hits into a more useful order
+};
+
+inline void AliITSUModule::Clear(Option_t *) {fHitsM->Clear();}
+
+#endif
+
+
+
diff --git a/ITS/UPGRADE/AliITSUSDigit.cxx b/ITS/UPGRADE/AliITSUSDigit.cxx
new file mode 100644
index 00000000000..239d28784e7
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSDigit.cxx
@@ -0,0 +1,274 @@
+/**************************************************************************
+ * Copyright(c) 1998-2004, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+#include 
+#include 
+#include "AliLog.h"
+#include "AliITSUSDigit.h"
+ClassImp(AliITSUSDigit)
+
+// Addapted from ITS/AliITSpListItem, ruben.shahoyan@cern.ch
+
+//______________________________________________________________________
+AliITSUSDigit::AliITSUSDigit() 
+: fModule(0)
+  ,fNTracks(0)
+  ,fTsignal(0.0)
+  ,fNoise(0.0)
+  ,fSignalAfterElect(0.0)
+{
+  // Default constructor
+}
+
+//______________________________________________________________________
+AliITSUSDigit::AliITSUSDigit(UInt_t module,UInt_t index,Double_t noise) 
+  :fModule(module)
+  ,fNTracks(0)
+  ,fTsignal(0.0)
+  ,fNoise(noise)
+  ,fSignalAfterElect(0.0)
+{
+  // Standard noise constructor
+  SetUniqueID(index);
+  for (int i=kBuffSize;i--;) {
+    fTrack[i] = -2;
+    fHits[i] = -1;
+    fSignal[i] = 0;
+  }
+}
+
+//______________________________________________________________________
+AliITSUSDigit::AliITSUSDigit(Int_t track,Int_t hit,UInt_t module,UInt_t index,Double_t signal)
+  :fModule(module)
+  ,fNTracks(1)
+  ,fTsignal(signal)
+  ,fNoise(0.0)
+  ,fSignalAfterElect(0.0)
+{
+  // Standard signal constructor
+  // Inputs:
+  //    Int_t track     The track number which produced this signal
+  //    Int_t hit       The hit number which produced this signal
+  //    Int_t module    The module where this signal occurred
+  //    Int_t index     The cell index where this signal occurred
+  //    Double_t signal The value of the signal (ionization)
+  SetUniqueID(index);
+  fTrack[0]  = track;
+  fHits[0]   = hit;
+  fSignal[0] = signal;
+  for (int i=1;i~AliITSUSDigit();
+    new(this) AliITSUSDigit(source);
+  }
+  return *this;
+  //
+}
+
+//______________________________________________________________________
+AliITSUSDigit::AliITSUSDigit(const AliITSUSDigit &source) 
+  :TObject(source)
+  ,fModule(source.fModule)
+  ,fNTracks(source.fNTracks)
+  ,fTsignal(source.fTsignal)
+  ,fNoise(source.fNoise)
+  ,fSignalAfterElect(source.fSignalAfterElect)
+{
+  // Copy operator
+  for(Int_t i=kBuffSize;i--;) {
+    fTrack[i]  = source.fTrack[i];
+    fSignal[i] = source.fSignal[i];
+    fHits[i]   = source.fHits[i];
+  } // end if i
+  //
+}
+
+//______________________________________________________________________
+void AliITSUSDigit::AddSignal(Int_t track,Int_t hit,Double_t signal)
+{
+  // Adds this track number and signal to the pList and orders them
+  // Inputs:
+  //    Int_t track     The track number which produced this signal
+  //    Int_t hit       The hit number which produced this signal
+  //    Int_t module    The module where this signal occurred
+  //    Int_t index     The cell index where this signal occurred
+  //    Double_t signal The value of the signal (ionization)
+  Int_t    i,j;
+  Bool_t   flg=kFALSE;
+  //
+  if (TMath::Abs(signal)>2147483647.0) {
+    //PH 2147483647 is the max. integer
+    //PH This apparently is a problem which needs investigation
+    AliWarning(Form("Too big or too small signal value %f",signal));
+    signal = TMath::Sign((Double_t)2147483647,signal);
+  }
+  //
+  fTsignal += signal; // Keep track of sum signal.
+  for (i=fNTracks;i--;) {
+    if ( track==fTrack[i]  ) {
+      fSignal[i] += signal;
+      flg = kTRUE;
+      break;
+    } // end for i & if.
+  }
+  //
+  if (flg && fNTracks>1) { // resort arrays.  
+    for (i=1;i0 && fSignal[j]>fSignal[j-1]) {
+	swap(fTrack[j-1],fTrack[j]);
+	swap(fHits[j-1] ,fHits[j]);
+	swap(fSignal[j-1],fSignal[j]);
+	j--;
+      } // end while
+    } // end if i
+    return;
+  } // end if added to existing and resorted array
+  //
+  // new entry add it in order.
+  // if this signal is <= smallest then don't add it.
+  if (fNTracks==(kBuffSize-1) && signal <= fSignal[kBuffSize-1]) return;
+  //
+  for (i=fNTracks;i--;) {
+    if (signal > fSignal[i]) {
+      fSignal[i+1] = fSignal[i];
+      fTrack[i+1]  = fTrack[i];
+      fHits[i+1]   = fHits[i];
+    } else {
+      fSignal[i+1] = signal;
+      fTrack[i+1]  = track;
+      fHits[i+1]   = hit;
+      fNTracks++;
+      return; // put it in the right place, now exit.
+    } //  end if
+  } // end if; end for i
+  //
+  // Still haven't found the right place. Must be at top of list.
+  fSignal[0] = signal;
+  fTrack[0]  = track;
+  fHits[0]   = hit;
+  fNTracks++;
+  return;
+}
+
+//______________________________________________________________________
+void AliITSUSDigit::Add(const AliITSUSDigit *pl)
+{
+  // Adds the contents of pl to this
+  // pl could come from different module and index 
+  Double_t sigT = 0.0;
+  for(int i=pl->GetNTracks();i--;) {
+    double sig = pl->GetSignal(i); 
+    AddSignal(pl->GetTrack(i),pl->GetHit(i),sig);
+    sigT += sig;
+  } // end for i
+  fTsignal += (pl->fTsignal - sigT);
+  fNoise   += pl->fNoise;
+  return;
+  //
+}
+
+//______________________________________________________________________
+void AliITSUSDigit::AddTo(Int_t fileIndex,const AliITSUSDigit *pl) 
+{
+  // Adds the contents of pl to this with track number off set given by
+  // fileIndex.
+  // Inputs:
+  //    Int_t fileIndex      track number offset value
+  //    AliITSUSDigit *pl  an AliITSUSDigit to be added to this class.
+  //
+  for (int i=pl->GetNTracks();i--;) AddSignal(pl->GetTrack(i)+fileIndex,pl->GetHit(i),pl->GetSignal(i));
+  fSignalAfterElect += (pl->fSignalAfterElect + pl->fNoise - fNoise);
+  fNoise = pl->fNoise;
+}
+
+//______________________________________________________________________
+void AliITSUSDigit::ShiftIndices(Int_t fileIndex)
+{
+  // Shift track numbers
+  //
+  for (int i=GetNTracks();i--;) fTrack[i] += fileIndex;
+}
+
+//______________________________________________________________________
+void AliITSUSDigit::Print(ostream *os) const 
+{
+  //Standard output format for this class
+  Int_t i;
+  //
+  *os << fModule <<","<> fModule >> ind >> fNTracks;
+  SetUniqueID(ind);
+  *is >> iss; // read in fNTracks
+  for(i=0;i> fTrack[i];
+  for(i=0;i> fHits[i];
+  for(i=0;i> fSignal[i];
+  *is >> fTsignal >> fNoise >> fSignalAfterElect;
+}
+
+//______________________________________________________________________
+ostream &operator<<(ostream &os,AliITSUSDigit &source)
+{
+  // Standard output streaming function.
+  source.Print(&os);
+  return os;
+}
+
+//______________________________________________________________________
+istream &operator>>(istream &os,AliITSUSDigit &source)
+{
+  // Standard output streaming function.
+  source.Read(&os);
+  return os;
+}
+
+//______________________________________________________________________
+Int_t AliITSUSDigit::Compare(const TObject* obj) const
+{
+  // compare objects
+  if (GetUniqueID()GetUniqueID()) return -1;
+  if (GetUniqueID()>obj->GetUniqueID()) return  1;
+  return 0;
+}
+
+//______________________________________________________________________
+void AliITSUSDigit::Print(Option_t*) const 
+{
+  // print itself
+  printf("Mod: %4d Index:%7d Ntr:%2d |",fModule,GetUniqueID(),fNTracks);
+  for (int i=0;i
+
+
+class AliITSUSDigit: public TObject 
+{
+ public:
+  enum {kBuffSize=10};
+  //
+  AliITSUSDigit();
+  AliITSUSDigit(Int_t track,Int_t hit,UInt_t module,UInt_t index,Double_t signal);
+  AliITSUSDigit(UInt_t module,UInt_t index,Double_t noise);
+  AliITSUSDigit(const AliITSUSDigit &source);
+  AliITSUSDigit& operator=(const AliITSUSDigit &source);
+  virtual ~AliITSUSDigit() {}
+  Double_t GetSignal(Int_t i)    const {return ( (i>=0&&i=0&&i=0&&iGetUniqueID();}
+  virtual Int_t  Compare(const TObject* obj)      const;
+
+  //
+  static Int_t GetBuffSize() {return kBuffSize;};
+  //
+ private:
+  UShort_t fModule;            // module number
+  UShort_t fNTracks;           // number of tracks contributing
+  Int_t    fTrack[kBuffSize];  // track Number
+  Int_t    fHits[kBuffSize];   // hit number
+  Float_t  fSignal[kBuffSize]; // Signals
+  Float_t  fTsignal;           // Total signal (no noise)
+  Float_t  fNoise;             // Total noise, coupling, ...
+  Float_t  fSignalAfterElect;  // Signal after electronics
+  //
+  ClassDef(AliITSUSDigit,1) // Item list of signals and track numbers
+};	
+
+// Input and output functions for standard C++ input/output.
+ostream & operator<<(ostream &os,AliITSUSDigit &source);
+istream & operator>>(istream &is,AliITSUSDigit &source);
+
+
+#endif
diff --git a/ITS/UPGRADE/AliITSsegmentationPixUpg.cxx b/ITS/UPGRADE/AliITSUSegmentationPix.cxx
similarity index 80%
rename from ITS/UPGRADE/AliITSsegmentationPixUpg.cxx
rename to ITS/UPGRADE/AliITSUSegmentationPix.cxx
index d7b163a3257..c83d288ec8a 100644
--- a/ITS/UPGRADE/AliITSsegmentationPixUpg.cxx
+++ b/ITS/UPGRADE/AliITSUSegmentationPix.cxx
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id: AliITSsegmentationPixUpg.cxx 47180 2011-02-08 09:42:29Z masera $ */
+/* $Id: AliITSUSegmentationPix.cxx 47180 2011-02-08 09:42:29Z masera $ */
 #include 
 #include 
 #include 
@@ -21,7 +21,8 @@
 #include 
 #include 
 #include 
-#include "AliITSsegmentationPixUpg.h"
+#include "AliITSUGeomTGeo.h"
+#include "AliITSUSegmentationPix.h"
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Segmentation class for pixels                                                                          //
@@ -33,12 +34,12 @@
 //                                                                                                        //
 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-ClassImp(AliITSsegmentationPixUpg)
+ClassImp(AliITSUSegmentationPix)
 
-const char* AliITSsegmentationPixUpg::fgkSegmListName = "ITSUpgradeSegmentations";
+const char* AliITSUSegmentationPix::fgkSegmListName = "ITSUpgradeSegmentations";
 
 //_____________________________________________________________________________RS
-AliITSsegmentationPixUpg::AliITSsegmentationPixUpg(int nchips,int ncol,int nrow,
+AliITSUSegmentationPix::AliITSUSegmentationPix(UInt_t id, int nchips,int ncol,int nrow,
 						   double pitchX,double pitchZ,
 						   double thickness,
 						   double pitchLftC,double pitchRgtC,
@@ -59,6 +60,7 @@ AliITSsegmentationPixUpg::AliITSsegmentationPixUpg(int nchips,int ncol,int nrow,
   ,fNCol(ncol)
 {
   // Default constructor, sizes in microns
+  if (nchips) SetUniqueID( AliITSUGeomTGeo::ComposeDetTypeID(id) );
   fChipDZ = (fNColPerChip-2)*fPitchZ + fPitchZLftCol + fPitchZRgtCol;
   SetDetSize( fNRow*fPitchX /*+fGuardTop+fGuardBot*/,
 	      fNChips*fChipDZ /*+fGuardLft+fGuardRgt*/,
@@ -67,7 +69,7 @@ AliITSsegmentationPixUpg::AliITSsegmentationPixUpg(int nchips,int ncol,int nrow,
 }
 
 //_____________________________________________________________________________RS
-void AliITSsegmentationPixUpg::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const 
+void AliITSUSegmentationPix::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const 
 {
   //  Returns pixel coordinates (ix,iz) for given real local coordinates (x,z)
   //  expects x, z in microns
@@ -80,7 +82,7 @@ void AliITSsegmentationPixUpg::GetPadIxz(Float_t x,Float_t z,Int_t &ix,Int_t &iz
 }
 
 //_____________________________________________________________________________RS
-void AliITSsegmentationPixUpg::GetPadTxz(Float_t &x,Float_t &z) const
+void AliITSUSegmentationPix::GetPadTxz(Float_t &x,Float_t &z) const
 {
   //  local transformation of real local coordinates (x,z)
   //  expects x, z in microns
@@ -90,7 +92,7 @@ void AliITSsegmentationPixUpg::GetPadTxz(Float_t &x,Float_t &z) const
 }
 
 //_____________________________________________________________________________RS
-void AliITSsegmentationPixUpg::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z) const
+void AliITSUSegmentationPix::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z) const
 {
   // Transform from pixel to real local coordinates
   // returns x, z in microns
@@ -100,7 +102,7 @@ void AliITSsegmentationPixUpg::GetPadCxz(Int_t ix,Int_t iz,Float_t &x,Float_t&z)
 }
 
 //_____________________________________________________________________________RS
-Float_t AliITSsegmentationPixUpg::Z2Col(Float_t z) const 
+Float_t AliITSUSegmentationPix::Z2Col(Float_t z) const 
 {
   // get column number (from 0) from local Z
   int chip = z/fChipDZ;
@@ -117,7 +119,7 @@ Float_t AliITSsegmentationPixUpg::Z2Col(Float_t z) const
 }
 
 //_____________________________________________________________________________RS
-Float_t AliITSsegmentationPixUpg::Col2Z(Int_t col) const 
+Float_t AliITSUSegmentationPix::Col2Z(Int_t col) const 
 {
   // convert column number (from 0) to Z coordinate
   int nchip = col/fNColPerChip;
@@ -132,7 +134,7 @@ Float_t AliITSsegmentationPixUpg::Col2Z(Int_t col) const
 }
 
 //______________________________________________________________________RS
-AliITSsegmentationPixUpg& AliITSsegmentationPixUpg::operator=(const AliITSsegmentationPixUpg &src)
+AliITSUSegmentationPix& AliITSUSegmentationPix::operator=(const AliITSUSegmentationPix &src)
 {
   // = operator
   if(this==&src) return *this;
@@ -156,7 +158,7 @@ AliITSsegmentationPixUpg& AliITSsegmentationPixUpg::operator=(const AliITSsegmen
 }
 
 //____________________________________________________________________________RS
-AliITSsegmentationPixUpg::AliITSsegmentationPixUpg(const AliITSsegmentationPixUpg &src) :
+AliITSUSegmentationPix::AliITSUSegmentationPix(const AliITSUSegmentationPix &src) :
   AliITSsegmentation(src)
   ,fGuardLft(src.fGuardLft)
   ,fGuardRgt(src.fGuardRgt)
@@ -175,14 +177,14 @@ AliITSsegmentationPixUpg::AliITSsegmentationPixUpg(const AliITSsegmentationPixUp
 }
 
 //____________________________________________________________________________RS
-Float_t AliITSsegmentationPixUpg::Dpx(Int_t ) const 
+Float_t AliITSUSegmentationPix::Dpx(Int_t ) const 
 {
   //returs x pixel pitch for a give pixel
   return fPitchX;
 }
 
 //____________________________________________________________________________RS
-Float_t AliITSsegmentationPixUpg::Dpz(Int_t col) const 
+Float_t AliITSUSegmentationPix::Dpz(Int_t col) const 
 {
   // returns z pixel pitch for a given pixel (cols starts from 0)
   col %= fNColPerChip;
@@ -193,7 +195,7 @@ Float_t AliITSsegmentationPixUpg::Dpz(Int_t col) const
 }
 
 //------------------------------
-void AliITSsegmentationPixUpg::Neighbours(Int_t iX, Int_t iZ, Int_t* nlist, Int_t xlist[8], Int_t zlist[8]) const 
+void AliITSUSegmentationPix::Neighbours(Int_t iX, Int_t iZ, Int_t* nlist, Int_t xlist[8], Int_t zlist[8]) const 
 {
   // returns the neighbouring pixels for use in Cluster Finders and the like.
   //
@@ -220,7 +222,7 @@ void AliITSsegmentationPixUpg::Neighbours(Int_t iX, Int_t iZ, Int_t* nlist, Int_
 }
 
 //______________________________________________________________________
-Bool_t AliITSsegmentationPixUpg::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const 
+Bool_t AliITSUSegmentationPix::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz) const 
 {
   // Transformation from Geant detector centered local coordinates (cm) to
   // Pixel cell numbers ix and iz.
@@ -249,7 +251,7 @@ Bool_t AliITSsegmentationPixUpg::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t
 }
 
 //______________________________________________________________________
-void AliITSsegmentationPixUpg::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
+void AliITSUSegmentationPix::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z) const
 {
 // Transformation from Detector cell coordiantes to Geant detector centerd 
 // local coordinates (cm).
@@ -275,7 +277,7 @@ void AliITSsegmentationPixUpg::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &
 }
 
 //______________________________________________________________________
-void AliITSsegmentationPixUpg::CellBoundries(Int_t ix,Int_t iz,Double_t &xl,Double_t &xu,Double_t &zl,Double_t &zu) const
+void AliITSUSegmentationPix::CellBoundries(Int_t ix,Int_t iz,Double_t &xl,Double_t &xu,Double_t &zl,Double_t &zu) const
 {
   // Transformation from Detector cell coordiantes to Geant detector centerd 
   // local coordinates (cm).
@@ -311,7 +313,7 @@ void AliITSsegmentationPixUpg::CellBoundries(Int_t ix,Int_t iz,Double_t &xl,Doub
 }
 
 //______________________________________________________________________
-Int_t AliITSsegmentationPixUpg::GetChipFromChannel(Int_t, Int_t iz) const 
+Int_t AliITSUSegmentationPix::GetChipFromChannel(Int_t, Int_t iz) const 
 {
   // returns chip number (in range 0-4) starting from channel number
   if(iz>=fNCol  || iz<0 ){
@@ -322,7 +324,7 @@ Int_t AliITSsegmentationPixUpg::GetChipFromChannel(Int_t, Int_t iz) const
 }
 
 //______________________________________________________________________
-Int_t AliITSsegmentationPixUpg::GetChipFromLocal(Float_t, Float_t zloc) const 
+Int_t AliITSUSegmentationPix::GetChipFromLocal(Float_t, Float_t zloc) const 
 {
   // returns chip number (in range 0-4) starting from local coordinates
   Int_t ix0,iz;
@@ -334,7 +336,7 @@ Int_t AliITSsegmentationPixUpg::GetChipFromLocal(Float_t, Float_t zloc) const
 }
 
 //______________________________________________________________________
-Int_t AliITSsegmentationPixUpg::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t, Float_t) const 
+Int_t AliITSUSegmentationPix::GetChipsInLocalWindow(Int_t* array, Float_t zmin, Float_t zmax, Float_t, Float_t) const 
 {
   // returns the number of chips containing a road defined by given local coordinate limits
   //
@@ -372,13 +374,13 @@ Int_t AliITSsegmentationPixUpg::GetChipsInLocalWindow(Int_t* array, Float_t zmin
 }
 
 //______________________________________________________________________
-void AliITSsegmentationPixUpg::Init()
+void AliITSUSegmentationPix::Init()
 {
   // init settings
 }
 
 //______________________________________________________________________
-Bool_t AliITSsegmentationPixUpg::StoreWithID(UInt_t id, const char* outf)
+Bool_t AliITSUSegmentationPix::Store(const char* outf)
 {
   // store in the special list under given ID
   TString fns = outf;
@@ -387,25 +389,16 @@ Bool_t AliITSsegmentationPixUpg::StoreWithID(UInt_t id, const char* outf)
   TFile* fout = TFile::Open(fns.Data(),"update");
   if (!fout) {AliFatal(Form("Failed to open output file %s",outf)); return kFALSE;}
   TObjArray* arr = (TObjArray*)fout->Get(fgkSegmListName);
+  int id = GetUniqueID();
   if (!arr) arr = new TObjArray();
-  else {
-    int nent = arr->GetEntriesFast();
-    for (int i=nent;i--;) {
-      AliITSsegmentationPixUpg* segm = dynamic_cast(arr->At(i));
-      if (segm && segm->GetUniqueID()==id) {
-	AliFatal(Form("Segmenation %d already exists in file %s",id,outf)); 
-	return kFALSE;
-      }
-    }
-  }
+  else if (arr->At(id)) {AliFatal(Form("Segmenation %d already exists in file %s",id,outf));return kFALSE;}
   //
-  this->SetUniqueID(id);  
-  arr->AddLast(this);
+  arr->AddAtAndExpand(this,id);
   arr->SetOwner(kTRUE);
   fout->WriteObject(arr,fgkSegmListName,"kSingleKey");
   fout->Close();
   delete fout;
-  arr->Remove(this);
+  arr->RemoveAt(id);
   delete arr;
   AliInfo(Form("Stored segmentation %d in %s",id,outf));
   return kTRUE;
@@ -413,7 +406,7 @@ Bool_t AliITSsegmentationPixUpg::StoreWithID(UInt_t id, const char* outf)
 }
 
 //______________________________________________________________________
-AliITSsegmentationPixUpg* AliITSsegmentationPixUpg::LoadWithID(UInt_t id, const char* inpf)
+AliITSUSegmentationPix* AliITSUSegmentationPix::LoadWithID(UInt_t id, const char* inpf)
 {
   // store in the special list under given ID
   TString fns = inpf;
@@ -426,16 +419,10 @@ AliITSsegmentationPixUpg* AliITSsegmentationPixUpg::LoadWithID(UInt_t id, const
     AliFatalGeneral("LoadWithID",Form("Failed to find segmenation array %s in %s",fgkSegmListName,inpf)); 
     return 0;
   }
-  AliITSsegmentationPixUpg* segm = 0;
-  int nent = arr->GetEntriesFast();
-  for (int i=nent;i--;) {
-    segm = dynamic_cast(arr->At(i));
-    if (segm && segm->GetUniqueID()==id) {arr->RemoveAt(i); break;}
-    segm = 0;
-  }
-  //
-  if (!segm) {AliFatalGeneral("LoadWithID",Form("Failed to find segmenation %d in %s",id,inpf)); return 0;}
+  AliITSUSegmentationPix* segm = dynamic_cast(arr->At(id));
+  if (!segm || segm->GetUniqueID()!=id) {AliFatalGeneral("LoadWithID",Form("Failed to find segmenation %d in %s",id,inpf)); return 0;}
   //
+  arr->RemoveAt(id);
   arr->SetOwner(kTRUE); // to not leave in memory other segmenations
   finp->Close();
   delete finp;
@@ -443,3 +430,27 @@ AliITSsegmentationPixUpg* AliITSsegmentationPixUpg::LoadWithID(UInt_t id, const
   //
   return segm;
 }
+
+//______________________________________________________________________
+void AliITSUSegmentationPix::LoadSegmentations(TObjArray* dest, const char* inpf)
+{
+  // store in the special list under given ID
+  if (!dest) return;
+  TString fns = inpf;
+  gSystem->ExpandPathName(fns);
+  if (fns.IsNull()) AliFatalGeneral("LoadWithID","No file name provided");
+  TFile* finp = TFile::Open(fns.Data());
+  if (!finp) AliFatalGeneral("LoadWithID",Form("Failed to open file %s",inpf));
+  TObjArray* arr = (TObjArray*)finp->Get(fgkSegmListName);
+  if (!arr) AliFatalGeneral("LoadWithID",Form("Failed to find segmenation array %s in %s",fgkSegmListName,inpf)); 
+  int nent = arr->GetEntriesFast();
+  TObject *segm = 0;
+  for (int i=nent;i--;) if ((segm=arr->At(i))) dest->AddAtAndExpand(segm,segm->GetUniqueID());
+  AliInfoGeneral("LoadSegmentations",Form("Loaded %d segmantions from %s",arr->GetEntries(),inpf));
+  arr->SetOwner(kFALSE);
+  arr->Delete();
+  finp->Close();
+  delete finp;
+  delete arr;
+  //
+}
diff --git a/ITS/UPGRADE/AliITSsegmentationPixUpg.h b/ITS/UPGRADE/AliITSUSegmentationPix.h
similarity index 78%
rename from ITS/UPGRADE/AliITSsegmentationPixUpg.h
rename to ITS/UPGRADE/AliITSUSegmentationPix.h
index 030be26ead1..7a950442eb5 100644
--- a/ITS/UPGRADE/AliITSsegmentationPixUpg.h
+++ b/ITS/UPGRADE/AliITSUSegmentationPix.h
@@ -1,5 +1,5 @@
-#ifndef ALIITSSEGMENTATIONPIXUPG_H
-#define ALIITSSEGMENTATIONPIXUPG_H
+#ifndef ALIITSUSEGMENTATIONPIX_H
+#define ALIITSUSEGMENTATIONPIX_H
 
 #include "AliITSsegmentation.h"
 
@@ -7,20 +7,20 @@
 
 // segmentation and response for pixels in ITS upgrade 
 
-class AliITSsegmentationPixUpg :
+class AliITSUSegmentationPix :
 public AliITSsegmentation {
  public:
   enum {kCM2MC=10000};
-  AliITSsegmentationPixUpg(int nchips=0,int ncol=0,int nrow=0,
+  AliITSUSegmentationPix(UInt_t id=0, int nchips=0,int ncol=0,int nrow=0,
 			   double pitchX=0,double pitchZ=0,
 			   double thickness=0,
 			   double pitchLftC=-1,double pitchRgtC=-1,
 			   double edgL=0,double edgR=0,double edgT=0,double edgB=0);
   
-  //  AliITSsegmentationPixUpg(Option_t *opt="" );
-  AliITSsegmentationPixUpg(const AliITSsegmentationPixUpg &source);
-  virtual ~AliITSsegmentationPixUpg() {}
-  AliITSsegmentationPixUpg& operator=(const AliITSsegmentationPixUpg &source);
+  //  AliITSUSegmentationPix(Option_t *opt="" );
+  AliITSUSegmentationPix(const AliITSUSegmentationPix &source);
+  virtual ~AliITSUSegmentationPix() {}
+  AliITSUSegmentationPix& operator=(const AliITSUSegmentationPix &source);
   //
   virtual void    Init();
   //  
@@ -56,8 +56,11 @@ public AliITSsegmentation {
   //
   virtual void PrintDefaultParameters() const {AliWarning("No def. parameters defined as const static data members");}
   //
-  Bool_t                           StoreWithID(UInt_t id, const char* outf);
-  static AliITSsegmentationPixUpg* LoadWithID(UInt_t id, const char* inpf);
+  virtual Int_t                    GetDetTypeID()              const {return GetUniqueID();}
+  //
+  Bool_t                           Store(const char* outf);
+  static AliITSUSegmentationPix* LoadWithID(UInt_t id, const char* inpf);
+  static void                      LoadSegmentations(TObjArray* dest, const char* inpf);
   //
  protected:
   Float_t Z2Col(Float_t z) const;
@@ -80,7 +83,7 @@ public AliITSsegmentation {
     //
     static const char* fgkSegmListName; // pattern for segmentations list name
     //
-  ClassDef(AliITSsegmentationPixUpg,1) //Segmentation class upgrade pixels 
+  ClassDef(AliITSUSegmentationPix,1) //Segmentation class upgrade pixels 
 
 };
 
diff --git a/ITS/UPGRADE/AliITSUSensMap.cxx b/ITS/UPGRADE/AliITSUSensMap.cxx
new file mode 100644
index 00000000000..3b408492dbb
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSensMap.cxx
@@ -0,0 +1,143 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: AliITSUSensMap.cxx 39464 2010-03-09 14:59:19Z masera $ */
+
+//***********************************************************************
+//
+// It consist of a TClonesArray of 
+// AliITSUSensMapItem objects
+// This array can be accessed via 2 indexed
+// it is used at digitization level by 
+// all the 3 ITS subdetectors
+//
+//
+// The items should be added to the map like this:
+// map->RegisterItem( new(map->GetFree()) ItemConstructor(...) );
+//
+// The items must be sortable with the same sorting algorithm like 
+// for the dummy class AliITSUSensMap::TObjSortable
+//
+// ***********************************************************************
+
+#include "AliITSUSensMap.h"
+#include "AliLog.h"
+//______________________________________________________________________
+
+ClassImp(AliITSUSensMap)
+//______________________________________________________________________
+AliITSUSensMap::AliITSUSensMap() 
+:  fDim0(0)
+  ,fDim1(0)
+  ,fItems(0)
+  ,fBTree(0)
+  ,fProbe()
+{
+  // Default constructor
+}
+
+//______________________________________________________________________
+AliITSUSensMap::AliITSUSensMap(const char* className, UInt_t dim0,UInt_t dim1)
+  :fDim0(dim0)
+  ,fDim1(dim1)
+  ,fItems(new TClonesArray(className,100))
+  ,fBTree(new TBtree())
+  ,fProbe()
+{
+  // Standard constructor
+}
+
+//______________________________________________________________________
+AliITSUSensMap::~AliITSUSensMap() 
+{
+  // Default destructor
+  delete fItems;
+  delete fBTree;
+}
+
+
+//______________________________________________________________________
+AliITSUSensMap::AliITSUSensMap(const AliITSUSensMap &source)
+  :TObject(source)
+  ,fDim0(source.fDim0)
+  ,fDim1(source.fDim1)
+  ,fItems( source.fItems ? new TClonesArray(*source.fItems) : 0)
+  ,fBTree( 0 )
+  ,fProbe( source.fProbe)
+{
+  if (source.fBTree) {
+    fBTree = new TBtree();
+    for (int i=fItems->GetEntriesFast();i--;) {
+      TObject* obj = fItems->At(i);
+      if (obj && ! IsDisabled(obj)) continue;
+      RegisterItem(obj);
+    }
+  }
+}
+
+//______________________________________________________________________
+AliITSUSensMap& AliITSUSensMap::operator=(const AliITSUSensMap &source)
+{
+  // = operator
+  if (this!=&source) {
+    this->~AliITSUSensMap();
+    new(this) AliITSUSensMap(source);
+  }
+  return *this;
+}
+
+//______________________________________________________________________
+void AliITSUSensMap::Clear(Option_t*) 
+{
+  // clean everything
+  if (fItems) fItems->Clear();
+  if (fBTree) fBTree->Clear();
+  fProbe.Clear();
+}
+
+//______________________________________________________________________
+void AliITSUSensMap::DeleteItem(UInt_t i,UInt_t j)
+{
+  // Delete a particular AliITSUSensMapItems.
+  fProbe.SetUniqueID( GetIndex(i,j) );
+  TObject* fnd = fBTree->FindObject(&fProbe);
+  if (!fnd) return;
+  Disable(fnd);
+  fBTree->Remove(fnd);
+}
+
+//______________________________________________________________________
+void AliITSUSensMap::DeleteItem(TObject* obj)
+{
+  // Delete a particular AliITSUSensMapItems.
+  TObject* fnd = fBTree->FindObject(obj);
+  if (!fnd) return;
+  Disable(fnd);
+  fBTree->Remove(fnd);
+}
+
+//______________________________________________________________________
+void AliITSUSensMap::GetCell(UInt_t index,UInt_t &i,UInt_t &j) const 
+{
+  // returns the i,j index numbers from the linearized index computed
+  // with GetIndex
+  if(index>=fDim0*fDim1){
+    Warning("GetCell","Index out of range 0<=index=%d<%d",index,fDim0*fDim1);
+    i=-1;j=-1;
+    return;
+  } // end if
+  i = index/fDim1;
+  j = index%fDim1;
+  return;
+}
diff --git a/ITS/UPGRADE/AliITSUSensMap.h b/ITS/UPGRADE/AliITSUSensMap.h
new file mode 100644
index 00000000000..5dfb894d1a0
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSensMap.h
@@ -0,0 +1,81 @@
+#ifndef ALIITSUSENSMAP_H
+#define ALIITSUSENSMAP_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+
+//***********************************************************************
+//
+// It consist of a TClonesArray of objects
+// and B-tree for fast sorted access
+// This array can be accessed via 2 indexed
+// it is used at digitization level by 
+// all the ITS subdetectors
+//
+// The items should be added to the map like this:
+// map->RegisterItem( new(map->GetFree()) ItemConstructor(...) );
+//
+// ***********************************************************************
+#include 
+#include 
+
+
+class AliITSUSensMap: public TObject 
+{
+
+ public:
+  enum {kDisableBit=BIT(14)};
+  //
+  AliITSUSensMap();
+  AliITSUSensMap(const char* className, UInt_t dim0,UInt_t dim1);
+  virtual ~AliITSUSensMap();
+  AliITSUSensMap(const AliITSUSensMap &source);
+  AliITSUSensMap& operator=(const AliITSUSensMap &source);
+  void Clear(Option_t* option = "");
+  void DeleteItem(UInt_t i,UInt_t j);
+  void DeleteItem(TObject* obj);
+  //
+  void  SetDimensions(UInt_t dim0,UInt_t dim1)   {fDim0 = dim0; fDim1 = dim1;}
+  void  GetMaxIndex(UInt_t &ni,UInt_t &nj) const {ni=fDim0;nj=fDim1;}
+  Int_t GetMaxIndex()                      const {return fDim0*fDim1;}
+  Int_t GetEntries()                       const {return fBTree->GetEntries();}
+  Int_t GetEntriesUnsorted()               const {return fItems->GetEntriesFast();}
+  void  GetMapIndex(UInt_t index,UInt_t &i,UInt_t &j) const {return GetCell(index, i,j);}
+  TObject* GetItem(UInt_t i,UInt_t j)            {fProbe.SetUniqueID(GetIndex(i,j)); return fBTree->FindObject(&fProbe);}
+  TObject* GetItem(UInt_t index)                 {fProbe.SetUniqueID(index);         return fBTree->FindObject(&fProbe);}
+  TObject* GetItem(const TObject* obj)           {return fBTree->FindObject(obj);}
+  TObject* At(Int_t i)                     const {return fBTree->At(i);}             //!!! Access in sorted order !!!
+  TObject* AtUnsorted(Int_t i)             const {return fItems->At(i);}             //!!! Access in unsorted order !!!
+  TObject* RegisterItem(TObject* obj)            {fBTree->Add(obj); return obj;}
+  TObject* GetFree()                             {return (*fItems)[fItems->GetEntriesFast()];}
+  //
+  void   GetCell(UInt_t index,UInt_t &i,UInt_t &j) const;
+  UInt_t GetIndex(UInt_t i,UInt_t j)       const  {return j+i*fDim1;}
+  //
+  TClonesArray* GetItems()                 const {return fItems;}
+  TBtree*       GetItemsBTree()            const {return fBTree;}
+  //
+  static Bool_t IsDisabled(TObject* obj)         {return obj ? obj->TestBit(kDisableBit) : kFALSE;}
+  static void   Disable(TObject* obj)            {if (obj) obj->SetBit(kDisableBit);}
+  static void   Enable(TObject* obj)             {if (obj) obj->ResetBit(kDisableBit);}
+  //
+ protected:
+  class TObjSortable : public TObject 
+  {
+  public:
+    Bool_t IsSortable()                const {return kTRUE;}
+    Bool_t IsEqual(const TObject* obj) const {return GetUniqueID()==obj->GetUniqueID();}
+    Int_t  Compare(const TObject* obj) const {return (GetUniqueID()GetUniqueID()) ? -1 : ((GetUniqueID()>obj->GetUniqueID()) ? 1 : 0 );}
+    ClassDef(TObjSortable,1)
+  };
+
+ protected:
+  //
+  UInt_t fDim0;              // 1st dimension of the matrix
+  UInt_t fDim1;              // 2nd dimention of the matrix
+  TClonesArray*    fItems;   // pListItems array
+  TBtree*          fBTree;   // tree for ordered access
+  TObjSortable     fProbe;   //! dummy object to test presence in the map
+  //
+  ClassDef(AliITSUSensMap,1) // list of sensor signals (should be sortable objects)
+};	
+#endif
diff --git a/ITS/UPGRADE/AliITSUSimuParam.cxx b/ITS/UPGRADE/AliITSUSimuParam.cxx
new file mode 100644
index 00000000000..8559e748872
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSimuParam.cxx
@@ -0,0 +1,485 @@
+/**************************************************************************
+ * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id: AliITSUSimuParam.cxx 48165 2011-03-07 17:48:57Z masera $ */
+
+///////////////////////////////////////////////////////////////////
+//                                                               //
+// Implementation of the class to store the parameters used in   //
+// the simulation of SPD, SDD and SSD detectors                  //
+// Origin: F.Prino, Torino, prino@to.infn.it                     //
+//                                                               //
+///////////////////////////////////////////////////////////////////
+#include "AliITSUSimuParam.h"
+#include "AliLog.h"
+
+
+const Double_t  AliITSUSimuParam::fgkPixUpgBiasVoltageDefault = 18.182;
+const Double_t  AliITSUSimuParam::fgkPixUpgThreshDefault = 3000.;
+const Double_t  AliITSUSimuParam::fgkPixUpgThrSigmaDefault = 250.;
+const UInt_t    AliITSUSimuParam::fgkPixUpgCouplingOptDefault = AliITSUSimuParam::kOldCouplingPixUpg;
+const Double_t  AliITSUSimuParam::fgkPixUpgCouplColDefault = 0.;
+const Double_t  AliITSUSimuParam::fgkPixUpgCouplRowDefault = 0.055;
+const Double_t  AliITSUSimuParam::fgkPixUpgEccDiffDefault = 0.85;
+const Double_t  AliITSUSimuParam::fgkPixUpgLorentzHoleWeightDefault = 1.0;
+const Double_t  AliITSUSimuParam::fgkGeVtoChargeDefault = 3.6e-9;
+const Double_t  AliITSUSimuParam::fgkDOverVDefault = 0.000375;
+const Double_t  AliITSUSimuParam::fgkTDefault = 300;
+
+const Double_t  AliITSUSimuParam::fgkNsigmasDefault = 3.;
+const Int_t    AliITSUSimuParam::fgkNcompsDefault = 121;
+
+ClassImp(AliITSUSimuParam)
+
+//______________________________________________________________________
+AliITSUSimuParam::AliITSUSimuParam()
+:  fGeVcharge(fgkGeVtoChargeDefault)
+  ,fDOverV(fgkDOverVDefault)
+  ,fT(fgkTDefault)
+  //
+  ,fNPixUpg(0)
+  ,fPixUpgCouplOpt(kOldCouplingPixUpg)
+  ,fPixUpgCouplCol(fgkPixUpgCouplColDefault)
+  ,fPixUpgCouplRow(fgkPixUpgCouplRowDefault)
+  ,fPixUpgEccDiff(fgkPixUpgEccDiffDefault)
+  ,fPixUpgLorentzDrift(kTRUE)
+  ,fPixUpgLorentzHoleWeight(fgkPixUpgLorentzHoleWeightDefault)
+  ,fPixUpgAddNoisyFlag(kFALSE)
+  ,fPixUpgRemoveDeadFlag(kFALSE)
+  //
+  ,fPixUpgThreshDef(fgkPixUpgThreshDefault)
+  ,fPixUpgThrSigmaDef(fgkPixUpgThrSigmaDefault)
+  ,fPixUpgBiasVoltageDef(fgkPixUpgBiasVoltageDefault)
+  ,fPixUpgNoiseDef(0)
+  ,fPixUpgBaselineDef(0)
+  //
+  ,fPixUpgThresh(0)
+  ,fPixUpgThrSigma(0)
+  ,fPixUpgBiasVoltage(0)
+  ,fPixUpgSigma(0)
+  ,fPixUpgNoise(0)
+  ,fPixUpgBaseline(0)
+{  
+  // default constructor
+}
+
+//______________________________________________________________________
+AliITSUSimuParam::AliITSUSimuParam(UInt_t nPixUpg)
+  :fGeVcharge(fgkGeVtoChargeDefault)
+  ,fDOverV(fgkDOverVDefault)
+  ,fT(fgkTDefault)
+    //
+  ,fNPixUpg(nPixUpg)
+  ,fPixUpgCouplOpt(kOldCouplingPixUpg)
+  ,fPixUpgCouplCol(fgkPixUpgCouplColDefault)
+  ,fPixUpgCouplRow(fgkPixUpgCouplRowDefault)
+  ,fPixUpgEccDiff(fgkPixUpgEccDiffDefault)
+  ,fPixUpgLorentzDrift(kTRUE)
+  ,fPixUpgLorentzHoleWeight(fgkPixUpgLorentzHoleWeightDefault)
+  ,fPixUpgAddNoisyFlag(kFALSE)
+  ,fPixUpgRemoveDeadFlag(kFALSE)
+  //
+  ,fPixUpgThreshDef(fgkPixUpgThreshDefault)
+  ,fPixUpgThrSigmaDef(fgkPixUpgThrSigmaDefault)
+  ,fPixUpgBiasVoltageDef(fgkPixUpgBiasVoltageDefault)
+  ,fPixUpgNoiseDef(0)
+  ,fPixUpgBaselineDef(0)
+  //
+  ,fPixUpgThresh(0)
+  ,fPixUpgThrSigma(0)
+  ,fPixUpgBiasVoltage(0)
+  ,fPixUpgSigma(0)
+  ,fPixUpgNoise(0)
+  ,fPixUpgBaseline(0)
+{  
+  // regular constructor
+  if (fNPixUpg>0) {
+    fPixUpgBiasVoltage = new Double_t[fNPixUpg];
+    fPixUpgThresh      = new Double_t[fNPixUpg];
+    fPixUpgThrSigma    = new Double_t[fNPixUpg];
+    fPixUpgNoise       = new Double_t[fNPixUpg];
+    fPixUpgBaseline    = new Double_t[fNPixUpg];
+  }
+  SetPixUpgThreshold(fgkPixUpgThreshDefault,fgkPixUpgThrSigmaDefault);
+  SetPixUpgNoise(0.,0.);
+  SetPixUpgBiasVoltage(fgkPixUpgBiasVoltageDefault);
+  //
+}
+
+//______________________________________________________________________
+AliITSUSimuParam::AliITSUSimuParam(const AliITSUSimuParam &simpar)
+  :TObject(simpar)
+  ,fGeVcharge(simpar.fGeVcharge)
+  ,fDOverV(simpar.fDOverV)
+  ,fT(simpar.fT)
+   //
+  ,fNPixUpg(simpar.fNPixUpg)
+  ,fPixUpgCouplOpt(simpar.fPixUpgCouplOpt)
+  ,fPixUpgCouplCol(simpar.fPixUpgCouplCol)
+  ,fPixUpgCouplRow(simpar.fPixUpgCouplRow)
+  ,fPixUpgEccDiff(simpar.fPixUpgEccDiff)
+  ,fPixUpgLorentzDrift(simpar.fPixUpgLorentzDrift)
+  ,fPixUpgLorentzHoleWeight(simpar.fPixUpgLorentzHoleWeight)
+  ,fPixUpgAddNoisyFlag(simpar.fPixUpgAddNoisyFlag)
+  ,fPixUpgRemoveDeadFlag(simpar.fPixUpgRemoveDeadFlag)
+   //
+  ,fPixUpgThreshDef(simpar.fPixUpgThreshDef)
+  ,fPixUpgThrSigmaDef(simpar.fPixUpgThrSigmaDef)
+  ,fPixUpgBiasVoltageDef(simpar.fPixUpgBiasVoltageDef)
+  ,fPixUpgNoiseDef(simpar.fPixUpgNoiseDef)
+  ,fPixUpgBaselineDef(simpar.fPixUpgBaselineDef)
+  //
+  ,fPixUpgThresh(0)
+  ,fPixUpgThrSigma(0)
+  ,fPixUpgBiasVoltage(0)
+  ,fPixUpgSigma(0)
+  ,fPixUpgNoise(0)
+  ,fPixUpgBaseline(0)   
+   //
+{
+  // copy constructor
+  if (fNPixUpg) {
+    fPixUpgBiasVoltage = new Double_t[fNPixUpg];
+    fPixUpgThresh      = new Double_t[fNPixUpg];
+    fPixUpgThrSigma    = new Double_t[fNPixUpg];
+    fPixUpgNoise       = new Double_t[fNPixUpg];
+    fPixUpgBaseline    = new Double_t[fNPixUpg];
+  }
+  for (Int_t i=fNPixUpg;i--;) {
+    fPixUpgBiasVoltage[i] = simpar.fPixUpgBiasVoltage[i];
+    fPixUpgThresh[i]      = simpar.fPixUpgThresh[i];
+    fPixUpgThrSigma[i]    = simpar.fPixUpgThrSigma[i];
+    fPixUpgNoise[i]       = simpar.fPixUpgNoise[i];
+    fPixUpgBaseline[i]    = simpar.fPixUpgBaseline[i];
+  }
+  //
+}
+
+//______________________________________________________________________
+AliITSUSimuParam& AliITSUSimuParam::operator=(const AliITSUSimuParam& source)
+{
+  // Assignment operator. 
+  if (this==&source) return *this;
+  this->~AliITSUSimuParam();
+  new(this) AliITSUSimuParam(source);
+  return *this;
+  //
+}
+
+//______________________________________________________________________
+AliITSUSimuParam::~AliITSUSimuParam() 
+{
+  // destructor
+  delete[] fPixUpgBiasVoltage;
+  delete[] fPixUpgThresh;
+  delete[] fPixUpgThrSigma;
+  delete[] fPixUpgNoise;
+  delete[] fPixUpgBaseline;
+}
+
+//________________________________________________________________________
+void AliITSUSimuParam::Print(Option_t *) const
+{
+  // Dump all parameters
+  Dump();
+}
+
+//_______________________________________________________________________
+Double_t AliITSUSimuParam::ApplyPixUpgBaselineAndNoise(UInt_t mod) const 
+{
+  // generate random noise 
+  double base,noise;
+  if (mod>=fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    base = fPixUpgBaselineDef;
+    noise = fPixUpgNoiseDef;
+  }
+  else {
+    base  = fPixUpgBaseline[mod];
+    noise = fPixUpgNoise[mod];    
+  }
+  return base+noise*gRandom->Gaus();
+}
+
+//_______________________________________________________________________
+Double_t AliITSUSimuParam::CalcProbNoiseOverThreshold(UInt_t mod) const 
+{
+  // calculate probability of noise exceeding the threshold
+  double base,noise,thresh;
+  if (mod>=fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    base   = fPixUpgBaselineDef;
+    noise  = fPixUpgNoiseDef;
+    thresh = fPixUpgThreshDef;
+  }
+  else {
+    base   = fPixUpgBaseline[mod];
+    noise  = fPixUpgNoise[mod];
+    thresh = fPixUpgThresh[mod];
+  }
+  if (noise<1e-12) {
+    if (base>thresh) return 1;
+    else             return 0;
+  }
+  return CalcProbNoiseOverThreshold(base, noise, thresh);
+}
+
+//_______________________________________________________________________
+void AliITSUSimuParam::SetPixUpgThreshold(Double_t thresh, Double_t sigma, int mod)
+{
+  // set threshold params
+  if (mod<0) {
+    fPixUpgThreshDef = thresh;
+    fPixUpgThrSigmaDef  = sigma;
+    for (int i=fNPixUpg;i--;) {
+      fPixUpgThresh[i] = thresh;
+      fPixUpgThrSigma[i]  = sigma;
+    }
+  }
+  else if (mod>=(int)fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    fPixUpgThreshDef = thresh;
+    fPixUpgThrSigmaDef  = sigma;
+  }
+  else {
+    fPixUpgThresh[mod] = thresh;
+    fPixUpgThrSigma[mod]  = sigma;
+  }
+  //
+}
+
+//_______________________________________________________________________
+Double_t AliITSUSimuParam::GetPixUpgThreshold(UInt_t mod) const
+{
+  // obtain threshold
+  if (mod>=fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    return fPixUpgThreshDef;
+  }
+  else return fPixUpgThresh[mod];
+}
+
+//_______________________________________________________________________
+void AliITSUSimuParam::GetPixUpgThreshold(UInt_t mod, Double_t &thresh, Double_t &sigma) const
+{
+  // obtain thresholds
+  if (mod>=fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    thresh = fPixUpgThreshDef;
+    sigma  = fPixUpgThrSigmaDef;
+  }
+  else {
+    thresh = fPixUpgThresh[mod];
+    sigma  = fPixUpgThrSigma[mod];
+  }
+}
+
+//_______________________________________________________________________
+void AliITSUSimuParam::SetPixUpgBiasVoltage(Double_t val, int mod)
+{
+  // set threshold params
+  if (mod<0) {
+    fPixUpgBiasVoltageDef = val;
+    for (int i=fNPixUpg;i--;) fPixUpgBiasVoltage[i] = val;
+  }
+  else if (mod>=(int)fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    fPixUpgBiasVoltageDef = val;
+  }
+  else fPixUpgBiasVoltage[mod] = val;
+  //
+}
+
+//_______________________________________________________________________
+Double_t AliITSUSimuParam::GetPixUpgBiasVoltage(UInt_t mod) const
+{
+  // obtain threshold
+  if (mod>=fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    return fPixUpgBiasVoltageDef;
+  }
+  else return fPixUpgBiasVoltage[mod];
+}
+
+//_______________________________________________________________________
+void AliITSUSimuParam::SetPixUpgNoise(Double_t noise, Double_t baseline, int mod)
+{
+  // set noise params
+  if (mod<0) {
+    fPixUpgNoiseDef = noise;
+    fPixUpgBaselineDef  = baseline;
+    for (int i=fNPixUpg;i--;) {
+      fPixUpgNoise[i] = noise;
+      fPixUpgBaseline[i]  = baseline;
+    }
+  }
+  else if (mod>=(int)fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    fPixUpgNoiseDef = noise;
+    fPixUpgBaselineDef  = baseline;
+  }
+  else {
+    fPixUpgNoise[mod] = noise;
+    fPixUpgBaseline[mod]  = baseline;
+  }
+  //
+}
+
+//_______________________________________________________________________
+void AliITSUSimuParam::GetPixUpgNoise(UInt_t mod, Double_t &noise, Double_t &baseline) const
+{
+  // obtain noise
+  if (mod>=fNPixUpg) {
+    if (fNPixUpg>0) {AliFatal(Form("Wrong module %d, NPidUpg=%d",mod,fNPixUpg));}
+    noise     = fPixUpgNoiseDef;
+    baseline  = fPixUpgBaselineDef;
+  }
+  else {
+    noise     = fPixUpgNoise[mod];
+    baseline  = fPixUpgBaseline[mod];
+  }
+}
+
+//_______________________________________________________________________
+void AliITSUSimuParam::SetPixUpgCouplingOption(UInt_t opt)
+{
+  // set coupling option
+  if (opt>=kMaxCouplingOptPixUpg) AliFatal(Form("Coupling option %d should be less than %d",opt,kMaxCouplingOptPixUpg));
+  fPixUpgCouplOpt = opt;
+}
+
+
+//______________________________________________________________________
+Double_t AliITSUSimuParam::LorentzAngleHole(Double_t B) const 
+{
+  // Computes the Lorentz angle for electrons in Si
+  // Input: magnetic Field in KGauss
+  // Output: Lorentz angle in radians (positive if Bz is positive)
+  // Main Reference: NIM A 497 (2003) 389–396.
+  // "An algorithm for calculating the Lorentz angle in silicon detectors", V. Bartsch et al.
+  //
+  const Double_t krH=0.70; // Hall scattering factor for Hole
+  const Double_t kT0  = 300.;       // reference Temperature (degree K).
+  const Double_t kmulow0 = 470.5;   // cm^2/Volt-sec
+  const Double_t keT0 = -2.5;       // Power of Temp.
+  const Double_t beta0 = 1.213;     // beta coeff. at T0=300K
+  const Double_t keT1 = 0.17;       // Power of Temp. for beta
+  const Double_t kvsat0 = 8.37E+06; // saturated velocity at T0=300K (cm/sec)
+  const Double_t keT2 = 0.52;       // Power of Temp. for vsat
+  Double_t tT = fT;
+  Double_t eE= 1./fDOverV;
+  Double_t muLow=kmulow0*TMath::Power(tT/kT0,keT0);
+  Double_t beta=beta0*TMath::Power(tT/kT0,keT1);
+  Double_t vsat=kvsat0*TMath::Power(tT/kT0,keT2);
+  Double_t mu=muLow/TMath::Power(1+TMath::Power(muLow*eE/vsat,beta),1/beta);
+  Double_t angle=TMath::ATan(krH*mu*B*1.E-05); // Conversion Factor
+  return angle;
+}
+
+//______________________________________________________________________
+Double_t AliITSUSimuParam::LorentzAngleElectron(Double_t B) const 
+{
+  // Computes the Lorentz angle for electrons in Si
+  // Input: magnetic Field in KGauss
+  // Output: Lorentz angle in radians (positive if Bz is positive)
+  // Main Reference: NIM A 497 (2003) 389–396.
+  // "An algorithm for calculating the Lorentz angle in silicon detectors", V. Bartsch et al.
+  //
+  const Double_t krH=1.15; // Hall scattering factor for Electron
+  const Double_t kT0  = 300.;       // reference Temperature (degree K).
+  const Double_t kmulow0 = 1417.0;  // cm^2/Volt-sec
+  const Double_t keT0 = -2.2;       // Power of Temp.
+  const Double_t beta0 = 1.109;     // beta coeff. at T0=300K
+  const Double_t keT1 = 0.66;       // Power of Temp. for beta
+  const Double_t kvsat0 = 1.07E+07; // saturated velocity at T0=300K (cm/sec)
+  const Double_t keT2 = 0.87;       // Power of Temp. for vsat
+  Double_t tT = fT;
+  Double_t eE= 1./fDOverV;
+  Double_t muLow=kmulow0*TMath::Power(tT/kT0,keT0);
+  Double_t beta=beta0*TMath::Power(tT/kT0,keT1);
+  Double_t vsat=kvsat0*TMath::Power(tT/kT0,keT2);
+  Double_t mu=muLow/TMath::Power(1+TMath::Power(muLow*eE/vsat,beta),1/beta);
+  Double_t angle=TMath::ATan(krH*mu*B*1.E-05);
+  return angle;
+}
+
+//______________________________________________________________________
+Double_t AliITSSimuParam::SigmaDiffusion3D(Double_t l) const 
+{
+  // Returns the Gaussian sigma^2 ==  [cm^2] due to the
+  // defusion of electrons or holes through a distance l [cm] caused
+  // by an applied voltage v [volt] through a distance d [cm] in any
+  //  material at a temperature T [degree K]. The sigma diffusion when
+  //  expressed in terms of the distance over which the diffusion
+  // occures, l=time/speed, is independent of the mobility and therefore
+  //  the properties of the material. The charge distributions is given by
+  // n = exp(-r^2/4Dt)/(4piDt)^1.5. From this  = 6Dt where D=mkT/e
+  // (m==mobility, k==Boltzman's constant, T==temparature, e==electric
+  // charge. and vel=m*v/d. consiquently sigma^2=6kTdl/ev.
+  // Inputs:
+  //    Double_t l   Distance the charge has to travel.
+  // Output:
+  //    none.
+  // Return:
+  //    The Sigma due to the diffution of electrons. [cm]
+  const Double_t kcon = 5.17040258E-04; // == 6k/e [J/col or volts]  
+  return TMath::Sqrt(kcon*fT*fDOverV*l);  // [cm]
+}
+
+//______________________________________________________________________
+Double_t AliITSUSimuParam::SigmaDiffusion2D(Double_t l) const 
+{
+  // Returns the Gaussian sigma^2 ==  [cm^2] due to the defusion
+  // of electrons or holes through a distance l [cm] caused by an applied
+  // voltage v [volt] through a distance d [cm] in any material at a
+  // temperature T [degree K]. The sigma diffusion when expressed in terms
+  // of the distance over which the diffusion occures, l=time/speed, is
+  // independent of the mobility and therefore the properties of the
+  // material. The charge distributions is given by
+  // n = exp(-r^2/4Dt)/(4piDt)^1.5. From this  = 4Dt where D=mkT/e
+  // (m==mobility, k==Boltzman's constant, T==temparature, e==electric
+  // charge. and vel=m*v/d. consiquently sigma^2=4kTdl/ev.
+  // Inputs:
+  //    Double_t l   Distance the charge has to travel.
+  // Output:
+  //    none.
+  // Return:
+  //    The Sigma due to the diffution of electrons. [cm]
+  const Double_t kcon = 3.446935053E-04; // == 4k/e [J/col or volts]
+  return TMath::Sqrt(kcon*fT*fDOverV*l);  // [cm]
+}
+
+//______________________________________________________________________
+Double_t AliITSSimuParam::SigmaDiffusion1D(Double_t l) const 
+{
+  // Returns the Gaussian sigma^2 ==  [cm^2] due to the defusion
+  // of electrons or holes through a distance l [cm] caused by an applied
+  // voltage v [volt] through a distance d [cm] in any material at a
+  // temperature T [degree K]. The sigma diffusion when expressed in terms
+  // of the distance over which the diffusion occures, l=time/speed, is
+  // independent of the mobility and therefore the properties of the
+  // material. The charge distributions is given by
+  // n = exp(-r^2/4Dt)/(4piDt)^1.5. From this  = 2Dt where D=mkT/e
+  // (m==mobility, k==Boltzman's constant, T==temparature, e==electric
+  // charge. and vel=m*v/d. consiquently sigma^2=2kTdl/ev.
+  // Inputs:
+  //    Double_t l   Distance the charge has to travel.
+  // Output:
+  //    none.
+  // Return:
+  //    The Sigma due to the diffution of electrons. [cm]
+  const Double_t kcon = 1.723467527E-04; // == 2k/e [J/col or volts]
+  return TMath::Sqrt(kcon*fT*fDOverV*l);  // [cm]
+}
diff --git a/ITS/UPGRADE/AliITSUSimuParam.h b/ITS/UPGRADE/AliITSUSimuParam.h
new file mode 100644
index 00000000000..88ea4f3fcd1
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSimuParam.h
@@ -0,0 +1,151 @@
+#ifndef ALIITSUSIMUPARAM_H
+#define ALIITSUSIMUPARAM_H
+/* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+///////////////////////////////////////////////////////////////////
+//                                                               //
+// Class to store the parameters used in the simulation ITS      //
+//                                                               //
+///////////////////////////////////////////////////////////////////
+#include 
+#include 
+#include 
+
+class AliITSUSimuParam : public TObject {
+
+ public:
+  enum {kOldCouplingPixUpg,kNewCouplingPixUpg,kMaxCouplingOptPixUpg};
+  //
+  AliITSUSimuParam();
+  AliITSUSimuParam(UInt_t nPixUpg);
+  AliITSUSimuParam(const AliITSUSimuParam& simpar);
+  // assignment operator 
+  AliITSUSimuParam& operator=(const AliITSUSimuParam& source);
+  ~AliITSUSimuParam();
+
+  Double_t ApplyPixUpgBaselineAndNoise(UInt_t mod) const;
+  Double_t CalcProbNoiseOverThreshold(UInt_t mod) const;
+  //
+  void     SetPixUpgThreshold(Double_t thresh, Double_t sigma, int mod=-1);
+  void     GetPixUpgThreshold(UInt_t mod, Double_t& thresh, Double_t& sigma) const;
+  Double_t GetPixUpgThreshold(UInt_t mod)                                    const;
+  //
+  void     SetPixUpgNoise(Double_t noise, Double_t baseline, Int_t mod=-1);
+  void     GetPixUpgNoise(UInt_t mod,Double_t &noise, Double_t &baseline)    const;
+  //
+  void     SetPixUpgBiasVoltage(Double_t bias=18.182,Int_t mod=-1);
+  Double_t GetPixUpgBiasVoltage(UInt_t mod)                                  const;
+
+ 
+  void     SetGeVToCharge(Double_t gc=fgkNcompsDefault)                             {fGeVcharge = gc;}
+  Double_t GetGeVToCharge()                                                  const  {return fGeVcharge;}
+  Double_t GeVToCharge(Double_t gev)                                         const  {return gev/fGeVcharge;}
+  //
+  void     SetDistanceOverVoltage(Double_t d,Double_t v)                            {fDOverV = d/v;}
+  void     SetDistanceOverVoltage(Double_t dv=fgkDOverVDefault)                     {fDOverV = dv;}
+  Double_t GetDistanceOverVoltage()                                          const  {return fDOverV;}
+  //
+  void     SetPixUpgCouplingOption(UInt_t opt);
+  UInt_t   GetPixUpgCouplingOption()                                         const  {return fPixUpgCouplOpt;}
+
+  void     SetPixUpgCouplingParam(Double_t col, Double_t row)                       {fPixUpgCouplCol = col; fPixUpgCouplRow = row;}
+  void     GetPixUpgCouplingParam(Double_t &col, Double_t &row)              const  {col = fPixUpgCouplCol; row = fPixUpgCouplRow;}
+
+  void     SetPixUpgSigmaDiffusionAsymmetry(Double_t ecc)                           {fPixUpgEccDiff=ecc;}   
+  void     GetPixUpgSigmaDiffusionAsymmetry(Double_t &ecc)                   const  {ecc=fPixUpgEccDiff;}
+
+  void     SetPixUpgLorentzDrift(Bool_t ison)                                       {fPixUpgLorentzDrift=ison;}
+  Bool_t   GetPixUpgLorentzDrift()                                           const  {return fPixUpgLorentzDrift;}
+  void     SetPixUpgLorentzHoleWeight(Double_t weight)                               {fPixUpgLorentzHoleWeight=weight;}
+  Double_t GetPixUpgLorentzHoleWeight()                                      const  {return fPixUpgLorentzHoleWeight;}
+  
+  void     SetPixUpgAddNoisyFlag(Bool_t value)                                      {fPixUpgAddNoisyFlag = value;}
+  Bool_t   GetPixUpgAddNoisyFlag()                                           const  {return fPixUpgAddNoisyFlag;}
+  void     SetPixUpgRemoveDeadFlag(Bool_t value)                                    {fPixUpgRemoveDeadFlag = value;}
+  Bool_t   GetPixUpgRemoveDeadFlag()                                         const  {return fPixUpgRemoveDeadFlag;}
+  //
+  Double_t LorentzAngleElectron(Double_t bz)                                 const;
+  Double_t LorentzAngleHole(Double_t bz)                                     const;
+  //
+  Double_t SigmaDiffusion3D(Double_t  l)                                     const;
+  Double_t SigmaDiffusion2D(Double_t l)                                      const;
+  Double_t SigmaDiffusion1D(Double_t l)                                      const;
+  //
+  virtual void Print(Option_t *opt = "")                                     const; 
+  //
+  static Double_t CalcProbNoiseOverThreshold(double base, double noise, double thresh);
+  static Double_t GenerateNoiseQFunction(double prob, double mean, double sigma);
+  //
+ protected:
+
+  static const Double_t fgkPixUpgBiasVoltageDefault;//default for fPixUpgBiasVoltage
+  static const Double_t fgkPixUpgThreshDefault; //default for fThresh
+  static const Double_t fgkPixUpgThrSigmaDefault; //default for fSigma
+  static const Double_t fgkPixUpgCouplColDefault; //default for fPixUpgCouplCol
+  static const Double_t fgkPixUpgCouplRowDefault; //default for fPixUpgCouplRow
+  static const Double_t fgkPixUpgEccDiffDefault;//default for fPixUpgEccDiff
+  static const Double_t fgkPixUpgLorentzHoleWeightDefault;//default for fPixUpgLorentzHoleWeight
+  static const UInt_t   fgkPixUpgCouplingOptDefault;  // type of pixel Coupling (old or new)
+  static const Double_t fgkDOverVDefault;             // default distance over voltage 
+  static const Double_t fgkGeVtoChargeDefault;        // default energy to ionize (free an electron) in GeV
+  static const Double_t fgkTDefault;                  // default temperature
+
+  static const Double_t fgkNsigmasDefault; //default for fNsigmas
+  static const Int_t fgkNcompsDefault; //default for fNcomps
+
+ private:
+  //
+  Double_t   fGeVcharge;          // Energy to ionize (free an electron) in GeV
+  Double_t   fDOverV;             // The parameter d/v where d is the disance over which the the potential v is applied d/v [cm/volts]
+  Double_t   fT;                  // The temperature of the Si in Degree K.
+  //
+  UInt_t     fNPixUpg;            // number of PixUpg type detectors
+  UInt_t     fPixUpgCouplOpt;     // PixUpg Coupling Option
+  Double_t   fPixUpgCouplCol;     // PixUpg Coupling parameter along the cols
+  Double_t   fPixUpgCouplRow;     // PixUpg Coupling parameter along the rows
+  Double_t   fPixUpgEccDiff;      // Eccentricity (i.e. asymmetry parameter) in the  Gaussian diffusion for PixUpg  
+  Bool_t     fPixUpgLorentzDrift;     // Flag to decide whether to simulate the Lorentz Drift or not in PixUpg
+  Double_t   fPixUpgLorentzHoleWeight;// Lorentz Angle is computed for PixUpg as average of Hole and Electron
+  //                                    this parameter gives the relative weights between the two
+  Bool_t     fPixUpgAddNoisyFlag;     // Flag saying whether noisy pixels should be added to digits
+  Bool_t     fPixUpgRemoveDeadFlag;   // Flag saying whether dead pixels should be removed from digits
+  //
+  Double_t   fPixUpgThreshDef;      // PixUpg Threshold value
+  Double_t   fPixUpgThrSigmaDef;    // PixUpg Threshold fluctuation
+  Double_t   fPixUpgBiasVoltageDef; // Bias Voltage for the PixUpg
+  Double_t   fPixUpgNoiseDef;       // PixUpg electronic noise: sigma
+  Double_t   fPixUpgBaselineDef;    // PixUpg electronic noise: baseline
+  //
+  Double_t*  fPixUpgThresh;      //[fNPixUpg] PixUpg Threshold value
+  Double_t*  fPixUpgThrSigma;    //[fNPixUpg] PixUpg Threshold fluctuation
+  Double_t*  fPixUpgBiasVoltage; //[fNPixUpg] Bias Voltage for the PixUpg
+  Double_t*  fPixUpgSigma;       //[fNPixUpg] PixUpg threshold fluctuations spread
+  Double_t*  fPixUpgNoise;       //[fNPixUpg] PixUpg electronic noise: sigma
+  Double_t*  fPixUpgBaseline;    //[fNPixUpg] PixUpg electronic noise: baseline
+  //
+
+  ClassDef(AliITSUSimuParam,1);
+};
+
+//_______________________________________________________________________
+inline Double_t AliITSUSimuParam::CalcProbNoiseOverThreshold(double mean, double sigma, double thresh) 
+{
+  // calculate probability of gaussian noise exceeding the threshold
+  const double ksqrt2 = 1.41421356237309515e+00;
+  return 0.5*TMath::Erfc( (thresh-mean)/(sigma*ksqrt2));
+}
+
+//_______________________________________________________________________
+inline Double_t AliITSUSimuParam::GenerateNoiseQFunction(double prob, double mean, double sigma) 
+{
+  // generate random noise exceeding threshold probability prob, i.e. find a random point in the right
+  // tail of the gaussian(base,noise), provided that the tail integral = prob
+  const double ksqrt2 = 1.41421356237309515e+00;
+  return mean+sigma*ksqrt2*TMath::ErfcInverse(2*prob*(1.-gRandom->Rndm()));
+}
+
+
+
+#endif
diff --git a/ITS/UPGRADE/AliITSUSimulation.cxx b/ITS/UPGRADE/AliITSUSimulation.cxx
new file mode 100644
index 00000000000..71bd11d50aa
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSimulation.cxx
@@ -0,0 +1,166 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+//////////////////////////////////////////////////////////////////////////////
+// This is the base class for ITS detector signal simulations. Data members //
+// include are a pointer to the AliITSDetTypeSim clas in order to access    //
+// segmentation and response objects                                        // 
+// classes. See the detector specific implementations for the propper code. //
+//////////////////////////////////////////////////////////////////////////////
+#include 
+#include "TSeqCollection.h"
+#include "AliITSUSimulation.h"
+#include "AliITSUSDigit.h"
+
+ClassImp(AliITSUSimulation)
+
+//______________________________________________________________________
+AliITSUSimulation::AliITSUSimulation()
+:  fSeg(0)
+  ,fCalibDead(0)
+  ,fCalibNoisy(0)
+  ,fSensMap(0)
+  ,fSimuParam(0)
+  ,fModule(0)
+  ,fEvent(0)
+  ,fDebug(0)
+{
+    // Default constructor
+}
+//______________________________________________________________________
+AliITSUSimulation::AliITSUSimulation(AliITSUSimuParam* sim,AliITSUSensMap* map)
+  :fSeg(0)
+  ,fCalibDead(0)
+  ,fCalibNoisy(0)
+  ,fSensMap(map)
+  ,fSimuParam(sim)
+  ,fModule(0)
+  ,fEvent(0)
+  ,fDebug(0)
+{
+    // Default constructor
+}
+
+//__________________________________________________________________________
+AliITSUSimulation::AliITSUSimulation(const AliITSUSimulation &s) 
+  :TObject(s)
+  ,fSeg(s.fSeg)
+  ,fCalibDead(s.fCalibDead)
+  ,fCalibNoisy(s.fCalibNoisy)
+  ,fSensMap(s.fSensMap)
+  ,fSimuParam(s.fSimuParam)   
+  ,fModule(s.fModule)
+  ,fEvent(s.fEvent)
+  ,fDebug(s.fDebug)
+{
+  //     Copy Constructor 
+}
+
+//_________________________________________________________________________
+AliITSUSimulation&  AliITSUSimulation::operator=(const AliITSUSimulation &s)
+{
+  //    Assignment operator
+  if(&s == this) return *this;
+  fSeg       = s.fSeg;
+  fCalibDead = s.fCalibDead;
+  fCalibNoisy= s.fCalibNoisy;
+  fSensMap   = s.fSensMap;
+  fSimuParam = s.fSimuParam;
+  fModule    = s.fModule;
+  fEvent     = s.fEvent;
+  return *this;
+}
+
+//______________________________________________________________________
+void AliITSUSimulation::InitSimulationModule(Int_t module, Int_t event, AliITSsegmentation* seg)
+{
+  //  This function creates maps to build the list of tracks for each
+  //  summable digit. Inputs defined by base class.
+  //
+  SetModule(module);
+  SetEvent(event);
+  SetSegmentation(seg);
+  ClearMap();
+}
+
+//______________________________________________________________________
+Bool_t AliITSUSimulation::AddSDigitsToModule(TSeqCollection *pItemArr,Int_t mask )
+{
+  // Add Summable digits to module maps.
+  // Inputs:
+  //    pItemArr  Array of AliITSpListItems (SDigits).
+  //    mask    Track number off set value 
+  //
+  Int_t nItems = pItemArr->GetEntries();
+  Bool_t sig = kFALSE;
+  // 
+  for( Int_t i=0; iAt( i ));
+    if( pItem->GetModule() != fModule ) AliFatal(Form("SDigits module %d != current module %d: exit", pItem->GetModule(), fModule ));
+    if(pItem->GetSumSignal()>0.0 ) sig = kTRUE;
+    AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(pItem);
+    if (!oldItem) {
+      oldItem = (AliITSUSDigit*)fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(*pItem) );
+      if (mask) oldItem->ShiftIndices(mask);
+    }
+    else oldItem->AddTo(mask, pItem);
+  }
+  return sig;
+}
+
+//______________________________________________________________________
+void AliITSUSimulation::UpdateMapSignal(UInt_t dim0,UInt_t dim1,Int_t trk,Int_t ht,Double_t signal) 
+{
+  // update map with new hit
+  UInt_t ind = fSensMap->GetIndex(dim0,dim1);
+  AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
+  if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(trk,ht,fModule,ind,signal) );
+  else oldItem->AddSignal(trk,ht,signal);
+}
+
+//______________________________________________________________________
+void AliITSUSimulation::UpdateMapNoise(UInt_t dim0,UInt_t dim1,Double_t noise) 
+{
+  // update map with new hit
+  UInt_t ind = fSensMap->GetIndex(dim0,dim1);
+  AliITSUSDigit* oldItem = (AliITSUSDigit*)fSensMap->GetItem(ind);
+  if (!oldItem) fSensMap->RegisterItem( new(fSensMap->GetFree()) AliITSUSDigit(fModule,ind,noise) );
+  else oldItem->AddNoise(noise);
+}
+
+//______________________________________________________________________
+Int_t AliITSUSimulation::GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,TArrayI &indx)
+{
+  // generate random sample [0:nmax] of ngen variables, and fill orreder indices 
+  // return actual number of generated values 
+  if (vals.GetSize()<(int)ngen) vals.Set(ngen);
+  if (indx.GetSize()<(int)ngen) indx.Set(ngen);
+  int* valA = vals.GetArray();
+  int* indA = indx.GetArray();
+  if (ngen>=nmax) {
+    ngen = nmax-1;
+    for (int i=(int)ngen;i--;) {valA[i]=indA[i]=i;}
+    return ngen;
+  }
+  Bool_t rep;
+  for (int i=0;i<(int)ngen;i++) {
+    do { // exclude repetitions
+      rep = kFALSE;
+      valA[i] = gRandom->Rndm()*nmax;
+      for (int j=i;j--;) if (valA[j]==valA[i]) {rep=kTRUE;break;}
+    } while(rep);
+  }
+  TMath::Sort((int)ngen,valA,indA,kFALSE);
+  return ngen;
+}
diff --git a/ITS/UPGRADE/AliITSUSimulation.h b/ITS/UPGRADE/AliITSUSimulation.h
new file mode 100644
index 00000000000..d0df46cae7a
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSimulation.h
@@ -0,0 +1,96 @@
+#ifndef ALIITSUSIMULATION_H
+#define ALIITSUSIMULATION_H
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+#include 
+#include "AliITSUSensMap.h"
+#include "AliITSsegmentation.h"
+
+class AliITSCalibration;
+class AliITSUSimuParam;
+class AliITSUModule;
+class TRandom;
+class TSegCollection;
+
+// This is the base class for ITS detector signal simulations. Data members
+// include are a pointer to the detectors specific response and segmentation
+// classes. See the detector specific implementations for the propper code.
+// The detector-specific implementations are responsible for processing detector type, 
+// which still may have different segmentations!
+// Note: the detector specific objects (segmentation, calib, etc.) are not owned
+// by the object but set externaly
+
+class AliITSUSimulation : public TObject 
+{
+ public:
+  AliITSUSimulation();
+  AliITSUSimulation(AliITSUSimuParam* sim, AliITSUSensMap* map);
+  virtual ~AliITSUSimulation() {} 
+  AliITSUSimulation(const AliITSUSimulation &source);
+  AliITSUSimulation& operator=(const AliITSUSimulation &source);
+  virtual void Init() = 0;
+  //
+  void UpdateMapSignal(UInt_t dim0,UInt_t dim1, Int_t trk,Int_t ht,Double_t signal);
+  void UpdateMapNoise(UInt_t dim0,UInt_t dim1, Double_t noise);
+  virtual void InitSimulationModule(Int_t, Int_t, AliITSsegmentation*);
+  //
+  // Hits -> SDigits
+  virtual void SDigitiseModule(AliITSUModule* mod, Int_t mask, Int_t event, AliITSsegmentation* seg) = 0;
+  virtual void FinishSDigitiseModule() = 0;
+  virtual Bool_t AddSDigitsToModule( TSeqCollection *pItemArray, Int_t mask );
+  //
+  // Hits -> Digits
+  virtual void DigitiseModule(AliITSUModule* mod, Int_t mask, Int_t event, AliITSsegmentation* seg) = 0;
+  virtual void CreateFastRecPoints(AliITSUModule *,Int_t,TRandom *,TClonesArray* /*recp*/) {}
+  //
+  AliITSCalibration*  GetCalibDead()                   const {return fCalibDead;}
+  AliITSCalibration*  GetCalibNoisy()                  const {return fCalibNoisy;}
+  AliITSsegmentation* GetSegmentation()                const {return fSeg;}
+  AliITSUSimuParam* GetSimuParam()                   const {return fSimuParam;}
+  AliITSUSensMap*   GetMap()                         const {return fSensMap;}
+  Int_t               GetModule()                      const {return fModule;}
+  Int_t               GetEvent()                       const {return fEvent;}
+  Bool_t              GetDebug(Int_t level=1)          const {return fDebug>=level;}
+
+  //
+  void SetCalibDead(AliITSCalibration *calib)              {fCalibDead = calib;}
+  void SetCalibNoisy(AliITSCalibration *calib)             {fCalibNoisy = calib;}
+  void SetSegmentation(AliITSsegmentation *seg)            {fSeg = seg; if (seg&&fSensMap) fSensMap->SetDimensions(seg->Npz(),seg->Npx());}
+  void SetSimuParam(AliITSUSimuParam *sp)                {fSimuParam = sp;}
+  void SetMap(AliITSUSensMap *p)                         {fSensMap = p;}
+  void SetModule(Int_t mod)                                {fModule=mod;} 
+  void SetEvent(Int_t evnt)                                {fEvent=evnt;} 
+  void SetDebug(Int_t level=5)                             {fDebug=level;}
+  void SetNoDebug()                                        {fDebug=0;}
+  void ClearMap()                                          {fSensMap->Clear();}
+  //
+  static  Int_t GenOrderedSample(UInt_t nmax,UInt_t ngen,TArrayI &vals,TArrayI &ind);
+  //
+ protected:
+  AliITSsegmentation  *fSeg;            //! segmentation
+  AliITSCalibration   *fCalibDead;      //! dead channels
+  AliITSCalibration   *fCalibNoisy;     //! noisy channels
+  AliITSUSensMap    *fSensMap;        //! sensor map for hits manipulations
+  AliITSUSimuParam  *fSimuParam;      //! simulation parameters
+  Int_t                fModule;         //! module number being processed
+  Int_t                fEvent;          //! event number being processed
+  Int_t                fDebug;          //!  debug flag
+
+  ClassDef(AliITSUSimulation,1)       // Simulation base class 
+    
+};
+
+#endif
diff --git a/ITS/UPGRADE/AliITSUSimulationPix.cxx b/ITS/UPGRADE/AliITSUSimulationPix.cxx
new file mode 100644
index 00000000000..4bc6ac3c29e
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSimulationPix.cxx
@@ -0,0 +1,787 @@
+/*
+ questions to experts: why RemoveDeadPixels should be called before FrompListToDigits ? 
+
+ 
+*/
+
+/**************************************************************************
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+#include 
+#include 
+#include 
+#include 
+#include "AliITSU.h"
+#include "AliITSUDigitPix.h"
+#include "AliITSUHit.h"
+#include "AliITSUModule.h"
+#include "AliITSUSensMap.h"
+#include "AliITSUCalibrationPix.h"
+#include "AliITSUSegmentationPix.h"
+#include "AliITSUSimulationPix.h"
+#include "AliLog.h"
+#include "AliRun.h"
+#include "AliMagF.h"
+#include "AliMathBase.h"
+#include "AliITSUSimuParam.h"
+#include "AliITSUSDigit.h"
+
+ClassImp(AliITSUSimulationPix)
+////////////////////////////////////////////////////////////////////////
+//  Version: 1
+//  Modified by D. Elia, G.E. Bruno, H. Tydesjo 
+//  Fast diffusion code by Bjorn S. Nilsen
+//  March-April 2006
+//  October     2007: GetCalibrationObjects() removed
+//
+//  Version: 0
+//  Written by Boris Batyunya
+//  December 20 1999
+//
+//  Adapted for pixels of ITS upgrade July 2012, ruben.shahoyan@cern.ch
+//
+//  AliITSUSimulationPix is to do the simulation of pixels
+//
+////////////////////////////////////////////////////////////////////////
+
+//______________________________________________________________________
+AliITSUSimulationPix::AliITSUSimulationPix()
+:  fTanLorAng(0)
+  ,fStrobe(kTRUE)
+  ,fStrobeLenght(4)
+  ,fStrobePhase(-12.5e-9)
+{
+   // Default constructor.
+}
+
+//______________________________________________________________________
+AliITSUSimulationPix::AliITSUSimulationPix(AliITSUSimuParam* sim,AliITSUSensMap* map)
+  :AliITSUSimulation(sim,map)
+  ,fTanLorAng(0)
+  ,fStrobe(kTRUE)
+  ,fStrobeLenght(4)
+  ,fStrobePhase(-12.5e-9)
+{
+  // standard constructor
+  Init();
+}
+
+//______________________________________________________________________
+AliITSUSimulationPix::AliITSUSimulationPix(const AliITSUSimulationPix &s) 
+  :AliITSUSimulation(s)
+  ,fTanLorAng(s.fTanLorAng)
+  ,fStrobe(s.fStrobe)
+  ,fStrobeLenght(s.fStrobeLenght)
+  ,fStrobePhase(s.fStrobePhase)
+{
+  //     Copy Constructor
+}
+
+
+//______________________________________________________________________
+AliITSUSimulationPix::~AliITSUSimulationPix()
+{
+  // destructor
+  // only the sens map is owned and it is deleted by ~AliITSUSimulation
+}
+
+//______________________________________________________________________
+AliITSUSimulationPix& AliITSUSimulationPix::operator=(const AliITSUSimulationPix &s)
+{
+  //    Assignment operator
+  if (&s == this) return *this;
+  AliITSUSimulation::operator=(s);
+  fStrobe       = s.fStrobe;
+  fStrobeLenght = s.fStrobeLenght;
+  fStrobePhase  = s.fStrobePhase;
+  return *this;
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::Init()
+{
+  // Initilization
+  if (fSimuParam->GetPixUpgLorentzDrift()) SetTanLorAngle(fSimuParam->GetPixUpgLorentzHoleWeight());
+}
+
+//______________________________________________________________________
+Bool_t AliITSUSimulationPix::SetTanLorAngle(Double_t weightHole) 
+{
+  // This function set the Tangent of the Lorentz angle. 
+  // A weighted average is used for electrons and holes 
+  // Input: Double_t weightHole: wheight for hole: it should be in the range [0,1]
+  // output: Bool_t : kTRUE in case of success
+  //
+  if (weightHole<0) {
+    weightHole=0.;
+    AliWarning("You have asked for negative Hole weight");
+    AliWarning("I'm going to use only electrons");
+  }
+  if (weightHole>1) {
+    weightHole=1.;
+    AliWarning("You have asked for weight > 1");
+    AliWarning("I'm going to use only holes");
+  }
+  Double_t weightEle=1.-weightHole;
+  AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+  if (!fld) AliFatal("The field is not initialized");
+  Double_t bz = fld->SolenoidField();
+  fTanLorAng = TMath::Tan(weightHole*fSimuParam->LorentzAngleHole(bz) +
+			  weightEle*fSimuParam->LorentzAngleElectron(bz));
+  return kTRUE;
+}
+
+//_____________________________________________________________________
+void AliITSUSimulationPix::SDigitiseModule(AliITSUModule *mod, Int_t /*mask*/,Int_t event, AliITSsegmentation* seg)
+{
+  //  This function begins the work of creating S-Digits.
+  if (!(mod->GetNHits())) {
+    AliDebug(1,Form("In event %d module %d there are %d hits returning.",
+		    event, mod->GetIndex(),mod->GetNHits()));
+    return;
+  } 
+  //
+  if (fStrobe) if (event != fEvent) GenerateStrobePhase(); 
+  InitSimulationModule(mod->GetIndex(), event, seg );
+  // Hits2SDigits(mod);
+  Hits2SDigitsFast(mod);
+  if (fSimuParam->GetPixUpgAddNoisyFlag())   AddNoisyPixels();
+  if (fSimuParam->GetPixUpgRemoveDeadFlag()) RemoveDeadPixels();  
+  WriteSDigits();
+  ClearMap();
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::WriteSDigits()
+{
+  //  This function adds each S-Digit to pList
+  static AliITSU *aliITS = (AliITSU*)gAlice->GetModule("ITS");
+  int nsd = fSensMap->GetEntries();
+  for (int i=0;iAt(i); // ordered in index
+    if (!sd->GetSumSignal()>0 || fSensMap->IsDisabled(sd)) continue;
+    aliITS->AddSumDigit(*sd);
+  }
+  return; 
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::FinishSDigitiseModule()
+{
+   //  This function calls SDigitsToDigits which creates Digits from SDigits
+  FrompListToDigits();
+  ClearMap();
+  return;
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::DigitiseModule(AliITSUModule *mod,Int_t /*mask*/, Int_t event, AliITSsegmentation* seg)
+{
+  //  This function creates Digits straight from the hits and then adds
+  //  electronic noise to the digits before adding them to pList
+  //  Each of the input variables is passed along to Hits2SDigits
+  //
+  if (fStrobe) if (event != fEvent) GenerateStrobePhase();
+  InitSimulationModule( mod->GetIndex(), event, seg );
+  // Hits2SDigits(mod);
+  Hits2SDigitsFast(mod);
+  //
+  if (fSimuParam->GetPixUpgAddNoisyFlag())   AddNoisyPixels();
+  if (fSimuParam->GetPixUpgRemoveDeadFlag()) RemoveDeadPixels();
+  FrompListToDigits();
+  ClearMap();
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::Hits2SDigits(AliITSUModule *mod)
+{
+  // Does the charge distributions using Gaussian diffusion charge charing.
+  const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+  const Double_t kcmtomic = 1.e4;
+  const Double_t kBunchLenght = 25e-9; // LHC clock
+  Int_t nhits = mod->GetNHits();
+  if (!nhits) return;
+  //
+  Int_t h,ix,iz,i;
+  Int_t idtrack;
+  Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0,ld=0.0;
+  Double_t x,y,z,t,tp,st,dt=0.2,el,sig,sigx,sigz,fda;
+  Double_t thick = 0.5*kmictocm*fSeg->Dy();  // Half Thickness
+  fSimuParam->GetPixUpgSigmaDiffusionAsymmetry(fda);
+  //
+  for (h=0;hGetHit(h)->GetTOF()GetHit(h)->GetTOF()>(fStrobePhase+fStrobeLenght*kBunchLenght)))
+	) continue;
+    //
+    if (!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
+    st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
+    if (st>0.0) {
+      st = (Double_t)((Int_t)(st*kcmtomic)); // number of microns
+      if (st<=1.0) st = 1.0;
+      dt = 1.0/st;
+      for (t=0.0;t<1.0;t+=dt) { // Integrate over t
+	tp  = t+0.5*dt;
+	x   = x0+x1*tp;
+	y   = y0+y1*tp;
+	z   = z0+z1*tp;
+	if (!(fSeg->LocalToDet(x,z,ix,iz))) continue; // outside
+	el  = dt * de / fSimuParam->GetGeVToCharge();
+	//
+	if (GetDebug(1)) if (el<=0.0) cout<<"el="<GetPixUpgCouplingOption());
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::Hits2SDigitsFast(AliITSUModule *mod)
+{
+  // Does the charge distributions using Gaussian diffusion charge charing.    // Inputs:
+  //    AliITSUModule *mod  Pointer to this module
+  // Output:
+  //    none.
+  // Return:
+  //    none.
+  const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+  const Int_t kn10=10;
+  const Double_t kti[kn10]={7.443716945e-3,2.166976971e-1,3.397047841e-1,
+			    4.325316833e-1,4.869532643e-1,5.130467358e-1,
+			    5.674683167e-1,6.602952159e-1,7.833023029e-1,
+			    9.255628306e-1};
+  const Double_t kwi[kn10]={1.477621124e-1,1.346333597e-1,1.095431813e-1,
+			    7.472567455e-2,3.333567215e-2,3.333567215e-2,
+			    7.472567455e-2,1.095431813e-1,1.346333597e-1,
+			    1.477621124e-1};
+  const Double_t kBunchLenght = 25e-9; // LHC clock
+  TObjArray *hits = mod->GetHits();
+  Int_t nhits = hits->GetEntriesFast();
+  if (nhits<=0) return;
+  //
+  Int_t h,ix,iz,i;
+  Int_t idtrack;
+  Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0,ld=0.0;
+  Double_t x,y,z,t,st,el,sig,sigx,sigz,fda;
+  Double_t thick = 0.5*kmictocm*fSeg->Dy();  // Half thickness
+  fSimuParam->GetPixUpgSigmaDiffusionAsymmetry(fda);
+  //
+  for (h=0;hGetHit(h)->GetTOF()GetHit(h)->GetTOF()>(fStrobePhase+fStrobeLenght*kBunchLenght)))
+	) continue;
+    //
+    if (!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
+    st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
+    if (st>0.0) 
+      for (i=0;iLocalToDet(x,z,ix,iz))) continue; // outside
+	el  = kwi[i]*de/fSimuParam->GetGeVToCharge();
+	sig = fSimuParam->SigmaDiffusion1D(TMath::Abs(thick + y));
+	sigx=sig;
+	sigz=sig*fda;
+	if (fSimuParam->GetPixUpgLorentzDrift()) ld=(y+thick)*fTanLorAng;
+	SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,ld,idtrack,h);
+	//                cout << "sigx sigz " << sigx << " " << sigz << endl; // dom
+      } // end for i // End Integrate over t
+    else { // st == 0.0 deposit it at this point
+      x   = x0;
+      y   = y0;
+      z   = z0;
+      if (!(fSeg->LocalToDet(x,z,ix,iz))) continue; // outside
+      el  = de / fSimuParam->GetGeVToCharge();
+      sig = fSimuParam->SigmaDiffusion1D(TMath::Abs(thick + y));
+      sigx=sig;
+      sigz=sig*fda;
+      if (fSimuParam->GetPixUpgLorentzDrift()) ld=(y+thick)*fTanLorAng;
+      SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,ld,idtrack,h);
+    } // end if st>0.0
+    
+  } // Loop over all hits h
+  
+  // Coupling
+  int nd = fSensMap->GetEntriesUnsorted(); // use unsorted access when possible, since it is faster
+  AliITSUSDigit* dg = 0;
+  switch (fSimuParam->GetPixUpgCouplingOption()) {
+  case AliITSUSimuParam::kNewCouplingPixUpg :
+    for (i=nd;i--;) {
+      dg = (AliITSUSDigit*)fSensMap->AtUnsorted(i);
+      if (fSensMap->IsDisabled(dg)) continue;
+      SetCoupling(dg,idtrack,h);
+    } 
+  case AliITSUSimuParam::kOldCouplingPixUpg:
+    for (i=nd;i--;) {
+      dg = (AliITSUSDigit*)fSensMap->AtUnsorted(i);
+      if (fSensMap->IsDisabled(dg)) continue;
+      SetCouplingOld(dg,idtrack,h);
+    } 
+    break;
+  default:
+    break;
+  } // end switch
+  if (GetDebug(2))Info("Hits2SDigits","Finished fCoupling=%d",fSimuParam->GetPixUpgCouplingOption());
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::SpreadCharge(Double_t x0,Double_t z0,
+					  Int_t ix0,Int_t iz0,
+					  Double_t el,Double_t sig,Double_t ld,
+					  Int_t t,Int_t hi)
+{
+   // Spreads the charge over neighboring cells. Assume charge is distributed
+   // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
+   // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
+   // if fSimuParam->GetPixUpgLorentzDrift()=kTRUE, then x0=x0+ld (Lorentz drift taken into account)
+   // Defined this way, the integral over all x and z is el.
+   // Inputs:
+   //    Double_t x0   x position of point where charge is liberated
+   //    Double_t z0   z position of point where charge is liberated
+   //    Int_t    ix0  row of cell corresponding to point x0
+   //    Int_t    iz0  columb of cell corresponding to point z0
+   //    Double_t el   number of electrons liberated in this step
+   //    Double_t sig  Sigma difusion for this step (y0 dependent)
+   //    Double_t ld   lorentz drift in x for this step (y0 dependent)
+   //    Int_t    t    track number
+   //    Int_t    ti   hit track index number
+   //    Int_t    hi   hit "hit" index number
+   // Outputs:
+   //     none.
+   // Return:
+   //     none.
+   const Int_t knx = 3,knz = 2;
+   const Double_t kRoot2 = 1.414213562; // Sqrt(2).
+   const Double_t kmictocm = 1.0e-4; // convert microns to cm.
+   Int_t ix,iz,ixs,ixe,izs,ize;
+   Float_t x,z;
+   Double_t x1,x2,z1,z2,s,sp;
+   //
+   if (GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
+   if (sig<=0.0) { // if sig<=0 No diffusion to simulate.
+     UpdateMapSignal(iz0,ix0,t,hi,el);
+     if (GetDebug(2)) cout << "sig<=0.0=" << sig << endl; // end if GetDebug
+     return;
+   } // end if
+   sp = 1.0/(sig*kRoot2);
+   if (GetDebug(2)) cout << "sig=" << sig << " sp=" << sp << endl; // end if GetDebug
+   ixs = TMath::Max(-knx+ix0,0);
+   ixe = TMath::Min(knx+ix0,fSeg->Npx()-1);
+   izs = TMath::Max(-knz+iz0,0);
+   ize = TMath::Min(knz+iz0,fSeg->Npz()-1);
+   for (ix=ixs;ix<=ixe;ix++) 
+     for (iz=izs;iz<=ize;iz++) {
+       fSeg->DetToLocal(ix,iz,x,z); // pixel center
+       x1  = x;
+       z1  = z;
+       x2  = x1 + 0.5*kmictocm*fSeg->Dpx(ix); // Upper
+       x1 -= 0.5*kmictocm*fSeg->Dpx(ix);  // Lower
+       z2  = z1 + 0.5*kmictocm*fSeg->Dpz(iz); // Upper
+       z1 -= 0.5*kmictocm*fSeg->Dpz(iz);  // Lower
+       x1 -= x0+ld; // Distance from where track traveled (taking into account the Lorentz drift)
+       x2 -= x0+ld; // Distance from where track traveled (taking into account the Lorentz drift)
+       z1 -= z0; // Distance from where track traveled
+       z2 -= z0; // Distance from where track traveled
+       s   = 0.25; // Correction based on definision of Erfc
+       s  *= AliMathBase::ErfcFast(sp*x1) - AliMathBase::ErfcFast(sp*x2);
+       if (GetDebug(3)) {
+	 cout <<"el="<GetMaxIndex();
+  double minProb = 0.1/maxInd;
+  //
+  int nsd = fSensMap->GetEntries();
+  Int_t prevID=0,curID=0;
+  TArrayI ordSampleInd(100),ordSample(100);
+  //
+  double probNoisy,noiseSig,noiseMean,thresh = fSimuParam->GetPixUpgThreshold(fModule);
+  fSimuParam->GetPixUpgNoise(fModule, noiseSig, noiseMean);
+  probNoisy = AliITSUSimuParam::CalcProbNoiseOverThreshold(noiseMean,noiseSig,thresh); // prob. to have noise above threshold
+  //
+  for (int i=0;iAt(i); // ordered in index
+    if (fSensMap->IsDisabled(sd)) continue;
+    curID = (int)sd->GetUniqueID();
+    //
+    if (probNoisy>minProb) { // generate randomly noisy pixels above the threshold, with ID's between previous hit and current
+      CreateNoisyDigits(prevID,curID,probNoisy, noiseSig, noiseMean);
+      prevID = curID+1;
+    }
+    //
+    if ((sig=sd->GetSumSignal())<=fSimuParam->GetPixUpgThreshold(fModule)) continue;
+    if (TMath::Abs(sig)>2147483647.0) { //RS?
+      //PH 2147483647 is the max. integer
+      //PH This apparently is a problem which needs investigation
+      AliWarning(Form("Too big or too small signal value %f",sig));
+    }
+    fSensMap->GetMapIndex(sd->GetUniqueID(),iz,ix);
+    dig.SetCoord1(iz);
+    dig.SetCoord2(ix);
+    dig.SetSignal(1);
+    dig.SetSignalPix((Int_t)sig);
+    int ntr = sd->GetNTracks();
+    for (int j=0;jGetTrack(j));
+      dig.SetHit(j,sd->GetHit(j));
+    }
+    for (int j=ntr;jAddSimDigit(AliITSUGeomTGeo::kDetTypePixUpg, &dig);
+  }
+  // if needed, add noisy pixels with id from last real hit to maxID
+  if (probNoisy>minProb) CreateNoisyDigits(prevID,maxInd,probNoisy, noiseSig, noiseMean);
+  // 
+}
+
+//______________________________________________________________________
+Int_t AliITSUSimulationPix::CreateNoisyDigits(Int_t minID,Int_t maxID,double probNoisy, double noise, double base)
+{
+  // create random noisy digits above threshold within id range [minID,maxID[
+  // see FrompListToDigits for details
+  //
+  static AliITSU *aliITS = (AliITSU*)gAlice->GetModule("ITS");
+  UInt_t ix,iz;
+  static AliITSUDigitPix dig;
+  static TArrayI ordSampleInd(100),ordSample(100); //RS!!! static is not thread-safe!!!
+  const Int_t    knmaxtrk=AliITSdigit::GetNTracks();
+  //
+  Int_t ncand = 0;
+  int npix = maxID-minID;
+  if (npix<1 || (ncand=gRandom->Poisson(npix*probNoisy))<1) return ncand; // decide how many noisy pixels will be added
+  ncand = GenOrderedSample(npix,ncand,ordSample,ordSampleInd); 
+  int* ordV = ordSample.GetArray();
+  int* ordI = ordSampleInd.GetArray();
+  for (int j=0;jGetMapIndex((UInt_t)ordV[ordI[j]],iz,ix);   // create noisy digit
+    dig.SetCoord1(iz);
+    dig.SetCoord2(ix);
+    dig.SetSignal(1);
+    dig.SetSignalPix((Int_t)AliITSUSimuParam::GenerateNoiseQFunction(probNoisy,base,noise));
+    for (int k=knmaxtrk;k--;) {
+      dig.SetTrack(k,-3);
+      dig.SetHit(k,-1);
+    }
+    aliITS->AddSimDigit(AliITSUGeomTGeo::kDetTypePixUpg,&dig);
+    AliInfo(Form("Add noisy pixel %d(%d/%d) Noise=%d",ordV[ordI[j]],iz,ix,dig.GetSignalPix()));
+  }
+  return ncand;
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::SetCoupling(AliITSUSDigit* old, Int_t ntrack, Int_t idhit) 
+{
+  //  Take into account the coupling between adiacent pixels.
+  //  The parameters probcol and probrow are the probability of the
+  //  signal in one pixel shared in the two adjacent pixels along
+  //  the column and row direction, respectively.
+  //  Note pList is goten via GetMap() and module is not need any more.
+  //  Otherwise it is identical to that coded by Tiziano Virgili (BSN).
+  //Begin_Html
+  /*
+    
+     
+
+ + . + +
+   */
+   //End_Html
+   // Inputs:
+  // old                  existing AliITSUSDigit
+  // Int_t ntrack         track incex number
+  // Int_t idhit          hit index number
+  UInt_t col,row;
+  Double_t pulse1,pulse2;
+  Double_t couplR=0.0,couplC=0.0;
+  Double_t xr=0.;
+  //
+  fSensMap->GetMapIndex(old->GetUniqueID(),col,row);
+  fSimuParam->GetPixUpgCouplingParam(couplC,couplR);
+  if (GetDebug(3)) Info("SetCoupling","(col=%d,row=%d,ntrack=%d,idhit=%d) "
+			"Calling SetCoupling couplC=%e couplR=%e",
+			col,row,ntrack,idhit,couplC,couplR);
+  pulse2 = pulse1 = old->GetSignal();
+  for (Int_t isign=-1;isign<=1;isign+=2) {
+    //
+    // loop in col direction
+    int j1 = int(col) + isign;
+    xr = gRandom->Rndm();
+    if ( !((j1<0) || (j1>fSeg->Npz()-1) || (xr>couplC)) ) UpdateMapSignal(UInt_t(j1),row,ntrack,idhit,pulse1);
+    //
+    // loop in row direction
+    int j2 = int(row) + isign;
+    xr = gRandom->Rndm();
+    if ( !((j2<0) || (j2>fSeg->Npx()-1) || (xr>couplR)) ) UpdateMapSignal(col,UInt_t(j2),ntrack,idhit,pulse2);
+  } 
+  //
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::SetCouplingOld(AliITSUSDigit* old, Int_t ntrack,Int_t idhit) 
+{
+  //  Take into account the coupling between adiacent pixels.
+  //  The parameters probcol and probrow are the fractions of the
+  //  signal in one pixel shared in the two adjacent pixels along
+  //  the column and row direction, respectively.
+  //Begin_Html
+  /*
+    
+    
+
+ + . + +
+  */
+  //End_Html
+  // Inputs:
+  // old            existing AliITSUSDigit
+  // ntrack         track incex number
+  // idhit          hit index number
+  // module         module number
+  //
+  UInt_t col,row;
+  Double_t pulse1,pulse2;
+  Double_t couplR=0.0,couplC=0.0;
+  //
+  fSensMap->GetMapIndex(old->GetUniqueID(),col,row);
+  fSimuParam->GetPixUpgCouplingParam(couplC,couplR);
+  if (GetDebug(3)) Info("SetCouplingOld","(col=%d,row=%d,ntrack=%d,idhit=%d) "
+                        "Calling SetCoupling couplC=%e couplR=%e",
+                        col,row,ntrack,idhit,couplC,couplR);
+  //
+  for (Int_t isign=-1;isign<=1;isign+=2) {// loop in col direction
+    pulse2 = pulse1 = old->GetSignal();
+    //
+    int j1 = int(col)+isign;
+    pulse1 *= couplC;
+    if ((j1<0)||(j1>fSeg->Npz()-1)||(pulse1GetPixUpgThreshold(fModule))) pulse1 = old->GetSignal();
+    else UpdateMapSignal(UInt_t(j1),row,ntrack,idhit,pulse1);
+
+    // loop in row direction
+    int j2 = int(row) + isign;
+    pulse2 *= couplR;
+    if ((j2<0)||(j2>(fSeg->Npx()-1))||(pulse2GetPixUpgThreshold(fModule))) pulse2 = old->GetSignal();
+    else UpdateMapSignal(col,UInt_t(j2),ntrack,idhit,pulse2);
+  } // for isign
+}
+
+//______________________________________________________________________
+void AliITSUSimulationPix::GenerateStrobePhase()
+{
+  // Generate randomly the strobe
+  // phase w.r.t to the LHC clock
+  // Done once per event
+  const Double_t kBunchLenght = 25e-9; // LHC clock
+  fStrobePhase = ((Double_t)gRandom->Integer(fStrobeLenght))*kBunchLenght-
+    (Double_t)fStrobeLenght*kBunchLenght+
+    kBunchLenght/2;
+}
+
diff --git a/ITS/UPGRADE/AliITSUSimulationPix.h b/ITS/UPGRADE/AliITSUSimulationPix.h
new file mode 100644
index 00000000000..b84b81c3109
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUSimulationPix.h
@@ -0,0 +1,66 @@
+#ifndef ALIITSUSIMULATIONPIX_H
+#define ALIITSUSIMULATIONPIX_H
+
+/* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+* See cxx source for full Copyright notice                               */
+
+////////////////////////////////////////////////////////////
+// Simulation class for upgrade pixels                    //
+////////////////////////////////////////////////////////////
+
+#include "TObjArray.h"
+#include "AliITSUSimulation.h"
+#include "AliITSUSegmentationPix.h"
+
+class TH1F;
+class AliITSUModule;
+class AliITSUSimuParam;
+
+//-------------------------------------------------------------------
+
+class AliITSUSimulationPix : public AliITSUSimulation {
+public:
+  AliITSUSimulationPix();
+  AliITSUSimulationPix(AliITSUSimuParam* sim,AliITSUSensMap* map);
+  virtual ~AliITSUSimulationPix();
+  AliITSUSimulationPix(const AliITSUSimulationPix &source); 
+  AliITSUSimulationPix& operator=(const AliITSUSimulationPix &s);
+  void Init();
+  //
+  void FinishSDigitiseModule();
+  void DigitiseModule(AliITSUModule *mod,Int_t mask, Int_t event, AliITSsegmentation* seg);
+  //
+  void SDigitiseModule(AliITSUModule *mod, Int_t mask, Int_t event, AliITSsegmentation* seg);
+  void WriteSDigits();
+  void Hits2SDigits(AliITSUModule *mod);
+  void Hits2SDigitsFast(AliITSUModule *mod);
+  void AddNoisyPixels();   
+  void RemoveDeadPixels();
+  void FrompListToDigits();
+  Int_t CreateNoisyDigits(Int_t minID,Int_t maxID,double probNoisy, double noise, double base);
+  Bool_t SetTanLorAngle(Double_t WeightHole=1.0);
+  Double_t GetTanLorAngle() const {return fTanLorAng;};
+  //
+  // For backwards compatibility
+  void SDigitsToDigits(){ FinishSDigitiseModule();}
+  
+  // This sets fStrobe flag and allows generating the strobe and applying it to select hits 
+  void SetStrobeGeneration(Bool_t b=kFALSE) {fStrobe=b;};
+  void GenerateStrobePhase();
+  //
+  
+ private:
+  void SpreadCharge(Double_t x0,Double_t z0,Int_t ix0,Int_t iz0,Double_t el,Double_t sig,Double_t ld,Int_t t,Int_t hi);
+  void SpreadChargeAsym(Double_t x0,Double_t z0,Int_t ix0,Int_t iz0,Double_t el,Double_t sigx,Double_t sigz,Double_t ld,Int_t t,Int_t hi);
+  //
+  void SetCoupling(AliITSUSDigit* old,Int_t ntrack,Int_t idhit);     // "New" coupling routine  Tiziano Virgili
+  void SetCouplingOld(AliITSUSDigit* old,Int_t ntrack,Int_t idhit);  // "Old" coupling routine  Rocco Caliandro
+  //   
+ protected:
+   Double_t      fTanLorAng;    //! Tangent of the Lorentz Angle (weighted average for hole and electrons)
+   Bool_t        fStrobe;       // kTRUE if readout strobe with proper phase applied to select hits
+   Int_t         fStrobeLenght; // Strobe signal lenght in units of 25 ns
+   Double_t      fStrobePhase;  // The phase of the strobe signal with respect to the trigger
+   ClassDef(AliITSUSimulationPix,1)  // Simulation of pixel clusters
+ };
+#endif 
diff --git a/ITS/UPGRADE/AliITSUpg.cxx b/ITS/UPGRADE/AliITSUpg.cxx
deleted file mode 100644
index 1325c7d56bb..00000000000
--- a/ITS/UPGRADE/AliITSUpg.cxx
+++ /dev/null
@@ -1,1393 +0,0 @@
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
-
-/* $Id: AliITSUpg.cxx $ */
-
-
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-//      An overview of the basic philosophy of the ITS code development      //
-// and analysis is show in the figure below.                                 //
-//Begin_Html                                                                 //
-/*                                               
-
-
-
- -

Roberto Barbera is in charge of the ITS Offline code (1999). -Roberto Barbera. - -

-*/
-//End_Html
-//
-//  AliITSUpg. Inner Traking System base class.
-//  This class contains the base procedures for the Inner Tracking System
-//
-//Begin_Html
-/*
-
-
-
- -

This show the class diagram of the different elements that are part of -the AliITS class. - -

-*/
-//End_Html
-//
-// Version: 0
-// Written by Rene Brun, Federico Carminati, and Roberto Barbera
-//
-// Version: 1
-// Modified and documented by Bjorn S. Nilsen
-// July 11 1999
-//
-// Version: 2
-// Modified and documented by A. Bologna
-// October 18 1999
-//
-// AliITSUpg is the general base class for the ITS. Also see AliDetector for
-// futher information.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "AliDetector.h"
-#include "AliITSUpg.h"
-#include "AliITSDetTypeSim.h"
-#include "AliITSDDLRawData.h"
-#include "AliITSLoader.h"
-#include "AliITSLoaderUpg.h"
-#include "AliITShit.h"
-#include "AliITSmodule.h"
-#include "AliITSpListItem.h"
-#include "AliITSsimulation.h"
-#include "AliITSsimulationFastPoints.h"
-#include "AliMC.h"
-#include "AliITSDigitizer.h"
-#include "AliITSRecPoint.h"
-#include "AliITSsegmentationSPD.h"
-#include "AliITSsegmentationSDD.h"
-#include "AliITSsimulationSDD.h"
-#include "AliITSCalibrationSDD.h"
-#include "AliITSCalibrationSSD.h"
-#include "AliITSsegmentationSSD.h"
-#include "AliITSRawStreamSPD.h"
-#include "AliITSRawStreamSSD.h"
-#include "AliITSRawStreamSDD.h"
-#include "AliRawReader.h"
-#include "AliRun.h"
-#include "AliLog.h"
-#include "AliITSInitGeometryUpg.h"
-#include "AliITSFOSignalsSPD.h"
-
-ClassImp(AliITSUpg)
-
-//______________________________________________________________________
-AliITSUpg::AliITSUpg() : AliDetector(),
-fDetTypeSim(0),
-fEuclidOut(0),
-fOpt("All"),
-fIdN(0),
-fIdSens(0),
-fIdName(0),
-fITSmodules(0),
-fTiming(kFALSE),
-fSimuParam(0),
-fModA(0),
-fpSDigits(0)
-{
-  // Default initializer for ITS
-  //      The default constructor of the AliITS class. In addition to
-  // creating the AliITS class it zeros the variables fIshunt (a member
-  // of AliDetector class), fEuclidOut, and fIdN, and zeros the pointers
-  // fIdSens, and fIdName. The AliDetector default constructor
-  // is also called.
-  
-//    SetDetectors(); // default to fOpt="All". This variable not written out.
-//PH    SetMarkerColor(kRed);
-}
-//______________________________________________________________________
-AliITSUpg::AliITSUpg(const Char_t *title):
-  AliDetector("ITS",title),
-  fDetTypeSim(0),
-  fEuclidOut(0),
-  fOpt("All"),
-  fIdN(0),
-  fIdSens(0),
-  fIdName(0),
-  fITSmodules(0),
-  fTiming(kFALSE),
-  fSimuParam(0),
-  fModA(0),
-  fpSDigits(0)
-{
-    //     The standard Constructor for the ITS class. 
-    // It also zeros the variables
-    // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
-    // the pointers fIdSens and fIdName. To help in displaying hits via the
-    // ROOT macro display.C AliITS also sets the marker color to red. The
-    // variables passes with this constructor, const char *name and *title,
-    // are used by the constructor of AliDetector class. See AliDetector
-    // class for a description of these parameters and its constructor
-    // functions.
-    // Inputs:
-    //   Char_t *title  Simulation title for the ITS
-    // Outputs:
-    //   none.
-    // Return:
-    //   none.
-  
-    fHits = new TClonesArray("AliITShit",1560); // from AliDetector
-    if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
-    //fNhits=0;  //done in AliDetector(name,title)
-    SetDetectors(); // default to fOpt="All". This variable not written out.
-    fDetTypeSim   = new AliITSDetTypeSim();
-    //PH  SetMarkerColor(kRed);
-    if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
-    fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-}
-//______________________________________________________________________
-AliITSUpg::AliITSUpg(const char *name, const char *title):
-  AliDetector(name,title),
-  fDetTypeSim(0),
-  fEuclidOut(0),
-  fOpt("All"),
-  fIdN(0),
-  fIdSens(0),
-  fIdName(0),
-  fITSmodules(0),
-  fTiming(kFALSE),
-  fSimuParam(0),
-  fModA(0),
-  fpSDigits(0)
-{
-  //     The standard Constructor for the ITS class. 
-  // It also zeros the variables
-  // fIshunt (a member of AliDetector class), fEuclidOut, and zeros
-  // the pointers fIdSens and fIdName. To help in displaying hits via the
-  // ROOT macro display.C AliITS also sets the marker color to red. The
-  // variables passes with this constructor, const char *name and *title,
-  // are used by the constructor of AliDetector class. See AliDetector
-  // class for a description of these parameters and its constructor
-  // functions.
-  
-  fHits = new TClonesArray("AliITShit",1560);
-  if(gAlice->GetMCApp()) gAlice->GetMCApp()->AddHitList(fHits);
-  //fNhits=0;  //done in AliDetector(name,title)
-
-  SetDetectors(); // default to fOpt="All". This variable not written out.
-    
-  fDetTypeSim   = new AliITSDetTypeSim();
-  //PH  SetMarkerColor(kRed);
-  if(!fLoader) MakeLoader(AliConfig::GetDefaultEventFolderName());
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-
-}
-//______________________________________________________________________
-AliITSUpg::~AliITSUpg(){
-    // Default destructor for ITS.
-    //     The default destructor of the AliITS class. In addition to deleting
-    // the AliITS class it deletes the memory pointed to by 
-    // fIdSens, fIdName, fDetTypeSim and it's contents.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-
-    if (fHits) {
-      fHits->Delete();
-      delete fHits;
-      fHits=0;
-    }
-    if(fITSmodules) {
-        this->ClearModules();
-        delete fITSmodules;
-	fITSmodules = 0;
-    }// end if fITSmodules!=0
-
-    delete[] fIdName;  // Array of TStrings
-    delete[] fIdSens;
-    Int_t size   = AliITSgeomTGeo::GetNModules();
-    if (fDetTypeSim){
-      delete fDetTypeSim;
-      fDetTypeSim = 0;
-    }
-    if(fSimuParam){
-      delete fSimuParam;
-      fSimuParam=0;
-    }
-    if(fModA){
-      if(size>0){
-	for(Int_t j=0; jDelete();
-	  delete fModA[j];
-	}
-      }
-      delete []fModA;
-    }
-    if(fpSDigits){
-      fpSDigits->Delete();
-      delete fpSDigits;
-    }
-}
-
-//______________________________________________________________________
-AliDigitizer* AliITSUpg::CreateDigitizer(AliDigitizationInput* manager)const{
-    // Creates the AliITSDigitizer in a standard way for use via AliModule.
-    // This function can not be included in the .h file because of problems
-    // with the order of inclusion (recursive).
-    // Inputs:
-    //    AliDigitizationInput *manager  The Manger class for Digitization
-    // Output:
-    //    none.
-    // Return:
-    //    A new AliITSRunDigitizer (cast as a AliDigitizer).
-
-     return new AliITSDigitizer(manager);
-}
-//______________________________________________________________________
-void AliITSUpg::Init(){
-    // Initializer ITS after it has been built
-    //     This routine initializes the AliITS class. It is intended to be
-    // called from the Init function in AliITSv?. Besides displaying a banner
-    // indicating that it has been called it initializes the array fIdSens
-    // and sets the default segmentation, response, digit and raw cluster
-    // classes therefore it should be called after a call to CreateGeometry.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-    Int_t i;
-    // Array of TStrings
-    if(gMC) for(i=0;iVolId(fIdName[i]);
- 
-}
-//______________________________________________________________________
-void AliITSUpg::SetDefaults(){
-    // sets the default segmentation, response, digit and raw cluster classes.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-    AliInfoClass("AliITSUpg::Setting Defaults");
-    if(!fDetTypeSim) { 
-     Error("SetDefaults()","fDetTypeSim is 0!"); 
-     return;
-    }
-
-    fDetTypeSim->SetDefaults();
-    if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-
-}
-//______________________________________________________________________
-void AliITSUpg::SetDefaultSimulation(){
-    // sets the default simulation.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-    if(!fDetTypeSim) { 
-     Error("SetDefaultSimulation()","fDetTypeSim is 0!"); 
-     return;
-    }
-
-    fDetTypeSim->SetDefaultSimulation();
-    if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-
-}
-
-
-//______________________________________________________________________
-void AliITSUpg::MakeBranch(Option_t* option){
-    // Creates Tree branches for the ITS.
-    // Inputs:
-    //      Option_t *option    String of Tree types S,D, and/or R.
-    //      const char *file    String of the file name where these branches
-    //                          are to be stored. If blank then these branches
-    //                          are written to the same tree as the Hits were
-    //                          read from.
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-  if(!fDetTypeSim) {
-    Error("MakeBranch","fDetTypeSim is 0!");
-    return;
-  }
-
-  Bool_t cH = (strstr(option,"H")!=0);
-  Bool_t cS = (strstr(option,"S")!=0);
-  Bool_t cD = (strstr(option,"D")!=0);
-  
-  if(cH && (fHits == 0x0)) fHits = new TClonesArray("AliITShit", 1560);
-  AliDetector::MakeBranch(option);
-  
-  if(cS) MakeBranchS(0);
-  if(cD) MakeBranchD(0);
-
-
-}
-//___________________________________________________________________
-void AliITSUpg::MakeBranchS(const char* fl){
-
-  // Creates Tree Branch for the ITS summable digits.
-  // Inputs:
-  //      cont char *fl  File name where SDigits branch is to be written
-  //                     to. If blank it write the SDigits to the same
-  //                     file in which the Hits were found.
-
-  
-  if(!fDetTypeSim){
-    Error("MakeBranchS","fDetTypeSim is 0!");
-  }
-  Int_t buffersize = 4000;
-  char branchname[31];
-
-  // only one branch for SDigits.
-  snprintf(branchname,30,"%s",GetName());
-
-  if(fLoader->TreeS()){
-    TClonesArray* sdig = (TClonesArray*)fDetTypeSim->GetSDigits();
-    MakeBranchInTree(fLoader->TreeS(),branchname,&sdig,buffersize,fl);
-  } 
-}
-//______________________________________________________________________
-void AliITSUpg::MakeBranchD(const char* file){
-
-  //Make branch for digits
-  if(!fDetTypeSim) {
-    Warning("MakeBranchD","fDetTypeSim is 0!");
-    return;
-  }
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-  MakeBranchInTreeD(fLoader->TreeD(),file);
-}
-
-//___________________________________________________________________
-void AliITSUpg:: MakeBranchInTreeD(TTree* treeD, const char* file){
-  // Creates Tree branches for the ITS.
-
-  if(!fDetTypeSim){
-    Error("MakeBranchS","fDetTypeSim is 0!");
-  }
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-
-  const Char_t *det[3] = {"SPD","SDD","SSD"};
-  const Char_t* digclass;
-  Int_t buffersize = 4000;
-  Char_t branchname[31];
-  
-  if(!fDetTypeSim->GetDigits()){
-    fDetTypeSim->SetDigits(new TObjArray(fgkNTYPES));
-  }
-  for(Int_t i=0;iGetDigitClassName(i);
-    TString classn = digclass;
-    if(!((fDetTypeSim->GetDigits())->At(i))){
-      (fDetTypeSim->GetDigits())->AddAt(new TClonesArray(classn.Data(),1000),i);
-    }
-    else ResetDigits(i);  
-    if(fgkNTYPES==3) snprintf(branchname,30,"%sDigits%s",GetName(),det[i]);
-    else sprintf(branchname,"%sDigits%d",GetName(),i+1);
-    TObjArray* dig = DigitsAddress(i);
-    if(GetDigits() && treeD) AliDetector::MakeBranchInTree(treeD,branchname, &dig,buffersize,file);
-  }
-
-}
-//______________________________________________________________________
-void AliITSUpg::SetTreeAddress(){
-    // Set branch address for the Trees.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-    
-  if(!fDetTypeSim) {
-    Error("SetTreeAddress","fDetTypeSim is 0!");
-    return;
-  }
-
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-
-  TTree *treeS = fLoader->TreeS();
-  TTree *treeD = fLoader->TreeD();
-  if (fLoader->TreeH() && (fHits == 0x0)) {
-      fHits = new TClonesArray("AliITShit", 1560);
-  }
-  AliDetector::SetTreeAddress();
-
-  fDetTypeSim->SetTreeAddressS(treeS, (Char_t*)GetName());
-  fDetTypeSim->SetTreeAddressD(treeD, (Char_t*)GetName());
-}
-//______________________________________________________________________
-void AliITSUpg::AddHit(Int_t track, Int_t *vol, Float_t *hits){
-    // Add an ITS hit
-    //     The function to add information to the AliITShit class. See the
-    // AliITShit class for a full description. This function allocates the
-    // necessary new space for the hit information and passes the variable
-    // track, and the pointers *vol and *hits to the AliITShit constructor
-    // function.
-    // Inputs:
-    //      Int_t   track   Track number which produced this hit.
-    //      Int_t   *vol    Array of Integer Hit information. See AliITShit.h
-    //      Float_t *hits   Array of Floating Hit information.  see AliITShit.h
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-  TClonesArray &lhits = *fHits;
-  new(lhits[fNhits++]) AliITShit(fIshunt,track,vol,hits);
-}
-
-//______________________________________________________________________
-void AliITSUpg::FillModules(Int_t /* evnt */,Int_t bgrev,Int_t /* nmodules */,
-                         Option_t *option, const char *filename){
-  // fill the modules with the sorted by module hits; add hits from
-  // background if option=Add.
-
-  static TTree *trH1;                 //Tree with background hits
-  static Bool_t first=kTRUE;
-  static TFile *file;
-  const char *addBgr = strstr(option,"Add");
-  
-  if (addBgr ) {
-    if(first) {
-      file=new TFile(filename);
-    } // end if first
-    first=kFALSE;
-    file->cd();
-    file->ls();
-    // Get Hits Tree header from file
-    if(trH1) delete trH1;
-    trH1=0;
-    
-    char treeName[21];
-    snprintf(treeName,20,"TreeH%d",bgrev);
-    trH1 = (TTree*)gDirectory->Get(treeName);
-    if (!trH1) {
-      Error("FillModules","cannot find Hits Tree for event:%d",bgrev);
-    } // end if !trH1
-    // Set branch addresses
-  } // end if addBgr
-  
-  FillModules(fLoader->TreeH(),0); // fill from this file's tree.
-    
-  if (addBgr ) {
-    FillModules(trH1,10000000); // Default mask 10M.
-    TTree *fAli=fLoader->GetRunLoader()->TreeK();
-    TFile *fileAli=0;
-    if (fAli) {
-      fileAli =fAli->GetCurrentFile();
-      fileAli->cd();
-    }
-  } // end if add
-  
-  
-}
-//______________________________________________________________________
-void AliITSUpg::FillModules(TTree *treeH, Int_t mask) {
-    // fill the modules with the sorted by module hits; 
-    // can be called many times to do a merging
-    // Inputs:
-    //      TTree *treeH  The tree containing the hits to be copied into
-    //                    the modules.
-    //      Int_t mask    The track number mask to indecate which file
-    //                    this hits came from.
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-
-    if (treeH == 0x0)
-     {
-       AliError("Tree H  is NULL");
-       return;
-     }
-    Int_t lay,lad,det,index;
-    AliITShit *itsHit=0;
-    AliITSmodule *mod=0;
-    char branchname[21];
-    snprintf(branchname,20,"%s",GetName());
-    TBranch *branch = treeH->GetBranch(branchname);
-    if (!branch) {
-        Error("FillModules","%s branch in TreeH not found",branchname);
-        return;
-    } // end if !branch
-    branch->SetAddress(&fHits);
-    Int_t nTracks =(Int_t) treeH->GetEntries();
-    Int_t iPrimTrack,h;
-    for(iPrimTrack=0; iPrimTrackGetEvent(iPrimTrack);
-        if (nBytes <= 0) continue;
-        Int_t nHits = fHits->GetEntriesFast();
-        for(h=0; hUncheckedAt(h);
-            itsHit->GetDetectorID(lay,lad,det);
-            if (GetITSgeom()) {
-                index = GetITSgeom()->GetModuleIndex(lay,lad,det);
-            } else {
-                index=det-1; // This should not be used.
-            } // end if [You must have fITSgeom for this to work!]
-            mod = GetModule(index);
-            itsHit->SetTrack(itsHit->GetTrack()+mask); // Set track mask.
-            mod->AddHit(itsHit,iPrimTrack,h);
-        } // end loop over hits 
-    } // end loop over tracks
-}
-
-//______________________________________________________________________
-Bool_t AliITSUpg::InitModules(Int_t size,Int_t &nmodules){
-    // Initialize the modules array.
-    // Inputs:
-    //      Int_t size  Size of array of the number of modules to be
-    //                  created. If size <=0 then the number of modules
-    //                  is gotten from AliITSgeom class kept in fITSgeom.
-    // Outputs:
-    //      Int_t &nmodules The number of modules existing.
-    // Return:
-    //      none.
-
-    if(fITSmodules){ 
-        fITSmodules->Delete();
-        delete fITSmodules;
-    } // end fir fITSmoudles
-
-    if(!fDetTypeSim) {
-      Error("InitModules","fDetTypeSim is null!");
-      return kFALSE;
-    }
-    if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-
-    Int_t nl,indexMAX,index;
-
-    if(size<=0){ // default to using data stored in AliITSgeom
-        if(fDetTypeSim->GetITSgeom()==0) {
-            Error("InitModules","fITSgeom not defined");
-            return kFALSE;
-        } // end if fITSgeom==0
-        nl = fDetTypeSim->GetITSgeom()->GetNlayers();
-        indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax();
-        nmodules = indexMAX;
-        fITSmodules = new TObjArray(indexMAX);
-        for(index=0;indexAddAt( new AliITSmodule(index),index);
-        } // end for index
-    }else{
-        fITSmodules = new TObjArray(size);
-        for(index=0;indexAddAt( new AliITSmodule(index),index);
-        } // end for index
-
-        nmodules = size;
-    } // end i size<=0
-    return kTRUE;
-}
-//______________________________________________________________________
-void AliITSUpg::Hits2SDigits(){
-    // Standard Hits to summable Digits function.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-  
-
-   if(!fDetTypeSim) {
-     Error("Hits2SDigits","fDetTypeSim is null!");
-     return; 
-  } 
-     
-  SetDefaults();
-  fLoader->LoadHits("read");
-  fLoader->LoadSDigits("recreate");
-  AliRunLoader* rl = fLoader->GetRunLoader(); 
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-
-  for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
-        // Do the Hits to Digits operation. Use Standard input values.
-        // Event number from file, no background hit merging , use size from
-        // AliITSgeom class, option="All", input from this file only.
-    rl->GetEvent(iEvent);
-    if (!fLoader->TreeS()) fLoader->MakeTree("S");
-    MakeBranch("S");
-    SetTreeAddress();
-    HitsToPreDigits(iEvent,0,-1," ",fOpt," ");
-  } // end for iEvent
-    
-  fLoader->UnloadHits();
-  fLoader->UnloadSDigits();
-  
-}
-//______________________________________________________________________
-void AliITSUpg::Hits2Digits(){
-
-  //Conversion from hits to digits
-  if(!fDetTypeSim) {
-    Error("Hits2SDigits","fDetTypeSim is 0!");
-    return;
-  }
-   
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-  SetDefaults();
-
-  fLoader->LoadHits("read");
-  fLoader->LoadDigits("recreate");
-  AliRunLoader* rl = fLoader->GetRunLoader(); 
-  for (Int_t iEvent = 0; iEvent < rl->GetNumberOfEvents(); iEvent++) {
-    rl->GetEvent(iEvent);
-    if (!fLoader->TreeD()) fLoader->MakeTree("D");
-    MakeBranch("D");
-    SetTreeAddress();   
-    HitsToDigits(iEvent,0,-1," ",fOpt," ");
-  } 
-  
-  fLoader->UnloadHits();
-  fLoader->UnloadDigits();
-  
-}
-
-//______________________________________________________________________
-void AliITSUpg::HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
-                          Option_t *option,Option_t *opt,
-                          const char *filename){
-    //   Keep galice.root for signal and name differently the file for 
-    // background when add! otherwise the track info for signal will be lost !
-    // the condition below will disappear when the geom class will be
-    // initialized for all versions - for the moment it is only for v5 !
-    // 7 is the SDD beam test version.
-    // Inputs:
-    //      Int_t evnt       Event to be processed.
-    //      Int_t bgrev      Background Hit tree number.
-    //      Int_t nmodules   Not used.
-    //      Option_t *option String indicating if merging hits or not. To
-    //                       merge hits set equal to "Add". Otherwise no
-    //                       background hits are considered.
-    //      Test_t *filename File name containing the background hits..
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-
-  if(!fDetTypeSim) {
-    Error("HitsToDigits","fDetTypeSim is null!");
-    return;
-  }
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-  if(!GetITSgeom()) return; // need transformations to do digitization.
-  AliITSgeom *geom = GetITSgeom();
-
-  const char *all = strstr(opt,"All");
-  const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
-			strstr(opt,"SSD")};
-  static Bool_t setDef=kTRUE;
-  if (setDef) SetDefaultSimulation();
-  setDef=kFALSE;
-  
-  Int_t nmodules;
-  InitModules(size,nmodules);
-  FillModules(evNumber,bgrev,nmodules,option,filename);
- 
-  // Reset Fast-OR signals for this event
-//  fDetTypeSim->ResetFOSignals();
-
-  AliITSsimulation *sim      = 0;
-  AliITSmodule     *mod      = 0;
-  Int_t id;
-  for(Int_t module=0;moduleGetIndexMax();module++){
-    id       = geom->GetModuleType(module);
-    if (!all && !det[id]) continue;
-    sim      = (AliITSsimulation*)fDetTypeSim->GetSimulationModel(id);
-    if (!sim) {
-      Error("HitsToDigits","The simulation class was not "
-	    "instanciated for module %d type %s!",module,
-	    geom->GetModuleTypeName(module));
-      exit(1);
-    } // end if !sim
-    mod      = (AliITSmodule *)fITSmodules->At(module);
-    sim->DigitiseModule(mod,module,evNumber);
-    // fills all branches - wasted disk space
-    fLoader->TreeD()->Fill(); 
-    ResetDigits();
-  } // end for module
-  
-  ClearModules();
- 
-  // Add Fast-OR signals to event (only one object per event)
-  if (all || det[0]) { // SPD present
-    WriteFOSignals();
-  }
-  
-  fLoader->TreeD()->GetEntries();
-  fLoader->TreeD()->AutoSave();
-  // reset tree
-  fLoader->TreeD()->Reset();
-}
-//_____________________________________________________________________
-void AliITSUpg::Hits2PreDigits(){ 
-  // Turn hits into SDigits
-
-  if(!fDetTypeSim) {
-    Error("Hits2SDigits","fDetTypeSim is 0!");
-    return;
-  }
-   
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-  SetDefaults();
-  
-  HitsToPreDigits(fLoader->GetRunLoader()->GetEventNumber(),
-		  0,-1," ",fOpt," ");
-}
-
-//______________________________________________________________________
-void AliITSUpg::HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
-                             Option_t *option,Option_t *opt,
-                             const char *filename){
-    //   Keep galice.root for signal and name differently the file for 
-    // background when add! otherwise the track info for signal will be lost !
-    // the condition below will disappear when the geom class will be
-    // initialized for all versions - for the moment it is only for v5 !
-    // 7 is the SDD beam test version.
-    // Inputs:
-    //      Int_t evnt       Event to be processed.
-    //      Int_t bgrev      Background Hit tree number.
-    //      Int_t nmodules   Not used.
-    //      Option_t *option String indicating if merging hits or not. To
-    //                       merge hits set equal to "Add". Otherwise no
-    //                       background hits are considered.
-    //      Test_t *filename File name containing the background hits..
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-
- 
-  if(!fDetTypeSim) {
-    Error("HitsToPreDigits","fDetTypeSim is null!");
-    return;
-  }
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-
-  if(!GetITSgeom()){
-    Error("HitsToPreDigits","fGeom is null!");
-    return; // need transformations to do digitization.
-  }
-  AliITSgeom *geom = GetITSgeom();
-
-  const char *all = strstr(opt,"All");
-  const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
-			strstr(opt,"SSD")};
-  static Bool_t setDef=kTRUE;
-  if (setDef) SetDefaultSimulation();
-  setDef=kFALSE;
-  
-  Int_t nmodules;
-  InitModules(size,nmodules);
-  FillModules(evNumber,bgrev,nmodules,option,filename);
-  
-
-  AliITSsimulation *sim      = 0;
-  AliITSmodule     *mod      = 0;
-  Int_t id,module;
-  for(module=0;moduleGetIndexMax();module++){
-    id       = geom->GetModuleType(module);
-    if (!all && !det[id]) continue;
-    sim      = (AliITSsimulation*)GetSimulationModel(id);
-    if (!sim) {
-      Error("HitsToPreDigits","The simulation class was not "
-	    "instanciated for module %d type %s!",module,
-	    geom->GetModuleTypeName(module));
-      exit(1);
-    } // end if !sim
-    mod      = (AliITSmodule *)fITSmodules->At(module);
-    sim->SDigitiseModule(mod,module,evNumber);
-    // fills all branches - wasted disk space
-    fLoader->TreeS()->Fill(); 
-    fDetTypeSim->ResetSDigits();
-  } // end for module
-
-  ClearModules();
-
-  
-  fLoader->TreeS()->GetEntries();
-  fLoader->TreeS()->AutoSave();
-  fLoader->WriteSDigits("OVERWRITE");
-  // reset tree
-  fLoader->TreeS()->Reset();
-}
-
-//_____________________________________________________________________
-void AliITSUpg::HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
-                                  Option_t *opt0,Option_t *opt1,
-                                 const char *flnm){
-    // keep galice.root for signal and name differently the file for 
-    // background when add! otherwise the track info for signal will be lost !
-    // the condition below will disappear when the geom class will be
-    // initialized for all versions - for the moment it is only for v5 !
-    // Inputs:
-    //      Int_t evnt       Event to be processed.
-    //      Int_t bgrev      Background Hit tree number.
-    //      Int_t size       Size used by InitModules. See InitModules.
-    //      Option_t *opt0   Option passed to FillModules. See FillModules.
-    //      Option_t *opt1   String indicating if merging hits or not. To
-    //                       merge hits set equal to "Add". Otherwise no
-    //                       background hits are considered.
-    //      Test_t *flnm     File name containing the background hits..
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-
-
-
-  if(!GetITSgeom()){
-    Error("HitsToPreDigits","fGeom is null!");
-    return; // need transformations to do digitization.
-  }
-  AliITSgeom *geom = GetITSgeom();
-
-  AliITSLoaderUpg *pITSloader = (AliITSLoaderUpg*)fLoader;
-
-  const char *all = strstr(opt1,"All");
-  const char *det[3] ={strstr(opt1,"SPD"),strstr(opt1,"SDD"),
-		       strstr(opt1,"SSD")};
-  Int_t nmodules;
-  InitModules(size,nmodules);
-  FillModules(evNumber,bgrev,nmodules,opt0,flnm);
-
-  AliITSsimulation *sim      = 0;
-  AliITSmodule     *mod      = 0;
-  Int_t id,module;
-
-  TTree *lTR = pITSloader->TreeR();
-  if(!lTR) {
-    pITSloader->MakeTree("R");
-    lTR = pITSloader->TreeR();
-  }
-  
-  TClonesArray* ptarray = new TClonesArray("AliITSRecPoint",1000);
-  TBranch* branch = (TBranch*)lTR->Branch("ITSRecPointsF",&ptarray);
-  branch->SetAddress(&ptarray);
-  //m.b. : this change is nothing but a nice way to make sure
-  //the CPU goes up !    
-  for(module=0;moduleGetIndexMax();module++){
-    id       = geom->GetModuleType(module);
-    if (!all && !det[id]) continue;
-    sim      = (AliITSsimulation*)GetSimulationModel(id);
-    if (!sim) {
-      Error("HitsToFastPoints","The simulation class was not "
-	    "instantiated for module %d type %s!",module,
-	    geom->GetModuleTypeName(module));
-      exit(1);
-    } // end if !sim
-    mod      = (AliITSmodule *)fITSmodules->At(module);
-    sim->CreateFastRecPoints(mod,module,gRandom,ptarray);
-    lTR->Fill();
-    ptarray->Clear();
-  } // end for module
-
-  ClearModules();
-  fLoader->WriteRecPoints("OVERWRITE");
-  delete ptarray;
-}
-//_____________________________________________________________________
-Int_t AliITSUpg::Hits2Clusters(TTree *hTree, TTree *cTree) {
-  //------------------------------------------------------------
-  // This function creates ITS clusters
-  //------------------------------------------------------------
-  if(!GetITSgeom()){
-    Error("HitsToPreDigits","fGeom is null!");
-    return 1; // need transformations to do digitization.
-  }
-  AliITSgeom *geom=GetITSgeom();
-  Int_t mmax=geom->GetIndexMax();
-
-  InitModules(-1,mmax);
-  FillModules(hTree,0);
-
-  TClonesArray *points = new TClonesArray("AliITSRecPoint",1000);
-  TBranch *branch=cTree->GetBranch("ITSRecPoints");
-  if (!branch) cTree->Branch("ITSRecPoints",&points);
-  else branch->SetAddress(&points);
-
-  AliITSsimulationFastPoints sim;
-  Int_t ncl=0;
-  for (Int_t m=0; mGetEntriesFast();
-    cTree->Fill();
-    points->Clear();
-  }
-
-  AliDebug(1,Form("Number of found fast clusters : %d",ncl));
-
-  //cTree->Write();
-
-  delete points;
-  return 0;
-}
-
-//_____________________________________________________________________
-void AliITSUpg::CheckLabels(Int_t lab[3]) const {
-  //------------------------------------------------------------
-  // Tries to find mother's labels
-  //------------------------------------------------------------
-
-  if(lab[0]<0 && lab[1]<0 && lab[2]<0) return; // In case of no labels just exit
-
-  Int_t ntracks = gAlice->GetMCApp()->GetNtrack();
-  for (Int_t i=0;i<3;i++){
-    Int_t label = lab[i];
-    if (label>=0 && labelGetMCApp()->Particle(label);
-      if (part->P() < 0.005) {
-	Int_t m=part->GetFirstMother();
-	if (m<0) {	
-	  continue;
-	}
-	if (part->GetStatusCode()>0) {
-	  continue;
-	}
-	lab[i]=m;       
-      }
-    }    
-  }
-  
-}
-
-//______________________________________________________________________
-void AliITSUpg::SDigitsToDigits(Option_t *opt){
-  // Standard Summable digits to Digits function.
-  // Inputs:
-  //      none.
-  // Outputs:
-  //      none.
-  if (!fDetTypeSim) {
-    AliError("fDetTypeSim is 0!");
-    return;
-  }
-  const char *all = strstr(opt,"All");
-  const char *det[3] ={strstr(opt,"SPD"),strstr(opt,"SDD"),
-		       strstr(opt,"SSD")};
-
-  // Reset Fast-OR signals for this event
-//  fDetTypeSim->ResetFOSignals();
-
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  SetDefaults();
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-  fDetTypeSim->SDigitsToDigits(opt,(Char_t*)GetName());
-
-  // Add Fast-OR signals to event (only one object per event)
-  if (all || det[0]) { // SPD present
-   WriteFOSignals();
-  }
-}
-
-//______________________________________________________________________
-void AliITSUpg::ResetDigits(){
-    // Reset number of digits and the digits array for the ITS detector.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-    if(!fDetTypeSim) {
-      Error("ResetDigits","fDetTypeSim is 0!");
-      return;
-    }
-   
-    fDetTypeSim->ResetDigits();
-
-
-}
-//______________________________________________________________________
-void AliITSUpg::ResetDigits(Int_t branch){
-    // Reset number of digits and the digits array for this branch.
-    // Inputs:
-    //      none.
-    // Outputs:
-    //      none.
-
-    if(!fDetTypeSim) {
-      Error("ResetDigits","fDetTypeSim is 0!");
-      return;
-    }
-   
-    fDetTypeSim->ResetDigits(branch);
-
-}
-//______________________________________________________________________
-void AliITSUpg::AddSumDigit(AliITSpListItem &sdig){
-    // Adds the a module full of summable digits to the summable digits tree.
-    // Inputs:
-    //      AliITSpListItem &sdig   SDigit to be added to SDigits tree.
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-
-    if(!fDetTypeSim) {
-      Error("AddSumDigit","fDetTypeSim is 0!");
-      return;
-    }
-    fDetTypeSim->AddSumDigit(sdig);
-    
-}
-//______________________________________________________________________
-void AliITSUpg::AddSimDigit(Int_t branch, AliITSdigit *d){
-    //    Add a simulated digit.
-    // Inputs:
-    //      Int_t id        Detector type number.
-    //      AliITSdigit *d  Digit to be added to the Digits Tree. See 
-    //                      AliITSdigit.h
-    // Outputs:
-    //      none.
-    // Return:
-    //      none.
-
-    if(!fDetTypeSim) {
-      Error("AddSimDigit","fDetTypeSim is 0!");
-      return;
-    }
-    fDetTypeSim->AddSimDigit(branch,d);
-
-}
-//______________________________________________________________________
-void AliITSUpg::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,Int_t *tracks,
-                         Int_t *hits,Float_t *charges, Int_t sigexpanded){
-  //   Add a simulated digit to the list.
-  // Inputs:
-  //      Int_t id        Detector type number.
-  //      Float_t phys    Physics indicator. See AliITSdigits.h
-  //      Int_t *digits   Integer array containing the digits info. See 
-  //                      AliITSdigit.h
-  //      Int_t *tracks   Integer array [AliITSdigitS?D::GetNTracks()] 
-  //                      containing the track numbers that contributed to
-  //                      this digit.
-  //      Int_t *hits     Integer array [AliITSdigitS?D::GetNTracks()]
-  //                      containing the hit numbers, from AliITSmodule, that
-  //                      contributed to this digit.
-  //      Float_t *charge Floating point array of the signals contributed
-  //                      to this digit by each track.
-  // Outputs:
-  //      none.
-  // Return:
-  //      none.
-
-    if(!fDetTypeSim) {
-      Error("AddSimDigit","fDetTypeSim is 0!");
-      return;
-    }
-    fDetTypeSim->AddSimDigit(branch,phys,digits,tracks,hits,charges,sigexpanded);
-
-}
-//______________________________________________________________________
-void AliITSUpg::Digits2Raw(){
-    // convert digits of the current event to raw data
-
-  if(!fDetTypeSim) {
-    Error("Digits2Raw","fDetTypeSim is 0!");
-    return;
-  }
-  fDetTypeSim->SetLoader((AliITSLoader*)fLoader);
-  SetDefaults();
-  if(fSimuParam) fDetTypeSim->SetSimuParam(fSimuParam);
-  fDetTypeSim->GetLoader()->LoadDigits();
-  TTree* digits = fDetTypeSim->GetLoader()->TreeD();
-  if (!digits) {
-      Error("Digits2Raw", "no digits tree");
-      return;
-  }
-  fDetTypeSim->SetTreeAddressD(digits,(Char_t*)GetName());
-  
-   // Get the FO signals for this event
-  AliITSFOSignalsSPD* foSignals = NULL;
-  AliRunLoader* runLoader = AliRunLoader::Instance();
-  AliITSLoaderUpg* itsLoader = (AliITSLoaderUpg*) runLoader->GetLoader("ITSLoader");
-  if (!itsLoader) {
-    AliError("ITS loader is NULL.");
-  }
-   else {
-      if(!itsLoader->TreeD()) AliError("   !!! No TreeD available !!!");
-      foSignals = (AliITSFOSignalsSPD*)itsLoader->TreeD()->GetUserInfo()->FindObject("AliITSFOSignalsSPD");
-      if(!foSignals) AliError("FO signals not retrieved");
-     }
- 
-  Bool_t deleteFOsignalsLater = kFALSE;
-  if (!foSignals) {
-    AliError("FO signals not available. No FO bits will be written.");
-    foSignals = new AliITSFOSignalsSPD(); // make a temporary dummy signals object
-    deleteFOsignalsLater = kTRUE;
-  }
-  
-  
-//  AliITSDDLModuleMapSDD* ddlsdd=fDetTypeSim->GetDDLModuleMapSDD();
-  Char_t rawSDD=fDetTypeSim->GetSimuParam()->GetSDDRawDataFormat();
-  AliITSDDLRawData rawWriter;
-  
-  rawWriter.SetSDDRawFormat(rawSDD);
-  //Verbose level
-  // 0: Silent
-  // 1: cout messages
-  // 2: txt files with digits 
-  //BE CAREFUL, verbose level 2 MUST be used only for debugging and
-  //it is highly suggested to use this mode only for debugging digits files
-  //reasonably small, because otherwise the size of the txt files can reach
-  //quickly several MB wasting time and disk space.
-  rawWriter.SetVerbose(0);
-    
-  //SILICON PIXEL DETECTOR
-  AliDebug(1,"Formatting raw data for SPD");
-  rawWriter.RawDataSPD(digits->GetBranch("ITSDigitsSPD"),foSignals);
-  if(deleteFOsignalsLater) delete foSignals;
-    
-  //SILICON DRIFT DETECTOR
-  AliDebug(1,Form("Formatting raw data for SDD - Format code =%d",rawSDD));
-//  rawWriter.RawDataSDD(digits->GetBranch("ITSDigitsSDD"),ddlsdd);
-    
-  //SILICON STRIP DETECTOR
-  AliDebug(1,"Formatting raw data for SSD");
-  rawWriter.RawDataSSD(digits->GetBranch("ITSDigitsSSD"));
-
-  fLoader->UnloadDigits();
-}
-//______________________________________________________________________
-AliLoader* AliITSUpg::MakeLoader(const char* topfoldername){ 
-    //builds ITSgetter (AliLoader type)
-    //if detector wants to use castomized getter, it must overload this method
-
-    AliDebug(1,Form("Creating AliITSLoaderUpg. Top folder is %s.",
-         topfoldername));
-    fLoader = new AliITSLoaderUpg(GetName(),topfoldername);
-    return fLoader;
-}
-//______________________________________________________________________
-Bool_t AliITSUpg::Raw2SDigits(AliRawReader* rawReader)
-{
-  //
-  // Converts RAW data to SDigits
-  //
-  // Get TreeS
-  //
-  Int_t last   = -1;
-  Int_t size   = AliITSgeomTGeo::GetNModules();
-  if(!fModA) {
-    fModA = new TClonesArray*[size];
-    for (Int_t mod = 0; mod < size; mod++) fModA[mod] = new TClonesArray("AliITSpListItem", 10000);
-  }
-  AliLoader* loader =  (AliRunLoader::Instance())->GetLoader("ITSLoader");
-  if (!loader){
-    Error("Open","Can not get ITS loader from Run Loader");
-    return kFALSE;
-  }
-
-  TTree* tree = 0;
-  tree = loader->TreeS();
-  if (!tree){
-    loader->MakeTree("S");
-    tree = loader->TreeS();
-  }
-  //
-  // Array for SDigits
-  // 
-  if(!fpSDigits){
-    fpSDigits = new TClonesArray("AliITSpListItem",10000);
-  }
-  TClonesArray& aSDigits = *fpSDigits;
-  Int_t bufsize = 32000;
-  tree->Branch("ITS", &fpSDigits, bufsize);
-  Int_t npx = 0;
-  //
-  // SPD
-  //
-  AliITSsegmentationSPD* segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
-  if(!segSPD){
-    AliWarning("Set AliITS defaults");
-    SetDefaults();
-    segSPD = (AliITSsegmentationSPD*) fDetTypeSim->GetSegmentationModel(0);
-  }
-  npx = segSPD->Npx();
-  Double_t thr, sigma; 
-    
-  AliITSRawStreamSPD inputSPD(rawReader);
-  while(1){
-    Bool_t next  = inputSPD.Next();
-    if (!next) break;
-
-    Int_t module = inputSPD.GetModuleID();
-    Int_t column = inputSPD.GetColumn();
-    Int_t row    = inputSPD.GetRow();
-    Int_t index  = npx * column + row;
-
-    if (module >= size) continue;
- 
-    last = (fModA[module])->GetEntries();
-    TClonesArray& dum = *fModA[module];
-    fDetTypeSim->GetSimuParam()->SPDThresholds(module,thr,sigma);
-    thr += 1.;
-    new (dum[last]) AliITSpListItem(-1, -1, module, index, thr);
-  }
-  rawReader->Reset();
-
-  //
-  // SDD
-  // 
-  AliITSsegmentationSDD* segSDD = (AliITSsegmentationSDD*) fDetTypeSim->GetSegmentationModel(1);
-  npx = segSDD->Npx();
-  Int_t scalef=AliITSsimulationSDD::ScaleFourier(segSDD);
-  Int_t firstSDD=AliITSgeomTGeo::GetModuleIndex(3,1,1);
-  Int_t firstSSD=AliITSgeomTGeo::GetModuleIndex(5,1,1);
-
-  AliITSRawStream* inputSDD=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
-  for(Int_t iMod=firstSDD; iModGetCalibrationModel(iMod);
-    Bool_t isZeroSupp=cal->GetZeroSupp();
-    if(isZeroSupp){ 
-      for(Int_t iSid=0; iSid<2; iSid++) inputSDD->SetZeroSuppLowThreshold(iMod-firstSDD,iSid,cal->GetZSLowThreshold(iSid));
-    }else{
-      for(Int_t iSid=0; iSid<2; iSid++) inputSDD->SetZeroSuppLowThreshold(iMod-firstSDD,iSid,0);
-    }
-  }
-
-//  AliITSDDLModuleMapSDD* ddlmap=fDetTypeSim->GetDDLModuleMapSDD();
-//  inputSDD->SetDDLModuleMap(ddlmap);
-  while(inputSDD->Next()){
-    if(inputSDD->IsCompletedModule()==kFALSE && 
-       inputSDD->IsCompletedDDL()==kFALSE){
-
-      Int_t module = inputSDD->GetModuleID();
-      Int_t anode  = inputSDD->GetCoord1()+segSDD->NpzHalf()*inputSDD->GetChannel();
-      Int_t time   = inputSDD->GetCoord2();
-      Int_t signal10 = inputSDD->GetSignal();
-      Int_t index = AliITSpList::GetIndex(anode,time,scalef*npx);
-
-      if (module >= size) continue;
-      last = fModA[module]->GetEntries();
-      TClonesArray& dum = *fModA[module];
-      new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal10));
-      ((AliITSpListItem*) dum.At(last))->AddSignalAfterElect(module, index, Double_t(signal10));
-    }
-  }
-  delete inputSDD;
-  rawReader->Reset();
-    
-  //
-  // SSD
-  // 
-  AliITSsegmentationSSD* segSSD = (AliITSsegmentationSSD*) fDetTypeSim->GetSegmentationModel(2);
-  npx = segSSD->Npx();
-  AliITSRawStreamSSD inputSSD(rawReader);
-  while(1){
-    Bool_t next  = inputSSD.Next();
-    if (!next) break;
-
-    Int_t module  = inputSSD.GetModuleID();
-    if(module<0)AliError(Form("Invalid SSD  module %d \n",module));
-    if(module<0)continue;
-    Int_t side    = inputSSD.GetSideFlag();
-    Int_t strip   = inputSSD.GetStrip();
-    Int_t signal  = inputSSD.GetSignal();
-    Int_t index  = npx * side + strip;
-
-    if (module >= size) continue;
-	
-    last = fModA[module]->GetEntries();
-    TClonesArray& dum = *fModA[module];
-    new (dum[last]) AliITSpListItem(-1, -1, module, index, Double_t(signal));
-  }
-  rawReader->Reset();
-  AliITSpListItem* sdig = 0;
-    
-  Int_t firstssd = GetITSgeom()->GetStartDet(kSSD);
-  Double_t adcToEv = 1.;
-  for (Int_t mod = 0; mod < size; mod++)
-    {
-      if(mod>=firstssd) {
-	AliITSCalibrationSSD* calssd = (AliITSCalibrationSSD*)fDetTypeSim->GetCalibrationModel(mod);
-	adcToEv = 1./calssd->GetSSDDEvToADC(1.);
-      }
-      Int_t nsdig =  fModA[mod]->GetEntries();
-      for (Int_t ie = 0; ie < nsdig; ie++) {
-	sdig = (AliITSpListItem*) (fModA[mod]->At(ie));
-      	Double_t digsig = sdig->GetSignal();
-	if(mod>=firstssd) digsig*=adcToEv; // for SSD: convert back charge from ADC to electron
-	new (aSDigits[ie]) AliITSpListItem(-1, -1, mod, sdig->GetIndex(), digsig);
-	Float_t sig = sdig->GetSignalAfterElect();
-	if(mod>=firstssd) sig*=adcToEv;
-	if (sig > 0.) {
-	  sdig = (AliITSpListItem*)aSDigits[ie];
-	  sdig->AddSignalAfterElect(mod, sdig->GetIndex(), Double_t(sig));
-	}
-      }
-	
-      tree->Fill();
-      aSDigits.Clear();
-      fModA[mod]->Clear();
-    }
-  loader->WriteSDigits("OVERWRITE");    
-  return kTRUE;
-}
-
-//______________________________________________________________________
-void AliITSUpg::UpdateInternalGeometry(){
-  //reads new geometry from TGeo 
-//   AliDebug(1,"Delete ITSgeom and create a new one reading TGeo");
-
-  AliITSVersion_t version = (AliITSVersion_t)IsVersion();
-  Int_t minor = 0;
-  AliITSInitGeometryUpg initgeom;
-  AliITSgeom* geom = initgeom.CreateAliITSgeom(version,minor);
-  SetITSgeom(geom);
-}
-//______________________________________________________________________
-AliTriggerDetector* AliITSUpg::CreateTriggerDetector() const {
-  // create an AliITSTrigger object (and set trigger conditions as input)
-  return new AliITSTrigger(fDetTypeSim->GetTriggerConditions());
-}
-//______________________________________________________________________
-void AliITSUpg::WriteFOSignals(){
-// This method write FO signals in Digits tree both in Hits2Digits
-// or SDigits2Digits
-
-//  fDetTypeSim->ProcessNoiseForFastOr();
-  fDetTypeSim->WriteFOSignals();
-}
diff --git a/ITS/UPGRADE/AliITSUpg.h b/ITS/UPGRADE/AliITSUpg.h
deleted file mode 100644
index 464b14edf71..00000000000
--- a/ITS/UPGRADE/AliITSUpg.h
+++ /dev/null
@@ -1,175 +0,0 @@
-#ifndef ALIITSUPG_H
-#define ALIITSUPG_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-/* $Id: AliITSUpg.h */
-
-////////////////////////////////////////////////////////////////////////
-//           Manager class for set: ITS Upgrade                       //
-////////////////////////////////////////////////////////////////////////
-
-
-#include  // used in inline function GetModule.
-#include "AliDetector.h"
-#include "AliITSTrigger.h"
-#include "AliITSDetTypeSim.h"
-
-
-class TString;
-class TTree;
-class AliITSpListItem;
-class AliITSsimulation;
-class AliITSsegmentation;
-
-class AliITSCalibration;
-class AliITShit;
-class AliITSgeom;
-class AliITSdigit;
-class AliITSmodule;
-class AliDigitizationInput;
-
-
-class AliITSUpg : public AliDetector {
-
- public:
-    //================= Standard Classes ===============================
-    AliITSUpg();  // Default creator.
-    AliITSUpg(const Char_t *title); // standard Creator
-    AliITSUpg(const char *name, const char *title); // extended standard Creator
-    virtual ~AliITSUpg(); // destructor
-    virtual Int_t IsVersion() const {return 11;}
-
-    //===================== Simulation Geometry ========================
-    // get geometry version - detailed (major) or coarse (minor)
-    virtual Int_t GetMajorVersion() const {return -1;}
-    virtual Int_t GetMinorVersion() const {return -1;}
-    virtual void  GetGeometryVersion(Int_t &a,Int_t &b) const
-	                   {a = GetMajorVersion();b=GetMinorVersion();return;}
-    virtual void  SetEUCLID(Bool_t euclid=kTRUE) {fEuclidOut = euclid;}
-    virtual Bool_t GetEUCLID()const {return fEuclidOut;}
-    //-------------------- Geometry Transformations --------------------
-
-    // ITS geometry functions From Simulation
-    AliITSgeom* GetITSgeom() const {return fDetTypeSim->GetITSgeom();}
-    void   SetITSgeom(AliITSgeom *geom) {fDetTypeSim->SetITSgeom(geom);}
-    // return pointer to the array of modules
-    TObjArray *GetModules(){return fITSmodules;}
-
-    AliITSmodule *GetModule(Int_t index){
-        return (AliITSmodule*)(fITSmodules->At(index));}
-    virtual void SetSimuParam(AliITSSimuParam *sp){
-      fSimuParam=sp;
-      fDetTypeSim->SetSimuParam(sp);
-    }
-    AliITSSimuParam* GetSimuParam() const {return fSimuParam;}
-
-    virtual void SetDetTypeSim(AliITSDetTypeSim* dts) {fDetTypeSim=dts;}
-    AliITSDetTypeSim* GetDetTypeSim() const {return fDetTypeSim;}
-    //================ Necessary general Classes =======================
-    virtual void Init();
-    virtual AliLoader* MakeLoader(const char* topfoldername);
-    virtual void SetDefaults();
-    virtual void SetDefaultSimulation();
-    virtual void MakeBranch(Option_t *opt=" ");
-    virtual void MakeBranchS(const char* fl);
-    virtual void MakeBranchD(const char* file);
-    virtual void MakeBranchInTreeD(TTree* treeD, const char* file=0);
-    virtual void SetTreeAddress();
-     //---------- Configuration Methods (per detector type) -------------
-    // Determines which ITS subdetectors will be processed. Effects
-    // digitization, and Reconstruction only.
-    void SetDetectors(Option_t *opt="All"){fOpt = opt;}
-    // Returns the list of ITS subdetectors that will be processed.
-    Option_t* GetDetectors(){return fOpt;}
-
-    // Set calibration
-    virtual void SetCalibrationModel(Int_t dettype, AliITSCalibration *cal){
-        fDetTypeSim->SetCalibrationModel(dettype,cal);}
-    // Set segmentation for Simulation
-    virtual void SetSegmentationModel(Int_t id, AliITSsegmentation *seg){
-        fDetTypeSim->SetSegmentationModel(id,seg);}
-    // Set simulation 
-    virtual void SetSimulationModel(Int_t id, AliITSsimulation *sim){
-        fDetTypeSim->SetSimulationModel(id,sim);}
-    // Set simulation 
-    virtual AliITSsimulation* GetSimulationModel(Int_t id){
-	return fDetTypeSim->GetSimulationModel(id);}
-    //=================== Hits =========================================
-    virtual void StepManager() {} // See Step Manager for specific geometry.
-    //------------ sort hits by module for Digitisation ----------------
-    virtual void FillModules(Int_t /* evnt */,Int_t bgrev,Int_t /* nmodules */,
-			     Option_t *opt, const char *filename); 
-    virtual Bool_t InitModules(Int_t size,Int_t &nmodules);  
-    virtual void FillModules(TTree *treeH, Int_t mask = 0);
-    virtual void ClearModules(){if(fITSmodules) fITSmodules->Delete();}
-    virtual void AddHit(Int_t track, Int_t *vol, Float_t *hits);
-   // Trigger
-    virtual AliTriggerDetector* CreateTriggerDetector() const;
-
-    AliDigitizer* CreateDigitizer(AliDigitizationInput* manager) const;
-    virtual void UpdateInternalGeometry();
-    virtual void SDigitsToDigits(Option_t *opt="All");
-    virtual void SDigits2Digits(){SDigitsToDigits("All");}
-    virtual void Hits2Digits(); 
-    virtual void Hits2SDigits();
-    virtual void Hits2PreDigits();
-    virtual void HitsToDigits(Int_t evNumber,Int_t bgrev,Int_t size,
-                          Option_t *option,Option_t *opt,
-                          const char *filename);
-    virtual void HitsToPreDigits(Int_t evNumber,Int_t bgrev,Int_t size,
-                             Option_t *option,Option_t *opt,
-                             const char *filename);
-    void HitsToSDigits(Int_t evNumber,Int_t bgrev,Int_t size,
-                       Option_t *add, Option_t *det, const char *filename)
-      {HitsToPreDigits(evNumber,bgrev,size,add,det,filename);}
-    
-    virtual void ResetDigits();
-    virtual void ResetDigits(Int_t branch);
-    virtual void AddSumDigit(AliITSpListItem &sdig);
-    virtual void AddSimDigit(Int_t branch, AliITSdigit *d);
-    virtual void AddSimDigit(Int_t branch,Float_t phys,Int_t* digits,
-		     Int_t* tracks,Int_t *hits,Float_t* trkcharges,
-		     Int_t sigexpanded=-1000);
-    TObjArray* GetDigits()  const {return fDetTypeSim->GetDigits();}
-    Int_t* GetNDigitArray() const {return fDetTypeSim->GetNDigitArray();}
-    TClonesArray *DigitsAddress(Int_t id) {
-	return fDetTypeSim->DigitsAddress(id);}
-    //Fast simulation
-    virtual void HitsToFastRecPoints(Int_t evNumber,Int_t bgrev,Int_t size,
-                 Option_t *add, Option_t *det, const char *filename);
-    virtual Int_t Hits2Clusters(TTree *in, TTree *out);
-    virtual void CheckLabels(Int_t lab[3]) const;
-
-    //===================== Raw Data IO ================================
-    // Write digits into raw data format
-    virtual void   Digits2Raw();
-    virtual Bool_t Raw2SDigits(AliRawReader*);
-    
-    //===================== FO signals ================================
-    // Write FO signals in UserInfo of SDigits/Digits tree
-    void WriteFOSignals();
-
- protected:
-    static const Int_t fgkNTYPES=3; //number of detector types
-    //================== Data Members ==================================
-    AliITSDetTypeSim *fDetTypeSim; //detector type for simulation
-    Bool_t        fEuclidOut;  // Flag to write geometry in euclid format
-    Option_t     *fOpt;        //! Detector option ="All" unless changed.
-    Int_t         fIdN;        // the number of layers
-    Int_t        *fIdSens;     //[fIdN] layer identifier
-    TString      *fIdName;     //[fIdN] layer identifier
-    TObjArray    *fITSmodules; //! Pointer to ITS modules
-    Bool_t        fTiming;     // flag to turn on/off timers.
-    AliITSSimuParam* fSimuParam; //simulation parameters
-    TClonesArray** fModA;      //! Used by Raw2SDigits (one TC per module)
-    TClonesArray* fpSDigits;   //! Branch address to build SD from raw data 
-
- private:
-    AliITSUpg(const AliITSUpg &source); // copy constructor. Not to be used!
-    AliITSUpg& operator=(const AliITSUpg &source); // = operator. Not to be used!
-    ClassDef(AliITSUpg,1) // Base class for ITS
-
-};
-
-#endif
diff --git a/ITS/UPGRADE/AliITSUv11.cxx b/ITS/UPGRADE/AliITSUv11.cxx
new file mode 100644
index 00000000000..e1c0bc8e6ce
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUv11.cxx
@@ -0,0 +1,704 @@
+/**************************************************************************
+ * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+
+/* $Id: AliITSUv11.cxx */
+
+
+//========================================================================
+//
+//        Geometry for the Upgrade of the Inner Tracking System
+//
+// Mario Sitta (sitta@to.infn.it)
+//
+//========================================================================
+
+
+
+// $Log: AliITSUv11.cxx,v $
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "AliITSU.h"
+#include "AliITSUHit.h"
+#include "AliLog.h"
+#include "AliMC.h"
+#include "AliMagF.h"
+#include "AliRun.h"
+#include "AliTrackReference.h"
+#include "AliITSv11Geometry.h"
+#include "AliITSUv11Layer.h"
+#include "AliITSv11GeomBeamPipe.h"
+#include "AliITSUv11.h"
+#include "AliITSUGeomTGeo.h"
+#include "AliGeomManager.h"
+
+const Double_t AliITSUv11::fgkBeamPipeHalfZLen = 400;
+
+
+ClassImp(AliITSUv11)
+
+//______________________________________________________________________
+AliITSUv11::AliITSUv11()
+:  fLayTurbo(0)
+  ,fLayRadii(0)
+  ,fLayZLength(0)
+  ,fLaddPerLay(0)
+  ,fModPerLadd(0)
+  ,fLadThick(0)
+  ,fLadWidth(0)
+  ,fLadTilt(0)
+  ,fDetThick(0)
+  ,fDetTypeID(0)
+  ,fBeamPipe(0)
+  ,fBeamPipeRmin(0)
+  ,fBeamPipeRmax(0)
+  ,fBeamPipeZlen(0)
+  ,fUpGeom(0)
+  ,fBPGeom(0)
+{
+  //    Standard default constructor
+  // Inputs:
+  //   none.
+  // Outputs:
+  //   none.
+  // Return:
+  //   none.
+}
+
+//______________________________________________________________________
+AliITSUv11::AliITSUv11(const char *title,const Int_t nlay)
+  :AliITSU(title,nlay)
+  ,fLayTurbo(0)
+  ,fLayRadii(0)
+  ,fLayZLength(0)
+  ,fLaddPerLay(0)
+  ,fModPerLadd(0)
+  ,fLadThick(0)
+  ,fLadWidth(0)
+  ,fLadTilt(0)
+  ,fDetThick(0)
+  ,fDetTypeID(0)
+  ,fBeamPipe(0)
+  ,fBeamPipeRmin(0)
+  ,fBeamPipeRmax(0)
+  ,fBeamPipeZlen(0)
+  ,fUpGeom(0)
+  ,fBPGeom(0)
+{
+  //    Standard constructor for the Upgrade geometry.
+  // Inputs:
+  //   const char * name   Ignored, set to "ITS"
+  //   const char * title  Arbitrary title
+  //   const Int_t nlay    Number of layers
+  //
+  fLayerName = new TString[fNLayers];
+  //
+  for (Int_t j=0; j 0) { // if not, we'll Fatal-ize in CreateGeometry
+    for (Int_t j=0; jGetAlignableEntryByUID(uid);
+  TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
+
+  Double_t *gtrans = globMatrix->GetTranslation(), rotMatrix[9];
+  memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+  Double_t al = TMath::ATan2(rotMatrix[1],rotMatrix[0]);
+  if (yRot180) {
+    al = TMath::ATan2(rotMatrix[1],-rotMatrix[0]);
+  }
+  Double_t xShift = gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al);
+  Double_t zShift = -gtrans[2];
+
+  TGeoHMatrix *matLtoT = new TGeoHMatrix;
+  matLtoT->SetDx( xShift ); // translation
+  matLtoT->SetDy( yShift );
+  matLtoT->SetDz( zShift );
+  rotMatrix[0]= 0;  rotMatrix[1]= 1;  rotMatrix[2]= 0; // + rotation
+  rotMatrix[3]= 1;  rotMatrix[4]= 0;  rotMatrix[5]= 0;
+  rotMatrix[6]= 0;  rotMatrix[7]= 0;  rotMatrix[8]=-1;
+  if (yFlip) rotMatrix[3] = -1;  // flipping in y  (for SPD1)
+  if (yFlip) rotMatrix[1] = -1;  // flipping in y  (for SPD1)
+
+  if (yRot180) { // rotation of pi around the axis perpendicular to the wafer
+    if (yFlip) matLtoT->SetDx( -xShift ); // flipping in y  (for SPD1)
+    matLtoT->SetDy( -yShift );
+    matLtoT->SetDz( -zShift );
+    rotMatrix[8]=1;
+    rotMatrix[3] = -1;
+    if (yFlip) rotMatrix[3] = 1;  // flipping in y  (for SPD1)
+  }
+
+  TGeoRotation rot;
+  rot.SetMatrix(rotMatrix);
+  matLtoT->MultiplyLeft(&rot);
+  TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+  delete matLtoT;
+  alignableEntry->SetMatrix(matTtoL);
+}
+
+//______________________________________________________________________
+void AliITSUv11::AddAlignableVolumes() const{
+  // Creates entries for alignable volumes associating the symbolic volume
+  // name with the corresponding volume path.
+  // 
+  // Records in the alignable entries the transformation matrices converting
+  // TGeo local coordinates (in the RS of alignable volumes) to the tracking
+  // system
+  // For this, this function has to run before the misalignment because we
+  // are using the ideal positions in the AliITSgeom object.
+  // Inputs:
+  //   none.
+  // Outputs:
+  //   none.
+  // Return:
+  //   none.
+
+  AliInfo("Add ITS alignable volumes");
+
+  if (!gGeoManager) { AliFatal("TGeoManager doesn't exist !"); return;  }
+  TString pth,snm;
+  //
+  pth = Form("ALIC_1/%s_2",AliITSUGeomTGeo::GetITSVolPattern());
+  // RS: to be checked with MS
+  if( !gGeoManager->SetAlignableEntry("ITS",pth.Data()) )
+    AliFatal(Form("Unable to set alignable entry ! %s :: %s","ITS",pth.Data()));    
+  //
+  for (int lr=0; lrSetAlignableEntry(snm.Data(),pth.Data());
+    int modNum = 0;
+    //
+    for (int ld=0; ldSetAlignableEntry(snmL.Data(),pthL.Data());
+      //
+      for (int md=0; mdSetAlignableEntry(snmM.Data(),pthM.Data(),modUID);
+	//
+	double yshift = -(fUpGeom[lr]->GetSensorThick()-fUpGeom[lr]->GetLadderThick())/2;
+	SetT2Lmatrix(modUID,yshift, kTRUE,kTRUE); // RS: do we need here special matrix, ask MS
+	//
+      }
+    }
+  }
+  //
+}
+
+//______________________________________________________________________
+void AliITSUv11::AddBeamPipe(const Double_t rmin, const Double_t rmax,
+				 const Double_t halfzlen) {
+
+  // Define the parameters for the beam pipe
+  if (fBeamPipe)
+    AliWarning("Redefining beam pipe parameters");
+
+  if (rmin <= 0) {
+    AliError(Form("Beam pipe min radius (%f) wrong",rmin));
+    return;
+  } else
+    fBeamPipeRmin = rmin;
+
+  if (rmax <= 0) {
+    AliError(Form("Beam pipe max radius (%f) wrong",rmax));
+    return;
+  } else
+    fBeamPipeRmax = rmax;
+
+  if (halfzlen < 0) {
+    AliError(Form("Beam pipe half Zlength (%f) wrong",halfzlen));
+    return;
+  } else {
+    if (halfzlen == 0) // Use default value
+      fBeamPipeZlen = fgkBeamPipeHalfZLen;
+    else
+      fBeamPipeZlen = halfzlen;
+  }
+
+  fBeamPipe = kTRUE;
+}
+
+//______________________________________________________________________
+void AliITSUv11::CreateGeometry() {
+
+  // Create the geometry and insert it in the mother volume ITSV
+  TGeoManager *geoManager = gGeoManager;
+
+  TGeoVolume *vALIC = geoManager->GetVolume("ALIC");
+
+  new TGeoVolumeAssembly(AliITSUGeomTGeo::GetITSVolPattern());
+  TGeoVolume *vITSV = geoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern());
+  vALIC->AddNode(vITSV, 2, 0);  // Copy number is 2 to cheat AliGeoManager::CheckSymNamesLUT
+
+  //
+  const Int_t kLength=100;
+  Char_t vstrng[kLength] = "xxxRS"; //?
+  vITSV->SetTitle(vstrng);
+  //
+  // Check that we have all needed parameters
+  if (fNLayers <= 0) AliFatal(Form("Wrong number of layers (%d)",fNLayers));
+  //
+  for (Int_t j=0; j 0) {
+      if (fLayRadii[j]<=fLayRadii[j-1])     AliFatal(Form("Layer %d radius (%f) is smaller than layer %d radius (%f)",
+							 j,fLayRadii[j],j-1,fLayRadii[j-1]));
+      if (fLayZLength[j]<=fLayZLength[j-1]) AliFatal(Form("Layer %d length (%f) is smaller than layer %d length (%f)",
+							  j,fLayZLength[j],j-1,fLayZLength[j-1]));
+    } // if (j > 0)
+
+    if (fLadThick[j] == 0) AliInfo(Form("Ladder thickness for layer %d not set, using default",j));
+    if (fDetThick[j] == 0) AliInfo(Form("Module thickness for layer %d not set, using default",j));
+
+  } // for (Int_t j=0; jSetLadderWidth(fLadWidth[j]);
+      fUpGeom[j]->SetLadderTilt(fLadTilt[j]);
+    }
+    else fUpGeom[j] = new AliITSUv11Layer(j,kFALSE);
+    //
+    fUpGeom[j]->SetRadius(fLayRadii[j]);
+    fUpGeom[j]->SetZLength(fLayZLength[j]);
+    fUpGeom[j]->SetNLadders(fLaddPerLay[j]);
+    fUpGeom[j]->SetNModules(fModPerLadd[j]);
+    fUpGeom[j]->SetDetType(fDetTypeID[j]);
+    //
+    if (fLadThick[j] != 0) fUpGeom[j]->SetLadderThick(fLadThick[j]);
+    if (fDetThick[j] != 0) fUpGeom[j]->SetSensorThick(fDetThick[j]);
+    fUpGeom[j]->CreateLayer(vITSV);
+  }
+  //
+  // Finally add the beam pipe
+  if (fBeamPipe) {
+    fBPGeom = new AliITSv11GeomBeamPipe(fBeamPipeRmin, fBeamPipeRmax,fBeamPipeZlen, kFALSE);
+    fBPGeom->CreateBeamPipe(vALIC); // We put the BP in the ALIC volume
+  }
+}
+
+//______________________________________________________________________
+void AliITSUv11::CreateMaterials() {
+  // Create ITS materials
+  //     This function defines the default materials used in the Geant
+  // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
+  // AliITSv11Hybrid.
+  // In general it is automatically replaced by
+  // the CreateMaterials 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.
+
+  Int_t   ifield = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
+  Float_t fieldm = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
+
+  Float_t tmaxfd = 0.1; // 1.0; // Degree
+  Float_t stemax = 1.0; // cm
+  Float_t deemax = 0.1; // 30.0; // Fraction of particle's energy 0= fNLayers || nlay < 0) {
+    AliError(Form("Wrong layer number (%d)",nlay));
+    return;
+  }
+  
+  fLayTurbo[nlay] = kFALSE;
+  fLayRadii[nlay] = r;
+  fLayZLength[nlay] = zlen;
+  fLaddPerLay[nlay] = nladd;
+  fModPerLadd[nlay] = nmod;
+  fLadThick[nlay] = lthick;
+  fDetThick[nlay] = dthick;
+  fDetTypeID[nlay] = dettypeID;
+    
+}
+
+//______________________________________________________________________
+void AliITSUv11::DefineLayerTurbo(const Int_t nlay, const Double_t r,
+				      const Double_t zlen, const Int_t nladd,
+				      const Int_t nmod, const Double_t width,
+				      const Double_t tilt,
+				      const Double_t lthick,
+				      const Double_t dthick,
+				      const UInt_t dettypeID)
+{
+  //     Sets the layer parameters for a "turbo" layer
+  //     (i.e. a layer whose ladders overlap in phi)
+  // Inputs:
+  //          nlay    layer number
+  //          r       layer radius
+  //          zlen    layer length
+  //          nladd   number of ladders
+  //          nmod    number of modules per ladder
+  //          width   layer width
+  //          tilt    layer tilt angle (degrees)
+  //          lthick  ladder thickness (if omitted, defaults to 0)
+  //          dthick  detector thickness (if omitted, defaults to 0)
+  // Outputs:
+  //   none.
+  // Return:
+  //   none.
+
+  if (nlay >= fNLayers || nlay < 0) {
+    AliError(Form("Wrong layer number (%d)",nlay));
+    return;
+  }
+
+  fLayTurbo[nlay] = kTRUE;
+  fLayRadii[nlay] = r;
+  fLayZLength[nlay] = zlen;
+  fLaddPerLay[nlay] = nladd;
+  fModPerLadd[nlay] = nmod;
+  fLadThick[nlay] = lthick;
+  fLadWidth[nlay] = width;
+  fLadTilt[nlay] = tilt;
+  fDetThick[nlay] = dthick;
+  fDetTypeID[nlay] = dettypeID;
+  //
+}
+
+//______________________________________________________________________
+void AliITSUv11::GetBeamPipeParameters(Double_t &rmin, Double_t &rmax,
+					   Double_t &hzlen){
+  //     Gets the beam pipe parameters
+  // Inputs:
+  //   none.
+  // Outputs:
+  //          rmin    min radius
+  //          rmax    max radius
+  //          hzlen   half Z length
+  // Return:
+  //   none.
+
+  rmin  = fBeamPipeRmin;
+  rmax  = fBeamPipeRmax;
+  hzlen = fBeamPipeZlen;
+
+}
+
+//______________________________________________________________________
+void AliITSUv11::GetLayerParameters(const Int_t nlay,
+					Double_t &r, Double_t &zlen,
+					Int_t &nladd, Int_t &nmod,
+					Double_t &width, Double_t &tilt,
+					Double_t <hick, Double_t &dthick){
+  //     Gets the layer parameters
+  // Inputs:
+  //          nlay    layer number
+  // Outputs:
+  //          r       layer radius
+  //          zlen    layer length
+  //          nladd   number of ladders
+  //          nmod    number of modules per ladder
+  //          width   ladder width
+  //          tilt    ladder tilt angle
+  //          lthick  ladder thickness
+  //          dthick  detector thickness
+  // Return:
+  //   none.
+
+  if (nlay >= fNLayers || nlay < 0) {
+    AliError(Form("Wrong layer number (%d)",nlay));
+    return;
+  }
+
+  r = fLayRadii[nlay];
+  zlen = fLayZLength[nlay];
+  nladd = fLaddPerLay[nlay];
+  nmod = fModPerLadd[nlay];
+  width = fLadWidth[nlay];
+  tilt = fLadTilt[nlay];
+  lthick = fLadThick[nlay];
+  dthick = fDetThick[nlay];
+}
+
+//______________________________________________________________________
+void AliITSUv11::Init()
+{
+  //     Initialise the ITS after it has been created.
+  UpdateInternalGeometry();
+  AliITSU::Init();
+  
+}
+
+//______________________________________________________________________
+Bool_t AliITSUv11::IsLayerTurbo(const Int_t nlay)
+{
+  //     Returns true if the layer is a "turbo" layer
+  if ( nlay < 0 || nlay > fNLayers ) {
+    AliError(Form("Wrong layer number %d",nlay));
+    return kFALSE;
+  } 
+  else return fUpGeom[nlay]->IsTurbo();
+}
+
+//______________________________________________________________________
+void AliITSUv11::SetDefaults()
+{
+  // sets the default segmentation, response, digit and raw cluster classes
+}
+
+//______________________________________________________________________
+void AliITSUv11::StepManager()
+{
+  //    Called for every step in the ITS, then calles the AliITSUHit class
+  // creator with the information to be recoreded about that hit.
+  //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
+  // printing of information to a file which can be used to create a .det
+  // file read in by the routine CreateGeometry(). If set to 0 or any other
+  // value except 1, the default behavior, then no such file is created nor
+  // it the extra variables and the like used in the printing allocated.
+  // Inputs:
+  //   none.
+  // Outputs:
+  //   none.
+  // Return:
+  //   none.
+  if(!(this->IsActive())) return;
+  if(!(gMC->TrackCharge())) return;
+  //
+  Int_t copy, lay = 0;
+  Int_t id = gMC->CurrentVolID(copy);
+
+  Bool_t notSens = kFALSE;
+  while ((layIsTrackExiting()) {
+    AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
+  } // if Outer ITS mother Volume
+
+  static TLorentzVector position, momentum; // Saves on calls to construtors
+  static AliITSUHit hit;// Saves on calls to constructors
+
+  TClonesArray &lhits = *(Hits());
+  Int_t   cpn0, cpn1, mod, status = 0;
+  //
+  // Track status
+  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;
+
+  //
+  // retrieve the indices with the volume path
+  //
+  if (lay < 0 || lay >= fNLayers) {
+    AliError(Form("Invalid value: lay=%d. Not an ITS sensitive volume",lay));
+    return; // not an ITS sensitive volume.
+  } else {
+    copy = 1;
+    gMC->CurrentVolOffID(1,cpn1);
+    gMC->CurrentVolOffID(2,cpn0);
+  } //
+
+  mod = fGeomTGeo->GetModuleIndex(lay,cpn0,cpn1);
+  //RS2DEL  fInitGeom.DecodeDetector(mod,lay+1,cpn0,cpn1,copy);
+  //
+  // Fill hit structure.
+  //
+  hit.SetModule(mod);
+  hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
+  gMC->TrackPosition(position);
+  gMC->TrackMomentum(momentum);
+  hit.SetPosition(position);
+  hit.SetTime(gMC->TrackTime());
+  hit.SetMomentum(momentum);
+  hit.SetStatus(status);
+  hit.SetEdep(gMC->Edep());
+  hit.SetShunt(GetIshunt());
+  if(gMC->IsTrackEntering()){
+    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.
+    //Info("StepManager","Calling Copy Constructor");
+  new(lhits[fNhits++]) AliITSUHit(hit); // Use Copy Construtor.
+  // Save old position... for next hit.
+  hit.SetStartPosition(position);
+  hit.SetStartTime(gMC->TrackTime());
+  hit.SetStartStatus(status);
+
+  return;
+}
+
+//______________________________________________________________________
+void AliITSUv11::SetLayerDetTypeID(Int_t lr, UInt_t id)
+{
+  // set det type
+  if (!fDetTypeID || fNLayers<=lr) AliFatal(Form("Number of layers %d, %d is manipulated",fNLayers,lr));
+  fDetTypeID[lr] = id;
+}
+
+//______________________________________________________________________
+Int_t AliITSUv11::GetLayerDetTypeID(Int_t lr)
+{
+  // set det type
+  if (!fDetTypeID || fNLayers<=lr) AliFatal(Form("Number of layers %d, %d is manipulated",fNLayers,lr));
+  return fDetTypeID[lr];
+}
diff --git a/ITS/UPGRADE/AliITSUv11.h b/ITS/UPGRADE/AliITSUv11.h
new file mode 100644
index 00000000000..f0187a44066
--- /dev/null
+++ b/ITS/UPGRADE/AliITSUv11.h
@@ -0,0 +1,95 @@
+#ifndef ALIITSVUPGRADE_H
+#define ALIITSVUPGRADE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//========================================================================
+//
+//        Geometry for the Upgrade of the Inner Tracking System
+//
+// Mario Sitta (sitta@to.infn.it)
+//
+//========================================================================
+
+
+// $Id: AliITSUv11.h 
+
+#include "AliITSU.h"
+
+class  AliITSUv11Layer;
+class  AliITSv11GeomBeamPipe;
+class  TGeoVolume;
+class  TGeoVolumeAssembly;
+
+class AliITSUv11 : public AliITSU {
+
+ public:
+  AliITSUv11();
+  AliITSUv11(const char *title, const Int_t nlay);
+  virtual       ~AliITSUv11() ;
+  
+  virtual void   AddAlignableVolumes() const;
+  virtual void   AddBeamPipe(const Double_t rmin, const Double_t rmax,const Double_t halfzlen=0.);
+  virtual void   CreateGeometry();
+  virtual void   CreateMaterials();
+  virtual void   DefineLayer(const Int_t nlay, const Double_t r,
+			     const Double_t zlen, const Int_t nladd,
+			     const Int_t nmod, const Double_t lthick = 0.,
+			     const Double_t dthick = 0.,
+			     const UInt_t detType=0);
+  virtual void   DefineLayerTurbo(const Int_t nlay, const Double_t r,
+				  const Double_t zlen, const Int_t nladd,
+				  const Int_t nmod, const Double_t width,
+				  const Double_t tilt,
+				  const Double_t lthick = 0.,
+				  const Double_t dthick = 0.,
+				  const UInt_t detType=0);
+  virtual void   GetBeamPipeParameters(Double_t &rmin, Double_t &rmax,
+				       Double_t &hzlen);
+  virtual void   GetLayerParameters(const Int_t nlay,
+				    Double_t &r, Double_t &zlen,
+				    Int_t &nladd, Int_t &nmod,
+				    Double_t &width, Double_t &tilt,
+				    Double_t <hick, Double_t &mthick);
+  virtual Bool_t HasBeamPipe() const {return fBeamPipe;}
+  virtual void   Init(); 
+  virtual Bool_t IsLayerTurbo(const Int_t nlay);
+  virtual Int_t  IsVersion() const { return 20;}  // vUpgrade ? do we need this
+  virtual void   SetDefaults();
+  virtual void   StepManager();
+  virtual void   SetLayerDetTypeID(Int_t lr, UInt_t id);
+  virtual Int_t  GetLayerDetTypeID(Int_t lr);
+  //
+ protected:
+  void SetT2Lmatrix(Int_t uid, Double_t yShift,Bool_t yFlip, Bool_t yRot180=kFALSE) const; // Set T2L matrix in TGeoPNEntries
+  
+ private:
+  AliITSUv11(const AliITSUv11 &source); // copy constructor
+  AliITSUv11& operator=(const AliITSUv11 &source); // assignment operator
+  //
+  Bool_t   *fLayTurbo;       // True for "turbo" layers
+  Double_t *fLayRadii;       // Vector of layer radii
+  Double_t *fLayZLength;     // Vector of layer length along Z
+  Int_t    *fLaddPerLay;     // Vector of number of ladders per layer
+  Int_t    *fModPerLadd;     // Vector of number of modules per ladder
+  Double_t *fLadThick;       // Vector of ladder thicknesses
+  Double_t *fLadWidth;       // Vector of ladder width (only used for turbo)
+  Double_t *fLadTilt;        // Vector of ladder tilt (only used for turbo)
+  Double_t *fDetThick;       // Vector of detector thicknesses
+  UInt_t   *fDetTypeID;      // Vector of detector type id
+  Bool_t    fBeamPipe;       // True for creating the beam pipe
+  Double_t  fBeamPipeRmin;   // Rmin of beam pipe
+  Double_t  fBeamPipeRmax;   // Rmax of beam pipe
+  Double_t  fBeamPipeZlen;   // Half Z length of beam pipe
+  //  
+  AliITSUv11Layer **fUpGeom; //! Geometry
+  AliITSv11GeomBeamPipe     *fBPGeom; //! Beam Pipe Geometry
+  
+  // Parameters for the Upgrade geometry
+  
+  static const Double_t fgkBeamPipeHalfZLen;  // Default value for beampipe Z
+  
+  ClassDef(AliITSUv11,0)                          
+};
+ 
+#endif
diff --git a/ITS/UPGRADE/AliITSv11GeometryUpgrade.cxx b/ITS/UPGRADE/AliITSUv11Layer.cxx
similarity index 87%
rename from ITS/UPGRADE/AliITSv11GeometryUpgrade.cxx
rename to ITS/UPGRADE/AliITSUv11Layer.cxx
index ff6f252c346..1e4515f3dc1 100644
--- a/ITS/UPGRADE/AliITSv11GeometryUpgrade.cxx
+++ b/ITS/UPGRADE/AliITSUv11Layer.cxx
@@ -22,7 +22,7 @@
 //*************************************************************************
 
 
-/* $Id: AliITSv11GeometryUpgrade.cxx  */
+/* $Id: AliITSUv11Layer.cxx  */
 // General Root includes
 #include 
 // Root Geometry includes
@@ -36,18 +36,18 @@
 #include 
 #include 
 #include 
-#include "AliITSv11GeometryUpgrade.h"
-#include "AliITSgeomTGeoUpg.h"
+#include "AliITSUv11Layer.h"
+#include "AliITSUGeomTGeo.h"
 
-const Double_t AliITSv11GeometryUpgrade::fgkDefaultSensorThick = 300*fgkmicron;
-const Double_t AliITSv11GeometryUpgrade::fgkDefaultLadderThick =   1*fgkcm;
+const Double_t AliITSUv11Layer::fgkDefaultSensorThick = 300*fgkmicron;
+const Double_t AliITSUv11Layer::fgkDefaultLadderThick =   1*fgkcm;
 
-ClassImp(AliITSv11GeometryUpgrade)
+ClassImp(AliITSUv11Layer)
 
 #define SQ(A) (A)*(A)
 
 //________________________________________________________________________
-AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(): 
+AliITSUv11Layer::AliITSUv11Layer(): 
   AliITSv11Geometry(),
   fLayerNumber(0),
   fLayRadius(0),
@@ -67,7 +67,7 @@ AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade():
 }
 
 //________________________________________________________________________
-AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(Int_t debug): 
+AliITSUv11Layer::AliITSUv11Layer(Int_t debug): 
   AliITSv11Geometry(debug),
   fLayerNumber(0),
   fLayRadius(0),
@@ -87,7 +87,7 @@ AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(Int_t debug):
 }
 
 //________________________________________________________________________
-AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(Int_t lay, Int_t debug): 
+AliITSUv11Layer::AliITSUv11Layer(Int_t lay, Int_t debug): 
   AliITSv11Geometry(debug),
   fLayerNumber(lay),
   fLayRadius(0),
@@ -107,7 +107,7 @@ AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(Int_t lay, Int_t debug):
 }
 
 //________________________________________________________________________
-AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(Int_t lay, Bool_t turbo, Int_t debug): 
+AliITSUv11Layer::AliITSUv11Layer(Int_t lay, Bool_t turbo, Int_t debug): 
   AliITSv11Geometry(debug),
   fLayerNumber(lay),
   fLayRadius(0),
@@ -128,7 +128,7 @@ AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(Int_t lay, Bool_t turbo, Int_
 }
 
 //________________________________________________________________________
-AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(const AliITSv11GeometryUpgrade &s):
+AliITSUv11Layer::AliITSUv11Layer(const AliITSUv11Layer &s):
   AliITSv11Geometry(s.GetDebug()),
   fLayerNumber(s.fLayerNumber),
   fLayRadius(s.fLayRadius),
@@ -148,7 +148,7 @@ AliITSv11GeometryUpgrade::AliITSv11GeometryUpgrade(const AliITSv11GeometryUpgrad
 }
 
 //________________________________________________________________________
-AliITSv11GeometryUpgrade& AliITSv11GeometryUpgrade::operator=(const AliITSv11GeometryUpgrade &s)
+AliITSUv11Layer& AliITSUv11Layer::operator=(const AliITSUv11Layer &s)
 {
   //
   // Assignment operator 
@@ -170,14 +170,14 @@ AliITSv11GeometryUpgrade& AliITSv11GeometryUpgrade::operator=(const AliITSv11Geo
 }
 
 //________________________________________________________________________
-AliITSv11GeometryUpgrade::~AliITSv11GeometryUpgrade() {
+AliITSUv11Layer::~AliITSUv11Layer() {
   //
   // Destructor
   //
 }
 
 //________________________________________________________________________
-void AliITSv11GeometryUpgrade::CreateLayer(TGeoVolume *moth,
+void AliITSUv11Layer::CreateLayer(TGeoVolume *moth,
 				     const TGeoManager *mgr){
 //
 // Creates the actual Layer and places inside its mother volume
@@ -248,7 +248,7 @@ void AliITSv11GeometryUpgrade::CreateLayer(TGeoVolume *moth,
   // We have all shapes: now create the real volumes
   TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
 
-  snprintf(volname, 30, "%s%d", AliITSgeomTGeoUpg::GetITSLayerPattern(),fLayerNumber);
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),fLayerNumber);
   TGeoVolume *layVol = new TGeoVolume(volname, layer, medAir);
   layVol->SetUniqueID(fDetTypeID);
 
@@ -267,7 +267,7 @@ void AliITSv11GeometryUpgrade::CreateLayer(TGeoVolume *moth,
     xpos = r*SinD(theta);
     ypos = r*CosD(theta);
     zpos = 0.;
-    layVol->AddNode(laddVol, j+1, new TGeoCombiTrans( xpos, ypos, zpos,
+    layVol->AddNode(laddVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
 				  new TGeoRotation("",-theta,0,0)));
   }
 
@@ -281,7 +281,7 @@ void AliITSv11GeometryUpgrade::CreateLayer(TGeoVolume *moth,
 }
 
 //________________________________________________________________________
-void AliITSv11GeometryUpgrade::CreateLayerTurbo(TGeoVolume *moth,
+void AliITSUv11Layer::CreateLayerTurbo(TGeoVolume *moth,
 					  const TGeoManager *mgr){
 //
 // Creates the actual Layer and places inside its mother volume
@@ -341,7 +341,7 @@ void AliITSv11GeometryUpgrade::CreateLayerTurbo(TGeoVolume *moth,
   // We have all shapes: now create the real volumes
   TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
 
-  snprintf(volname, 30, "%s%d", AliITSgeomTGeoUpg::GetITSLayerPattern(), fLayerNumber);
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(), fLayerNumber);
   TGeoVolume *layVol = new TGeoVolume(volname, layer, medAir);
   layVol->SetUniqueID(fDetTypeID);
   layVol->SetVisibility(kTRUE);
@@ -361,7 +361,7 @@ void AliITSv11GeometryUpgrade::CreateLayerTurbo(TGeoVolume *moth,
     xpos = r*SinD(theta);
     ypos = r*CosD(theta);
     zpos = 0.;
-    layVol->AddNode(laddVol, j+1, new TGeoCombiTrans( xpos, ypos, zpos,
+    layVol->AddNode(laddVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
 				 new TGeoRotation("",-theta+fLadderTilt,0,0)));
   }
 
@@ -373,7 +373,7 @@ void AliITSv11GeometryUpgrade::CreateLayerTurbo(TGeoVolume *moth,
 }
 
 //________________________________________________________________________
-TGeoVolume* AliITSv11GeometryUpgrade::CreateLadder(const TGeoManager *mgr){
+TGeoVolume* AliITSUv11Layer::CreateLadder(const TGeoManager *mgr){
 //
 // Creates the actual Ladder
 //
@@ -407,7 +407,7 @@ TGeoVolume* AliITSv11GeometryUpgrade::CreateLadder(const TGeoManager *mgr){
   // We have all shapes: now create the real volumes
   TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
 
-  snprintf(volname, 30, "%s%d", AliITSgeomTGeoUpg::GetITSLadderPattern(), fLayerNumber);
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
   TGeoVolume *laddVol = new TGeoVolume(volname, ladder, medAir);
 
 //  laddVol->SetVisibility(kFALSE);
@@ -424,7 +424,7 @@ TGeoVolume* AliITSv11GeometryUpgrade::CreateLadder(const TGeoManager *mgr){
     xpos = 0.;
     ypos = 0.;
     zpos = -ladder->GetDZ() + j*2*zmod + zmod;
-    laddVol->AddNode(modVol, j+1, new TGeoTranslation(xpos, ypos, zpos));
+    laddVol->AddNode(modVol, j, new TGeoTranslation(xpos, ypos, zpos));
   }
 
 
@@ -433,7 +433,7 @@ TGeoVolume* AliITSv11GeometryUpgrade::CreateLadder(const TGeoManager *mgr){
 }
 
 //________________________________________________________________________
-TGeoVolume* AliITSv11GeometryUpgrade::CreateModule(const Double_t xlad,
+TGeoVolume* AliITSUv11Layer::CreateModule(const Double_t xlad,
 						   const Double_t ylad,
 						   const Double_t zlad,
 						   const TGeoManager *mgr){
@@ -472,13 +472,13 @@ TGeoVolume* AliITSv11GeometryUpgrade::CreateModule(const Double_t xlad,
   TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
   TGeoMedium *medSi  = mgr->GetMedium("ITS_SI$");
 
-  snprintf(volname, 30, "%s%d", AliITSgeomTGeoUpg::GetITSModulePattern() ,fLayerNumber);
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSModulePattern() ,fLayerNumber);
   TGeoVolume *modVol = new TGeoVolume(volname, module, medAir);
 
   modVol->SetVisibility(kFALSE);
   modVol->SetLineColor(1);
 
-  snprintf(volname, 30, "%s%d", AliITSgeomTGeoUpg::GetITSSensorPattern(), fLayerNumber);
+  snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSSensorPattern(), fLayerNumber);
   TGeoVolume *sensVol = new TGeoVolume(volname, sensor, medSi);
 
   sensVol->SetVisibility(kTRUE);
@@ -501,7 +501,7 @@ TGeoVolume* AliITSv11GeometryUpgrade::CreateModule(const Double_t xlad,
 }
 
 //________________________________________________________________________
-Double_t AliITSv11GeometryUpgrade::RadiusOfTurboContainer(){
+Double_t AliITSUv11Layer::RadiusOfTurboContainer(){
 //
 // Computes the inner radius of the air container for the Turbo configuration
 // as the radius of either the circle tangent to the ladder or the circle
@@ -537,7 +537,7 @@ Double_t AliITSv11GeometryUpgrade::RadiusOfTurboContainer(){
 }
 
 //________________________________________________________________________
-void AliITSv11GeometryUpgrade::SetLadderTilt(const Double_t t){
+void AliITSUv11Layer::SetLadderTilt(const Double_t t){
 //
 // Sets the Ladder tilt angle (for turbo layers only)
 //
@@ -559,7 +559,7 @@ void AliITSv11GeometryUpgrade::SetLadderTilt(const Double_t t){
 }
 
 //________________________________________________________________________
-void AliITSv11GeometryUpgrade::SetLadderWidth(const Double_t w){
+void AliITSUv11Layer::SetLadderWidth(const Double_t w){
 //
 // Sets the Ladder width (for turbo layers only)
 //
diff --git a/ITS/UPGRADE/AliITSv11GeometryUpgrade.h b/ITS/UPGRADE/AliITSUv11Layer.h
similarity index 84%
rename from ITS/UPGRADE/AliITSv11GeometryUpgrade.h
rename to ITS/UPGRADE/AliITSUv11Layer.h
index 180b0910495..401b93e6135 100644
--- a/ITS/UPGRADE/AliITSv11GeometryUpgrade.h
+++ b/ITS/UPGRADE/AliITSUv11Layer.h
@@ -14,7 +14,7 @@
 
 
 /*
-  $Id: AliITSv11GeometryUpgrade.h
+  $Id: AliITSUv11Layer.h
  */
 
 #include "AliITSv11Geometry.h"
@@ -24,15 +24,15 @@
 
 class TGeoVolume;
 
-class AliITSv11GeometryUpgrade : public AliITSv11Geometry {
+class AliITSUv11Layer : public AliITSv11Geometry {
   public:
-    AliITSv11GeometryUpgrade();
-    AliITSv11GeometryUpgrade(Int_t debug);
-    AliITSv11GeometryUpgrade(Int_t lay, Int_t debug);
-    AliITSv11GeometryUpgrade(Int_t lay, Bool_t turbo, Int_t debug);
-    AliITSv11GeometryUpgrade(const AliITSv11GeometryUpgrade &source);
-    AliITSv11GeometryUpgrade& operator=(const AliITSv11GeometryUpgrade &source);
-    virtual ~AliITSv11GeometryUpgrade();
+    AliITSUv11Layer();
+    AliITSUv11Layer(Int_t debug);
+    AliITSUv11Layer(Int_t lay, Int_t debug);
+    AliITSUv11Layer(Int_t lay, Bool_t turbo, Int_t debug);
+    AliITSUv11Layer(const AliITSUv11Layer &source);
+    AliITSUv11Layer& operator=(const AliITSUv11Layer &source);
+    virtual ~AliITSUv11Layer();
     //
     Bool_t    IsTurbo() {return fIsTurbo;};
 
@@ -85,7 +85,7 @@ class AliITSv11GeometryUpgrade : public AliITSv11Geometry {
     static const Double_t fgkDefaultSensorThick; // Default sensor thickness
     static const Double_t fgkDefaultLadderThick; // Default ladder thickness
 
-  ClassDef(AliITSv11GeometryUpgrade,0) // ITS v11 Upgrade geometry
+  ClassDef(AliITSUv11Layer,0) // ITS v11 Upgrade geometry
 };
 
 #endif
diff --git a/ITS/UPGRADE/AliITSgeomTGeoUpg.h b/ITS/UPGRADE/AliITSgeomTGeoUpg.h
deleted file mode 100644
index b61f65b0264..00000000000
--- a/ITS/UPGRADE/AliITSgeomTGeoUpg.h
+++ /dev/null
@@ -1,146 +0,0 @@
-#ifndef ALIITSGEOMTGEOUPG_H
-#define ALIITSGEOMTGEOUPG_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-/////////////////////////////////////////////////////////////////////////
-//  AliITSgeomTGeoUpg is a simple interface class to TGeoManager       //
-//  It is used in the simulation and reconstruction in order to        //
-//  query the TGeo ITS geometry                                        //
-//                                                                     //
-//  author - cvetan.cheshkov@cern.ch                                   //
-//  15/02/2007                                                         //
-//  adapted to ITSupg 18/07/2012 - ruben.shahoyan@cern.ch              //
-//  RS: in order to preserve the static character of the class but     //
-//  make it dynamically access geometry, we need to check in every     //
-//  method if the structures are initialized. To be converted to       //
-//  singleton at later stage.                                          //
-//                                                                     //
-/////////////////////////////////////////////////////////////////////////
-
-#include 
-#include 
-
-class TGeoPNEntry;
-class TDatime;
-
-class AliITSgeomTGeoUpg : public TObject {
-
- public:
-  enum {kNLayersOld = 6}; // The number of layers in OLD ITS.
-  enum {kITSVNA, kITSVOld, kITSVUpg}; // ITS version
-
-  AliITSgeomTGeoUpg() { } // Default constructor
-  virtual ~AliITSgeomTGeoUpg() { }// Destructor
-
-  // This function returns the total number of ITS modules 
-  static Int_t GetNModules() {CheckInit(); return fgNModules;}
-  // This function returns the number of detectors/ladder for a given layer 
-  static Int_t GetNDetectors(Int_t lay) {CheckInit(); return (lay<1||lay>fgNLayers) ? 0:fgNDetectors[lay-1];}
-  // This function returns the number of ladders for a given layer
-  static Int_t GetNLadders(Int_t lay)   {CheckInit(); return (lay<1||lay>fgNLayers) ? 0:fgNLadders[lay-1];}
-  // This function returns the number of layers
-  static Int_t GetNLayers()             {CheckInit(); return fgNLayers;}
-
-  // Two methods to map module index to layer,ladder,detector indeces
-  static Int_t  GetModuleIndex(Int_t lay,Int_t lad,Int_t det);
-  static Bool_t GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det);
-
-  static const char *GetSymName(Int_t index); // Get TGeoPNEntry symbolic name
-  static const char *GetSymName(Int_t lay,Int_t lad,Int_t det)
-    { return GetSymName(GetModuleIndex(lay,lad,det)); }
- 
-  // This function returns a pointer to the TGeoHMatrix (local->global)
-  // of a given module index
-  static TGeoHMatrix* GetMatrix(Int_t index);
-  static TGeoHMatrix* GetMatrix(Int_t lay,Int_t lad,Int_t det) { return GetMatrix(GetModuleIndex(lay,lad,det)); }
-
-  static Bool_t GetTranslation(Int_t index, Double_t t[3]);
-  static Bool_t GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) { return GetTranslation(GetModuleIndex(lay,lad,det),t); }
-
-  static Bool_t GetRotation(Int_t index, Double_t r[9]);
-  static Bool_t GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9])
-    { return GetRotation(GetModuleIndex(lay,lad,det),r); }
-
-  // This function returns a pointer to the original TGeoHMatrix (local->global)
-  // for a specific module index
-  static Bool_t GetOrigMatrix(Int_t index, TGeoHMatrix &m);
-  static Bool_t GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m)
-    { return GetOrigMatrix(GetModuleIndex(lay,lad,det),m); }
-
-  static Bool_t GetOrigTranslation(Int_t index, Double_t t[3]);
-  static Bool_t GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3])
-    { return GetOrigTranslation(GetModuleIndex(lay,lad,det),t); }
-
-  static Bool_t GetOrigRotation(Int_t index, Double_t r[9]);
-  static Bool_t GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9])
-    { return GetOrigRotation(GetModuleIndex(lay,lad,det),r); }
-
-  static const TGeoHMatrix* GetTracking2LocalMatrix(Int_t index);
-  static const TGeoHMatrix* GetTracking2LocalMatrix(Int_t lay,Int_t lad,Int_t det)
-    { return GetTracking2LocalMatrix(GetModuleIndex(lay,lad,det)); }
-
-  static Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m);
-  static Bool_t GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m)
-    { return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m); }
-
-  static Bool_t LocalToGlobal(Int_t index, const Double_t *loc, Double_t *glob);
-  static Bool_t LocalToGlobal(Int_t lay, Int_t lad, Int_t det,
-			      const Double_t *loc, Double_t *glob)
-    { return LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob);}
-
-  static Bool_t GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc);
-  static Bool_t GlobalToLocal(Int_t lay, Int_t lad, Int_t det,
-			      const Double_t *glob, Double_t *loc)
-    { return GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc);}
-
-  static Bool_t LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob);
-  static Bool_t GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc);
-  static void   CheckInit() { if (fgVersion==kITSVNA) BuildITS(); }
-  static Int_t  GetLayerDetTypeID(Int_t lr) {CheckInit();  return (lr<1||lr>fgNLayers||!fgLrDetType) ? -1:fgLrDetType[lr-1];}
-
-  static const char* GetITSVolPattern()        {return fgkITSVolName;}
-  static const char* GetITSLayerPattern()      {return fgkITSLrName;}
-  static const char* GetITSLadderPattern()     {return fgkITSLadName;}
-  static const char* GetITSModulePattern()     {return fgkITSModName;}
-  static const char* GetITSSensorPattern()     {return fgkITSSensName;}
-
- private:
-
-  static Bool_t       GetLayer(Int_t index,Int_t &lay,Int_t &index2);
-  static TGeoPNEntry* GetPNEntry(Int_t index);
-  static Int_t        ExtractNumberOfDetectors(const Int_t lay);
-  static Int_t        ExtractNumberOfLadders(const Int_t lay);
-  static Int_t        ExtractLayerDetType(const Int_t lay);
-  static Int_t        ExtractNumberOfLayers();
-  static Bool_t       ReadVersionString(const Char_t *str,Int_t &maj,Int_t &min,TDatime &dt);
-  static void         BuildITSUpg();
-  static void         BuildITSOld();
-  static void         BuildITS();
- //
-  AliITSgeomTGeoUpg(const AliITSgeomTGeoUpg &geom);     // Copy constructor
-  AliITSgeomTGeoUpg& operator=(const AliITSgeomTGeoUpg &geom);// Assignment operator
-
-  static Int_t  fgVersion;             // ITS Version 
-  static Int_t  fgNLayers;             // number of layers
-  static Int_t  fgNModules;            // The total number of modules
-  static Int_t *fgNLadders;            // Array of the number of ladders/layer(layer)
-  static Int_t *fgLrDetType;           // Array of layer detector types
-  static Int_t *fgNDetectors;          // Array of the number of detector/ladder(layer)
-
-
-  // these are hardwired settings for old ITS
-  static const Int_t  fgkNModulesOld;            // The total number of modules
-  static const Int_t  fgkNLaddersOld[kNLayersOld];  // Array of the number of ladders/layer(layer)
-  static const Int_t  fgkNDetectorsOld[kNLayersOld];// Array of the number of detector/ladder(layer)
-  //
-  static const char*  fgkITSVolName;             // ITS mother volume name
-  static const char*  fgkITSLrName;              // ITS Layer name
-  static const char*  fgkITSLadName;             // ITS Ladder name 
-  static const char*  fgkITSModName;             // ITS Module name 
-  static const char*  fgkITSSensName;            // ITS Sensor name 
-
-  ClassDef(AliITSgeomTGeoUpg, 0) // ITS geometry based on TGeo
-};
-
-#endif
diff --git a/ITS/UPGRADE/AliITSresponsePixUpg.cxx b/ITS/UPGRADE/AliITSresponsePixUpg.cxx
deleted file mode 100644
index f8e02de70ad..00000000000
--- a/ITS/UPGRADE/AliITSresponsePixUpg.cxx
+++ /dev/null
@@ -1,46 +0,0 @@
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
-///////////////////////////////////////////////////////////////////////////
-//  Base Response for pixels                      
-//  It is used to set static data members           
-//  connected to parameters equal for all           
-//  the SPD modules                                 
-//
-//  Modified by D. Elia, G.E. Bruno
-//  March-April 2006
-//  September   2007: Coupling params taken out
-//                    left in AliITSCalibrationSPD only
-//
-///////////////////////////////////////////////////////////////////////////
-
-#include "AliITSresponsePixUpg.h"
-
-const Float_t AliITSresponsePixUpg::fgkDiffCoeffDefault = 0.; //change this
-const TString AliITSresponsePixUpg::fgkCouplingOptDefault = "old";
-const Float_t AliITSresponsePixUpg::fgkEccentricityDiffDefault = 0.85;
-
-ClassImp(AliITSresponsePixUpg)	
-//______________________________________________________________________
-AliITSresponsePixUpg::AliITSresponsePixUpg():
-  AliITSresponse(),
-fCouplOpt(0),
-fEccDiff(0){
-
-  // constructor
-  SetCouplingOption(fgkCouplingOptDefault);
-  SetDiffCoeff(fgkDiffCoeffDefault,0.);
-  SetSigmaDiffusionAsymmetry(fgkEccentricityDiffDefault);
-
-}
diff --git a/ITS/UPGRADE/AliITSresponsePixUpg.h b/ITS/UPGRADE/AliITSresponsePixUpg.h
deleted file mode 100644
index dcfdc2b010c..00000000000
--- a/ITS/UPGRADE/AliITSresponsePixUpg.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef ALIITSRESPONSESPD_H
-#define ALIITSRESPONSESPD_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-
-#include "AliITSresponse.h"
-///////////////////////////////////////////
-//                                       //
-// ITS response class for Pixels         //
-///////////////////////////////////////////
-  
-class AliITSresponsePixUpg :  public AliITSresponse {
- public:
-  AliITSresponsePixUpg(); // default constructor
-  virtual ~AliITSresponsePixUpg() {;} // destructror
-  //
-  virtual  void   SetSigmaDiffusionAsymmetry(Double_t ecc)        {fEccDiff=ecc;}   
-  virtual  void   GetSigmaDiffusionAsymmetry(Double_t &ecc) const {ecc=fEccDiff;}
-  //
- protected:
-  //
-  static const Float_t fgkDiffCoeffDefault;  //default for fDiffCoeff
-  static const TString fgkCouplingOptDefault;  // type of pixel Coupling (old or new)
-  static const Float_t fgkEccentricityDiffDefault;//default for fCouplRow 
-  
-    TString fCouplOpt;        // Coupling Option
-    Float_t fEccDiff;         // Eccentricity (i.e. asymmetry parameter) in the Gaussian Diffusion
-
-
-    ClassDef(AliITSresponsePixUpg,1) // pixel upgrade base response class
-};
-
-#endif
diff --git a/ITS/UPGRADE/AliITSsimulationPixUpg.cxx b/ITS/UPGRADE/AliITSsimulationPixUpg.cxx
deleted file mode 100644
index 848d7fc4d78..00000000000
--- a/ITS/UPGRADE/AliITSsimulationPixUpg.cxx
+++ /dev/null
@@ -1,1020 +0,0 @@
-/**************************************************************************
-* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
-*                                                                        *
-* Author: The ALICE Off-line Project.                                    *
-* Contributors are mentioned in the code where appropriate.              *
-*                                                                        *
-* Permission to use, copy, modify and distribute this software and its   *
-* documentation strictly for non-commercial purposes is hereby granted   *
-* without fee, provided that the above copyright notice appears in all   *
-* copies and that both the copyright notice and this permission notice   *
-* appear in the supporting documentation. The authors make no claims     *
-* about the suitability of this software for any purpose. It is          *
-* provided "as is" without express or implied warranty.                  *
-**************************************************************************/
-
-#include 
-#include 
-#include 
-#include 
-#include "AliITS.h"
-#include "AliITSdigitPixUpg.h"
-#include "AliITShit.h"
-#include "AliITSmodule.h"
-#include "AliITSpList.h"
-#include "AliITSCalibrationPixUpg.h"
-#include "AliITSsegmentationPixUpg.h"
-#include "AliITSsimulationPixUpg.h"
-#include "AliLog.h"
-#include "AliRun.h"
-#include "AliMagF.h"
-#include "AliMathBase.h"
-
-//#define DEBUG
-
-using std::endl;
-using std::cout;
-ClassImp(AliITSsimulationPixUpg)
-////////////////////////////////////////////////////////////////////////
-//  Version: 1
-//  Modified by D. Elia, G.E. Bruno, H. Tydesjo 
-//  Fast diffusion code by Bjorn S. Nilsen
-//  March-April 2006
-//  October     2007: GetCalibrationObjects() removed
-//
-//  Version: 0
-//  Written by Boris Batyunya
-//  December 20 1999
-//
-//  Adapted for pixels of ITS upgrade July 2012, ruben.shahoyan@cern.ch
-//
-// AliITSsimulationPixUpg is to do the simulation of pixels
-//
-////////////////////////////////////////////////////////////////////////
-
-//______________________________________________________________________
-AliITSsimulationPixUpg::AliITSsimulationPixUpg():
-AliITSsimulation(),
-fHistos(0),
-fHistName(),
-fCoupling(),
-fLorentz(kFALSE),
-fTanLorAng(0),
-fStrobe(kTRUE),
-fStrobeLenght(4),
-fStrobePhase(-12.5e-9)
-{
-   // Default constructor.
-   // Inputs:
-   //    none.
-   // Outputs:
-   //    none.
-   // Return:
-   //    A default constructed AliITSsimulationPixUpg class.
-
-   AliDebug(1,Form("Calling default constructor"));
-//    Init();
-}
-
-//______________________________________________________________________
-AliITSsimulationPixUpg::AliITSsimulationPixUpg(AliITSDetTypeSimUpg *dettyp):
-AliITSsimulation(dettyp),
-fHistos(0),
-fHistName(),
-fCoupling(),
-fLorentz(kFALSE),
-fTanLorAng(0),
-fStrobe(kTRUE),
-fStrobeLenght(4),
-fStrobePhase(-12.5e-9)
-{
-   // standard constructor
-   // Inputs:
-   //    AliITSsegmentation *seg  A pointer to the segmentation class
-   //                             to be used for this simulation
-   //    AliITSCalibration     *resp A pointer to the responce class to
-   //                             be used for this simulation
-   // Outputs:
-   //    none.
-   // Return:
-   //    A default constructed AliITSsimulationPixUpg class.
-
-   AliDebug(1,Form("Calling standard constructor "));
-   Init();
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::Init()
-{
-  // Initilization
-  // Inputs:
-  //    none.
-  // Outputs:
-  //    none.
-  // Return:
-  //    none.
-  const Double_t kmictocm = 1.0e-4; // convert microns to cm.
-  
-  SetModuleNumber(0);
-  SetEventNumber(0);
-  SetMap(new AliITSpList(GetNPixelsZ(),GetNPixelsX()));
-  AliITSSimuParam* simpar = fDetType->GetSimuParam();
-  AliITSsegmentationPixUpg* seg = (AliITSsegmentationPixUpg*)GetSegmentationModel(-1);
-  Double_t bias = simpar->GetSPDBiasVoltage(); //RS !!!
-//    cout << "Bias Voltage --> " << bias << endl; // dom    
-   simpar->SetDistanceOverVoltage(kmictocm*seg->Dy(),bias);
-// set kind of coupling ("old" or "new")
-   char opt[20] = {"new"};
-   //   simpar->GetSPDCouplingOption(opt); //RS !!!
-   char *old = strstr(opt,"old");
-   if (old) {
-     fCoupling=2;
-   } else {
-     fCoupling=1;
-   } // end if
-   SetLorentzDrift(simpar->GetSPDLorentzDrift());
-   if (fLorentz) SetTanLorAngle(simpar->GetSPDLorentzHoleWeight());
-   //SetStrobeGeneration(kFALSE);
-   if (fStrobe) GenerateStrobePhase();
-}
-
-//______________________________________________________________________
-Bool_t AliITSsimulationPixUpg::SetTanLorAngle(Double_t weightHole) 
-{
-    // This function set the Tangent of the Lorentz angle. 
-    // A weighted average is used for electrons and holes 
-    // Input: Double_t weightHole: wheight for hole: it should be in the range [0,1]
-    // output: Bool_t : kTRUE in case of success
-    //
-    if (!fDetType) {
-      AliError("AliITSsimulationPixUpg::SetTanLorAngle: AliITSDetTypeSim* fDetType not set ");
-      return kFALSE;}
-    if (weightHole<0) {
-       weightHole=0.;
-       AliWarning("AliITSsimulationPixUpg::SetTanLorAngle: You have asked for negative Hole weight");
-       AliWarning("AliITSsimulationPixUpg::SetTanLorAngle: I'm going to use only electrons");
-    }
-    if (weightHole>1) {
-       weightHole=1.;
-       AliWarning("AliITSsimulationPixUpg::SetTanLorAngle: You have asked for weight > 1");
-       AliWarning("AliITSsimulationPixUpg::SetTanLorAngle: I'm going to use only holes");
-    }
-    Double_t weightEle=1.-weightHole;
-    AliITSSimuParam* simpar = fDetType->GetSimuParam();
-    AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
-    if (!fld) AliFatal("The field is not initialized");
-    Double_t bz = fld->SolenoidField();
-    fTanLorAng = TMath::Tan(weightHole*simpar->LorentzAngleHole(bz) +
-                             weightEle*simpar->LorentzAngleElectron(bz));
-    return kTRUE;
-}
-
-//______________________________________________________________________
-AliITSsimulationPixUpg::~AliITSsimulationPixUpg()
-{
-   // destructor
-   // Inputs:
-   //    none.
-   // Outputs:
-   //    none.
-   // Return:
-   //     none.
-
-   if (fHistos) {
-       fHistos->Delete(); 
-       delete fHistos;     
-   } // end if fHistos
-}
-
-//______________________________________________________________________
-AliITSsimulationPixUpg::AliITSsimulationPixUpg(const AliITSsimulationPixUpg &s) : 
-  AliITSsimulation(s),
-  fHistos(s.fHistos),
-  fHistName(s.fHistName),
-  fCoupling(s.fCoupling),
-  fLorentz(s.fLorentz),
-  fTanLorAng(s.fTanLorAng),
-  fStrobe(s.fStrobe),
-  fStrobeLenght(s.fStrobeLenght),
-  fStrobePhase(s.fStrobePhase)
-{
-  //     Copy Constructor
-   // Inputs:
-   //    AliITSsimulationPixUpg &s The original class for which
-   //                                this class is a copy of
-   // Outputs:
-   //    none.
-   // Return:
-
-}
-
-//______________________________________________________________________
-AliITSsimulationPixUpg&  AliITSsimulationPixUpg::operator=(const AliITSsimulationPixUpg &s)
-{
-   //    Assignment operator
-   // Inputs:
-   //    AliITSsimulationPixUpg &s The original class for which
-   //                                this class is a copy of
-   // Outputs:
-   //    none.
-   // Return:
-
-   if (&s == this) return *this;
-   this->fHistos = s.fHistos;
-   fCoupling  = s.fCoupling;
-   fHistName   = s.fHistName;
-   fLorentz   = s.fLorentz;
-   fTanLorAng = s.fTanLorAng;
-   fStrobe       = s.fStrobe;
-   fStrobeLenght = s.fStrobeLenght;
-   fStrobePhase  = s.fStrobePhase;
-   return *this;
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::InitSimulationModule(Int_t module, Int_t event)
-{
-   //  This function creates maps to build the list of tracks for each
-   //  summable digit. Inputs defined by base class.
-   //  Inputs:
-   //    Int_t module   // Module number to be simulated
-   //    Int_t event    // Event number to be simulated
-   //  Outputs:
-   //    none
-   //  Returns:
-   //    none
-
-   AliDebug(1,Form("(module=%d,event=%d)",module,event));
-   const Double_t kmictocm = 1.0e-4; // convert microns to cm.
-   AliITSSimuParam* simpar = fDetType->GetSimuParam();
-   AliITSsegmentationPixUpg* seg = (AliITSsegmentationPixUpg*)GetSegmentationModel(-1);
-   SetModuleNumber(module);
-   SetEventNumber(event);
-   simpar->SetDistanceOverVoltage(kmictocm*seg->Dy(),simpar->GetSPDBiasVoltage(module)); 
-   ClearMap();
-}
-
-//_____________________________________________________________________
-void AliITSsimulationPixUpg::SDigitiseModule(AliITSmodule *mod,Int_t, Int_t event)
-{
-  //  This function begins the work of creating S-Digits.  Inputs defined
-  //  by base class.
-  //  Inputs:
-  //    AliITSmodule *mod  //  module
-  //    Int_t              //  not used
-  //    Int_t event        //  Event number
-  //  Outputs:
-  //    none
-  //  Return:
-  //    test              //  test returns kTRUE if the module contained hits
-  //                      //  test returns kFALSE if it did not contain hits
-  
-  AliDebug(1,Form("(mod=%p, ,event=%d)",mod,event));
-  if (!(mod->GetNhits())) {
-    AliDebug(1,Form("In event %d module %d there are %d hits returning.",
-		    event, mod->GetIndex(),mod->GetNhits()));
-    return;// if module has no hits don't create Sdigits
-  } // end if
-  SetModuleNumber(mod->GetIndex());
-  if (fStrobe) if (event != GetEventNumber()) GenerateStrobePhase(); 
-  SetEventNumber(event);
-  InitSimulationModule( GetModuleNumber() , event );
-  // HitToSDigit(mod);
-  HitToSDigitFast(mod);
-  if (fDetType->GetSimuParam()->GetSPDAddNoisyFlag())   AddNoisyPixels();
-  if (fDetType->GetSimuParam()->GetSPDRemoveDeadFlag()) RemoveDeadPixels();
-  
-  //    cout << "After Remove in SDigitiseModule !!!!!" << endl; // dom
-  //    cout << "Module " << mod->GetIndex() << " Event " << event << endl; // dom
-  WriteSDigits();
-  ClearMap();
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::WriteSDigits()
-{
-   //  This function adds each S-Digit to pList
-   //  Inputs:
-   //    none.
-   //  Outputs:
-   //    none.
-   //  Return:
-   //    none
-   Int_t ix, nix, iz, niz;
-   static AliITS *aliITS = (AliITS*)gAlice->GetModule("ITS");
-
-   AliDebug(1,Form("Writing SDigits for module %d",GetModuleNumber()));
-//    cout << "WriteSDigits for module " << GetModuleNumber() << endl; // dom
-   GetMap()->GetMaxMapIndex(niz, nix);
-   for (iz=0; izGetSignalOnly(iz,ix)>0.0) {
-	 //            cout << " Signal gt 0  iz ix " << iz << ix << " Module " << GetModuleNumber() << endl; // dom
-	 aliITS->AddSumDigit(*(GetMap()->GetpListItem(iz,ix)));
-	 if (AliDebugLevel()>0) {
-	   AliDebug(1,Form("%d, %d",iz,ix));
-	   cout << *(GetMap()->GetpListItem(iz,ix)) << endl;
-	 } // end if GetDebug
-       } // end if GetMap()->GetSignalOnly(iz,ix)>0.0
-     } // end for iz,ix
-   return; 
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::FinishSDigitiseModule()
-{
-   //  This function calls SDigitsToDigits which creates Digits from SDigits
-   //  Inputs:
-   //    none
-   //  Outputs:
-   //    none
-   //  Return
-   //    none
-
-   AliDebug(1,"()");
-//    cout << "FinishSDigitiseModule for module " << GetModuleNumber() << endl; // dom
-   FrompListToDigits(); // Charge To Signal both adds noise and
-   ClearMap();
-   return;
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::DigitiseModule(AliITSmodule *mod,Int_t, Int_t event)
-{
-   //  This function creates Digits straight from the hits and then adds
-   //  electronic noise to the digits before adding them to pList
-   //  Each of the input variables is passed along to HitToSDigit
-   //  Inputs:
-   //    AliITSmodule *mod     module
-   //    Int_t                 Dummy.
-   //    Int_t                 Dummy
-   //  Outputs:
-   //     none.
-   //  Return:
-   //    none.
-
-  if (fStrobe) if (event != GetEventNumber()) GenerateStrobePhase();
-  AliDebug(1,Form("(mod=%p,,0)",mod));
-  // HitToSDigit(mod);
-  InitSimulationModule( mod->GetIndex(), event );
-  HitToSDigitFast(mod);
-  
-  if (fDetType->GetSimuParam()->GetSPDAddNoisyFlag())   AddNoisyPixels();
-  if (fDetType->GetSimuParam()->GetSPDRemoveDeadFlag()) RemoveDeadPixels();
-  //    cout << "After Remove in DigitiseModule in module " << mod->GetIndex() << endl; // dom
-  FrompListToDigits();
-  ClearMap();
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::HitToSDigit(AliITSmodule *mod)
-{
-   // Does the charge distributions using Gaussian diffusion charge charing.
-   // Inputs:
-   //    AliITSmodule *mod  Pointer to this module
-   // Output:
-   //    none.
-   // Return:
-   //    none.
-   const Double_t kmictocm = 1.0e-4; // convert microns to cm.
-   const Double_t kBunchLenght = 25e-9; // LHC clock
-   TObjArray *hits = mod->GetHits();
-   Int_t nhits = hits->GetEntriesFast();
-   Int_t h,ix,iz,i;
-   Int_t idtrack;
-   Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0,ld=0.0;
-   Double_t x,y,z,t,tp,st,dt=0.2,el,sig,sigx,sigz,fda;
-   AliITSsegmentationPixUpg* seg = (AliITSsegmentationPixUpg*)GetSegmentationModel(-1);
-   AliITSSimuParam *simpar = fDetType->GetSimuParam();
-   Double_t thick = 0.5*kmictocm*seg->Dy();  // Half Thickness
-   simpar->GetSPDSigmaDiffusionAsymmetry(fda);  //
-
-   AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
-   if (nhits<=0) return;
-   for (h=0;h0) {
-       AliDebug(1,Form("Hits, %d", h));
-       cout << *(mod->GetHit(h)) << endl;
-     } // end if GetDebug
-     // Check if the hit is inside readout window
-     if (fStrobe)
-       if ((mod->GetHit(h)->GetTOF() < fStrobePhase) ||
-	   (mod->GetHit(h)->GetTOF() > (fStrobePhase+(Double_t)fStrobeLenght*kBunchLenght))) continue;
-     if (!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
-     st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
-     if (st>0.0) {
-       st = (Double_t)((Int_t)(st/kmictocm)); // number of microns
-       if (st<=1.0) st = 1.0;
-       dt = 1.0/st;
-       for (t=0.0;t<1.0;t+=dt) { // Integrate over t
-	 tp  = t+0.5*dt;
-	 x   = x0+x1*tp;
-	 y   = y0+y1*tp;
-	 z   = z0+z1*tp;
-	 if (!(seg->LocalToDet(x,z,ix,iz))) continue; // outside
-	 //el  = res->GeVToCharge((Double_t)(dt*de));
-	 el  = dt * de / simpar->GetGeVToCharge();
-	 //
-	 if (GetDebug(1)) if (el<=0.0) cout<<"el="<GetHits();
-  Int_t nhits = hits->GetEntriesFast();
-  Int_t h,ix,iz,i;
-  Int_t idtrack;
-  Double_t x0=0.0,x1=0.0,y0=0.0,y1=0.0,z0=0.0,z1=0.0,de=0.0,ld=0.0;
-  Double_t x,y,z,t,st,el,sig,sigx,sigz,fda;
-  AliITSsegmentationPixUpg* seg = (AliITSsegmentationPixUpg*)GetSegmentationModel(-1);
-  AliITSSimuParam* simpar = fDetType->GetSimuParam();
-  Double_t thick = 0.5*kmictocm*seg->Dy();  // Half thickness
-  simpar->GetSPDSigmaDiffusionAsymmetry(fda);
-  //    cout << "Half Thickness " << thick << endl;  // dom
-  //    cout << "Diffusion asymm " << fda << endl;  // dom
-  
-  AliDebug(1,Form("(mod=%p) fCoupling=%d",mod,fCoupling));
-  if (nhits<=0) return;
-  for (h=0;h0) {
-      AliDebug(1,Form("Hits, %d", h));
-      cout << *(mod->GetHit(h)) << endl;
-    } // end if GetDebug
-    // Check if the hit is inside readout window
-    if (fStrobe)
-      if ((mod->GetHit(h)->GetTOF() < fStrobePhase) ||
-	  (mod->GetHit(h)->GetTOF() > (fStrobePhase+(Double_t)fStrobeLenght*kBunchLenght))) continue;
-    if (!mod->LineSegmentL(h,x0,x1,y0,y1,z0,z1,de,idtrack)) continue;
-    st = TMath::Sqrt(x1*x1+y1*y1+z1*z1);
-    if (st>0.0) for (i=0;iLocalToDet(x,z,ix,iz))) continue; // outside
-	el  = kwi[i]*de/simpar->GetGeVToCharge();
-	if (GetDebug(1)) {
-	  if (el<=0.0) cout<<"el="<LocalToDet(x,z,ix,iz))) continue; // outside
-      el  = de / simpar->GetGeVToCharge();
-      sig = simpar->SigmaDiffusion1D(TMath::Abs(thick + y));
-      sigx=sig;
-      sigz=sig*fda;
-      if (fLorentz) ld=(y+thick)*fTanLorAng;
-      SpreadChargeAsym(x,z,ix,iz,el,sigx,sigz,ld,idtrack,h);
-    } // end if st>0.0
-    
-  } // Loop over all hits h
-  
-  // Coupling
-  switch (fCoupling) {
-  default:
-    break;
-  case 1: // case 3:
-    for (i=0;iGetEntries();i++)
-      if (GetMap()->GetpListItem(i)==0) continue;
-      else{
-	GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);
-	SetCoupling(iz,ix,idtrack,h);
-      } // end for i
-    break;
-  case 2: // case 4:
-    for (i=0;iGetEntries();i++)
-      if (GetMap()->GetpListItem(i)==0) continue;
-      else {
-	GetMap()->GetMapIndex(GetMap()->GetpListItem(i)->GetIndex(),iz,ix);  
-	SetCouplingOld(iz,ix,idtrack,h);
-      } // end for i
-    break;
-  } // end switch
-  if (GetDebug(2))Info("HitToSDigit","Finished fCoupling=%d",fCoupling);
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::SpreadCharge(Double_t x0,Double_t z0,
-					  Int_t ix0,Int_t iz0,
-					  Double_t el,Double_t sig,Double_t ld,
-					  Int_t t,Int_t hi)
-{
-   // Spreads the charge over neighboring cells. Assume charge is distributed
-   // as charge(x,z) = (el/2*pi*sig*sig)*exp(-arg)
-   // arg=((x-x0)*(x-x0)/2*sig*sig)+((z-z0*z-z0)/2*sig*sig)
-   // if fLorentz=kTRUE, then x0=x0+ld (Lorentz drift taken into account)
-   // Defined this way, the integral over all x and z is el.
-   // Inputs:
-   //    Double_t x0   x position of point where charge is liberated
-   //    Double_t z0   z position of point where charge is liberated
-   //    Int_t    ix0  row of cell corresponding to point x0
-   //    Int_t    iz0  columb of cell corresponding to point z0
-   //    Double_t el   number of electrons liberated in this step
-   //    Double_t sig  Sigma difusion for this step (y0 dependent)
-   //    Double_t ld   lorentz drift in x for this step (y0 dependent)
-   //    Int_t    t    track number
-   //    Int_t    ti   hit track index number
-   //    Int_t    hi   hit "hit" index number
-   // Outputs:
-   //     none.
-   // Return:
-   //     none.
-   const Int_t knx = 3,knz = 2;
-   const Double_t kRoot2 = 1.414213562; // Sqrt(2).
-   const Double_t kmictocm = 1.0e-4; // convert microns to cm.
-   Int_t ix,iz,ixs,ixe,izs,ize;
-   Float_t x,z;
-   Double_t x1,x2,z1,z2,s,sp;
-   AliITSsegmentationPixUpg* seg = (AliITSsegmentationPixUpg*)GetSegmentationModel(-1);
-   //
-   if (GetDebug(4)) Info("SpreadCharge","(x0=%e,z0=%e,ix0=%d,iz0=%d,el=%e,sig=%e,t=%d,i=%d)",x0,z0,ix0,iz0,el,sig,t,hi);
-   if (sig<=0.0) { // if sig<=0 No diffusion to simulate.
-     GetMap()->AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
-     if (GetDebug(2)) cout << "sig<=0.0=" << sig << endl; // end if GetDebug
-     return;
-   } // end if
-   sp = 1.0/(sig*kRoot2);
-   if (GetDebug(2)) cout << "sig=" << sig << " sp=" << sp << endl; // end if GetDebug
-   ixs = TMath::Max(-knx+ix0,0);
-   ixe = TMath::Min(knx+ix0,seg->Npx()-1);
-   izs = TMath::Max(-knz+iz0,0);
-   ize = TMath::Min(knz+iz0,seg->Npz()-1);
-   for (ix=ixs;ix<=ixe;ix++) for (iz=izs;iz<=ize;iz++) {
-       seg->DetToLocal(ix,iz,x,z); // pixel center
-       x1  = x;
-       z1  = z;
-       x2  = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
-       x1 -= 0.5*kmictocm*seg->Dpx(ix);  // Lower
-       z2  = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
-       z1 -= 0.5*kmictocm*seg->Dpz(iz);  // Lower
-       x1 -= x0+ld; // Distance from where track traveled (taking into account the Lorentz drift)
-       x2 -= x0+ld; // Distance from where track traveled (taking into account the Lorentz drift)
-       z1 -= z0; // Distance from where track traveled
-       z2 -= z0; // Distance from where track traveled
-       s   = 0.25; // Correction based on definision of Erfc
-       s  *= AliMathBase::ErfcFast(sp*x1) - AliMathBase::ErfcFast(sp*x2);
-       if (GetDebug(3)) {
-	 cout <<"el="<AddSignal(iz0,ix0,t,hi,GetModuleNumber(),el);
-     if (GetDebug(2)) {
-       cout << "sigx<=0.0=" << sigx << endl;
-       cout << "sigz<=0.0=" << sigz << endl;
-     } // end if GetDebug
-     return;
-   } // end if
-   spx = 1.0/(sigx*kRoot2);     spz = 1.0/(sigz*kRoot2);
-   if (GetDebug(2)) {
-     cout << "sigx=" << sigx << " spx=" << spx << endl;
-     cout << "sigz=" << sigz << " spz=" << spz << endl;
-   } // end if GetDebug
-   ixs = TMath::Max(-knx+ix0,0);
-   ixe = TMath::Min(knx+ix0,seg->Npx()-1);
-   izs = TMath::Max(-knz+iz0,0);
-   ize = TMath::Min(knz+iz0,seg->Npz()-1);
-   for (ix=ixs;ix<=ixe;ix++) for (iz=izs;iz<=ize;iz++) {
-       seg->DetToLocal(ix,iz,x,z); // pixel center
-       x1  = x;
-       z1  = z;
-       x2  = x1 + 0.5*kmictocm*seg->Dpx(ix); // Upper
-       x1 -= 0.5*kmictocm*seg->Dpx(ix);  // Lower
-       z2  = z1 + 0.5*kmictocm*seg->Dpz(iz); // Upper
-       z1 -= 0.5*kmictocm*seg->Dpz(iz);  // Lower
-       x1 -= x0+ld; // Distance from where track traveled (taking into account the Lorentz drift)
-       x2 -= x0+ld; // Distance from where track traveled (taking into account the Lorentz drift)
-       z1 -= z0; // Distance from where track traveled
-       z2 -= z0; // Distance from where track traveled
-       s   = 0.25; // Correction based on definision of Erfc
-       s  *= AliMathBase::ErfcFast(spx*x1) - AliMathBase::ErfcFast(spx*x2);
-       if (GetDebug(3)) cout <<"el="<GetSimuParam();
-  if (GetDebug(1)) Info("FrompListToDigits","()");
-  for (iz=0; izApplySPDBaselineAndNoise();
-      UpdateMapNoise(ix,iz,electronics);
-      //
-      // Apply Threshold and write Digits.
-      sig = GetMap()->GetSignalOnly(iz,ix);
-      FillHistograms(ix,iz,sig+electronics);
-      if (GetDebug(3)) {
-	cout<threshold("<GetNEntries()) {
-	  dig.SetTrack(j,GetMap()->GetTrack(iz,ix,j));
-	  dig.SetHit(j,GetMap()->GetHit(iz,ix,j));
-	}else { // Default values
-	  dig.SetTrack(j,-3);
-	  dig.SetHit(j,-1);
-	} // end if GetMap()
-      } // end for j
-      if (GetDebug(3)) {
-	cout<GetpListItem(iz,ix))<AddSimDigit(0,&dig);
-      // simulate fo signal response for this pixel hit:
-      //RS      fDetType->ProcessSPDDigitForFastOr(fModule, dig.GetCoord1(), dig.GetCoord2());
-    } //  for ix/iz
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::CreateHistograms() 
-{
-   // create 1D histograms for tests
-   // Inputs:
-   //    none.
-   // Outputs:
-   //    none.
-   // Return:
-   //     none.
-
-   if (GetDebug(1)) Info("CreateHistograms","create histograms");
-
-   fHistos = new TObjArray(GetNPixelsZ());
-   fHistName="pix_";
-   for (Int_t i=0;iAddAt(new TH1F(fHistName.Data(),"pixel maps",
-			     GetNPixelsX(),0.,(Double_t)GetNPixelsX()),i);
-   } // end for i
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::FillHistograms(Int_t ix,Int_t iz,Double_t v) 
-{
-   // Fill the histogram
-   // Inputs:
-   //    none.
-   // Outputs:
-   //    none.
-   // Return:
-   //     none.
-  
-  if (!GetHistArray()) return; // Only fill if setup.
-  if (GetDebug(2)) Info("FillHistograms","fill histograms");
-  GetHistogram(iz)->Fill(ix,v);
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::ResetHistograms() 
-{
-  // Reset histograms for this detector
-  // Inputs:
-  //    none.
-  // Outputs:
-  //    none.
-  // Return:
-  //     none.
-  
-  if (!GetHistArray()) return; // Only fill if setup.
-  if (GetDebug(2)) Info("FillHistograms","fill histograms");
-  for ( int i=0;iAt(i))    ((TH1F*)fHistos->At(i))->Reset();
-  //
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::SetCoupling(Int_t col, Int_t row, Int_t ntrack, Int_t idhit) {
-  //  Take into account the coupling between adiacent pixels.
-  //  The parameters probcol and probrow are the probability of the
-  //  signal in one pixel shared in the two adjacent pixels along
-  //  the column and row direction, respectively.
-  //  Note pList is goten via GetMap() and module is not need any more.
-  //  Otherwise it is identical to that coded by Tiziano Virgili (BSN).
-  //Begin_Html
-  /*
-    
-     
-
- - . - -
-   */
-   //End_Html
-   // Inputs:
-   //    Int_t col            z cell index
-   //    Int_t row            x cell index
-   //    Int_t ntrack         track incex number
-   //    Int_t idhit          hit index number
-   // Outputs:
-   //    none.
-   // Return:
-   //     none.
-   Int_t j1,j2,flag=0;
-   Double_t pulse1,pulse2;
-   Double_t couplR=0.0,couplC=0.0;
-   Double_t xr=0.;
-
-   GetCouplings(couplC,couplR);
-   if (GetDebug(3)) Info("SetCoupling","(col=%d,row=%d,ntrack=%d,idhit=%d) "
-			 "Calling SetCoupling couplC=%e couplR=%e",
-			 col,row,ntrack,idhit,couplC,couplR);
-   j1 = col;
-   j2 = row;
-   pulse1 = GetMap()->GetSignalOnly(col,row);
-   pulse2 = pulse1;
-   for (Int_t isign=-1;isign<=1;isign+=2) {// loop in col direction
-     do {
-       j1 += isign;
-       xr = gRandom->Rndm();
-       if ((j1<0) || (j1>GetNPixelsZ()-1) || (xr>couplC)) {
-	 j1 = col;
-	 flag = 1;
-       } else {
-	 UpdateMapSignal(row,j1,ntrack,idhit,pulse1);
-	 //  flag = 0;
-	 flag = 1; // only first next!!
-       } // end if
-     } while (flag == 0);
-     // loop in row direction
-     do {
-       j2 += isign;
-       xr = gRandom->Rndm();
-       if ((j2<0) || (j2>GetNPixelsX()-1) || (xr>couplR)) {
-	 j2 = row;
-	 flag = 1;
-       } else {
-	 UpdateMapSignal(j2,col,ntrack,idhit,pulse2);
-	 //  flag = 0;
-	 flag = 1; // only first next!!
-       } // end if
-     } while(flag == 0);
-   } // for isign
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::SetCouplingOld(Int_t col, Int_t row,Int_t ntrack,Int_t idhit) 
-{
-  //  Take into account the coupling between adiacent pixels.
-  //  The parameters probcol and probrow are the fractions of the
-  //  signal in one pixel shared in the two adjacent pixels along
-  //  the column and row direction, respectively.
-  //Begin_Html
-  /*
-    
-    
-
- - . - -
-  */
-  //End_Html
-  // Inputs:
-  //    Int_t col            z cell index
-  //    Int_t row            x cell index
-  //    Int_t ntrack         track incex number
-  //    Int_t idhit          hit index number
-  //    Int_t module         module number
-  // Outputs:
-  //    none.
-  // Return:
-  //     none.
-  Int_t j1,j2,flag=0;
-  Double_t pulse1,pulse2;
-  Double_t couplR=0.0,couplC=0.0;
-  
-  GetCouplings(couplC,couplR);
-  
-  //  Debugging ...
-  //    cout << "Threshold --> " << GetThreshold() << endl;  // dom
-  //    cout << "Couplings --> " << couplC << " " << couplR << endl;  // dom
-  
-  if (GetDebug(3)) Info("SetCouplingOld","(col=%d,row=%d,ntrack=%d,idhit=%d) "
-                        "Calling SetCoupling couplC=%e couplR=%e",
-                        col,row,ntrack,idhit,couplC,couplR);
-  for (Int_t isign=-1;isign<=1;isign+=2) {// loop in col direction
-    pulse1 = GetMap()->GetSignalOnly(col,row);
-    pulse2 = pulse1;
-    j1 = col;
-    j2 = row;
-    do{
-      j1 += isign;
-      pulse1 *= couplC;
-      if ((j1<0)||(j1>GetNPixelsZ()-1)||(pulse1GetSignalOnly(col,row);
-	j1 = col;
-	flag = 1;
-      }else{
-	UpdateMapSignal(row,j1,ntrack,idhit,pulse1);
-	// flag = 0;
-	flag = 1;  // only first next !!
-      } // end if
-    } while(flag == 0);
-    // loop in row direction
-    do{
-      j2 += isign;
-      pulse2 *= couplR;
-      if ((j2<0)||(j2>(GetNPixelsX()-1))||(pulse2GetSignalOnly(col,row);
-	j2 = row;
-	flag = 1;
-      }else{
-	UpdateMapSignal(j2,col,ntrack,idhit,pulse2);
-	// flag = 0;
-	flag = 1; // only first next!!
-      } // end if
-    } while(flag == 0);
-  } // for isign
-}
-
-//______________________________________________________________________
-void AliITSsimulationPixUpg::GenerateStrobePhase()
-{
-  // Generate randomly the strobe
-  // phase w.r.t to the LHC clock
-  // Done once per event
-  const Double_t kBunchLenght = 25e-9; // LHC clock
-  fStrobePhase = ((Double_t)gRandom->Integer(fStrobeLenght))*kBunchLenght-
-    (Double_t)fStrobeLenght*kBunchLenght+
-    kBunchLenght/2;
-}
-
diff --git a/ITS/UPGRADE/AliITSsimulationPixUpg.h b/ITS/UPGRADE/AliITSsimulationPixUpg.h
deleted file mode 100644
index 9afa6f53bff..00000000000
--- a/ITS/UPGRADE/AliITSsimulationPixUpg.h
+++ /dev/null
@@ -1,126 +0,0 @@
-#ifndef ALIITSSIMULATIONPIXUPG_H
-#define ALIITSSIMULATIONPIXUPG_H
-
-/* Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
-* See cxx source for full Copyright notice                               */
-
-////////////////////////////////////////////////////////////
-// Simulation class for upgrade pixels                    //
-////////////////////////////////////////////////////////////
-
-#include "TObjArray.h"
-#include "AliITSsimulation.h"
-#include "AliITSsegmentationPixUpg.h"
-#include "AliITSDetTypeSimUpg.h"
-
-class TH1F;
-class AliITSmodule;
-
-//-------------------------------------------------------------------
-
-class AliITSsimulationPixUpg : public AliITSsimulation {
-public:
-  AliITSsimulationPixUpg();
-  AliITSsimulationPixUpg(AliITSDetTypeSimUpg *dettyp);
-  virtual ~AliITSsimulationPixUpg();
-  AliITSsimulationPixUpg(const AliITSsimulationPixUpg &source); 
-  AliITSsimulationPixUpg& operator=(const AliITSsimulationPixUpg &s);
-  void Init();
-  //
-  // General User calling routines
-  // Initilize simulation for a specific event and module
-  void InitSimulationModule(Int_t module, Int_t event);
-  // Finish and write S Digitization
-  void FinishSDigitiseModule();
-  // From hits to Digits, without creating SDigits
-  void DigitiseModule(AliITSmodule *mod,Int_t,Int_t);
-  //
-   // More or less Internal Routines
-   // Create S Digits from specific module
-   void SDigitiseModule(AliITSmodule *mod, Int_t mask, Int_t event);
-   // Write S Digits to the tree of SDigits.
-   void WriteSDigits();
-   // fill pList from hits, charge sharing, diffusion, coupling
-   void HitToSDigit(AliITSmodule *mod);
-   // fill pList from hits, charge sharing, diffusion, coupling  (faster method optimized by Bjorne)
-   void HitToSDigitFast(AliITSmodule *mod);
-   // Adds noisy pixels to pList
-   void AddNoisyPixels();   
-   // Removes dead pixels from pList
-   void RemoveDeadPixels();
-   // Take pList of signals and apply noise... create Digits
-   void FrompListToDigits();
-   // This set the Lorentz drift of Electrons and Holes: by deafult equal weights to Electrons and Holes
-   void SetLorentzDrift(Bool_t b=kFALSE)
-   {fLorentz=b; if(fLorentz) SetTanLorAngle();};
-   // This function set the relative contribution between holes and electrons: use  0<=WeightHole<=1
-   Bool_t SetTanLorAngle(Double_t WeightHole=1.0);
-   // Getter for the Lorentz angle
-   Double_t GetTanLorAngle() const {return fTanLorAng;};
-   //
-   void CreateHistograms();
-   void FillHistograms(Int_t ix,Int_t iz,Double_t v=1.0);
-   void ResetHistograms();
-   TH1F* GetHistogram(Int_t i){return (TH1F*)(fHistos->At(i));}// get histogram
-   TObjArray*  GetHistArray() {return fHistos;}// get hist array
-   TString& GetHistName(){return fHistName;}
-   void SetHistName(TString &n){fHistName = n;}
-   //
-   // For backwards compatibility
-   void SDigitsToDigits(){ FinishSDigitiseModule();};
-   void HitToDigit(AliITSmodule *mod){
-     // Standard interface to DigitiseModule  Inputs: AliITSmodule *mod  Pointer to this module
-     DigitiseModule(mod,GetModuleNumber(),0);};
-   
-   // This sets fStrobe flag and allows generating the strobe and applying it to select hits 
-   void SetStrobeGeneration(Bool_t b=kFALSE) {fStrobe=b;};
-   void GenerateStrobePhase();
-   
- private:
-   void SpreadCharge(Double_t x0,Double_t z0,Int_t ix0,Int_t iz0,
-		     Double_t el,Double_t sig,Double_t ld,Int_t t,Int_t hi);
-   void SpreadChargeAsym(Double_t x0,Double_t z0,Int_t ix0,Int_t iz0,
-			 Double_t el,Double_t sigx,Double_t sigz,Double_t ld,Int_t t,Int_t hi);
-   void UpdateMapSignal(Int_t ix,Int_t iz,Int_t trk,Int_t ht,Double_t signal){
-     //  This function adds a signal to the pList from the pList class
-     //  Inputs: iz column number  ix row number  trk track number  ht hit number  signal signal strength
-     GetMap()->AddSignal(iz,ix,trk,ht,GetModuleNumber(),signal);};
-   void UpdateMapNoise(Int_t ix,Int_t iz,Float_t noise){
-     //  This function adds noise to data in the MapA2 as well as the pList
-     //  Inputs:  iz column number  ix row number  noise electronic noise generated by FrompListToDigits
-     GetMap()->AddNoise(iz,ix,GetModuleNumber(),noise);}
-   // Get a pointer to the segmentation object
-   virtual AliITSsegmentation* GetSegmentationModel(Int_t /*dt*/){return fDetType->GetSegmentationModel(AliITSDetTypeSimUpg::kDetPixUpg);}
-   // set pointer to segmentation objec
-   virtual void SetSegmentationModel(Int_t /*dt*/, AliITSsegmentation *seg){fDetType->SetSegmentationModel(AliITSDetTypeSimUpg::kDetPixUpg,seg);}
-   // Bari-Salerno Coupling parameters
-   // "New" coupling routine  Tiziano Virgili
-   void SetCoupling(Int_t col,Int_t row,Int_t ntrack,Int_t idhit);
-   // "Old" coupling routine  Rocco Caliandro
-   void SetCouplingOld(Int_t col, Int_t row,Int_t ntrack,Int_t idhit);
-   // Getters for data kept in fSegmentation and fResponse.
-   // Returns the Threshold in electrons
-   Double_t GetThreshold(){
-     Double_t th,sig;AliITSSimuParam* simpar = fDetType->GetSimuParam(); 
-     simpar->SPDThresholds(GetModuleNumber(),th,sig);return th;}; 
-   // Returns the couplings Columb and Row.
-   void GetCouplings(Double_t &cc,Double_t &cr){
-     AliITSSimuParam* simpar = fDetType->GetSimuParam();
-     simpar->GetSPDCouplingParam(cc,cr);};
-   // Returns the number of pixels in x
-   Int_t GetNPixelsX(){return GetSegmentationModel(-1)->Npx();};
-   // Returns the number of pixels in z
-   Int_t GetNPixelsZ(){return GetSegmentationModel(-1)->Npz();};
-   
-   TObjArray    *fHistos;         //! just in case for histogramming
-   TString       fHistName;      //! Histogram name
-   Int_t         fCoupling;     // Sets the coupling to be used.
-                                // ==1 use SetCoupling, ==2 use SetCouplingOld
-   Bool_t        fLorentz;      // kTRUE if Lorentz drift has been allowed 
-   Double_t      fTanLorAng;    //! Tangent of the Lorentz Angle (weighted average for hole and electrons)
-   Bool_t        fStrobe;       // kTRUE if readout strobe with proper phase applied to select hits
-   Int_t         fStrobeLenght; // Strobe signal lenght in units of 25 ns
-   Double_t      fStrobePhase;  // The phase of the strobe signal with respect to the trigger
-   ClassDef(AliITSsimulationPixUpg,1)  // Simulation of pixel clusters
- };
-#endif 
diff --git a/ITS/UPGRADE/CMakelibITSUpgradeBase.pkg b/ITS/UPGRADE/CMakelibITSUpgradeBase.pkg
index 97b72864662..239f5c1800a 100644
--- a/ITS/UPGRADE/CMakelibITSUpgradeBase.pkg
+++ b/ITS/UPGRADE/CMakelibITSUpgradeBase.pkg
@@ -30,11 +30,12 @@ v0/AliITSDigitUpgrade.cxx
 v0/AliITSsegmentationUpgrade.cxx 
 v0/AliITSRecPointU.cxx 
 #
-AliITSInitGeometryUpg.cxx 
-AliITSLoaderUpg.cxx 
-AliITSgeomTGeoUpg.cxx
-AliITSCalibrationPixUpg.cxx
-AliITSsegmentationPixUpg.cxx
+AliITSULoader.cxx 
+AliITSUGeomTGeo.cxx
+AliITSUCalibrationPix.cxx
+AliITSUSegmentationPix.cxx
+AliITSUSensMap.cxx
+AliITSUSDigit.cxx
 )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
diff --git a/ITS/UPGRADE/CMakelibITSUpgradeSim.pkg b/ITS/UPGRADE/CMakelibITSUpgradeSim.pkg
index 1ba44896f52..bbde3fd8fb4 100644
--- a/ITS/UPGRADE/CMakelibITSUpgradeSim.pkg
+++ b/ITS/UPGRADE/CMakelibITSUpgradeSim.pkg
@@ -29,13 +29,16 @@ set ( SRCS
 v0/AliITSupgrade.cxx 
 v0/AliITSupgradeDigitizer.cxx 
 #
-AliITSUpg.cxx 
-AliITSvUpgrade.cxx 
-AliITSv11GeometryUpgrade.cxx 
+AliITSU.cxx 
+AliITSUv11.cxx 
+AliITSUv11Layer.cxx 
 AliITSv11GeomBeamPipe.cxx
-AliITSDetTypeSimUpg.cxx
-AliITSsimulationPixUpg.cxx
-AliITSdigitPixUpg.cxx
+AliITSUModule.cxx
+AliITSUSimulation.cxx
+AliITSUSimulationPix.cxx
+AliITSUDigitPix.cxx
+AliITSUDigitizer.cxx
+AliITSUHit.cxx
 )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
diff --git a/ITS/UPGRADE/ITSUpgradeBaseLinkDef.h b/ITS/UPGRADE/ITSUpgradeBaseLinkDef.h
index 83c136d7837..399b292940d 100644
--- a/ITS/UPGRADE/ITSUpgradeBaseLinkDef.h
+++ b/ITS/UPGRADE/ITSUpgradeBaseLinkDef.h
@@ -15,9 +15,10 @@
 #pragma link C++ class  AliITSRecPointU+;
 // v0 part <<<
 //
-#pragma link C++ class  AliITSInitGeometryUpg+;
-#pragma link C++ class  AliITSLoaderUpg+;
-#pragma link C++ class  AliITSgeomTGeoUpg+;
-#pragma link C++ class  AliITSCalibrationPixUpg+;
-#pragma link C++ class  AliITSsegmentationPixUpg+;
+#pragma link C++ class  AliITSULoader+;
+#pragma link C++ class  AliITSUGeomTGeo+;
+#pragma link C++ class  AliITSUCalibrationPix+;
+#pragma link C++ class  AliITSUSegmentationPix+;
+#pragma link C++ class  AliITSUSensMap+;
+#pragma link C++ class  AliITSUSDigit+;
 #endif
diff --git a/ITS/UPGRADE/ITSUpgradeSimLinkDef.h b/ITS/UPGRADE/ITSUpgradeSimLinkDef.h
index d9b617b250c..a8892e12b45 100644
--- a/ITS/UPGRADE/ITSUpgradeSimLinkDef.h
+++ b/ITS/UPGRADE/ITSUpgradeSimLinkDef.h
@@ -17,13 +17,16 @@
 #pragma link C++ class  AliITSupgradeDigitizer+;
 //v0 part <<<
 // 
-#pragma link C++ class  AliITSUpg+;
-#pragma link C++ class  AliITSvUpgrade+;
-#pragma link C++ class  AliITSv11GeometryUpgrade+;
+#pragma link C++ class  AliITSU+;
+#pragma link C++ class  AliITSUv11+;
+#pragma link C++ class  AliITSUv11Layer+;
 #pragma link C++ class  AliITSv11GeomBeamPipe+;
-#pragma link C++ class  AliITSDetTypeSimUpg+;
-#pragma link C++ class  AliITSsimulationPixUpg+;
-#pragma link C++ class  AliITSdigitPixUpg+;
+#pragma link C++ class  AliITSUModule+;
+#pragma link C++ class  AliITSUSimulation+;
+#pragma link C++ class  AliITSUSimulationPix+;
+#pragma link C++ class  AliITSUDigitPix+;
+#pragma link C++ class  AliITSUDigitizer+;
+#pragma link C++ class  AliITSUHit+;
 
 
 #endif
-- 
2.39.3