Using a conservative 3% estimate for the K0s signal extraction systematics. Using...
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerQADataMakerRec.cxx
index b330c0b..51794e8 100644 (file)
@@ -1,4 +1,4 @@
-/**************************************************************************
+ /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
  * Author: The ALICE Off-line Project.                                    *
 // --- MUON header files ---
 #include "AliMUONTrackerQADataMakerRec.h"
 
-#include "AliQAv1.h"
+#include "AliCDBManager.h"
+#include "AliCodeTimer.h"
+#include "AliDAQ.h"
+#include "AliESDEvent.h"
+#include "AliESDMuonTrack.h"
+#include "AliLog.h"
+#include "AliMUON2DMap.h"
+#include "AliMUONCalibParamND.h"
+#include "AliMUONCalibrationData.h"
 #include "AliMUONConstants.h"  
 #include "AliMUONDigitMaker.h"
+#include "AliMUONESDInterface.h"
+#include "AliMUONLogger.h"
+#include "AliMUONQADataMakerRec.h"
 #include "AliMUONQAIndices.h"
 #include "AliMUONQAMappingCheck.h"
+#include "AliMUONTrack.h"
+#include "AliMUONTrackParam.h"
+#include "AliMUONTrackerData.h"
 #include "AliMUONTrackerDataMaker.h"
 #include "AliMUONVCluster.h"
 #include "AliMUONVClusterStore.h"
 #include "AliMUONVDigit.h"
+#include "AliMUONVDigit.h"
 #include "AliMUONVDigitStore.h"
-#include "AliMUONVTrackerData.h"
-#include "AliMUONTrack.h"
-#include "AliMUONTrackParam.h"
-#include "AliMUONESDInterface.h"
-#include "AliMUONCalibrationData.h"
 #include "AliMpBusPatch.h"
 #include "AliMpConstants.h"
+#include "AliMpDDL.h"
 #include "AliMpDDLStore.h"
 #include "AliMpDEIterator.h"
 #include "AliMpDEManager.h"
 #include "AliMpDetElement.h"
-
-// --- AliRoot header files ---
-#include "AliCDBManager.h"
-#include "AliESDEvent.h"
-#include "AliESDMuonTrack.h"
-#include "AliLog.h"
+#include "AliMpManuIterator.h"
+#include "AliQAv1.h"
 #include "AliRawReader.h"
-#include "AliCodeTimer.h"
-#include "AliMUONVDigit.h"
-
-// --- ROOT system ---
+#include "AliRawEventHeaderBase.h"
+#include <Riostream.h>
 #include <TH1F.h> 
 #include <TH1I.h> 
 #include <TH2F.h>
-#include <Riostream.h>
 #include <TMath.h>
+#include <TObjArray.h>
+#include <TPaveText.h>
 
 //-----------------------------------------------------------------------------
 /// \class AliMUONTrackerQADataMakerRec
 ///
-/// MUON base class for quality assurance data (histo) maker
+/// Quality assurance data (histo) maker for MUON tracker
+///
+///
+/// Note that all the methods of this class shoud not be called when eventSpecie is AliRecoParam::kCalib !
 ///
 /// \author C. Finck, D. Stocco, L. Aphecetche
 
 ClassImp(AliMUONTrackerQADataMakerRec)
 /// \endcond
            
+namespace
+{
+  Double_t ProtectedSqrt(Double_t x)
+  {
+    return ( x > 0.0 ? TMath::Sqrt(x) : 0.0 );
+  }
+  
+}
+
 //____________________________________________________________________________ 
 AliMUONTrackerQADataMakerRec::AliMUONTrackerQADataMakerRec(AliQADataMakerRec* master) : 
 AliMUONVQADataMakerRec(master),
-fDigitStore(AliMUONVDigitStore::Create("AliMUONDigitStoreV1")),
+fDigitStore(0x0),
 fDigitMaker(new AliMUONDigitMaker(kTRUE)),
 fClusterStore(0x0),
-fTrackerDataMaker(0x0),
-fMappingCheckRecPoints(0x0),
-fCalibrationData(new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun()))
+fCalibrationData(new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun())),
+fLogger(0x0),
+fBusPatchConfig(0x0),
+fBPxmin(0),
+fBPxmax(0),
+fBPnbins(0),
+fTrackerDataMakerArray(0x0),
+fTrackerCalDataArray(0x0),
+fTrackerRecDataArray(0x0),
+fMappingCheckRecPointsArray(0x0)
 {
   /// ctor
 }
@@ -87,14 +112,27 @@ AliMUONTrackerQADataMakerRec::~AliMUONTrackerQADataMakerRec()
   delete fDigitStore;
   delete fDigitMaker;
   delete fClusterStore;
-  delete fTrackerDataMaker;
   delete fCalibrationData;
-  delete fMappingCheckRecPoints;
+  delete fMappingCheckRecPointsArray;
+  if (fLogger)
+  {
+    if ( fLogger->NumberOfEntries() != 0 ) 
+    {
+      AliError("Some unprocessed logged errors are still there... Please check");
+    }
+    delete fLogger;    
+  }
+  delete fTrackerDataMakerArray;
+  delete fTrackerCalDataArray;
+  delete fTrackerRecDataArray;
+  delete fBusPatchConfig;  
 }
 
 //____________________________________________________________________________ 
-void AliMUONTrackerQADataMakerRec::InsertTrackerData(Int_t specie, TObjArray** list,
-                                                     TObject* object, Int_t indexNumber,
+void AliMUONTrackerQADataMakerRec::InsertTrackerData(Int_t specie, 
+                                                     TObjArray** list,
+                                                     TObject* object, 
+                                                     Int_t indexNumber,
                                                      Bool_t replace)
 {
   /// Insert an object to a given list
@@ -103,13 +141,17 @@ void AliMUONTrackerQADataMakerRec::InsertTrackerData(Int_t specie, TObjArray** l
   TObject* o;
   TObject* old(0x0);
   Bool_t alreadyThere(kFALSE);
+  
   while ( ( o = next() ) && !alreadyThere )
   {
     TString classname(o->ClassName());
     if ( classname.Contains("TrackerData") ) 
     {
-      alreadyThere = kTRUE;
-      old = o;
+      if ( !strcmp(object->GetName(),o->GetName()) ) 
+      {
+        alreadyThere = kTRUE;
+        old = o;
+      }
     }
   }
   if ( (!alreadyThere && object) || (alreadyThere && replace) )
@@ -127,366 +169,921 @@ void AliMUONTrackerQADataMakerRec::InsertTrackerData(Int_t specie, TObjArray** l
 void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleESDs(Int_t, TObjArray**)
 {
   /// Normalize ESD histograms
-  
-  if (!GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack)) return;
-  
-  Double_t nTracks = GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack)->GetEntries();
-  if (nTracks <= 0) return;
-  
-  TH1* hESDnClustersPerCh = GetESDsData(AliMUONQAIndices::kESDnClustersPerCh);
-  TH1* hESDnClustersPerDE = GetESDsData(AliMUONQAIndices::kESDnClustersPerDE);
-  TH1* hESDClusterChargePerChMean = GetESDsData(AliMUONQAIndices::kESDClusterChargePerChMean);
-  TH1* hESDClusterChargePerChSigma = GetESDsData(AliMUONQAIndices::kESDClusterChargePerChSigma);
-  TH1* hESDClusterSizePerChMean = GetESDsData(AliMUONQAIndices::kESDClusterSizePerChMean);
-  TH1* hESDClusterSizePerChSigma = GetESDsData(AliMUONQAIndices::kESDClusterSizePerChSigma);
-  TH1* hESDResidualXPerChMean = GetESDsData(AliMUONQAIndices::kESDResidualXPerChMean);
-  TH1* hESDResidualXPerChSigma = GetESDsData(AliMUONQAIndices::kESDResidualXPerChSigma);
-  TH1* hESDResidualYPerChMean = GetESDsData(AliMUONQAIndices::kESDResidualYPerChMean);
-  TH1* hESDResidualYPerChSigma = GetESDsData(AliMUONQAIndices::kESDResidualYPerChSigma);
-  TH1* hESDLocalChi2XPerChMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2XPerChMean);
-  TH1* hESDLocalChi2YPerChMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2YPerChMean);
-  TH1* hESDLocalChi2PerChMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2PerChMean);
-  TH1* hESDClusterChargePerDE = GetESDsData(AliMUONQAIndices::kESDClusterChargePerDE);
-  TH1* hESDClusterSizePerDE = GetESDsData(AliMUONQAIndices::kESDClusterSizePerDE);
-  TH1* hESDResidualXPerDEMean = GetESDsData(AliMUONQAIndices::kESDResidualXPerDEMean);
-  TH1* hESDResidualXPerDESigma = GetESDsData(AliMUONQAIndices::kESDResidualXPerDESigma);
-  TH1* hESDResidualYPerDEMean = GetESDsData(AliMUONQAIndices::kESDResidualYPerDEMean);
-  TH1* hESDResidualYPerDESigma = GetESDsData(AliMUONQAIndices::kESDResidualYPerDESigma);
-  TH1* hESDLocalChi2XPerDEMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2XPerDEMean);
-  TH1* hESDLocalChi2YPerDEMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2YPerDEMean);
-  TH1* hESDLocalChi2PerDEMean = GetESDsData(AliMUONQAIndices::kESDLocalChi2PerDEMean);
-  TH1* hESDnTotClustersPerCh = GetESDsData(AliMUONQAIndices::kESDnTotClustersPerCh);
-  TH1* hESDnTotClustersPerDE = GetESDsData(AliMUONQAIndices::kESDnTotClustersPerDE);
-  TH1* hESDnTotFullClustersPerDE = GetESDsData(AliMUONQAIndices::kESDnTotFullClustersPerDE);
-  TH1* hESDSumClusterChargePerDE = GetESDsData(AliMUONQAIndices::kESDSumClusterChargePerDE);
-  TH1* hESDSumClusterSizePerDE = GetESDsData(AliMUONQAIndices::kESDSumClusterSizePerDE);
-  TH1* hESDSumResidualXPerDE = GetESDsData(AliMUONQAIndices::kESDSumResidualXPerDE);
-  TH1* hESDSumResidualYPerDE = GetESDsData(AliMUONQAIndices::kESDSumResidualYPerDE);
-  TH1* hESDSumResidualX2PerDE = GetESDsData(AliMUONQAIndices::kESDSumResidualX2PerDE);
-  TH1* hESDSumResidualY2PerDE = GetESDsData(AliMUONQAIndices::kESDSumResidualY2PerDE);
-  TH1* hESDSumLocalChi2XPerDE = GetESDsData(AliMUONQAIndices::kESDSumLocalChi2XPerDE);
-  TH1* hESDSumLocalChi2YPerDE = GetESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE);
-  TH1* hESDSumLocalChi2PerDE = GetESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE);
-  
-  hESDnClustersPerCh->Reset();
-  hESDnClustersPerDE->Reset();
-  hESDnClustersPerCh->Add(hESDnTotClustersPerCh, 1./nTracks);
-  hESDnClustersPerDE->Add(hESDnTotClustersPerDE, 1./nTracks);
-  
-  // loop over chambers
-  for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
-    
-    TH1* hESDClusterChargeInCh = GetESDsData(AliMUONQAIndices::kESDClusterChargeInCh+iCh);
-    Double_t sigmaCharge = hESDClusterChargeInCh->GetRMS();
-    hESDClusterChargePerChMean->SetBinContent(iCh+1, hESDClusterChargeInCh->GetMean());
-    hESDClusterChargePerChMean->SetBinError(iCh+1, hESDClusterChargeInCh->GetMeanError());
-    hESDClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
-    hESDClusterChargePerChSigma->SetBinError(iCh+1, hESDClusterChargeInCh->GetRMSError());
-    
-    TH1* hESDClusterSizeInCh = GetESDsData(AliMUONQAIndices::kESDClusterSizeInCh+iCh);
-    Double_t sigmaSize = hESDClusterSizeInCh->GetRMS();
-    hESDClusterSizePerChMean->SetBinContent(iCh+1, hESDClusterSizeInCh->GetMean());
-    hESDClusterSizePerChMean->SetBinError(iCh+1, hESDClusterSizeInCh->GetMeanError());
-    hESDClusterSizePerChSigma->SetBinContent(iCh+1, sigmaSize);
-    hESDClusterSizePerChSigma->SetBinError(iCh+1, hESDClusterSizeInCh->GetRMSError());
-    
-    TH1* hESDResidualXInCh = GetESDsData(AliMUONQAIndices::kESDResidualXInCh+iCh);
-    Double_t sigmaResidualX = hESDResidualXInCh->GetRMS();
-    hESDResidualXPerChMean->SetBinContent(iCh+1, hESDResidualXInCh->GetMean());
-    hESDResidualXPerChMean->SetBinError(iCh+1, hESDResidualXInCh->GetMeanError());
-    hESDResidualXPerChSigma->SetBinContent(iCh+1, sigmaResidualX);
-    hESDResidualXPerChSigma->SetBinError(iCh+1, hESDResidualXInCh->GetRMSError());
-    
-    TH1* hESDResidualYInCh = GetESDsData(AliMUONQAIndices::kESDResidualYInCh+iCh);
-    Double_t sigmaResidualY = hESDResidualYInCh->GetRMS();
-    hESDResidualYPerChMean->SetBinContent(iCh+1, hESDResidualYInCh->GetMean());
-    hESDResidualYPerChMean->SetBinError(iCh+1, hESDResidualYInCh->GetMeanError());
-    hESDResidualYPerChSigma->SetBinContent(iCh+1, sigmaResidualY);
-    hESDResidualYPerChSigma->SetBinError(iCh+1, hESDResidualYInCh->GetRMSError());
-    
-    TH1* hESDLocalChi2XInCh = GetESDsData(AliMUONQAIndices::kESDLocalChi2XInCh+iCh);
-    Double_t sigmaLocalChi2X = hESDLocalChi2XInCh->GetRMS();
-    hESDLocalChi2XPerChMean->SetBinContent(iCh+1, hESDLocalChi2XInCh->GetMean());
-    hESDLocalChi2XPerChMean->SetBinError(iCh+1, hESDLocalChi2XInCh->GetMeanError());
-    
-    TH1* hESDLocalChi2YInCh = GetESDsData(AliMUONQAIndices::kESDLocalChi2YInCh+iCh);
-    Double_t sigmaLocalChi2Y = hESDLocalChi2YInCh->GetRMS();
-    hESDLocalChi2YPerChMean->SetBinContent(iCh+1, hESDLocalChi2YInCh->GetMean());
-    hESDLocalChi2YPerChMean->SetBinError(iCh+1, hESDLocalChi2YInCh->GetMeanError());
-    
-    TH1* hESDLocalChi2InCh = GetESDsData(AliMUONQAIndices::kESDLocalChi2InCh+iCh);
-    Double_t sigmaLocalChi2 = hESDLocalChi2InCh->GetRMS();
-    hESDLocalChi2PerChMean->SetBinContent(iCh+1, hESDLocalChi2InCh->GetMean());
-    hESDLocalChi2PerChMean->SetBinError(iCh+1, hESDLocalChi2InCh->GetMeanError());
-    
-    // loop over DE into chamber iCh
-    AliMpDEIterator it;
-    it.First(iCh);
-    while ( !it.IsDone()) {
+  //
+  Bool_t firstFill = kTRUE;
+  //
+  for (int itc=-1;itc<Master()->GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class
+    //
+    TH1* hESDnClustersPerTr = Master()->GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack, itc);
+    if (! hESDnClustersPerTr) continue;
+    Double_t nTracks = hESDnClustersPerTr->GetEntries();
+    if (nTracks <= 0) continue;
+    //
+    if (firstFill) { AliCodeTimerAuto("",0); firstFill = kFALSE;}
+  
+    TH1* hESDnClustersPerCh = Master()->GetESDsData(AliMUONQAIndices::kESDnClustersPerCh,itc);
+    TH1* hESDnClustersPerDE = Master()->GetESDsData(AliMUONQAIndices::kESDnClustersPerDE,itc);
+    TH1* hESDClusterChargePerChMean = Master()->GetESDsData(AliMUONQAIndices::kESDClusterChargePerChMean,itc);
+    TH1* hESDClusterChargePerChSigma = Master()->GetESDsData(AliMUONQAIndices::kESDClusterChargePerChSigma,itc);
+    TH1* hESDClusterSizePerChMean = Master()->GetESDsData(AliMUONQAIndices::kESDClusterSizePerChMean,itc);
+    TH1* hESDClusterSizePerChSigma = Master()->GetESDsData(AliMUONQAIndices::kESDClusterSizePerChSigma,itc);
+    TH1* hESDResidualXPerChMean = Master()->GetESDsData(AliMUONQAIndices::kESDResidualXPerChMean,itc);
+    TH1* hESDResidualXPerChSigma = Master()->GetESDsData(AliMUONQAIndices::kESDResidualXPerChSigma,itc);
+    TH1* hESDResidualYPerChMean = Master()->GetESDsData(AliMUONQAIndices::kESDResidualYPerChMean,itc);
+    TH1* hESDResidualYPerChSigma = Master()->GetESDsData(AliMUONQAIndices::kESDResidualYPerChSigma,itc);
+    TH1* hESDLocalChi2XPerChMean = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2XPerChMean,itc);
+    TH1* hESDLocalChi2YPerChMean = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2YPerChMean,itc);
+    TH1* hESDLocalChi2PerChMean = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2PerChMean,itc);
+    TH1* hESDClusterChargePerDE = Master()->GetESDsData(AliMUONQAIndices::kESDClusterChargePerDE,itc);
+    TH1* hESDClusterSizePerDE = Master()->GetESDsData(AliMUONQAIndices::kESDClusterSizePerDE,itc);
+    TH1* hESDResidualXPerDEMean = Master()->GetESDsData(AliMUONQAIndices::kESDResidualXPerDEMean,itc);
+    TH1* hESDResidualXPerDESigma = Master()->GetESDsData(AliMUONQAIndices::kESDResidualXPerDESigma,itc);
+    TH1* hESDResidualYPerDEMean = Master()->GetESDsData(AliMUONQAIndices::kESDResidualYPerDEMean,itc);
+    TH1* hESDResidualYPerDESigma = Master()->GetESDsData(AliMUONQAIndices::kESDResidualYPerDESigma,itc);
+    TH1* hESDLocalChi2XPerDEMean = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2XPerDEMean,itc);
+    TH1* hESDLocalChi2YPerDEMean = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2YPerDEMean,itc);
+    TH1* hESDLocalChi2PerDEMean = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2PerDEMean,itc);
+    TH1* hESDnTotClustersPerCh = Master()->GetESDsData(AliMUONQAIndices::kESDnTotClustersPerCh,itc);
+    TH1* hESDnTotClustersPerDE = Master()->GetESDsData(AliMUONQAIndices::kESDnTotClustersPerDE,itc);
+    TH1* hESDnTotFullClustersPerDE = Master()->GetESDsData(AliMUONQAIndices::kESDnTotFullClustersPerDE,itc);
+    TH1* hESDSumClusterChargePerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumClusterChargePerDE,itc);
+    TH1* hESDSumClusterSizePerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumClusterSizePerDE,itc);
+    TH1* hESDSumResidualXPerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumResidualXPerDE,itc);
+    TH1* hESDSumResidualYPerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumResidualYPerDE,itc);
+    TH1* hESDSumResidualX2PerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumResidualX2PerDE,itc);
+    TH1* hESDSumResidualY2PerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumResidualY2PerDE,itc);
+    TH1* hESDSumLocalChi2XPerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumLocalChi2XPerDE,itc);
+    TH1* hESDSumLocalChi2YPerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE,itc);
+    TH1* hESDSumLocalChi2PerDE = Master()->GetESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE,itc);
+    //  
+    if (hESDnClustersPerCh && hESDnTotClustersPerCh) {
+      hESDnClustersPerCh->Reset(); 
+      hESDnClustersPerCh->Add(hESDnTotClustersPerCh, 1./nTracks);
+    }
+    if (hESDnClustersPerDE && hESDnTotClustersPerDE) {
+      hESDnClustersPerDE->Reset();      
+      hESDnClustersPerDE->Add(hESDnTotClustersPerDE, 1./nTracks);
+    }
+    //
+    // loop over chambers
+    for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
+      //
+      double sigmaCharge=0,sigmaSize=0,sigmaResidualX=0,sigmaResidualY=0,sigmaLocalChi2X=0,sigmaLocalChi2Y=0,sigmaLocalChi2=0;
+      //
+      TH1* hESDClusterChargeInCh = Master()->GetESDsData(AliMUONQAIndices::kESDClusterChargeInCh+iCh,itc);
+      if (hESDClusterChargeInCh) {
+       sigmaCharge = hESDClusterChargeInCh->GetRMS();
+       if (hESDClusterChargePerChMean) { 
+         hESDClusterChargePerChMean->SetBinContent(iCh+1, hESDClusterChargeInCh->GetMean());
+         hESDClusterChargePerChMean->SetBinError(iCh+1, hESDClusterChargeInCh->GetMeanError());
+       }
+       if (hESDClusterChargePerChSigma) {
+         hESDClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
+         hESDClusterChargePerChSigma->SetBinError(iCh+1, hESDClusterChargeInCh->GetRMSError());
+       }    
+      }
+      //
+      TH1* hESDClusterSizeInCh = Master()->GetESDsData(AliMUONQAIndices::kESDClusterSizeInCh+iCh,itc);
+      if (hESDClusterSizeInCh) {
+       sigmaSize = hESDClusterSizeInCh->GetRMS();
+       if (hESDClusterSizePerChMean) {
+         hESDClusterSizePerChMean->SetBinContent(iCh+1, hESDClusterSizeInCh->GetMean());
+         hESDClusterSizePerChMean->SetBinError(iCh+1, hESDClusterSizeInCh->GetMeanError());
+       }
+       if (hESDClusterSizePerChSigma) {
+         hESDClusterSizePerChSigma->SetBinContent(iCh+1, sigmaSize);
+         hESDClusterSizePerChSigma->SetBinError(iCh+1, hESDClusterSizeInCh->GetRMSError());
+       }
+      }    
+      //
+      TH1* hESDResidualXInCh = Master()->GetESDsData(AliMUONQAIndices::kESDResidualXInCh+iCh,itc);
+      if (hESDResidualXInCh) {
+       sigmaResidualX = hESDResidualXInCh->GetRMS();
+       if (hESDResidualXPerChMean) {
+         hESDResidualXPerChMean->SetBinContent(iCh+1, hESDResidualXInCh->GetMean());
+         hESDResidualXPerChMean->SetBinError(iCh+1, hESDResidualXInCh->GetMeanError());
+       }
+       if (hESDResidualXPerChSigma) {
+         hESDResidualXPerChSigma->SetBinContent(iCh+1, sigmaResidualX);
+         hESDResidualXPerChSigma->SetBinError(iCh+1, hESDResidualXInCh->GetRMSError());
+       }
+      }
+      //
+      TH1* hESDResidualYInCh = Master()->GetESDsData(AliMUONQAIndices::kESDResidualYInCh+iCh,itc);
+      if (hESDResidualYInCh) {
+       sigmaResidualY = hESDResidualYInCh->GetRMS();
+       if (hESDResidualYPerChMean) {
+         hESDResidualYPerChMean->SetBinContent(iCh+1, hESDResidualYInCh->GetMean());
+         hESDResidualYPerChMean->SetBinError(iCh+1, hESDResidualYInCh->GetMeanError());
+       }
+       if (hESDResidualYPerChSigma) {
+         hESDResidualYPerChSigma->SetBinContent(iCh+1, sigmaResidualY);
+         hESDResidualYPerChSigma->SetBinError(iCh+1, hESDResidualYInCh->GetRMSError());
+       }
+      }
+      //      
+      TH1* hESDLocalChi2XInCh = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2XInCh+iCh,itc);
+      if (hESDLocalChi2XInCh) {
+       sigmaLocalChi2X = hESDLocalChi2XInCh->GetRMS();
+       if (hESDLocalChi2XPerChMean) {
+         hESDLocalChi2XPerChMean->SetBinContent(iCh+1, hESDLocalChi2XInCh->GetMean());
+         hESDLocalChi2XPerChMean->SetBinError(iCh+1, hESDLocalChi2XInCh->GetMeanError());
+       }
+      }
+      //
+      TH1* hESDLocalChi2YInCh = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2YInCh+iCh,itc);
+      if (hESDLocalChi2YInCh) {
+       sigmaLocalChi2Y = hESDLocalChi2YInCh->GetRMS();
+       if (hESDLocalChi2YPerChMean) {
+         hESDLocalChi2YPerChMean->SetBinContent(iCh+1, hESDLocalChi2YInCh->GetMean());
+         hESDLocalChi2YPerChMean->SetBinError(iCh+1, hESDLocalChi2YInCh->GetMeanError());
+       }    
+      }
+      //
+      TH1* hESDLocalChi2InCh = Master()->GetESDsData(AliMUONQAIndices::kESDLocalChi2InCh+iCh,itc);
+      if (hESDLocalChi2InCh) {
+       sigmaLocalChi2 = hESDLocalChi2InCh->GetRMS();
+       if (hESDLocalChi2PerChMean) {
+         hESDLocalChi2PerChMean->SetBinContent(iCh+1, hESDLocalChi2InCh->GetMean());
+         hESDLocalChi2PerChMean->SetBinError(iCh+1, hESDLocalChi2InCh->GetMeanError());
+       }
+      }
+      //
+      // loop over DE into chamber iCh
+      AliMpDEIterator it;
+      it.First(iCh);
+      while ( !it.IsDone()) {
+       
+       Int_t iDE = it.CurrentDEId();
+       
+       Double_t nClusters = hESDnTotClustersPerDE ? hESDnTotClustersPerDE->GetBinContent(iDE+1) : 0;
+       if (nClusters > 1) {
+         
+         if (hESDClusterChargePerDE && hESDSumClusterChargePerDE) {
+           hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1)/nClusters);
+           hESDClusterChargePerDE->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
+         }
+        
+         if (hESDResidualXPerDEMean && hESDResidualXPerDESigma && hESDSumResidualXPerDE && hESDSumResidualX2PerDE) {
+           Double_t meanResX = hESDSumResidualXPerDE->GetBinContent(iDE+1)/nClusters;
+           hESDResidualXPerDEMean->SetBinContent(iDE+1, meanResX);
+           hESDResidualXPerDEMean->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(nClusters));
+           //
+           hESDResidualXPerDESigma->SetBinContent(iDE+1, ProtectedSqrt(hESDSumResidualX2PerDE->GetBinContent(iDE+1)/nClusters - meanResX*meanResX));
+           hESDResidualXPerDESigma->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(2.*nClusters));
+         }
+         //        
+         if (hESDResidualYPerDEMean && hESDResidualYPerDESigma && hESDSumResidualYPerDE && hESDSumResidualY2PerDE) {
+           Double_t meanResY = hESDSumResidualYPerDE->GetBinContent(iDE+1)/nClusters;
+           hESDResidualYPerDEMean->SetBinContent(iDE+1, meanResY);
+           hESDResidualYPerDEMean->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(nClusters));
+           hESDResidualYPerDESigma->SetBinContent(iDE+1, ProtectedSqrt(hESDSumResidualY2PerDE->GetBinContent(iDE+1)/nClusters - meanResY*meanResY));
+           hESDResidualYPerDESigma->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(2.*nClusters));
+         }
+         //
+         if (hESDLocalChi2XPerDEMean && hESDSumLocalChi2XPerDE) {
+           hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1)/nClusters);
+           hESDLocalChi2XPerDEMean->SetBinError(iDE+1, sigmaLocalChi2X/TMath::Sqrt(nClusters));
+         }
+         //
+         if (hESDLocalChi2YPerDEMean && hESDSumLocalChi2YPerDE) {
+           hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1)/nClusters);
+           hESDLocalChi2YPerDEMean->SetBinError(iDE+1, sigmaLocalChi2Y/TMath::Sqrt(nClusters));
+         }
+         //
+         if (hESDLocalChi2PerDEMean && hESDSumLocalChi2PerDE) {
+           hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1)/nClusters);
+           hESDLocalChi2PerDEMean->SetBinError(iDE+1, sigmaLocalChi2/TMath::Sqrt(nClusters));
+         }
+       } 
+       else {
+         if (hESDClusterChargePerDE && hESDClusterChargeInCh && hESDSumClusterChargePerDE) {
+           hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1));
+           hESDClusterChargePerDE->SetBinError(iDE+1, hESDClusterChargeInCh->GetXaxis()->GetXmax());
+         }
+         //
+         if (hESDResidualXPerDEMean && hESDResidualXPerDESigma && hESDSumResidualXPerDE && hESDResidualXInCh) {
+           hESDResidualXPerDEMean->SetBinContent(iDE+1, hESDSumResidualXPerDE->GetBinContent(iDE+1));
+           hESDResidualXPerDEMean->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
+           hESDResidualXPerDESigma->SetBinContent(iDE+1, 0.);
+           hESDResidualXPerDESigma->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
+         }
+         //
+         if (hESDResidualYPerDEMean && hESDResidualYPerDESigma && hESDSumResidualYPerDE && hESDResidualYInCh) {
+           hESDResidualYPerDEMean->SetBinContent(iDE+1, hESDSumResidualYPerDE->GetBinContent(iDE+1));
+           hESDResidualYPerDEMean->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
+           hESDResidualYPerDESigma->SetBinContent(iDE+1, 0.);
+           hESDResidualYPerDESigma->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
+         }
+         //
+         if (hESDLocalChi2XPerDEMean && hESDSumLocalChi2XPerDE && hESDLocalChi2XInCh) {        
+           hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1));
+           hESDLocalChi2XPerDEMean->SetBinError(iDE+1, hESDLocalChi2XInCh->GetXaxis()->GetXmax());
+         }
+         //
+         if (hESDLocalChi2YPerDEMean && hESDSumLocalChi2YPerDE && hESDLocalChi2YInCh) {
+           hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1));
+           hESDLocalChi2YPerDEMean->SetBinError(iDE+1, hESDLocalChi2YInCh->GetXaxis()->GetXmax());
+         }
+         //
+         if (hESDLocalChi2PerDEMean && hESDSumLocalChi2PerDE && hESDLocalChi2InCh) {
+           hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1));
+           hESDLocalChi2PerDEMean->SetBinError(iDE+1, hESDLocalChi2InCh->GetXaxis()->GetXmax());
+         }
+       }
       
-      Int_t iDE = it.CurrentDEId();
+       Double_t nFullClusters = hESDnTotFullClustersPerDE ? hESDnTotFullClustersPerDE->GetBinContent(iDE+1) : 0;
+       if (nFullClusters > 1) {
+         if (hESDClusterSizePerDE && hESDSumClusterSizePerDE) {        
+           hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1)/nFullClusters);
+           hESDClusterSizePerDE->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nFullClusters));
+         }
+       }
+       else {
+         if (hESDClusterSizePerDE && hESDSumClusterSizePerDE) {
+           hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1));
+           hESDClusterSizePerDE->SetBinError(iDE+1, hESDClusterSizeInCh->GetXaxis()->GetXmax());
+         }
+       }
+       
+       it.Next();
+      } // while
       
-      Double_t nClusters = hESDnTotClustersPerDE->GetBinContent(iDE+1);
-      if (nClusters > 1) {
-        
-        hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1)/nClusters);
-        hESDClusterChargePerDE->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
-        
-        Double_t meanResX = hESDSumResidualXPerDE->GetBinContent(iDE+1)/nClusters;
-        hESDResidualXPerDEMean->SetBinContent(iDE+1, meanResX);
-        hESDResidualXPerDEMean->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(nClusters));
-        hESDResidualXPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualX2PerDE->GetBinContent(iDE+1)/nClusters - meanResX*meanResX));
-        hESDResidualXPerDESigma->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(2.*nClusters));
-        
-        Double_t meanResY = hESDSumResidualYPerDE->GetBinContent(iDE+1)/nClusters;
-        hESDResidualYPerDEMean->SetBinContent(iDE+1, meanResY);
-        hESDResidualYPerDEMean->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(nClusters));
-        hESDResidualYPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualY2PerDE->GetBinContent(iDE+1)/nClusters - meanResY*meanResY));
-        hESDResidualYPerDESigma->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(2.*nClusters));
-        
-        hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1)/nClusters);
-        hESDLocalChi2XPerDEMean->SetBinError(iDE+1, sigmaLocalChi2X/TMath::Sqrt(nClusters));
-        
-        hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1)/nClusters);
-        hESDLocalChi2YPerDEMean->SetBinError(iDE+1, sigmaLocalChi2Y/TMath::Sqrt(nClusters));
-        
-        hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1)/nClusters);
-        hESDLocalChi2PerDEMean->SetBinError(iDE+1, sigmaLocalChi2/TMath::Sqrt(nClusters));
-        
-      } else {
-        
-        hESDClusterChargePerDE->SetBinContent(iDE+1, hESDSumClusterChargePerDE->GetBinContent(iDE+1));
-        hESDClusterChargePerDE->SetBinError(iDE+1, hESDClusterChargeInCh->GetXaxis()->GetXmax());
-        
-        hESDResidualXPerDEMean->SetBinContent(iDE+1, hESDSumResidualXPerDE->GetBinContent(iDE+1));
-        hESDResidualXPerDEMean->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
-        hESDResidualXPerDESigma->SetBinContent(iDE+1, 0.);
-        hESDResidualXPerDESigma->SetBinError(iDE+1, hESDResidualXInCh->GetXaxis()->GetXmax());
-        
-        hESDResidualYPerDEMean->SetBinContent(iDE+1, hESDSumResidualYPerDE->GetBinContent(iDE+1));
-        hESDResidualYPerDEMean->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
-        hESDResidualYPerDESigma->SetBinContent(iDE+1, 0.);
-        hESDResidualYPerDESigma->SetBinError(iDE+1, hESDResidualYInCh->GetXaxis()->GetXmax());
-        
-        hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1));
-        hESDLocalChi2XPerDEMean->SetBinError(iDE+1, hESDLocalChi2XInCh->GetXaxis()->GetXmax());
-        
-        hESDLocalChi2YPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2YPerDE->GetBinContent(iDE+1));
-        hESDLocalChi2YPerDEMean->SetBinError(iDE+1, hESDLocalChi2YInCh->GetXaxis()->GetXmax());
-        
-        hESDLocalChi2PerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2PerDE->GetBinContent(iDE+1));
-        hESDLocalChi2PerDEMean->SetBinError(iDE+1, hESDLocalChi2InCh->GetXaxis()->GetXmax());
-        
+    } // iCh loop
+
+  } // trigger classes loop
+
+}
+  
+//____________________________________________________________________________ 
+void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRecPoints(Int_t specie, TObjArray** list)
+{
+  /// Normalize RecPoints histograms
+  //
+  Bool_t firstFill=kTRUE, needIns0=kTRUE, needIns1=kTRUE;
+  //
+  for (int itc=-1;itc<Master()->GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class 
+
+    TH1* hTrackerClusterChargePerChMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChMean,itc);
+    if (!hTrackerClusterChargePerChMean) continue;
+    //
+    if (firstFill) { AliCodeTimerAuto("",0); firstFill = kFALSE;}
+
+    TH1* hTrackerClusterChargePerChSigma = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChSigma,itc);
+    TH1* hTrackerClusterMultiplicityPerChMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChMean,itc);
+    TH1* hTrackerClusterMultiplicityPerChSigma = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChSigma,itc);
+    TH1* hTrackerClusterChargePerDEMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDEMean,itc);
+    TH1* hTrackerClusterMultiplicityPerDEMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDEMean,itc);
+  
+    // loop over chambers
+    for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
+    
+      TH1* hTrackerClusterChargePerChamber = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChamber+iCh,itc);
+      Double_t sigmaCharge = 0;
+      if (hTrackerClusterChargePerChamber) {
+       sigmaCharge = hTrackerClusterChargePerChamber->GetRMS();
+       hTrackerClusterChargePerChMean->SetBinContent(iCh+1, hTrackerClusterChargePerChamber->GetMean());
+       hTrackerClusterChargePerChMean->SetBinError(iCh+1,   hTrackerClusterChargePerChamber->GetMeanError());
+       //
+       if (hTrackerClusterChargePerChSigma) {
+         hTrackerClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
+         hTrackerClusterChargePerChSigma->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetRMSError());
+       }
+      }
+      //
+      TH1* hTrackerClusterMultiplicityPerChamber = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+iCh,itc);
+      Double_t sigmaSize = 0;
+      if (hTrackerClusterMultiplicityPerChamber) {
+       sigmaSize = hTrackerClusterMultiplicityPerChamber->GetRMS();
+       if (hTrackerClusterMultiplicityPerChMean) {
+         hTrackerClusterMultiplicityPerChMean->SetBinContent(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMean());
+         hTrackerClusterMultiplicityPerChMean->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMeanError());
+       }
+       if (hTrackerClusterMultiplicityPerChSigma) {
+         hTrackerClusterMultiplicityPerChSigma->SetBinContent(iCh+1, sigmaSize);
+         hTrackerClusterMultiplicityPerChSigma->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetRMSError());
+       }
       }
+      //
+      // loop over DE into chamber iCh
+      AliMpDEIterator it;
+      it.First(iCh);
+      while ( !it.IsDone()) {
       
-      Double_t nFullClusters = hESDnTotFullClustersPerDE->GetBinContent(iDE+1);
-      if (nFullClusters > 1) {
-        
-        hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1)/nFullClusters);
-        hESDClusterSizePerDE->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nFullClusters));
-        
-      } else {
+       Int_t iDE = it.CurrentDEId();
+      
+       TH1* hTrackerClusterChargePerDE = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDE+iDE,itc);
+       if (hTrackerClusterChargePerDEMean && hTrackerClusterChargePerDE) {
+         hTrackerClusterChargePerDEMean->SetBinContent(iDE+1, hTrackerClusterChargePerDE->GetMean());
+         Double_t nClusters = hTrackerClusterChargePerDE->GetEntries();
+         if (nClusters > 1) hTrackerClusterChargePerDEMean->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
+         else hTrackerClusterChargePerDEMean->SetBinError(iDE+1, hTrackerClusterChargePerChamber ? 
+                                                          hTrackerClusterChargePerChamber->GetXaxis()->GetXmax() : 0);
+       }
+       TH1* hTrackerClusterMultiplicityPerDE = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+iDE,itc);
+       if (hTrackerClusterMultiplicityPerDEMean && hTrackerClusterMultiplicityPerDE) {
+         hTrackerClusterMultiplicityPerDEMean->SetBinContent(iDE+1, hTrackerClusterMultiplicityPerDE->GetMean());
+         Double_t nClusters = hTrackerClusterMultiplicityPerDE->GetEntries();
+         if (nClusters > 1) hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nClusters));
+         else hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, hTrackerClusterMultiplicityPerChamber ? 
+                                                                hTrackerClusterMultiplicityPerChamber->GetXaxis()->GetXmax() : 0);
+       }
+       it.Next();
+      }
+    }
+  
+    if (needIns0 && MappingCheckRecPoints(specie) ) { // RS: I guess this should not be in the itc loop, do this only once
+      InsertTrackerData(specie,list,MappingCheckRecPoints(specie)->CreateData("RecPoints"),AliMUONQAIndices::kTrackerRecPoints,kTRUE);    
+      needIns0 = kFALSE;
+    }
+    
+    if ( TrackerRecData(specie) ) {
+      /// put the trackerdata in the pipeline
+      if (needIns1) { // RS: I guess this should not be in the itc loop, do this only once
+       InsertTrackerData(specie,list,TrackerRecData(specie),AliMUONQAIndices::kTrackerData);
+       needIns1 = kFALSE;
+      }
+      TH1* hbp = GetRecPointsData(AliMUONQAIndices::kTrackerBusPatchOccupancy,itc);
+      TH1* hnevents = GetRecPointsData(AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed,itc);
+      TH1* hddl = GetRecPointsData(AliMUONQAIndices::kTrackerDDLOccupancy,itc);
+      TH1* hddlevents = GetRecPointsData(AliMUONQAIndices::kTrackerDDLNofEventsUsed,itc);
+    
+      if (itc==-1 && (!hbp || !hnevents || !hddl || !hddlevents)) { //RS: produce error only for trigger-blind class
+       AliError(Form("Missing some histograms : cannot work : hbp=%p hnevents=%p hddl=%p hddlevents=%p",hbp,hnevents,hddl,hddlevents));
+       continue; // return; // RS: the histos might be booked for some trigger class only
+      }
+      //
+      ProjectTrackerData(TrackerRecData(specie),*hbp,*hnevents,*hddl,*hddlevents);    
+    }
+    else {
+      AliError(Form("TrackerRecData is null for specie %s",AliRecoParam::GetEventSpecieName(specie)));
+    }
+  } //  RS: loop over eventual clones per trigger class
+}
+
+//____________________________________________________________________________ 
+void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleDigits(Int_t specie, TObjArray** list)
+{
+  /// create digits histograms in digits subdir
+  
+  if ( TrackerCalData(specie) )
+  {
+    AliCodeTimerAuto("",0);
+    
+    /// put the trackerdata in the pipeline
+    InsertTrackerData(specie,list,TrackerCalData(specie),AliMUONQAIndices::kTrackerData);
+    //
+    for (int itc=-1;itc<Master()->GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class 
+      //    
+      TH1* hbp = GetDigitsData(AliMUONQAIndices::kTrackerBusPatchOccupancy, itc);
+      TH1* hnevents = GetDigitsData(AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed, itc);
+      TH1* hddl = GetDigitsData(AliMUONQAIndices::kTrackerDDLOccupancy, itc);
+      TH1* hddlevents = GetDigitsData(AliMUONQAIndices::kTrackerDDLNofEventsUsed, itc);
+    
+      if ( (!hbp || !hnevents || !hddl || !hddlevents) ) 
+      { 
+        if (itc==-1)
+        {
+          // report error only for trigger-blind class
+          AliError(Form("Missing some histograms : cannot work : hbp=%p hnevents=%p hddl=%p hddlevents=%p",hbp,hnevents,hddl,hddlevents));
+          continue; //return; // RS
+        }
+        else
+        {
+          continue;
+        }
+      }
+      //    
+      ProjectTrackerData(TrackerCalData(specie), *hbp,*hnevents,*hddl,*hddlevents);    
+    } //  RS: loop over eventual clones per trigger class 
+  }
+}
+
+//____________________________________________________________________________ 
+AliMUONQADataMakerRec* AliMUONTrackerQADataMakerRec::Master() const
+{
+  /// Get our master
+  return static_cast<AliMUONQADataMakerRec*>(fMaster); 
+}
+
+//____________________________________________________________________________ 
+void AliMUONTrackerQADataMakerRec::ProjectTrackerData(AliMUONVTrackerData* data, 
+                                                      TH1& hbp,
+                                                      TH1& hnevents,
+                                                      TH1& hddl,
+                                                      TH1& hddlevents)
+{
+  /// Project tracker data into shifter-friendly histograms
+  
+  AliCodeTimerAuto(Form("%s",data->Name()),0);
+  
+  /// project the tracerdata into buspatch occupancies (for the experts)
+  hbp.Reset();
+  hbp.SetStats(kFALSE);
+  
+  TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
+  AliMpBusPatch* bp(0x0);
+  Int_t occDim = 2;
+  
+  while ( ( bp = static_cast<AliMpBusPatch*>(nextBP())) )
+  {
+    Int_t busPatchId = bp->GetId();
+    Int_t bin = hbp.FindBin(busPatchId);
+    if ( data->HasBusPatch(busPatchId) )
+    {
+      hbp.SetBinContent(bin,data->BusPatch(busPatchId,occDim)*100.0); // occupancy, in percent
+    }
+  }
+  
+  /// log the readout errors (for the shifter)
+  hnevents.Reset();
+  hnevents.SetStats(kFALSE);
+  hnevents.SetBinContent(1,data->NumberOfEvents(-1));
+  
+  /// project tracker data into DDL occupancies (for the shifter)
+  hddl.Reset();
+  hddl.SetStats(kFALSE);
+  hddlevents.Reset();
+  hddlevents.SetStats(kFALSE);
+  
+  const Int_t nddls = AliDAQ::NumberOfDdls("MUONTRK");
+  const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
+  
+  for ( Int_t iddl = 0; iddl < nddls; ++iddl )
+  {
+    AliMpDDL* ddl = AliMpDDLStore::Instance()->GetDDL(iddl);
+    
+    Int_t ddlId = offset + ddl->GetId();
+    Int_t npads = 0;
+    
+    Int_t nevents = data->NumberOfEvents(iddl);
+    
+    hddlevents.Fill(ddlId,nevents);
+    
+    Double_t occ(0.0);
+    
+    if ( nevents > 0 )
+    {
+      for ( Int_t ide = 0; ide < ddl->GetNofDEs(); ++ide )
+      {
+        Int_t de = ddl->GetDEId(ide);
         
-        hESDClusterSizePerDE->SetBinContent(iDE+1, hESDSumClusterSizePerDE->GetBinContent(iDE+1));
-        hESDClusterSizePerDE->SetBinError(iDE+1, hESDClusterSizeInCh->GetXaxis()->GetXmax());
+        npads += TMath::Nint(data->DetectionElement(de,3));
         
+        occ +=  data->DetectionElement(de,4);
       }
       
-      it.Next();
+      if ( npads > 0 )
+      {
+        occ = occ/npads/nevents;
+      }
+      else 
+      {
+        occ = 0.0;
+      }
     }
-
+    
+    hddl.Fill(ddlId,100.0*occ); // occ in percent
   }
+  
+  TPaveText* text = new TPaveText(0.50,0.8,0.9,0.9,"NDC");
+  
+  text->AddText(Form("MCH RUN %d - %d events",AliCDBManager::Instance()->GetRun(),data->NumberOfEvents(-1)));
 
+  hddl.GetListOfFunctions()->Add(text);
 }
+
+//____________________________________________________________________________ 
+void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRaws(Int_t specie, TObjArray** list)
+{
+  /// create Raws histograms in Raws subdir
   
+  if ( TrackerDataMaker(specie) && TrackerDataMaker(specie)->Data() ) 
+  {
+    AliCodeTimerAuto("",0);
+    
+    /// put the trackerdata in the pipeline
+    InsertTrackerData(specie,list,TrackerDataMaker(specie)->Data(),AliMUONQAIndices::kTrackerData);
+    TrackerDataMaker(specie)->SetOwnerOfData(kFALSE); // now that it's attached to list, list will take care of the deletion
+    //    
+    for (int itc=-1;itc<Master()->GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class
+
+      TH1* hbp = GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy, itc);
+      TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed, itc);
+      TH1* hddl = GetRawsData(AliMUONQAIndices::kTrackerDDLOccupancy, itc);
+      TH1* hddlevents = GetRawsData(AliMUONQAIndices::kTrackerDDLNofEventsUsed, itc);
+      //
+      if (!hbp || !hnevents || !hddl || !hddlevents) {
+       if (itc==-1) AliError(Form("Missing some histograms : cannot work : hbp=%p hnevents=%p hddl=%p hddlevents=%p",hbp,hnevents,hddl,hddlevents));
+       continue; // return; // RS
+      }
+      //
+      ProjectTrackerData(TrackerDataMaker(specie)->Data(), *hbp,*hnevents,*hddl,*hddlevents);
+      //
+      FillReadoutStatus(*fLogger,TrackerDataMaker(specie)->Data(), itc);      
+    } // RS: loop over eventual clones per trigger class
+    //
+  }    
+}
+
 //____________________________________________________________________________ 
-void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRecPoints(Int_t specie, TObjArray** list)
+void AliMUONTrackerQADataMakerRec::FillReadoutStatus(AliMUONLogger& log, AliMUONVTrackerData* data, Int_t trigCl)
 {
-  /// Normalize RecPoints histograms
+  // RS: I am not sure if this part is valid for looping over trigger classes (loggers are not cloned)
+  if (trigCl!=-1) return; // For the moment only trigCl==-1 will be processed (i.e. trigger-blind histos)
+
+  log.ResetItr();
+
+  TString msg;
+  Int_t occurence;
+  
+  TH1* hparity = GetRawsData(AliMUONQAIndices::kTrackerBusPatchParityErrors, trigCl);
+
+  TH1* htoken = GetRawsData(AliMUONQAIndices::kTrackerBusPatchTokenLostErrors, trigCl);
+
+  TH1* hpadding = GetRawsData(AliMUONQAIndices::kTrackerBusPatchPaddingErrors, trigCl);
+  
+  TH1* hrostatus = GetRawsData(AliMUONQAIndices::kTrackerReadoutStatus, trigCl);
+    
+  TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofPhysicsEventsSeen, trigCl);
+
+  //
+  if (!hparity || !htoken || !hpadding || !hrostatus || !hnevents) return;
+    
+  Int_t nevents = TMath::Nint(hnevents->GetBinContent(1));
+  
+  if ( !nevents ) 
+  {
+    TPaveText* text = new TPaveText(0,0,0.99,0.99,"NDC");
+    text->AddText("FATAL : 0 event seen ? That's NOT normal...");
+    text->SetFillColor(2); // red = FATAL
+    hrostatus->GetListOfFunctions()->Delete();
+    hrostatus->GetListOfFunctions()->Add(text);
+    return;
+  }
+  
+  hparity->Reset();
+  htoken->Reset();
+  hpadding->Reset();
+  hrostatus->Reset();
   
-  if (!GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChMean)) return;
-  
-  TH1* hTrackerClusterChargePerChMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChMean);
-  TH1* hTrackerClusterChargePerChSigma = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChSigma);
-  TH1* hTrackerClusterMultiplicityPerChMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChMean);
-  TH1* hTrackerClusterMultiplicityPerChSigma = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChSigma);
-  TH1* hTrackerClusterChargePerDEMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDEMean);
-  TH1* hTrackerClusterMultiplicityPerDEMean = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDEMean);
-  
-  // loop over chambers
-  for (Int_t iCh = 0; iCh < AliMUONConstants::NTrackingCh(); iCh++) {
-    
-    TH1* hTrackerClusterChargePerChamber = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChamber+iCh);
-    Double_t sigmaCharge = hTrackerClusterChargePerChamber->GetRMS();
-    hTrackerClusterChargePerChMean->SetBinContent(iCh+1, hTrackerClusterChargePerChamber->GetMean());
-    hTrackerClusterChargePerChMean->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetMeanError());
-    hTrackerClusterChargePerChSigma->SetBinContent(iCh+1, sigmaCharge);
-    hTrackerClusterChargePerChSigma->SetBinError(iCh+1, hTrackerClusterChargePerChamber->GetRMSError());
-    
-    TH1* hTrackerClusterMultiplicityPerChamber = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+iCh);
-    Double_t sigmaSize = hTrackerClusterMultiplicityPerChamber->GetRMS();
-    hTrackerClusterMultiplicityPerChMean->SetBinContent(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMean());
-    hTrackerClusterMultiplicityPerChMean->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetMeanError());
-    hTrackerClusterMultiplicityPerChSigma->SetBinContent(iCh+1, sigmaSize);
-    hTrackerClusterMultiplicityPerChSigma->SetBinError(iCh+1, hTrackerClusterMultiplicityPerChamber->GetRMSError());
-    
-    // loop over DE into chamber iCh
-    AliMpDEIterator it;
-    it.First(iCh);
-    while ( !it.IsDone()) {
+  /////////////////////////////////////////////////////////////////
+  /// Start by counting the number of errors
+  /////////////////////////////////////////////////////////////////
+  
+  while ( log.Next(msg,occurence) )
+  {
+    AliDebug(1,Form("msg=%s occurence=%d",msg.Data(),occurence));
+             
+    if ( msg.Contains("token") )
+    {
+      Int_t dsp(-1),iddl(-1),ecode(-1);
       
-      Int_t iDE = it.CurrentDEId();
+      sscanf(msg.Data(),"Lost token error detected with address 0x%10X of DDL %10d and code %10d.",
+             &dsp,&iddl,&ecode);
+      Int_t localBP = ((dsp >> 16)- 4)*5 + 1;
+      Int_t buspatch = localBP + iddl*100;
       
-      TH1* hTrackerClusterChargePerDE = GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDE+iDE);
-      hTrackerClusterChargePerDEMean->SetBinContent(iDE+1, hTrackerClusterChargePerDE->GetMean());
-      Double_t nClusters = hTrackerClusterChargePerDE->GetEntries();
-      if (nClusters > 1) hTrackerClusterChargePerDEMean->SetBinError(iDE+1, sigmaCharge/TMath::Sqrt(nClusters));
-      else hTrackerClusterChargePerDEMean->SetBinError(iDE+1, hTrackerClusterChargePerChamber->GetXaxis()->GetXmax());
+      // Let's try to get all the suspected bus patches (i.e. one full FRT, as currently
+      // we don't have more precise information to locate the faulty bus patch(es)).
       
-      TH1* hTrackerClusterMultiplicityPerDE = GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+iDE);
-      hTrackerClusterMultiplicityPerDEMean->SetBinContent(iDE+1, hTrackerClusterMultiplicityPerDE->GetMean());
-      nClusters = hTrackerClusterMultiplicityPerDE->GetEntries();
-      if (nClusters > 1) hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, sigmaSize/TMath::Sqrt(nClusters));
-      else hTrackerClusterMultiplicityPerDEMean->SetBinError(iDE+1, hTrackerClusterMultiplicityPerChamber->GetXaxis()->GetXmax());
+      AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(buspatch,kFALSE);
+      if (bp)
+      {
+        Int_t frt = bp->GetFrtId();
+        AliMpDDL* ddl = AliMpDDLStore::Instance()->GetDDL(bp->GetDdlId());
+        Int_t* b = new Int_t[ddl->GetMaxDsp()];
+        ddl->GetBusPerDsp(b);
+        Int_t nbus(0);
+        for ( Int_t i = 0; i < ddl->GetNofFrts() && !nbus; ++i ) 
+        {
+          if ( ddl->GetFrtId(i) == frt ) 
+          {
+            nbus = b[i];
+          }
+        }
+        if (nbus<=0) 
+        {
+          AliError("GOT NBUS<=0 ! THAT IS BAD ! CHECK !");
+          nbus=1;
+        }
+        delete[] b;
       
-      it.Next();
+        while (nbus) {
+          htoken->Fill(buspatch+nbus-1,occurence);
+          --nbus;
+        }
+      }
+      hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofTokenLostErrors,occurence);
+    }
+    
+    if ( msg.Contains("Parity") )
+    {
+      Int_t buspatch;
+      sscanf(msg.Data(),"Parity error in buspatch %d (0x%X).",&buspatch,&buspatch);
+      hparity->Fill(buspatch,occurence);      
+      hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofParityErrors,occurence);
+    }
+    
+    if ( msg.Contains("Glitch") ) 
+    {
+      hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofGlitchErrors,occurence);      
+    }
+    
+    if ( msg.Contains("Padding") )
+    {
+      Int_t block, dsp, buspatch;      
+      sscanf(msg.Data(),"Padding word error for iBlock %d, iDsp %d, iBus %d.",&block,&dsp,&buspatch);
+      hpadding->Fill(buspatch,occurence);
+      hrostatus->Fill(1.0*AliMUONQAIndices::kTrackerRawNofPaddingErrors,occurence);      
     }
   }
   
-  if ( fMappingCheckRecPoints ) InsertTrackerData(specie,list,fMappingCheckRecPoints->CreateData("RecPoints"),AliMUONQAIndices::kTrackerRecPoints,kTRUE);
-}
+  /////////////////////////////////////////////////////////////////
+  ///
+  /// Then make the status about number of missing bus patches
+  ///
+  /////////////////////////////////////////////////////////////////
 
+  Int_t nofBusPatchesNotInConfig(0);
+    
+  for ( int i = 1; i <= fBusPatchConfig->GetNbinsX(); ++i )
+  {
+    Double_t buspatchId = fBusPatchConfig->GetBinCenter(i);
+    if ( TMath::Nint(buspatchId) != i ) 
+    {
+      AliError(Form("buspathId=%e i=%d",buspatchId,i));
+    }
+    Double_t content = fBusPatchConfig->GetBinContent(i);
+    
+    if ( content <= 0. /* no content */
+        && 
+        AliMpDDLStore::Instance()->GetBusPatch(i,kFALSE) /* but a valid bus patch */ )
+    {
+      ++nofBusPatchesNotInConfig;
+    }    
+  }
+  
+  Double_t nbuspatches = fBusPatchConfig->GetEntries();
+  
+  Int_t bin = hrostatus->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromConfig);
+  hrostatus->SetBinContent(bin,nofBusPatchesNotInConfig*nevents/nbuspatches);
+  
+  Double_t nofBusPatchesNotInData(0);
+  
+  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
+  AliMpBusPatch* bp;
+  
+  while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) )
+  {
+    if ( !data->HasBusPatch(bp->GetId()) ) ++nofBusPatchesNotInData;
+  }
+  
+  bin = hrostatus->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromDataStream);
+  hrostatus->SetBinContent(bin,nofBusPatchesNotInData*nevents/nbuspatches);
+}
 
 //____________________________________________________________________________ 
