Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / MUON / AliMUONQADataMakerRec.cxx
index fb9c320..0f91829 100644 (file)
 // --- MUON header files ---
 #include "AliMUONQADataMakerRec.h"
 
-#include "AliMUON2DMap.h"
-#include "AliMUONCluster.h"  
-#include "AliMUONConstants.h"  
-#include "AliMUONDDLTrigger.h"
-#include "AliMUONDarcHeader.h"
-#include "AliMUONDigitMaker.h"
-#include "AliMUONLocalStruct.h"
-#include "AliMUONLocalTrigger.h"
-#include "AliMUONRawStreamTracker.h"
-#include "AliMUONRawStreamTrigger.h"
-#include "AliMUONRegHeader.h"
-#include "AliMUONTrackerCalibratedDataMaker.h"
-#include "AliMUONTriggerDisplay.h"
-#include "AliMUONVCluster.h"
-#include "AliMUONVClusterStore.h"
-#include "AliMUONVDigit.h"
-#include "AliMUONVDigitStore.h"
-#include "AliMUONVTrackerData.h"
-#include "AliMUONVTriggerStore.h"
-#include "AliMpCDB.h"
-#include "AliMpConstants.h"
-#include "AliMpDDLStore.h"
-#include "AliMpDEIterator.h"
-#include "AliMpDEManager.h"
-#include "AliMpLocalBoard.h"
-#include "AliMpStationType.h"
-#include "AliMpTriggerCrate.h"
-#include "AliRawEventHeaderBase.h"
-
-// --- AliRoot header files ---
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
-#include "AliESDEvent.h"
-#include "AliESDMuonTrack.h"
-#include "AliESDMuonCluster.h"
-#include "AliLog.h"
-#include "AliRawReader.h"
-#include "AliQAChecker.h"
-#include "AliCodeTimer.h"
-
-// --- ROOT system ---
-#include <TClonesArray.h>
-#include <TFile.h> 
-#include <TH1F.h> 
-#include <TH1I.h> 
-#include <TH2F.h>
-#include <TH3F.h> 
-#include <TLorentzVector.h>
-#include <Riostream.h>
-
 //-----------------------------------------------------------------------------
 /// \class AliMUONQADataMakerRec
 ///
 /// MUON base class for quality assurance data (histo) maker
 ///
-/// \author C. Finck, D. Stocco, L. Aphecetche
+/// It is now only a steering class for the two subclasses AliMUONTrackerQADataMakerRec
+/// and AliMUONTriggerQADataMakerRec
+///
+/// \author C. Finck, D. Stocco, L. Aphecetche, A. Blanc
+
+#include "AliDAQ.h"
+#include "AliMUONTrackerQADataMakerRec.h"
+#include "AliMUONTriggerQADataMakerRec.h"
+#include "AliQAChecker.h"
+#include "AliRawReader.h"
+#include "AliRawEventHeaderBase.h"
 
 /// \cond CLASSIMP
 ClassImp(AliMUONQADataMakerRec)
 /// \endcond
            
 //____________________________________________________________________________ 
-AliMUONQADataMakerRec::AliMUONQADataMakerRec() : 
-AliQADataMakerRec(AliQA::GetDetName(AliQA::kMUON), "MUON Quality Assurance Data Maker"),
-fIsInitRaws(kFALSE),
-fIsInitRecPointsTracker(kFALSE),
-fIsInitRecPointsTrigger(kFALSE),
-fIsInitESDs(kFALSE),
-fDigitStore(0x0),
-fTriggerStore(0x0),
-fDigitMaker(0x0),
-fClusterStore(0x0),
-fTrackerDataMaker(0x0)
-{
-    /// ctor
-       
-       Ctor();
-}
-
-//____________________________________________________________________________ 
-void
-AliMUONQADataMakerRec::Ctor()
+AliMUONQADataMakerRec::AliMUONQADataMakerRec(Bool_t tracker, Bool_t trigger) : 
+AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kMUON), "MUON Quality Assurance Data Maker"),
+fTracker(tracker ? new AliMUONTrackerQADataMakerRec(this) : 0x0),
+fTrigger(trigger ? new AliMUONTriggerQADataMakerRec(this) : 0x0)
 {
-       /// Init some members
-       fDigitStore = AliMUONVDigitStore::Create("AliMUONDigitStoreV1");
-       fDigitMaker = new AliMUONDigitMaker(kTRUE);
-}
-
-//____________________________________________________________________________ 
-AliMUONQADataMakerRec::AliMUONQADataMakerRec(const AliMUONQADataMakerRec& qadm) :
-AliQADataMakerRec(qadm),
-fIsInitRaws(kFALSE),
-fIsInitRecPointsTracker(kFALSE),
-fIsInitRecPointsTrigger(kFALSE),
-fIsInitESDs(kFALSE),
-fDigitStore(0x0),
-fTriggerStore(0x0),
-fDigitMaker(0x0),
-fClusterStore(0x0),
-fTrackerDataMaker(0x0)
-{
-    ///copy ctor 
-    SetName((const char*)qadm.GetName()) ; 
-    SetTitle((const char*)qadm.GetTitle()); 
-
-       // Do not copy the digit store and digit maker, but create its own ones
-       
-       Ctor();
-       
-}
-
-//__________________________________________________________________
-AliMUONQADataMakerRec& AliMUONQADataMakerRec::operator = (const AliMUONQADataMakerRec& qadm )
-{
-  /// Assignment operator
-
-  // check assignment to self
-  if (this == &qadm) return *this;
-
-  this->~AliMUONQADataMakerRec();
-  new(this) AliMUONQADataMakerRec(qadm);
-  return *this;
+  /// ctor
+  AliInfo(Form("tracker=%d trigger=%d",tracker,trigger));
 }
 
 //__________________________________________________________________
 AliMUONQADataMakerRec::~AliMUONQADataMakerRec()
 {
     /// dtor
-  
-  AliCodeTimerAuto("");
-  
-  delete fDigitStore;
-  delete fTriggerStore;
-  delete fDigitMaker;
-       delete fClusterStore;
-       delete fTrackerDataMaker;
+  delete fTracker;
+  delete fTrigger;
 }
 
 //____________________________________________________________________________ 
