]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDQADataMakerRec.cxx
Setters added (Magnus)
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMakerRec.cxx
index c803ab23ee736d53919274cd746de58497245c9d..9b6495b3bcf5ea310dd4c4647ff5f8858117cf71 100644 (file)
 #include "AliTRDcluster.h"
 #include "AliTRDQADataMakerRec.h"
 #include "AliTRDgeometry.h"
-//#include "AliTRDdataArrayI.h"
 #include "AliTRDrawStream.h"
 
+#include "AliTRDdigitsManager.h"
+#include "AliTRDSignalIndex.h"
+#include "AliTRDarrayADC.h"
+
 #include "AliQAChecker.h"
 
 ClassImp(AliTRDQADataMakerRec)
@@ -94,14 +97,32 @@ void AliTRDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArr
   /**/
   AliDebug(AliQAv1::GetQADebugLevel(), "End of TRD cycle");
   
+
+  if (task == AliQAv1::kRAWS) {
+
+    // loop over event types
+    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+      
+      if (! IsValidEventSpecie(specie, list)) continue;
+      
+
+      TH2D *mnCls = (TH2D*)list[specie]->At(1); 
+      TH2D *mClsDet = (TH2D*)list[specie]->At(2);  
+  
+      mClsDet->Divide(mnCls);
+    }
+  }
+
+
   if (task == AliQAv1::kRECPOINTS) {
     
     TH1D * hist = new TH1D("fitHist", "", 200, -0.5, 199.5);
 
     // loop over event types
     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-
-      //list[specie]->Print();
+      if (! IsValidEventSpecie(specie, list)) 
+        continue ;
+    //list[specie]->Print();
       
       // fill detector map;
       for(Int_t i = 0 ; i < 540 ; i++) {
@@ -229,7 +250,9 @@ void AliTRDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArr
     
     // create ratios
     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-      for(Int_t type = 0 ; type < 2 ; type++) {
+      if (! IsValidEventSpecie(specie, list)) 
+        continue ;
+     for(Int_t type = 0 ; type < 2 ; type++) {
         for(Int_t i = 0 ; i < knRatio ; i++) {
           TH1D *ratio = (TH1D*)list[specie]->At(19 + 2*i + type);
           TH1D *histN = (TH1D*)list[specie]->At(3 + 2*kN[i] + type);
@@ -266,25 +289,25 @@ void AliTRDQADataMakerRec::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 TH1D("qaTRD_esd_ntracks", "TRD esd ntracks;Number of tracks;Counts", 300, -0.5, 299.5);
+  hist[++histoCounter] = new TH1D("qaTRD_esd_sector", "TRD esd sector;Sector;Counts", 18, -0.5, 17.7);
+  hist[++histoCounter] = new TH1D("qaTRD_esd_bits", "TRD esd bits;Bits;Counts", 64, -0.5, 63.5);
 
   const Int_t knbits = 6;
   const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
 
   // histo = 3
   for(Int_t i=0; i<knbits; i++) { 
-    hist[++histoCounter] = new TH1D(Form("qaTRD_esd_pt%s",suf[i]), ";p_{T} (GeV/c);", 100, 0, 10);
+    hist[++histoCounter] = new TH1D(Form("qaTRD_esd_pt%s",suf[i]), Form("qaTRD_esd_pt%s;p_{T} (GeV/c);Counts",suf[i]), 100, 0, 10);
     hist[++histoCounter] = new TH1D(Form("qaTRD_esd_trdz%s", suf[i]), ";z (cm)", 200, -400, 400); 
   }
 
-  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDo", "TRDo;number of clusters", 180, -0.5, 179.5);;
-  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDr", "TRDr;number of clusters", 180, -0.5, 179.5);;
-  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDz", "TRDz;number of clusters", 180, -0.5, 179.5);;
+  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDo", "TRDo;number of clusters;Counts", 180, -0.5, 179.5);;
+  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDr", "TRDr;number of clusters;Counts", 180, -0.5, 179.5);;
+  hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDz", "TRDz;number of clusters;Counts", 180, -0.5, 179.5);;
   //hist[++histoCounter] = new TH1D("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 TH2D("qaTRD_esd_sigMom", "TRD esd sig Mom;momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
 
   // end of cycle plots (hist 19)
   const char *sufRatio[4] = {"TRDrTRDo", "TRDoTPCo", "TRDrTPCo", "TRDzTPCo"};
@@ -300,23 +323,23 @@ void AliTRDQADataMakerRec::InitESDs()
   }
 
   // 27 - 31
-  hist[27] = new TH1D("qaTRD_esd_quality", ";quality", 120, 0, 12);
-  hist[28] = new TH1D("qaTRD_esd_budget", ";NN", 110, -1000, 100);
-  hist[29] = new TH1D("qaTRD_esd_chi2", ";chi2", 200, 0, 100);
-  hist[30] = new TH1D("qaTRD_esd_timeBin", ";time bin", 7, -0.5, 6.5);
-  hist[31] = new TH1D("qaTRD_esd_pidQuality", "pid Quality", 7, -0.5, 6.5);
+  hist[27] = new TH1D("qaTRD_esd_quality", "TRD esd quality;quality;Counts", 120, 0, 12);
+  hist[28] = new TH1D("qaTRD_esd_budget", "TRD esd budget;NN;Counts", 110, -1000, 100);
+  hist[29] = new TH1D("qaTRD_esd_chi2", "TRD esd chi2;chi2;Counts", 200, 0, 100);
+  hist[30] = new TH1D("qaTRD_esd_timeBin", "TRD esd timeBin;time bin;Counts", 7, -0.5, 6.5);
+  hist[31] = new TH1D("qaTRD_esd_pidQuality", "pid Quality;quality;;Counts", 7, -0.5, 6.5);
 
   // stack by stack electron identyfication
-  hist[32] = new TH1D("qaTRD_esd_tracksStack", "number of all tracks;stack", 90, -0.5, 89.5);
-  hist[33] = new TH1D("qaTRD_esd_electronStack", "number of electron tracks;stack", 90, -0.5, 89.5);
-  hist[34] = new TH1D("qaTRD_esd_elRatioStack", "fraction of electron tracks;stack", 90, -0.5, 89.5);
+  hist[32] = new TH1D("qaTRD_esd_tracksStack", "number of all tracks;stack;Counts", 90, -0.5, 89.5);
+  hist[33] = new TH1D("qaTRD_esd_electronStack", "number of electron tracks;stack;Counts", 90, -0.5, 89.5);
+  hist[34] = new TH1D("qaTRD_esd_elRatioStack", "fraction of electron tracks;stack;Counts", 90, -0.5, 89.5);
   hist[35] = new TH1D("qaTRD_esd_thetaOut", ";tan(theta);", 100, -1, 1);
   
   const char *partType[5] = {"Electron", "Muon", "Pion", "Kaon", "Proton"}; 
 
   for(Int_t i=0; i<AliPID::kSPECIES; i++)
     hist[36+i] = new TH1D(Form("qaTRD_esd_pid%d",i),
-                         Form("%s;probability",partType[i]), 100, 0, 1);
+                         Form("%s;probability;Counts",partType[i]), 100, 0, 1);
  
   // dE/dX vs momentum in three regions
   const char *zoneName[4] = {"total charge", "ampilification range", "plateau", "TR range"};
@@ -338,7 +361,7 @@ void AliTRDQADataMakerRec::InitESDs()
 
   for(Int_t i=0; i<4; i++) {
     hist[41+i] = new TH2D(Form("qaTRD_esd_signalPzone_%d",i), 
-                         Form("%s;momentum (GeV/c);singal (a.u.)", zoneName[i]),
+                         Form("%s;momentum (GeV/c);signal (a.u.)", zoneName[i]),
                          nscalex, scalex, nscaley, scaley);
   }
 
@@ -363,30 +386,30 @@ void AliTRDQADataMakerRec::InitRecPoints()
   const Int_t kNhist = 14 + 4 * 18 + 2 + 9;// + 540;
   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 TH1D("qaTRD_recPoints_det", "RRD recPoints det;Detector ID of the cluster;Counts", 540, -0.5, 539.5);
+  hist[1] = new TH2D("qaTRD_recPoints_amp", "TRD recPoints amp;Amplitude;??", 540, -0.5, 539, 200, -0.5, 199.5);
+  hist[2] = new TH1D("qaTRD_recPoints_npad", "TRD recPoints npad;Number of Pads;Counts", 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 TH1D("qaTRD_recPoints_dist2", "TRD recPoints dist2;residuals [2pad];Counts", 100, -1, 1);
+  hist[4] = new TH1D("qaTRD_recPoints_dist3", "TRD recPoints dist3;residuals [3pad];Counts", 100, -1, 1);
+  hist[5] = new TH1D("qaTRD_recPoints_dist4", "TRD recPoints dist4;residuals [4pad];Counts", 100, -1, 1);
+  hist[6] = new TH1D("qaTRD_recPoints_dist5", "TRD recPoints dist5;residuals [5pad];Counts", 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", kTimeBin, -0.5, kTimeBin-0.5);
-  hist[9] = new TH1D("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5);
+  hist[7] = new TH2D("qaTRD_recPoints_rowCol", "TRDrecPointsrowCol;row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
+  hist[8] = new TH1D("qaTRD_recPoints_time", "TRDrecPoints time;time bin;Counts", kTimeBin, -0.5, kTimeBin-0.5);
+  hist[9] = new TH1D("qaTRD_recPoints_nCls", "TRD recPoints nCls;number of clusters;Counts", 500, -0.5, 499.5);
 
-  hist[10] = new TH3D("qaTRD_recPoints_sigTime", ";chamber;time bin;signal", 
+  hist[10] = new TH3D("qaTRD_recPoints_sigTime", "TRD recPoints sigTime;chamber;time bin;signal", 
                      540, -0.5, 539.5, kTimeBin, -0.5, kTimeBin-0.5, 200, -0.5, 199.5);
-  hist[11] = new TProfile("qaTRD_recPoints_prf", ";distance;center of gravity"
+  hist[11] = new TProfile("qaTRD_recPoints_prf", "TRD recPoints prf;distance;center of gravity;Counts"
                          , 120, -0.6, 0.6, -1.2, 1.2, "");
 
-  hist[12] = new TH1D("qaTRD_recPoints_ampMPV", ";amplitude MPV", 150, 0, 150);
-  hist[13] = new TH1D("qaTRD_recPoints_ampSigma", ";amplitude Sigma", 200, 0, 200); 
+  hist[12] = new TH1D("qaTRD_recPoints_ampMPV", "TRD recPoints ampMPV;amplitude MPV;Counts", 150, 0, 150);
+  hist[13] = new TH1D("qaTRD_recPoints_ampSigma", "TRD recPoints ampSigma;amplitude Sigma;Counts", 200, 0, 200); 
   
   // chamber by chamber
   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 TH2D(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin",i), 
                        30, -0.5, 29.5, kTimeBin, -0.5, kTimeBin-0.5);
     hist[14+i]->SetMinimum(0);
     hist[14+i]->SetMaximum(150);
@@ -395,7 +418,7 @@ void AliTRDQADataMakerRec::InitRecPoints()
   // time bin by time bin sm-by-sm
   for(Int_t i=0; i<18; i++) {
     hist[14+18+i] = new TH1D(Form("qaTRD_recPoints_sigTimeShape_sm%d", i), 
-                            Form("sm%d;time bin;signal"),
+                            Form("sm%d;time bin;signal",i),
                             kTimeBin, -0.5, kTimeBin-0.5);
 
     hist[14+18+i]->SetMaximum(150);    
@@ -415,13 +438,13 @@ void AliTRDQADataMakerRec::InitRecPoints()
                          kTimeBin, -0.5, kTimeBin-0.5);
   }
 
-  hist[86] = new TH1D("qaTRD_recPoints_signal", ";amplitude", 400, -0.5, 399.5);
-  hist[87] = new TH2D("qaTRD_recPoints_detMap", ";sm;chamber", 18, -0.5, 17.5, 30, -0.5, 29.5);
+  hist[86] = new TH1D("qaTRD_recPoints_signal", "TRD recPoints signal;amplitude;Counts", 400, -0.5, 399.5);
+  hist[87] = new TH2D("qaTRD_recPoints_detMap", "TRD recPoints detMap;sm;chamber;Counts", 18, -0.5, 17.5, 30, -0.5, 29.5);
 
   
   // amplitude as a function of the pad size
   for(Int_t i=0; i<9; i++) {
-    hist[88+i] = new TH1D(Form("qaTRD_recPoints_signalNpad_%d", i+2), ";amplitude, ADC", 400, -0.5, 399.5); 
+    hist[88+i] = new TH1D(Form("qaTRD_recPoints_signalNpad_%d", i+2), Form("qaTRD_recPoints_signalNpad_%d;amplitude, ADC", i+2), 400, -0.5, 399.5); 
   }
   
   // one 2D histogram per chamber
@@ -447,38 +470,34 @@ void AliTRDQADataMakerRec::InitRaws()
   const Bool_t image    = kTRUE ; 
   
   AliInfo("Initialization of QA for Raw Data");
-
-  //const Int_t kSM = 18;
-  //const Int_t kNCh = 540;
-  const Int_t kNhist = 6;
+  
+  const Int_t kNhist = 7;
   TH1 *hist[kNhist];
 
-  // link monitor
-  const char *linkName[3] = {"smLink", "smBeaf", "smData"};
-  for(Int_t i=0; i<3; i++) {
-    hist[i] = new TH2D(Form("qaTRD_raws_%s", linkName[i]), 
-                      ";super module;link", 
-                      18, -0.5, 17.5, 60, -0.5, 59.5);
-  }
-
-  hist[3] = new TH1D("qaTRD_raws_errorHC", ";error ID;", 18, -3.5, 14.5);
-  hist[4] = new TH1D("qaTRD_raws_errorMCM", ";error ID;", 18, -3.5, 14.5);
-  hist[5] = new TH1D("qaTRD_raws_errorADC", ";error ID;", 18, -3.5, 14.5);
+  hist[0] = new TH2D("qaTRD_raws_nADC","number of ADC channels;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
+  hist[1] = new TH2D("qaTRD_raws_nCls", "number of clusters;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
+  hist[2] = new TH2D("qaTRD_raws_meanSig", "mean signal;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
+  
+  hist[3] = new TH1D("qaTRD_raws_ADC", "ADC amplitude;ADC counts", 100, -0.5, 99.5);
+  hist[4] = new TH1D("qaTRD_raws_Cls", "Cluster amplitude; ADC counts", 100, -0.5, 199.5);
+  hist[5] = new TH2D("qaTRD_raws_ClsTb", "Clusters vs Time Bin;time bin;amoplitude", 30, -0.5, 29.5, 200, -0.5, 199.5);
+  
+  hist[6] = new TH2D("qaTRD_raws_ClsAmpDet", ";detector;amplitude", 540, -0.5, 539.5, 100, 0, 200);
+  
 
   /*
-  // 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);
-  //
-  
-  // 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[0] = new TH2D("qaTRD_raws_DataVolume", ";Sector;Data Volume, kB", 18, -0.5, 17.5, 100, 0, 30);
+    hist[1] = new TH2D("qaTRD_raws_HC", "Data Headers;Sector;HC", 18, -0.5, 17.5, 60, -0.5, 59.5);
+    hist[2] = new TH2D("qaTRD_raws_LME", "Link Monitor Error;Sector;HC", 18, -0.5, 17.5, 60, -0.5, 59.5);
+    
+    hist[3] = new TH1D("qaTRD_rawd_cls", "Clusters amplitude;ADC counts", 100, 0, 200);
+    hist[4] = new TH2D("qaTRD_raws_clsTB", "amplitude - time bins;time bin;amplitude"
+    30, -0.5, 29.5, 100, 0, 200);
+    hist[5] = new TH2D("qaTRD_raws_clsSec", "amplitude in sectors;Sector;amplitude, ADCs"
+    18, -0.5, 17.5);
   */
 
+
   // register
   for(Int_t i=0; i<kNhist; i++) {
     //hist[i]->Sumw2();
@@ -493,7 +512,7 @@ void AliTRDQADataMakerRec::MakeESDs(AliESDEvent * esd)
   //
   // Make QA data from ESDs
   //
-
+  
   Int_t nTracks = esd->GetNumberOfTracks();
   GetESDsData(0)->Fill(nTracks);
 
@@ -691,160 +710,107 @@ void AliTRDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   //
   // Makes QA data from raw data
   //
+
+  AliInfo("Making QA for Raws");
+
+  // take histograms
+
+  TH2D *mnADC = (TH2D*)GetRawsData(0);
+  TH2D *mnCls = (TH2D*)GetRawsData(1); 
+  TH2D *mClsDet = (TH2D*)GetRawsData(2);
   
-  AliInfo("Execution of QA for Raw data");
-  //printf("Execution of QA for Raw data\n");
+  TH1D *mADC = (TH1D*)GetRawsData(3);
+  TH1D *mCls = (TH1D*)GetRawsData(4);
+  TH2D *mClsTb = (TH2D*)GetRawsData(5);
 
-  // create raw reader TB
+  TH2D *mClsDetAmp = (TH2D*)GetRawsData(6);
+
+  const Int_t baseline = 10;
+
+  // configure the reader
   rawReader->Reset();
   rawReader->SelectEquipment(0, 1024, 1041);
   rawReader->Select("TRD");
-  
-  // AliTRDrawStreamTB::AllowCorruptedData();
-  // AliTRDrawStreamTB::DisableStackNumberChecker();
-  // AliTRDrawStreamTB::DisableStackLinkNumberChecker();
-  // AliTRDrawStreamTB::DisableSkipData();
 
-  //AliTRDrawStreamTB *data = (AliTRDrawStreamTB*)AliTRDrawStreamBase::GetRawStream(rawReader);
-  AliTRDrawStream *data = (AliTRDrawStream *)AliTRDrawStreamBase::GetRawStream(rawReader);  
+  AliTRDrawStream *data = new AliTRDrawStream(rawReader);
 
-  //if (raw->IsA()->GetName())
+  // build data manager  
+  AliTRDdigitsManager *digitsManager;
+  digitsManager = new AliTRDdigitsManager(kTRUE);
+  digitsManager->CreateArrays();
 
+  // error container 
+  const UShort_t kErrorChmb = 1411;
+  UShort_t **fErrorContainer = new UShort_t *[2];
+  fErrorContainer[0] = new UShort_t[kErrorChmb];
+  fErrorContainer[1] = new UShort_t[kErrorChmb];
+  
+  Int_t det = 0;
+  Int_t row, col;
 
-  // import the histograms
-  TH2D *fSMLink[3];
-  for(Int_t i=0; i<3; i++) {
-    fSMLink[i] = (TH2D*)GetRawsData(i);
-    //printf("address = %d\n", fSMLink[i]);
-  }
+  while ((det = data->NextChamber(digitsManager, NULL, fErrorContainer)) >= 0){
     
-  TH1D *fErrorHC =  (TH1D*)GetRawsData(3);
-  TH1D *fErrorMCM = (TH1D*)GetRawsData(4);
-  TH1D *fErrorADC = (TH1D*)GetRawsData(5);
-
+    //printf("DET = %d\n", det);
 
-  // loop over super-modules
-  while (data->NextBuffer()) {
-    
-    //printf("processing next buffer\n");
-    // check sm
-    Int_t sm = rawReader->GetEquipmentId() - 1024;
-    if (sm < 0 || sm > 18) return;
-    
-    // loop over links
-    for (Int_t istack = 0; istack < 5; istack++) {     
-      for (Int_t ilink = 0; ilink < 12; ilink++) {
-       
-       //Int_t det = sm * 30 + istack * 6 + ilink/2;   
+    AliTRDSignalIndex* indexes = digitsManager->GetIndexes(det);
+    if (indexes->HasEntry()) {
       
-       // check if data delivered
-       if (!(data->IsLinkActiveInStack(istack, ilink))) continue;
-       fSMLink[0]->Fill(sm, istack * 12 + ilink);
-       
-       // check if beaf-beaf
-       if (data->GetLinkMonitorError(istack, ilink)) {
-         fSMLink[1]->Fill(sm, istack * 12 + ilink);
-         continue;
-       }
-       
-       // fill histogram with HC header errors
-       Int_t nErrHc = 0;
-       
-       nErrHc = FillBits(fErrorHC, data->GetH0ErrorCode(istack, ilink), 0);
-       if (!nErrHc) fErrorHC->Fill(-3);
-             
-       nErrHc = FillBits(fErrorHC, data->GetH1ErrorCode(istack, ilink), 2);
-       if (!nErrHc) fErrorHC->Fill(-2);
-             
-       nErrHc = FillBits(fErrorHC, data->GetHCErrorCode(istack, ilink), 4);
-       if (!nErrHc) fErrorHC->Fill(-1);
-       
-       // data integrity protection 
-       if (data->GetH0ErrorCode(istack, ilink) > 0) continue;
-       if (data->GetH1ErrorCode(istack, ilink) > 0) continue;
-       
-       fSMLink[2]->Fill(sm, istack * 12 + ilink);      
+      AliTRDarrayADC *digits = (AliTRDarrayADC*) digitsManager->GetDigits(det);
 
-       // loop over MCMs
-       for (Int_t imcm = 0; imcm < data->GetHCMCMmax(istack, ilink); imcm++ ){
-         
-         Int_t nErrMcm = 0;
-       
-         nErrMcm = FillBits(fErrorMCM, data->GetMCMhdErrorCode(istack, ilink, imcm), 0);
-         if (!nErrMcm) fErrorMCM->Fill(-3);
-       
-         nErrMcm = FillBits(fErrorMCM, data->GetMCMADCMaskErrorCode(istack, ilink, imcm), 5);
-         if (!nErrMcm) fErrorMCM->Fill(-2);
-       
-         nErrMcm = FillBits(fErrorMCM, data->GetMCMErrorCode(istack, ilink, imcm), 10);
-         if (!nErrMcm) fErrorMCM->Fill(-1);
+      while(indexes->NextRCIndex(row, col))  {
+
+       mnADC->Fill(det/30, det%30);
        
-         // MCM protection
-         if ( (data->GetMCMhdErrorCode(istack,ilink,imcm)) & 2 ) continue;
+       for(Int_t tb = 0; tb < digits->GetNtime(); tb++) {
+         Int_t value = digits->GetData(row, col, tb);
+         mADC->Fill(value);
+         
+         // simple clusterizer
+         if (col < 1 || col > digits->GetNcol()-2) continue;
+         if (tb < 1 || tb > digits->GetNtime()-2) continue;
+         
+         value -= baseline;
 
-         // loop over ADC chanels      
-         for (Int_t iadc=0; iadc < data->GetADCcount(istack, ilink, imcm); iadc++) {
+         Int_t valueL = digits->GetData(row, col-1, tb) - baseline;
+         if (valueL >= value) continue;
+         
+         Int_t valueR = digits->GetData(row, col+1, tb) - baseline;
+         if (valueR >= value) continue;
+         
+         Int_t valueUp = digits->GetData(row, col-1, tb+1) + 
+           digits->GetData(row, col, tb+1) + digits->GetData(row, col+1, tb+1) - 3 * baseline;
+         if (valueUp < 10) continue;
+         
+         Int_t valueDown = digits->GetData(row, col-1, tb-1) + 
+           digits->GetData(row, col, tb-1) + digits->GetData(row, col+1, tb-1) - 3 * baseline;
+         if (valueDown < 10) continue;
          
-           // fill ADC error bits
-           Int_t nErrAdc = FillBits(fErrorADC, data->GetADCErrorCode(), 0);
-           if (!nErrAdc) fErrorADC->Fill(-1);
+         Int_t valueTot = value + valueL + valueR;
+         if (valueTot < 0) continue;
+
+         mCls->Fill(valueTot);
+         mClsTb->Fill(tb, valueTot);
+         mClsDetAmp->Fill(det, valueTot);
+
+         if (valueTot < 200) {
+           mnCls->Fill(det/30, det%30); 
+           mClsDet->Fill(det/30, det%30, valueTot);
          }
-       } // mcm 
+       
+       }
       }
-    } // link
 
-    //printf("buffer analyzed\n");
+      digitsManager->ClearArrays(det); // do we need this if object will be deleted ??
+    }    
   }
   
-  // clean up
-
-  AliInfo("sucessfull execution of QA for TRD raw data");
-  //printf("sucessfull execution of QA for TRD raw data\n");
+  delete [] fErrorContainer[0];
+  delete [] fErrorContainer[1];
+  delete [] fErrorContainer;
+  fErrorContainer = NULL;
   
-
-  /*
-  // 157
-  // T9 -- T10
-
-  //const Int_t kSM = 18;
-  //const Int_t kROC = 30;
-  const Int_t kROB = 8;
-  //const Int_t kLayer = 6;
-  //const Int_t kStack = 5;
-  const Int_t kMCM = 16;
-  //  const Int_t kADC = 22;
-
-  rawReader->Reset() ; 
-  //AliTRDrawStreamBase::SetRawStreamVersion("TB");
-  AliTRDrawStreamBase *raw = AliTRDrawStreamBase::GetRawStream(rawReader);
-  AliDebug(2,Form("Stream version: %s", raw->IsA()->GetName()));
-
-  while (raw->Next()) {
-
-    GetRawsData(0)->Fill(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]);
-    // ---
-
-    GetRawsData(2)->Fill(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 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);
-  }
-
-  delete raw;
-  */
+  delete digitsManager;  
+  delete data;
 }
 
 //____________________________________________________________________________
@@ -855,7 +821,7 @@ void AliTRDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
   // 
   
   //  Info("MakeRecPoints", "making");
-
   Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster))); 
   TObjArray *clusterArray = new TObjArray(nsize+1000); 
 
@@ -959,6 +925,7 @@ void AliTRDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
        
       //}
     }
+    clusterArray->Delete();
   }
 
   /*