]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDQADataMakerRec.cxx
Update HFE v2
[u/mrichter/AliRoot.git] / FMD / AliFMDQADataMakerRec.cxx
index 3f63e8e03068e7bc594e06a665183fef3865e718..dc0fe45015c696407c8444b512061c04cf913601 100644 (file)
 #include <TH1F.h> 
 #include <TH1I.h> 
 #include <TH2I.h> 
+#include <TGeoManager.h>
 
 // --- AliRoot header files ---
 #include "AliESDEvent.h"
 #include "AliLog.h"
+#include "AliGeomManager.h"
 #include "AliFMDQADataMakerRec.h"
 #include "AliFMDDigit.h"
 #include "AliFMDRecPoint.h"
@@ -30,6 +32,7 @@
 #include "AliESDFMD.h"
 #include "AliFMDParameters.h"
 #include "AliFMDRawReader.h"
+#include "AliFMDReconstructor.h"
 #include "AliRawReader.h"
 #include "AliFMDAltroMapping.h"
 #include "AliFMDDebug.h"
@@ -54,10 +57,12 @@ ClassImp(AliFMDQADataMakerRec)
 #endif
            
 //_____________________________________________________________________
-AliFMDQADataMakerRec::AliFMDQADataMakerRec() : 
-  AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
-                   "FMD Quality Assurance Data Maker"),
-  fRecPointsArray("AliFMDRecPoint", 1000)
+AliFMDQADataMakerRec::AliFMDQADataMakerRec() 
+  : AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
+                     "FMD Quality Assurance Data Maker"),
+    fRecPointsArray("AliFMDRecPoint", 1000), 
+    fReconstructor(0),
+    fUseReconstructor(true)
 {
   // ctor
  
@@ -67,7 +72,9 @@ AliFMDQADataMakerRec::AliFMDQADataMakerRec() :
 AliFMDQADataMakerRec::AliFMDQADataMakerRec(const AliFMDQADataMakerRec& qadm) 
   : AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kFMD), 
                      "FMD Quality Assurance Data Maker"),
-    fRecPointsArray(qadm.fRecPointsArray)
+    fRecPointsArray(qadm.fRecPointsArray), 
+    fReconstructor(qadm.fReconstructor),
+    fUseReconstructor(qadm.fUseReconstructor)
 {
   // copy ctor 
   // Parameters: 
@@ -87,8 +94,10 @@ AliFMDQADataMakerRec::operator = (const AliFMDQADataMakerRec& qadm )
   // Return:
   //    Reference to this
   //
-  fRecPointsArray = qadm.fRecPointsArray;
-  
+  if (&qadm == this) return *this;
+  fRecPointsArray   = qadm.fRecPointsArray;
+  fReconstructor    = qadm.fReconstructor;
+  fUseReconstructor = qadm.fUseReconstructor;
   return *this;
 }
 //_____________________________________________________________________
@@ -108,6 +117,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",
@@ -138,6 +148,7 @@ TH1* AliFMDQADataMakerRec::MakeADCHist(UShort_t d, Char_t r, Short_t b)
   hist->SetLineColor(color);
   hist->SetMarkerColor(color);
   hist->GetXaxis()->SetNdivisions(408,false);
+  hist->SetDirectory(0);
   // hist->SetStats(0);
 
   return hist;
@@ -157,13 +168,15 @@ TH1* AliFMDQADataMakerRec::MakeELossHist(UShort_t d, Char_t r, Short_t b)
       title.Append(Form("[0x%02x]", b));
     }
   }
-  TH1* hist = new TH1F(name, title,300,0, 15);
-  hist->SetXTitle("#Delta E/#Delta_{mip}");
+  TH1* hist = new TH1F(name, title,600,0, 15);
+  hist->SetXTitle("#Delta/#Delta_{mip}");
   hist->SetYTitle("Events [log]");
   hist->SetFillStyle(3001);
   hist->SetFillColor(color);
   hist->SetLineColor(color);
   hist->SetMarkerColor(color);
+  hist->Sumw2();
+  hist->SetDirectory(0);
   // hist->SetStats(0);
 
   return hist;