-void AliMUONQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray* list)
+Int_t AliMUONQADataMakerRec::Add2List(TH1 * hist, const Int_t index, AliQAv1::TASKINDEX_t task, const Bool_t expert, const Bool_t image, const Bool_t saveForCorr)
 {
-       ///Detector specific actions at end of cycle
-       
-       // Display trigger histos in a more user friendly way
-       DisplayTriggerInfo(task);
-       
-       if ( task == AliQA::kRAWS ) 
-       {
-               TIter next(list);
-               TObject* o;
-               Bool_t alreadyThere(kFALSE);
-               while ( ( o = next() ) && !alreadyThere )
-               {
-                       TString classname(o->ClassName());
-                       if ( classname.Contains("TrackerData") ) alreadyThere = kTRUE;
-               }
-               if (!alreadyThere) list->AddAt(fTrackerDataMaker->Data(),(Int_t)kTrackerData);
-       }
-       
-       // do the QA checking
-       AliQAChecker::Instance()->Run(AliQA::kMUON, task, list) ;
+  TObjArray** list = GetList(task);
+  if (list)
+  {
+    return Add2List(hist,index,list,expert,image,saveForCorr);
+  }
+  return -1;
 }
 
 //____________________________________________________________________________ 
-void AliMUONQADataMakerRec::InitRaws()
+void AliMUONQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray** list)
 {
-    /// create Raws histograms in Raws subdir
-       
-       if ( ! AliCDBManager::Instance()->GetDefaultStorage() )
-       {
-               AliError("CDB default storage not set. Cannot work.");
-               fIsInitRaws=kFALSE;
-       }
-       
-       TH3F* h3 = new TH3F("hTriggerScalersBendPlane", "Trigger scalers in bending plane",
-                                                                                       4, 10.5, 14.5,
-                                                                                       234, 0.5, 234.5,
-                                                                                       16, -0.5, 15.5);
-       h3->GetXaxis()->SetTitle("Chamber");
-       h3->GetYaxis()->SetTitle("Board");
-       h3->GetZaxis()->SetTitle("Strip");
-       Add2RawsList(h3, kTriggerScalersBP);
-       
-       TH3F* h4 = new TH3F("hTriggerScalersNonBendPlane", "Trigger scalers in non-bending plane",
-                                                                                       4, 10.5, 14.5,
-                                                                                       234, 0.5, 234.5,
-                                                                                       16, -0.5, 15.5);
-       h4->GetXaxis()->SetTitle("Chamber");
-       h4->GetYaxis()->SetTitle("Board");
-       h4->GetZaxis()->SetTitle("Strip");
-       Add2RawsList(h4, kTriggerScalersNBP);
-       
-       AliMUONTriggerDisplay triggerDisplay;
-       TString histoName, histoTitle;
-       for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
-               TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
-               for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
-                       histoName = Form("hScalers%sChamber%i", cathName.Data(), 11+iChamber);
-                       histoTitle = Form("Chamber %i: Scalers %s", 11+iChamber, cathName.Data());
-                       TH2F* h5 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
-                                                                                                                                                                                                                                               iCath, iChamber, histoTitle);
-                       Add2RawsList(h5, kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
-               }
-       }
-       
-       fIsInitRaws = kTRUE;
+  /// Detector specific actions at end of cycle
+  //
+  ResetEventTrigClasses(); // RS
+  //
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
+  {
+    if (! IsValidEventSpecie(specie, list)  ) continue;
+    
+    SetEventSpecie(AliRecoParam::ConvertIndex(specie)); // needed by the GetXXXData methods
+    
+    if ( task == AliQAv1::kRAWS ) 
+    {
+      if ( fTracker ) fTracker->EndOfDetectorCycleRaws(specie,list);
+      if ( fTrigger ) fTrigger->EndOfDetectorCycleRaws(specie,list);
+    }  
+    else if ( task == AliQAv1::kRECPOINTS )
+    {
+      // normalize recpoints histograms
+      if ( fTracker ) fTracker->EndOfDetectorCycleRecPoints(specie,list);
+      if ( fTrigger ) fTrigger->EndOfDetectorCycleRecPoints(specie,list);
+    }
+    else if ( task == AliQAv1::kESDS ) 
+    {
+      // normalize esds histograms
+      if ( fTracker ) fTracker->EndOfDetectorCycleESDs(specie,list);
+      if ( fTrigger ) fTrigger->EndOfDetectorCycleESDs(specie,list);
+    }
+    else if ( task == AliQAv1::kDIGITSR ) 
+    {
+      if ( fTracker ) fTracker->EndOfDetectorCycleDigits(specie,list);        
+      if ( fTrigger ) fTrigger->EndOfDetectorCycleDigits(specie,list);
+    }
+    else
+    {
+      AliFatal(Form("Not implemented for task %s",AliQAv1::GetTaskName(task).Data()));
+    }
+  } // loop on specie
+    
+  // do the QA checking
+  AliQAChecker::Instance()->Run(AliQAv1::kMUON,task,list,const_cast<AliDetectorRecoParam*>(GetRecoParam()));
 }
 
 //____________________________________________________________________________ 
