]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSQASDDDataMakerRec.cxx
Fix for Savannah bug 66143
[u/mrichter/AliRoot.git] / ITS / AliITSQASDDDataMakerRec.cxx
index 3d0c738e436038cc62d1a2fa204e1928cecc6a5e..289a640f6ff09a99899e4d4599e7595485332801 100644 (file)
 
 #include <TProfile2D.h>
 #include <TH2D.h>
+#include <TH1F.h>
 #include <TBranch.h>
 #include <TTree.h>
-#include <TGaxis.h>
 #include <TMath.h>
-#include <TF1.h>
-#include <TDirectory.h>
-#include <TSystem.h>
+#include <TObjArray.h>
+
 // --- Standard library ---
 
 // --- AliRoot header files ---
 #include "AliITSQASDDDataMakerRec.h"
-#include "AliLog.h"
 #include "AliQAv1.h"
-#include "AliQAChecker.h"
 #include "AliRawReader.h"
 #include "AliITSRawStream.h"
 #include "AliITSRawStreamSDD.h"
-#include "AliITSRawStreamSDDCompressed.h"
-#include "AliITSDetTypeRec.h"
 #include "AliITSdigit.h"
 #include "AliITSRecPoint.h"
+#include "AliITSRecPointContainer.h"
 #include "AliITSgeomTGeo.h"
 #include "AliCDBManager.h"
-#include "AliCDBStorage.h"
 #include "AliCDBEntry.h"
-#include "Riostream.h"
-#include "AliITSdigitSDD.h"
-#include "AliITS.h"
-#include "AliRunLoader.h"
-#include "AliITSLoader.h"
-#include "AliITSDetTypeRec.h"
+#include "AliITSCalibrationSDD.h"
+
+class TGaxis;
+class TF1;
+class TSystem;
+class AliLog;
+class AliQAChecker;
+class AliITSRawStreamSDDCompressed;
+class AliCDBStorage;
+class Riostream;
+class AliITSdigitSDD;
+class AliITS;
+class AliRunLoader;
+class AliITSLoader;
+class AliITSDetTypeRec;
 
 
 
@@ -77,11 +81,11 @@ fGenRawsOffset(0),
 fGenDigitsOffset(0),
 fGenRecPointsOffset(0),
 fTimeBinSize(1),
+fNEvent(0),
+fNEventRP(0),
 fDDLModuleMap(0),
-fGoodAnodes(0),
-fBadAnodes(0),
-fGoodAnodesCurrent(0),
-fBadAnodesCurrent(0)
+fCalibration(0),
+fHistoCalibration(0)
 {
   //ctor used to discriminate OnLine-Offline analysis
   if(fLDC < 0 || fLDC > 6) {
@@ -89,10 +93,14 @@ fBadAnodesCurrent(0)
   }
        fGenRawsOffset = new Int_t[AliRecoParam::kNSpecies];
        fGenRecPointsOffset = new Int_t[AliRecoParam::kNSpecies];
+       fGenDigitsOffset = new Int_t[AliRecoParam::kNSpecies];
        for(Int_t i=0; i<AliRecoParam::kNSpecies; i++) {
                fGenRawsOffset[i] = 0;
                fGenRecPointsOffset[i] = 0;
+               fGenDigitsOffset[i]=0;
        }
+
+       InitCalibrationArray();
 }
 
 //____________________________________________________________________________ 
@@ -107,22 +115,24 @@ fSDDhRecPointsTask(qadm.fSDDhRecPointsTask),
 fGenRawsOffset(qadm.fGenRawsOffset),
 fGenDigitsOffset(qadm.fGenDigitsOffset),
 fGenRecPointsOffset(qadm.fGenRecPointsOffset),
