]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerQADataMakerRec.cxx
SetFlag GetFlag lifted to interface
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerQADataMakerRec.cxx
index 2a9a78e9ffe9d0c6044e4731d83a784f2bc36f32..454e9d6b3fdac191480eb2ee06378058051f8a3a 100644 (file)
@@ -64,6 +64,7 @@ ClassImp(AliMUONTriggerQADataMakerRec)
 #include "AliMpPad.h"
 #include "AliMpVSegmentation.h"
 #include "AliMpSegmentation.h"
+#include "AliMUONTriggerUtilities.h"
 
 namespace
 {
@@ -78,7 +79,11 @@ AliMUONVQADataMakerRec(master),
 fDigitMaker(new AliMUONDigitMaker(kFALSE)),
 fCalibrationData(0x0),
 fTriggerProcessor(0x0),
-fDigitStore(0x0)
+fDigitStore(0x0),
+fDigitStoreFromRaw(0x0),
+fTriggerStoreFromRaw(0x0),
+fTriggerStoreReprocessRaw(0x0),
+fTriggerUtils(0x0)
 {
     /// ctor
 }
@@ -89,9 +94,13 @@ AliMUONTriggerQADataMakerRec::~AliMUONTriggerQADataMakerRec()
 {
     /// dtor
   delete fDigitMaker;
-  delete fDigitStore;
   delete fTriggerProcessor;
   delete fCalibrationData;
+  delete fDigitStore;
+  delete fDigitStoreFromRaw;
+  delete fTriggerStoreFromRaw;
+  delete fTriggerStoreReprocessRaw;
+  delete fTriggerUtils;
 }
 
 //____________________________________________________________________________ 
@@ -138,8 +147,9 @@ void AliMUONTriggerQADataMakerRec::EndOfDetectorCycleRaws(Int_t /*specie*/, TObj
     // 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++){
+      Float_t nbevent = ( histoRawsIndex[ihisto] == AliMUONQAIndices::kTriggerReadOutErrors ) ? histo1D->GetBinContent(1) : histo1D->GetBinContent(2);
       TH1* inputHisto = GetRawsData(histoRawsIndex[ihisto],itc);
       TH1* scaledHisto = GetRawsData(histoRawsScaledIndex[ihisto],itc);
       // Check here for both since we do not clone Calib-only histograms
@@ -200,7 +210,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   // 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 ; 
@@ -215,7 +225,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   AliMUONTriggerDisplay triggerDisplay;
 
   TString histoName, histoTitle;
-  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) {
+  if ( CurrentEventSpecie() == AliRecoParam::kCalib ) {
     histo1D = new TH1F("hTriggerScalersTime", "Acquisition time from trigger scalers", 1, 0.5, 1.5);
     histo1D->GetXaxis()->SetBinLabel(1, "One-bin histogram: bin is filled at each scaler event.");
     histo1D->GetYaxis()->SetTitle("Cumulated scaler time (s)");
@@ -251,7 +261,8 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
       } // loop on chambers
     } // loop on cathodes    
 
-    TString axisLabel[AliMUONQAIndices::kNtrigCalibSummaryBins] = {"#splitline{Dead}{Channels}", "#splitline{Dead}{Local Boards}", "#splitline{Dead}{Regional Boards}", "#splitline{Dead}{Global Board}", "#splitline{Noisy}{Strips}"};
+    //TString axisLabel[AliMUONQAIndices::kNtrigCalibSummaryBins] = {"#splitline{Dead}{Channels}", "#splitline{Dead}{Local Boards}", "#splitline{Dead}{Regional Boards}", "#splitline{Dead}{Global Board}", "#splitline{Noisy}{Strips}"};
+    TString axisLabel[AliMUONQAIndices::kNtrigCalibSummaryBins] = {"#splitline{Dead}{Channels}", "#splitline{Dead}{Local Boards}", "#splitline{Dead}{Regional Boards}", "#splitline{Dead}{Global Board}", ""}; // Change for nosiy strips
 
     TH1F* histoCalib = new TH1F("hTriggerCalibSummaryAll", "MTR calibration summary counts", AliMUONQAIndices::kNtrigCalibSummaryBins, -0.5, (Float_t)AliMUONQAIndices::kNtrigCalibSummaryBins - 0.5);
     for (Int_t ibin=1; ibin<=AliMUONQAIndices::kNtrigCalibSummaryBins; ibin++){
@@ -324,7 +335,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   histo1D->GetYaxis()->SetTitle(errorAxisTitle.Data());
   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerErrorLocalTrigY, expert, !image, !saveCorr);
 
-  if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
+  if ( CurrentEventSpecie() != 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");
@@ -444,13 +455,14 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   Add2RawsList(histoGlobalMult,     AliMUONQAIndices::kTriggerGlobalOutput,     expert, !image, !saveCorr);
   Add2RawsList(histoGlobalMultNorm, AliMUONQAIndices::kTriggerGlobalOutputNorm, expert, !image, !saveCorr);
 
-  histo1D = new TH1F("hTriggerRawNAnalyzedEvents", "Number of analyzed events per specie", 1, 0.5, 1.5);
-  Int_t esindex = AliRecoParam::AConvert(CurrentEventSpecie());
-  histo1D->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(esindex));
+  histo1D = new TH1F("hTriggerRawNAnalyzedEvents", "Number of analyzed events per specie", 2, 0.5, 2.5);
+  //histo1D->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(CurrentEventSpecie()));
+  histo1D->GetXaxis()->SetBinLabel(1,"All");
+  histo1D->GetXaxis()->SetBinLabel(2,"w/o Readout errors");
   histo1D->GetYaxis()->SetTitle("Number of analyzed events");
   Add2RawsList(histo1D, AliMUONQAIndices::kTriggerRawNAnalyzedEvents, expert, !image, !saveCorr);
 
-  if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
+  if ( CurrentEventSpecie() != 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");
@@ -465,7 +477,7 @@ void AliMUONTriggerQADataMakerRec::InitRaws()
   histo1D = new TH1F("hTriggerIsThere","trigger is there",1,0,1);
   Add2RawsList(histo1D,AliMUONQAIndices::kTriggerIsThere,kTRUE,kFALSE,kFALSE);
 
-  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) {
+  if ( CurrentEventSpecie() == 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");
@@ -515,8 +527,7 @@ void AliMUONTriggerQADataMakerRec::InitRecPoints()
   TH1F* histo1D = 0x0;
 
   histo1D = new TH1F("hTriggerNAnalyzedEvents", "Number of analyzed events per specie", 1, 0.5, 1.5);
-  Int_t esindex = AliRecoParam::AConvert(CurrentEventSpecie());
-  histo1D->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(esindex));
+  histo1D->GetXaxis()->SetBinLabel(1, AliRecoParam::GetEventSpecieName(CurrentEventSpecie()));
   histo1D->GetYaxis()->SetTitle("Number of analyzed events");
   Add2RecPointsList(histo1D, AliMUONQAIndices::kTriggerNAnalyzedEvents, expert, !image);
   ForbidCloning(histo1D);
@@ -564,20 +575,20 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     //fTriggerInputGlobalDataHPt[reg][bit]=0;
     //}
     //}
-
-    AliMUONDigitStoreV2R digitStore;
-    
-    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;
 
-    UShort_t maxNcounts = 0xFFFF;
+    //UShort_t maxNcounts = 0xFFFF; // Uncomment for noisy strips
     
     // Get trigger Local, Regional, Global in/outputs and scalers
-
-    Int_t loCircuit=0;
+  
     AliMpCDB::LoadDDLStore();
 
     const AliMUONRawStreamTriggerHP::AliHeader*          darcHeader  = 0x0;
@@ -589,22 +600,31 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
 
     // When a crate is not present, the loop on boards is not performed
     // This should allow to correctly count the local boards
-    Int_t countNotifiedBoards = 0, countAllBoards = 0;
+    Int_t countAllBoards = 0;
 
     Bool_t containTriggerData = kFALSE;
+    Bool_t hasReadoutErrors = kFALSE;
     AliMUONRawStreamTriggerHP rawStreamTrig(rawReader);
     while (rawStreamTrig.NextDDL()) 
       {
        containTriggerData = kTRUE;
 
-      Bool_t scalerEvent =  rawReader->GetDataHeader()->GetL1TriggerMessage() & 0x1;
+       const AliRawDataHeader * cdh = rawReader->GetDataHeader();
+       const AliRawDataHeaderV3 * cdh3 = rawReader->GetDataHeaderV3();
+       
+       if (!cdh && !cdh3) continue;
+
+       Bool_t scalerEvent = ((cdh ?  cdh->GetL1TriggerMessage() : cdh3->GetL1TriggerMessage()) & 0x1) == 0x1;
+
+        if ( scalerEvent ) AliDebug(1,Form("Scaler event: evtSpecie recoParam %s  QA %s\n",
+                                           AliRecoParam::GetEventSpecieName(AliRecoParam::Convert(GetRecoParam()->GetEventSpecie())),
+                                           AliRecoParam::GetEventSpecieName(CurrentEventSpecie())));
 
       Bool_t fillScalerHistos = ( scalerEvent && 
-                                 ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) );
+                                 ( CurrentEventSpecie() == AliRecoParam::kCalib ) );
 
       if ( scalerEvent != fillScalerHistos ) {
-       Int_t esindex = AliRecoParam::AConvert(CurrentEventSpecie());
-       AliWarning(Form("Scaler event found but event specie is %s. Scaler histos will not be filled", AliRecoParam::GetEventSpecieName(esindex)));
+        AliWarning(Form("Scaler event found but event specie is %s. Scaler histos will not be filled", AliRecoParam::GetEventSpecieName(CurrentEventSpecie())));
       }
 
       darcHeader = rawStreamTrig.GetHeaders();
@@ -675,44 +695,38 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
 
          // if card exist
          if (!localStruct) continue;
-          
-         loCircuit = crate->GetLocalBoardId(localStruct->GetId());
+    
+         Int_t loCircuit = crate->GetLocalBoardId(localStruct->GetId());
 
          if ( !loCircuit ) continue; // empty slot
-
+    
          AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
 
          nBoardsInReg++; // Not necessary when regional output will work
          countAllBoards++;
 
-         // skip copy cards
-         if( !localBoard->IsNotified()) 
-           continue;
-
          AliMUONLocalTrigger inputLocalTrigger;
          inputLocalTrigger.SetLocalStruct(loCircuit, *localStruct);
-         inputTriggerStore.Add(inputLocalTrigger);
-
-         countNotifiedBoards++;  
+         fTriggerStoreFromRaw->Add(inputLocalTrigger);
 
          TArrayS xyPattern[2];   
          localStruct->GetXPattern(xyPattern[0]);
          localStruct->GetYPattern(xyPattern[1]);
-         fDigitMaker->TriggerDigits(loCircuit, xyPattern, digitStore);
+         fDigitMaker->TriggerDigits(loCircuit, xyPattern, *fDigitStoreFromRaw);
 
          //Get electronic Decisions from data
 
          //Get regional inputs -> not checked, hardware read-out doesn't work
          //fTriggerInputRegionalDataLPt[0][loCircuit]=Int_t(((regHeader->GetInput(0))>>(2*iLocal))&1);
          //fTriggerInputRegionalDataLPt[1][loCircuit]=Int_t(((regHeader->GetInput(1))>>((2*iLocal)+1))&1);
+    
+    if ( ! localBoard->IsNotified() ) continue;
 
          //Get local in/outputs
          if (Int_t(localStruct->GetDec())!=0){
            FillRawsData(AliMUONQAIndices::kTriggeredBoards,loCircuit);
          }
-         else if ( fillScalerHistos ){
-           nDeadLocal++;
-         }
+         else if ( fillScalerHistos && ! TriggerUtilities()->IsMaskedBoard(loCircuit) ) nDeadLocal++;
 
          // loop over strips
          if ( fillScalerHistos ) {
@@ -746,7 +760,7 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
                                        
           AliMpPad pad = seg->PadByLocation(loCircuit,istrip,kFALSE);
           if (!pad.IsValid()) continue;
-          nStripsTot++;
+          if ( ! TriggerUtilities()->IsMasked(pad, detElemId, cathode)) nStripsTot++;
           
           // UShort_t pattern = (UShort_t)xyPattern[cathode].At(ich); 
           // if ((pattern >> ibitxy) & 0x1) nFiredStrips++;
@@ -757,42 +771,52 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
             nFiredStrips++;
           }
 
-          if ( scalerVal[ich] >= maxNcounts )
-            nNoisyStrips++;
+          //if ( scalerVal[ich] >= maxNcounts ) nNoisyStrips++; // Uncomment for noisy strips
         } // loop on chamber
            } // loop on strips
          } // scaler event
        } // iLocal
