]> 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 f95d040b44b51496af8879496285cd047fa67acc..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 "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.  
@@ -52,7 +57,6 @@ ClassImp(AliFMDQADataMakerRec)
 AliFMDQADataMakerRec::AliFMDQADataMakerRec() : 
   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
                    "FMD Quality Assurance Data Maker"),
-  fDigitsArray("AliFMDDigit", 0),
   fRecPointsArray("AliFMDRecPoint", 1000)
 {
   // ctor
@@ -63,7 +67,6 @@ AliFMDQADataMakerRec::AliFMDQADataMakerRec() :
 AliFMDQADataMakerRec::AliFMDQADataMakerRec(const AliFMDQADataMakerRec& qadm) 
   : AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
                      "FMD Quality Assurance Data Maker"),
-    fDigitsArray(qadm.fDigitsArray),
     fRecPointsArray(qadm.fRecPointsArray)
 {
   // copy ctor 
@@ -72,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;
@@ -82,7 +94,9 @@ AliFMDQADataMakerRec& AliFMDQADataMakerRec::operator = (const AliFMDQADataMakerR
 //_____________________________________________________________________
 AliFMDQADataMakerRec::~AliFMDQADataMakerRec()
 {
+  // 
+  // Destrcutor 
+  // 
 }
 
 
@@ -94,6 +108,7 @@ AliFMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task,
 {
   // 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",
@@ -101,6 +116,61 @@ AliFMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task,
   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()
 {
@@ -108,11 +178,21 @@ void AliFMDQADataMakerRec::InitESDs()
   const Bool_t expert   = kTRUE ; 
   const Bool_t image    = kTRUE ; 
   
-  TH1F* hEnergyOfESD = new TH1F("hEnergyOfESD","Energy distribution",100,0,3);
-  hEnergyOfESD->SetXTitle("Edep/Emip");
-  hEnergyOfESD->SetYTitle("Counts");
-  Add2ESDsList(hEnergyOfESD, 0, !expert, image);
-    
+  TH1* hist = MakeELossHist();
+  Add2ESDsList(hist, 0, !expert, image);
+  ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line    
+}
+
+//_____________________________________________________________________
+void AliFMDQADataMakerRec::InitDigits()
+{
+  // create Digits histograms in Digits subdir
+  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
 }
 
 //_____________________________________________________________________ 
@@ -122,11 +202,9 @@ void AliFMDQADataMakerRec::InitRecPoints()
   const Bool_t expert   = kTRUE ; 
   const Bool_t image    = kTRUE ; 
 
-  TH1F* hEnergyOfRecpoints = new TH1F("hEnergyOfRecpoints",
-                                     "Energy Distribution",100,0,3);
-  hEnergyOfRecpoints->SetXTitle("Edep/Emip");
-  hEnergyOfRecpoints->SetYTitle("");
-  Add2RecPointsList(hEnergyOfRecpoints,0, !expert, image);
+  TH1* hist = MakeELossHist();
+  Add2RecPointsList(hist,0, !expert, image);
+  ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last linea
 }
 
 //_____________________________________________________________________ 
@@ -136,51 +214,92 @@ void AliFMDQADataMakerRec::InitRaws()
   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));
 
-  TH1I* hADCCounts;
-  for(Int_t det = 1; det<=3; det++) {
-    Int_t firstring = (det==1 ? 1 : 0);
-    for(Int_t iring = firstring;iring<=1;iring++) {
-      Char_t ring = (iring == 1 ? 'I' : 'O');
-      hADCCounts      = new TH1I(Form("hADCCounts_FMD%d%c",
-                                     det, ring), "ADC counts",
-                                1024,0,1023);
-      
-      Int_t index1 = GetHalfringIndex(det, ring, 0,1);
-      Add2RawsList(hADCCounts, index1, expert, !image, !saveCorr);
+  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(Int_t b = 0; b<=1;b++) {
-       
+      for(UShort_t b = 0; b <= 1; b++) {
        //Hexadecimal board numbers 0x0, 0x1, 0x10, 0x11;
-       UInt_t board = (iring == 1 ? 0 : 1);
-       board = board + b*16;
-       
-       
-       hADCCounts      = new TH1I(Form("hADCCounts_FMD%d%c_board%d",
-                                       det, ring, board), "ADC counts",
-                                  1024,0,1023);
-       hADCCounts->SetXTitle("ADC counts");
-       hADCCounts->SetYTitle("");
-       Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
-       Add2RawsList(hADCCounts, index2, !expert, image, !saveCorr);
+       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);
@@ -189,51 +308,78 @@ 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();
                
@@ -250,18 +396,26 @@ void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
     Short_t           board = pars->GetAltroMap()->Sector2Board(ring, sec);
     
     Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
-    GetRawsData(index1)->Fill(digit->Counts());
+    FillRawsData(index1,digit->Counts());
     Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
-    GetRawsData(index2)->Fill(digit->Counts());
+    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) { 
@@ -276,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();
+  //
 }
 
 //_____________________________________________________________________ 
@@ -294,14 +448,31 @@ void AliFMDQADataMakerRec::StartOfDetectorCycle()
 Int_t AliFMDQADataMakerRec::GetHalfringIndex(UShort_t det, 
                                             Char_t ring, 
                                             UShort_t board, 
-                                            UShort_t monitor) {
-  
-  UShort_t iring  =  (ring == 'I' ? 1 : 0);
-  
-  Int_t index = ( ((det-1) << 3) | (iring << 2) | (board << 1) | (monitor << 0));
-  
+                                            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;
-  
 }
 
 //_____________________________________________________________________