]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerQADataMakerRec.cxx
Fixing minor bug recognizing diffractive events in simulation
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerQADataMakerRec.cxx
index be658f89a30130b88414c660e368ff6d0d326201..ab453ee2bf6538dc2a0bac5e813611129165cc79 100644 (file)
@@ -61,6 +61,9 @@ ClassImp(AliMUONTriggerQADataMakerRec)
 #include "AliMUONGlobalTrigger.h"
 #include "AliMUONGlobalCrateConfig.h"
 #include "AliMUONQAIndices.h"
+#include "AliMpPad.h"
+#include "AliMpVSegmentation.h"
+#include "AliMpSegmentation.h"
 
 namespace
 {
@@ -73,9 +76,12 @@ namespace
 AliMUONTriggerQADataMakerRec::AliMUONTriggerQADataMakerRec(AliQADataMakerRec* master) : 
 AliMUONVQADataMakerRec(master),
 fDigitMaker(new AliMUONDigitMaker(kFALSE)),
-fCalibrationData(new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun())),
-fTriggerProcessor(new AliMUONTriggerElectronics(fCalibrationData)),
-fDigitStore(0x0)
+fCalibrationData(0x0),
+fTriggerProcessor(0x0),
+fDigitStore(0x0),
+fDigitStoreFromRaw(0x0),
+fTriggerStoreFromRaw(0x0),
+fTriggerStoreReprocessRaw(0x0)
 {
     /// ctor
 }
@@ -86,9 +92,12 @@ AliMUONTriggerQADataMakerRec::~AliMUONTriggerQADataMakerRec()
 {
     /// dtor
   delete fDigitMaker;
-  delete fDigitStore;
   delete fTriggerProcessor;
   delete fCalibrationData;
+  delete fDigitStore;
+  delete fDigitStoreFromRaw;
+  delete fTriggerStoreFromRaw;
+  delete fTriggerStoreReprocessRaw;
 }
 
 //____________________________________________________________________________ 
@@ -101,7 +110,6 @@ void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleESDs(Int_t /*specie*/, TObj
 void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleRecPoints(Int_t /*specie*/, TObjArray** /*list*/)
 {
   /// Normalize RecPoints histograms
-  
 }
 
 
@@ -109,11 +117,7 @@ void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleRecPoints(Int_t /*specie*/,
 void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleRaws(Int_t /*specie*/, TObjArray** /*list*/)
 {
   /// create Raws histograms in Raws subdir
-
-  DisplayTriggerInfo();
-
-  // Normalize RawData histos
-  Float_t nbevent = GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents)->GetBinContent(1);
+  
   Int_t histoRawsIndex[] = {
     AliMUONQAIndices::kTriggerErrorSummary,
     AliMUONQAIndices::kTriggerCalibSummary,
@@ -126,53 +130,83 @@ void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleRaws(Int_t /*specie*/, TObj
     AliMUONQAIndices::kTriggerReadOutErrorsNorm,
     AliMUONQAIndices::kTriggerGlobalOutputNorm
   };
+  
   const Int_t kNrawsHistos = sizeof(histoRawsIndex)/sizeof(histoRawsIndex[0]);
   Float_t scaleFactor[kNrawsHistos] = {100., 100., 100., 1.};
-  for(Int_t ihisto=0; ihisto<kNrawsHistos; ihisto++){
-    TH1* inputHisto = GetRawsData(histoRawsIndex[ihisto]);
-    TH1* scaledHisto = GetRawsData(histoRawsScaledIndex[ihisto]);
-    if ( scaledHisto && inputHisto &&  nbevent > 0 ) {
-      scaledHisto->Reset();
-      scaledHisto->Add(inputHisto);
-      scaledHisto->Scale(scaleFactor[ihisto]/nbevent);
-    }
-  } // loop on histos
 
-  TH1* hYCopy = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopy); //number of YCopy error per board
-  TH1* hYCopyTests = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyTest); //contains the number of YCopy test per board
-  TH1* hYCopyNorm = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyNorm); 
-  hYCopyNorm->Reset();
-  hYCopyNorm->Divide(hYCopy, hYCopyTests, 100., 1.);
+  for ( Int_t itc=-1; itc<AliQADataMakerRec::GetNTrigClasses(); itc++) { 
+  
+    DisplayTriggerInfo(itc);
+
+    // Normalize RawData histos
+    TH1* histo1D = GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents,itc);
+    // This histogram is there for all relevant triggers
+    // if it is not there, it means that the trigger is not taken into account
+    // so we can skip the trigger class for all other histos
+    if ( ! histo1D ) continue;
+    Float_t nbevent = histo1D->GetBinContent(1);
+    for(Int_t ihisto=0; ihisto<kNrawsHistos; ihisto++){
+      TH1* inputHisto = GetRawsData(histoRawsIndex[ihisto],itc);
+      TH1* scaledHisto = GetRawsData(histoRawsScaledIndex[ihisto],itc);
+      // Check here for both since we do not clone Calib-only histograms
+      if ( scaledHisto && inputHisto &&  nbevent > 0 ) {
+        scaledHisto->Reset();
+        scaledHisto->Add(inputHisto);
+        scaledHisto->Scale(scaleFactor[ihisto]/nbevent);
+      }
+    } // loop on histos
+
+    
+    // The following histograms are surely there
+    // if the histogram with analyzed events is there:
+    // test on the existence of each histogram is not necessary
+    TH1* hYCopy = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopy,itc); //number of YCopy error per board
+    TH1* hYCopyTests = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyTest,itc); //contains the number of YCopy test per board
+    TH1* hYCopyNorm = GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyNorm,itc); 
+    hYCopyNorm->Reset();
+    hYCopyNorm->Divide(hYCopy, hYCopyTests, 100., 1.);
      
-  Float_t mean = hYCopyNorm->Integral();
+    Float_t mean = hYCopyNorm->Integral();
       
-  TH1* hSummary = GetRawsData(AliMUONQAIndices::kTriggerErrorSummary);
-  hSummary->SetBinContent(AliMUONQAIndices::kAlgoLocalYCopy+1,mean/192.); //put the mean of the % of YCopy error in the kTriggerError's corresponding bin
+    TH1* hSummary = GetRawsData(AliMUONQAIndices::kTriggerErrorSummaryNorm,itc);
+    hSummary->SetBinContent(AliMUONQAIndices::kAlgoLocalYCopy+1,mean/192.); //put the mean of the % of YCopy error in the kTriggerError's corresponding bin
 
