]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrackerQADataMakerRec.cxx
Modifications to get a much more explicit report on token lost readout errors for...
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackerQADataMakerRec.cxx
index 96d1de3cf2bda48ae26b41023eab612d3812a0b9..571df26378496d269b8c3a1262000ea30b449256 100644 (file)
@@ -18,7 +18,9 @@
 // --- MUON header files ---
 #include "AliMUONTrackerQADataMakerRec.h"
 
+#include "AliDAQ.h"
 #include "AliQAv1.h"
+#include "AliMpDDL.h"
 #include "AliMUONConstants.h"  
 #include "AliMUONDigitMaker.h"
 #include "AliMUONQAIndices.h"
 ClassImp(AliMUONTrackerQADataMakerRec)
 /// \endcond
            
-Double_t AliMUONTrackerQADataMakerRec::fgkRawNofGlitchErrors(0.0);
-Double_t AliMUONTrackerQADataMakerRec::fgkRawNofTokenLostErrors(1.0);
-Double_t AliMUONTrackerQADataMakerRec::fgkRawNofParityErrors(2.0);
-Double_t AliMUONTrackerQADataMakerRec::fgkRawNofPaddingErrors(3.0);
-
+namespace
+{
+  Double_t ProtectedSqrt(Double_t x)
+  {
+    return ( x > 0.0 ? TMath::Sqrt(x) : 0.0 );
+  }
+}
 //____________________________________________________________________________ 
 AliMUONTrackerQADataMakerRec::AliMUONTrackerQADataMakerRec(AliQADataMakerRec* master) : 
 AliMUONVQADataMakerRec(master),
@@ -251,13 +255,13 @@ void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleESDs(Int_t, TObjArray**)
         Double_t meanResX = hESDSumResidualXPerDE->GetBinContent(iDE+1)/nClusters;
         hESDResidualXPerDEMean->SetBinContent(iDE+1, meanResX);
         hESDResidualXPerDEMean->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(nClusters));
-        hESDResidualXPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualX2PerDE->GetBinContent(iDE+1)/nClusters - meanResX*meanResX));
+        hESDResidualXPerDESigma->SetBinContent(iDE+1, ProtectedSqrt(hESDSumResidualX2PerDE->GetBinContent(iDE+1)/nClusters - meanResX*meanResX));
         hESDResidualXPerDESigma->SetBinError(iDE+1, sigmaResidualX/TMath::Sqrt(2.*nClusters));
         
         Double_t meanResY = hESDSumResidualYPerDE->GetBinContent(iDE+1)/nClusters;
         hESDResidualYPerDEMean->SetBinContent(iDE+1, meanResY);
         hESDResidualYPerDEMean->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(nClusters));
-        hESDResidualYPerDESigma->SetBinContent(iDE+1, TMath::Sqrt(hESDSumResidualY2PerDE->GetBinContent(iDE+1)/nClusters - meanResY*meanResY));
+        hESDResidualYPerDESigma->SetBinContent(iDE+1, ProtectedSqrt(hESDSumResidualY2PerDE->GetBinContent(iDE+1)/nClusters - meanResY*meanResY));
         hESDResidualYPerDESigma->SetBinError(iDE+1, sigmaResidualY/TMath::Sqrt(2.*nClusters));
         
         hESDLocalChi2XPerDEMean->SetBinContent(iDE+1, hESDSumLocalChi2XPerDE->GetBinContent(iDE+1)/nClusters);
