]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCQADataMakerRec.cxx
removes OCDB access during merging by splitting out the functionality
[u/mrichter/AliRoot.git] / TPC / AliTPCQADataMakerRec.cxx
index f49be1a2daae00d937a2a2ecc2f4bc6128fd6d57..80b2741609483d8b4d756a42f9b7bc9edfb95fce 100644 (file)
   Produces the data needed to calculate the quality assurance. 
   All data must be mergeable objects.
   P. Christiansen, Lund, January 2008
-*/
 
-/*
-  Implementation:
+  Updated July 2011:
+  ==================
+
+  Major changes to accomodate updates of general DQM/QA changes to have per
+  trigger histograms (for a given event specie).
+
+  1) One instance of AliTPCdataQA only. (This also solves some old wishes by
+  offline team to use less memory because event the 2d arrays for this object
+  is not used). This now has a new flag for only keeping DQM info event by
+  event! For this reason there is no need for a special DQM reset any more
+  between runs!
+
+  2) Fill the histogram for each event. The histograms are no longer filled
+  from the AliTPCdataQA but per event.
+
+  3) Use profiles for the RAW info. By adding the profiles event by event we
+  get the correct event averages WITHOUT having to normalize in the end!
+  Results should therefore also be directly mergable when that feature will
+  come. (none of the other histograms are merged).
+
+  This means that from the DQM/QA point of view the TPC DQM is now fully
+  standard and should ease future developments.
+
+  Updated June 2010:
+  ==================
 
-  We have chosen to have the histograms as non-persistent meber to
-  allow better debugging. In the copy constructor we then have to
-  assign the pointers to the existing histograms in the copied
-  list. This have been implemented but not tested.
+  The "beautification" of the online DQM histograms have been moved to
+  an amore macro.  
+
+  The per event RAW histograms have been modified in AliTPCdataQA and
+  the copies have therefore also been modified here.
+
+  The AliTPCdataQA can now be configured a bit from here: time bin
+  range (extended default range to 1-1000, event range at start:
+  0-100000, 1000 events per bin). (At least the parameters are not
+  hardcoded:-)
+
+  Implementation:
+  ===============
 
   For the QA of the RAW data we use the class, AliTPCdataQA, from the
   existing TPC Calibration framework (which is more advanced than the
-  standard QA framework) and extract the histograms at the end. This
-  has been tested with zero-suppressed data. The Analyse method of the
-  AliTPCdataQA class is called in the method, EndOfDetectorCycle, and
-  there also: 1d histogram(s) are projected and added to the QA list.
-*/
-
-/*
-  TODO:
-  Sumw2 for RAW histogram(s)?
-  RecPoints and ESD could have many more histograms
+  standard QA framework) and extract the histograms at the end. The
+  Analyse method of the AliTPCdataQA class is called in the method,
+  EndOfDetectorCycle, and there also: 1d histogram(s) are projected
+  and added to the QA list.
 */
 
 #include "AliTPCQADataMakerRec.h"
 #include <TString.h>
 #include <TSystem.h>
 #include <TBox.h>
+#include <TLine.h>
+#include <TAxis.h>
+#include <TH1.h> 
+#include <TProfile.h> 
+#include <TProfile2D.h> 
 
 // --- Standard library ---
 
@@ -65,6 +95,8 @@
 #include "AliTPCClustersRow.h"
 #include "AliTPCclusterMI.h"
 #include "AliSimDigits.h"
+#include <AliDetectorRecoParam.h>
+
 
 ClassImp(AliTPCQADataMakerRec)
 
@@ -72,16 +104,11 @@ ClassImp(AliTPCQADataMakerRec)
 AliTPCQADataMakerRec::AliTPCQADataMakerRec() : 
 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTPC), 
                  "TPC Rec Quality Assurance Data Maker"),