-  TH1F* hTriggerRatio = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434);
-  if ( hTriggerRatio ){
-    hTriggerRatio->Divide(((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec)),((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec)));
+    TH1F* hTriggerRatio = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434,itc);
+    if ( hTriggerRatio ){
+      hTriggerRatio->Divide(((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec,itc)),((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec,itc)));
 
-    FillRatio4434Histos(1);
+      FillRatio4434Histos(1,itc,kTRUE);
 
-    //reset bins temporary used to store informations
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(0,0); 
-    Int_t nbins =  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->GetNbinsX();
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(nbins+1,0);
+      //reset bins temporary used to store informations
+      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents,itc))->SetBinContent(0,0); 
+      Int_t nbins =  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents,itc))->GetNbinsX();
+      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents,itc))->SetBinContent(nbins+1,0);
 
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434))->SetMaximum(1.1);
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetMaximum(1.1);
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetMaximum(1.1);
-  }
+      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434,itc))->SetMaximum(1.1);
+      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents,itc))->SetMaximum(1.1);
+      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate,itc))->SetMaximum(1.1);
+    }
+  
+    if ( GetRawsData(AliMUONQAIndices::kTriggerGlobalScalersNorm,itc) ) {
+      TH1* inputHisto = GetRawsData(AliMUONQAIndices::kTriggerGlobalScalers,itc);
+      TH1* scaledHisto = GetRawsData(AliMUONQAIndices::kTriggerGlobalScalersNorm,itc);
+      scaledHisto->Reset();
+      scaledHisto->Add(inputHisto);
+      Float_t scaleValue = ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerScalersTime,itc))->GetBinContent(1);
+      if ( scaleValue > 0. ) scaledHisto->Scale(1./scaleValue);
+    }
+  } // loop on trigger classes
 }
 
 //____________________________________________________________________________ 
 void AliMUONTriggerQADataMakerRec::InitRaws()
 {
     /// create Raws histograms in Raws subdir
-       
-  AliCodeTimerAuto("",0);
   
+  // RS: Since there is no sense in cloning trigger scalers per trigger, I am (for the moment) forbidding their cloning
+
+  AliCodeTimerAuto("",0);
+    
   const Bool_t expert   = kTRUE ; 
   const Bool_t saveCorr = kTRUE ; 
   const Bool_t image    = kTRUE ; 
@@ -192,6 +226,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
     histo1D->GetXaxis()->SetBinLabel(1, "One-bin histogram: bin is filled at each scaler event.");
     histo1D->GetYaxis()->SetTitle("Cumulated scaler time (s)");
     Add2RawsList(histo1D, AliMUONQAIndices::kTriggerScalersTime, expert, !image, !saveCorr);
+    ForbidCloning(histo1D); // RS
 
     for(Int_t iCath=0; iCath<AliMpConstants::NofCathodes(); iCath++){
       TString cathName = ( iCath==0 ) ? "BendPlane" : "NonBendPlane";
@@ -205,6 +240,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
        histo2D->GetYaxis()->SetTitle("Strip"); 
        histo2D->SetOption("COLZ");     
        Add2RawsList(histo2D, AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber, expert, !image, !saveCorr);
+       ForbidCloning(histo2D); // RS
       } // loop on chambers
     } // loop on cathodes
        
@@ -217,6 +253,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
                                                             iCath, iChamber, histoTitle);
        histo2D->SetOption("COLZ");
        Add2RawsList(histo2D, AliMUONQAIndices::kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, expert, !image, !saveCorr);
+       ForbidCloning(histo2D); // RS
       } // loop on chambers
     } // loop on cathodes    
 
@@ -231,11 +268,15 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
     // Copy of previous histo for scaling purposes
     TH1F* histoCalibNorm = (TH1F*)histoCalib->Clone("hTriggerCalibSummary");
     histoCalibNorm->SetTitle("MTR calibration summary");
-    histoCalibNorm->SetOption("bar2");
+    histoCalibNorm->SetOption("bartext0");
     histoCalibNorm->GetYaxis()->SetTitle("Percentage per event (%)");
     // Adding both histos after cloning to avoid problems with the expert bit
     Add2RawsList(histoCalib,     AliMUONQAIndices::kTriggerCalibSummary,      expert, !image, !saveCorr);
+    ForbidCloning(histoCalib); // RS
+
     Add2RawsList(histoCalibNorm, AliMUONQAIndices::kTriggerCalibSummaryNorm, !expert,  image, !saveCorr);
+    ForbidCloning(histoCalibNorm); // RS
+
   } // Calibration reco param
        
   const char *globalXaxisName[6] = {"US HPt", "US LPt", "LS HPt", "LS LPt", "SGL HPt", "SGL LPt"};
@@ -347,7 +388,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   histoAlgoErr->SetFillColor(kBlue);
   // Copy of previous histo for scaling purposes
   TH1F* histoAlgoErrNorm = (TH1F*)histoAlgoErr->Clone("hTriggerAlgoErrors");
-  histoAlgoErrNorm->SetOption("bar2");
+  histoAlgoErrNorm->SetOption("bartext0");
   histoAlgoErrNorm->SetTitle("Trigger algorithm errors");
   histoAlgoErrNorm->GetYaxis()->SetTitle("% of events with errors");
   // Adding both histos after cloning to avoid problems with the expert bit
@@ -385,7 +426,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   // Copy of previous histo for scaling purposes
   TH1F* histoROerrNorm = (TH1F*)histoROerr->Clone("hTriggerReadoutErrors");
   histoROerrNorm->SetTitle("Trigger Read-Out errors");
-  histoROerrNorm->SetOption("bar2");
+  histoROerrNorm->SetOption("bartext0");
   histoROerrNorm->GetYaxis()->SetTitle("% of errors per event");
   // Adding both histos after cloning to avoid problems with the expert bit
   Add2RawsList(histoROerr,     AliMUONQAIndices::kTriggerReadOutErrors,      expert, !image, !saveCorr);
@@ -401,9 +442,9 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   // Copy of previous histo for scaling purposes
   TH1F* histoGlobalMultNorm = (TH1F*)histoGlobalMult->Clone("hTriggerGlobalOutMultiplicityPerEvt");
   histoGlobalMultNorm->SetTitle("Trigger global outputs multiplicity per event");
-  histoGlobalMultNorm->SetOption("bar2");
-  histoGlobalMultNorm->SetBarWidth(0.5);
-  histoGlobalMultNorm->SetBarOffset(0.25);
+  histoGlobalMultNorm->SetOption("bartext0");
+  //histoGlobalMultNorm->SetBarWidth(0.5);
+  //histoGlobalMultNorm->SetBarOffset(0.25);
   histoGlobalMultNorm->GetYaxis()->SetTitle("Triggers per event");
   // Adding both histos after cloning to avoid problems with the expert bit
   Add2RawsList(histoGlobalMult,     AliMUONQAIndices::kTriggerGlobalOutput,     expert, !image, !saveCorr);
@@ -426,6 +467,31 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
     histo1D->GetYaxis()->SetTitle("Number of 4/4");
     Add2RawsList(histo1D, AliMUONQAIndices::kTriggerNumberOf44Dec, expert, !image, !saveCorr);
   }
