]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSDetTypeSim.cxx
CreateVertexer now instantiates by default a AliITSVertexer3D object.
[u/mrichter/AliRoot.git] / ITS / AliITSDetTypeSim.cxx
index 2b3371c7194c22d48a47931212187e7bb2d579d6..1b98518f72e9b2c993bb0d4b96d7a4d2351c4867 100644 (file)
 #include "AliITSpListItem.h"
 #include "AliITSresponseSDD.h"
 #include "AliITSCalibrationSDD.h"
+#include "AliITSMapSDD.h"
+#include "AliITSDriftSpeedArraySDD.h"
+#include "AliITSDriftSpeedSDD.h"
+#include "AliITSCalibrationSSD.h"
+#include "AliITSNoiseSSD.h"
+#include "AliITSGainSSD.h"
+#include "AliITSBadChannelsSSD.h"
 #include "AliITSCalibrationSSD.h"
 #include "AliITSsegmentationSPD.h"
 #include "AliITSsegmentationSDD.h"
@@ -64,19 +71,23 @@ ClassImp(AliITSDetTypeSim)
 //----------------------------------------------------------------------
 AliITSDetTypeSim::AliITSDetTypeSim():
 TObject(),
-fGeom(),         //
 fSimulation(),   // [NDet]
 fSegmentation(), // [NDet]
 fCalibration(),     // [NMod]
 fPreProcess(),   // [] e.g. Fill fHitModule with hits
 fPostProcess(),  // [] e.g. Wright Raw data
 fNSDigits(0),    //! number of SDigits
-fSDigits(),      //! [NMod][NSDigits]
+fSDigits("AliITSpListItem",1000),   
 fNDigits(0),     //! number of Digits
+fRunNumber(0),   //! Run number (to access DB)
 fDigits(),       //! [NMod][NDigits]
+fSimuPar(0),
+fDDLMapSDD(0),
 fHitClassName(), // String with Hit class name.
 fSDigClassName(),// String with SDigit class name.
-fDigClassName(){ // String with digit class name.
+fDigClassName(), // String with digit class name.
+fLoader(0),      // local pointer to loader
+fFirstcall(kTRUE){ // flag
     // Default Constructor
     // Inputs:
     //    none.
@@ -84,23 +95,18 @@ fDigClassName(){ // String with digit class name.
     //    none.
     // Return:
     //    A properly zero-ed AliITSDetTypeSim class.
-  fGeom = 0;
+
   fSimulation = new TObjArray(fgkNdettypes);
   fSegmentation = new TObjArray(fgkNdettypes);
   fSegmentation->SetOwner(kTRUE);
-  fCalibration = 0;
-  fPreProcess = 0;
-  fPostProcess = 0;
-  fNSDigits = 0;
-  fSDigits = new TClonesArray("AliITSpListItem",1000);
   fDigits = new TObjArray(fgkNdettypes);
   fNDigits = new Int_t[fgkNdettypes];
-  fLoader = 0;
+  fDDLMapSDD=new AliITSDDLModuleMapSDD();
+  fSimuPar= new AliITSSimuParam();
   fNMod[0] = fgkDefaultNModulesSPD;
   fNMod[1] = fgkDefaultNModulesSDD;
   fNMod[2] = fgkDefaultNModulesSSD;
   SetRunNumber();
-  fFirstcall = kTRUE;
 }
 //----------------------------------------------------------------------
 AliITSDetTypeSim::~AliITSDetTypeSim(){
@@ -111,85 +117,126 @@ AliITSDetTypeSim::~AliITSDetTypeSim(){
     //    none.
     // Return:
     //    Nothing.
-  
+
     if(fSimulation){
-      fSimulation->Delete();
-      delete fSimulation;
-      fSimulation = 0;
+       fSimulation->Delete();
+       delete fSimulation;
     }
-    
+    fSimulation = 0;
     if(fSegmentation){
-      fSegmentation->Delete();
-      delete fSegmentation;
-      fSegmentation = 0;
+       fSegmentation->Delete();
+       delete fSegmentation;
     }
-    
+    fSegmentation = 0;
     if(fCalibration && fRunNumber<0){
-      AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSPD()))->GetResponse();
-      AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSDD()))->GetResponse();
-      AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSSD()))->GetResponse();
-      if(rspd) delete rspd;
-      if(rsdd) delete rsdd;
-      if(rssd) delete rssd;
-      fCalibration->Delete();
-      delete fCalibration;
-      fCalibration = 0;
+       AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
+                               GetITSgeom()->GetStartSPD()))->GetResponse();
+       AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(
+                               GetITSgeom()->GetStartSDD()))->GetResponse();
+       AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
+                               GetITSgeom()->GetStartSSD()))->GetResponse();
+       if(rspd) delete rspd;
+       if(rsdd) delete rsdd;
+       if(rssd) delete rssd;
+       fCalibration->Delete();
+       delete fCalibration;
     }
