store also difference in local Y
[u/mrichter/AliRoot.git] / ITS / AliITSQASPDDataMakerSim.cxx
index f14f771..2dbe1d4 100644 (file)
@@ -33,7 +33,7 @@
 #include "AliRun.h"
 #include "AliITSQADataMakerSim.h"
 #include "AliITSQASPDDataMakerSim.h"
-#include "AliQA.h"
+#include "AliQAv1.h"
 #include "AliQAChecker.h"
 #include "AliITSdigit.h"   
 #include "AliITSdigitSPD.h"
@@ -49,23 +49,40 @@ ClassImp(AliITSQASPDDataMakerSim)
 AliITSQASPDDataMakerSim::AliITSQASPDDataMakerSim(AliITSQADataMakerSim *aliITSQADataMakerSim) :
 TObject(),
 fAliITSQADataMakerSim(aliITSQADataMakerSim),
-fSPDhTask(0),
-fGenOffset(0)
+fSPDhHTask(0),
+fSPDhSTask(0),
+fSPDhDTask(0),
+fGenOffsetH(0),
+fGenOffsetS(0),
+fGenOffsetD(0)
 {
   //ctor used to discriminate OnLine-Offline analysis   
+  fGenOffsetH=  new Int_t[AliRecoParam::kNSpecies];                       
+  fGenOffsetS=  new Int_t[AliRecoParam::kNSpecies];                           
+  fGenOffsetD=  new Int_t[AliRecoParam::kNSpecies];
+  for(Int_t i=0; i<AliRecoParam::kNSpecies; i++) {
+    fGenOffsetH[i]= 0;
+    fGenOffsetS[i]= 0;
+    fGenOffsetD[i]= 0;
+  }             
 }
 
 //____________________________________________________________________________ 
 AliITSQASPDDataMakerSim::AliITSQASPDDataMakerSim(const AliITSQASPDDataMakerSim& qadm) :
 TObject(),
 fAliITSQADataMakerSim(qadm.fAliITSQADataMakerSim),
-fSPDhTask(qadm.fSPDhTask),
-fGenOffset(qadm.fGenOffset)
+fSPDhHTask(qadm.fSPDhHTask),
+fSPDhSTask(qadm.fSPDhSTask),
+fSPDhDTask(qadm.fSPDhDTask),
+fGenOffsetH(qadm.fGenOffsetH),
+fGenOffsetS(qadm.fGenOffsetS),
+fGenOffsetD(qadm.fGenOffsetD)
 {
   //copy ctor 
   fAliITSQADataMakerSim->SetName((const char*)qadm.fAliITSQADataMakerSim->GetName()) ; 
   fAliITSQADataMakerSim->SetTitle((const char*)qadm.fAliITSQADataMakerSim->GetTitle());
-  }
+
+}
 
 //__________________________________________________________________
 AliITSQASPDDataMakerSim& AliITSQASPDDataMakerSim::operator = (const AliITSQASPDDataMakerSim& qac )
@@ -80,82 +97,90 @@ AliITSQASPDDataMakerSim& AliITSQASPDDataMakerSim::operator = (const AliITSQASPDD
 void AliITSQASPDDataMakerSim::StartOfDetectorCycle()
 {
   //Detector specific actions at start of cycle
-  AliDebug(1,"AliITSQADM::Start of SPD Cycle\n");
+  AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SPD Cycle\n");
 }
 
 //____________________________________________________________________________ 
-void AliITSQASPDDataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX_t /*task*/, TObjArray* /*list*/)
+void AliITSQASPDDataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray** /*list*/)
 {
   // launch the QA checking
-  AliDebug(1,"AliITSDM instantiates checker with Run(AliQA::kITS, task, list)\n"); 
+  AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
   
-  //AliQAChecker::Instance()->Run( AliQA::kITS , task, list);
+  //AliQAChecker::Instance()->Run( AliQAv1::kITS , task, list);
 }
 
 //____________________________________________________________________________ 