+  
+  histo1D = new TH1F("hTriggerIsThere","trigger is there",1,0,1);
+  Add2RawsList(histo1D,AliMUONQAIndices::kTriggerIsThere,kTRUE,kFALSE,kFALSE);
+
+  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) {
+    TH1F* histoGlobalScalers = new TH1F("hTriggerGlobalScalers","Trigger global scalers", 6, -0.5, 6.-0.5);
+    histoGlobalScalers->GetYaxis()->SetTitle("L0 counts");
+    histoGlobalScalers->GetXaxis()->SetTitle("Global output");
+    for (int ibin=0;ibin<6;ibin++){
+      histoGlobalScalers->GetXaxis()->SetBinLabel(ibin+1,globalXaxisName[ibin]);
+    }        
+    // Copy of previous histo for scaling purposes
+    TH1F* histoGlobalScalersNorm = (TH1F*)histoGlobalScalers->Clone("hTriggerGlobalScalersRate");
+    histoGlobalScalersNorm->SetTitle("Trigger global L0 scalers rate");
+    histoGlobalScalersNorm->SetOption("etext0");
+    histoGlobalScalersNorm->GetYaxis()->SetTitle("L0 scalers rate (Hz)");
+    // Adding both histos after cloning to avoid problems with the expert bit
+    Add2RawsList(histoGlobalScalers,     AliMUONQAIndices::kTriggerGlobalScalers,     expert, !image, !saveCorr);
+    ForbidCloning(histoGlobalScalers); // RS
+    Add2RawsList(histoGlobalScalersNorm, AliMUONQAIndices::kTriggerGlobalScalersNorm, expert, !image, !saveCorr);
+    ForbidCloning(histoGlobalScalersNorm); // RS
+  }
+  //
+  //ClonePerTrigClass(AliQAv1::kRAWS); // RS: this should be the last line  DONE at parent level
+  //
 }
 
 //__________________________________________________________________
@@ -437,6 +503,10 @@ void AliMUONTriggerQADataMakerRec::InitDigits()
   
   TH1I* h0 = new TH1I("hTriggerDigitsDetElem", "Detection element distribution in Digits;Detection element Id;Counts",  400, 1100, 1500); 
   Add2DigitsList(h0, 0, !expert, image);
+  ForbidCloning(h0);
+  //
+  //ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line  DONE at parent level
+  //
 } 
 
 //____________________________________________________________________________ 
@@ -455,6 +525,7 @@ void AliMUONTriggerQADataMakerRec::InitRecPoints()
   histo1D->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(esindex));
   histo1D->GetYaxis()->SetTitle("Number of analyzed events");
   Add2RecPointsList(histo1D, AliMUONQAIndices::kTriggerNAnalyzedEvents, expert, !image);
+  ForbidCloning(histo1D);
 
   histo1D = new TH1F("hTriggerTrippedChambers", "Trigger RPCs in trip", 418, 1100-0.5, 1417+0.5);
   histo1D->GetXaxis()->SetTitle("DetElemId");
@@ -462,8 +533,12 @@ void AliMUONTriggerQADataMakerRec::InitRecPoints()
   histo1D->SetFillColor(kRed);
   histo1D->SetLineColor(kRed);
   Add2RecPointsList(histo1D, AliMUONQAIndices::kTriggerRPCtrips, !expert, image);
-
-  FillTriggerDCSHistos();      
+  ForbidCloning(histo1D);   // RS this histo is not cloned
+  //
+  FillTriggerDCSHistos();
+  //
+  //ClonePerTrigClass(AliQAv1::kRECPOINTS); DONE at parent level
+  //
 }
 
 
@@ -481,6 +556,7 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     AliCodeTimerAuto("",0);
        
     // Init Local/Regional/Global decision with fake values
