]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSDetTypeRec.cxx
typo fix
[u/mrichter/AliRoot.git] / ITS / AliITSDetTypeRec.cxx
index 32527514bdce9e20e62fcee00a5236169632fa6a..afeb70d9f3162bbd7c7a43adc51b2143606486d5 100644 (file)
@@ -13,9 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
- $Id$
-*/
+
 
 ////////////////////////////////////////////////////////////////////////
 // This class defines the "Standard" reconstruction for the ITS       // 
 #include "AliITSClusterFinder.h"
 #include "AliITSClusterFinderV2SPD.h"
 #include "AliITSClusterFinderV2SDD.h"
+#include "AliITSClusterFinderSDDfast.h"
 #include "AliITSClusterFinderV2SSD.h"
 #include "AliITSDetTypeRec.h"
 #include "AliITSDDLModuleMapSDD.h"
 #include "AliITSRecPoint.h"
+#include "AliITSRecPointContainer.h"
 #include "AliITSCalibrationSDD.h"
 #include "AliITSMapSDD.h"
 #include "AliITSCalibrationSSD.h"
@@ -55,6 +55,7 @@
 #include "AliDataLoader.h"
 #include "AliITSLoader.h"
 
+
 class AliITSDriftSpeedArraySDD;
 class AliITSCorrMapSDD;
 class AliITSRecoParam;
@@ -75,6 +76,7 @@ fSegmentation(0),
 fCalibration(0),
 fSSDCalibration(0),
 fSPDDead(0),
+fSPDSparseDead(0),
 fTriggerConditions(0),
 fDigits(0),
 fFOSignals(0),
@@ -104,7 +106,6 @@ fFastOrFiredMap(1200){
   fNMod[0] = fgkDefaultNModulesSPD;
   fNMod[1] = fgkDefaultNModulesSDD;
   fNMod[2] = fgkDefaultNModulesSSD;
-  fRecPoints = new TClonesArray("AliITSRecPoint",3000);
   fNRecPoints = 0;
   
   
@@ -119,6 +120,7 @@ fSegmentation(rec.fSegmentation),
 fCalibration(rec.fCalibration),
 fSSDCalibration(rec.fSSDCalibration),
 fSPDDead(rec.fSPDDead),
+fSPDSparseDead(rec.fSPDSparseDead),
 fTriggerConditions(rec.fTriggerConditions),
 fDigits(rec.fDigits),
 fFOSignals(rec.fFOSignals),
@@ -132,7 +134,9 @@ fLoadOnlySPDCalib(rec.fLoadOnlySPDCalib),
 fFastOrFiredMap(rec.fFastOrFiredMap){
 
   // Copy constructor. 
-
+  for(Int_t i=0; i<3; i++){    
+    fkDigClassName[i]=rec.fkDigClassName[i];  // NB only copies Char_t*, so not so safe, but this code should never be reached anyways
+  }
 }
 //______________________________________________________________________
 AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
@@ -150,46 +154,49 @@ AliITSDetTypeRec::~AliITSDetTypeRec(){
   if(fReconstruction){
     fReconstruction->Delete();
     delete fReconstruction;
-    fReconstruction = 0;
   }
   if(fSegmentation){
     fSegmentation->Delete();
     delete fSegmentation;
-    fSegmentation = 0;
   }
   if(fCalibration){
     if(!(AliCDBManager::Instance()->GetCacheFlag())) {
       fCalibration->Delete();
       delete fCalibration;
-      fCalibration = 0;
       if(fRespSDD) delete fRespSDD;
       if(fDDLMapSDD) delete fDDLMapSDD;
    }
   }
-  if(fSSDCalibration) delete fSSDCalibration;
+  if(fSSDCalibration){
+    if(!(AliCDBManager::Instance()->GetCacheFlag())) {
+      delete fSSDCalibration;
+    }
+  }
    if(fSPDDead){
     if(!(AliCDBManager::Instance()->GetCacheFlag())) {
       fSPDDead->Delete();
       delete fSPDDead;
-      fSPDDead = 0;
+    }
+  } 
+     if(fSPDSparseDead){
+    if(!(AliCDBManager::Instance()->GetCacheFlag())) {
+      fSPDSparseDead->Delete();
+      delete fSPDSparseDead;
     }
   } 
   if(fTriggerConditions){
     if(!(AliCDBManager::Instance()->GetCacheFlag())) {
       fTriggerConditions->Delete();
       delete fTriggerConditions;
-      fTriggerConditions = 0;
     }
   } 
   if(fDigits){
     fDigits->Delete();
     delete fDigits;
-    fDigits=0;
   }
   if(fRecPoints){
     fRecPoints->Delete();
     delete fRecPoints;
-    fRecPoints=0;
   }
   delete [] fNMod;
   
@@ -269,6 +276,20 @@ void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
   fSPDDead->AddAt(cal,iMod);
 }
 //_______________________________________________________________________
+void AliITSDetTypeRec::SetSPDSparseDeadModel(Int_t iMod, AliITSCalibration *cal){
+
+  //Set dead pixel info for the SPD ACTIVE module iMod
+  if (fSPDSparseDead==0) {
+    fSPDSparseDead = new TObjArray(fgkDefaultNModulesSPD);
+    fSPDSparseDead->SetOwner(kTRUE);
+    fSPDSparseDead->Clear();
+  }
+
+  if (fSPDSparseDead->At(iMod) != 0)
+    delete (AliITSCalibration*) fSPDSparseDead->At(iMod);
+  fSPDSparseDead->AddAt(cal,iMod);
+}
+//_______________________________________________________________________
 AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod) const {
   
   //Get calibration model for module type
@@ -299,6 +320,17 @@ AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod) const {
   return (AliITSCalibration*)fSPDDead->At(iMod);
 }
 //_______________________________________________________________________
