]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerQADataMakerRec.cxx
Changed signature of store digits to correspond to base class
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerQADataMakerRec.cxx
index 9638decf41cdbacf99c395eabc9efd3f4bcbe312..75079da5714190e4b0f3c9fc9101d4a4d57f905f 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
 {
@@ -72,8 +75,6 @@ namespace
 //____________________________________________________________________________ 
 AliMUONTriggerQADataMakerRec::AliMUONTriggerQADataMakerRec(AliQADataMakerRec* master) : 
 AliMUONVQADataMakerRec(master),
-fNumberOf34Dec(0x0),
-fNumberOf44Dec(0x0),
 fDigitMaker(new AliMUONDigitMaker(kFALSE)),
 fCalibrationData(new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun())),
 fTriggerProcessor(new AliMUONTriggerElectronics(fCalibrationData)),
@@ -91,8 +92,6 @@ AliMUONTriggerQADataMakerRec::~AliMUONTriggerQADataMakerRec()
   delete fDigitStore;
   delete fTriggerProcessor;
   delete fCalibrationData;
-  delete fNumberOf34Dec;
-  delete fNumberOf44Dec;
 }
 
 //____________________________________________________________________________ 
@@ -153,15 +152,21 @@ void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleRaws(Int_t /*specie*/, TObj
   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
 
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434))->Divide(fNumberOf44Dec,fNumberOf34Dec);
+  TH1F* hTriggerRatio = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434);
+  if ( hTriggerRatio ){
+    hTriggerRatio->Divide(((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec)),((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec)));
 
-  //reset bins temporary used to store informations
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(1,0); 
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(2,0);
+    FillRatio4434Histos(1);
 
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434))->SetMaximum(1.1);
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetMaximum(1.1);
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetMaximum(1.1);
+    //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);
+
+    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerLocalRatio4434))->SetMaximum(1.1);
+    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetMaximum(1.1);
+    ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetMaximum(1.1);
+  }
 }
 
 //____________________________________________________________________________ 
@@ -229,7 +234,7 @@ 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);
@@ -287,19 +292,21 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalTrigY, expert, !image, !saveCorr);
 
-  histo1D = new TH1F("hTriggerRatio4434Local", "Ratio4434Local",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
-  histo1D->GetXaxis()->SetTitle(boardName.Data());
-  histo1D->GetYaxis()->SetTitle("ratio 44/34");
-  Add2RawsList(histo1D, AliMUONQAIndices::kTriggerLocalRatio4434, expert, !image, !saveCorr);                                               
-  histo1D = new TH1F("hTriggerRatio4434AllEvents", "Ratio4434AllEvents",1,0,1);
-  histo1D->GetXaxis()->SetTitle("Event number");
-  histo1D->GetYaxis()->SetTitle("ratio 44/34");
-  histo1D->SetLineColor(4);                           
-  Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRatio4434AllEvents, expert, !image, !saveCorr);                                               
-  histo1D = new TH1F("hTriggerRatio4434SinceLastUpdate", "Ratio4434SinceLastUpdate",1,0,1);
-  histo1D->GetXaxis()->SetTitle("Event number");
-  histo1D->GetYaxis()->SetTitle("ratio 44/34");                           
-  Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate, expert, !image, !saveCorr);
+  if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
+    histo1D = new TH1F("hTriggerRatio4434Local", "Ratio4434Local",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
+    histo1D->GetXaxis()->SetTitle(boardName.Data());
+    histo1D->GetYaxis()->SetTitle("ratio 44/34");
+    Add2RawsList(histo1D, AliMUONQAIndices::kTriggerLocalRatio4434, expert, !image, !saveCorr);                                               
+    histo1D = new TH1F("hTriggerRatio4434AllEvents", "Ratio4434AllEvents",1,0,1);
+    histo1D->GetXaxis()->SetTitle("Event number");
+    histo1D->GetYaxis()->SetTitle("ratio 44/34");
+    histo1D->SetLineColor(4);                           
+    Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRatio4434AllEvents, expert, !image, !saveCorr);                                               
+    histo1D = new TH1F("hTriggerRatio4434SinceLastUpdate", "Ratio4434SinceLastUpdate",1,0,1);
+    histo1D->GetXaxis()->SetTitle("Event number");
+    histo1D->GetYaxis()->SetTitle("ratio 44/34");                           
+    Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate, expert, !image, !saveCorr);
+  }
 
   histo1D = new TH1F("hTriggerErrorLocal2RegionalLPtLSB", "ErrorLocal2RegionalLPtLSB",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
   histo1D->GetXaxis()->SetTitle(boardName.Data());
@@ -343,7 +350,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
@@ -381,7 +388,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);
@@ -397,9 +404,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);
@@ -411,10 +418,20 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   histo1D->GetYaxis()->SetTitle("Number of analyzed events");
   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRawNAnalyzedEvents, expert, !image, !saveCorr);
 
