]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDQADataMaker.cxx
Changes in QA to be able to process separately different triggers (Ruben)
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMaker.cxx
index 82afad865c7b6943a234b068b8019cbf0cb5c006..e95096f9fa400af1e93d28cbd70a3c33d483ed46 100644 (file)
 
 // --- ROOT system ---
 #include <TClonesArray.h>
-#include <TFile.h> 
-#include <TH1D.h> 
-#include <TH2D.h>
-#include <TH3D.h>
+#include <TH1F.h> 
+#include <TH2F.h>
+#include <TH3F.h>
 #include <TProfile.h>
 #include <TF1.h>
-#include <TCanvas.h>
 
 // --- AliRoot header files ---
 #include "AliESDEvent.h"
-#include "AliLog.h"
+#include "AliQAChecker.h"
+
 #include "AliTRDdigit.h"
 #include "AliTRDhit.h"
 #include "AliTRDcluster.h"
 #include "AliTRDQADataMaker.h"
 #include "AliTRDdigitsManager.h"
 #include "AliTRDgeometry.h"
-#include "AliTRDdataArrayI.h"
-#include "AliTRDrawStreamTB.h"
-
-#include "AliQAChecker.h"
+#include "AliTRDarrayADC.h"
 
 ClassImp(AliTRDQADataMaker)
 
 //____________________________________________________________________________ 
   AliTRDQADataMaker::AliTRDQADataMaker() : 
-  AliQADataMaker(AliQA::GetDetName(AliQA::kTRD), "TRD Quality Assurance Data Maker")
+  AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker")
 {
   //
   // Default constructor
@@ -86,66 +82,90 @@ AliTRDQADataMaker& AliTRDQADataMaker::operator=(const AliTRDQADataMaker& qadm)
 }
 
 //____________________________________________________________________________ 