-void AliITSQASPDDataMakerSim::InitDigits()
+Int_t AliITSQASPDDataMakerSim::InitDigits()
 { 
   // Initialization for DIGIT data - SPD -
-  fGenOffset = (fAliITSQADataMakerSim->fDigitsQAList)->GetEntries();
-  //fSPDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ;
+  Int_t rv = 0 ; 
+  //fGenOffsetD = (fAliITSQADataMakerSim->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
+  //fSPDhDTask must be incremented by one unit every time a histogram is ADDED to the QA List
 
-  Char_t name[50];
-  Char_t title[50];
+  Char_t name[51];
+  Char_t title[51];
 
-  TH1F *hlayer = new TH1F("LayPattern_SPD","Layer map - SPD",6,0.,6.);
+  TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
   hlayer->GetXaxis()->SetTitle("Layer number");
   hlayer->GetYaxis()->SetTitle("Entries");
-  fAliITSQADataMakerSim->Add2DigitsList(hlayer,fGenOffset);
-  fSPDhTask++;
+  rv = fAliITSQADataMakerSim->Add2DigitsList(hlayer,fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], expert, !image);
+  fSPDhDTask++;
   
   TH1F **hmod = new TH1F*[2];
   for (Int_t iLay=0; iLay<2; iLay++) {
-    sprintf(name,"ModPattern_SPD%d",iLay+1);
-    sprintf(title,"Module map - SPD Layer %d",iLay+1);
+    snprintf(name,50,"SPDModPattern_SPD%d",iLay+1);
+    snprintf(title,50,"Module map - SPD Layer %d",iLay+1);
     hmod[iLay]=new TH1F(name,title,240,0,240);
     hmod[iLay]->GetXaxis()->SetTitle("Module number");
     hmod[iLay]->GetYaxis()->SetTitle("Entries");
-    fAliITSQADataMakerSim->Add2DigitsList(hmod[iLay],1+iLay+fGenOffset);
-    fSPDhTask++;
+    rv = fAliITSQADataMakerSim->Add2DigitsList(hmod[iLay],1+iLay+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
+    fSPDhDTask++;
   }
   
-  TH1F *hcolumns = new TH1F("Columns_SPD","Columns - SPD",160,0.,160.);
+  TH1F *hcolumns = new TH1F("SPDColumns_SPD","Columns - SPD",160,0.,160.);
   hcolumns->GetXaxis()->SetTitle("Column number");
   hcolumns->GetYaxis()->SetTitle("Entries");
-  fAliITSQADataMakerSim->Add2DigitsList(hcolumns,3+fGenOffset);
-  fSPDhTask++;
+  fAliITSQADataMakerSim->Add2DigitsList(hcolumns,3+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], expert, !image);
+  fSPDhDTask++;
 
-  TH1F *hrows = new TH1F("Rows_SPD","Rows - SPD",256,0.,256.);
+  TH1F *hrows = new TH1F("SPDRows_SPD","Rows - SPD",256,0.,256.);
   hrows->GetXaxis()->SetTitle("Row number");
   hrows->GetYaxis()->SetTitle("Entries");
-  fAliITSQADataMakerSim->Add2DigitsList(hrows,4+fGenOffset);
-  fSPDhTask++;
+  rv = fAliITSQADataMakerSim->Add2DigitsList(hrows,4+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], expert, !image);
+  fSPDhDTask++;
 
   TH1F** hMultSPDdigits = new TH1F*[2];
   for (Int_t iLay=0; iLay<2; ++iLay) {
-    sprintf(name,"DigitMultiplicity_SPD%d",iLay+1);
-    sprintf(title,"Digit multiplicity - SPD Layer %d",iLay+1);
+    snprintf(name,50,"SPDDigitMultiplicity_SPD%d",iLay+1);
+    snprintf(title,50,"Digit multiplicity - SPD Layer %d",iLay+1);
     hMultSPDdigits[iLay]=new TH1F(name,title,200,0.,200.);
     hMultSPDdigits[iLay]->GetXaxis()->SetTitle("Digit multiplicity");
     hMultSPDdigits[iLay]->GetYaxis()->SetTitle("Entries");
-    fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenOffset);
-    fSPDhTask++;
+    rv = fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
+    fSPDhDTask++;
   }
 