-void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRaws(Int_t specie, TObjArray** list)
+void AliMUONTrackerQADataMakerRec::FillEventSize(AliRawReader* rawReader)
 {
-  /// create Raws histograms in Raws subdir
+  /// Fill event size histogram(s)
+  // RS: substituted explicit histo filling by QA framework filling accounting for cloned histos
   
-  if ( !GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy) ) return;
-
-  if ( fTrackerDataMaker ) 
+  FillRawsData(AliMUONQAIndices::kTrackerNofPhysicsEventsSeen,0.0);
+  
+  Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
+  
+  for ( int i = 0; i < AliDAQ::NumberOfDdls("MUONTRK"); ++i )
   {
-    InsertTrackerData(specie,list,fTrackerDataMaker->Data(),AliMUONQAIndices::kTrackerData);
+    rawReader->Reset();
+    rawReader->Select("MUONTRK",i,i);
+    if (rawReader->ReadHeader() )
+    {
+      UInt_t ddlsize = rawReader->GetEquipmentSize();
+      FillRawsData(AliMUONQAIndices::kTrackerDDLEventSize,i+offset,ddlsize);
+      FillRawsData(AliMUONQAIndices::kTrackerDDLNofEventsSeen,i+offset);
+    }      
+  }
+  rawReader->Reset();
+}
 