-       if ( nBoardsInReg == 0 )
-         nDeadRegional++; // Not necessary when regional output will work
+        if ( nBoardsInReg == 0 ) {
+          // Check masks
+          Int_t nMaskedInReg = 0;
+          for ( Int_t iLocal = 0; iLocal < crate->GetNofLocalBoards(); ++iLocal ) {
+            Int_t loCircuit = crate->GetLocalBoardId(iLocal);
+            if ( TriggerUtilities()->IsMaskedBoard(loCircuit) ) nMaskedInReg++;
+          }
+          if ( nMaskedInReg != crate->GetNofLocalBoards() ) nDeadRegional++; // Not necessary when regional output will work
+        }
       } // iReg
 
       Float_t readoutErrors[AliMUONQAIndices::kNtrigStructErrorBins] = {
-       ((Float_t)rawStreamTrig.GetLocalEoWErrors())/((Float_t)countAllBoards),
-       ((Float_t)rawStreamTrig.GetRegEoWErrors())/16.,
-       ((Float_t)rawStreamTrig.GetGlobalEoWErrors())/6.,
-       ((Float_t)rawStreamTrig.GetDarcEoWErrors())/2.
+       countAllBoards>0?((Float_t)rawStreamTrig.GetLocalEoWErrors())/((Float_t)countAllBoards):0,
+       static_cast<Float_t>(((Float_t)rawStreamTrig.GetRegEoWErrors())/16.),
+       static_cast<Float_t>(((Float_t)rawStreamTrig.GetGlobalEoWErrors())/6.),
+       static_cast<Float_t>(((Float_t)rawStreamTrig.GetDarcEoWErrors())/2.)
       };
     
       for (Int_t ibin=0; ibin<AliMUONQAIndices::kNtrigStructErrorBins; ibin++){
-       if ( readoutErrors[ibin] > 0 )
-         FillRawsData(AliMUONQAIndices::kTriggerReadOutErrors, ibin, readoutErrors[ibin]);
+        if ( readoutErrors[ibin] > 0 ) {
+          hasReadoutErrors = kTRUE;
+          FillRawsData(AliMUONQAIndices::kTriggerReadOutErrors, ibin, readoutErrors[ibin]);
+        }
       }
     } // NextDDL
 
     if ( ! containTriggerData ) return;
 
     FillRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents,1.);