-
-    if(fGeom) delete fGeom;
-    
+    fCalibration = 0;
     if(fPreProcess){
-      fPreProcess->Delete();
-      delete fPreProcess;
-      fPreProcess = 0;
+       fPreProcess->Delete();
+       delete fPreProcess;
     }
-    
+    fPreProcess = 0;
     if(fPostProcess){
-      fPostProcess->Delete();
-      delete fPostProcess;
-      fPostProcess = 0;
+       fPostProcess->Delete();
+       delete fPostProcess;
     }
-
+    fPostProcess = 0;
+    if(fSimuPar) delete fSimuPar;
+    if(fDDLMapSDD) delete fDDLMapSDD;
     if(fNDigits) delete [] fNDigits;
-
-    if (fLoader)
-      {
-       fLoader->GetModulesFolder()->Remove(this);
-      }
-    
-    if (fSDigits) {
-      fSDigits->Delete();
-      delete fSDigits;
-      fSDigits=0;
-    }
+    fNDigits = 0;
+    if (fLoader)fLoader->GetModulesFolder()->Remove(this);
+    fLoader = 0; // Not deleting it.
+    fSDigits.Delete();
     if (fDigits) {
       fDigits->Delete();
       delete fDigits;
-      fDigits=0;
     }
-  
+    fDigits=0;
 }
 //----------------------------------------------------------------------
-AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source){
+AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source),
+fSimulation(source.fSimulation),   // [NDet]
+fSegmentation(source.fSegmentation), // [NDet]
+fCalibration(source.fCalibration),     // [NMod]
+fPreProcess(source.fPreProcess),   // [] e.g. Fill fHitModule with hits
+fPostProcess(source.fPostProcess),  // [] e.g. Wright Raw data
+fNSDigits(source.fNSDigits),    //! number of SDigits
+fSDigits(*((TClonesArray*)source.fSDigits.Clone())),
+fNDigits(source.fNDigits),     //! number of Digits
+fRunNumber(source.fRunNumber),   //! Run number (to access DB)
+fDigits(source.fDigits),       //! [NMod][NDigits]
+fSimuPar(source.fSimuPar),
+fDDLMapSDD(source.fDDLMapSDD),
+fHitClassName(source.fHitClassName), // String with Hit class name.
+fSDigClassName(source.fSDigClassName),// String with SDigit class name.
+fDigClassName(), // String with digit class name.
+fLoader(source.fLoader),      // local pointer to loader
+fFirstcall(source.fFirstcall)
+{
     // Copy Constructor for object AliITSDetTypeSim not allowed
-  if(this==&source) return;
-  Error("Copy constructor",
-       "You are not allowed to make a copy of the AliITSDetTypeSim");
-  exit(1);
-
-        
+  for(Int_t i=0;i<fgkNdettypes;i++){
+    fDigClassName[i] = source.fDigClassName[i];
+  }
 }
 //----------------------------------------------------------------------
 AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){
     // The = operator for object AliITSDetTypeSim
  
-    if(&source==this) return *this;
-    Error("operator=","You are not allowed to make a copy of the AliITSDetTypeSIm");
-    exit(1);
-    return *this;
+  this->~AliITSDetTypeSim();
+  new(this) AliITSDetTypeSim(source);
+  return *this;
 }
 