-    TH1* hbp = GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
-    hbp->Reset();
-    TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
+//____________________________________________________________________________ 
+void AliMUONTrackerQADataMakerRec::InitCommon()
+{  
+  if (!fBusPatchConfig)
+  {
+    Int_t bpmin(999999);
+    Int_t bpmax(0);
+    
+    TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
     AliMpBusPatch* bp(0x0);
-    AliMUONVTrackerData* data = fTrackerDataMaker->Data();
-    Int_t occDim = 2;
+    while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
+    {
+      bpmin = TMath::Min(bpmin,bp->GetId());
+      bpmax = TMath::Max(bpmax,bp->GetId());
+    }
+    
+    fBPxmin = bpmin-0.5;
+    fBPxmax = bpmax+0.5;
+    fBPnbins = TMath::Nint(fBPxmax-fBPxmin);
+        
+    AliMUONVStore* config = fCalibrationData->Config();
     
-    while ( ( bp = static_cast<AliMpBusPatch*>(nextBP())) )
+    if (config)
     {
-      Int_t busPatchId = bp->GetId();
-      Int_t bin = hbp->FindBin(busPatchId);
-      hbp->SetBinContent(bin,data->BusPatch(busPatchId,occDim)*100.0); // occupancy, in percent
+      fBusPatchConfig = new TH1F("hTrackerBusPatchConfig","Configuration of bus patches",fBPnbins,fBPxmin,fBPxmax);
+      fBusPatchConfig->SetDirectory(0);
+    }
+    else
+    {
+      AliWarning("Tracker configuration not found. Will not be able to cut on low occupancies");
+    }
+    
+    next.Reset();
+    while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
+    {
+      if ( config ) 
+      {
+        Int_t nofManusInConfig(0);
+      
+        for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
+        {
+          Int_t manuId = bp->GetManuId(imanu);
+          if ( config->FindObject(bp->GetDEId(),manuId)) ++nofManusInConfig;
+        }
+        
+        if ( nofManusInConfig > 0 )
+        {
+          fBusPatchConfig->Fill(bp->GetId(),1.0);
+        }
+        else
+        {
+          fBusPatchConfig->Fill(bp->GetId(),0.0);          
+        }
+      }      
+      else // no config, we assume all is there...
+      {
+        fBusPatchConfig->Fill(bp->GetId());
+      }
     }
   }
 }
 
 //____________________________________________________________________________ 
