store also difference in local Y
[u/mrichter/AliRoot.git] / ITS / AliITSQASPDDataMakerSim.cxx
index c058c76..2dbe1d4 100644 (file)
@@ -57,6 +57,14 @@ 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;
+  }             
 }
 
 //____________________________________________________________________________ 
@@ -73,7 +81,8 @@ 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 )
@@ -92,7 +101,7 @@ void AliITSQASPDDataMakerSim::StartOfDetectorCycle()
 }
 
 //____________________________________________________________________________ 
-void AliITSQASPDDataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/)
+void AliITSQASPDDataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray** /*list*/)
 {
   // launch the QA checking
   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
@@ -110,46 +119,46 @@ Int_t AliITSQASPDDataMakerSim::InitDigits()
   //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("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
   hlayer->GetXaxis()->SetTitle("Layer number");
   hlayer->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerSim->Add2DigitsList(hlayer,fGenOffsetD, expert, !image);
+  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,"SPDModPattern_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");
-    rv = fAliITSQADataMakerSim->Add2DigitsList(hmod[iLay],1+iLay+fGenOffsetD, !expert, image);
+    rv = fAliITSQADataMakerSim->Add2DigitsList(hmod[iLay],1+iLay+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
     fSPDhDTask++;
   }
   
   TH1F *hcolumns = new TH1F("SPDColumns_SPD","Columns - SPD",160,0.,160.);
   hcolumns->GetXaxis()->SetTitle("Column number");
   hcolumns->GetYaxis()->SetTitle("Entries");
-  fAliITSQADataMakerSim->Add2DigitsList(hcolumns,3+fGenOffsetD, expert, !image);
+  fAliITSQADataMakerSim->Add2DigitsList(hcolumns,3+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], expert, !image);
   fSPDhDTask++;
 
   TH1F *hrows = new TH1F("SPDRows_SPD","Rows - SPD",256,0.,256.);
   hrows->GetXaxis()->SetTitle("Row number");
   hrows->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerSim->Add2DigitsList(hrows,4+fGenOffsetD, expert, !image);
+  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,"SPDDigitMultiplicity_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");
-    rv = fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenOffsetD, !expert, image);
+    rv = fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
     fSPDhDTask++;
   }
 
@@ -157,10 +166,12 @@ Int_t AliITSQASPDDataMakerSim::InitDigits()
        = 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)");
-  rv = fAliITSQADataMakerSim->Add2DigitsList(hMultSPDdig2MultSPDdig1,7+fGenOffsetD, !expert, image);
+  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 ; 
 }
 
@@ -169,10 +180,7 @@ Int_t AliITSQASPDDataMakerSim::MakeDigits(TTree *digits)
 { 
   // Fill QA for DIGIT - SPD -
   Int_t rv = 0 ; 
-  // Check id histograms already created for this Event Specie
-  if ( ! fAliITSQADataMakerSim->GetDigitsData(fGenOffsetD) )
-    rv = InitDigits() ;
-  
   AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
   fITS->SetTreeAddress();
   TClonesArray *iITSdigits  = fITS->DigitsAddress(0);  // 0->SPD
@@ -184,26 +192,27 @@ Int_t AliITSQASPDDataMakerSim::MakeDigits(TTree *digits)
     digits->GetEvent(imod);
     Int_t ndigits = iITSdigits->GetEntries();
     if (imod<80) {
-      fAliITSQADataMakerSim->GetDigitsData(0+fGenOffsetD)->Fill(0.5,ndigits);
-      fAliITSQADataMakerSim->GetDigitsData(1+fGenOffsetD)->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+fGenOffsetD)->Fill(1,ndigits);
-      fAliITSQADataMakerSim->GetDigitsData(2+fGenOffsetD)->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+fGenOffsetD)->Fill(col);
-      fAliITSQADataMakerSim->GetDigitsData(4+fGenOffsetD)->Fill(row);
+      fAliITSQADataMakerSim->FillDigitsData(3+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],col);
+      fAliITSQADataMakerSim->FillDigitsData(4+fGenOffsetD[fAliITSQADataMakerSim->GetEventSpecie()],row);
     }
   }
-  fAliITSQADataMakerSim->GetDigitsData(5+fGenOffsetD)->Fill(nDigitsL1);
-  fAliITSQADataMakerSim->GetDigitsData(6+fGenOffsetD)->Fill(nDigitsL2);
-  fAliITSQADataMakerSim->GetDigitsData(7+fGenOffsetD)->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 ; 
 }
 
@@ -218,27 +227,28 @@ Int_t AliITSQASPDDataMakerSim::InitSDigits()
   //printf("--W-- AliITSQASPDDataMakerSim::InitSDigits()  fGenOffset= %d \n",fGenOffset);
   //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("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
   hlayer->GetXaxis()->SetTitle("Layer number");
   hlayer->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerSim->Add2SDigitsList(hlayer,fGenOffsetS, expert, !image);
+  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,"SPDModPattern_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");
-    rv = fAliITSQADataMakerSim->Add2SDigitsList(hmod[iLay],1+iLay+fGenOffsetS, !expert, image);
+    rv = fAliITSQADataMakerSim->Add2SDigitsList(hmod[iLay],1+iLay+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
     fSPDhSTask++;
   }
 
   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD SDigits histograms booked\n",fSPDhSTask));
+  delete [] hmod;
   return rv ; 
 }
 