@@ -382,8 +386,10 @@ void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRaws(Int_t specie, TObjArra
 
   if ( fTrackerDataMaker ) 
   {
+    /// put the trackerdata in the pipeline
     InsertTrackerData(specie,list,fTrackerDataMaker->Data(),AliMUONQAIndices::kTrackerData);
 
+    /// project the tracerdata into buspatch occupancies (for the experts)
     TH1* hbp = GetRawsData(AliMUONQAIndices::kTrackerBusPatchOccupancy);
     hbp->Reset();
     TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
@@ -398,6 +404,7 @@ void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRaws(Int_t specie, TObjArra
       hbp->SetBinContent(bin,data->BusPatch(busPatchId,occDim)*100.0); // occupancy, in percent
     }
     
+    /// log the readout errors (for the shifter)
     TH1* hnevents = GetRawsData(AliMUONQAIndices::kTrackerNofRawEventSeen);
     hnevents->Reset();
     hnevents->Fill(0.0,fTrackerDataMaker->Data()->NumberOfEvents(-1));
@@ -408,6 +415,45 @@ void AliMUONTrackerQADataMakerRec::EndOfDetectorCycleRaws(Int_t specie, TObjArra
       FillErrors(*fLogger);      
       fLogger->Clear();
     }
+
+    /// project tracker data into DDL occupancies (for the shifter)
+    TH1* hddl = GetRawsData(AliMUONQAIndices::kTrackerDDLOccupancy);
+    hddl->Reset();
+    TH1* hddlevents = GetRawsData(AliMUONQAIndices::kTrackerDDLNofEvents);
+    hddlevents->Reset();
+    
+    const Int_t nddls = AliDAQ::NumberOfDdls("MUONTRK");
+    const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
+    
+    for ( Int_t iddl = 0; iddl < nddls; ++iddl )
+    {
+      AliMpDDL* ddl = AliMpDDLStore::Instance()->GetDDL(iddl);
+      
+      Int_t ddlId = offset + ddl->GetId();
+      Int_t npads = 0;
+      
+      Int_t nevents = data->NumberOfEvents(iddl);
+      
+      hddlevents->Fill(ddlId,nevents);
+      
+      Double_t occ(0.0);
+      
+      for ( Int_t ide = 0; ide < ddl->GetNofDEs(); ++ide )
+      {
+        Int_t de = ddl->GetDEId(ide);
+        
+        npads += TMath::Nint(data->DetectionElement(de,3));
+        
+        occ +=  data->DetectionElement(de,4);
+      }
+      
+      if ( nevents > 0 && npads > 0 )
+      {
+        occ = occ/npads/nevents;
+      }
+
+      hddl->Fill(ddlId,100.0*occ); // occ in percent
+    }
   }
 }
 
@@ -446,15 +492,43 @@ void AliMUONTrackerQADataMakerRec::FillErrors(AliMUONLogger& log)
              
     if ( msg.Contains("token") )
     {
-      Int_t dsp(-1),ddl(-1),ecode(-1);
+      Int_t dsp(-1),iddl(-1),ecode(-1);
       
-      sscanf(msg.Data(),"Lost token error detected in DSP 0x%X of DDL %d and code %d.",
-             &dsp,&ddl,&ecode);
+      sscanf(msg.Data(),"Lost token error detected with address 0x%X of DDL %d and code %d.",
+             &dsp,&iddl,&ecode);
       Int_t localBP = ((dsp >> 16)- 4)*5 + 1;
-      Int_t buspatch = localBP + ddl*100;
-      htoken->Fill(buspatch,occurence);
-      hroe->Fill(fgkRawNofTokenLostErrors,occurence);
-      AliDebug(1,Form("DDL %d DSP %d busPatch %d",ddl,dsp,buspatch));
+      Int_t buspatch = localBP + iddl*100;
+      
+      // Let's try to get all the suspected bus patches (i.e. one full FRT, as currently
+      // we don't have more precise information to locate the faulty bus patch(es)).
+      
+      AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(buspatch);
+      Int_t frt = bp->GetFrtId();
+      AliMpDDL* ddl = AliMpDDLStore::Instance()->GetDDL(bp->GetDdlId());
+      Int_t* b = new Int_t[ddl->GetMaxDsp()];
+      ddl->GetBusPerDsp(b);
+      Int_t nbus(0);
+      for ( Int_t i = 0; i < ddl->GetNofFrts() && !nbus; ++i ) 
+      {
+        if ( ddl->GetFrtId(i) == frt ) 
+        {
+          nbus = b[i];
+        }
+      }
+      if (nbus<=0) 
+      {
+        AliError("GOT NBUS<=0 ! THAT IS BAD ! CHECK !");
+        nbus=1;
+      }
+      
+      delete[] b;
+      
+      while (nbus) {
+        htoken->Fill(buspatch+nbus-1,occurence);
+        --nbus;
+      }
+      
+      hroe->Fill(1.0*AliMUONQAIndices::kTrackerRawNofTokenLostErrors,occurence);
     }
     
     if ( msg.Contains("Parity") )
@@ -462,12 +536,12 @@ void AliMUONTrackerQADataMakerRec::FillErrors(AliMUONLogger& log)
       Int_t buspatch;
       sscanf(msg.Data(),"Parity error in buspatch %d (0x%X).",&buspatch,&buspatch);
       hparity->Fill(buspatch,occurence);      
-      hroe->Fill(fgkRawNofParityErrors,occurence);
+      hroe->Fill(1.0*AliMUONQAIndices::kTrackerRawNofParityErrors,occurence);
     }
     
     if ( msg.Contains("Glitch") ) 
     {
-      hroe->Fill(fgkRawNofGlitchErrors,occurence);      
+      hroe->Fill(1.0*AliMUONQAIndices::kTrackerRawNofGlitchErrors,occurence);      
     }
     
     if ( msg.Contains("Padding") )
