]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDQADataMakerRec.cxx
Changes in QA to be able to process separately different triggers (Ruben)
[u/mrichter/AliRoot.git] / FMD / AliFMDQADataMakerRec.cxx
index 64d379c707ffb4e7d8ec53dedfb7f89c55ca3a28..6f6ae2c7900fb23a5b1b221c96631314857f47ee 100644 (file)
@@ -18,6 +18,7 @@
 #include <TFile.h> 
 #include <TH1F.h> 
 #include <TH1I.h> 
+#include <TH2I.h> 
 
 // --- AliRoot header files ---
 #include "AliESDEvent.h"
 #include "AliFMDParameters.h"
 #include "AliFMDRawReader.h"
 #include "AliRawReader.h"
+#include "AliFMDAltroMapping.h"
+#include "AliFMDDebug.h"
 
+namespace {
+  Int_t colors[3] = {kRed,kGreen,kBlue};
+}
 //_____________________________________________________________________
 // This is the class that collects the QA data for the FMD during
 // reconstruction.  
@@ -49,9 +55,8 @@ ClassImp(AliFMDQADataMakerRec)
            
 //_____________________________________________________________________
 AliFMDQADataMakerRec::AliFMDQADataMakerRec() : 
-  AliQADataMakerRec(AliQA::GetDetName(AliQA::kFMD), 
+  AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
                    "FMD Quality Assurance Data Maker"),