-void AliMUONQADataMakerRec::InitRecPoints()
+TObject* AliMUONQADataMakerRec::GetData(AliQAv1::TASKINDEX_t task, const Int_t index)
 {
-       /// create Reconstructed Points histograms in RecPoints subdir
-       InitRecPointsTrigger();
-       InitRecPointsTracker();
+  TObjArray** list = GetList(task);
+  if (list) return GetData(list,index);
+  return 0x0;
 }
 
 //____________________________________________________________________________ 
-void AliMUONQADataMakerRec::InitRecPointsTracker()
+TObjArray** AliMUONQADataMakerRec::GetList(AliQAv1::TASKINDEX_t task)
 {
-       /// create Reconstructed Points histograms in RecPoints subdir for the
-       /// MUON tracker subsystem.
-
-       AliMpDEIterator it;
-       
-       it.First();
-       
-       Int_t ndes(0);
-       
-       while ( !it.IsDone())
-       {
-               Int_t detElemId = it.CurrentDEId();
-               
-               it.Next();
-
-               if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger )
-               {
-                       ndes = TMath::Max(ndes,detElemId);
-
-                       TH1* h = new TH1I(Form("hTrackerClusterMultiplicityForDE%04d",detElemId),
-                                                                                               Form("Multiplicity of the clusters in detection element %d",detElemId),
-                                                                                               100,0,100);
-                       
-                       h->GetXaxis()->SetTitle("Detection Element Id");
-                       
-                       Add2RecPointsList(h,kTrackerClusterMultiplicityPerDE+detElemId);
-                       
-                       h =  new TH1I(Form("hTrackerClusterChargeForDE%04d",detElemId),
-                                                                               Form("Charge of the clusters in detection element %d",detElemId),
-                                                                               100,0,1000);
-
-                       h->GetXaxis()->SetTitle("Detection Element Id");
-
-                       Add2RecPointsList(h,kTrackerClusterChargePerDE+detElemId);
-
-               }
-
-       }
-
-       TH1* h = new TH1I("hTrackerNumberOfClustersPerDE","Number of clusters per detection element",
-                                                                               ndes, -0.5, ndes - 0.5);
-
-       h->GetXaxis()->SetTitle("Detection Element Id");
-
-       Add2RecPointsList(h, kTrackerNumberOfClustersPerDE);
-
-       for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i ) 
-       {
-               TH1* h1 = new TH1I("hTrackerNumberOfClustersPerChamber","Number of clusters per chamber",AliMpConstants::NofTrackingChambers(),-0.5,AliMpConstants::NofTrackingChambers()-0.5);
-               Add2RecPointsList(h1,kTrackerNumberOfClustersPerChamber);
-               h1 = new TH1I(Form("hTrackerClusterMultiplicityForChamber%d",i),
-                                                                Form("Cluster multiplicity for chamber %d",i),
-                                                                100,0,100);
-               Add2RecPointsList(h1,kTrackerClusterMultiplicityPerChamber+i);
-               h1 = new TH1I(Form("hTrackerClusterChargeForChamber%d",i),
-                                                                Form("Cluster charge for chamber %d",i),
-                                                                100,0,1000);
-               Add2RecPointsList(h1,kTrackerClusterChargePerChamber+i);
-       }
-       
-       fIsInitRecPointsTracker=kTRUE;
+  //  enum TASKINDEX_t {
+  //    kNULLTASKINDEX=-1, kRAWS, kHITS, kSDIGITS, kDIGITS, kDIGITSR, kRECPOINTS, kTRACKSEGMENTS, kRECPARTICLES, kESDS, kNTASKINDEX };
+  if ( task == AliQAv1::kRAWS ) 
+  {
+      return fRawsQAList;
+  }
+  else if ( task == AliQAv1::kDIGITS || task == AliQAv1::kDIGITSR )
+  {
+    return fDigitsQAList;
+  }
+  else if ( task == AliQAv1::kRECPOINTS ) 
+  {
+    return fRecPointsQAList;
+  }
+  else
+  {
+      AliFatal(Form("task %s not supported here yet",AliQAv1::GetTaskName(task).Data()));
+  }
+  return 0x0;
 }
 
 //____________________________________________________________________________ 