-  fTPCdataQA(NULL),
-  fBeautifyOption(1),   // 0:no beautify, !=0:beautify RAW 
-  fOccHighLimit(1e-4),  // high limit for accepting occupancy values
-  fQmaxLowLimit(8),    // low limit for accepting Qmax values
-  fQmaxHighLimit(40)    // high limit for accepting Qmax values
+fTPCdataQA(NULL),
+fRawFirstTimeBin(1),
+fRawLastTimeBin(1000)
 {
   // ctor
-  fTPCdataQA = new AliTPCdataQA*[AliRecoParam::kNSpecies] ;
-  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
-    fTPCdataQA[specie] = NULL ; 
   
   for(Int_t i = 0; i < 6; i++)
     fMapping[i] = 0;
@@ -91,10 +118,8 @@ AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTPC),
 AliTPCQADataMakerRec::AliTPCQADataMakerRec(const AliTPCQADataMakerRec& qadm) :
   AliQADataMakerRec(),
   fTPCdataQA(NULL),
-  fBeautifyOption(qadm.GetBeautifyOption()),
-  fOccHighLimit(qadm.GetOccHighLimit()),
-  fQmaxLowLimit(qadm.GetQmaxLowLimit()),
-  fQmaxHighLimit(qadm.GetQmaxHighLimit())
+  fRawFirstTimeBin(qadm.GetRawFirstTimeBin()),
+  fRawLastTimeBin(qadm.GetRawLastTimeBin())
 {
   //copy ctor 
   // Does not copy the calibration object, instead InitRaws have to be
@@ -102,18 +127,8 @@ AliTPCQADataMakerRec::AliTPCQADataMakerRec(const AliTPCQADataMakerRec& qadm) :
   SetName((const char*)qadm.GetName()) ; 
   SetTitle((const char*)qadm.GetTitle()); 
 
-  fTPCdataQA = new AliTPCdataQA*[AliRecoParam::kNSpecies] ;
-  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
-    fTPCdataQA[specie] = NULL ; 
-  
   for(Int_t i = 0; i < 6; i++)
     fMapping[i] = 0;
-
-  //
-  // Associate class histogram objects to the copies in the list
-  // Could also be done with the indexes
-  //
-
 }
 
 //__________________________________________________________________
