]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALQAChecker.cxx
Fix Coverity
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALQAChecker.cxx
index 8d50db14f71c8db3f4d75b7f2b4ffa23a3886eec..9bad785cdee61a45141785ba647648cab2976155 100644 (file)
@@ -54,21 +54,33 @@ ClassImp(AliEMCALQAChecker)
 //__________________________________________________________________
 AliEMCALQAChecker::AliEMCALQAChecker() : 
 AliQACheckerBase("EMCAL","EMCAL Quality Assurance Data Maker"),
-fTextSM(new TText*[fknSM]),
-fLineCol(new TLine(48.0,0.,48.0,47.0)),
-fLineRow(new TLine(0.,24.,96.,24.)),
-fText(new TPaveText(0.4,10,0.7,20.))
+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 C1");
+  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(64, 12, "SM C0");
+  fTextSM[6]= new TText(64, 36, "SM C1");
+  fTextSM[7]= new TText(64, 60, "SM C2");
+  fTextSM[8]= new TText(64, 84, "SM C3");
+  fTextSM[9]= new TText(64, 108,"SM C4");
+
+       for(int i = 0; i < 4; 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);
+       }
+
+
 }          
 
 //__________________________________________________________________
@@ -77,35 +89,33 @@ AliEMCALQAChecker::~AliEMCALQAChecker()
        /// dtor
   delete [] fTextSM ;
   delete fLineCol ;
-  delete fLineRow ;
+  for (Int_t i=0; i<4; ++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.4,10,0.7,20.))
+fText(new TPaveText(0.2,0.7,0.8,0.9,"NDC"))
 {
    // copy ctor 
-  for (Int_t sm = 0 ; sm < fknSM ; sm++){
+  for (Int_t sm = 0 ; sm < fgknSM ; sm++){
     fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
   }
+       for(Int_t i = 0 ; i < 4 ; 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.4,10,0.7,20.) ;
-  for (Int_t sm = 0 ; sm < fknSM ; sm++){
-    fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
-  }
-  return *this ;
+{ // assignment operator; use copy ctor
+  if (&qac == this) return *this;
+
+  new (this) AliEMCALQAChecker(qac);
+  return *this;
 }
 
 //______________________________________________________________________________
@@ -162,21 +172,17 @@ AliEMCALQAChecker::MarkHisto(TH1& histo, Double_t value) const
 //______________________________________________________________________________
 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)) 
@@ -189,21 +195,47 @@ void AliEMCALQAChecker::CheckRaws(Double_t * test, TObjArray ** list)
       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);
        }
-      }   
-//      if ( ratio->GetListOfFunctions()->GetEntries() == 0 ){
-//        ratio->GetListOfFunctions()->Add(fText) ;
-//      }
-
+       else {
+         AliWarning(Form("Checker : empty list of data functions; returning"));
+         return;
+       }
+      }
+      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;
+       } 
+      }
+      lstF->Add(fText->Clone()) ;
+      //
       //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) ; 
@@ -212,23 +244,27 @@ void AliEMCALQAChecker::CheckRaws(Double_t * test, TObjArray ** list)
         }
       }
       rv = NGoodTower/nTot ; 
-      
-      
-//      if (rv < 0.9) {
-//        test[specie] = 0.9 ;
-//        // 2 lines text info for quality 
-//        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 {
-//        test[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
+      printf("%2.2f %% towers out of range [0.8, 1.2]\n", (1-rv)*100);
+      if(fText){
+        fText->Clear() ; 
+        
+        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
 }
 
 //______________________________________________________________________________