-void AliMUONQADataMakerRec::InitRecPointsTrigger()
+void AliMUONQADataMakerRec::InitRaws()
 {
-       /// create Reconstructed Points histograms in RecPoints subdir for the
-       /// MUON Trigger subsystem.
+  /// create Raws histograms in Raws subdir
        
-    TH3F* h0 = new TH3F("hTriggerDigitsBendPlane", "Trigger digits in bending plane",
-                       4, 10.5, 14.5,
-                       234, 0.5, 234.5,
-                       16, -0.5, 15.5);
-    h0->GetXaxis()->SetTitle("Chamber");
-    h0->GetYaxis()->SetTitle("Board");
-    h0->GetZaxis()->SetTitle("Strip");
-    Add2RecPointsList(h0, kTriggerDigitsBendPlane);
-
-    TH3F* h1 = new TH3F("hTriggerDigitsNonBendPlane", "Trigger digits in non-bending plane",
-                       4, 10.5, 14.5,
-                       234, 0.5, 234.5,
-                       16, -0.5, 15.5);
-    h1->GetXaxis()->SetTitle("Chamber");
-    h1->GetYaxis()->SetTitle("Board");
-    h1->GetZaxis()->SetTitle("Strip");
-    Add2RecPointsList(h1, kTriggerDigitsNonBendPlane);
-
-    TH1F* h2 = new TH1F("hTriggeredBoards", "Triggered boards", 234, 0.5, 234.5);
-    Add2RecPointsList(h2, kTriggeredBoards);
+  if ( fTracker ) fTracker->InitRaws();
+  if ( fTrigger ) fTrigger->InitRaws();
+  //
+  ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
+}
 
-    AliMUONTriggerDisplay triggerDisplay;
-    TString histoName, histoTitle;
-    for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
-      TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
-      for(Int_t iChamber=0; iChamber<AliMpConstants::NofTriggerChambers(); iChamber++){
-       histoName = Form("hTriggerDigits%sChamber%i", cathName.Data(), 11+iChamber);
-       histoTitle = Form("Chamber %i: Fired pads %s", 11+iChamber, cathName.Data());
-       TH2F* h3 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto(histoName, AliMUONTriggerDisplay::kDisplayStrips, 
-                                                             iCath, iChamber, histoTitle);
-       Add2RecPointsList(h3, kTriggerDigitsDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
-      }
-    }
+//__________________________________________________________________
+void AliMUONQADataMakerRec::InitDigits() 
+{
+  /// Initialized Digits spectra 
+  if ( fTracker ) fTracker->InitDigits();
+  if ( fTrigger ) fTrigger->InitDigits();
+  //
+  ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
+} 
 