@@ -129,10 +144,7 @@ AliTPCQADataMakerRec& AliTPCQADataMakerRec::operator = (const AliTPCQADataMakerR
 AliTPCQADataMakerRec::~AliTPCQADataMakerRec()
 {
   // Destructor
-  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
-    if ( fTPCdataQA[specie] != NULL )
-      delete fTPCdataQA[specie] ; 
-  delete[] fTPCdataQA; 
+  delete fTPCdataQA; 
 
   for(Int_t i = 0; i < 6; i++) 
     delete fMapping[i];
@@ -142,188 +154,8 @@ AliTPCQADataMakerRec::~AliTPCQADataMakerRec()
 void AliTPCQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
 {
   //Detector specific actions at end of cycle
-  
-  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-    if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
-      continue ; 
-    if(fTPCdataQA[specie] != NULL) { // do the final step of the QA for Raw data
-
-      fTPCdataQA[specie]->Analyse(); // 31/1-08 Analyse is now protected against
-                           //         RAW data files with no TPC data
-
-      SetEventSpecie(AliRecoParam::ConvertIndex(specie)) ; 
-      TH1F * histRawsOccupancy                 = (TH1F*)GetRawsData(kRawsOccupancy) ;
-      TH1F * histRawsOccupancyVsSector         = (TH1F*)GetRawsData(kRawsOccupancyVsSector) ;
-      TH1F * histRawsNClustersPerEventVsSector = (TH1F*)GetRawsData(kRawsNClustersPerEventVsSector) ;
-      TH1F * histRawsQVsSector                 = (TH1F*)GetRawsData(kRawsQVsSector) ;
-      TH1F * histRawsQmaxVsSector              = (TH1F*)GetRawsData(kRawsQmaxVsSector) ;
-      TH1F * histRawsOccupancyVsEvent          = (TH1F*)GetRawsData(kRawsOccupancyVsEvent) ;
-      TH1F * histRawsNclustersVsEvent          = (TH1F*)GetRawsData(kRawsNclustersVsEvent) ;
-      if ( !histRawsOccupancy ||
-          !histRawsOccupancyVsSector ||
-          !histRawsNClustersPerEventVsSector ||
-          !histRawsQVsSector ||
-          !histRawsQmaxVsSector ||
-          !histRawsOccupancyVsEvent ||
-          !histRawsNclustersVsEvent ) {
-        AliError("Something very wrong here, corrupted memory ?????. Please check\n") ; 
-        continue ; 
-      }
-        
-      //Add2RawsList(fTPCdataQA, 0);
-      // get the histograms and add them to the output
-      // 31/8-08 Histogram is only added if the Calibration class 
-      //         receives TPC data 
-      const Int_t eventCounter = fTPCdataQA[specie]->GetEventCounter();
-      if(eventCounter>0) { // some TPC data has been processed
-
-        // Reset histograms and refill them 
-        histRawsOccupancy->Reset();
-        histRawsOccupancyVsSector->Reset();
-        histRawsNClustersPerEventVsSector->Reset();
-        histRawsQVsSector->Reset();
-        histRawsQmaxVsSector->Reset();
-      
-        TH1F* hNormOcc = new TH1F("hNormOcc", 0, 72, 0, 72);
-        hNormOcc->Sumw2();
-        TH1F* hNormNclusters = new TH1F("hNormNclusters", 0, 72, 0, 72);
-        hNormNclusters->Sumw2();
-
-        for (Int_t iSec = 0; iSec < 72; iSec++) {
-       
-          AliTPCCalROC* occupancyROC = 
-          fTPCdataQA[specie]->GetNoThreshold()->GetCalROC(iSec); 
-          AliTPCCalROC* nclusterROC = 
-          fTPCdataQA[specie]->GetNLocalMaxima()->GetCalROC(iSec); 
-          AliTPCCalROC* qROC = 
-          fTPCdataQA[specie]->GetMeanCharge()->GetCalROC(iSec); 
-          AliTPCCalROC* qmaxROC = 
-          fTPCdataQA[specie]->GetMaxCharge()->GetCalROC(iSec); 
-
-          const Int_t nRows = occupancyROC->GetNrows(); 
-          for (Int_t iRow = 0; iRow < nRows; iRow++) {
-
-            const Int_t nPads = occupancyROC->GetNPads(iRow); 
-            for (Int_t iPad = 0; iPad < nPads; iPad++) {
-             
-              histRawsOccupancy->Fill(occupancyROC->GetValue(iRow, iPad));
-              hNormOcc->Fill(iSec);
-              histRawsOccupancyVsSector
-               ->Fill(iSec, occupancyROC->GetValue(iRow, iPad));
-             
-              const Int_t nClusters = TMath::Nint(nclusterROC->GetValue(iRow, iPad));
-             
-              if(nClusters>0) {
-               
-               hNormNclusters->Fill(iSec,nClusters);
-                histRawsNClustersPerEventVsSector->Fill(iSec, nClusters);
-                histRawsQVsSector->Fill(iSec, 
-                                       nClusters*qROC->GetValue(iRow, iPad));
-                histRawsQmaxVsSector->Fill(iSec, 
-                                          nClusters*qmaxROC->GetValue(iRow, iPad));
-              }
-            }
-          }
-        } // end loop over sectors
-      
-       // update event histograms - copy info from TPDdataQA histos
-       TH1F* hQAOccVsEvent = fTPCdataQA[specie]->GetHistOccupancyVsEvent();
-       TH1F* hQANclVsEvent = fTPCdataQA[specie]->GetHistNclustersVsEvent();
-       
-       // the two event histograms should have the same number of bins
-       const Int_t nBins = hQAOccVsEvent->GetXaxis()->GetNbins();
-       for(Int_t bin = 1; bin <= nBins; bin++) {
-         
-         histRawsOccupancyVsEvent->SetBinContent(bin, hQAOccVsEvent->GetBinContent(bin));
-         histRawsNclustersVsEvent->SetBinContent(bin, hQANclVsEvent->GetBinContent(bin));
-       }
-       
-       histRawsOccupancyVsEvent->GetXaxis()->SetRange(hQAOccVsEvent->GetXaxis()->GetFirst(), hQAOccVsEvent->GetXaxis()->GetLast());
-       histRawsNclustersVsEvent->GetXaxis()->SetRange(hQANclVsEvent->GetXaxis()->GetFirst(), hQANclVsEvent->GetXaxis()->GetLast());
-
-        // Normalize histograms
-        histRawsOccupancyVsSector->Divide(hNormOcc);
-        histRawsNClustersPerEventVsSector->Scale(1.0/Float_t(eventCounter));
-        histRawsQVsSector->Divide(hNormNclusters);
-        histRawsQmaxVsSector->Divide(hNormNclusters);
-        delete hNormOcc;
-        delete hNormNclusters;
-
-       if(fBeautifyOption!=0) {
-         // Help make the histogram easier to interpret for the DQM shifter
-         
-         histRawsOccupancyVsSector->ResetBit(AliQAv1::GetQABit());
-         histRawsQmaxVsSector->ResetBit(AliQAv1::GetQABit());
-
-         histRawsOccupancyVsSector->SetMinimum(0.0);
-         if(histRawsOccupancyVsSector->GetMaximum()<1.5*fOccHighLimit)
-           histRawsOccupancyVsSector->SetMaximum(1.5*fOccHighLimit);
-         
-         histRawsQmaxVsSector->SetMinimum(0.0);
-         if(histRawsQmaxVsSector->GetMaximum()<1.5*fQmaxHighLimit)
-           histRawsQmaxVsSector->SetMaximum(1.5*fQmaxHighLimit);
-         
-         Double_t xminOcc = histRawsOccupancyVsSector->GetXaxis()->GetXmin();
-         Double_t xmaxOcc = histRawsOccupancyVsSector->GetXaxis()->GetXmax();
-         Double_t yminOcc = histRawsOccupancyVsSector->GetMinimum();
-         Double_t ymaxOcc = histRawsOccupancyVsSector->GetMaximum();
-         
-         Double_t xminQmax = histRawsQmaxVsSector->GetXaxis()->GetXmin();
-         Double_t xmaxQmax = histRawsQmaxVsSector->GetXaxis()->GetXmax();
-         Double_t yminQmax = histRawsQmaxVsSector->GetMinimum();
-         Double_t ymaxQmax = histRawsQmaxVsSector->GetMaximum();
-         
-         TBox* boxOccOk = new TBox(xminOcc,0,xmaxOcc,fOccHighLimit);
-         boxOccOk->SetFillColor(kGreen);
-         histRawsOccupancyVsSector->GetListOfFunctions()->Add(boxOccOk);
-         
-         TBox* boxQmaxOk = new TBox(xminQmax,fQmaxLowLimit,xmaxQmax,fQmaxHighLimit);
-         boxQmaxOk->SetFillColor(kGreen);
-         histRawsQmaxVsSector->GetListOfFunctions()->Add(boxQmaxOk);
-         
-         
-         for(Int_t bin = 1; bin <= 72; bin++) {
-           
-           if(histRawsOccupancyVsSector->GetBinContent(bin)<=0 ||
-              histRawsOccupancyVsSector->GetBinContent(bin)>fOccHighLimit) {
-             
-             histRawsOccupancyVsSector->SetBit(AliQAv1::GetQABit());
-
-             TBox* boxErr = 
-               new TBox(histRawsOccupancyVsSector->GetXaxis()->GetBinLowEdge(bin), yminOcc,
-                        histRawsOccupancyVsSector->GetXaxis()->GetBinUpEdge(bin), ymaxOcc);
-             boxErr->SetFillColor(kRed);
-             histRawsOccupancyVsSector->GetListOfFunctions()->Add(boxErr);
-           }
-           
-           if(histRawsQmaxVsSector->GetBinContent(bin)<fQmaxLowLimit||
-              histRawsQmaxVsSector->GetBinContent(bin)>fQmaxHighLimit) {
-             
-             // Mark that histogram has error
-             histRawsQmaxVsSector->SetBit(AliQAv1::GetQABit());
-
-             TBox* boxErr = 
-               new TBox(histRawsQmaxVsSector->GetXaxis()->GetBinLowEdge(bin), yminQmax,
-                        histRawsQmaxVsSector->GetXaxis()->GetBinUpEdge(bin), ymaxQmax);
-             boxErr->SetFillColor(kRed);
-             histRawsQmaxVsSector->GetListOfFunctions()->Add(boxErr);
-           }
-         }
-
-         // Now we have to add a copy of the histograms to draw
-         // because the boxes covers the data points
-         TH1F* hOccCopy = new TH1F(*histRawsOccupancyVsSector);
-         hOccCopy->SetOption("SAME P");
-         histRawsOccupancyVsSector->GetListOfFunctions()->Add(hOccCopy);
-
-         TH1F* hQmaxCopy = new TH1F(*histRawsQmaxVsSector);
-         hQmaxCopy->SetOption("SAME P");
-         histRawsQmaxVsSector->GetListOfFunctions()->Add(hQmaxCopy);
-
-       } // end beautify
-      }
-    }
-  }
+  ResetEventTrigClasses();
+
   AliQAChecker::Instance()->Run(AliQAv1::kTPC, task, list) ;  
 }
 
@@ -339,7 +171,7 @@ void AliTPCQADataMakerRec::InitESDs()
     new TH1F("hESDclusters", "N TPC clusters per track; N clusters; Counts",
             160, 0, 160);
   histESDclusters->Sumw2();
-  Add2ESDsList(histESDclusters, KClusters, !expert, image);
+  Add2ESDsList(histESDclusters, kClusters, !expert, image);
 
   TH1F * histESDratio = 
     new TH1F("hESDratio", "Ratio: TPC clusters / findable; Ratio: cluster/findable; Counts",
@@ -352,9 +184,8 @@ void AliTPCQADataMakerRec::InitESDs()
             50, 0, 5);
   histESDpt->Sumw2();
   Add2ESDsList(histESDpt, kPt, !expert, image);
-
-  // This means we are not running DQM so do not beautify
-  SetBeautifyOption(0);
+  //
+  ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -372,76 +203,55 @@ void AliTPCQADataMakerRec::InitRaws()
   const Bool_t saveCorr = kTRUE ; 
   const Bool_t image    = kTRUE ; 
   
-  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-    
-    // It might happen that we will be in this method a few times because
-    // we create all dataQAs at the first call to this method
-    if(fTPCdataQA[specie]!=0) // data QA already created
-      continue;
-    fTPCdataQA[specie] = new AliTPCdataQA(AliRecoParam::ConvertIndex(specie));
+  // It might happen that we will be in this method a few times
+  // (we create the dataQA at the first call to this method)
+  if(!fTPCdataQA) {
+    fTPCdataQA = new AliTPCdataQA();
     LoadMaps(); // Load Altro maps
-    fTPCdataQA[specie]->SetAltroMapping(fMapping); // set Altro mapping
-    fTPCdataQA[specie]->SetRangeTime(100, 920); // set time bin interval 
-//    Add2RawsList(fTPCdataQA, kTPCdataQ, !expert, image, !saveCorrA); // This is used by the AMORE monitoring <------- THIS WILL FAIL (YS)
+    fTPCdataQA->SetAltroMapping(fMapping); // set Altro mapping
+    fTPCdataQA->SetRangeTime(fRawFirstTimeBin, fRawLastTimeBin); // set time bin interval 
+    fTPCdataQA->SetIsDQM(kTRUE);
   }
 
-  TH1F * histRawsOccupancy = 
-    new TH1F("hRawsOccupancy", "Occupancy (all pads); Occupancy; Counts",
-            100, 0, 1);
-  histRawsOccupancy->Sumw2();
-  Add2RawsList(histRawsOccupancy, kRawsOccupancy, expert, image, !saveCorr);
-  
-  TH1F * histRawsOccupancyVsSector = 
-    new TH1F("hRawsOccupancyVsSector", "Occupancy vs sector; Sector; Occupancy",
+  TProfile * histRawsOccupancyVsSector = 
+    new TProfile("hRawsOccupancyVsSector", "Occupancy vs sector; Sector; Occupancy",
             72, 0, 72);
-  histRawsOccupancyVsSector->Sumw2();
   histRawsOccupancyVsSector->SetMarkerStyle(20);
   histRawsOccupancyVsSector->SetOption("P");
   histRawsOccupancyVsSector->SetStats(kFALSE);
-  Add2RawsList(histRawsOccupancyVsSector, kRawsOccupancyVsSector, !expert, image, !saveCorr);
-
-  TH1F * histRawsNClustersPerEventVsSector = 
-    new TH1F("hRawsNClustersPerEventVsSector", "Nclusters per event vs sector; Sector; Nclusters per event",
-            72, 0, 72);
-  histRawsNClustersPerEventVsSector->Sumw2();
-  Add2RawsList(histRawsNClustersPerEventVsSector, kRawsNClustersPerEventVsSector, expert, image, !saveCorr);
-  
-  TH1F * histRawsQVsSector = 
-    new TH1F("hRawsQVsSector", "<Q> vs sector; Sector; <Q>",
+  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib )
+    Add2RawsList(histRawsOccupancyVsSector, kRawsOccupancyVsSector, expert, image, !saveCorr);
+  else
+    Add2RawsList(histRawsOccupancyVsSector, kRawsOccupancyVsSector, !expert, image, !saveCorr);
+    
+  TProfile * histRawsQVsSector = 
+    new TProfile("hRawsQVsSector", "<Q> vs sector; Sector; <Q>",
             72, 0, 72);
-  histRawsQVsSector->Sumw2();
-  Add2RawsList(histRawsQVsSector, kRawsQVsSector, expert, image, !saveCorr);
+  Add2RawsList(histRawsQVsSector, kRawsQVsSector, expert, !image, !saveCorr);
 
-  TH1F * histRawsQmaxVsSector = 
-    new TH1F("hRawsQmaxVsSector", "<Qmax> vs sector; Sector; <Qmax>",
+  TProfile * histRawsQmaxVsSector = 
+    new TProfile("hRawsQmaxVsSector", "<Qmax> vs sector; Sector; <Qmax>",
             72, 0, 72);
-  histRawsQmaxVsSector->Sumw2();
   histRawsQmaxVsSector->SetMarkerStyle(20);
   histRawsQmaxVsSector->SetOption("P");
   histRawsQmaxVsSector->SetStats(kFALSE);
-  Add2RawsList(histRawsQmaxVsSector, kRawsQmaxVsSector, !expert, image, !saveCorr);
-
-  // Get histogram information from data QA to build copy
-  TH1F* hOccHelp = fTPCdataQA[0]->GetHistOccupancyVsEvent();
-  TH1F * histRawsOccupancyVsEvent = 
-    new TH1F("hRawsOccupancyVsEvent", hOccHelp->GetTitle(),
-            hOccHelp->GetXaxis()->GetNbins(),
-            hOccHelp->GetXaxis()->GetXmin(), hOccHelp->GetXaxis()->GetXmax());
-  histRawsOccupancyVsEvent->SetMarkerStyle(20);
-  histRawsOccupancyVsEvent->SetOption("P");
-  histRawsOccupancyVsEvent->SetStats(kFALSE);
-  Add2RawsList(histRawsOccupancyVsEvent, kRawsOccupancyVsEvent, !expert, image, !saveCorr);
-
-  // Get histogram information from data QA to build copy
-  TH1F* hNclHelp = fTPCdataQA[0]->GetHistNclustersVsEvent();
-  TH1F * histRawsNclustersVsEvent = 
-    new TH1F("hRawsNclustersVsEvent", hNclHelp->GetTitle(),
-            hNclHelp->GetXaxis()->GetNbins(),
-            hNclHelp->GetXaxis()->GetXmin(), hNclHelp->GetXaxis()->GetXmax());
-  histRawsNclustersVsEvent->SetMarkerStyle(20);
-  histRawsNclustersVsEvent->SetOption("P");
-  histRawsNclustersVsEvent->SetStats(kFALSE);
-  Add2RawsList(histRawsNclustersVsEvent, kRawsNclustersVsEvent, !expert, image, !saveCorr);
+  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib )
+    Add2RawsList(histRawsQmaxVsSector, kRawsQmaxVsSector, expert, image, !saveCorr);
+  else
+    Add2RawsList(histRawsQmaxVsSector, kRawsQmaxVsSector, !expert, image, !saveCorr);
+
+  TProfile2D * histRawsOccupancy2dVsSector = 
+    new TProfile2D("hRawsOccupancy2dVsSector", "Occupancy vs sector; Sector; Patch",
+                  72, 0, 36, 6, 0, 6);
+  histRawsOccupancy2dVsSector->SetOption("COLZ");
+  histRawsOccupancy2dVsSector->SetStats(kFALSE);
+  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib )
+    Add2RawsList(histRawsOccupancy2dVsSector, kRawsOccupancy2dVsSector, expert, image, !saveCorr);
+  else
+    Add2RawsList(histRawsOccupancy2dVsSector, kRawsOccupancy2dVsSector, !expert, image, !saveCorr);
+    
+  //
+  ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -454,9 +264,8 @@ void AliTPCQADataMakerRec::InitDigits()
              1000, 0, 1000);
   histDigitsADC->Sumw2();
   Add2DigitsList(histDigitsADC, kDigitsADC, !expert, image);