+    //
 
     UInt_t globalInput[4];
     for (Int_t bit=0; bit<4; bit++){
@@ -494,19 +570,13 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     //fTriggerInputGlobalDataHPt[reg][bit]=0;
     //}
     //}
-
-    AliMUONDigitStoreV2R digitStore;
-
-    AliMUONDigitStoreV2R digitStoreAll;
-    TArrayS xyPatternAll[2];
-    for(Int_t icath=0; icath<AliMpConstants::NofCathodes(); icath++){
-      xyPatternAll[icath].Set(AliMpConstants::NofTriggerChambers());
-      xyPatternAll[icath].Reset(1);
-    }
-    
-    AliMUONTriggerStoreV1 recoTriggerStore;
-
-    AliMUONTriggerStoreV1 inputTriggerStore;
+  
+  if ( fDigitStoreFromRaw ) fDigitStoreFromRaw->Clear();
+  else fDigitStoreFromRaw = new AliMUONDigitStoreV2R();
+  if ( fTriggerStoreFromRaw ) fTriggerStoreFromRaw->Clear();
+  else fTriggerStoreFromRaw =  new AliMUONTriggerStoreV1();
+  if ( fTriggerStoreReprocessRaw ) fTriggerStoreReprocessRaw->Clear();
+  else fTriggerStoreReprocessRaw = new AliMUONTriggerStoreV1();
 
     AliMUONGlobalTrigger inputGlobalTrigger;
 
@@ -522,6 +592,7 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     const AliMUONRawStreamTriggerHP::AliLocalStruct*     localStruct = 0x0;
 
     Int_t nDeadLocal = 0, nDeadRegional = 0, nDeadGlobal = 0, nNoisyStrips = 0;
+    Int_t nFiredStrips = 0, nStripsTot = 0;
 
     // When a crate is not present, the loop on boards is not performed
     // This should allow to correctly count the local boards
@@ -530,8 +601,8 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     Bool_t containTriggerData = kFALSE;
     AliMUONRawStreamTriggerHP rawStreamTrig(rawReader);
     while (rawStreamTrig.NextDDL()) 
-    {
-      containTriggerData = kTRUE;
+      {
+       containTriggerData = kTRUE;
 
       Bool_t scalerEvent =  rawReader->GetDataHeader()->GetL1TriggerMessage() & 0x1;
 
@@ -546,36 +617,41 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
       darcHeader = rawStreamTrig.GetHeaders();
 
       if (darcHeader->GetGlobalFlag()){
-       if ( fillScalerHistos ) {
-         UInt_t nOfClocks = darcHeader->GetGlobalClock();
-         Double_t nOfSeconds = ((Double_t) nOfClocks) / 40e6; // 1 clock each 25 ns
-         ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerScalersTime))->Fill(1., nOfSeconds);
-       }
-
-       //Get Global datas
-       inputGlobalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput());
-       Bool_t resp[6] = {inputGlobalTrigger.PairUnlikeHpt(), inputGlobalTrigger.PairUnlikeLpt(),
-                         inputGlobalTrigger.PairLikeHpt(), inputGlobalTrigger.PairLikeLpt(),
-                         inputGlobalTrigger.SingleHpt(), inputGlobalTrigger.SingleLpt()}; 
-       for (Int_t bit=0; bit<6; bit++){
-         if ( ! resp[bit] ){
-           if ( fillScalerHistos )
-             nDeadGlobal++;
-         }
-         else
-           ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerGlobalOutput))->Fill(bit);
-       }
-
-       //for (Int_t Bit=0; Bit<32; Bit++){
-       //fTriggerInputGlobalDataLPt[Bit/4][Bit%4]=((darcHeader->GetGlobalInput(0)>>Bit)&1);
-       //fTriggerInputGlobalDataLPt[Bit/4+8][Bit%4]=((darcHeader->GetGlobalInput(1)>>Bit)&1);
-       //fTriggerInputGlobalDataHPt[Bit/4][Bit%4]=((darcHeader->GetGlobalInput(2)>>Bit)&1);
-       //fTriggerInputGlobalDataHPt[Bit/4+8][Bit%4]=((darcHeader->GetGlobalInput(3)>>Bit)&1);
-       //}
-
-       for (Int_t i=0; i<4; i++){
-         globalInput[i]=darcHeader->GetGlobalInput(i);
-       }
+        if ( fillScalerHistos ) {
+          UInt_t nOfClocks = darcHeader->GetGlobalClock();
+          Double_t nOfSeconds = ((Double_t) nOfClocks) / 40e6; // 1 clock each 25 ns
+          FillRawsData(AliMUONQAIndices::kTriggerScalersTime, 1., nOfSeconds);
+          const UInt_t* globScaler = darcHeader->GetGlobalScaler();
+          Int_t bitCorr[6] = {2,0,3,1,4,5};
+          for (Int_t bit=0; bit<6; bit++){
+            FillRawsData(AliMUONQAIndices::kTriggerGlobalScalers, bitCorr[bit],(double)(*(globScaler+bit)));
+          }
+        }
+
+        //Get Global datas
+        inputGlobalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput());
+        Int_t resp[6] = {inputGlobalTrigger.PairUnlikeHpt(), inputGlobalTrigger.PairUnlikeLpt(),
+          inputGlobalTrigger.PairLikeHpt(), inputGlobalTrigger.PairLikeLpt(),
+          inputGlobalTrigger.SingleHpt(), inputGlobalTrigger.SingleLpt()}; 
+        for (Int_t bit=0; bit<6; bit++){
+          if ( resp[bit] == 0 ){
+            if ( fillScalerHistos )
+              nDeadGlobal++;
+          }
+          else
+            FillRawsData(AliMUONQAIndices::kTriggerGlobalOutput, bit, resp[bit]);
+        } // loop on bits
+
+        //for (Int_t Bit=0; Bit<32; Bit++){
+        //fTriggerInputGlobalDataLPt[Bit/4][Bit%4]=((darcHeader->GetGlobalInput(0)>>Bit)&1);
+        //fTriggerInputGlobalDataLPt[Bit/4+8][Bit%4]=((darcHeader->GetGlobalInput(1)>>Bit)&1);
+        //fTriggerInputGlobalDataHPt[Bit/4][Bit%4]=((darcHeader->GetGlobalInput(2)>>Bit)&1);
+        //fTriggerInputGlobalDataHPt[Bit/4+8][Bit%4]=((darcHeader->GetGlobalInput(3)>>Bit)&1);
+        //}
+
+        for (Int_t i=0; i<4; i++){
+          globalInput[i]=darcHeader->GetGlobalInput(i);
+        }
       }
 
       Int_t nReg = rawStreamTrig.GetRegionalHeaderCount();
@@ -622,16 +698,14 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
 
          AliMUONLocalTrigger inputLocalTrigger;
          inputLocalTrigger.SetLocalStruct(loCircuit, *localStruct);
-         inputTriggerStore.Add(inputLocalTrigger);
+         fTriggerStoreFromRaw->Add(inputLocalTrigger);
 
          countNotifiedBoards++;  
 
          TArrayS xyPattern[2];   
          localStruct->GetXPattern(xyPattern[0]);
          localStruct->GetYPattern(xyPattern[1]);
-         fDigitMaker->TriggerDigits(loCircuit, xyPattern, digitStore);
-         if ( fillScalerHistos ) // Compute total number of strips
-           fDigitMaker->TriggerDigits(loCircuit, xyPatternAll, digitStoreAll);
+         fDigitMaker->TriggerDigits(loCircuit, xyPattern, *fDigitStoreFromRaw);
 
          //Get electronic Decisions from data
 
@@ -641,7 +715,7 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
 
          //Get local in/outputs
          if (Int_t(localStruct->GetDec())!=0){
-             ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggeredBoards))->Fill(loCircuit);
+           FillRawsData(AliMUONQAIndices::kTriggeredBoards,loCircuit);
          }
          else if ( fillScalerHistos ){
            nDeadLocal++;
@@ -650,6 +724,10 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
          // loop over strips
          if ( fillScalerHistos ) {
            Int_t cathode = localStruct->GetComptXY()%2;
+      
+      Int_t offset = 0;
+      if (cathode && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB)) offset = -8;
+
            for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
              if (ibitxy==0){
                AliDebug(AliQAv1::GetQADebugLevel(),"Filling trigger scalers");
@@ -661,15 +739,34 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
                localStruct->GetXY3(ibitxy),
                localStruct->GetXY4(ibitxy)
              };
-
-             for(Int_t ich=0; ich<AliMpConstants::NofTriggerChambers(); ich++){
-               if ( scalerVal[ich] > 0 )
-                 ((TH2F*)GetRawsData(AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + ich))
-                   ->Fill(loCircuit, ibitxy, 2*(Float_t)scalerVal[ich]);
-
-               if ( scalerVal[ich] >= maxNcounts )
-                 nNoisyStrips++;
-             } // loop on chamber
+        
+        
+
+        for(Int_t ich=0; ich<AliMpConstants::NofTriggerChambers(); ich++){
+          // getDetElemId
+          Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromLocalBoard(loCircuit, ich);
+                                       
+          const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId, AliMp::GetCathodType(cathode));
+                                       
+                                       
+          Int_t istrip = ibitxy + offset;
+                                       
+          AliMpPad pad = seg->PadByLocation(loCircuit,istrip,kFALSE);
+          if (!pad.IsValid()) continue;
+          nStripsTot++;
+          
+          // UShort_t pattern = (UShort_t)xyPattern[cathode].At(ich); 
+          // if ((pattern >> ibitxy) & 0x1) nFiredStrips++;
+          
+          if ( scalerVal[ich] > 0 ) {
+            FillRawsData(AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + ich,
+                        loCircuit, istrip, 2*(Float_t)scalerVal[ich]);
+            nFiredStrips++;
+          }
+
+          if ( scalerVal[ich] >= maxNcounts )
+            nNoisyStrips++;
+        } // loop on chamber
            } // loop on strips
          } // scaler event
        } // iLocal