-  TH2F *hMultSPDdig2MultSPDdig1 = new TH2F("DigitMultCorrelation_SPD","Digit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
+  TH2F *hMultSPDdig2MultSPDdig1 
+       = new TH2F("SPDDigitMultCorrelation_SPD","Digit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
   hMultSPDdig2MultSPDdig1->GetXaxis()->SetTitle("Digit multiplicity (Layer 1)");
   hMultSPDdig2MultSPDdig1->GetYaxis()->SetTitle("Digit multiplicity (Layer 2)");
-  fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdig2MultSPDdig1,7+fGenOffset);
-  fSPDhTask++;
-
-  AliDebug(1,Form("%d SPD Digits histograms booked\n",fSPDhTask));
+  rv = fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdig2MultSPDdig1,7+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
+  fSPDhDTask++;
 
+  AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Digits histograms booked\n",fSPDhDTask));
+  delete [] hmod;
+  delete [] hMultSPDdigits;
+  return rv ; 
 }
 
 //____________________________________________________________________________
-void AliITSQASPDDataMakerSim::MakeDigits(TTree *digits)
+Int_t AliITSQASPDDataMakerSim::MakeDigits(TTree *digits)
 { 
   // Fill QA for DIGIT - SPD -
+  Int_t rv = 0 ; 
   AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
   fITS->SetTreeAddress();
   TClonesArray *iITSdigits  = fITS->DigitsAddress(0);  // 0->SPD
@@ -167,131 +192,148 @@ void AliITSQASPDDataMakerSim::MakeDigits(TTree *digits)
     digits->GetEvent(imod);
     Int_t ndigits = iITSdigits->GetEntries();
     if (imod<80) {
-      fAliITSQADataMakerSim->GetDigitsData(0+fGenOffset)->Fill(0.5,ndigits);
-      fAliITSQADataMakerSim->GetDigitsData(1+fGenOffset)->Fill(imod,ndigits);
+      fAliITSQADataMakerSim->FillDigitsData(0+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],0.5,ndigits);
+      fAliITSQADataMakerSim->FillDigitsData(1+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],imod,ndigits);
       nDigitsL1+=ndigits;
     }
     else {
-      fAliITSQADataMakerSim->GetDigitsData(0+fGenOffset)->Fill(1,ndigits);
-      fAliITSQADataMakerSim->GetDigitsData(2+fGenOffset)->Fill(imod,ndigits);
+      fAliITSQADataMakerSim->FillDigitsData(0+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],1,ndigits);
+      fAliITSQADataMakerSim->FillDigitsData(2+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],imod,ndigits);
       nDigitsL2+=ndigits;
     }
     for (Int_t idig=0; idig<ndigits; ++idig) {
       AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
       Int_t col=dig->GetCoord1();  // cell number z
       Int_t row=dig->GetCoord2();  // cell number x
-      fAliITSQADataMakerSim->GetDigitsData(3+fGenOffset)->Fill(col);
-      fAliITSQADataMakerSim->GetDigitsData(4+fGenOffset)->Fill(row);
+      fAliITSQADataMakerSim->FillDigitsData(3+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],col);
+      fAliITSQADataMakerSim->FillDigitsData(4+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],row);
     }
   }
-  fAliITSQADataMakerSim->GetDigitsData(5+fGenOffset)->Fill(nDigitsL1);
-  fAliITSQADataMakerSim->GetDigitsData(6+fGenOffset)->Fill(nDigitsL2);
-  fAliITSQADataMakerSim->GetDigitsData(7+fGenOffset)->Fill(nDigitsL1,nDigitsL2);
+  fAliITSQADataMakerSim->FillDigitsData(5+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],nDigitsL1);
+  fAliITSQADataMakerSim->FillDigitsData(6+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],nDigitsL2);
+  fAliITSQADataMakerSim->FillDigitsData(7+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],nDigitsL1,nDigitsL2);
+  //
+  return rv ; 
 }
 
 //____________________________________________________________________________ 