-void AliMUONTrackerQADataMakerRec::InitRaws()
+void AliMUONTrackerQADataMakerRec::BookHistograms(AliQAv1::TASKINDEX_t task)
 {
-    /// create Raws histograms in Raws subdir
-       
   AliCodeTimerAuto("",0);
+
+  InitCommon();
   
   const Bool_t expert   = kTRUE ; 
   const Bool_t saveCorr = kTRUE ; 
   const Bool_t image    = kTRUE ; 
-   Int_t bpmin(999999);
-  Int_t bpmax(0);
   
-  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
-  AliMpBusPatch* bp(0x0);
-  while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
+  TH1* hbp = new TH1F("hTrackerBusPatchOccupancy","Occupancy of bus patches",fBPnbins,fBPxmin,fBPxmax);
+  
+  Master()->Add2List(hbp,AliMUONQAIndices::kTrackerBusPatchOccupancy, task, expert, !image, !saveCorr);
+  
+  TH1* h = new TH1F("hTrackerBusPatchParityErrors","Number of parity errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
+  
+  Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchParityErrors,task,expert,!image,!saveCorr);
+  
+  h = new TH1F("hTrackerBusPatchTokenLostErrors","Number of token lost errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
+  Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchTokenLostErrors,task,expert,!image,!saveCorr);
+  
+  h = new TH1F("hTrackerBusPatchPaddingErrors","Number of padding errors per bus patch",fBPnbins,fBPxmin,fBPxmax);
+  
+  Master()->Add2List(h,AliMUONQAIndices::kTrackerBusPatchPaddingErrors,task,expert,!image,!saveCorr);
+  
+  
+  TH1* hnevents(0x0);
+  
+  if ( task == AliQAv1::kRAWS )
   {
-    bpmin = TMath::Min(bpmin,bp->GetId());
-    bpmax = TMath::Max(bpmax,bp->GetId());
+    // for raw data, we differentiate events seen from events used to be able to detect
+    // severe decoder errors that lead to no event decoded (i.e. zero event used) even if
+    // events are there (i.e non-zero event seen).
+    hnevents = new TH1F("hTrackerNofPhysicsEventsSeen","Number of physics events seen",1,-0.5,0.5);
+    // this one will count the number of physics event the rawdatamaker is *seeing*
+    TAxis* a = hnevents->GetXaxis();
+    a->SetBinLabel(1,"NPhysicsEvents");
+    hnevents->SetStats(kFALSE);
+    Master()->Add2List(hnevents,AliMUONQAIndices::kTrackerNofPhysicsEventsSeen,task,expert,!image,!saveCorr);
   }
   
-  Double_t xmin = bpmin-0.5;
-  Double_t xmax = bpmax+0.5;
-  Int_t nbins = bpmax-bpmin+1;
-  
-  TH1* hbp = new TH1F("hTrackerBusPatchOccupancy","Occupancy of bus patches",nbins,xmin,xmax);
-
-
-  TH1* hbpnpads = new TH1F("hTrackerBusPatchNofPads","Number of pads per bus patch",nbins,xmin,xmax);
+  hnevents = new TH1F("hTrackerNofGoodPhysicsEventsUsed","Number of good physics events used",1,-0.5,0.5);
+  // this one will get its content from the TrackerData, i.e. it will count the number of *good* physics events *used*
+  // (i.e. not empty and with no fatal readout error)
+  TAxis* a = hnevents->GetXaxis();
+  a->SetBinLabel(1,"NGoodPhysicsEvents");
+  hnevents->SetStats(kFALSE);  
 
-  TH1* hbpnmanus = new TH1F("hTrackerBusPatchNofManus","Number of manus per bus patch",nbins,xmin,xmax);
+  Master()->Add2List(hnevents,AliMUONQAIndices::kTrackerNofGoodPhysicsEventsUsed,task,expert,!image,!saveCorr);
 
-  Add2RawsList(hbp,AliMUONQAIndices::kTrackerBusPatchOccupancy, !expert, image, !saveCorr);
-  Add2RawsList(hbpnpads,AliMUONQAIndices::kTrackerBusPatchNofPads, expert, !image, !saveCorr);
-  Add2RawsList(hbpnmanus,AliMUONQAIndices::kTrackerBusPatchNofManus, expert, !image, !saveCorr);
+  Master()->Add2List(static_cast<TH1*>(fBusPatchConfig->Clone()),AliMUONQAIndices::kTrackerBusPatchConfig, task,expert, !image, !saveCorr);
 
-  const Bool_t histogram(kFALSE);
+  Int_t nbins = AliDAQ::NumberOfDdls("MUONTRK");
+  const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
+  
+  Double_t xmin = offset - 0.5;
+  Double_t xmax  = offset + nbins - 0.5;
+  
+  TString what(AliQAv1::GetTaskName(task));
+  
+  h = new TH1F(Form("hTrackerDDL%sOccupancy",what.Data()),Form(";DDLId;DDL Occupancy in %% (from %s)",what.Data()),nbins,xmin,xmax);
+  
+  Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLOccupancy,task,expert,!image,!saveCorr);
 