-fTimeBinSize(1),
-fDDLModuleMap(0),
-fGoodAnodes(qadm.fGoodAnodes),
-fBadAnodes(qadm.fBadAnodes),
-fGoodAnodesCurrent(qadm.fGoodAnodesCurrent),
-fBadAnodesCurrent(qadm.fBadAnodesCurrent){
+fTimeBinSize(qadm.fTimeBinSize),
+fNEvent(qadm.fNEvent),
+fNEventRP(qadm.fNEventRP),
+fDDLModuleMap(qadm.fDDLModuleMap),
+fCalibration(qadm.fCalibration),
+fHistoCalibration(qadm.fHistoCalibration)
+{
   //copy ctor 
   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
-  fDDLModuleMap=NULL;
+  //fDDLModuleMap=NULL;
 }
 
 //____________________________________________________________________________ 
 AliITSQASDDDataMakerRec::~AliITSQASDDDataMakerRec(){
   // destructor
-  //   if(fDDLModuleMap) delete fDDLModuleMap;
+  //if(fDDLModuleMap) delete fDDLModuleMap;
+  if(fHistoCalibration){delete fHistoCalibration; fHistoCalibration=NULL;}
 }
 //__________________________________________________________________
 AliITSQASDDDataMakerRec& AliITSQASDDDataMakerRec::operator = (const AliITSQASDDDataMakerRec& qac )
@@ -136,91 +146,126 @@ AliITSQASDDDataMakerRec& AliITSQASDDDataMakerRec::operator = (const AliITSQASDDD
 //____________________________________________________________________________ 
 void AliITSQASDDDataMakerRec::StartOfDetectorCycle()
 {
-  //Detector specific actions at start of cycle
-  AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SDD Cycle\n");
+
+  //Start of a QA cycle
+
+  AliDebug(AliQAv1::GetQADebugLevel(),Form("Start of SDD Cycle with event specie %s for task %s\n",AliRecoParam::GetEventSpecieName(fAliITSQADataMakerRec->GetEventSpecie()),AliQAv1::GetTaskName(fAliITSQADataMakerRec->GetTaskIndexSelected()).Data()));
+  if(!fCalibration) {CreateTheCalibration();}
+
+  if(fAliITSQADataMakerRec->GetEventSpecie()==0) return;//not the kDefault EventSpecie
+    //Detector specific actions at start of cycle
+    if(fAliITSQADataMakerRec->GetTaskIndexSelected()==AliQAv1::kRAWS){
+      AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SDD Cycle\n");
+      if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRAWS)==kFALSE)return;
+
+       AliDebug(AliQAv1::GetQADebugLevel(),Form("Reset of Raw Data normalized histograms with eventspecie %s ",AliRecoParam::GetEventSpecieName(fAliITSQADataMakerRec->GetEventSpecie())));
+
+       fAliITSQADataMakerRec->GetRawsData(3+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
+       fAliITSQADataMakerRec->GetRawsData(4+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
+       fAliITSQADataMakerRec->GetRawsData(5+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
+      
+    }
+    if(fAliITSQADataMakerRec->GetTaskIndexSelected()==AliQAv1::kRECPOINTS){
+      if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRECPOINTS)==kFALSE)return;
+
+       AliDebug(AliQAv1::GetQADebugLevel(),Form("Reset of RecPoints normalized histograms with eventspecie %s ",AliRecoParam::GetEventSpecieName(fAliITSQADataMakerRec->GetEventSpecie())));
+
+       fAliITSQADataMakerRec->GetRecPointsData(9+  fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
+       fAliITSQADataMakerRec->GetRecPointsData(10+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
+       fAliITSQADataMakerRec->GetRecPointsData(11+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
+      }
 }
 
 //____________________________________________________________________________ 
-void AliITSQASDDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/)
+void AliITSQASDDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray* /*list*/)
 {
-  
-  // launch the QA checking
-       if(fkOnline) {
-               AnalyseBNG(); // Analyse Baseline, Noise, Gain
-               AnalyseINJ(); // Analyse Injectors
-       }
-  
+  //end of a QA cycle
        AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
+       if(task==AliQAv1::kRAWS){
+         //      printf("fNevent %d \n",fNEvent);
+         if(fNEvent!=0){
+           ((TH1D*)fAliITSQADataMakerRec->GetRawsData(3 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH1D*)fAliITSQADataMakerRec->GetRawsData(0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH1D*) (fHistoCalibration->At(0))),1.,(Double_t)fNEvent);
+         
+           ((TH2D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRawsData(1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEvent);
+           
+           ((TH2D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRawsData(2 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEvent);
+         }       
+       }//end raws
+       
+       if(task==AliQAv1::kRECPOINTS){
+         //      printf("fNeventRP %d \n",fNEventRP);
+         if(fNEventRP!=0){
+           ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(9 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(6 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH1D*) (fHistoCalibration->At(0))),1.,(Double_t)fNEventRP);
+           
+           ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(10+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(7 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEventRP);
+           
+           ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(11+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(8 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEventRP);
+         }
+       }//end recpoints
+       
 }
 
 //____________________________________________________________________________ 
 Int_t AliITSQASDDDataMakerRec::InitRaws()
 { 
+
   // Initialization for RAW data - SDD -
   const Bool_t expert   = kTRUE ; 
   const Bool_t saveCorr = kTRUE ; 
   const Bool_t image    = kTRUE ; 
-  Int_t rv = 0 ; 
-  AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
-  Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
-  if(!ddlMapSDD)
-    {
-      AliError("Calibration object retrieval failed! SDD will not be processed");
-      fDDLModuleMap = NULL;
-      return rv;
-    }
-  fDDLModuleMap = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
-  if(!cacheStatus)ddlMapSDD->SetObject(NULL);
-  ddlMapSDD->SetOwner(kTRUE);
-  if(!cacheStatus)
-    {
-      delete ddlMapSDD;
-    }
 
+  Int_t rv = 0 ; 
   Int_t lay, lad, det;
   Int_t indexlast = 0;
   Int_t index1 = 0;
 
-  if(fkOnline) 
-    {
-      AliInfo("Book Online Histograms for SDD\n");
-    }
-  else 
-    {
-      AliInfo("Book Offline Histograms for SDD\n ");
-    }
+  if(fkOnline){AliInfo("Book Online Histograms for SDD\n");}
+  else {AliInfo("Book Offline Histograms for SDD\n ");}
   TH1D *h0 = new TH1D("SDDModPattern","HW Modules pattern",fgknSDDmodules,239.5,499.5); //0
   h0->GetXaxis()->SetTitle("Module Number");
   h0->GetYaxis()->SetTitle("Counts");
-   rv = fAliITSQADataMakerRec->Add2RawsList((new TH1D(*h0)),0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
-  delete h0;
+  rv = fAliITSQADataMakerRec->Add2RawsList(h0,0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
   fSDDhRawsTask++;
   
   //zPhi distribution using ladder and modules numbers
-  TH2D *hphil3 = new TH2D("SDDphizL3","SDD #varphiz Layer3 ",6,0.5,6.5,14,0.5,14.5);
-  hphil3->GetXaxis()->SetTitle("z[#Module L3 ]");
-  hphil3->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
-   rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hphil3)),1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr); 
-  delete hphil3;
+  TH2D *hphil3 = new TH2D("SDDphizL3","SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);//1
+  hphil3->GetXaxis()->SetTitle("z[Module Number L3 ]");
+  hphil3->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
+  rv = fAliITSQADataMakerRec->Add2RawsList(hphil3,1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr); 
   fSDDhRawsTask++;
   
-  TH2D *hphil4 = new TH2D("SDDphizL4","SDD #varphiz Layer4 ",8,0.5,8.5,22,0.5,22.5); 
-  hphil4->GetXaxis()->SetTitle("z[#Module L4]");
-  hphil4->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
-   rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hphil4)),2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr); 
-  delete hphil4;
+  TH2D *hphil4 = new TH2D("SDDphizL4","SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5); //2
+  hphil4->GetXaxis()->SetTitle("z[Module Number L4]");
+  hphil4->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
+   rv = fAliITSQADataMakerRec->Add2RawsList(hphil4,2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr); 
   fSDDhRawsTask++;
   
+  //normalized histograms
+  TH1D *h0norm = new TH1D("SDDModPatternNORM","NORM HW Modules pattern",fgknSDDmodules,239.5,499.5); //3
+  h0norm->GetXaxis()->SetTitle("Module Number");
+  h0norm->GetYaxis()->SetTitle("Counts");
+  rv = fAliITSQADataMakerRec->Add2RawsList(h0norm,3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
+  fSDDhRawsTask++;
+  
+  //zPhi distribution using ladder and modules numbers
+  TH2D *hphil3norm = new TH2D("SDDphizL3NORM","NORM SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);//4
+  hphil3norm->GetXaxis()->SetTitle("z[Module Number L3 ]");
+  hphil3norm->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
+  rv = fAliITSQADataMakerRec->Add2RawsList(hphil3norm,4+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
+  fSDDhRawsTask++;
+  
+  TH2D *hphil4norm = new TH2D("SDDphizL4NORM","NORM SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5); //5
+  hphil4norm->GetXaxis()->SetTitle("z[Module Number L4]");
+  hphil4norm->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
+   rv = fAliITSQADataMakerRec->Add2RawsList(hphil4norm,5+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
+  fSDDhRawsTask++;
 
-  if(fkOnline) 
-    {
-
+  if(fkOnline){
       //DDL Pattern 
-      TH2D *hddl = new TH2D("SDDDDLPattern","SDD DDL Pattern ",24,-0.5,23.5,24,-0.5,23.5); 
+      TH2D *hddl = new TH2D("SDDDDLPattern","SDD DDL Pattern ",24,-0.5,11.5,24,-0.5,23.5); //6
       hddl->GetXaxis()->SetTitle("Channel");
-      hddl->GetYaxis()->SetTitle("#DDL");
-      rv = fAliITSQADataMakerRec->Add2RawsList((new TH2D(*hddl)),3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
-      delete hddl;
+      hddl->GetYaxis()->SetTitle("DDL Number");
+      rv = fAliITSQADataMakerRec->Add2RawsList(hddl,6+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
       fSDDhRawsTask++;
       Int_t indexlast1 = 0;
   
@@ -239,9 +284,7 @@ Int_t AliITSQASDDDataMakerRec::InitRaws()
          TProfile2D *fModuleChargeMapFSE = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
          fModuleChargeMapFSE->GetXaxis()->SetTitle("Time Bin");
          fModuleChargeMapFSE->GetYaxis()->SetTitle("Anode");
-          rv = fAliITSQADataMakerRec->Add2RawsList((new TProfile2D(*fModuleChargeMapFSE)),indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
-         delete fModuleChargeMapFSE;
-         
+          rv = fAliITSQADataMakerRec->Add2RawsList(fModuleChargeMapFSE,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);        
          fSDDhRawsTask++;
          index1++;      
        }
@@ -254,18 +297,22 @@ Int_t AliITSQASDDDataMakerRec::InitRaws()
          sprintf(hname[1],"SDDChargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
          TProfile2D *fModuleChargeMap = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
          fModuleChargeMap->GetXaxis()->SetTitle("Time Bin");
-         fModuleChargeMap->GetYaxis()->SetTitle("Anode");
-          rv = fAliITSQADataMakerRec->Add2RawsList((new TProfile2D(*fModuleChargeMap)),indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
-         delete fModuleChargeMap;
-         
+         fModuleChargeMap->GetYaxis()->SetTitle("Anode Number");
+          rv = fAliITSQADataMakerRec->Add2RawsList(fModuleChargeMap,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
          fSDDhRawsTask++;
          index1++;      
        }
       }
       
+      //Event Size 
+      TH1F *hsize = new TH1F("SDDEventSize","SDD Event Size ",500,-0.5,199.5); 
+      hsize->SetBit(TH1::kCanRebin);
+      hsize->GetXaxis()->SetTitle("Event Size [kB]");
+      hsize->GetYaxis()->SetTitle("Entries");
+      rv = fAliITSQADataMakerRec->Add2RawsList(hsize,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
+      fSDDhRawsTask++;
          
     }  // kONLINE
-  
   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Raws histograms booked\n",fSDDhRawsTask));
   return rv ; 
 }
@@ -275,16 +322,14 @@ Int_t AliITSQASDDDataMakerRec::InitRaws()
 Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
 { 
   // Fill QA for RAW - SDD -
-       Int_t rv = 0;
+  Int_t rv = 0;
   // Check id histograms already created for this Event Specie
-
-  if(!fDDLModuleMap){
-    AliError("SDD DDL module map not available - skipping SDD QA");
-    return rv;
-  }
+  fNEvent++;
+  if(!fDDLModuleMap){CreateTheMap();}
   if(rawReader->GetType() != 7) return rv;  // skips non physical triggers
   AliDebug(AliQAv1::GetQADebugLevel(),"entering MakeRaws\n");                 
   rawReader->Reset();       
+  rawReader->Select("ITSSDD");
   AliITSRawStream *stream=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
    stream->SetDDLModuleMap(fDDLModuleMap);
   
@@ -294,7 +339,7 @@ Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
   if(fkOnline) {
     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
       for(Int_t iside=0;iside<fgknSide;iside++) {
-               if(fSDDhRawsTask > 4 + index) fAliITSQADataMakerRec->GetRawsData(4 + index +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();   
+               if(fSDDhRawsTask > 7 + index) fAliITSQADataMakerRec->GetRawsData(7 + index +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();   
        // 4  because the 2D histos for single events start after the fourth position
        index++;
       }
@@ -306,11 +351,19 @@ Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
   Int_t iddl = -1;
   Int_t isddmod = -1;
   Int_t coord1, coord2, signal, moduleSDD, activeModule, index1; 
-  
+  //if(fkOnline)
+  //{
+      Int_t prevDDLID = -1;
+      UInt_t size = 0;
+      int totalddl=static_cast<int>(fDDLModuleMap->GetNDDLs());
+      Bool_t *ddldata=new Bool_t[totalddl];
+      for(Int_t jddl=0;jddl<totalddl;jddl++){ddldata[jddl]=kFALSE;}
+      //}
   while(stream->Next()) {
     ildcID = rawReader->GetLDCId();
-    iddl = rawReader->GetDDLID() - fgkDDLIDshift;
-    
+    iddl = rawReader->GetDDLID();// - fgkDDLIDshift;
+    //printf("----------------------iddl %i\n",iddl);
+
     isddmod = fDDLModuleMap->GetModuleNumber(iddl,stream->GetCarlosId());
     if(isddmod==-1){
       AliDebug(AliQAv1::GetQADebugLevel(),Form("Found module with iddl: %d, stream->GetCarlosId: %d \n",iddl,stream->GetCarlosId()));
@@ -321,6 +374,13 @@ Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
       continue;
     } 
     if(stream->IsCompletedDDL()) {
+      if(fkOnline){
+       if ((rawReader->GetDDLID() != prevDDLID)&&(ddldata[iddl])==kFALSE){
+         size += rawReader->GetDataSize();//in bytes
+         prevDDLID = rawReader->GetDDLID();
+         ddldata[iddl]=kTRUE;
+       }
+      }
       AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedDDL == KTRUE\n"));
       continue;
     } 
@@ -337,20 +397,18 @@ Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
     }
     
     AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
-    fAliITSQADataMakerRec->GetRawsData( 0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] )->Fill(isddmod);   
-    if(lay==3)    fAliITSQADataMakerRec->GetRawsData(1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det,lad); 
-    if(lay==4) { 
-      fAliITSQADataMakerRec->GetRawsData(2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det,lad);}  
-    
     Short_t iside = stream->GetChannel();
-    
-
-    
 
+    //printf(" \n%i %i %i %i \n ",lay, lad, det,iside );
+    fAliITSQADataMakerRec->GetRawsData( 0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] )->Fill(isddmod);   
+    if(lay==3)    fAliITSQADataMakerRec->GetRawsData(1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad); 
+    if(lay==4) {fAliITSQADataMakerRec->GetRawsData(2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);}  
     if(fkOnline) {
 
-      fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(2*(stream->GetCarlosId())+iside,iddl);
-
+      fAliITSQADataMakerRec->GetRawsData(6+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill((stream->GetCarlosId())+0.5*iside -0.5,iddl);
+      //  printf("content ddlmap %d, %d = %f \n",(stream->GetCarlosId()+0.5*iside -0.5),iddl,fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetBinContent(1+(det-1)*2;lad));
+      //printf("content ddlmap %d, %d = %f \n",(stream->GetCarlosId())+0.5*iside -0.5,iddl,fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetBinContent(1+(stream->GetCarlosId()-1)*2,iddl));
       activeModule = moduleSDD;
       index1 = activeModule * 2 + iside;
       
@@ -358,14 +416,16 @@ Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
         AliDebug(AliQAv1::GetQADebugLevel(),Form("Wrong index number %d - patched to 0\n",index1));
        index1 = 0;
       }      
-      fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(2*(stream->GetCarlosId())+iside,iddl);
-      if(fSDDhRawsTask > 4 + index1) {                                  
-        ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(4 + index1 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);     
-        ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(4 + index1 + 260*2 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal); 
+
+      if(fSDDhRawsTask > 7 + index1) {                                  
+        ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(7 + index1 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);     
+        ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(7 + index1 + 260*2 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal); 
       }
-    }
+    }//online
     cnt++;
     if(!(cnt%10000)) AliDebug(AliQAv1::GetQADebugLevel(),Form(" %d raw digits read",cnt));
+  }//end next()
+  if(fkOnline){((TH1F*)(fAliITSQADataMakerRec->GetRawsData(7 + 260*4 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(size/1024.);//KB
   }
   AliDebug(AliQAv1::GetQADebugLevel(),Form("Event completed, %d raw digits read",cnt)); 
   delete stream;
@@ -376,15 +436,15 @@ Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
 //             AnalyseINJ(); // Analyse Injectors
 //     }
 
-
+  delete []ddldata;
+  ddldata=NULL;
   return rv ; 
 }
 
 //____________________________________________________________________________ 
 Int_t AliITSQASDDDataMakerRec::InitDigits()
 { 
-
-
+  //  if(!fHistoCalibration)InitCalibrationArray();
   // Initialization for DIGIT data - SDD -  
   const Bool_t expert   = kTRUE ; 
   const Bool_t image    = kTRUE ;
@@ -394,23 +454,27 @@ Int_t AliITSQASDDDataMakerRec::InitDigits()
   TH1F* h0=new TH1F("SDD DIGITS Module Pattern","SDD DIGITS Module Pattern",260,239.5,499.5);       //hmod
   h0->GetXaxis()->SetTitle("SDD Module Number");
   h0->GetYaxis()->SetTitle("# DIGITS");
-  rv = fAliITSQADataMakerRec->Add2DigitsList(h0,fGenDigitsOffset, !expert, image);
+  rv = fAliITSQADataMakerRec->Add2DigitsList(h0,fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
   fSDDhDigitsTask ++;
+  // printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
   TH1F* h1=new TH1F("SDD Anode Distribution","DIGITS Anode Distribution",512,-0.5,511.5);      //hanocc
   h1->GetXaxis()->SetTitle("Anode Number");
   h1->GetYaxis()->SetTitle("# DIGITS");
-  rv = fAliITSQADataMakerRec->Add2DigitsList(h1,1+fGenDigitsOffset, !expert, image);
+  rv = fAliITSQADataMakerRec->Add2DigitsList(h1,1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
   fSDDhDigitsTask ++;
+  //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
   TH1F* h2=new TH1F("SDD Tbin Distribution","DIGITS Tbin Distribution",256,-0.5,255.5);      //htbocc
   h2->GetXaxis()->SetTitle("Tbin Number");
   h2->GetYaxis()->SetTitle("# DIGITS");
-  rv = fAliITSQADataMakerRec->Add2DigitsList(h2,2+fGenDigitsOffset, !expert, image);
+  rv = fAliITSQADataMakerRec->Add2DigitsList(h2,2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
   fSDDhDigitsTask ++;
+  //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
   TH1F* h3=new TH1F("SDD ADC Counts Distribution","DIGITS ADC Counts Distribution",200,0.,1024.);          //hsig
   h3->GetXaxis()->SetTitle("ADC Value");
   h3->GetYaxis()->SetTitle("# DIGITS");
-  rv = fAliITSQADataMakerRec->Add2DigitsList(h3,3+fGenDigitsOffset, !expert, image);
+  rv = fAliITSQADataMakerRec->Add2DigitsList(h3,3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
   fSDDhDigitsTask ++;
+  //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Digits histograms booked\n",fSDDhDigitsTask));
   return rv ; 
 }
@@ -445,16 +509,16 @@ Int_t AliITSQASDDDataMakerRec::MakeDigits(TTree * digits)
     Int_t nmod=i+240;
     digits->GetEvent(nmod);
     Int_t ndigits = iITSdigits->GetEntries();
-    fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset)->Fill(nmod,ndigits);
+    fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nmod,ndigits);
 
     for (Int_t idig=0; idig<ndigits; idig++) {
       AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
       Int_t iz=dig->GetCoord1();  // cell number z
       Int_t ix=dig->GetCoord2();  // cell number x
       Int_t sig=dig->GetSignal();
-      fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset)->Fill(iz);
-      fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset)->Fill(ix);
-      fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset)->Fill(sig);
+      fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iz);
+      fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(ix);
+      fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(sig);
     }
   }
   return rv ; 
@@ -463,7 +527,7 @@ Int_t AliITSQASDDDataMakerRec::MakeDigits(TTree * digits)
 //____________________________________________________________________________ 
 Int_t AliITSQASDDDataMakerRec::InitRecPoints()
 {
-
+  //if(!fHistoCalibration)InitCalibrationArray();
        //AliInfo("Initialize SDD recpoints histos\n");
   // Initialization for RECPOINTS - SDD -
   const Bool_t expert   = kTRUE ; 
@@ -471,137 +535,151 @@ Int_t AliITSQASDDDataMakerRec::InitRecPoints()
   Int_t rv = 0 ; 
 //  fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
 
-  Int_t nOnline=1;
-  Int_t  nOnline2=1;
-  Int_t  nOnline3=1; 
-  Int_t  nOnline4=1;
-  if(fkOnline)
-    {
-      nOnline=4;
-      nOnline2=28;
-      nOnline3=64;
-      nOnline4=14;
-    }
-
   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
-  TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",1000/nOnline,-0.5, 499.5); //position number 0
-  h0->GetXaxis()->SetTitle("ADC value");
+  TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",250,-0.5, 499.5); //position number 0
+  //h0->SetBit(TH1::kCanRebin);
+  h0->GetXaxis()->SetTitle("KeV");
   h0->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h0)), 0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
-  //delete h0;
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h0, 0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
   fSDDhRecPointsTask++;
  
-  TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",1000/nOnline,-0.5, 499.5);//position number 1
-  h1->GetXaxis()->SetTitle("ADC value");
+  TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",250,-0.5, 499.5);//position number 1
+  //h1->SetBit(TH1::kCanRebin);
+  h1->GetXaxis()->SetTitle("Kev");
   h1->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h1)), 1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
-  delete h1;
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h1, 1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
   fSDDhRecPointsTask++;
 
   char hisnam[50];
-  TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 2
+  TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",56,-28,28,56,-28,28);//position number 2
   h2->GetYaxis()->SetTitle("Y[cm]");
   h2->GetXaxis()->SetTitle("X[cm]");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h2)),2+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, !image);
-  delete h2;
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h2,2+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert image
   fSDDhRecPointsTask++;
 
-  TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",6400/nOnline3,-32,32,1400/nOnline4,12,26);//position number 3
+  TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",128,-32,32,56,12,26);//position number 3
   h3->GetYaxis()->SetTitle("R[cm]");
   h3->GetXaxis()->SetTitle("Z[cm]");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h3)),3+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, !image);
-  delete h3;
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h3,3+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert image
   fSDDhRecPointsTask++;
   
-  TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 4
+  TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",46,-23,23,90,-TMath::Pi(),TMath::Pi());//position number 4
   h4->GetYaxis()->SetTitle("#phi[rad]");
   h4->GetXaxis()->SetTitle("Z[cm]");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h4)),4+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
-  delete h4;
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h4,4+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
   fSDDhRecPointsTask++;
 
-  TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",6400/nOnline3,-32,32,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 5
+  TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",62,-31,31,90,-TMath::Pi(),TMath::Pi());//position number 5
   h5->GetYaxis()->SetTitle("#phi[rad]");
   h5->GetXaxis()->SetTitle("Z[cm]");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h5)),5+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
-  delete h5;
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h5,5+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
   fSDDhRecPointsTask++;
   
-  TH1F *h6 = new TH1F("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
+  TH1D *h6 = new TH1D("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
   h6->GetXaxis()->SetTitle("Module number"); //spd offset = 240
   h6->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h6)),6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-  delete h6;
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h6,6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
   fSDDhRecPointsTask++;
-  TH1F *h7 = new TH1F("SDDLadPatternL3RP","Ladder pattern L3 RP",14,0.5,14.5);  //position number 7
-  h7->GetXaxis()->SetTitle("Ladder #, Layer 3");
-  h7->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h7)),7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-  delete h7;
+
+  
+  TH2D *h7 = new TH2D("SDDModPatternL3RP","Modules pattern L3 RP",12,0.5,6.5,14,0.5,14.5);  //position number 7
+  h7->GetXaxis()->SetTitle("z[#Module L3 ]");
+  h7->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h7,7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
   fSDDhRecPointsTask++;