+  
+  // Do not check algorithm if there are ReadOut errors
+  if ( hasReadoutErrors ) return; // COMMENT if you want to check events with readout errors as well
+  FillRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents,2.);
 
-    nDeadLocal += AliMUONConstants::NTriggerCircuit() - countNotifiedBoards;
     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 - nFiredStrips)) / ((Float_t)nStripsTot),
-       //(Float_t)nDeadLocal / ((Float_t)countNotifiedBoards),
-       (Float_t)nDeadLocal / ((Float_t)AliMUONConstants::NTriggerCircuit()),
-       (Float_t)nDeadRegional / 16.,
-       (Float_t)nDeadGlobal / 6., // Number of bits of global response
+        (Float_t)nDeadLocal / ((Float_t)AliMUONConstants::NTriggerCircuit()),
+       static_cast<Float_t>((Float_t)nDeadRegional / 16.),
+       static_cast<Float_t>((Float_t)nDeadGlobal / 6.), // Number of bits of global response
        (Float_t)nNoisyStrips / ((Float_t)nStripsTot),
       };
 
@@ -802,10 +826,10 @@ void AliMUONTriggerQADataMakerRec::MakeRaws(AliRawReader* rawReader)
       }
     }
 
-  TriggerElectronics()->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);
@@ -813,7 +837,7 @@ 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
   for ( Int_t itc=-1; itc<AliQADataMakerRec::GetNEventTrigClasses(); ++itc ) FillRatio4434Histos(fgkUpdateRatio4434, itc, kFALSE);
   //RawTriggerMatchOutLocalInRegional(); // Not tested, hardware read-out doesn't work
