]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALQAChecker.cxx
moving esdLayout object from HLT/ConfigHLT to HLT/Calib, the old object is going...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALQAChecker.cxx
index 233dfe1d90877dd3cf7c84a8aff8a5dd54361b99..f2c48633e45b5585cce8146a7cd98e26d0e538c1 100644 (file)
@@ -54,108 +54,93 @@ ClassImp(AliEMCALQAChecker)
 //__________________________________________________________________
 AliEMCALQAChecker::AliEMCALQAChecker() : 
 AliQACheckerBase("EMCAL","EMCAL Quality Assurance Data Maker"),
-fTextSM(new TText*[fknSM]),
-fLineCol(new TLine(47.5,-0.5,47.5,47.5)),
-fLineRow(new TLine(-0.5,23.5,95.5,23.5)),
-fText(new TPaveText(0.2,1000.,0.7,2000.,"NDC")),
-fTest(new Double_t[AliRecoParam::kNSpecies])
+fTextSM(new TText*[fgknSM]),
+fLineCol(new TLine(47.5,-0.5,47.5,119.5)),
+fText(new TPaveText(0.2,0.7,0.8,0.9,"NDC"))
 {
   // ctor
   fLineCol->SetLineColor(1);
   fLineCol->SetLineWidth(2);
-  fLineRow->SetLineColor(1);
-  fLineRow->SetLineWidth(2);
 
   fTextSM[0]= new TText(20, 12, "SM A0");
-  fTextSM[1]= new TText(20, 38, "SM A1");
-  fTextSM[2]= new TText(64, 12, "SM C0");
-  fTextSM[3]= new TText(64, 38, "SM A0");
+  fTextSM[1]= new TText(20, 36, "SM A1");
+  fTextSM[2]= new TText(20, 60, "SM A2");
+  fTextSM[3]= new TText(20, 84, "SM A3");
+  fTextSM[4]= new TText(20, 108,"SM A4");
+  fTextSM[5]= new TText(20, 132,"SM A5");
+
+  fTextSM[6]= new TText(64, 12, "SM C0");
+  fTextSM[7]= new TText(64, 36, "SM C1");
+  fTextSM[8]= new TText(64, 60, "SM C2");
+  fTextSM[9]= new TText(64, 84, "SM C3");
+  fTextSM[10]= new TText(64, 108,"SM C4");
+  fTextSM[11]= new TText(64, 132,"SM C5");
+
+       for(int i = 0; i < 5; i++) {
+               fLineRow[i] = new TLine(-0.5,23.5+(24*i),95.5,23.5+(24*i));
+               fLineRow[i]->SetLineColor(1);
+               fLineRow[i]->SetLineWidth(2);
+       }
+
 
-  for (Int_t sm = 0 ; sm < fknSM ; sm++){
-//    fLine[sm] = NULL ; 
-//    fHref[sm] = NULL ; 
-  }
-  for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
-   fTest[es] = 1.0 ; 
-  } 
 }          
 
 //__________________________________________________________________
 AliEMCALQAChecker::~AliEMCALQAChecker() 
 {
        /// dtor
-//  delete [] fLine ; 
-//  delete [] fHref ;
   delete [] fTextSM ;
-  if (fLineCol)
-    delete fLineCol ;
-  if (fLineRow)
-    delete fLineRow ;
-  if (fText) 
-    delete fText  ; 
-  if (fTest)
-    delete [] fTest ;
+  delete fLineCol ;
+  for (Int_t i=0; i<5; ++i) delete fLineRow[i] ;
+  delete fText  ; 
 }
 
 //__________________________________________________________________
 AliEMCALQAChecker::AliEMCALQAChecker(const AliEMCALQAChecker& qac) : 
 AliQACheckerBase(qac.GetName(), qac.GetTitle()), 
-fTextSM(new TText*[fknSM]) ,
+fTextSM(new TText*[fgknSM]) ,
 fLineCol(static_cast<TLine*>(qac.fLineCol->Clone())) , 