-void AliITSQASPDDataMakerSim::InitSDigits()
+Int_t AliITSQASPDDataMakerSim::InitSDigits()
 { 
   // Initialization for SDIGIT data - SPD -
-  fGenOffset = (fAliITSQADataMakerSim->fSDigitsQAList)->GetEntries();
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ;
+  Int_t rv = 0 ; 
+  //fGenOffsetS = (fAliITSQADataMakerSim->fSDigitsQAList[AliRecoParam::kDefault])->GetEntries();
   //printf("--W-- AliITSQASPDDataMakerSim::InitSDigits()  fGenOffset= %d \n",fGenOffset);
-  //fSPDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
+  //fSPDhSTask must be incremented by one unit every time a histogram is ADDED to the QA List
   
-  Char_t name[50];
-  Char_t title[50];
+  Char_t name[51];
+  Char_t title[51];
 
-  TH1F *hlayer = new TH1F("LayPattern_SPD","Layer map - SPD",6,0.,6.);
+  TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
   hlayer->GetXaxis()->SetTitle("Layer number");
   hlayer->GetYaxis()->SetTitle("Entries");
-  fAliITSQADataMakerSim->Add2SDigitsList(hlayer,fGenOffset);
-  fSPDhTask++;
+  rv = fAliITSQADataMakerSim->Add2SDigitsList(hlayer,fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()], expert, !image);
+  fSPDhSTask++;
 
   TH1F **hmod = new TH1F*[2];
   for (Int_t iLay=0; iLay<2; ++iLay) {
-    sprintf(name,"ModPattern_SPD%d",iLay+1);
-    sprintf(title,"Module map - SPD Layer %d",iLay+1);
+    snprintf(name,50,"SPDModPattern_SPD%d",iLay+1);
+    snprintf(title,50,"Module map - SPD Layer %d",iLay+1);
     hmod[iLay]=new TH1F(name,title,240,0,240);
     hmod[iLay]->GetXaxis()->SetTitle("Module number");
     hmod[iLay]->GetYaxis()->SetTitle("Entries");
-    fAliITSQADataMakerSim->Add2SDigitsList(hmod[iLay],1+iLay+fGenOffset);
-    fSPDhTask++;
+    rv = fAliITSQADataMakerSim->Add2SDigitsList(hmod[iLay],1+iLay+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
+    fSPDhSTask++;
   }
-  
-
-  AliDebug(1,Form("%d SPD SDigits histograms booked\n",fSPDhTask));
 
+  AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD SDigits histograms booked\n",fSPDhSTask));
+  delete [] hmod;
+  return rv ; 
 }
 
 //____________________________________________________________________________
-void AliITSQASPDDataMakerSim::MakeSDigits(TTree *sdigits)
+Int_t AliITSQASPDDataMakerSim::MakeSDigits(TTree *sdigits)
 { 
   // Fill QA for SDIGIT - SPD -
+  Int_t rv = 0 ; 
+  static TClonesArray * sdig ; 
+  if (! sdig )
+    sdig = new TClonesArray( "AliITSpListItem",1000 );
+  
   TBranch *brchSDigits = sdigits->GetBranch("ITS");
   for (Int_t imod=0; imod<240; ++imod){
-    TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 );
     brchSDigits->SetAddress( &sdig );
     brchSDigits->GetEvent(imod);
     Int_t nsdig=sdig->GetEntries();
     if (imod<80) {
-      fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffset)->Fill(0.5,nsdig);
-      fAliITSQADataMakerSim->GetSDigitsData(1+fGenOffset)->Fill(imod,nsdig);
+      fAliITSQADataMakerSim->FillSDigitsData(0+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],0.5,nsdig);
+      fAliITSQADataMakerSim->FillSDigitsData(1+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],imod,nsdig);
     }
     else {
-      fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffset)->Fill(1,nsdig);
-      fAliITSQADataMakerSim->GetSDigitsData(2+fGenOffset)->Fill(imod,nsdig);
+      fAliITSQADataMakerSim->FillSDigitsData(0+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],1,nsdig);
+      fAliITSQADataMakerSim->FillSDigitsData(2+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],imod,nsdig);
     }