-  fDigitsArray("AliFMDDigit", 0),
   fRecPointsArray("AliFMDRecPoint", 1000)
 {
   // ctor
@@ -60,9 +65,8 @@ AliFMDQADataMakerRec::AliFMDQADataMakerRec() :
 
 //_____________________________________________________________________
 AliFMDQADataMakerRec::AliFMDQADataMakerRec(const AliFMDQADataMakerRec& qadm) 
-  : AliQADataMakerRec(AliQA::GetDetName(AliQA::kFMD), 
+  : AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
                      "FMD Quality Assurance Data Maker"),
-    fDigitsArray(qadm.fDigitsArray),
     fRecPointsArray(qadm.fRecPointsArray)
 {
   // copy ctor 
@@ -71,9 +75,18 @@ AliFMDQADataMakerRec::AliFMDQADataMakerRec(const AliFMDQADataMakerRec& qadm)
   
 }
 //_____________________________________________________________________
-AliFMDQADataMakerRec& AliFMDQADataMakerRec::operator = (const AliFMDQADataMakerRec& qadm ) 
+AliFMDQADataMakerRec& 
+AliFMDQADataMakerRec::operator = (const AliFMDQADataMakerRec& qadm ) 
 {
-  fDigitsArray = qadm.fDigitsArray;
+  // 
+  // Assignment operator 
+  // 
+  // Parameters:
+  //    qadm What to assign from 
+  // 
+  // Return:
+  //    Reference to this
+  //
   fRecPointsArray = qadm.fRecPointsArray;
   
   return *this;
@@ -81,81 +94,212 @@ AliFMDQADataMakerRec& AliFMDQADataMakerRec::operator = (const AliFMDQADataMakerR
 //_____________________________________________________________________
 AliFMDQADataMakerRec::~AliFMDQADataMakerRec()
 {
+  // 
+  // Destrcutor 
+  // 
 }
 
 
 //_____________________________________________________________________ 
 
 void 
-AliFMDQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, 
-                                        TObjArray * list)
+AliFMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, 
+                                        TObjArray ** list)
 {
   // Detector specific actions at end of cycle
   // do the QA checking
+  ResetEventTrigClasses(); // reset triggers list to select all histos
   AliLog::Message(5,"FMD: end of detector cycle",
                  "AliFMDQADataMakerRec","AliFMDQADataMakerRec",
                  "AliFMDQADataMakerRec::EndOfDetectorCycle",
                  "AliFMDQADataMakerRec.cxx",95);
-  AliQAChecker::Instance()->Run(AliQA::kFMD, task, list);
+  AliQAChecker::Instance()->Run(AliQAv1::kFMD, task, list);
 }
 
+//_____________________________________________________________________ 
+TH1* AliFMDQADataMakerRec::MakeADCHist(UShort_t d, Char_t r, Short_t b)
+{
+  TString name("adc"); 
+  TString title("ADC counts");
+  Int_t   color = kRed+1; 
+  if (d > 0) { 
+    name.Append(Form("FMD%d%c", d, r));
+    title.Append(Form(" in FMD%d%c", d, r));
+    color = colors[d-1]+3+(r == 'I' || r == 'i' ? 0 : 1);
+    if (b >= 0) {
+      name.Append(Form("_0x%02x", b));
+      title.Append(Form("[0x%02x]", b));
+    }
+  }
+  TH1* hist = new TH1F(name, title,1024,0,1024);
+  hist->SetXTitle("Amplitude [ADC counts]");
+  hist->SetYTitle("Events [log]");
+  hist->SetFillStyle(3001);
+  hist->SetFillColor(color);
+  hist->SetLineColor(color);
+  hist->SetMarkerColor(color);
+  hist->GetXaxis()->SetNdivisions(408,false);
+  // hist->SetStats(0);
+
+  return hist;
+}
+//_____________________________________________________________________ 
+TH1* AliFMDQADataMakerRec::MakeELossHist(UShort_t d, Char_t r, Short_t b)
+{
+  TString name("eloss"); 
+  TString title("Energy loss");
+  Int_t   color = kBlue+1;
+  if (d > 0) { 
+    name.Append(Form("FMD%d%c", d, r));
+    title.Append(Form(" in FMD%d%c", d, r));
+    color = colors[d-1]+3+(r == 'I' || r == 'i' ? 0 : 1);
+    if (b >= 0) {
+      name.Append(Form("_0x%02x", b));
+      title.Append(Form("[0x%02x]", b));
+    }
+  }
+  TH1* hist = new TH1F(name, title,300,0, 15);
+  hist->SetXTitle("#Delta E/#Delta_{mip}");
+  hist->SetYTitle("Events [log]");
+  hist->SetFillStyle(3001);
+  hist->SetFillColor(color);
+  hist->SetLineColor(color);
+  hist->SetMarkerColor(color);
+  // hist->SetStats(0);
+
+  return hist;
+}
+
+
 //_____________________________________________________________________ 
 void AliFMDQADataMakerRec::InitESDs()
 {
   // create Digits histograms in Digits subdir
-  TH1F* hEnergyOfESD = new TH1F("hEnergyOfESD","Energy distribution",100,0,3);
-  hEnergyOfESD->SetXTitle("Edep/Emip");
-  hEnergyOfESD->SetYTitle("Counts");
-  Add2ESDsList(hEnergyOfESD, 0);
-    
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
+  
+  TH1* hist = MakeELossHist();
+  Add2ESDsList(hist, 0, !expert, image);
+  ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line    
 }
 
-//_____________________________________________________________________ 
-/*void AliFMDQADataMakerRec::InitDigits()
+//_____________________________________________________________________
+void AliFMDQADataMakerRec::InitDigits()
 {
   // create Digits histograms in Digits subdir
-  TH1I* hADCCounts      = new TH1I("hADCCounts","Dist of ADC counts",
-                                  1024,0,1024);
-  hADCCounts->SetXTitle("ADC counts");
-  hADCCounts->SetYTitle("");
-  Add2DigitsList(hADCCounts, 0);
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
   
+  TH1* hist = MakeADCHist();
+  Add2DigitsList(hist, 0, !expert, image);
+  ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
 }
-*/
+
 //_____________________________________________________________________ 
 void AliFMDQADataMakerRec::InitRecPoints()
 {
-  TH1F* hEnergyOfRecpoints = new TH1F("hEnergyOfRecpoints",
-                                     "Energy Distribution",100,0,3);
-  hEnergyOfRecpoints->SetXTitle("Edep/Emip");
-  hEnergyOfRecpoints->SetYTitle("");
-  Add2RecPointsList(hEnergyOfRecpoints,0);
+  // create Reconstructed Points histograms in RecPoints subdir
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
+
+  TH1* hist = MakeELossHist();
+  Add2RecPointsList(hist,0, !expert, image);
+  ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last linea
 }
 
 //_____________________________________________________________________ 
 void AliFMDQADataMakerRec::InitRaws()
 {
-  TH1I* hADCCounts      = new TH1I("hADCCounts","Dist of ADC counts",
-                                  1024,0,1023);
-  hADCCounts->SetXTitle("ADC counts");
-  hADCCounts->SetYTitle("");
-  Add2RawsList(hADCCounts, 0);
+  // create Raws histograms in Raws subdir  
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t saveCorr = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
+  TH2I* hErrors = new TH2I("readoutErrors", "Read out errors", 3, .5, 3.5,
+                          160, 0, 160); 
+  hErrors->GetXaxis()->SetBinLabel(1, "FMD1");
+  hErrors->GetXaxis()->SetBinLabel(2, "FMD2");
+  hErrors->GetXaxis()->SetBinLabel(3, "FMD3");
+  hErrors->SetYTitle("# errors");
+  hErrors->SetZTitle("Events [log]");
+  Add2RawsList(hErrors, 1, !expert, image, !saveCorr);
+  //AliInfo(Form("Adding %30s to raw list @ %2d", hErrors->GetName(), 1));
+
+  TH1* hist;
+  Int_t idx = 0;
+  for(UShort_t d = 1; d<=3; d++) {
+    UShort_t nR = (d == 1 ? 1 : 2); 
+    for(UShort_t q = 0; q < nR; q++) {
+      Char_t r = (q == 1 ? 'O' : 'I');
+      hist = MakeADCHist(d, r, -1);
 
+      Int_t index1 = GetHalfringIndex(d, r, 0, 1);
+      idx          = TMath::Max(index1, idx);
+      Add2RawsList(hist, index1, !expert, image, !saveCorr);
+      //AliInfo(Form("Adding %30s to raw list @ %2d", hist->GetName(), index1));
+      
+      for(UShort_t b = 0; b <= 1; b++) {
+       //Hexadecimal board numbers 0x0, 0x1, 0x10, 0x11;
+       UShort_t board = (q == 1 ? 0 : 1) + b*16;
+
+       hist = MakeADCHist(d, r, board);
+       Int_t index2 = GetHalfringIndex(d, r, board/16,0);
+       idx          = TMath::Max(index2, idx);
+       Add2RawsList(hist, index2, expert, !image, !saveCorr);
+       //AliInfo(Form("Adding %30s to raw list @ %2d",hist->GetName(),index2));
+      }
+    }
+  }
+  //
+  ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
 }
 
+#if 0
+struct FillESDHist : public AliESDFMD::ForOne
+{
+  FillESDHist(AliFMDQADataMakerRec* m) : fM(m) {}
+  FillESDHist(const FillESDHist& o) : fM(o.fM) {}
+  FillESDHist& operator=(const FillESDHist& o) { fM = o.fM; return *this;  }
+  Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Float_t m, Float_t) 
+  {
+    // Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
+    if(m == AliESDFMD::kInvalidMult) return true;
+    
+    fM->FillESDsData(0,m);
+    return true;
+  }
+  AliFMDQADataMakerRec* fM;
+};
+#endif
+
 //_____________________________________________________________________
 void AliFMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
 {
+  // 
+  // Analyse ESD event
+  // 
+  // Parameters:
+  //    esd ESD event
+  //
   if(!esd) {
     AliError("FMD ESD object not found!!") ; 
     return;
   }
+  AliFMDDebug(2, ("Will loop over ESD data and fill histogram"));
+
   AliESDFMD* fmd = esd->GetFMDData();
   if (!fmd) return;
-  
+
+#if 0
+  FillESDHist f(this);
+  fmd->ForEach(f);
+#else
+
+
+
+  // FIXME - we should use AliESDFMD::ForOne subclass to do this!
   for(UShort_t det=1;det<=3;det++) {
-    for (UShort_t ir = 0; ir < 2; ir++) {
+    UShort_t nrng = (det == 1 ? 1 : 2);
+    for (UShort_t ir = 0; ir < nrng; ir++) {
       Char_t   ring = (ir == 0 ? 'I' : 'O');
       UShort_t nsec = (ir == 0 ? 20  : 40);
       UShort_t nstr = (ir == 0 ? 512 : 256);
@@ -164,68 +308,114 @@ void AliFMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
          Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
          if(mult == AliESDFMD::kInvalidMult) continue;
          
-         GetESDsData(0)->Fill(mult);
+         FillESDsData(0,mult);
        }
       }
     }
   }