-
+//______________________________________________________________________
+void AliITSDetTypeSim::SetITSgeom(AliITSgeom *geom){
+    // Sets/replaces the existing AliITSgeom object kept in AliITSLoader
+    // 
+    // Inputs:
+    //   AliITSgoem   *geom  The AliITSgeom object to be used.
+    // Output:
+    //   none.
+    // Return:
+    //   none.
+  if(!fLoader){
+    Error("SetITSgeom","No pointer to loader - nothing done");
+    return;
+  }
+  else {
+    fLoader->SetITSgeom(geom);  // protections in AliITSLoader::SetITSgeom
+  }
+}
+//______________________________________________________________________
+void AliITSDetTypeSim::SetLoader(AliITSLoader *loader){
+    // Sets the local copy of the AliITSLoader, and passes on the
+    // AliITSgeom object as needed.
+    // Inputs
+    //   AliITSLoader  *loader pointer to AliITSLoader for local use
+    // Outputs:
+    //   none.
+    // Return:
+    //  none.
+
+    if(fLoader==loader) return; // Same do nothing
+    if(fLoader){ // alread have an existing loader
+       Error("SetLoader",
+               "Already have an exisiting loader ptr=%p Nothing done",
+               fLoader);
+    } // end if
+    fLoader = loader;
+}
 //______________________________________________________________________
 void AliITSDetTypeSim::SetSimulationModel(Int_t dettype,AliITSsimulation *sim){
 
@@ -212,37 +259,36 @@ AliITSsimulation* AliITSDetTypeSim::GetSimulationModel(Int_t dettype){
 AliITSsimulation* AliITSDetTypeSim::GetSimulationModelByModule(Int_t module){
 
   //Get simulation model by module number
-  if(fGeom==0) {
-    Warning("GetSimulationModelByModule","fGeom is 0!");
+  if(GetITSgeom()==0) {
+    Warning("GetSimulationModelByModule","GetITSgeom() is 0!");
     return 0;
   }
   
-  return GetSimulationModel(fGeom->GetModuleType(module));
+  return GetSimulationModel(GetITSgeom()->GetModuleType(module));
 }
 //_______________________________________________________________________
 void AliITSDetTypeSim::SetDefaultSegmentation(Int_t idet){
-  // Set default segmentation model objects
-  AliITSsegmentation *seg;
-  if(fSegmentation==0x0){
-    fSegmentation = new TObjArray(fgkNdettypes);
-    fSegmentation->SetOwner(kTRUE);
-  }
-  if(GetSegmentationModel(idet))delete (AliITSsegmentation*)fSegmentation->At(idet);
-  if(idet==0){
-    seg = new AliITSsegmentationSPD(fGeom);
-  }
-  else if(idet==1){
-    AliITSCalibration* res = GetCalibrationModel(fGeom->GetStartSDD());
-    seg = new AliITSsegmentationSDD(fGeom,res);
-  }
-  else {
-    seg = new AliITSsegmentationSSD(fGeom);
-  }
-  SetSegmentationModel(idet,seg);
-}
+    // Set default segmentation model objects
+    AliITSsegmentation *seg;
 
+    if(fSegmentation==0x0){
+       fSegmentation = new TObjArray(fgkNdettypes);
+       fSegmentation->SetOwner(kTRUE);
+    }
+    if(GetSegmentationModel(idet))
+       delete (AliITSsegmentation*)fSegmentation->At(idet);
+    if(idet==0){
+       seg = new AliITSsegmentationSPD();
+    }else if(idet==1){
+       seg = new AliITSsegmentationSDD();
+    }else {
+       seg = new AliITSsegmentationSSD();
+    }
+    SetSegmentationModel(idet,seg);
+}
 //______________________________________________________________________
-void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
+void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype,
+                                           AliITSsegmentation *seg){
    
   //Set segmentation model for detector type
   if(fSegmentation==0x0){
@@ -250,152 +296,106 @@ void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype,AliITSsegmentation *se
     fSegmentation->SetOwner(kTRUE);
   }
   fSegmentation->AddAt(seg,dettype);
-
 }
 //______________________________________________________________________
 AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModel(Int_t dettype){
-
   //Get segmentation model for detector type
    
    if(fSegmentation==0) {
-     Warning("GetSegmentationModel","fSegmentation is 0!");
-     return 0; 
+       Warning("GetSegmentationModel","fSegmentation is 0!");
+       return 0; 
    } 
    return (AliITSsegmentation*)(fSegmentation->At(dettype));
-
 }
 //_______________________________________________________________________
 AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModelByModule(Int_t module){
-  
-  //Get segmentation model by module number
-   if(fGeom==0){
-     Warning("GetSegmentationModelByModule","fGeom is 0!");
-     return 0;
-   }     
-   return GetSegmentationModel(fGeom->GetModuleType(module));
-
+    //Get segmentation model by module number
+    if(GetITSgeom()==0){
+       Warning("GetSegmentationModelByModule","GetITSgeom() is 0!");
+       return 0;
+    }     
+    return GetSegmentationModel(GetITSgeom()->GetModuleType(module));
 }
 //_______________________________________________________________________
 void AliITSDetTypeSim::CreateCalibrationArray() {
+    //Create the container of calibration functions with correct size
+    if (fCalibration) {
+       Warning("CreateCalibration","pointer to calibration object exists\n");
+       fCalibration->Delete();
+       delete fCalibration;
+    }
 
-  //Create the container of calibration functions with correct size
-  if (fCalibration) {
-    Warning("CreateCalibration","pointer to calibration object exists\n");
-    fCalibration->Delete();
-    delete fCalibration;
-  }
-
-  Int_t nModTot = fGeom->GetIndexMax();
-  fCalibration = new TObjArray(nModTot);
-  fCalibration->SetOwner(kTRUE);
-  fCalibration->Clear();
-
+    Int_t nModTot = GetITSgeom()->GetIndexMax();
+    fCalibration = new TObjArray(nModTot);
+    fCalibration->SetOwner(kTRUE);
+    fCalibration->Clear();
 }
 //_______________________________________________________________________
 void AliITSDetTypeSim::SetCalibrationModel(Int_t iMod, AliITSCalibration *resp){
+    //Set response model for modules
 
-  //Set response model for modules
-
-  if (fCalibration==0) CreateCalibrationArray();
+    if (fCalibration==0) CreateCalibrationArray();
  
-  if (fCalibration->At(iMod)!=0)
-    delete (AliITSCalibration*) fCalibration->At(iMod);
-  fCalibration->AddAt(resp, iMod);
-
+    if (fCalibration->At(iMod)!=0)
+       delete (AliITSCalibration*) fCalibration->At(iMod);
+    fCalibration->AddAt(resp, iMod);
 }
-
 //______________________________________________________________________
 void AliITSDetTypeSim::ResetCalibrationArray(){
-
-  //resets response array
-  if(fCalibration && fRunNumber<0){  // if fRunNumber<0 fCalibration is owner
-    AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSPD()))->GetResponse();
-    AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSDD()))->GetResponse();
-    AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSSD()))->GetResponse();
-    if(rspd) delete rspd;
-    if(rsdd) delete rsdd;
-    if(rssd) delete rssd;
-    fCalibration->Clear();
-  }
-  else if (fCalibration && fRunNumber>=0){
-    fCalibration->Clear();
-  }
+    //resets response array
+    if(fCalibration && fRunNumber<0){  // if fRunNumber<0 fCalibration is owner
+       AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
+                                GetITSgeom()->GetStartSPD()))->GetResponse();
+       AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(
+                                GetITSgeom()->GetStartSDD()))->GetResponse();
+       AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
+                                GetITSgeom()->GetStartSSD()))->GetResponse();
+       if(rspd) delete rspd;
+       if(rsdd) delete rsdd;
+       if(rssd) delete rssd;
+       fCalibration->Clear();
+    }else if (fCalibration && fRunNumber>=0){
+       fCalibration->Clear();
+    }
 }
 //______________________________________________________________________
 void AliITSDetTypeSim::ResetSegmentation(){
- //Resets segmentation array
-  if(fSegmentation) fSegmentation->Clear();
+    //Resets segmentation array
+    if(fSegmentation) fSegmentation->Clear();
 }