@@ -678,7 +775,7 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
       } // iReg
 
       Float_t readoutErrors[AliMUONQAIndices::kNtrigStructErrorBins] = {
-       ((Float_t)rawStreamTrig.GetLocalEoWErrors())/((Float_t)countAllBoards),
+       countAllBoards>0?((Float_t)rawStreamTrig.GetLocalEoWErrors())/((Float_t)countAllBoards):0,
        ((Float_t)rawStreamTrig.GetRegEoWErrors())/16.,
        ((Float_t)rawStreamTrig.GetGlobalEoWErrors())/6.,
        ((Float_t)rawStreamTrig.GetDarcEoWErrors())/2.
@@ -686,19 +783,19 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     
       for (Int_t ibin=0; ibin<AliMUONQAIndices::kNtrigStructErrorBins; ibin++){
        if ( readoutErrors[ibin] > 0 )
-         ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerReadOutErrors))->Fill(ibin, readoutErrors[ibin]);
+         FillRawsData(AliMUONQAIndices::kTriggerReadOutErrors, ibin, readoutErrors[ibin]);
       }
     } // NextDDL
 
     if ( ! containTriggerData ) return;
 
-    GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents)->Fill(1.);
+    FillRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents,1.);
 
     nDeadLocal += AliMUONConstants::NTriggerCircuit() - countNotifiedBoards;
-    Int_t nStripsTot = digitStoreAll.GetSize();
     if ( nStripsTot > 0 ) { // The value is != 0 only for scaler events
+      AliDebug(AliQAv1::GetQADebugLevel(), Form("nStripsFired %i  nStripsTot %i", nFiredStrips, nStripsTot));
       Float_t fraction[AliMUONQAIndices::kNtrigCalibSummaryBins] = {
-       ((Float_t)(nStripsTot - digitStore.GetSize())) / ((Float_t)nStripsTot),
+       ((Float_t)(nStripsTot - nFiredStrips)) / ((Float_t)nStripsTot),
        //(Float_t)nDeadLocal / ((Float_t)countNotifiedBoards),
        (Float_t)nDeadLocal / ((Float_t)AliMUONConstants::NTriggerCircuit()),
        (Float_t)nDeadRegional / 16.,
@@ -708,14 +805,14 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
 
       for(Int_t ibin = 0; ibin < AliMUONQAIndices::kNtrigCalibSummaryBins; ibin++){
        if ( fraction[ibin] > 0. )
-         ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerCalibSummary))->Fill(ibin, fraction[ibin]);
+         FillRawsData(AliMUONQAIndices::kTriggerCalibSummary,ibin, fraction[ibin]);
       }
     }
 
-  fTriggerProcessor->Digits2Trigger(digitStore,recoTriggerStore);
+  TriggerElectronics()->Digits2Trigger(*fDigitStoreFromRaw,*fTriggerStoreReprocessRaw);
 
   AliMUONGlobalTrigger* recoGlobalTriggerFromLocal;
-  recoGlobalTriggerFromLocal = recoTriggerStore.Global();
+  recoGlobalTriggerFromLocal = fTriggerStoreReprocessRaw->Global();
 
   //Reconstruct Global decision from Global inputs
   UChar_t recoResp = RawTriggerInGlobal2OutGlobal(globalInput);
@@ -723,14 +820,15 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   recoGlobalTriggerFromGlobal.SetFromGlobalResponse(recoResp);
 
   // Compare data and reconstructed decisions and fill histos
-  RawTriggerMatchOutLocal(inputTriggerStore, recoTriggerStore);
+  RawTriggerMatchOutLocal();
   //Fill ratio 44/34 histos
-  FillRatio4434Histos(fgkUpdateRatio4434);
+  for ( Int_t itc=-1; itc<AliQADataMakerRec::GetNEventTrigClasses(); ++itc ) FillRatio4434Histos(fgkUpdateRatio4434, itc, kFALSE);
   //RawTriggerMatchOutLocalInRegional(); // Not tested, hardware read-out doesn't work
   RawTriggerMatchOutGlobal(inputGlobalTrigger, recoGlobalTriggerFromGlobal, 'G');
   // Global, reconstruction from Local inputs: compare data and reconstructed decisions and fill histos
   RawTriggerMatchOutGlobal(inputGlobalTrigger, *recoGlobalTriggerFromLocal, 'L');
   // Global, reconstruction from Global inputs: compare data and reconstructed decisions and fill histos
+  //
 }
 
 //__________________________________________________________________
@@ -740,10 +838,10 @@ void AliMUONTriggerQADataMakerRec::MakeDigits(TTree* digitsTree)
 
   // Do nothing in case of calibration event
   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
-
+  
   if (!fDigitStore)
     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
-
+  
   fDigitStore->Clear();
   fDigitStore->Connect(*digitsTree, false);
   digitsTree->GetEvent(0);
@@ -754,7 +852,7 @@ void AliMUONTriggerQADataMakerRec::MakeDigits(TTree* digitsTree)
   
   while ( ( dig = static_cast<AliMUONVDigit*>(next()) ) )
     {
-    GetDigitsData(0)->Fill(dig->DetElemId());
+      FillDigitsData(0,dig->DetElemId());
     }
 }
 
@@ -766,7 +864,7 @@ void AliMUONTriggerQADataMakerRec::MakeRecPoints(TTree* /*clustersTree*/)
   // Do nothing in case of calibration event
   if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
        
-  GetRecPointsData(AliMUONQAIndices::kTriggerNAnalyzedEvents)->Fill(1.);
+  FillRecPointsData(AliMUONQAIndices::kTriggerNAnalyzedEvents,1.);
 }
 
 //____________________________________________________________________________
@@ -777,7 +875,7 @@ void AliMUONTriggerQADataMakerRec::MakeESDs(AliESDEvent* /*esd*/)
 
 
 //____________________________________________________________________________ 