-
-  // This means we are not running DQM so do not beautify
-  SetBeautifyOption(0);
+  //
+  ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
 }
 
 //____________________________________________________________________________ 
@@ -506,9 +315,8 @@ void AliTPCQADataMakerRec::InitRecPoints()
             159, 0, 159);
   histRecPointsRow->Sumw2();
   Add2RecPointsList(histRecPointsRow, kRow, !expert, image);
-
-  // This means we are not running DQM so do not beautify
-  SetBeautifyOption(0);
+  //
+  ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
 }
 
 //____________________________________________________________________________
@@ -530,10 +338,14 @@ void AliTPCQADataMakerRec::MakeESDs(AliESDEvent * esd)
     Int_t nTPCclusters         = track->GetTPCNcls();
     Int_t nTPCclustersFindable = track->GetTPCNclsF();
     if ( nTPCclustersFindable<=0) continue;
-    GetESDsData(KClusters)->Fill(nTPCclusters);
-    GetESDsData(kRatio)->Fill(Float_t(nTPCclusters)/Float_t(nTPCclustersFindable));
-    GetESDsData(kPt)->Fill(track->Pt()); 
+    FillESDsData(kClusters,nTPCclusters);
+    FillESDsData(kRatio,Float_t(nTPCclusters)/Float_t(nTPCclustersFindable));
+    FillESDsData(kPt,track->Pt()); 
   }