-
 //_______________________________________________________________________
 AliITSCalibration* AliITSDetTypeSim::GetCalibrationModel(Int_t iMod){
-   //Get response model for module number iMod 
+    //Get response model for module number iMod 
  
-  if(fCalibration==0) {
-    AliError("fCalibration is 0!");
-    return 0; 
-  }
-
+    if(fCalibration==0) {
+       AliError("fCalibration is 0!");
+       return 0; 
+    }
   return (AliITSCalibration*)(fCalibration->At(iMod));
-
 }
 //_______________________________________________________________________
 void AliITSDetTypeSim::SetDefaults(){
+    //Set defaults for segmentation and response
 
-  //Set defaults for segmentation and response
+    if(GetITSgeom()==0){
+       Warning("SetDefaults","GetITSgeom() is 0!");
+       return;
+    } // end if
+    if (fCalibration==0) {
+       CreateCalibrationArray();
+    } // end if
 
-  if(fGeom==0){
-    Warning("SetDefaults","fGeom is 0!");
-    return;
-  }
-  if (fCalibration==0) {
-    CreateCalibrationArray();
-  }
+    ResetSegmentation();
+    if(!GetCalibration()){AliFatal("Exit"); exit(0);}
 
-  ResetSegmentation();
-  if(!GetCalibration()){AliFatal("Exit"); exit(0);}
+    SetDigitClassName(0,"AliITSdigitSPD");
+    SetDigitClassName(1,"AliITSdigitSDD");
+    SetDigitClassName(2,"AliITSdigitSSD");
 
-  for(Int_t idet=0;idet<fgkNdettypes;idet++){
-    //SPD
-    if(idet==0){
-      if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
-      const char *kData0=(GetCalibrationModel(fGeom->GetStartSPD()))->DataType();
-      if (strstr(kData0,"real")) {
-       SetDigitClassName(idet,"AliITSdigit");
-      }
-      else {
-       SetDigitClassName(idet,"AliITSdigitSPD");
-      }
-    }
-    //SDD
-    if(idet==1){
+    for(Int_t idet=0;idet<fgkNdettypes;idet++){
       if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
-      AliITSCalibrationSDD* rsp = (AliITSCalibrationSDD*)GetCalibrationModel(fGeom->GetStartSDD());
-      const char *kopt = ((AliITSresponseSDD*)rsp->GetResponse())->ZeroSuppOption();
-      if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) {
-       SetDigitClassName(idet,"AliITSdigit");
-      }
-      else {
-       SetDigitClassName(idet,"AliITSdigitSDD");
-      }
-    
-    }
-    //SSD
-    if(idet==2){
-      if(!GetSegmentationModel(idet))SetDefaultSegmentation(idet);
-
-      const char *kData2 = (GetCalibrationModel(fGeom->GetStartSSD())->DataType());
-      if (strstr(kData2,"real")) {
-       SetDigitClassName(idet,"AliITSdigit");
-      }
-      else {
-       SetDigitClassName(idet,"AliITSdigitSSD");
-      }
     }
-  }
 }