-fLineRow(static_cast<TLine*>(qac.fLineRow->Clone())) , 
-fText(new TPaveText(0.2,1000.,0.7,2000.,"NDC")),
-fTest(new Double_t[AliRecoParam::kNSpecies])
+fText(new TPaveText(0.2,0.7,0.8,0.9,"NDC"))
 {
    // copy ctor 
-  for (Int_t sm = 0 ; sm < fknSM ; sm++){
-//    fLine[sm] = new TLine(qac.fLine[sm]) ; 
-//    fHref[sm] = new TLine(qac.fHref[sm]) ; 
+  for (Int_t sm = 0 ; sm < fgknSM ; sm++){
     fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
   }
-  for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
-   fTest[es] = 0.0 ; 
-  } 
+       for(Int_t i = 0 ; i < 5 ; i++) {
+
+               fLineRow[i] = static_cast<TLine*>(qac.fLineRow[i]->Clone()) ; 
+       }
 }   
 //__________________________________________________________________
 AliEMCALQAChecker& AliEMCALQAChecker::operator = (const AliEMCALQAChecker &qac) 
-{
-  fTextSM  = new TText*[fknSM] ;
-  fLineCol = static_cast<TLine*>(qac.fLineCol->Clone()) ; 
-  fLineRow = static_cast<TLine*>(qac.fLineRow->Clone()) ; 
-  fText    = new TPaveText(0.2,1000.,0.7,2000.,"NDC") ;
-  fTest    = new Double_t[AliRecoParam::kNSpecies] ;
-  for (Int_t sm = 0 ; sm < fknSM ; sm++){
-    fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
-  }
-  for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
-   fTest[es] = 0.0 ; 
-  } 
-  return *this ;
+{ // assignment operator; use copy ctor
+  if (&qac == this) return *this;
+
+  new (this) AliEMCALQAChecker(qac);
+  return *this;
 }
 
 //______________________________________________________________________________