-void AliTRDQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray * list)
+void AliTRDQADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
 {
   //
   // Detector specific actions at end of cycle
   //
-
-  //AliInfo(Form("EndOfCycle", "Fitting RecPoints %d", task));
-
-  if (task == AliQA::kRECPOINTS) {
-
-    //list->Print();
-    
-    // Rec points full chambers
-    if (((TH2D*)list->At(1))->GetEntries() > 1e4) {
-      for (Int_t i=0; i<540; i++) {
-       
-       TH1D *h = ((TH2D*)list->At(1))->ProjectionY(Form("qaTRD_recPoints_amp_%d",i), i+1, i+1);
-       if (h->GetSum() < 100) continue; // chamber not present
-       
-       h->Fit("landau", "q0", "goff", 10, 180);
-       TF1 *fit = h->GetFunction("landau");
-       ((TH1D*)list->At(12))->Fill(fit->GetParameter(1));
-       ((TH1D*)list->At(13))->Fill(fit->GetParameter(2));
-       delete h;      
-      }
-    }
-    
-    
-    if (((TH2D*)list->At(10))->GetEntries() > 1e5) {
-      for (Int_t i=0; i<540; i++) {
-       
-       TH1D *test = ((TH3D*)list->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, 0, 35);     
-       if (test->GetSum() < 100) continue;
-       
-       //AliInfo(Form("fitting det = %d", i));
-       
-       for(Int_t j=0; j<35; j++) {
-         
-         TH1D *h =  ((TH3D*)list->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1);     
-         if (h->GetSum() < 50) continue;
-         
-         h->Fit("landau", "q0", "goff", 10, 180);
-         TF1 *fit = h->GetFunction("landau");
-         
-         Int_t sm = i/18;
-         Int_t det = i%18;
-         TH2D *h2 = (TH2D*)list->At(14+sm);
-         Int_t bin = h2->FindBin(det,j);
-         // printf("%d %d %d\n", det, j, bin);
-         h2->SetBinContent(bin, fit->GetParameter(1));
+  //TStopwatch watch;
+  //watch.Start();
+  ResetEventTrigClasses();
+  //
+  //AliDebug(AliQAv1::GetQADebugLevel(), Form("EndOfCycle", "Fitting RecPoints %d", task))
+  TH1F *hist = new TH1F("fitHist", "", 200, -0.5, 199.5);
+  //
+  // RS Add a loop over species
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+    if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) continue ; 
+    SetEventSpecie(specie);
+    //
+    for (int itc=-1;itc<GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class
+      //
+      if (task == AliQAv1::kRECPOINTS) {
+
+       //list->Print();
+       TObjArray& arrRP = *GetRecPointsDataOfTrigClass(itc); // RS Histos matching to trigger class
+       // Rec points full chambers
+       TH2* h2tmp = (TH2*) arrRP[1];
+       if (h2tmp) {
+         for (Int_t i=0; i<540; i++) {
+           hist->Reset();
+           for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
+             Double_t xvalue = hist->GetBinCenter(b);
+             Int_t bin = h2tmp->FindBin(i,xvalue);
+             Double_t value =  h2tmp->GetBinContent(bin);
+             hist->SetBinContent(b, value);
+           }
+           //printf("Sum = %d %f\n", i, hist->GetSum());
+           if (hist->GetSum() < 100) continue; // chamber not present
+           //
+           hist->Fit("landau", "q0", "goff", 10, 180);
+           TF1 *fit = hist->GetFunction("landau");
+           if (arrRP[12]) ((TH1*)arrRP[12])->Fill(fit->GetParameter(1));
+           if (arrRP[13]) ((TH1*)arrRP[13])->Fill(fit->GetParameter(2));
+         }
        }
-      }
-    }
-  }
+       //
+       // time-bin by time-bin
+       TH3* h3tmp = (TH3*) arrRP[10]; 
+       if (h3tmp) {
+         for (Int_t i=0; i<540; i++) {
+           for(Int_t j=0; j<35; j++) {
+             hist->Reset();
+             for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
+               Double_t xvalue = hist->GetBinCenter(b);
+               Int_t bin = h3tmp->FindBin(i,j,xvalue);
+               Double_t value =  h2tmp->GetBinContent(bin);
+               //printf("v = %f\n", value);
+               hist->SetBinContent(b, value);
+             }
+             if (hist->GetSum() < 100) continue;
+             //printf("fitting %d %d %f\n", i, j, hist->GetSum());           
+             hist->Fit("landau", "q0", "goff", 10, 180);
+             TF1 *fit = hist->GetFunction("landau");
+             //
+             Int_t sm = i/18;
+             Int_t det = i%18;
+             TH2* h2 = (TH2*)arrRP[14+sm];
+             if (!h2) continie;
+             Int_t bin = h2->FindBin(det,j);
+             // printf("%d %d %d\n", det, j, bin);
+             h2->SetBinContent(bin, fit->GetParameter(1));
+           }
+         }
+       } // h3tmp
+      } // RESPOINTS
+    } // RS: loop over eventual clones per trigger class
+  } // loop over species
+  
+  
+  delete hist;
   
   // call the checker
-  AliQAChecker::Instance()->Run(AliQA::kTRD, task, list) ;    
-
+  AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;    
 
+  //watch.Stop();
+  //watch.Print();
 }
 
 //____________________________________________________________________________ 
@@ -159,30 +179,31 @@ void AliTRDQADataMaker::InitESDs()
   TH1 *hist[kNhist];
   Int_t histoCounter = -1 ;
 