-    TH2F* h4 = (TH2F*)triggerDisplay.GetEmptyDisplayHisto("hFiredBoardsDisplay", AliMUONTriggerDisplay::kDisplayBoards,
-                                                         0, 0, "Fired boards");
-    Add2RecPointsList(h4, kTriggerBoardsDisplay);
-       
-       fIsInitRecPointsTrigger = kTRUE;
+//____________________________________________________________________________ 
+void AliMUONQADataMakerRec::InitRecPoints()
+{
+       /// create Reconstructed Points histograms in RecPoints subdir
+  if ( fTracker ) fTracker->InitRecPoints();
+  if ( fTrigger ) fTrigger->InitRecPoints();
+  //
+  ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
 }
 
 
 //____________________________________________________________________________ 
 void AliMUONQADataMakerRec::InitESDs()
 {
-    ///create ESDs histograms in ESDs subdir
-  TH1F* h0 = new TH1F("hESDnTracks", "ESDs track number distribution", 30, 0., 30.);  
-  Add2ESDsList(h0, kESDnTracks);
-
-  TH1F* h1 = new TH1F("hESDMomentum", "ESDs P distribution", 300, 0., 300) ; 
-  Add2ESDsList(h1, kESDMomentum);
-
-  TH1F* h2 = new TH1F("hESDPt", "ESDs Pt distribution", 200, 0., 50) ; 
-  Add2ESDsList(h2, kESDPt);
-
-  TH1F* h3 = new TH1F("hESDRapidity", "ESDs rapidity distribution", 200, -4.5,-2.) ; 
-  Add2ESDsList(h3, kESDRapidity);
-
-  for (Int_t i = 0; i < AliMUONConstants::NTrackingCh(); ++i) 
-  {
-    TH2F* h4 = new TH2F(Form("%s%d", "hESDClusterHitMap", i), 
-                    Form("%s %d", "ESD Clusters hit distribution for chamber", i),
-                    100, -1*AliMUONConstants::Rmax(i/2), AliMUONConstants::Rmax(i/2),
-                    100, -1*AliMUONConstants::Rmax(i/2), AliMUONConstants::Rmax(i/2)); 
-    Add2ESDsList(h4, kESDClusterHitMap+i);
-  }
-  
-  fIsInitESDs =  kTRUE;
+  ///create ESDs histograms in ESDs subdir
+  if ( fTracker ) fTracker->InitESDs();
+  if ( fTrigger ) fTrigger->InitESDs();
+  //
+  ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
 }
 
 //____________________________________________________________________________
 void AliMUONQADataMakerRec::MakeRaws(AliRawReader* rawReader)
 {
-    /// make QA for rawdata
-
-    if ( ! fIsInitRaws ) {
-      AliWarningStream() 
-        << "Skipping function due to a failure in Init" << endl;
-      return;
-    }    
-
-  if ( rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ) 
+  /// make QA for rawdata
+  /// Note that we do not call the sub-datamaker MakeRaws method
+  /// for events where the MCH or MTR is not part of the readout...
+  
+  if ( !rawReader || !rawReader->GetDetectorPattern() ) return;
+  
+  UInt_t clmask = rawReader->GetDetectorPattern()[0];
+    
+  if ( fTracker && rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ) 
   {
-    rawReader->Reset();
-    MakeRawsTracker(rawReader);
+    UInt_t mchMask = AliDAQ::DetectorPattern(" MUONTRK ");
+    if ( clmask & mchMask ) 
+    {
+      rawReader->Reset();
+      fTracker->MakeRaws(rawReader);
+    }
   }
   
-  rawReader->Reset();    
-  MakeRawsTrigger(rawReader);
+  if ( fTrigger && (rawReader->GetType() == AliRawEventHeaderBase::kPhysicsEvent ||
+                    rawReader->GetType() == AliRawEventHeaderBase::kCalibrationEvent ) )
+  {
+    UInt_t mtrMask = AliDAQ::DetectorPattern(" MUONTRG ");
+    if ( clmask & mtrMask )
+    {
+      rawReader->Reset();    
+      fTrigger->MakeRaws(rawReader);
+    }
+  }
+  //
+  IncEvCountCycleRaws();
+  IncEvCountTotalRaws();
+  //
 }
 
-//____________________________________________________________________________
-void AliMUONQADataMakerRec::MakeRawsTracker(AliRawReader* rawReader)
+//__________________________________________________________________
+void AliMUONQADataMakerRec::MakeDigits()         
 {
-       /// make QA for rawdata tracker
+  /// makes data from Digits
   
-       if (!fTrackerDataMaker) 
-       {
-               const Bool_t histogram(kFALSE);
-               const Bool_t fastDecoder(kTRUE);
-    
-//    fTrackerDataMaker = new AliMUONTrackerRawDataMaker(rawReader,histogram,fastDecoder,takeRawReaderOwnership);
-
-               fTrackerDataMaker = new AliMUONTrackerCalibratedDataMaker(GetRecoParam(),
-                                                              AliCDBManager::Instance()->GetRun(),
-                                                              rawReader,
-                                                                                                                                                                                                                                                       AliCDBManager::Instance()->GetDefaultStorage()->GetURI(),
-                                                                                                                                                                                                                                                       "NOGAIN",
-                                                                                                                                                                                                                                                       histogram,
-                                                                                                                                                                                                                                                       0.0,0.0,
-                                                              fastDecoder);
-               
-               fTrackerDataMaker->Data()->DisableChannelLevel(); // to save up disk space, we only store starting at the manu level
-               
-               fTrackerDataMaker->SetRunning(kTRUE);
-       }
-       
-       ((AliMUONTrackerCalibratedDataMaker*)fTrackerDataMaker)->SetRawReader(rawReader);
-       
-       fTrackerDataMaker->ProcessEvent();
+  AliFatal("Not implemented");
 }
 