-
 //______________________________________________________________________
 Bool_t AliITSDetTypeSim::GetCalibration() {
   // Get Default calibration if a storage is not defined.
@@ -410,7 +410,6 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
 
   SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
   Int_t run=GetRunNumber();
-  if(run<0)run=0;   // if the run number is not yet set, use fake run # 0
 
   Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag();
   Bool_t isCacheActive = kTRUE;
@@ -424,28 +423,32 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
 
   AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
 
-  AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", run);
+  AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead", run);
   AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
-  AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
+  AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD",run);
+  AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD",run);
+  AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD",run);
+  AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD",run);
+  // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
+  AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
+  AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
+  AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
+
   AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", run);
   AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", run);
   AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", run);
 
-  if(!entrySPD || !entrySDD || !entrySSD || !entry2SPD || !entry2SDD || !entry2SSD){
-    AliWarning("Calibration object retrieval failed! Dummy calibration will be used.");
-    AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage();
-    AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-       
-    entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", run);
-    entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
-    entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
-    entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", run);
-    entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", run);
-    entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", run);
-       
-    AliCDBManager::Instance()->SetDefaultStorage(origStorage);
-  }
+  if(!entrySPD || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD || 
+     !entry2SPD || !entry2SDD || !entry2SSD || !drSpSDD || !ddlMapSDD || !mapASDD ||!mapTSDD){
+    AliFatal("Calibration object retrieval failed! ");
+    return kFALSE;
+  }    
 
+//   if(!entrySPD || !entrySDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD || 
+//      !entry2SPD || !entry2SDD || !entry2SSD){
+//     AliFatal("Calibration object retrieval failed! ");
+//     return kFALSE;
+//   }         
 
   TObjArray *calSPD = (TObjArray *)entrySPD->GetObject();
   if(!isCacheActive)entrySPD->SetObject(NULL);
@@ -463,9 +466,39 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
   if(!isCacheActive)entry2SDD->SetObject(NULL);
   entry2SDD->SetOwner(kTRUE);
 
+  TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
+  if(!isCacheActive)drSpSDD->SetObject(NULL);
+  drSpSDD->SetOwner(kTRUE);
+
+  AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
+  if(!isCacheActive)ddlMapSDD->SetObject(NULL);
+  ddlMapSDD->SetOwner(kTRUE);
+
+  TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
+  if(!isCacheActive)mapASDD->SetObject(NULL);
+  mapASDD->SetOwner(kTRUE);
+
+  TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
+  if(!isCacheActive)mapTSDD->SetObject(NULL);
+  mapTSDD->SetOwner(kTRUE);
+
+  /*
   TObjArray *calSSD = (TObjArray *)entrySSD->GetObject();
   if(!isCacheActive)entrySSD->SetObject(NULL);
   entrySSD->SetOwner(kTRUE);
+  */
+
+  TObjArray *noiseSSD = (TObjArray *)entryNoiseSSD->GetObject();
+  if(!isCacheActive)entryNoiseSSD->SetObject(NULL);
+  entryNoiseSSD->SetOwner(kTRUE);
+
+  TObjArray *gainSSD = (TObjArray *)entryGainSSD->GetObject();
+  if(!isCacheActive)entryGainSSD->SetObject(NULL);
+  entryGainSSD->SetOwner(kTRUE);
+
+  TObjArray *badchannelsSSD = (TObjArray *)entryBadChannelsSSD->GetObject();
+  if(!isCacheActive)entryBadChannelsSSD->SetObject(NULL);
+  entryBadChannelsSSD->SetOwner(kTRUE);
 
   AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject();
   if(!isCacheActive)entry2SSD->SetObject(NULL);
@@ -475,25 +508,29 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
   if(!isCacheActive){
     delete entrySPD;
     delete entrySDD;
-    delete entrySSD;
+    delete entryNoiseSSD;
+    delete entryGainSSD;
+    delete entryBadChannelsSSD;
     delete entry2SPD;
     delete entry2SDD;
     delete entry2SSD;
+    delete mapASDD;   
+    delete mapTSDD;
+    delete drSpSDD;
+    delete ddlMapSDD;
   }
   
   AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
 
-  if ((!pSPD)||(!pSDD)||(!pSSD)) {
-    AliWarning("Can not get calibration from calibration database !");
-    return kFALSE;
-  }
-  if ((! calSPD)||(! calSDD)||(! calSSD)) {
+  if ((!pSPD)||(!pSDD)||(!pSSD) || (!calSPD) || (!calSDD) || (!drSp) || (!ddlsdd)
+      || (!mapAn) || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badchannelsSSD)) {
     AliWarning("Can not get calibration from calibration database !");
     return kFALSE;
   }
+
   fNMod[0] = calSPD->GetEntries();
   fNMod[1] = calSDD->GetEntries();
-  fNMod[2] = calSSD->GetEntries();
+  fNMod[2] = noiseSSD->GetEntries();
   AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
               fNMod[0], fNMod[1], fNMod[2]));
   AliITSCalibration* cal;