+  //
+  IncEvCountCycleESDs();
+  IncEvCountTotalESDs();
+  //
 }
 
 //____________________________________________________________________________
@@ -546,10 +358,47 @@ void AliTPCQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   
   GetRawsData(0); // dummy call to init raw data
   rawReader->Reset() ; 
-  if (! fTPCdataQA[AliRecoParam::AConvert(fEventSpecie)] ) {
-    AliError("Something unexpected here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") ; 
+  if (! fTPCdataQA ) {
+
+    AliError("No TPC data QA (no call to InitRaws?)!!!!") ; 
   } else {  
-    fTPCdataQA[AliRecoParam::AConvert(fEventSpecie)]->ProcessEvent(rawReader);  
+
+    if(fTPCdataQA->GetIsDQM() == kFALSE)
+      AliError("Data QA has to be initialized as DQM!!!!") ; 
+
+    // Fill profile data
+    fTPCdataQA->ResetProfiles();
+    
+    if(fTPCdataQA->ProcessEvent(rawReader)) { // means that TPC data was processed  
+
+      fTPCdataQA->FillOccupancyProfile();
+      
+      // Fill histograms    
+      TObjArray *arrRW = GetMatchingRawsData(kRawsOccupancyVsSector); // all kRawsOccupancyVsSector clones matching to triggers
+      for (int ih=arrRW->GetEntriesFast();ih--;) {
+       TProfile* hRawsOccupancyVsSector = dynamic_cast<TProfile*>(arrRW->At(ih));
+       if (hRawsOccupancyVsSector) hRawsOccupancyVsSector->Add(fTPCdataQA->GetHistOccVsSector());
+      }
+      arrRW = GetMatchingRawsData(kRawsOccupancy2dVsSector);
+      for (int ih=arrRW->GetEntriesFast();ih--;) {
+       TProfile2D* hRawsOccupancy2dVsSector = dynamic_cast<TProfile2D*>(arrRW->At(ih));
+       if (hRawsOccupancy2dVsSector) hRawsOccupancy2dVsSector->Add(fTPCdataQA->GetHistOcc2dVsSector());
+      }
+      arrRW = GetMatchingRawsData(kRawsQVsSector);
+      for (int ih=arrRW->GetEntriesFast();ih--;) {
+       TProfile* hRawsQVsSector = dynamic_cast<TProfile*>(arrRW->At(ih));
+       if (hRawsQVsSector) hRawsQVsSector->Add(fTPCdataQA->GetHistQVsSector());
+      }
+      arrRW = GetMatchingRawsData(kRawsQmaxVsSector);
+      for (int ih=arrRW->GetEntriesFast();ih--;) {
+       TProfile* hRawsQmaxVsSector = dynamic_cast<TProfile*>(arrRW->At(ih));
+       if (hRawsQmaxVsSector) hRawsQmaxVsSector->Add(fTPCdataQA->GetHistQmaxVsSector());
+      }
+      //
+      IncEvCountCycleRaws();
+      IncEvCountTotalRaws();
+      //
+    }
   }
 }
 