-void AliMUONTriggerQADataMakerRec::DisplayTriggerInfo()
+void AliMUONTriggerQADataMakerRec::DisplayTriggerInfo(Int_t itc)
 {
   //
   /// Display trigger information in a user-friendly way:
@@ -786,34 +884,34 @@ void AliMUONTriggerQADataMakerRec::DisplayTriggerInfo()
 
   AliMUONTriggerDisplay triggerDisplay;
   
-  TH2F* histoStrips=0x0;
-  TH2F* histoDisplayStrips=0x0;
-  if ( GetRawsData(AliMUONQAIndices::kTriggerScalers) ) {
+  TH2* histoStrips=0x0;
+  TH2* histoDisplayStrips=0x0;
+  if ( GetRawsData(AliMUONQAIndices::kTriggerScalers, itc) ) {
     AliMUONTriggerDisplay::EDisplayOption displayOption = AliMUONTriggerDisplay::kNormalizeToArea;
     for (Int_t iCath = 0; iCath < AliMpConstants::NofCathodes(); iCath++)
       {    
        for (Int_t iChamber = 0; iChamber < AliMpConstants::NofTriggerChambers(); iChamber++)
          {
-           histoStrips = (TH2F*)GetRawsData(AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
+           histoStrips = (TH2*)GetRawsData(AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*iCath + iChamber, itc);
 
            if(histoStrips->GetEntries()==0) continue; // No events found => No need to display
 
-           histoDisplayStrips = (TH2F*)GetRawsData(AliMUONQAIndices::kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber);
+           histoDisplayStrips = (TH2*)GetRawsData(AliMUONQAIndices::kTriggerScalersDisplay + AliMpConstants::NofTriggerChambers()*iCath + iChamber, itc);
 
            triggerDisplay.FillDisplayHistogram(histoStrips, histoDisplayStrips,
                                                AliMUONTriggerDisplay::kDisplayStrips, iCath, iChamber, displayOption);
 
-           Float_t scaleValue = ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerScalersTime))->GetBinContent(1);
+           Float_t scaleValue = ((TH1*)GetRawsData(AliMUONQAIndices::kTriggerScalersTime, itc))->GetBinContent(1);
            if(scaleValue>0.) histoDisplayStrips->Scale(1./scaleValue);
          } // iChamber
       } // iCath
   }
-
-  if ( GetRawsData(AliMUONQAIndices::kTriggeredBoards) ){
-    TH1F* histoBoards = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggeredBoards);
-    TH2F* histoDisplayBoards = (TH2F*)GetRawsData(AliMUONQAIndices::kTriggerBoardsDisplay);
+  
+  if ( GetRawsData(AliMUONQAIndices::kTriggeredBoards, itc) ){
+    TH1* histoBoards = (TH1*)GetRawsData(AliMUONQAIndices::kTriggeredBoards, itc);
+    TH2* histoDisplayBoards = (TH2*)GetRawsData(AliMUONQAIndices::kTriggerBoardsDisplay, itc);
     triggerDisplay.FillDisplayHistogram(histoBoards, histoDisplayBoards, AliMUONTriggerDisplay::kDisplayBoards, 0, 0);
-    Float_t scaleValue = GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents)->GetBinContent(1);
+    Float_t scaleValue = GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents, itc)->GetBinContent(1);
     if(scaleValue>0.) histoDisplayBoards->Scale(1./scaleValue);
   }
 }
@@ -824,10 +922,12 @@ Bool_t
 AliMUONTriggerQADataMakerRec::FillTriggerDCSHistos()
 {
   /// Get HV and currents values for one trigger chamber
-  
+  // RS: Note: the histos involved in this routin are forbidden to be cloned, -1 in GetRawsData returns the default histos
+  int itc = -1;
+  //
   AliCodeTimerAuto("",0);
-
-  TMap* triggerDcsMap = fCalibrationData->TriggerDCS();
+  
+  TMap* triggerDcsMap = CalibrationData()->TriggerDCS();
 
   if ( !triggerDcsMap ) 
   {
@@ -962,7 +1062,7 @@ AliMUONTriggerQADataMakerRec::FillTriggerDCSHistos()
       histoName = Form("hTriggerRPCHVChamber%i", 11+ich);
       histoTitle = Form("Chamber %i: RPC HV (kV)", 11+ich);
 
-      currHisto = (TH2F*)GetRecPointsData(histoIndex);
+      currHisto = (TH2F*)GetRecPointsData(histoIndex,itc); // RS this histo is not cloned
 
       if(!currHisto){
        currHisto  = new TH2F(histoName.Data(), histoTitle.Data(),
@@ -975,6 +1075,7 @@ AliMUONTriggerQADataMakerRec::FillTriggerDCSHistos()
        currHisto->GetYaxis()->SetTitle("RPC");
        currHisto->SetOption("TEXT45COLZ");
        Add2RecPointsList(currHisto, histoIndex, expert, !image);
+       ForbidCloning(currHisto); // RS
       }
 
       Int_t slat = detElemId%100;
@@ -1034,7 +1135,7 @@ AliMUONTriggerQADataMakerRec::FillTriggerDCSHistos()
        previousVal = currVal;
       } // loop on values
       currHisto->SetBinContent(previousBin, slatBin, scaleFactor*sumValuesPerBin/((Double_t)nValuesPerBin)); // Fill last value
-      if ( isTrip ) ((TH1F*)GetRecPointsData(AliMUONQAIndices::kTriggerRPCtrips))->Fill(detElemId);
+      if ( isTrip ) ((TH1*)GetRecPointsData(AliMUONQAIndices::kTriggerRPCtrips,itc))->Fill(detElemId);
     } // if ( values ) 
     deIt.Next();
   } // loop on detElem
@@ -1084,7 +1185,7 @@ UChar_t AliMUONTriggerQADataMakerRec::RawTriggerInGlobal2OutGlobal(UInt_t global
 
     AliCodeTimerAuto("",0);
 
-    AliMUONGlobalCrateConfig* globalConfig = fCalibrationData->GlobalTriggerCrateConfig();
+    AliMUONGlobalCrateConfig* globalConfig = CalibrationData()->GlobalTriggerCrateConfig();
 
     AliMUONGlobalTriggerBoard globalTriggerBoard;
     globalTriggerBoard.Reset();
@@ -1099,12 +1200,10 @@ UChar_t AliMUONTriggerQADataMakerRec::RawTriggerInGlobal2OutGlobal(UInt_t global
 }
 
 //____________________________________________________________________________ 
-void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTriggerStore& inputTriggerStore,
-                                                          const AliMUONVTriggerStore& recoTriggerStore)
+void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal()
 {
   //
   /// Match data and reconstructed Local Trigger decision
-  //
 
   AliCodeTimerAuto("",0);
 
@@ -1115,16 +1214,16 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
 
   // First search for YCopy errors.
   Int_t loCircuit = -1;
-  TIter next(recoTriggerStore.CreateLocalIterator());
+  TIter next(fTriggerStoreReprocessRaw->CreateLocalIterator());
   AliMUONLocalTrigger* recoLocalTrigger, *inputLocalTrigger;
   while ( ( recoLocalTrigger = static_cast<AliMUONLocalTrigger*>(next()) ) )
   {  
     loCircuit = recoLocalTrigger->LoCircuit();
     Int_t iboard = loCircuit - 1;
 
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyTest))->Fill(loCircuit);
+    FillRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyTest,loCircuit);
   