-  fNumberOf34Dec = new TH1F("hTriggerNumberOf34Dec", "hNumberOf34Dec",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
-  fNumberOf34Dec->SetDirectory(0); // Detach histo from file to avoid double delete
-  fNumberOf44Dec = new TH1F("hTriggerNumberOf44Dec", "hNumberOf44Dec",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
-  fNumberOf44Dec->SetDirectory(0); // Detach histo from file to avoid double delete
+  if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
+    histo1D = new TH1F("hTriggerNumberOf34Dec", "Number of 3/4",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
+    histo1D->GetXaxis()->SetTitle(boardName.Data());
+    histo1D->GetYaxis()->SetTitle("Number of 3/4");
+    Add2RawsList(histo1D, AliMUONQAIndices::kTriggerNumberOf34Dec, expert, !image, !saveCorr);
+
+    histo1D = new TH1F("hTriggerNumberOf44Dec", "Number of 4/4",nbLocalBoard,0.5,(Float_t)nbLocalBoard+0.5);
+    histo1D->GetXaxis()->SetTitle(boardName.Data());
+    histo1D->GetYaxis()->SetTitle("Number of 4/4");
+    Add2RawsList(histo1D, AliMUONQAIndices::kTriggerNumberOf44Dec, expert, !image, !saveCorr);
+  }
+  
+  Add2RawsList(new TH1F("hTriggerIsThere","trigger is there",1,0,1),AliMUONQAIndices::kTriggerIsThere,kTRUE,kFALSE,kFALSE);
+
 }
 
 //__________________________________________________________________
@@ -485,13 +502,6 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     //}
 
     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;
 
@@ -511,6 +521,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
@@ -619,8 +630,6 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
          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);
 
          //Get electronic Decisions from data
 
@@ -639,6 +648,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");
@@ -650,15 +663,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 ) {
+            ((TH2F*)GetRawsData(AliMUONQAIndices::kTriggerScalers + AliMpConstants::NofTriggerChambers()*cathode + ich))
+              ->Fill(loCircuit, istrip, 2*(Float_t)scalerVal[ich]);
+            nFiredStrips++;
+          }
+
+          if ( scalerVal[ich] >= maxNcounts )
+            nNoisyStrips++;
+        } // loop on chamber
            } // loop on strips
          } // scaler event
        } // iLocal
@@ -680,13 +712,14 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     } // NextDDL
 
     if ( ! containTriggerData ) return;