@@ -830,7 +854,7 @@ void AliMUONTriggerQADataMakerRec::MakeDigits(TTree* digitsTree)
   /// makes data from Digits
 
   // Do nothing in case of calibration event
-  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
+  if ( CurrentEventSpecie() == AliRecoParam::kCalib ) return;
   
   if (!fDigitStore)
     fDigitStore = AliMUONVDigitStore::Create(*digitsTree);
@@ -855,7 +879,7 @@ void AliMUONTriggerQADataMakerRec::MakeRecPoints(TTree* /*clustersTree*/)
   /// Fill histogram with total number of analyzed events for normalization purposes
 
   // Do nothing in case of calibration event
-  if ( GetRecoParam()->GetEventSpecie() == AliRecoParam::kCalib ) return;
+  if ( CurrentEventSpecie() == AliRecoParam::kCalib ) return;
        
   FillRecPointsData(AliMUONQAIndices::kTriggerNAnalyzedEvents,1.);
 }
@@ -1147,7 +1171,7 @@ AliMUONTriggerQADataMakerRec::GetDCSValues(Int_t iMeas, Int_t detElemId,
 
   if ( AliMpDEManager::GetStationType(detElemId) != AliMp::kStationTrigger) return 0x0;
 
-  TString currAlias = triggerDcsNamer.DCSChannelName(detElemId, 0, iMeas);
+  TString currAlias = triggerDcsNamer.DCSAliasName(detElemId, 0, iMeas);
 
   TPair* triggerDcsPair = static_cast<TPair*>(triggerDcsMap->FindObject(currAlias.Data()));
 
@@ -1193,8 +1217,7 @@ 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
@@ -1208,16 +1231,18 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
 
   // First search for YCopy errors.
   Int_t loCircuit = -1;
-  TIter next(recoTriggerStore.CreateLocalIterator());
-  AliMUONLocalTrigger* recoLocalTrigger, *inputLocalTrigger;
+  TIter next(fTriggerStoreReprocessRaw->CreateLocalIterator());
+  AliMUONLocalTrigger* recoLocalTrigger = 0x0;
   while ( ( recoLocalTrigger = static_cast<AliMUONLocalTrigger*>(next()) ) )
   {  
     loCircuit = recoLocalTrigger->LoCircuit();
+    // FIXME: skip copy boards for the moment
+    if ( loCircuit > AliMUONConstants::NTriggerCircuit() ) continue;
     Int_t iboard = loCircuit - 1;
 
     FillRawsData(AliMUONQAIndices::kTriggerErrorLocalYCopyTest,loCircuit);
   
-    inputLocalTrigger = inputTriggerStore.FindLocal(loCircuit);
+    AliMUONLocalTrigger* 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()};
@@ -1254,29 +1279,41 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
   while ( ( recoLocalTrigger = static_cast<AliMUONLocalTrigger*>(next()) ) )
   {  
     loCircuit = recoLocalTrigger->LoCircuit();
+    // FIXME: skip copy boards for the moment
+    if ( loCircuit > AliMUONConstants::NTriggerCircuit() ) continue;
     Int_t iboard = loCircuit - 1;
+    
+    AliMUONLocalTrigger* inputLocalTrigger = fTriggerStoreFromRaw->FindLocal(loCircuit);
+    
+    TString debugString = Form("Local board %i", loCircuit);
   
     // Fill ratio 44/34 histos (if not scaler event)
-    if ( GetRecoParam()->GetEventSpecie() != AliRecoParam::kCalib ) {
-      Bool_t is34 = ( recoLocalTrigger->GetLoDecision() != 0 );
+    if ( CurrentEventSpecie() != AliRecoParam::kCalib ) {
+      Bool_t is34 = ( recoLocalTrigger->IsTrigX() && recoLocalTrigger->IsTrigY() );
       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");
+      
+      if ( is44 && ! is34 ) {
+        AliWarning(Form("Local board %i satisfies the 4/4 conditions but not the 3/4", loCircuit));
+        debugString += Form("  is34 %i is44 %i is34_recalc %i", is34, is44, TriggerElectronics()->ModifiedLocalResponse(loCircuit, respBendPlane, respNonBendPlane, kFALSE));
+        debugString += Form("  isTrigX %i %i  isTrigY %i %i  Lpt %i %i  Hpt %i %i", recoLocalTrigger->IsTrigX(), inputLocalTrigger->IsTrigX(),
+                              recoLocalTrigger->IsTrigY(), inputLocalTrigger->IsTrigY(),
+                              recoLocalTrigger->LoLpt(), inputLocalTrigger->LoLpt(), 
+                              recoLocalTrigger->LoHpt(), inputLocalTrigger->LoHpt());
+      }
     }
-    
-    inputLocalTrigger = inputTriggerStore.FindLocal(loCircuit);
 
     if ( recoLocalTrigger->LoStripX() != inputLocalTrigger->LoStripX() ) {
       FillRawsData(AliMUONQAIndices::kTriggerErrorLocalXPos,loCircuit);
       errorInXPosDev = kTRUE;
+      debugString += Form("  errXpos (%i, %i)", recoLocalTrigger->LoStripX(), inputLocalTrigger->LoStripX());
     }
     
     if ( recoLocalTrigger->GetDeviation() != inputLocalTrigger->GetDeviation() ) {
       FillRawsData(AliMUONQAIndices::kTriggerErrorLocalDev,loCircuit);
       errorInXPosDev = kTRUE;
+      debugString += Form("  errXdev (%i, %i)", recoLocalTrigger->GetDeviation(), inputLocalTrigger->GetDeviation());
     }
 
     // Skip following checks in case we previously found YCopy error and YPos or trigY errors
@@ -1284,6 +1321,7 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
        
        if ( recoLocalTrigger->GetLoDecision() != inputLocalTrigger->GetLoDecision() ) {
          FillRawsData(AliMUONQAIndices::kTriggerErrorLocalTriggerDec,loCircuit);
+    debugString += Form("  errDecision (%i, %i)", recoLocalTrigger->GetLoDecision(), inputLocalTrigger->GetLoDecision());
        }
        
        // Test Hpt and LPT
@@ -1294,6 +1332,7 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
        for (Int_t ilut=0; ilut<2; ilut++){
            Int_t bitDiff = recoLut[ilut]^inputLut[ilut];
            if ( bitDiff == 0 ) continue;
+    debugString += Form("  errLUT[%i] (%i, %i)", ilut, recoLut[ilut], inputLut[ilut]);
            for (Int_t ibit=0; ibit<2; ibit++){
                Bool_t isBitDifferent = (bitDiff>>ibit)&1;
                if ( isBitDifferent ){
@@ -1306,18 +1345,23 @@ void AliMUONTriggerQADataMakerRec::RawTriggerMatchOutLocal(const AliMUONVTrigger
     
  
     // Skip following checks in case we previously found YCopy errors
-    if ( skipBoard[iboard] ) continue;
+    if ( ! skipBoard[iboard] ) {
 
-    if ( recoLocalTrigger->LoStripY() != inputLocalTrigger->LoStripY() ) {
-      FillRawsData(AliMUONQAIndices::kTriggerErrorLocalYPos,loCircuit);
-      errorInYPosTrigY = kTRUE;
-    }
+      if ( recoLocalTrigger->LoStripY() != inputLocalTrigger->LoStripY() ) {
+        FillRawsData(AliMUONQAIndices::kTriggerErrorLocalYPos,loCircuit);
+        errorInYPosTrigY = kTRUE;
+        debugString += Form("  errYpos (%i, %i)", recoLocalTrigger->LoStripY(), inputLocalTrigger->LoStripY());
+      }
 
-    if ( recoLocalTrigger->LoTrigY() != inputLocalTrigger->LoTrigY()  ) {
-      FillRawsData(AliMUONQAIndices::kTriggerErrorLocalTrigY,loCircuit);       
-      errorInYPosTrigY = kTRUE;
+      if ( recoLocalTrigger->LoTrigY() != inputLocalTrigger->LoTrigY()  ) {
+        FillRawsData(AliMUONQAIndices::kTriggerErrorLocalTrigY,loCircuit);     
+        errorInYPosTrigY = kTRUE;
+        debugString += Form("  errYtrig (%i, %i)", recoLocalTrigger->LoTrigY(), inputLocalTrigger->LoTrigY());
+      }
     }
+    if ( debugString.Length() > 15 ) AliDebug(1,debugString.Data());
   } // loop on local boards
+    
   
   if (errorInXPosDev)
     FillRawsData(AliMUONQAIndices::kTriggerErrorSummary,AliMUONQAIndices::kAlgoLocalX);
@@ -1406,7 +1450,7 @@ void AliMUONTriggerQADataMakerRec::FillRatio4434Histos(Int_t evtInterval, Int_t
   /// Fill ratio 44/34 histos
   TH1* histoEvents = ( isEndOfCycle ) ? GetRawsData(AliMUONQAIndices::kTriggerRawNAnalyzedEvents,itc) : GetMatchingRawsHisto(AliMUONQAIndices::kTriggerRawNAnalyzedEvents,itc);
   if ( ! histoEvents ) return;
-  Int_t numEvent = Int_t(histoEvents->GetBinContent(1));
+  Int_t numEvent = Int_t(histoEvents->GetBinContent(2));
 
   // Fill every fgkUpdateRatio4434 events
   if (numEvent % evtInterval != 0)
@@ -1415,6 +1459,8 @@ void AliMUONTriggerQADataMakerRec::FillRatio4434Histos(Int_t evtInterval, Int_t
   TH1* histo44dec = ( isEndOfCycle ) ? GetRawsData(AliMUONQAIndices::kTriggerNumberOf44Dec,itc) : GetMatchingRawsHisto(AliMUONQAIndices::kTriggerNumberOf44Dec,itc);
   TH1* histo34dec = ( isEndOfCycle ) ? GetRawsData(AliMUONQAIndices::kTriggerNumberOf34Dec,itc) : GetMatchingRawsHisto(AliMUONQAIndices::kTriggerNumberOf34Dec,itc);
   
+  if ( ! histo44dec || ! histo34dec ) return; // protection when running on calibration events only
+  
   Float_t totalNumberOf44 = histo44dec->GetSumOfWeights();
   Float_t totalNumberOf34 = histo34dec->GetSumOfWeights();
 
@@ -1513,6 +1559,16 @@ AliMUONCalibrationData* AliMUONTriggerQADataMakerRec::CalibrationData()
   return fCalibrationData;
 }
 
+//____________________________________________________________________________
+AliMUONTriggerUtilities* AliMUONTriggerQADataMakerRec::TriggerUtilities()
+{
+  /// Return trigger utilities for masks
+  /// (create it if necessary)
+  if ( ! fTriggerUtils )
+    fTriggerUtils = new AliMUONTriggerUtilities(CalibrationData());
+  return fTriggerUtils;
+}
+
 //____________________________________________________________________________ 
 void AliMUONTriggerQADataMakerRec::ResetDetectorRaws(TObjArray* list)
 {