-//____________________________________________________________________________
-void AliMUONQADataMakerRec::MakeRawsTrigger(AliRawReader* rawReader)
+//__________________________________________________________________
+void AliMUONQADataMakerRec::MakeDigits(TTree* digitsTree)         
 {
-       /// make QA for rawdata trigger
-       
-    // Get trigger scalers
+  /// makes data from Digits
 
-    Int_t loCircuit=0;
-    AliMpCDB::LoadDDLStore();
+  // Do nothing in case of calibration event
+  if ( GetEventSpecie() == AliRecoParam::kCalib ) return;
 
-    AliMUONRawStreamTrigger rawStreamTrig(rawReader);
-    while (rawStreamTrig.NextDDL()) 
-    {
-      // If not a scaler event, do nothing
-      Bool_t scalerEvent =  rawReader->GetDataHeader()->GetL1TriggerMessage() & 0x1;
-      if(!scalerEvent) break;
-
-      AliMUONDDLTrigger* ddlTrigger = rawStreamTrig.GetDDLTrigger();
-      AliMUONDarcHeader* darcHeader = ddlTrigger->GetDarcHeader();
-
-      Int_t nReg = darcHeader->GetRegHeaderEntries();
-    
-      for(Int_t iReg = 0; iReg < nReg ;iReg++)
-      {   //reg loop
-
-       // crate info  
-       AliMpTriggerCrate* crate = AliMpDDLStore::Instance()->
-         GetTriggerCrate(rawStreamTrig.GetDDL(), iReg);
-
-       AliMUONRegHeader* regHeader =  darcHeader->GetRegHeaderEntry(iReg);
-
-       // loop over local structures
-       Int_t nLocal = regHeader->GetLocalEntries();
-       for(Int_t iLocal = 0; iLocal < nLocal; iLocal++) 
-       {
-         AliMUONLocalStruct* localStruct = regHeader->GetLocalEntry(iLocal);
-        
-         // if card exist
-         if (!localStruct) continue;
-          
-         loCircuit = crate->GetLocalBoardId(localStruct->GetId());
-
-         if ( !loCircuit ) continue; // empty slot
-
-         AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
-
-         // skip copy cards
-         if( !localBoard->IsNotified()) 
-           continue;
-
-         Int_t cathode = localStruct->GetComptXY()%2;
-
-         ERaw hindex = (cathode==0) ? kTriggerScalersBP : kTriggerScalersNBP;
-
-         // loop over strips
-         for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
-           if(localStruct->GetXY1(ibitxy) > 0)
-             ((TH3F*)GetRawsData(hindex))->Fill(11+0, loCircuit, ibitxy, 2*localStruct->GetXY1(ibitxy));
-           if(localStruct->GetXY2(ibitxy) > 0)
-             ((TH3F*)GetRawsData(hindex))->Fill(11+1, loCircuit, ibitxy, 2*localStruct->GetXY2(ibitxy));
-           if(localStruct->GetXY3(ibitxy) > 0)
-             ((TH3F*)GetRawsData(hindex))->Fill(11+2, loCircuit, ibitxy, 2*localStruct->GetXY3(ibitxy));
-           if(localStruct->GetXY4(ibitxy) > 0)
-             ((TH3F*)GetRawsData(hindex))->Fill(11+3, loCircuit, ibitxy, 2*localStruct->GetXY4(ibitxy));
-         } // loop on strips
-       } // iLocal
-      } // iReg
-    } // NextDDL
+  if ( fTracker ) fTracker->MakeDigits(digitsTree);
+  if ( fTrigger ) fTrigger->MakeDigits(digitsTree);  
+  //
+  IncEvCountCycleDigits();
+  IncEvCountTotalDigits();
+  //
 }
 
 //____________________________________________________________________________
 void AliMUONQADataMakerRec::MakeRecPoints(TTree* clustersTree)
 {
        /// Fill histograms from treeR
-       
-       if (fIsInitRecPointsTracker) MakeRecPointsTracker(clustersTree);
-       if (fIsInitRecPointsTrigger) MakeRecPointsTrigger(clustersTree);
-}
-
-//____________________________________________________________________________
-void AliMUONQADataMakerRec::MakeRecPointsTracker(TTree* clustersTree)
-{
-       /// Fill histograms related to tracker clusters 
-       
-       // First things first : do we have clusters in the TreeR ?
-       // In "normal" production mode, it should be perfectly normal
-       // *not* to have them.
-       // But if for some reason we de-activated the combined tracking,
-       // then we have clusters in TreeR, so let's take that opportunity
-       // to QA them...
-       
-       if (!fClusterStore)
-       {
-               AliCodeTimerAuto("ClusterStore creation");
-               fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
-               if (!fClusterStore) 
-               {
-                       fIsInitRecPointsTracker = kFALSE;
-                       return;
-               }
-       }
-       
-       AliCodeTimerAuto("");
-       
-       fClusterStore->Connect(*clustersTree,kFALSE);
-       clustersTree->GetEvent(0);
-
-       TIter next(fClusterStore->CreateIterator());
-       AliMUONVCluster* cluster;
-       
-       while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) )
-       {
-               Int_t detElemId = cluster->GetDetElemId();
-               Int_t chamberId = AliMpDEManager::GetChamberId(detElemId);
-               
-               GetRecPointsData(kTrackerNumberOfClustersPerDE)->Fill(detElemId);
-               GetRecPointsData(kTrackerClusterChargePerDE+detElemId)->Fill(cluster->GetCharge());
-               GetRecPointsData(kTrackerClusterMultiplicityPerDE+detElemId)->Fill(cluster->GetNDigits());
 
-               GetRecPointsData(kTrackerNumberOfClustersPerChamber)->Fill(chamberId);
-               GetRecPointsData(kTrackerClusterChargePerChamber+chamberId)->Fill(cluster->GetCharge());
-               GetRecPointsData(kTrackerClusterMultiplicityPerChamber+chamberId)->Fill(cluster->GetNDigits());
-               
-       }
+  // Do nothing in case of calibration event
+  if ( GetEventSpecie() == AliRecoParam::kCalib ) return;
        