@@ -174,67 +187,114 @@ TH1* AliFMDQADataMakerRec::MakeELossHist(UShort_t d, Char_t r, Short_t b)
 void AliFMDQADataMakerRec::InitESDs()
 {
   // create Digits histograms in Digits subdir
+  Info("InitESDs", "Initializing ESDs");
   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()
 {
   // create Digits histograms in Digits subdir
+  Info("InitDigits", "Initializing Digits");
   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()
 {
   // create Reconstructed Points histograms in RecPoints subdir
+  Info("InitRecPoints", "Initializing RecPoints");
   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()
 {
   // create Raws histograms in Raws subdir  
-  const Bool_t expert   = kTRUE ; 
-  const Bool_t saveCorr = kTRUE ; 
-  const Bool_t image    = kTRUE ; 
+  Info("InitRaws", "Initializing Raws");
+  const Bool_t expert   = kTRUE ; // Flag - not the setting
+  const Bool_t saveCorr = kTRUE ; // Flag - not setting
+  const Bool_t image    = kTRUE ; // Flag - not the setting
   TH2I* hErrors = new TH2I("readoutErrors", "Read out errors", 3, .5, 3.5,
-                          160, 0, 160); 
+                          160, -.5, 159.5); 
   hErrors->GetXaxis()->SetBinLabel(1, "FMD1");
   hErrors->GetXaxis()->SetBinLabel(2, "FMD2");
   hErrors->GetXaxis()->SetBinLabel(3, "FMD3");
-  hErrors->SetYTitle("# errors");
+  hErrors->SetYTitle("# errors [log]");
   hErrors->SetZTitle("Events [log]");
+  hErrors->SetDirectory(0);
   Add2RawsList(hErrors, 1, !expert, image, !saveCorr);
   //AliInfo(Form("Adding %30s to raw list @ %2d", hErrors->GetName(), 1));
 
+  if (fUseReconstructor && !fReconstructor) {
+    // Int_t oldDbg = AliLog::GetDebugLevel("FMD","");
+    // AliLog::SetModuleDebugLevel("FMD", 5);
+
+    if (!gGeoManager) {
+      Info("InitRaws", "Loading the geometry");
+      AliGeomManager::LoadGeometry();
+    }
+
+    fReconstructor = new AliFMDReconstructor();
+    fReconstructor->SetDiagnose(false);
+    fReconstructor->Init();
+    // AliLog::SetModuleDebugLevel("FMD", oldDbg);
+  }
+
+  TH2* status = new TH2D("status", "Fit status per cycle", 
+                         5, .5, 5.5, 4, -.5, 3.5);
+  status->SetDirectory(0);
+  // status->SetXTitle("Detector");
+  // status->SetYTitle("Status");
+  status->SetZTitle("N_{cycles} [LOG]");
+  status->GetXaxis()->SetBinLabel(1, "FMD1i");
+  status->GetXaxis()->SetBinLabel(2, "FMD2i");
+  status->GetXaxis()->SetBinLabel(3, "FMD2o");
+  status->GetXaxis()->SetBinLabel(4, "FMD3i");
+  status->GetXaxis()->SetBinLabel(5, "FMD3o");
+  status->GetYaxis()->SetBinLabel(1, "OK");
+  status->GetYaxis()->SetBinLabel(2, "Problem");
+  status->GetYaxis()->SetBinLabel(3, "Bad");
+  status->GetYaxis()->SetBinLabel(4, "What the ...?");
+  status->GetXaxis()->SetLabelSize(0.16);
+  status->GetYaxis()->SetLabelSize(0.16);
+  status->SetStats(0);
+  Add2RawsList(status, GetHalfringIndex(4, 'i', 0, 0), 
+              !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);
+      hist = (fUseReconstructor ? 
+             MakeELossHist(d, r, -1) : 
+             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));
       
+      // If we're using the reconstructor, do not make expert histograms 
+      if (fUseReconstructor) continue;
+      
       for(UShort_t b = 0; b <= 1; b++) {
        //Hexadecimal board numbers 0x0, 0x1, 0x10, 0x11;
        UShort_t board = (q == 1 ? 0 : 1) + b*16;
@@ -247,6 +307,8 @@ void AliFMDQADataMakerRec::InitRaws()
       }
     }
   }
+  //
+  ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
 }
 
 #if 0
@@ -260,7 +322,7 @@ struct FillESDHist : public AliESDFMD::ForOne
     // Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
     if(m == AliESDFMD::kInvalidMult) return true;
     
-    fM->GetESDsData(0)->Fill(m);    
+    fM->FillESDsData(0,m);
     return true;
   }
   AliFMDQADataMakerRec* fM;
@@ -304,12 +366,14 @@ 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();
 }
 
 
@@ -325,7 +389,7 @@ void AliFMDQADataMakerRec::MakeDigits()
   for(Int_t i=0;i<fDigitsArray->GetEntriesFast();i++) {
     //Raw ADC counts
     AliFMDDigit* digit = static_cast<AliFMDDigit*>(fDigitsArray->At(i));
-    GetDigitsData(0)->Fill(digit->Counts());
+    FillDigitsData(0,digit->Counts());
   }
 }
 
@@ -338,7 +402,6 @@ void AliFMDQADataMakerRec::MakeDigits(TTree * digitTree)
   // Parameters:
   //    digitTree Tree of digits
   //
-  
   if (fDigitsArray) 
     fDigitsArray->Clear();
   else 
@@ -352,6 +415,9 @@ void AliFMDQADataMakerRec::MakeDigits(TTree * digitTree)
   branch->SetAddress(&fDigitsArray);
   branch->GetEntry(0); 
   MakeDigits();