-  if(!fTrackerDataMaker) 
+  if ( task == AliQAv1::kRAWS )
   {
-    fTrackerDataMaker = new AliMUONTrackerDataMaker(GetRecoParam(),
-                                                    AliCDBManager::Instance()->GetRun(),
-                                                    0x0,
-                                                    "",
-                                                    "NOGAIN",
-                                                    histogram,
-                                                    0.0,0.0);
+    // see above the comment about why we have event seen vs used for raw data.
+    h = new TH1F("hTrackerDDLNofEventsSeen","Number of events seen by DDL;DDLId",nbins,xmin,xmax);
+    Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLNofEventsSeen,task,expert,!image,!saveCorr);
   }
   
-  fTrackerDataMaker->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
+  h = new TH1F("hTrackerDDLNofEventsUsed","Number of events used by DDL;DDLId",nbins,xmin,xmax);
+  Master()->Add2List(h,AliMUONQAIndices::kTrackerDDLNofEventsUsed,task,expert,!image,!saveCorr);
+  
+}
 
-  fTrackerDataMaker->SetRunning(kTRUE);
+//____________________________________________________________________________ 
+void AliMUONTrackerQADataMakerRec::InitRaws()
+{
+  /// create monitor objects for RAWS
+       
+  TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
   
-  next.Reset();
+  /// Book histograms that are common to Raws and Digits
+  BookHistograms(AliQAv1::kRAWS);
+  
+  /// Now the Raws specific parts
+  TH1* h = new TH1F("hTrackerReadoutStatus","Readout status (x events)",7,-0.5,6.5);
+  h->SetStats(kFALSE);
+  
+  TAxis* a = h->GetXaxis();
+  
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofGlitchErrors),"Glitch errors");
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofTokenLostErrors),"Token lost errors");
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofParityErrors),"Parity errors");
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofPaddingErrors),"Padding errors");
+  
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofEmptyEvents),"Empty events");
+  
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromConfig),"Not readout bus patches");
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofMissingBusPatchesFromDataStream),"Missing bus patches");
 