+AliITSCalibration* AliITSDetTypeRec::GetSPDSparseDeadModel(Int_t iMod) const {
+  
+  //Get SPD dead for module iMod
+  
+  if(fSPDSparseDead==0) {
+    AliWarning("fSPDSparseDead is 0!");
+    return 0; 
+  }  
+  return (AliITSCalibration*)fSPDSparseDead->At(iMod);
+}
+//_______________________________________________________________________
 AliITSTriggerConditions* AliITSDetTypeRec::GetTriggerConditions() const {
   //Get Pixel Trigger Conditions
   if (fTriggerConditions==0) {
@@ -317,21 +349,19 @@ void AliITSDetTypeRec::SetTreeAddressD(TTree* const treeD){
   char branchname[30];
 
   if(!treeD) return;
-  if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
+  if (fDigits == 0x0) {
+    fDigits = new TObjArray(fgkNdettypes);
+  }
+  else {
+    ResetDigits();
+  }
   for (i=0; i<fgkNdettypes; i++) {
     digclass = GetDigitClassName(i);
-    if(!(fDigits->At(i))) {
-      fDigits->AddAt(new TClonesArray(digclass,1000),i);
-    }
-    else{
-      ResetDigits(i);
-    } 
-    if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
-    else  sprintf(branchname,"%sDigits%d",det[3],i+1);
-    if (fDigits) {
-      branch = treeD->GetBranch(branchname);
-      if (branch) branch->SetAddress(&((*fDigits)[i]));
-    }
+    fDigits->AddAt(new TClonesArray(digclass,1000),i); 
+    if (fgkNdettypes==3) snprintf(branchname,29,"%sDigits%s",det[3],det[i]);
+    else  snprintf(branchname,29,"%sDigits%d",det[3],i+1);
+    branch = treeD->GetBranch(branchname);
+    if (branch) branch->SetAddress(&((*fDigits)[i]));
   } 
 
 }
@@ -384,17 +414,17 @@ void AliITSDetTypeRec::SetDefaults(){
       SetSegmentationModel(dettype,seg);
       SetDigitClassName(dettype,"AliITSdigitSPD");
     }
-    if(fLoadOnlySPDCalib==kFALSE){
-      if(dettype==1){
-       seg = new AliITSsegmentationSDD();
+    if(dettype==1){
+      seg = new AliITSsegmentationSDD();
+      if(fLoadOnlySPDCalib==kFALSE){
        AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
        if(cal->IsAMAt20MHz()){ 
          seg->SetPadSize(seg->Dpz(0),20.);
          seg->SetNPads(seg->Npz()/2,128);
        }
-       SetSegmentationModel(dettype,seg);
-       SetDigitClassName(dettype,"AliITSdigitSDD");
       }
+      SetSegmentationModel(dettype,seg);
+      SetDigitClassName(dettype,"AliITSdigitSDD");
     }
     if(dettype==2){
       AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
@@ -446,7 +476,8 @@ Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
  
   AliCDBEntry *noisySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
   AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
-  AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("ITS/Calib/PITConditions");
+  AliCDBEntry *deadSparseSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDSparseDead");
+  AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("TRIGGER/SPD/PITConditions");
   if(!noisySPD || !deadSPD || !pitCond ){
     AliFatal("SPD Calibration object retrieval failed! ");
     return kFALSE;
@@ -460,6 +491,11 @@ Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
   if (!cacheStatus) deadSPD->SetObject(NULL);
   deadSPD->SetOwner(kTRUE);
 
+  TObjArray *calSparseDeadSPD = (TObjArray*) deadSparseSPD->GetObject();
+  if (!cacheStatus) deadSparseSPD->SetObject(NULL);
+  deadSparseSPD->SetOwner(kTRUE);
+
+  
   AliITSTriggerConditions *calPitCond = (AliITSTriggerConditions*) pitCond->GetObject();
   if (!cacheStatus) pitCond->SetObject(NULL);
   pitCond->SetOwner(kTRUE);
@@ -467,13 +503,13 @@ Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
   if(!cacheStatus){
     delete noisySPD;
     delete deadSPD;
+    delete deadSparseSPD;
     delete pitCond;
   }
-  if ((!calNoisySPD) || (!calDeadSPD) || (!calPitCond)){ 
+  if ((!calNoisySPD) || (!calDeadSPD) || (!calSparseDeadSPD) || (!calPitCond)){ 
     AliWarning("Can not get SPD calibration from calibration database !");
     return kFALSE;
   }
-
   fNMod[0] = calNoisySPD->GetEntries();
 
   AliITSCalibration* cal;
@@ -482,6 +518,8 @@ Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
     SetCalibrationModel(i, cal);
     cal = (AliITSCalibration*) calDeadSPD->At(i);
     SetSPDDeadModel(i, cal);
+    cal = (AliITSCalibration*) calSparseDeadSPD->At(i);
+    SetSPDSparseDeadModel(i, cal);
   }
   fTriggerConditions = calPitCond;
 
@@ -614,11 +652,12 @@ Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
   }    
 
   TObject *emptyssd = 0; TString ssdobjectname;
-  AliITSNoiseSSDv2 *noiseSSD = new AliITSNoiseSSDv2();  
+  AliITSNoiseSSDv2 *noiseSSD = NULL; 
   emptyssd = (TObject *)entryNoiseSSD->GetObject();
   ssdobjectname = emptyssd->GetName();
   if(ssdobjectname=="TObjArray") {
     TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
+    noiseSSD = new AliITSNoiseSSDv2(); 
     ReadOldSSDNoise(noiseSSDOld, noiseSSD);
   }
   else if(ssdobjectname=="AliITSNoiseSSDv2")
@@ -626,11 +665,12 @@ Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
   if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
   entryNoiseSSD->SetOwner(kTRUE);
 
-  AliITSGainSSDv2 *gainSSD = new AliITSGainSSDv2();
+  AliITSGainSSDv2 *gainSSD = NULL;;
   emptyssd = (TObject *)entryGainSSD->GetObject();
   ssdobjectname = emptyssd->GetName();
   if(ssdobjectname=="Gain") {
     TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
+    gainSSD = new AliITSGainSSDv2();
     ReadOldSSDGain(gainSSDOld, gainSSD);
   }
   else if(ssdobjectname=="AliITSGainSSDv2")
@@ -638,11 +678,12 @@ Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
   if(!cacheStatus)entryGainSSD->SetObject(NULL);
   entryGainSSD->SetOwner(kTRUE);
 
-  AliITSBadChannelsSSDv2 *badChannelsSSD = new AliITSBadChannelsSSDv2();
+  AliITSBadChannelsSSDv2 *badChannelsSSD = NULL;
   emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
   ssdobjectname = emptyssd->GetName();
   if(ssdobjectname=="TObjArray") {
     TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
+    badChannelsSSD = new AliITSBadChannelsSSDv2();
     ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
   }
   else if(ssdobjectname=="AliITSBadChannelsSSDv2")
@@ -671,7 +712,7 @@ Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
 }
 
 //________________________________________________________________
-void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
+void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata, Bool_t fastSDD){
 
   //Set defaults for cluster finder V2
 
@@ -696,7 +737,12 @@ void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
     //SDD
     if(dettype==1){
       if(!GetReconstructionModel(dettype)){
-       clf = new AliITSClusterFinderV2SDD(this);
+       if(fastSDD){
+         clf = new AliITSClusterFinderSDDfast(this);
+       }
+       else {
+         clf = new AliITSClusterFinderV2SDD(this);
+       }
        clf->InitGeometry();
        if(!rawdata) clf->SetDigits(DigitsAddress(1));
        SetReconstructionModel(dettype,clf);
@@ -766,9 +812,9 @@ void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
  
   
   if(oFast){
-    sprintf(branchname,"%sRecPointsF",detname);
+    snprintf(branchname,29,"%sRecPointsF",detname);
   } else {
-    sprintf(branchname,"%sRecPoints",detname);
+    snprintf(branchname,29,"%sRecPoints",detname);
   }
   
   if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
@@ -790,13 +836,13 @@ void AliITSDetTypeRec::SetTreeAddressR(TTree* const treeR){
    if(!treeR) return;
    if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
    TBranch *branch;
-   sprintf(branchname,"%sRecPoints",namedet);
+   snprintf(branchname,29,"%sRecPoints",namedet);
    branch = treeR->GetBranch(branchname);
    if (branch) {
       branch->SetAddress(&fRecPoints);
     } 
     else {
-      sprintf(branchname,"%sRecPointsF",namedet);
+      snprintf(branchname,29,"%sRecPointsF",namedet);
       branch = treeR->GetBranch(branchname);
       if (branch) {
        branch->SetAddress(&fRecPoints);
@@ -813,7 +859,6 @@ void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
     //      none.
     // Return:
     //      none.
-
     TClonesArray &lrecp = *fRecPoints;
     new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
 }
@@ -838,10 +883,10 @@ void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastent
                         strstr(opt,"SSD")};
   if(optCluFind==0){
     SetDefaultClusterFindersV2();
-    AliInfo("V2 cluster finder has been selected \n");
+    AliDebug(1,"V2 cluster finder has been selected \n");
   }else{
-    SetDefaultClusterFindersV2();
-    AliInfo("Cluster Finder Option not implemented, V2 cluster finder will be used \n");    
+    SetDefaultClusterFindersV2(kFALSE,kTRUE);
+    AliDebug(1,"SPD and SSD V2 Cluster Finder - SDD fast Cluster Finder \n");    
   }
 
   
@@ -871,8 +916,10 @@ void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastent
       if(det[id]) first = GetITSgeom()->GetStartDet(id);
       rec = (AliITSClusterFinder*)GetReconstructionModel(id);
       TClonesArray *itsDigits  = DigitsAddress(id);
-      if (!rec)
-          AliFatal("The reconstruction class was not instanciated!");
+      if (!rec){
+       AliFatal("The reconstruction class was not instanciated!");
+       return;
+      }
       ResetDigits();  // MvL: Not sure we neeed this when rereading anyways
       if (all) {
           treeD->GetEvent(lastentry+module);
@@ -894,7 +941,16 @@ void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastent
    // Remove PIT in-active chips from Fast-OR fired map
   if (all || det[0]) { // SPD present
     RemoveFastOrFiredInActive();
+    // here removing bits which have no associated clusters 
+    RemoveFastOrFiredFromDead(GetFiredChipMap(treeR));  
   }
+
+  AliITSRecPointContainer* rpcont = AliITSRecPointContainer::Instance();
+  Int_t nClu[6];
+  nClu[0]=rpcont->GetNClustersInLayer(1,treeR);
+  for(Int_t iLay=2; iLay<=6; iLay++) nClu[iLay-1]=rpcont->GetNClustersInLayerFast(iLay);
+  AliInfo(Form("Number of RecPoints in ITS Layers = %d %d %d %d %d %d",
+              nClu[0],nClu[1],nClu[2],nClu[3],nClu[4],nClu[5]));
 }
 //______________________________________________________________________
 void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
@@ -914,53 +970,42 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Op
                         strstr(opt,"SSD")};
   
   Int_t id=0;
-
-  TClonesArray *array=new TClonesArray("AliITSRecPoint",1000);
+  AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
+  rpc->FullReset();
+  TClonesArray* array = rpc->UncheckedGetClusters(0);
   TBranch *branch = treeR->Branch("ITSRecPoints",&array);
-  delete array;
-  TClonesArray** clusters = new TClonesArray*[GetITSgeom()->GetIndexMax()]; 
-  for (Int_t iModule = 0; iModule < GetITSgeom()->GetIndexMax(); iModule++) {
-    clusters[iModule] = NULL;
-  }
-
-  DigitsToRecPoints(rawReader,clusters,opt);
+  DigitsToRecPoints(rawReader,opt); 
 
   Int_t nClusters =0;
-  TClonesArray *emptyArray=new TClonesArray("AliITSRecPoint");
   for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
     id = GetITSgeom()->GetModuleType(iModule);
     if (!all && !det[id]) continue;
-    array = clusters[iModule];
+    array = rpc->UncheckedGetClusters(iModule);
     if(!array){
       AliDebug(1,Form("data for module %d missing!",iModule));
-      array = emptyArray;
     }
     branch->SetAddress(&array);
     treeR->Fill();
     nClusters+=array->GetEntriesFast();
-
-    if (array != emptyArray) {
-      array->Delete();
-      delete array;
-    }
   }
-  delete emptyArray;
 
-  delete[] clusters;
-  Info("DigitsToRecPoints", "total number of found recpoints in ITS: %d\n", 
-       nClusters);
-  
+  rpc->FullReset();
+
+  AliITSRecPointContainer* rpcont = AliITSRecPointContainer::Instance();
+  Int_t nClu[6];
+  nClu[0]=rpcont->GetNClustersInLayer(1,treeR);
+  for(Int_t iLay=2; iLay<=6; iLay++) nClu[iLay-1]=rpcont->GetNClustersInLayerFast(iLay);
+  AliInfo(Form("Number of RecPoints in ITS Layers = %d %d %d %d %d %d, Total = %d",
+              nClu[0],nClu[1],nClu[2],nClu[3],nClu[4],nClu[5],nClusters));
 }
 //______________________________________________________________________
-void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TClonesArray** clusters,Option_t *opt){
+void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,Option_t *opt){
   // cluster finding and reconstruction of space points
   // 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:
   //      AliRawReader *rawReader  Pointer to the raw-data reader
-  //      TClonesArray **clusters  Clusters Array
   // Outputs:
   //      none.
   // Return:
@@ -978,15 +1023,20 @@ void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TClonesArray**
   for(id=0;id<3;id++){
     if (!all && !det[id]) continue;
     rec = (AliITSClusterFinder*)GetReconstructionModel(id);
-    if (!rec)
+    if (!rec){
       AliFatal("The reconstruction class was not instantiated");
+      return;
+    }
     rec->SetDetTypeRec(this);
-    rec->RawdataToClusters(rawReader,clusters);    
+    rec->RawdataToClusters(rawReader);    
   } 
    
   // Remove PIT in-active chips from Fast-OR fired map
   if (all || det[0]) { // SPD present
     RemoveFastOrFiredInActive();
+    // here removing bits which have no associated clusters 
+    RemoveFastOrFiredFromDead(GetFiredChipMap());
+   
   }  
 }
 //______________________________________________________________________
@@ -997,7 +1047,7 @@ void AliITSDetTypeRec::ReadOldSSDNoise(const TObjArray *array,
   const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
 
   Int_t gNMod = array->GetEntries();
-  cout<<"Converting old calibration object for noise..."<<endl;
+  AliInfo("Converting old calibration object for noise...\n");
 
   //NOISE
   Double_t noise = 0.0;
@@ -1018,7 +1068,7 @@ void AliITSDetTypeRec::ReadOldSSDBadChannels(const TObjArray *array,
                                             AliITSBadChannelsSSDv2 *badChannelsSSD) {
   //Reads the old SSD calibration object and converts it to the new format
   Int_t gNMod = array->GetEntries();
-  cout<<"Converting old calibration object for bad channels..."<<endl;
+  AliInfo("Converting old calibration object for bad channels...");
   for (Int_t iModule = 0; iModule < gNMod; iModule++) {
     //for (Int_t iModule = 0; iModule < 1; iModule++) {
     AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
@@ -1043,7 +1093,7 @@ void AliITSDetTypeRec::ReadOldSSDGain(const TObjArray *array,
   //Reads the old SSD calibration object and converts it to the new format
 
   Int_t gNMod = array->GetEntries();
-  cout<<"Converting old calibration object for gain..."<<endl;
+  AliInfo("Converting old calibration object for gain...\n");
 
   //GAIN
   for (Int_t iModule = 0; iModule < gNMod; iModule++) {
@@ -1063,6 +1113,7 @@ void AliITSDetTypeRec::ReadOldSSDGain(const TObjArray *array,
 //______________________________________________________________________
 void AliITSDetTypeRec::RemoveFastOrFiredInActive() {
   // Removes the chips that were in-active in the pixel trigger (from fast-or fired map)
+
   if (fTriggerConditions==NULL) {
     AliError("Pixel trigger conditions are missing.");
     return;
@@ -1076,10 +1127,116 @@ void AliITSDetTypeRec::RemoveFastOrFiredInActive() {
   }
 }
 //______________________________________________________________________
+TBits AliITSDetTypeRec::GetFiredChipMap() const {
+  
+  //
+  // TBits of the fired chips  
+  //
+  AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
+
+  TBits isfiredchip(1200);
+  
+   AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+   if(!segSPD) {
+    AliError("no segmentation model for SPD available, the fired chip map is empty. Exiting"); 
+    return isfiredchip;
+   }
+   
+  
+  for(Int_t imod =0; imod < fgkDefaultNModulesSPD; imod++){
+    TClonesArray *array = rpc->UncheckedGetClusters(imod);
+    if(!array) continue;
+    Int_t nCluster = array->GetEntriesFast();
+    while(nCluster--) {
+      AliITSRecPoint* cluster = (AliITSRecPoint*)array->UncheckedAt(nCluster);
+     if (cluster->GetLayer()>1)continue;
+     Float_t local[3]={-1,-1};
+     local[1]=cluster->GetDetLocalX();
+     local[0]=cluster->GetDetLocalZ();
+     
+     Int_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(imod);
+     Int_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(imod);
+     Int_t row, col;
+     segSPD->LocalToDet(0.5,local[0],row,col);
+     Int_t chip = AliITSRawStreamSPD::GetOnlineChipFromOffline(imod,col);
+     Int_t chipkey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
+     isfiredchip.SetBitNumber(chipkey,kTRUE);
+    }
+    
+  } 
+  return isfiredchip;
+  
+}
+//______________________________________________________________________
+TBits AliITSDetTypeRec::GetFiredChipMap(TTree *treeR) const{
+  //
+  // TBits of the fired chips  
+  //
+  TBits isfiredchip(1200);
+  
+  if(!treeR) {
+     AliError("no treeR. fired chip map stays empty. Exiting.");
+     return isfiredchip;
+   }
+   
+  AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
+  TClonesArray *recpoints = NULL;
+  rpcont->FetchClusters(0,treeR);
+  if(!rpcont->GetStatusOK() || !rpcont->IsSPDActive()){
+    AliError("no clusters. fired chip map stays empty. Exiting.");
+     return isfiredchip;
+  }
+  
+   AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)GetSegmentationModel(0);
+      
+   for(Int_t imod =0; imod < fgkDefaultNModulesSPD; imod++){
+    recpoints = rpcont->UncheckedGetClusters(imod);
+    Int_t nCluster = recpoints->GetEntriesFast();
+    
+    // loop over clusters
+    while(nCluster--) {
+      AliITSRecPoint* cluster = (AliITSRecPoint*)recpoints->UncheckedAt(nCluster);
+      if (cluster->GetLayer()>1)continue;
+      Float_t local[3]={-1,-1};
+      local[1]=cluster->GetDetLocalX();
+      local[0]=cluster->GetDetLocalZ();
+      
+      Int_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(imod);
+      Int_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(imod);
+      Int_t row, col;
+      segSPD->LocalToDet(0.5,local[0],row,col);
+      Int_t chip = AliITSRawStreamSPD::GetOnlineChipFromOffline(imod,col);
+      Int_t chipkey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
+      isfiredchip.SetBitNumber(chipkey,kTRUE);
+    }
+  }
+  return isfiredchip;
+}
+//______________________________________________________________________
+void  AliITSDetTypeRec::RemoveFastOrFiredFromDead(TBits firedchipmap){
+  //
+  // resetting of the fast-or bit on cluster basis. 
+  // fast-or bits can be remnant from SPD ideal simulation (no dead channels)
+  //
+  
+  for(Int_t chipKey=0; chipKey<1200; chipKey++){
+    // FO masked chips have been previously removed  
+   if(!fFastOrFiredMap.TestBitNumber(chipKey)) continue; 
+   if(!firedchipmap.TestBitNumber(chipKey))  {
+    fFastOrFiredMap.SetBitNumber(chipKey,kFALSE);
+    AliDebug(2,Form("removing bit in key %i \n ",chipKey));
+  }
+ }
+   
+}
+//______________________________________________________________________
 void AliITSDetTypeRec::SetFastOrFiredMapOnline(UInt_t eq, UInt_t hs, UInt_t chip) {
   // Set fast-or fired map for this chip
   Int_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
   return SetFastOrFiredMap(chipKey);
 }
 
-