-       fClusterStore->Clear();
+  if ( fTracker ) fTracker->MakeRecPoints(clustersTree);
+  if ( fTrigger ) fTrigger->MakeRecPoints(clustersTree);  
+  //
+  IncEvCountCycleRecPoints();
+  IncEvCountTotalRecPoints();
+  //
 }
 
 //____________________________________________________________________________
-void AliMUONQADataMakerRec::MakeRecPointsTrigger(TTree* clustersTree)
+void AliMUONQADataMakerRec::MakeESDs(AliESDEvent* esd)
 {
-       /// makes data from trigger response
-      
-    // Fired pads info
-    fDigitStore->Clear();
-
-    if (!fTriggerStore) fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
-    fTriggerStore->Clear();
-    fTriggerStore->Connect(*clustersTree, false);
-    clustersTree->GetEvent(0);
-
-    AliMUONLocalTrigger* locTrg;
-    TIter nextLoc(fTriggerStore->CreateLocalIterator());
-
-    while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(nextLoc()) ) ) 
-    {
-      if (locTrg->IsNull()) continue;
-   
-      TArrayS xyPattern[2];
-      locTrg->GetXPattern(xyPattern[0]);
-      locTrg->GetYPattern(xyPattern[1]);
+  /// make QA data from ESDs
 
-      Int_t nBoard = locTrg->LoCircuit();
+  // Do nothing in case of calibration event
+  if ( GetEventSpecie() == AliRecoParam::kCalib ) return;
+  
+  if ( fTracker ) fTracker->MakeESDs(esd);
+  if ( fTrigger ) fTrigger->MakeESDs(esd);  
+  //
+  IncEvCountCycleESDs();
+  IncEvCountTotalESDs();
+  //
+ }
 