@@ -571,34 +420,38 @@ void AliTPCQADataMakerRec::MakeDigits(TTree* digitTree)
       do {
         Float_t dig = digArray->CurrentDigit();
         
-        GetDigitsData(kDigitsADC)->Fill(dig);
+        FillDigitsData(kDigitsADC,dig);
       } while (digArray->Next());    
   }
+  //
+  IncEvCountCycleDigits();
+  IncEvCountTotalDigits();
+  //
 }
 
 //____________________________________________________________________________
 void AliTPCQADataMakerRec::MakeRecPoints(TTree* recTree)
 {
-
-  AliTPCClustersRow clrow;
-  clrow.SetClass("AliTPCclusterMI");
-  clrow.SetArray(0);
-  clrow.GetArray()->ExpandCreateFast(10000);
-  AliTPCClustersRow * pclrow = &clrow;
-  TBranch* branch = recTree->GetBranch("Segment");
   
-  branch->SetAddress(&pclrow);
+  AliTPCClustersRow* clrow = 0x0;
+  TBranch* branch = recTree->GetBranch("Segment");  
+  branch->SetAddress(&clrow);
+  TClonesArray * clarray = 0x0;
 
   const Int_t nEntries = Int_t(recTree->GetEntries());
   for (Int_t i = 0; i < nEntries; i++) {
     
     branch->GetEntry(i);
-    
-    const Int_t nClusters = clrow.GetArray()->GetEntriesFast();
+
+    clarray = clrow->GetArray();
+
+    if (!clarray) continue;
+
+    const Int_t nClusters = clarray->GetEntriesFast();
     for (Int_t icl=0; icl < nClusters; icl++){
       
       AliTPCclusterMI* cluster = 
-       (AliTPCclusterMI*)clrow.GetArray()->At(icl);
+       (AliTPCclusterMI*)clarray->At(icl);
       
       Float_t Qmax = cluster->GetMax();
       Float_t Q    = cluster->GetQ();
@@ -606,25 +459,28 @@ void AliTPCQADataMakerRec::MakeRecPoints(TTree* recTree)
 
       if(cluster->GetDetector()<36) { // IROC (short pads)
 
-       GetRecPointsData(kQmaxShort)->Fill(Qmax);
-       GetRecPointsData(kQShort)->Fill(Q);
+       FillRecPointsData(kQmaxShort,Qmax);
+       FillRecPointsData(kQShort,Q);
       } else { // OROC (medium and long pads)
        row += 63;
        if(cluster->GetRow()<64) { // medium pads
 
-         GetRecPointsData(kQmaxMedium)->Fill(Qmax);
-         GetRecPointsData(kQMedium)->Fill(Q);
+         FillRecPointsData(kQmaxMedium,Qmax);
+         FillRecPointsData(kQMedium,Q);
        } else { // long pads
 
-         GetRecPointsData(kQmaxLong)->Fill(Qmax);
-         GetRecPointsData(kQLong)->Fill(Q);
+         FillRecPointsData(kQmaxLong,Qmax);
+         FillRecPointsData(kQLong,Q);
        }
       }
       
-      GetRecPointsData(kRow)->Fill(row);
+      FillRecPointsData(kRow,row);
     } // end loop over clusters
   } // end loop over tree
-
+  //
+  IncEvCountCycleRecPoints();
+  IncEvCountTotalRecPoints();
+  //
 }
 
 //____________________________________________________________________________