-    delete sdig;
+    sdig->Clear() ;
   }
-
+  //
+  return rv ; 
 }
 
 //____________________________________________________________________________ 
-void AliITSQASPDDataMakerSim::InitHits()
+Int_t AliITSQASPDDataMakerSim::InitHits()
 { 
   // Initialization for HITS data - SPD -
-  fGenOffset = (fAliITSQADataMakerSim->fHitsQAList)->GetEntries();
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ;
+  Int_t rv = 0 ; 
+  
+  //fGenOffsetH = (fAliITSQADataMakerSim->fHitsQAList[AliRecoParam::kDefault])->GetEntries();
   //printf("--W-- AliITSQASPDDataMakerSim::InitHits()  fGenOffset= %d \n",fGenOffset);
-  //fSPDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
+  //fSPDhHTask must be incremented by one unit every time a histogram is ADDED to the QA List
   Char_t name[50];
   Char_t title[50];
 
-  TH1F *hlayer = new TH1F("LayPattern_SPD","Layer map - SPD",6,0.,6.);
+  TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
   hlayer->GetXaxis()->SetTitle("Layer number");
   hlayer->GetYaxis()->SetTitle("Entries");
-  fAliITSQADataMakerSim->Add2HitsList(hlayer,fGenOffset);
-  fSPDhTask++;
+  rv = fAliITSQADataMakerSim->Add2HitsList(hlayer,fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], expert, !image);
+  fSPDhHTask++;
 
   TH1F **hmod = new TH1F*[2];
   for (Int_t iLay=0; iLay<2; ++iLay) {
-    sprintf(name,"ModPattern_SPD%d",iLay+1);
-    sprintf(title,"Module map - SPD Layer %d",iLay+1);
+    snprintf(name,49,"SPDModPattern_SPD%d",iLay+1);
+    snprintf(title,49,"Module map - SPD Layer %d",iLay+1);
     hmod[iLay]=new TH1F(name,title,240,0,240);
     hmod[iLay]->GetXaxis()->SetTitle("Module number");
     hmod[iLay]->GetYaxis()->SetTitle("Entries");
-    fAliITSQADataMakerSim->Add2HitsList(hmod[iLay],1+iLay+fGenOffset);
-    fSPDhTask++;
+    rv = fAliITSQADataMakerSim->Add2HitsList(hmod[iLay],1+iLay+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
+    fSPDhHTask++;
   }
 
-  TH1F *hhitlenght = new TH1F("Lenght_SPD","Hit lenght along y_{loc} coord",210,0.,210.);
+  TH1F *hhitlenght = new TH1F("SPDLenght_SPD","SPD Hit lenght along y_{loc} coord",210,0.,210.);
   hhitlenght->GetXaxis()->SetTitle("Hit lenght [#mum]");
   hhitlenght->GetYaxis()->SetTitle("# hits");
-  fAliITSQADataMakerSim->Add2HitsList(hhitlenght,3+fGenOffset);
-  fSPDhTask++;
+  rv = fAliITSQADataMakerSim->Add2HitsList(hhitlenght,3+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
+  fSPDhHTask++;
 
-  TH1F *hEdepos = new TH1F("EnergyDeposit_SPD","Deposited energy distribution (y_{loc}>180 #mum)",150,0.,300.); 
+  TH1F *hEdepos = new TH1F("SPDEnergyDeposit_SPD","SPD Deposited energy distribution (y_{loc}>180 #mum)",150,0.,300.); 
   hEdepos->GetXaxis()->SetTitle("Deposited energy [keV]"); 
   hEdepos->GetYaxis()->SetTitle("# hits");
-  fAliITSQADataMakerSim->Add2HitsList(hEdepos,4+fGenOffset);
-  fSPDhTask++;
-
-  AliDebug(1,Form("%d SPD Hits histograms booked\n",fSPDhTask));
+  rv = fAliITSQADataMakerSim->Add2HitsList(hEdepos,4+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
+  fSPDhHTask++;
 
+  AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Hits histograms booked\n",fSPDhHTask));
+  delete [] hmod;
+  return rv ; 
 }
 
 //____________________________________________________________________________
-void AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
+Int_t AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
 { 
   // Fill QA for HITS - SPD -
+  Int_t rv = 0 ; 
   AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
   fITS->SetTreeAddress();
   Int_t nmodules;
@@ -305,11 +347,11 @@ void AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
     TObjArray *arrHits = module->GetHits();
     Int_t nhits = arrHits->GetEntriesFast();
     if (imod<80) {
-      fAliITSQADataMakerSim->GetHitsData(fGenOffset)->Fill(0.5,nhits);
-      fAliITSQADataMakerSim->GetHitsData(1+fGenOffset)->Fill(imod,nhits);
+      fAliITSQADataMakerSim->FillHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],0.5,nhits);
+      fAliITSQADataMakerSim->FillHitsData(1+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],imod,nhits);
     } else {
-      fAliITSQADataMakerSim->GetHitsData(fGenOffset)->Fill(1,nhits);
-      fAliITSQADataMakerSim->GetHitsData(2+fGenOffset)->Fill(imod,nhits);
+      fAliITSQADataMakerSim->FillHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],1,nhits);
+      fAliITSQADataMakerSim->FillHitsData(2+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],imod,nhits);
     }
     for (Int_t iHit=0; iHit<nhits; ++iHit) {
       AliITShit *hit = (AliITShit*) arrHits->At(iHit);
@@ -318,11 +360,73 @@ void AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
       hit->GetPositionL(xl,yl,zl,tof);
       hit->GetPositionL0(xl0,yl0,zl0,tof0);
       Float_t dyloc=TMath::Abs(yl-yl0)*10000.;
-      fAliITSQADataMakerSim->GetHitsData(3+fGenOffset)->Fill(dyloc);
+      fAliITSQADataMakerSim->FillHitsData(3+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],dyloc);
       Float_t edep=hit->GetIonization()*1000000;
       if(dyloc>180.){
-        fAliITSQADataMakerSim->GetHitsData(4+fGenOffset)->Fill(edep);
+        fAliITSQADataMakerSim->FillHitsData(4+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],edep);
       }
     }
   }