-Double_t *
-AliEMCALQAChecker::Check(AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
+void AliEMCALQAChecker::Check(Double_t * test, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
 {
        /// Check objects in list
        
        if ( index == AliQAv1::kRAW ) 
        {
-               return CheckRaws(list);
+    CheckRaws(test, list);
                printf ("checkers for task %d \n", index) ;             
        }
        
        if ( index == AliQAv1::kREC)
        {
-               return CheckRecPoints(list);
+    CheckRecPoints(test, list);
        }
        
        if ( index == AliQAv1::kESD )
        {
-               return CheckESD(list);
+    CheckESD(test, list);
        }
        AliWarning(Form("Checker for task %d not implement for the moment",index));
-       return NULL;
 }
 
 //______________________________________________________________________________
@@ -187,49 +172,71 @@ AliEMCALQAChecker::MarkHisto(TH1& histo, Double_t value) const
 
 
 //______________________________________________________________________________
-Double_t * AliEMCALQAChecker::CheckRaws(TObjArray ** list)
+void AliEMCALQAChecker::CheckRaws(Double_t * test, TObjArray ** list)
 {
-//  Check RAW QA histograms    
-//  We count the times of the response for each tower, the propability for all towers should be the same (average is given value).
-//  We skip the first few cycles since the statistics is not enough, the average should be always larger than 1 at least.
-//  By calculating the difference between the counts for each tower and the average, we decide whether we should recalculate 
-//  the average depending the the gaus fitting on the divation distribution. 
-//  During the recalutation of the average, we count how many towers are used for the calculation.
-//  From the fraction of towers used, we decide whether each SM works fine or not
-//  From the divation of average, we set the QA flag for the full detetcor as INFO, WARNING, ERROR or FATAL.
+  //  Check RAW QA histograms  
+  //  -- Yaxian Mao, CCNU/CERN/LPSC
+  //adding new checking method: 25/04/2010, Yaxian Mao
+  //Comparing the amplitude from current run to the reference run, if the ratio in the range [0.8, .12], count as a good tower.
+  //If more than 90% towers are good, EMCAL works fine, otherwise experts should be contacted. 
   
-//  -- Yaxian Mao, CCNU/CERN/LPSC
                                
   //Float_t kThreshold = 80. ; 
   Int_t nTowersPerSM = 24*48; // number of towers in a SuperModule; 24x48
-  Double_t nTot = fknSM * nTowersPerSM ;
-  Double_t rv = 0. ;
+  Double_t nTot = fgknSM * nTowersPerSM ;
+  TList *lstF = 0;
   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+    test[specie] = 0.0 ; 
     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie)) 
       continue ; 
     if (list[specie]->GetEntries() == 0)  
-      fTest[specie] = 0. ; // nothing to check
+      test[specie] = 0. ; // nothing to check
     else {
       TH2F * hdata  = (TH2F*)list[specie]->At(k2DRatioAmp) ; 
       TH1F * ratio = (TH1F*)list[specie]->At(kRatioDist) ;
       if(hdata->GetEntries()==0 || ratio->GetEntries()==0)
         continue;
       //adding the lines to distinguish different SMs
-      if ( hdata->GetListOfFunctions()->GetEntries() == 0 ){
-        hdata->GetListOfFunctions()->Add(fLineCol); 
-        hdata->GetListOfFunctions()->Add(fLineRow); 
-        //Now adding the text to for each SM
-        for(Int_t iSM = 0 ; iSM < fknSM ; iSM++){  //number of SMs loop start
-          hdata->GetListOfFunctions()->Add(fTextSM[iSM]); 
+      lstF = hdata->GetListOfFunctions();
+      { // RS: clean list of functions
+       if (lstF) {
+         TObject *stats = lstF->FindObject("stats"); lstF->Remove(stats);
+         TObject *obj;
+         while ((obj = lstF->First())) { while(lstF->Remove(obj)) { } delete obj; }
+         if (stats) lstF->Add(stats);
+       }
+       else {
+         AliWarning(Form("Checker : empty list of data functions; returning"));
+         return;
        }
-      }   
-      if ( ratio->GetListOfFunctions()->GetEntries() == 0 ){
-        ratio->GetListOfFunctions()->Add(fText) ;
       }
-
+      lstF->Add(fLineCol->Clone()); 
+      for(Int_t iLine = 0; iLine < 4; iLine++) {
+       lstF->Add(fLineRow[iLine]->Clone());
+      } 
+      //Now adding the text to for each SM
+      for(Int_t iSM = 0 ; iSM < fgknSM ; iSM++){  //number of SMs loop start
+       lstF->Add(fTextSM[iSM]->Clone()); 
+      }
+      //
+      lstF = ratio->GetListOfFunctions();
+      { // RS: clean list of functions
+       if (lstF) {
+         TObject *stats = lstF->FindObject("stats"); lstF->Remove(stats);
+         TObject *obj;
+         while ((obj = lstF->First())) { while(lstF->Remove(obj)) { } delete obj; }
+         if (stats) lstF->Add(stats);
+       }
+       else {
+         AliWarning(Form("Checker : empty list of ratio functions; returning"));
+         return;
+       } 
+      }
+      //
       //now check the ratio histogram
       Double_t binContent = 0. ;  
       Int_t NGoodTower = 0 ;
+      Double_t rv = 0. ;
       for(Int_t ix = 1; ix <= hdata->GetNbinsX(); ix++) {
         for(Int_t iy = 1; iy <= hdata->GetNbinsY(); iy++) {
           binContent = hdata->GetBinContent(ix, iy) ; 
@@ -238,24 +245,28 @@ Double_t * AliEMCALQAChecker::CheckRaws(TObjArray ** list)
         }
       }
       rv = NGoodTower/nTot ; 
-      
-      
-      if (rv < 0.9) {
-        fTest[specie] = 0.9 ;
-        // 2 lines text info for quality 
+      printf("%2.2f %% towers out of range [0.8, 1.2]\n", (1-rv)*100);
+      if(fText){
+       lstF->Add(fText->Clone()) ;
         fText->Clear() ; 
-        fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100)); 
-        fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!")); 
-      }
-      else {
-        fTest[specie] = 0.1 ;
-        fText->Clear() ; 
-        fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100)); 
-        fText->AddText(Form("EMCAL = OK")); 
-      }
-     } 
-    } //finish the checking
-   return fTest ; 
+        
+        fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100));     
+        if (rv < 0.9) {
+          test[specie] = 0.9 ;
+          // 2 lines text info for quality         
+          fText->SetFillColor(2) ;
+          fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!")); 
+        }
+        else {
+          test[specie] = 0.1 ;
+          fText->SetFillColor(3) ;
+          fText->AddText(Form("EMCAL = OK, ENJOY...")); 
+        }
+        //hdata->Reset("ICE");
+        //ratio->Reset("ICE");
+      }//fText
+    } 
+  } //finish the checking
 }
 
 //______________________________________________________________________________