-  TH1F *h8 = new TH1F("SDDLadPatternL4RP","Ladder pattern L4 RP",22,0.5,22.5); //position number 8
-  h8->GetXaxis()->SetTitle("Ladder #, Layer 4");
-  h8->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h8)),8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-  delete h8;
+
+  TH2D *h8 = new TH2D("SDDModPatternL4RP","Modules pattern L4 RP",16,0.5,8.5,22,0.5,22.5); //position number 8
+  h8->GetXaxis()->SetTitle("[#Module L3 ]");
+  h8->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h8,8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
   fSDDhRecPointsTask++;
-  TH2F *h9 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",1000/nOnline,-4,4,1000/nOnline,-4,4);//position number 9
-  h9->GetXaxis()->SetTitle("X local coord, drift, cm");
-  h9->GetYaxis()->SetTitle("Z local coord, anode, cm");
-  rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h9)),9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-  delete h9;
+
+  //------------------------norm--------------------------//
+
+
+  TH1D *h9 = new TH1D("SDDModPatternRPNORM","Modules pattern RP NORM",fgknSDDmodules,239.5,499.5); //position number 9
+  h9->GetXaxis()->SetTitle("Module number"); //spd offset = 240
+  h9->GetYaxis()->SetTitle("Entries");
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h9,9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
   fSDDhRecPointsTask++;
 