+#endif
+  IncEvCountCycleESDs();
+  IncEvCountTotalESDs();
 }
 
-/*
+
 //_____________________________________________________________________
-void AliFMDQADataMakerRec::MakeDigits(TClonesArray * digits)
+void AliFMDQADataMakerRec::MakeDigits()
 {
   // makes data from Digits  
-  if(!digits)  {
+  if(!fDigitsArray)  {
     AliError("FMD Digit object not found!!") ;
     return;
   }
-  for(Int_t i=0;i<digits->GetEntriesFast();i++) {
+  
+  for(Int_t i=0;i<fDigitsArray->GetEntriesFast();i++) {
     //Raw ADC counts
-    AliFMDDigit* digit = static_cast<AliFMDDigit*>(digits->At(i));
-    GetDigitsData(0)->Fill(digit->Counts());
+    AliFMDDigit* digit = static_cast<AliFMDDigit*>(fDigitsArray->At(i));
+    FillDigitsData(0,digit->Counts());
   }
 }
 
 //_____________________________________________________________________
 void AliFMDQADataMakerRec::MakeDigits(TTree * digitTree)
 {
-  
-  fDigitsArray.Clear();
+  // 
+  // Analyse digits
+  // 
+  // Parameters:
+  //    digitTree Tree of digits
+  //
+  if (fDigitsArray) 
+    fDigitsArray->Clear();
+  else 
+    fDigitsArray = new TClonesArray("AliFMDDigit", 1000);
+
   TBranch*      branch = digitTree->GetBranch("FMD");
   if (!branch) {
     AliWarning("FMD branch in Digit Tree not found") ; 
     return;
   } 
-  TClonesArray* digitsAddress = &fDigitsArray;
-  branch->SetAddress(&digitsAddress);
+  branch->SetAddress(&fDigitsArray);
   branch->GetEntry(0); 
-  MakeDigits(digitsAddress);
+  MakeDigits();
+  //
+  IncEvCountCycleDigits();
+  IncEvCountTotalDigits();
 }
-*/
+
 //_____________________________________________________________________
 void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
 {
+  // 
+  // Analyse raw 
+  // 
+  // Parameters:
+  //    rawReader Raw reader
+  //
  
   AliFMDRawReader fmdReader(rawReader,0);
-  TClonesArray* digitsAddress = &fDigitsArray;
+  
+  if (fDigitsArray) 
+    fDigitsArray->Clear();
+  else 
+    fDigitsArray = new TClonesArray("AliFMDDigit", 1000);
+
+  TClonesArray* digitsAddress = fDigitsArray;
   
   rawReader->Reset();
                
-       digitsAddress->Clear();
-       fmdReader.ReadAdcs(digitsAddress);
-       for(Int_t i=0;i<digitsAddress->GetEntriesFast();i++) {
-               //Raw ADC counts
-               AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
-               GetRawsData(0)->Fill(digit->Counts());
-       }
+  digitsAddress->Clear();
+  fmdReader.ReadAdcs(digitsAddress);
+  for(Int_t i=0;i<digitsAddress->GetEntriesFast();i++) {
+    //Raw ADC counts
+    AliFMDDigit*      digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
+    UShort_t          det   = digit->Detector();
+    Char_t            ring  = digit->Ring();
+    UShort_t          sec   = digit->Sector();
+    // UShort_t strip = digit->Strip();
+    AliFMDParameters* pars  = AliFMDParameters::Instance();
+    Short_t           board = pars->GetAltroMap()->Sector2Board(ring, sec);
+    
+    Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
+    FillRawsData(index1,digit->Counts());
+    Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
+    FillRawsData(index2,digit->Counts());
+    
+  }
+  //
+  FillRawsData(1,1, fmdReader.GetNErrors(0));
+  FillRawsData(1,2, fmdReader.GetNErrors(1));
+  FillRawsData(1,3, fmdReader.GetNErrors(2));
+  //
+  IncEvCountCycleRaws();
+  IncEvCountTotalRaws();
 }
 
 //_____________________________________________________________________
 void AliFMDQADataMakerRec::MakeRecPoints(TTree* clustersTree)
 {
   // makes data from RecPoints
-  AliFMDParameters* pars = AliFMDParameters::Instance();
+  
+   AliFMDParameters* pars = AliFMDParameters::Instance();
   fRecPointsArray.Clear();
   TBranch *fmdbranch = clustersTree->GetBranch("FMD");
   if (!fmdbranch) { 
@@ -240,11 +430,11 @@ void AliFMDQADataMakerRec::MakeRecPoints(TTree* clustersTree)
   TIter next(RecPointsAddress) ; 
   AliFMDRecPoint * rp ; 
   while ((rp = static_cast<AliFMDRecPoint*>(next()))) {
-    
-    GetRecPointsData(0)->Fill(rp->Edep()/pars->GetEdepMip()) ;
-  
+    FillRecPointsData(0,rp->Edep()/pars->GetEdepMip());
   }
-
+  IncEvCountCycleRecPoints();
+  IncEvCountTotalRecPoints();
+  //
 }
 
 //_____________________________________________________________________ 
@@ -255,6 +445,39 @@ void AliFMDQADataMakerRec::StartOfDetectorCycle()
   // do?
 }
 //_____________________________________________________________________ 
+Int_t AliFMDQADataMakerRec::GetHalfringIndex(UShort_t det, 
+                                            Char_t ring, 
+                                            UShort_t board, 
+                                            UShort_t monitor) const
+{
+  // 
+  // Get the half-ring index
+  // 
+  // Parameters:
+  //    det      Detector
+  //    ring     Ring
+  //    board    Board number
+  //    monitor  Monitor 
+  // 
+  // Return:
+  //    Half ring index
+  //  
+  UShort_t iring = (ring == 'I' || ring == 'i' ? 1 : 0);
+  Int_t    index = ((((det-1) & 0x3) << 3) | 
+                   ((iring   & 0x1) << 2) |
+                   ((board   & 0x1) << 1) | 
+                   ((monitor & 0x1) << 0));
+#if 0
+  AliInfo(Form("d=%d, r=%c, b=%d, m=%d -> (%d<<3)|(%d<<2)|(%d<<1)|(%d<<0)=%2d",
+              det, ring, board, monitor, (det-1) & 0x3, iring & 0x1, 
+              board & 0x1, monitor & 0x1, index));
+#endif
+  return index-2;
+}
+
+//_____________________________________________________________________ 
+
+
 //
 // EOF
 //