+
     GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents)->Fill(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.,
@@ -713,7 +746,7 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   // Compare data and reconstructed decisions and fill histos
   RawTriggerMatchOutLocal(inputTriggerStore, recoTriggerStore);
   //Fill ratio 44/34 histos
-  FillRatio4434Histos();
+  FillRatio4434Histos(fgkUpdateRatio4434);
   //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
@@ -1087,8 +1120,8 @@ UChar_t AliMUONTriggerQADataMakerRec::RawTriggerInGlobal2OutGlobal(UInt_t global
 }
 
 //____________________________________________________________________________ 
-void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(AliMUONVTriggerStore& inputTriggerStore,
-                                                          AliMUONVTriggerStore& recoTriggerStore)
+void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTriggerStore& inputTriggerStore,
+                                                          const AliMUONVTriggerStore& recoTriggerStore)
 {
   //
   /// Match data and reconstructed Local Trigger decision
@@ -1151,9 +1184,16 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(AliMUONVTriggerStore&
     loCircuit = recoLocalTrigger->LoCircuit();
     Int_t iboard = loCircuit - 1;
   
-    // Fill ratio 44/34 histos
-    if (recoLocalTrigger->GetLoDecision()!=0) fNumberOf34Dec->Fill(loCircuit);
-    if (fTriggerProcessor->ModifiedLocalResponse(loCircuit, respBendPlane, respNonBendPlane, kTRUE)) fNumberOf44Dec->Fill(loCircuit);
+    // 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);
+
+      if ( is44 && ! is34 )
+       AliWarning("Event satisfies the 4/4 conditions but not the 3/4");
+    }
     
     inputLocalTrigger = inputTriggerStore.FindLocal(loCircuit);
 
@@ -1289,54 +1329,87 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutGlobal(AliMUONGlobalTrigger
 }
 
 //____________________________________________________________________________ 
-void AliMUONTriggerQADataMakerRec::FillRatio4434Histos()
+void AliMUONTriggerQADataMakerRec::FillRatio4434Histos(Int_t evtInterval)
 {
   /// Fill ratio 44/34 histos
 
   Int_t numEvent = Int_t(((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents))->GetBinContent(1));
 
-  if (numEvent % fgkUpdateRatio4434 == 0){
-      Float_t totalNumberOf44 = fNumberOf44Dec->GetSumOfWeights();
-      Float_t totalNumberOf34 = fNumberOf34Dec->GetSumOfWeights();
-      Float_t ratio4434;
-      Float_t errorRatio4434;
-
-    if(totalNumberOf34!=0){
-      ratio4434 = totalNumberOf44/totalNumberOf34;
-      errorRatio4434 = ProtectedSqrt(totalNumberOf44*(1-ratio4434))/totalNumberOf34;
-    }else{
-      ratio4434 = 0;
-      errorRatio4434 = 0;
-    }
-    
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(numEvent,ratio4434);
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinError(numEvent,errorRatio4434);
+  // 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();
+
+  if ( totalNumberOf34 == 0 )
+    return;
+
+  TH1F* histoAllEvents = (TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents);
+  if ( ! histoAllEvents ) return;
+  Int_t nbins =  histoAllEvents->GetNbinsX();
+  Float_t maxBin = histoAllEvents->GetXaxis()->GetBinLowEdge(nbins+1);
 
+  if ( numEvent - maxBin < 1) return;
 
-      Float_t NumberOf44Update = totalNumberOf44 - ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->GetBinContent(2);
-      Float_t NumberOf34Update = totalNumberOf34 - ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->GetBinContent(1);
-      Float_t ratio4434Update;
-      Float_t errorRatio4434Update;
+  // Use the underflow and overflow to store the number of 34 and 44
+  // in previous event
+  Float_t previousNumOf34 = histoAllEvents->GetBinContent(0);
+  Float_t previousNumOf44 = histoAllEvents->GetBinContent(nbins+1);
 
-    if(NumberOf34Update!=0){
-      ratio4434Update = NumberOf44Update/NumberOf34Update;
-      errorRatio4434Update = ProtectedSqrt(NumberOf44Update*(1-ratio4434Update))/NumberOf34Update;
-    }else{
-      ratio4434Update = 0;
-      errorRatio4434Update = 0;
+  Float_t numOf34Update = totalNumberOf34 - previousNumOf34;
+  Float_t numOf44Update = totalNumberOf44 - previousNumOf44;
+
+  // Not enough new tracks since last update
+  //if ( numOf34Update == 0 && numOf44Update == 0 )
+  if ( numOf34Update < evtInterval - 1 )
+    return;
+
+  Int_t newNbins = ( (Int_t)maxBin % fgkUpdateRatio4434 ) ? nbins : nbins+1;
+  TString cloneName;
+
+  Int_t hIndex[2] = {AliMUONQAIndices::kTriggerRatio4434AllEvents, AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate};
+  
+  for (Int_t ihisto=0; ihisto<2; ihisto++){
+    TH1F* currHisto = (TH1F*)GetRawsData(hIndex[ihisto]);
+    cloneName = Form("%sClone", currHisto->GetName());
+    TArrayD newAxis(newNbins+1);
+    for (Int_t ibin=0; ibin<newNbins; ibin++){
+      newAxis[ibin] = currHisto->GetXaxis()->GetBinLowEdge(ibin+1);
     }
+    newAxis[newNbins] = numEvent;
+    TH1F* copyHisto = (TH1F*)currHisto->Clone(cloneName.Data());
+    //currHisto->SetBins(newNbins, 0., fgkUpdateRatio4434*newNbins);
+    currHisto->SetBins(newNbins, newAxis.GetArray());
+    for (Int_t ibin=1; ibin<newNbins; ibin++){
+      currHisto->SetBinContent(ibin, copyHisto->GetBinContent(ibin));
+      currHisto->SetBinError(ibin, copyHisto->GetBinError(ibin));
+    }
+    delete copyHisto;
+  }
+
+  Float_t ratio4434 = totalNumberOf44/totalNumberOf34;
+  Float_t errorRatio4434 = ProtectedSqrt(totalNumberOf44*(1-ratio4434))/totalNumberOf34;
     
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBinContent(numEvent,ratio4434Update);
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBinError(numEvent,errorRatio4434Update);
+  histoAllEvents->SetBinContent(newNbins,ratio4434);
+  histoAllEvents->SetBinError(newNbins,errorRatio4434);
 
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(1,totalNumberOf34);
-      ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBinContent(2,totalNumberOf44);
-   
+  Float_t ratio4434Update = 0.;
+  Float_t errorRatio4434Update = 0.;
+
+  if(numOf34Update!=0){
+    ratio4434Update = numOf44Update/numOf34Update;
+    if ( numOf44Update > numOf34Update ){
+      AliWarning(Form("Number of 4/4 (%f) is higher than number of 3/4 (%f)", numOf44Update, numOf34Update));
+    }
+    errorRatio4434Update = ProtectedSqrt(numOf44Update*(1-ratio4434Update))/numOf34Update;
   }
-  
-  Int_t newNBins = ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->GetNbinsX()+1;
-  
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434AllEvents))->SetBins(newNBins,0,newNBins);
-  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBins(newNBins,0,newNBins);
+
+  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBinContent(newNbins,ratio4434Update);
+  ((TH1F*)GetRawsData(AliMUONQAIndices::kTriggerRatio4434SinceLastUpdate))->SetBinError(newNbins,errorRatio4434Update);
+
+  histoAllEvents->SetBinContent(0,totalNumberOf34);
+  histoAllEvents->SetBinContent(newNbins+1,totalNumberOf44);
+
 }