+  //
+  IncEvCountCycleDigits();
+  IncEvCountTotalDigits();
 }
 
 //_____________________________________________________________________
@@ -363,40 +429,68 @@ void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   // Parameters:
   //    rawReader Raw reader
   //
   AliFMDRawReader fmdReader(rawReader,0);
-  
-  if (fDigitsArray) 
-    fDigitsArray->Clear();
-  else 
-    fDigitsArray = new TClonesArray("AliFMDDigit", 1000);
-
+  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));
-    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);
+  //
+  FillRawsData(1,1, fmdReader.GetNErrors(0));
+  FillRawsData(1,2, fmdReader.GetNErrors(1));
+  FillRawsData(1,3, fmdReader.GetNErrors(2));
+
+  if (fUseReconstructor) { 
+    AliESDFMD* fmd = fReconstructor->GetESDObject();
+    fmd->Clear();
     
-    Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
-    Int_t index2 = GetHalfringIndex(det, ring, board/16,0);
-    // AliInfo(Form("FMD%d%c[0x%02x]->%2d,%2d", 
-    //              det, ring, board, index1, index2));
-    GetRawsData(index1)->Fill(digit->Counts());
-    GetRawsData(index2)->Fill(digit->Counts()); 
+    // AliLog::SetModuleDebugLevel("FMD", 15);
+    fReconstructor->ProcessDigits(digitsAddress, fmdReader);
+
+    if (!fmd) AliFatal("No ESD object from reconstructor");
+
+    for(UShort_t det=1;det<=3;det++) {
+      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);
+       for(UShort_t sec =0; sec < nsec;  sec++)  {
+         for(UShort_t strip = 0; strip < nstr; strip++) {
+           Float_t mult = fmd->Multiplicity(det,ring,sec,strip);
+           if(mult == AliESDFMD::kInvalidMult) continue;
+           
+           Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
+           FillRawsData(index1,mult);
+         }
+       }
+      }
+    }
+  }
+  else {
+    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());
+    }
   }
-  GetRawsData(1)->Fill(1, fmdReader.GetNErrors(0));
-  GetRawsData(1)->Fill(2, fmdReader.GetNErrors(1));
-  GetRawsData(1)->Fill(3, fmdReader.GetNErrors(2));
+  //
+  IncEvCountCycleRaws();
+  IncEvCountTotalRaws();
 }
 
 //_____________________________________________________________________
@@ -419,25 +513,46 @@ 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();
+  //
 }
 
 //_____________________________________________________________________ 
 void AliFMDQADataMakerRec::StartOfDetectorCycle()
 {
-  // What 
-  // to 
-  // do?
+  // Do an init on the reconstructor.  If we have the
+  // same run nothing happens, but if we have a new run, we update our
+  // parameters.
+  if (fUseReconstructor && fReconstructor) fReconstructor->Init();
+  if (fRawsQAList) {
+    for (Int_t index = 0 ; index < AliRecoParam::kNSpecies ; index++) {
+      if (!fRawsQAList[index]) continue;
+      AliRecoParam::EventSpecie_t specie = AliRecoParam::ConvertIndex(index);
+      if (specie == AliRecoParam::kCalib || specie == AliRecoParam::kCosmic) 
+       continue;
+
+      TIter    nextObject(fRawsQAList[index]);
+      TObject* object = 0;
+      while ((object = nextObject())) { 
+       if (!object->InheritsFrom(TH1::Class())) continue;
+       TH1* hist = static_cast<TH1*>(object);
+       if (!hist->TestBit(kResetBit)) continue;
+       
+       AliInfoF("Resetting histogram %s", hist->GetName());
+       hist->Reset("M");
+       hist->SetBit(kResetBit, false);
+      }
+    }
+  }
 }
 //_____________________________________________________________________ 
 Int_t AliFMDQADataMakerRec::GetHalfringIndex(UShort_t det, 
                                             Char_t ring, 
                                             UShort_t board, 
-                                            UShort_t monitor) const
+                                            UShort_t monitor)
 {
   // 
   // Get the half-ring index
@@ -463,6 +578,19 @@ Int_t AliFMDQADataMakerRec::GetHalfringIndex(UShort_t det,
 #endif
   return index-2;
 }
+//_____________________________________________________________________ 
+void AliFMDQADataMakerRec::GetHalfringFromIndex(Int_t     idx, 
+                                               UShort_t& det, 
+                                               Char_t&   ring, 
+                                               UShort_t& board, 
+                                               UShort_t& monitor)
+{
+  det     = ((idx >> 3) & 0x3) + 1;
+  ring    = ((idx >> 2) & 0x1) == 1 ? 'I' : 'O';
+  board   = ((idx >> 1) & 0x1);
+  monitor = ((idx >> 0) & 0x1);
+}
+
 
 //_____________________________________________________________________