-  hist[++histoCounter] = new TH1D("qaTRD_esd_ntracks", ":Number of tracks", 300, -0.5, 299.5);
-  hist[++histoCounter] = new TH1D("qaTRD_esd_sector", ":Sector", 18, -0.5, 17.7);
-  hist[++histoCounter] = new TH1D("qaTRD_esd_bits", ";Bits", 64, -0.5, 63.5);
+  hist[++histoCounter] = new TH1F("qaTRD_esd_ntracks", ":Number of tracks", 300, -0.5, 299.5);
+  hist[++histoCounter] = new TH1F("qaTRD_esd_sector", ":Sector", 18, -0.5, 17.7);
+  hist[++histoCounter] = new TH1F("qaTRD_esd_bits", ";Bits", 64, -0.5, 63.5);
 
   const Int_t knbits = 6;
   const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
 
   for(Int_t i=0; i<knbits; i++) {
-    hist[++histoCounter] = new TH1D(Form("qaTRD_esd_pt%s",suf[i]), ";p_{T} (GeV/c);", 50, 0, 10);
-    hist[++histoCounter] = new TH1D(Form("qaTRD_esd_trdz%s", suf[i]), ";z (cm)", 200, -400, 400); 
+    hist[++histoCounter] = new TH1F(Form("qaTRD_esd_pt%s",suf[i]), ";p_{T} (GeV/c);", 50, 0, 10);
+    hist[++histoCounter] = new TH1F(Form("qaTRD_esd_trdz%s", suf[i]), ";z (cm)", 200, -400, 400); 
   }
 
-  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDo", "TRDo;number of clusters", 130, -0.5, 129.5);;
-  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDr", "TRDr;number of clusters", 130, -0.5, 129.5);;
-  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDz", "TRDz;number of clusters", 130, -0.5, 129.5);;
-  //hist[++histoCounter] = new TH1D("qaTRD_esd_clsRatio", ";cluster ratio", 100, 0., 1.3);;
+  hist[++histoCounter] = new TH1F("qaTRD_esd_clsTRDo", "TRDo;number of clusters", 130, -0.5, 129.5);;
+  hist[++histoCounter] = new TH1F("qaTRD_esd_clsTRDr", "TRDr;number of clusters", 130, -0.5, 129.5);;
+  hist[++histoCounter] = new TH1F("qaTRD_esd_clsTRDz", "TRDz;number of clusters", 130, -0.5, 129.5);;
+  //hist[++histoCounter] = new TH1F("qaTRD_esd_clsRatio", ";cluster ratio", 100, 0., 1.3);;
 