@@ -501,32 +538,69 @@ Bool_t AliITSDetTypeSim::GetCalibration() {
     cal = (AliITSCalibration*) calSPD->At(i);
     cal->SetResponse(pSPD);
     SetCalibrationModel(i, cal);
- }
-  for (Int_t i=0; i<fNMod[1]; i++) {
-    cal = (AliITSCalibration*) calSDD->At(i);
-    cal->SetResponse(pSDD);
-    Int_t iMod = i + fNMod[0];
-    SetCalibrationModel(iMod, cal);
- }
-  for (Int_t i=0; i<fNMod[2]; i++) {
-    cal = (AliITSCalibration*) calSSD->At(i);
-    cal->SetResponse(pSSD);
-    Int_t iMod = i + fNMod[0] + fNMod[1];
-    SetCalibrationModel(iMod, cal);
- }
+  }
 
-  return kTRUE;
-}
+  fDDLMapSDD->SetDDLMap(ddlsdd);
+
+  for (Int_t i=0; i<fgkDefaultNModulesSDD; i++) {
+    Int_t iddl,icarlos;
+    Int_t iMod = i + fgkDefaultNModulesSPD;
+    fDDLMapSDD->FindInDDLMap(iMod,iddl,icarlos);
+    if(iddl<0){ 
+      AliITSCalibrationSDD* calsdddead=new AliITSCalibrationSDD();
+      calsdddead->SetResponse(pSDD);
+      calsdddead->SetBad();      
+      AliITSDriftSpeedSDD* driftspdef = new AliITSDriftSpeedSDD();
+      AliITSDriftSpeedArraySDD* arrdrsp=new AliITSDriftSpeedArraySDD(1);
+      arrdrsp->AddDriftSpeed(driftspdef);
+      calsdddead->SetDriftSpeed(0,arrdrsp);
+      calsdddead->SetDriftSpeed(1,arrdrsp);
+      SetCalibrationModel(iMod, calsdddead);
+      AliWarning(Form("SDD module %d not present in DDL map: set it as dead",iMod));
+    }else{
+      cal = (AliITSCalibration*) calSDD->At(i);
+      cal->SetResponse(pSDD);
+      Int_t i0=2*i;
+      Int_t i1=1+2*i;
+      AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
+      AliITSMapSDD* ma0 = (AliITSMapSDD*)mapAn->At(i0);
+      AliITSMapSDD* mt0 = (AliITSMapSDD*)mapT->At(i0);
+      AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
+      AliITSMapSDD* ma1 = (AliITSMapSDD*)mapAn->At(i1);
+      AliITSMapSDD* mt1 = (AliITSMapSDD*)mapT->At(i1);
+      cal->SetDriftSpeed(0,arr0);
+      cal->SetDriftSpeed(1,arr1);
+      cal->SetMapA(0,ma0);
+      cal->SetMapA(1,ma1);
+      cal->SetMapT(0,mt0);
+      cal->SetMapT(1,mt1);
+      SetCalibrationModel(iMod, cal);
+    }
+  }
 