-    inputLocalTrigger = inputTriggerStore.FindLocal(loCircuit);
+    inputLocalTrigger = fTriggerStoreFromRaw->FindLocal(loCircuit);
 
     Int_t recoTrigPattern[4]  = {recoLocalTrigger->GetY1Pattern(), recoLocalTrigger->GetY2Pattern(), recoLocalTrigger->GetY3Pattern(), recoLocalTrigger->GetY4Pattern()};
     Int_t inputTrigPattern[4] = {inputLocalTrigger->GetY1Pattern(), inputLocalTrigger->GetY2Pattern(), inputLocalTrigger->GetY3Pattern(), inputLocalTrigger->GetY4Pattern()};
@@ -1146,11 +1245,11 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
       }
     } // loop on chambers
     if ( errorInCopyBoard )
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopy))->Fill(loCircuit);    
+      FillRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopy,loCircuit);    
   } // loop on local boards
 
   if (errorInYCopy)
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(AliMUONQAIndices::kAlgoLocalYCopy);
+    FillRawsData(AliMUONQAIndices::kTriggerErrorSummary,AliMUONQAIndices::kAlgoLocalYCopy);
   
   Bool_t errorInXPosDev = kFALSE;
   Bool_t errorInYPosTrigY = kFALSE;
@@ -1166,23 +1265,23 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
     // Fill ratio 44/34 histos (if not scaler event)
     if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
       Bool_t is34 = ( recoLocalTrigger->GetLoDecision() != 0 );
-      Bool_t is44 = fTriggerProcessor->ModifiedLocalResponse(loCircuit, respBendPlane, respNonBendPlane, kTRUE);
-      if ( is34 ) ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec))->Fill(loCircuit);
-      if ( is44 ) ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec))->Fill(loCircuit);
+      Bool_t is44 = TriggerElectronics()->ModifiedLocalResponse(loCircuit, respBendPlane, respNonBendPlane, kTRUE);
+      if ( is34 ) FillRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec,loCircuit);
+      if ( is44 ) FillRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec,loCircuit);
 
       if ( is44 && ! is34 )
-       AliWarning("Event satisfies the 4/4 conditions but not the 3/4");
+       AliWarning(Form("Local board %i satisfies the 4/4 conditions but not the 3/4", loCircuit));
     }
     
-    inputLocalTrigger = inputTriggerStore.FindLocal(loCircuit);
+    inputLocalTrigger = fTriggerStoreFromRaw->FindLocal(loCircuit);
 
     if ( recoLocalTrigger->LoStripX() != inputLocalTrigger->LoStripX() ) {
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalXPos))->Fill(loCircuit);
+      FillRawsData(AliMUONQAIndices::kTriggerErrorLocalXPos,loCircuit);
       errorInXPosDev = kTRUE;
     }
-
+    
     if ( recoLocalTrigger->GetDeviation() != inputLocalTrigger->GetDeviation() ) {
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalDev))->Fill(loCircuit);
+      FillRawsData(AliMUONQAIndices::kTriggerErrorLocalDev,loCircuit);
       errorInXPosDev = kTRUE;
     }
 
@@ -1190,7 +1289,7 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
     if ( (!skipBoard[iboard]) || ( (recoLocalTrigger->LoStripY() == inputLocalTrigger->LoStripY()) && (recoLocalTrigger->LoTrigY() == inputLocalTrigger->LoTrigY())) ) {
        
        if ( recoLocalTrigger->GetLoDecision() != inputLocalTrigger->GetLoDecision() ) {
-           ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalTriggerDec))->Fill(loCircuit);
+         FillRawsData(AliMUONQAIndices::kTriggerErrorLocalTriggerDec,loCircuit);
        }
        
        // Test Hpt and LPT
@@ -1204,8 +1303,8 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
            for (Int_t ibit=0; ibit<2; ibit++){
                Bool_t isBitDifferent = (bitDiff>>ibit)&1;
                if ( isBitDifferent ){
-                   ((TH1F*)GetRawsData(currIndex[ilut][ibit]))->Fill(loCircuit);
-                   errorInLUT = kTRUE;
+                 FillRawsData(currIndex[ilut][ibit],loCircuit);
+                 errorInLUT = kTRUE;
                }
            }
        }
@@ -1216,24 +1315,24 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
     if ( skipBoard[iboard] ) continue;
 
     if ( recoLocalTrigger->LoStripY() != inputLocalTrigger->LoStripY() ) {
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalYPos))->Fill(loCircuit);
+      FillRawsData(AliMUONQAIndices::kTriggerErrorLocalYPos,loCircuit);
       errorInYPosTrigY = kTRUE;
     }
 
     if ( recoLocalTrigger->LoTrigY() != inputLocalTrigger->LoTrigY()  ) {
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorLocalTrigY))->Fill(loCircuit);        
+      FillRawsData(AliMUONQAIndices::kTriggerErrorLocalTrigY,loCircuit);       
       errorInYPosTrigY = kTRUE;
     }
   } // loop on local boards
-
+  
   if (errorInXPosDev)
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(AliMUONQAIndices::kAlgoLocalX);
+    FillRawsData(AliMUONQAIndices::kTriggerErrorSummary,AliMUONQAIndices::kAlgoLocalX);
 
   if (errorInLUT)
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(AliMUONQAIndices::kAlgoLocalLUT);
+    FillRawsData(AliMUONQAIndices::kTriggerErrorSummary,AliMUONQAIndices::kAlgoLocalLUT);
 
   if (errorInYPosTrigY)