-      Bool_t xTrig=locTrg->IsTrigX();
-      Bool_t yTrig=locTrg->IsTrigY();
+//____________________________________________________________________________ 
+void AliMUONQADataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
+{
+  /// Reset internals
+  
+  for (int spec = 0; spec < AliRecoParam::kNSpecies; ++spec) 
+  {
+    if (!AliQAv1::Instance()->IsEventSpecieSet(AliRecoParam::ConvertIndex(spec)))
+      continue;
     
-      if (xTrig && yTrig)
-       ((TH1F*)GetRecPointsData(kTriggeredBoards))->Fill(nBoard);
-
-      fDigitMaker->TriggerDigits(nBoard, xyPattern, *fDigitStore);
+    if ( task == AliQAv1::kRAWS ) 
+    {
+      if (fTracker) fTracker->ResetDetectorRaws(fRawsQAList[spec]);
+      if (fTrigger) fTrigger->ResetDetectorRaws(fRawsQAList[spec]);
     }
-
-    TIter nextDigit(fDigitStore->CreateIterator());
-    AliMUONVDigit* mDigit;
-    while ( ( mDigit = static_cast<AliMUONVDigit*>(nextDigit()) ) )
+    else if ( task == AliQAv1::kRECPOINTS )
     {
-      Int_t detElemId = mDigit->DetElemId();
-      Int_t ch = detElemId/100;
-      Int_t localBoard = mDigit->ManuId();
-      Int_t channel = mDigit->ManuChannel();
-      Int_t cathode = mDigit->Cathode();
-      ERecPoints hindex 
-        = ( cathode == 0 ) ? kTriggerDigitsBendPlane : kTriggerDigitsNonBendPlane;
-      
-      ((TH3F*)GetRecPointsData(hindex))->Fill(ch, localBoard, channel);
+      if (fTracker) fTracker->ResetDetectorRecPoints(fRecPointsQAList[spec]);
+      if (fTrigger) fTrigger->ResetDetectorRecPoints(fRecPointsQAList[spec]);
     }
-}
-
-//____________________________________________________________________________
-void AliMUONQADataMakerRec::MakeESDs(AliESDEvent* esd)
-{
-    /// make QA data from ESDs
-
-    if ( ! fIsInitESDs ) {
-      AliWarningStream() 
-        << "Skipping function due to a failure in Init" << endl;
-      return;
-    }    
-
-    TLorentzVector v1;
-
-    Int_t nTracks = (Int_t)esd->GetNumberOfMuonTracks() ; 
-    GetESDsData(0)->Fill(nTracks);
-
-    for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) {
-
-      AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
-      
-      // skip "ghosts"
-      if (!muonTrack->ContainTrackerData()) continue;
-      
-      muonTrack->LorentzP(v1);
-
-      GetESDsData(1)->Fill(v1.P());
-      GetESDsData(2)->Fill(v1.Pt());
-      GetESDsData(3)->Fill(v1.Rapidity());
-
-      TClonesArray clusters =  muonTrack->GetClusters();
-
-      for (Int_t iCluster = 0; iCluster <clusters.GetEntriesFast(); ++iCluster) {
-       AliESDMuonCluster* cluster = (AliESDMuonCluster*)clusters.At(iCluster);
-       GetESDsData(kESDClusterHitMap+cluster->GetChamberId())
-          ->Fill(cluster->GetX(), cluster->GetY());
-      }
+    else if ( task == AliQAv1::kESDS ) 
+    {
+      if (fTracker) fTracker->ResetDetectorESDs(fESDsQAList[spec]);
+      if (fTrigger) fTrigger->ResetDetectorESDs(fESDsQAList[spec]);
+    }
+    else if ( task == AliQAv1::kDIGITS ) 
+    {
+      if (fTracker) fTracker->ResetDetectorDigits(fDigitsQAList[spec]);
+      if (fTrigger) fTrigger->ResetDetectorDigits(fDigitsQAList[spec]);
     }
+    else
+    {
+      AliFatal(Form("Not implemented for task %s",AliQAv1::GetTaskName(task).Data()));
+    }
+  }
 }
 
 //____________________________________________________________________________ 
 void AliMUONQADataMakerRec::StartOfDetectorCycle()
 {
-    /// Detector specific actions at start of cycle
+  /// Detector specific actions at start of cycle  
   
 }
-
-//____________________________________________________________________________ 
-void AliMUONQADataMakerRec::DisplayTriggerInfo(AliQA::TASKINDEX_t task)
-{
-  //
-  /// Display trigger information in a user-friendly way:
-  /// from local board and strip numbers to their position on chambers
-  //
-  if(task!=AliQA::kRECPOINTS && task!=AliQA::kRAWS) return;
-
-  AliMUONTriggerDisplay triggerDisplay;
-  
-  TH3F* histoStrips=0x0;
-  TH2F* histoDisplayStrips=0x0;
-
-  for (Int_t iCath = 0; iCath < AliMpConstants::NofCathodes(); iCath++)
-  {
-    if(task==AliQA::kRECPOINTS){
-      ERecPoints hindex 
-       = ( iCath == 0 ) ? kTriggerDigitsBendPlane : kTriggerDigitsNonBendPlane;
-      histoStrips = (TH3F*)GetRecPointsData(hindex);
-    }
-    else if(task==AliQA::kRAWS){
-      ERaw hindex 
-       = ( iCath == 0 ) ? kTriggerScalersBP : kTriggerScalersNBP;
-      histoStrips = (TH3F*)GetRawsData(hindex);
-      if(histoStrips->GetEntries()==0) return; // No scalers found
-    }
-    
-    for (Int_t iChamber = 0; iChamber < AliMpConstants::NofTriggerChambers(); iChamber++)
-    {
-      if(task==AliQA::kRECPOINTS){
-       histoDisplayStrips = (TH2F*)GetRecPointsData(kTriggerDigitsDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
-      }
-      else if(task==AliQA::kRAWS){
-       histoDisplayStrips = (TH2F*)GetRawsData(kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
-      }
-      Int_t bin = histoStrips->GetXaxis()->FindBin(11+iChamber);
-      histoStrips->GetXaxis()->SetRange(bin,bin);
-      TH2F* inputHisto = (TH2F*)histoStrips->Project3D("zy");
-      triggerDisplay.FillDisplayHistogram(inputHisto, histoDisplayStrips, AliMUONTriggerDisplay::kDisplayStrips, iCath, iChamber);
-    } // iChamber
-  } // iCath
-
-  if(task!=AliQA::kRECPOINTS) return;
-  TH1F* histoBoards = (TH1F*)GetRecPointsData(kTriggeredBoards);
-  TH2F* histoDisplayBoards = (TH2F*)GetRecPointsData(kTriggerBoardsDisplay);
-  triggerDisplay.FillDisplayHistogram(histoBoards, histoDisplayBoards, AliMUONTriggerDisplay::kDisplayBoards, 0, 0);
-}