+  for (Int_t i=0; i<fNMod[2]; i++) {
+    AliITSCalibrationSSD *calibSSD = new AliITSCalibrationSSD();
+    calibSSD->SetResponse((AliITSresponse*)pSSD);
+    
+    AliITSNoiseSSD *noise = (AliITSNoiseSSD*) (noiseSSD->At(i));
+    calibSSD->SetNoise(noise);
+    AliITSGainSSD *gain = (AliITSGainSSD*) (gainSSD->At(i));
+    calibSSD->SetGain(gain);
+    AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (badchannelsSSD->At(i));
+    calibSSD->SetBadChannels(bad);
 
+    Int_t iMod = i + fgkDefaultNModulesSPD + fgkDefaultNModulesSDD;
+    SetCalibrationModel(iMod, calibSSD);
 
+ }
+  return kTRUE;
+}
 //_______________________________________________________________________
 void AliITSDetTypeSim::SetDefaultSimulation(){
-
   //Set default simulation for detector type
 
-  if(fGeom==0){
-    Warning("SetDefaultSimulation","fGeom is 0!");
+  if(GetITSgeom()==0){
+    Warning("SetDefaultSimulation","GetITSgeom() is 0!");
     return;
   }
   if(fCalibration==0){
@@ -536,22 +610,17 @@ void AliITSDetTypeSim::SetDefaultSimulation(){
   if(fSegmentation==0){
     Warning("SetDefaultSimulation","fSegmentation is 0!");
     for(Int_t i=0;i<fgkNdettypes;i++) SetDefaultSegmentation(i);
-  }
-  else{
-    for(Int_t i=0;i<fgkNdettypes;i++){
-      if(!GetSegmentationModel(i)){
-       Warning("SetDefaultSimulation","Segmentation not defined for det %d - Default taken\n!",i);
-       SetDefaultSegmentation(i);
-      }
-    }
+  }else for(Int_t i=0;i<fgkNdettypes;i++) if(!GetSegmentationModel(i)){
+      Warning("SetDefaultSimulation",
+             "Segmentation not defined for det %d - Default taken\n!",i);
+      SetDefaultSegmentation(i);
   }
   AliITSsimulation* sim;
 
   for(Int_t idet=0;idet<fgkNdettypes;idet++){
    //SPD
     if(idet==0){
-      sim = GetSimulationModel(idet);
+      sim = GetSimulationModel(idet); 
       if(!sim){
        sim = new AliITSsimulationSPD(this);
        SetSimulationModel(idet,sim);
@@ -563,8 +632,7 @@ void AliITSDetTypeSim::SetDefaultSimulation(){
       if(!sim){
        sim = new AliITSsimulationSDD(this);
        SetSimulationModel(idet,sim);
-      }
-      
+      }      
     }
     //SSD
     if(idet==2){
@@ -573,31 +641,23 @@ void AliITSDetTypeSim::SetDefaultSimulation(){
        sim = new AliITSsimulationSSD(this);
        SetSimulationModel(idet,sim);
       }
-
     }
 
   }
 }
-
-
-
-
 //___________________________________________________________________
 void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, Char_t* name){
-  // Set branch address for the ITS summable digits Trees.
-  
+  // Set branch address for the ITS summable digits Trees.  
   char branchname[30];
 
   if(!treeS){
     return;
   }
-  if (fSDigits ==  0x0){
-    fSDigits = new TClonesArray("AliITSpListItem",1000);
-  }
   TBranch *branch;
   sprintf(branchname,"%s",name);
   branch = treeS->GetBranch(branchname);
-  if (branch) branch->SetAddress(&fSDigits);
+  TClonesArray *sdigi = &fSDigits;
+  if (branch) branch->SetAddress(&sdigi);
 
 }
 //___________________________________________________________________
@@ -641,8 +701,7 @@ void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, Char_t* name){
 }
 //___________________________________________________________________
 void AliITSDetTypeSim::ResetDigits(){
-  // Reset number of digits and the digits array for the ITS detector.
-  
+  // Reset number of digits and the digits array for the ITS detector.  
 
   if(!fDigits){
     Error("ResetDigits","fDigits is null!");
@@ -668,8 +727,8 @@ void AliITSDetTypeSim::ResetDigits(Int_t branch){
 //_______________________________________________________________________
 void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
   // Standard Summable digits to Digits function.
-  if(!fGeom){
-    Warning("SDigitsToDigits","fGeom is null!!");
+  if(!GetITSgeom()){
+    Warning("SDigitsToDigits","GetITSgeom() is null!!");
     return;
   }
   
@@ -692,22 +751,21 @@ void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
   TBranch* brchSDigits = trees->GetBranch(name);
   
   Int_t id;
-  for(Int_t module=0;module<fGeom->GetIndexMax();module++){
-     id = fGeom->GetModuleType(module);
+  for(Int_t module=0;module<GetITSgeom()->GetIndexMax();module++){
+     id = GetITSgeom()->GetModuleType(module);
     if (!all && !det[id]) continue;
     sim = (AliITSsimulation*)GetSimulationModel(id);
-    printf("module=%d name=%s\n",module,sim->ClassName());
     if(!sim){
       Error("SDigit2Digits","The simulation class was not "
            "instanciated for module %d type %s!",module,
-           fGeom->GetModuleTypeName(module));
+           GetITSgeom()->GetModuleTypeName(module));
       exit(1);
     }
     sim->InitSimulationModule(module,gAlice->GetEvNumber());
     
-    fSDigits->Clear();
+    fSDigits.Clear();
     brchSDigits->GetEvent(module);
-    sim->AddSDigitsToModule(fSDigits,0);
+    sim->AddSDigitsToModule(&fSDigits,0);
     sim->FinishSDigitiseModule();
     fLoader->TreeD()->Fill();
     ResetDigits();
@@ -716,26 +774,16 @@ void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
   fLoader->TreeD()->AutoSave();
   fLoader->TreeD()->Reset();
 }
-
-
-
 //_________________________________________________________
-void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){
-  
+void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){  
   //Adds the module full of summable digits to the summable digits tree.
-  TClonesArray &lsdig = *fSDigits;
-  new(lsdig[fNSDigits++]) AliITSpListItem(sdig);
-}
-//__________________________________________________________
-void AliITSDetTypeSim::AddRealDigit(Int_t branch, Int_t *digits){
-  //   Add a real digit - as coming from data.
-  TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
-  new(ldigits[fNDigits[branch]++]) AliITSdigit(digits); 
+
+  new(fSDigits[fNSDigits++]) AliITSpListItem(sdig);
 }
 //__________________________________________________________
-void AliITSDetTypeSim::AddSimDigit(Int_t branch, AliITSdigit* d){
-  
+void AliITSDetTypeSim::AddSimDigit(Int_t branch, AliITSdigit* d){  
   //    Add a simulated digit.
+
   TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
   switch(branch){
   case 0:
@@ -747,39 +795,32 @@ void AliITSDetTypeSim::AddSimDigit(Int_t branch, AliITSdigit* d){
   case 2:
     new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
     break;
-  } 
-  
+  }  
 }
-
 //______________________________________________________________________
 void AliITSDetTypeSim::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,
-                                  Int_t *tracks,Int_t *hits,Float_t *charges){
+                                  Int_t *tracks,Int_t *hits,Float_t *charges, 
+                                  Int_t sigexpanded){
   //   Add a simulated digit to the list.
 
   TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
-  AliITSCalibrationSDD *resp = 0;
   switch(branch){
   case 0:
     new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(digits,tracks,hits);
     break;
   case 1:
-    resp = (AliITSCalibrationSDD*)GetCalibrationModel(fGeom->GetStartSDD());
     new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(phys,digits,tracks,
-                                                  hits,charges,resp);
+                                                  hits,charges,sigexpanded);
     break;
   case 2:
     new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(digits,tracks,hits);
     break;
   } 
 }
-
-
-
 //______________________________________________________________________
-void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun, AliCDBMetaData &md) {
-
+void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun,
+                                       AliCDBMetaData &md) {
   // Store calibration in the calibration database
-
   // The database must be created in an external piece of code (i.e. 
   // a configuration macro )
 
@@ -792,7 +833,7 @@ void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun, AliCDBMet
     AliError("AliITSCalibration classes are not defined - nothing done");
     return;
   }
-  AliCDBId idRespSPD("ITS/Calib/CalibSPD",firstRun, lastRun);
+  AliCDBId idRespSPD("ITS/Calib/SPDDead",firstRun, lastRun);
   AliCDBId idRespSDD("ITS/Calib/CalibSDD",firstRun, lastRun);
   AliCDBId idRespSSD("ITS/Calib/CalibSSD",firstRun, lastRun);
 
@@ -822,9 +863,6 @@ void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun, AliCDBMet
   AliCDBManager::Instance()->Put(&respSPD, idRespSPD, &md);
   AliCDBManager::Instance()->Put(&respSDD, idRespSDD, &md);
   AliCDBManager::Instance()->Put(&respSSD, idRespSSD, &md);
-
-
-
 }