Based on PHOS code written by
Y. Schutz CERN July 2007
- For the moment we only implement the checking of raw data QA
- by looking at the average at the each tower.
- We count the times of the response for each tower, the propability for all towers should be the same (given value)
- depending on that value, the resulting QA flag is info, warning, error or fatal.
- Also we check the percentage of towers inside the average for each SM
+ For the moment we only implement the checking of raw data QA.
+ The checked for ESD and RecPoints will be implemented later.
- -- Yaxian Mao, CCNU/CERN/LPSC
*/
#include <TH1.h>
#include <TF1.h>
#include <TH1I.h>
+#include <TH2F.h>
#include <TIterator.h>
#include <TKey.h>
#include <TFile.h>
#include <TLine.h>
+#include <TText.h>
#include <TPaveText.h>
#include <TMath.h>
#include "AliQAv1.h"
#include "AliQAChecker.h"
#include "AliEMCALQAChecker.h"
-#include "AliEMCALQADataMakerRec.h"
ClassImp(AliEMCALQAChecker)
//__________________________________________________________________
AliEMCALQAChecker::AliEMCALQAChecker() :
AliQACheckerBase("EMCAL","EMCAL Quality Assurance Data Maker"),
-fLine(new TLine*[fknSM]),
-fHref(new TLine*[fknSM]),
-fText(NULL)
+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.2,0.7,0.8,0.9,"NDC"))
{
- /// ctor
- for (Int_t sm = 0 ; sm < fknSM ; sm++){
- fLine[sm] = NULL ;
- fHref[sm] = NULL ;
- }
+ // 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");
}
//__________________________________________________________________
AliEMCALQAChecker::~AliEMCALQAChecker()
{
/// dtor
- delete [] fLine ;
- delete [] fHref ;
- if (fText)
- delete fText ;
+ delete [] fTextSM ;
+ delete fLineCol ;
+ delete fLineRow ;
+ delete fText ;
}
//__________________________________________________________________
AliEMCALQAChecker::AliEMCALQAChecker(const AliEMCALQAChecker& qac) :
AliQACheckerBase(qac.GetName(), qac.GetTitle()),
-fLine(new TLine*[fknSM]),
-fHref(new TLine*[fknSM]),
-fText(qac.fText)
+fTextSM(new TText*[fknSM]) ,
+fLineCol(static_cast<TLine*>(qac.fLineCol->Clone())) ,
+fLineRow(static_cast<TLine*>(qac.fLineRow->Clone())) ,
+fText(new TPaveText(0.2,0.7,0.8,0.9,"NDC"))
{
- /// copy ctor
+ // copy ctor
for (Int_t sm = 0 ; sm < fknSM ; sm++){
- fLine[sm] = qac.fLine[sm] ;
- fHref[sm] = qac.fHref[sm] ;
+ fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
}
+
}
//__________________________________________________________________
-AliEMCALQAChecker& AliEMCALQAChecker::operator = (const AliEMCALQAChecker &qac)
+AliEMCALQAChecker& AliEMCALQAChecker::operator = (const AliEMCALQAChecker &qac)
{
- fText = qac.fText;
-
+ fTextSM = new TText*[fknSM] ;
+ fLineCol = static_cast<TLine*>(qac.fLineCol->Clone()) ;
+ fLineRow = static_cast<TLine*>(qac.fLineRow->Clone()) ;
+ fText = new TPaveText(0.2,0.7,0.8,0.9,"NDC") ;
for (Int_t sm = 0 ; sm < fknSM ; sm++){
- fLine[sm] = qac.fLine[sm] ;
- fHref[sm] = qac.fHref[sm] ;
+ fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
}
return *this ;
}
//______________________________________________________________________________
-Double_t *
-AliEMCALQAChecker::Check(AliQAv1::ALITASK_t index, TObjArray ** list, 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;
}
//______________________________________________________________________________
//______________________________________________________________________________
-Double_t *
-AliEMCALQAChecker::CheckRaws(TObjArray ** list)
+void AliEMCALQAChecker::CheckRaws(Double_t * test, TObjArray ** list)
{
- /// Check raws
+ // 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.
- Float_t kThreshold = 80. ;
-
- Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
- for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
- test[specie] = 1.0 ;
- if ( !AliQAv1::Instance()->IsEventSpecieSet(specie))
- continue ;
- if (list[specie]->GetEntries() == 0)
- test[specie] = 0. ; // nothing to check
- else {
- TH1 * hdata = (TH1*)list[specie]->At(kTowerHG) ;
- if(hdata->GetEntries()==0)
- continue;
- Int_t nbin = hdata->GetNbinsX() ;
- Int_t nTower = nbin/4 ;
- if(fText) {
- fText->DeleteText() ;
- fText->Clear() ;
+
+ //Float_t kThreshold = 80. ;
+ Int_t nTowersPerSM = 24*48; // number of towers in a SuperModule; 24x48
+ Double_t nTot = fknSM * nTowersPerSM ;
+ for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+ test[specie] = 0.0 ;
+ if ( !AliQAv1::Instance()->IsEventSpecieSet(specie))
+ continue ;
+ if (list[specie]->GetEntries() == 0)
+ 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]);
+ }
+ }
+ if ( ratio->GetListOfFunctions()->GetEntries() == 0 ){ //adding the object at the beginning
+ ratio->GetListOfFunctions()->Add(fText) ;
}
- else {
- fText = new TPaveText(0.3,0.6,0.7,0.9,"NDC") ;
+
+ //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) ;
+ if (binContent < 1.2 && binContent > 0.8)
+ NGoodTower++ ;
+ }
}
- fText->AddText(Form("OK if more than %2.2f %% inside aver-sigma < HG counts < aver+sigma", kThreshold));
- //TPaveText * fText[fknSM] = {0};
- Double_t rv = 0. ;
- for(Int_t iSM = 0 ; iSM < fknSM ; iSM++){
- TString projname = Form("proj_%d",iSM);
- Double_t aver = 0. ;
- Double_t recal = 0 ;
- Double_t init = 0. ;
- Double_t mean = 0. ;
- Double_t width = 0. ;
- Int_t flag = 0 ;
- Double_t ratio = 0. ;
- TH1F * proj = NULL ;
- for(Int_t iTower = iSM*nTower ; iTower<(iSM+1)*nTower ; iTower++){
- aver += hdata->GetBinContent(iTower);
- //printf("Tower: %d has counts = %f\n",iTower, hdata->GetBinContent(iTower));
- }
- aver /=nTower;
- AliInfo(Form("SM: %d has average = %f\n",iSM, aver));
- Double_t ymin = hdata->GetBinContent(hdata->GetMinimumBin());
- Double_t ymax = hdata->GetBinContent(hdata->GetMaximumBin());
- proj = new TH1F(projname,projname,nbin,-aver,aver);
+ rv = NGoodTower/nTot ;
+ printf("%2.2f %% towers out of range [0.8, 1.2]\n", (1-rv)*100);
+ if(fText){
+ fText->Clear() ;
- fLine[iSM] = dynamic_cast<TLine*>(hdata->GetListOfFunctions()->FindObject(fLine[iSM]));
- if (!fLine[iSM]) {
- fLine[iSM] = new TLine((iSM+1)*nTower,ymin,(iSM+1)*nTower,ymax);
- fLine[iSM]->SetLineColor(1);
- fLine[iSM]->SetLineWidth(2);
- hdata->GetListOfFunctions()->Add(fLine[iSM]);
- list[specie]->AddAt(hdata, kTowerHG) ;
- }
- else {
- fLine[iSM]->SetX1((iSM+1)*nTower) ;
- fLine[iSM]->SetY1(ymin) ;
- fLine[iSM]->SetX2((iSM+1)*nTower) ;
- fLine[iSM]->SetY2(ymax) ;
- }
-
- //Double_t size = 0.24 ;
- //fText[iSM] = new TPaveText(0.1+size*iSM,0.7,size*(iSM+1),0.9,"NDC");
- for(Int_t iTower = iSM*nTower ; iTower<(iSM+1)*nTower ; iTower++){
- proj->Fill(hdata->GetBinContent(iTower)-aver);
- }
- proj->Fit("gaus","","QNO");
- mean=proj->GetFunction("gaus")->GetParameter(1);
- width=proj->GetFunction("gaus")->GetParameter(2);
- AliInfo(Form("aver = %f, mean = %f, sigma =%f\n",aver,mean, width));
- //if mean or sigma is too huge from the fitting, fitting failed
- if(aver < 0 || width/aver >2.) flag = -1 ;
- else { //recalculate the average if the fitting didn't give the initial average
- aver+=mean;
- init=TMath::Abs(mean/aver);
- while(init>0.01){
- if(flag) flag = 0 ;
- for(Int_t iTower = iSM*nTower ; iTower < (iSM+1)*nTower ; iTower++){
- if(hdata->GetBinContent(iTower)>(aver-width) && hdata->GetBinContent(iTower)<(aver+width)){
- flag++ ;
- recal += hdata->GetBinContent(iTower);
- }
- }
- recal/=flag;
- aver =(aver+recal)/2 ;
- init=(aver-recal)/(aver+recal) ;
- } //recalculate the average
- if(flag)ratio=100.0*flag/nTower ; //counting how many towers used for average recalculation
- rv+=TMath::Abs((aver-recal)/(aver+recal)) ;
- AliInfo(Form("SM %d has %2.2f %% chanhel works \n", iSM, ratio));
+ 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!!!"));
}
- fHref[iSM] = dynamic_cast<TLine*>(hdata->GetListOfFunctions()->FindObject(fHref[iSM]));
- if(!fHref[iSM]) {
- fHref[iSM] = new TLine(iSM*nTower,aver,(iSM+1)*nTower,aver);
- hdata->GetListOfFunctions()->Add(fHref[iSM]);
- list[specie]->AddAt(hdata, kTowerHG) ;
- }
else {
- fHref[iSM]->Clear() ;
- fHref[iSM]->SetX1(iSM*nTower) ;
- fHref[iSM]->SetY1(aver) ;
- fHref[iSM]->SetX2((iSM+1)*nTower) ;
- fHref[iSM]->SetY2(aver) ;
- }
- hdata->Paint() ;
- if(ratio<= kThreshold && flag >0){ //if towers used for average recalculation smaller than 10%, then the problem on this SM
- //fText->SetFillColor(2);
- fHref[iSM]->SetLineColor(2);
- fHref[iSM]->SetLineWidth(2);
- fText->SetFillColor(2);
- fText->AddText(Form("SM %d: NOK = %2.0f %% channels OK!!!",iSM,ratio));
- //fText[iSM]->AddText(Form("SM %d NOT OK, only %5.2f %% works!!!",iSM,flag/nTower));
- }
- else if (flag == -1 || flag == 0 || ratio == 0.) {
- fText->SetFillColor(2);
- fHref[iSM]->SetLineColor(2);
- fHref[iSM]->SetLineWidth(2);
- fText->SetFillColor(2);
- fText->AddText(Form("SM %d: NOK Fitting failed",iSM,ratio));
- //fText[iSM]->AddText(Form("SM %d has %5.2f %% towers wok normally",iSM,flag/nTower));
- } else {
- fText->SetFillColor(3);
- fHref[iSM]->SetLineColor(3);
- fHref[iSM]->SetLineWidth(2);
- fText->AddText(Form("SM %d: OK = %2.0f %% channels OK",iSM,ratio));
- //fText[iSM]->AddText(Form("SM %d has %5.2f %% towers wok normally",iSM,flag/nTower));
- }
- hdata->Paint() ;
- //hdata->GetListOfFunctions()->Add(fText[iSM]);
- delete proj ;
- }
- rv/=fknSM;
- hdata->GetListOfFunctions()->Add(fText);
- hdata->Paint() ;
- if ( rv <=0.1 )
- {
- AliInfo(Form("Got a small deviation rv = %f from average, SM works fine",rv));
- test[specie] = 0.05;
- }
-
- if ( rv <=0.5 && rv >0.1 )
- {
- AliWarning(Form("Got a deviation rv = %f from average, be careful!",rv));
- test[specie] = 0.3;
- }
-
- if ( rv <=0.5 && rv >0.8 )
- {
- AliError(Form("Got a large deviation of %f from average for SMs!!!",rv));
- test[specie] = 0.7;
- }
- if ( rv >0.8 )
- {
- AliError(Form("Got too large deviation of %f from average !!!???",rv));
- test[specie] = 0.9;
- }
- }
-
- }
- return test ;
+ test[specie] = 0.1 ;
+ fText->SetFillColor(3) ;
+ fText->AddText(Form("EMCAL = OK, ENJOY..."));
+ }
+ //hdata->Reset("ICE");
+ //ratio->Reset("ICE");
+ }//fText
+ }
+ } //finish the checking
}
//______________________________________________________________________________
Float_t lowValue[AliQAv1::kNBIT] ;
lowValue[AliQAv1::kINFO] = 0.0 ;
hiValue[AliQAv1::kINFO] = 0.1 ;
- hiValue[AliQAv1::kWARNING] = 0.5;
lowValue[AliQAv1::kWARNING] = 0.1 ;
+ hiValue[AliQAv1::kWARNING] = 0.5 ;
lowValue[AliQAv1::kERROR] = 0.5 ;
hiValue[AliQAv1::kERROR] = 0.8 ;
lowValue[AliQAv1::kFATAL] = 0.8 ;