-    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(AliMUONQAIndices::kAlgoLocalY);
+    FillRawsData(AliMUONQAIndices::kTriggerErrorSummary,AliMUONQAIndices::kAlgoLocalY);
 
 }
 /*
@@ -1270,7 +1369,7 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutGlobal(AliMUONGlobalTrigger
 {
   //
   /// Match data and reconstructed Global Trigger decision for a reconstruction from Global inputs.
-  /// histo='G': fill FromGlobalInput histo='F': fill from Local input;
+  /// histo='G': fill FromGlobalInput histo='L': fill from Local input;
   //
 
   if ( recoGlobalTrigger.GetGlobalResponse() == inputGlobalTrigger.GetGlobalResponse() )
@@ -1286,45 +1385,50 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutGlobal(AliMUONGlobalTrigger
          histoToFill=AliMUONQAIndices::kTriggerErrorOutGlobalFromInLocal;
          binToFill=AliMUONQAIndices::kAlgoGlobalFromLocal;
       }else{
-         AliWarning(Form("Global histos not filled, 3rd argument must be 'G' or 'F'"));
+         AliWarning(Form("Global histos not filled, 3rd argument must be 'G' or 'L'"));
          return;
       } 
   }
 
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerErrorSummary))->Fill(binToFill);
-
-  Bool_t inputResp[6] = {inputGlobalTrigger.PairUnlikeHpt(), inputGlobalTrigger.PairUnlikeLpt(),
-                        inputGlobalTrigger.PairLikeHpt(), inputGlobalTrigger.PairLikeLpt(),
-                        inputGlobalTrigger.SingleHpt(), inputGlobalTrigger.SingleLpt()};
-
-  Bool_t recoResp[6] = {recoGlobalTrigger.PairUnlikeHpt(), recoGlobalTrigger.PairUnlikeLpt(),
-                       recoGlobalTrigger.PairLikeHpt(), recoGlobalTrigger.PairLikeLpt(),
-                       recoGlobalTrigger.SingleHpt(), recoGlobalTrigger.SingleLpt()};
-
+  FillRawsData(AliMUONQAIndices::kTriggerErrorSummary,binToFill);
+  
+  Int_t inputResp[6] = {inputGlobalTrigger.PairUnlikeHpt(), inputGlobalTrigger.PairUnlikeLpt(),
+                       inputGlobalTrigger.PairLikeHpt(), inputGlobalTrigger.PairLikeLpt(),
+                       inputGlobalTrigger.SingleHpt(), inputGlobalTrigger.SingleLpt()};
+  
+  Int_t recoResp[6] = {recoGlobalTrigger.PairUnlikeHpt(), recoGlobalTrigger.PairUnlikeLpt(),
+                      recoGlobalTrigger.PairLikeHpt(), recoGlobalTrigger.PairLikeLpt(),
+                      recoGlobalTrigger.SingleHpt(), recoGlobalTrigger.SingleLpt()};
+  
   for (int bit=0;bit<6;bit++){
     if ( recoResp[bit] != inputResp[bit] )
-      ((TH1F*)GetRawsData(histoToFill))->Fill(bit);
+      FillRawsData(histoToFill,bit);
   }
 }
 
 //____________________________________________________________________________ 
-void AliMUONTriggerQADataMakerRec::FillRatio4434Histos(Int_t evtInterval)
+void AliMUONTriggerQADataMakerRec::FillRatio4434Histos(Int_t evtInterval, Int_t itc, Bool_t isEndOfCycle)
 {
   /// Fill ratio 44/34 histos
-
-  Int_t numEvent = Int_t(((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents))->GetBinContent(1));
+  TH1* histoEvents = ( isEndOfCycle ) ? GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents,itc) : GetMatchingRawsHisto(AliMUONQAIndices::kTriggerRawNAnalyzedEvents,itc);
+  if ( ! histoEvents ) return;
+  Int_t numEvent = Int_t(histoEvents->GetBinContent(1));
 
   // Fill every fgkUpdateRatio4434 events
   if (numEvent % evtInterval != 0)
     return;
-
-  Float_t totalNumberOf44 = ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec))->GetSumOfWeights();
-  Float_t totalNumberOf34 = ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec))->GetSumOfWeights();
+  
+  TH1* histo44dec = ( isEndOfCycle ) ? GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec,itc) : GetMatchingRawsHisto(AliMUONQAIndices::kTriggerNumberOf44Dec,itc);
+  TH1* histo34dec = ( isEndOfCycle ) ? GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec,itc) : GetMatchingRawsHisto(AliMUONQAIndices::kTriggerNumberOf34Dec,itc);
+  
+  Float_t totalNumberOf44 = histo44dec->GetSumOfWeights();
+  Float_t totalNumberOf34 = histo34dec->GetSumOfWeights();
 
   if ( totalNumberOf34 == 0 )
     return;
 
-  TH1F* histoAllEvents = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents);
+  TH1* histoAllEvents = ( isEndOfCycle ) ? GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents,itc) : GetMatchingRawsHisto(AliMUONQAIndices::kTriggerRatio4434AllEvents,itc);
+  
   if ( ! histoAllEvents ) return;
   Int_t nbins =  histoAllEvents->GetNbinsX();
   Float_t maxBin = histoAllEvents->GetXaxis()->GetBinLowEdge(nbins+1);
@@ -1346,11 +1450,13 @@ void AliMUONTriggerQADataMakerRec::FillRatio4434Histos(Int_t evtInterval)
 
   Int_t newNbins = ( (Int_t)maxBin % fgkUpdateRatio4434 ) ? nbins : nbins+1;
   TString cloneName;
+  
+  TH1* histoRatioSinceLastUpdate = ( isEndOfCycle ) ? GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate,itc) : GetMatchingRawsHisto(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate,itc);
 
-  Int_t hIndex[2] = {AliMUONQAIndices::kTriggerRatio4434AllEvents, AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate};
+  TH1* histos[2] = {histoAllEvents, histoRatioSinceLastUpdate};
   
   for (Int_t ihisto=0; ihisto<2; ihisto++){
-    TH1F* currHisto = (TH1F*)GetRawsData(hIndex[ihisto]);
+    TH1* currHisto = histos[ihisto];
     cloneName = Form("%sClone", currHisto->GetName());
     TArrayD newAxis(newNbins+1);
     for (Int_t ibin=0; ibin<newNbins; ibin++){
@@ -1384,11 +1490,42 @@ void AliMUONTriggerQADataMakerRec::FillRatio4434Histos(Int_t evtInterval)
     errorRatio4434Update = ProtectedSqrt(numOf44Update*(1-ratio4434Update))/numOf34Update;
   }
 
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBinContent(newNbins,ratio4434Update);
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBinError(newNbins,errorRatio4434Update);
+  histoRatioSinceLastUpdate->SetBinContent(newNbins,ratio4434Update);
+  histoRatioSinceLastUpdate->SetBinError(newNbins,errorRatio4434Update);
 
   histoAllEvents->SetBinContent(0,totalNumberOf34);
   histoAllEvents->SetBinContent(newNbins+1,totalNumberOf44);
 
 }
 
+
+//____________________________________________________________________________ 
+AliMUONTriggerElectronics* AliMUONTriggerQADataMakerRec::TriggerElectronics()
+{
+  /// Return trigger electronics
+  /// (create it if necessary)
+  if ( ! fTriggerProcessor ) 
+    fTriggerProcessor = new AliMUONTriggerElectronics(CalibrationData());
+  return fTriggerProcessor;
+}
+
+
+//____________________________________________________________________________ 
+AliMUONCalibrationData* AliMUONTriggerQADataMakerRec::CalibrationData()
+{
+  /// Return calibration data
+  /// (create it if necessary)
+  if ( ! fCalibrationData ) fCalibrationData = new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun());
+  return fCalibrationData;
+}
+
+//____________________________________________________________________________ 
+void AliMUONTriggerQADataMakerRec::ResetDetectorRaws(TObjArray* list)
+{
+  /// Reset the calibration data
+  ResetDetector(list);
+  delete fTriggerProcessor;
+  fTriggerProcessor = 0x0;
+  delete fCalibrationData;
+  fCalibrationData = 0x0;
+}