+  //
+  return rv ; 
+}
+
+
+//_______________________________________________________________
+
+Int_t AliITSQASPDDataMakerSim::GetOffset(AliQAv1::TASKINDEX_t task,Int_t specie){
+  // Returns histogram offset according to the specified task
+  Int_t offset=0;
+  if( task == AliQAv1::kHITS){
+    offset=fGenOffsetH[specie];
+  }
+  else if( task == AliQAv1::kSDIGITS) {
+    offset=fGenOffsetS[specie];
+  }
+  else if( task == AliQAv1::kDIGITS) {
+    offset=fGenOffsetD[specie];
+  }
+  else {
+    AliInfo("No task has been selected. TaskHisto set to zero.\n");
+  }
+
+  return offset;
+}
+
+//____________________________________________________________________________ 
+void AliITSQASPDDataMakerSim::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset,Int_t specie ){
+  // Returns histogram offset according to the specified task
+  if( task == AliQAv1::kHITS){
+    fGenOffsetH[specie] = offset;  
+  }
+  else if( task == AliQAv1::kSDIGITS) {
+    fGenOffsetS[specie] = offset;   
+  }
+  else if( task == AliQAv1::kDIGITS) {
+    fGenOffsetD[specie] = offset;   
+  }
+  else {
+    AliInfo("No task has been selected. TaskHisto set to zero.\n");
+  }
+}
+
+//_______________________________________________________________
+
+Int_t AliITSQASPDDataMakerSim::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
+  // Returns the number of booked histograms for the selected task
+  Int_t histotot=0;
+  if( task == AliQAv1::kHITS) {
+    histotot=fSPDhHTask ;
+  }
+  else if( task == AliQAv1::kSDIGITS) {
+    histotot=fSPDhSTask;
+  }
+  else if( task == AliQAv1::kDIGITS) {
+    histotot=fSPDhDTask ;
+  }
+  else {
+    AliInfo("No task has been selected. TaskHisto set to zero.\n");
+  }
+  return histotot;
+
 }