@@ -247,26 +257,26 @@ Int_t AliITSQASPDDataMakerSim::MakeSDigits(TTree *sdigits)
 { 
   // Fill QA for SDIGIT - SPD -
   Int_t rv = 0 ; 
-  // Check id histograms already created for this Event Specie
-  if ( ! fAliITSQADataMakerSim->GetSDigitsData(fGenOffsetS) )
-   rv = InitSDigits() ;
+  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+fGenOffsetS)->Fill(0.5,nsdig);
-      fAliITSQADataMakerSim->GetSDigitsData(1+fGenOffsetS)->Fill(imod,nsdig);
+      fAliITSQADataMakerSim->FillSDigitsData(0+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],0.5,nsdig);
+      fAliITSQADataMakerSim->FillSDigitsData(1+fGenOffsetS[fAliITSQADataMakerSim->GetEventSpecie()],imod,nsdig);
     }
     else {
-      fAliITSQADataMakerSim->GetSDigitsData(0+fGenOffsetS)->Fill(1,nsdig);
-      fAliITSQADataMakerSim->GetSDigitsData(2+fGenOffsetS)->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 ; 
 }
 
@@ -287,33 +297,34 @@ Int_t AliITSQASPDDataMakerSim::InitHits()
   TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
   hlayer->GetXaxis()->SetTitle("Layer number");
   hlayer->GetYaxis()->SetTitle("Entries");
-  rv = fAliITSQADataMakerSim->Add2HitsList(hlayer,fGenOffsetH, expert, !image);
+  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,"SPDModPattern_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");
-    rv = fAliITSQADataMakerSim->Add2HitsList(hmod[iLay],1+iLay+fGenOffsetH, !expert, image);
+    rv = fAliITSQADataMakerSim->Add2HitsList(hmod[iLay],1+iLay+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
     fSPDhHTask++;
   }
 
   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");
-  rv = fAliITSQADataMakerSim->Add2HitsList(hhitlenght,3+fGenOffsetH, !expert, image);
+  rv = fAliITSQADataMakerSim->Add2HitsList(hhitlenght,3+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()], !expert, image);
   fSPDhHTask++;
 
   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");
-  rv = fAliITSQADataMakerSim->Add2HitsList(hEdepos,4+fGenOffsetH, !expert, image);
+  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 ; 
 }
 
@@ -322,9 +333,6 @@ Int_t AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
 { 
   // Fill QA for HITS - SPD -
   Int_t rv = 0 ; 
-  // Check id histograms already created for this Event Specie
-  if ( ! fAliITSQADataMakerSim->GetHitsData(fGenOffsetH) )
-    rv = InitHits() ;
  
   AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
   fITS->SetTreeAddress();
@@ -339,11 +347,11 @@ Int_t AliITSQASPDDataMakerSim::MakeHits(TTree *hits)
     TObjArray *arrHits = module->GetHits();
     Int_t nhits = arrHits->GetEntriesFast();
     if (imod<80) {
-      fAliITSQADataMakerSim->GetHitsData(fGenOffsetH)->Fill(0.5,nhits);
-      fAliITSQADataMakerSim->GetHitsData(1+fGenOffsetH)->Fill(imod,nhits);
+      fAliITSQADataMakerSim->FillHitsData(fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],0.5,nhits);
+      fAliITSQADataMakerSim->FillHitsData(1+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],imod,nhits);
     } else {
-      fAliITSQADataMakerSim->GetHitsData(fGenOffsetH)->Fill(1,nhits);
-      fAliITSQADataMakerSim->GetHitsData(2+fGenOffsetH)->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);
@@ -352,30 +360,31 @@ Int_t 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+fGenOffsetH)->Fill(dyloc);
+      fAliITSQADataMakerSim->FillHitsData(3+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],dyloc);
       Float_t edep=hit->GetIonization()*1000000;
       if(dyloc>180.){
-        fAliITSQADataMakerSim->GetHitsData(4+fGenOffsetH)->Fill(edep);
+        fAliITSQADataMakerSim->FillHitsData(4+fGenOffsetH[fAliITSQADataMakerSim->GetEventSpecie()],edep);
       }
     }
   }
+  //
   return rv ; 
 }
 
 
 //_______________________________________________________________
 
-Int_t AliITSQASPDDataMakerSim::GetOffset(AliQAv1::TASKINDEX_t task){
+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;
+    offset=fGenOffsetH[specie];
   }
   else if( task == AliQAv1::kSDIGITS) {
-    offset=fGenOffsetS;
+    offset=fGenOffsetS[specie];
   }
   else if( task == AliQAv1::kDIGITS) {
-    offset=fGenOffsetD;
+    offset=fGenOffsetD[specie];
   }
   else {
     AliInfo("No task has been selected. TaskHisto set to zero.\n");
@@ -385,16 +394,16 @@ Int_t AliITSQASPDDataMakerSim::GetOffset(AliQAv1::TASKINDEX_t task){
 }
 
 //____________________________________________________________________________ 
-void AliITSQASPDDataMakerSim::SetOffset(AliQAv1::TASKINDEX_t task, Int_t 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 = offset;  
+    fGenOffsetH[specie] = offset;  
   }
   else if( task == AliQAv1::kSDIGITS) {
-    fGenOffsetS = offset;   
+    fGenOffsetS[specie] = offset;   
   }
   else if( task == AliQAv1::kDIGITS) {
-    fGenOffsetD = offset;   
+    fGenOffsetD[specie] = offset;   
   }
   else {
     AliInfo("No task has been selected. TaskHisto set to zero.\n");