-  AliMUONVStore* config = fCalibrationData->Config();
+  TH1* h1 = static_cast<TH1*>(h->Clone("hTrackerReadoutStatusPerEvent"));
+  h1->SetTitle("Readout status per event");
+  h1->GetYaxis()->SetTitle("Percentage");
+  
+  // The QA shifter will only see the summary plot below
 
-  TH1* hbpconfig(0x0);
+  Add2RawsList(h,AliMUONQAIndices::kTrackerReadoutStatus,kTRUE,kFALSE,kFALSE);    
+  Add2RawsList(h1,AliMUONQAIndices::kTrackerReadoutStatusPerEvent,kFALSE,kTRUE,kFALSE);  
+
+  // Lastly the event size histograms
   
-  if (config)
-  {
-    hbpconfig = new TH1F("hTrackerBusPatchConfig","Configuration of bus patches",nbins,xmin,xmax);
-    Add2RawsList(hbpconfig,AliMUONQAIndices::kTrackerBusPatchConfig, expert, !image, !saveCorr);
-  }
-  else
-  {
-    AliWarning("Tracker configuration not found. Will not be able to cut on low occupancies");
-  }
+  Int_t nbins = AliDAQ::NumberOfDdls("MUONTRK");
+  const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
   
-  while ( ( bp = static_cast<AliMpBusPatch*>(next())) )
-  {
-    Int_t n(0);
-    Bool_t inConfig(kTRUE);
+  Double_t xmin = offset - 0.5;
+  Double_t xmax  = offset + nbins - 0.5;
+  
+  h = new TH1F("hTrackerDDLEventSize","DDL event size (bytes);DDL Id;Data size (bytes)",nbins,xmin,xmax);  
+  h->SetStats(kFALSE);
+  Add2RawsList(h,AliMUONQAIndices::kTrackerDDLEventSize,kTRUE,kFALSE,kFALSE);
+
+  h = new TH1F("hTrackerDDLMeanEventSize","DDL mean event size (KB) per event;DDL Id;Mean Event size (KB)",nbins,xmin,xmax);  
+  h->SetStats(kFALSE);
+  Add2RawsList(h,AliMUONQAIndices::kTrackerDDLEventSizePerEvent,kFALSE,kTRUE,kFALSE);
     
-    for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
-    {
-      Int_t manuId = bp->GetManuId(imanu);
-      AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(bp->GetDEId());      
-      n += de->NofChannelsInManu(manuId);
-      if ( config && !config->FindObject(de->GetId(),manuId)) inConfig=kFALSE;
-    }
-    hbpnpads->Fill(bp->GetId(),n*1.0);
-    hbpnmanus->Fill(bp->GetId(),bp->GetNofManus()*1.0);
-    if ( hbpconfig && inConfig ) 
-    {
-      hbpconfig->Fill(bp->GetId());
-    }
-  }
+  Add2RawsList(new TH1F("hTrackerIsThere","tracker is there",1,0,1),AliMUONQAIndices::kTrackerIsThere,kTRUE,kFALSE,kFALSE);
+  //
+  //ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line  DONE at parent level
 }
 
 //__________________________________________________________________
 void AliMUONTrackerQADataMakerRec::InitDigits() 
 {
-  /// Initialized Digits spectra 
-  const Bool_t expert   = kTRUE ; 
-  const Bool_t image    = kTRUE ; 
+  /// create monitor objects for DIGITS
   
-  TH1I* h0 = new TH1I("hDigitsDetElem", "Detection element distribution in Digits;Detection element Id;Counts",  1400, 100, 1500); 
-  Add2DigitsList(h0, 0, !expert, image);
+  AliCodeTimerAuto("",0);
+
+  if ( GetRecoParam()->TryRecover() )
+  {
+    fDigitMaker->SetTryRecover(kTRUE);
+  }
+  else
+  {
+    fDigitMaker->SetTryRecover(kFALSE);    
+  }
   
-  TH1I* h1 = new TH1I("hDigitsADC", "ADC distribution in Digits;ACD value;Counts", 4096, 0, 4095); 
-  Add2DigitsList(h1, 1, !expert, image);    
+  TrackerCalData(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
+  
+  /// Book histograms that are common to Raws and Digits
+  BookHistograms(AliQAv1::kDIGITSR);
+  //
+  //ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line  DONE at parent level
 } 
 
 //____________________________________________________________________________ 
@@ -498,6 +1095,10 @@ void AliMUONTrackerQADataMakerRec::InitRecPoints()
   const Bool_t image    = kTRUE ; 
   
   AliCodeTimerAuto("",0);
+
+  TrackerRecData(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
+  
+  BookHistograms(AliQAv1::kRECPOINTS);
   
   TH1I *h1I;
   TH1F *h1F;
@@ -584,7 +1185,9 @@ void AliMUONTrackerQADataMakerRec::InitRecPoints()
   h1F->SetMarkerColor(kRed);
   Add2RecPointsList(h1F, AliMUONQAIndices::kTrackerClusterChargePerDEMean, !expert, image);
   
-  if (!fMappingCheckRecPoints) fMappingCheckRecPoints = new AliMUONQAMappingCheck(RunNumber());  
+  MappingCheckRecPoints(AliRecoParam::AConvert(Master()->GetEventSpecie()),kTRUE);
+  //
+  //ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line  DONE at parent level
 }
 
 //____________________________________________________________________________ 
@@ -818,6 +1421,8 @@ void AliMUONTrackerQADataMakerRec::InitESDs()
   Add2ESDsList(hESDSumLocalChi2YPerDE, AliMUONQAIndices::kESDSumLocalChi2YPerDE, expert, !image);
   TH1F* hESDSumLocalChi2PerDE = new TH1F("hESDSumLocalChi2PerDE", "sum of local chi2 (~0.5*(#chi^{2}_{X}+#chi^{2}_{Y})) per DE;DetElem ID;#Sigma(local #chi^{2})", nDE+1, -0.5, nDE+0.5);
   Add2ESDsList(hESDSumLocalChi2PerDE, AliMUONQAIndices::kESDSumLocalChi2PerDE, expert, !image);
+  //
+  //ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line  DONE at parent level
 }
 
 //____________________________________________________________________________