-       //AliInfo("Create SDD recpoints histos\n");
+  
+  TH2D *h10 = new TH2D("SDDModPatternL3RPNORM","Modules pattern L3 RP NORM",12,0.5,6.5,14,0.5,14.5);  //position number 10
+  h10->GetXaxis()->SetTitle("z[#Module L3 ]");
+  h10->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h10,10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO  image
+  fSDDhRecPointsTask++;
 
-    TH1F *h10 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,18.);//position number 10 (L3)
-    h10->GetXaxis()->SetTitle("r[cm]");
-    h10->GetXaxis()->CenterTitle();
-    h10->GetYaxis()->SetTitle("Entries");
-    rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h10)),10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-    delete h10;
-    fSDDhRecPointsTask++;
+  TH2D *h11 = new TH2D("SDDModPatternL4RPNORM","Modules pattern L4 RP NORM",16,0.5,8.5,22,0.5,22.5); //position number 11
+  h11->GetXaxis()->SetTitle("[#Module L3 ]");
+  h10->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h11,11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert NO image
+  fSDDhRecPointsTask++;
 
-    TH1F *h11 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,22.,26.);// and position number 11 (L4)
-    h11->GetXaxis()->SetTitle("r[cm]");
-    h11->GetXaxis()->CenterTitle();
-    h11->GetYaxis()->SetTitle("Entries");
-    rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h11)),11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-    delete h11;
-    fSDDhRecPointsTask++;
+  //--------------------------------------------------------//
 