-  hist[++histoCounter] = new TH2D("qaTRD_esd_sigMom", ";momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
+  hist[++histoCounter] = new TH2F("qaTRD_esd_sigMom", ";momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
 
   for(Int_t i=0; i<=histoCounter; i++) {
     //hist[i]->Sumw2();
     Add2ESDsList(hist[i], i);
   }
-
+  //
+  ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -193,19 +214,20 @@ void AliTRDQADataMaker::InitHits()
   //
 
   const Int_t kNhist = 4;
-  TH1D *hist[kNhist];
+  TH1F *hist[kNhist];
 
-  hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ; 
+  hist[0] = new TH1F("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ; 
 
-  hist[1] = new TH1D("qaTRD_hist_Qdrift", ";Charge from tracks", 100, 0, 100);
-  hist[2] = new TH1D("qaTRD_hist_Qamp", ";Charge from TRD photon", 100, 0, 100);
-  hist[3] = new TH1D("qaTRD_hist_Qphoton", ";Charge from TRD photon", 100, 0, 100);
+  hist[1] = new TH1F("qaTRD_hist_Qdrift", ";Charge from tracks", 100, 0, 100);
+  hist[2] = new TH1F("qaTRD_hist_Qamp", ";Charge from TRD photon", 100, 0, 100);
+  hist[3] = new TH1F("qaTRD_hist_Qphoton", ";Charge from TRD photon", 100, 0, 100);
 
   for(Int_t i=0; i<kNhist; i++) {
     //hist[i]->Sumw2();
     Add2HitsList(hist[i], i);
   }
-
+  //
+  ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -216,17 +238,18 @@ void AliTRDQADataMaker::InitDigits()
   //
 
   const Int_t kNhist = 3;
-  TH1D *hist[kNhist];
+  TH1F *hist[kNhist];
 
-  hist[0] = new TH1D("qaTRD_digits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
-  hist[1] = new TH1D("qaTRD_digits_time", ";Time bin", 40, -0.5, 39.5);
-  hist[2] = new TH1D("qaTRD_digits_amp", ";Amplitude", 100, 0, 100.);
+  hist[0] = new TH1F("qaTRD_digits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
+  hist[1] = new TH1F("qaTRD_digits_time", ";Time bin", 40, -0.5, 39.5);
+  hist[2] = new TH1F("qaTRD_digits_amp", ";Amplitude", 100, 0, 100.);
 
   for(Int_t i=0; i<kNhist; i++) {
     hist[i]->Sumw2();
     Add2DigitsList(hist[i], i);
   }
-
+  //
+  ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -239,29 +262,29 @@ void AliTRDQADataMaker::InitRecPoints()
   const Int_t kNhist = 14 + 18;
   TH1 *hist[kNhist];
 
-  hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5);
-  hist[1] = new TH2D("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5);
-  hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5);
+  hist[0] = new TH1F("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5);
+  hist[1] = new TH2F("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5);
+  hist[2] = new TH1F("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5);
 
-  hist[3] = new TH1D("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1);
-  hist[4] = new TH1D("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1);
-  hist[5] = new TH1D("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1);
-  hist[6] = new TH1D("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1);
+  hist[3] = new TH1F("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1);
+  hist[4] = new TH1F("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1);
+  hist[5] = new TH1F("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1);
+  hist[6] = new TH1F("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1);
 
-  hist[7] = new TH2D("qaTRD_recPoints_rowCol", ";row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
-  hist[8] = new TH1D("qaTRD_recPoints_time", ";time bin", 35, -0.5, 34.5);
-  hist[9] = new TH1D("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5);
+  hist[7] = new TH2F("qaTRD_recPoints_rowCol", ";row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
+  hist[8] = new TH1F("qaTRD_recPoints_time", ";time bin", 35, -0.5, 34.5);
+  hist[9] = new TH1F("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5);
 
-  hist[10] = new TH3D("qaTRD_recPoints_sigTime", ";chamber;time bin;signal", 
-                     540, -0.5, 539.5, 35, -0.5, 34.5, 100, 0, 200);
+  hist[10] = new TH3F("qaTRD_recPoints_sigTime", ";chamber;time bin;signal", 
+                     540, -0.5, 539.5, 35, -0.5, 34.5, 200, 0.5, 199.5);
   hist[11] = new TProfile("qaTRD_recPoints_prf", ";distance;center of gravity"
                          , 120, -0.6, 0.6, -1.2, 1.2, "");
 
-  hist[12] = new TH1D("qaTRD_recPoints_ampMPV", ";amplitude MPV", 100, 0, 100);
-  hist[13] = new TH1D("qaTRD_recPoints_ampSigma", ";amplitude Sigma", 100, 0, 100); 
+  hist[12] = new TH1F("qaTRD_recPoints_ampMPV", ";amplitude MPV", 100, 0, 100);
+  hist[13] = new TH1F("qaTRD_recPoints_ampSigma", ";amplitude Sigma", 100, 0, 100); 
 
   for(Int_t i=0; i<18; i++) {
-    hist[14+i] = new TH2D(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin"), 
+    hist[14+i] = new TH2F(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin"), 
                        30, -0.5, 29.5, 35, -0.5, 34.5);
     hist[14+i]->SetMinimum(20);
     hist[14+i]->SetMaximum(40);
@@ -271,7 +294,8 @@ void AliTRDQADataMaker::InitRecPoints()
     //hist[i]->Sumw2();
     Add2RecPointsList(hist[i], i);
   }
-
+  //
+  ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -284,26 +308,27 @@ void AliTRDQADataMaker::InitRaws()
   const Int_t kSM = 18;
   //const Int_t kNCh = 540;
   const Int_t kNhist = 4+kSM;
-  TH1D *hist[kNhist];
+  TH1F *hist[kNhist];
 
   // four histograms to be published
-  hist[0] = new TH1D("qaTRD_raws_det", ";detector", 540, -0.5, 539.5);
-  hist[1] = new TH1D("qaTRD_raws_sig", ";signal", 100, -0.5, 99.5);
-  hist[2] = new TH1D("qaTRD_raws_timeBin", ";time bin", 40, -0.5, 39.5); 
-  hist[3] = new TH1D("qaTRD_raws_smId", ";supermodule", 18, -0.5, 17.5);
+  hist[0] = new TH1F("qaTRD_raws_det", ";detector", 540, -0.5, 539.5);
+  hist[1] = new TH1F("qaTRD_raws_sig", ";signal", 100, -0.5, 99.5);
+  hist[2] = new TH1F("qaTRD_raws_timeBin", ";time bin", 40, -0.5, 39.5); 
+  hist[3] = new TH1F("qaTRD_raws_smId", ";supermodule", 18, -0.5, 17.5);
   //
   
   // one double per MCM (not published)
   const Int_t kNMCM = 30 * 8 * 16;
   for(Int_t i=0; i<kSM; i++)
-    hist[4+i] = new TH1D(Form("qaTRD_raws_sm%d",i),"",kNMCM, -0.5, kNMCM-0.5); 
+    hist[4+i] = new TH1F(Form("qaTRD_raws_sm%d",i),"",kNMCM, -0.5, kNMCM-0.5); 
   
   // register
   for(Int_t i=0; i<kNhist; i++) {
     //hist[i]->Sumw2();
     Add2RawsList(hist[i], i);
   }
-
+  //
+  ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -314,28 +339,29 @@ void AliTRDQADataMaker::InitSDigits()
   //
 
   const Int_t kNhist = 3;
-  TH1D *hist[kNhist];
+  TH1F *hist[kNhist];
 
-  hist[0] = new TH1D("qaTRD_sdigits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
-  hist[1] = new TH1D("qaTRD_sdigits_time", ";Time bin", 40, -0.5, 39.5);
-  hist[2] = new TH1D("qaTRD_sdigits_amp", ";Amplitude", 100, 0, 1e7);
+  hist[0] = new TH1F("qaTRD_sdigits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
+  hist[1] = new TH1F("qaTRD_sdigits_time", ";Time bin", 40, -0.5, 39.5);
+  hist[2] = new TH1F("qaTRD_sdigits_amp", ";Amplitude", 100, 0, 1e7);
 
   for(Int_t i=0; i<kNhist; i++) {
     hist[i]->Sumw2();
     Add2SDigitsList(hist[i], i);
   }
-
+  //
+  ClonePerTrigClass(AliQAv1::kSDIGITS); // this should be the last line
 }
 
 //____________________________________________________________________________
-void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
+void AliTRDQADataMaker::MakeESDs(AliESDEvent * const esd)
 {
   //
   // Make QA data from ESDs
   //
 
   Int_t nTracks = esd->GetNumberOfTracks();
-  GetESDsData(0)->Fill(nTracks);
+  FillESDsData(0,nTracks);
 
   // track loop
   for (Int_t i=0; i<nTracks; i++) {
@@ -356,12 +382,11 @@ void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
 
     // .. in the acceptance
     Int_t sector = GetSector(paramOut->GetAlpha());
-    GetESDsData(1)->Fill(sector);
 
     UInt_t u = 1;
     UInt_t status = track->GetStatus();
     for(Int_t bit=0; bit<32; bit++) 
-      if (u<<bit & status) GetESDsData(2)->Fill(bit);
+      if (u<<bit & status) FillESDsData(2,bit);
 
     const Int_t knbits = 6; 
     Int_t bit[6] = {0,0,0,0,0,0};    
@@ -378,14 +403,14 @@ void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
 
     for(Int_t b=0; b<knbits; b++) {
       if (bit[b]) {
-       GetESDsData(2*b+3)->Fill(pt); 
-       GetESDsData(2*b+4)->Fill(extZ);
+       FillESDsData(2*b+3,pt); 
+       FillESDsData(2*b+4,extZ);
       }
     }
 
     // clusters
     for(Int_t b=0; b<3; b++) 
-      if (bit[3+b]) GetESDsData(b+15)->Fill(track->GetTRDncls());
+      if (bit[3+b]) FillESDsData(b+15,track->GetTRDncls());
 
     // refitted only
     if (!bit[4]) continue;
@@ -394,7 +419,8 @@ void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
     //fBudget->Fill(track->GetTRDBudget());
     //fSignal->Fill(track->GetTRDsignal());
        
-    GetESDsData(18)->Fill(track->GetP(), track->GetTRDsignal());
+    FillESDsData(18,track->GetP(), track->GetTRDsignal());
+    FillESDsData(1,sector);
 
     /*
     // PID only
@@ -431,7 +457,10 @@ void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
     */
 
   }
-
+  //
+  IncEvCountCycleESDs();
+  IncEvCountTotalESDs();
+  //
 }
 
 //______________________________________________________________________________
@@ -468,7 +497,7 @@ Double_t AliTRDQADataMaker::GetExtZ(const AliExternalTrackParam *in) const
 }
 
 //____________________________________________________________________________
-void AliTRDQADataMaker::MakeHits(TClonesArray * hits)
+void AliTRDQADataMaker::MakeHits(TClonesArray * const hits)
 {
   //
   // Make QA data from Hits
@@ -478,12 +507,12 @@ void AliTRDQADataMaker::MakeHits(TClonesArray * hits)
   AliTRDhit * hit; 
 
   while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
-    GetHitsData(0)->Fill(hit->GetDetector());
+    FillHitsData(0,hit->GetDetector());
     Double_t q = TMath::Abs(hit->GetCharge());
 
-    if (hit->FromDrift()) GetHitsData(1)->Fill(q);
-    if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
-    if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
+    if (hit->FromDrift()) FillHitsData(1,q);
+    if (hit->FromAmplification()) FillHitsData(2,q);
+    if (hit->FromTRphoton()) FillHitsData(3,q);
   }
 
 }
@@ -519,11 +548,14 @@ void AliTRDQADataMaker::MakeHits(TTree * hitTree)
   tmp->Delete();
   delete tmp;
   MakeHits(hits);
-
+  //
+  IncEvCountCycleHits();
+  IncEvCountTotalHits();
+  //
 }
 
 //____________________________________________________________________________
-void AliTRDQADataMaker::MakeDigits(TClonesArray * digits)
+void AliTRDQADataMaker::MakeDigits(TClonesArray * const digits)
 {
   //
   // Makes data from Digits
@@ -532,9 +564,9 @@ void AliTRDQADataMaker::MakeDigits(TClonesArray * digits)
   TIter next(digits) ; 
   AliTRDdigit * digit ; 
   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
-    GetDigitsData(0)->Fill(digit->GetDetector());
-    GetDigitsData(1)->Fill(digit->GetTime());
-    GetDigitsData(2)->Fill(digit->GetAmp());
+    FillDigitsData(0,digit->GetDetector());
+    FillDigitsData(1,digit->GetTime());
+    FillDigitsData(2,digit->GetAmp());
   }
 
 }
@@ -552,12 +584,12 @@ void AliTRDQADataMaker::MakeDigits(TTree * digits)
 
   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
 
-    AliTRDdataArrayI *digitsIn = digitsManager->GetDigits(i);      
+    AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);      
 
     // This is to take care of switched off super modules
     if (digitsIn->GetNtime() == 0) continue;
 
-    digitsIn->Expand();
+    digitsIn->Expand(); 
 
     //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
     //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
@@ -568,23 +600,26 @@ void AliTRDQADataMaker::MakeDigits(TTree * digits)
 
     for(Int_t row = 0; row < nRows; row++) 
       for(Int_t col = 0; col < nCols; col++) 
-       for(Int_t time = 0; time < nTbins; time++) {
-
-         Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
-         GetDigitsData(0)->Fill(i);
-         GetDigitsData(1)->Fill(time);
-         GetDigitsData(2)->Fill(signal);
-       }
+       for(Int_t time = 0; time < nTbins; time++) 
+         {
+           Float_t signal = digitsIn->GetData(row,col,time);
+           FillDigitsData(0,i);
+           FillDigitsData(1,time);
+           FillDigitsData(2,signal);
+         }
 
     //delete digitsIn;
   }
 
   delete digitsManager;
-
+  //
+  IncEvCountCycleDigits();
+  IncEvCountTotalDigits();
+  //
 }
 
 //____________________________________________________________________________
-void AliTRDQADataMaker::MakeSDigits(TClonesArray * sdigits)
+void AliTRDQADataMaker::MakeSDigits(TClonesArray * const sdigits)
 {
   //
   // Makes data from Digits
@@ -593,9 +628,9 @@ void AliTRDQADataMaker::MakeSDigits(TClonesArray * sdigits)
   TIter next(sdigits) ; 
   AliTRDdigit * digit ; 
   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
-    GetDigitsData(0)->Fill(digit->GetDetector());
-    GetDigitsData(1)->Fill(digit->GetTime());
-    GetDigitsData(2)->Fill(digit->GetAmp());
+    FillDigitsData(0,digit->GetDetector());
+    FillDigitsData(1,digit->GetTime());
+    FillDigitsData(2,digit->GetAmp());
   }
 
 }
@@ -611,14 +646,14 @@ void AliTRDQADataMaker::MakeSDigits(TTree * digits)
   digitsManager->CreateArrays();
   digitsManager->ReadDigits(digits);
 
-  for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
-
-    AliTRDdataArrayI *digitsIn = digitsManager->GetDigits(i);      
+  for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) 
+    {
+    AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);      
 
     // This is to take care of switched off super modules
     if (digitsIn->GetNtime() == 0) continue;
 
-    digitsIn->Expand();
+    digitsIn->Expand();  
 
     //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
     //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
@@ -629,24 +664,27 @@ void AliTRDQADataMaker::MakeSDigits(TTree * digits)
 
     for(Int_t row = 0; row < nRows; row++) 
       for(Int_t col = 0; col < nCols; col++) 
-       for(Int_t time = 0; time < nTbins; time++) {
-
-         Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
-         if (signal <= 0) continue;
-         GetSDigitsData(0)->Fill(i);
-         GetSDigitsData(1)->Fill(time);
-         GetSDigitsData(2)->Fill(signal);
-       }
-
+       for(Int_t time = 0; time < nTbins; time++) 
+         {
+           Float_t signal = digitsIn->GetData(row,col,time);
+           if (signal <= 0) continue;
+           FillSDigitsData(0,i);
+           FillSDigitsData(1,time);
+           FillSDigitsData(2,signal);
+         }
+    
     // delete digitsIn;
   }
 
   delete digitsManager;
-
+  //
+  IncEvCountCycleSDigits();
+  IncEvCountTotalSDigits();
+  //
 }
 
 //____________________________________________________________________________
-void AliTRDQADataMaker::MakeRaws(AliRawReader* rawReader)
+void AliTRDQADataMaker::MakeRaws(AliRawReader * const rawReader)
 {
   //
   // Makes QA data from raw data
@@ -663,37 +701,37 @@ void AliTRDQADataMaker::MakeRaws(AliRawReader* rawReader)
   const Int_t kMCM = 16;
   //  const Int_t kADC = 22;
 
-  AliTRDrawStreamTB *raw = new AliTRDrawStreamTB(rawReader);
+  AliTRDrawStream raw(rawReader);
+  raw.SetRawVersion(3);
+  raw.Init();
 
-  //raw->SetRawVersion(3);
-  //raw->Init();
+  while (raw.Next()) {
 
-  while (raw->Next()) {
-
-    GetRawsData(0)->Fill(raw->GetDet());
+    FillRawsData(0,raw.GetDet());
 
     // possibly needs changes with the new reader !!
-    Int_t *sig = raw->GetSignals();
-    for(Int_t i=0; i<3; i++) GetRawsData(1)->Fill(sig[i]);
+    Int_t *sig = raw.GetSignals();
+    for(Int_t i=0; i<3; i++) FillRawsData(1,sig[i]);
     // ---
 
-    GetRawsData(2)->Fill(raw->GetTimeBin());
+    FillRawsData(2,raw.GetTimeBin());
 
     // calculate the index;
-    Int_t sm = raw->GetSM();
-    Int_t roc = raw->GetROC();
-    Int_t rob = raw->GetROB();
-    Int_t mcm = raw->GetMCM();
-    //Int_t adc = raw->GetADC();
+    Int_t sm = raw.GetSM();
+    Int_t roc = raw.GetROC();
+    Int_t rob = raw.GetROB();
+    Int_t mcm = raw.GetMCM();
+    //Int_t adc = raw.GetADC();
 
     //Int_t index = roc * (kROB*kMCM*kADC) + rob * (kMCM*kADC) + mcm * kADC + adc;
     Int_t  index = roc * (kROB*kMCM) + rob * kMCM + mcm;
-    GetRawsData(3)->Fill(sm);
-    GetRawsData(4+sm)->Fill(index);
+    FillRawsData(3,sm);
+    FillRawsData(4+sm,index);
   }
-
-  delete raw;
-
+  //
+  IncEvCountCycleRaws();
+  IncEvCountTotalRaws();
+  //
 }
 
 //____________________________________________________________________________
@@ -734,17 +772,18 @@ void AliTRDQADataMaker::MakeRecPoints(TTree * clustersTree)
 
       Int_t iDet = c->GetDetector();
       nDet[iDet]++;
-      GetRecPointsData(0)->Fill(iDet);
-      GetRecPointsData(1)->Fill(iDet, c->GetQ());
-      GetRecPointsData(2)->Fill(c->GetNPads());
+      FillRecPointsData(0,iDet);
+      FillRecPointsData(1,iDet, c->GetQ());
+      FillRecPointsData(2,c->GetNPads());
       if (c->GetNPads() < 6)
-       GetRecPointsData(1+c->GetNPads())->Fill(c->GetCenter());
+       FillRecPointsData(1+c->GetNPads(),c->GetCenter());
 
       //if (c->GetPadTime() < 5)
-      ((TH2D*)GetRecPointsData(7))->Fill(c->GetPadRow(), c->GetPadCol());
-      GetRecPointsData(8)->Fill(c->GetPadTime());
+      FillRecPointsData(7,c->GetPadRow(), c->GetPadCol());
+      FillRecPointsData(8,c->GetPadTime());
 
-      ((TH3D*)GetRecPointsData(10))->Fill(iDet, c->GetPadTime(), c->GetQ());
+      TObjArray *hists = GetMatchingRecPointsData(10); //RS no alias for 3d histo filling, to directly
+      for (int ih=hists->GetEntriesFast();ih--;) ((TH3F*)hists->UncheckedAt(ih))->Fill(iDet, c->GetPadTime(), c->GetQ());
 
       // PRF for 2pad
       //if (c->GetNPads() == 2) {
@@ -757,14 +796,14 @@ void AliTRDQADataMaker::MakeRecPoints(TTree * clustersTree)
       if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0)
        frac = -1. * sig[2] / (sig[2] + sig[3]);
 
-      if (frac > -10)  ((TProfile*)GetRecPointsData(11))->Fill(c->GetCenter(), frac);
+      if (frac > -10)  FillRecPointsData(11,c->GetCenter(), frac);
        
       //}
     }
   }
 
   for(Int_t i=0; i<540; i++) 
-    if (nDet[i] > 0) GetRecPointsData(9)->Fill(nDet[i]);
+    if (nDet[i] > 0) FillRecPointsData(9,nDet[i]);
 
   delete clusterArray;
 
@@ -780,7 +819,7 @@ void AliTRDQADataMaker::StartOfDetectorCycle()
 }
 
 //__________________________________________________________________________
-Int_t AliTRDQADataMaker::CheckPointer(TObject *obj, const char *name) 
+Int_t AliTRDQADataMaker::CheckPointer(TObject * const obj, const char *name) 
 {
   //
   // Checks initialization of pointers