@@ -825,25 +1430,40 @@ void AliMUONTrackerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
 {
        /// make QA for rawdata tracker
        
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
 
   /// forces init
   GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
   
-       ((AliMUONTrackerDataMaker*)fTrackerDataMaker)->SetRawReader(rawReader);
+  AliMUONTrackerDataMaker* dm = static_cast<AliMUONTrackerDataMaker*>(TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie())));
+
+  dm->SetRawReader(rawReader);
        
-       fTrackerDataMaker->ProcessEvent();
+  Int_t eventType = rawReader->GetType();
+  
+  if (eventType == AliRawEventHeaderBase::kPhysicsEvent ) 
+  {
+    dm->ProcessEvent();
+    
+    FillEventSize(rawReader);
+        
+    if ( dm->LastEventWasEmpty() )
+    {
+      FillRawsData(AliMUONQAIndices::kTrackerReadoutStatus,1.0*AliMUONQAIndices::kTrackerRawNofEmptyEvents);
+    }    
+  }
+  //
 }
 
 //__________________________________________________________________
 void AliMUONTrackerQADataMakerRec::MakeDigits(TTree* digitsTree)         
 {
   /// makes data from Digits
-
-  AliCodeTimerAuto("",0);
+  AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
   
-  // Do nothing in case of calibration event
-  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
+  /// forces init
+
+  GetDigitsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
 
   if (!fDigitStore)
     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
@@ -854,14 +1474,33 @@ void AliMUONTrackerQADataMakerRec::MakeDigits(TTree* digitsTree)
   
   AliMUONVDigit* dig = 0x0;
   
+  AliMUON2DMap oneEventData(true);
+  
   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
+  {
+    if ( dig->IsTracker() )
     {
-    GetDigitsData(0)->Fill(dig->DetElemId());
-    GetDigitsData(1)->Fill(dig->ADC());
+      if ( dig->Charge() > 0.0 )
+      {
+        
+        Int_t detElemId = dig->DetElemId();
+        Int_t manuId = dig->ManuId();
+        
+        AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(oneEventData.FindObject(detElemId,manuId));
+        if (!param)
+        {
+          param = new AliMUONCalibParamND(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,
+                                          AliMUONVCalibParam::InvalidFloatValue());
+          oneEventData.Add(param);
+        }
+        param->SetValueAsDouble(dig->ManuChannel(),0,dig->Charge());
+      }
     }
+  }
+  TrackerCalData(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Add(oneEventData);
+  //
 }
 
-
 //____________________________________________________________________________
 void AliMUONTrackerQADataMakerRec::MakeRecPoints(TTree* clustersTree)
 {
@@ -874,10 +1513,9 @@ void AliMUONTrackerQADataMakerRec::MakeRecPoints(TTree* clustersTree)
        // then we have clusters in TreeR, so let's take that opportunity
        // to QA them...
        
-  AliCodeTimerAuto("",0);
-
-  // Do nothing in case of calibration event
-  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
+  AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
+  // Forces init by requesting an histogram
+  GetRecPointsData(AliMUONQAIndices::kTrackerBusPatchOccupancy); 
 
        if (!fClusterStore)
        {
@@ -895,27 +1533,49 @@ void AliMUONTrackerQADataMakerRec::MakeRecPoints(TTree* clustersTree)
        TIter next(fClusterStore->CreateIterator());
        AliMUONVCluster* cluster;
        
-  if ( fMappingCheckRecPoints ) fMappingCheckRecPoints->NewEvent();
+  AliMUONQAMappingCheck* mcr = MappingCheckRecPoints(AliRecoParam::AConvert(Master()->GetEventSpecie()));
+  
+  if ( mcr ) mcr->NewEvent();
+  
+  AliMUON2DMap oneEventData(true);
   
        while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
        {
                Int_t detElemId = cluster->GetDetElemId();
                Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
                
-               GetRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerDE)->Fill(detElemId);
-               GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDE+detElemId)->Fill(cluster->GetCharge());
-               GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+detElemId)->Fill(cluster->GetNDigits());
-
-               GetRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerChamber)->Fill(chamberId);
-               GetRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChamber+chamberId)->Fill(cluster->GetCharge());
-               GetRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+chamberId)->Fill(cluster->GetNDigits());
-               GetRecPointsData(AliMUONQAIndices::kTrackerClusterHitMapPerChamber+chamberId)->Fill(cluster->GetX(),cluster->GetY());
+               FillRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerDE,detElemId);
+               FillRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerDE+detElemId,cluster->GetCharge());
+               FillRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerDE+detElemId,cluster->GetNDigits());
+
+               FillRecPointsData(AliMUONQAIndices::kTrackerNumberOfClustersPerChamber,chamberId);
+               FillRecPointsData(AliMUONQAIndices::kTrackerClusterChargePerChamber+chamberId,cluster->GetCharge());
+               FillRecPointsData(AliMUONQAIndices::kTrackerClusterMultiplicityPerChamber+chamberId,cluster->GetNDigits());
+               FillRecPointsData(AliMUONQAIndices::kTrackerClusterHitMapPerChamber+chamberId,cluster->GetX(),cluster->GetY());
                
-    if ( fMappingCheckRecPoints ) fMappingCheckRecPoints->Store(*cluster);
+    if ( mcr ) mcr->Store(*cluster);
     
+    for ( int i = 0; i < cluster->GetNDigits(); ++i ) 
+    {
+      UInt_t digitId = cluster->GetDigitId(i);
+      
+      Int_t manuId = AliMUONVDigit::ManuId(digitId);
+      Int_t manuChannel = AliMUONVDigit::ManuChannel(digitId);
+      
+      AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(oneEventData.FindObject(detElemId,manuId));
+      if (!param)
+      {
+        param = new AliMUONCalibParamND(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
+        oneEventData.Add(param);
+      }
+      param->SetValueAsDouble(manuChannel,0,1.0);
+    }
        }
        
-       fClusterStore->Clear();
+  TrackerRecData(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Add(oneEventData);    
+
+  fClusterStore->Clear();
+  //
 }
 
 //____________________________________________________________________________
@@ -923,20 +1583,16 @@ void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
 {
   /// make QA data from ESDs
 
-  AliCodeTimerAuto("",0);
-  
-  // Do nothing in case of calibration event
-  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
-  
+  AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
+   
   // load ESD event in the interface
-  AliMUONESDInterface esdInterface;
-  if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam(), kFALSE);
-  else AliError("Unable to get recoParam: use default ones for residual calculation");
-  esdInterface.LoadEvent(*esd);
+  if (!AliMUONESDInterface::GetTracker()) {
+    if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam(), kFALSE);
+    else AliError("Unable to get recoParam: use default ones for residual calculation");
+  }
   
-  GetESDsData(AliMUONQAIndices::kESDnTracks)->Fill(esdInterface.GetNTracks());
   
-  Int_t nTrackMatchTrig = 0;
+  Int_t nTrkTracks = 0, nTrackMatchTrig = 0;
   
   // loop over tracks
   Int_t nTracks = (Int_t) esd->GetNumberOfMuonTracks(); 
@@ -945,23 +1601,25 @@ void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
     // get the ESD track and skip "ghosts"
     AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
     if (!esdTrack->ContainTrackerData()) continue;
+    nTrkTracks++;
     
     // get corresponding MUON track
-    AliMUONTrack* track = esdInterface.FindTrack(esdTrack->GetUniqueID());
+    AliMUONTrack track;
+    AliMUONESDInterface::ESDToMUON(*esdTrack, track);
     
     if (esdTrack->ContainTriggerData()) nTrackMatchTrig++;
     