+  TH2F *h12 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",160,-4,4,160,-4,4);//position number 12
+  h12->GetXaxis()->SetTitle("X local coord, drift, cm");
+  h12->GetYaxis()->SetTitle("Z local coord, anode, cm");
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h12,12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert  NO image
+  fSDDhRecPointsTask++;
+  
+  //AliInfo("Create SDD recpoints histos\n");
+  
+  TH1F *h13 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,16.5);//position number 13 (L3)
+  h13->SetBit(TH1::kCanRebin);
+  h13->GetXaxis()->SetTitle("r[cm]");
+  h13->GetXaxis()->CenterTitle();
+  h13->GetYaxis()->SetTitle("Entries");
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h13,13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
+  fSDDhRecPointsTask++;
+  
+  TH1F *h14 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,23.,25.);// and position number 14 (L4)
+  h14->SetBit(TH1::kCanRebin);
+  h14->GetXaxis()->SetTitle("r[cm]");
+  h14->GetXaxis()->CenterTitle();
+  h14->GetYaxis()->SetTitle("Entries");
+  rv = fAliITSQADataMakerRec->Add2RecPointsList(h14,14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
+  fSDDhRecPointsTask++;
+  
   for(Int_t iLay=0; iLay<=1; iLay++){
     sprintf(hisnam,"SDDphidistrib_Layer%d",iLay+3);
-    TH1F *h12 = new TH1F(hisnam,hisnam,180,-TMath::Pi(),TMath::Pi());//position number 12 (L3) and position number 13 (L4)
-    h12->GetXaxis()->SetTitle("#varphi[rad]");
-    h12->GetXaxis()->CenterTitle();
-    h12->GetYaxis()->SetTitle("Entries");
-    rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH1F(*h12)),iLay+12+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-    delete h12;
+    TH1F *h15 = new TH1F(hisnam,hisnam,180,-TMath::Pi(),TMath::Pi());//position number 15 (L3) and position number 16 (L4)
+    h15->GetXaxis()->SetTitle("#varphi[rad]");
+    h15->GetXaxis()->CenterTitle();
+    h15->GetYaxis()->SetTitle("Entries");
+    rv = fAliITSQADataMakerRec->Add2RecPointsList(h15,iLay+15+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
     fSDDhRecPointsTask++;
   }
-
-  if(fkOnline)
-    {
-      TH2F *h14 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 14
-      h14->GetYaxis()->SetTitle("Y[cm]");
-      h14->GetXaxis()->SetTitle("X[cm]");
-      rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h14)),14+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-      delete h14;
-      fSDDhRecPointsTask++;
-      
-      TH2F *h15 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",Int_t(6400/nOnline3),-32,32,1400/nOnline4,12,26);//position number 15
-      h15->GetYaxis()->SetTitle("R[cm]");
-      h15->GetXaxis()->SetTitle("Z[cm]");
-      rv = fAliITSQADataMakerRec->Add2RecPointsList((new TH2F(*h15)),15+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
-      delete h15;
+  
+  for(Int_t iLay=0; iLay<=1; iLay++){
+    sprintf(hisnam,"SDDdrifttime_Layer%d",iLay+3);
+    TH1F *h17 = new TH1F(hisnam,hisnam,45,-0.5,4499.5);//position number 17 (L3) and position number 18 (L4)
+    h17->SetBit(TH1::kCanRebin);
+    h17->GetXaxis()->SetTitle("drift time[ns]");
+    h17->GetXaxis()->CenterTitle();
+    h17->GetYaxis()->SetTitle("Entries");
+    rv = fAliITSQADataMakerRec->Add2RecPointsList(h17,iLay+17+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert  image
+    fSDDhRecPointsTask++;
+  }
+  
+  if(fkOnline){
+      TH2F *h19 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",112,-28,28,112,-28,28);//position number 19
+      h19->GetYaxis()->SetTitle("Y[cm]");
+      h19->GetXaxis()->SetTitle("X[cm]");
+      rv = fAliITSQADataMakerRec->Add2RecPointsList(h19,19+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
       fSDDhRecPointsTask++;
       
+      TH2F *h20 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",128,-32,32,56,12,26);//position number 20
+      h20->GetYaxis()->SetTitle("R[cm]");
+      h20->GetXaxis()->SetTitle("Z[cm]");
+      rv = fAliITSQADataMakerRec->Add2RecPointsList(h20,20+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
+      fSDDhRecPointsTask++;      
     }//online
-
+  
   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Recs histograms booked\n",fSDDhRecPointsTask));
-
+  
   return rv ; 
 }
 
@@ -609,567 +687,264 @@ Int_t AliITSQASDDDataMakerRec::InitRecPoints()
 Int_t AliITSQASDDDataMakerRec::MakeRecPoints(TTree * clustersTree)
 {
  // Fill QA for RecPoints - SDD -
-  Int_t rv = 0 ; 
-
-  //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
-  //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
-  // Check id histograms already created for this Event Specie
-//  if ( ! fAliITSQADataMakerRec->GetRecPointsData(fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]) )
-//    rv = InitRecPoints() ;
+  Int_t rv = 0 ;
+  fNEventRP++; 
   Int_t lay, lad, det; 
   //AliInfo("get the branch with the ITS clusters !\n");
-  TBranch *branchRecP = clustersTree->GetBranch("ITSRecPoints");
-  if (!branchRecP) {
-    AliError("can't get the branch with the ITS clusters !");
-    return rv ;
+  AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
+  TClonesArray *recpoints=NULL; 
+  if(fkOnline){recpoints = rpcont->FetchClusters(0,clustersTree,fAliITSQADataMakerRec->GetEventNumber());}
+  else{recpoints = rpcont->FetchClusters(0,clustersTree);}
+  if(!rpcont->GetStatusOK() || !rpcont->IsSDDActive()){
+    AliError("can't get SDD clusters !");
+    return rv;
   }
 
-  static TClonesArray statRecpoints("AliITSRecPoint") ;
-  TClonesArray *recpoints = &statRecpoints;
-  branchRecP->SetAddress(&recpoints);
   Int_t npoints = 0;      
   Float_t cluglo[3]={0.,0.,0.}; 
-  if(fkOnline)
-    {
-      for(Int_t i=14;i<16;i++)
-       {
+  if(fkOnline){
+      for(Int_t i=19;i<21;i++){
          fAliITSQADataMakerRec->GetRecPointsData(i+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
        }
     }
-       for(Int_t module=0; module<clustersTree->GetEntries();module++){
-               //AliInfo(Form("Module %d\n",module));
-               branchRecP->GetEvent(module);
-               npoints += recpoints->GetEntries();
-               //AliInfo(Form("modnumb %d, npoints %d, total points %d\n",module, recpoints->GetEntries(),npoints));
-               AliITSgeomTGeo::GetModuleId(module, lay, lad, det);
-               //AliInfo(Form("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det));
-               Bool_t kSDD = kFALSE;
-               if(lay == 3 || lay == 4) kSDD = kTRUE;
-               if(!kSDD) continue;
-               //AliInfo(Form("modnumb %d, entries %d\n",module, recpoints->GetEntries()));
-               for(Int_t j=0;j<recpoints->GetEntries();j++){
-                       //AliInfo(Form("modnumb %d, entry %d \n",module, j));
-                       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j);    
-                       fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(module);//modpatternrp
-                       recp->GetGlobalXYZ(cluglo);
-                       Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
-                       Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
-                       fAliITSQADataMakerRec->GetRecPointsData(9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
-                       fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX
-                       fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz
-                       if(fkOnline) {
-                               fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
-                               fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz FSE
-                       }
-                       if(recp->GetLayer() == 2) {
-                               fAliITSQADataMakerRec->GetRecPointsData(0  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge of layer 3
-                               fAliITSQADataMakerRec->GetRecPointsData(7  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//lad pattern layer 3
-                               fAliITSQADataMakerRec->GetRecPointsData(10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution layer 3
-                               fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);// phi distribution layer 3
-                               fAliITSQADataMakerRec->GetRecPointsData(4  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// phi distribution layer 3
-                       } else if(recp->GetLayer() == 3) {
-                               fAliITSQADataMakerRec->GetRecPointsData(1  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge layer 4
-                               fAliITSQADataMakerRec->GetRecPointsData(8  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//ladpatternlayer4
-                               fAliITSQADataMakerRec->GetRecPointsData(11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution
-                               fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);//phi distribution
-                               fAliITSQADataMakerRec->GetRecPointsData(5  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// phi distribution layer 4
-                       }
-               }
-       }
-       statRecpoints.Clear();
-       return rv ; 
+  Int_t firMod=AliITSgeomTGeo::GetModuleIndex(3,1,1);
+  Int_t lasMod=AliITSgeomTGeo::GetModuleIndex(5,1,1);
+  for(Int_t module=firMod; module<lasMod;module++){
+    //AliInfo(Form("Module %d\n",module));
+    recpoints = rpcont->UncheckedGetClusters(module);
+    npoints += recpoints->GetEntries();
+    //AliInfo(Form("modnumb %d, npoints %d, total points %d\n",module, recpoints->GetEntries(),npoints));
+    //AliITSgeomTGeo::GetModuleId(module, lay, lad, det);
+    //AliInfo(Form("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det));
+    
+    //AliInfo(Form("modnumb %d, entries %d\n",module, recpoints->GetEntries()));
+    for(Int_t j=0;j<recpoints->GetEntries();j++){
+      //AliInfo(Form("modnumb %d, entry %d \n",module, j));
+      AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j); 
+      Int_t index = recp->GetDetectorIndex();
+      lay=recp->GetLayer();
+      Int_t modnumb=index+AliITSgeomTGeo::GetModuleIndex(lay+1,1,1);
+      //printf("modnumb  %i\n",modnumb);  
+      AliITSgeomTGeo::GetModuleId(modnumb, lay, lad, det);  
+      fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(modnumb);//modpatternrp
+      recp->GetGlobalXYZ(cluglo);
+      Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
+      Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
+      Float_t drifttime=recp->GetDriftTime();
+      fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
+      if(lay==3||lay==4)fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX
+      fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz
+      if(fkOnline) {
+       fAliITSQADataMakerRec->GetRecPointsData(19 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
+       fAliITSQADataMakerRec->GetRecPointsData(20 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz FSE
+      }
+      if(recp->GetLayer() == 2) {
+       fAliITSQADataMakerRec->GetRecPointsData(0  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge of layer 3
+       //fAliITSQADataMakerRec->GetRecPointsData(7  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//lad pattern layer 3
+       Int_t iside=recp->GetDriftSide();
+       //printf("iside =%d\n",iside);
+       fAliITSQADataMakerRec->GetRecPointsData(7  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);//mod pattern layer 3
+       fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution layer 3
+       fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);// phi distribution layer 3
+       fAliITSQADataMakerRec->GetRecPointsData(4  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// zphi distribution layer
+       fAliITSQADataMakerRec->GetRecPointsData(17  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(drifttime);// time distribution layer 3
+      } else if(recp->GetLayer() == 3) {
+       fAliITSQADataMakerRec->GetRecPointsData(1  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge layer 4
+       //fAliITSQADataMakerRec->GetRecPointsData(8  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//ladpatternlayer4
+       Int_t iside=recp->GetDriftSide();
+       //printf("iside =%d\n",iside);
+       fAliITSQADataMakerRec->GetRecPointsData(8  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);//mod pattern layer 4
+       fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution
+       fAliITSQADataMakerRec->GetRecPointsData(16 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);//phi distribution
+       fAliITSQADataMakerRec->GetRecPointsData(5  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// zphi distribution layer 4
+       fAliITSQADataMakerRec->GetRecPointsData(18  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(drifttime);// time distribution layer 4
+      }
+    }
+  }
+  return rv ; 
 }
 
 //_______________________________________________________________
 
-Int_t AliITSQASDDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task)
+Int_t AliITSQASDDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task, Int_t specie)const
 {
+  // Returns offset number according to the specified task
   Int_t offset=0;
-  if( task == AliQAv1::kRAWS )
-    {
-      offset=fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()];  
-    }
-  else if(task == AliQAv1::kDIGITSR )
-    {
-      offset=fGenDigitsOffset;
-    }
-  else if( task == AliQAv1::kRECPOINTS )
-    {
-      offset=fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()];   
-    }
+  if( task == AliQAv1::kRAWS ){offset=fGenRawsOffset[specie];}
+  else if(task == AliQAv1::kDIGITSR ){offset=fGenDigitsOffset[specie];}
+  else if( task == AliQAv1::kRECPOINTS ){offset=fGenRecPointsOffset[specie];}
   return offset;
 }
 
 //_______________________________________________________________
 
 void AliITSQASDDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
-  // Returns offset number according to the specified task
-  if( task == AliQAv1::kRAWS ) {
-    fGenRawsOffset[specie]=offset;
-  }
-  else if( task == AliQAv1::kDIGITSR ) {
-    fGenDigitsOffset=offset;
-  }
-  else if( task == AliQAv1::kRECPOINTS ) {
-    fGenRecPointsOffset[specie]=offset;
-  }
+  // Set offset number according to the specified task
+  if( task == AliQAv1::kRAWS ) {fGenRawsOffset[specie]=offset;}
+  else if( task == AliQAv1::kDIGITSR ) {fGenDigitsOffset[specie]=offset;}
+  else if( task == AliQAv1::kRECPOINTS ) {fGenRecPointsOffset[specie]=offset;}
 }
 
 //_______________________________________________________________
 
 Int_t AliITSQASDDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task)
 {
-
+  //return the number of histo booked for a given Task
   Int_t histotot=0;
-
-  if( task == AliQAv1::kRAWS )
-    {
-      histotot=fSDDhRawsTask ;  
-    }
-  else if(task == AliQAv1::kDIGITSR)
-    {
-      histotot=fSDDhDigitsTask;
-    }
-  else if( task == AliQAv1::kRECPOINTS )
-    {
-      histotot=fSDDhRecPointsTask;   
-    }
-  else {
-    AliInfo("No task has been selected. TaskHisto set to zero.\n");
-  }
+  if( task == AliQAv1::kRAWS ){ histotot=fSDDhRawsTask ;}
+  else if(task == AliQAv1::kDIGITSR) { histotot=fSDDhDigitsTask;}
+  else if( task == AliQAv1::kRECPOINTS ){ histotot=fSDDhRecPointsTask;}
+  else {AliInfo("No task has been selected. TaskHisto set to zero.\n");}
   return histotot;
 }
 
-//_______________________________________________________________
 
-void AliITSQASDDDataMakerRec::AnalyseBNG()
-{
+//_______________________________________________________________
 
-// get file time for Previous test
-       AliInfo("AnalyseBNG\n");
-       static Int_t bngtimePrevious[6]; 
-       FILE *fpinPrevious = fopen( "SDDgainHistos.time", "r" );
-       if(fpinPrevious) {
-               for(Int_t i=0; i<6; i++) fscanf(fpinPrevious,"%d",&bngtimePrevious[i]);
-               fclose (fpinPrevious);
-       } else 
-               for(Int_t i=0; i<6; i++) bngtimePrevious[i] = 0;
-       Int_t bngtimeCurrent[6] = { 0 }; 
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDgainHistos1.root > SDDgainHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDgainHistos2.root >> SDDgainHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDgainHistos3.root >> SDDgainHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDgainHistos4.root >> SDDgainHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDgainHistos5.root >> SDDgainHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDgainHistos6.root >> SDDgainHistos.time");
-       FILE *fpin = fopen( "SDDgainHistos.time", "r" );
-       for(Int_t i=0; i<6; i++) {
-               fscanf(fpin,"%d",&bngtimeCurrent[i]);
-//             AliInfo(Form("bngtimeCurrent[%d] %d, bngtimePrevious[%d] %d\n",i,bngtimeCurrent[i],i,bngtimePrevious[i]));
-       }
-       Bool_t kAnalyse = kTRUE;
-       for(Int_t i=0; i<6; i++) if(bngtimeCurrent[i] <= bngtimePrevious[i]) kAnalyse = kFALSE;
-       if(kAnalyse) {
-               // new bng file found
-               for(Int_t i=0; i<6; i++) bngtimePrevious[i] = bngtimeCurrent[i];
-               Bool_t kFilesExist = kTRUE;
-               char *hname = new char[50];
-               for(Int_t i=0; i<6; i++) {
-                       sprintf(hname,"SDDgainHistos%d.root",i+1);
-                       TFile gainFile(hname);
-                       if(gainFile.IsZombie()) kFilesExist = kFALSE;
-               }
-               if(kFilesExist) {
-                       AnodeStatus();
-                       AnalyseHistos(1); // Baseline
-                       AnalyseHistos(2); // Uncorrected Noise
-                       AnalyseHistos(3); // Common Mode Noise
-                       AnalyseHistos(4); // Corrected Noise
-                       AnalyseHistos(5); // Gain
-                       gSystem->Exec("cp SDDgainHistos1.root SDDgainHistosPrevious1.root");
-                       gSystem->Exec("cp SDDgainHistos2.root SDDgainHistosPrevious2.root");
-                       gSystem->Exec("cp SDDgainHistos3.root SDDgainHistosPrevious3.root");
-                       gSystem->Exec("cp SDDgainHistos4.root SDDgainHistosPrevious4.root");
-                       gSystem->Exec("cp SDDgainHistos5.root SDDgainHistosPrevious5.root");
-                       gSystem->Exec("cp SDDgainHistos6.root SDDgainHistosPrevious6.root");
-               } else {
-                       AliInfo("file(s) SDDgainHistos .root not found \n");
-               }
-       }
-       fclose (fpin);
-//     delete fpin;
 
+void AliITSQASDDDataMakerRec::CreateTheMap()
+{
+  //Create the SDD DDL Module Map
+  AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
+  Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
+  if(!ddlMapSDD){
+      AliError("Calibration object retrieval failed! SDD will not be processed");
+      fDDLModuleMap = NULL;
+      //return rv;
+    }
+  fDDLModuleMap = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
+  if(!cacheStatus)ddlMapSDD->SetObject(NULL);
+  ddlMapSDD->SetOwner(kTRUE);
+  if(!cacheStatus){ delete ddlMapSDD;}
+  AliInfo("DDL Map Created\n ");
 }
 
 //_______________________________________________________________
 
-void AliITSQASDDDataMakerRec::AnalyseINJ()
+
+void AliITSQASDDDataMakerRec::CreateTheCalibration()
 {
-// get file time for last test
-
-       AliInfo("AnalyseINJ\n");
-       static Int_t injtimePrevious[6]; 
-       FILE *fpinPrevious = fopen( "SDDinjectHistos.time", "r" );
-       if(fpinPrevious) {
-               for(Int_t i=0; i<6; i++) fscanf(fpinPrevious,"%d",&injtimePrevious[i]);
-               fclose (fpinPrevious);
-       } else 
-               for(Int_t i=0; i<6; i++) injtimePrevious[i] = 0;
-       Int_t injtimeCurrent[6] = { 0 }; 
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDinjectHistos1.root > SDDinjectHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDinjectHistos2.root >> SDDinjectHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDinjectHistos3.root >> SDDinjectHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDinjectHistos4.root >> SDDinjectHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDinjectHistos5.root >> SDDinjectHistos.time");
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDinjectHistos6.root >> SDDinjectHistos.time");
-       FILE *fpin = fopen( "SDDinjectHistos.time", "r" );
-       for(Int_t i=0; i<6; i++) {
-               fscanf(fpin,"%d",&injtimeCurrent[i]);
-//             AliInfo(Form("injtimeCurrent[%d] %d, injtimePrevious[%d] %d\n",i,injtimeCurrent[i],i,injtimePrevious[i]));
-       }
-       Bool_t kAnalyse = kTRUE;
-       for(Int_t i=0; i<6; i++) if(injtimeCurrent[i] <= injtimePrevious[i]) kAnalyse = kFALSE;
-       if(kAnalyse) {
-               // new inj file found
-               for(Int_t i=0; i<6; i++) injtimePrevious[i] = injtimeCurrent[i];
-               Bool_t kFilesExist = kTRUE;
-               char *hname = new char[50];
-               for(Int_t i=0; i<6; i++) {
-                       sprintf(hname,"SDDinjectHistos%d.root",i+1);
-                       TFile gainFile(hname);
-                       if(gainFile.IsZombie()) kFilesExist = kFALSE;
-               }
-               if(kFilesExist) {
-                       AnalyseHistos(6); // Drift Speed
-                       gSystem->Exec("cp SDDinjectHistos1.root SDDinjectHistosPrevious1.root");
-                       gSystem->Exec("cp SDDinjectHistos2.root SDDinjectHistosPrevious2.root");
-                       gSystem->Exec("cp SDDinjectHistos3.root SDDinjectHistosPrevious3.root");
-                       gSystem->Exec("cp SDDinjectHistos4.root SDDinjectHistosPrevious4.root");
-                       gSystem->Exec("cp SDDinjectHistos5.root SDDinjectHistosPrevious5.root");
-                       gSystem->Exec("cp SDDinjectHistos6.root SDDinjectHistosPrevious6.root");
-               } else {
-                       AliInfo("file(s) SDDinjectHistos .root not found \n");
-               }
-       }
-       fclose (fpin);
-/*
-       static Int_t injtimeLast = 0; 
-       FILE *fpinlast = fopen( "SDDinjectHistos.time", "r" );
-       if(fpinlast) {
-               fscanf(fpinlast,"%d",&injtimeLast);
-               fclose (fpinlast);
-       } else 
-               injtimeLast = 0;
-       Int_t injtimeCurrent = 0; 
-       gSystem->Exec("perl -e '@d=localtime ((stat(shift))[9]); printf \"%02d%02d%02d%02d%02d\n\", $d[5]-100,$d[4]+1,$d[3],$d[2],$d[1]'  SDDinjectHistos.root > SDDinjectHistos.time");
-       FILE *fpin = fopen( "SDDinjectHistos.time", "r" );
-       fscanf(fpin,"%d",&injtimeCurrent);
-       if(injtimeCurrent > injtimeLast) {
-               // new gain file found
-               injtimeLast = injtimeCurrent;
-
-               TFile injectFile("SDDinjectHistos.root");
-               if(!injectFile.IsZombie()) {
-                       AnalyseHistos(6); // Drift Speed
-                       gSystem->Exec("cp SDDinjectHistos.root SDDinjectHistosLast.root");
-               } else {
-                       AliInfo("file SDDinjectHistos.root not found \n");
-               }
+  //Take from the OCDB the calibration information for the SDD 
+    AliCDBEntry *calibSDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
+    Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
+    if(!calibSDD)
+      {
+       AliError("Calibration object retrieval failed! SDD will not be processed");
+       fCalibration = NULL;;
+      }
+    fCalibration = (TObjArray *)calibSDD->GetObject();
+    
+    if(!cacheStatus)calibSDD->SetObject(NULL);
+    calibSDD->SetOwner(kTRUE);
+    if(!cacheStatus){delete calibSDD;}
+
+    AliITSCalibrationSDD * cal=NULL;
+    for(Int_t imod=0;imod<fgknSDDmodules;imod++)
+      {
+       //cal=NULL;
+       Int_t fillmodhisto1=fgkTotalNumberSDDAnodes;
+       Int_t fillmodhisto2side0=fgkNumberOfSDDAnodesperSide;
+       Int_t fillmodhisto2side1=fgkNumberOfSDDAnodesperSide;
+       Int_t fillmodhisto3side0=fgkNumberOfSDDAnodesperSide;
+       Int_t fillmodhisto3side1=fgkNumberOfSDDAnodesperSide;
+       
+       Int_t badmodhisto1=0;
+       Int_t badmodhisto2side0=0;
+       Int_t badmodhisto2side1=0;
+       Int_t badmodhisto3side0=0;
+       Int_t badmodhisto3side1=0;
+       //printf("imod %i\t ==== \t",imod);
+       Int_t module=imod + 240;
+       //printf("module %i\t ==== \t",module);
+       cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
+       Int_t lay,lad,det;
+       AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
+       Int_t index=1+(det-1)*2;
+       if(cal==0){continue;}
+       if (cal->IsBad()){continue;}//bad module check
+       else{
+         for(Int_t i=0;i<8;i++) //check on bad chips in good modules
+           {
+             if(lay==3){
+               if(cal->IsChipBad(i)){
+                 if(i<4){badmodhisto2side0+=64;}
+                 if(i>=4){badmodhisto2side1+=64;}
+               }//end if chip
+             }//end if  layer3
+             else if(lay==4){
+               if(cal->IsChipBad(i)){
+                 if(i<4){badmodhisto3side0+=64;}
+                 if(i>=4){badmodhisto3side1+=64;}               
+               }//end if  chip
+             }//ens if layer4
+           }//end for  chip
+         for(Int_t iAn=0; iAn<512; iAn++){//anodes loop 
+           Int_t ic=cal->GetChip(iAn);//chip with this anode number
+           if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){// good chip   good module   bad channel 
+             if(lay==3){
+                 if(ic<4) badmodhisto2side0++;
+                 else if(ic>=4)badmodhisto2side1++;
+               }//end if layer 3
+             else if(lay==4){
+                 if(ic<4) badmodhisto3side0++;
+                 else if(ic>=4)badmodhisto3side1++;
+               }//end if layer 4
+           }//end if chip module channel
+         }//end for anodes
+         if(lay==3){
+           badmodhisto1=badmodhisto2side0+badmodhisto2side1;
+           fillmodhisto1-=badmodhisto1;
+           fillmodhisto2side0-=badmodhisto2side0;
+           fillmodhisto2side1-=badmodhisto2side1;
+           ((TH1D*)(fHistoCalibration->At(0)))->SetBinContent(imod+1,fillmodhisto1);
+           ((TH2D*)(fHistoCalibration->At(1)))->SetBinContent(index,lad,fillmodhisto2side0);
+           ((TH2D*)(fHistoCalibration->At(1)))->SetBinContent(index+1,lad,fillmodhisto2side1);
+         }//end layer 3
+         else if(lay==4){
+           badmodhisto1=badmodhisto3side0+badmodhisto3side1;
+           fillmodhisto1-=badmodhisto1;
+           fillmodhisto3side0-=badmodhisto3side0;
+           fillmodhisto3side1-=badmodhisto3side1;
+           ((TH1D*)(fHistoCalibration->At(0)))->SetBinContent(imod+1,fillmodhisto1);
+           ((TH2D*)(fHistoCalibration->At(2)))->SetBinContent(index,lad,fillmodhisto3side0);
+           ((TH2D*)(fHistoCalibration->At(2)))->SetBinContent(index+1,lad,fillmodhisto2side1);
+         }//end layer 4
+       }//end else bad module
+      }//end module for
 
-       }
-       fclose (fpin);
-*/
-//     delete fpin;
 }
 
-//_______________________________________________________________
+//____________________________________________________________________
 
-void AliITSQASDDDataMakerRec::AnodeStatus()
+void AliITSQASDDDataMakerRec::InitCalibrationArray()
 {
-       char *hnamePrevious = new char[50];
-       char *fnamePrevious = new char[50];
-    fGoodAnodes = 0;
-
-       for(Int_t k=0;k<6;k++) {
-               sprintf(fnamePrevious,"SDDgainHistosPrevious%d.root",k+1);
-               TFile gainFilePrevious(fnamePrevious);
-               if(gainFilePrevious.IsZombie()) continue;
-               for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
-                       for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
-                               for(Int_t iside=0;iside<fgknSide;iside++){
-                                       Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
-                       //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
-                                       sprintf(hnamePrevious,"hgood%02dc%02ds%d",ddl,crx,iside);
-                               //AliInfo(Form("get histo %s\n",hnamePrevious));
-                                       TH1F *hgood = (TH1F *) gainFilePrevious.Get(hnamePrevious);
-                                       if(!hgood) continue;
-                                       for(Int_t i=0; i<hgood->GetNbinsX();i++) {
-                                               fAnodeMap[moduleSDD-fgkmodoffset][iside][i] = hgood->GetBinContent(i);
-                                               if(fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) fGoodAnodes++;
-                                       }
-                                       delete hgood;
-                               }
-                       }
-               }
-               gainFilePrevious.Close();
-       }
+  //create the histograms with the calibration informations. The histograms are stored in a TObjArray
+    TH1D *pattern1  = new TH1D("CALSDDModPattern","Calibration HW Modules pattern",fgknSDDmodules,239.5,499.5);
+    TH2D *patternl3 = new TH2D("CALSDDphizL3","Calibration SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);
+    TH2D *patternl4 = new TH2D("CALSDDphizL4"," Calibration SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5);
 
-       fGoodAnodesCurrent = 0;
-       fBadAnodesCurrent = 0;
-       char *hname = new char[50];
-       Int_t nChangedStatus = 0;
-       Bool_t CurrentAnodeMap[fgknSDDmodules][fgknSide][fgknAnode];    
-       for(Int_t k=0;k<6;k++) {
-               sprintf(fnamePrevious,"SDDgainHistos%d.root",k+1);
-               TFile gainFile(fnamePrevious);
-               if(gainFile.IsZombie()) continue;
-               for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
-                       for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
-                               for(Int_t iside=0;iside<fgknSide;iside++){
-                                       Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
-                               //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
-                                       sprintf(hname,"hgood%02dc%02ds%d",ddl,crx,iside);
-                               //AliInfo(Form("get histo %s\n",hname));
-                                       TH1F *hgood = (TH1F *) gainFile.Get(hname);
-                                       if(!hgood) continue;
-                                       for(Int_t i=0; i<hgood->GetNbinsX();i++) {
-                                               CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i] = hgood->GetBinContent(i);
-                                               if(CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i]) fGoodAnodesCurrent++;
-                                               else fBadAnodesCurrent++;
-                                               if(CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i] != fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) {
-                                                       fAnodeMap[moduleSDD-fgkmodoffset][iside][i] = CurrentAnodeMap[moduleSDD-fgkmodoffset][iside][i];
-                                                       nChangedStatus++;
-                                                       AliWarning(Form("DDL %d, CRX %d, Side %d, Anode %d changed status to %d \n",ddl,crx,iside,i,fAnodeMap[moduleSDD-fgkmodoffset][iside][i]));
-                                               }
-                                       }
-                                       delete hgood;
-                               }
-                       }
-               }
-               gainFile.Close();
-       }
-       
-       AliWarning(Form("Number of good anodes changed from %d to %d, that is %f %%\n",fGoodAnodes,fGoodAnodesCurrent,((Float_t) TMath::Abs(fGoodAnodes-fGoodAnodesCurrent))/(fBadAnodesCurrent+fGoodAnodesCurrent)));
-       if(fGoodAnodesCurrent != fGoodAnodes) {
-               fGoodAnodes = fGoodAnodesCurrent;
-       }
-       AliWarning(Form("Number of bad anodes changed from %d to %d, that is %f %%\n",fBadAnodes,fBadAnodesCurrent,((Float_t) TMath::Abs(fBadAnodes-fBadAnodesCurrent))/(fBadAnodesCurrent+fGoodAnodesCurrent)));
-       if(fBadAnodesCurrent != fBadAnodes) {
-               fBadAnodes = fBadAnodesCurrent;
-       }
-//     delete hname;
+    fHistoCalibration = new TObjArray(3); 
+    fHistoCalibration->AddAtAndExpand(pattern1,0);
+    fHistoCalibration->AddAtAndExpand(patternl3,1);
+    fHistoCalibration->AddAtAndExpand(patternl4,2);
+
+    //    printf("Calibration Histograms created!\n");
 }
 
-//_______________________________________________________________
+//____________________________________________________________________
 
-void AliITSQASDDDataMakerRec::AnalyseHistos(Int_t type)
+void AliITSQASDDDataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
 {
+  //reset the SDD calibration histograms
+  AliInfo(Form("Reset detector in SDD called for task index %i", task));
+  if(task== AliQAv1::kRAWS ){
+  fDDLModuleMap=NULL;
+  }
+  fCalibration=NULL;
 
-       if(type < 1 || type > 6) AliWarning(Form("Wrong type (%d), must be between 1 and 6\n",type));
-       
-       Double_t Current[fgknSDDmodules][fgknSide][fgknAnode];  
-       char *hnamePrevious = new char[50];
-       char *fnamePrevious = new char[50];
-
-       for(Int_t k=0; k<6; k++) {
-               if(type < 6) sprintf(fnamePrevious,"SDDgainHistosPrevious%d.root",k+1);
-               else sprintf(fnamePrevious,"SDDinjectHistosPrevious%d.root",k+1);
-               TFile *gainFilePrevious = new TFile(fnamePrevious);
-               if(gainFilePrevious->IsZombie()) continue;
-
-               for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
-                       for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
-                               for(Int_t iside=0;iside<fgknSide;iside++){
-                                       Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
-                       //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
-                                       if(type == 1) sprintf(hnamePrevious,"hbase%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 2) sprintf(hnamePrevious,"hnois%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 3) sprintf(hnamePrevious,"hcmn%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 4) sprintf(hnamePrevious,"hcorn%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 5) sprintf(hnamePrevious,"hgain%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 6) sprintf(hnamePrevious,"hdrsp%02dc%02ds%d",ddl,crx,iside);
-                               //AliInfo(Form("get histo %s\n",hnamePrevious));
-                                       TH1F *hhist = (TH1F *) gainFilePrevious->Get(hnamePrevious);
-                                       if(!hhist) continue;
-                                       for(Int_t i=0; i<hhist->GetNbinsX();i++) {
-                                               Current[moduleSDD-fgkmodoffset][iside][i] = hhist->GetBinContent(i);
-                                       }
-                                       delete hhist;
-                               }
-                       }
-               }
-               gainFilePrevious->Close();
-               delete gainFilePrevious;
-       }
-
-       Float_t xmin = 0.;
-       Float_t xmax = 0;
-       Int_t nbins = 1;
-       TH1F *hDist = 0;
-       TH1F *hDistDiff = 0;
-       if(type == 1) {
-               xmin = 0.;
-               xmax = 500.;
-               nbins = (Int_t)(xmax-xmin);
-               hDist = new TH1F("hBaseline","Baseline",nbins,xmin,xmax);
-               hDistDiff = new TH1F("hBaselineDiff","Baseline Difference",200,-100.,100.);
-       } else if(type == 2) {
-               xmin = 0.;
-               xmax = 10.;
-               nbins = (Int_t) (100.*(xmax-xmin));
-               hDist = new TH1F("hNoiseUnc","Noise (before correction)",nbins,xmin,xmax);
-               hDistDiff = new TH1F("hNoiseUncDiff","Noise (before correction) Difference",200,-10.,10.);
-       } else if(type == 3) {
-               xmin = 0.;
-               xmax = 10.;
-               nbins = (Int_t)( 100.*(xmax-xmin));
-               hDist = new TH1F("hNoiseCMN","Noise (common mode)",nbins,xmin,xmax);
-               hDistDiff = new TH1F("hNoiseCMNDiff","Noise (common mode) Difference",200,-10.,10.);
-       } else if(type == 4) {
-               xmin = 0.;
-               xmax = 10.;
-               nbins = (Int_t)(100.*(xmax-xmin));
-               hDist = new TH1F("hNoiseCor","Noise (after correction)",nbins,xmin,xmax);
-               hDistDiff = new TH1F("hNoiseCorDiff","Noise (after correction) Difference",200,-10.,10.);
-       } else if(type == 5) {
-               xmin = 0.;
-               xmax = 5.;
-               nbins = (Int_t)(100.*(xmax-xmin));
-               hDist = new TH1F("hGain","Gain",nbins,xmin,xmax);
-               hDistDiff = new TH1F("hGainDiff","Gain Difference",200,-10.,10.);
-       } else if(type == 6) {
-               xmin = 0.;
-               xmax = 10.;
-               nbins = (Int_t)(100.*(xmax-xmin));
-               hDist = new TH1F("hDriftSpeed","Drift Speed",nbins,xmin,xmax);
-               hDistDiff = new TH1F("hDriftSpeedDiff","Drift Speed Difference",200,-10.,10.);
-       }
-
-       Float_t binw = (xmax-xmin)/nbins;
-
-       for(Int_t k=0; k<6; k++) {
-               if(type < 6) sprintf(fnamePrevious,"SDDgainHistos%d.root",k+1);
-               else sprintf(fnamePrevious,"SDDinjectHistos%d.root",k+1);
-               TFile *gainFile = new TFile(fnamePrevious);
-               if(gainFile->IsZombie()) continue;
-
-               for(Int_t ddl =0; ddl<fDDLModuleMap->GetNDDLs(); ddl++){
-                       for(Int_t crx =0; crx<fDDLModuleMap->GetNModPerDDL(); crx++){
-                               for(Int_t iside=0;iside<fgknSide;iside++){
-                                       Int_t moduleSDD = fDDLModuleMap->GetModuleNumber(ddl,crx);
-                       //AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
-                                       if(type == 1) sprintf(hnamePrevious,"hbase%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 2) sprintf(hnamePrevious,"hnois%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 3) sprintf(hnamePrevious,"hcmn%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 4) sprintf(hnamePrevious,"hcorn%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 5) sprintf(hnamePrevious,"hgain%02dc%02ds%d",ddl,crx,iside);
-                                       else if(type == 6) sprintf(hnamePrevious,"hdrsp%02dc%02ds%d",ddl,crx,iside);
-                               //AliInfo(Form("get histo %s\n",hname));
-                                       TH1F *hhist = (TH1F *) gainFile->Get(hnamePrevious);
-                                       if(!hhist) continue;
-                                       for(Int_t i=0; i<hhist->GetNbinsX();i++) {
-                                               if(!fAnodeMap[moduleSDD-fgkmodoffset][iside][i]) continue;
-                                               hDist->Fill(hhist->GetBinContent(i));
-                                               hDistDiff->Fill(hhist->GetBinContent(i)-Current[moduleSDD-fgkmodoffset][iside][i]);
-                                       }
-                                       delete hhist;
-                               }
-                       }
-               }
-               gainFile->Close();
-               delete gainFile;
-
-       }
-       
-       TF1 ff("ff", "gaus", xmin+0.1, xmax-0.1);
-       hDist->Fit("ff","NWR");
-//     hDist->Fit("gaus","","",xmin+0.1, xmax-0.1);
-//     Float_t ChiSquared = (Float_t) ff.GetChisquare();
-//     Int_t NDF = ff.GetNumberFitPoints() - ff.GetNpar();
-       Float_t average = (Float_t) ff.GetParameter(1);
-       Float_t sigma = (Float_t) ff.GetParameter(2);
-//     Float_t mean = hDist->GetMean();
-//     Float_t rms = hDist->GetRMS();
-       Int_t badB = 0;
-       for(Int_t i=0; i<hDist->GetNbinsX();i++) {
-//             if(type < 6) 
-         if(TMath::Abs(i*binw-average) > 4.*sigma) badB += (Int_t)hDist->GetBinContent(i);
-//             else
-//                     if(TMath::Abs(i-mean) > 4*rms) badB += hDist->GetBinContent(i);
-       }
-       if(type == 1) {
-               AliInfo(Form("Number of anodes with baseline out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
-       } else if(type == 2) {
-               AliInfo(Form("Number of anodes with uncorrected noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
-       } else if(type == 3) {
-               AliInfo(Form("Number of anodes with common mode noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
-       } else if(type == 4) {
-               AliInfo(Form("Number of anodes with corrected noise out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
-       } else if(type == 5) {
-               AliInfo(Form("Number of anodes with gain out of 4*sigma from average: %d, %f%%\n",badB,100.*((Float_t) badB)/hDist->GetEntries()));
-       } else if(type == 6) {
-               Int_t badspeed = (Int_t)hDist->GetBinContent(1);
-               AliInfo(Form("Number of anodes with drift speed equal to 0: %d\n",badspeed));
-               AliInfo(Form("Number of anodes with drift speed out of 4*sigma from average: %d, %f%%\n",badB-badspeed,100.*((Float_t) (badB-badspeed))/(hDist->GetEntries()-badspeed)));
-       }
-       
-       TH1F *hDistHistoryCurrent = NULL;
-       TH1F *hDistHistoryPrevious = NULL;
-
-       TFile *gainHistoryFile;
-       if(type < 6) 
-               gainHistoryFile = new TFile("SDDgainHistory.root","UPDATE");
-       else
-               gainHistoryFile = new TFile("SDDinjectHistory.root","UPDATE");
-       hDist->Write();
-       hDistDiff->Write();
-       //AliInfo("SDDgainHistory.root file opened\n");
-       if(!gainHistoryFile->IsZombie()) {
-               if(type == 1) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hBaselineHistory");
-               else if(type == 2) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseUncHistory");
-               else if(type == 3) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseCMNHistory");
-               else if(type == 4) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hNoiseCorHistory");
-               else if(type == 5) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hGainHistory");
-               else if(type == 6) hDistHistoryPrevious = (TH1F *) gainHistoryFile->Get("hDriftSpeedHistory");
-               //AliInfo(Form("hDistHistoryPrevious %x\n",hDistHistoryPrevious));
-       
-               if(!hDistHistoryPrevious) {
-                       if(type == 1) hDistHistoryCurrent = new TH1F("hBaselineHistory","Average Baseline History",1,0,1);
-                       else if(type == 2) hDistHistoryCurrent = new TH1F("hNoiseUncHistory","Average Uncorrected Noise History",1,0,1);
-                       else if(type == 3) hDistHistoryCurrent = new TH1F("hNoiseCMNHistory","Average Common Mode Noise History",1,0,1);
-                       else if(type == 4) hDistHistoryCurrent = new TH1F("hNoiseCorHistory","Average Corrected Noise History",1,0,1);
-                       else if(type == 5) hDistHistoryCurrent = new TH1F("hGainHistory","Average Gain History",1,0,1);
-                       else if(type == 6) hDistHistoryCurrent = new TH1F("hDriftSpeedHistory","Average Drift Speed History",1,0,1);
-                       //AliInfo(Form("hDistHistoryCurrent 1 %x\n",hDistHistoryCurrent));
-//                     if(type < 6) {
-                               hDistHistoryCurrent->SetBinContent(1,average);
-                               hDistHistoryCurrent->SetBinError(1,sigma);
-/*
-                       } else {
-                               hDistHistoryCurrent->SetBinContent(1,mean);
-                               hDistHistoryCurrent->SetBinError(1,rms);
-                       }
-*/
-               } else {
-                       if(type == 1) hDistHistoryCurrent = new TH1F("hBaselineHistory","Average Baseline History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
-                       else if(type == 2) hDistHistoryCurrent = new TH1F("hNoiseUncHistory","Average Uncorrected Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
-                       else if(type == 3) hDistHistoryCurrent = new TH1F("hNoiseCMNHistory","Average Common Mode Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
-                       else if(type == 4) hDistHistoryCurrent = new TH1F("hNoiseCorHistory","Average Corrected Noise History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
-                       else if(type == 5) hDistHistoryCurrent = new TH1F("hGainHistory","Average Gain History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
-                       else if(type == 6) hDistHistoryCurrent = new TH1F("hDriftSpeedHistory","Average Drift Speed History",hDistHistoryPrevious->GetNbinsX()+1,0,hDistHistoryPrevious->GetNbinsX()+1);
-                       //AliInfo(Form("hBaselineHistory 2 %x\n",hDistHistory));
-                       for(Int_t i=0;i<hDistHistoryPrevious->GetNbinsX();i++) {
-                               hDistHistoryCurrent->SetBinContent(i,hDistHistoryPrevious->GetBinContent(i));
-                               hDistHistoryCurrent->SetBinError(i,hDistHistoryPrevious->GetBinError(i));
-                       }
-                       hDistHistoryCurrent->SetBinContent(hDistHistoryPrevious->GetNbinsX(),average);
-                       hDistHistoryCurrent->SetBinError(hDistHistoryPrevious->GetNbinsX(),sigma);
-               }
-       }
-       hDistHistoryCurrent->Write();
-       gainHistoryFile->Close();
-       delete gainHistoryFile;
-//     delete hname;
-       delete hDist;
-       delete hDistDiff;
-}//_______________________________________________________________
+  ((TH1D*)(fHistoCalibration->At(0)))->Reset();
+  ((TH2D*)(fHistoCalibration->At(1)))->Reset();
+  ((TH2D*)(fHistoCalibration->At(2)))->Reset();
+  
+}