@@ -475,7 +549,7 @@ void AliMUONTrackerQADataMakerRec::FillErrors(AliMUONLogger& log)
       Int_t block, dsp, buspatch;      
       sscanf(msg.Data(),"Padding word error for iBlock %d, iDsp %d, iBus %d.",&block,&dsp,&buspatch);
       hpadding->Fill(buspatch,occurence);
-      hroe->Fill(fgkRawNofPaddingErrors,occurence);      
+      hroe->Fill(1.0*AliMUONQAIndices::kTrackerRawNofPaddingErrors,occurence);      
     }
   }
   
@@ -516,7 +590,7 @@ void AliMUONTrackerQADataMakerRec::InitRaws()
 
   TH1* hbpnmanus = new TH1F("hTrackerBusPatchNofManus","Number of manus per bus patch",nbins,xmin,xmax);
 
-  Add2RawsList(hbp,AliMUONQAIndices::kTrackerBusPatchOccupancy, !expert, image, !saveCorr);
+  Add2RawsList(hbp,AliMUONQAIndices::kTrackerBusPatchOccupancy, expert, image, !saveCorr);
   Add2RawsList(hbpnpads,AliMUONQAIndices::kTrackerBusPatchNofPads, expert, !image, !saveCorr);
   Add2RawsList(hbpnmanus,AliMUONQAIndices::kTrackerBusPatchNofManus, expert, !image, !saveCorr);
 
@@ -535,10 +609,10 @@ void AliMUONTrackerQADataMakerRec::InitRaws()
   // The QA shifter will only see the summary plot below
   TAxis* a = h->GetXaxis();
   
-  a->SetBinLabel(h->FindBin(fgkRawNofGlitchErrors),"Glitch errors");
-  a->SetBinLabel(h->FindBin(fgkRawNofTokenLostErrors),"Token lost errors");
-  a->SetBinLabel(h->FindBin(fgkRawNofParityErrors),"Parity errors");
-  a->SetBinLabel(h->FindBin(fgkRawNofPaddingErrors),"Padding errors");
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofGlitchErrors),"Glitch errors");
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofTokenLostErrors),"Token lost errors");
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofParityErrors),"Parity errors");
+  a->SetBinLabel(h->FindBin(1.0*AliMUONQAIndices::kTrackerRawNofPaddingErrors),"Padding errors");
 
   Add2RawsList(h,AliMUONQAIndices::kTrackerReadoutErrors,!expert,image,!saveCorr);
 
@@ -606,6 +680,18 @@ void AliMUONTrackerQADataMakerRec::InitRaws()
       hbpconfig->Fill(bp->GetId());
     }
   }
+  
+  nbins = AliDAQ::NumberOfDdls("MUONTRK");
+  const Int_t offset = AliDAQ::DdlIDOffset("MUONTRK");
+  
+  xmin = offset - 0.5;
+  xmax  = offset + nbins - 0.5;
+  
+  Add2RawsList(new TH1F("hTrackerDDLOccupancy",";DDLId;DDL Occupancy in %",nbins,xmin,xmax),
+               AliMUONQAIndices::kTrackerDDLOccupancy,!expert,image,!saveCorr);
+  Add2RawsList(new TH1F("hTrackerDDLNofEvents","Number of events seen by DDL;DDLId",nbins,xmin,xmax),
+               AliMUONQAIndices::kTrackerDDLNofEvents,expert,!image,!saveCorr);
+  
 }
 
 //__________________________________________________________________
@@ -1175,9 +1261,9 @@ AliMUONTrackerQADataMakerRec::ResetDetectorRaws(TObjArray* list)
       
       if ( hn.Contains("Tracker") )
       {
-        if ( hn != "hTrackerBusPatchNofPads" && 
-            hn != "hTrackerBusPatchNofManus" &&
-            hn != "hTrackerBusPatchConfig" )
+        if ( !hn.Contains("hTrackerBusPatchNofPads") && 
+            !hn.Contains("hTrackerBusPatchNofManus") &&
+            !hn.Contains("hTrackerBusPatchConfig" ) )
         {
           AliDebug(1,Form("Resetting %s",hn.Data()));
           h->Reset();                  
@@ -1202,4 +1288,4 @@ AliMUONTrackerQADataMakerRec::ResetDetectorRaws(TObjArray* list)
       }
     }
   }
-}
\ No newline at end of file
+}