-    GetESDsData(AliMUONQAIndices::kESDMomentum)->Fill(esdTrack->P());
-    GetESDsData(AliMUONQAIndices::kESDPt)->Fill(esdTrack->Pt());
-    GetESDsData(AliMUONQAIndices::kESDRapidity)->Fill(esdTrack->Y());
-    GetESDsData(AliMUONQAIndices::kESDChi2)->Fill(track->GetNormalizedChi2());
-    GetESDsData(AliMUONQAIndices::kESDProbChi2)->Fill(TMath::Prob(track->GetGlobalChi2(),track->GetNDF()));
-    GetESDsData(AliMUONQAIndices::kESDThetaX)->Fill(esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
-    GetESDsData(AliMUONQAIndices::kESDThetaY)->Fill(esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
-    GetESDsData(AliMUONQAIndices::kESDnClustersPerTrack)->Fill(track->GetNClusters());
+    FillESDsData(AliMUONQAIndices::kESDMomentum,esdTrack->P());
+    FillESDsData(AliMUONQAIndices::kESDPt,esdTrack->Pt());
+    FillESDsData(AliMUONQAIndices::kESDRapidity,esdTrack->Y());
+    FillESDsData(AliMUONQAIndices::kESDChi2,track.GetNormalizedChi2());
+    FillESDsData(AliMUONQAIndices::kESDProbChi2,TMath::Prob(track.GetGlobalChi2(),track.GetNDF()));
+    FillESDsData(AliMUONQAIndices::kESDThetaX,esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
+    FillESDsData(AliMUONQAIndices::kESDThetaY,esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
+    FillESDsData(AliMUONQAIndices::kESDnClustersPerTrack,track.GetNClusters());
     
     // loop over clusters
-    AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
+    AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->First());
     while (trackParam) {
       
       AliMUONVCluster* cluster = trackParam->GetClusterPtr();
@@ -975,49 +1633,238 @@ void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
       Double_t localChi2Y = (sigmaResidualY2 > 0.) ? residualY*residualY/sigmaResidualY2 : 0.;
       Double_t localChi2 = 0.5 * trackParam->GetLocalChi2();
       
-      GetESDsData(AliMUONQAIndices::kESDClusterHitMap+chId)->Fill(cluster->GetX(), cluster->GetY());
+      FillESDsData(AliMUONQAIndices::kESDClusterHitMap+chId,cluster->GetX(), cluster->GetY());
       
-      GetESDsData(AliMUONQAIndices::kESDnTotClustersPerCh)->Fill(chId);
-      GetESDsData(AliMUONQAIndices::kESDnTotClustersPerDE)->Fill(deID);
+      FillESDsData(AliMUONQAIndices::kESDnTotClustersPerCh,chId);
+      FillESDsData(AliMUONQAIndices::kESDnTotClustersPerDE,deID);
       
-      GetESDsData(AliMUONQAIndices::kESDClusterChargeInCh+chId)->Fill(cluster->GetCharge());
-      GetESDsData(AliMUONQAIndices::kESDSumClusterChargePerDE)->Fill(deID, cluster->GetCharge());
+      FillESDsData(AliMUONQAIndices::kESDClusterChargeInCh+chId,cluster->GetCharge());
+      FillESDsData(AliMUONQAIndices::kESDSumClusterChargePerDE,deID, cluster->GetCharge());
       
       if (cluster->GetNDigits() > 0) { // discard clusters with pad not stored in ESD
-       GetESDsData(AliMUONQAIndices::kESDnTotFullClustersPerDE)->Fill(deID);
-        GetESDsData(AliMUONQAIndices::kESDClusterSizeInCh+chId)->Fill(cluster->GetNDigits());
-       GetESDsData(AliMUONQAIndices::kESDSumClusterSizePerDE)->Fill(deID, cluster->GetNDigits());
+       FillESDsData(AliMUONQAIndices::kESDnTotFullClustersPerDE,deID);
+        FillESDsData(AliMUONQAIndices::kESDClusterSizeInCh+chId,cluster->GetNDigits());
+       FillESDsData(AliMUONQAIndices::kESDSumClusterSizePerDE,deID, cluster->GetNDigits());
       }
       
-      GetESDsData(AliMUONQAIndices::kESDResidualXInCh+chId)->Fill(residualX);
-      GetESDsData(AliMUONQAIndices::kESDResidualYInCh+chId)->Fill(residualY);
-      GetESDsData(AliMUONQAIndices::kESDSumResidualXPerDE)->Fill(deID, residualX);
-      GetESDsData(AliMUONQAIndices::kESDSumResidualYPerDE)->Fill(deID, residualY);
-      GetESDsData(AliMUONQAIndices::kESDSumResidualX2PerDE)->Fill(deID, residualX*residualX);
-      GetESDsData(AliMUONQAIndices::kESDSumResidualY2PerDE)->Fill(deID, residualY*residualY);
+      FillESDsData(AliMUONQAIndices::kESDResidualXInCh+chId,residualX);
+      FillESDsData(AliMUONQAIndices::kESDResidualYInCh+chId,residualY);
+      FillESDsData(AliMUONQAIndices::kESDSumResidualXPerDE,deID, residualX);
+      FillESDsData(AliMUONQAIndices::kESDSumResidualYPerDE,deID, residualY);
+      FillESDsData(AliMUONQAIndices::kESDSumResidualX2PerDE,deID, residualX*residualX);
+      FillESDsData(AliMUONQAIndices::kESDSumResidualY2PerDE,deID, residualY*residualY);
       
-      GetESDsData(AliMUONQAIndices::kESDLocalChi2XInCh+chId)->Fill(localChi2X);
-      GetESDsData(AliMUONQAIndices::kESDLocalChi2YInCh+chId)->Fill(localChi2Y);
-      GetESDsData(AliMUONQAIndices::kESDLocalChi2InCh+chId)->Fill(localChi2);
-      GetESDsData(AliMUONQAIndices::kESDSumLocalChi2XPerDE)->Fill(deID, localChi2X);
-      GetESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE)->Fill(deID, localChi2Y);
-      GetESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE)->Fill(deID, localChi2);
+      FillESDsData(AliMUONQAIndices::kESDLocalChi2XInCh+chId,localChi2X);
+      FillESDsData(AliMUONQAIndices::kESDLocalChi2YInCh+chId,localChi2Y);
+      FillESDsData(AliMUONQAIndices::kESDLocalChi2InCh+chId,localChi2);
+      FillESDsData(AliMUONQAIndices::kESDSumLocalChi2XPerDE,deID, localChi2X);
+      FillESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE,deID, localChi2Y);
+      FillESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE,deID, localChi2);
       
-      trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
+      trackParam = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->After(trackParam));
       
     }
     
   }
 
-  GetESDsData(AliMUONQAIndices::kESDMatchTrig)->Fill(nTrackMatchTrig);
-  
+  FillESDsData(AliMUONQAIndices::kESDnTracks,nTrkTracks);
+  FillESDsData(AliMUONQAIndices::kESDMatchTrig,nTrackMatchTrig);
+  //
 }
 
 //____________________________________________________________________________ 
 AliMUONVTrackerData* AliMUONTrackerQADataMakerRec::GetTrackerData() const
 { 
-/// Return tracker data
+  /// Return tracker data
+  
+  return TrackerDataMaker(AliRecoParam::AConvert(Master()->GetEventSpecie()))->Data(); 
+}
+
+//____________________________________________________________________________ 
+void
+AliMUONTrackerQADataMakerRec::ResetDetectorRaws(TObjArray* list)
+{
+  /// Reset those histograms that must be reset (and only those), plus
+  /// the trackerdata itself.
+  
+  TIter next(list);
+  TObject* o;
+  while ( ( o = next() ) )
+  {
+    TH1* h = dynamic_cast<TH1*>(o);
+    if (h)
+    {
+      TString hn(h->GetName());
+      
+      if ( !hn.Contains("TrackerBusPatchConfig") )
+      {
+        AliDebug(1,Form("Resetting %s",hn.Data()));
+
+        h->Reset();
+      }
+      else
+      {
+        AliDebug(1,Form("Will not reset histogram %s",hn.Data()));          
+      }
+      continue;
+    }
+    // RS account for the case when this histos were cloned per trigger class
+    TObjArray* harr = dynamic_cast<TObjArray*>(o);
+    if (harr) {
+      TString hn(harr->GetName());
+      if ( !hn.Contains("TrackerBusPatchConfig") ) {
+
+       AliDebug(1,Form("Resetting clones of %s",hn.Data()));
+
+       TIter nextCl(harr);
+       TH1* hc = 0;
+       while ( (hc=dynamic_cast<TH1*>(nextCl())) ) hc->Reset();
+      }
+      else {
+       AliDebug(1,Form("Will not reset clones of histogram %s",hn.Data()));  
+      }
+      continue;
+    }
+    //
+    AliMUONVTrackerData* d = dynamic_cast<AliMUONVTrackerData*>(o);
+    if (d) {
+      AliDebug(1,Form("Resetting %s",d->GetName()));
+      d->Clear();
+    }
+    else {
+      AliError(Form("Found an object of class %s. Do not know how to reset.",o->ClassName()));
+    }
+  }
+
+  fLogger->Clear();
+}
+
+//____________________________________________________________________________ 
+TObjArray* AliMUONTrackerQADataMakerRec::GetArray(TObjArray*& array, Bool_t create)
+{
+  /// Get (or create) the array
+
+  if ( ! array ) 
+  {
+    if ( create ) 
+    {
+      array = new TObjArray(AliRecoParam::kNSpecies);
+    }
+  }
+  
+  return array;
+}
+
+//____________________________________________________________________________ 
+AliMUONVTrackerDataMaker* 
+AliMUONTrackerQADataMakerRec::TrackerDataMaker(Int_t specieIndex)  const
+{
+  /// const version of the getter
+  if ( fTrackerDataMakerArray )
+  {
+    return static_cast<AliMUONVTrackerDataMaker*>(fTrackerDataMakerArray->At(specieIndex));
+  }
+  return 0x0;
+}
+
+//____________________________________________________________________________ 
+AliMUONVTrackerDataMaker* 
+AliMUONTrackerQADataMakerRec::TrackerDataMaker(Int_t specieIndex, Bool_t create)
+{
+  /// Get (or create) TrackerDataMaker object for a given specie
+  
+  TObjArray* array = GetArray(fTrackerDataMakerArray,create);
+  TObject* o(0x0);
+  
+  if ( array ) 
+  {
+    array->SetOwner(kTRUE);
+    o = array->At(specieIndex);
+    if (!o && create)
+    {
+      
+      AliMUONTrackerDataMaker* dm = new AliMUONTrackerDataMaker(0x0,
+                                                                AliCDBManager::Instance()->GetRun(),
+                                                                0x0,
+                                                                "",
+                                                                "",
+                                                                kFALSE,
+                                                                0.0,0.0);
+      
+      if (!fLogger) fLogger = new AliMUONLogger(-1); // note that we share the logger between species... should not be a big deal though
+      dm->EnableErrorLogger(fLogger);
+      dm->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level    
+      dm->Data()->SetName("RawCharges");
+      dm->SetRunning(kTRUE);
+
+      o = dm;
+      array->AddAt(o,specieIndex);      
+    }
+  }
+  return static_cast<AliMUONVTrackerDataMaker*>(o);
+}
+
+//____________________________________________________________________________ 
+AliMUONVTrackerData* 
+AliMUONTrackerQADataMakerRec::TrackerCalData(Int_t specieIndex, Bool_t create)
+{
+  TObjArray* array = GetArray(fTrackerCalDataArray,create);
+  TObject* o(0x0);
   
-  return fTrackerDataMaker->Data(); 
+  if (array)
+  {
+    o = array->At(specieIndex);
+    if (!o && create)
+    {
+      AliMUONTrackerData* data = new AliMUONTrackerData("CalCharges",Form("Calibrated charges (fC) %s",GetRecoParam()->GetCalibrationMode()),1);
+      data->SetDimensionName(0,"charge");
+      data->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
+      o=data;
+      array->AddAt(o,specieIndex);
+    }
+  }
+  return static_cast<AliMUONVTrackerData*>(o);
+}
+
+//____________________________________________________________________________ 
+AliMUONVTrackerData* 
+AliMUONTrackerQADataMakerRec::TrackerRecData(Int_t specieIndex, Bool_t create)
+{
+  TObjArray* array = GetArray(fTrackerRecDataArray,create);
+  TObject* o(0x0);
   
+  if (array)
+  {
+    o = array->At(specieIndex);
+    if (!o && create)
+    {
+      AliMUONTrackerData* data = new AliMUONTrackerData("RecCharges",Form("Calibrated charges (fC) %s for digits belonging to a reconstructed cluster",GetRecoParam()->GetCalibrationMode()),1);
+      data->SetDimensionName(0,"one");
+      data->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
+      o=data;
+      array->AddAt(o,specieIndex);
+    }
+  }
+  return static_cast<AliMUONVTrackerData*>(o);
+}
+
+//____________________________________________________________________________ 
+AliMUONQAMappingCheck* 
+AliMUONTrackerQADataMakerRec::MappingCheckRecPoints(Int_t specieIndex, Bool_t create)
+{
+  TObjArray* array = GetArray(fMappingCheckRecPointsArray,create);
+  TObject* o(0x0);
+  
+  if (array)
+  {
+    o = array->At(specieIndex);
+    array->SetOwner(kTRUE);
+    if (!o && create)
+    {
+      AliMUONQAMappingCheck* mcheck = new AliMUONQAMappingCheck(RunNumber()); 
+      o=mcheck;
+      array->AddAt(o,specieIndex);
+    }
+  }
+  return static_cast<AliMUONQAMappingCheck*>(o);
 }